60 lines
2.1 KiB
JavaScript
60 lines
2.1 KiB
JavaScript
shadow$provide.module$node_modules$pixi_DOT_js$lib$utils$data$ViewableBuffer = function(global, require, module, exports) {
|
|
class ViewableBuffer {
|
|
constructor(sizeOrBuffer) {
|
|
this.rawBinaryData = "number" === typeof sizeOrBuffer ? new ArrayBuffer(sizeOrBuffer) : sizeOrBuffer instanceof Uint8Array ? sizeOrBuffer.buffer : sizeOrBuffer;
|
|
this.uint32View = new Uint32Array(this.rawBinaryData);
|
|
this.float32View = new Float32Array(this.rawBinaryData);
|
|
this.size = this.rawBinaryData.byteLength;
|
|
}
|
|
get int8View() {
|
|
this._int8View || (this._int8View = new Int8Array(this.rawBinaryData));
|
|
return this._int8View;
|
|
}
|
|
get uint8View() {
|
|
this._uint8View || (this._uint8View = new Uint8Array(this.rawBinaryData));
|
|
return this._uint8View;
|
|
}
|
|
get int16View() {
|
|
this._int16View || (this._int16View = new Int16Array(this.rawBinaryData));
|
|
return this._int16View;
|
|
}
|
|
get int32View() {
|
|
this._int32View || (this._int32View = new Int32Array(this.rawBinaryData));
|
|
return this._int32View;
|
|
}
|
|
get float64View() {
|
|
this._float64Array || (this._float64Array = new Float64Array(this.rawBinaryData));
|
|
return this._float64Array;
|
|
}
|
|
get bigUint64View() {
|
|
this._bigUint64Array || (this._bigUint64Array = new BigUint64Array(this.rawBinaryData));
|
|
return this._bigUint64Array;
|
|
}
|
|
view(type) {
|
|
return this[`${type}View`];
|
|
}
|
|
destroy() {
|
|
this._bigUint64Array = this._float64Array = this._int32View = this._int16View = this._uint8View = this._int8View = this.uint16View = this.float32View = this.uint32View = this.rawBinaryData = null;
|
|
}
|
|
static sizeOf(type) {
|
|
switch(type) {
|
|
case "int8":
|
|
case "uint8":
|
|
return 1;
|
|
case "int16":
|
|
case "uint16":
|
|
return 2;
|
|
case "int32":
|
|
case "uint32":
|
|
case "float32":
|
|
return 4;
|
|
default:
|
|
throw Error(`${type} isn't a valid view type`);
|
|
}
|
|
}
|
|
}
|
|
exports.ViewableBuffer = ViewableBuffer;
|
|
};
|
|
|
|
//# sourceMappingURL=module$node_modules$pixi_DOT_js$lib$utils$data$ViewableBuffer.js.map
|