@babylonjs/core 7.13.0 → 7.13.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.
Files changed (87) hide show
  1. package/Animations/animationGroupMask.d.ts +1 -1
  2. package/Animations/animationKey.d.ts +1 -1
  3. package/Behaviors/Meshes/handConstraintBehavior.d.ts +3 -3
  4. package/Buffers/bufferUtils.d.ts +13 -0
  5. package/Buffers/bufferUtils.js +42 -0
  6. package/Buffers/bufferUtils.js.map +1 -0
  7. package/Buffers/index.d.ts +1 -0
  8. package/Buffers/index.js +1 -0
  9. package/Buffers/index.js.map +1 -1
  10. package/Cameras/Inputs/flyCameraMouseInput.d.ts +0 -1
  11. package/Cameras/Inputs/flyCameraMouseInput.js +0 -1
  12. package/Cameras/Inputs/flyCameraMouseInput.js.map +1 -1
  13. package/Collisions/gpuPicker.d.ts +1 -0
  14. package/Collisions/gpuPicker.js +1 -0
  15. package/Collisions/gpuPicker.js.map +1 -1
  16. package/Debug/debugLayer.d.ts +1 -1
  17. package/Decorators/nodeDecorator.d.ts +1 -1
  18. package/DeviceInput/InputDevices/deviceEnums.d.ts +5 -5
  19. package/Engines/Extensions/engine.computeShader.d.ts +1 -1
  20. package/Engines/WebGPU/webgpuConstants.d.ts +39 -39
  21. package/Engines/abstractEngine.js +2 -2
  22. package/Engines/abstractEngine.js.map +1 -1
  23. package/Events/deviceInputEvents.d.ts +1 -1
  24. package/FlowGraph/flowGraph.d.ts +1 -1
  25. package/FlowGraph/flowGraphConnection.d.ts +1 -1
  26. package/Gamepads/dualShockGamepad.d.ts +2 -2
  27. package/Gamepads/xboxGamepad.d.ts +2 -2
  28. package/Gizmos/gizmo.d.ts +2 -2
  29. package/Loading/sceneLoader.d.ts +1 -1
  30. package/Materials/GreasedLine/greasedLineMaterialInterfaces.d.ts +3 -3
  31. package/Materials/Node/Blocks/meshAttributeExistsBlock.d.ts +1 -1
  32. package/Materials/Node/Blocks/waveBlock.d.ts +1 -1
  33. package/Materials/Node/Enums/nodeMaterialBlockConnectionPointMode.d.ts +1 -1
  34. package/Materials/Node/nodeMaterialBlockConnectionPoint.d.ts +2 -2
  35. package/Materials/Textures/internalTexture.d.ts +1 -1
  36. package/Materials/Textures/ktx2decoderTypes.d.ts +1 -1
  37. package/Materials/materialPluginEvent.d.ts +1 -1
  38. package/Materials/meshDebugPluginMaterial.d.ts +1 -1
  39. package/Materials/shaderLanguage.d.ts +1 -1
  40. package/Maths/math.axis.d.ts +2 -2
  41. package/Maths/math.path.d.ts +1 -1
  42. package/Maths/math.vector.js +32 -6
  43. package/Maths/math.vector.js.map +1 -1
  44. package/Meshes/Builders/greasedLineBuilder.d.ts +2 -2
  45. package/Meshes/GreasedLine/greasedLineBaseMesh.d.ts +3 -3
  46. package/Meshes/Node/nodeGeometryBlockConnectionPoint.d.ts +2 -2
  47. package/Meshes/abstractMesh.d.ts +49 -17
  48. package/Meshes/abstractMesh.js +126 -130
  49. package/Meshes/abstractMesh.js.map +1 -1
  50. package/Meshes/csg.js +12 -0
  51. package/Meshes/csg.js.map +1 -1
  52. package/Meshes/geometry.d.ts +8 -0
  53. package/Meshes/geometry.js +17 -0
  54. package/Meshes/geometry.js.map +1 -1
  55. package/Meshes/instancedMesh.d.ts +5 -8
  56. package/Meshes/instancedMesh.js +15 -9
  57. package/Meshes/instancedMesh.js.map +1 -1
  58. package/Meshes/mesh.d.ts +7 -3
  59. package/Meshes/mesh.js +20 -11
  60. package/Meshes/mesh.js.map +1 -1
  61. package/Meshes/meshSimplification.d.ts +1 -1
  62. package/Misc/assetsManager.d.ts +1 -1
  63. package/Misc/asyncLock.d.ts +24 -0
  64. package/Misc/asyncLock.js +32 -0
  65. package/Misc/asyncLock.js.map +1 -0
  66. package/Misc/copyTextureToTexture.d.ts +1 -1
  67. package/Misc/iInspectable.d.ts +1 -1
  68. package/Misc/index.d.ts +1 -0
  69. package/Misc/index.js +1 -0
  70. package/Misc/index.js.map +1 -1
  71. package/Misc/timer.d.ts +1 -1
  72. package/Misc/virtualJoystick.d.ts +1 -1
  73. package/Particles/gpuParticleSystem.js +1 -0
  74. package/Particles/gpuParticleSystem.js.map +1 -1
  75. package/Particles/pointsCloudSystem.d.ts +1 -1
  76. package/Particles/subEmitter.d.ts +1 -1
  77. package/Physics/physicsHelper.d.ts +2 -2
  78. package/Physics/v2/IPhysicsEnginePlugin.d.ts +8 -8
  79. package/Physics/v2/physicsMaterial.d.ts +1 -1
  80. package/PostProcesses/depthOfFieldEffect.d.ts +1 -1
  81. package/PostProcesses/tonemapPostProcess.d.ts +1 -1
  82. package/Rendering/fluidRenderer/fluidRenderingTargetRenderer.d.ts +1 -1
  83. package/XR/features/WebXRHandTracking.d.ts +2 -2
  84. package/XR/features/WebXRNearInteraction.d.ts +1 -1
  85. package/XR/webXRTypes.d.ts +2 -2
  86. package/package.json +1 -1
  87. package/scene.d.ts +1 -1
