@babylonjs/core 7.48.2 → 7.49.0

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 (38) hide show
  1. package/Animations/animatable.core.d.ts +1 -0
  2. package/Animations/animatable.core.js +3 -1
  3. package/Animations/animatable.core.js.map +1 -1
  4. package/Engines/Native/nativeInterfaces.d.ts +6 -0
  5. package/Engines/Native/nativeInterfaces.js.map +1 -1
  6. package/Engines/WebGPU/webgpuCacheSampler.js +12 -3
  7. package/Engines/WebGPU/webgpuCacheSampler.js.map +1 -1
  8. package/Engines/abstractEngine.js +2 -2
  9. package/Engines/abstractEngine.js.map +1 -1
  10. package/Engines/nativeEngine.d.ts +5 -1
  11. package/Engines/nativeEngine.js +13 -0
  12. package/Engines/nativeEngine.js.map +1 -1
  13. package/Inputs/scene.inputManager.js +4 -4
  14. package/Inputs/scene.inputManager.js.map +1 -1
  15. package/Meshes/Node/Blocks/Sources/pointListBlock.d.ts +35 -0
  16. package/Meshes/Node/Blocks/Sources/pointListBlock.js +76 -0
  17. package/Meshes/Node/Blocks/Sources/pointListBlock.js.map +1 -0
  18. package/Meshes/Node/Blocks/computeNormalsBlock.js +3 -0
  19. package/Meshes/Node/Blocks/computeNormalsBlock.js.map +1 -1
  20. package/Meshes/Node/index.d.ts +1 -0
  21. package/Meshes/Node/index.js +1 -0
  22. package/Meshes/Node/index.js.map +1 -1
  23. package/Meshes/abstractMesh.hotSpot.d.ts +4 -4
  24. package/Meshes/abstractMesh.hotSpot.js +7 -10
  25. package/Meshes/abstractMesh.hotSpot.js.map +1 -1
  26. package/Meshes/csg2.js +1 -1
  27. package/Meshes/csg2.js.map +1 -1
  28. package/Meshes/mesh.d.ts +5 -0
  29. package/Meshes/mesh.js +32 -20
  30. package/Meshes/mesh.js.map +1 -1
  31. package/Misc/snapshotRenderingHelper.d.ts +3 -1
  32. package/Misc/snapshotRenderingHelper.js +27 -5
  33. package/Misc/snapshotRenderingHelper.js.map +1 -1
  34. package/Rendering/GlobalIllumination/giRSMManager.js +2 -2
  35. package/Rendering/GlobalIllumination/giRSMManager.js.map +1 -1
  36. package/ShadersWGSL/screenSpaceReflection2.fragment.js +1 -0
  37. package/ShadersWGSL/screenSpaceReflection2.fragment.js.map +1 -1
  38. package/package.json +1 -1
