Package Exports
- gulp-structify
- gulp-structify/buf
- gulp-structify/struct
- gulp-structify/template
This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (gulp-structify) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.
Readme
gulp-structify
Generates WebGL-compatible structs and struct buffers from a template file.
Install
npm install gulp-structify --save-dev
Create a template file:
MyTemplate.template.ts
import Template from "gulp-structify/template";
export class MyTemplate extends Template<Float32Array> {
property1: number;
property2: number;
method1(){ }
method2(){ }
}
Notes:
- The type argument (in this case
Float32Array
) specifies the type ofTypedArray
that should be used to back the object when instantiated as a struct or a struct buffer. - The object properties must all be of type
number
. - The class should not include a constructor or any static methods.
- The following methods are inherited from
Template
:set(other: this)
add(other: this)
subtract(other: this)
mulScalar(k: number)
divScalar(k: number)
equals(other: this)
equalsScalar(k: number)
epsilonEquals(other: this, e: number)
epsilonEqualsScalar(k: number, e: number)
toString()
Example templates:
Run gulp task:
var gulp = require("gulp");
var rename = require("gulp-rename");
var structify = require("gulp-structify");
gulp.task("structify", function () {
// Search for files ending in .template.ts
return gulp.src("./examples/**/*.template.ts")
// Generate struct file
.pipe(structify())
// Remove ".template" from filename
.pipe(rename(function(p) {
let base = p.basename;
let length = base.length - ".template".length;
p.basename = base.substr(0, length);
}))
// Output to same folder to preserve imports
.pipe(gulp.dest("./examples/"));
});
gulp structify