@@ -12,7 +12,7 @@ import type { GreasedLineMaterialOptions } from "../../Materials/GreasedLine/gre
12
12
  * How are the colors distributed along the color table
13
13
  * {@link https://doc.babylonjs.com/features/featuresDeepDive/mesh/creation/param/greased_line#colors-and-colordistribution}
14
14
  */
15
- export declare const enum GreasedLineMeshColorDistribution {
15
+ export declare enum GreasedLineMeshColorDistribution {
16
16
  /**
17
17
  * Do no modify the color table
18
18
  */
@@ -42,7 +42,7 @@ export declare const enum GreasedLineMeshColorDistribution {
42
42
  * How are the widths distributed along the width table
43
43
  * {@link https://doc.babylonjs.com/features/featuresDeepDive/mesh/creation/param/greased_line#widths-and-widthdistribution}
44
44
  */
45
- export declare const enum GreasedLineMeshWidthDistribution {
45
+ export declare enum GreasedLineMeshWidthDistribution {
46
46
  /**
47
47
  * Do no modify the width table
48
48
  */
@@ -10,7 +10,7 @@ import type { FloatArray, IndicesArray } from "../../types";
10
10
  * In POINTS_MODE_POINTS every array of points will become the center (backbone) of the ribbon. The ribbon will be expanded by `width / 2` to `+direction` and `-direction` as well.
11
11
  * In POINTS_MODE_PATHS every array of points specifies an edge. These will be used to build one ribbon.
12
12
  */
13
- export declare const enum GreasedLineRibbonPointsMode {
13
+ export declare enum GreasedLineRibbonPointsMode {
14
14
  POINTS_MODE_POINTS = 0,
15
15
  POINTS_MODE_PATHS = 1
16
16
  }
@@ -19,7 +19,7 @@ export declare const enum GreasedLineRibbonPointsMode {
19
19
  * FACES_MODE_SINGLE_SIDED_NO_BACKFACE_CULLING single sided without back face culling. Sets backFaceCulling = false on the material so it affects all line ribbons added to the line ribbon instance.
20
20
  * FACES_MODE_DOUBLE_SIDED extra back faces are created. This doubles the amount of faces of the mesh.
21
21
  */
22
- export declare const enum GreasedLineRibbonFacesMode {
22
+ export declare enum GreasedLineRibbonFacesMode {
23
23
  FACES_MODE_SINGLE_SIDED = 0,
24
24
  FACES_MODE_SINGLE_SIDED_NO_BACKFACE_CULLING = 1,
25
25
  FACES_MODE_DOUBLE_SIDED = 2
@@ -32,7 +32,7 @@ export declare const enum GreasedLineRibbonFacesMode {
32
32
  * AUTO_DIRECTIONS_FACE_TO in this mode the direction (slope) will be calculated for each line segment according to the direction vector between each point of the line segments and a direction (face-to) vector specified in direction. The resulting line will face to the direction of this face-to vector.
33
33
  * AUTO_DIRECTIONS_NONE you have to set the direction (slope) manually. Recommended.
34
34
  */
35
- export declare const enum GreasedLineRibbonAutoDirectionMode {
35
+ export declare enum GreasedLineRibbonAutoDirectionMode {
36
36
  AUTO_DIRECTIONS_FROM_FIRST_SEGMENT = 0,
37
37
  AUTO_DIRECTIONS_FROM_ALL_SEGMENTS = 1,
38
38
  AUTO_DIRECTIONS_ENHANCED = 2,
@@ -6,7 +6,7 @@ import type { NodeGeometryBuildState } from "./nodeGeometryBuildState";
6
6
  /**
7
7
  * Enum used to define the compatibility state between two connection points
8
8
  */
9
- export declare const enum NodeGeometryConnectionPointCompatibilityStates {
9
+ export declare enum NodeGeometryConnectionPointCompatibilityStates {
10
10
  /** Points are compatibles */
11
11
  Compatible = 0,
12
12
  /** Points are incompatible because of their types */
@@ -17,7 +17,7 @@ export declare const enum NodeGeometryConnectionPointCompatibilityStates {
17
17
  /**
18
18
  * Defines the direction of a connection point
19
19
  */
20
- export declare const enum NodeGeometryConnectionPointDirection {
20
+ export declare enum NodeGeometryConnectionPointDirection {
21
21
  /** Input */
22
22
  Input = 0,
23
23
  /** Output */
@@ -30,6 +30,33 @@ import type { Collider } from "../Collisions/collider";
30
30
  import type { TrianglePickingPredicate } from "../Culling/ray";
31
31
  import type { RenderingGroup } from "../Rendering/renderingGroup";
32
32
  import type { IEdgesRendererOptions } from "../Rendering/edgesRenderer";
33
+ /**
34
+ * Opaque cache when computing data about a mesh
35
+ */
36
+ export interface IMeshDataCache {
37
+ /** @internal */
38
+ _outputData?: Float32Array;
39
+ /** @internal */
40
+ _vertexData?: {
41
+ [kind: string]: Float32Array;
42
+ };
43
+ }
44
+ /**
45
+ * Options when computing data about a mesh
46
+ */
47
+ export interface IMeshDataOptions {
48
+ /** Apply skeleton when computing the bounding info. Defaults to false. */
49
+ applySkeleton?: boolean;
50
+ /** Apply morph when computing the bounding info. Defaults to false. */
51
+ applyMorph?: boolean;
52
+ /** Update the cached positions stored as a Vector3 array. Defaults to true. */
53
+ updatePositionsArray?: boolean;
54
+ /**
55
+ * Cache to avoid redundant allocations and computations when computing the bounding info multiple times. Pass in
56
+ * an initial empty object and continue with subsequent calls using the same object. Caching is disabled by default.
57
+ */
58
+ cache?: IMeshDataCache;
59
+ }
33
60
  /** @internal */
34
61
  declare class _FacetDataStorage {
35
62
  facetPositions: Vector3[];
@@ -477,7 +504,7 @@ export declare abstract class AbstractMesh extends TransformNode implements IDis
477
504
  /** Gets the list of lights affecting that mesh */
478
505
  get lightSources(): Light[];
479
506
  /** @internal */
480
- get _positions(): Nullable<Vector3[]>;
507
+ abstract get _positions(): Nullable<Vector3[]>;
481
508
  /** @internal */
482
509
  _waitingData: {
483
510
  lods: Nullable<any>;
@@ -606,6 +633,14 @@ export declare abstract class AbstractMesh extends TransformNode implements IDis
606
633
  * @returns null
607
634
  */
608
635
  getVerticesData(kind: string): Nullable<FloatArray>;
636
+ /**
637
+ * Copies the requested vertex data kind into the given vertex data map. Float data is constructed if the map doesn't have the data.
638
+ * @param kind defines the vertex data kind to use
639
+ * @param vertexData defines the map that stores the resulting data
640
+ */
641
+ abstract copyVerticesData(kind: string, vertexData: {
642
+ [kind: string]: Float32Array;
643
+ }): void;
609
644
  /**
610
645
  * Sets the vertex data of the mesh geometry for the requested `kind`.
611
646
  * If the mesh has no geometry, a new Geometry object is set to the mesh and then passed this vertex data.
@@ -783,11 +818,18 @@ export declare abstract class AbstractMesh extends TransformNode implements IDis
783
818
  /**
784
819
  * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
785
820
  * This means the mesh underlying bounding box and sphere are recomputed.
786
- * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
787
- * @param applyMorph defines whether to apply the morph target before computing the bounding info
821
+ * @param options defines a set of options for computing the bounding info
822
+ * @returns the current mesh
823
+ */
824
+ abstract refreshBoundingInfo(options: IMeshDataOptions): AbstractMesh;
825
+ /**
826
+ * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
827
+ * This means the mesh underlying bounding box and sphere are recomputed.
828
+ * @param applySkeletonOrOptions defines whether to apply the skeleton before computing the bounding info or a set of options
829
+ * @param applyMorph defines whether to apply the morph target before computing the bounding info
788
830
  * @returns the current mesh
789
831
  */
790
- refreshBoundingInfo(applySkeleton?: boolean, applyMorph?: boolean): AbstractMesh;
832
+ abstract refreshBoundingInfo(applySkeletonOrOptions: boolean | IMeshDataOptions, applyMorph: boolean): AbstractMesh;
791
833
  /**
792
834
  * @internal
793
835
  */
@@ -799,15 +841,9 @@ export declare abstract class AbstractMesh extends TransformNode implements IDis
799
841
  minimum: Vector3;
800
842
  maximum: Vector3;
801
843
  }): void;
802
- /**
803
- * Internal function to get buffer data and possibly apply morphs and normals
804
- * @param applySkeleton
805
- * @param applyMorph
806
- * @param data
807
- * @param kind the kind of data you want. Can be Normal or Position
808
- * @returns a FloatArray of the vertex data
809
- */
810
- private _getData;
844
+ private static _ApplySkeleton;
845
+ /** @internal */
846
+ protected _getData(options: IMeshDataOptions, data: Nullable<FloatArray>, kind?: string): Nullable<FloatArray>;
811
847
  /**
812
848
  * Get the normals vertex data and optionally apply skeleton and morphing.
813
849
  * @param applySkeleton defines whether to apply the skeleton
@@ -823,10 +859,6 @@ export declare abstract class AbstractMesh extends TransformNode implements IDis
823
859
  * @returns the position data
824
860
  */
825
861
  getPositionData(applySkeleton?: boolean, applyMorph?: boolean, data?: Nullable<FloatArray>): Nullable<FloatArray>;
826
- /**
827
- * @internal
828
- */
829
- _getPositionData(applySkeleton: boolean, applyMorph: boolean): Nullable<FloatArray>;
830
862
  /** @internal */
831
863
  _updateBoundingInfo(): AbstractMesh;
832
864
  /**
@@ -1,3 +1,4 @@
1
+ import { __decorate } from "../tslib.es6.js";
1
2
  import { Observable } from "../Misc/observable.js";
2
3
  import { Quaternion, Matrix, Vector3, TmpVectors } from "../Maths/math.vector.js";
3
4
  import { Engine } from "../Engines/engine.js";
@@ -15,6 +16,69 @@ import { Color3, Color4 } from "../Maths/math.color.js";
15
16
  import { Epsilon } from "../Maths/math.constants.js";
16
17
  import { Axis } from "../Maths/math.axis.js";
17
18
  import { RegisterClass } from "../Misc/typeStore.js";
19
+ import { nativeOverride } from "../Misc/decorators.js";
20
+ function applyMorph(data, kind, morphTargetManager) {
21
+ let getTargetData = null;
22
+ switch (kind) {
23
+ case VertexBuffer.PositionKind:
24
+ getTargetData = (target) => target.getPositions();
25
+ break;
26
+ case VertexBuffer.NormalKind:
27
+ getTargetData = (target) => target.getNormals();
28
+ break;
29
+ case VertexBuffer.TangentKind:
30
+ getTargetData = (target) => target.getTangents();
31
+ break;
32
+ case VertexBuffer.UVKind:
33
+ getTargetData = (target) => target.getUVs();
34
+ break;
35
+ default:
36
+ return;
37
+ }
38
+ for (let index = 0; index < data.length; index++) {
39
+ let value = data[index];
40
+ for (let targetCount = 0; targetCount < morphTargetManager.numTargets; targetCount++) {
41
+ const target = morphTargetManager.getTarget(targetCount);
42
+ const influence = target.influence;
43
+ if (influence !== 0) {
44
+ const targetData = getTargetData(target);
45
+ if (targetData) {
46
+ value += (targetData[index] - data[index]) * influence;
47
+ }
48
+ }
49
+ }
50
+ data[index] = value;
51
+ }
52
+ }
53
+ function applySkeleton(data, kind, skeletonMatrices, matricesIndicesData, matricesWeightsData, matricesIndicesExtraData, matricesWeightsExtraData) {
54
+ const tempVector = TmpVectors.Vector3[0];
55
+ const finalMatrix = TmpVectors.Matrix[0];
56
+ const tempMatrix = TmpVectors.Matrix[1];
57
+ const transformFromFloatsToRef = kind === VertexBuffer.NormalKind ? Vector3.TransformNormalFromFloatsToRef : Vector3.TransformCoordinatesFromFloatsToRef;
58
+ for (let index = 0, matWeightIdx = 0; index < data.length; index += 3, matWeightIdx += 4) {
59
+ finalMatrix.reset();
60
+ let inf;
61
+ let weight;
62
+ for (inf = 0; inf < 4; inf++) {
63
+ weight = matricesWeightsData[matWeightIdx + inf];
64
+ if (weight > 0) {
65
+ Matrix.FromFloat32ArrayToRefScaled(skeletonMatrices, Math.floor(matricesIndicesData[matWeightIdx + inf] * 16), weight, tempMatrix);
66
+ finalMatrix.addToSelf(tempMatrix);
67
+ }
68
+ }
69
+ if (matricesIndicesExtraData && matricesWeightsExtraData) {
70
+ for (inf = 0; inf < 4; inf++) {
71
+ weight = matricesWeightsExtraData[matWeightIdx + inf];
72
+ if (weight > 0) {
73
+ Matrix.FromFloat32ArrayToRefScaled(skeletonMatrices, Math.floor(matricesIndicesExtraData[matWeightIdx + inf] * 16), weight, tempMatrix);
74
+ finalMatrix.addToSelf(tempMatrix);
75
+ }
76
+ }
77
+ }
78
+ transformFromFloatsToRef(data[index], data[index + 1], data[index + 2], finalMatrix, tempVector);
79
+ tempVector.toArray(data, index);
80
+ }
81
+ }
18
82
  /** @internal */
19
83
  // eslint-disable-next-line @typescript-eslint/naming-convention
20
84
  class _FacetDataStorage {
@@ -480,10 +544,6 @@ export class AbstractMesh extends TransformNode {
480
544
  get lightSources() {
481
545
  return this._lightSources;
482
546
  }
483
- /** @internal */
484
- get _positions() {
485
- return null;
486
- }
487
547
  /**
488
548
  * Gets or sets a skeleton to apply skinning transformations
489
549
  * @see https://doc.babylonjs.com/features/featuresDeepDive/mesh/bonesSkeletons
@@ -1188,20 +1248,6 @@ export class AbstractMesh extends TransformNode {
1188
1248
  const defForwardMult = this.definedFacingForward ? 1 : -1;
1189
1249
  return new Vector3(flipBack * defForwardMult, twirlClockwise, tiltRight * defForwardMult);
1190
1250
  }
1191
- /**
1192
- * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
1193
- * This means the mesh underlying bounding box and sphere are recomputed.
1194
- * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
1195
- * @param applyMorph defines whether to apply the morph target before computing the bounding info
1196
- * @returns the current mesh
1197
- */
1198
- refreshBoundingInfo(applySkeleton = false, applyMorph = false) {
1199
- if (this._boundingInfo && this._boundingInfo.isLocked) {
1200
- return this;
1201
- }
1202
- this._refreshBoundingInfo(this._getPositionData(applySkeleton, applyMorph), null);
1203
- return this;
1204
- }
1205
1251
  /**
1206
1252
  * @internal
1207
1253
  */
@@ -1239,101 +1285,66 @@ export class AbstractMesh extends TransformNode {
1239
1285
  }
1240
1286
  this._updateBoundingInfo();
1241
1287
  }
1242
- /**
1243
- * Internal function to get buffer data and possibly apply morphs and normals
1244
- * @param applySkeleton
1245
- * @param applyMorph
1246
- * @param data
1247
- * @param kind the kind of data you want. Can be Normal or Position
1248
- * @returns a FloatArray of the vertex data
1249
- */
1250
- _getData(applySkeleton = false, applyMorph = false, data, kind = VertexBuffer.PositionKind) {
1251
- data = data ?? this.getVerticesData(kind).slice();
1252
- if (data && applyMorph && this.morphTargetManager) {
1253
- let faceIndexCount = 0;
1254
- let positionIndex = 0;
1255
- for (let vertexCount = 0; vertexCount < data.length; vertexCount++) {
1256
- let value = data[vertexCount];
1257
- for (let targetCount = 0; targetCount < this.morphTargetManager.numTargets; targetCount++) {
1258
- const targetMorph = this.morphTargetManager.getTarget(targetCount);
1259
- const influence = targetMorph.influence;
1260
- if (influence !== 0.0) {
1261
- let morphTargetData = null;
1262
- switch (kind) {
1263
- case VertexBuffer.PositionKind:
1264
- morphTargetData = targetMorph.getPositions();
1265
- break;
1266
- case VertexBuffer.NormalKind:
1267
- morphTargetData = targetMorph.getNormals();
1268
- break;
1269
- case VertexBuffer.TangentKind:
1270
- morphTargetData = targetMorph.getTangents();
1271
- break;
1272
- case VertexBuffer.UVKind:
1273
- morphTargetData = targetMorph.getUVs();
1274
- break;
1275
- }
1276
- if (morphTargetData) {
1277
- value += (morphTargetData[vertexCount] - data[vertexCount]) * influence;
1278
- }
1279
- }
1280
- }
1281
- data[vertexCount] = value;
1282
- faceIndexCount++;
1283
- if (kind === VertexBuffer.PositionKind) {
1284
- if (this._positions && faceIndexCount === 3) {
1285
- // We want to merge into positions every 3 indices starting (but not 0)
1286
- faceIndexCount = 0;
1287
- const index = positionIndex * 3;
1288
- this._positions[positionIndex++].copyFromFloats(data[index], data[index + 1], data[index + 2]);
1289
- }
1288
+ // This function is only here so we can apply the nativeOverride decorator.
1289
+ static _ApplySkeleton(data, kind, skeletonMatrices, matricesIndicesData, matricesWeightsData, matricesIndicesExtraData, matricesWeightsExtraData) {
1290
+ applySkeleton(data, kind, skeletonMatrices, matricesIndicesData, matricesWeightsData, matricesIndicesExtraData, matricesWeightsExtraData);
1291
+ }
1292
+ /** @internal */
1293
+ _getData(options, data, kind = VertexBuffer.PositionKind) {
1294
+ const cache = options.cache;
1295
+ const getVertexData = (kind) => {
1296
+ if (cache) {
1297
+ const vertexData = (cache._vertexData || (cache._vertexData = {}));
1298
+ if (!vertexData[kind]) {
1299
+ this.copyVerticesData(kind, vertexData);
1290
1300
  }
1301
+ return vertexData[kind];
1302
+ }
1303
+ return this.getVerticesData(kind);
1304
+ };
1305
+ data || (data = getVertexData(kind));
1306
+ if (!data) {
1307
+ return null;
1308
+ }
1309
+ if (cache) {
1310
+ if (cache._outputData) {
1311
+ cache._outputData.set(data);
1312
+ }
1313
+ else {
1314
+ cache._outputData = new Float32Array(data);
1291
1315
  }
1316
+ data = cache._outputData;
1292
1317
  }
1293
- if (data && applySkeleton && this.skeleton) {
1294
- const matricesIndicesData = this.getVerticesData(VertexBuffer.MatricesIndicesKind);
1295
- const matricesWeightsData = this.getVerticesData(VertexBuffer.MatricesWeightsKind);
1318
+ else if ((options.applyMorph && this.morphTargetManager) || (options.applySkeleton && this.skeleton)) {
1319
+ data = data.slice();
1320
+ }
1321
+ if (options.applyMorph && this.morphTargetManager) {
1322
+ applyMorph(data, kind, this.morphTargetManager);
1323
+ }
1324
+ if (options.applySkeleton && this.skeleton) {
1325
+ const matricesIndicesData = getVertexData(VertexBuffer.MatricesIndicesKind);
1326
+ const matricesWeightsData = getVertexData(VertexBuffer.MatricesWeightsKind);
1296
1327
  if (matricesWeightsData && matricesIndicesData) {
1297
1328
  const needExtras = this.numBoneInfluencers > 4;
1298
- const matricesIndicesExtraData = needExtras ? this.getVerticesData(VertexBuffer.MatricesIndicesExtraKind) : null;
1299
- const matricesWeightsExtraData = needExtras ? this.getVerticesData(VertexBuffer.MatricesWeightsExtraKind) : null;
1329
+ const matricesIndicesExtraData = needExtras ? getVertexData(VertexBuffer.MatricesIndicesExtraKind) : null;
1330
+ const matricesWeightsExtraData = needExtras ? getVertexData(VertexBuffer.MatricesWeightsExtraKind) : null;
1300
1331
  const skeletonMatrices = this.skeleton.getTransformMatrices(this);
1301
- const tempVector = TmpVectors.Vector3[0];
1302
- const finalMatrix = TmpVectors.Matrix[0];
1303
- const tempMatrix = TmpVectors.Matrix[1];
1304
- let matWeightIdx = 0;
1305
- for (let index = 0; index < data.length; index += 3, matWeightIdx += 4) {
1306
- finalMatrix.reset();
1307
- let inf;
1308
- let weight;
1309
- for (inf = 0; inf < 4; inf++) {
1310
- weight = matricesWeightsData[matWeightIdx + inf];
1311
- if (weight > 0) {
1312
- Matrix.FromFloat32ArrayToRefScaled(skeletonMatrices, Math.floor(matricesIndicesData[matWeightIdx + inf] * 16), weight, tempMatrix);
1313
- finalMatrix.addToSelf(tempMatrix);
1314
- }
1315
- }
1316
- if (needExtras) {
1317
- for (inf = 0; inf < 4; inf++) {
1318
- weight = matricesWeightsExtraData[matWeightIdx + inf];
1319
- if (weight > 0) {
1320
- Matrix.FromFloat32ArrayToRefScaled(skeletonMatrices, Math.floor(matricesIndicesExtraData[matWeightIdx + inf] * 16), weight, tempMatrix);
1321
- finalMatrix.addToSelf(tempMatrix);
1322
- }
1323
- }
1324
- }
1325
- if (kind === VertexBuffer.NormalKind) {
1326
- Vector3.TransformNormalFromFloatsToRef(data[index], data[index + 1], data[index + 2], finalMatrix, tempVector);
1327
- }
1328
- else {
1329
- Vector3.TransformCoordinatesFromFloatsToRef(data[index], data[index + 1], data[index + 2], finalMatrix, tempVector);
1330
- }
1331
- tempVector.toArray(data, index);
1332
- if (kind === VertexBuffer.PositionKind && this._positions) {
1333
- this._positions[index / 3].copyFrom(tempVector);
1334
- }
1332
+ AbstractMesh._ApplySkeleton(data, kind, skeletonMatrices, matricesIndicesData, matricesWeightsData, matricesIndicesExtraData, matricesWeightsExtraData);
1333
+ }
1334
+ }
1335
+ if (options.updatePositionsArray !== false && kind === VertexBuffer.PositionKind) {
1336
+ const positions = this._internalAbstractMeshDataInfo._positions || [];
1337
+ const previousLength = positions.length;
1338
+ positions.length = data.length / 3;
1339
+ if (previousLength < positions.length) {
1340
+ for (let positionIndex = previousLength; positionIndex < positions.length; positionIndex++) {
1341
+ positions[positionIndex] = new Vector3();
1335
1342
  }
1336
1343
  }
1344
+ for (let positionIndex = 0, dataIndex = 0; positionIndex < positions.length; positionIndex++, dataIndex += 3) {
1345
+ positions[positionIndex].copyFromFloats(data[dataIndex], data[dataIndex + 1], data[dataIndex + 2]);
1346
+ }
1347
+ this._internalAbstractMeshDataInfo._positions = positions;
1337
1348
  }
1338
1349
  return data;
1339
1350
  }
@@ -1344,7 +1355,7 @@ export class AbstractMesh extends TransformNode {
1344
1355
  * @returns the normals data
1345
1356
  */
1346
1357
  getNormalsData(applySkeleton = false, applyMorph = false) {
1347
- return this._getData(applySkeleton, applyMorph, null, VertexBuffer.NormalKind);
1358
+ return this._getData({ applySkeleton, applyMorph, updatePositionsArray: false }, null, VertexBuffer.NormalKind);
1348
1359
  }
1349
1360
  /**
1350
1361
  * Get the position vertex data and optionally apply skeleton and morphing.
@@ -1353,30 +1364,8 @@ export class AbstractMesh extends TransformNode {
1353
1364
  * @param data defines the position data to apply the skeleton and morph to
1354
1365
  * @returns the position data
1355
1366
  */
1356
- getPositionData(applySkeleton = false, applyMorph = false, data) {
1357
- return this._getData(applySkeleton, applyMorph, data, VertexBuffer.PositionKind);
1358
- }
1359
- /**
1360
- * @internal
1361
- */
1362
- _getPositionData(applySkeleton, applyMorph) {
1363
- let data = this.getVerticesData(VertexBuffer.PositionKind);
1364
- if (this._internalAbstractMeshDataInfo._positions) {
1365
- this._internalAbstractMeshDataInfo._positions = null;
1366
- }
1367
- if (data && ((applySkeleton && this.skeleton) || (applyMorph && this.morphTargetManager))) {
1368
- data = data.slice();
1369
- this._generatePointsArray();
1370
- if (this._positions) {
1371
- const pos = this._positions;
1372
- this._internalAbstractMeshDataInfo._positions = new Array(pos.length);
1373
- for (let i = 0; i < pos.length; i++) {
1374
- this._internalAbstractMeshDataInfo._positions[i] = pos[i]?.clone() || new Vector3();
1375
- }
1376
- }
1377
- return this.getPositionData(applySkeleton, applyMorph, data);
1378
- }
1379
- return data;
1367
+ getPositionData(applySkeleton = false, applyMorph = false, data = null) {
1368
+ return this._getData({ applySkeleton, applyMorph, updatePositionsArray: false }, data, VertexBuffer.PositionKind);
1380
1369
  }
1381
1370
  /** @internal */
1382
1371
  _updateBoundingInfo() {
@@ -2285,5 +2274,12 @@ AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION = 2;
2285
2274
  * If not, apply the Bounding Sphere Only strategy. No Bounding Box is tested here.
2286
2275
  */
2287
2276
  AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY = 3;
2277
+ __decorate([
2278
+ nativeOverride.filter((...[data, matricesIndicesData, matricesWeightsData, matricesIndicesExtraData, matricesWeightsExtraData]) => !Array.isArray(data) &&
2279
+ !Array.isArray(matricesIndicesData) &&
2280
+ !Array.isArray(matricesWeightsData) &&
2281
+ !Array.isArray(matricesIndicesExtraData) &&
2282
+ !Array.isArray(matricesWeightsExtraData))
2283
+ ], AbstractMesh, "_ApplySkeleton", null);
2288
2284
  RegisterClass("BABYLON.AbstractMesh", AbstractMesh);
2289
2285
  //# sourceMappingURL=abstractMesh.js.map