@babylonjs/core 6.21.2 → 6.21.4
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/Animations/animatable.d.ts +4 -0
- package/Animations/animatable.js +6 -0
- package/Animations/animatable.js.map +1 -1
- package/Animations/animationGroup.d.ts +9 -0
- package/Animations/animationGroup.js +14 -0
- package/Animations/animationGroup.js.map +1 -1
- package/Buffers/buffer.d.ts +31 -2
- package/Buffers/buffer.js +100 -65
- package/Buffers/buffer.js.map +1 -1
- package/Engines/engine.d.ts +5 -0
- package/Engines/thinEngine.js +2 -2
- package/Engines/thinEngine.js.map +1 -1
- package/FlowGraph/Blocks/Data/Logic/flowGraphBitwiseBlocks.d.ts +59 -0
- package/FlowGraph/Blocks/Data/Logic/flowGraphBitwiseBlocks.js +86 -0
- package/FlowGraph/Blocks/Data/Logic/flowGraphBitwiseBlocks.js.map +1 -0
- package/FlowGraph/Blocks/Data/Logic/index.d.ts +2 -0
- package/FlowGraph/Blocks/Data/Logic/index.js +3 -0
- package/FlowGraph/Blocks/Data/Logic/index.js.map +1 -0
- package/FlowGraph/Blocks/Data/Math/flowGraphNumberMathBlocks.d.ts +2 -1
- package/FlowGraph/Blocks/Data/Math/flowGraphNumberMathBlocks.js +6 -2
- package/FlowGraph/Blocks/Data/Math/flowGraphNumberMathBlocks.js.map +1 -1
- package/FlowGraph/Blocks/Data/Math/index.d.ts +4 -0
- package/FlowGraph/Blocks/Data/Math/index.js +5 -0
- package/FlowGraph/Blocks/Data/Math/index.js.map +1 -0
- package/FlowGraph/Blocks/Data/flowGraphBinaryOperationBlock.js +1 -1
- package/FlowGraph/Blocks/Data/flowGraphBinaryOperationBlock.js.map +1 -1
- package/FlowGraph/Blocks/Data/flowGraphConditionalDataBlock.js +1 -1
- package/FlowGraph/Blocks/Data/flowGraphConditionalDataBlock.js.map +1 -1
- package/FlowGraph/Blocks/Data/flowGraphConstantOperationBlock.d.ts +2 -1
- package/FlowGraph/Blocks/Data/flowGraphConstantOperationBlock.js +2 -2
- package/FlowGraph/Blocks/Data/flowGraphConstantOperationBlock.js.map +1 -1
- package/FlowGraph/Blocks/Data/flowGraphGetVariableBlock.d.ts +1 -8
- package/FlowGraph/Blocks/Data/flowGraphGetVariableBlock.js +2 -5
- package/FlowGraph/Blocks/Data/flowGraphGetVariableBlock.js.map +1 -1
- package/FlowGraph/Blocks/Data/flowGraphUnaryOperationBlock.js +1 -1
- package/FlowGraph/Blocks/Data/flowGraphUnaryOperationBlock.js.map +1 -1
- package/FlowGraph/Blocks/Data/index.d.ts +2 -4
- package/FlowGraph/Blocks/Data/index.js +4 -4
- package/FlowGraph/Blocks/Data/index.js.map +1 -1
- package/FlowGraph/Blocks/Event/flowGraphReceiveCustomEventBlock.js +1 -1
- package/FlowGraph/Blocks/Event/flowGraphReceiveCustomEventBlock.js.map +1 -1
- package/FlowGraph/Blocks/Execution/Animation/flowGraphPlayAnimationBlock.js +1 -3
- package/FlowGraph/Blocks/Execution/Animation/flowGraphPlayAnimationBlock.js.map +1 -1
- package/FlowGraph/Blocks/Execution/{flowGraphConditionalBlock.d.ts → ControlFlow/flowGraphConditionalBlock.d.ts} +5 -5
- package/FlowGraph/Blocks/Execution/{flowGraphConditionalBlock.js → ControlFlow/flowGraphConditionalBlock.js} +3 -3
- package/FlowGraph/Blocks/Execution/ControlFlow/flowGraphConditionalBlock.js.map +1 -0
- package/FlowGraph/Blocks/Execution/ControlFlow/flowGraphCounterBlock.d.ts +20 -0
- package/FlowGraph/Blocks/Execution/ControlFlow/flowGraphCounterBlock.js +26 -0
- package/FlowGraph/Blocks/Execution/ControlFlow/flowGraphCounterBlock.js.map +1 -0
- package/FlowGraph/Blocks/Execution/ControlFlow/flowGraphDebounceBlock.d.ts +24 -0
- package/FlowGraph/Blocks/Execution/ControlFlow/flowGraphDebounceBlock.js +30 -0
- package/FlowGraph/Blocks/Execution/ControlFlow/flowGraphDebounceBlock.js.map +1 -0
- package/FlowGraph/Blocks/Execution/ControlFlow/flowGraphDoNBlock.d.ts +24 -0
- package/FlowGraph/Blocks/Execution/ControlFlow/flowGraphDoNBlock.js +27 -0
- package/FlowGraph/Blocks/Execution/ControlFlow/flowGraphDoNBlock.js.map +1 -0
- package/FlowGraph/Blocks/Execution/ControlFlow/flowGraphFlipFlopBlock.d.ts +24 -0
- package/FlowGraph/Blocks/Execution/ControlFlow/flowGraphFlipFlopBlock.js +27 -0
- package/FlowGraph/Blocks/Execution/ControlFlow/flowGraphFlipFlopBlock.js.map +1 -0
- package/FlowGraph/Blocks/Execution/{flowGraphForLoopBlock.d.ts → ControlFlow/flowGraphForLoopBlock.d.ts} +4 -4
- package/FlowGraph/Blocks/Execution/{flowGraphForLoopBlock.js → ControlFlow/flowGraphForLoopBlock.js} +4 -5
- package/FlowGraph/Blocks/Execution/ControlFlow/flowGraphForLoopBlock.js.map +1 -0
- package/FlowGraph/Blocks/Execution/ControlFlow/flowGraphMultiGateBlock.d.ts +51 -0
- package/FlowGraph/Blocks/Execution/ControlFlow/flowGraphMultiGateBlock.js +77 -0
- package/FlowGraph/Blocks/Execution/ControlFlow/flowGraphMultiGateBlock.js.map +1 -0
- package/FlowGraph/Blocks/Execution/ControlFlow/flowGraphSwitchBlock.d.ts +31 -0
- package/FlowGraph/Blocks/Execution/ControlFlow/flowGraphSwitchBlock.js +32 -0
- package/FlowGraph/Blocks/Execution/ControlFlow/flowGraphSwitchBlock.js.map +1 -0
- package/FlowGraph/Blocks/Execution/ControlFlow/flowGraphThrottleBlock.d.ts +24 -0
- package/FlowGraph/Blocks/Execution/ControlFlow/flowGraphThrottleBlock.js +31 -0
- package/FlowGraph/Blocks/Execution/ControlFlow/flowGraphThrottleBlock.js.map +1 -0
- package/FlowGraph/Blocks/Execution/{flowGraphTimerBlock.d.ts → ControlFlow/flowGraphTimerBlock.d.ts} +5 -9
- package/FlowGraph/Blocks/Execution/{flowGraphTimerBlock.js → ControlFlow/flowGraphTimerBlock.js} +5 -9
- package/FlowGraph/Blocks/Execution/ControlFlow/flowGraphTimerBlock.js.map +1 -0
- package/FlowGraph/Blocks/Execution/ControlFlow/flowGraphWaitAllBlock.d.ts +32 -0
- package/FlowGraph/Blocks/Execution/ControlFlow/flowGraphWaitAllBlock.js +62 -0
- package/FlowGraph/Blocks/Execution/ControlFlow/flowGraphWaitAllBlock.js.map +1 -0
- package/FlowGraph/Blocks/Execution/ControlFlow/flowGraphWhileLoopBlock.d.ts +31 -0
- package/FlowGraph/Blocks/Execution/ControlFlow/flowGraphWhileLoopBlock.js +27 -0
- package/FlowGraph/Blocks/Execution/ControlFlow/flowGraphWhileLoopBlock.js.map +1 -0
- package/FlowGraph/Blocks/Execution/ControlFlow/index.d.ts +12 -0
- package/FlowGraph/Blocks/Execution/ControlFlow/index.js +13 -0
- package/FlowGraph/Blocks/Execution/ControlFlow/index.js.map +1 -0
- package/FlowGraph/Blocks/Execution/flowGraphLogBlock.js +0 -1
- package/FlowGraph/Blocks/Execution/flowGraphLogBlock.js.map +1 -1
- package/FlowGraph/Blocks/Execution/flowGraphSetVariableBlock.d.ts +1 -5
- package/FlowGraph/Blocks/Execution/flowGraphSetVariableBlock.js +3 -8
- package/FlowGraph/Blocks/Execution/flowGraphSetVariableBlock.js.map +1 -1
- package/FlowGraph/Blocks/Execution/index.d.ts +1 -3
- package/FlowGraph/Blocks/Execution/index.js +2 -3
- package/FlowGraph/Blocks/Execution/index.js.map +1 -1
- package/FlowGraph/flowGraphConnection.d.ts +4 -0
- package/FlowGraph/flowGraphConnection.js +5 -0
- package/FlowGraph/flowGraphConnection.js.map +1 -1
- package/FlowGraph/flowGraphContext.d.ts +42 -2
- package/FlowGraph/flowGraphContext.js +58 -6
- package/FlowGraph/flowGraphContext.js.map +1 -1
- package/FlowGraph/flowGraphDataConnection.d.ts +19 -2
- package/FlowGraph/flowGraphDataConnection.js +29 -5
- package/FlowGraph/flowGraphDataConnection.js.map +1 -1
- package/FlowGraph/flowGraphExecutionBlock.d.ts +1 -1
- package/FlowGraph/flowGraphExecutionBlock.js.map +1 -1
- package/FlowGraph/flowGraphSignalConnection.js +1 -1
- package/FlowGraph/flowGraphSignalConnection.js.map +1 -1
- package/Lights/Shadows/cascadedShadowGenerator.js +1 -1
- package/Lights/Shadows/cascadedShadowGenerator.js.map +1 -1
- package/Materials/Textures/equiRectangularCubeTexture.js +2 -0
- package/Materials/Textures/equiRectangularCubeTexture.js.map +1 -1
- package/Materials/Textures/texture.js +2 -2
- package/Materials/Textures/texture.js.map +1 -1
- package/Meshes/Compression/dracoCompression.js +28 -13
- package/Meshes/Compression/dracoCompression.js.map +1 -1
- package/Misc/fileTools.js +2 -2
- package/Misc/fileTools.js.map +1 -1
- package/Misc/webRequest.d.ts +5 -0
- package/Misc/webRequest.js +7 -0
- package/Misc/webRequest.js.map +1 -1
- package/XR/features/WebXRPlaneDetector.d.ts +8 -0
- package/XR/features/WebXRPlaneDetector.js +13 -0
- package/XR/features/WebXRPlaneDetector.js.map +1 -1
- package/package.json +1 -1
- package/FlowGraph/Blocks/Execution/flowGraphConditionalBlock.js.map +0 -1
- package/FlowGraph/Blocks/Execution/flowGraphForLoopBlock.js.map +0 -1
- package/FlowGraph/Blocks/Execution/flowGraphTimerBlock.js.map +0 -1
package/Buffers/buffer.js
CHANGED
|
@@ -3,6 +3,12 @@ import { DataBuffer } from "./dataBuffer.js";
|
|
|
3
3
|
* Class used to store data that will be store in GPU memory
|
|
4
4
|
*/
|
|
5
5
|
export class Buffer {
|
|
6
|
+
/**
|
|
7
|
+
* Gets a boolean indicating if the Buffer is disposed
|
|
8
|
+
*/
|
|
9
|
+
get isDisposed() {
|
|
10
|
+
return this._isDisposed;
|
|
11
|
+
}
|
|
6
12
|
/**
|
|
7
13
|
* Constructor
|
|
8
14
|
* @param engine the engine
|
|
@@ -16,6 +22,7 @@ export class Buffer {
|
|
|
16
22
|
*/
|
|
17
23
|
constructor(engine, data, updatable, stride = 0, postponeInternalCreation = !engine, instanced = false, useBytes = false, divisor) {
|
|
18
24
|
this._isAlreadyOwned = false;
|
|
25
|
+
this._isDisposed = false;
|
|
19
26
|
if (engine && engine.getScene) {
|
|
20
27
|
// old versions of VertexBuffer accepted 'mesh' instead of 'engine'
|
|
21
28
|
this._engine = engine.getScene().getEngine();
|
|
@@ -102,9 +109,6 @@ export class Buffer {
|
|
|
102
109
|
if (!data) {
|
|
103
110
|
return;
|
|
104
111
|
}
|
|
105
|
-
if (!this._engine) {
|
|
106
|
-
throw new Error("Engine must be provided in the buffer constructor in order to create");
|
|
107
|
-
}
|
|
108
112
|
if (!this._buffer) {
|
|
109
113
|
// create buffer
|
|
110
114
|
if (this._updatable) {
|
|
@@ -145,9 +149,6 @@ export class Buffer {
|
|
|
145
149
|
return;
|
|
146
150
|
}
|
|
147
151
|
if (this._updatable) {
|
|
148
|
-
if (!this._engine) {
|
|
149
|
-
throw new Error("Engine must be provided in the buffer constructor in order to update directly");
|
|
150
|
-
}
|
|
151
152
|
// update buffer
|
|
152
153
|
this._engine.updateDynamicVertexBuffer(this._buffer, data, useBytes ? offset : offset * Float32Array.BYTES_PER_ELEMENT, vertexCount ? vertexCount * this.byteStride : undefined);
|
|
153
154
|
if (offset === 0 && vertexCount === undefined) {
|
|
@@ -177,11 +178,12 @@ export class Buffer {
|
|
|
177
178
|
if (!this._buffer) {
|
|
178
179
|
return;
|
|
179
180
|
}
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
181
|
+
// The data buffer has an internal counter as this buffer can be used by several VertexBuffer objects
|
|
182
|
+
// This means that we only flag it as disposed when all references are released (when _releaseBuffer will return true)
|
|
183
|
+
if (this._engine._releaseBuffer(this._buffer)) {
|
|
184
|
+
this._isDisposed = true;
|
|
185
|
+
this._data = null;
|
|
186
|
+
this._buffer = null;
|
|
185
187
|
}
|
|
186
188
|
}
|
|
187
189
|
}
|
|
@@ -189,6 +191,12 @@ export class Buffer {
|
|
|
189
191
|
* Specialized buffer used to store vertex data
|
|
190
192
|
*/
|
|
191
193
|
export class VertexBuffer {
|
|
194
|
+
/**
|
|
195
|
+
* Gets a boolean indicating if the Buffer is disposed
|
|
196
|
+
*/
|
|
197
|
+
get isDisposed() {
|
|
198
|
+
return this._isDisposed;
|
|
199
|
+
}
|
|
192
200
|
/**
|
|
193
201
|
* Gets or sets the instance divisor when in instanced mode
|
|
194
202
|
*/
|
|
@@ -221,6 +229,7 @@ export class VertexBuffer {
|
|
|
221
229
|
* @param takeBufferOwnership defines if the buffer should be released when the vertex buffer is disposed
|
|
222
230
|
*/
|
|
223
231
|
constructor(engine, data, kind, updatable, postponeInternalCreation, stride, instanced, offset, size, type, normalized = false, useBytes = false, divisor = 1, takeBufferOwnership = false) {
|
|
232
|
+
this._isDisposed = false;
|
|
224
233
|
if (data instanceof Buffer) {
|
|
225
234
|
this._buffer = data;
|
|
226
235
|
this._ownsBuffer = takeBufferOwnership;
|
|
@@ -233,25 +242,7 @@ export class VertexBuffer {
|
|
|
233
242
|
this._kind = kind;
|
|
234
243
|
if (type == undefined) {
|
|
235
244
|
const vertexData = this.getData();
|
|
236
|
-
this.type = VertexBuffer.FLOAT;
|
|
237
|
-
if (vertexData instanceof Int8Array) {
|
|
238
|
-
this.type = VertexBuffer.BYTE;
|
|
239
|
-
}
|
|
240
|
-
else if (vertexData instanceof Uint8Array) {
|
|
241
|
-
this.type = VertexBuffer.UNSIGNED_BYTE;
|
|
242
|
-
}
|
|
243
|
-
else if (vertexData instanceof Int16Array) {
|
|
244
|
-
this.type = VertexBuffer.SHORT;
|
|
245
|
-
}
|
|
246
|
-
else if (vertexData instanceof Uint16Array) {
|
|
247
|
-
this.type = VertexBuffer.UNSIGNED_SHORT;
|
|
248
|
-
}
|
|
249
|
-
else if (vertexData instanceof Int32Array) {
|
|
250
|
-
this.type = VertexBuffer.INT;
|
|
251
|
-
}
|
|
252
|
-
else if (vertexData instanceof Uint32Array) {
|
|
253
|
-
this.type = VertexBuffer.UNSIGNED_INT;
|
|
254
|
-
}
|
|
245
|
+
this.type = vertexData ? VertexBuffer.GetDataType(vertexData) : VertexBuffer.FLOAT;
|
|
255
246
|
}
|
|
256
247
|
else {
|
|
257
248
|
this.type = type;
|
|
@@ -322,41 +313,7 @@ export class VertexBuffer {
|
|
|
322
313
|
if (!data) {
|
|
323
314
|
return null;
|
|
324
315
|
}
|
|
325
|
-
|
|
326
|
-
const count = totalVertices * this.getSize();
|
|
327
|
-
if (this.type !== VertexBuffer.FLOAT || this.byteStride !== tightlyPackedByteStride) {
|
|
328
|
-
const copy = new Float32Array(count);
|
|
329
|
-
this.forEach(count, (value, index) => (copy[index] = value));
|
|
330
|
-
return copy;
|
|
331
|
-
}
|
|
332
|
-
if (!(data instanceof Array || data instanceof Float32Array) || this.byteOffset !== 0 || data.length !== count) {
|
|
333
|
-
if (data instanceof Array) {
|
|
334
|
-
const offset = this.byteOffset / 4;
|
|
335
|
-
return data.slice(offset, offset + count);
|
|
336
|
-
}
|
|
337
|
-
else if (data instanceof ArrayBuffer) {
|
|
338
|
-
return new Float32Array(data, this.byteOffset, count);
|
|
339
|
-
}
|
|
340
|
-
else {
|
|
341
|
-
let offset = data.byteOffset + this.byteOffset;
|
|
342
|
-
if (forceCopy) {
|
|
343
|
-
const result = new Float32Array(count);
|
|
344
|
-
const source = new Float32Array(data.buffer, offset, count);
|
|
345
|
-
result.set(source);
|
|
346
|
-
return result;
|
|
347
|
-
}
|
|
348
|
-
// Protect against bad data
|
|
349
|
-
const remainder = offset % 4;
|
|
350
|
-
if (remainder) {
|
|
351
|
-
offset = Math.max(0, offset - remainder);
|
|
352
|
-
}
|
|
353
|
-
return new Float32Array(data.buffer, offset, count);
|
|
354
|
-
}
|
|
355
|
-
}
|
|
356
|
-
if (forceCopy) {
|
|
357
|
-
return data.slice();
|
|
358
|
-
}
|
|
359
|
-
return data;
|
|
316
|
+
return VertexBuffer.GetFloatData(data, this._size, this.type, this.byteOffset, this.byteStride, this.normalized, totalVertices, forceCopy);
|
|
360
317
|
}
|
|
361
318
|
/**
|
|
362
319
|
* Gets underlying native buffer
|
|
@@ -437,6 +394,7 @@ export class VertexBuffer {
|
|
|
437
394
|
if (this._ownsBuffer) {
|
|
438
395
|
this._buffer.dispose();
|
|
439
396
|
}
|
|
397
|
+
this._isDisposed = true;
|
|
440
398
|
}
|
|
441
399
|
/**
|
|
442
400
|
* Enumerates each value of this vertex buffer as numbers.
|
|
@@ -474,6 +432,34 @@ export class VertexBuffer {
|
|
|
474
432
|
throw new Error("Invalid kind '" + kind + "'");
|
|
475
433
|
}
|
|
476
434
|
}
|
|
435
|
+
/**
|
|
436
|
+
* Gets the vertex buffer type of the given data array.
|
|
437
|
+
* @param data the data array
|
|
438
|
+
* @returns the vertex buffer type
|
|
439
|
+
*/
|
|
440
|
+
static GetDataType(data) {
|
|
441
|
+
if (data instanceof Int8Array) {
|
|
442
|
+
return VertexBuffer.BYTE;
|
|
443
|
+
}
|
|
444
|
+
else if (data instanceof Uint8Array) {
|
|
445
|
+
return VertexBuffer.UNSIGNED_BYTE;
|
|
446
|
+
}
|
|
447
|
+
else if (data instanceof Int16Array) {
|
|
448
|
+
return VertexBuffer.SHORT;
|
|
449
|
+
}
|
|
450
|
+
else if (data instanceof Uint16Array) {
|
|
451
|
+
return VertexBuffer.UNSIGNED_SHORT;
|
|
452
|
+
}
|
|
453
|
+
else if (data instanceof Int32Array) {
|
|
454
|
+
return VertexBuffer.INT;
|
|
455
|
+
}
|
|
456
|
+
else if (data instanceof Uint32Array) {
|
|
457
|
+
return VertexBuffer.UNSIGNED_INT;
|
|
458
|
+
}
|
|
459
|
+
else {
|
|
460
|
+
return VertexBuffer.FLOAT;
|
|
461
|
+
}
|
|
462
|
+
}
|
|
477
463
|
/**
|
|
478
464
|
* Gets the byte length of the given type.
|
|
479
465
|
* @param type the type
|
|
@@ -575,6 +561,55 @@ export class VertexBuffer {
|
|
|
575
561
|
}
|
|
576
562
|
}
|
|
577
563
|
}
|
|
564
|
+
/**
|
|
565
|
+
* Gets the given data array as a float array. Float data is constructed if the data array cannot be returned directly.
|
|
566
|
+
* @param data the input data array
|
|
567
|
+
* @param size the number of components
|
|
568
|
+
* @param type the component type
|
|
569
|
+
* @param byteOffset the byte offset of the data
|
|
570
|
+
* @param byteStride the byte stride of the data
|
|
571
|
+
* @param normalized whether the data is normalized
|
|
572
|
+
* @param totalVertices number of vertices in the buffer to take into account
|
|
573
|
+
* @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
|
|
574
|
+
* @returns a float array containing vertex data
|
|
575
|
+
*/
|
|
576
|
+
static GetFloatData(data, size, type, byteOffset, byteStride, normalized, totalVertices, forceCopy) {
|
|
577
|
+
const tightlyPackedByteStride = size * VertexBuffer.GetTypeByteLength(type);
|
|
578
|
+
const count = totalVertices * size;
|
|
579
|
+
if (type !== VertexBuffer.FLOAT || byteStride !== tightlyPackedByteStride) {
|
|
580
|
+
const copy = new Float32Array(count);
|
|
581
|
+
VertexBuffer.ForEach(data, byteOffset, byteStride, size, type, count, normalized, (value, index) => (copy[index] = value));
|
|
582
|
+
return copy;
|
|
583
|
+
}
|
|
584
|
+
if (!(data instanceof Array || data instanceof Float32Array) || byteOffset !== 0 || data.length !== count) {
|
|
585
|
+
if (data instanceof Array) {
|
|
586
|
+
const offset = byteOffset / 4;
|
|
587
|
+
return data.slice(offset, offset + count);
|
|
588
|
+
}
|
|
589
|
+
else if (data instanceof ArrayBuffer) {
|
|
590
|
+
return new Float32Array(data, byteOffset, count);
|
|
591
|
+
}
|
|
592
|
+
else {
|
|
593
|
+
let offset = data.byteOffset + byteOffset;
|
|
594
|
+
if (forceCopy) {
|
|
595
|
+
const result = new Float32Array(count);
|
|
596
|
+
const source = new Float32Array(data.buffer, offset, count);
|
|
597
|
+
result.set(source);
|
|
598
|
+
return result;
|
|
599
|
+
}
|
|
600
|
+
// Protect against bad data
|
|
601
|
+
const remainder = offset % 4;
|
|
602
|
+
if (remainder) {
|
|
603
|
+
offset = Math.max(0, offset - remainder);
|
|
604
|
+
}
|
|
605
|
+
return new Float32Array(data.buffer, offset, count);
|
|
606
|
+
}
|
|
607
|
+
}
|
|
608
|
+
if (forceCopy) {
|
|
609
|
+
return data.slice();
|
|
610
|
+
}
|
|
611
|
+
return data;
|
|
612
|
+
}
|
|
578
613
|
}
|
|
579
614
|
VertexBuffer._Counter = 0;
|
|
580
615
|
/**
|
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;AAG1C;;GAEG;AACH,MAAM,OAAO,MAAM;IAef;;;;;;;;;;OAUG;IACH,YACI,MAA4B,EAC5B,IAA4B,EAC5B,SAAkB,EAClB,MAAM,GAAG,CAAC,EACV,wBAAwB,GAAG,CAAC,MAAM,EAClC,SAAS,GAAG,KAAK,EACjB,QAAQ,GAAG,KAAK,EAChB,OAAgB;QA1BZ,oBAAe,GAAG,KAAK,CAAC;QA4B5B,IAAI,MAAM,IAAK,MAA0B,CAAC,QAAQ,EAAE;YAChD,mEAAmE;YACnE,IAAI,CAAC,OAAO,GAAI,MAA0B,CAAC,QAAQ,EAAE,CAAC,SAAS,EAAE,CAAC;SACrE;aAAM;YACH,IAAI,CAAC,OAAO,GAAG,MAAM,CAAC;SACzB;QAED,IAAI,CAAC,UAAU,GAAG,SAAS,CAAC;QAC5B,IAAI,CAAC,UAAU,GAAG,SAAS,CAAC;QAC5B,IAAI,CAAC,QAAQ,GAAG,OAAO,IAAI,CAAC,CAAC;QAE7B,IAAI,IAAI,YAAY,UAAU,EAAE;YAC5B,IAAI,CAAC,KAAK,GAAG,IAAI,CAAC;YAClB,IAAI,CAAC,OAAO,GAAG,IAAI,CAAC;SACvB;aAAM;YACH,IAAI,CAAC,KAAK,GAAG,IAAI,CAAC;YAClB,IAAI,CAAC,OAAO,GAAG,IAAI,CAAC;SACvB;QAED,IAAI,CAAC,UAAU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,CAAC;AAC/D;;GAEG;AACoB,gCAAmB,GAAG,iBAAiB,CAAC;AAC/D;;GAEG;AACoB,qCAAwB,GAAG,sBAAsB,CAAC;AACzE;;GAEG;AACoB,qCAAwB,GAAG,sBAAsB,CAAC","sourcesContent":["import type { Nullable, DataArray, FloatArray } from \"../types\";\r\nimport type { ThinEngine } from \"../Engines/thinEngine\";\r\nimport { DataBuffer } from \"./dataBuffer\";\r\nimport type { Mesh } from \"../Meshes/mesh\";\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: Nullable<ThinEngine>;\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\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 */\r\n constructor(\r\n engine: Nullable<ThinEngine>,\r\n data: DataArray | DataBuffer,\r\n updatable: boolean,\r\n stride = 0,\r\n postponeInternalCreation = !engine,\r\n instanced = false,\r\n useBytes = false,\r\n divisor?: number\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\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._engine) {\r\n throw new Error(\"Engine must be provided in the buffer constructor in order to create\");\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);\r\n this._data = data;\r\n } else {\r\n this._buffer = this._engine.createVertexBuffer(data);\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 this._buffer = null;\r\n this.create(this._data);\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 if (!this._engine) {\r\n throw new Error(\"Engine must be provided in the buffer constructor in order to update directly\");\r\n }\r\n\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 if (this._engine) {\r\n if (this._engine._releaseBuffer(this._buffer)) {\r\n this._buffer = null;\r\n this._data = null;\r\n }\r\n }\r\n }\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 private _ownsBuffer: boolean;\r\n private _instanced: boolean;\r\n private _instanceDivisor: number;\r\n\r\n /**\r\n * The byte type.\r\n */\r\n public static readonly BYTE = 5120;\r\n\r\n /**\r\n * The unsigned byte type.\r\n */\r\n public static readonly UNSIGNED_BYTE = 5121;\r\n\r\n /**\r\n * The short type.\r\n */\r\n public static readonly SHORT = 5122;\r\n\r\n /**\r\n * The unsigned short type.\r\n */\r\n public static readonly UNSIGNED_SHORT = 5123;\r\n\r\n /**\r\n * The integer type.\r\n */\r\n public static readonly INT = 5124;\r\n\r\n /**\r\n * The unsigned integer type.\r\n */\r\n public static readonly UNSIGNED_INT = 5125;\r\n\r\n /**\r\n * The float type.\r\n */\r\n public static readonly FLOAT = 5126;\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 * 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: any,\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 = false,\r\n useBytes = false,\r\n divisor = 1,\r\n takeBufferOwnership = false\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);\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 = VertexBuffer.FLOAT;\r\n if (vertexData instanceof Int8Array) {\r\n this.type = VertexBuffer.BYTE;\r\n } else if (vertexData instanceof Uint8Array) {\r\n this.type = VertexBuffer.UNSIGNED_BYTE;\r\n } else if (vertexData instanceof Int16Array) {\r\n this.type = VertexBuffer.SHORT;\r\n } else if (vertexData instanceof Uint16Array) {\r\n this.type = VertexBuffer.UNSIGNED_SHORT;\r\n } else if (vertexData instanceof Int32Array) {\r\n this.type = VertexBuffer.INT;\r\n } else if (vertexData instanceof Uint32Array) {\r\n this.type = VertexBuffer.UNSIGNED_INT;\r\n }\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._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 if (!this._buffer) {\r\n return;\r\n }\r\n\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 const tightlyPackedByteStride = this.getSize() * VertexBuffer.GetTypeByteLength(this.type);\r\n const count = totalVertices * this.getSize();\r\n\r\n if (this.type !== VertexBuffer.FLOAT || this.byteStride !== tightlyPackedByteStride) {\r\n const copy = new Float32Array(count);\r\n this.forEach(count, (value, index) => (copy[index] = value));\r\n return copy;\r\n }\r\n\r\n if (!(data instanceof Array || data instanceof Float32Array) || this.byteOffset !== 0 || data.length !== count) {\r\n if (data instanceof Array) {\r\n const offset = this.byteOffset / 4;\r\n return data.slice(offset, offset + count);\r\n } else if (data instanceof ArrayBuffer) {\r\n return new Float32Array(data, this.byteOffset, count);\r\n } else {\r\n let offset = data.byteOffset + this.byteOffset;\r\n if (forceCopy) {\r\n const result = new Float32Array(count);\r\n const source = new Float32Array(data.buffer, offset, count);\r\n\r\n result.set(source);\r\n\r\n return result;\r\n }\r\n\r\n // Protect against bad data\r\n const remainder = offset % 4;\r\n\r\n if (remainder) {\r\n offset = Math.max(0, offset - remainder);\r\n }\r\n\r\n return new Float32Array(data.buffer, offset, 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 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 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 }\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 }\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 }\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\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 // Enums\r\n /**\r\n * Positions\r\n */\r\n public static readonly PositionKind = \"position\";\r\n /**\r\n * Normals\r\n */\r\n public static readonly NormalKind = \"normal\";\r\n /**\r\n * Tangents\r\n */\r\n public static readonly TangentKind = \"tangent\";\r\n /**\r\n * Texture coordinates\r\n */\r\n public static readonly UVKind = \"uv\";\r\n /**\r\n * Texture coordinates 2\r\n */\r\n public static readonly UV2Kind = \"uv2\";\r\n /**\r\n * Texture coordinates 3\r\n */\r\n public static readonly UV3Kind = \"uv3\";\r\n /**\r\n * Texture coordinates 4\r\n */\r\n public static readonly UV4Kind = \"uv4\";\r\n /**\r\n * Texture coordinates 5\r\n */\r\n public static readonly UV5Kind = \"uv5\";\r\n /**\r\n * Texture coordinates 6\r\n */\r\n public static readonly UV6Kind = \"uv6\";\r\n /**\r\n * Colors\r\n */\r\n public static readonly ColorKind = \"color\";\r\n /**\r\n * Instance Colors\r\n */\r\n public static readonly ColorInstanceKind = \"instanceColor\";\r\n /**\r\n * Matrix indices (for bones)\r\n */\r\n public static readonly MatricesIndicesKind = \"matricesIndices\";\r\n /**\r\n * Matrix weights (for bones)\r\n */\r\n public static readonly MatricesWeightsKind = \"matricesWeights\";\r\n /**\r\n * Additional matrix indices (for bones)\r\n */\r\n public static readonly MatricesIndicesExtraKind = \"matricesIndicesExtra\";\r\n /**\r\n * Additional matrix weights (for bones)\r\n */\r\n public static readonly MatricesWeightsExtraKind = \"matricesWeightsExtra\";\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.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 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"]}
|
|
1
|
+
{"version":3,"file":"buffer.js","sourceRoot":"","sources":["../../../../dev/core/src/Buffers/buffer.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,UAAU,EAAE,MAAM,cAAc,CAAC;AAG1C;;GAEG;AACH,MAAM,OAAO,MAAM;IAWf;;OAEG;IACH,IAAW,UAAU;QACjB,OAAO,IAAI,CAAC,WAAW,CAAC;IAC5B,CAAC;IAOD;;;;;;;;;;OAUG;IACH,YACI,MAAkB,EAClB,IAA4B,EAC5B,SAAkB,EAClB,MAAM,GAAG,CAAC,EACV,wBAAwB,GAAG,CAAC,MAAM,EAClC,SAAS,GAAG,KAAK,EACjB,QAAQ,GAAG,KAAK,EAChB,OAAgB;QAlCZ,oBAAe,GAAG,KAAK,CAAC;QACxB,gBAAW,GAAG,KAAK,CAAC;QAmCxB,IAAI,MAAM,IAAK,MAA0B,CAAC,QAAQ,EAAE;YAChD,mEAAmE;YACnE,IAAI,CAAC,OAAO,GAAI,MAA0B,CAAC,QAAQ,EAAE,CAAC,SAAS,EAAE,CAAC;SACrE;aAAM;YACH,IAAI,CAAC,OAAO,GAAG,MAAM,CAAC;SACzB;QAED,IAAI,CAAC,UAAU,GAAG,SAAS,CAAC;QAC5B,IAAI,CAAC,UAAU,GAAG,SAAS,CAAC;QAC5B,IAAI,CAAC,QAAQ,GAAG,OAAO,IAAI,CAAC,CAAC;QAE7B,I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AQ;AAElC;;GAEG;AACoB,yBAAY,GAAG,IAAI,AAAP,CAAQ;AAE3C;;GAEG;AACoB,kBAAK,GAAG,IAAI,AAAP,CAAQ;AAmSpC,QAAQ;AACR;;GAEG;AACoB,yBAAY,GAAG,UAAU,AAAb,CAAc;AACjD;;GAEG;AACoB,uBAAU,GAAG,QAAQ,AAAX,CAAY;AAC7C;;GAEG;AACoB,wBAAW,GAAG,SAAS,AAAZ,CAAa;AAC/C;;GAEG;AACoB,mBAAM,GAAG,IAAI,AAAP,CAAQ;AACrC;;GAEG;AACoB,oBAAO,GAAG,KAAK,AAAR,CAAS;AACvC;;GAEG;AACoB,oBAAO,GAAG,KAAK,AAAR,CAAS;AACvC;;GAEG;AACoB,oBAAO,GAAG,KAAK,AAAR,CAAS;AACvC;;GAEG;AACoB,oBAAO,GAAG,KAAK,AAAR,CAAS;AACvC;;GAEG;AACoB,oBAAO,GAAG,KAAK,AAAR,CAAS;AACvC;;GAEG;AACoB,sBAAS,GAAG,OAAO,AAAV,CAAW;AAC3C;;GAEG;AACoB,8BAAiB,GAAG,eAAe,AAAlB,CAAmB;AAC3D;;GAEG;AACoB,gCAAmB,GAAG,iBAAiB,AAApB,CAAqB;AAC/D;;GAEG;AACoB,gCAAmB,GAAG,iBAAiB,AAApB,CAAqB;AAC/D;;GAEG;AACoB,qCAAwB,GAAG,sBAAsB,AAAzB,CAA0B;AACzE;;GAEG;AACoB,qCAAwB,GAAG,sBAAsB,AAAzB,CAA0B","sourcesContent":["import type { Nullable, DataArray, FloatArray } from \"../types\";\r\nimport type { ThinEngine } from \"../Engines/thinEngine\";\r\nimport { DataBuffer } from \"./dataBuffer\";\r\nimport type { Mesh } from \"../Meshes/mesh\";\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: ThinEngine;\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\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 */\r\n constructor(\r\n engine: ThinEngine,\r\n data: DataArray | DataBuffer,\r\n updatable: boolean,\r\n stride = 0,\r\n postponeInternalCreation = !engine,\r\n instanced = false,\r\n useBytes = false,\r\n divisor?: number\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\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);\r\n this._data = data;\r\n } else {\r\n this._buffer = this._engine.createVertexBuffer(data);\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 this._buffer = null;\r\n this.create(this._data);\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 * 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 private _ownsBuffer: boolean;\r\n private _instanced: boolean;\r\n private _instanceDivisor: number;\r\n private _isDisposed = false;\r\n\r\n /**\r\n * The byte type.\r\n */\r\n public static readonly BYTE = 5120;\r\n\r\n /**\r\n * The unsigned byte type.\r\n */\r\n public static readonly UNSIGNED_BYTE = 5121;\r\n\r\n /**\r\n * The short type.\r\n */\r\n public static readonly SHORT = 5122;\r\n\r\n /**\r\n * The unsigned short type.\r\n */\r\n public static readonly UNSIGNED_SHORT = 5123;\r\n\r\n /**\r\n * The integer type.\r\n */\r\n public static readonly INT = 5124;\r\n\r\n /**\r\n * The unsigned integer type.\r\n */\r\n public static readonly UNSIGNED_INT = 5125;\r\n\r\n /**\r\n * The float type.\r\n */\r\n public static readonly FLOAT = 5126;\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 * 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: ThinEngine,\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 = false,\r\n useBytes = false,\r\n divisor = 1,\r\n takeBufferOwnership = false\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);\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._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 if (!this._buffer) {\r\n return;\r\n }\r\n\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 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 }\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 }\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 }\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 // Enums\r\n /**\r\n * Positions\r\n */\r\n public static readonly PositionKind = \"position\";\r\n /**\r\n * Normals\r\n */\r\n public static readonly NormalKind = \"normal\";\r\n /**\r\n * Tangents\r\n */\r\n public static readonly TangentKind = \"tangent\";\r\n /**\r\n * Texture coordinates\r\n */\r\n public static readonly UVKind = \"uv\";\r\n /**\r\n * Texture coordinates 2\r\n */\r\n public static readonly UV2Kind = \"uv2\";\r\n /**\r\n * Texture coordinates 3\r\n */\r\n public static readonly UV3Kind = \"uv3\";\r\n /**\r\n * Texture coordinates 4\r\n */\r\n public static readonly UV4Kind = \"uv4\";\r\n /**\r\n * Texture coordinates 5\r\n */\r\n public static readonly UV5Kind = \"uv5\";\r\n /**\r\n * Texture coordinates 6\r\n */\r\n public static readonly UV6Kind = \"uv6\";\r\n /**\r\n * Colors\r\n */\r\n public static readonly ColorKind = \"color\";\r\n /**\r\n * Instance Colors\r\n */\r\n public static readonly ColorInstanceKind = \"instanceColor\";\r\n /**\r\n * Matrix indices (for bones)\r\n */\r\n public static readonly MatricesIndicesKind = \"matricesIndices\";\r\n /**\r\n * Matrix weights (for bones)\r\n */\r\n public static readonly MatricesWeightsKind = \"matricesWeights\";\r\n /**\r\n * Additional matrix indices (for bones)\r\n */\r\n public static readonly MatricesIndicesExtraKind = \"matricesIndicesExtra\";\r\n /**\r\n * Additional matrix weights (for bones)\r\n */\r\n public static readonly MatricesWeightsExtraKind = \"matricesWeightsExtra\";\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.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 let offset = data.byteOffset + byteOffset;\r\n if (forceCopy) {\r\n const result = new Float32Array(count);\r\n const source = new Float32Array(data.buffer, offset, count);\r\n\r\n result.set(source);\r\n\r\n return result;\r\n }\r\n\r\n // Protect against bad data\r\n const remainder = offset % 4;\r\n\r\n if (remainder) {\r\n offset = Math.max(0, offset - remainder);\r\n }\r\n\r\n return new Float32Array(data.buffer, offset, 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"]}
|
package/Engines/engine.d.ts
CHANGED
|
@@ -3557,6 +3557,11 @@ interface XRFrame {
|
|
|
3557
3557
|
getLightEstimate(xrLightProbe: XRLightProbe): XRLightEstimate;
|
|
3558
3558
|
}
|
|
3559
3559
|
|
|
3560
|
+
// Plane detection
|
|
3561
|
+
interface XRSession {
|
|
3562
|
+
initiateRoomCapture?(): Promise<void>;
|
|
3563
|
+
}
|
|
3564
|
+
|
|
3560
3565
|
type XREventType = keyof XRSessionEventMap;
|
|
3561
3566
|
|
|
3562
3567
|
type XRImageTrackingState = "tracked" | "emulated";
|
package/Engines/thinEngine.js
CHANGED
|
@@ -34,13 +34,13 @@ export class ThinEngine {
|
|
|
34
34
|
*/
|
|
35
35
|
// Not mixed with Version for tooling purpose.
|
|
36
36
|
static get NpmPackage() {
|
|
37
|
-
return "babylonjs@6.21.
|
|
37
|
+
return "babylonjs@6.21.4";
|
|
38
38
|
}
|
|
39
39
|
/**
|
|
40
40
|
* Returns the current version of the framework
|
|
41
41
|
*/
|
|
42
42
|
static get Version() {
|
|
43
|
-
return "6.21.
|
|
43
|
+
return "6.21.4";
|
|
44
44
|
}
|
|
45
45
|
/**
|
|
46
46
|
* Returns a string describing the current engine
|