@babylonjs/core 8.47.2 → 8.48.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (80) hide show
  1. package/Audio/analyser.js.map +1 -1
  2. package/AudioV2/webAudio/subNodes/webAudioAnalyzerSubNode.js.map +1 -1
  3. package/Buffers/buffer.align.js +3 -3
  4. package/Buffers/buffer.align.js.map +1 -1
  5. package/Buffers/bufferUtils.d.ts +7 -0
  6. package/Buffers/bufferUtils.js +31 -13
  7. package/Buffers/bufferUtils.js.map +1 -1
  8. package/Engines/Extensions/engine.dynamicBuffer.js +3 -3
  9. package/Engines/Extensions/engine.dynamicBuffer.js.map +1 -1
  10. package/Engines/Native/nativeDataStream.d.ts +1 -1
  11. package/Engines/Native/nativeDataStream.js.map +1 -1
  12. package/Engines/Native/nativeInterfaces.d.ts +4 -4
  13. package/Engines/Native/nativeInterfaces.js.map +1 -1
  14. package/Engines/WebGPU/Extensions/engine.rawTexture.d.ts +13 -1
  15. package/Engines/WebGPU/Extensions/engine.rawTexture.js +26 -8
  16. package/Engines/WebGPU/Extensions/engine.rawTexture.js.map +1 -1
  17. package/Engines/WebGPU/webgpuTextureManager.d.ts +2 -1
  18. package/Engines/WebGPU/webgpuTextureManager.js +19 -6
  19. package/Engines/WebGPU/webgpuTextureManager.js.map +1 -1
  20. package/Engines/abstractEngine.d.ts +4 -2
  21. package/Engines/abstractEngine.functions.d.ts +1 -1
  22. package/Engines/abstractEngine.functions.js +8 -8
  23. package/Engines/abstractEngine.functions.js.map +1 -1
  24. package/Engines/abstractEngine.js +6 -4
  25. package/Engines/abstractEngine.js.map +1 -1
  26. package/Engines/engine.d.ts +12 -0
  27. package/Engines/thinNativeEngine.js +1 -1
  28. package/Engines/thinNativeEngine.js.map +1 -1
  29. package/Engines/thinWebGPUEngine.js +3 -0
  30. package/Engines/thinWebGPUEngine.js.map +1 -1
  31. package/Engines/webgpuEngine.js +18 -18
  32. package/Engines/webgpuEngine.js.map +1 -1
  33. package/Lights/Clustered/clusteredLightContainer.js.map +1 -1
  34. package/Materials/Background/backgroundMaterial.d.ts +16 -8
  35. package/Materials/GaussianSplatting/gaussianSplattingMaterial.js +14 -1
  36. package/Materials/GaussianSplatting/gaussianSplattingMaterial.js.map +1 -1
  37. package/Materials/Node/nodeMaterial.d.ts +16 -8
  38. package/Materials/PBR/openpbrMaterial.d.ts +16 -8
  39. package/Materials/PBR/pbrBaseMaterial.d.ts +16 -8
  40. package/Materials/Textures/Loaders/EXR/exrLoader.compression.rle.d.ts +1 -1
  41. package/Materials/Textures/Loaders/EXR/exrLoader.compression.rle.js.map +1 -1
  42. package/Materials/Textures/Loaders/EXR/exrLoader.core.d.ts +1 -1
  43. package/Materials/Textures/Loaders/EXR/exrLoader.core.js.map +1 -1
  44. package/Materials/Textures/internalTexture.d.ts +6 -0
  45. package/Materials/Textures/internalTexture.js +24 -2
  46. package/Materials/Textures/internalTexture.js.map +1 -1
  47. package/Materials/Textures/rawTexture.d.ts +8 -1
  48. package/Materials/Textures/rawTexture.js +12 -3
  49. package/Materials/Textures/rawTexture.js.map +1 -1
  50. package/Materials/Textures/rawTexture2DArray.d.ts +8 -1
  51. package/Materials/Textures/rawTexture2DArray.js +14 -3
  52. package/Materials/Textures/rawTexture2DArray.js.map +1 -1
  53. package/Materials/imageProcessing.d.ts +47 -8
  54. package/Materials/standardMaterial.d.ts +16 -8
  55. package/Meshes/Builders/shapeBuilder.d.ts +4 -0
  56. package/Meshes/Builders/shapeBuilder.js +12 -9
  57. package/Meshes/Builders/shapeBuilder.js.map +1 -1
  58. package/Meshes/GaussianSplatting/gaussianSplattingMesh.d.ts +68 -4
  59. package/Meshes/GaussianSplatting/gaussianSplattingMesh.js +343 -26
  60. package/Meshes/GaussianSplatting/gaussianSplattingMesh.js.map +1 -1
  61. package/Misc/dds.js.map +1 -1
  62. package/Misc/environmentTextureTools.js +3 -1
  63. package/Misc/environmentTextureTools.js.map +1 -1
  64. package/Misc/fileTools.js +9 -1
  65. package/Misc/fileTools.js.map +1 -1
  66. package/Physics/v1/physicsImpostor.d.ts +2 -2
  67. package/Physics/v1/physicsImpostor.js.map +1 -1
  68. package/Shaders/ShadersInclude/gaussianSplatting.js +16 -3
  69. package/Shaders/ShadersInclude/gaussianSplatting.js.map +1 -1
  70. package/Shaders/gaussianSplatting.vertex.js +17 -4
  71. package/Shaders/gaussianSplatting.vertex.js.map +1 -1
  72. package/ShadersWGSL/ShadersInclude/gaussianSplatting.js +11 -1
  73. package/ShadersWGSL/ShadersInclude/gaussianSplatting.js.map +1 -1
  74. package/ShadersWGSL/gaussianSplatting.vertex.js +17 -4
  75. package/ShadersWGSL/gaussianSplatting.vertex.js.map +1 -1
  76. package/XR/native/nativeXRFrame.d.ts +1 -1
  77. package/XR/native/nativeXRFrame.js.map +1 -1
  78. package/package.json +1 -1
  79. package/types.d.ts +1 -1
  80. package/types.js.map +1 -1