@@ -1 +1 @@
1
- {"version":3,"file":"computeNormalsBlock.js","sourceRoot":"","sources":["../../../../../../dev/core/src/Meshes/Node/Blocks/computeNormalsBlock.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,iCAAoC;AACzD,OAAO,EAAE,aAAa,EAAE,MAAM,yBAAyB,CAAC;AACxD,OAAO,EAAE,qCAAqC,EAAE,MAAM,2CAA2C,CAAC;AAClG,OAAO,EAAE,iBAAiB,EAAE,MAAM,sBAAsB,CAAC;AAEzD;;GAEG;AACH,MAAM,OAAO,mBAAoB,SAAQ,iBAAiB;IACtD;;;OAGG;IACH,YAAmB,IAAY;QAC3B,KAAK,CAAC,IAAI,CAAC,CAAC;QAEZ,IAAI,CAAC,aAAa,CAAC,UAAU,EAAE,qCAAqC,CAAC,QAAQ,CAAC,CAAC;QAC/E,IAAI,CAAC,cAAc,CAAC,QAAQ,EAAE,qCAAqC,CAAC,QAAQ,CAAC,CAAC;IAClF,CAAC;IAED;;;OAGG;IACa,YAAY;QACxB,OAAO,qBAAqB,CAAC;IACjC,CAAC;IAED;;OAEG;IACH,IAAW,QAAQ;QACf,OAAO,IAAI,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC;IAC3B,CAAC;IAED;;OAEG;IACH,IAAW,MAAM;QACb,OAAO,IAAI,CAAC,QAAQ,CAAC,CAAC,CAAC,CAAC;IAC5B,CAAC;IAEkB,WAAW;QAC1B,IAAI,CAAC,MAAM,CAAC,eAAe,GAAG,CAAC,KAAK,EAAE,EAAE;YACpC,IAAI,CAAC,IAAI,CAAC,QAAQ,CAAC,WAAW,EAAE,CAAC;gBAC7B,OAAO,IAAI,CAAC;YAChB,CAAC;YAED,MAAM,UAAU,GAAG,IAAI,CAAC,QAAQ,CAAC,iBAAiB,CAAC,KAAK,CAAC,CAAC;YAC1D,IAAI,CAAC,UAAU,CAAC,OAAO,EAAE,CAAC;gBACtB,UAAU,CAAC,OAAO,GAAG,EAAE,CAAC;YAC5B,CAAC;YAED,UAAU,CAAC,cAAc,CAAC,UAAU,CAAC,SAAS,EAAE,UAAU,CAAC,OAAO,EAAE,UAAU,CAAC,OAAO,CAAC,CAAC;YAExF,OAAO,UAAU,CAAC;QACtB,CAAC,CAAC;IACN,CAAC;CACJ;AAED,aAAa,CAAC,6BAA6B,EAAE,mBAAmB,CAAC,CAAC","sourcesContent":["import { VertexData } from \"core/Meshes/mesh.vertexData\";\r\nimport { RegisterClass } from \"../../../Misc/typeStore\";\r\nimport { NodeGeometryBlockConnectionPointTypes } from \"../Enums/nodeGeometryConnectionPointTypes\";\r\nimport { NodeGeometryBlock } from \"../nodeGeometryBlock\";\r\nimport type { NodeGeometryConnectionPoint } from \"../nodeGeometryBlockConnectionPoint\";\r\n/**\r\n * Block used to recompute normals for a geometry\r\n */\r\nexport class ComputeNormalsBlock extends NodeGeometryBlock {\r\n /**\r\n * Creates a new ComputeNormalsBlock\r\n * @param name defines the block name\r\n */\r\n public constructor(name: string) {\r\n super(name);\r\n\r\n this.registerInput(\"geometry\", NodeGeometryBlockConnectionPointTypes.Geometry);\r\n this.registerOutput(\"output\", NodeGeometryBlockConnectionPointTypes.Geometry);\r\n }\r\n\r\n /**\r\n * Gets the current class name\r\n * @returns the class name\r\n */\r\n public override getClassName() {\r\n return \"ComputeNormalsBlock\";\r\n }\r\n\r\n /**\r\n * Gets the geometry component\r\n */\r\n public get geometry(): NodeGeometryConnectionPoint {\r\n return this._inputs[0];\r\n }\r\n\r\n /**\r\n * Gets the output component\r\n */\r\n public get output(): NodeGeometryConnectionPoint {\r\n return this._outputs[0];\r\n }\r\n\r\n protected override _buildBlock() {\r\n this.output._storedFunction = (state) => {\r\n if (!this.geometry.isConnected) {\r\n return null;\r\n }\r\n\r\n const vertexData = this.geometry.getConnectedValue(state);\r\n if (!vertexData.normals) {\r\n vertexData.normals = [];\r\n }\r\n\r\n VertexData.ComputeNormals(vertexData.positions, vertexData.indices, vertexData.normals);\r\n\r\n return vertexData;\r\n };\r\n }\r\n}\r\n\r\nRegisterClass(\"BABYLON.ComputeNormalsBlock\", ComputeNormalsBlock);\r\n"]}
1
+ {"version":3,"file":"computeNormalsBlock.js","sourceRoot":"","sources":["../../../../../../dev/core/src/Meshes/Node/Blocks/computeNormalsBlock.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,iCAAoC;AACzD,OAAO,EAAE,aAAa,EAAE,MAAM,yBAAyB,CAAC;AACxD,OAAO,EAAE,qCAAqC,EAAE,MAAM,2CAA2C,CAAC;AAClG,OAAO,EAAE,iBAAiB,EAAE,MAAM,sBAAsB,CAAC;AAEzD;;GAEG;AACH,MAAM,OAAO,mBAAoB,SAAQ,iBAAiB;IACtD;;;OAGG;IACH,YAAmB,IAAY;QAC3B,KAAK,CAAC,IAAI,CAAC,CAAC;QAEZ,IAAI,CAAC,aAAa,CAAC,UAAU,EAAE,qCAAqC,CAAC,QAAQ,CAAC,CAAC;QAC/E,IAAI,CAAC,cAAc,CAAC,QAAQ,EAAE,qCAAqC,CAAC,QAAQ,CAAC,CAAC;IAClF,CAAC;IAED;;;OAGG;IACa,YAAY;QACxB,OAAO,qBAAqB,CAAC;IACjC,CAAC;IAED;;OAEG;IACH,IAAW,QAAQ;QACf,OAAO,IAAI,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC;IAC3B,CAAC;IAED;;OAEG;IACH,IAAW,MAAM;QACb,OAAO,IAAI,CAAC,QAAQ,CAAC,CAAC,CAAC,CAAC;IAC5B,CAAC;IAEkB,WAAW;QAC1B,IAAI,CAAC,MAAM,CAAC,eAAe,GAAG,CAAC,KAAK,EAAE,EAAE;YACpC,IAAI,CAAC,IAAI,CAAC,QAAQ,CAAC,WAAW,EAAE,CAAC;gBAC7B,OAAO,IAAI,CAAC;YAChB,CAAC;YAED,MAAM,UAAU,GAAG,IAAI,CAAC,QAAQ,CAAC,iBAAiB,CAAC,KAAK,CAAC,CAAC;YAC1D,IAAI,CAAC,UAAU,EAAE,CAAC;gBACd,OAAO,IAAI,CAAC;YAChB,CAAC;YAED,IAAI,CAAC,UAAU,CAAC,OAAO,EAAE,CAAC;gBACtB,UAAU,CAAC,OAAO,GAAG,EAAE,CAAC;YAC5B,CAAC;YAED,UAAU,CAAC,cAAc,CAAC,UAAU,CAAC,SAAS,EAAE,UAAU,CAAC,OAAO,EAAE,UAAU,CAAC,OAAO,CAAC,CAAC;YAExF,OAAO,UAAU,CAAC;QACtB,CAAC,CAAC;IACN,CAAC;CACJ;AAED,aAAa,CAAC,6BAA6B,EAAE,mBAAmB,CAAC,CAAC","sourcesContent":["import { VertexData } from \"core/Meshes/mesh.vertexData\";\r\nimport { RegisterClass } from \"../../../Misc/typeStore\";\r\nimport { NodeGeometryBlockConnectionPointTypes } from \"../Enums/nodeGeometryConnectionPointTypes\";\r\nimport { NodeGeometryBlock } from \"../nodeGeometryBlock\";\r\nimport type { NodeGeometryConnectionPoint } from \"../nodeGeometryBlockConnectionPoint\";\r\n/**\r\n * Block used to recompute normals for a geometry\r\n */\r\nexport class ComputeNormalsBlock extends NodeGeometryBlock {\r\n /**\r\n * Creates a new ComputeNormalsBlock\r\n * @param name defines the block name\r\n */\r\n public constructor(name: string) {\r\n super(name);\r\n\r\n this.registerInput(\"geometry\", NodeGeometryBlockConnectionPointTypes.Geometry);\r\n this.registerOutput(\"output\", NodeGeometryBlockConnectionPointTypes.Geometry);\r\n }\r\n\r\n /**\r\n * Gets the current class name\r\n * @returns the class name\r\n */\r\n public override getClassName() {\r\n return \"ComputeNormalsBlock\";\r\n }\r\n\r\n /**\r\n * Gets the geometry component\r\n */\r\n public get geometry(): NodeGeometryConnectionPoint {\r\n return this._inputs[0];\r\n }\r\n\r\n /**\r\n * Gets the output component\r\n */\r\n public get output(): NodeGeometryConnectionPoint {\r\n return this._outputs[0];\r\n }\r\n\r\n protected override _buildBlock() {\r\n this.output._storedFunction = (state) => {\r\n if (!this.geometry.isConnected) {\r\n return null;\r\n }\r\n\r\n const vertexData = this.geometry.getConnectedValue(state);\r\n if (!vertexData) {\r\n return null;\r\n }\r\n\r\n if (!vertexData.normals) {\r\n vertexData.normals = [];\r\n }\r\n\r\n VertexData.ComputeNormals(vertexData.positions, vertexData.indices, vertexData.normals);\r\n\r\n return vertexData;\r\n };\r\n }\r\n}\r\n\r\nRegisterClass(\"BABYLON.ComputeNormalsBlock\", ComputeNormalsBlock);\r\n"]}
@@ -19,6 +19,7 @@ export * from "./Blocks/Sources/cylinderBlock";
19
19
  export * from "./Blocks/Sources/capsuleBlock";
20
20
  export * from "./Blocks/Sources/discBlock";
21
21
  export * from "./Blocks/Sources/nullBlock";
22
+ export * from "./Blocks/Sources/pointListBlock";
22
23
  export * from "./Blocks/Set/setPositionsBlock";
23
24
  export * from "./Blocks/Set/setNormalsBlock";
24
25
  export * from "./Blocks/Set/setUVsBlock";
@@ -19,6 +19,7 @@ export * from "./Blocks/Sources/cylinderBlock.js";
19
19
  export * from "./Blocks/Sources/capsuleBlock.js";
20
20
  export * from "./Blocks/Sources/discBlock.js";
21
21
  export * from "./Blocks/Sources/nullBlock.js";
22
+ export * from "./Blocks/Sources/pointListBlock.js";
22
23
  export * from "./Blocks/Set/setPositionsBlock.js";
23
24
  export * from "./Blocks/Set/setNormalsBlock.js";
24
25
  export * from "./Blocks/Set/setUVsBlock.js";
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../../dev/core/src/Meshes/Node/index.ts"],"names":[],"mappings":"AAAA,cAAc,gBAAgB,CAAC;AAC/B,cAAc,qBAAqB,CAAC;AACpC,cAAc,oCAAoC,CAAC;AACnD,cAAc,0BAA0B,CAAC;AACzC,cAAc,2CAA2C,CAAC;AAC1D,cAAc,0CAA0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;AAC5D,cAAc,qCAAqC,CAAC;AACpD,cAAc,2CAA2C,CAAC;AAC1D,cAAc,2CAA2C,CAAC;AAC1D,cAAc,iCAAiC,CAAC;AAChD,cAAc,qBAAqB,CAAC;AACpC,cAAc,4BAA4B,CAAC;AAC3C,cAAc,uBAAuB,CAAC;AACtC,cAAc,6BAA6B,CAAC;AAC5C,cAAc,mCAAmC,CAAC;AAClD,cAAc,oCAAoC,CAAC;AACnD,cAAc,wCAAwC,CAAC;AACvD,cAAc,6CAA6C,CAAC;AAC5D,cAAc,wBAAwB,CAAC;AACvC,cAAc,+BAA+B,CAAC;AAC9C,cAAc,+BAA+B,CAAC;AAC9C,cAAc,4BAA4B,CAAC;AAC3C,cAAc,6BAA6B,CAAC;AAC5C,cAAc,4BAA4B,CAAC;AAC3C,cAAc,kCAAkC,CAAC;AACjD,cAAc,2BAA2B,CAAC;AAC1C,cAAc,2BAA2B,CAAC;AAC1C,cAAc,6BAA6B,CAAC;AAC5C,cAAc,6BAA6B,CAAC;AAC5C,cAAc,6BAA6B,CAAC;AAC5C,cAAc,kCAAkC,CAAC;AACjD,cAAc,iCAAiC,CAAC;AAChD,cAAc,oCAAoC,CAAC;AACnD,cAAc,gCAAgC,CAAC;AAC/C,cAAc,2BAA2B,CAAC;AAC1C,cAAc,8BAA8B,CAAC;AAC7C,cAAc,gCAAgC,CAAC;AAC/C,cAAc,mCAAmC,CAAC;AAClD,cAAc,8BAA8B,CAAC","sourcesContent":["export * from \"./nodeGeometry\";\r\nexport * from \"./nodeGeometryBlock\";\r\nexport * from \"./nodeGeometryBlockConnectionPoint\";\r\nexport * from \"./nodeGeometryBuildState\";\r\nexport * from \"./Interfaces/nodeGeometryExecutionContext\";\r\nexport * from \"./Enums/nodeGeometryConnectionPointTypes\";\r\nexport * from \"./Enums/nodeGeometryContextualSources\";\r\nexport * from \"./Blocks/geometryOptimizeBlock\";\r\nexport * from \"./Blocks/geometryOutputBlock\";\r\nexport * from \"./Blocks/geometryInputBlock\";\r\nexport * from \"./Blocks/Sources/planeBlock\";\r\nexport * from \"./Blocks/Sources/boxBlock\";\r\nexport * from \"./Blocks/Sources/meshBlock\";\r\nexport * from \"./Blocks/Sources/icoSphereBlock\";\r\nexport * from \"./Blocks/Sources/sphereBlock\";\r\nexport * from \"./Blocks/Sources/gridBlock\";\r\nexport * from \"./Blocks/Sources/torusBlock\";\r\nexport * from \"./Blocks/Sources/cylinderBlock\";\r\nexport * from \"./Blocks/Sources/capsuleBlock\";\r\nexport * from \"./Blocks/Sources/discBlock\";\r\nexport * from \"./Blocks/Sources/nullBlock\";\r\nexport * from \"./Blocks/Set/setPositionsBlock\";\r\nexport * from \"./Blocks/Set/setNormalsBlock\";\r\nexport * from \"./Blocks/Set/setUVsBlock\";\r\nexport * from \"./Blocks/Set/setColorsBlock\";\r\nexport * from \"./Blocks/Set/setTangentsBlock\";\r\nexport * from \"./Blocks/mathBlock\";\r\nexport * from \"./Blocks/mapRangeBlock\";\r\nexport * from \"./Blocks/conditionBlock\";\r\nexport * from \"./Blocks/randomBlock\";\r\nexport * from \"./Blocks/noiseBlock\";\r\nexport * from \"./Blocks/mergeGeometryBlock\";\r\nexport * from \"./Blocks/geometryCollectionBlock\";\r\nexport * from \"./Blocks/cleanGeometryBlock\";\r\nexport * from \"./Blocks/geometryElbowBlock\";\r\nexport * from \"./Blocks/computeNormalsBlock\";\r\nexport * from \"./Blocks/vectorConverterBlock\";\r\nexport * from \"./Blocks/normalizeVectorBlock\";\r\nexport * from \"./Blocks/Set/setMaterialIDBlock\";\r\nexport * from \"./Blocks/Set/latticeBlock\";\r\nexport * from \"./Blocks/geometryTrigonometryBlock\";\r\nexport * from \"./Blocks/geometryTransformBlock\";\r\nexport * from \"./Blocks/Matrices/rotationXBlock\";\r\nexport * from \"./Blocks/Matrices/rotationYBlock\";\r\nexport * from \"./Blocks/Matrices/rotationZBlock\";\r\nexport * from \"./Blocks/Matrices/scalingBlock\";\r\nexport * from \"./Blocks/Matrices/alignBlock\";\r\nexport * from \"./Blocks/Matrices/translationBlock\";\r\nexport * from \"./Blocks/Instances/instantiateOnVerticesBlock\";\r\nexport * from \"./Blocks/Instances/instantiateOnFacesBlock\";\r\nexport * from \"./Blocks/Instances/instantiateOnVolumeBlock\";\r\nexport * from \"./Blocks/Instances/instantiateBlock\";\r\nexport * from \"./Blocks/Instances/instantiateLinearBlock\";\r\nexport * from \"./Blocks/Instances/instantiateRadialBlock\";\r\nexport * from \"./Blocks/intFloatConverterBlock\";\r\nexport * from \"./Blocks/debugBlock\";\r\nexport * from \"./Blocks/geometryInfoBlock\";\r\nexport * from \"./Blocks/mappingBlock\";\r\nexport * from \"./Blocks/matrixComposeBlock\";\r\nexport * from \"./Blocks/Teleport/teleportInBlock\";\r\nexport * from \"./Blocks/Teleport/teleportOutBlock\";\r\nexport * from \"./Blocks/Textures/geometryTextureBlock\";\r\nexport * from \"./Blocks/Textures/geometryTextureFetchBlock\";\r\nexport * from \"./Blocks/boundingBlock\";\r\nexport * from \"./Blocks/booleanGeometryBlock\";\r\nexport * from \"./Blocks/geometryArcTan2Block\";\r\nexport * from \"./Blocks/geometryLerpBlock\";\r\nexport * from \"./Blocks/geometryNLerpBlock\";\r\nexport * from \"./Blocks/geometryStepBlock\";\r\nexport * from \"./Blocks/geometrySmoothStepBlock\";\r\nexport * from \"./Blocks/geometryModBlock\";\r\nexport * from \"./Blocks/geometryPowBlock\";\r\nexport * from \"./Blocks/geometryClampBlock\";\r\nexport * from \"./Blocks/geometryCrossBlock\";\r\nexport * from \"./Blocks/geometryCurveBlock\";\r\nexport * from \"./Blocks/geometryDesaturateBlock\";\r\nexport * from \"./Blocks/geometryPosterizeBlock\";\r\nexport * from \"./Blocks/geometryReplaceColorBlock\";\r\nexport * from \"./Blocks/geometryDistanceBlock\";\r\nexport * from \"./Blocks/geometryDotBlock\";\r\nexport * from \"./Blocks/geometryLengthBlock\";\r\nexport * from \"./Blocks/geometryRotate2dBlock\";\r\nexport * from \"./Blocks/geometryInterceptorBlock\";\r\nexport * from \"./Blocks/Set/aggregatorBlock\";\r\n"]}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../../dev/core/src/Meshes/Node/index.ts"],"names":[],"mappings":"AAAA,cAAc,gBAAgB,CAAC;AAC/B,cAAc,qBAAqB,CAAC;AACpC,cAAc,oCAAoC,CAAC;AACnD,cAAc,0BAA0B,CAAC;AACzC,cAAc,2CAA2C,CAAC;AAC1D,cAAc,0CAA0C,CAAC;AACzD,cAAc,uCAAuC,CAAC;AACtD,cAAc,gCAAgC,CAAC;AAC/C,cAAc,8BAA8B,CAAC;AAC7C,cAAc,6BAA6B,CAAC;AAC5C,cAAc,6BAA6B,CAAC;AAC5C,cAAc,2BAA2B,CAAC;AAC1C,cAAc,4BAA4B,CAAC;AAC3C,cAAc,iCAAiC,CAAC;AAChD,cAAc,8BAA8B,CAAC;AAC7C,cAAc,4BAA4B,CAAC;AAC3C,cAAc,6BAA6B,CAAC;AAC5C,cAAc,gCAAgC,CAAC;AAC/C,cAAc,+BAA+B,CAAC;AAC9C,cAAc,4BAA4B,CAAC;AAC3C,cAAc,4BAA4B,CAAC;AAC3C,cAAc,iCAAiC,CAAC;AAChD,cAAc,gCAAgC,CAAC;AAC/C,cAAc,8BAA8B,CAAC;AAC7C,cAAc,0BAA0B,CAAC;AACzC,cAAc,6BAA6B,CAAC;AAC5C,cAAc,+BAA+B,CAAC;AAC9C,cAAc,oBAAoB,CAAC;AACnC,cAAc,wBAAwB,CAAC;AACvC,cAAc,yBAAyB,CAAC;AACxC,cAAc,sBAAsB,CAAC;AACrC,cAAc,qBAAqB,CAAC;AACpC,cAAc,6BAA6B,CAAC;AAC5C,cAAc,kCAAkC,CAAC;AACjD,cAAc,6BAA6B,CAAC;AAC5C,cAAc,6BAA6B,CAAC;AAC5C,cAAc,8BAA8B,CAAC;AAC7C,cAAc,+BAA+B,CAAC;AAC9C,cAAc,+BAA+B,CAAC;AAC9C,cAAc,iCAAiC,CAAC;AAChD,cAAc,2B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\";\r\nexport * from \"./nodeGeometryBlock\";\r\nexport * from \"./nodeGeometryBlockConnectionPoint\";\r\nexport * from \"./nodeGeometryBuildState\";\r\nexport * from \"./Interfaces/nodeGeometryExecutionContext\";\r\nexport * from \"./Enums/nodeGeometryConnectionPointTypes\";\r\nexport * from \"./Enums/nodeGeometryContextualSources\";\r\nexport * from \"./Blocks/geometryOptimizeBlock\";\r\nexport * from \"./Blocks/geometryOutputBlock\";\r\nexport * from \"./Blocks/geometryInputBlock\";\r\nexport * from \"./Blocks/Sources/planeBlock\";\r\nexport * from \"./Blocks/Sources/boxBlock\";\r\nexport * from \"./Blocks/Sources/meshBlock\";\r\nexport * from \"./Blocks/Sources/icoSphereBlock\";\r\nexport * from \"./Blocks/Sources/sphereBlock\";\r\nexport * from \"./Blocks/Sources/gridBlock\";\r\nexport * from \"./Blocks/Sources/torusBlock\";\r\nexport * from \"./Blocks/Sources/cylinderBlock\";\r\nexport * from \"./Blocks/Sources/capsuleBlock\";\r\nexport * from \"./Blocks/Sources/discBlock\";\r\nexport * from \"./Blocks/Sources/nullBlock\";\r\nexport * from \"./Blocks/Sources/pointListBlock\";\r\nexport * from \"./Blocks/Set/setPositionsBlock\";\r\nexport * from \"./Blocks/Set/setNormalsBlock\";\r\nexport * from \"./Blocks/Set/setUVsBlock\";\r\nexport * from \"./Blocks/Set/setColorsBlock\";\r\nexport * from \"./Blocks/Set/setTangentsBlock\";\r\nexport * from \"./Blocks/mathBlock\";\r\nexport * from \"./Blocks/mapRangeBlock\";\r\nexport * from \"./Blocks/conditionBlock\";\r\nexport * from \"./Blocks/randomBlock\";\r\nexport * from \"./Blocks/noiseBlock\";\r\nexport * from \"./Blocks/mergeGeometryBlock\";\r\nexport * from \"./Blocks/geometryCollectionBlock\";\r\nexport * from \"./Blocks/cleanGeometryBlock\";\r\nexport * from \"./Blocks/geometryElbowBlock\";\r\nexport * from \"./Blocks/computeNormalsBlock\";\r\nexport * from \"./Blocks/vectorConverterBlock\";\r\nexport * from \"./Blocks/normalizeVectorBlock\";\r\nexport * from \"./Blocks/Set/setMaterialIDBlock\";\r\nexport * from \"./Blocks/Set/latticeBlock\";\r\nexport * from \"./Blocks/geometryTrigonometryBlock\";\r\nexport * from \"./Blocks/geometryTransformBlock\";\r\nexport * from \"./Blocks/Matrices/rotationXBlock\";\r\nexport * from \"./Blocks/Matrices/rotationYBlock\";\r\nexport * from \"./Blocks/Matrices/rotationZBlock\";\r\nexport * from \"./Blocks/Matrices/scalingBlock\";\r\nexport * from \"./Blocks/Matrices/alignBlock\";\r\nexport * from \"./Blocks/Matrices/translationBlock\";\r\nexport * from \"./Blocks/Instances/instantiateOnVerticesBlock\";\r\nexport * from \"./Blocks/Instances/instantiateOnFacesBlock\";\r\nexport * from \"./Blocks/Instances/instantiateOnVolumeBlock\";\r\nexport * from \"./Blocks/Instances/instantiateBlock\";\r\nexport * from \"./Blocks/Instances/instantiateLinearBlock\";\r\nexport * from \"./Blocks/Instances/instantiateRadialBlock\";\r\nexport * from \"./Blocks/intFloatConverterBlock\";\r\nexport * from \"./Blocks/debugBlock\";\r\nexport * from \"./Blocks/geometryInfoBlock\";\r\nexport * from \"./Blocks/mappingBlock\";\r\nexport * from \"./Blocks/matrixComposeBlock\";\r\nexport * from \"./Blocks/Teleport/teleportInBlock\";\r\nexport * from \"./Blocks/Teleport/teleportOutBlock\";\r\nexport * from \"./Blocks/Textures/geometryTextureBlock\";\r\nexport * from \"./Blocks/Textures/geometryTextureFetchBlock\";\r\nexport * from \"./Blocks/boundingBlock\";\r\nexport * from \"./Blocks/booleanGeometryBlock\";\r\nexport * from \"./Blocks/geometryArcTan2Block\";\r\nexport * from \"./Blocks/geometryLerpBlock\";\r\nexport * from \"./Blocks/geometryNLerpBlock\";\r\nexport * from \"./Blocks/geometryStepBlock\";\r\nexport * from \"./Blocks/geometrySmoothStepBlock\";\r\nexport * from \"./Blocks/geometryModBlock\";\r\nexport * from \"./Blocks/geometryPowBlock\";\r\nexport * from \"./Blocks/geometryClampBlock\";\r\nexport * from \"./Blocks/geometryCrossBlock\";\r\nexport * from \"./Blocks/geometryCurveBlock\";\r\nexport * from \"./Blocks/geometryDesaturateBlock\";\r\nexport * from \"./Blocks/geometryPosterizeBlock\";\r\nexport * from \"./Blocks/geometryReplaceColorBlock\";\r\nexport * from \"./Blocks/geometryDistanceBlock\";\r\nexport * from \"./Blocks/geometryDotBlock\";\r\nexport * from \"./Blocks/geometryLengthBlock\";\r\nexport * from \"./Blocks/geometryRotate2dBlock\";\r\nexport * from \"./Blocks/geometryInterceptorBlock\";\r\nexport * from \"./Blocks/Set/aggregatorBlock\";\r\n"]}
@@ -1,4 +1,4 @@
1
- import type { AbstractMesh, Nullable, PickingInfo } from "../index.js";
1
+ import type { AbstractMesh, PickingInfo } from "../index.js";
2
2
  import { Vector3 } from "../Maths/math.vector";
