UNPKG

gl2d

Version:

2D graphics package for WebGL

349 lines 12 kB
"use strict"; var __extends = (this && this.__extends) || (function () { var extendStatics = Object.setPrototypeOf || ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; return function (d, b) { extendStatics(d, b); function __() { this.constructor = d; } d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); }; })(); Object.defineProperty(exports, "__esModule", { value: true }); // THIS IS AN AUTOGENERATED FILE. DO NOT EDIT THIS FILE DIRECTLY. var struct_1 = require("gulp-structify/struct"); var buffer_1 = require("gulp-structify/buffer"); var mixin_1 = require("gulp-structify/mixin"); /** * Holds the three indices for a triangle. */ var IndexTuple = (function () { /** * Holds the three indices for a triangle. */ function IndexTuple(first, second, third) { if (first === void 0) { first = 0; } if (second === void 0) { second = 0; } if (third === void 0) { third = 0; } this.first = first; this.second = second; this.third = third; } IndexTuple.create = function (other) { var indexTuple = new IndexTuple(); indexTuple.set(other); return indexTuple; }; /** * Sets each component of this IndexTuple to that of the other IndexTuple. */ IndexTuple.prototype.set = function (other) { this.first = other.first; this.second = other.second; this.third = other.third; }; /** * Sets each component of this IndexTuple. */ IndexTuple.prototype.set$ = function (first, second, third) { this.first = first; this.second = second; this.third = third; }; /** * Sets each component of this IndexTuple to the specified scalar. */ IndexTuple.prototype.setScalar = function (k) { this.first = k; this.second = k; this.third = k; }; /** * Adds the other IndexTuple to this IndexTuple componentwise. */ IndexTuple.prototype.add = function (other) { this.first += other.first; this.second += other.second; this.third += other.third; }; /** * Adds the specified values to this IndexTuple componentwise. */ IndexTuple.prototype.add$ = function (first, second, third) { this.first += first; this.second += second; this.third += third; }; /** * Subtracts the other IndexTuple from this IndexTuple componentwise. */ IndexTuple.prototype.subtract = function (other) { this.first -= other.first; this.second -= other.second; this.third -= other.third; }; /** * Subtracts the specified values from this IndexTuple componentwise. */ IndexTuple.prototype.subtract$ = function (first, second, third) { this.first -= first; this.second -= second; this.third -= third; }; /** * Multiplies each component of this IndexTuple by the specified scalar. */ IndexTuple.prototype.mulScalar = function (k) { this.first *= k; this.second *= k; this.third *= k; }; /** * Divides each component of this IndexTuple by the specified scalar. */ IndexTuple.prototype.divScalar = function (k) { this.first /= k; this.second /= k; this.third /= k; }; /** * Checks if each component of this IndexTuple is exactly equal to that of the other IndexTuple. */ IndexTuple.prototype.equals = function (other) { return this.first === other.first && this.second === other.second && this.third === other.third; }; /** * Checks if each component of this IndexTuple is exactly equal to the specified scalar. */ IndexTuple.prototype.equalsScalar = function (k) { return this.first === k && this.second === k && this.third === k; }; /** * Checks if each component of this IndexTuple is approximately equal to that of the other IndexTuple. */ IndexTuple.prototype.epsilonEquals = function (other, e) { return Math.abs(this.first - other.first) <= e && Math.abs(this.second - other.second) <= e && Math.abs(this.third - other.third) <= e; }; /** * Checks if each component of this IndexTuple is approximately equal to the specified scalar. */ IndexTuple.prototype.epsilonEqualsScalar = function (k, e) { return Math.abs(this.first - k) <= e && Math.abs(this.second - k) <= e && Math.abs(this.third - k) <= e; }; /** * Returns a string representation of this IndexTuple. */ IndexTuple.prototype.toString = function () { return "{ first: " + this.first + ", second: " + this.second + ", third: " + this.third + " }"; }; return IndexTuple; }()); exports.IndexTuple = IndexTuple; /** * A IndexTuple backed by a Uint16Array. */ var IndexTupleStruct = (function (_super) { __extends(IndexTupleStruct, _super); /** * Creates a IndexTuple struct backed by the specified data. */ function IndexTupleStruct(data) { if (data === void 0) { data = new Uint16Array(3); } return _super.call(this, data) || this; } IndexTupleStruct.create = function (other) { var indexTuple = new IndexTupleStruct(); indexTuple.set(other); return indexTuple; }; IndexTupleStruct.create$ = function (first, second, third) { var indexTuple = new IndexTupleStruct(); indexTuple.set$(first, second, third); return indexTuple; }; Object.defineProperty(IndexTupleStruct.prototype, "first", { /** * The index of the first triangle vertex. */ get: function () { return this.data[0]; }, /** * The index of the first triangle vertex. */ set: function (value) { this.data[0] = value; }, enumerable: true, configurable: true }); Object.defineProperty(IndexTupleStruct.prototype, "second", { /** * The index of the second triangle vertex. */ get: function () { return this.data[1]; }, /** * The index of the second triangle vertex. */ set: function (value) { this.data[1] = value; }, enumerable: true, configurable: true }); Object.defineProperty(IndexTupleStruct.prototype, "third", { /** * The index of the third triangle vertex. */ get: function () { return this.data[2]; }, /** * The index of the third triangle vertex. */ set: function (value) { this.data[2] = value; }, enumerable: true, configurable: true }); return IndexTupleStruct; }(struct_1.Struct)); exports.IndexTupleStruct = IndexTupleStruct; mixin_1.applyMixins(IndexTupleStruct, IndexTuple); /** * A IndexTuple buffer backed by a Uint16Array. */ var IndexTupleBuffer = (function (_super) { __extends(IndexTupleBuffer, _super); function IndexTupleBuffer() { return _super !== null && _super.apply(this, arguments) || this; } /** * Creates an empty IndexTuple buffer with the specified IndexTuple capacity. */ IndexTupleBuffer.create = function (capacity) { return new IndexTupleBuffer(new Uint16Array(capacity * 3)); }; Object.defineProperty(IndexTupleBuffer.prototype, "first", { /** * The index of the first triangle vertex. */ get: function () { return this.data[this.dataPosition + 0]; }, /** * The index of the first triangle vertex. */ set: function (value) { this.data[this.dataPosition + 0] = value; }, enumerable: true, configurable: true }); Object.defineProperty(IndexTupleBuffer.prototype, "second", { /** * The index of the second triangle vertex. */ get: function () { return this.data[this.dataPosition + 1]; }, /** * The index of the second triangle vertex. */ set: function (value) { this.data[this.dataPosition + 1] = value; }, enumerable: true, configurable: true }); Object.defineProperty(IndexTupleBuffer.prototype, "third", { /** * The index of the third triangle vertex. */ get: function () { return this.data[this.dataPosition + 2]; }, /** * The index of the third triangle vertex. */ set: function (value) { this.data[this.dataPosition + 2] = value; }, enumerable: true, configurable: true }); /** * Gets the number of properties in a IndexTuple, namely 3. */ IndexTupleBuffer.prototype.structLength = function () { return 3; }; /** * Gets the components of the IndexTuple at the specified position of this buffer. */ IndexTupleBuffer.prototype.aget = function (position, dst) { if (dst === void 0) { dst = new IndexTuple(); } ; var dataPos = position * this.structLength(); dst.first = this.data[dataPos++]; dst.second = this.data[dataPos++]; dst.third = this.data[dataPos++]; return dst; }; /** * Gets the components of the current IndexTuple, then moves to the next position of this buffer. */ IndexTupleBuffer.prototype.rget = function (dst) { if (dst === void 0) { dst = new IndexTuple(); } ; dst.first = this.data[this.dataPosition++]; dst.second = this.data[this.dataPosition++]; dst.third = this.data[this.dataPosition++]; return dst; }; /** * Sets each component of the IndexTuple at the specified position to that of the src IndexTuple. */ IndexTupleBuffer.prototype.aset = function (position, src) { var dataPos = position * this.structLength(); this.data[dataPos++] = src.first; this.data[dataPos++] = src.second; this.data[dataPos++] = src.third; }; /** * Sets each component of the IndexTuple at the specified position. */ IndexTupleBuffer.prototype.aset$ = function (position, first, second, third) { var dataPos = position * this.structLength(); this.data[dataPos++] = first; this.data[dataPos++] = second; this.data[dataPos++] = third; }; /** * Sets each component of the current IndexTuple to that of the src IndexTuple, then moves to the next position of this buffer. */ IndexTupleBuffer.prototype.rset = function (src) { this.data[this.dataPosition++] = src.first; this.data[this.dataPosition++] = src.second; this.data[this.dataPosition++] = src.third; }; /** * Sets each component of the current IndexTuple, then moves to the next position of this buffer. */ IndexTupleBuffer.prototype.rset$ = function (first, second, third) { this.data[this.dataPosition++] = first; this.data[this.dataPosition++] = second; this.data[this.dataPosition++] = third; }; return IndexTupleBuffer; }(buffer_1.StructBuffer)); exports.IndexTupleBuffer = IndexTupleBuffer; mixin_1.applyMixins(IndexTupleBuffer, IndexTuple); //# sourceMappingURL=indexTuple.js.map