b15b76039d113eae7981056c53165810382971d4e527eebe0d42d5c5e5b0c65a.json 16 KB

1
  1. {"ast":null,"code":"import { Buffer, VertexBuffer } from \"./buffer.js\";\nconst isLittleEndian = (() => {\n const array = new Uint8Array(4);\n const view = new Uint32Array(array.buffer);\n return !!((view[0] = 1) & array[0]);\n})();\nObject.defineProperty(VertexBuffer.prototype, \"effectiveByteStride\", {\n get: function () {\n return this._alignedBuffer && this._alignedBuffer.byteStride || this.byteStride;\n },\n enumerable: true,\n configurable: true\n});\nObject.defineProperty(VertexBuffer.prototype, \"effectiveByteOffset\", {\n get: function () {\n return this._alignedBuffer ? 0 : this.byteOffset;\n },\n enumerable: true,\n configurable: true\n});\nObject.defineProperty(VertexBuffer.prototype, \"effectiveBuffer\", {\n get: function () {\n return this._alignedBuffer && this._alignedBuffer.getBuffer() || this._buffer.getBuffer();\n },\n enumerable: true,\n configurable: true\n});\nVertexBuffer.prototype._rebuild = function () {\n var _this$_buffer, _this$_alignedBuffer;\n (_this$_buffer = this._buffer) === null || _this$_buffer === void 0 || _this$_buffer._rebuild();\n (_this$_alignedBuffer = this._alignedBuffer) === null || _this$_alignedBuffer === void 0 || _this$_alignedBuffer._rebuild();\n};\nVertexBuffer.prototype.dispose = function () {\n var _this$_alignedBuffer2;\n if (this._ownsBuffer) {\n this._buffer.dispose();\n }\n (_this$_alignedBuffer2 = this._alignedBuffer) === null || _this$_alignedBuffer2 === void 0 || _this$_alignedBuffer2.dispose();\n this._alignedBuffer = undefined;\n this._isDisposed = true;\n};\nVertexBuffer.prototype.getWrapperBuffer = function () {\n return this._alignedBuffer || this._buffer;\n};\nVertexBuffer.prototype._alignBuffer = function () {\n var _this$_alignedBuffer3, _this$_label;\n const data = this._buffer.getData();\n if (!this.engine._features.forceVertexBufferStrideAndOffsetMultiple4Bytes || this.byteStride % 4 === 0 && this.byteOffset % 4 === 0 || !data) {\n return;\n }\n const typeByteLength = VertexBuffer.GetTypeByteLength(this.type);\n const alignedByteStride = this.byteStride + 3 & ~3;\n const alignedSize = alignedByteStride / typeByteLength;\n const totalVertices = this._maxVerticesCount;\n const totalByteLength = totalVertices * alignedByteStride;\n const totalLength = totalByteLength / typeByteLength;\n let sourceData;\n if (Array.isArray(data)) {\n const sourceDataAsFloat = new Float32Array(data);\n sourceData = new DataView(sourceDataAsFloat.buffer, sourceDataAsFloat.byteOffset, sourceDataAsFloat.byteLength);\n } else if (data instanceof ArrayBuffer) {\n sourceData = new DataView(data, 0, data.byteLength);\n } else {\n sourceData = new DataView(data.buffer, data.byteOffset, data.byteLength);\n }\n let alignedData;\n if (this.type === VertexBuffer.BYTE) {\n alignedData = new Int8Array(totalLength);\n } else if (this.type === VertexBuffer.UNSIGNED_BYTE) {\n alignedData = new Uint8Array(totalLength);\n } else if (this.type === VertexBuffer.SHORT) {\n alignedData = new Int16Array(totalLength);\n } else if (this.type === VertexBuffer.UNSIGNED_SHORT) {\n alignedData = new Uint16Array(totalLength);\n } else if (this.type === VertexBuffer.INT) {\n alignedData = new Int32Array(totalLength);\n } else if (this.type === VertexBuffer.UNSIGNED_INT) {\n alignedData = new Uint32Array(totalLength);\n } else {\n alignedData = new Float32Array(totalLength);\n }\n const numComponents = this.getSize();\n let sourceOffset = this.byteOffset;\n for (let i = 0; i < totalVertices; ++i) {\n for (let j = 0; j < numComponents; ++j) {\n switch (this.type) {\n case VertexBuffer.BYTE:\n alignedData[i * alignedSize + j] = sourceData.getInt8(sourceOffset + j);\n break;\n case VertexBuffer.UNSIGNED_BYTE:\n alignedData[i * alignedSize + j] = sourceData.getUint8(sourceOffset + j);\n break;\n case VertexBuffer.SHORT:\n alignedData[i * alignedSize + j] = sourceData.getInt16(sourceOffset + j * 2, isLittleEndian);\n break;\n case VertexBuffer.UNSIGNED_SHORT:\n alignedData[i * alignedSize + j] = sourceData.getUint16(sourceOffset + j * 2, isLittleEndian);\n break;\n case VertexBuffer.INT:\n alignedData[i * alignedSize + j] = sourceData.getInt32(sourceOffset + j * 4, isLittleEndian);\n break;\n case VertexBuffer.UNSIGNED_INT:\n alignedData[i * alignedSize + j] = sourceData.getUint32(sourceOffset + j * 4, isLittleEndian);\n break;\n case VertexBuffer.FLOAT:\n alignedData[i * alignedSize + j] = sourceData.getFloat32(sourceOffset + j * 4, isLittleEndian);\n break;\n }\n }\n sourceOffset += this.byteStride;\n }\n (_this$_alignedBuffer3 = this._alignedBuffer) === null || _this$_alignedBuffer3 === void 0 || _this$_alignedBuffer3.dispose();\n this._alignedBuffer = new Buffer(this.engine, alignedData, false, alignedByteStride, false, this.getIsInstanced(), true, this.instanceDivisor, ((_this$_label = this._label) !== null && _this$_label !== void 0 ? _this$_label : \"VertexBuffer\") + \"_aligned\");\n};","map":{"version":3,"names":["Buffer","VertexBuffer","isLittleEndian","array","Uint8Array","view","Uint32Array","buffer","Object","defineProperty","prototype","get","_alignedBuffer","byteStride","enumerable","configurable","byteOffset","getBuffer","_buffer","_rebuild","_this$_buffer","_this$_alignedBuffer","dispose","_this$_alignedBuffer2","_ownsBuffer","undefined","_isDisposed","getWrapperBuffer","_alignBuffer","_this$_alignedBuffer3","_this$_label","data","getData","engine","_features","forceVertexBufferStrideAndOffsetMultiple4Bytes","typeByteLength","GetTypeByteLength","type","alignedByteStride","alignedSize","totalVertices","_maxVerticesCount","totalByteLength","totalLength","sourceData","Array","isArray","sourceDataAsFloat","Float32Array","DataView","byteLength","ArrayBuffer","alignedData","BYTE","Int8Array","UNSIGNED_BYTE","SHORT","Int16Array","UNSIGNED_SHORT","Uint16Array","INT","Int32Array","UNSIGNED_INT","numComponents","getSize","sourceOffset","i","j","getInt8","getUint8","getInt16","getUint16","getInt32","getUint32","FLOAT","getFloat32","getIsInstanced","instanceDivisor","_label"],"sources":["F:/workspace/202226701027/huinongbao-app/node_modules/@babylonjs/core/Buffers/buffer.align.js"],"sourcesContent":["import { Buffer, VertexBuffer } from \"./buffer.js\";\nconst isLittleEndian = (() => {\n const array = new Uint8Array(4);\n const view = new Uint32Array(array.buffer);\n return !!((view[0] = 1) & array[0]);\n})();\nObject.defineProperty(VertexBuffer.prototype, \"effectiveByteStride\", {\n get: function () {\n return (this._alignedBuffer && this._alignedBuffer.byteStride) || this.byteStride;\n },\n enumerable: true,\n configurable: true,\n});\nObject.defineProperty(VertexBuffer.prototype, \"effectiveByteOffset\", {\n get: function () {\n return this._alignedBuffer ? 0 : this.byteOffset;\n },\n enumerable: true,\n configurable: true,\n});\nObject.defineProperty(VertexBuffer.prototype, \"effectiveBuffer\", {\n get: function () {\n return (this._alignedBuffer && this._alignedBuffer.getBuffer()) || this._buffer.getBuffer();\n },\n enumerable: true,\n configurable: true,\n});\nVertexBuffer.prototype._rebuild = function () {\n this._buffer?._rebuild();\n this._alignedBuffer?._rebuild();\n};\nVertexBuffer.prototype.dispose = function () {\n if (this._ownsBuffer) {\n this._buffer.dispose();\n }\n this._alignedBuffer?.dispose();\n this._alignedBuffer = undefined;\n this._isDisposed = true;\n};\nVertexBuffer.prototype.getWrapperBuffer = function () {\n return this._alignedBuffer || this._buffer;\n};\nVertexBuffer.prototype._alignBuffer = function () {\n const data = this._buffer.getData();\n if (!this.engine._features.forceVertexBufferStrideAndOffsetMultiple4Bytes || (this.byteStride % 4 === 0 && this.byteOffset % 4 === 0) || !data) {\n return;\n }\n const typeByteLength = VertexBuffer.GetTypeByteLength(this.type);\n const alignedByteStride = (this.byteStride + 3) & ~3;\n const alignedSize = alignedByteStride / typeByteLength;\n const totalVertices = this._maxVerticesCount;\n const totalByteLength = totalVertices * alignedByteStride;\n const totalLength = totalByteLength / typeByteLength;\n let sourceData;\n if (Array.isArray(data)) {\n const sourceDataAsFloat = new Float32Array(data);\n sourceData = new DataView(sourceDataAsFloat.buffer, sourceDataAsFloat.byteOffset, sourceDataAsFloat.byteLength);\n }\n else if (data instanceof ArrayBuffer) {\n sourceData = new DataView(data, 0, data.byteLength);\n }\n else {\n sourceData = new DataView(data.buffer, data.byteOffset, data.byteLength);\n }\n let alignedData;\n if (this.type === VertexBuffer.BYTE) {\n alignedData = new Int8Array(totalLength);\n }\n else if (this.type === VertexBuffer.UNSIGNED_BYTE) {\n alignedData = new Uint8Array(totalLength);\n }\n else if (this.type === VertexBuffer.SHORT) {\n alignedData = new Int16Array(totalLength);\n }\n else if (this.type === VertexBuffer.UNSIGNED_SHORT) {\n alignedData = new Uint16Array(totalLength);\n }\n else if (this.type === VertexBuffer.INT) {\n alignedData = new Int32Array(totalLength);\n }\n else if (this.type === VertexBuffer.UNSIGNED_INT) {\n alignedData = new Uint32Array(totalLength);\n }\n else {\n alignedData = new Float32Array(totalLength);\n }\n const numComponents = this.getSize();\n let sourceOffset = this.byteOffset;\n for (let i = 0; i < totalVertices; ++i) {\n for (let j = 0; j < numComponents; ++j) {\n switch (this.type) {\n case VertexBuffer.BYTE:\n alignedData[i * alignedSize + j] = sourceData.getInt8(sourceOffset + j);\n break;\n case VertexBuffer.UNSIGNED_BYTE:\n alignedData[i * alignedSize + j] = sourceData.getUint8(sourceOffset + j);\n break;\n case VertexBuffer.SHORT:\n alignedData[i * alignedSize + j] = sourceData.getInt16(sourceOffset + j * 2, isLittleEndian);\n break;\n case VertexBuffer.UNSIGNED_SHORT:\n alignedData[i * alignedSize + j] = sourceData.getUint16(sourceOffset + j * 2, isLittleEndian);\n break;\n case VertexBuffer.INT:\n alignedData[i * alignedSize + j] = sourceData.getInt32(sourceOffset + j * 4, isLittleEndian);\n break;\n case VertexBuffer.UNSIGNED_INT:\n alignedData[i * alignedSize + j] = sourceData.getUint32(sourceOffset + j * 4, isLittleEndian);\n break;\n case VertexBuffer.FLOAT:\n alignedData[i * alignedSize + j] = sourceData.getFloat32(sourceOffset + j * 4, isLittleEndian);\n break;\n }\n }\n sourceOffset += this.byteStride;\n }\n this._alignedBuffer?.dispose();\n this._alignedBuffer = new Buffer(this.engine, alignedData, false, alignedByteStride, false, this.getIsInstanced(), true, this.instanceDivisor, (this._label ?? \"VertexBuffer\") + \"_aligned\");\n};\n"],"mappings":"AAAA,SAASA,MAAM,EAAEC,YAAY,QA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