3
3
  /**
4
4
  * Data for mesh hotspot computation
@@ -15,11 +15,11 @@ export type HotSpotQuery = {
15
15
  };
16
16
  /**
17
17
  * Create a HotSpotQuery from a picking info
18
- * @remarks If there is no pickedMesh or the pickedMesh has no indices, null will be returned
18
+ * @remarks If there is no pickedMesh or the pickedMesh has no indices, the faceId is used as the base index
19
19
  * @param pickingInfo picking info to use
20
- * @returns HotSpotQuery or null if it was not possible to create one
20
+ * @returns the created HotSpotQuery
21
21
  */
22
- export declare function CreateHotSpotQueryForPickingInfo(pickingInfo: PickingInfo): Nullable<HotSpotQuery>;
22
+ export declare function CreateHotSpotQueryForPickingInfo(pickingInfo: PickingInfo): HotSpotQuery;
23
23
  /**
24
24
  * Return a transformed local position from a mesh and vertex index
25
25
  * @param mesh mesh used to get vertex array from
@@ -3,20 +3,17 @@ import { VertexBuffer } from "../Buffers/buffer.js";
3
3
 
4
4
  /**
5
5
  * Create a HotSpotQuery from a picking info
6
- * @remarks If there is no pickedMesh or the pickedMesh has no indices, null will be returned
6
+ * @remarks If there is no pickedMesh or the pickedMesh has no indices, the faceId is used as the base index
7
7
  * @param pickingInfo picking info to use
8
- * @returns HotSpotQuery or null if it was not possible to create one
8
+ * @returns the created HotSpotQuery
9
9
  */
10
10
  export function CreateHotSpotQueryForPickingInfo(pickingInfo) {
11
11
  const indices = pickingInfo.pickedMesh?.getIndices();
12
- if (indices) {
13
- const base = pickingInfo.faceId * 3;
14
- return {
15
- pointIndex: [indices[base], indices[base + 1], indices[base + 2]],
16
- barycentric: [pickingInfo.bu, pickingInfo.bv, 1 - pickingInfo.bu - pickingInfo.bv],
17
- };
18
- }
19
- return null;
12
+ const base = pickingInfo.faceId * 3;
13
+ return {
14
+ pointIndex: indices ? [indices[base], indices[base + 1], indices[base + 2]] : [base, base + 1, base + 2],
15
+ barycentric: [pickingInfo.bu, pickingInfo.bv, 1 - pickingInfo.bu - pickingInfo.bv],
16
+ };
20
17
  }
