@babylonjs/core 7.37.0 → 7.37.2
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.
- package/Buffers/buffer.d.ts +3 -1
- package/Buffers/buffer.js +20 -122
- package/Buffers/buffer.js.map +1 -1
- package/Buffers/bufferUtils.d.ts +32 -1
- package/Buffers/bufferUtils.js +221 -10
- package/Buffers/bufferUtils.js.map +1 -1
- package/Cameras/arcRotateCamera.d.ts +3 -1
- package/Cameras/arcRotateCamera.js +14 -3
- package/Cameras/arcRotateCamera.js.map +1 -1
- package/Engines/abstractEngine.js +2 -2
- package/Engines/abstractEngine.js.map +1 -1
- package/Engines/engine.js +0 -4
- package/Engines/engine.js.map +1 -1
- package/Engines/thinEngine.js +2 -2
- package/Engines/thinEngine.js.map +1 -1
- package/FrameGraph/Node/nodeRenderGraphBlock.js +1 -0
- package/FrameGraph/Node/nodeRenderGraphBlock.js.map +1 -1
- package/FrameGraph/Node/nodeRenderGraphBlockConnectionPoint.d.ts +2 -0
- package/FrameGraph/Node/nodeRenderGraphBlockConnectionPoint.js +3 -1
- package/FrameGraph/Node/nodeRenderGraphBlockConnectionPoint.js.map +1 -1
- package/Inputs/scene.inputManager.js +2 -0
- package/Inputs/scene.inputManager.js.map +1 -1
- package/Lights/IES/iesLoader.d.ts +19 -0
- package/Lights/IES/iesLoader.js +150 -0
- package/Lights/IES/iesLoader.js.map +1 -0
- package/Lights/index.d.ts +1 -0
- package/Lights/index.js +1 -0
- package/Lights/index.js.map +1 -1
- package/Materials/GaussianSplatting/gaussianSplattingMaterial.js +12 -2
- package/Materials/GaussianSplatting/gaussianSplattingMaterial.js.map +1 -1
- package/Materials/GreasedLine/greasedLineMaterialInterfaces.d.ts +5 -0
- package/Materials/GreasedLine/greasedLineMaterialInterfaces.js.map +1 -1
- package/Materials/GreasedLine/greasedLinePluginMaterial.d.ts +21 -5
- package/Materials/GreasedLine/greasedLinePluginMaterial.js +52 -176
- package/Materials/GreasedLine/greasedLinePluginMaterial.js.map +1 -1
- package/Materials/GreasedLine/greasedLinePluginMaterialShadersGLSL.d.ts +11 -0
- package/Materials/GreasedLine/greasedLinePluginMaterialShadersGLSL.js +158 -0
- package/Materials/GreasedLine/greasedLinePluginMaterialShadersGLSL.js.map +1 -0
- package/Materials/GreasedLine/greasedLinePluginMaterialShadersWGSL.d.ts +11 -0
- package/Materials/GreasedLine/greasedLinePluginMaterialShadersWGSL.js +177 -0
- package/Materials/GreasedLine/greasedLinePluginMaterialShadersWGSL.js.map +1 -0
- package/Materials/GreasedLine/greasedLineSimpleMaterial.d.ts +4 -2
- package/Materials/GreasedLine/greasedLineSimpleMaterial.js +45 -25
- package/Materials/GreasedLine/greasedLineSimpleMaterial.js.map +1 -1
- package/Materials/Node/Blocks/PBR/reflectionBlock.js +6 -0
- package/Materials/Node/Blocks/PBR/reflectionBlock.js.map +1 -1
- package/Materials/Node/Blocks/index.d.ts +1 -0
- package/Materials/Node/Blocks/index.js +1 -0
- package/Materials/Node/Blocks/index.js.map +1 -1
- package/Materials/Node/Blocks/matrixSplitterBlock.d.ts +56 -0
- package/Materials/Node/Blocks/matrixSplitterBlock.js +130 -0
- package/Materials/Node/Blocks/matrixSplitterBlock.js.map +1 -0
- package/Materials/Node/nodeMaterialBlock.js +1 -0
- package/Materials/Node/nodeMaterialBlock.js.map +1 -1
- package/Materials/Node/nodeMaterialBlockConnectionPoint.d.ts +2 -0
- package/Materials/Node/nodeMaterialBlockConnectionPoint.js +4 -1
- package/Materials/Node/nodeMaterialBlockConnectionPoint.js.map +1 -1
- package/Materials/PBR/pbrBaseMaterial.d.ts +1 -0
- package/Materials/PBR/pbrBaseMaterial.js +12 -0
- package/Materials/PBR/pbrBaseMaterial.js.map +1 -1
- package/Materials/Textures/Loaders/iesTextureLoader.d.ts +23 -0
- package/Materials/Textures/Loaders/iesTextureLoader.js +40 -0
- package/Materials/Textures/Loaders/iesTextureLoader.js.map +1 -0
- package/Materials/Textures/Loaders/index.d.ts +1 -0
- package/Materials/Textures/Loaders/index.js +1 -0
- package/Materials/Textures/Loaders/index.js.map +1 -1
- package/Materials/Textures/Loaders/textureLoaderManager.js +3 -0
- package/Materials/Textures/Loaders/textureLoaderManager.js.map +1 -1
- package/Materials/effectRenderer.js +1 -1
- package/Materials/effectRenderer.js.map +1 -1
- package/Materials/index.d.ts +4 -0
- package/Materials/index.js +5 -0
- package/Materials/index.js.map +1 -1
- package/Maths/math.scalar.d.ts +0 -1
- package/Maths/math.scalar.js +1 -2
- package/Maths/math.scalar.js.map +1 -1
- package/Meshes/Builders/greasedLineBuilder.js +2 -2
- package/Meshes/Builders/greasedLineBuilder.js.map +1 -1
- package/Meshes/GaussianSplatting/gaussianSplattingMesh.d.ts +15 -2
- package/Meshes/GaussianSplatting/gaussianSplattingMesh.js +68 -20
- package/Meshes/GaussianSplatting/gaussianSplattingMesh.js.map +1 -1
- package/Meshes/Node/Blocks/geometryInputBlock.d.ts +4 -0
- package/Meshes/Node/Blocks/geometryInputBlock.js +8 -0
- package/Meshes/Node/Blocks/geometryInputBlock.js.map +1 -1
- package/Meshes/Node/nodeGeometryBlock.js +1 -0
- package/Meshes/Node/nodeGeometryBlock.js.map +1 -1
- package/Meshes/Node/nodeGeometryBlockConnectionPoint.d.ts +2 -0
- package/Meshes/Node/nodeGeometryBlockConnectionPoint.js +3 -1
- package/Meshes/Node/nodeGeometryBlockConnectionPoint.js.map +1 -1
- package/Meshes/abstractMesh.hotSpot.d.ts +8 -1
- package/Meshes/abstractMesh.hotSpot.js +17 -0
- package/Meshes/abstractMesh.hotSpot.js.map +1 -1
- package/Meshes/linesMesh.js +1 -1
- package/Meshes/linesMesh.js.map +1 -1
- package/Misc/deepMerger.d.ts +6 -0
- package/Misc/deepMerger.js +26 -0
- package/Misc/deepMerger.js.map +1 -0
- package/Misc/index.d.ts +1 -0
- package/Misc/index.js +1 -0
- package/Misc/index.js.map +1 -1
- package/Misc/virtualJoystick.js +2 -0
- package/Misc/virtualJoystick.js.map +1 -1
- package/Rendering/IBLShadows/iblShadowsRenderPipeline.d.ts +3 -23
- package/Rendering/IBLShadows/iblShadowsRenderPipeline.js +30 -67
- package/Rendering/IBLShadows/iblShadowsRenderPipeline.js.map +1 -1
- package/Rendering/IBLShadows/iblShadowsVoxelTracingPass.d.ts +1 -1
- package/Rendering/IBLShadows/iblShadowsVoxelTracingPass.js +8 -4
- package/Rendering/IBLShadows/iblShadowsVoxelTracingPass.js.map +1 -1
- package/Rendering/boundingBoxRenderer.d.ts +63 -1
- package/Rendering/boundingBoxRenderer.js +224 -3
- package/Rendering/boundingBoxRenderer.js.map +1 -1
- package/Rendering/edgesRenderer.js +4 -1
- package/Rendering/edgesRenderer.js.map +1 -1
- package/Rendering/{IBLShadows/iblShadowsImportanceSamplingRenderer.d.ts → iblCdfGenerator.d.ts} +15 -12
- package/Rendering/{IBLShadows/iblShadowsImportanceSamplingRenderer.js → iblCdfGenerator.js} +37 -27
- package/Rendering/iblCdfGenerator.js.map +1 -0
- package/Rendering/iblCdfGeneratorSceneComponent.d.ts +59 -0
- package/Rendering/iblCdfGeneratorSceneComponent.js +83 -0
- package/Rendering/iblCdfGeneratorSceneComponent.js.map +1 -0
- package/Rendering/index.d.ts +12 -10
- package/Rendering/index.js +12 -10
- package/Rendering/index.js.map +1 -1
- package/Shaders/ShadersInclude/gaussianSplatting.js +72 -2
- package/Shaders/ShadersInclude/gaussianSplatting.js.map +1 -1
- package/Shaders/ShadersInclude/gaussianSplattingVertexDeclaration.js +1 -1
- package/Shaders/ShadersInclude/gaussianSplattingVertexDeclaration.js.map +1 -1
- package/Shaders/ShadersInclude/hdrFilteringFunctions.js +29 -4
- package/Shaders/ShadersInclude/hdrFilteringFunctions.js.map +1 -1
- package/Shaders/ShadersInclude/pbrBlockReflection.js +9 -1
- package/Shaders/ShadersInclude/pbrBlockReflection.js.map +1 -1
- package/Shaders/ShadersInclude/pbrBlockSubSurface.js +9 -1
- package/Shaders/ShadersInclude/pbrBlockSubSurface.js.map +1 -1
- package/Shaders/ShadersInclude/pbrFragmentSamplersDeclaration.js +3 -0
- package/Shaders/ShadersInclude/pbrFragmentSamplersDeclaration.js.map +1 -1
- package/Shaders/boundingBoxRenderer.vertex.js +7 -0
- package/Shaders/boundingBoxRenderer.vertex.js.map +1 -1
- package/Shaders/gaussianSplatting.vertex.js +16 -2
- package/Shaders/gaussianSplatting.vertex.js.map +1 -1
- package/Shaders/{iblShadowsCdfy.fragment.d.ts → iblCdfx.fragment.d.ts} +1 -1
- package/Shaders/{iblShadowsCdfx.fragment.js → iblCdfx.fragment.js} +3 -3
- package/Shaders/iblCdfx.fragment.js.map +1 -0
- package/Shaders/{iblShadowsCdfx.fragment.d.ts → iblCdfy.fragment.d.ts} +1 -1
- package/Shaders/{iblShadowsCdfy.fragment.js → iblCdfy.fragment.js} +3 -3
- package/Shaders/iblCdfy.fragment.js.map +1 -0
- package/Shaders/{iblShadowsIcdfx.fragment.d.ts → iblIcdfx.fragment.d.ts} +1 -1
- package/Shaders/{iblShadowsIcdfx.fragment.js → iblIcdfx.fragment.js} +3 -3
- package/Shaders/iblIcdfx.fragment.js.map +1 -0
- package/Shaders/{iblShadowsIcdfy.fragment.d.ts → iblIcdfy.fragment.d.ts} +1 -1
- package/Shaders/{iblShadowsIcdfy.fragment.js → iblIcdfy.fragment.js} +3 -3
- package/Shaders/iblIcdfy.fragment.js.map +1 -0
- package/Shaders/importanceSamplingDebug.fragment.d.ts +5 -0
- package/Shaders/{iblShadowsImportanceSamplingDebug.fragment.js → importanceSamplingDebug.fragment.js} +3 -3
- package/Shaders/importanceSamplingDebug.fragment.js.map +1 -0
- package/Shaders/pbr.fragment.js +8 -0
- package/Shaders/pbr.fragment.js.map +1 -1
- package/ShadersWGSL/ShadersInclude/gaussianSplatting.js +77 -1
- package/ShadersWGSL/ShadersInclude/gaussianSplatting.js.map +1 -1
- package/ShadersWGSL/ShadersInclude/hdrFilteringFunctions.js +28 -4
- package/ShadersWGSL/ShadersInclude/hdrFilteringFunctions.js.map +1 -1
- package/ShadersWGSL/ShadersInclude/lightFragment.js +1 -1
- package/ShadersWGSL/ShadersInclude/lightFragment.js.map +1 -1
- package/ShadersWGSL/ShadersInclude/oitFragment.js +1 -1
- package/ShadersWGSL/ShadersInclude/oitFragment.js.map +1 -1
- package/ShadersWGSL/ShadersInclude/pbrBlockReflection.js +14 -1
- package/ShadersWGSL/ShadersInclude/pbrBlockReflection.js.map +1 -1
- package/ShadersWGSL/ShadersInclude/pbrBlockSubSurface.js +14 -1
- package/ShadersWGSL/ShadersInclude/pbrBlockSubSurface.js.map +1 -1
- package/ShadersWGSL/ShadersInclude/pbrFragmentSamplersDeclaration.js +3 -0
- package/ShadersWGSL/ShadersInclude/pbrFragmentSamplersDeclaration.js.map +1 -1
- package/ShadersWGSL/ShadersInclude/shadowsFragmentFunctions.js +1 -1
- package/ShadersWGSL/ShadersInclude/shadowsFragmentFunctions.js.map +1 -1
- package/ShadersWGSL/boundingBoxRenderer.vertex.js +9 -1
- package/ShadersWGSL/boundingBoxRenderer.vertex.js.map +1 -1
- package/ShadersWGSL/gaussianSplatting.vertex.js +18 -2
- package/ShadersWGSL/gaussianSplatting.vertex.js.map +1 -1
- package/ShadersWGSL/greasedLine.fragment.d.ts +5 -0
- package/ShadersWGSL/greasedLine.fragment.js +25 -0
- package/ShadersWGSL/greasedLine.fragment.js.map +1 -0
- package/ShadersWGSL/greasedLine.vertex.d.ts +9 -0
- package/ShadersWGSL/greasedLine.vertex.js +43 -0
- package/ShadersWGSL/greasedLine.vertex.js.map +1 -0
- package/ShadersWGSL/iblCdfx.fragment.d.ts +5 -0
- package/ShadersWGSL/{iblShadowsCdfx.fragment.js → iblCdfx.fragment.js} +3 -3
- package/ShadersWGSL/iblCdfx.fragment.js.map +1 -0
- package/ShadersWGSL/iblCdfy.fragment.d.ts +5 -0
- package/ShadersWGSL/{iblShadowsCdfy.fragment.js → iblCdfy.fragment.js} +3 -3
- package/ShadersWGSL/iblCdfy.fragment.js.map +1 -0
- package/ShadersWGSL/iblIcdfx.fragment.d.ts +5 -0
- package/ShadersWGSL/{iblShadowsIcdfx.fragment.js → iblIcdfx.fragment.js} +3 -3
- package/ShadersWGSL/iblIcdfx.fragment.js.map +1 -0
- package/ShadersWGSL/iblIcdfy.fragment.d.ts +5 -0
- package/ShadersWGSL/{iblShadowsIcdfy.fragment.js → iblIcdfy.fragment.js} +3 -3
- package/ShadersWGSL/iblIcdfy.fragment.js.map +1 -0
- package/ShadersWGSL/importanceSamplingDebug.fragment.d.ts +5 -0
- package/ShadersWGSL/{iblShadowsImportanceSamplingDebug.fragment.js → importanceSamplingDebug.fragment.js} +3 -3
- package/ShadersWGSL/importanceSamplingDebug.fragment.js.map +1 -0
- package/ShadersWGSL/pbr.fragment.js +12 -0
- package/ShadersWGSL/pbr.fragment.js.map +1 -1
- package/package.json +1 -1
- package/scene.d.ts +4 -0
- package/scene.js +6 -0
- package/scene.js.map +1 -1
- package/sceneComponent.d.ts +1 -1
- package/sceneComponent.js +1 -1
- package/sceneComponent.js.map +1 -1
- package/Rendering/IBLShadows/iblShadowsImportanceSamplingRenderer.js.map +0 -1
- package/Shaders/iblShadowsCdfx.fragment.js.map +0 -1
- package/Shaders/iblShadowsCdfy.fragment.js.map +0 -1
- package/Shaders/iblShadowsIcdfx.fragment.js.map +0 -1
- package/Shaders/iblShadowsIcdfy.fragment.js.map +0 -1
- package/Shaders/iblShadowsImportanceSamplingDebug.fragment.d.ts +0 -5
- package/Shaders/iblShadowsImportanceSamplingDebug.fragment.js.map +0 -1
- package/ShadersWGSL/iblShadowsCdfx.fragment.d.ts +0 -5
- package/ShadersWGSL/iblShadowsCdfx.fragment.js.map +0 -1
- package/ShadersWGSL/iblShadowsCdfy.fragment.d.ts +0 -5
- package/ShadersWGSL/iblShadowsCdfy.fragment.js.map +0 -1
- package/ShadersWGSL/iblShadowsIcdfx.fragment.d.ts +0 -5
- package/ShadersWGSL/iblShadowsIcdfx.fragment.js.map +0 -1
- package/ShadersWGSL/iblShadowsIcdfy.fragment.d.ts +0 -5
- package/ShadersWGSL/iblShadowsIcdfy.fragment.js.map +0 -1
- package/ShadersWGSL/iblShadowsImportanceSamplingDebug.fragment.d.ts +0 -5
- package/ShadersWGSL/iblShadowsImportanceSamplingDebug.fragment.js.map +0 -1
package/Buffers/buffer.d.ts
CHANGED
|
@@ -437,6 +437,7 @@ export declare class VertexBuffer {
|
|
|
437
437
|
* Gets the byte length of the given type.
|
|
438
438
|
* @param type the type
|
|
439
439
|
* @returns the number of bytes
|
|
440
|
+
* @deprecated Use `getTypeByteLength` from `bufferUtils` instead
|
|
440
441
|
*/
|
|
441
442
|
static GetTypeByteLength(type: number): number;
|
|
442
443
|
/**
|
|
@@ -449,9 +450,9 @@ export declare class VertexBuffer {
|
|
|
449
450
|
* @param count the number of values to enumerate
|
|
450
451
|
* @param normalized whether the data is normalized
|
|
451
452
|
* @param callback the callback function called for each value
|
|
453
|
+
* @deprecated Use `EnumerateFloatValues` from `bufferUtils` instead
|
|
452
454
|
*/
|
|
453
455
|
static ForEach(data: DataArray, byteOffset: number, byteStride: number, componentCount: number, componentType: number, count: number, normalized: boolean, callback: (value: number, index: number) => void): void;
|
|
454
|
-
private static _GetFloatValue;
|
|
455
456
|
/**
|
|
456
457
|
* Gets the given data array as a float array. Float data is constructed if the data array cannot be returned directly.
|
|
457
458
|
* @param data the input data array
|
|
@@ -463,6 +464,7 @@ export declare class VertexBuffer {
|
|
|
463
464
|
* @param totalVertices number of vertices in the buffer to take into account
|
|
464
465
|
* @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
|
|
465
466
|
* @returns a float array containing vertex data
|
|
467
|
+
* @deprecated Use `GetFloatData` from `bufferUtils` instead
|
|
466
468
|
*/
|
|
467
469
|
static GetFloatData(data: DataArray, size: number, type: number, byteOffset: number, byteStride: number, normalized: boolean, totalVertices: number, forceCopy?: boolean): FloatArray;
|
|
468
470
|
}
|
package/Buffers/buffer.js
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { DataBuffer } from "./dataBuffer.js";
|
|
2
2
|
import { Logger } from "../Misc/logger.js";
|
|
3
3
|
|
|
4
|
+
import { EnumerateFloatValues, GetFloatData, GetTypeByteLength } from "./bufferUtils.js";
|
|
4
5
|
/**
|
|
5
6
|
* Class used to store data that will be store in GPU memory
|
|
6
7
|
*/
|
|
@@ -291,7 +292,7 @@ export class VertexBuffer {
|
|
|
291
292
|
else {
|
|
292
293
|
this.type = type;
|
|
293
294
|
}
|
|
294
|
-
const typeByteLength =
|
|
295
|
+
const typeByteLength = GetTypeByteLength(this.type);
|
|
295
296
|
if (useBytes) {
|
|
296
297
|
this._size = size || (stride ? stride / typeByteLength : VertexBuffer.DeduceStride(kind));
|
|
297
298
|
this.byteStride = stride || this._buffer.byteStride || this._size * typeByteLength;
|
|
@@ -355,7 +356,7 @@ export class VertexBuffer {
|
|
|
355
356
|
if (!data) {
|
|
356
357
|
return null;
|
|
357
358
|
}
|
|
358
|
-
return
|
|
359
|
+
return GetFloatData(data, this._size, this.type, this.byteOffset, this.byteStride, this.normalized, totalVertices, forceCopy);
|
|
359
360
|
}
|
|
360
361
|
/**
|
|
361
362
|
* Gets underlying native buffer
|
|
@@ -378,7 +379,7 @@ export class VertexBuffer {
|
|
|
378
379
|
* @deprecated Please use byteStride instead.
|
|
379
380
|
*/
|
|
380
381
|
getStrideSize() {
|
|
381
|
-
return this.byteStride /
|
|
382
|
+
return this.byteStride / GetTypeByteLength(this.type);
|
|
382
383
|
}
|
|
383
384
|
/**
|
|
384
385
|
* Returns the offset as a multiple of the type byte length.
|
|
@@ -386,7 +387,7 @@ export class VertexBuffer {
|
|
|
386
387
|
* @deprecated Please use byteOffset instead.
|
|
387
388
|
*/
|
|
388
389
|
getOffset() {
|
|
389
|
-
return this.byteOffset /
|
|
390
|
+
return this.byteOffset / GetTypeByteLength(this.type);
|
|
390
391
|
}
|
|
391
392
|
/**
|
|
392
393
|
* Returns the number of components or the byte size per vertex attribute
|
|
@@ -394,7 +395,7 @@ export class VertexBuffer {
|
|
|
394
395
|
* @returns the number of components
|
|
395
396
|
*/
|
|
396
397
|
getSize(sizeInBytes = false) {
|
|
397
|
-
return sizeInBytes ? this._size *
|
|
398
|
+
return sizeInBytes ? this._size * GetTypeByteLength(this.type) : this._size;
|
|
398
399
|
}
|
|
399
400
|
/**
|
|
400
401
|
* Gets a boolean indicating is the internal buffer of the VertexBuffer is instanced
|
|
@@ -454,7 +455,11 @@ export class VertexBuffer {
|
|
|
454
455
|
* @param callback the callback function called for each value
|
|
455
456
|
*/
|
|
456
457
|
forEach(count, callback) {
|
|
457
|
-
|
|
458
|
+
EnumerateFloatValues(this._buffer.getData(), this.byteOffset, this.byteStride, this._size, this.type, count, this.normalized, (values, index) => {
|
|
459
|
+
for (let i = 0; i < this._size; i++) {
|
|
460
|
+
callback(values[i], index + i);
|
|
461
|
+
}
|
|
462
|
+
});
|
|
458
463
|
}
|
|
459
464
|
/** @internal */
|
|
460
465
|
_alignBuffer() { }
|
|
@@ -519,22 +524,10 @@ export class VertexBuffer {
|
|
|
519
524
|
* Gets the byte length of the given type.
|
|
520
525
|
* @param type the type
|
|
521
526
|
* @returns the number of bytes
|
|
527
|
+
* @deprecated Use `getTypeByteLength` from `bufferUtils` instead
|
|
522
528
|
*/
|
|
523
529
|
static GetTypeByteLength(type) {
|
|
524
|
-
|
|
525
|
-
case VertexBuffer.BYTE:
|
|
526
|
-
case VertexBuffer.UNSIGNED_BYTE:
|
|
527
|
-
return 1;
|
|
528
|
-
case VertexBuffer.SHORT:
|
|
529
|
-
case VertexBuffer.UNSIGNED_SHORT:
|
|
530
|
-
return 2;
|
|
531
|
-
case VertexBuffer.INT:
|
|
532
|
-
case VertexBuffer.UNSIGNED_INT:
|
|
533
|
-
case VertexBuffer.FLOAT:
|
|
534
|
-
return 4;
|
|
535
|
-
default:
|
|
536
|
-
throw new Error(`Invalid type '${type}'`);
|
|
537
|
-
}
|
|
530
|
+
return GetTypeByteLength(type);
|
|
538
531
|
}
|
|
539
532
|
/**
|
|
540
533
|
* Enumerates each value of the given parameters as numbers.
|
|
@@ -546,75 +539,14 @@ export class VertexBuffer {
|
|
|
546
539
|
* @param count the number of values to enumerate
|
|
547
540
|
* @param normalized whether the data is normalized
|
|
548
541
|
* @param callback the callback function called for each value
|
|
542
|
+
* @deprecated Use `EnumerateFloatValues` from `bufferUtils` instead
|
|
549
543
|
*/
|
|
550
544
|
static ForEach(data, byteOffset, byteStride, componentCount, componentType, count, normalized, callback) {
|
|
551
|
-
|
|
552
|
-
let
|
|
553
|
-
|
|
554
|
-
for (let index = 0; index < count; index += componentCount) {
|
|
555
|
-
for (let componentIndex = 0; componentIndex < componentCount; componentIndex++) {
|
|
556
|
-
callback(data[offset + componentIndex], index + componentIndex);
|
|
557
|
-
}
|
|
558
|
-
offset += stride;
|
|
559
|
-
}
|
|
560
|
-
}
|
|
561
|
-
else {
|
|
562
|
-
const dataView = data instanceof ArrayBuffer ? new DataView(data) : new DataView(data.buffer, data.byteOffset, data.byteLength);
|
|
563
|
-
const componentByteLength = VertexBuffer.GetTypeByteLength(componentType);
|
|
564
|
-
for (let index = 0; index < count; index += componentCount) {
|
|
565
|
-
let componentByteOffset = byteOffset;
|
|
566
|
-
for (let componentIndex = 0; componentIndex < componentCount; componentIndex++) {
|
|
567
|
-
const value = VertexBuffer._GetFloatValue(dataView, componentType, componentByteOffset, normalized);
|
|
568
|
-
callback(value, index + componentIndex);
|
|
569
|
-
componentByteOffset += componentByteLength;
|
|
570
|
-
}
|
|
571
|
-
byteOffset += byteStride;
|
|
545
|
+
EnumerateFloatValues(data, byteOffset, byteStride, componentCount, componentType, count, normalized, (values, index) => {
|
|
546
|
+
for (let componentIndex = 0; componentIndex < componentCount; componentIndex++) {
|
|
547
|
+
callback(values[componentIndex], index + componentIndex);
|
|
572
548
|
}
|
|
573
|
-
}
|
|
574
|
-
}
|
|
575
|
-
static _GetFloatValue(dataView, type, byteOffset, normalized) {
|
|
576
|
-
switch (type) {
|
|
577
|
-
case VertexBuffer.BYTE: {
|
|
578
|
-
let value = dataView.getInt8(byteOffset);
|
|
579
|
-
if (normalized) {
|
|
580
|
-
value = Math.max(value / 127, -1);
|
|
581
|
-
}
|
|
582
|
-
return value;
|
|
583
|
-
}
|
|
584
|
-
case VertexBuffer.UNSIGNED_BYTE: {
|
|
585
|
-
let value = dataView.getUint8(byteOffset);
|
|
586
|
-
if (normalized) {
|
|
587
|
-
value = value / 255;
|
|
588
|
-
}
|
|
589
|
-
return value;
|
|
590
|
-
}
|
|
591
|
-
case VertexBuffer.SHORT: {
|
|
592
|
-
let value = dataView.getInt16(byteOffset, true);
|
|
593
|
-
if (normalized) {
|
|
594
|
-
value = Math.max(value / 32767, -1);
|
|
595
|
-
}
|
|
596
|
-
return value;
|
|
597
|
-
}
|
|
598
|
-
case VertexBuffer.UNSIGNED_SHORT: {
|
|
599
|
-
let value = dataView.getUint16(byteOffset, true);
|
|
600
|
-
if (normalized) {
|
|
601
|
-
value = value / 65535;
|
|
602
|
-
}
|
|
603
|
-
return value;
|
|
604
|
-
}
|
|
605
|
-
case VertexBuffer.INT: {
|
|
606
|
-
return dataView.getInt32(byteOffset, true);
|
|
607
|
-
}
|
|
608
|
-
case VertexBuffer.UNSIGNED_INT: {
|
|
609
|
-
return dataView.getUint32(byteOffset, true);
|
|
610
|
-
}
|
|
611
|
-
case VertexBuffer.FLOAT: {
|
|
612
|
-
return dataView.getFloat32(byteOffset, true);
|
|
613
|
-
}
|
|
614
|
-
default: {
|
|
615
|
-
throw new Error(`Invalid component type ${type}`);
|
|
616
|
-
}
|
|
617
|
-
}
|
|
549
|
+
});
|
|
618
550
|
}
|
|
619
551
|
/**
|
|
620
552
|
* Gets the given data array as a float array. Float data is constructed if the data array cannot be returned directly.
|
|
@@ -627,44 +559,10 @@ export class VertexBuffer {
|
|
|
627
559
|
* @param totalVertices number of vertices in the buffer to take into account
|
|
628
560
|
* @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
|
|
629
561
|
* @returns a float array containing vertex data
|
|
562
|
+
* @deprecated Use `GetFloatData` from `bufferUtils` instead
|
|
630
563
|
*/
|
|
631
564
|
static GetFloatData(data, size, type, byteOffset, byteStride, normalized, totalVertices, forceCopy) {
|
|
632
|
-
|
|
633
|
-
const count = totalVertices * size;
|
|
634
|
-
if (type !== VertexBuffer.FLOAT || byteStride !== tightlyPackedByteStride) {
|
|
635
|
-
const copy = new Float32Array(count);
|
|
636
|
-
VertexBuffer.ForEach(data, byteOffset, byteStride, size, type, count, normalized, (value, index) => (copy[index] = value));
|
|
637
|
-
return copy;
|
|
638
|
-
}
|
|
639
|
-
if (!(data instanceof Array || data instanceof Float32Array) || byteOffset !== 0 || data.length !== count) {
|
|
640
|
-
if (data instanceof Array) {
|
|
641
|
-
const offset = byteOffset / 4;
|
|
642
|
-
return data.slice(offset, offset + count);
|
|
643
|
-
}
|
|
644
|
-
else if (data instanceof ArrayBuffer) {
|
|
645
|
-
return new Float32Array(data, byteOffset, count);
|
|
646
|
-
}
|
|
647
|
-
else {
|
|
648
|
-
const offset = data.byteOffset + byteOffset;
|
|
649
|
-
if ((offset & 3) !== 0) {
|
|
650
|
-
Logger.Warn("Float array must be aligned to 4-bytes border");
|
|
651
|
-
forceCopy = true;
|
|
652
|
-
}
|
|
653
|
-
if (forceCopy) {
|
|
654
|
-
const result = new Uint8Array(count * Float32Array.BYTES_PER_ELEMENT);
|
|
655
|
-
const source = new Uint8Array(data.buffer, offset, result.length);
|
|
656
|
-
result.set(source);
|
|
657
|
-
return new Float32Array(result.buffer);
|
|
658
|
-
}
|
|
659
|
-
else {
|
|
660
|
-
return new Float32Array(data.buffer, offset, count);
|
|
661
|
-
}
|
|
662
|
-
}
|
|
663
|
-
}
|
|
664
|
-
if (forceCopy) {
|
|
665
|
-
return data.slice();
|
|
666
|
-
}
|
|
667
|
-
return data;
|
|
565
|
+
return GetFloatData(data, size, type, byteOffset, byteStride, normalized, totalVertices, forceCopy);
|
|
668
566
|
}
|
|
669
567
|
}
|
|
670
568
|
VertexBuffer._Counter = 0;
|
package/Buffers/buffer.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"buffer.js","sourceRoot":"","sources":["../../../../dev/core/src/Buffers/buffer.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,UAAU,EAAE,MAAM,cAAc,CAAC;AAE1C,OAAO,EAAE,MAAM,EAAE,MAAM,gBAAgB,CAAC;AACxC,OAAO,EAAE,SAAS,EAAE,MAAM,sBAAsB,CAAC;AAEjD;;GAEG;AACH,MAAM,OAAO,MAAM;IAYf;;OAEG;IACH,IAAW,UAAU;QACjB,OAAO,IAAI,CAAC,WAAW,CAAC;IAC5B,CAAC;IAOD;;;;;;;;;;;OAWG;IACH,YACI,MAAsB,EACtB,IAA4B,EAC5B,SAAkB,EAClB,MAAM,GAAG,CAAC,EACV,wBAAwB,GAAG,KAAK,EAChC,SAAS,GAAG,KAAK,EACjB,QAAQ,GAAG,KAAK,EAChB,OAAgB,EAChB,KAAc;QArCV,oBAAe,GAAG,KAAK,CAAC;QACxB,gBAAW,GAAG,KAAK,CAAC;QAsCxB,IAAI,MAAM,IAAK,MAA0B,CAAC,QAAQ,EAAE,CAAC;YACjD,mEAAmE;YACnE,IAAI,CAAC,OAAO,GAAI,MAA0B,CAAC,QAAQ,EAAE,CAAC,SAAS,EAAE,CAAC;QACtE,CAAC;aAAM,CAAC;YACJ,IAAI,CAAC,OAAO,GAAG,MAAM,CAAC;QAC1B,CAAC;QAED,IAAI,CAAC,UAAU,GAAG,SAAS,CAAC;QAC5B,IAAI,CAAC,UAAU,GAAG,SAAS,CAAC;QAC5B,IAAI,CAAC,QAAQ,GAAG,OAAO,IAAI,CAAC,CAAC;QAC7B,IAAI,CAAC,MAAM,GAAG,KAAK,CAAC;QAEpB,IAAI,IAAI,YAAY,UAAU,EAAE,CAAC;YAC7B,IAAI,CAAC,KAAK,GAAG,IAAI,CAAC;YAClB,IAAI,CAAC,OAAO,GAAG,IAAI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;AACoB,mBAAM,GAAG,SAAS,CAAC,MAAM,AAAnB,CAAoB;AACjD;;GAEG;AACoB,oBAAO,GAAG,SAAS,CAAC,OAAO,AAApB,CAAqB;AACnD;;GAEG;AACoB,oBAAO,GAAG,SAAS,CAAC,OAAO,AAApB,CAAqB;AACnD;;GAEG;AACoB,oBAAO,GAAG,SAAS,CAAC,OAAO,AAApB,CAAqB;AACnD;;GAEG;AACoB,oBAAO,GAAG,SAAS,CAAC,OAAO,AAApB,CAAqB;AACnD;;GAEG;AACoB,oBAAO,GAAG,SAAS,CAAC,OAAO,AAApB,CAAqB;AACnD;;GAEG;AACoB,sBAAS,GAAG,SAAS,CAAC,SAAS,AAAtB,CAAuB;AACvD;;GAEG;AACoB,8BAAiB,GAAG,SAAS,CAAC,iBAAiB,AAA9B,CAA+B;AACvE;;GAEG;AACoB,gCAAmB,GAAG,SAAS,CAAC,mBAAmB,AAAhC,CAAiC;AAC3E;;GAEG;AACoB,gCAAmB,GAAG,SAAS,CAAC,mBAAmB,AAAhC,CAAiC;AAC3E;;GAEG;AACoB,qCAAwB,GAAG,SAAS,CAAC,wBAAwB,AAArC,CAAsC;AACrF;;GAEG;AACoB,qCAAwB,GAAG,SAAS,CAAC,wBAAwB,AAArC,CAAsC","sourcesContent":["import type { Nullable, DataArray, FloatArray } from \"../types\";\r\nimport type { AbstractEngine } from \"../Engines/abstractEngine\";\r\nimport { DataBuffer } from \"./dataBuffer\";\r\nimport type { Mesh } from \"../Meshes/mesh\";\r\nimport { Logger } from \"../Misc/logger\";\r\nimport { Constants } from \"../Engines/constants\";\r\n\r\n/**\r\n * Class used to store data that will be store in GPU memory\r\n */\r\nexport class Buffer {\r\n private _engine: AbstractEngine;\r\n private _buffer: Nullable<DataBuffer>;\r\n /** @internal */\r\n public _data: Nullable<DataArray>;\r\n private _updatable: boolean;\r\n private _instanced: boolean;\r\n private _divisor: number;\r\n private _isAlreadyOwned = false;\r\n private _isDisposed = false;\r\n private _label?: string;\r\n\r\n /**\r\n * Gets a boolean indicating if the Buffer is disposed\r\n */\r\n public get isDisposed(): boolean {\r\n return this._isDisposed;\r\n }\r\n\r\n /**\r\n * Gets the byte stride.\r\n */\r\n public readonly byteStride: number;\r\n\r\n /**\r\n * Constructor\r\n * @param engine the engine\r\n * @param data the data to use for this buffer\r\n * @param updatable whether the data is updatable\r\n * @param stride the stride (optional)\r\n * @param postponeInternalCreation whether to postpone creating the internal WebGL buffer (optional)\r\n * @param instanced whether the buffer is instanced (optional)\r\n * @param useBytes set to true if the stride in in bytes (optional)\r\n * @param divisor sets an optional divisor for instances (1 by default)\r\n * @param label defines the label of the buffer (for debug purpose)\r\n */\r\n constructor(\r\n engine: AbstractEngine,\r\n data: DataArray | DataBuffer,\r\n updatable: boolean,\r\n stride = 0,\r\n postponeInternalCreation = false,\r\n instanced = false,\r\n useBytes = false,\r\n divisor?: number,\r\n label?: string\r\n ) {\r\n if (engine && (engine as unknown as Mesh).getScene) {\r\n // old versions of VertexBuffer accepted 'mesh' instead of 'engine'\r\n this._engine = (engine as unknown as Mesh).getScene().getEngine();\r\n } else {\r\n this._engine = engine;\r\n }\r\n\r\n this._updatable = updatable;\r\n this._instanced = instanced;\r\n this._divisor = divisor || 1;\r\n this._label = label;\r\n\r\n if (data instanceof DataBuffer) {\r\n this._data = null;\r\n this._buffer = data;\r\n } else {\r\n this._data = data;\r\n this._buffer = null;\r\n }\r\n\r\n this.byteStride = useBytes ? stride : stride * Float32Array.BYTES_PER_ELEMENT;\r\n\r\n if (!postponeInternalCreation) {\r\n // by default\r\n this.create();\r\n }\r\n }\r\n\r\n /**\r\n * Create a new VertexBuffer based on the current buffer\r\n * @param kind defines the vertex buffer kind (position, normal, etc.)\r\n * @param offset defines offset in the buffer (0 by default)\r\n * @param size defines the size in floats of attributes (position is 3 for instance)\r\n * @param stride defines the stride size in floats in the buffer (the offset to apply to reach next value when data is interleaved)\r\n * @param instanced defines if the vertex buffer contains indexed data\r\n * @param useBytes defines if the offset and stride are in bytes *\r\n * @param divisor sets an optional divisor for instances (1 by default)\r\n * @returns the new vertex buffer\r\n */\r\n public createVertexBuffer(kind: string, offset: number, size: number, stride?: number, instanced?: boolean, useBytes = false, divisor?: number): VertexBuffer {\r\n const byteOffset = useBytes ? offset : offset * Float32Array.BYTES_PER_ELEMENT;\r\n const byteStride = stride ? (useBytes ? stride : stride * Float32Array.BYTES_PER_ELEMENT) : this.byteStride;\r\n\r\n // a lot of these parameters are ignored as they are overridden by the buffer\r\n return new VertexBuffer(\r\n this._engine,\r\n this,\r\n kind,\r\n this._updatable,\r\n true,\r\n byteStride,\r\n instanced === undefined ? this._instanced : instanced,\r\n byteOffset,\r\n size,\r\n undefined,\r\n undefined,\r\n true,\r\n this._divisor || divisor\r\n );\r\n }\r\n\r\n // Properties\r\n\r\n /**\r\n * Gets a boolean indicating if the Buffer is updatable?\r\n * @returns true if the buffer is updatable\r\n */\r\n public isUpdatable(): boolean {\r\n return this._updatable;\r\n }\r\n\r\n /**\r\n * Gets current buffer's data\r\n * @returns a DataArray or null\r\n */\r\n public getData(): Nullable<DataArray> {\r\n return this._data;\r\n }\r\n\r\n /**\r\n * Gets underlying native buffer\r\n * @returns underlying native buffer\r\n */\r\n public getBuffer(): Nullable<DataBuffer> {\r\n return this._buffer;\r\n }\r\n\r\n /**\r\n * Gets the stride in float32 units (i.e. byte stride / 4).\r\n * May not be an integer if the byte stride is not divisible by 4.\r\n * @returns the stride in float32 units\r\n * @deprecated Please use byteStride instead.\r\n */\r\n public getStrideSize(): number {\r\n return this.byteStride / Float32Array.BYTES_PER_ELEMENT;\r\n }\r\n\r\n // Methods\r\n\r\n /**\r\n * Store data into the buffer. Creates the buffer if not used already.\r\n * If the buffer was already used, it will be updated only if it is updatable, otherwise it will do nothing.\r\n * @param data defines the data to store\r\n */\r\n public create(data: Nullable<DataArray> = null): void {\r\n if (!data && this._buffer) {\r\n return; // nothing to do\r\n }\r\n\r\n data = data || this._data;\r\n\r\n if (!data) {\r\n return;\r\n }\r\n\r\n if (!this._buffer) {\r\n // create buffer\r\n if (this._updatable) {\r\n this._buffer = this._engine.createDynamicVertexBuffer(data, this._label);\r\n this._data = data;\r\n } else {\r\n this._buffer = this._engine.createVertexBuffer(data, undefined, this._label);\r\n }\r\n } else if (this._updatable) {\r\n // update buffer\r\n this._engine.updateDynamicVertexBuffer(this._buffer, data);\r\n this._data = data;\r\n }\r\n }\r\n\r\n /** @internal */\r\n public _rebuild(): void {\r\n if (!this._data) {\r\n if (!this._buffer) {\r\n // Buffer was not yet created, nothing to do\r\n return;\r\n }\r\n if (this._buffer.capacity > 0) {\r\n // We can at least recreate the buffer with the right size, even if we don't have the data\r\n if (this._updatable) {\r\n this._buffer = this._engine.createDynamicVertexBuffer(this._buffer.capacity, this._label);\r\n } else {\r\n this._buffer = this._engine.createVertexBuffer(this._buffer.capacity, undefined, this._label);\r\n }\r\n return;\r\n }\r\n Logger.Warn(`Missing data for buffer \"${this._label}\" ${this._buffer ? \"(uniqueId: \" + this._buffer.uniqueId + \")\" : \"\"}. Buffer reconstruction failed.`);\r\n this._buffer = null;\r\n } else {\r\n this._buffer = null;\r\n this.create(this._data);\r\n }\r\n }\r\n\r\n /**\r\n * Update current buffer data\r\n * @param data defines the data to store\r\n */\r\n public update(data: DataArray): void {\r\n this.create(data);\r\n }\r\n\r\n /**\r\n * Updates the data directly.\r\n * @param data the new data\r\n * @param offset the new offset\r\n * @param vertexCount the vertex count (optional)\r\n * @param useBytes set to true if the offset is in bytes\r\n */\r\n public updateDirectly(data: DataArray, offset: number, vertexCount?: number, useBytes: boolean = false): void {\r\n if (!this._buffer) {\r\n return;\r\n }\r\n\r\n if (this._updatable) {\r\n // update buffer\r\n this._engine.updateDynamicVertexBuffer(\r\n this._buffer,\r\n data,\r\n useBytes ? offset : offset * Float32Array.BYTES_PER_ELEMENT,\r\n vertexCount ? vertexCount * this.byteStride : undefined\r\n );\r\n if (offset === 0 && vertexCount === undefined) {\r\n // Keep the data if we easily can\r\n this._data = data;\r\n } else {\r\n this._data = null;\r\n }\r\n }\r\n }\r\n\r\n /** @internal */\r\n public _increaseReferences() {\r\n if (!this._buffer) {\r\n return;\r\n }\r\n\r\n if (!this._isAlreadyOwned) {\r\n this._isAlreadyOwned = true;\r\n return;\r\n }\r\n\r\n this._buffer.references++;\r\n }\r\n\r\n /**\r\n * Release all resources\r\n */\r\n public dispose(): void {\r\n if (!this._buffer) {\r\n return;\r\n }\r\n\r\n // The data buffer has an internal counter as this buffer can be used by several VertexBuffer objects\r\n // This means that we only flag it as disposed when all references are released (when _releaseBuffer will return true)\r\n if (this._engine._releaseBuffer(this._buffer)) {\r\n this._isDisposed = true;\r\n this._data = null;\r\n this._buffer = null;\r\n }\r\n }\r\n}\r\n\r\n/**\r\n * Options to be used when creating a vertex buffer\r\n */\r\nexport interface IVertexBufferOptions {\r\n /**\r\n * whether the data is updatable (default: false)\r\n */\r\n updatable?: boolean;\r\n /**\r\n * whether to postpone creating the internal WebGL buffer (default: false)\r\n */\r\n postponeInternalCreation?: boolean;\r\n /**\r\n * the stride (will be automatically computed from the kind parameter if not specified)\r\n */\r\n stride?: number;\r\n /**\r\n * whether the buffer is instanced (default: false)\r\n */\r\n instanced?: boolean;\r\n /**\r\n * the offset of the data (default: 0)\r\n */\r\n offset?: number;\r\n /**\r\n * the number of components (will be automatically computed from the kind parameter if not specified)\r\n */\r\n size?: number;\r\n /**\r\n * the type of the component (will be deduce from the data parameter if not specified)\r\n */\r\n type?: number;\r\n /**\r\n * whether the data contains normalized data (default: false)\r\n */\r\n normalized?: boolean;\r\n /**\r\n * set to true if stride and offset are in bytes (default: false)\r\n */\r\n useBytes?: boolean;\r\n /**\r\n * defines the instance divisor to use (default: 1, only used if instanced is true)\r\n */\r\n divisor?: number;\r\n /**\r\n * defines if the buffer should be released when the vertex buffer is disposed (default: false)\r\n */\r\n takeBufferOwnership?: boolean;\r\n /**\r\n * label to use for this vertex buffer (debugging purpose)\r\n */\r\n label?: string;\r\n}\r\n\r\n/**\r\n * Specialized buffer used to store vertex data\r\n */\r\nexport class VertexBuffer {\r\n private static _Counter = 0;\r\n\r\n /** @internal */\r\n public _buffer: Buffer;\r\n /** @internal */\r\n public _validOffsetRange: boolean; // used internally by the engine\r\n private _kind: string;\r\n private _size: number;\r\n /** @internal */\r\n public _ownsBuffer: boolean;\r\n private _instanced: boolean;\r\n private _instanceDivisor: number;\r\n /** @internal */\r\n public _isDisposed = false;\r\n /** @internal */\r\n public _label?: string;\r\n\r\n /**\r\n * The byte type.\r\n */\r\n public static readonly BYTE = Constants.BYTE;\r\n\r\n /**\r\n * The unsigned byte type.\r\n */\r\n public static readonly UNSIGNED_BYTE = Constants.UNSIGNED_BYTE;\r\n\r\n /**\r\n * The short type.\r\n */\r\n public static readonly SHORT = Constants.SHORT;\r\n\r\n /**\r\n * The unsigned short type.\r\n */\r\n public static readonly UNSIGNED_SHORT = Constants.UNSIGNED_SHORT;\r\n\r\n /**\r\n * The integer type.\r\n */\r\n public static readonly INT = Constants.INT;\r\n\r\n /**\r\n * The unsigned integer type.\r\n */\r\n public static readonly UNSIGNED_INT = Constants.UNSIGNED_INT;\r\n\r\n /**\r\n * The float type.\r\n */\r\n public static readonly FLOAT = Constants.FLOAT;\r\n\r\n /**\r\n * Gets a boolean indicating if the Buffer is disposed\r\n */\r\n public get isDisposed(): boolean {\r\n return this._isDisposed;\r\n }\r\n\r\n /**\r\n * Gets or sets the instance divisor when in instanced mode\r\n */\r\n public get instanceDivisor(): number {\r\n return this._instanceDivisor;\r\n }\r\n\r\n public set instanceDivisor(value: number) {\r\n const isInstanced = value != 0;\r\n this._instanceDivisor = value;\r\n\r\n if (isInstanced !== this._instanced) {\r\n this._instanced = isInstanced;\r\n this._computeHashCode();\r\n }\r\n }\r\n\r\n /**\r\n * Gets the byte stride.\r\n */\r\n public readonly byteStride: number;\r\n\r\n /**\r\n * Gets the byte offset.\r\n */\r\n public readonly byteOffset: number;\r\n\r\n /**\r\n * Gets whether integer data values should be normalized into a certain range when being casted to a float.\r\n */\r\n public readonly normalized: boolean;\r\n\r\n /**\r\n * Gets the data type of each component in the array.\r\n */\r\n public readonly type: number;\r\n\r\n /**\r\n * Gets the unique id of this vertex buffer\r\n */\r\n public readonly uniqueId: number;\r\n\r\n /**\r\n * Gets a hash code representing the format (type, normalized, size, instanced, stride) of this buffer\r\n * All buffers with the same format will have the same hash code\r\n */\r\n public readonly hashCode: number;\r\n\r\n /**\r\n * Gets the engine associated with the buffer\r\n */\r\n public readonly engine: AbstractEngine;\r\n\r\n /**\r\n * Gets the max possible amount of vertices stored within the current vertex buffer.\r\n * We do not have the end offset or count so this will be too big for concatenated vertex buffers.\r\n * @internal\r\n */\r\n public get _maxVerticesCount() {\r\n const data = this.getData();\r\n if (!data) {\r\n return 0;\r\n }\r\n\r\n if (Array.isArray(data)) {\r\n // data is a regular number[] with float values\r\n return data.length / (this.byteStride / 4) - this.byteOffset / 4;\r\n }\r\n\r\n return (data.byteLength - this.byteOffset) / this.byteStride;\r\n }\r\n\r\n /**\r\n * Constructor\r\n * @param engine the engine\r\n * @param data the data to use for this vertex buffer\r\n * @param kind the vertex buffer kind\r\n * @param updatable whether the data is updatable\r\n * @param postponeInternalCreation whether to postpone creating the internal WebGL buffer (optional)\r\n * @param stride the stride (optional)\r\n * @param instanced whether the buffer is instanced (optional)\r\n * @param offset the offset of the data (optional)\r\n * @param size the number of components (optional)\r\n * @param type the type of the component (optional)\r\n * @param normalized whether the data contains normalized data (optional)\r\n * @param useBytes set to true if stride and offset are in bytes (optional)\r\n * @param divisor defines the instance divisor to use (1 by default)\r\n * @param takeBufferOwnership defines if the buffer should be released when the vertex buffer is disposed\r\n */\r\n constructor(\r\n engine: AbstractEngine,\r\n data: DataArray | Buffer | DataBuffer,\r\n kind: string,\r\n updatable: boolean,\r\n postponeInternalCreation?: boolean,\r\n stride?: number,\r\n instanced?: boolean,\r\n offset?: number,\r\n size?: number,\r\n type?: number,\r\n normalized?: boolean,\r\n useBytes?: boolean,\r\n divisor?: number,\r\n takeBufferOwnership?: boolean\r\n );\r\n\r\n /**\r\n * Constructor\r\n * @param engine the engine\r\n * @param data the data to use for this vertex buffer\r\n * @param kind the vertex buffer kind\r\n * @param options defines the rest of the options used to create the buffer\r\n */\r\n constructor(engine: AbstractEngine, data: DataArray | Buffer | DataBuffer, kind: string, options?: IVertexBufferOptions);\r\n\r\n /** @internal */\r\n constructor(\r\n engine: AbstractEngine,\r\n data: DataArray | Buffer | DataBuffer,\r\n kind: string,\r\n updatableOrOptions?: boolean | IVertexBufferOptions,\r\n postponeInternalCreation?: boolean,\r\n stride?: number,\r\n instanced?: boolean,\r\n offset?: number,\r\n size?: number,\r\n type?: number,\r\n normalized = false,\r\n useBytes = false,\r\n divisor = 1,\r\n takeBufferOwnership = false\r\n ) {\r\n let updatable = false;\r\n\r\n this.engine = engine;\r\n\r\n if (typeof updatableOrOptions === \"object\" && updatableOrOptions !== null) {\r\n updatable = updatableOrOptions.updatable ?? false;\r\n postponeInternalCreation = updatableOrOptions.postponeInternalCreation;\r\n stride = updatableOrOptions.stride;\r\n instanced = updatableOrOptions.instanced;\r\n offset = updatableOrOptions.offset;\r\n size = updatableOrOptions.size;\r\n type = updatableOrOptions.type;\r\n normalized = updatableOrOptions.normalized ?? false;\r\n useBytes = updatableOrOptions.useBytes ?? false;\r\n divisor = updatableOrOptions.divisor ?? 1;\r\n takeBufferOwnership = updatableOrOptions.takeBufferOwnership ?? false;\r\n this._label = updatableOrOptions.label;\r\n } else {\r\n updatable = !!updatableOrOptions;\r\n }\r\n\r\n if (data instanceof Buffer) {\r\n this._buffer = data;\r\n this._ownsBuffer = takeBufferOwnership;\r\n } else {\r\n this._buffer = new Buffer(engine, data, updatable, stride, postponeInternalCreation, instanced, useBytes, divisor, this._label);\r\n this._ownsBuffer = true;\r\n }\r\n\r\n this.uniqueId = VertexBuffer._Counter++;\r\n this._kind = kind;\r\n\r\n if (type === undefined) {\r\n const vertexData = this.getData();\r\n this.type = vertexData ? VertexBuffer.GetDataType(vertexData) : VertexBuffer.FLOAT;\r\n } else {\r\n this.type = type;\r\n }\r\n\r\n const typeByteLength = VertexBuffer.GetTypeByteLength(this.type);\r\n\r\n if (useBytes) {\r\n this._size = size || (stride ? stride / typeByteLength : VertexBuffer.DeduceStride(kind));\r\n this.byteStride = stride || this._buffer.byteStride || this._size * typeByteLength;\r\n this.byteOffset = offset || 0;\r\n } else {\r\n this._size = size || stride || VertexBuffer.DeduceStride(kind);\r\n this.byteStride = stride ? stride * typeByteLength : this._buffer.byteStride || this._size * typeByteLength;\r\n this.byteOffset = (offset || 0) * typeByteLength;\r\n }\r\n\r\n this.normalized = normalized;\r\n\r\n this._instanced = instanced !== undefined ? instanced : false;\r\n this._instanceDivisor = instanced ? divisor : 0;\r\n\r\n this._alignBuffer();\r\n this._computeHashCode();\r\n }\r\n\r\n private _computeHashCode(): void {\r\n // note: cast to any because the property is declared readonly\r\n (this.hashCode as any) =\r\n ((this.type - 5120) << 0) +\r\n ((this.normalized ? 1 : 0) << 3) +\r\n (this._size << 4) +\r\n ((this._instanced ? 1 : 0) << 6) +\r\n /* keep 5 bits free */\r\n (this.byteStride << 12);\r\n }\r\n\r\n /** @internal */\r\n public _rebuild(): void {\r\n this._buffer?._rebuild();\r\n }\r\n\r\n /**\r\n * Returns the kind of the VertexBuffer (string)\r\n * @returns a string\r\n */\r\n public getKind(): string {\r\n return this._kind;\r\n }\r\n\r\n // Properties\r\n\r\n /**\r\n * Gets a boolean indicating if the VertexBuffer is updatable?\r\n * @returns true if the buffer is updatable\r\n */\r\n public isUpdatable(): boolean {\r\n return this._buffer.isUpdatable();\r\n }\r\n\r\n /**\r\n * Gets current buffer's data\r\n * @returns a DataArray or null\r\n */\r\n public getData(): Nullable<DataArray> {\r\n return this._buffer.getData();\r\n }\r\n\r\n /**\r\n * Gets current buffer's data as a float array. Float data is constructed if the vertex buffer data cannot be returned directly.\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\n public getFloatData(totalVertices: number, forceCopy?: boolean): Nullable<FloatArray> {\r\n const data = this.getData();\r\n if (!data) {\r\n return null;\r\n }\r\n\r\n return VertexBuffer.GetFloatData(data, this._size, this.type, this.byteOffset, this.byteStride, this.normalized, totalVertices, forceCopy);\r\n }\r\n\r\n /**\r\n * Gets underlying native buffer\r\n * @returns underlying native buffer\r\n */\r\n public getBuffer(): Nullable<DataBuffer> {\r\n return this._buffer.getBuffer();\r\n }\r\n\r\n /**\r\n * Gets the Buffer instance that wraps the native GPU buffer\r\n * @returns the wrapper buffer\r\n */\r\n public getWrapperBuffer(): Buffer {\r\n return this._buffer;\r\n }\r\n\r\n /**\r\n * Gets the stride in float32 units (i.e. byte stride / 4).\r\n * May not be an integer if the byte stride is not divisible by 4.\r\n * @returns the stride in float32 units\r\n * @deprecated Please use byteStride instead.\r\n */\r\n public getStrideSize(): number {\r\n return this.byteStride / VertexBuffer.GetTypeByteLength(this.type);\r\n }\r\n\r\n /**\r\n * Returns the offset as a multiple of the type byte length.\r\n * @returns the offset in bytes\r\n * @deprecated Please use byteOffset instead.\r\n */\r\n public getOffset(): number {\r\n return this.byteOffset / VertexBuffer.GetTypeByteLength(this.type);\r\n }\r\n\r\n /**\r\n * Returns the number of components or the byte size per vertex attribute\r\n * @param sizeInBytes If true, returns the size in bytes or else the size in number of components of the vertex attribute (default: false)\r\n * @returns the number of components\r\n */\r\n public getSize(sizeInBytes = false): number {\r\n return sizeInBytes ? this._size * VertexBuffer.GetTypeByteLength(this.type) : this._size;\r\n }\r\n\r\n /**\r\n * Gets a boolean indicating is the internal buffer of the VertexBuffer is instanced\r\n * @returns true if this buffer is instanced\r\n */\r\n public getIsInstanced(): boolean {\r\n return this._instanced;\r\n }\r\n\r\n /**\r\n * Returns the instancing divisor, zero for non-instanced (integer).\r\n * @returns a number\r\n */\r\n public getInstanceDivisor(): number {\r\n return this._instanceDivisor;\r\n }\r\n\r\n // Methods\r\n\r\n /**\r\n * Store data into the buffer. If the buffer was already used it will be either recreated or updated depending on isUpdatable property\r\n * @param data defines the data to store\r\n */\r\n public create(data?: DataArray): void {\r\n this._buffer.create(data);\r\n this._alignBuffer();\r\n }\r\n\r\n /**\r\n * Updates the underlying buffer according to the passed numeric array or Float32Array.\r\n * This function will create a new buffer if the current one is not updatable\r\n * @param data defines the data to store\r\n */\r\n public update(data: DataArray): void {\r\n this._buffer.update(data);\r\n this._alignBuffer();\r\n }\r\n\r\n /**\r\n * Updates directly the underlying WebGLBuffer according to the passed numeric array or Float32Array.\r\n * Returns the directly updated WebGLBuffer.\r\n * @param data the new data\r\n * @param offset the new offset\r\n * @param useBytes set to true if the offset is in bytes\r\n */\r\n public updateDirectly(data: DataArray, offset: number, useBytes: boolean = false): void {\r\n this._buffer.updateDirectly(data, offset, undefined, useBytes);\r\n this._alignBuffer();\r\n }\r\n\r\n /**\r\n * Disposes the VertexBuffer and the underlying WebGLBuffer.\r\n */\r\n public dispose(): void {\r\n if (this._ownsBuffer) {\r\n this._buffer.dispose();\r\n }\r\n\r\n this._isDisposed = true;\r\n }\r\n\r\n /**\r\n * Enumerates each value of this vertex buffer as numbers.\r\n * @param count the number of values to enumerate\r\n * @param callback the callback function called for each value\r\n */\r\n public forEach(count: number, callback: (value: number, index: number) => void): void {\r\n VertexBuffer.ForEach(this._buffer.getData()!, this.byteOffset, this.byteStride, this._size, this.type, count, this.normalized, callback);\r\n }\r\n\r\n /** @internal */\r\n public _alignBuffer() {}\r\n\r\n // Enums\r\n /**\r\n * Positions\r\n */\r\n public static readonly PositionKind = Constants.PositionKind;\r\n /**\r\n * Normals\r\n */\r\n public static readonly NormalKind = Constants.NormalKind;\r\n /**\r\n * Tangents\r\n */\r\n public static readonly TangentKind = Constants.TangentKind;\r\n /**\r\n * Texture coordinates\r\n */\r\n public static readonly UVKind = Constants.UVKind;\r\n /**\r\n * Texture coordinates 2\r\n */\r\n public static readonly UV2Kind = Constants.UV2Kind;\r\n /**\r\n * Texture coordinates 3\r\n */\r\n public static readonly UV3Kind = Constants.UV3Kind;\r\n /**\r\n * Texture coordinates 4\r\n */\r\n public static readonly UV4Kind = Constants.UV4Kind;\r\n /**\r\n * Texture coordinates 5\r\n */\r\n public static readonly UV5Kind = Constants.UV5Kind;\r\n /**\r\n * Texture coordinates 6\r\n */\r\n public static readonly UV6Kind = Constants.UV6Kind;\r\n /**\r\n * Colors\r\n */\r\n public static readonly ColorKind = Constants.ColorKind;\r\n /**\r\n * Instance Colors\r\n */\r\n public static readonly ColorInstanceKind = Constants.ColorInstanceKind;\r\n /**\r\n * Matrix indices (for bones)\r\n */\r\n public static readonly MatricesIndicesKind = Constants.MatricesIndicesKind;\r\n /**\r\n * Matrix weights (for bones)\r\n */\r\n public static readonly MatricesWeightsKind = Constants.MatricesWeightsKind;\r\n /**\r\n * Additional matrix indices (for bones)\r\n */\r\n public static readonly MatricesIndicesExtraKind = Constants.MatricesIndicesExtraKind;\r\n /**\r\n * Additional matrix weights (for bones)\r\n */\r\n public static readonly MatricesWeightsExtraKind = Constants.MatricesWeightsExtraKind;\r\n\r\n /**\r\n * Deduces the stride given a kind.\r\n * @param kind The kind string to deduce\r\n * @returns The deduced stride\r\n */\r\n public static DeduceStride(kind: string): number {\r\n switch (kind) {\r\n case VertexBuffer.UVKind:\r\n case VertexBuffer.UV2Kind:\r\n case VertexBuffer.UV3Kind:\r\n case VertexBuffer.UV4Kind:\r\n case VertexBuffer.UV5Kind:\r\n case VertexBuffer.UV6Kind:\r\n return 2;\r\n case VertexBuffer.NormalKind:\r\n case VertexBuffer.PositionKind:\r\n return 3;\r\n case VertexBuffer.ColorKind:\r\n case VertexBuffer.ColorInstanceKind:\r\n case VertexBuffer.MatricesIndicesKind:\r\n case VertexBuffer.MatricesIndicesExtraKind:\r\n case VertexBuffer.MatricesWeightsKind:\r\n case VertexBuffer.MatricesWeightsExtraKind:\r\n case VertexBuffer.TangentKind:\r\n return 4;\r\n default:\r\n throw new Error(\"Invalid kind '\" + kind + \"'\");\r\n }\r\n }\r\n\r\n /**\r\n * Gets the vertex buffer type of the given data array.\r\n * @param data the data array\r\n * @returns the vertex buffer type\r\n */\r\n public static GetDataType(data: DataArray): number {\r\n if (data instanceof Int8Array) {\r\n return VertexBuffer.BYTE;\r\n } else if (data instanceof Uint8Array) {\r\n return VertexBuffer.UNSIGNED_BYTE;\r\n } else if (data instanceof Int16Array) {\r\n return VertexBuffer.SHORT;\r\n } else if (data instanceof Uint16Array) {\r\n return VertexBuffer.UNSIGNED_SHORT;\r\n } else if (data instanceof Int32Array) {\r\n return VertexBuffer.INT;\r\n } else if (data instanceof Uint32Array) {\r\n return VertexBuffer.UNSIGNED_INT;\r\n } else {\r\n return VertexBuffer.FLOAT;\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\n public static GetTypeByteLength(type: number): number {\r\n switch (type) {\r\n case VertexBuffer.BYTE:\r\n case VertexBuffer.UNSIGNED_BYTE:\r\n return 1;\r\n case VertexBuffer.SHORT:\r\n case VertexBuffer.UNSIGNED_SHORT:\r\n return 2;\r\n case VertexBuffer.INT:\r\n case VertexBuffer.UNSIGNED_INT:\r\n case VertexBuffer.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 * Enumerates each value of the given parameters as numbers.\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 value\r\n */\r\n public static ForEach(\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: (value: number, index: number) => void\r\n ): void {\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 callback(data[offset + componentIndex], index + componentIndex);\r\n }\r\n offset += stride;\r\n }\r\n } else {\r\n const dataView = data instanceof ArrayBuffer ? new DataView(data) : new DataView(data.buffer, data.byteOffset, data.byteLength);\r\n const componentByteLength = VertexBuffer.GetTypeByteLength(componentType);\r\n for (let index = 0; index < count; index += componentCount) {\r\n let componentByteOffset = byteOffset;\r\n for (let componentIndex = 0; componentIndex < componentCount; componentIndex++) {\r\n const value = VertexBuffer._GetFloatValue(dataView, componentType, componentByteOffset, normalized);\r\n callback(value, index + componentIndex);\r\n componentByteOffset += componentByteLength;\r\n }\r\n byteOffset += byteStride;\r\n }\r\n }\r\n }\r\n\r\n private static _GetFloatValue(dataView: DataView, type: number, byteOffset: number, normalized: boolean): number {\r\n switch (type) {\r\n case VertexBuffer.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 VertexBuffer.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 VertexBuffer.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 VertexBuffer.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 VertexBuffer.INT: {\r\n return dataView.getInt32(byteOffset, true);\r\n }\r\n case VertexBuffer.UNSIGNED_INT: {\r\n return dataView.getUint32(byteOffset, true);\r\n }\r\n case VertexBuffer.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\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\n public static 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 * VertexBuffer.GetTypeByteLength(type);\r\n const count = totalVertices * size;\r\n\r\n if (type !== VertexBuffer.FLOAT || byteStride !== tightlyPackedByteStride) {\r\n const copy = new Float32Array(count);\r\n VertexBuffer.ForEach(data, byteOffset, byteStride, size, type, count, normalized, (value, index) => (copy[index] = value));\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 const result = new Uint8Array(count * Float32Array.BYTES_PER_ELEMENT);\r\n const source = new Uint8Array(data.buffer, offset, result.length);\r\n result.set(source);\r\n return new Float32Array(result.buffer);\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"]}
|
|
1
|
+
{"version":3,"file":"buffer.js","sourceRoot":"","sources":["../../../../dev/core/src/Buffers/buffer.ts"],"names":[],"mappings":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AzB,CAA0B;AAE7D;;GAEG;AACoB,kBAAK,GAAG,SAAS,CAAC,KAAK,AAAlB,CAAmB;AA0X/C,QAAQ;AACR;;GAEG;AACoB,yBAAY,GAAG,SAAS,CAAC,YAAY,AAAzB,CAA0B;AAC7D;;GAEG;AACoB,uBAAU,GAAG,SAAS,CAAC,UAAU,AAAvB,CAAwB;AACzD;;GAEG;AACoB,wBAAW,GAAG,SAAS,CAAC,WAAW,AAAxB,CAAyB;AAC3D;;GAEG;AACoB,mBAAM,GAAG,SAAS,CAAC,MAAM,AAAnB,CAAoB;AACjD;;GAEG;AACoB,oBAAO,GAAG,SAAS,CAAC,OAAO,AAApB,CAAqB;AACnD;;GAEG;AACoB,oBAAO,GAAG,SAAS,CAAC,OAAO,AAApB,CAAqB;AACnD;;GAEG;AACoB,oBAAO,GAAG,SAAS,CAAC,OAAO,AAApB,CAAqB;AACnD;;GAEG;AACoB,oBAAO,GAAG,SAAS,CAAC,OAAO,AAApB,CAAqB;AACnD;;GAEG;AACoB,oBAAO,GAAG,SAAS,CAAC,OAAO,AAApB,CAAqB;AACnD;;GAEG;AACoB,sBAAS,GAAG,SAAS,CAAC,SAAS,AAAtB,CAAuB;AACvD;;GAEG;AACoB,8BAAiB,GAAG,SAAS,CAAC,iBAAiB,AAA9B,CAA+B;AACvE;;GAEG;AACoB,gCAAmB,GAAG,SAAS,CAAC,mBAAmB,AAAhC,CAAiC;AAC3E;;GAEG;AACoB,gCAAmB,GAAG,SAAS,CAAC,mBAAmB,AAAhC,CAAiC;AAC3E;;GAEG;AACoB,qCAAwB,GAAG,SAAS,CAAC,wBAAwB,AAArC,CAAsC;AACrF;;GAEG;AACoB,qCAAwB,GAAG,SAAS,CAAC,wBAAwB,AAArC,CAAsC","sourcesContent":["import type { Nullable, DataArray, FloatArray } from \"../types\";\r\nimport type { AbstractEngine } from \"../Engines/abstractEngine\";\r\nimport { DataBuffer } from \"./dataBuffer\";\r\nimport type { Mesh } from \"../Meshes/mesh\";\r\nimport { Logger } from \"../Misc/logger\";\r\nimport { Constants } from \"../Engines/constants\";\r\nimport { EnumerateFloatValues, GetFloatData, GetTypeByteLength } from \"./bufferUtils\";\r\n\r\n/**\r\n * Class used to store data that will be store in GPU memory\r\n */\r\nexport class Buffer {\r\n private _engine: AbstractEngine;\r\n private _buffer: Nullable<DataBuffer>;\r\n /** @internal */\r\n public _data: Nullable<DataArray>;\r\n private _updatable: boolean;\r\n private _instanced: boolean;\r\n private _divisor: number;\r\n private _isAlreadyOwned = false;\r\n private _isDisposed = false;\r\n private _label?: string;\r\n\r\n /**\r\n * Gets a boolean indicating if the Buffer is disposed\r\n */\r\n public get isDisposed(): boolean {\r\n return this._isDisposed;\r\n }\r\n\r\n /**\r\n * Gets the byte stride.\r\n */\r\n public readonly byteStride: number;\r\n\r\n /**\r\n * Constructor\r\n * @param engine the engine\r\n * @param data the data to use for this buffer\r\n * @param updatable whether the data is updatable\r\n * @param stride the stride (optional)\r\n * @param postponeInternalCreation whether to postpone creating the internal WebGL buffer (optional)\r\n * @param instanced whether the buffer is instanced (optional)\r\n * @param useBytes set to true if the stride in in bytes (optional)\r\n * @param divisor sets an optional divisor for instances (1 by default)\r\n * @param label defines the label of the buffer (for debug purpose)\r\n */\r\n constructor(\r\n engine: AbstractEngine,\r\n data: DataArray | DataBuffer,\r\n updatable: boolean,\r\n stride = 0,\r\n postponeInternalCreation = false,\r\n instanced = false,\r\n useBytes = false,\r\n divisor?: number,\r\n label?: string\r\n ) {\r\n if (engine && (engine as unknown as Mesh).getScene) {\r\n // old versions of VertexBuffer accepted 'mesh' instead of 'engine'\r\n this._engine = (engine as unknown as Mesh).getScene().getEngine();\r\n } else {\r\n this._engine = engine;\r\n }\r\n\r\n this._updatable = updatable;\r\n this._instanced = instanced;\r\n this._divisor = divisor || 1;\r\n this._label = label;\r\n\r\n if (data instanceof DataBuffer) {\r\n this._data = null;\r\n this._buffer = data;\r\n } else {\r\n this._data = data;\r\n this._buffer = null;\r\n }\r\n\r\n this.byteStride = useBytes ? stride : stride * Float32Array.BYTES_PER_ELEMENT;\r\n\r\n if (!postponeInternalCreation) {\r\n // by default\r\n this.create();\r\n }\r\n }\r\n\r\n /**\r\n * Create a new VertexBuffer based on the current buffer\r\n * @param kind defines the vertex buffer kind (position, normal, etc.)\r\n * @param offset defines offset in the buffer (0 by default)\r\n * @param size defines the size in floats of attributes (position is 3 for instance)\r\n * @param stride defines the stride size in floats in the buffer (the offset to apply to reach next value when data is interleaved)\r\n * @param instanced defines if the vertex buffer contains indexed data\r\n * @param useBytes defines if the offset and stride are in bytes *\r\n * @param divisor sets an optional divisor for instances (1 by default)\r\n * @returns the new vertex buffer\r\n */\r\n public createVertexBuffer(kind: string, offset: number, size: number, stride?: number, instanced?: boolean, useBytes = false, divisor?: number): VertexBuffer {\r\n const byteOffset = useBytes ? offset : offset * Float32Array.BYTES_PER_ELEMENT;\r\n const byteStride = stride ? (useBytes ? stride : stride * Float32Array.BYTES_PER_ELEMENT) : this.byteStride;\r\n\r\n // a lot of these parameters are ignored as they are overridden by the buffer\r\n return new VertexBuffer(\r\n this._engine,\r\n this,\r\n kind,\r\n this._updatable,\r\n true,\r\n byteStride,\r\n instanced === undefined ? this._instanced : instanced,\r\n byteOffset,\r\n size,\r\n undefined,\r\n undefined,\r\n true,\r\n this._divisor || divisor\r\n );\r\n }\r\n\r\n // Properties\r\n\r\n /**\r\n * Gets a boolean indicating if the Buffer is updatable?\r\n * @returns true if the buffer is updatable\r\n */\r\n public isUpdatable(): boolean {\r\n return this._updatable;\r\n }\r\n\r\n /**\r\n * Gets current buffer's data\r\n * @returns a DataArray or null\r\n */\r\n public getData(): Nullable<DataArray> {\r\n return this._data;\r\n }\r\n\r\n /**\r\n * Gets underlying native buffer\r\n * @returns underlying native buffer\r\n */\r\n public getBuffer(): Nullable<DataBuffer> {\r\n return this._buffer;\r\n }\r\n\r\n /**\r\n * Gets the stride in float32 units (i.e. byte stride / 4).\r\n * May not be an integer if the byte stride is not divisible by 4.\r\n * @returns the stride in float32 units\r\n * @deprecated Please use byteStride instead.\r\n */\r\n public getStrideSize(): number {\r\n return this.byteStride / Float32Array.BYTES_PER_ELEMENT;\r\n }\r\n\r\n // Methods\r\n\r\n /**\r\n * Store data into the buffer. Creates the buffer if not used already.\r\n * If the buffer was already used, it will be updated only if it is updatable, otherwise it will do nothing.\r\n * @param data defines the data to store\r\n */\r\n public create(data: Nullable<DataArray> = null): void {\r\n if (!data && this._buffer) {\r\n return; // nothing to do\r\n }\r\n\r\n data = data || this._data;\r\n\r\n if (!data) {\r\n return;\r\n }\r\n\r\n if (!this._buffer) {\r\n // create buffer\r\n if (this._updatable) {\r\n this._buffer = this._engine.createDynamicVertexBuffer(data, this._label);\r\n this._data = data;\r\n } else {\r\n this._buffer = this._engine.createVertexBuffer(data, undefined, this._label);\r\n }\r\n } else if (this._updatable) {\r\n // update buffer\r\n this._engine.updateDynamicVertexBuffer(this._buffer, data);\r\n this._data = data;\r\n }\r\n }\r\n\r\n /** @internal */\r\n public _rebuild(): void {\r\n if (!this._data) {\r\n if (!this._buffer) {\r\n // Buffer was not yet created, nothing to do\r\n return;\r\n }\r\n if (this._buffer.capacity > 0) {\r\n // We can at least recreate the buffer with the right size, even if we don't have the data\r\n if (this._updatable) {\r\n this._buffer = this._engine.createDynamicVertexBuffer(this._buffer.capacity, this._label);\r\n } else {\r\n this._buffer = this._engine.createVertexBuffer(this._buffer.capacity, undefined, this._label);\r\n }\r\n return;\r\n }\r\n Logger.Warn(`Missing data for buffer \"${this._label}\" ${this._buffer ? \"(uniqueId: \" + this._buffer.uniqueId + \")\" : \"\"}. Buffer reconstruction failed.`);\r\n this._buffer = null;\r\n } else {\r\n this._buffer = null;\r\n this.create(this._data);\r\n }\r\n }\r\n\r\n /**\r\n * Update current buffer data\r\n * @param data defines the data to store\r\n */\r\n public update(data: DataArray): void {\r\n this.create(data);\r\n }\r\n\r\n /**\r\n * Updates the data directly.\r\n * @param data the new data\r\n * @param offset the new offset\r\n * @param vertexCount the vertex count (optional)\r\n * @param useBytes set to true if the offset is in bytes\r\n */\r\n public updateDirectly(data: DataArray, offset: number, vertexCount?: number, useBytes: boolean = false): void {\r\n if (!this._buffer) {\r\n return;\r\n }\r\n\r\n if (this._updatable) {\r\n // update buffer\r\n this._engine.updateDynamicVertexBuffer(\r\n this._buffer,\r\n data,\r\n useBytes ? offset : offset * Float32Array.BYTES_PER_ELEMENT,\r\n vertexCount ? vertexCount * this.byteStride : undefined\r\n );\r\n if (offset === 0 && vertexCount === undefined) {\r\n // Keep the data if we easily can\r\n this._data = data;\r\n } else {\r\n this._data = null;\r\n }\r\n }\r\n }\r\n\r\n /** @internal */\r\n public _increaseReferences() {\r\n if (!this._buffer) {\r\n return;\r\n }\r\n\r\n if (!this._isAlreadyOwned) {\r\n this._isAlreadyOwned = true;\r\n return;\r\n }\r\n\r\n this._buffer.references++;\r\n }\r\n\r\n /**\r\n * Release all resources\r\n */\r\n public dispose(): void {\r\n if (!this._buffer) {\r\n return;\r\n }\r\n\r\n // The data buffer has an internal counter as this buffer can be used by several VertexBuffer objects\r\n // This means that we only flag it as disposed when all references are released (when _releaseBuffer will return true)\r\n if (this._engine._releaseBuffer(this._buffer)) {\r\n this._isDisposed = true;\r\n this._data = null;\r\n this._buffer = null;\r\n }\r\n }\r\n}\r\n\r\n/**\r\n * Options to be used when creating a vertex buffer\r\n */\r\nexport interface IVertexBufferOptions {\r\n /**\r\n * whether the data is updatable (default: false)\r\n */\r\n updatable?: boolean;\r\n /**\r\n * whether to postpone creating the internal WebGL buffer (default: false)\r\n */\r\n postponeInternalCreation?: boolean;\r\n /**\r\n * the stride (will be automatically computed from the kind parameter if not specified)\r\n */\r\n stride?: number;\r\n /**\r\n * whether the buffer is instanced (default: false)\r\n */\r\n instanced?: boolean;\r\n /**\r\n * the offset of the data (default: 0)\r\n */\r\n offset?: number;\r\n /**\r\n * the number of components (will be automatically computed from the kind parameter if not specified)\r\n */\r\n size?: number;\r\n /**\r\n * the type of the component (will be deduce from the data parameter if not specified)\r\n */\r\n type?: number;\r\n /**\r\n * whether the data contains normalized data (default: false)\r\n */\r\n normalized?: boolean;\r\n /**\r\n * set to true if stride and offset are in bytes (default: false)\r\n */\r\n useBytes?: boolean;\r\n /**\r\n * defines the instance divisor to use (default: 1, only used if instanced is true)\r\n */\r\n divisor?: number;\r\n /**\r\n * defines if the buffer should be released when the vertex buffer is disposed (default: false)\r\n */\r\n takeBufferOwnership?: boolean;\r\n /**\r\n * label to use for this vertex buffer (debugging purpose)\r\n */\r\n label?: string;\r\n}\r\n\r\n/**\r\n * Specialized buffer used to store vertex data\r\n */\r\nexport class VertexBuffer {\r\n private static _Counter = 0;\r\n\r\n /** @internal */\r\n public _buffer: Buffer;\r\n /** @internal */\r\n public _validOffsetRange: boolean; // used internally by the engine\r\n private _kind: string;\r\n private _size: number;\r\n /** @internal */\r\n public _ownsBuffer: boolean;\r\n private _instanced: boolean;\r\n private _instanceDivisor: number;\r\n /** @internal */\r\n public _isDisposed = false;\r\n /** @internal */\r\n public _label?: string;\r\n\r\n /**\r\n * The byte type.\r\n */\r\n public static readonly BYTE = Constants.BYTE;\r\n\r\n /**\r\n * The unsigned byte type.\r\n */\r\n public static readonly UNSIGNED_BYTE = Constants.UNSIGNED_BYTE;\r\n\r\n /**\r\n * The short type.\r\n */\r\n public static readonly SHORT = Constants.SHORT;\r\n\r\n /**\r\n * The unsigned short type.\r\n */\r\n public static readonly UNSIGNED_SHORT = Constants.UNSIGNED_SHORT;\r\n\r\n /**\r\n * The integer type.\r\n */\r\n public static readonly INT = Constants.INT;\r\n\r\n /**\r\n * The unsigned integer type.\r\n */\r\n public static readonly UNSIGNED_INT = Constants.UNSIGNED_INT;\r\n\r\n /**\r\n * The float type.\r\n */\r\n public static readonly FLOAT = Constants.FLOAT;\r\n\r\n /**\r\n * Gets a boolean indicating if the Buffer is disposed\r\n */\r\n public get isDisposed(): boolean {\r\n return this._isDisposed;\r\n }\r\n\r\n /**\r\n * Gets or sets the instance divisor when in instanced mode\r\n */\r\n public get instanceDivisor(): number {\r\n return this._instanceDivisor;\r\n }\r\n\r\n public set instanceDivisor(value: number) {\r\n const isInstanced = value != 0;\r\n this._instanceDivisor = value;\r\n\r\n if (isInstanced !== this._instanced) {\r\n this._instanced = isInstanced;\r\n this._computeHashCode();\r\n }\r\n }\r\n\r\n /**\r\n * Gets the byte stride.\r\n */\r\n public readonly byteStride: number;\r\n\r\n /**\r\n * Gets the byte offset.\r\n */\r\n public readonly byteOffset: number;\r\n\r\n /**\r\n * Gets whether integer data values should be normalized into a certain range when being casted to a float.\r\n */\r\n public readonly normalized: boolean;\r\n\r\n /**\r\n * Gets the data type of each component in the array.\r\n */\r\n public readonly type: number;\r\n\r\n /**\r\n * Gets the unique id of this vertex buffer\r\n */\r\n public readonly uniqueId: number;\r\n\r\n /**\r\n * Gets a hash code representing the format (type, normalized, size, instanced, stride) of this buffer\r\n * All buffers with the same format will have the same hash code\r\n */\r\n public readonly hashCode: number;\r\n\r\n /**\r\n * Gets the engine associated with the buffer\r\n */\r\n public readonly engine: AbstractEngine;\r\n\r\n /**\r\n * Gets the max possible amount of vertices stored within the current vertex buffer.\r\n * We do not have the end offset or count so this will be too big for concatenated vertex buffers.\r\n * @internal\r\n */\r\n public get _maxVerticesCount() {\r\n const data = this.getData();\r\n if (!data) {\r\n return 0;\r\n }\r\n\r\n if (Array.isArray(data)) {\r\n // data is a regular number[] with float values\r\n return data.length / (this.byteStride / 4) - this.byteOffset / 4;\r\n }\r\n\r\n return (data.byteLength - this.byteOffset) / this.byteStride;\r\n }\r\n\r\n /**\r\n * Constructor\r\n * @param engine the engine\r\n * @param data the data to use for this vertex buffer\r\n * @param kind the vertex buffer kind\r\n * @param updatable whether the data is updatable\r\n * @param postponeInternalCreation whether to postpone creating the internal WebGL buffer (optional)\r\n * @param stride the stride (optional)\r\n * @param instanced whether the buffer is instanced (optional)\r\n * @param offset the offset of the data (optional)\r\n * @param size the number of components (optional)\r\n * @param type the type of the component (optional)\r\n * @param normalized whether the data contains normalized data (optional)\r\n * @param useBytes set to true if stride and offset are in bytes (optional)\r\n * @param divisor defines the instance divisor to use (1 by default)\r\n * @param takeBufferOwnership defines if the buffer should be released when the vertex buffer is disposed\r\n */\r\n constructor(\r\n engine: AbstractEngine,\r\n data: DataArray | Buffer | DataBuffer,\r\n kind: string,\r\n updatable: boolean,\r\n postponeInternalCreation?: boolean,\r\n stride?: number,\r\n instanced?: boolean,\r\n offset?: number,\r\n size?: number,\r\n type?: number,\r\n normalized?: boolean,\r\n useBytes?: boolean,\r\n divisor?: number,\r\n takeBufferOwnership?: boolean\r\n );\r\n\r\n /**\r\n * Constructor\r\n * @param engine the engine\r\n * @param data the data to use for this vertex buffer\r\n * @param kind the vertex buffer kind\r\n * @param options defines the rest of the options used to create the buffer\r\n */\r\n constructor(engine: AbstractEngine, data: DataArray | Buffer | DataBuffer, kind: string, options?: IVertexBufferOptions);\r\n\r\n /** @internal */\r\n constructor(\r\n engine: AbstractEngine,\r\n data: DataArray | Buffer | DataBuffer,\r\n kind: string,\r\n updatableOrOptions?: boolean | IVertexBufferOptions,\r\n postponeInternalCreation?: boolean,\r\n stride?: number,\r\n instanced?: boolean,\r\n offset?: number,\r\n size?: number,\r\n type?: number,\r\n normalized = false,\r\n useBytes = false,\r\n divisor = 1,\r\n takeBufferOwnership = false\r\n ) {\r\n let updatable = false;\r\n\r\n this.engine = engine;\r\n\r\n if (typeof updatableOrOptions === \"object\" && updatableOrOptions !== null) {\r\n updatable = updatableOrOptions.updatable ?? false;\r\n postponeInternalCreation = updatableOrOptions.postponeInternalCreation;\r\n stride = updatableOrOptions.stride;\r\n instanced = updatableOrOptions.instanced;\r\n offset = updatableOrOptions.offset;\r\n size = updatableOrOptions.size;\r\n type = updatableOrOptions.type;\r\n normalized = updatableOrOptions.normalized ?? false;\r\n useBytes = updatableOrOptions.useBytes ?? false;\r\n divisor = updatableOrOptions.divisor ?? 1;\r\n takeBufferOwnership = updatableOrOptions.takeBufferOwnership ?? false;\r\n this._label = updatableOrOptions.label;\r\n } else {\r\n updatable = !!updatableOrOptions;\r\n }\r\n\r\n if (data instanceof Buffer) {\r\n this._buffer = data;\r\n this._ownsBuffer = takeBufferOwnership;\r\n } else {\r\n this._buffer = new Buffer(engine, data, updatable, stride, postponeInternalCreation, instanced, useBytes, divisor, this._label);\r\n this._ownsBuffer = true;\r\n }\r\n\r\n this.uniqueId = VertexBuffer._Counter++;\r\n this._kind = kind;\r\n\r\n if (type === undefined) {\r\n const vertexData = this.getData();\r\n this.type = vertexData ? VertexBuffer.GetDataType(vertexData) : VertexBuffer.FLOAT;\r\n } else {\r\n this.type = type;\r\n }\r\n\r\n const typeByteLength = GetTypeByteLength(this.type);\r\n\r\n if (useBytes) {\r\n this._size = size || (stride ? stride / typeByteLength : VertexBuffer.DeduceStride(kind));\r\n this.byteStride = stride || this._buffer.byteStride || this._size * typeByteLength;\r\n this.byteOffset = offset || 0;\r\n } else {\r\n this._size = size || stride || VertexBuffer.DeduceStride(kind);\r\n this.byteStride = stride ? stride * typeByteLength : this._buffer.byteStride || this._size * typeByteLength;\r\n this.byteOffset = (offset || 0) * typeByteLength;\r\n }\r\n\r\n this.normalized = normalized;\r\n\r\n this._instanced = instanced !== undefined ? instanced : false;\r\n this._instanceDivisor = instanced ? divisor : 0;\r\n\r\n this._alignBuffer();\r\n this._computeHashCode();\r\n }\r\n\r\n private _computeHashCode(): void {\r\n // note: cast to any because the property is declared readonly\r\n (this.hashCode as any) =\r\n ((this.type - 5120) << 0) +\r\n ((this.normalized ? 1 : 0) << 3) +\r\n (this._size << 4) +\r\n ((this._instanced ? 1 : 0) << 6) +\r\n /* keep 5 bits free */\r\n (this.byteStride << 12);\r\n }\r\n\r\n /** @internal */\r\n public _rebuild(): void {\r\n this._buffer?._rebuild();\r\n }\r\n\r\n /**\r\n * Returns the kind of the VertexBuffer (string)\r\n * @returns a string\r\n */\r\n public getKind(): string {\r\n return this._kind;\r\n }\r\n\r\n // Properties\r\n\r\n /**\r\n * Gets a boolean indicating if the VertexBuffer is updatable?\r\n * @returns true if the buffer is updatable\r\n */\r\n public isUpdatable(): boolean {\r\n return this._buffer.isUpdatable();\r\n }\r\n\r\n /**\r\n * Gets current buffer's data\r\n * @returns a DataArray or null\r\n */\r\n public getData(): Nullable<DataArray> {\r\n return this._buffer.getData();\r\n }\r\n\r\n /**\r\n * Gets current buffer's data as a float array. Float data is constructed if the vertex buffer data cannot be returned directly.\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\n public getFloatData(totalVertices: number, forceCopy?: boolean): Nullable<FloatArray> {\r\n const data = this.getData();\r\n if (!data) {\r\n return null;\r\n }\r\n\r\n return GetFloatData(data, this._size, this.type, this.byteOffset, this.byteStride, this.normalized, totalVertices, forceCopy);\r\n }\r\n\r\n /**\r\n * Gets underlying native buffer\r\n * @returns underlying native buffer\r\n */\r\n public getBuffer(): Nullable<DataBuffer> {\r\n return this._buffer.getBuffer();\r\n }\r\n\r\n /**\r\n * Gets the Buffer instance that wraps the native GPU buffer\r\n * @returns the wrapper buffer\r\n */\r\n public getWrapperBuffer(): Buffer {\r\n return this._buffer;\r\n }\r\n\r\n /**\r\n * Gets the stride in float32 units (i.e. byte stride / 4).\r\n * May not be an integer if the byte stride is not divisible by 4.\r\n * @returns the stride in float32 units\r\n * @deprecated Please use byteStride instead.\r\n */\r\n public getStrideSize(): number {\r\n return this.byteStride / GetTypeByteLength(this.type);\r\n }\r\n\r\n /**\r\n * Returns the offset as a multiple of the type byte length.\r\n * @returns the offset in bytes\r\n * @deprecated Please use byteOffset instead.\r\n */\r\n public getOffset(): number {\r\n return this.byteOffset / GetTypeByteLength(this.type);\r\n }\r\n\r\n /**\r\n * Returns the number of components or the byte size per vertex attribute\r\n * @param sizeInBytes If true, returns the size in bytes or else the size in number of components of the vertex attribute (default: false)\r\n * @returns the number of components\r\n */\r\n public getSize(sizeInBytes = false): number {\r\n return sizeInBytes ? this._size * GetTypeByteLength(this.type) : this._size;\r\n }\r\n\r\n /**\r\n * Gets a boolean indicating is the internal buffer of the VertexBuffer is instanced\r\n * @returns true if this buffer is instanced\r\n */\r\n public getIsInstanced(): boolean {\r\n return this._instanced;\r\n }\r\n\r\n /**\r\n * Returns the instancing divisor, zero for non-instanced (integer).\r\n * @returns a number\r\n */\r\n public getInstanceDivisor(): number {\r\n return this._instanceDivisor;\r\n }\r\n\r\n // Methods\r\n\r\n /**\r\n * Store data into the buffer. If the buffer was already used it will be either recreated or updated depending on isUpdatable property\r\n * @param data defines the data to store\r\n */\r\n public create(data?: DataArray): void {\r\n this._buffer.create(data);\r\n this._alignBuffer();\r\n }\r\n\r\n /**\r\n * Updates the underlying buffer according to the passed numeric array or Float32Array.\r\n * This function will create a new buffer if the current one is not updatable\r\n * @param data defines the data to store\r\n */\r\n public update(data: DataArray): void {\r\n this._buffer.update(data);\r\n this._alignBuffer();\r\n }\r\n\r\n /**\r\n * Updates directly the underlying WebGLBuffer according to the passed numeric array or Float32Array.\r\n * Returns the directly updated WebGLBuffer.\r\n * @param data the new data\r\n * @param offset the new offset\r\n * @param useBytes set to true if the offset is in bytes\r\n */\r\n public updateDirectly(data: DataArray, offset: number, useBytes: boolean = false): void {\r\n this._buffer.updateDirectly(data, offset, undefined, useBytes);\r\n this._alignBuffer();\r\n }\r\n\r\n /**\r\n * Disposes the VertexBuffer and the underlying WebGLBuffer.\r\n */\r\n public dispose(): void {\r\n if (this._ownsBuffer) {\r\n this._buffer.dispose();\r\n }\r\n\r\n this._isDisposed = true;\r\n }\r\n\r\n /**\r\n * Enumerates each value of this vertex buffer as numbers.\r\n * @param count the number of values to enumerate\r\n * @param callback the callback function called for each value\r\n */\r\n public forEach(count: number, callback: (value: number, index: number) => void): void {\r\n EnumerateFloatValues(this._buffer.getData()!, this.byteOffset, this.byteStride, this._size, this.type, count, this.normalized, (values, index) => {\r\n for (let i = 0; i < this._size; i++) {\r\n callback(values[i], index + i);\r\n }\r\n });\r\n }\r\n\r\n /** @internal */\r\n public _alignBuffer() {}\r\n\r\n // Enums\r\n /**\r\n * Positions\r\n */\r\n public static readonly PositionKind = Constants.PositionKind;\r\n /**\r\n * Normals\r\n */\r\n public static readonly NormalKind = Constants.NormalKind;\r\n /**\r\n * Tangents\r\n */\r\n public static readonly TangentKind = Constants.TangentKind;\r\n /**\r\n * Texture coordinates\r\n */\r\n public static readonly UVKind = Constants.UVKind;\r\n /**\r\n * Texture coordinates 2\r\n */\r\n public static readonly UV2Kind = Constants.UV2Kind;\r\n /**\r\n * Texture coordinates 3\r\n */\r\n public static readonly UV3Kind = Constants.UV3Kind;\r\n /**\r\n * Texture coordinates 4\r\n */\r\n public static readonly UV4Kind = Constants.UV4Kind;\r\n /**\r\n * Texture coordinates 5\r\n */\r\n public static readonly UV5Kind = Constants.UV5Kind;\r\n /**\r\n * Texture coordinates 6\r\n */\r\n public static readonly UV6Kind = Constants.UV6Kind;\r\n /**\r\n * Colors\r\n */\r\n public static readonly ColorKind = Constants.ColorKind;\r\n /**\r\n * Instance Colors\r\n */\r\n public static readonly ColorInstanceKind = Constants.ColorInstanceKind;\r\n /**\r\n * Matrix indices (for bones)\r\n */\r\n public static readonly MatricesIndicesKind = Constants.MatricesIndicesKind;\r\n /**\r\n * Matrix weights (for bones)\r\n */\r\n public static readonly MatricesWeightsKind = Constants.MatricesWeightsKind;\r\n /**\r\n * Additional matrix indices (for bones)\r\n */\r\n public static readonly MatricesIndicesExtraKind = Constants.MatricesIndicesExtraKind;\r\n /**\r\n * Additional matrix weights (for bones)\r\n */\r\n public static readonly MatricesWeightsExtraKind = Constants.MatricesWeightsExtraKind;\r\n\r\n /**\r\n * Deduces the stride given a kind.\r\n * @param kind The kind string to deduce\r\n * @returns The deduced stride\r\n */\r\n public static DeduceStride(kind: string): number {\r\n switch (kind) {\r\n case VertexBuffer.UVKind:\r\n case VertexBuffer.UV2Kind:\r\n case VertexBuffer.UV3Kind:\r\n case VertexBuffer.UV4Kind:\r\n case VertexBuffer.UV5Kind:\r\n case VertexBuffer.UV6Kind:\r\n return 2;\r\n case VertexBuffer.NormalKind:\r\n case VertexBuffer.PositionKind:\r\n return 3;\r\n case VertexBuffer.ColorKind:\r\n case VertexBuffer.ColorInstanceKind:\r\n case VertexBuffer.MatricesIndicesKind:\r\n case VertexBuffer.MatricesIndicesExtraKind:\r\n case VertexBuffer.MatricesWeightsKind:\r\n case VertexBuffer.MatricesWeightsExtraKind:\r\n case VertexBuffer.TangentKind:\r\n return 4;\r\n default:\r\n throw new Error(\"Invalid kind '\" + kind + \"'\");\r\n }\r\n }\r\n\r\n /**\r\n * Gets the vertex buffer type of the given data array.\r\n * @param data the data array\r\n * @returns the vertex buffer type\r\n */\r\n public static GetDataType(data: DataArray): number {\r\n if (data instanceof Int8Array) {\r\n return VertexBuffer.BYTE;\r\n } else if (data instanceof Uint8Array) {\r\n return VertexBuffer.UNSIGNED_BYTE;\r\n } else if (data instanceof Int16Array) {\r\n return VertexBuffer.SHORT;\r\n } else if (data instanceof Uint16Array) {\r\n return VertexBuffer.UNSIGNED_SHORT;\r\n } else if (data instanceof Int32Array) {\r\n return VertexBuffer.INT;\r\n } else if (data instanceof Uint32Array) {\r\n return VertexBuffer.UNSIGNED_INT;\r\n } else {\r\n return VertexBuffer.FLOAT;\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 * @deprecated Use `getTypeByteLength` from `bufferUtils` instead\r\n */\r\n public static GetTypeByteLength(type: number): number {\r\n return GetTypeByteLength(type);\r\n }\r\n\r\n /**\r\n * Enumerates each value of the given parameters as numbers.\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 value\r\n * @deprecated Use `EnumerateFloatValues` from `bufferUtils` instead\r\n */\r\n public static ForEach(\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: (value: number, index: number) => void\r\n ): void {\r\n EnumerateFloatValues(data, byteOffset, byteStride, componentCount, componentType, count, normalized, (values, index) => {\r\n for (let componentIndex = 0; componentIndex < componentCount; componentIndex++) {\r\n callback(values[componentIndex], index + componentIndex);\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 * @deprecated Use `GetFloatData` from `bufferUtils` instead\r\n */\r\n public static 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 return GetFloatData(data, size, type, byteOffset, byteStride, normalized, totalVertices, forceCopy);\r\n }\r\n}\r\n"]}
|
package/Buffers/bufferUtils.d.ts
CHANGED
|
@@ -1,4 +1,35 @@
|
|
|
1
|
-
import type { DataArray } from "../types";
|
|
1
|
+
import type { DataArray, FloatArray } from "../types";
|
|
2
|
+
/**
|
|
3
|
+
* Gets the byte length of the given type.
|
|
4
|
+
* @param type the type
|
|
5
|
+
* @returns the number of bytes
|
|
6
|
+
*/
|
|
7
|
+
export declare function GetTypeByteLength(type: number): number;
|
|
8
|
+
/**
|
|
9
|
+
* Enumerates each value of the data array and calls the given callback.
|
|
10
|
+
* @param data the data to enumerate
|
|
11
|
+
* @param byteOffset the byte offset of the data
|
|
12
|
+
* @param byteStride the byte stride of the data
|
|
13
|
+
* @param componentCount the number of components per element
|
|
14
|
+
* @param componentType the type of the component
|
|
15
|
+
* @param count the number of values to enumerate
|
|
16
|
+
* @param normalized whether the data is normalized
|
|
17
|
+
* @param callback the callback function called for each group of component values
|
|
18
|
+
*/
|
|
19
|
+
export declare function EnumerateFloatValues(data: DataArray, byteOffset: number, byteStride: number, componentCount: number, componentType: number, count: number, normalized: boolean, callback: (values: number[], index: number) => void): void;
|
|
20
|
+
/**
|
|
21
|
+
* Gets the given data array as a float array. Float data is constructed if the data array cannot be returned directly.
|
|
22
|
+
* @param data the input data array
|
|
23
|
+
* @param size the number of components
|
|
24
|
+
* @param type the component type
|
|
25
|
+
* @param byteOffset the byte offset of the data
|
|
26
|
+
* @param byteStride the byte stride of the data
|
|
27
|
+
* @param normalized whether the data is normalized
|
|
28
|
+
* @param totalVertices number of vertices in the buffer to take into account
|
|
29
|
+
* @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
|
|
30
|
+
* @returns a float array containing vertex data
|
|
31
|
+
*/
|
|
32
|
+
export declare function GetFloatData(data: DataArray, size: number, type: number, byteOffset: number, byteStride: number, normalized: boolean, totalVertices: number, forceCopy?: boolean): FloatArray;
|
|
2
33
|
/**
|
|
3
34
|
* Copies the given data array to the given float array.
|
|
4
35
|
* @param input the input data array
|