UNPKG

@awayjs/stage

Version:
149 lines (148 loc) 5.33 kB
import { __extends } from "tslib"; import { AssetBase } from '@awayjs/core'; import { AttributesBuffer } from './AttributesBuffer'; var AttributesView = /** @class */ (function (_super) { __extends(AttributesView, _super); function AttributesView(arrayClass, dimensions, attributesBufferCount, unsigned) { if (attributesBufferCount === void 0) { attributesBufferCount = 0; } if (unsigned === void 0) { unsigned = false; } var _this = _super.call(this) || this; _this._arrayClass = arrayClass; _this._size = arrayClass.BYTES_PER_ELEMENT; _this._dimensions = dimensions; _this._attributesBuffer = (attributesBufferCount instanceof AttributesBuffer) ? attributesBufferCount : new AttributesBuffer(_this._dimensions * _this._size, attributesBufferCount); _this._attributesBuffer._addView(_this); _this._unsigned = unsigned; return _this; } Object.defineProperty(AttributesView.prototype, "assetType", { /** * * */ get: function () { return AttributesView.assetType; }, enumerable: false, configurable: true }); Object.defineProperty(AttributesView.prototype, "attributesBuffer", { get: function () { return this._attributesBuffer; }, enumerable: false, configurable: true }); Object.defineProperty(AttributesView.prototype, "size", { /** * * @returns {number} */ get: function () { return this._size; }, set: function (value) { if (this._size == value) return; this._size = value; this._attributesBuffer._removeView(this); this._attributesBuffer._addView(this); }, enumerable: false, configurable: true }); Object.defineProperty(AttributesView.prototype, "dimensions", { /** * * @returns {number} */ get: function () { return this._dimensions; }, set: function (value) { if (this._dimensions == value) return; this._dimensions = value; //reset view this._attributesBuffer._removeView(this); this._attributesBuffer._addView(this); }, enumerable: false, configurable: true }); Object.defineProperty(AttributesView.prototype, "unsigned", { get: function () { return this._unsigned; }, enumerable: false, configurable: true }); Object.defineProperty(AttributesView.prototype, "count", { get: function () { return this._attributesBuffer.count; }, set: function (value) { this._attributesBuffer.count = value; }, enumerable: false, configurable: true }); Object.defineProperty(AttributesView.prototype, "offset", { get: function () { return this._attributesBuffer._getOffset(this._index); }, enumerable: false, configurable: true }); Object.defineProperty(AttributesView.prototype, "length", { get: function () { return this._attributesBuffer.count * this._dimensions; }, enumerable: false, configurable: true }); Object.defineProperty(AttributesView.prototype, "stride", { get: function () { return this._attributesBuffer.stride / this._size; }, enumerable: false, configurable: true }); AttributesView.prototype.set = function (values, offset) { if (offset === void 0) { offset = 0; } this._attributesBuffer._setAttributes(this._index, (values instanceof Array) ? new (this._arrayClass)(values) : values, offset); }; AttributesView.prototype.get = function (count, offset) { if (offset === void 0) { offset = 0; } return new (this._arrayClass)(this._attributesBuffer.buffer, offset * this._attributesBuffer.stride + this.offset, count * this.stride - this.offset / this.size); }; AttributesView.prototype._internalClone = function (attributesBuffer) { return (this._cloneCache = new AttributesView(this._arrayClass, this._dimensions, attributesBuffer, this._unsigned)); }; AttributesView.prototype.clone = function (attributesBuffer) { if (attributesBuffer === void 0) { attributesBuffer = null; } if (attributesBuffer) this._internalClone(attributesBuffer); if (!this._cloneCache) this._attributesBuffer.clone(); var cloneCache = this._cloneCache; this._cloneCache = null; return cloneCache; }; AttributesView.prototype.invalidate = function () { _super.prototype.invalidate.call(this); this._attributesBuffer.invalidate(); }; /** * @inheritDoc */ AttributesView.prototype.dispose = function () { if (!this._attributesBuffer) return; this._attributesBuffer._removeView(this); this._attributesBuffer = null; }; AttributesView.assetType = '[attributes AttributesView]'; return AttributesView; }(AssetBase)); export { AttributesView };