21
18
  /**
22
19
  * Return a transformed local position from a mesh and vertex index
@@ -1 +1 @@
1
- {"version":3,"file":"abstractMesh.hotSpot.js","sourceRoot":"","sources":["../../../../dev/core/src/Meshes/abstractMesh.hotSpot.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,OAAO,EAAE,UAAU,EAAE,MAAM,EAAE,MAAM,sBAAsB,CAAC;AACnE,OAAO,EAAE,YAAY,EAAE,MAAM,mBAAmB,CAAC;AACjD,OAAO,EAAE,SAAS,EAAE,gCAA+B;AAgBnD;;;;;GAKG;AACH,MAAM,UAAU,gCAAgC,CAAC,WAAwB;IACrE,MAAM,OAAO,GAAG,WAAW,CAAC,UAAU,EAAE,UAAU,EAAE,CAAC;IACrD,IAAI,OAAO,EAAE,CAAC;QACV,MAAM,IAAI,GAAG,WAAW,CAAC,MAAM,GAAG,CAAC,CAAC;QACpC,OAAO;YACH,UAAU,EAAE,CAAC,OAAO,CAAC,IAAI,CAAC,EAAE,OAAO,CAAC,IAAI,GAAG,CAAC,CAAC,EAAE,OAAO,CAAC,IAAI,GAAG,CAAC,CAAC,CAAC;YACjE,WAAW,EAAE,CAAC,WAAW,CAAC,EAAE,EAAE,WAAW,CAAC,EAAE,E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AAC;QACjC,QAAQ,CAAC,SAAS,EAAE,CAAC;QACrB,QAAQ,CAAC,SAAS,EAAE,CAAC;QACrB,OAAO,CAAC,UAAU,CAAC,QAAQ,EAAE,QAAQ,EAAE,SAAS,CAAC,CAAC;QAElD,2CAA2C;QAC3C,MAAM,UAAU,GACZ,IAAI,CAAC,QAAQ;YACb,IAAI,CAAC,QAAQ,CAAC,eAAe;gBACzB,CAAC,IAAI,CAAC,QAAQ,EAAE,CAAC,oBAAoB,CAAC,CAAC,CAAC,SAAS,CAAC,iCAAiC,CAAC,CAAC,CAAC,SAAS,CAAC,wCAAwC,CAAC,CAAC;QAElJ,IAAI,UAAU,EAAE,CAAC;YACb,SAAS,CAAC,YAAY,CAAC,CAAC,CAAC,CAAC,CAAC;QAC/B,CAAC;QAED,oCAAoC;QACpC,OAAO,CAAC,oBAAoB,CAAC,SAAS,EAAE,IAAI,CAAC,cAAc,EAAE,EAAE,SAAS,CAAC,CAAC;QAC1E,SAAS,CAAC,SAAS,EAAE,CAAC;IAC1B,CAAC;IAED,OAAO,IAAI,CAAC;AAChB,CAAC","sourcesContent":["// eslint-disable-next-line import/no-internal-modules\r\nimport type { AbstractMesh, Nullable, PickingInfo } from \"core/index\";\r\nimport { Vector3, TmpVectors, Matrix } from \"../Maths/math.vector\";\r\nimport { VertexBuffer } from \"../Buffers/buffer\";\r\nimport { Constants } from \"core/Engines/constants\";\r\n\r\n/**\r\n * Data for mesh hotspot computation\r\n */\r\nexport type HotSpotQuery = {\r\n /**\r\n * 3 point indices\r\n */\r\n pointIndex: [number, number, number];\r\n /**\r\n * 3 barycentric coordinates\r\n */\r\n barycentric: [number, number, number];\r\n};\r\n\r\n/**\r\n * Create a HotSpotQuery from a picking info\r\n * @remarks If there is no pickedMesh or the pickedMesh has no indices, null will be returned\r\n * @param pickingInfo picking info to use\r\n * @returns HotSpotQuery or null if it was not possible to create one\r\n */\r\nexport function CreateHotSpotQueryForPickingInfo(pickingInfo: PickingInfo): Nullable<HotSpotQuery> {\r\n const indices = pickingInfo.pickedMesh?.getIndices();\r\n if (indices) {\r\n const base = pickingInfo.faceId * 3;\r\n return {\r\n pointIndex: [indices[base], indices[base + 1], indices[base + 2]],\r\n barycentric: [pickingInfo.bu, pickingInfo.bv, 1 - pickingInfo.bu - pickingInfo.bv],\r\n };\r\n }\r\n\r\n return null;\r\n}\r\n\r\n/**\r\n * Return a transformed local position from a mesh and vertex index\r\n * @param mesh mesh used to get vertex array from\r\n * @param index vertex index\r\n * @param res resulting local position\r\n * @returns false if it was not possible to compute the position for that vertex\r\n */\r\nexport function GetTransformedPosition(mesh: AbstractMesh, index: number, res: Vector3): boolean {\r\n const data = mesh.getVerticesData(VertexBuffer.PositionKind);\r\n if (!data) {\r\n return false;\r\n }\r\n const base = index * 3;\r\n const values = [data[base + 0], data[base + 1], data[base + 2]];\r\n if (values.some((value) => isNaN(value ?? Number.NaN))) {\r\n return false;\r\n }\r\n\r\n if (mesh.morphTargetManager) {\r\n for (let component = 0; component < 3; component++) {\r\n let value = values[component];\r\n for (let targetCount = 0; targetCount < mesh.morphTargetManager.numTargets; targetCount++) {\r\n const target = mesh.morphTargetManager.getTarget(targetCount);\r\n const influence = target.influence;\r\n if (influence !== 0) {\r\n const targetData = target.getPositions();\r\n if (targetData) {\r\n value += (targetData[base + component] - data[base + component]) * influence;\r\n }\r\n }\r\n }\r\n values[component] = value;\r\n }\r\n }\r\n res.fromArray(values);\r\n if (mesh.skeleton) {\r\n const matricesIndicesData = mesh.getVerticesData(VertexBuffer.MatricesIndicesKind);\r\n const matricesWeightsData = mesh.getVerticesData(VertexBuffer.MatricesWeightsKind);\r\n if (matricesWeightsData && matricesIndicesData) {\r\n const needExtras = mesh.numBoneInfluencers > 4;\r\n const matricesIndicesExtraData = needExtras ? mesh.getVerticesData(VertexBuffer.MatricesIndicesExtraKind) : null;\r\n const matricesWeightsExtraData = needExtras ? mesh.getVerticesData(VertexBuffer.MatricesWeightsExtraKind) : null;\r\n const skeletonMatrices = mesh.skeleton.getTransformMatrices(mesh);\r\n\r\n const finalMatrix = TmpVectors.Matrix[0];\r\n const tempMatrix = TmpVectors.Matrix[1];\r\n\r\n finalMatrix.reset();\r\n const matWeightIdx = index * 4;\r\n\r\n let inf: number;\r\n let weight: number;\r\n for (inf = 0; inf < 4; inf++) {\r\n weight = matricesWeightsData[matWeightIdx + inf];\r\n if (weight > 0) {\r\n Matrix.FromFloat32ArrayToRefScaled(skeletonMatrices, Math.floor(matricesIndicesData[matWeightIdx + inf] * 16), weight, tempMatrix);\r\n finalMatrix.addToSelf(tempMatrix);\r\n }\r\n }\r\n if (matricesIndicesExtraData && matricesWeightsExtraData) {\r\n for (inf = 0; inf < 4; inf++) {\r\n weight = matricesWeightsExtraData[matWeightIdx + inf];\r\n if (weight > 0) {\r\n Matrix.FromFloat32ArrayToRefScaled(skeletonMatrices, Math.floor(matricesIndicesExtraData[matWeightIdx + inf] * 16), weight, tempMatrix);\r\n finalMatrix.addToSelf(tempMatrix);\r\n }\r\n }\r\n }\r\n\r\n Vector3.TransformCoordinatesFromFloatsToRef(values[0], values[1], values[2], finalMatrix, res);\r\n }\r\n }\r\n\r\n return true;\r\n}\r\n\r\n/**\r\n * Compute a world space hotspot position\r\n * TmpVectors.Vector3[0..4] are modified by this function. Do not use them as result output.\r\n * @param mesh mesh used to get hotspot from\r\n * @param hotSpotQuery point indices and barycentric\r\n * @param resPosition output world position\r\n * @param resNormal optional output world normal\r\n * @returns false if it was not possible to compute the hotspot position\r\n */\r\nexport function GetHotSpotToRef(mesh: AbstractMesh, hotSpotQuery: HotSpotQuery, resPosition: Vector3, resNormal?: Vector3): boolean {\r\n resPosition.set(0, 0, 0);\r\n for (let i = 0; i < 3; i++) {\r\n const index = hotSpotQuery.pointIndex[i];\r\n if (!GetTransformedPosition(mesh, index, TmpVectors.Vector3[i])) {\r\n return false;\r\n }\r\n TmpVectors.Vector3[i].scaleAndAddToRef(hotSpotQuery.barycentric[i], resPosition);\r\n }\r\n\r\n // Convert the result to world space\r\n Vector3.TransformCoordinatesToRef(resPosition, mesh.getWorldMatrix(), resPosition);\r\n\r\n // compute normal in world space\r\n if (resNormal) {\r\n const pointA = TmpVectors.Vector3[0];\r\n const pointB = TmpVectors.Vector3[1];\r\n const pointC = TmpVectors.Vector3[2];\r\n const segmentA = TmpVectors.Vector3[3];\r\n const segmentB = TmpVectors.Vector3[4];\r\n segmentA.copyFrom(pointB);\r\n segmentA.subtractInPlace(pointA);\r\n segmentB.copyFrom(pointC);\r\n segmentB.subtractInPlace(pointA);\r\n segmentA.normalize();\r\n segmentB.normalize();\r\n Vector3.CrossToRef(segmentA, segmentB, resNormal);\r\n\r\n // flip normal when face culling is changed\r\n const flipNormal =\r\n mesh.material &&\r\n mesh.material.sideOrientation ===\r\n (mesh.getScene().useRightHandedSystem ? Constants.MATERIAL_ClockWiseSideOrientation : Constants.MATERIAL_CounterClockWiseSideOrientation);\r\n\r\n if (flipNormal) {\r\n resNormal.scaleInPlace(-1);\r\n }\r\n\r\n // Convert the result to world space\r\n Vector3.TransformNormalToRef(resNormal, mesh.getWorldMatrix(), resNormal);\r\n resNormal.normalize();\r\n }\r\n\r\n return true;\r\n}\r\n"]}
1
+ {"version":3,"file":"abstractMesh.hotSpot.js","sourceRoot":"","sources":["../../../../dev/core/src/Meshes/abstractMesh.hotSpot.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,OAAO,EAAE,UAAU,EAAE,MAAM,EAAE,MAAM,sBAAsB,CAAC;AACnE,OAAO,EAAE,YAAY,EAAE,MAAM,mBAAmB,CAAC;AACjD,OAAO,EAAE,SAAS,EAAE,gCAA+B;AAgBnD;;;;;GAKG;AACH,MAAM,UAAU,gCAAgC,CAAC,WAAwB;IACrE,MAAM,OAAO,GAAG,WAAW,CAAC,UAAU,EAAE,UAAU,EAAE,CAAC;IACrD,MAAM,IAAI,GAAG,WAAW,CAAC,MAAM,GAAG,CAAC,CAAC;IAEpC,OAAO;QACH,UAAU,EAAE,OAAO,CAAC,CAAC,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AG,UAAU,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC;QACvC,QAAQ,CAAC,QAAQ,CAAC,MAAM,CAAC,CAAC;QAC1B,QAAQ,CAAC,eAAe,CAAC,MAAM,CAAC,CAAC;QACjC,QAAQ,CAAC,QAAQ,CAAC,MAAM,CAAC,CAAC;QAC1B,QAAQ,CAAC,eAAe,CAAC,MAAM,CAAC,CAAC;QACjC,QAAQ,CAAC,SAAS,EAAE,CAAC;QACrB,QAAQ,CAAC,SAAS,EAAE,CAAC;QACrB,OAAO,CAAC,UAAU,CAAC,QAAQ,EAAE,QAAQ,EAAE,SAAS,CAAC,CAAC;QAElD,2CAA2C;QAC3C,MAAM,UAAU,GACZ,IAAI,CAAC,QAAQ;YACb,IAAI,CAAC,QAAQ,CAAC,eAAe;gBACzB,CAAC,IAAI,CAAC,QAAQ,EAAE,CAAC,oBAAoB,CAAC,CAAC,CAAC,SAAS,CAAC,iCAAiC,CAAC,CAAC,CAAC,SAAS,CAAC,wCAAwC,CAAC,CAAC;QAElJ,IAAI,UAAU,EAAE,CAAC;YACb,SAAS,CAAC,YAAY,CAAC,CAAC,CAAC,CAAC,CAAC;QAC/B,CAAC;QAED,oCAAoC;QACpC,OAAO,CAAC,oBAAoB,CAAC,SAAS,EAAE,IAAI,CAAC,cAAc,EAAE,EAAE,SAAS,CAAC,CAAC;QAC1E,SAAS,CAAC,SAAS,EAAE,CAAC;IAC1B,CAAC;IAED,OAAO,IAAI,CAAC;AAChB,CAAC","sourcesContent":["// eslint-disable-next-line import/no-internal-modules\r\nimport type { AbstractMesh, PickingInfo } from \"core/index\";\r\nimport { Vector3, TmpVectors, Matrix } from \"../Maths/math.vector\";\r\nimport { VertexBuffer } from \"../Buffers/buffer\";\r\nimport { Constants } from \"core/Engines/constants\";\r\n\r\n/**\r\n * Data for mesh hotspot computation\r\n */\r\nexport type HotSpotQuery = {\r\n /**\r\n * 3 point indices\r\n */\r\n pointIndex: [number, number, number];\r\n /**\r\n * 3 barycentric coordinates\r\n */\r\n barycentric: [number, number, number];\r\n};\r\n\r\n/**\r\n * Create a HotSpotQuery from a picking info\r\n * @remarks If there is no pickedMesh or the pickedMesh has no indices, the faceId is used as the base index\r\n * @param pickingInfo picking info to use\r\n * @returns the created HotSpotQuery\r\n */\r\nexport function CreateHotSpotQueryForPickingInfo(pickingInfo: PickingInfo): HotSpotQuery {\r\n const indices = pickingInfo.pickedMesh?.getIndices();\r\n const base = pickingInfo.faceId * 3;\r\n\r\n return {\r\n pointIndex: indices ? [indices[base], indices[base + 1], indices[base + 2]] : [base, base + 1, base + 2],\r\n barycentric: [pickingInfo.bu, pickingInfo.bv, 1 - pickingInfo.bu - pickingInfo.bv],\r\n };\r\n}\r\n\r\n/**\r\n * Return a transformed local position from a mesh and vertex index\r\n * @param mesh mesh used to get vertex array from\r\n * @param index vertex index\r\n * @param res resulting local position\r\n * @returns false if it was not possible to compute the position for that vertex\r\n */\r\nexport function GetTransformedPosition(mesh: AbstractMesh, index: number, res: Vector3): boolean {\r\n const data = mesh.getVerticesData(VertexBuffer.PositionKind);\r\n if (!data) {\r\n return false;\r\n }\r\n const base = index * 3;\r\n const values = [data[base + 0], data[base + 1], data[base + 2]];\r\n if (values.some((value) => isNaN(value ?? Number.NaN))) {\r\n return false;\r\n }\r\n\r\n if (mesh.morphTargetManager) {\r\n for (let component = 0; component < 3; component++) {\r\n let value = values[component];\r\n for (let targetCount = 0; targetCount < mesh.morphTargetManager.numTargets; targetCount++) {\r\n const target = mesh.morphTargetManager.getTarget(targetCount);\r\n const influence = target.influence;\r\n if (influence !== 0) {\r\n const targetData = target.getPositions();\r\n if (targetData) {\r\n value += (targetData[base + component] - data[base + component]) * influence;\r\n }\r\n }\r\n }\r\n values[component] = value;\r\n }\r\n }\r\n res.fromArray(values);\r\n if (mesh.skeleton) {\r\n const matricesIndicesData = mesh.getVerticesData(VertexBuffer.MatricesIndicesKind);\r\n const matricesWeightsData = mesh.getVerticesData(VertexBuffer.MatricesWeightsKind);\r\n if (matricesWeightsData && matricesIndicesData) {\r\n const needExtras = mesh.numBoneInfluencers > 4;\r\n const matricesIndicesExtraData = needExtras ? mesh.getVerticesData(VertexBuffer.MatricesIndicesExtraKind) : null;\r\n const matricesWeightsExtraData = needExtras ? mesh.getVerticesData(VertexBuffer.MatricesWeightsExtraKind) : null;\r\n const skeletonMatrices = mesh.skeleton.getTransformMatrices(mesh);\r\n\r\n const finalMatrix = TmpVectors.Matrix[0];\r\n const tempMatrix = TmpVectors.Matrix[1];\r\n\r\n finalMatrix.reset();\r\n const matWeightIdx = index * 4;\r\n\r\n let inf: number;\r\n let weight: number;\r\n for (inf = 0; inf < 4; inf++) {\r\n weight = matricesWeightsData[matWeightIdx + inf];\r\n if (weight > 0) {\r\n Matrix.FromFloat32ArrayToRefScaled(skeletonMatrices, Math.floor(matricesIndicesData[matWeightIdx + inf] * 16), weight, tempMatrix);\r\n finalMatrix.addToSelf(tempMatrix);\r\n }\r\n }\r\n if (matricesIndicesExtraData && matricesWeightsExtraData) {\r\n for (inf = 0; inf < 4; inf++) {\r\n weight = matricesWeightsExtraData[matWeightIdx + inf];\r\n if (weight > 0) {\r\n Matrix.FromFloat32ArrayToRefScaled(skeletonMatrices, Math.floor(matricesIndicesExtraData[matWeightIdx + inf] * 16), weight, tempMatrix);\r\n finalMatrix.addToSelf(tempMatrix);\r\n }\r\n }\r\n }\r\n\r\n Vector3.TransformCoordinatesFromFloatsToRef(values[0], values[1], values[2], finalMatrix, res);\r\n }\r\n }\r\n\r\n return true;\r\n}\r\n\r\n/**\r\n * Compute a world space hotspot position\r\n * TmpVectors.Vector3[0..4] are modified by this function. Do not use them as result output.\r\n * @param mesh mesh used to get hotspot from\r\n * @param hotSpotQuery point indices and barycentric\r\n * @param resPosition output world position\r\n * @param resNormal optional output world normal\r\n * @returns false if it was not possible to compute the hotspot position\r\n */\r\nexport function GetHotSpotToRef(mesh: AbstractMesh, hotSpotQuery: HotSpotQuery, resPosition: Vector3, resNormal?: Vector3): boolean {\r\n resPosition.set(0, 0, 0);\r\n for (let i = 0; i < 3; i++) {\r\n const index = hotSpotQuery.pointIndex[i];\r\n if (!GetTransformedPosition(mesh, index, TmpVectors.Vector3[i])) {\r\n return false;\r\n }\r\n TmpVectors.Vector3[i].scaleAndAddToRef(hotSpotQuery.barycentric[i], resPosition);\r\n }\r\n\r\n // Convert the result to world space\r\n Vector3.TransformCoordinatesToRef(resPosition, mesh.getWorldMatrix(), resPosition);\r\n\r\n // compute normal in world space\r\n if (resNormal) {\r\n const pointA = TmpVectors.Vector3[0];\r\n const pointB = TmpVectors.Vector3[1];\r\n const pointC = TmpVectors.Vector3[2];\r\n const segmentA = TmpVectors.Vector3[3];\r\n const segmentB = TmpVectors.Vector3[4];\r\n segmentA.copyFrom(pointB);\r\n segmentA.subtractInPlace(pointA);\r\n segmentB.copyFrom(pointC);\r\n segmentB.subtractInPlace(pointA);\r\n segmentA.normalize();\r\n segmentB.normalize();\r\n Vector3.CrossToRef(segmentA, segmentB, resNormal);\r\n\r\n // flip normal when face culling is changed\r\n const flipNormal =\r\n mesh.material &&\r\n mesh.material.sideOrientation ===\r\n (mesh.getScene().useRightHandedSystem ? Constants.MATERIAL_ClockWiseSideOrientation : Constants.MATERIAL_CounterClockWiseSideOrientation);\r\n\r\n if (flipNormal) {\r\n resNormal.scaleInPlace(-1);\r\n }\r\n\r\n // Convert the result to world space\r\n Vector3.TransformNormalToRef(resNormal, mesh.getWorldMatrix(), resNormal);\r\n resNormal.normalize();\r\n }\r\n\r\n return true;\r\n}\r\n"]}
package/Meshes/csg2.js CHANGED
@@ -333,7 +333,7 @@ export function IsCSG2Ready() {
333
333
  */
334
334
  export async function InitializeCSG2Async(options) {
335
335
  const localOptions = {
336
- manifoldUrl: "https://unpkg.com/manifold-3d@3.0.0",
336
+ manifoldUrl: "https://unpkg.com/manifold-3d@3.0.1",
337
337
  ...options,
338
338
  };
339
339
  if (localOptions.manifoldInstance) {
@@ -1 +1 @@
1
- {"version":3,"file":"csg2.js","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,WAAW;;;;;SAKjD,CACA,CAAC;QAEF,QAAQ,GAAG,MAAM,CAAC,QAAQ,CAAC;QAC3B,YAAY,GAAG,MAAM,CAAC,IAAI,CAAC;IAC/B,CAAC;IAED,0FAA0F;IAC1F,OAAO,GAAG,QAAQ,CAAC,UAAU,CAAC,KAAK,CAAC,CAAC;AACzC,CAAC","sourcesContent":["import { Mesh } from \"./mesh\";\r\nimport type { IDisposable, Scene } from \"core/scene\";\r\nimport type { IVertexDataLike } from \"./mesh.vertexData\";\r\nimport { VertexData } from \"./mesh.vertexData\";\r\nimport { VertexBuffer } from \"../Buffers/buffer\";\r\nimport { Logger } from \"core/Misc/logger\";\r\nimport { MultiMaterial } from \"core/Materials/multiMaterial\";\r\nimport { SubMesh } from \"./subMesh\";\r\nimport type { Material } from \"core/Materials/material\";\r\nimport { _LoadScriptModuleAsync } from \"core/Misc/tools.internals\";\r\nimport type { FloatArray, Nullable } from \"core/types\";\r\nimport type { Matrix } from \"core/Maths/math.vector\";\r\nimport { Vector3 } from \"core/Maths/math.vector\";\r\n\r\n/**\r\n * Main manifold library\r\n */\r\n// eslint-disable-next-line @typescript-eslint/naming-convention\r\nlet Manifold: any;\r\n\r\n/**\r\n * Manifold mesh\r\n */\r\n// eslint-disable-next-line @typescript-eslint/naming-convention\r\nlet ManifoldMesh: any;\r\n\r\n/**\r\n * First ID to use for materials indexing\r\n */\r\n// eslint-disable-next-line @typescript-eslint/naming-convention\r\nlet FirstID: number;\r\n\r\n/**\r\n * Interface to customize the Manifold library import\r\n */\r\nexport interface ICSG2Options {\r\n /**\r\n * Custom manifold URL\r\n */\r\n manifoldUrl?: string;\r\n /**\r\n * Custom manifold instance\r\n */\r\n manifoldInstance: any;\r\n /**\r\n * Custom manifold mesh instance\r\n */\r\n manifoldMeshInstance: any;\r\n}\r\n\r\n/**\r\n * Interface to customize the mesh rebuild options\r\n */\r\nexport interface IMeshRebuildOptions {\r\n /**\r\n * Rebuild normals\r\n */\r\n rebuildNormals?: boolean;\r\n /**\r\n * True to center the mesh on 0,0,0\r\n */\r\n centerMesh?: boolean;\r\n /**\r\n * Defines a material to use for that mesh. When not defined the system will either reuse the one from the source or create a multimaterial if several materials were involved\r\n */\r\n materialToUse?: Material;\r\n}\r\n\r\n/**\r\n * Interface to customize the vertex data rebuild options\r\n */\r\nexport interface IVertexDataRebuildOptions {\r\n /**\r\n * Rebuild normals\r\n */\r\n rebuildNormals?: boolean;\r\n}\r\n\r\ninterface IManifoldMesh {\r\n numProp: number;\r\n vertProperties: Float32Array;\r\n triVerts: Uint32Array;\r\n runIndex: Uint32Array;\r\n runOriginalID: Uint32Array;\r\n numRun: number;\r\n}\r\n\r\ninterface IManifoldVertexComponent {\r\n stride: number;\r\n kind: string;\r\n data?: FloatArray;\r\n}\r\n\r\n/**\r\n * Wrapper around the Manifold library\r\n * https://manifoldcad.org/\r\n * Use this class to perform fast boolean operations on meshes\r\n * #IW43EB#15 - basic operations\r\n * #JUKXQD#6104 - skull vs box\r\n * #JUKXQD#6111 - skull vs vertex data\r\n */\r\nexport class CSG2 implements IDisposable {\r\n private _manifold: any;\r\n private _numProp: number;\r\n private _vertexStructure: IManifoldVertexComponent[];\r\n\r\n /**\r\n * Return the size of a vertex (at least 3 for the position)\r\n */\r\n public get numProp() {\r\n return this._numProp;\r\n }\r\n\r\n private constructor(manifold: any, numProp: number, vertexStructure: IManifoldVertexComponent[]) {\r\n this._manifold = manifold;\r\n this._numProp = numProp;\r\n this._vertexStructure = vertexStructure;\r\n }\r\n\r\n private _process(operation: \"difference\" | \"intersection\" | \"union\", csg: CSG2) {\r\n if (this.numProp !== csg.numProp) {\r\n throw new Error(\"CSG must be used with geometries having the same number of properties\");\r\n }\r\n return new CSG2(Manifold[operation](this._manifold, csg._manifold), this.numProp, this._vertexStructure);\r\n }\r\n\r\n /**\r\n * Run a difference operation between two CSG\r\n * @param csg defines the CSG to use to create the difference\r\n * @returns a new csg\r\n */\r\n public subtract(csg: CSG2) {\r\n return this._process(\"difference\", csg);\r\n }\r\n\r\n /**\r\n * Run an intersection operation between two CSG\r\n * @param csg defines the CSG to use to create the intersection\r\n * @returns a new csg\r\n */\r\n public intersect(csg: CSG2) {\r\n return this._process(\"intersection\", csg);\r\n }\r\n\r\n /**\r\n * Run an union operation between two CSG\r\n * @param csg defines the CSG to use to create the union\r\n * @returns a new csg\r\n */\r\n public add(csg: CSG2) {\r\n return this._process(\"union\", csg);\r\n }\r\n\r\n /**\r\n * Print debug information about the CSG\r\n */\r\n public printDebug() {\r\n Logger.Log(\"Genus:\" + this._manifold.genus());\r\n const properties = this._manifold.getProperties();\r\n Logger.Log(\"Volume:\" + properties.volume);\r\n Logger.Log(\"surface area:\" + properties.surfaceArea);\r\n }\r\n\r\n /**\r\n * Generate a vertex data from the CSG\r\n * @param options defines the options to use to rebuild the vertex data\r\n * @returns a new vertex data\r\n */\r\n public toVertexData(options?: Partial<IVertexDataRebuildOptions>): VertexData {\r\n const localOptions = {\r\n rebuildNormals: false,\r\n ...options,\r\n };\r\n const vertexData = new VertexData();\r\n const normalComponent = this._vertexStructure.find((c) => c.kind === VertexBuffer.NormalKind);\r\n const manifoldMesh: IManifoldMesh = this._manifold.getMesh(localOptions.rebuildNormals && normalComponent ? [3, 4, 5] : undefined);\r\n\r\n vertexData.indices = manifoldMesh.triVerts.length > 65535 ? new Uint32Array(manifoldMesh.triVerts) : new Uint16Array(manifoldMesh.triVerts);\r\n\r\n for (let i = 0; i < manifoldMesh.triVerts.length; i += 3) {\r\n vertexData.indices[i] = manifoldMesh.triVerts[i + 2];\r\n vertexData.indices[i + 1] = manifoldMesh.triVerts[i + 1];\r\n vertexData.indices[i + 2] = manifoldMesh.triVerts[i];\r\n }\r\n\r\n const vertexCount = manifoldMesh.vertProperties.length / manifoldMesh.numProp;\r\n\r\n // Attributes\r\n let offset = 0;\r\n for (let componentIndex = 0; componentIndex < this._vertexStructure.length; componentIndex++) {\r\n const component = this._vertexStructure[componentIndex];\r\n\r\n const data = new Float32Array(vertexCount * component.stride);\r\n for (let i = 0; i < vertexCount; i++) {\r\n for (let strideIndex = 0; strideIndex < component.stride; strideIndex++) {\r\n data[i * component.stride + strideIndex] = manifoldMesh.vertProperties[i * manifoldMesh.numProp + offset + strideIndex];\r\n }\r\n }\r\n vertexData.set(data, component.kind);\r\n offset += component.stride;\r\n }\r\n\r\n // Rebuild mesh from vertex data\r\n return vertexData;\r\n }\r\n\r\n /**\r\n * Generate a mesh from the CSG\r\n * @param name defines the name of the mesh\r\n * @param scene defines the scene to use to create the mesh\r\n * @param options defines the options to use to rebuild the mesh\r\n * @returns a new Mesh\r\n */\r\n public toMesh(name: string, scene?: Scene, options?: Partial<IMeshRebuildOptions>): Mesh {\r\n const localOptions = {\r\n rebuildNormals: false,\r\n centerMesh: true,\r\n ...options,\r\n };\r\n const vertexData = this.toVertexData({ rebuildNormals: localOptions.rebuildNormals });\r\n const normalComponent = this._vertexStructure.find((c) => c.kind === VertexBuffer.NormalKind);\r\n const manifoldMesh: IManifoldMesh = this._manifold.getMesh(localOptions.rebuildNormals && normalComponent ? [3, 4, 5] : undefined);\r\n const vertexCount = manifoldMesh.vertProperties.length / manifoldMesh.numProp;\r\n\r\n // Rebuild mesh from vertex data\r\n const output = new Mesh(name, scene);\r\n vertexData.applyToMesh(output);\r\n\r\n // Center mesh\r\n if (localOptions.centerMesh) {\r\n const extents = output.getBoundingInfo().boundingSphere.center;\r\n output.position.set(-extents.x, -extents.y, -extents.z);\r\n output.bakeCurrentTransformIntoVertices();\r\n }\r\n\r\n // Submeshes\r\n let id = manifoldMesh.runOriginalID[0];\r\n let start = manifoldMesh.runIndex[0];\r\n let materialIndex = 0;\r\n const materials: Material[] = [];\r\n scene = output.getScene();\r\n for (let run = 0; run < manifoldMesh.numRun; ++run) {\r\n const nextID = manifoldMesh.runOriginalID[run + 1];\r\n if (nextID !== id) {\r\n const end = manifoldMesh.runIndex[run + 1];\r\n new SubMesh(materialIndex, 0, vertexCount, start, end - start, output);\r\n materials.push(scene.getMaterialByUniqueID(id - FirstID) || scene.defaultMaterial);\r\n id = nextID;\r\n start = end;\r\n materialIndex++;\r\n }\r\n }\r\n\r\n if (localOptions.materialToUse) {\r\n output.material = localOptions.materialToUse;\r\n } else {\r\n if (materials.length > 1) {\r\n const multiMaterial = new MultiMaterial(name, scene);\r\n multiMaterial.subMaterials = materials;\r\n output.material = multiMaterial;\r\n } else {\r\n output.material = materials[0];\r\n }\r\n }\r\n\r\n return output;\r\n }\r\n\r\n /**\r\n * Dispose the CSG resources\r\n */\r\n public dispose() {\r\n if (this._manifold) {\r\n this._manifold.delete();\r\n this._manifold = null;\r\n }\r\n }\r\n\r\n private static _ProcessData(\r\n vertexCount: number,\r\n triVerts: Uint32Array,\r\n structure: IManifoldVertexComponent[],\r\n numProp: number,\r\n runIndex?: Uint32Array,\r\n runOriginalID?: Uint32Array\r\n ) {\r\n const vertProperties = new Float32Array(vertexCount * structure.reduce((acc, cur) => acc + cur.stride, 0));\r\n\r\n for (let i = 0; i < vertexCount; i++) {\r\n let offset = 0;\r\n for (let idx = 0; idx < structure.length; idx++) {\r\n const component = structure[idx];\r\n\r\n for (let strideIndex = 0; strideIndex < component.stride; strideIndex++) {\r\n vertProperties[i * numProp + offset + strideIndex] = component.data![i * component.stride + strideIndex];\r\n }\r\n offset += component.stride;\r\n }\r\n }\r\n\r\n const manifoldMesh = new ManifoldMesh({ numProp: numProp, vertProperties, triVerts, runIndex, runOriginalID });\r\n manifoldMesh.merge();\r\n\r\n let returnValue: CSG2;\r\n try {\r\n returnValue = new CSG2(new Manifold(manifoldMesh), numProp, structure);\r\n } catch (e) {\r\n throw new Error(\"Error while creating the CSG: \" + e.message);\r\n }\r\n\r\n return returnValue;\r\n }\r\n\r\n private static _Construct(data: IVertexDataLike, worldMatrix: Nullable<Matrix>, runIndex?: Uint32Array, runOriginalID?: Uint32Array) {\r\n // Create the MeshGL for I/O with Manifold library.\r\n const triVerts = new Uint32Array(data.indices!.length);\r\n\r\n // Revert order\r\n for (let i = 0; i < data.indices!.length; i += 3) {\r\n triVerts[i] = data.indices![i + 2];\r\n triVerts[i + 1] = data.indices![i + 1];\r\n triVerts[i + 2] = data.indices![i];\r\n }\r\n\r\n const tempVector3 = new Vector3();\r\n let numProp = 3;\r\n const structure: IManifoldVertexComponent[] = [{ stride: 3, kind: VertexBuffer.PositionKind }];\r\n\r\n if (!worldMatrix) {\r\n structure[0].data = data.positions!;\r\n } else {\r\n const positions = new Float32Array(data.positions!.length);\r\n for (let i = 0; i < data.positions!.length; i += 3) {\r\n Vector3.TransformCoordinatesFromFloatsToRef(data.positions![i], data.positions![i + 1], data.positions![i + 2], worldMatrix, tempVector3);\r\n tempVector3.toArray(positions, i);\r\n }\r\n structure[0].data = positions;\r\n }\r\n\r\n // Normals\r\n const sourceNormals = data.normals!;\r\n if (sourceNormals) {\r\n numProp += 3;\r\n structure.push({ stride: 3, kind: VertexBuffer.NormalKind });\r\n if (!worldMatrix) {\r\n structure[1].data = sourceNormals;\r\n } else {\r\n const normals = new Float32Array(sourceNormals.length);\r\n for (let i = 0; i < sourceNormals.length; i += 3) {\r\n Vector3.TransformNormalFromFloatsToRef(sourceNormals[i], sourceNormals[i + 1], sourceNormals[i + 2], worldMatrix, tempVector3);\r\n tempVector3.toArray(normals, i);\r\n }\r\n structure[1].data = normals;\r\n }\r\n }\r\n\r\n // UVs\r\n for (const kind of [VertexBuffer.UVKind, VertexBuffer.UV2Kind, VertexBuffer.UV3Kind, VertexBuffer.UV4Kind, VertexBuffer.UV5Kind, VertexBuffer.UV6Kind]) {\r\n const sourceUV = (data as any)[kind === VertexBuffer.UVKind ? \"uvs\" : kind];\r\n if (sourceUV) {\r\n numProp += 2;\r\n structure.push({ stride: 2, kind: kind, data: sourceUV });\r\n }\r\n }\r\n\r\n // Colors\r\n const sourceColors = data.colors;\r\n if (sourceColors) {\r\n numProp += 4;\r\n structure.push({ stride: 4, kind: VertexBuffer.ColorKind, data: sourceColors });\r\n }\r\n\r\n return this._ProcessData(data.positions!.length / 3, triVerts, structure, numProp, runIndex, runOriginalID);\r\n }\r\n\r\n /**\r\n * Create a new Constructive Solid Geometry from a vertexData\r\n * @param vertexData defines the vertexData to use to create the CSG\r\n * @returns a new CSG2 class\r\n */\r\n public static FromVertexData(vertexData: VertexData): CSG2 {\r\n const sourceVertices = vertexData.positions;\r\n const sourceIndices = vertexData.indices;\r\n\r\n if (!sourceVertices || !sourceIndices) {\r\n throw new Error(\"The vertexData must at least have positions and indices\");\r\n }\r\n\r\n return this._Construct(vertexData, null);\r\n }\r\n\r\n /**\r\n * Create a new Constructive Solid Geometry from a mesh\r\n * @param mesh defines the mesh to use to create the CSG\r\n * @param ignoreWorldMatrix defines if the world matrix should be ignored\r\n * @returns a new CSG2 class\r\n */\r\n public static FromMesh(mesh: Mesh, ignoreWorldMatrix = false): CSG2 {\r\n const sourceVertices = mesh.getVerticesData(VertexBuffer.PositionKind);\r\n const sourceIndices = mesh.getIndices();\r\n const worldMatrix = mesh.computeWorldMatrix(true);\r\n\r\n if (!sourceVertices || !sourceIndices) {\r\n throw new Error(\"The mesh must at least have positions and indices\");\r\n }\r\n\r\n // Create a triangle run for each submesh (material)\r\n const starts = [...Array(mesh.subMeshes.length)].map((_, idx) => mesh.subMeshes[idx].indexStart);\r\n\r\n // Map the materials to ID.\r\n const sourceMaterial = mesh.material || mesh.getScene().defaultMaterial;\r\n const isMultiMaterial = sourceMaterial.getClassName() === \"MultiMaterial\";\r\n const originalIDs = [...Array(mesh.subMeshes.length)].map((_, idx) => {\r\n if (isMultiMaterial) {\r\n return FirstID + (sourceMaterial as MultiMaterial).subMaterials[mesh.subMeshes[idx].materialIndex]!.uniqueId;\r\n }\r\n\r\n return FirstID + sourceMaterial.uniqueId;\r\n });\r\n\r\n // List the runs in sequence.\r\n const indices = Array.from(starts.keys());\r\n indices.sort((a, b) => starts[a] - starts[b]);\r\n const runIndex = new Uint32Array(indices.map((i) => starts[i]));\r\n const runOriginalID = new Uint32Array(indices.map((i) => originalIDs[i]));\r\n\r\n // Process\r\n const data = {\r\n positions: sourceVertices,\r\n indices: sourceIndices,\r\n normals: mesh.getVerticesData(VertexBuffer.NormalKind),\r\n colors: mesh.getVerticesData(VertexBuffer.ColorKind),\r\n uvs: mesh.getVerticesData(VertexBuffer.UVKind),\r\n uvs2: mesh.getVerticesData(VertexBuffer.UV2Kind),\r\n uvs3: mesh.getVerticesData(VertexBuffer.UV3Kind),\r\n uvs4: mesh.getVerticesData(VertexBuffer.UV4Kind),\r\n uvs5: mesh.getVerticesData(VertexBuffer.UV5Kind),\r\n uvs6: mesh.getVerticesData(VertexBuffer.UV6Kind),\r\n };\r\n return this._Construct(data, ignoreWorldMatrix ? null : worldMatrix, runIndex, runOriginalID);\r\n }\r\n}\r\n\r\n/**\r\n * Checks if the Manifold library is ready\r\n * @returns true if the Manifold library is ready\r\n */\r\nexport function IsCSG2Ready() {\r\n return Manifold !== undefined;\r\n}\r\n\r\n/**\r\n * Initialize the Manifold library\r\n * @param options defines the options to use to initialize the library\r\n */\r\nexport async function InitializeCSG2Async(options?: Partial<ICSG2Options>) {\r\n const localOptions = {\r\n manifoldUrl: \"https://unpkg.com/manifold-3d@3.0.0\",\r\n ...options,\r\n };\r\n\r\n if (localOptions.manifoldInstance) {\r\n Manifold = localOptions.manifoldInstance;\r\n ManifoldMesh = localOptions.manifoldMeshInstance;\r\n } else {\r\n const result = await _LoadScriptModuleAsync(\r\n `\r\n import Module from '${localOptions.manifoldUrl}/manifold.js';\r\n const wasm = await Module();\r\n wasm.setup();\r\n const {Manifold, Mesh} = wasm;\r\n const returnedValue = {Manifold, Mesh};\r\n `\r\n );\r\n\r\n Manifold = result.Manifold;\r\n ManifoldMesh = result.Mesh;\r\n }\r\n\r\n // Reserve IDs for materials (we consider that there will be no more than 65536 materials)\r\n FirstID = Manifold.reserveIDs(65536);\r\n}\r\n"]}
1
+ {"version":3,"file":"csg2.js","sourceRoot":"","sources":["../../../../dev/core/src/Meshes/csg2.ts"],"names":[],"mappings":"AAAA,OAAO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CAAC;QAC3B,YAAY,GAAG,MAAM,CAAC,IAAI,CAAC;IAC/B,CAAC;IAED,0FAA0F;IAC1F,OAAO,GAAG,QAAQ,CAAC,UAAU,CAAC,KAAK,CAAC,CAAC;AACzC,CAAC","sourcesContent":["import { Mesh } from \"./mesh\";\r\nimport type { IDisposable, Scene } from \"core/scene\";\r\nimport type { IVertexDataLike } from \"./mesh.vertexData\";\r\nimport { VertexData } from \"./mesh.vertexData\";\r\nimport { VertexBuffer } from \"../Buffers/buffer\";\r\nimport { Logger } from \"core/Misc/logger\";\r\nimport { MultiMaterial } from \"core/Materials/multiMaterial\";\r\nimport { SubMesh } from \"./subMesh\";\r\nimport type { Material } from \"core/Materials/material\";\r\nimport { _LoadScriptModuleAsync } from \"core/Misc/tools.internals\";\r\nimport type { FloatArray, Nullable } from \"core/types\";\r\nimport type { Matrix } from \"core/Maths/math.vector\";\r\nimport { Vector3 } from \"core/Maths/math.vector\";\r\n\r\n/**\r\n * Main manifold library\r\n */\r\n// eslint-disable-next-line @typescript-eslint/naming-convention\r\nlet Manifold: any;\r\n\r\n/**\r\n * Manifold mesh\r\n */\r\n// eslint-disable-next-line @typescript-eslint/naming-convention\r\nlet ManifoldMesh: any;\r\n\r\n/**\r\n * First ID to use for materials indexing\r\n */\r\n// eslint-disable-next-line @typescript-eslint/naming-convention\r\nlet FirstID: number;\r\n\r\n/**\r\n * Interface to customize the Manifold library import\r\n */\r\nexport interface ICSG2Options {\r\n /**\r\n * Custom manifold URL\r\n */\r\n manifoldUrl?: string;\r\n /**\r\n * Custom manifold instance\r\n */\r\n manifoldInstance: any;\r\n /**\r\n * Custom manifold mesh instance\r\n */\r\n manifoldMeshInstance: any;\r\n}\r\n\r\n/**\r\n * Interface to customize the mesh rebuild options\r\n */\r\nexport interface IMeshRebuildOptions {\r\n /**\r\n * Rebuild normals\r\n */\r\n rebuildNormals?: boolean;\r\n /**\r\n * True to center the mesh on 0,0,0\r\n */\r\n centerMesh?: boolean;\r\n /**\r\n * Defines a material to use for that mesh. When not defined the system will either reuse the one from the source or create a multimaterial if several materials were involved\r\n */\r\n materialToUse?: Material;\r\n}\r\n\r\n/**\r\n * Interface to customize the vertex data rebuild options\r\n */\r\nexport interface IVertexDataRebuildOptions {\r\n /**\r\n * Rebuild normals\r\n */\r\n rebuildNormals?: boolean;\r\n}\r\n\r\ninterface IManifoldMesh {\r\n numProp: number;\r\n vertProperties: Float32Array;\r\n triVerts: Uint32Array;\r\n runIndex: Uint32Array;\r\n runOriginalID: Uint32Array;\r\n numRun: number;\r\n}\r\n\r\ninterface IManifoldVertexComponent {\r\n stride: number;\r\n kind: string;\r\n data?: FloatArray;\r\n}\r\n\r\n/**\r\n * Wrapper around the Manifold library\r\n * https://manifoldcad.org/\r\n * Use this class to perform fast boolean operations on meshes\r\n * #IW43EB#15 - basic operations\r\n * #JUKXQD#6104 - skull vs box\r\n * #JUKXQD#6111 - skull vs vertex data\r\n */\r\nexport class CSG2 implements IDisposable {\r\n private _manifold: any;\r\n private _numProp: number;\r\n private _vertexStructure: IManifoldVertexComponent[];\r\n\r\n /**\r\n * Return the size of a vertex (at least 3 for the position)\r\n */\r\n public get numProp() {\r\n return this._numProp;\r\n }\r\n\r\n private constructor(manifold: any, numProp: number, vertexStructure: IManifoldVertexComponent[]) {\r\n this._manifold = manifold;\r\n this._numProp = numProp;\r\n this._vertexStructure = vertexStructure;\r\n }\r\n\r\n private _process(operation: \"difference\" | \"intersection\" | \"union\", csg: CSG2) {\r\n if (this.numProp !== csg.numProp) {\r\n throw new Error(\"CSG must be used with geometries having the same number of properties\");\r\n }\r\n return new CSG2(Manifold[operation](this._manifold, csg._manifold), this.numProp, this._vertexStructure);\r\n }\r\n\r\n /**\r\n * Run a difference operation between two CSG\r\n * @param csg defines the CSG to use to create the difference\r\n * @returns a new csg\r\n */\r\n public subtract(csg: CSG2) {\r\n return this._process(\"difference\", csg);\r\n }\r\n\r\n /**\r\n * Run an intersection operation between two CSG\r\n * @param csg defines the CSG to use to create the intersection\r\n * @returns a new csg\r\n */\r\n public intersect(csg: CSG2) {\r\n return this._process(\"intersection\", csg);\r\n }\r\n\r\n /**\r\n * Run an union operation between two CSG\r\n * @param csg defines the CSG to use to create the union\r\n * @returns a new csg\r\n */\r\n public add(csg: CSG2) {\r\n return this._process(\"union\", csg);\r\n }\r\n\r\n /**\r\n * Print debug information about the CSG\r\n */\r\n public printDebug() {\r\n Logger.Log(\"Genus:\" + this._manifold.genus());\r\n const properties = this._manifold.getProperties();\r\n Logger.Log(\"Volume:\" + properties.volume);\r\n Logger.Log(\"surface area:\" + properties.surfaceArea);\r\n }\r\n\r\n /**\r\n * Generate a vertex data from the CSG\r\n * @param options defines the options to use to rebuild the vertex data\r\n * @returns a new vertex data\r\n */\r\n public toVertexData(options?: Partial<IVertexDataRebuildOptions>): VertexData {\r\n const localOptions = {\r\n rebuildNormals: false,\r\n ...options,\r\n };\r\n const vertexData = new VertexData();\r\n const normalComponent = this._vertexStructure.find((c) => c.kind === VertexBuffer.NormalKind);\r\n const manifoldMesh: IManifoldMesh = this._manifold.getMesh(localOptions.rebuildNormals && normalComponent ? [3, 4, 5] : undefined);\r\n\r\n vertexData.indices = manifoldMesh.triVerts.length > 65535 ? new Uint32Array(manifoldMesh.triVerts) : new Uint16Array(manifoldMesh.triVerts);\r\n\r\n for (let i = 0; i < manifoldMesh.triVerts.length; i += 3) {\r\n vertexData.indices[i] = manifoldMesh.triVerts[i + 2];\r\n vertexData.indices[i + 1] = manifoldMesh.triVerts[i + 1];\r\n vertexData.indices[i + 2] = manifoldMesh.triVerts[i];\r\n }\r\n\r\n const vertexCount = manifoldMesh.vertProperties.length / manifoldMesh.numProp;\r\n\r\n // Attributes\r\n let offset = 0;\r\n for (let componentIndex = 0; componentIndex < this._vertexStructure.length; componentIndex++) {\r\n const component = this._vertexStructure[componentIndex];\r\n\r\n const data = new Float32Array(vertexCount * component.stride);\r\n for (let i = 0; i < vertexCount; i++) {\r\n for (let strideIndex = 0; strideIndex < component.stride; strideIndex++) {\r\n data[i * component.stride + strideIndex] = manifoldMesh.vertProperties[i * manifoldMesh.numProp + offset + strideIndex];\r\n }\r\n }\r\n vertexData.set(data, component.kind);\r\n offset += component.stride;\r\n }\r\n\r\n // Rebuild mesh from vertex data\r\n return vertexData;\r\n }\r\n\r\n /**\r\n * Generate a mesh from the CSG\r\n * @param name defines the name of the mesh\r\n * @param scene defines the scene to use to create the mesh\r\n * @param options defines the options to use to rebuild the mesh\r\n * @returns a new Mesh\r\n */\r\n public toMesh(name: string, scene?: Scene, options?: Partial<IMeshRebuildOptions>): Mesh {\r\n const localOptions = {\r\n rebuildNormals: false,\r\n centerMesh: true,\r\n ...options,\r\n };\r\n const vertexData = this.toVertexData({ rebuildNormals: localOptions.rebuildNormals });\r\n const normalComponent = this._vertexStructure.find((c) => c.kind === VertexBuffer.NormalKind);\r\n const manifoldMesh: IManifoldMesh = this._manifold.getMesh(localOptions.rebuildNormals && normalComponent ? [3, 4, 5] : undefined);\r\n const vertexCount = manifoldMesh.vertProperties.length / manifoldMesh.numProp;\r\n\r\n // Rebuild mesh from vertex data\r\n const output = new Mesh(name, scene);\r\n vertexData.applyToMesh(output);\r\n\r\n // Center mesh\r\n if (localOptions.centerMesh) {\r\n const extents = output.getBoundingInfo().boundingSphere.center;\r\n output.position.set(-extents.x, -extents.y, -extents.z);\r\n output.bakeCurrentTransformIntoVertices();\r\n }\r\n\r\n // Submeshes\r\n let id = manifoldMesh.runOriginalID[0];\r\n let start = manifoldMesh.runIndex[0];\r\n let materialIndex = 0;\r\n const materials: Material[] = [];\r\n scene = output.getScene();\r\n for (let run = 0; run < manifoldMesh.numRun; ++run) {\r\n const nextID = manifoldMesh.runOriginalID[run + 1];\r\n if (nextID !== id) {\r\n const end = manifoldMesh.runIndex[run + 1];\r\n new SubMesh(materialIndex, 0, vertexCount, start, end - start, output);\r\n materials.push(scene.getMaterialByUniqueID(id - FirstID) || scene.defaultMaterial);\r\n id = nextID;\r\n start = end;\r\n materialIndex++;\r\n }\r\n }\r\n\r\n if (localOptions.materialToUse) {\r\n output.material = localOptions.materialToUse;\r\n } else {\r\n if (materials.length > 1) {\r\n const multiMaterial = new MultiMaterial(name, scene);\r\n multiMaterial.subMaterials = materials;\r\n output.material = multiMaterial;\r\n } else {\r\n output.material = materials[0];\r\n }\r\n }\r\n\r\n return output;\r\n }\r\n\r\n /**\r\n * Dispose the CSG resources\r\n */\r\n public dispose() {\r\n if (this._manifold) {\r\n this._manifold.delete();\r\n this._manifold = null;\r\n }\r\n }\r\n\r\n private static _ProcessData(\r\n vertexCount: number,\r\n triVerts: Uint32Array,\r\n structure: IManifoldVertexComponent[],\r\n numProp: number,\r\n runIndex?: Uint32Array,\r\n runOriginalID?: Uint32Array\r\n ) {\r\n const vertProperties = new Float32Array(vertexCount * structure.reduce((acc, cur) => acc + cur.stride, 0));\r\n\r\n for (let i = 0; i < vertexCount; i++) {\r\n let offset = 0;\r\n for (let idx = 0; idx < structure.length; idx++) {\r\n const component = structure[idx];\r\n\r\n for (let strideIndex = 0; strideIndex < component.stride; strideIndex++) {\r\n vertProperties[i * numProp + offset + strideIndex] = component.data![i * component.stride + strideIndex];\r\n }\r\n offset += component.stride;\r\n }\r\n }\r\n\r\n const manifoldMesh = new ManifoldMesh({ numProp: numProp, vertProperties, triVerts, runIndex, runOriginalID });\r\n manifoldMesh.merge();\r\n\r\n let returnValue: CSG2;\r\n try {\r\n returnValue = new CSG2(new Manifold(manifoldMesh), numProp, structure);\r\n } catch (e) {\r\n throw new Error(\"Error while creating the CSG: \" + e.message);\r\n }\r\n\r\n return returnValue;\r\n }\r\n\r\n private static _Construct(data: IVertexDataLike, worldMatrix: Nullable<Matrix>, runIndex?: Uint32Array, runOriginalID?: Uint32Array) {\r\n // Create the MeshGL for I/O with Manifold library.\r\n const triVerts = new Uint32Array(data.indices!.length);\r\n\r\n // Revert order\r\n for (let i = 0; i < data.indices!.length; i += 3) {\r\n triVerts[i] = data.indices![i + 2];\r\n triVerts[i + 1] = data.indices![i + 1];\r\n triVerts[i + 2] = data.indices![i];\r\n }\r\n\r\n const tempVector3 = new Vector3();\r\n let numProp = 3;\r\n const structure: IManifoldVertexComponent[] = [{ stride: 3, kind: VertexBuffer.PositionKind }];\r\n\r\n if (!worldMatrix) {\r\n structure[0].data = data.positions!;\r\n } else {\r\n const positions = new Float32Array(data.positions!.length);\r\n for (let i = 0; i < data.positions!.length; i += 3) {\r\n Vector3.TransformCoordinatesFromFloatsToRef(data.positions![i], data.positions![i + 1], data.positions![i + 2], worldMatrix, tempVector3);\r\n tempVector3.toArray(positions, i);\r\n }\r\n structure[0].data = positions;\r\n }\r\n\r\n // Normals\r\n const sourceNormals = data.normals!;\r\n if (sourceNormals) {\r\n numProp += 3;\r\n structure.push({ stride: 3, kind: VertexBuffer.NormalKind });\r\n if (!worldMatrix) {\r\n structure[1].data = sourceNormals;\r\n } else {\r\n const normals = new Float32Array(sourceNormals.length);\r\n for (let i = 0; i < sourceNormals.length; i += 3) {\r\n Vector3.TransformNormalFromFloatsToRef(sourceNormals[i], sourceNormals[i + 1], sourceNormals[i + 2], worldMatrix, tempVector3);\r\n tempVector3.toArray(normals, i);\r\n }\r\n structure[1].data = normals;\r\n }\r\n }\r\n\r\n // UVs\r\n for (const kind of [VertexBuffer.UVKind, VertexBuffer.UV2Kind, VertexBuffer.UV3Kind, VertexBuffer.UV4Kind, VertexBuffer.UV5Kind, VertexBuffer.UV6Kind]) {\r\n const sourceUV = (data as any)[kind === VertexBuffer.UVKind ? \"uvs\" : kind];\r\n if (sourceUV) {\r\n numProp += 2;\r\n structure.push({ stride: 2, kind: kind, data: sourceUV });\r\n }\r\n }\r\n\r\n // Colors\r\n const sourceColors = data.colors;\r\n if (sourceColors) {\r\n numProp += 4;\r\n structure.push({ stride: 4, kind: VertexBuffer.ColorKind, data: sourceColors });\r\n }\r\n\r\n return this._ProcessData(data.positions!.length / 3, triVerts, structure, numProp, runIndex, runOriginalID);\r\n }\r\n\r\n /**\r\n * Create a new Constructive Solid Geometry from a vertexData\r\n * @param vertexData defines the vertexData to use to create the CSG\r\n * @returns a new CSG2 class\r\n */\r\n public static FromVertexData(vertexData: VertexData): CSG2 {\r\n const sourceVertices = vertexData.positions;\r\n const sourceIndices = vertexData.indices;\r\n\r\n if (!sourceVertices || !sourceIndices) {\r\n throw new Error(\"The vertexData must at least have positions and indices\");\r\n }\r\n\r\n return this._Construct(vertexData, null);\r\n }\r\n\r\n /**\r\n * Create a new Constructive Solid Geometry from a mesh\r\n * @param mesh defines the mesh to use to create the CSG\r\n * @param ignoreWorldMatrix defines if the world matrix should be ignored\r\n * @returns a new CSG2 class\r\n */\r\n public static FromMesh(mesh: Mesh, ignoreWorldMatrix = false): CSG2 {\r\n const sourceVertices = mesh.getVerticesData(VertexBuffer.PositionKind);\r\n const sourceIndices = mesh.getIndices();\r\n const worldMatrix = mesh.computeWorldMatrix(true);\r\n\r\n if (!sourceVertices || !sourceIndices) {\r\n throw new Error(\"The mesh must at least have positions and indices\");\r\n }\r\n\r\n // Create a triangle run for each submesh (material)\r\n const starts = [...Array(mesh.subMeshes.length)].map((_, idx) => mesh.subMeshes[idx].indexStart);\r\n\r\n // Map the materials to ID.\r\n const sourceMaterial = mesh.material || mesh.getScene().defaultMaterial;\r\n const isMultiMaterial = sourceMaterial.getClassName() === \"MultiMaterial\";\r\n const originalIDs = [...Array(mesh.subMeshes.length)].map((_, idx) => {\r\n if (isMultiMaterial) {\r\n return FirstID + (sourceMaterial as MultiMaterial).subMaterials[mesh.subMeshes[idx].materialIndex]!.uniqueId;\r\n }\r\n\r\n return FirstID + sourceMaterial.uniqueId;\r\n });\r\n\r\n // List the runs in sequence.\r\n const indices = Array.from(starts.keys());\r\n indices.sort((a, b) => starts[a] - starts[b]);\r\n const runIndex = new Uint32Array(indices.map((i) => starts[i]));\r\n const runOriginalID = new Uint32Array(indices.map((i) => originalIDs[i]));\r\n\r\n // Process\r\n const data = {\r\n positions: sourceVertices,\r\n indices: sourceIndices,\r\n normals: mesh.getVerticesData(VertexBuffer.NormalKind),\r\n colors: mesh.getVerticesData(VertexBuffer.ColorKind),\r\n uvs: mesh.getVerticesData(VertexBuffer.UVKind),\r\n uvs2: mesh.getVerticesData(VertexBuffer.UV2Kind),\r\n uvs3: mesh.getVerticesData(VertexBuffer.UV3Kind),\r\n uvs4: mesh.getVerticesData(VertexBuffer.UV4Kind),\r\n uvs5: mesh.getVerticesData(VertexBuffer.UV5Kind),\r\n uvs6: mesh.getVerticesData(VertexBuffer.UV6Kind),\r\n };\r\n return this._Construct(data, ignoreWorldMatrix ? null : worldMatrix, runIndex, runOriginalID);\r\n }\r\n}\r\n\r\n/**\r\n * Checks if the Manifold library is ready\r\n * @returns true if the Manifold library is ready\r\n */\r\nexport function IsCSG2Ready() {\r\n return Manifold !== undefined;\r\n}\r\n\r\n/**\r\n * Initialize the Manifold library\r\n * @param options defines the options to use to initialize the library\r\n */\r\nexport async function InitializeCSG2Async(options?: Partial<ICSG2Options>) {\r\n const localOptions = {\r\n manifoldUrl: \"https://unpkg.com/manifold-3d@3.0.1\",\r\n ...options,\r\n };\r\n\r\n if (localOptions.manifoldInstance) {\r\n Manifold = localOptions.manifoldInstance;\r\n ManifoldMesh = localOptions.manifoldMeshInstance;\r\n } else {\r\n const result = await _LoadScriptModuleAsync(\r\n `\r\n import Module from '${localOptions.manifoldUrl}/manifold.js';\r\n const wasm = await Module();\r\n wasm.setup();\r\n const {Manifold, Mesh} = wasm;\r\n const returnedValue = {Manifold, Mesh};\r\n `\r\n );\r\n\r\n Manifold = result.Manifold;\r\n ManifoldMesh = result.Mesh;\r\n }\r\n\r\n // Reserve IDs for materials (we consider that there will be no more than 65536 materials)\r\n FirstID = Manifold.reserveIDs(65536);\r\n}\r\n"]}
package/Meshes/mesh.d.ts CHANGED
@@ -763,6 +763,11 @@ export declare class Mesh extends AbstractMesh implements IGetSetVerticesData {
763
763
  * @internal
764
764
  */
765
765
  _getInstancesRenderList(subMeshId: number, isReplacementMode?: boolean): _InstancesBatch;
766
+ /**
767
+ * This method will also draw the instances if fillMode and effect are passed
768
+ * @internal
769
+ */
770
+ _updateInstancedBuffers(subMesh: SubMesh, batch: _InstancesBatch, currentInstancesBufferSize: number, engine: AbstractEngine, fillMode?: number, effect?: Effect): void;
766
771
  /**
767
772
  * @internal
768
773
  */
package/Meshes/mesh.js CHANGED
@@ -1608,26 +1608,15 @@ export class Mesh extends AbstractMesh {
1608
1608
  return batchCache;
1609
1609
  }
1610
1610
  /**
1611
+ * This method will also draw the instances if fillMode and effect are passed
1611
1612
  * @internal
1612
1613
  */
1613
- _renderWithInstances(subMesh, fillMode, batch, effect, engine) {
1614
+ _updateInstancedBuffers(subMesh, batch, currentInstancesBufferSize, engine, fillMode, effect) {
1614
1615
  const visibleInstances = batch.visibleInstances[subMesh._id];
1615
1616
  const visibleInstanceCount = visibleInstances ? visibleInstances.length : 0;
1616
1617
  const instanceStorage = this._instanceDataStorage;
1617
- const currentInstancesBufferSize = instanceStorage.instancesBufferSize;
1618
1618
  let instancesBuffer = instanceStorage.instancesBuffer;
1619
1619
  let instancesPreviousBuffer = instanceStorage.instancesPreviousBuffer;
1620
- const matricesCount = visibleInstanceCount + 1;
1621
- const bufferSize = matricesCount * 16 * 4;
1622
- while (instanceStorage.instancesBufferSize < bufferSize) {
1623
- instanceStorage.instancesBufferSize *= 2;
1624
- }
1625
- if (!instanceStorage.instancesData || currentInstancesBufferSize != instanceStorage.instancesBufferSize) {
1626
- instanceStorage.instancesData = new Float32Array(instanceStorage.instancesBufferSize / 4);
1627
- }
1628
- if ((this._scene.needsPreviousWorldMatrices && !instanceStorage.instancesPreviousData) || currentInstancesBufferSize != instanceStorage.instancesBufferSize) {
1629
- instanceStorage.instancesPreviousData = new Float32Array(instanceStorage.instancesBufferSize / 4);
1630
- }
1631
1620
  let offset = 0;
1632
1621
  let instancesCount = 0;
1633
1622
  const renderSelf = batch.renderSelf[subMesh._id];
@@ -1725,14 +1714,16 @@ export class Mesh extends AbstractMesh {
1725
1714
  }
1726
1715
  }
1727
1716
  this._processInstancedBuffers(visibleInstances, renderSelf);
1728
- // Stats
1729
- this.getScene()._activeIndices.addCount(subMesh.indexCount * instancesCount, false);
1730
- // Draw
1731
- if (engine._currentDrawContext) {
1732
- engine._currentDrawContext.useInstancing = true;
1717
+ if (effect && fillMode !== undefined) {
1718
+ // Stats
1719
+ this.getScene()._activeIndices.addCount(subMesh.indexCount * instancesCount, false);
1720
+ // Draw
1721
+ if (engine._currentDrawContext) {
1722
+ engine._currentDrawContext.useInstancing = true;
1723
+ }
1724
+ this._bind(subMesh, effect, fillMode);
1725
+ this._draw(subMesh, fillMode, instancesCount);
1733
1726
  }
1734
- this._bind(subMesh, effect, fillMode);
1735
- this._draw(subMesh, fillMode, instancesCount);
1736
1727
  // Write current matrices as previous matrices in case of manual update
1737
1728
  // Default behaviour when previous matrices are not specified explicitly
1738
1729
  // Will break if instances number/order changes
@@ -1743,6 +1734,27 @@ export class Mesh extends AbstractMesh {
1743
1734
  !this._instanceDataStorage.previousManualUpdate) {
1744
1735
  instancesPreviousBuffer.updateDirectly(instanceStorage.instancesData, 0, instancesCount);
1745
1736
  }
1737
+ }
1738
+ /**
1739
+ * @internal
1740
+ */
1741
+ _renderWithInstances(subMesh, fillMode, batch, effect, engine) {
1742
+ const visibleInstances = batch.visibleInstances[subMesh._id];
1743
+ const visibleInstanceCount = visibleInstances ? visibleInstances.length : 0;
1744
+ const instanceStorage = this._instanceDataStorage;
1745
+ const currentInstancesBufferSize = instanceStorage.instancesBufferSize;
1746
+ const matricesCount = visibleInstanceCount + 1;
1747
+ const bufferSize = matricesCount * 16 * 4;
1748
+ while (instanceStorage.instancesBufferSize < bufferSize) {
1749
+ instanceStorage.instancesBufferSize *= 2;
1750
+ }
1751
+ if (!instanceStorage.instancesData || currentInstancesBufferSize != instanceStorage.instancesBufferSize) {
1752
+ instanceStorage.instancesData = new Float32Array(instanceStorage.instancesBufferSize / 4);
1753
+ }
1754
+ if ((this._scene.needsPreviousWorldMatrices && !instanceStorage.instancesPreviousData) || currentInstancesBufferSize != instanceStorage.instancesBufferSize) {
1755
+ instanceStorage.instancesPreviousData = new Float32Array(instanceStorage.instancesBufferSize / 4);
1756
+ }
1757
+ this._updateInstancedBuffers(subMesh, batch, currentInstancesBufferSize, engine, fillMode, effect);
1746
1758
  engine.unbindInstanceAttributes();
1747
1759
  return this;
1748
1760
  }