@@ -1 +1 @@
1
- {"version":3,"file":"analyser.js","sourceRoot":"","sources":["../../../../dev/core/src/Audio/analyser.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,KAAK,EAAE,MAAM,eAAe,CAAC;AACtC,OAAO,EAAE,WAAW,EAAE,MAAM,wBAAwB,CAAC;AACrD,OAAO,EAAE,cAAc,EAAE,qCAAoC;AAE7D;;;GAGG;AACH,MAAM,OAAO,QAAQ;IAgCjB;;;OAGG;IACH,YAAY,KAAuB;QAnCnC;;WAEG;QACI,cAAS,GAAG,IAAI,CAAC;QACxB;;WAEG;QACI,aAAQ,GAAG,GAAG,CAAC;QACtB;;WAEG;QACI,sBAAiB,GAAG,GAAG,CAAC;QAC/B;;WAEG;QACI,mBAAc,GAAG,EAAE,CAAC,EAAE,EAAE,EAAE,CAAC,EAAE,EAAE,EAAE,CAAC;QACzC;;WAEG;QACI,oBAAe,GAAG,EAAE,KAAK,EAAE,GAAG,EAAE,MAAM,EAAE,GAAG,EAAE,CAAC;QAiBjD,KAAK,GAAG,KAAK,IAAI,WAAW,C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AI,CAAC,iBAAiB,CAAC,CAAC;YAC/C,IAAI,CAAC,iBAAiB,CAAC,OAAO,CAAC,eAAe,CAAC,CAAC;QACpD,CAAC;IACL,CAAC;IAED;;OAEG;IACI,OAAO;QACV,IAAI,IAAI,CAAC,YAAY,CAAC,cAAc,EAAE,CAAC;YACnC,IAAI,CAAC,iBAAiB,CAAC,UAAU,EAAE,CAAC;QACxC,CAAC;IACL,CAAC;CACJ","sourcesContent":["/* eslint-disable @typescript-eslint/naming-convention */\r\nimport type { Nullable } from \"../types\";\r\nimport type { Scene } from \"../scene\";\r\nimport type { IAudioEngine } from \"./Interfaces/IAudioEngine\";\r\nimport { Tools } from \"../Misc/tools\";\r\nimport { EngineStore } from \"../Engines/engineStore\";\r\nimport { AbstractEngine } from \"core/Engines/abstractEngine\";\r\n\r\n/**\r\n * Class used to work with sound analyzer using fast fourier transform (FFT)\r\n * @see https://doc.babylonjs.com/features/featuresDeepDive/audio/playingSoundsMusic\r\n */\r\nexport class Analyser {\r\n /**\r\n * Gets or sets the smoothing\r\n */\r\n public SMOOTHING = 0.75;\r\n /**\r\n * Gets or sets the FFT table size\r\n */\r\n public FFT_SIZE = 512;\r\n /**\r\n * Gets or sets the bar graph amplitude\r\n */\r\n public BARGRAPHAMPLITUDE = 256;\r\n /**\r\n * Gets or sets the position of the debug canvas\r\n */\r\n public DEBUGCANVASPOS = { x: 20, y: 20 };\r\n /**\r\n * Gets or sets the debug canvas size\r\n */\r\n public DEBUGCANVASSIZE = { width: 320, height: 200 };\r\n\r\n private _byteFreqs: Uint8Array;\r\n private _byteTime: Uint8Array;\r\n private _floatFreqs: Float32Array;\r\n private _webAudioAnalyser: AnalyserNode;\r\n private _debugCanvas: Nullable<HTMLCanvasElement>;\r\n private _debugCanvasContext: Nullable<CanvasRenderingContext2D>;\r\n private _scene: Scene;\r\n private _registerFunc: Nullable<() => void>;\r\n private _audioEngine: IAudioEngine;\r\n\r\n /**\r\n * Creates a new analyser\r\n * @param scene defines hosting scene\r\n */\r\n constructor(scene?: Nullable<Scene>) {\r\n scene = scene || EngineStore.LastCreatedScene;\r\n if (!scene) {\r\n return;\r\n }\r\n this._scene = scene;\r\n if (!AbstractEngine.audioEngine) {\r\n Tools.Warn(\"No audio engine initialized, failed to create an audio analyser\");\r\n return;\r\n }\r\n this._audioEngine = AbstractEngine.audioEngine;\r\n if (this._audioEngine.canUseWebAudio && this._audioEngine.audioContext) {\r\n this._webAudioAnalyser = this._audioEngine.audioContext.createAnalyser();\r\n this._webAudioAnalyser.minDecibels = -140;\r\n this._webAudioAnalyser.maxDecibels = 0;\r\n this._byteFreqs = new Uint8Array(this._webAudioAnalyser.frequencyBinCount);\r\n this._byteTime = new Uint8Array(this._webAudioAnalyser.frequencyBinCount);\r\n this._floatFreqs = new Float32Array(this._webAudioAnalyser.frequencyBinCount);\r\n }\r\n }\r\n\r\n /**\r\n * Get the number of data values you will have to play with for the visualization\r\n * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/frequencyBinCount\r\n * @returns a number\r\n */\r\n public getFrequencyBinCount(): number {\r\n if (this._audioEngine.canUseWebAudio) {\r\n return this._webAudioAnalyser.frequencyBinCount;\r\n } else {\r\n return 0;\r\n }\r\n }\r\n\r\n /**\r\n * Gets the current frequency data as a byte array\r\n * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteFrequencyData\r\n * @returns a Uint8Array\r\n */\r\n public getByteFrequencyData(): Uint8Array {\r\n if (this._audioEngine.canUseWebAudio) {\r\n this._webAudioAnalyser.smoothingTimeConstant = this.SMOOTHING;\r\n this._webAudioAnalyser.fftSize = this.FFT_SIZE;\r\n this._webAudioAnalyser.getByteFrequencyData(this._byteFreqs);\r\n }\r\n return this._byteFreqs;\r\n }\r\n\r\n /**\r\n * Gets the current waveform as a byte array\r\n * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteTimeDomainData\r\n * @returns a Uint8Array\r\n */\r\n public getByteTimeDomainData(): Uint8Array {\r\n if (this._audioEngine.canUseWebAudio) {\r\n this._webAudioAnalyser.smoothingTimeConstant = this.SMOOTHING;\r\n this._webAudioAnalyser.fftSize = this.FFT_SIZE;\r\n this._webAudioAnalyser.getByteTimeDomainData(this._byteTime);\r\n }\r\n return this._byteTime;\r\n }\r\n\r\n /**\r\n * Gets the current frequency data as a float array\r\n * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteFrequencyData\r\n * @returns a Float32Array\r\n */\r\n public getFloatFrequencyData(): Float32Array {\r\n if (this._audioEngine.canUseWebAudio) {\r\n this._webAudioAnalyser.smoothingTimeConstant = this.SMOOTHING;\r\n this._webAudioAnalyser.fftSize = this.FFT_SIZE;\r\n this._webAudioAnalyser.getFloatFrequencyData(this._floatFreqs);\r\n }\r\n return this._floatFreqs;\r\n }\r\n\r\n /**\r\n * Renders the debug canvas\r\n */\r\n public drawDebugCanvas() {\r\n if (this._audioEngine.canUseWebAudio) {\r\n if (!this._debugCanvas) {\r\n this._debugCanvas = document.createElement(\"canvas\");\r\n this._debugCanvas.width = this.DEBUGCANVASSIZE.width;\r\n this._debugCanvas.height = this.DEBUGCANVASSIZE.height;\r\n this._debugCanvas.style.position = \"absolute\";\r\n this._debugCanvas.style.top = this.DEBUGCANVASPOS.y + \"px\";\r\n this._debugCanvas.style.left = this.DEBUGCANVASPOS.x + \"px\";\r\n this._debugCanvasContext = this._debugCanvas.getContext(\"2d\");\r\n document.body.appendChild(this._debugCanvas);\r\n this._registerFunc = () => {\r\n this.drawDebugCanvas();\r\n };\r\n this._scene.registerBeforeRender(this._registerFunc);\r\n }\r\n if (this._registerFunc && this._debugCanvasContext) {\r\n const workingArray = this.getByteFrequencyData();\r\n\r\n this._debugCanvasContext.fillStyle = \"rgb(0, 0, 0)\";\r\n this._debugCanvasContext.fillRect(0, 0, this.DEBUGCANVASSIZE.width, this.DEBUGCANVASSIZE.height);\r\n\r\n // Draw the frequency domain chart.\r\n for (let i = 0; i < this.getFrequencyBinCount(); i++) {\r\n const value = workingArray[i];\r\n const percent = value / this.BARGRAPHAMPLITUDE;\r\n const height = this.DEBUGCANVASSIZE.height * percent;\r\n const offset = this.DEBUGCANVASSIZE.height - height - 1;\r\n const barWidth = this.DEBUGCANVASSIZE.width / this.getFrequencyBinCount();\r\n const hue = (i / this.getFrequencyBinCount()) * 360;\r\n this._debugCanvasContext.fillStyle = \"hsl(\" + hue + \", 100%, 50%)\";\r\n this._debugCanvasContext.fillRect(i * barWidth, offset, barWidth, height);\r\n }\r\n }\r\n }\r\n }\r\n\r\n /**\r\n * Stops rendering the debug canvas and removes it\r\n */\r\n public stopDebugCanvas() {\r\n if (this._debugCanvas) {\r\n if (this._registerFunc) {\r\n this._scene.unregisterBeforeRender(this._registerFunc);\r\n this._registerFunc = null;\r\n }\r\n document.body.removeChild(this._debugCanvas);\r\n this._debugCanvas = null;\r\n this._debugCanvasContext = null;\r\n }\r\n }\r\n\r\n /**\r\n * Connects two audio nodes\r\n * @param inputAudioNode defines first node to connect\r\n * @param outputAudioNode defines second node to connect\r\n */\r\n public connectAudioNodes(inputAudioNode: AudioNode, outputAudioNode: AudioNode) {\r\n if (this._audioEngine.canUseWebAudio) {\r\n inputAudioNode.connect(this._webAudioAnalyser);\r\n this._webAudioAnalyser.connect(outputAudioNode);\r\n }\r\n }\r\n\r\n /**\r\n * Releases all associated resources\r\n */\r\n public dispose() {\r\n if (this._audioEngine.canUseWebAudio) {\r\n this._webAudioAnalyser.disconnect();\r\n }\r\n }\r\n}\r\n"]}
1
+ {"version":3,"file":"analyser.js","sourceRoot":"","sources":["../../../../dev/core/src/Audio/analyser.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,KAAK,EAAE,MAAM,eAAe,CAAC;AACtC,OAAO,EAAE,WAAW,EAAE,MAAM,wBAAwB,CAAC;AACrD,OAAO,EAAE,cAAc,EAAE,qCAAoC;AAE7D;;;GAGG;AACH,MAAM,OAAO,QAAQ;IAgCjB;;;OAGG;IACH,YAAY,KAAuB;QAnCnC;;W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,CAAC;YAC9B,CAAC;YACD,QAAQ,CAAC,IAAI,CAAC,WAAW,CAAC,IAAI,CAAC,YAAY,CAAC,CAAC;YAC7C,IAAI,CAAC,YAAY,GAAG,IAAI,CAAC;YACzB,IAAI,CAAC,mBAAmB,GAAG,IAAI,CAAC;QACpC,CAAC;IACL,CAAC;IAED;;;;OAIG;IACI,iBAAiB,CAAC,cAAyB,EAAE,eAA0B;QAC1E,IAAI,IAAI,CAAC,YAAY,CAAC,cAAc,EAAE,CAAC;YACnC,cAAc,CAAC,OAAO,CAAC,IAAI,CAAC,iBAAiB,CAAC,CAAC;YAC/C,IAAI,CAAC,iBAAiB,CAAC,OAAO,CAAC,eAAe,CAAC,CAAC;QACpD,CAAC;IACL,CAAC;IAED;;OAEG;IACI,OAAO;QACV,IAAI,IAAI,CAAC,YAAY,CAAC,cAAc,EAAE,CAAC;YACnC,IAAI,CAAC,iBAAiB,CAAC,UAAU,EAAE,CAAC;QACxC,CAAC;IACL,CAAC;CACJ","sourcesContent":["/* eslint-disable @typescript-eslint/naming-convention */\r\nimport type { Nullable } from \"../types\";\r\nimport type { Scene } from \"../scene\";\r\nimport type { IAudioEngine } from \"./Interfaces/IAudioEngine\";\r\nimport { Tools } from \"../Misc/tools\";\r\nimport { EngineStore } from \"../Engines/engineStore\";\r\nimport { AbstractEngine } from \"core/Engines/abstractEngine\";\r\n\r\n/**\r\n * Class used to work with sound analyzer using fast fourier transform (FFT)\r\n * @see https://doc.babylonjs.com/features/featuresDeepDive/audio/playingSoundsMusic\r\n */\r\nexport class Analyser {\r\n /**\r\n * Gets or sets the smoothing\r\n */\r\n public SMOOTHING = 0.75;\r\n /**\r\n * Gets or sets the FFT table size\r\n */\r\n public FFT_SIZE = 512;\r\n /**\r\n * Gets or sets the bar graph amplitude\r\n */\r\n public BARGRAPHAMPLITUDE = 256;\r\n /**\r\n * Gets or sets the position of the debug canvas\r\n */\r\n public DEBUGCANVASPOS = { x: 20, y: 20 };\r\n /**\r\n * Gets or sets the debug canvas size\r\n */\r\n public DEBUGCANVASSIZE = { width: 320, height: 200 };\r\n\r\n private _byteFreqs: Uint8Array<ArrayBuffer>;\r\n private _byteTime: Uint8Array<ArrayBuffer>;\r\n private _floatFreqs: Float32Array<ArrayBuffer>;\r\n private _webAudioAnalyser: AnalyserNode;\r\n private _debugCanvas: Nullable<HTMLCanvasElement>;\r\n private _debugCanvasContext: Nullable<CanvasRenderingContext2D>;\r\n private _scene: Scene;\r\n private _registerFunc: Nullable<() => void>;\r\n private _audioEngine: IAudioEngine;\r\n\r\n /**\r\n * Creates a new analyser\r\n * @param scene defines hosting scene\r\n */\r\n constructor(scene?: Nullable<Scene>) {\r\n scene = scene || EngineStore.LastCreatedScene;\r\n if (!scene) {\r\n return;\r\n }\r\n this._scene = scene;\r\n if (!AbstractEngine.audioEngine) {\r\n Tools.Warn(\"No audio engine initialized, failed to create an audio analyser\");\r\n return;\r\n }\r\n this._audioEngine = AbstractEngine.audioEngine;\r\n if (this._audioEngine.canUseWebAudio && this._audioEngine.audioContext) {\r\n this._webAudioAnalyser = this._audioEngine.audioContext.createAnalyser();\r\n this._webAudioAnalyser.minDecibels = -140;\r\n this._webAudioAnalyser.maxDecibels = 0;\r\n this._byteFreqs = new Uint8Array(this._webAudioAnalyser.frequencyBinCount);\r\n this._byteTime = new Uint8Array(this._webAudioAnalyser.frequencyBinCount);\r\n this._floatFreqs = new Float32Array(this._webAudioAnalyser.frequencyBinCount);\r\n }\r\n }\r\n\r\n /**\r\n * Get the number of data values you will have to play with for the visualization\r\n * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/frequencyBinCount\r\n * @returns a number\r\n */\r\n public getFrequencyBinCount(): number {\r\n if (this._audioEngine.canUseWebAudio) {\r\n return this._webAudioAnalyser.frequencyBinCount;\r\n } else {\r\n return 0;\r\n }\r\n }\r\n\r\n /**\r\n * Gets the current frequency data as a byte array\r\n * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteFrequencyData\r\n * @returns a Uint8Array\r\n */\r\n public getByteFrequencyData(): Uint8Array {\r\n if (this._audioEngine.canUseWebAudio) {\r\n this._webAudioAnalyser.smoothingTimeConstant = this.SMOOTHING;\r\n this._webAudioAnalyser.fftSize = this.FFT_SIZE;\r\n this._webAudioAnalyser.getByteFrequencyData(this._byteFreqs);\r\n }\r\n return this._byteFreqs;\r\n }\r\n\r\n /**\r\n * Gets the current waveform as a byte array\r\n * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteTimeDomainData\r\n * @returns a Uint8Array\r\n */\r\n public getByteTimeDomainData(): Uint8Array {\r\n if (this._audioEngine.canUseWebAudio) {\r\n this._webAudioAnalyser.smoothingTimeConstant = this.SMOOTHING;\r\n this._webAudioAnalyser.fftSize = this.FFT_SIZE;\r\n this._webAudioAnalyser.getByteTimeDomainData(this._byteTime);\r\n }\r\n return this._byteTime;\r\n }\r\n\r\n /**\r\n * Gets the current frequency data as a float array\r\n * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteFrequencyData\r\n * @returns a Float32Array\r\n */\r\n public getFloatFrequencyData(): Float32Array {\r\n if (this._audioEngine.canUseWebAudio) {\r\n this._webAudioAnalyser.smoothingTimeConstant = this.SMOOTHING;\r\n this._webAudioAnalyser.fftSize = this.FFT_SIZE;\r\n this._webAudioAnalyser.getFloatFrequencyData(this._floatFreqs);\r\n }\r\n return this._floatFreqs;\r\n }\r\n\r\n /**\r\n * Renders the debug canvas\r\n */\r\n public drawDebugCanvas() {\r\n if (this._audioEngine.canUseWebAudio) {\r\n if (!this._debugCanvas) {\r\n this._debugCanvas = document.createElement(\"canvas\");\r\n this._debugCanvas.width = this.DEBUGCANVASSIZE.width;\r\n this._debugCanvas.height = this.DEBUGCANVASSIZE.height;\r\n this._debugCanvas.style.position = \"absolute\";\r\n this._debugCanvas.style.top = this.DEBUGCANVASPOS.y + \"px\";\r\n this._debugCanvas.style.left = this.DEBUGCANVASPOS.x + \"px\";\r\n this._debugCanvasContext = this._debugCanvas.getContext(\"2d\");\r\n document.body.appendChild(this._debugCanvas);\r\n this._registerFunc = () => {\r\n this.drawDebugCanvas();\r\n };\r\n this._scene.registerBeforeRender(this._registerFunc);\r\n }\r\n if (this._registerFunc && this._debugCanvasContext) {\r\n const workingArray = this.getByteFrequencyData();\r\n\r\n this._debugCanvasContext.fillStyle = \"rgb(0, 0, 0)\";\r\n this._debugCanvasContext.fillRect(0, 0, this.DEBUGCANVASSIZE.width, this.DEBUGCANVASSIZE.height);\r\n\r\n // Draw the frequency domain chart.\r\n for (let i = 0; i < this.getFrequencyBinCount(); i++) {\r\n const value = workingArray[i];\r\n const percent = value / this.BARGRAPHAMPLITUDE;\r\n const height = this.DEBUGCANVASSIZE.height * percent;\r\n const offset = this.DEBUGCANVASSIZE.height - height - 1;\r\n const barWidth = this.DEBUGCANVASSIZE.width / this.getFrequencyBinCount();\r\n const hue = (i / this.getFrequencyBinCount()) * 360;\r\n this._debugCanvasContext.fillStyle = \"hsl(\" + hue + \", 100%, 50%)\";\r\n this._debugCanvasContext.fillRect(i * barWidth, offset, barWidth, height);\r\n }\r\n }\r\n }\r\n }\r\n\r\n /**\r\n * Stops rendering the debug canvas and removes it\r\n */\r\n public stopDebugCanvas() {\r\n if (this._debugCanvas) {\r\n if (this._registerFunc) {\r\n this._scene.unregisterBeforeRender(this._registerFunc);\r\n this._registerFunc = null;\r\n }\r\n document.body.removeChild(this._debugCanvas);\r\n this._debugCanvas = null;\r\n this._debugCanvasContext = null;\r\n }\r\n }\r\n\r\n /**\r\n * Connects two audio nodes\r\n * @param inputAudioNode defines first node to connect\r\n * @param outputAudioNode defines second node to connect\r\n */\r\n public connectAudioNodes(inputAudioNode: AudioNode, outputAudioNode: AudioNode) {\r\n if (this._audioEngine.canUseWebAudio) {\r\n inputAudioNode.connect(this._webAudioAnalyser);\r\n this._webAudioAnalyser.connect(outputAudioNode);\r\n }\r\n }\r\n\r\n /**\r\n * Releases all associated resources\r\n */\r\n public dispose() {\r\n if (this._audioEngine.canUseWebAudio) {\r\n this._webAudioAnalyser.disconnect();\r\n }\r\n }\r\n}\r\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"webAudioAnalyzerSubNode.js","sourceRoot":"","sources":["../../../../../../dev/core/src/AudioV2/webAudio/subNodes/webAudioAnalyzerSubNode.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,qBAAqB,EAAE,MAAM,mDAAmD,CAAC;AAE1F,OAAO,EAAE,0BAA0B,EAAE,2BAA2B,EAAE,MAAM,iDAAiD,CAAC;AAI1H,gBAAgB;AAChB,4DAA4D;AAC5D,MAAM,CAAC,KAAK,UAAU,gCAAgC,CAAC,MAAuB;IAC1E,OAAO,IAAI,wBAAwB,CAAC,MAAM,CAAC,CAAC;AAChD,CAAC;AAED,gBAAgB;AAChB,MAAM,OAAO,wBAAyB,SAAQ,qBAAqB;IAK/D,gBAAgB;IAChB,YAAmB,MAAuB;QACtC,KAAK,CAAC,MAAM,CAAC,CAAC;QALV,uBAAkB,GAAyB,IAAI,CAAC;QAChD,wBAAmB,GAA2B,IAAI,CAAC;QAMvD,IAAI,CAAC,aAAa,GAAG,IAAI,YAAY,CAAC,MAAM,CAAC,aAAa,CAAC,CAAC;IAChE,CAAC;IAED,gBAAgB;IAChB,IAAW,OAAO;QACd,OAAO,IAAI,CAAC,aAAa,CAAC,OAAmC,CAAC;IAClE,CAAC;IAED,IAAW,OAAO,CAAC,KAA+B;QAC9C,IAAI,KAAK,KAAK,IAAI,CAAC,aAAa,CAAC,OAAO,EAAE,CAAC;YACvC,OAAO;QACX,CAAC;QAED,IAAI,CAAC,aAAa,CAAC,OAAO,GAAG,KAAK,CAAC;QAEnC,IAAI,CAAC,YAAY,EAAE,CAAC;IACxB,CAAC;IAED,gBAAgB;IAChB,IAAW,OAAO;QACd,OAAO,IAAI,CAAC,aAAa,CAAC;IAC9B,CAAC;IAED,gBAAgB;IAChB,IAAW,WAAW;QAClB,OAAO,IAAI,CAAC,aAAa,CAAC,WAA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mB,IAAI,IAAI,CAAC,mBAAmB,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;YACrE,IAAI,CAAC,mBAAmB,GAAG,IAAI,YAAY,CAAC,IAAI,CAAC,aAAa,CAAC,iBAAiB,CAAC,CAAC;QACtF,CAAC;QACD,IAAI,CAAC,aAAa,CAAC,qBAAqB,CAAC,IAAI,CAAC,mBAAmB,CAAC,CAAC;QACnE,OAAO,IAAI,CAAC,mBAAmB,CAAC;IACpC,CAAC;IAEO,YAAY;QAChB,IAAI,CAAC,kBAAkB,EAAE,GAAG,CAAC,0BAA0B,EAAE,CAAC,CAAC;QAC3D,IAAI,CAAC,mBAAmB,EAAE,GAAG,CAAC,2BAA2B,EAAE,CAAC,CAAC;IACjE,CAAC;CACJ","sourcesContent":["import type { Nullable } from \"../../../types\";\nimport { _AudioAnalyzerSubNode } from \"../../abstractAudio/subNodes/audioAnalyzerSubNode\";\nimport type { AudioAnalyzerFFTSizeType } from \"../../abstractAudio/subProperties/abstractAudioAnalyzer\";\nimport { _GetEmptyByteFrequencyData, _GetEmptyFloatFrequencyData } from \"../../abstractAudio/subProperties/audioAnalyzer\";\nimport type { _WebAudioEngine } from \"../webAudioEngine\";\nimport type { IWebAudioInNode } from \"../webAudioNode\";\n\n/** @internal */\n// eslint-disable-next-line @typescript-eslint/require-await\nexport async function _CreateAudioAnalyzerSubNodeAsync(engine: _WebAudioEngine): Promise<_AudioAnalyzerSubNode> {\n return new _WebAudioAnalyzerSubNode(engine);\n}\n\n/** @internal */\nexport class _WebAudioAnalyzerSubNode extends _AudioAnalyzerSubNode implements IWebAudioInNode {\n private readonly _analyzerNode: AnalyserNode;\n private _byteFrequencyData: Nullable<Uint8Array> = null;\n private _floatFrequencyData: Nullable<Float32Array> = null;\n\n /** @internal */\n public constructor(engine: _WebAudioEngine) {\n super(engine);\n\n this._analyzerNode = new AnalyserNode(engine._audioContext);\n }\n\n /** @internal */\n public get fftSize(): AudioAnalyzerFFTSizeType {\n return this._analyzerNode.fftSize as AudioAnalyzerFFTSizeType;\n }\n\n public set fftSize(value: AudioAnalyzerFFTSizeType) {\n if (value === this._analyzerNode.fftSize) {\n return;\n }\n\n this._analyzerNode.fftSize = value;\n\n this._clearArrays();\n }\n\n /** @internal */\n public get _inNode(): AudioNode {\n return this._analyzerNode;\n }\n\n /** @internal */\n public get minDecibels(): number {\n return this._analyzerNode.minDecibels;\n }\n\n public set minDecibels(value: number) {\n this._analyzerNode.minDecibels = value;\n }\n\n /** @internal */\n public get maxDecibels(): number {\n return this._analyzerNode.maxDecibels;\n }\n\n public set maxDecibels(value: number) {\n this._analyzerNode.maxDecibels = value;\n }\n\n /** @internal */\n public get smoothing(): number {\n return this._analyzerNode.smoothingTimeConstant;\n }\n\n public set smoothing(value: number) {\n this._analyzerNode.smoothingTimeConstant = value;\n }\n\n /** @internal */\n public override dispose(): void {\n super.dispose();\n\n this._clearArrays();\n this._byteFrequencyData = null;\n this._floatFrequencyData = null;\n\n this._analyzerNode.disconnect();\n }\n\n /** @internal */\n public getClassName(): string {\n return \"_WebAudioAnalyzerSubNode\";\n }\n\n /** @internal */\n public getByteFrequencyData(): Uint8Array {\n if (!this._byteFrequencyData || this._byteFrequencyData.length === 0) {\n this._byteFrequencyData = new Uint8Array(this._analyzerNode.frequencyBinCount);\n }\n this._analyzerNode.getByteFrequencyData(this._byteFrequencyData);\n return this._byteFrequencyData;\n }\n\n /** @internal */\n public getFloatFrequencyData(): Float32Array {\n if (!this._floatFrequencyData || this._floatFrequencyData.length === 0) {\n this._floatFrequencyData = new Float32Array(this._analyzerNode.frequencyBinCount);\n }\n this._analyzerNode.getFloatFrequencyData(this._floatFrequencyData);\n return this._floatFrequencyData;\n }\n\n private _clearArrays(): void {\n this._byteFrequencyData?.set(_GetEmptyByteFrequencyData());\n this._floatFrequencyData?.set(_GetEmptyFloatFrequencyData());\n }\n}\n"]}
1
+ {"version":3,"file":"webAudioAnalyzerSubNode.js","sourceRoot":"","sources":["../../../../../../dev/core/src/AudioV2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F,CAAC;QACD,IAAI,CAAC,aAAa,CAAC,qBAAqB,CAAC,IAAI,CAAC,mBAAmB,CAAC,CAAC;QACnE,OAAO,IAAI,CAAC,mBAAmB,CAAC;IACpC,CAAC;IAEO,YAAY;QAChB,IAAI,CAAC,kBAAkB,EAAE,GAAG,CAAC,0BAA0B,EAAE,CAAC,CAAC;QAC3D,IAAI,CAAC,mBAAmB,EAAE,GAAG,CAAC,2BAA2B,EAAE,CAAC,CAAC;IACjE,CAAC;CACJ","sourcesContent":["import type { Nullable } from \"../../../types\";\nimport { _AudioAnalyzerSubNode } from \"../../abstractAudio/subNodes/audioAnalyzerSubNode\";\nimport type { AudioAnalyzerFFTSizeType } from \"../../abstractAudio/subProperties/abstractAudioAnalyzer\";\nimport { _GetEmptyByteFrequencyData, _GetEmptyFloatFrequencyData } from \"../../abstractAudio/subProperties/audioAnalyzer\";\nimport type { _WebAudioEngine } from \"../webAudioEngine\";\nimport type { IWebAudioInNode } from \"../webAudioNode\";\n\n/** @internal */\n// eslint-disable-next-line @typescript-eslint/require-await\nexport async function _CreateAudioAnalyzerSubNodeAsync(engine: _WebAudioEngine): Promise<_AudioAnalyzerSubNode> {\n return new _WebAudioAnalyzerSubNode(engine);\n}\n\n/** @internal */\nexport class _WebAudioAnalyzerSubNode extends _AudioAnalyzerSubNode implements IWebAudioInNode {\n private readonly _analyzerNode: AnalyserNode;\n private _byteFrequencyData: Nullable<Uint8Array<ArrayBuffer>> = null;\n private _floatFrequencyData: Nullable<Float32Array<ArrayBuffer>> = null;\n\n /** @internal */\n public constructor(engine: _WebAudioEngine) {\n super(engine);\n\n this._analyzerNode = new AnalyserNode(engine._audioContext);\n }\n\n /** @internal */\n public get fftSize(): AudioAnalyzerFFTSizeType {\n return this._analyzerNode.fftSize as AudioAnalyzerFFTSizeType;\n }\n\n public set fftSize(value: AudioAnalyzerFFTSizeType) {\n if (value === this._analyzerNode.fftSize) {\n return;\n }\n\n this._analyzerNode.fftSize = value;\n\n this._clearArrays();\n }\n\n /** @internal */\n public get _inNode(): AudioNode {\n return this._analyzerNode;\n }\n\n /** @internal */\n public get minDecibels(): number {\n return this._analyzerNode.minDecibels;\n }\n\n public set minDecibels(value: number) {\n this._analyzerNode.minDecibels = value;\n }\n\n /** @internal */\n public get maxDecibels(): number {\n return this._analyzerNode.maxDecibels;\n }\n\n public set maxDecibels(value: number) {\n this._analyzerNode.maxDecibels = value;\n }\n\n /** @internal */\n public get smoothing(): number {\n return this._analyzerNode.smoothingTimeConstant;\n }\n\n public set smoothing(value: number) {\n this._analyzerNode.smoothingTimeConstant = value;\n }\n\n /** @internal */\n public override dispose(): void {\n super.dispose();\n\n this._clearArrays();\n this._byteFrequencyData = null;\n this._floatFrequencyData = null;\n\n this._analyzerNode.disconnect();\n }\n\n /** @internal */\n public getClassName(): string {\n return \"_WebAudioAnalyzerSubNode\";\n }\n\n /** @internal */\n public getByteFrequencyData(): Uint8Array {\n if (!this._byteFrequencyData || this._byteFrequencyData.length === 0) {\n this._byteFrequencyData = new Uint8Array(this._analyzerNode.frequencyBinCount);\n }\n this._analyzerNode.getByteFrequencyData(this._byteFrequencyData);\n return this._byteFrequencyData;\n }\n\n /** @internal */\n public getFloatFrequencyData(): Float32Array {\n if (!this._floatFrequencyData || this._floatFrequencyData.length === 0) {\n this._floatFrequencyData = new Float32Array(this._analyzerNode.frequencyBinCount);\n }\n this._analyzerNode.getFloatFrequencyData(this._floatFrequencyData);\n return this._floatFrequencyData;\n }\n\n private _clearArrays(): void {\n this._byteFrequencyData?.set(_GetEmptyByteFrequencyData());\n this._floatFrequencyData?.set(_GetEmptyFloatFrequencyData());\n }\n}\n"]}
@@ -57,11 +57,11 @@ VertexBuffer.prototype._alignBuffer = function () {
57
57
  const sourceDataAsFloat = new Float32Array(data);
58
58
  sourceData = new DataView(sourceDataAsFloat.buffer, sourceDataAsFloat.byteOffset, sourceDataAsFloat.byteLength);
59
59
  }
60
- else if (data instanceof ArrayBuffer) {
61
- sourceData = new DataView(data, 0, data.byteLength);
60
+ else if (ArrayBuffer.isView(data)) {
61
+ sourceData = new DataView(data.buffer, data.byteOffset, data.byteLength);
62
62
  }
63
63
  else {
64
- sourceData = new DataView(data.buffer, data.byteOffset, data.byteLength);
64
+ sourceData = new DataView(data, 0, data.byteLength);
65
65
  }
66
66
  let alignedData;
67
67
  if (this.type === VertexBuffer.BYTE) {
@@ -1 +1 @@
1
- {"version":3,"file":"buffer.align.js","sourceRoot":"","sources":["../../../../dev/core/src/Buffers/buffer.align.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,MAAM,EAAE,YAAY,EAAE,MAAM,UAAU,CAAC;AAChD,OAAO,EAAE,iBAAiB,EAAE,MAAM,eAAe,CAAC;AAElD,MAAM,cAAc,GAAG,CAAC,GAAG,EAAE;IACzB,MAAM,KAAK,GAAG,IAAI,UAAU,CAAC,CAAC,CAAC,CAAC;IAChC,MAAM,IAAI,GAAG,IAAI,WAAW,CAAC,KAAK,CAAC,MAAM,CAAC,CAAC;IAE3C,OAAO,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,GAAG,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC;AACxC,CAAC,CAAC,EAAE,CAAC;AA+BL,MAAM,CAAC,cAAc,CAAC,YAAY,CAAC,SAAS,EAAE,qBAAqB,EAAE;IACjE,GAAG,EAAE;QACD,OAAO,CAAC,IAAI,CAAC,cAAc,IAAI,IAAI,CAAC,cAAc,CAAC,UAAU,CAAC,IAAI,IAAI,CAAC,UAAU,CAAC;IACtF,CAAC;IACD,UAAU,EAAE,IAAI;IAChB,YAAY,EAAE,IAAI;CACrB,CAAC,CAAC;AAEH,MAAM,CAAC,cAAc,CAAC,YAAY,CAAC,SAAS,EAAE,qBAAqB,EAAE;IACjE,GAAG,EAAE;QACD,OAAO,IAAI,CAAC,cAAc,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,UAAU,CAAC;IACrD,CAAC;IACD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,IAAI,CAAC,cAAc,EAAE,EACrB,IAAI,EACJ,IAAI,CAAC,eAAe,EACpB,CAAC,IAAI,CAAC,MAAM,IAAI,cAAc,CAAC,GAAG,UAAU,CAC/C,CAAC;AACN,CAAC,CAAC","sourcesContent":["import type { Nullable } from \"core/types\";\r\nimport type { DataBuffer } from \"./dataBuffer\";\r\nimport { Buffer, VertexBuffer } from \"./buffer\";\r\nimport { GetTypeByteLength } from \"./bufferUtils\";\r\n\r\nconst IsLittleEndian = (() => {\r\n const array = new Uint8Array(4);\r\n const view = new Uint32Array(array.buffer);\r\n\r\n return !!((view[0] = 1) & array[0]);\r\n})();\r\n\r\ndeclare module \"./buffer\" {\r\n // eslint-disable-next-line @typescript-eslint/naming-convention\r\n export interface VertexBuffer {\r\n /**\r\n * Gets the effective byte stride, that is the byte stride of the buffer that is actually sent to the GPU.\r\n * It could be different from VertexBuffer.byteStride if a new buffer must be created under the hood because of the forceVertexBufferStrideAndOffsetMultiple4Bytes engine flag.\r\n */\r\n effectiveByteStride: number;\r\n\r\n /**\r\n * Gets the effective byte offset, that is the byte offset of the buffer that is actually sent to the GPU.\r\n * It could be different from VertexBuffer.byteOffset if a new buffer must be created under the hood because of the forceVertexBufferStrideAndOffsetMultiple4Bytes engine flag.\r\n */\r\n effectiveByteOffset: number;\r\n\r\n /**\r\n * Gets the effective buffer, that is the buffer that is actually sent to the GPU.\r\n * It could be different from VertexBuffer.getBuffer() if a new buffer must be created under the hood because of the forceVertexBufferStrideAndOffsetMultiple4Bytes engine flag.\r\n */\r\n effectiveBuffer: Nullable<DataBuffer>;\r\n\r\n /** @internal */\r\n _alignBuffer(): void;\r\n\r\n /** @internal */\r\n _alignedBuffer?: Buffer;\r\n }\r\n}\r\n\r\nObject.defineProperty(VertexBuffer.prototype, \"effectiveByteStride\", {\r\n get: function (this: VertexBuffer) {\r\n return (this._alignedBuffer && this._alignedBuffer.byteStride) || this.byteStride;\r\n },\r\n enumerable: true,\r\n configurable: true,\r\n});\r\n\r\nObject.defineProperty(VertexBuffer.prototype, \"effectiveByteOffset\", {\r\n get: function (this: VertexBuffer) {\r\n return this._alignedBuffer ? 0 : this.byteOffset;\r\n },\r\n enumerable: true,\r\n configurable: true,\r\n});\r\n\r\nObject.defineProperty(VertexBuffer.prototype, \"effectiveBuffer\", {\r\n get: function (this: VertexBuffer) {\r\n return (this._alignedBuffer && this._alignedBuffer.getBuffer()) || this._buffer.getBuffer();\r\n },\r\n enumerable: true,\r\n configurable: true,\r\n});\r\n\r\nVertexBuffer.prototype._rebuild = function (): void {\r\n this._buffer?._rebuild();\r\n this._alignedBuffer?._rebuild();\r\n};\r\n\r\nVertexBuffer.prototype.dispose = function (): void {\r\n if (this._ownsBuffer) {\r\n this._buffer.dispose();\r\n }\r\n\r\n this._alignedBuffer?.dispose();\r\n this._alignedBuffer = undefined;\r\n\r\n this._isDisposed = true;\r\n};\r\n\r\nVertexBuffer.prototype.getWrapperBuffer = function (): Buffer {\r\n return this._alignedBuffer || this._buffer;\r\n};\r\n\r\nVertexBuffer.prototype._alignBuffer = function (): void {\r\n const data = this._buffer.getData();\r\n\r\n if (!this.engine._features.forceVertexBufferStrideAndOffsetMultiple4Bytes || (this.byteStride % 4 === 0 && this.byteOffset % 4 === 0) || !data) {\r\n return;\r\n }\r\n\r\n const typeByteLength = GetTypeByteLength(this.type);\r\n const alignedByteStride = (this.byteStride + 3) & ~3;\r\n const alignedSize = alignedByteStride / typeByteLength;\r\n const totalVertices = this._maxVerticesCount;\r\n const totalByteLength = totalVertices * alignedByteStride;\r\n const totalLength = totalByteLength / typeByteLength;\r\n\r\n let sourceData: DataView;\r\n\r\n if (Array.isArray(data)) {\r\n const sourceDataAsFloat = new Float32Array(data);\r\n sourceData = new DataView(sourceDataAsFloat.buffer, sourceDataAsFloat.byteOffset, sourceDataAsFloat.byteLength);\r\n } else if (data instanceof ArrayBuffer) {\r\n sourceData = new DataView(data, 0, data.byteLength);\r\n } else {\r\n sourceData = new DataView(data.buffer, data.byteOffset, data.byteLength);\r\n }\r\n\r\n let alignedData: Int8Array | Uint8Array | Int16Array | Uint16Array | Int32Array | Uint32Array | Float32Array;\r\n\r\n if (this.type === VertexBuffer.BYTE) {\r\n alignedData = new Int8Array(totalLength);\r\n } else if (this.type === VertexBuffer.UNSIGNED_BYTE) {\r\n alignedData = new Uint8Array(totalLength);\r\n } else if (this.type === VertexBuffer.SHORT) {\r\n alignedData = new Int16Array(totalLength);\r\n } else if (this.type === VertexBuffer.UNSIGNED_SHORT) {\r\n alignedData = new Uint16Array(totalLength);\r\n } else if (this.type === VertexBuffer.INT) {\r\n alignedData = new Int32Array(totalLength);\r\n } else if (this.type === VertexBuffer.UNSIGNED_INT) {\r\n alignedData = new Uint32Array(totalLength);\r\n } else {\r\n alignedData = new Float32Array(totalLength);\r\n }\r\n\r\n const numComponents = this.getSize();\r\n\r\n let sourceOffset = this.byteOffset;\r\n\r\n for (let i = 0; i < totalVertices; ++i) {\r\n for (let j = 0; j < numComponents; ++j) {\r\n switch (this.type) {\r\n case VertexBuffer.BYTE:\r\n alignedData[i * alignedSize + j] = sourceData.getInt8(sourceOffset + j);\r\n break;\r\n case VertexBuffer.UNSIGNED_BYTE:\r\n alignedData[i * alignedSize + j] = sourceData.getUint8(sourceOffset + j);\r\n break;\r\n case VertexBuffer.SHORT:\r\n alignedData[i * alignedSize + j] = sourceData.getInt16(sourceOffset + j * 2, IsLittleEndian);\r\n break;\r\n case VertexBuffer.UNSIGNED_SHORT:\r\n alignedData[i * alignedSize + j] = sourceData.getUint16(sourceOffset + j * 2, IsLittleEndian);\r\n break;\r\n case VertexBuffer.INT:\r\n alignedData[i * alignedSize + j] = sourceData.getInt32(sourceOffset + j * 4, IsLittleEndian);\r\n break;\r\n case VertexBuffer.UNSIGNED_INT:\r\n alignedData[i * alignedSize + j] = sourceData.getUint32(sourceOffset + j * 4, IsLittleEndian);\r\n break;\r\n case VertexBuffer.FLOAT:\r\n alignedData[i * alignedSize + j] = sourceData.getFloat32(sourceOffset + j * 4, IsLittleEndian);\r\n break;\r\n }\r\n }\r\n sourceOffset += this.byteStride;\r\n }\r\n\r\n this._alignedBuffer?.dispose();\r\n this._alignedBuffer = new Buffer(\r\n this.engine,\r\n alignedData,\r\n false,\r\n alignedByteStride,\r\n false,\r\n this.getIsInstanced(),\r\n true,\r\n this.instanceDivisor,\r\n (this._label ?? \"VertexBuffer\") + \"_aligned\"\r\n );\r\n};\r\n"]}
1
+ {"version":3,"file":"buffer.align.js","sourceRoot":"","sources":["../../../../dev/core/src/Buffers/buffer.align.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,MAAM,EAAE,YAAY,EAAE,MAAM,UAAU,CAAC;AAChD,OAAO,EAAE,iBAAiB,EAAE,MAAM,eAAe,CAAC;AAElD,MAAM,cAAc,GAAG,CAAC,GAAG,EAAE;IACzB,MAAM,KAAK,GAAG,IAAI,UAAU,CAAC,CAAC,CAAC,CAAC;IAChC,MAAM,IAAI,GAAG,IAAI,WAAW,CAAC,KAAK,CAAC,MAAM,CAAC,CAAC;IAE3C,OAAO,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,GAAG,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC;AACxC,CAAC,CAAC,EAAE,CAAC;AA+BL,MAAM,CAAC,cAAc,CAAC,YAAY,CAAC,SAAS,EAAE,qBAAqB,EAAE;IACjE,GAAG,EAAE;QACD,OAAO,CAAC,IAAI,CAAC,cAAc,IAAI,IAAI,CAAC,cAAc,CAAC,UAAU,CAAC,IAAI,IAAI,CAAC,UAAU,CAAC;IACtF,CAAC;IACD,UAAU,EAAE,IAAI;IAChB,YAAY,EAAE,IAAI;CACrB,CAAC,CAAC;AAEH,MAAM,CAAC,cAAc,CAAC,YAAY,CAAC,SAAS,EAAE,qBAAqB,EAAE;IACjE,GAAG,EAAE;QACD,OAAO,IAAI,CAAC,cAAc,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,U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AAW,EACX,KAAK,EACL,iBAAiB,EACjB,KAAK,EACL,IAAI,CAAC,cAAc,EAAE,EACrB,IAAI,EACJ,IAAI,CAAC,eAAe,EACpB,CAAC,IAAI,CAAC,MAAM,IAAI,cAAc,CAAC,GAAG,UAAU,CAC/C,CAAC;AACN,CAAC,CAAC","sourcesContent":["import type { Nullable } from \"core/types\";\r\nimport type { DataBuffer } from \"./dataBuffer\";\r\nimport { Buffer, VertexBuffer } from \"./buffer\";\r\nimport { GetTypeByteLength } from \"./bufferUtils\";\r\n\r\nconst IsLittleEndian = (() => {\r\n const array = new Uint8Array(4);\r\n const view = new Uint32Array(array.buffer);\r\n\r\n return !!((view[0] = 1) & array[0]);\r\n})();\r\n\r\ndeclare module \"./buffer\" {\r\n // eslint-disable-next-line @typescript-eslint/naming-convention\r\n export interface VertexBuffer {\r\n /**\r\n * Gets the effective byte stride, that is the byte stride of the buffer that is actually sent to the GPU.\r\n * It could be different from VertexBuffer.byteStride if a new buffer must be created under the hood because of the forceVertexBufferStrideAndOffsetMultiple4Bytes engine flag.\r\n */\r\n effectiveByteStride: number;\r\n\r\n /**\r\n * Gets the effective byte offset, that is the byte offset of the buffer that is actually sent to the GPU.\r\n * It could be different from VertexBuffer.byteOffset if a new buffer must be created under the hood because of the forceVertexBufferStrideAndOffsetMultiple4Bytes engine flag.\r\n */\r\n effectiveByteOffset: number;\r\n\r\n /**\r\n * Gets the effective buffer, that is the buffer that is actually sent to the GPU.\r\n * It could be different from VertexBuffer.getBuffer() if a new buffer must be created under the hood because of the forceVertexBufferStrideAndOffsetMultiple4Bytes engine flag.\r\n */\r\n effectiveBuffer: Nullable<DataBuffer>;\r\n\r\n /** @internal */\r\n _alignBuffer(): void;\r\n\r\n /** @internal */\r\n _alignedBuffer?: Buffer;\r\n }\r\n}\r\n\r\nObject.defineProperty(VertexBuffer.prototype, \"effectiveByteStride\", {\r\n get: function (this: VertexBuffer) {\r\n return (this._alignedBuffer && this._alignedBuffer.byteStride) || this.byteStride;\r\n },\r\n enumerable: true,\r\n configurable: true,\r\n});\r\n\r\nObject.defineProperty(VertexBuffer.prototype, \"effectiveByteOffset\", {\r\n get: function (this: VertexBuffer) {\r\n return this._alignedBuffer ? 0 : this.byteOffset;\r\n },\r\n enumerable: true,\r\n configurable: true,\r\n});\r\n\r\nObject.defineProperty(VertexBuffer.prototype, \"effectiveBuffer\", {\r\n get: function (this: VertexBuffer) {\r\n return (this._alignedBuffer && this._alignedBuffer.getBuffer()) || this._buffer.getBuffer();\r\n },\r\n enumerable: true,\r\n configurable: true,\r\n});\r\n\r\nVertexBuffer.prototype._rebuild = function (): void {\r\n this._buffer?._rebuild();\r\n this._alignedBuffer?._rebuild();\r\n};\r\n\r\nVertexBuffer.prototype.dispose = function (): void {\r\n if (this._ownsBuffer) {\r\n this._buffer.dispose();\r\n }\r\n\r\n this._alignedBuffer?.dispose();\r\n this._alignedBuffer = undefined;\r\n\r\n this._isDisposed = true;\r\n};\r\n\r\nVertexBuffer.prototype.getWrapperBuffer = function (): Buffer {\r\n return this._alignedBuffer || this._buffer;\r\n};\r\n\r\nVertexBuffer.prototype._alignBuffer = function (): void {\r\n const data = this._buffer.getData();\r\n\r\n if (!this.engine._features.forceVertexBufferStrideAndOffsetMultiple4Bytes || (this.byteStride % 4 === 0 && this.byteOffset % 4 === 0) || !data) {\r\n return;\r\n }\r\n\r\n const typeByteLength = GetTypeByteLength(this.type);\r\n const alignedByteStride = (this.byteStride + 3) & ~3;\r\n const alignedSize = alignedByteStride / typeByteLength;\r\n const totalVertices = this._maxVerticesCount;\r\n const totalByteLength = totalVertices * alignedByteStride;\r\n const totalLength = totalByteLength / typeByteLength;\r\n\r\n let sourceData: DataView;\r\n\r\n if (Array.isArray(data)) {\r\n const sourceDataAsFloat = new Float32Array(data);\r\n sourceData = new DataView(sourceDataAsFloat.buffer, sourceDataAsFloat.byteOffset, sourceDataAsFloat.byteLength);\r\n } else if (ArrayBuffer.isView(data)) {\r\n sourceData = new DataView(data.buffer, data.byteOffset, data.byteLength);\r\n } else {\r\n sourceData = new DataView(data, 0, data.byteLength);\r\n }\r\n\r\n let alignedData: Int8Array | Uint8Array | Int16Array | Uint16Array | Int32Array | Uint32Array | Float32Array;\r\n\r\n if (this.type === VertexBuffer.BYTE) {\r\n alignedData = new Int8Array(totalLength);\r\n } else if (this.type === VertexBuffer.UNSIGNED_BYTE) {\r\n alignedData = new Uint8Array(totalLength);\r\n } else if (this.type === VertexBuffer.SHORT) {\r\n alignedData = new Int16Array(totalLength);\r\n } else if (this.type === VertexBuffer.UNSIGNED_SHORT) {\r\n alignedData = new Uint16Array(totalLength);\r\n } else if (this.type === VertexBuffer.INT) {\r\n alignedData = new Int32Array(totalLength);\r\n } else if (this.type === VertexBuffer.UNSIGNED_INT) {\r\n alignedData = new Uint32Array(totalLength);\r\n } else {\r\n alignedData = new Float32Array(totalLength);\r\n }\r\n\r\n const numComponents = this.getSize();\r\n\r\n let sourceOffset = this.byteOffset;\r\n\r\n for (let i = 0; i < totalVertices; ++i) {\r\n for (let j = 0; j < numComponents; ++j) {\r\n switch (this.type) {\r\n case VertexBuffer.BYTE:\r\n alignedData[i * alignedSize + j] = sourceData.getInt8(sourceOffset + j);\r\n break;\r\n case VertexBuffer.UNSIGNED_BYTE:\r\n alignedData[i * alignedSize + j] = sourceData.getUint8(sourceOffset + j);\r\n break;\r\n case VertexBuffer.SHORT:\r\n alignedData[i * alignedSize + j] = sourceData.getInt16(sourceOffset + j * 2, IsLittleEndian);\r\n break;\r\n case VertexBuffer.UNSIGNED_SHORT:\r\n alignedData[i * alignedSize + j] = sourceData.getUint16(sourceOffset + j * 2, IsLittleEndian);\r\n break;\r\n case VertexBuffer.INT:\r\n alignedData[i * alignedSize + j] = sourceData.getInt32(sourceOffset + j * 4, IsLittleEndian);\r\n break;\r\n case VertexBuffer.UNSIGNED_INT:\r\n alignedData[i * alignedSize + j] = sourceData.getUint32(sourceOffset + j * 4, IsLittleEndian);\r\n break;\r\n case VertexBuffer.FLOAT:\r\n alignedData[i * alignedSize + j] = sourceData.getFloat32(sourceOffset + j * 4, IsLittleEndian);\r\n break;\r\n }\r\n }\r\n sourceOffset += this.byteStride;\r\n }\r\n\r\n this._alignedBuffer?.dispose();\r\n this._alignedBuffer = new Buffer(\r\n this.engine,\r\n alignedData,\r\n false,\r\n alignedByteStride,\r\n false,\r\n this.getIsInstanced(),\r\n true,\r\n this.instanceDivisor,\r\n (this._label ?? \"VertexBuffer\") + \"_aligned\"\r\n );\r\n};\r\n"]}
@@ -82,3 +82,10 @@ export declare function AreIndices32Bits(indices: IndicesArray, count: number, s
82
82
  * @returns The aligned typed array
83
83
  */
84
84
  export declare function CreateAlignedTypedArray<T extends TypedArray>(type: TypedArrayConstructor<T>, elementCount: number): T;
85
+ /**
86
+ * Gets a BufferSource from an ArrayBufferView, ensuring that the returned ArrayBuffer is not a SharedArrayBuffer.
87
+ * If the input view's buffer is a SharedArrayBuffer, a new ArrayBuffer is created and the data is copied over.
88
+ * @param view The input ArrayBufferView
89
+ * @returns An ArrayBuffer containing the data from the view
90
+ */
91
+ export declare function GetBlobBufferSource(view: ArrayBufferView): BufferSource;
@@ -213,10 +213,7 @@ export function GetFloatData(data, size, type, byteOffset, byteStride, normalize
213
213
  const offset = byteOffset / 4;
214
214
  return data.slice(offset, offset + count);
215
215
  }
216
- else if (data instanceof ArrayBuffer) {
217
- return new Float32Array(data, byteOffset, count);
218
- }
219
- else {
216
+ else if (ArrayBuffer.isView(data)) {
220
217
  const offset = data.byteOffset + byteOffset;
221
218
  if ((offset & 3) !== 0) {
222
219
  Logger.Warn("Float array must be aligned to 4-bytes border");
@@ -229,6 +226,9 @@ export function GetFloatData(data, size, type, byteOffset, byteStride, normalize
229
226
  return new Float32Array(data.buffer, offset, count);
230
227
  }
231
228
  }
229
+ else {
230
+ return new Float32Array(data, byteOffset, count);
231
+ }
232
232
  }
233
233
  if (forceCopy) {
234
234
  return data.slice();
@@ -279,13 +279,13 @@ export function GetTypedArrayData(data, size, type, byteOffset, byteStride, tota
279
279
  // Handle ArrayBuffer and ArrayBufferView
280
280
  let buffer;
281
281
  let adjustedByteOffset = byteOffset;
282
- if (data instanceof ArrayBuffer) {
283
- buffer = data;
284
- }
285
- else {
282
+ if (ArrayBuffer.isView(data)) {
286
283
  buffer = data.buffer;
287
284
  adjustedByteOffset += data.byteOffset;
288
285
  }
286
+ else {
287
+ buffer = data;
288
+ }
289
289
  const lastByteOffset = adjustedByteOffset + (totalVertices - 1) * byteStride + size * typeByteLength;
290
290
  if (lastByteOffset > buffer.byteLength) {
291
291
  throw new Error("Last accessed byte is out of bounds.");
@@ -341,11 +341,7 @@ export function CopyFloatData(input, size, type, byteOffset, byteStride, normali
341
341
  const offset = byteOffset / 4;
342
342
  output.set(input, offset);
343
343
  }
344
- else if (input instanceof ArrayBuffer) {
345
- const floatData = new Float32Array(input, byteOffset, count);
346
- output.set(floatData);
347
- }
348
- else {
344
+ else if (ArrayBuffer.isView(input)) {
349
345
  const offset = input.byteOffset + byteOffset;
350
346
  if ((offset & 3) !== 0) {
351
347
  Logger.Warn("Float array must be aligned to 4-bytes border");
@@ -355,6 +351,10 @@ export function CopyFloatData(input, size, type, byteOffset, byteStride, normali
355
351
  const floatData = new Float32Array(input.buffer, offset, count);
356
352
  output.set(floatData);
357
353
  }
354
+ else {
355
+ const floatData = new Float32Array(input, byteOffset, count);
356
+ output.set(floatData);
357
+ }
358
358
  }
359
359
  /**
360
360
  * Utility function to determine if an IndicesArray is an Uint32Array. If indices is an Array, determines whether at least one index is 32 bits.
@@ -391,4 +391,22 @@ export function CreateAlignedTypedArray(type, elementCount) {
391
391
  const backingBuffer = new ArrayBuffer(byteSize);
392
392
  return new type(backingBuffer, 0, elementCount);
393
393
  }
394
+ /**
395
+ * Gets a BufferSource from an ArrayBufferView, ensuring that the returned ArrayBuffer is not a SharedArrayBuffer.
396
+ * If the input view's buffer is a SharedArrayBuffer, a new ArrayBuffer is created and the data is copied over.
397
+ * @param view The input ArrayBufferView
398
+ * @returns An ArrayBuffer containing the data from the view
399
+ */
400
+ export function GetBlobBufferSource(view) {
401
+ const buffer = view.buffer;
402
+ if (buffer instanceof ArrayBuffer) {
403
+ // Safely cast here because we know bytes is not a SharedArrayBuffer
404
+ return view;
405
+ }
406
+ // We are dealing with a SharedArrayBuffer, so we need to create a new ArrayBuffer and copy the data over
407
+ const unsharedBuffer = new ArrayBuffer(view.byteLength);
408
+ const copyView = new Uint8Array(unsharedBuffer);
409
+ copyView.set(new Uint8Array(buffer, view.byteOffset, view.byteLength));
410
+ return unsharedBuffer;
411
+ }
394
412
  //# sourceMappingURL=bufferUtils.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"bufferUtils.js","sourceRoot":"","sources":["../../../../dev/core/src/Buffers/bufferUtils.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,sBAAsB,CAAC;AACjD,OAAO,EAAE,MAAM,EAAE,MAAM,gBAAgB,CAAC;AAQxC,SAAS,aAAa,CAAC,QAAkB,EAAE,IAAY,EAAE,UAAkB,EAAE,UAAmB;IAC5F,QAAQ,IAAI,EAAE,CAAC;QACX,KAAK,SAAS,CAAC,IAAI,CAAC,CAAC,CAAC;YAClB,IAAI,KAAK,GAAG,QAAQ,CAAC,OAAO,CAAC,UAAU,CAAC,CAAC;YACzC,IAAI,UAAU,EAAE,CAAC;gBACb,KAAK,GAAG,IAAI,CAAC,GAAG,CAAC,KAAK,GAAG,GAAG,EAAE,CAAC,CAAC,CAAC,CAAC;YACtC,CAAC;YACD,OAAO,KAAK,CAAC;QACjB,CAAC;QACD,KAAK,SAAS,CAAC,aAAa,CAAC,CAAC,CAAC;YAC3B,IAAI,KAAK,GAAG,QAAQ,CAAC,QAAQ,CAAC,UAAU,CAAC,CAAC;YAC1C,IAAI,UAAU,EAAE,CAAC;gBACb,KAAK,GAAG,KAAK,GAAG,GAAG,CAAC;YACxB,CAAC;YACD,OAAO,KAAK,CAAC;QACjB,CAAC;QACD,KAAK,SAAS,CAAC,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AAI,CAAC,YAAY,CAAC,CAAC;IAClC,CAAC;IAED,QAAQ,GAAG,CAAC,QAAQ,GAAG,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC;IAE/B,MAAM,aAAa,GAAG,IAAI,WAAW,CAAC,QAAQ,CAAC,CAAC;IAEhD,OAAO,IAAI,IAAI,CAAC,aAAa,EAAE,CAAC,EAAE,YAAY,CAAC,CAAC;AACpD,CAAC","sourcesContent":["import { Constants } from \"../Engines/constants\";\r\nimport { Logger } from \"../Misc/logger\";\r\nimport type { DataArray, FloatArray, IndicesArray, TypedArray, TypedArrayConstructor } from \"../types\";\r\n\r\n/**\r\n * Union of TypedArrays that can be used for vertex data.\r\n */\r\nexport type VertexDataTypedArray = Exclude<TypedArray, Float64Array | BigInt64Array | BigUint64Array>;\r\n\r\nfunction GetFloatValue(dataView: DataView, type: number, byteOffset: number, normalized: boolean): number {\r\n switch (type) {\r\n case Constants.BYTE: {\r\n let value = dataView.getInt8(byteOffset);\r\n if (normalized) {\r\n value = Math.max(value / 127, -1);\r\n }\r\n return value;\r\n }\r\n case Constants.UNSIGNED_BYTE: {\r\n let value = dataView.getUint8(byteOffset);\r\n if (normalized) {\r\n value = value / 255;\r\n }\r\n return value;\r\n }\r\n case Constants.SHORT: {\r\n let value = dataView.getInt16(byteOffset, true);\r\n if (normalized) {\r\n value = Math.max(value / 32767, -1);\r\n }\r\n return value;\r\n }\r\n case Constants.UNSIGNED_SHORT: {\r\n let value = dataView.getUint16(byteOffset, true);\r\n if (normalized) {\r\n value = value / 65535;\r\n }\r\n return value;\r\n }\r\n case Constants.INT: {\r\n return dataView.getInt32(byteOffset, true);\r\n }\r\n case Constants.UNSIGNED_INT: {\r\n return dataView.getUint32(byteOffset, true);\r\n }\r\n case Constants.FLOAT: {\r\n return dataView.getFloat32(byteOffset, true);\r\n }\r\n default: {\r\n throw new Error(`Invalid component type ${type}`);\r\n }\r\n }\r\n}\r\n\r\nfunction SetFloatValue(dataView: DataView, type: number, byteOffset: number, normalized: boolean, value: number): void {\r\n switch (type) {\r\n case Constants.BYTE: {\r\n if (normalized) {\r\n value = Math.round(value * 127.0);\r\n }\r\n dataView.setInt8(byteOffset, value);\r\n break;\r\n }\r\n case Constants.UNSIGNED_BYTE: {\r\n if (normalized) {\r\n value = Math.round(value * 255);\r\n }\r\n dataView.setUint8(byteOffset, value);\r\n break;\r\n }\r\n case Constants.SHORT: {\r\n if (normalized) {\r\n value = Math.round(value * 32767);\r\n }\r\n dataView.setInt16(byteOffset, value, true);\r\n break;\r\n }\r\n case Constants.UNSIGNED_SHORT: {\r\n if (normalized) {\r\n value = Math.round(value * 65535);\r\n }\r\n dataView.setUint16(byteOffset, value, true);\r\n break;\r\n }\r\n case Constants.INT: {\r\n dataView.setInt32(byteOffset, value, true);\r\n break;\r\n }\r\n case Constants.UNSIGNED_INT: {\r\n dataView.setUint32(byteOffset, value, true);\r\n break;\r\n }\r\n case Constants.FLOAT: {\r\n dataView.setFloat32(byteOffset, value, true);\r\n break;\r\n }\r\n default: {\r\n throw new Error(`Invalid component type ${type}`);\r\n }\r\n }\r\n}\r\n\r\n/**\r\n * Gets the byte length of the given type.\r\n * @param type the type\r\n * @returns the number of bytes\r\n */\r\nexport function GetTypeByteLength(type: number): number {\r\n switch (type) {\r\n case Constants.BYTE:\r\n case Constants.UNSIGNED_BYTE:\r\n return 1;\r\n case Constants.SHORT:\r\n case Constants.UNSIGNED_SHORT:\r\n return 2;\r\n case Constants.INT:\r\n case Constants.UNSIGNED_INT:\r\n case Constants.FLOAT:\r\n return 4;\r\n default:\r\n throw new Error(`Invalid type '${type}'`);\r\n }\r\n}\r\n\r\n/**\r\n * Gets the appropriate TypedArray constructor for the given component type.\r\n * @param componentType the component type\r\n * @returns the constructor object\r\n */\r\nexport function GetTypedArrayConstructor(componentType: number): TypedArrayConstructor<VertexDataTypedArray> {\r\n switch (componentType) {\r\n case Constants.BYTE:\r\n return Int8Array;\r\n case Constants.UNSIGNED_BYTE:\r\n return Uint8Array;\r\n case Constants.SHORT:\r\n return Int16Array;\r\n case Constants.UNSIGNED_SHORT:\r\n return Uint16Array;\r\n case Constants.INT:\r\n return Int32Array;\r\n case Constants.UNSIGNED_INT:\r\n return Uint32Array;\r\n case Constants.FLOAT:\r\n return Float32Array;\r\n default:\r\n throw new Error(`Invalid component type '${componentType}'`);\r\n }\r\n}\r\n\r\n/**\r\n * Enumerates each value of the data array and calls the given callback.\r\n * @param data the data to enumerate\r\n * @param byteOffset the byte offset of the data\r\n * @param byteStride the byte stride of the data\r\n * @param componentCount the number of components per element\r\n * @param componentType the type of the component\r\n * @param count the number of values to enumerate\r\n * @param normalized whether the data is normalized\r\n * @param callback the callback function called for each group of component values\r\n */\r\nexport function EnumerateFloatValues(\r\n data: DataArray,\r\n byteOffset: number,\r\n byteStride: number,\r\n componentCount: number,\r\n componentType: number,\r\n count: number,\r\n normalized: boolean,\r\n callback: (values: number[], index: number) => void\r\n): void {\r\n const oldValues = new Array<number>(componentCount);\r\n const newValues = new Array<number>(componentCount);\r\n\r\n if (data instanceof Array) {\r\n let offset = byteOffset / 4;\r\n const stride = byteStride / 4;\r\n for (let index = 0; index < count; index += componentCount) {\r\n for (let componentIndex = 0; componentIndex < componentCount; componentIndex++) {\r\n oldValues[componentIndex] = newValues[componentIndex] = data[offset + componentIndex];\r\n }\r\n\r\n callback(newValues, index);\r\n\r\n for (let componentIndex = 0; componentIndex < componentCount; componentIndex++) {\r\n if (oldValues[componentIndex] !== newValues[componentIndex]) {\r\n data[offset + componentIndex] = newValues[componentIndex];\r\n }\r\n }\r\n\r\n offset += stride;\r\n }\r\n } else {\r\n const dataView = !ArrayBuffer.isView(data) ? new DataView(data) : new DataView(data.buffer, data.byteOffset, data.byteLength);\r\n const componentByteLength = GetTypeByteLength(componentType);\r\n for (let index = 0; index < count; index += componentCount) {\r\n for (let componentIndex = 0, componentByteOffset = byteOffset; componentIndex < componentCount; componentIndex++, componentByteOffset += componentByteLength) {\r\n oldValues[componentIndex] = newValues[componentIndex] = GetFloatValue(dataView, componentType, componentByteOffset, normalized);\r\n }\r\n\r\n callback(newValues, index);\r\n\r\n for (let componentIndex = 0, componentByteOffset = byteOffset; componentIndex < componentCount; componentIndex++, componentByteOffset += componentByteLength) {\r\n if (oldValues[componentIndex] !== newValues[componentIndex]) {\r\n SetFloatValue(dataView, componentType, componentByteOffset, normalized, newValues[componentIndex]);\r\n }\r\n }\r\n\r\n byteOffset += byteStride;\r\n }\r\n }\r\n}\r\n\r\n/**\r\n * Gets the given data array as a float array. Float data is constructed if the data array cannot be returned directly.\r\n * @param data the input data array\r\n * @param size the number of components\r\n * @param type the component type\r\n * @param byteOffset the byte offset of the data\r\n * @param byteStride the byte stride of the data\r\n * @param normalized whether the data is normalized\r\n * @param totalVertices number of vertices in the buffer to take into account\r\n * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it\r\n * @returns a float array containing vertex data\r\n */\r\nexport function GetFloatData(\r\n data: DataArray,\r\n size: number,\r\n type: number,\r\n byteOffset: number,\r\n byteStride: number,\r\n normalized: boolean,\r\n totalVertices: number,\r\n forceCopy?: boolean\r\n): FloatArray {\r\n const tightlyPackedByteStride = size * GetTypeByteLength(type);\r\n const count = totalVertices * size;\r\n\r\n if (type !== Constants.FLOAT || byteStride !== tightlyPackedByteStride) {\r\n const copy = new Float32Array(count);\r\n EnumerateFloatValues(data, byteOffset, byteStride, size, type, count, normalized, (values, index) => {\r\n for (let i = 0; i < size; i++) {\r\n copy[index + i] = values[i];\r\n }\r\n });\r\n return copy;\r\n }\r\n\r\n if (!(data instanceof Array || data instanceof Float32Array) || byteOffset !== 0 || data.length !== count) {\r\n if (data instanceof Array) {\r\n const offset = byteOffset / 4;\r\n return data.slice(offset, offset + count);\r\n } else if (data instanceof ArrayBuffer) {\r\n return new Float32Array(data, byteOffset, count);\r\n } else {\r\n const offset = data.byteOffset + byteOffset;\r\n if ((offset & 3) !== 0) {\r\n Logger.Warn(\"Float array must be aligned to 4-bytes border\");\r\n forceCopy = true;\r\n }\r\n\r\n if (forceCopy) {\r\n return new Float32Array(data.buffer.slice(offset, offset + count * Float32Array.BYTES_PER_ELEMENT));\r\n } else {\r\n return new Float32Array(data.buffer, offset, count);\r\n }\r\n }\r\n }\r\n\r\n if (forceCopy) {\r\n return data.slice();\r\n }\r\n\r\n return data;\r\n}\r\n\r\n/**\r\n * Gets the given data array as a typed array that matches the component type. If the data cannot be used directly, a copy is made to support the new typed array.\r\n * If the data is number[], byteOffset and byteStride must be a multiple of 4, as data will be treated like a list of floats.\r\n * @param data the input data array\r\n * @param size the number of components\r\n * @param type the component type\r\n * @param byteOffset the byte offset of the data\r\n * @param byteStride the byte stride of the data\r\n * @param totalVertices number of vertices in the buffer to take into account\r\n * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it\r\n * @returns a typed array containing vertex data\r\n */\r\nexport function GetTypedArrayData(\r\n data: DataArray,\r\n size: number,\r\n type: number,\r\n byteOffset: number,\r\n byteStride: number,\r\n totalVertices: number,\r\n forceCopy?: boolean\r\n): VertexDataTypedArray {\r\n const typeByteLength = GetTypeByteLength(type);\r\n const constructor = GetTypedArrayConstructor(type);\r\n const count = totalVertices * size;\r\n\r\n // Handle number[]\r\n if (Array.isArray(data)) {\r\n if ((byteOffset & 3) !== 0 || (byteStride & 3) !== 0) {\r\n throw new Error(\"byteOffset and byteStride must be a multiple of 4 for number[] data.\");\r\n }\r\n\r\n const offset = byteOffset / 4;\r\n const stride = byteStride / 4;\r\n\r\n const lastIndex = offset + (totalVertices - 1) * stride + size;\r\n if (lastIndex > data.length) {\r\n throw new Error(\"Last accessed index is out of bounds.\");\r\n }\r\n\r\n if (stride < size) {\r\n throw new Error(\"Data stride cannot be smaller than the component size.\");\r\n }\r\n if (stride !== size) {\r\n const copy = new constructor(count);\r\n EnumerateFloatValues(data, byteOffset, byteStride, size, type, count, false, (values, index) => {\r\n for (let i = 0; i < size; i++) {\r\n copy[index + i] = values[i];\r\n }\r\n });\r\n return copy;\r\n }\r\n\r\n return new constructor(data.slice(offset, offset + count));\r\n }\r\n\r\n // Handle ArrayBuffer and ArrayBufferView\r\n let buffer: ArrayBuffer;\r\n let adjustedByteOffset = byteOffset;\r\n\r\n if (data instanceof ArrayBuffer) {\r\n buffer = data;\r\n } else {\r\n buffer = data.buffer;\r\n adjustedByteOffset += data.byteOffset;\r\n }\r\n\r\n const lastByteOffset = adjustedByteOffset + (totalVertices - 1) * byteStride + size * typeByteLength;\r\n if (lastByteOffset > buffer.byteLength) {\r\n throw new Error(\"Last accessed byte is out of bounds.\");\r\n }\r\n\r\n const tightlyPackedByteStride = size * typeByteLength;\r\n if (byteStride < tightlyPackedByteStride) {\r\n throw new Error(\"Byte stride cannot be smaller than the component's byte size.\");\r\n }\r\n if (byteStride !== tightlyPackedByteStride) {\r\n const copy = new constructor(count);\r\n EnumerateFloatValues(buffer, adjustedByteOffset, byteStride, size, type, count, false, (values, index) => {\r\n for (let i = 0; i < size; i++) {\r\n copy[index + i] = values[i];\r\n }\r\n });\r\n return copy;\r\n }\r\n\r\n if (typeByteLength !== 1 && (adjustedByteOffset & (typeByteLength - 1)) !== 0) {\r\n Logger.Warn(\"Array must be aligned to border of element size. Data will be copied.\");\r\n forceCopy = true;\r\n }\r\n\r\n if (forceCopy) {\r\n return new constructor(buffer.slice(adjustedByteOffset, adjustedByteOffset + count * typeByteLength));\r\n }\r\n\r\n return new constructor(buffer, adjustedByteOffset, count);\r\n}\r\n\r\n/**\r\n * Copies the given data array to the given float array.\r\n * @param input the input data array\r\n * @param size the number of components\r\n * @param type the component type\r\n * @param byteOffset the byte offset of the data\r\n * @param byteStride the byte stride of the data\r\n * @param normalized whether the data is normalized\r\n * @param totalVertices number of vertices in the buffer to take into account\r\n * @param output the output float array\r\n */\r\nexport function CopyFloatData(\r\n input: DataArray,\r\n size: number,\r\n type: number,\r\n byteOffset: number,\r\n byteStride: number,\r\n normalized: boolean,\r\n totalVertices: number,\r\n output: Float32Array\r\n): void {\r\n const tightlyPackedByteStride = size * GetTypeByteLength(type);\r\n const count = totalVertices * size;\r\n\r\n if (output.length !== count) {\r\n throw new Error(\"Output length is not valid\");\r\n }\r\n\r\n if (type !== Constants.FLOAT || byteStride !== tightlyPackedByteStride) {\r\n EnumerateFloatValues(input, byteOffset, byteStride, size, type, count, normalized, (values, index) => {\r\n for (let i = 0; i < size; i++) {\r\n output[index + i] = values[i];\r\n }\r\n });\r\n return;\r\n }\r\n\r\n if (input instanceof Array) {\r\n const offset = byteOffset / 4;\r\n output.set(input, offset);\r\n } else if (input instanceof ArrayBuffer) {\r\n const floatData = new Float32Array(input, byteOffset, count);\r\n output.set(floatData);\r\n } else {\r\n const offset = input.byteOffset + byteOffset;\r\n if ((offset & 3) !== 0) {\r\n Logger.Warn(\"Float array must be aligned to 4-bytes border\");\r\n output.set(new Float32Array(input.buffer.slice(offset, offset + count * Float32Array.BYTES_PER_ELEMENT)));\r\n return;\r\n }\r\n\r\n const floatData = new Float32Array(input.buffer, offset, count);\r\n output.set(floatData);\r\n }\r\n}\r\n\r\n/**\r\n * Utility function to determine if an IndicesArray is an Uint32Array. If indices is an Array, determines whether at least one index is 32 bits.\r\n * @param indices The IndicesArray to check.\r\n * @param count The number of indices. Only used if indices is an Array.\r\n * @param start The offset to start at (default: 0). Only used if indices is an Array.\r\n * @param offset The offset to substract from the indices before testing (default: 0). Only used if indices is an Array.\r\n * @returns True if the indices use 32 bits\r\n */\r\nexport function AreIndices32Bits(indices: IndicesArray, count: number, start = 0, offset = 0): boolean {\r\n if (Array.isArray(indices)) {\r\n for (let index = 0; index < count; index++) {\r\n if (indices[start + index] - offset > 65535) {\r\n return true;\r\n }\r\n }\r\n return false;\r\n }\r\n\r\n return indices.BYTES_PER_ELEMENT === 4;\r\n}\r\n\r\n/**\r\n * Creates a typed array suitable for GPU buffer operations, as some engines require CPU buffer sizes to be aligned to specific boundaries (e.g., 4 bytes).\r\n * The use of non-aligned arrays still works but may result in a performance penalty.\r\n * @param type The type of the array. For instance, Float32Array or Uint8Array\r\n * @param elementCount The number of elements to store in the array\r\n * @returns The aligned typed array\r\n */\r\nexport function CreateAlignedTypedArray<T extends TypedArray>(type: TypedArrayConstructor<T>, elementCount: number): T {\r\n let byteSize = elementCount * type.BYTES_PER_ELEMENT;\r\n\r\n if ((byteSize & 3) === 0) {\r\n return new type(elementCount);\r\n }\r\n\r\n byteSize = (byteSize + 3) & ~3;\r\n\r\n const backingBuffer = new ArrayBuffer(byteSize);\r\n\r\n return new type(backingBuffer, 0, elementCount);\r\n}\r\n"]}
1
+ {"version":3,"file":"bufferUtils.js","sourceRoot":"","sources":["../../../../dev/core/src/Buffers/bufferUtils.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,sBAAsB,CAAC;AACjD,OAAO,EAAE,MAAM,EAAE,MAAM,gBAAgB,CAAC;AAQxC,SAAS,aAAa,CAAC,QAAkB,EAAE,IAAY,EAAE,UAAkB,EAAE,UAAmB;IAC5F,QAAQ,IAAI,EAAE,CAAC;QACX,KAAK,SAAS,CAAC,IAAI,CAAC,CAAC,CAAC;YAClB,IAAI,KAAK,GAAG,QAAQ,CAAC,OAAO,CAAC,UAAU,CAAC,CAAC;YACzC,IAAI,UAAU,EAAE,CAAC;gBACb,KAAK,GAAG,IAAI,CAAC,GAAG,CAAC,KAAK,GAAG,GAAG,EAAE,CAAC,CAAC,CAAC,CAAC;YACtC,CAAC;YACD,OAAO,KAAK,CAAC;QACjB,CAAC;QACD,KAAK,SAAS,CAAC,aAAa,CAAC,CAAC,CAAC;YAC3B,IAAI,KAAK,GAAG,QAAQ,CAAC,QAAQ,CAAC,UAAU,CAAC,CAAC;YAC1C,IAAI,UAAU,EAAE,CAAC;gBACb,KAAK,GAAG,KAAK,GAAG,GAAG,CAAC;YACxB,CAAC;YACD,OAAO,KAAK,CAAC;QACjB,CAAC;QACD,KAAK,SAAS,CAAC,KAAK,CAAC,CAAC,CAAC;YACnB,IAAI,KAAK,GAAG,QAAQ,CAAC,QAAQ,CAAC,UAAU,EAA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IAClC,CAAC;IAED,QAAQ,GAAG,CAAC,QAAQ,GAAG,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC;IAE/B,MAAM,aAAa,GAAG,IAAI,WAAW,CAAC,QAAQ,CAAC,CAAC;IAEhD,OAAO,IAAI,IAAI,CAAC,aAAa,EAAE,CAAC,EAAE,YAAY,CAAC,CAAC;AACpD,CAAC;AAED;;;;;GAKG;AACH,MAAM,UAAU,mBAAmB,CAAC,IAAqB;IACrD,MAAM,MAAM,GAAG,IAAI,CAAC,MAAM,CAAC;IAC3B,IAAI,MAAM,YAAY,WAAW,EAAE,CAAC;QAChC,oEAAoE;QACpE,OAAO,IAAoC,CAAC;IAChD,CAAC;IAED,yGAAyG;IACzG,MAAM,cAAc,GAAG,IAAI,WAAW,CAAC,IAAI,CAAC,UAAU,CAAC,CAAC;IACxD,MAAM,QAAQ,GAAG,IAAI,UAAU,CAAC,cAAc,CAAC,CAAC;IAChD,QAAQ,CAAC,GAAG,CAAC,IAAI,UAAU,CAAC,MAAM,EAAE,IAAI,CAAC,UAAU,EAAE,IAAI,CAAC,UAAU,CAAC,CAAC,CAAC;IACvE,OAAO,cAAc,CAAC;AAC1B,CAAC","sourcesContent":["import { Constants } from \"../Engines/constants\";\r\nimport { Logger } from \"../Misc/logger\";\r\nimport type { DataArray, FloatArray, IndicesArray, TypedArray, TypedArrayConstructor } from \"../types\";\r\n\r\n/**\r\n * Union of TypedArrays that can be used for vertex data.\r\n */\r\nexport type VertexDataTypedArray = Exclude<TypedArray, Float64Array | BigInt64Array | BigUint64Array>;\r\n\r\nfunction GetFloatValue(dataView: DataView, type: number, byteOffset: number, normalized: boolean): number {\r\n switch (type) {\r\n case Constants.BYTE: {\r\n let value = dataView.getInt8(byteOffset);\r\n if (normalized) {\r\n value = Math.max(value / 127, -1);\r\n }\r\n return value;\r\n }\r\n case Constants.UNSIGNED_BYTE: {\r\n let value = dataView.getUint8(byteOffset);\r\n if (normalized) {\r\n value = value / 255;\r\n }\r\n return value;\r\n }\r\n case Constants.SHORT: {\r\n let value = dataView.getInt16(byteOffset, true);\r\n if (normalized) {\r\n value = Math.max(value / 32767, -1);\r\n }\r\n return value;\r\n }\r\n case Constants.UNSIGNED_SHORT: {\r\n let value = dataView.getUint16(byteOffset, true);\r\n if (normalized) {\r\n value = value / 65535;\r\n }\r\n return value;\r\n }\r\n case Constants.INT: {\r\n return dataView.getInt32(byteOffset, true);\r\n }\r\n case Constants.UNSIGNED_INT: {\r\n return dataView.getUint32(byteOffset, true);\r\n }\r\n case Constants.FLOAT: {\r\n return dataView.getFloat32(byteOffset, true);\r\n }\r\n default: {\r\n throw new Error(`Invalid component type ${type}`);\r\n }\r\n }\r\n}\r\n\r\nfunction SetFloatValue(dataView: DataView, type: number, byteOffset: number, normalized: boolean, value: number): void {\r\n switch (type) {\r\n case Constants.BYTE: {\r\n if (normalized) {\r\n value = Math.round(value * 127.0);\r\n }\r\n dataView.setInt8(byteOffset, value);\r\n break;\r\n }\r\n case Constants.UNSIGNED_BYTE: {\r\n if (normalized) {\r\n value = Math.round(value * 255);\r\n }\r\n dataView.setUint8(byteOffset, value);\r\n break;\r\n }\r\n case Constants.SHORT: {\r\n if (normalized) {\r\n value = Math.round(value * 32767);\r\n }\r\n dataView.setInt16(byteOffset, value, true);\r\n break;\r\n }\r\n case Constants.UNSIGNED_SHORT: {\r\n if (normalized) {\r\n value = Math.round(value * 65535);\r\n }\r\n dataView.setUint16(byteOffset, value, true);\r\n break;\r\n }\r\n case Constants.INT: {\r\n dataView.setInt32(byteOffset, value, true);\r\n break;\r\n }\r\n case Constants.UNSIGNED_INT: {\r\n dataView.setUint32(byteOffset, value, true);\r\n break;\r\n }\r\n case Constants.FLOAT: {\r\n dataView.setFloat32(byteOffset, value, true);\r\n break;\r\n }\r\n default: {\r\n throw new Error(`Invalid component type ${type}`);\r\n }\r\n }\r\n}\r\n\r\n/**\r\n * Gets the byte length of the given type.\r\n * @param type the type\r\n * @returns the number of bytes\r\n */\r\nexport function GetTypeByteLength(type: number): number {\r\n switch (type) {\r\n case Constants.BYTE:\r\n case Constants.UNSIGNED_BYTE:\r\n return 1;\r\n case Constants.SHORT:\r\n case Constants.UNSIGNED_SHORT:\r\n return 2;\r\n case Constants.INT:\r\n case Constants.UNSIGNED_INT:\r\n case Constants.FLOAT:\r\n return 4;\r\n default:\r\n throw new Error(`Invalid type '${type}'`);\r\n }\r\n}\r\n\r\n/**\r\n * Gets the appropriate TypedArray constructor for the given component type.\r\n * @param componentType the component type\r\n * @returns the constructor object\r\n */\r\nexport function GetTypedArrayConstructor(componentType: number): TypedArrayConstructor<VertexDataTypedArray> {\r\n switch (componentType) {\r\n case Constants.BYTE:\r\n return Int8Array;\r\n case Constants.UNSIGNED_BYTE:\r\n return Uint8Array;\r\n case Constants.SHORT:\r\n return Int16Array;\r\n case Constants.UNSIGNED_SHORT:\r\n return Uint16Array;\r\n case Constants.INT:\r\n return Int32Array;\r\n case Constants.UNSIGNED_INT:\r\n return Uint32Array;\r\n case Constants.FLOAT:\r\n return Float32Array;\r\n default:\r\n throw new Error(`Invalid component type '${componentType}'`);\r\n }\r\n}\r\n\r\n/**\r\n * Enumerates each value of the data array and calls the given callback.\r\n * @param data the data to enumerate\r\n * @param byteOffset the byte offset of the data\r\n * @param byteStride the byte stride of the data\r\n * @param componentCount the number of components per element\r\n * @param componentType the type of the component\r\n * @param count the number of values to enumerate\r\n * @param normalized whether the data is normalized\r\n * @param callback the callback function called for each group of component values\r\n */\r\nexport function EnumerateFloatValues(\r\n data: DataArray,\r\n byteOffset: number,\r\n byteStride: number,\r\n componentCount: number,\r\n componentType: number,\r\n count: number,\r\n normalized: boolean,\r\n callback: (values: number[], index: number) => void\r\n): void {\r\n const oldValues = new Array<number>(componentCount);\r\n const newValues = new Array<number>(componentCount);\r\n\r\n if (data instanceof Array) {\r\n let offset = byteOffset / 4;\r\n const stride = byteStride / 4;\r\n for (let index = 0; index < count; index += componentCount) {\r\n for (let componentIndex = 0; componentIndex < componentCount; componentIndex++) {\r\n oldValues[componentIndex] = newValues[componentIndex] = data[offset + componentIndex];\r\n }\r\n\r\n callback(newValues, index);\r\n\r\n for (let componentIndex = 0; componentIndex < componentCount; componentIndex++) {\r\n if (oldValues[componentIndex] !== newValues[componentIndex]) {\r\n data[offset + componentIndex] = newValues[componentIndex];\r\n }\r\n }\r\n\r\n offset += stride;\r\n }\r\n } else {\r\n const dataView = !ArrayBuffer.isView(data) ? new DataView(data) : new DataView(data.buffer, data.byteOffset, data.byteLength);\r\n const componentByteLength = GetTypeByteLength(componentType);\r\n for (let index = 0; index < count; index += componentCount) {\r\n for (let componentIndex = 0, componentByteOffset = byteOffset; componentIndex < componentCount; componentIndex++, componentByteOffset += componentByteLength) {\r\n oldValues[componentIndex] = newValues[componentIndex] = GetFloatValue(dataView, componentType, componentByteOffset, normalized);\r\n }\r\n\r\n callback(newValues, index);\r\n\r\n for (let componentIndex = 0, componentByteOffset = byteOffset; componentIndex < componentCount; componentIndex++, componentByteOffset += componentByteLength) {\r\n if (oldValues[componentIndex] !== newValues[componentIndex]) {\r\n SetFloatValue(dataView, componentType, componentByteOffset, normalized, newValues[componentIndex]);\r\n }\r\n }\r\n\r\n byteOffset += byteStride;\r\n }\r\n }\r\n}\r\n\r\n/**\r\n * Gets the given data array as a float array. Float data is constructed if the data array cannot be returned directly.\r\n * @param data the input data array\r\n * @param size the number of components\r\n * @param type the component type\r\n * @param byteOffset the byte offset of the data\r\n * @param byteStride the byte stride of the data\r\n * @param normalized whether the data is normalized\r\n * @param totalVertices number of vertices in the buffer to take into account\r\n * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it\r\n * @returns a float array containing vertex data\r\n */\r\nexport function GetFloatData(\r\n data: DataArray,\r\n size: number,\r\n type: number,\r\n byteOffset: number,\r\n byteStride: number,\r\n normalized: boolean,\r\n totalVertices: number,\r\n forceCopy?: boolean\r\n): FloatArray {\r\n const tightlyPackedByteStride = size * GetTypeByteLength(type);\r\n const count = totalVertices * size;\r\n\r\n if (type !== Constants.FLOAT || byteStride !== tightlyPackedByteStride) {\r\n const copy = new Float32Array(count);\r\n EnumerateFloatValues(data, byteOffset, byteStride, size, type, count, normalized, (values, index) => {\r\n for (let i = 0; i < size; i++) {\r\n copy[index + i] = values[i];\r\n }\r\n });\r\n return copy;\r\n }\r\n\r\n if (!(data instanceof Array || data instanceof Float32Array) || byteOffset !== 0 || data.length !== count) {\r\n if (data instanceof Array) {\r\n const offset = byteOffset / 4;\r\n return data.slice(offset, offset + count);\r\n } else if (ArrayBuffer.isView(data)) {\r\n const offset = data.byteOffset + byteOffset;\r\n if ((offset & 3) !== 0) {\r\n Logger.Warn(\"Float array must be aligned to 4-bytes border\");\r\n forceCopy = true;\r\n }\r\n\r\n if (forceCopy) {\r\n return new Float32Array(data.buffer.slice(offset, offset + count * Float32Array.BYTES_PER_ELEMENT));\r\n } else {\r\n return new Float32Array(data.buffer, offset, count);\r\n }\r\n } else {\r\n return new Float32Array(data, byteOffset, count);\r\n }\r\n }\r\n\r\n if (forceCopy) {\r\n return data.slice();\r\n }\r\n\r\n return data;\r\n}\r\n\r\n/**\r\n * Gets the given data array as a typed array that matches the component type. If the data cannot be used directly, a copy is made to support the new typed array.\r\n * If the data is number[], byteOffset and byteStride must be a multiple of 4, as data will be treated like a list of floats.\r\n * @param data the input data array\r\n * @param size the number of components\r\n * @param type the component type\r\n * @param byteOffset the byte offset of the data\r\n * @param byteStride the byte stride of the data\r\n * @param totalVertices number of vertices in the buffer to take into account\r\n * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it\r\n * @returns a typed array containing vertex data\r\n */\r\nexport function GetTypedArrayData(\r\n data: DataArray,\r\n size: number,\r\n type: number,\r\n byteOffset: number,\r\n byteStride: number,\r\n totalVertices: number,\r\n forceCopy?: boolean\r\n): VertexDataTypedArray {\r\n const typeByteLength = GetTypeByteLength(type);\r\n const constructor = GetTypedArrayConstructor(type);\r\n const count = totalVertices * size;\r\n\r\n // Handle number[]\r\n if (Array.isArray(data)) {\r\n if ((byteOffset & 3) !== 0 || (byteStride & 3) !== 0) {\r\n throw new Error(\"byteOffset and byteStride must be a multiple of 4 for number[] data.\");\r\n }\r\n\r\n const offset = byteOffset / 4;\r\n const stride = byteStride / 4;\r\n\r\n const lastIndex = offset + (totalVertices - 1) * stride + size;\r\n if (lastIndex > data.length) {\r\n throw new Error(\"Last accessed index is out of bounds.\");\r\n }\r\n\r\n if (stride < size) {\r\n throw new Error(\"Data stride cannot be smaller than the component size.\");\r\n }\r\n if (stride !== size) {\r\n const copy = new constructor(count);\r\n EnumerateFloatValues(data, byteOffset, byteStride, size, type, count, false, (values, index) => {\r\n for (let i = 0; i < size; i++) {\r\n copy[index + i] = values[i];\r\n }\r\n });\r\n return copy;\r\n }\r\n\r\n return new constructor(data.slice(offset, offset + count));\r\n }\r\n\r\n // Handle ArrayBuffer and ArrayBufferView\r\n let buffer: ArrayBufferLike;\r\n let adjustedByteOffset = byteOffset;\r\n\r\n if (ArrayBuffer.isView(data)) {\r\n buffer = data.buffer;\r\n adjustedByteOffset += data.byteOffset;\r\n } else {\r\n buffer = data;\r\n }\r\n\r\n const lastByteOffset = adjustedByteOffset + (totalVertices - 1) * byteStride + size * typeByteLength;\r\n if (lastByteOffset > buffer.byteLength) {\r\n throw new Error(\"Last accessed byte is out of bounds.\");\r\n }\r\n\r\n const tightlyPackedByteStride = size * typeByteLength;\r\n if (byteStride < tightlyPackedByteStride) {\r\n throw new Error(\"Byte stride cannot be smaller than the component's byte size.\");\r\n }\r\n if (byteStride !== tightlyPackedByteStride) {\r\n const copy = new constructor(count);\r\n EnumerateFloatValues(buffer, adjustedByteOffset, byteStride, size, type, count, false, (values, index) => {\r\n for (let i = 0; i < size; i++) {\r\n copy[index + i] = values[i];\r\n }\r\n });\r\n return copy;\r\n }\r\n\r\n if (typeByteLength !== 1 && (adjustedByteOffset & (typeByteLength - 1)) !== 0) {\r\n Logger.Warn(\"Array must be aligned to border of element size. Data will be copied.\");\r\n forceCopy = true;\r\n }\r\n\r\n if (forceCopy) {\r\n return new constructor(buffer.slice(adjustedByteOffset, adjustedByteOffset + count * typeByteLength));\r\n }\r\n\r\n return new constructor(buffer, adjustedByteOffset, count);\r\n}\r\n\r\n/**\r\n * Copies the given data array to the given float array.\r\n * @param input the input data array\r\n * @param size the number of components\r\n * @param type the component type\r\n * @param byteOffset the byte offset of the data\r\n * @param byteStride the byte stride of the data\r\n * @param normalized whether the data is normalized\r\n * @param totalVertices number of vertices in the buffer to take into account\r\n * @param output the output float array\r\n */\r\nexport function CopyFloatData(\r\n input: DataArray,\r\n size: number,\r\n type: number,\r\n byteOffset: number,\r\n byteStride: number,\r\n normalized: boolean,\r\n totalVertices: number,\r\n output: Float32Array\r\n): void {\r\n const tightlyPackedByteStride = size * GetTypeByteLength(type);\r\n const count = totalVertices * size;\r\n\r\n if (output.length !== count) {\r\n throw new Error(\"Output length is not valid\");\r\n }\r\n\r\n if (type !== Constants.FLOAT || byteStride !== tightlyPackedByteStride) {\r\n EnumerateFloatValues(input, byteOffset, byteStride, size, type, count, normalized, (values, index) => {\r\n for (let i = 0; i < size; i++) {\r\n output[index + i] = values[i];\r\n }\r\n });\r\n return;\r\n }\r\n\r\n if (input instanceof Array) {\r\n const offset = byteOffset / 4;\r\n output.set(input, offset);\r\n } else if (ArrayBuffer.isView(input)) {\r\n const offset = input.byteOffset + byteOffset;\r\n if ((offset & 3) !== 0) {\r\n Logger.Warn(\"Float array must be aligned to 4-bytes border\");\r\n output.set(new Float32Array(input.buffer.slice(offset, offset + count * Float32Array.BYTES_PER_ELEMENT)));\r\n return;\r\n }\r\n\r\n const floatData = new Float32Array(input.buffer, offset, count);\r\n output.set(floatData);\r\n } else {\r\n const floatData = new Float32Array(input, byteOffset, count);\r\n output.set(floatData);\r\n }\r\n}\r\n\r\n/**\r\n * Utility function to determine if an IndicesArray is an Uint32Array. If indices is an Array, determines whether at least one index is 32 bits.\r\n * @param indices The IndicesArray to check.\r\n * @param count The number of indices. Only used if indices is an Array.\r\n * @param start The offset to start at (default: 0). Only used if indices is an Array.\r\n * @param offset The offset to substract from the indices before testing (default: 0). Only used if indices is an Array.\r\n * @returns True if the indices use 32 bits\r\n */\r\nexport function AreIndices32Bits(indices: IndicesArray, count: number, start = 0, offset = 0): boolean {\r\n if (Array.isArray(indices)) {\r\n for (let index = 0; index < count; index++) {\r\n if (indices[start + index] - offset > 65535) {\r\n return true;\r\n }\r\n }\r\n return false;\r\n }\r\n\r\n return indices.BYTES_PER_ELEMENT === 4;\r\n}\r\n\r\n/**\r\n * Creates a typed array suitable for GPU buffer operations, as some engines require CPU buffer sizes to be aligned to specific boundaries (e.g., 4 bytes).\r\n * The use of non-aligned arrays still works but may result in a performance penalty.\r\n * @param type The type of the array. For instance, Float32Array or Uint8Array\r\n * @param elementCount The number of elements to store in the array\r\n * @returns The aligned typed array\r\n */\r\nexport function CreateAlignedTypedArray<T extends TypedArray>(type: TypedArrayConstructor<T>, elementCount: number): T {\r\n let byteSize = elementCount * type.BYTES_PER_ELEMENT;\r\n\r\n if ((byteSize & 3) === 0) {\r\n return new type(elementCount);\r\n }\r\n\r\n byteSize = (byteSize + 3) & ~3;\r\n\r\n const backingBuffer = new ArrayBuffer(byteSize);\r\n\r\n return new type(backingBuffer, 0, elementCount);\r\n}\r\n\r\n/**\r\n * Gets a BufferSource from an ArrayBufferView, ensuring that the returned ArrayBuffer is not a SharedArrayBuffer.\r\n * If the input view's buffer is a SharedArrayBuffer, a new ArrayBuffer is created and the data is copied over.\r\n * @param view The input ArrayBufferView\r\n * @returns An ArrayBuffer containing the data from the view\r\n */\r\nexport function GetBlobBufferSource(view: ArrayBufferView): BufferSource {\r\n const buffer = view.buffer;\r\n if (buffer instanceof ArrayBuffer) {\r\n // Safely cast here because we know bytes is not a SharedArrayBuffer\r\n return view as ArrayBufferView<ArrayBuffer>;\r\n }\r\n\r\n // We are dealing with a SharedArrayBuffer, so we need to create a new ArrayBuffer and copy the data over\r\n const unsharedBuffer = new ArrayBuffer(view.byteLength);\r\n const copyView = new Uint8Array(unsharedBuffer);\r\n copyView.set(new Uint8Array(buffer, view.byteOffset, view.byteLength));\r\n return unsharedBuffer;\r\n}\r\n"]}
@@ -35,11 +35,11 @@ ThinEngine.prototype.updateDynamicVertexBuffer = function (vertexBuffer, data, b
35
35
  this._gl.bufferSubData(this._gl.ARRAY_BUFFER, byteOffset, new Float32Array(data).subarray(0, byteLength / 4));
36
36
  }
37
37
  else {
38
- if (data instanceof ArrayBuffer) {
39
- data = new Uint8Array(data, 0, byteLength);
38
+ if (ArrayBuffer.isView(data)) {
39
+ data = new Uint8Array(data.buffer, data.byteOffset, byteLength);
40
40
  }
41
41
  else {
42
- data = new Uint8Array(data.buffer, data.byteOffset, byteLength);
42
+ data = new Uint8Array(data, 0, byteLength);
43
43
  }
44
44
  this._gl.bufferSubData(this._gl.ARRAY_BUFFER, byteOffset, data);
45
45
  }
@@ -1 +1 @@
1
- {"version":3,"file":"engine.dynamicBuffer.js","sourceRoot":"","sources":["../../../../../dev/core/src/Engines/Extensions/engine.dynamicBuffer.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,0BAA0B,CAAC;AA0BtD,6DAA6D;AAC7D,UAAU,CAAC,SAAS,CAAC,wBAAwB,GAAG,UAA4B,WAAuB,EAAE,OAAqB,EAAE,SAAiB,CAAC;IAC1I,qBAAqB;IACrB,IAAI,CAAC,mBAAmB,CAAC,IAAI,CAAC,GAAG,CAAC,oBAAoB,CAAC,GAAG,IAAI,CAAC;IAC/D,IAAI,CAAC,eAAe,CAAC,WAAW,CAAC,CAAC;IAElC,IAAI,IAAqB,CAAC;IAC1B,IAAI,WAAW,CAAC,QAAQ,EAAE,CAAC;QACvB,sEAAsE;QACtE,IAAI,GAAG,OAAO,YAAY,WAAW,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,IAAI,WAAW,CAAC,OAAO,CAAC,CAAC;IAC/E,CAAC;SAAM,CAAC;QACJ,sEAAsE;QACtE,IAAI,GA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,CAAC,CAAC,EAAE,UAAU,GAAG,CAAC,CAAC,CAAC,CAAC;QAClH,CAAC;aAAM,CAAC;YACJ,IAAI,IAAI,YAAY,WAAW,EAAE,CAAC;gBAC9B,IAAI,GAAG,IAAI,UAAU,CAAC,IAAI,EAAE,CAAC,EAAE,UAAU,CAAC,CAAC;YAC/C,CAAC;iBAAM,CAAC;gBACJ,IAAI,GAAG,IAAI,UAAU,CAAC,IAAI,CAAC,MAAM,EAAE,IAAI,CAAC,UAAU,EAAE,UAAU,CAAC,CAAC;YACpE,CAAC;YAED,IAAI,CAAC,GAAG,CAAC,aAAa,CAAC,IAAI,CAAC,GAAG,CAAC,YAAY,EAAE,UAAU,EAAE,IAAI,CAAC,CAAC;QACpE,CAAC;IACL,CAAC;IAED,IAAI,CAAC,yBAAyB,EAAE,CAAC;AACrC,CAAC,CAAC","sourcesContent":["import { ThinEngine } from \"../../Engines/thinEngine\";\r\nimport type { DataBuffer } from \"../../Buffers/dataBuffer\";\r\nimport type { IndicesArray, DataArray } from \"../../types\";\r\n\r\ndeclare module \"../../Engines/abstractEngine\" {\r\n // eslint-disable-next-line @typescript-eslint/naming-convention\r\n export interface AbstractEngine {\r\n /**\r\n * Update a dynamic index buffer\r\n * @param indexBuffer defines the target index buffer\r\n * @param indices defines the data to update\r\n * @param offset defines the offset in the target index buffer where update should start\r\n */\r\n updateDynamicIndexBuffer(indexBuffer: DataBuffer, indices: IndicesArray, offset?: number): void;\r\n\r\n /**\r\n * Updates a dynamic vertex buffer.\r\n * @param vertexBuffer the vertex buffer to update\r\n * @param data the data used to update the vertex buffer\r\n * @param byteOffset the byte offset of the data\r\n * @param byteLength the byte length of the data\r\n */\r\n updateDynamicVertexBuffer(vertexBuffer: DataBuffer, data: DataArray, byteOffset?: number, byteLength?: number): void;\r\n }\r\n}\r\n\r\n// eslint-disable-next-line @typescript-eslint/no-unused-vars\r\nThinEngine.prototype.updateDynamicIndexBuffer = function (this: ThinEngine, indexBuffer: DataBuffer, indices: IndicesArray, offset: number = 0): void {\r\n // Force cache update\r\n this._currentBoundBuffer[this._gl.ELEMENT_ARRAY_BUFFER] = null;\r\n this.bindIndexBuffer(indexBuffer);\r\n\r\n let view: ArrayBufferView;\r\n if (indexBuffer.is32Bits) {\r\n // anything else than Uint32Array needs to be converted to Uint32Array\r\n view = indices instanceof Uint32Array ? indices : new Uint32Array(indices);\r\n } else {\r\n // anything else than Uint16Array needs to be converted to Uint16Array\r\n view = indices instanceof Uint16Array ? indices : new Uint16Array(indices);\r\n }\r\n\r\n this._gl.bufferData(this._gl.ELEMENT_ARRAY_BUFFER, view, this._gl.DYNAMIC_DRAW);\r\n\r\n this._resetIndexBufferBinding();\r\n};\r\n\r\nThinEngine.prototype.updateDynamicVertexBuffer = function (this: ThinEngine, vertexBuffer: DataBuffer, data: DataArray, byteOffset?: number, byteLength?: number): void {\r\n this.bindArrayBuffer(vertexBuffer);\r\n\r\n if (byteOffset === undefined) {\r\n byteOffset = 0;\r\n }\r\n\r\n const dataLength = (data as ArrayBuffer).byteLength || (data as number[]).length;\r\n\r\n if (byteLength === undefined || (byteLength >= dataLength && byteOffset === 0)) {\r\n if (data instanceof Array) {\r\n this._gl.bufferSubData(this._gl.ARRAY_BUFFER, byteOffset, new Float32Array(data));\r\n } else {\r\n this._gl.bufferSubData(this._gl.ARRAY_BUFFER, byteOffset, data);\r\n }\r\n } else {\r\n if (data instanceof Array) {\r\n this._gl.bufferSubData(this._gl.ARRAY_BUFFER, byteOffset, new Float32Array(data).subarray(0, byteLength / 4));\r\n } else {\r\n if (data instanceof ArrayBuffer) {\r\n data = new Uint8Array(data, 0, byteLength);\r\n } else {\r\n data = new Uint8Array(data.buffer, data.byteOffset, byteLength);\r\n }\r\n\r\n this._gl.bufferSubData(this._gl.ARRAY_BUFFER, byteOffset, data);\r\n }\r\n }\r\n\r\n this._resetVertexBufferBinding();\r\n};\r\n"]}
1
+ {"version":3,"file":"engine.dynamicBuffer.js","sourceRoot":"","sources":["../../../../../dev/core/src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uffer\";\r\nimport type { IndicesArray, DataArray } from \"../../types\";\r\n\r\ndeclare module \"../../Engines/abstractEngine\" {\r\n // eslint-disable-next-line @typescript-eslint/naming-convention\r\n export interface AbstractEngine {\r\n /**\r\n * Update a dynamic index buffer\r\n * @param indexBuffer defines the target index buffer\r\n * @param indices defines the data to update\r\n * @param offset defines the offset in the target index buffer where update should start\r\n */\r\n updateDynamicIndexBuffer(indexBuffer: DataBuffer, indices: IndicesArray, offset?: number): void;\r\n\r\n /**\r\n * Updates a dynamic vertex buffer.\r\n * @param vertexBuffer the vertex buffer to update\r\n * @param data the data used to update the vertex buffer\r\n * @param byteOffset the byte offset of the data\r\n * @param byteLength the byte length of the data\r\n */\r\n updateDynamicVertexBuffer(vertexBuffer: DataBuffer, data: DataArray, byteOffset?: number, byteLength?: number): void;\r\n }\r\n}\r\n\r\n// eslint-disable-next-line @typescript-eslint/no-unused-vars\r\nThinEngine.prototype.updateDynamicIndexBuffer = function (this: ThinEngine, indexBuffer: DataBuffer, indices: IndicesArray, offset: number = 0): void {\r\n // Force cache update\r\n this._currentBoundBuffer[this._gl.ELEMENT_ARRAY_BUFFER] = null;\r\n this.bindIndexBuffer(indexBuffer);\r\n\r\n let view: ArrayBufferView;\r\n if (indexBuffer.is32Bits) {\r\n // anything else than Uint32Array needs to be converted to Uint32Array\r\n view = indices instanceof Uint32Array ? indices : new Uint32Array(indices);\r\n } else {\r\n // anything else than Uint16Array needs to be converted to Uint16Array\r\n view = indices instanceof Uint16Array ? indices : new Uint16Array(indices);\r\n }\r\n\r\n this._gl.bufferData(this._gl.ELEMENT_ARRAY_BUFFER, view, this._gl.DYNAMIC_DRAW);\r\n\r\n this._resetIndexBufferBinding();\r\n};\r\n\r\nThinEngine.prototype.updateDynamicVertexBuffer = function (this: ThinEngine, vertexBuffer: DataBuffer, data: DataArray, byteOffset?: number, byteLength?: number): void {\r\n this.bindArrayBuffer(vertexBuffer);\r\n\r\n if (byteOffset === undefined) {\r\n byteOffset = 0;\r\n }\r\n\r\n const dataLength = (data as ArrayBuffer).byteLength || (data as number[]).length;\r\n\r\n if (byteLength === undefined || (byteLength >= dataLength && byteOffset === 0)) {\r\n if (data instanceof Array) {\r\n this._gl.bufferSubData(this._gl.ARRAY_BUFFER, byteOffset, new Float32Array(data));\r\n } else {\r\n this._gl.bufferSubData(this._gl.ARRAY_BUFFER, byteOffset, data);\r\n }\r\n } else {\r\n if (data instanceof Array) {\r\n this._gl.bufferSubData(this._gl.ARRAY_BUFFER, byteOffset, new Float32Array(data).subarray(0, byteLength / 4));\r\n } else {\r\n if (ArrayBuffer.isView(data)) {\r\n data = new Uint8Array(data.buffer, data.byteOffset, byteLength);\r\n } else {\r\n data = new Uint8Array(data, 0, byteLength);\r\n }\r\n\r\n this._gl.bufferSubData(this._gl.ARRAY_BUFFER, byteOffset, data);\r\n }\r\n }\r\n\r\n this._resetVertexBufferBinding();\r\n};\r\n"]}
@@ -1,6 +1,6 @@
1
1
  import type { DeepImmutable, FloatArray } from "../../types.js";
2
2
  /** @internal */
3
- export type NativeData = Uint32Array;
3
+ export type NativeData = Uint32Array<ArrayBuffer>;
4
4
  /** @internal */
5
5
  export declare class NativeDataStream {
6
6
  private readonly _uint32s;
@@ -1 +1 @@
1
- {"version":3,"file":"nativeDataStream.js","sourceRoot":"","sources":["../../../../../dev/core/src/Engines/Native/nativeDataStream.ts"],"names":[],"mappings":"AASA,gBAAgB;AAChB,MAAM,OAAO,gBAAgB;IAYzB;QACI,MAAM,MAAM,GAAG,IAAI,WAAW,CAAC,gBAAgB,CAAC,mBAAmB,CAAC,CAAC;QACrE,IAAI,CAAC,QAAQ,GAAG,IAAI,WAAW,CAAC,MAAM,CAAC,CAAC;QACxC,IAAI,CAAC,OAAO,GAAG,IAAI,UAAU,CAAC,MAAM,CAAC,CAAC;QACtC,IAAI,CAAC,SAAS,GAAG,IAAI,YAAY,CAAC,MAAM,CAAC,CAAC;QAE1C,IAAI,CAAC,OAAO,GAAG,gBAAgB,CAAC,mBAA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AQ,CAAC,MAAM,EAAE,IAAI,CAAC,SAAS,CAAC,CAAC;QACzE,IAAI,CAAC,SAAS,GAAG,CAAC,CAAC;IACvB,CAAC;;AAzGD,yBAAyB;AACzB,gEAAgE;AACxC,oCAAmB,GAAG,KAAK,CAAC","sourcesContent":["import type { DeepImmutable, FloatArray } from \"../../types\";\r\nimport type { INative, INativeDataStream } from \"./nativeInterfaces\";\r\n\r\n// eslint-disable-next-line @typescript-eslint/naming-convention\r\ndeclare const _native: INative;\r\n\r\n/** @internal */\r\nexport type NativeData = Uint32Array;\r\n\r\n/** @internal */\r\nexport class NativeDataStream {\r\n private readonly _uint32s: Uint32Array;\r\n private readonly _int32s: Int32Array;\r\n private readonly _float32s: Float32Array;\r\n private readonly _length: number;\r\n private _position: number;\r\n private readonly _nativeDataStream: INativeDataStream;\r\n\r\n // Must be multiple of 4!\r\n // eslint-disable-next-line @typescript-eslint/naming-convention\r\n private static readonly DEFAULT_BUFFER_SIZE = 65536;\r\n\r\n constructor() {\r\n const buffer = new ArrayBuffer(NativeDataStream.DEFAULT_BUFFER_SIZE);\r\n this._uint32s = new Uint32Array(buffer);\r\n this._int32s = new Int32Array(buffer);\r\n this._float32s = new Float32Array(buffer);\r\n\r\n this._length = NativeDataStream.DEFAULT_BUFFER_SIZE / 4;\r\n this._position = 0;\r\n\r\n this._nativeDataStream = new _native.NativeDataStream(() => {\r\n this._flush();\r\n });\r\n }\r\n\r\n /**\r\n * Writes a uint32 to the stream\r\n * @param value the value to write\r\n */\r\n public writeUint32(value: number): void {\r\n this._flushIfNecessary(1);\r\n this._uint32s[this._position++] = value;\r\n }\r\n\r\n /**\r\n * Writes an int32 to the stream\r\n * @param value the value to write\r\n */\r\n public writeInt32(value: number): void {\r\n this._flushIfNecessary(1);\r\n this._int32s[this._position++] = value;\r\n }\r\n\r\n /**\r\n * Writes a float32 to the stream\r\n * @param value the value to write\r\n */\r\n public writeFloat32(value: number): void {\r\n this._flushIfNecessary(1);\r\n this._float32s[this._position++] = value;\r\n }\r\n\r\n /**\r\n * Writes a uint32 array to the stream\r\n * @param values the values to write\r\n */\r\n public writeUint32Array(values: Uint32Array): void {\r\n this._flushIfNecessary(1 + values.length);\r\n this._uint32s[this._position++] = values.length;\r\n this._uint32s.set(values, this._position);\r\n this._position += values.length;\r\n }\r\n\r\n /**\r\n * Writes an int32 array to the stream\r\n * @param values the values to write\r\n */\r\n public writeInt32Array(values: Int32Array): void {\r\n this._flushIfNecessary(1 + values.length);\r\n this._uint32s[this._position++] = values.length;\r\n this._int32s.set(values, this._position);\r\n this._position += values.length;\r\n }\r\n\r\n /**\r\n * Writes a float32 array to the stream\r\n * @param values the values to write\r\n */\r\n public writeFloat32Array(values: DeepImmutable<FloatArray>): void {\r\n this._flushIfNecessary(1 + values.length);\r\n this._uint32s[this._position++] = values.length;\r\n this._float32s.set(values, this._position);\r\n this._position += values.length;\r\n }\r\n\r\n /**\r\n * Writes native data to the stream\r\n * @param handle the handle to the native data\r\n */\r\n public writeNativeData(handle: NativeData) {\r\n this._flushIfNecessary(handle.length);\r\n this._uint32s.set(handle, this._position);\r\n this._position += handle.length;\r\n }\r\n\r\n /**\r\n * Writes a boolean to the stream\r\n * @param value the value to write\r\n */\r\n public writeBoolean(value: boolean) {\r\n this.writeUint32(value ? 1 : 0);\r\n }\r\n\r\n private _flushIfNecessary(required: number): void {\r\n if (this._position + required > this._length) {\r\n this._flush();\r\n }\r\n }\r\n\r\n private _flush(): void {\r\n this._nativeDataStream.writeBuffer(this._uint32s.buffer, this._position);\r\n this._position = 0;\r\n }\r\n}\r\n"]}
1
+ {"version":3,"file":"nativeDataStream.js","sourceRoot":"","sources":["../../../../../dev/core/src/Engines/Native/nativeDataStream.ts"],"names":[],"mappings":"AASA,gBAAgB;AAChB,MAAM,OAAO,gBAAgB;IAYzB;QACI,MAAM,MAAM,GAAG,IAAI,WAAW,CAAC,gBAAgB,CAAC,mBAAmB,CAAC,CAAC;QACrE,IAAI,CAAC,QAAQ,GAAG,IAAI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AgB;QACtC,IAAI,IAAI,CAAC,SAAS,GAAG,QAAQ,GAAG,IAAI,CAAC,OAAO,EAAE,CAAC;YAC3C,IAAI,CAAC,MAAM,EAAE,CAAC;QAClB,CAAC;IACL,CAAC;IAEO,MAAM;QACV,IAAI,CAAC,iBAAiB,CAAC,WAAW,CAAC,IAAI,CAAC,QAAQ,CAAC,MAAM,EAAE,IAAI,CAAC,SAAS,CAAC,CAAC;QACzE,IAAI,CAAC,SAAS,GAAG,CAAC,CAAC;IACvB,CAAC;;AAzGD,yBAAyB;AACzB,gEAAgE;AACxC,oCAAmB,GAAG,KAAK,CAAC","sourcesContent":["import type { DeepImmutable, FloatArray } from \"../../types\";\r\nimport type { INative, INativeDataStream } from \"./nativeInterfaces\";\r\n\r\n// eslint-disable-next-line @typescript-eslint/naming-convention\r\ndeclare const _native: INative;\r\n\r\n/** @internal */\r\nexport type NativeData = Uint32Array<ArrayBuffer>;\r\n\r\n/** @internal */\r\nexport class NativeDataStream {\r\n private readonly _uint32s: Uint32Array<ArrayBuffer>;\r\n private readonly _int32s: Int32Array<ArrayBuffer>;\r\n private readonly _float32s: Float32Array<ArrayBuffer>;\r\n private readonly _length: number;\r\n private _position: number;\r\n private readonly _nativeDataStream: INativeDataStream;\r\n\r\n // Must be multiple of 4!\r\n // eslint-disable-next-line @typescript-eslint/naming-convention\r\n private static readonly DEFAULT_BUFFER_SIZE = 65536;\r\n\r\n constructor() {\r\n const buffer = new ArrayBuffer(NativeDataStream.DEFAULT_BUFFER_SIZE);\r\n this._uint32s = new Uint32Array(buffer);\r\n this._int32s = new Int32Array(buffer);\r\n this._float32s = new Float32Array(buffer);\r\n\r\n this._length = NativeDataStream.DEFAULT_BUFFER_SIZE / 4;\r\n this._position = 0;\r\n\r\n this._nativeDataStream = new _native.NativeDataStream(() => {\r\n this._flush();\r\n });\r\n }\r\n\r\n /**\r\n * Writes a uint32 to the stream\r\n * @param value the value to write\r\n */\r\n public writeUint32(value: number): void {\r\n this._flushIfNecessary(1);\r\n this._uint32s[this._position++] = value;\r\n }\r\n\r\n /**\r\n * Writes an int32 to the stream\r\n * @param value the value to write\r\n */\r\n public writeInt32(value: number): void {\r\n this._flushIfNecessary(1);\r\n this._int32s[this._position++] = value;\r\n }\r\n\r\n /**\r\n * Writes a float32 to the stream\r\n * @param value the value to write\r\n */\r\n public writeFloat32(value: number): void {\r\n this._flushIfNecessary(1);\r\n this._float32s[this._position++] = value;\r\n }\r\n\r\n /**\r\n * Writes a uint32 array to the stream\r\n * @param values the values to write\r\n */\r\n public writeUint32Array(values: Uint32Array): void {\r\n this._flushIfNecessary(1 + values.length);\r\n this._uint32s[this._position++] = values.length;\r\n this._uint32s.set(values, this._position);\r\n this._position += values.length;\r\n }\r\n\r\n /**\r\n * Writes an int32 array to the stream\r\n * @param values the values to write\r\n */\r\n public writeInt32Array(values: Int32Array): void {\r\n this._flushIfNecessary(1 + values.length);\r\n this._uint32s[this._position++] = values.length;\r\n this._int32s.set(values, this._position);\r\n this._position += values.length;\r\n }\r\n\r\n /**\r\n * Writes a float32 array to the stream\r\n * @param values the values to write\r\n */\r\n public writeFloat32Array(values: DeepImmutable<FloatArray>): void {\r\n this._flushIfNecessary(1 + values.length);\r\n this._uint32s[this._position++] = values.length;\r\n this._float32s.set(values, this._position);\r\n this._position += values.length;\r\n }\r\n\r\n /**\r\n * Writes native data to the stream\r\n * @param handle the handle to the native data\r\n */\r\n public writeNativeData(handle: NativeData) {\r\n this._flushIfNecessary(handle.length);\r\n this._uint32s.set(handle, this._position);\r\n this._position += handle.length;\r\n }\r\n\r\n /**\r\n * Writes a boolean to the stream\r\n * @param value the value to write\r\n */\r\n public writeBoolean(value: boolean) {\r\n this.writeUint32(value ? 1 : 0);\r\n }\r\n\r\n private _flushIfNecessary(required: number): void {\r\n if (this._position + required > this._length) {\r\n this._flush();\r\n }\r\n }\r\n\r\n private _flush(): void {\r\n this._nativeDataStream.writeBuffer(this._uint32s.buffer, this._position);\r\n this._position = 0;\r\n }\r\n}\r\n"]}
@@ -21,12 +21,12 @@ export interface INativeEngine {
21
21
  requestAnimationFrame(callback: () => void): void;
22
22
  setDeviceLostCallback(callback: () => void): void;
23
23
  createVertexArray(): NativeData;
24
- createIndexBuffer(dataBuffer: ArrayBuffer, dataByteOffset: number, dataByteLength: number, is32Bits: boolean, dynamic: boolean): NativeData;
24
+ createIndexBuffer(dataBuffer: ArrayBufferLike, dataByteOffset: number, dataByteLength: number, is32Bits: boolean, dynamic: boolean): NativeData;
25
25
  recordIndexBuffer(vertexArray: NativeData, indexBuffer: NativeData): void;
26
- updateDynamicIndexBuffer(indexBuffer: NativeData, data: ArrayBuffer, dataByteOffset: number, dataByteLength: number, startIndex: number): void;
27
- createVertexBuffer(dataBuffer: ArrayBuffer, dataByteOffset: number, dataByteLength: number, dynamic: boolean): NativeData;
26
+ updateDynamicIndexBuffer(indexBuffer: NativeData, data: ArrayBufferLike, dataByteOffset: number, dataByteLength: number, startIndex: number): void;
27
+ createVertexBuffer(dataBuffer: ArrayBufferLike, dataByteOffset: number, dataByteLength: number, dynamic: boolean): NativeData;
28
28
  recordVertexBuffer(vertexArray: NativeData, vertexBuffer: NativeData, location: number, byteOffset: number, byteStride: number, numElements: number, type: number, normalized: boolean, instanceDivisor: number): void;
29
- updateDynamicVertexBuffer(vertexBuffer: NativeData, dataBuffer: ArrayBuffer, dataByteOffset: number, dataByteLength: number, vertexByteOffset?: number): void;
29
+ updateDynamicVertexBuffer(vertexBuffer: NativeData, dataBuffer: ArrayBufferLike, dataByteOffset: number, dataByteLength: number, vertexByteOffset?: number): void;
30
30
  createProgram(vertexShader: string, fragmentShader: string): NativeProgram;
31
31
  createProgramAsync(vertexShader: string, fragmentShader: string, onSuccess: () => void, onError: (error: Error) => void): NativeProgram;
32
32
  getUniforms(shaderProgram: NativeProgram, uniformsNames: string[]): WebGLUniformLocation[];