1 |
- {"ast":null,"code":"/**\n * This class is a small wrapper around a native buffer that can be read and/or written\n */\nexport class StorageBuffer {\n /**\n * Creates a new storage buffer instance\n * @param engine The engine the buffer will be created inside\n * @param size The size of the buffer in bytes\n * @param creationFlags flags to use when creating the buffer (see undefined). The BUFFER_CREATIONFLAG_STORAGE flag will be automatically added.\n * @param label defines the label of the buffer (for debug purpose)\n */\n constructor(engine, size, creationFlags = 3, label) {\n this._engine = engine;\n this._label = label;\n this._engine._storageBuffers.push(this);\n this._create(size, creationFlags);\n }\n _create(size, creationFlags) {\n this._bufferSize = size;\n this._creationFlags = creationFlags;\n this._buffer = this._engine.createStorageBuffer(size, creationFlags, this._label);\n }\n /** @internal */\n _rebuild() {\n this._create(this._bufferSize, this._creationFlags);\n }\n /**\n * Gets underlying native buffer\n * @returns underlying native buffer\n */\n getBuffer() {\n return this._buffer;\n }\n /**\n * Updates the storage buffer\n * @param data the data used to update the storage buffer\n * @param byteOffset the byte offset of the data (optional)\n * @param byteLength the byte length of the data (optional)\n */\n update(data, byteOffset, byteLength) {\n if (!this._buffer) {\n return;\n }\n this._engine.updateStorageBuffer(this._buffer, data, byteOffset, byteLength);\n }\n /**\n * Reads data from the storage buffer\n * @param offset The offset in the storage buffer to start reading from (default: 0)\n * @param size The number of bytes to read from the storage buffer (default: capacity of the buffer)\n * @param buffer The buffer to write the data we have read from the storage buffer to (optional)\n * @param noDelay If true, a call to flushFramebuffer will be issued so that the data can be read back immediately. This can speed up data retrieval, at the cost of a small perf penalty (default: false).\n * @returns If not undefined, returns the (promise) buffer (as provided by the 4th parameter) filled with the data, else it returns a (promise) Uint8Array with the data read from the storage buffer\n */\n read(offset, size, buffer, noDelay) {\n return this._engine.readFromStorageBuffer(this._buffer, offset, size, buffer, noDelay);\n }\n /**\n * Disposes the storage buffer\n */\n dispose() {\n const storageBuffers = this._engine._storageBuffers;\n const index = storageBuffers.indexOf(this);\n if (index !== -1) {\n storageBuffers[index] = storageBuffers[storageBuffers.length - 1];\n storageBuffers.pop();\n }\n this._engine._releaseBuffer(this._buffer);\n this._buffer = null;\n }\n}","map":{"version":3,"names":["StorageBuffer","constructor","engine","size","creationFlags","label","_engine","_label","_storageBuffers","push","_create","_bufferSize","_creationFlags","_buffer","createStorageBuffer","_rebuild","getBuffer","update","data","byteOffset","byteLength","updateStorageBuffer","read","offset","buffer","noDelay","readFromStorageBuffer","dispose","storageBuffers","index","indexOf","length","pop","_releaseBuffer"],"sources":["F:/workspace/202226701027/huinongbao-app/node_modules/@babylonjs/core/Buffers/storageBuffer.js"],"sourcesContent":["\n/**\n * This class is a small wrapper around a native buffer that can be read and/or written\n */\nexport class StorageBuffer {\n /**\n * Creates a new storage buffer instance\n * @param engine The engine the buffer will be created inside\n * @param size The size of the buffer in bytes\n * @param creationFlags flags to use when creating the buffer (see undefined). The BUFFER_CREATIONFLAG_STORAGE flag will be automatically added.\n * @param label defines the label of the buffer (for debug purpose)\n */\n constructor(engine, size, creationFlags = 3, label) {\n this._engine = engine;\n this._label = label;\n this._engine._storageBuffers.push(this);\n this._create(size, creationFlags);\n }\n _create(size, creationFlags) {\n this._bufferSize = size;\n this._creationFlags = creationFlags;\n this._buffer = this._engine.createStorageBuffer(size, creationFlags, this._label);\n }\n /** @internal */\n _rebuild() {\n this._create(this._bufferSize, this._creationFlags);\n }\n /**\n * Gets underlying native buffer\n * @returns underlying native buffer\n */\n getBuffer() {\n return this._buffer;\n }\n /**\n * Updates the storage buffer\n * @param data the data used to update the storage buffer\n * @param byteOffset the byte offset of the data (optional)\n * @param byteLength the byte length of the data (optional)\n */\n update(data, byteOffset, byteLength) {\n if (!this._buffer) {\n return;\n }\n this._engine.updateStorageBuffer(this._buffer, data, byteOffset, byteLength);\n }\n /**\n * Reads data from the storage buffer\n * @param offset The offset in the storage buffer to start reading from (default: 0)\n * @param size The number of bytes to read from the storage buffer (default: capacity of the buffer)\n * @param buffer The buffer to write the data we have read from the storage buffer to (optional)\n * @param noDelay If true, a call to flushFramebuffer will be issued so that the data can be read back immediately. This can speed up data retrieval, at the cost of a small perf penalty (default: false).\n * @returns If not undefined, returns the (promise) buffer (as provided by the 4th parameter) filled with the data, else it returns a (promise) Uint8Array with the data read from the storage buffer\n */\n read(offset, size, buffer, noDelay) {\n return this._engine.readFromStorageBuffer(this._buffer, offset, size, buffer, noDelay);\n }\n /**\n * Disposes the storage buffer\n */\n dispose() {\n const storageBuffers = this._engine._storageBuffers;\n const index = storageBuffers.indexOf(this);\n if (index !== -1) {\n storageBuffers[index] = storageBuffers[storageBuffers.length - 1];\n storageBuffers.pop();\n }\n this._engine._releaseBuffer(this._buffer);\n this._buffer = null;\n }\n}\n"],"mappings":"AACA;AACA;AACA;AACA,OAAO,MAAMA,aAAa,CAAC;EACvB;AACJ;AACA;AACA;AACA;AACA;AACA;EACIC,WAAWA,CAACC,MAAM,EAAEC,IAAI,EAAEC,aAAa,GAAG,CAAC,EAAEC,KAAK,EAAE;IAChD,IAAI,CAACC,OAAO,GAAGJ,MAAM;IACrB,IAAI,CAACK,MAAM,GAAGF,KAAK;IACnB,IAAI,CAACC,OAAO,CAACE,eAAe,CAACC,IAAI,CAAC,IAAI,CAAC;IACvC,IAAI,CAACC,OAAO,CAACP,IAAI,EAAEC,aAAa,CAAC;EACrC;EACAM,OAAOA,CAACP,IAAI,EAAEC,aAAa,EAAE;IACzB,IAAI,CAACO,WAAW,GAAGR,IAAI;IACvB,IAAI,CAACS,cAAc,GAAGR,aAAa;IACnC,IAAI,CAACS,OAAO,GAAG,IAAI,CAACP,OAAO,CAACQ,mBAAmB,CAACX,IAAI,EAAEC,aAAa,EAAE,IAAI,CAACG,MAAM,CAAC;EACrF;EACA;EACAQ,QAAQA,CAAA,EAAG;IACP,IAAI,CAACL,OAAO,CAAC,IAAI,CAACC,WAAW,EAAE,IAAI,CAACC,cAAc,CAAC;EACvD;EACA;AACJ;AACA;AACA;EACII,SAASA,CAAA,EAAG;IACR,OAAO,IAAI,CAACH,OAAO;EACvB;EACA;AACJ;AACA;AACA;AACA;AACA;EACII,MAAMA,CAACC,IAAI,EAAEC,UAAU,EAAEC,UAAU,EAAE;IACjC,IAAI,CAAC,IAAI,CAACP,OAAO,EAAE;MACf;IACJ;IACA,IAAI,CAACP,OAAO,CAACe,mBAAmB,CAAC,IAAI,CAACR,OAAO,EAAEK,IAAI,EAAEC,UAAU,EAAEC,UAAU,CAAC;EAChF;EACA;AACJ;AACA;AACA;AACA;AACA;AACA;AACA;EACIE,IAAIA,CAACC,MAAM,EAAEpB,IAAI,EAAEqB,MAAM,EAAEC,OAAO,EAAE;IAChC,OAAO,IAAI,CAACnB,OAAO,CAACoB,qBAAqB,CAAC,IAAI,CAACb,OAAO,EAAEU,MAAM,EAAEpB,IAAI,EAAEqB,MAAM,EAAEC,OAAO,CAAC;EAC1F;EACA;AACJ;AACA;EACIE,OAAOA,CAAA,EAAG;IACN,MAAMC,cAAc,GAAG,IAAI,CAACtB,OAAO,CAACE,eAAe;IACnD,MAAMqB,KAAK,GAAGD,cAAc,CAACE,OAAO,CAAC,IAAI,CAAC;IAC1C,IAAID,KAAK,KAAK,CAAC,CAAC,EAAE;MACdD,cAAc,CAACC,KAAK,CAAC,GAAGD,cAAc,CAACA,cAAc,CAACG,MAAM,GAAG,CAAC,CAAC;MACjEH,cAAc,CAACI,GAAG,CAAC,CAAC;IACxB;IACA,IAAI,CAAC1B,OAAO,CAAC2B,cAAc,CAAC,IAAI,CAACpB,OAAO,CAAC;IACzC,IAAI,CAACA,OAAO,GAAG,IAAI;EACvB;AACJ","ignoreList":[]},"metadata":{},"sourceType":"module","externalDependencies":[]}
|