@babylonjs/core 7.53.0 → 7.53.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 (126) hide show
  1. package/Culling/Helper/boundingInfoHelper.d.ts +2 -2
  2. package/Culling/Helper/boundingInfoHelper.js +2 -2
  3. package/Culling/Helper/boundingInfoHelper.js.map +1 -1
  4. package/Engines/abstractEngine.js +2 -2
  5. package/Engines/abstractEngine.js.map +1 -1
  6. package/FlowGraph/Blocks/Data/Math/flowGraphMathBlocks.js +1 -1
  7. package/FlowGraph/Blocks/Data/Math/flowGraphMathBlocks.js.map +1 -1
  8. package/FlowGraph/Blocks/Data/Math/flowGraphMatrixMathBlocks.js +7 -2
  9. package/FlowGraph/Blocks/Data/Math/flowGraphMatrixMathBlocks.js.map +1 -1
  10. package/FlowGraph/CustomTypes/flowGraphMatrix.d.ts +1 -0
  11. package/FlowGraph/CustomTypes/flowGraphMatrix.js +18 -17
  12. package/FlowGraph/CustomTypes/flowGraphMatrix.js.map +1 -1
  13. package/FlowGraph/flowGraphDataConnection.d.ts +10 -1
  14. package/FlowGraph/flowGraphDataConnection.js +23 -13
  15. package/FlowGraph/flowGraphDataConnection.js.map +1 -1
  16. package/FlowGraph/flowGraphRichTypes.d.ts +5 -0
  17. package/FlowGraph/flowGraphRichTypes.js +12 -0
  18. package/FlowGraph/flowGraphRichTypes.js.map +1 -1
  19. package/FrameGraph/Node/Blocks/Layers/glowLayerBlock.d.ts +2 -2
  20. package/FrameGraph/Node/Blocks/Layers/glowLayerBlock.js +6 -6
  21. package/FrameGraph/Node/Blocks/Layers/glowLayerBlock.js.map +1 -1
  22. package/FrameGraph/Node/Blocks/Layers/highlightLayerBlock.d.ts +2 -2
  23. package/FrameGraph/Node/Blocks/Layers/highlightLayerBlock.js +6 -6
  24. package/FrameGraph/Node/Blocks/Layers/highlightLayerBlock.js.map +1 -1
  25. package/FrameGraph/Node/Blocks/PostProcesses/anaglyphPostProcessBlock.d.ts +30 -0
  26. package/FrameGraph/Node/Blocks/PostProcesses/anaglyphPostProcessBlock.js +48 -0
  27. package/FrameGraph/Node/Blocks/PostProcesses/anaglyphPostProcessBlock.js.map +1 -0
  28. package/FrameGraph/Node/Blocks/PostProcesses/basePostProcessBlock.d.ts +3 -3
  29. package/FrameGraph/Node/Blocks/PostProcesses/basePostProcessBlock.js +6 -6
  30. package/FrameGraph/Node/Blocks/PostProcesses/basePostProcessBlock.js.map +1 -1
  31. package/FrameGraph/Node/Blocks/PostProcesses/chromaticAberrationPostProcessBlock.d.ts +38 -0
  32. package/FrameGraph/Node/Blocks/PostProcesses/chromaticAberrationPostProcessBlock.js +88 -0
  33. package/FrameGraph/Node/Blocks/PostProcesses/chromaticAberrationPostProcessBlock.js.map +1 -0
  34. package/FrameGraph/Node/Blocks/Rendering/baseObjectRendererBlock.d.ts +2 -2
  35. package/FrameGraph/Node/Blocks/Rendering/baseObjectRendererBlock.js +6 -6
  36. package/FrameGraph/Node/Blocks/Rendering/baseObjectRendererBlock.js.map +1 -1
  37. package/FrameGraph/Node/Blocks/Rendering/utilityLayerRendererBlock.d.ts +2 -2
  38. package/FrameGraph/Node/Blocks/Rendering/utilityLayerRendererBlock.js +6 -6
  39. package/FrameGraph/Node/Blocks/Rendering/utilityLayerRendererBlock.js.map +1 -1
  40. package/FrameGraph/Node/Blocks/Textures/clearBlock.d.ts +2 -2
  41. package/FrameGraph/Node/Blocks/Textures/clearBlock.js +7 -7
  42. package/FrameGraph/Node/Blocks/Textures/clearBlock.js.map +1 -1
  43. package/FrameGraph/Node/Blocks/Textures/copyTextureBlock.d.ts +2 -2
  44. package/FrameGraph/Node/Blocks/Textures/copyTextureBlock.js +6 -6
  45. package/FrameGraph/Node/Blocks/Textures/copyTextureBlock.js.map +1 -1
  46. package/FrameGraph/Node/Blocks/Textures/generateMipmapsBlock.d.ts +2 -2
  47. package/FrameGraph/Node/Blocks/Textures/generateMipmapsBlock.js +7 -7
  48. package/FrameGraph/Node/Blocks/Textures/generateMipmapsBlock.js.map +1 -1
  49. package/FrameGraph/Node/Blocks/index.d.ts +2 -0
  50. package/FrameGraph/Node/Blocks/index.js +2 -0
  51. package/FrameGraph/Node/Blocks/index.js.map +1 -1
  52. package/FrameGraph/Node/nodeRenderGraph.js +2 -2
  53. package/FrameGraph/Node/nodeRenderGraph.js.map +1 -1
  54. package/FrameGraph/Tasks/Layers/baseLayerTask.d.ts +3 -3
  55. package/FrameGraph/Tasks/Layers/baseLayerTask.js +12 -12
  56. package/FrameGraph/Tasks/Layers/baseLayerTask.js.map +1 -1
  57. package/FrameGraph/Tasks/PostProcesses/anaglyphTask.d.ts +21 -0
  58. package/FrameGraph/Tasks/PostProcesses/anaglyphTask.js +27 -0
  59. package/FrameGraph/Tasks/PostProcesses/anaglyphTask.js.map +1 -0
  60. package/FrameGraph/Tasks/PostProcesses/bloomTask.d.ts +2 -2
  61. package/FrameGraph/Tasks/PostProcesses/bloomTask.js +5 -5
  62. package/FrameGraph/Tasks/PostProcesses/bloomTask.js.map +1 -1
  63. package/FrameGraph/Tasks/PostProcesses/chromaticAberrationTask.d.ts +17 -0
  64. package/FrameGraph/Tasks/PostProcesses/chromaticAberrationTask.js +23 -0
  65. package/FrameGraph/Tasks/PostProcesses/chromaticAberrationTask.js.map +1 -0
  66. package/FrameGraph/Tasks/PostProcesses/depthOfFieldTask.d.ts +2 -2
  67. package/FrameGraph/Tasks/PostProcesses/depthOfFieldTask.js +5 -5
  68. package/FrameGraph/Tasks/PostProcesses/depthOfFieldTask.js.map +1 -1
  69. package/FrameGraph/Tasks/PostProcesses/postProcessTask.d.ts +2 -2
  70. package/FrameGraph/Tasks/PostProcesses/postProcessTask.js +1 -1
  71. package/FrameGraph/Tasks/PostProcesses/postProcessTask.js.map +1 -1
  72. package/FrameGraph/Tasks/PostProcesses/ssrRenderingPipelineTask.d.ts +2 -2
  73. package/FrameGraph/Tasks/PostProcesses/ssrRenderingPipelineTask.js +8 -8
  74. package/FrameGraph/Tasks/PostProcesses/ssrRenderingPipelineTask.js.map +1 -1
  75. package/FrameGraph/Tasks/Rendering/objectRendererTask.d.ts +3 -3
  76. package/FrameGraph/Tasks/Rendering/objectRendererTask.js +9 -9
  77. package/FrameGraph/Tasks/Rendering/objectRendererTask.js.map +1 -1
  78. package/FrameGraph/Tasks/Rendering/taaObjectRendererTask.js +7 -7
  79. package/FrameGraph/Tasks/Rendering/taaObjectRendererTask.js.map +1 -1
  80. package/FrameGraph/Tasks/Rendering/utilityLayerRendererTask.d.ts +3 -3
  81. package/FrameGraph/Tasks/Rendering/utilityLayerRendererTask.js +3 -3
  82. package/FrameGraph/Tasks/Rendering/utilityLayerRendererTask.js.map +1 -1
  83. package/FrameGraph/Tasks/Texture/clearTextureTask.d.ts +3 -3
  84. package/FrameGraph/Tasks/Texture/clearTextureTask.js +8 -8
  85. package/FrameGraph/Tasks/Texture/clearTextureTask.js.map +1 -1
  86. package/FrameGraph/Tasks/Texture/copyToTextureTask.d.ts +3 -3
  87. package/FrameGraph/Tasks/Texture/copyToTextureTask.js +3 -3
  88. package/FrameGraph/Tasks/Texture/copyToTextureTask.js.map +1 -1
  89. package/FrameGraph/Tasks/Texture/generateMipMapsTask.d.ts +2 -2
  90. package/FrameGraph/Tasks/Texture/generateMipMapsTask.js +5 -5
  91. package/FrameGraph/Tasks/Texture/generateMipMapsTask.js.map +1 -1
  92. package/FrameGraph/index.d.ts +2 -0
  93. package/FrameGraph/index.js +2 -0
  94. package/FrameGraph/index.js.map +1 -1
  95. package/Materials/Textures/internalTexture.js +2 -2
  96. package/Materials/Textures/internalTexture.js.map +1 -1
  97. package/Materials/material.js +1 -1
  98. package/Materials/material.js.map +1 -1
  99. package/Materials/materialDefines.js +1 -1
  100. package/Materials/materialDefines.js.map +1 -1
  101. package/Meshes/Builders/shapeBuilder.d.ts +6 -2
  102. package/Meshes/Builders/shapeBuilder.js.map +1 -1
  103. package/Meshes/subMesh.js +1 -1
  104. package/Meshes/subMesh.js.map +1 -1
  105. package/Physics/v2/characterController.d.ts +3 -2
  106. package/Physics/v2/characterController.js +12 -0
  107. package/Physics/v2/characterController.js.map +1 -1
  108. package/PostProcesses/anaglyphPostProcess.d.ts +0 -1
  109. package/PostProcesses/anaglyphPostProcess.js +14 -11
  110. package/PostProcesses/anaglyphPostProcess.js.map +1 -1
  111. package/PostProcesses/chromaticAberrationPostProcess.d.ts +15 -8
  112. package/PostProcesses/chromaticAberrationPostProcess.js +72 -42
  113. package/PostProcesses/chromaticAberrationPostProcess.js.map +1 -1
  114. package/PostProcesses/index.d.ts +2 -0
  115. package/PostProcesses/index.js +2 -0
  116. package/PostProcesses/index.js.map +1 -1
  117. package/PostProcesses/thinAnaglyphPostProcess.d.ts +23 -0
  118. package/PostProcesses/thinAnaglyphPostProcess.js +42 -0
  119. package/PostProcesses/thinAnaglyphPostProcess.js.map +1 -0
  120. package/PostProcesses/thinChromaticAberrationPostProcess.d.ts +45 -0
  121. package/PostProcesses/thinChromaticAberrationPostProcess.js +69 -0
  122. package/PostProcesses/thinChromaticAberrationPostProcess.js.map +1 -0
  123. package/package.json +1 -1
  124. package/scene.d.ts +3 -0
  125. package/scene.js +5 -0
  126. package/scene.js.map +1 -1
@@ -43,7 +43,9 @@ export declare function ExtrudeShape(name: string, options: {
43
43
  invertUV?: boolean;
44
44
  firstNormal?: Vector3;
45
45
  adjustFrame?: boolean;
46
- capFunction?: Function;
46
+ capFunction?: Nullable<{
47
+ (shapePath: Vector3[]): Vector3[];
48
+ }>;
47
49
  }, scene?: Nullable<Scene>): Mesh;
48
50
  /**
49
51
  * Creates an custom extruded shape mesh.
@@ -97,7 +99,9 @@ export declare function ExtrudeShapeCustom(name: string, options: {
97
99
  invertUV?: boolean;
98
100
  firstNormal?: Vector3;
99
101
  adjustFrame?: boolean;
100
- capFunction?: Function;
102
+ capFunction?: Nullable<{
103
+ (shapePath: Vector3[]): Vector3[];
104
+ }>;
101
105
  }, scene?: Nullable<Scene>): Mesh;
102
106
  /**
103
107
  * Class containing static functions to help procedurally build meshes
@@ -1 +1 @@
1
- {"version":3,"file":"shapeBuilder.js","sourceRoot":"","sources":["../../../../../dev/core/src/Meshes/Builders/shapeBuilder.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,OAAO,EAAE,UAAU,EAAE,MAAM,EAAE,MAAM,yBAAyB,CAAC;AACtE,OAAO,EAAE,IAAI,EAAE,MAAM,SAAS,CAAC;AAC/B,OAAO,EAAE,YAAY,EAAE,MAAM,iBAAiB,CAAC;AAC/C,OAAO,EAAE,MAAM,EAAE,MAAM,uBAAuB,CAAC;AAE/C;;;;;;;;;;;;;;;;;;;;;;;GAuBG;AACH,MAAM,UAAU,YAAY,CACxB,IAAY,EACZ,OAiBC,EACD,QAAyB,IAAI;IAE7B,MAAM,IAAI,GAAG,OAAO,CAAC,IAAI,CAAC;IAC1B,MAAM,KAAK,GAAG,OAAO,CAAC,KAAK,CAAC;IAC5B,MAAM,KAAK,GAAG,OAAO,CAAC,KAAK,IAAI,CAAC,CAAC;IACjC,MAAM,QAAQ,GAAG,OAAO,CAAC,QAAQ,IAAI,CAAC,CAAC;IACvC,MAAM,GAAG,GAAG,OAAO,CAAC,GAAG,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,OAAO,CAAC,GAAG,IAAI,IAAI,CAAC,MAAM,CAAC;IAC/D,MAAM,SAAS,GAAG,OAAO,CAAC,SAAS,CAAC;IACpC,MAAM,eAAe,GAAG,IAAI,CAAC,0BAA0B,CAAC,OAAO,CAAC,eAAe,CAAC,CAAC;IACjF,MAAM,QAAQ,GAAG,OAAO,CAAC,QAAQ,IAAI,IAAI,CAAC;IAC1C,MAAM,QAAQ,GAAG,OAAO,CAAC,QAAQ,IAAI,KAAK,CAAC;IAC3C,MAAM,UAAU,GAAG,OAAO,CAAC,UAAU,IAAI,KAAK,CAAC;IAC/C,MAAM,SAAS,GAAG,OAAO,CAAC,SAAS,IAAI,KAAK,CAAC;IAC7C,MAAM,WAAW,GAAG,OA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;QAClC,eAAe,EAAE,eAAe;QAChC,GAAG,EAAE,GAAG,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,GAAG,IAAI,IAAI,CAAC,MAAM;QACvC,eAAe,EAAE,eAAe;QAChC,QAAQ,EAAE,QAAQ;QAClB,SAAS,EAAE,SAAS;KACvB,CAAC;IAEF,OAAO,kBAAkB,CAAC,IAAI,EAAE,OAAO,EAAE,KAAK,CAAC,CAAC;AACpD,CAAC,CAAC","sourcesContent":["import type { Nullable } from \"../../types\";\r\nimport type { Scene } from \"../../scene\";\r\nimport type { Vector4 } from \"../../Maths/math.vector\";\r\nimport { Vector3, TmpVectors, Matrix } from \"../../Maths/math.vector\";\r\nimport { Mesh } from \"../mesh\";\r\nimport { CreateRibbon } from \"./ribbonBuilder\";\r\nimport { Path3D } from \"../../Maths/math.path\";\r\n\r\n/**\r\n * Creates an extruded shape mesh. The extrusion is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters.\r\n * * The parameter `shape` is a required array of successive Vector3. This array depicts the shape to be extruded in its local space : the shape must be designed in the xOy plane and will be extruded along the Z axis.\r\n * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.\r\n * * The parameter `rotation` (float, default 0 radians) is the angle value to rotate the shape each step (each path point), from the former step (so rotation added each step) along the curve.\r\n * * The parameter `scale` (float, default 1) is the value to scale the shape.\r\n * * The parameter `closeShape` (boolean, default false) closes the shape when true, since v5.0.0.\r\n * * The parameter `closePath` (boolean, default false) closes the path when true and no caps, since v5.0.0.\r\n * * The parameter `cap` sets the way the extruded shape is capped. Possible values : BABYLON.Mesh.NO_CAP (default), BABYLON.Mesh.CAP_START, BABYLON.Mesh.CAP_END, BABYLON.Mesh.CAP_ALL\r\n * * The optional parameter `instance` is an instance of an existing ExtrudedShape object to be updated with the passed `shape`, `path`, `scale` or `rotation` parameters : https://doc.babylonjs.com/features/featuresDeepDive/mesh/dynamicMeshMorph#extruded-shape\r\n * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.\r\n * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE\r\n * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/features/featuresDeepDive/mesh/creation/set#side-orientation\r\n * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture.\r\n * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.\r\n * * The optional parameter `firstNormal` (Vector3) defines the direction of the first normal of the supplied path. Consider using this for any path that is straight, and particular for paths in the xy plane.\r\n * * The optional `adjustFrame` (boolean, default false) will cause the internally generated Path3D tangents, normals, and binormals to be adjusted so that a) they are always well-defined, and b) they do not reverse from one path point to the next. This prevents the extruded shape from being flipped and/or rotated with resulting mesh self-intersections. This is primarily useful for straight paths that can reverse direction.\r\n * @param name defines the name of the mesh\r\n * @param options defines the options used to create the mesh\r\n * @param scene defines the hosting scene\r\n * @returns the extruded shape mesh\r\n * @see https://doc.babylonjs.com/features/featuresDeepDive/mesh/creation/param\r\n * @see https://doc.babylonjs.com/features/featuresDeepDive/mesh/creation/param#extruded-shapes\r\n */\r\nexport function ExtrudeShape(\r\n name: string,\r\n options: {\r\n shape: Vector3[];\r\n path: Vector3[];\r\n scale?: number;\r\n rotation?: number;\r\n closeShape?: boolean;\r\n closePath?: boolean;\r\n cap?: number;\r\n updatable?: boolean;\r\n sideOrientation?: number;\r\n frontUVs?: Vector4;\r\n backUVs?: Vector4;\r\n instance?: Mesh;\r\n invertUV?: boolean;\r\n firstNormal?: Vector3;\r\n adjustFrame?: boolean;\r\n capFunction?: Function;\r\n },\r\n scene: Nullable<Scene> = null\r\n): Mesh {\r\n const path = options.path;\r\n const shape = options.shape;\r\n const scale = options.scale || 1;\r\n const rotation = options.rotation || 0;\r\n const cap = options.cap === 0 ? 0 : options.cap || Mesh.NO_CAP;\r\n const updatable = options.updatable;\r\n const sideOrientation = Mesh._GetDefaultSideOrientation(options.sideOrientation);\r\n const instance = options.instance || null;\r\n const invertUV = options.invertUV || false;\r\n const closeShape = options.closeShape || false;\r\n const closePath = options.closePath || false;\r\n const capFunction = options.capFunction || null;\r\n\r\n return _ExtrudeShapeGeneric(\r\n name,\r\n shape,\r\n path,\r\n scale,\r\n rotation,\r\n null,\r\n null,\r\n closePath,\r\n closeShape,\r\n cap,\r\n false,\r\n scene,\r\n updatable ? true : false,\r\n sideOrientation,\r\n instance,\r\n invertUV,\r\n options.frontUVs || null,\r\n options.backUVs || null,\r\n options.firstNormal || null,\r\n options.adjustFrame ? true : false,\r\n capFunction\r\n );\r\n}\r\n\r\n/**\r\n * Creates an custom extruded shape mesh.\r\n * The custom extrusion is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters.\r\n * * The parameter `shape` is a required array of successive Vector3. This array depicts the shape to be extruded in its local space : the shape must be designed in the xOy plane and will be extruded along the Z axis.\r\n * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.\r\n * * The parameter `rotationFunction` (JS function) is a custom Javascript function called on each path point. This function is passed the position i of the point in the path and the distance of this point from the beginning of the path\r\n * * It must returns a float value that will be the rotation in radians applied to the shape on each path point.\r\n * * The parameter `scaleFunction` (JS function) is a custom Javascript function called on each path point. This function is passed the position i of the point in the path and the distance of this point from the beginning of the path\r\n * * It must returns a float value that will be the scale value applied to the shape on each path point\r\n * * The parameter `closeShape` (boolean, default false) closes the shape when true, since v5.0.0.\r\n * * The parameter `closePath` (boolean, default false) closes the path when true and no caps, since v5.0.0.\r\n * * The parameter `ribbonClosePath` (boolean, default false) forces the extrusion underlying ribbon to close all the paths in its `pathArray` - depreciated in favor of closeShape\r\n * * The parameter `ribbonCloseArray` (boolean, default false) forces the extrusion underlying ribbon to close its `pathArray` - depreciated in favor of closePath\r\n * * The parameter `cap` sets the way the extruded shape is capped. Possible values : BABYLON.Mesh.NO_CAP (default), BABYLON.Mesh.CAP_START, BABYLON.Mesh.CAP_END, BABYLON.Mesh.CAP_ALL\r\n * * The optional parameter `instance` is an instance of an existing ExtrudedShape object to be updated with the passed `shape`, `path`, `scale` or `rotation` parameters : https://doc.babylonjs.com/features/featuresDeepDive/mesh/dynamicMeshMorph#extruded-shape\r\n * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape\r\n * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE\r\n * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/features/featuresDeepDive/mesh/creation/set#side-orientation\r\n * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture\r\n * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created\r\n * * The optional parameter `firstNormal` (Vector3) defines the direction of the first normal of the supplied path. It should be supplied when the path is in the xy plane, and particularly if these sections are straight, because the underlying Path3D object will pick a normal in the xy plane that causes the extrusion to be collapsed into the plane. This should be used for any path that is straight.\r\n * * The optional `adjustFrame` (boolean, default false) will cause the internally generated Path3D tangents, normals, and binormals to be adjusted so that a) they are always well-defined, and b) they do not reverse from one path point to the next. This prevents the extruded shape from being flipped and/or rotated with resulting mesh self-intersections. This is primarily useful for straight paths that can reverse direction.\r\n * @param name defines the name of the mesh\r\n * @param options defines the options used to create the mesh\r\n * @param scene defines the hosting scene\r\n * @returns the custom extruded shape mesh\r\n * @see https://doc.babylonjs.com/features/featuresDeepDive/mesh/creation/param#custom-extruded-shapes\r\n * @see https://doc.babylonjs.com/features/featuresDeepDive/mesh/creation/param\r\n * @see https://doc.babylonjs.com/features/featuresDeepDive/mesh/creation/param#extruded-shapes\r\n */\r\nexport function ExtrudeShapeCustom(\r\n name: string,\r\n options: {\r\n shape: Vector3[];\r\n path: Vector3[];\r\n scaleFunction?: Nullable<{ (i: number, distance: number): number }>;\r\n rotationFunction?: Nullable<{ (i: number, distance: number): number }>;\r\n ribbonCloseArray?: boolean;\r\n ribbonClosePath?: boolean;\r\n closeShape?: boolean;\r\n closePath?: boolean;\r\n cap?: number;\r\n updatable?: boolean;\r\n sideOrientation?: number;\r\n frontUVs?: Vector4;\r\n backUVs?: Vector4;\r\n instance?: Mesh;\r\n invertUV?: boolean;\r\n firstNormal?: Vector3;\r\n adjustFrame?: boolean;\r\n capFunction?: Function;\r\n },\r\n scene: Nullable<Scene> = null\r\n): Mesh {\r\n const path = options.path;\r\n const shape = options.shape;\r\n const scaleFunction =\r\n options.scaleFunction ||\r\n (() => {\r\n return 1;\r\n });\r\n const rotationFunction =\r\n options.rotationFunction ||\r\n (() => {\r\n return 0;\r\n });\r\n const ribbonCloseArray = options.closePath || options.ribbonCloseArray || false;\r\n const ribbonClosePath = options.closeShape || options.ribbonClosePath || false;\r\n const cap = options.cap === 0 ? 0 : options.cap || Mesh.NO_CAP;\r\n const updatable = options.updatable;\r\n const firstNormal = options.firstNormal || null;\r\n const adjustFrame = options.adjustFrame || false;\r\n const sideOrientation = Mesh._GetDefaultSideOrientation(options.sideOrientation);\r\n const instance = options.instance;\r\n const invertUV = options.invertUV || false;\r\n const capFunction = options.capFunction || null;\r\n return _ExtrudeShapeGeneric(\r\n name,\r\n shape,\r\n path,\r\n null,\r\n null,\r\n scaleFunction,\r\n rotationFunction,\r\n ribbonCloseArray,\r\n ribbonClosePath,\r\n cap,\r\n true,\r\n scene,\r\n updatable ? true : false,\r\n sideOrientation,\r\n instance || null,\r\n invertUV,\r\n options.frontUVs || null,\r\n options.backUVs || null,\r\n firstNormal,\r\n adjustFrame,\r\n capFunction || null\r\n );\r\n}\r\n\r\nfunction _ExtrudeShapeGeneric(\r\n name: string,\r\n shape: Vector3[],\r\n curve: Vector3[],\r\n scale: Nullable<number>,\r\n rotation: Nullable<number>,\r\n scaleFunction: Nullable<{ (i: number, distance: number): number }>,\r\n rotateFunction: Nullable<{ (i: number, distance: number): number }>,\r\n rbCA: boolean,\r\n rbCP: boolean,\r\n cap: number,\r\n custom: boolean,\r\n scene: Nullable<Scene>,\r\n updtbl: boolean,\r\n side: number,\r\n instance: Nullable<Mesh>,\r\n invertUV: boolean,\r\n frontUVs: Nullable<Vector4>,\r\n backUVs: Nullable<Vector4>,\r\n firstNormal: Nullable<Vector3>,\r\n adjustFrame: boolean,\r\n capFunction: Nullable<Function>\r\n): Mesh {\r\n // extrusion geometry\r\n const extrusionPathArray = (\r\n shape: Vector3[],\r\n curve: Vector3[],\r\n path3D: Path3D,\r\n shapePaths: Vector3[][],\r\n scale: Nullable<number>,\r\n rotation: Nullable<number>,\r\n scaleFunction: Nullable<{ (i: number, distance: number): number }>,\r\n rotateFunction: Nullable<{ (i: number, distance: number): number }>,\r\n cap: number,\r\n custom: boolean,\r\n adjustFrame: boolean\r\n ) => {\r\n const tangents = path3D.getTangents();\r\n const normals = path3D.getNormals();\r\n const binormals = path3D.getBinormals();\r\n const distances = path3D.getDistances();\r\n if (adjustFrame) {\r\n /* fix tangents,normals, binormals */\r\n for (let i = 0; i < tangents.length; i++) {\r\n if (tangents[i].x == 0 && tangents[i].y == 0 && tangents[i].z == 0) {\r\n tangents[i].copyFrom(tangents[i - 1]);\r\n }\r\n if (normals[i].x == 0 && normals[i].y == 0 && normals[i].z == 0) {\r\n normals[i].copyFrom(normals[i - 1]);\r\n }\r\n if (binormals[i].x == 0 && binormals[i].y == 0 && binormals[i].z == 0) {\r\n binormals[i].copyFrom(binormals[i - 1]);\r\n }\r\n if (i > 0) {\r\n let v = tangents[i - 1];\r\n if (Vector3.Dot(v, tangents[i]) < 0) {\r\n tangents[i].scaleInPlace(-1);\r\n }\r\n v = normals[i - 1];\r\n if (Vector3.Dot(v, normals[i]) < 0) {\r\n normals[i].scaleInPlace(-1);\r\n }\r\n v = binormals[i - 1];\r\n if (Vector3.Dot(v, binormals[i]) < 0) {\r\n binormals[i].scaleInPlace(-1);\r\n }\r\n }\r\n }\r\n }\r\n let angle = 0;\r\n const returnScale = () => {\r\n return scale !== null ? scale : 1;\r\n };\r\n const returnRotation = () => {\r\n return rotation !== null ? rotation : 0;\r\n };\r\n const rotate: { (i: number, distance: number): number } = custom && rotateFunction ? rotateFunction : returnRotation;\r\n const scl: { (i: number, distance: number): number } = custom && scaleFunction ? scaleFunction : returnScale;\r\n let index = cap === Mesh.NO_CAP || cap === Mesh.CAP_END ? 0 : 2;\r\n const rotationMatrix: Matrix = TmpVectors.Matrix[0];\r\n\r\n for (let i = 0; i < curve.length; i++) {\r\n const shapePath: Vector3[] = [];\r\n const angleStep = rotate(i, distances[i]);\r\n const scaleRatio = scl(i, distances[i]);\r\n Matrix.RotationAxisToRef(tangents[i], angle, rotationMatrix);\r\n for (let p = 0; p < shape.length; p++) {\r\n const planed = tangents[i].scale(shape[p].z).add(normals[i].scale(shape[p].x)).add(binormals[i].scale(shape[p].y));\r\n const rotated = Vector3.Zero();\r\n Vector3.TransformCoordinatesToRef(planed, rotationMatrix, rotated);\r\n rotated.scaleInPlace(scaleRatio).addInPlace(curve[i]);\r\n shapePath[p] = rotated;\r\n }\r\n shapePaths[index] = shapePath;\r\n angle += angleStep;\r\n index++;\r\n }\r\n // cap\r\n const defaultCapPath = (shapePath: Vector3[]) => {\r\n const pointCap = Array<Vector3>();\r\n const barycenter = Vector3.Zero();\r\n let i: number;\r\n for (i = 0; i < shapePath.length; i++) {\r\n barycenter.addInPlace(shapePath[i]);\r\n }\r\n barycenter.scaleInPlace(1.0 / shapePath.length);\r\n for (i = 0; i < shapePath.length; i++) {\r\n pointCap.push(barycenter);\r\n }\r\n return pointCap;\r\n };\r\n const capPath = capFunction || defaultCapPath;\r\n switch (cap) {\r\n case Mesh.NO_CAP:\r\n break;\r\n case Mesh.CAP_START:\r\n shapePaths[0] = capPath(shapePaths[2]);\r\n shapePaths[1] = shapePaths[2];\r\n break;\r\n case Mesh.CAP_END:\r\n shapePaths[index] = shapePaths[index - 1];\r\n shapePaths[index + 1] = capPath(shapePaths[index - 1]);\r\n break;\r\n case Mesh.CAP_ALL:\r\n shapePaths[0] = capPath(shapePaths[2]);\r\n shapePaths[1] = shapePaths[2];\r\n shapePaths[index] = shapePaths[index - 1];\r\n shapePaths[index + 1] = capPath(shapePaths[index - 1]);\r\n break;\r\n default:\r\n break;\r\n }\r\n return shapePaths;\r\n };\r\n let path3D;\r\n let pathArray;\r\n if (instance) {\r\n // instance update\r\n const storage = instance._creationDataStorage!;\r\n path3D = firstNormal ? storage.path3D.update(curve, firstNormal) : storage.path3D.update(curve);\r\n pathArray = extrusionPathArray(shape, curve, storage.path3D, storage.pathArray, scale, rotation, scaleFunction, rotateFunction, storage.cap, custom, adjustFrame);\r\n instance = CreateRibbon(\"\", { pathArray, closeArray: false, closePath: false, offset: 0, updatable: false, sideOrientation: 0, instance }, scene || undefined);\r\n\r\n return instance;\r\n }\r\n // extruded shape creation\r\n path3D = firstNormal ? new Path3D(curve, firstNormal) : new Path3D(curve);\r\n const newShapePaths = new Array<Array<Vector3>>();\r\n cap = cap < 0 || cap > 3 ? 0 : cap;\r\n pathArray = extrusionPathArray(shape, curve, path3D, newShapePaths, scale, rotation, scaleFunction, rotateFunction, cap, custom, adjustFrame);\r\n const extrudedGeneric = CreateRibbon(\r\n name,\r\n {\r\n pathArray: pathArray,\r\n closeArray: rbCA,\r\n closePath: rbCP,\r\n updatable: updtbl,\r\n sideOrientation: side,\r\n invertUV: invertUV,\r\n frontUVs: frontUVs || undefined,\r\n backUVs: backUVs || undefined,\r\n },\r\n scene\r\n );\r\n extrudedGeneric._creationDataStorage!.pathArray = pathArray;\r\n extrudedGeneric._creationDataStorage!.path3D = path3D;\r\n extrudedGeneric._creationDataStorage!.cap = cap;\r\n\r\n return extrudedGeneric;\r\n}\r\n\r\n/**\r\n * Class containing static functions to help procedurally build meshes\r\n * @deprecated please use the functions directly from the module\r\n */\r\nexport const ShapeBuilder = {\r\n // eslint-disable-next-line @typescript-eslint/naming-convention\r\n ExtrudeShape,\r\n // eslint-disable-next-line @typescript-eslint/naming-convention\r\n ExtrudeShapeCustom,\r\n};\r\n\r\nMesh.ExtrudeShape = (\r\n name: string,\r\n shape: Vector3[],\r\n path: Vector3[],\r\n scale: number,\r\n rotation: number,\r\n cap: number,\r\n scene: Nullable<Scene> = null,\r\n updatable?: boolean,\r\n sideOrientation?: number,\r\n instance?: Mesh\r\n): Mesh => {\r\n const options = {\r\n shape: shape,\r\n path: path,\r\n scale: scale,\r\n rotation: rotation,\r\n cap: cap === 0 ? 0 : cap || Mesh.NO_CAP,\r\n sideOrientation: sideOrientation,\r\n instance: instance,\r\n updatable: updatable,\r\n };\r\n\r\n return ExtrudeShape(name, options, scene);\r\n};\r\n\r\nMesh.ExtrudeShapeCustom = (\r\n name: string,\r\n shape: Vector3[],\r\n path: Vector3[],\r\n scaleFunction: Nullable<{ (i: number, distance: number): number }>,\r\n rotationFunction: Nullable<{ (i: number, distance: number): number }>,\r\n ribbonCloseArray: boolean,\r\n ribbonClosePath: boolean,\r\n cap: number,\r\n scene: Scene,\r\n updatable?: boolean,\r\n sideOrientation?: number,\r\n instance?: Mesh\r\n): Mesh => {\r\n const options = {\r\n shape: shape,\r\n path: path,\r\n scaleFunction: scaleFunction,\r\n rotationFunction: rotationFunction,\r\n ribbonCloseArray: ribbonCloseArray,\r\n ribbonClosePath: ribbonClosePath,\r\n cap: cap === 0 ? 0 : cap || Mesh.NO_CAP,\r\n sideOrientation: sideOrientation,\r\n instance: instance,\r\n updatable: updatable,\r\n };\r\n\r\n return ExtrudeShapeCustom(name, options, scene);\r\n};\r\n"]}
1
+ {"version":3,"file":"shapeBuilder.js","sourceRoot":"","sources":["../../../../../dev/core/src/Meshes/Builders/shapeBuilder.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,OAAO,EAAE,UAAU,EAAE,MAAM,EAAE,MAAM,yBAAyB,CAAC;AACtE,OAAO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vB,CAAC;IAEF,OAAO,kBAAkB,CAAC,IAAI,EAAE,OAAO,EAAE,KAAK,CAAC,CAAC;AACpD,CAAC,CAAC","sourcesContent":["import type { Nullable } from \"../../types\";\r\nimport type { Scene } from \"../../scene\";\r\nimport type { Vector4 } from \"../../Maths/math.vector\";\r\nimport { Vector3, TmpVectors, Matrix } from \"../../Maths/math.vector\";\r\nimport { Mesh } from \"../mesh\";\r\nimport { CreateRibbon } from \"./ribbonBuilder\";\r\nimport { Path3D } from \"../../Maths/math.path\";\r\n\r\n/**\r\n * Creates an extruded shape mesh. The extrusion is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters.\r\n * * The parameter `shape` is a required array of successive Vector3. This array depicts the shape to be extruded in its local space : the shape must be designed in the xOy plane and will be extruded along the Z axis.\r\n * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.\r\n * * The parameter `rotation` (float, default 0 radians) is the angle value to rotate the shape each step (each path point), from the former step (so rotation added each step) along the curve.\r\n * * The parameter `scale` (float, default 1) is the value to scale the shape.\r\n * * The parameter `closeShape` (boolean, default false) closes the shape when true, since v5.0.0.\r\n * * The parameter `closePath` (boolean, default false) closes the path when true and no caps, since v5.0.0.\r\n * * The parameter `cap` sets the way the extruded shape is capped. Possible values : BABYLON.Mesh.NO_CAP (default), BABYLON.Mesh.CAP_START, BABYLON.Mesh.CAP_END, BABYLON.Mesh.CAP_ALL\r\n * * The optional parameter `instance` is an instance of an existing ExtrudedShape object to be updated with the passed `shape`, `path`, `scale` or `rotation` parameters : https://doc.babylonjs.com/features/featuresDeepDive/mesh/dynamicMeshMorph#extruded-shape\r\n * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.\r\n * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE\r\n * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/features/featuresDeepDive/mesh/creation/set#side-orientation\r\n * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture.\r\n * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.\r\n * * The optional parameter `firstNormal` (Vector3) defines the direction of the first normal of the supplied path. Consider using this for any path that is straight, and particular for paths in the xy plane.\r\n * * The optional `adjustFrame` (boolean, default false) will cause the internally generated Path3D tangents, normals, and binormals to be adjusted so that a) they are always well-defined, and b) they do not reverse from one path point to the next. This prevents the extruded shape from being flipped and/or rotated with resulting mesh self-intersections. This is primarily useful for straight paths that can reverse direction.\r\n * @param name defines the name of the mesh\r\n * @param options defines the options used to create the mesh\r\n * @param scene defines the hosting scene\r\n * @returns the extruded shape mesh\r\n * @see https://doc.babylonjs.com/features/featuresDeepDive/mesh/creation/param\r\n * @see https://doc.babylonjs.com/features/featuresDeepDive/mesh/creation/param#extruded-shapes\r\n */\r\nexport function ExtrudeShape(\r\n name: string,\r\n options: {\r\n shape: Vector3[];\r\n path: Vector3[];\r\n scale?: number;\r\n rotation?: number;\r\n closeShape?: boolean;\r\n closePath?: boolean;\r\n cap?: number;\r\n updatable?: boolean;\r\n sideOrientation?: number;\r\n frontUVs?: Vector4;\r\n backUVs?: Vector4;\r\n instance?: Mesh;\r\n invertUV?: boolean;\r\n firstNormal?: Vector3;\r\n adjustFrame?: boolean;\r\n capFunction?: Nullable<{ (shapePath: Vector3[]): Vector3[] }>;\r\n },\r\n scene: Nullable<Scene> = null\r\n): Mesh {\r\n const path = options.path;\r\n const shape = options.shape;\r\n const scale = options.scale || 1;\r\n const rotation = options.rotation || 0;\r\n const cap = options.cap === 0 ? 0 : options.cap || Mesh.NO_CAP;\r\n const updatable = options.updatable;\r\n const sideOrientation = Mesh._GetDefaultSideOrientation(options.sideOrientation);\r\n const instance = options.instance || null;\r\n const invertUV = options.invertUV || false;\r\n const closeShape = options.closeShape || false;\r\n const closePath = options.closePath || false;\r\n const capFunction = options.capFunction || null;\r\n\r\n return _ExtrudeShapeGeneric(\r\n name,\r\n shape,\r\n path,\r\n scale,\r\n rotation,\r\n null,\r\n null,\r\n closePath,\r\n closeShape,\r\n cap,\r\n false,\r\n scene,\r\n updatable ? true : false,\r\n sideOrientation,\r\n instance,\r\n invertUV,\r\n options.frontUVs || null,\r\n options.backUVs || null,\r\n options.firstNormal || null,\r\n options.adjustFrame ? true : false,\r\n capFunction\r\n );\r\n}\r\n\r\n/**\r\n * Creates an custom extruded shape mesh.\r\n * The custom extrusion is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters.\r\n * * The parameter `shape` is a required array of successive Vector3. This array depicts the shape to be extruded in its local space : the shape must be designed in the xOy plane and will be extruded along the Z axis.\r\n * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.\r\n * * The parameter `rotationFunction` (JS function) is a custom Javascript function called on each path point. This function is passed the position i of the point in the path and the distance of this point from the beginning of the path\r\n * * It must returns a float value that will be the rotation in radians applied to the shape on each path point.\r\n * * The parameter `scaleFunction` (JS function) is a custom Javascript function called on each path point. This function is passed the position i of the point in the path and the distance of this point from the beginning of the path\r\n * * It must returns a float value that will be the scale value applied to the shape on each path point\r\n * * The parameter `closeShape` (boolean, default false) closes the shape when true, since v5.0.0.\r\n * * The parameter `closePath` (boolean, default false) closes the path when true and no caps, since v5.0.0.\r\n * * The parameter `ribbonClosePath` (boolean, default false) forces the extrusion underlying ribbon to close all the paths in its `pathArray` - depreciated in favor of closeShape\r\n * * The parameter `ribbonCloseArray` (boolean, default false) forces the extrusion underlying ribbon to close its `pathArray` - depreciated in favor of closePath\r\n * * The parameter `cap` sets the way the extruded shape is capped. Possible values : BABYLON.Mesh.NO_CAP (default), BABYLON.Mesh.CAP_START, BABYLON.Mesh.CAP_END, BABYLON.Mesh.CAP_ALL\r\n * * The optional parameter `instance` is an instance of an existing ExtrudedShape object to be updated with the passed `shape`, `path`, `scale` or `rotation` parameters : https://doc.babylonjs.com/features/featuresDeepDive/mesh/dynamicMeshMorph#extruded-shape\r\n * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape\r\n * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE\r\n * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/features/featuresDeepDive/mesh/creation/set#side-orientation\r\n * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture\r\n * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created\r\n * * The optional parameter `firstNormal` (Vector3) defines the direction of the first normal of the supplied path. It should be supplied when the path is in the xy plane, and particularly if these sections are straight, because the underlying Path3D object will pick a normal in the xy plane that causes the extrusion to be collapsed into the plane. This should be used for any path that is straight.\r\n * * The optional `adjustFrame` (boolean, default false) will cause the internally generated Path3D tangents, normals, and binormals to be adjusted so that a) they are always well-defined, and b) they do not reverse from one path point to the next. This prevents the extruded shape from being flipped and/or rotated with resulting mesh self-intersections. This is primarily useful for straight paths that can reverse direction.\r\n * @param name defines the name of the mesh\r\n * @param options defines the options used to create the mesh\r\n * @param scene defines the hosting scene\r\n * @returns the custom extruded shape mesh\r\n * @see https://doc.babylonjs.com/features/featuresDeepDive/mesh/creation/param#custom-extruded-shapes\r\n * @see https://doc.babylonjs.com/features/featuresDeepDive/mesh/creation/param\r\n * @see https://doc.babylonjs.com/features/featuresDeepDive/mesh/creation/param#extruded-shapes\r\n */\r\nexport function ExtrudeShapeCustom(\r\n name: string,\r\n options: {\r\n shape: Vector3[];\r\n path: Vector3[];\r\n scaleFunction?: Nullable<{ (i: number, distance: number): number }>;\r\n rotationFunction?: Nullable<{ (i: number, distance: number): number }>;\r\n ribbonCloseArray?: boolean;\r\n ribbonClosePath?: boolean;\r\n closeShape?: boolean;\r\n closePath?: boolean;\r\n cap?: number;\r\n updatable?: boolean;\r\n sideOrientation?: number;\r\n frontUVs?: Vector4;\r\n backUVs?: Vector4;\r\n instance?: Mesh;\r\n invertUV?: boolean;\r\n firstNormal?: Vector3;\r\n adjustFrame?: boolean;\r\n capFunction?: Nullable<{ (shapePath: Vector3[]): Vector3[] }>;\r\n },\r\n scene: Nullable<Scene> = null\r\n): Mesh {\r\n const path = options.path;\r\n const shape = options.shape;\r\n const scaleFunction =\r\n options.scaleFunction ||\r\n (() => {\r\n return 1;\r\n });\r\n const rotationFunction =\r\n options.rotationFunction ||\r\n (() => {\r\n return 0;\r\n });\r\n const ribbonCloseArray = options.closePath || options.ribbonCloseArray || false;\r\n const ribbonClosePath = options.closeShape || options.ribbonClosePath || false;\r\n const cap = options.cap === 0 ? 0 : options.cap || Mesh.NO_CAP;\r\n const updatable = options.updatable;\r\n const firstNormal = options.firstNormal || null;\r\n const adjustFrame = options.adjustFrame || false;\r\n const sideOrientation = Mesh._GetDefaultSideOrientation(options.sideOrientation);\r\n const instance = options.instance;\r\n const invertUV = options.invertUV || false;\r\n const capFunction = options.capFunction || null;\r\n return _ExtrudeShapeGeneric(\r\n name,\r\n shape,\r\n path,\r\n null,\r\n null,\r\n scaleFunction,\r\n rotationFunction,\r\n ribbonCloseArray,\r\n ribbonClosePath,\r\n cap,\r\n true,\r\n scene,\r\n updatable ? true : false,\r\n sideOrientation,\r\n instance || null,\r\n invertUV,\r\n options.frontUVs || null,\r\n options.backUVs || null,\r\n firstNormal,\r\n adjustFrame,\r\n capFunction || null\r\n );\r\n}\r\n\r\nfunction _ExtrudeShapeGeneric(\r\n name: string,\r\n shape: Vector3[],\r\n curve: Vector3[],\r\n scale: Nullable<number>,\r\n rotation: Nullable<number>,\r\n scaleFunction: Nullable<{ (i: number, distance: number): number }>,\r\n rotateFunction: Nullable<{ (i: number, distance: number): number }>,\r\n rbCA: boolean,\r\n rbCP: boolean,\r\n cap: number,\r\n custom: boolean,\r\n scene: Nullable<Scene>,\r\n updtbl: boolean,\r\n side: number,\r\n instance: Nullable<Mesh>,\r\n invertUV: boolean,\r\n frontUVs: Nullable<Vector4>,\r\n backUVs: Nullable<Vector4>,\r\n firstNormal: Nullable<Vector3>,\r\n adjustFrame: boolean,\r\n capFunction: Nullable<{ (shapePath: Vector3[]): Vector3[] }>\r\n): Mesh {\r\n // extrusion geometry\r\n const extrusionPathArray = (\r\n shape: Vector3[],\r\n curve: Vector3[],\r\n path3D: Path3D,\r\n shapePaths: Vector3[][],\r\n scale: Nullable<number>,\r\n rotation: Nullable<number>,\r\n scaleFunction: Nullable<{ (i: number, distance: number): number }>,\r\n rotateFunction: Nullable<{ (i: number, distance: number): number }>,\r\n cap: number,\r\n custom: boolean,\r\n adjustFrame: boolean\r\n ) => {\r\n const tangents = path3D.getTangents();\r\n const normals = path3D.getNormals();\r\n const binormals = path3D.getBinormals();\r\n const distances = path3D.getDistances();\r\n if (adjustFrame) {\r\n /* fix tangents,normals, binormals */\r\n for (let i = 0; i < tangents.length; i++) {\r\n if (tangents[i].x == 0 && tangents[i].y == 0 && tangents[i].z == 0) {\r\n tangents[i].copyFrom(tangents[i - 1]);\r\n }\r\n if (normals[i].x == 0 && normals[i].y == 0 && normals[i].z == 0) {\r\n normals[i].copyFrom(normals[i - 1]);\r\n }\r\n if (binormals[i].x == 0 && binormals[i].y == 0 && binormals[i].z == 0) {\r\n binormals[i].copyFrom(binormals[i - 1]);\r\n }\r\n if (i > 0) {\r\n let v = tangents[i - 1];\r\n if (Vector3.Dot(v, tangents[i]) < 0) {\r\n tangents[i].scaleInPlace(-1);\r\n }\r\n v = normals[i - 1];\r\n if (Vector3.Dot(v, normals[i]) < 0) {\r\n normals[i].scaleInPlace(-1);\r\n }\r\n v = binormals[i - 1];\r\n if (Vector3.Dot(v, binormals[i]) < 0) {\r\n binormals[i].scaleInPlace(-1);\r\n }\r\n }\r\n }\r\n }\r\n let angle = 0;\r\n const returnScale = () => {\r\n return scale !== null ? scale : 1;\r\n };\r\n const returnRotation = () => {\r\n return rotation !== null ? rotation : 0;\r\n };\r\n const rotate: { (i: number, distance: number): number } = custom && rotateFunction ? rotateFunction : returnRotation;\r\n const scl: { (i: number, distance: number): number } = custom && scaleFunction ? scaleFunction : returnScale;\r\n let index = cap === Mesh.NO_CAP || cap === Mesh.CAP_END ? 0 : 2;\r\n const rotationMatrix: Matrix = TmpVectors.Matrix[0];\r\n\r\n for (let i = 0; i < curve.length; i++) {\r\n const shapePath: Vector3[] = [];\r\n const angleStep = rotate(i, distances[i]);\r\n const scaleRatio = scl(i, distances[i]);\r\n Matrix.RotationAxisToRef(tangents[i], angle, rotationMatrix);\r\n for (let p = 0; p < shape.length; p++) {\r\n const planed = tangents[i].scale(shape[p].z).add(normals[i].scale(shape[p].x)).add(binormals[i].scale(shape[p].y));\r\n const rotated = Vector3.Zero();\r\n Vector3.TransformCoordinatesToRef(planed, rotationMatrix, rotated);\r\n rotated.scaleInPlace(scaleRatio).addInPlace(curve[i]);\r\n shapePath[p] = rotated;\r\n }\r\n shapePaths[index] = shapePath;\r\n angle += angleStep;\r\n index++;\r\n }\r\n // cap\r\n const defaultCapPath = (shapePath: Vector3[]) => {\r\n const pointCap = Array<Vector3>();\r\n const barycenter = Vector3.Zero();\r\n let i: number;\r\n for (i = 0; i < shapePath.length; i++) {\r\n barycenter.addInPlace(shapePath[i]);\r\n }\r\n barycenter.scaleInPlace(1.0 / shapePath.length);\r\n for (i = 0; i < shapePath.length; i++) {\r\n pointCap.push(barycenter);\r\n }\r\n return pointCap;\r\n };\r\n const capPath = capFunction || defaultCapPath;\r\n switch (cap) {\r\n case Mesh.NO_CAP:\r\n break;\r\n case Mesh.CAP_START:\r\n shapePaths[0] = capPath(shapePaths[2]);\r\n shapePaths[1] = shapePaths[2];\r\n break;\r\n case Mesh.CAP_END:\r\n shapePaths[index] = shapePaths[index - 1];\r\n shapePaths[index + 1] = capPath(shapePaths[index - 1]);\r\n break;\r\n case Mesh.CAP_ALL:\r\n shapePaths[0] = capPath(shapePaths[2]);\r\n shapePaths[1] = shapePaths[2];\r\n shapePaths[index] = shapePaths[index - 1];\r\n shapePaths[index + 1] = capPath(shapePaths[index - 1]);\r\n break;\r\n default:\r\n break;\r\n }\r\n return shapePaths;\r\n };\r\n let path3D;\r\n let pathArray;\r\n if (instance) {\r\n // instance update\r\n const storage = instance._creationDataStorage!;\r\n path3D = firstNormal ? storage.path3D.update(curve, firstNormal) : storage.path3D.update(curve);\r\n pathArray = extrusionPathArray(shape, curve, storage.path3D, storage.pathArray, scale, rotation, scaleFunction, rotateFunction, storage.cap, custom, adjustFrame);\r\n instance = CreateRibbon(\"\", { pathArray, closeArray: false, closePath: false, offset: 0, updatable: false, sideOrientation: 0, instance }, scene || undefined);\r\n\r\n return instance;\r\n }\r\n // extruded shape creation\r\n path3D = firstNormal ? new Path3D(curve, firstNormal) : new Path3D(curve);\r\n const newShapePaths = new Array<Array<Vector3>>();\r\n cap = cap < 0 || cap > 3 ? 0 : cap;\r\n pathArray = extrusionPathArray(shape, curve, path3D, newShapePaths, scale, rotation, scaleFunction, rotateFunction, cap, custom, adjustFrame);\r\n const extrudedGeneric = CreateRibbon(\r\n name,\r\n {\r\n pathArray: pathArray,\r\n closeArray: rbCA,\r\n closePath: rbCP,\r\n updatable: updtbl,\r\n sideOrientation: side,\r\n invertUV: invertUV,\r\n frontUVs: frontUVs || undefined,\r\n backUVs: backUVs || undefined,\r\n },\r\n scene\r\n );\r\n extrudedGeneric._creationDataStorage!.pathArray = pathArray;\r\n extrudedGeneric._creationDataStorage!.path3D = path3D;\r\n extrudedGeneric._creationDataStorage!.cap = cap;\r\n\r\n return extrudedGeneric;\r\n}\r\n\r\n/**\r\n * Class containing static functions to help procedurally build meshes\r\n * @deprecated please use the functions directly from the module\r\n */\r\nexport const ShapeBuilder = {\r\n // eslint-disable-next-line @typescript-eslint/naming-convention\r\n ExtrudeShape,\r\n // eslint-disable-next-line @typescript-eslint/naming-convention\r\n ExtrudeShapeCustom,\r\n};\r\n\r\nMesh.ExtrudeShape = (\r\n name: string,\r\n shape: Vector3[],\r\n path: Vector3[],\r\n scale: number,\r\n rotation: number,\r\n cap: number,\r\n scene: Nullable<Scene> = null,\r\n updatable?: boolean,\r\n sideOrientation?: number,\r\n instance?: Mesh\r\n): Mesh => {\r\n const options = {\r\n shape: shape,\r\n path: path,\r\n scale: scale,\r\n rotation: rotation,\r\n cap: cap === 0 ? 0 : cap || Mesh.NO_CAP,\r\n sideOrientation: sideOrientation,\r\n instance: instance,\r\n updatable: updatable,\r\n };\r\n\r\n return ExtrudeShape(name, options, scene);\r\n};\r\n\r\nMesh.ExtrudeShapeCustom = (\r\n name: string,\r\n shape: Vector3[],\r\n path: Vector3[],\r\n scaleFunction: Nullable<{ (i: number, distance: number): number }>,\r\n rotationFunction: Nullable<{ (i: number, distance: number): number }>,\r\n ribbonCloseArray: boolean,\r\n ribbonClosePath: boolean,\r\n cap: number,\r\n scene: Scene,\r\n updatable?: boolean,\r\n sideOrientation?: number,\r\n instance?: Mesh\r\n): Mesh => {\r\n const options = {\r\n shape: shape,\r\n path: path,\r\n scaleFunction: scaleFunction,\r\n rotationFunction: rotationFunction,\r\n ribbonCloseArray: ribbonCloseArray,\r\n ribbonClosePath: ribbonClosePath,\r\n cap: cap === 0 ? 0 : cap || Mesh.NO_CAP,\r\n sideOrientation: sideOrientation,\r\n instance: instance,\r\n updatable: updatable,\r\n };\r\n\r\n return ExtrudeShapeCustom(name, options, scene);\r\n};\r\n"]}
package/Meshes/subMesh.js CHANGED
@@ -236,7 +236,7 @@ export class SubMesh {
236
236
  getMaterial(getDefaultMaterial = true) {
237
237
  const rootMaterial = this._renderingMesh.getMaterialForRenderPass(this._engine.currentRenderPassId) ?? this._renderingMesh.material;
238
238
  if (!rootMaterial) {
239
- return getDefaultMaterial ? this._mesh.getScene().defaultMaterial : null;
239
+ return getDefaultMaterial && this._mesh.getScene()._hasDefaultMaterial ? this._mesh.getScene().defaultMaterial : null;
240
240
  }
241
241
  else if (this._isMultiMaterial(rootMaterial)) {
242
242
  const effectiveMaterial = rootMaterial.getSubMaterial(this.materialIndex);
@@ -1 +1 @@
1
- {"version":3,"file":"subMesh.js","sourceRoot":"","sources":["../../../../dev/core/src/Meshes/subMesh.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,YAAY,EAAE,MAAM,mBAAmB,CAAC;AACjD,OAAO,EAAE,gBAAgB,EAAE,MAAM,gCAAgC,CAAC;AAElE,OAAO,EAAE,YAAY,EAAE,MAAM,yBAAyB,CAAC;AAEvD,OAAO,EAAE,SAAS,EAAE,MAAM,sBAAsB,CAAC;AAEjD,OAAO,EAAE,uBAAuB,EAAE,MAAM,yBAAyB,CAAC;AAElE,OAAO,EAAE,WAAW,EAAE,MAAM,0BAA0B,CAAC;AAavD;;GAEG;AACH,MAAM,OAAO,OAAO;IAMhB;;OAEG;IACH,IAAW,eAAe;QACtB,OAAO,IAAI,CAAC,wBAAwB,CAAC,CAAC,CAAE,IAAI,CAAC,wBAAwB,CAAC,OAA2B,CAAC,CAAC,CAAE,IAAI,CAAC,eAAe,EAAE,EAAE,OAAqC,CAAC;IACvK,CAAC;IAED;;OAEG;IACH,IAAW,eAAe,CAAC,OAAkC;QACzD,MAAM,WAAW,GAAG,IAAI,CAAC,wBAAwB,IAAI,IAAI,CAAC,eAAe,CAAC,SAAS,EAAE,IAAI,CAAE,CAAC;QAC5F,WAAW,CAAC,OAAO,GAAG,OAAO,CAAC;IAClC,CAAC;IAED;;OAEG;IACI,eAAe,CAAC,MAAe,EAAE,mBAAmB,GAAG,KAAK;QAC/D,MAAM,GAAG,MAAM,IAAI,IAAI,CAAC,OAAO,CAAC,mBAAmB,CAAC;QACpD,IAAI,WAAW,GAAG,IAAI,CAAC,aAAa,CAAC,MAAM,CAAC,CAAC;QAC7C,IAAI,CAAC,WAAW,IAAI,mBAAmB,EAAE,CAAC;YACtC,IAAI,CAAC,aAAa,CAAC,MAAM,CAAC,GAAG,WAAW,GAAG,IAAI,WAAW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GAAG,UAAU,EAAE,KAAK,EAAE,EAAE,CAAC;YACpE,MAAM,WAAW,GAAG,OAAO,CAAC,KAAK,CAAC,CAAC;YAEnC,IAAI,WAAW,GAAG,cAAc,EAAE,CAAC;gBAC/B,cAAc,GAAG,WAAW,CAAC;YACjC,CAAC;YACD,IAAI,WAAW,GAAG,cAAc,EAAE,CAAC;gBAC/B,cAAc,GAAG,WAAW,CAAC;YACjC,CAAC;QACL,CAAC;QAED,OAAO,IAAI,OAAO,CAAC,aAAa,EAAE,cAAc,EAAE,cAAc,GAAG,cAAc,GAAG,CAAC,EAAE,UAAU,EAAE,UAAU,EAAE,IAAI,EAAE,aAAa,EAAE,iBAAiB,CAAC,CAAC;IAC3J,CAAC;CACJ","sourcesContent":["import type { Nullable, IndicesArray, DeepImmutable, FloatArray } from \"../types\";\r\nimport type { Matrix, Vector3 } from \"../Maths/math.vector\";\r\nimport { VertexBuffer } from \"../Buffers/buffer\";\r\nimport { IntersectionInfo } from \"../Collisions/intersectionInfo\";\r\nimport type { ICullable } from \"../Culling/boundingInfo\";\r\nimport { BoundingInfo } from \"../Culling/boundingInfo\";\r\nimport type { Effect } from \"../Materials/effect\";\r\nimport { Constants } from \"../Engines/constants\";\r\nimport type { DataBuffer } from \"../Buffers/dataBuffer\";\r\nimport { extractMinAndMaxIndexed } from \"../Maths/math.functions\";\r\nimport type { Plane } from \"../Maths/math.plane\";\r\nimport { DrawWrapper } from \"../Materials/drawWrapper\";\r\nimport type { IMaterialContext } from \"../Engines/IMaterialContext\";\r\n\r\nimport type { Collider } from \"../Collisions/collider\";\r\nimport type { Material } from \"../Materials/material\";\r\nimport type { MaterialDefines } from \"../Materials/materialDefines\";\r\nimport type { MultiMaterial } from \"../Materials/multiMaterial\";\r\nimport type { AbstractMesh } from \"./abstractMesh\";\r\nimport type { Mesh } from \"./mesh\";\r\nimport type { Ray } from \"../Culling/ray\";\r\nimport type { TrianglePickingPredicate } from \"../Culling/ray\";\r\nimport type { AbstractEngine } from \"core/Engines/abstractEngine\";\r\n\r\n/**\r\n * Defines a subdivision inside a mesh\r\n */\r\nexport class SubMesh implements ICullable {\r\n private _engine: AbstractEngine;\r\n /** @internal */\r\n public _drawWrappers: Array<DrawWrapper>; // index in this array = pass id\r\n private _mainDrawWrapperOverride: Nullable<DrawWrapper> = null;\r\n\r\n /**\r\n * Gets material defines used by the effect associated to the sub mesh\r\n */\r\n public get materialDefines(): Nullable<MaterialDefines> {\r\n return this._mainDrawWrapperOverride ? (this._mainDrawWrapperOverride.defines as MaterialDefines) : (this._getDrawWrapper()?.defines as Nullable<MaterialDefines>);\r\n }\r\n\r\n /**\r\n * Sets material defines used by the effect associated to the sub mesh\r\n */\r\n public set materialDefines(defines: Nullable<MaterialDefines>) {\r\n const drawWrapper = this._mainDrawWrapperOverride ?? this._getDrawWrapper(undefined, true)!;\r\n drawWrapper.defines = defines;\r\n }\r\n\r\n /**\r\n * @internal\r\n */\r\n public _getDrawWrapper(passId?: number, createIfNotExisting = false): DrawWrapper | undefined {\r\n passId = passId ?? this._engine.currentRenderPassId;\r\n let drawWrapper = this._drawWrappers[passId];\r\n if (!drawWrapper && createIfNotExisting) {\r\n this._drawWrappers[passId] = drawWrapper = new DrawWrapper(this._mesh.getScene().getEngine());\r\n }\r\n return drawWrapper;\r\n }\r\n\r\n /**\r\n * @internal\r\n */\r\n public _removeDrawWrapper(passId: number, disposeWrapper = true, immediate = false): void {\r\n if (disposeWrapper) {\r\n this._drawWrappers[passId]?.dispose(immediate);\r\n }\r\n this._drawWrappers[passId] = undefined as any;\r\n }\r\n\r\n /**\r\n * Gets associated (main) effect (possibly the effect override if defined)\r\n */\r\n public get effect(): Nullable<Effect> {\r\n return this._mainDrawWrapperOverride ? this._mainDrawWrapperOverride.effect : (this._getDrawWrapper()?.effect ?? null);\r\n }\r\n\r\n /** @internal */\r\n public get _drawWrapper(): DrawWrapper {\r\n return this._mainDrawWrapperOverride ?? this._getDrawWrapper(undefined, true)!;\r\n }\r\n\r\n /** @internal */\r\n public get _drawWrapperOverride(): Nullable<DrawWrapper> {\r\n return this._mainDrawWrapperOverride;\r\n }\r\n\r\n /**\r\n * @internal\r\n */\r\n public _setMainDrawWrapperOverride(wrapper: Nullable<DrawWrapper>): void {\r\n this._mainDrawWrapperOverride = wrapper;\r\n }\r\n\r\n /**\r\n * Sets associated effect (effect used to render this submesh)\r\n * @param effect defines the effect to associate with\r\n * @param defines defines the set of defines used to compile this effect\r\n * @param materialContext material context associated to the effect\r\n * @param resetContext true to reset the draw context\r\n */\r\n public setEffect(effect: Nullable<Effect>, defines: Nullable<string | MaterialDefines> = null, materialContext?: IMaterialContext, resetContext = true) {\r\n const drawWrapper = this._drawWrapper;\r\n drawWrapper.setEffect(effect, defines, resetContext);\r\n if (materialContext !== undefined) {\r\n drawWrapper.materialContext = materialContext;\r\n }\r\n if (!effect) {\r\n drawWrapper.defines = null;\r\n drawWrapper.materialContext = undefined;\r\n }\r\n }\r\n\r\n /**\r\n * Resets the draw wrappers cache\r\n * @param passId If provided, releases only the draw wrapper corresponding to this render pass id\r\n * @param immediate If true, the draw wrapper will dispose the effect immediately (false by default)\r\n */\r\n public resetDrawCache(passId?: number, immediate = false): void {\r\n if (this._drawWrappers) {\r\n if (passId !== undefined) {\r\n this._removeDrawWrapper(passId, true, immediate);\r\n return;\r\n } else {\r\n for (const drawWrapper of this._drawWrappers) {\r\n drawWrapper?.dispose(immediate);\r\n }\r\n }\r\n }\r\n this._drawWrappers = [];\r\n }\r\n\r\n /** @internal */\r\n public _linesIndexCount: number = 0;\r\n private _mesh: AbstractMesh;\r\n private _renderingMesh: Mesh;\r\n private _boundingInfo: BoundingInfo;\r\n private _linesIndexBuffer: Nullable<DataBuffer> = null;\r\n /** @internal */\r\n public _lastColliderWorldVertices: Nullable<Vector3[]> = null;\r\n /** @internal */\r\n public _trianglePlanes: Plane[];\r\n /** @internal */\r\n public _lastColliderTransformMatrix: Nullable<Matrix> = null;\r\n /** @internal */\r\n public _wasDispatched = false;\r\n\r\n /** @internal */\r\n public _renderId = 0;\r\n /** @internal */\r\n public _alphaIndex: number = 0;\r\n /** @internal */\r\n public _distanceToCamera: number = 0;\r\n /** @internal */\r\n public _id: number;\r\n\r\n private _currentMaterial: Nullable<Material> = null;\r\n\r\n /**\r\n * Add a new submesh to a mesh\r\n * @param materialIndex defines the material index to use\r\n * @param verticesStart defines vertex index start\r\n * @param verticesCount defines vertices count\r\n * @param indexStart defines index start\r\n * @param indexCount defines indices count\r\n * @param mesh defines the parent mesh\r\n * @param renderingMesh defines an optional rendering mesh\r\n * @param createBoundingBox defines if bounding box should be created for this submesh\r\n * @returns the new submesh\r\n */\r\n public static AddToMesh(\r\n materialIndex: number,\r\n verticesStart: number,\r\n verticesCount: number,\r\n indexStart: number,\r\n indexCount: number,\r\n mesh: AbstractMesh,\r\n renderingMesh?: Mesh,\r\n createBoundingBox: boolean = true\r\n ): SubMesh {\r\n return new SubMesh(materialIndex, verticesStart, verticesCount, indexStart, indexCount, mesh, renderingMesh, createBoundingBox);\r\n }\r\n\r\n /**\r\n * Creates a new submesh\r\n * @param materialIndex defines the material index to use\r\n * @param verticesStart defines vertex index start\r\n * @param verticesCount defines vertices count\r\n * @param indexStart defines index start\r\n * @param indexCount defines indices count\r\n * @param mesh defines the parent mesh\r\n * @param renderingMesh defines an optional rendering mesh\r\n * @param createBoundingBox defines if bounding box should be created for this submesh\r\n * @param addToMesh defines a boolean indicating that the submesh must be added to the mesh.subMeshes array (true by default)\r\n */\r\n constructor(\r\n /** the material index to use */\r\n public materialIndex: number,\r\n /** vertex index start */\r\n public verticesStart: number,\r\n /** vertices count */\r\n public verticesCount: number,\r\n /** index start */\r\n public indexStart: number,\r\n /** indices count */\r\n public indexCount: number,\r\n mesh: AbstractMesh,\r\n renderingMesh?: Mesh,\r\n createBoundingBox: boolean = true,\r\n addToMesh = true\r\n ) {\r\n this._mesh = mesh;\r\n this._renderingMesh = renderingMesh || <Mesh>mesh;\r\n if (addToMesh) {\r\n mesh.subMeshes.push(this);\r\n }\r\n\r\n this._engine = this._mesh.getScene().getEngine();\r\n this.resetDrawCache();\r\n this._trianglePlanes = [];\r\n\r\n this._id = mesh.subMeshes.length - 1;\r\n\r\n if (createBoundingBox) {\r\n this.refreshBoundingInfo();\r\n mesh.computeWorldMatrix(true);\r\n }\r\n }\r\n\r\n /**\r\n * Returns true if this submesh covers the entire parent mesh\r\n * @ignorenaming\r\n */\r\n // eslint-disable-next-line @typescript-eslint/naming-convention\r\n public get IsGlobal(): boolean {\r\n return this.verticesStart === 0 && this.verticesCount === this._mesh.getTotalVertices() && this.indexStart === 0 && this.indexCount === this._mesh.getTotalIndices();\r\n }\r\n\r\n /**\r\n * Returns the submesh BoundingInfo object\r\n * @returns current bounding info (or mesh's one if the submesh is global)\r\n */\r\n public getBoundingInfo(): BoundingInfo {\r\n if (this.IsGlobal || this._mesh.hasThinInstances) {\r\n return this._mesh.getBoundingInfo();\r\n }\r\n\r\n return this._boundingInfo;\r\n }\r\n\r\n /**\r\n * Sets the submesh BoundingInfo\r\n * @param boundingInfo defines the new bounding info to use\r\n * @returns the SubMesh\r\n */\r\n public setBoundingInfo(boundingInfo: BoundingInfo): SubMesh {\r\n this._boundingInfo = boundingInfo;\r\n return this;\r\n }\r\n\r\n /**\r\n * Returns the mesh of the current submesh\r\n * @returns the parent mesh\r\n */\r\n public getMesh(): AbstractMesh {\r\n return this._mesh;\r\n }\r\n\r\n /**\r\n * Returns the rendering mesh of the submesh\r\n * @returns the rendering mesh (could be different from parent mesh)\r\n */\r\n public getRenderingMesh(): Mesh {\r\n return this._renderingMesh;\r\n }\r\n\r\n /**\r\n * Returns the replacement mesh of the submesh\r\n * @returns the replacement mesh (could be different from parent mesh)\r\n */\r\n public getReplacementMesh(): Nullable<AbstractMesh> {\r\n return this._mesh._internalAbstractMeshDataInfo._actAsRegularMesh ? this._mesh : null;\r\n }\r\n\r\n /**\r\n * Returns the effective mesh of the submesh\r\n * @returns the effective mesh (could be different from parent mesh)\r\n */\r\n public getEffectiveMesh(): AbstractMesh {\r\n const replacementMesh = this._mesh._internalAbstractMeshDataInfo._actAsRegularMesh ? this._mesh : null;\r\n\r\n return replacementMesh ? replacementMesh : this._renderingMesh;\r\n }\r\n\r\n /**\r\n * Returns the submesh material\r\n * @param getDefaultMaterial Defines whether or not to get the default material if nothing has been defined.\r\n * @returns null or the current material\r\n */\r\n public getMaterial(getDefaultMaterial = true): Nullable<Material> {\r\n const rootMaterial = this._renderingMesh.getMaterialForRenderPass(this._engine.currentRenderPassId) ?? this._renderingMesh.material;\r\n\r\n if (!rootMaterial) {\r\n return getDefaultMaterial ? this._mesh.getScene().defaultMaterial : null;\r\n } else if (this._isMultiMaterial(rootMaterial)) {\r\n const effectiveMaterial = rootMaterial.getSubMaterial(this.materialIndex);\r\n\r\n if (this._currentMaterial !== effectiveMaterial) {\r\n this._currentMaterial = effectiveMaterial;\r\n this.resetDrawCache();\r\n }\r\n\r\n return effectiveMaterial;\r\n }\r\n\r\n return rootMaterial;\r\n }\r\n\r\n private _isMultiMaterial(material: Material): material is MultiMaterial {\r\n return (material as MultiMaterial).getSubMaterial !== undefined;\r\n }\r\n\r\n // Methods\r\n\r\n /**\r\n * Sets a new updated BoundingInfo object to the submesh\r\n * @param data defines an optional position array to use to determine the bounding info\r\n * @returns the SubMesh\r\n */\r\n public refreshBoundingInfo(data: Nullable<FloatArray> = null): SubMesh {\r\n this._lastColliderWorldVertices = null;\r\n\r\n if (this.IsGlobal || !this._renderingMesh || !this._renderingMesh.geometry) {\r\n return this;\r\n }\r\n\r\n if (!data) {\r\n data = this._renderingMesh.getVerticesData(VertexBuffer.PositionKind);\r\n }\r\n\r\n if (!data) {\r\n this._boundingInfo = this._mesh.getBoundingInfo();\r\n return this;\r\n }\r\n\r\n const indices = <IndicesArray>this._renderingMesh.getIndices();\r\n let extend: { minimum: Vector3; maximum: Vector3 };\r\n\r\n //is this the only submesh?\r\n if (this.indexStart === 0 && this.indexCount === indices.length) {\r\n const boundingInfo = this._renderingMesh.getBoundingInfo();\r\n\r\n //the rendering mesh's bounding info can be used, it is the standard submesh for all indices.\r\n extend = { minimum: boundingInfo.minimum.clone(), maximum: boundingInfo.maximum.clone() };\r\n } else {\r\n extend = extractMinAndMaxIndexed(data, indices, this.indexStart, this.indexCount, this._renderingMesh.geometry.boundingBias);\r\n }\r\n\r\n if (this._boundingInfo) {\r\n this._boundingInfo.reConstruct(extend.minimum, extend.maximum);\r\n } else {\r\n this._boundingInfo = new BoundingInfo(extend.minimum, extend.maximum);\r\n }\r\n return this;\r\n }\r\n\r\n /**\r\n * @internal\r\n */\r\n public _checkCollision(collider: Collider): boolean {\r\n const boundingInfo = this.getBoundingInfo();\r\n\r\n return boundingInfo._checkCollision(collider);\r\n }\r\n\r\n /**\r\n * Updates the submesh BoundingInfo\r\n * @param world defines the world matrix to use to update the bounding info\r\n * @returns the submesh\r\n */\r\n public updateBoundingInfo(world: DeepImmutable<Matrix>): SubMesh {\r\n let boundingInfo = this.getBoundingInfo();\r\n\r\n if (!boundingInfo) {\r\n this.refreshBoundingInfo();\r\n boundingInfo = this.getBoundingInfo();\r\n }\r\n if (boundingInfo) {\r\n (<BoundingInfo>boundingInfo).update(world);\r\n }\r\n return this;\r\n }\r\n\r\n /**\r\n * True is the submesh bounding box intersects the frustum defined by the passed array of planes.\r\n * @param frustumPlanes defines the frustum planes\r\n * @returns true if the submesh is intersecting with the frustum\r\n */\r\n public isInFrustum(frustumPlanes: Plane[]): boolean {\r\n const boundingInfo = this.getBoundingInfo();\r\n\r\n if (!boundingInfo) {\r\n return false;\r\n }\r\n return boundingInfo.isInFrustum(frustumPlanes, this._mesh.cullingStrategy);\r\n }\r\n\r\n /**\r\n * True is the submesh bounding box is completely inside the frustum defined by the passed array of planes\r\n * @param frustumPlanes defines the frustum planes\r\n * @returns true if the submesh is inside the frustum\r\n */\r\n public isCompletelyInFrustum(frustumPlanes: Plane[]): boolean {\r\n const boundingInfo = this.getBoundingInfo();\r\n\r\n if (!boundingInfo) {\r\n return false;\r\n }\r\n return boundingInfo.isCompletelyInFrustum(frustumPlanes);\r\n }\r\n\r\n /**\r\n * Renders the submesh\r\n * @param enableAlphaMode defines if alpha needs to be used\r\n * @returns the submesh\r\n */\r\n public render(enableAlphaMode: boolean): SubMesh {\r\n this._renderingMesh.render(this, enableAlphaMode, this._mesh._internalAbstractMeshDataInfo._actAsRegularMesh ? this._mesh : undefined);\r\n return this;\r\n }\r\n\r\n /**\r\n * @internal\r\n */\r\n public _getLinesIndexBuffer(indices: IndicesArray, engine: AbstractEngine): DataBuffer {\r\n if (!this._linesIndexBuffer) {\r\n const adjustedIndexCount = Math.floor(this.indexCount / 3) * 6;\r\n const shouldUseUint32 = this.verticesStart + this.verticesCount > 65535;\r\n const linesIndices = shouldUseUint32 ? new Uint32Array(adjustedIndexCount) : new Uint16Array(adjustedIndexCount);\r\n\r\n let offset = 0;\r\n if (indices.length === 0) {\r\n // Unindexed mesh\r\n for (let index = this.indexStart; index < this.indexStart + this.indexCount; index += 3) {\r\n linesIndices[offset++] = index;\r\n linesIndices[offset++] = index + 1;\r\n linesIndices[offset++] = index + 1;\r\n linesIndices[offset++] = index + 2;\r\n linesIndices[offset++] = index + 2;\r\n linesIndices[offset++] = index;\r\n }\r\n } else {\r\n for (let index = this.indexStart; index < this.indexStart + this.indexCount; index += 3) {\r\n linesIndices[offset++] = indices[index];\r\n linesIndices[offset++] = indices[index + 1];\r\n linesIndices[offset++] = indices[index + 1];\r\n linesIndices[offset++] = indices[index + 2];\r\n linesIndices[offset++] = indices[index + 2];\r\n linesIndices[offset++] = indices[index];\r\n }\r\n }\r\n\r\n this._linesIndexBuffer = engine.createIndexBuffer(linesIndices);\r\n this._linesIndexCount = linesIndices.length;\r\n }\r\n return this._linesIndexBuffer;\r\n }\r\n\r\n /**\r\n * Checks if the submesh intersects with a ray\r\n * @param ray defines the ray to test\r\n * @returns true is the passed ray intersects the submesh bounding box\r\n */\r\n public canIntersects(ray: Ray): boolean {\r\n const boundingInfo = this.getBoundingInfo();\r\n\r\n if (!boundingInfo) {\r\n return false;\r\n }\r\n return ray.intersectsBox(boundingInfo.boundingBox);\r\n }\r\n\r\n /**\r\n * Intersects current submesh with a ray\r\n * @param ray defines the ray to test\r\n * @param positions defines mesh's positions array\r\n * @param indices defines mesh's indices array\r\n * @param fastCheck defines if the first intersection will be used (and not the closest)\r\n * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected\r\n * @returns intersection info or null if no intersection\r\n */\r\n public intersects(ray: Ray, positions: Vector3[], indices: IndicesArray, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<IntersectionInfo> {\r\n const material = this.getMaterial();\r\n if (!material) {\r\n return null;\r\n }\r\n let step = 3;\r\n let checkStopper = false;\r\n\r\n switch (material.fillMode) {\r\n case Constants.MATERIAL_PointListDrawMode:\r\n case Constants.MATERIAL_LineLoopDrawMode:\r\n case Constants.MATERIAL_LineStripDrawMode:\r\n case Constants.MATERIAL_TriangleFanDrawMode:\r\n return null;\r\n case Constants.MATERIAL_TriangleStripDrawMode:\r\n step = 1;\r\n checkStopper = true;\r\n break;\r\n default:\r\n break;\r\n }\r\n\r\n // LineMesh first as it's also a Mesh...\r\n if (material.fillMode === Constants.MATERIAL_LineListDrawMode) {\r\n // Check if mesh is unindexed\r\n if (!indices.length) {\r\n return this._intersectUnIndexedLines(ray, positions, indices, (this._mesh as any).intersectionThreshold, fastCheck);\r\n }\r\n return this._intersectLines(ray, positions, indices, (this._mesh as any).intersectionThreshold, fastCheck);\r\n } else {\r\n // Check if mesh is unindexed\r\n if (!indices.length && this._mesh._unIndexed) {\r\n return this._intersectUnIndexedTriangles(ray, positions, indices, fastCheck, trianglePredicate);\r\n }\r\n\r\n return this._intersectTriangles(ray, positions, indices, step, checkStopper, fastCheck, trianglePredicate);\r\n }\r\n }\r\n\r\n /**\r\n * @internal\r\n */\r\n private _intersectLines(ray: Ray, positions: Vector3[], indices: IndicesArray, intersectionThreshold: number, fastCheck?: boolean): Nullable<IntersectionInfo> {\r\n let intersectInfo: Nullable<IntersectionInfo> = null;\r\n\r\n // Line test\r\n for (let index = this.indexStart; index < this.indexStart + this.indexCount; index += 2) {\r\n const p0 = positions[indices[index]];\r\n const p1 = positions[indices[index + 1]];\r\n\r\n const length = ray.intersectionSegment(p0, p1, intersectionThreshold);\r\n if (length < 0) {\r\n continue;\r\n }\r\n\r\n if (fastCheck || !intersectInfo || length < intersectInfo.distance) {\r\n intersectInfo = new IntersectionInfo(null, null, length);\r\n intersectInfo.faceId = index / 2;\r\n if (fastCheck) {\r\n break;\r\n }\r\n }\r\n }\r\n return intersectInfo;\r\n }\r\n\r\n /**\r\n * @internal\r\n */\r\n private _intersectUnIndexedLines(ray: Ray, positions: Vector3[], indices: IndicesArray, intersectionThreshold: number, fastCheck?: boolean): Nullable<IntersectionInfo> {\r\n let intersectInfo: Nullable<IntersectionInfo> = null;\r\n\r\n // Line test\r\n for (let index = this.verticesStart; index < this.verticesStart + this.verticesCount; index += 2) {\r\n const p0 = positions[index];\r\n const p1 = positions[index + 1];\r\n\r\n const length = ray.intersectionSegment(p0, p1, intersectionThreshold);\r\n if (length < 0) {\r\n continue;\r\n }\r\n\r\n if (fastCheck || !intersectInfo || length < intersectInfo.distance) {\r\n intersectInfo = new IntersectionInfo(null, null, length);\r\n intersectInfo.faceId = index / 2;\r\n if (fastCheck) {\r\n break;\r\n }\r\n }\r\n }\r\n\r\n return intersectInfo;\r\n }\r\n\r\n /**\r\n * @internal\r\n */\r\n private _intersectTriangles(\r\n ray: Ray,\r\n positions: Vector3[],\r\n indices: IndicesArray,\r\n step: number,\r\n checkStopper: boolean,\r\n fastCheck?: boolean,\r\n trianglePredicate?: TrianglePickingPredicate\r\n ): Nullable<IntersectionInfo> {\r\n let intersectInfo: Nullable<IntersectionInfo> = null;\r\n\r\n // Triangles test\r\n let faceId = -1;\r\n for (let index = this.indexStart; index < this.indexStart + this.indexCount - (3 - step); index += step) {\r\n faceId++;\r\n const indexA = indices[index];\r\n const indexB = indices[index + 1];\r\n const indexC = indices[index + 2];\r\n\r\n if (checkStopper && indexC === 0xffffffff) {\r\n index += 2;\r\n continue;\r\n }\r\n\r\n const p0 = positions[indexA];\r\n const p1 = positions[indexB];\r\n const p2 = positions[indexC];\r\n\r\n // stay defensive and don't check against undefined positions.\r\n if (!p0 || !p1 || !p2) {\r\n continue;\r\n }\r\n\r\n if (trianglePredicate && !trianglePredicate(p0, p1, p2, ray, indexA, indexB, indexC)) {\r\n continue;\r\n }\r\n\r\n const currentIntersectInfo = ray.intersectsTriangle(p0, p1, p2);\r\n\r\n if (currentIntersectInfo) {\r\n if (currentIntersectInfo.distance < 0) {\r\n continue;\r\n }\r\n\r\n if (fastCheck || !intersectInfo || currentIntersectInfo.distance < intersectInfo.distance) {\r\n intersectInfo = currentIntersectInfo;\r\n intersectInfo.faceId = faceId;\r\n\r\n if (fastCheck) {\r\n break;\r\n }\r\n }\r\n }\r\n }\r\n return intersectInfo;\r\n }\r\n\r\n /**\r\n * @internal\r\n */\r\n private _intersectUnIndexedTriangles(\r\n ray: Ray,\r\n positions: Vector3[],\r\n indices: IndicesArray,\r\n fastCheck?: boolean,\r\n trianglePredicate?: TrianglePickingPredicate\r\n ): Nullable<IntersectionInfo> {\r\n let intersectInfo: Nullable<IntersectionInfo> = null;\r\n // Triangles test\r\n for (let index = this.verticesStart; index < this.verticesStart + this.verticesCount; index += 3) {\r\n const p0 = positions[index];\r\n const p1 = positions[index + 1];\r\n const p2 = positions[index + 2];\r\n\r\n if (trianglePredicate && !trianglePredicate(p0, p1, p2, ray, -1, -1, -1)) {\r\n continue;\r\n }\r\n\r\n const currentIntersectInfo = ray.intersectsTriangle(p0, p1, p2);\r\n\r\n if (currentIntersectInfo) {\r\n if (currentIntersectInfo.distance < 0) {\r\n continue;\r\n }\r\n\r\n if (fastCheck || !intersectInfo || currentIntersectInfo.distance < intersectInfo.distance) {\r\n intersectInfo = currentIntersectInfo;\r\n intersectInfo.faceId = index / 3;\r\n\r\n if (fastCheck) {\r\n break;\r\n }\r\n }\r\n }\r\n }\r\n return intersectInfo;\r\n }\r\n\r\n /** @internal */\r\n public _rebuild(): void {\r\n if (this._linesIndexBuffer) {\r\n this._linesIndexBuffer = null;\r\n }\r\n }\r\n\r\n // Clone\r\n /**\r\n * Creates a new submesh from the passed mesh\r\n * @param newMesh defines the new hosting mesh\r\n * @param newRenderingMesh defines an optional rendering mesh\r\n * @returns the new submesh\r\n */\r\n public clone(newMesh: AbstractMesh, newRenderingMesh?: Mesh): SubMesh {\r\n const result = new SubMesh(this.materialIndex, this.verticesStart, this.verticesCount, this.indexStart, this.indexCount, newMesh, newRenderingMesh, false);\r\n\r\n if (!this.IsGlobal) {\r\n const boundingInfo = this.getBoundingInfo();\r\n\r\n if (!boundingInfo) {\r\n return result;\r\n }\r\n\r\n result._boundingInfo = new BoundingInfo(boundingInfo.minimum, boundingInfo.maximum);\r\n }\r\n\r\n return result;\r\n }\r\n\r\n // Dispose\r\n\r\n /**\r\n * Release associated resources\r\n * @param immediate If true, the effect will be disposed immediately (false by default)\r\n */\r\n public dispose(immediate = false): void {\r\n if (this._linesIndexBuffer) {\r\n this._mesh.getScene().getEngine()._releaseBuffer(this._linesIndexBuffer);\r\n this._linesIndexBuffer = null;\r\n }\r\n\r\n // Remove from mesh\r\n const index = this._mesh.subMeshes.indexOf(this);\r\n this._mesh.subMeshes.splice(index, 1);\r\n\r\n this.resetDrawCache(undefined, immediate);\r\n }\r\n\r\n /**\r\n * Gets the class name\r\n * @returns the string \"SubMesh\".\r\n */\r\n public getClassName(): string {\r\n return \"SubMesh\";\r\n }\r\n\r\n // Statics\r\n /**\r\n * Creates a new submesh from indices data\r\n * @param materialIndex the index of the main mesh material\r\n * @param startIndex the index where to start the copy in the mesh indices array\r\n * @param indexCount the number of indices to copy then from the startIndex\r\n * @param mesh the main mesh to create the submesh from\r\n * @param renderingMesh the optional rendering mesh\r\n * @param createBoundingBox defines if bounding box should be created for this submesh\r\n * @returns a new submesh\r\n */\r\n public static CreateFromIndices(\r\n materialIndex: number,\r\n startIndex: number,\r\n indexCount: number,\r\n mesh: AbstractMesh,\r\n renderingMesh?: Mesh,\r\n createBoundingBox: boolean = true\r\n ): SubMesh {\r\n let minVertexIndex = Number.MAX_VALUE;\r\n let maxVertexIndex = -Number.MAX_VALUE;\r\n\r\n const whatWillRender = renderingMesh || mesh;\r\n const indices = whatWillRender!.getIndices()!;\r\n\r\n for (let index = startIndex; index < startIndex + indexCount; index++) {\r\n const vertexIndex = indices[index];\r\n\r\n if (vertexIndex < minVertexIndex) {\r\n minVertexIndex = vertexIndex;\r\n }\r\n if (vertexIndex > maxVertexIndex) {\r\n maxVertexIndex = vertexIndex;\r\n }\r\n }\r\n\r\n return new SubMesh(materialIndex, minVertexIndex, maxVertexIndex - minVertexIndex + 1, startIndex, indexCount, mesh, renderingMesh, createBoundingBox);\r\n }\r\n}\r\n"]}
1
+ {"version":3,"file":"subMesh.js","sourceRoot":"","sources":["../../../../dev/core/src/Meshes/subMesh.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,YAAY,EAAE,MAAM,mBAAmB,CAAC;AACjD,OAAO,EAAE,gBAAgB,EAAE,MAAM,gCAAgC,CAAC;AAElE,OAAO,EAAE,YAAY,EAAE,MAAM,yBAAyB,CAAC;AAEvD,OAAO,EAAE,SAAS,EAAE,MAAM,sBAAsB,CAAC;AAEjD,OAAO,EAAE,uBAAuB,EAAE,MAAM,yBAAyB,CAAC;AAElE,OAAO,EAAE,WAAW,EAAE,MAAM,0BAA0B,CAAC;AAavD;;GAEG;AACH,MAAM,OAAO,OAAO;IAMhB;;OAEG;IACH,IAAW,eAAe;QACtB,OAAO,IAAI,CAAC,wBAAwB,CAAC,CAAC,CAAE,IAAI,CAAC,wBAAwB,CAAC,OAA2B,CAAC,CAAC,CAAE,IAAI,CAAC,eAAe,EAAE,EAAE,OAAqC,CAAC;IACvK,CAAC;IAED;;OAEG;IACH,IAAW,eAAe,CAAC,OAAkC;QACzD,MAAM,WAAW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CAAC,SAAS,EAAE,SAAS,CAAC,CAAC;IAC9C,CAAC;IAED;;;OAGG;IACI,YAAY;QACf,OAAO,SAAS,CAAC;IACrB,CAAC;IAED,UAAU;IACV;;;;;;;;;OASG;IACI,MAAM,CAAC,iBAAiB,CAC3B,aAAqB,EACrB,UAAkB,EAClB,UAAkB,EAClB,IAAkB,EAClB,aAAoB,EACpB,oBAA6B,IAAI;QAEjC,IAAI,cAAc,GAAG,MAAM,CAAC,SAAS,CAAC;QACtC,IAAI,cAAc,GAAG,CAAC,MAAM,CAAC,SAAS,CAAC;QAEvC,MAAM,cAAc,GAAG,aAAa,IAAI,IAAI,CAAC;QAC7C,MAAM,OAAO,GAAG,cAAe,CAAC,UAAU,EAAG,CAAC;QAE9C,KAAK,IAAI,KAAK,GAAG,UAAU,EAAE,KAAK,GAAG,UAAU,GAAG,UAAU,EAAE,KAAK,EAAE,EAAE,CAAC;YACpE,MAAM,WAAW,GAAG,OAAO,CAAC,KAAK,CAAC,CAAC;YAEnC,IAAI,WAAW,GAAG,cAAc,EAAE,CAAC;gBAC/B,cAAc,GAAG,WAAW,CAAC;YACjC,CAAC;YACD,IAAI,WAAW,GAAG,cAAc,EAAE,CAAC;gBAC/B,cAAc,GAAG,WAAW,CAAC;YACjC,CAAC;QACL,CAAC;QAED,OAAO,IAAI,OAAO,CAAC,aAAa,EAAE,cAAc,EAAE,cAAc,GAAG,cAAc,GAAG,CAAC,EAAE,UAAU,EAAE,UAAU,EAAE,IAAI,EAAE,aAAa,EAAE,iBAAiB,CAAC,CAAC;IAC3J,CAAC;CACJ","sourcesContent":["import type { Nullable, IndicesArray, DeepImmutable, FloatArray } from \"../types\";\r\nimport type { Matrix, Vector3 } from \"../Maths/math.vector\";\r\nimport { VertexBuffer } from \"../Buffers/buffer\";\r\nimport { IntersectionInfo } from \"../Collisions/intersectionInfo\";\r\nimport type { ICullable } from \"../Culling/boundingInfo\";\r\nimport { BoundingInfo } from \"../Culling/boundingInfo\";\r\nimport type { Effect } from \"../Materials/effect\";\r\nimport { Constants } from \"../Engines/constants\";\r\nimport type { DataBuffer } from \"../Buffers/dataBuffer\";\r\nimport { extractMinAndMaxIndexed } from \"../Maths/math.functions\";\r\nimport type { Plane } from \"../Maths/math.plane\";\r\nimport { DrawWrapper } from \"../Materials/drawWrapper\";\r\nimport type { IMaterialContext } from \"../Engines/IMaterialContext\";\r\n\r\nimport type { Collider } from \"../Collisions/collider\";\r\nimport type { Material } from \"../Materials/material\";\r\nimport type { MaterialDefines } from \"../Materials/materialDefines\";\r\nimport type { MultiMaterial } from \"../Materials/multiMaterial\";\r\nimport type { AbstractMesh } from \"./abstractMesh\";\r\nimport type { Mesh } from \"./mesh\";\r\nimport type { Ray } from \"../Culling/ray\";\r\nimport type { TrianglePickingPredicate } from \"../Culling/ray\";\r\nimport type { AbstractEngine } from \"core/Engines/abstractEngine\";\r\n\r\n/**\r\n * Defines a subdivision inside a mesh\r\n */\r\nexport class SubMesh implements ICullable {\r\n private _engine: AbstractEngine;\r\n /** @internal */\r\n public _drawWrappers: Array<DrawWrapper>; // index in this array = pass id\r\n private _mainDrawWrapperOverride: Nullable<DrawWrapper> = null;\r\n\r\n /**\r\n * Gets material defines used by the effect associated to the sub mesh\r\n */\r\n public get materialDefines(): Nullable<MaterialDefines> {\r\n return this._mainDrawWrapperOverride ? (this._mainDrawWrapperOverride.defines as MaterialDefines) : (this._getDrawWrapper()?.defines as Nullable<MaterialDefines>);\r\n }\r\n\r\n /**\r\n * Sets material defines used by the effect associated to the sub mesh\r\n */\r\n public set materialDefines(defines: Nullable<MaterialDefines>) {\r\n const drawWrapper = this._mainDrawWrapperOverride ?? this._getDrawWrapper(undefined, true)!;\r\n drawWrapper.defines = defines;\r\n }\r\n\r\n /**\r\n * @internal\r\n */\r\n public _getDrawWrapper(passId?: number, createIfNotExisting = false): DrawWrapper | undefined {\r\n passId = passId ?? this._engine.currentRenderPassId;\r\n let drawWrapper = this._drawWrappers[passId];\r\n if (!drawWrapper && createIfNotExisting) {\r\n this._drawWrappers[passId] = drawWrapper = new DrawWrapper(this._mesh.getScene().getEngine());\r\n }\r\n return drawWrapper;\r\n }\r\n\r\n /**\r\n * @internal\r\n */\r\n public _removeDrawWrapper(passId: number, disposeWrapper = true, immediate = false): void {\r\n if (disposeWrapper) {\r\n this._drawWrappers[passId]?.dispose(immediate);\r\n }\r\n this._drawWrappers[passId] = undefined as any;\r\n }\r\n\r\n /**\r\n * Gets associated (main) effect (possibly the effect override if defined)\r\n */\r\n public get effect(): Nullable<Effect> {\r\n return this._mainDrawWrapperOverride ? this._mainDrawWrapperOverride.effect : (this._getDrawWrapper()?.effect ?? null);\r\n }\r\n\r\n /** @internal */\r\n public get _drawWrapper(): DrawWrapper {\r\n return this._mainDrawWrapperOverride ?? this._getDrawWrapper(undefined, true)!;\r\n }\r\n\r\n /** @internal */\r\n public get _drawWrapperOverride(): Nullable<DrawWrapper> {\r\n return this._mainDrawWrapperOverride;\r\n }\r\n\r\n /**\r\n * @internal\r\n */\r\n public _setMainDrawWrapperOverride(wrapper: Nullable<DrawWrapper>): void {\r\n this._mainDrawWrapperOverride = wrapper;\r\n }\r\n\r\n /**\r\n * Sets associated effect (effect used to render this submesh)\r\n * @param effect defines the effect to associate with\r\n * @param defines defines the set of defines used to compile this effect\r\n * @param materialContext material context associated to the effect\r\n * @param resetContext true to reset the draw context\r\n */\r\n public setEffect(effect: Nullable<Effect>, defines: Nullable<string | MaterialDefines> = null, materialContext?: IMaterialContext, resetContext = true) {\r\n const drawWrapper = this._drawWrapper;\r\n drawWrapper.setEffect(effect, defines, resetContext);\r\n if (materialContext !== undefined) {\r\n drawWrapper.materialContext = materialContext;\r\n }\r\n if (!effect) {\r\n drawWrapper.defines = null;\r\n drawWrapper.materialContext = undefined;\r\n }\r\n }\r\n\r\n /**\r\n * Resets the draw wrappers cache\r\n * @param passId If provided, releases only the draw wrapper corresponding to this render pass id\r\n * @param immediate If true, the draw wrapper will dispose the effect immediately (false by default)\r\n */\r\n public resetDrawCache(passId?: number, immediate = false): void {\r\n if (this._drawWrappers) {\r\n if (passId !== undefined) {\r\n this._removeDrawWrapper(passId, true, immediate);\r\n return;\r\n } else {\r\n for (const drawWrapper of this._drawWrappers) {\r\n drawWrapper?.dispose(immediate);\r\n }\r\n }\r\n }\r\n this._drawWrappers = [];\r\n }\r\n\r\n /** @internal */\r\n public _linesIndexCount: number = 0;\r\n private _mesh: AbstractMesh;\r\n private _renderingMesh: Mesh;\r\n private _boundingInfo: BoundingInfo;\r\n private _linesIndexBuffer: Nullable<DataBuffer> = null;\r\n /** @internal */\r\n public _lastColliderWorldVertices: Nullable<Vector3[]> = null;\r\n /** @internal */\r\n public _trianglePlanes: Plane[];\r\n /** @internal */\r\n public _lastColliderTransformMatrix: Nullable<Matrix> = null;\r\n /** @internal */\r\n public _wasDispatched = false;\r\n\r\n /** @internal */\r\n public _renderId = 0;\r\n /** @internal */\r\n public _alphaIndex: number = 0;\r\n /** @internal */\r\n public _distanceToCamera: number = 0;\r\n /** @internal */\r\n public _id: number;\r\n\r\n private _currentMaterial: Nullable<Material> = null;\r\n\r\n /**\r\n * Add a new submesh to a mesh\r\n * @param materialIndex defines the material index to use\r\n * @param verticesStart defines vertex index start\r\n * @param verticesCount defines vertices count\r\n * @param indexStart defines index start\r\n * @param indexCount defines indices count\r\n * @param mesh defines the parent mesh\r\n * @param renderingMesh defines an optional rendering mesh\r\n * @param createBoundingBox defines if bounding box should be created for this submesh\r\n * @returns the new submesh\r\n */\r\n public static AddToMesh(\r\n materialIndex: number,\r\n verticesStart: number,\r\n verticesCount: number,\r\n indexStart: number,\r\n indexCount: number,\r\n mesh: AbstractMesh,\r\n renderingMesh?: Mesh,\r\n createBoundingBox: boolean = true\r\n ): SubMesh {\r\n return new SubMesh(materialIndex, verticesStart, verticesCount, indexStart, indexCount, mesh, renderingMesh, createBoundingBox);\r\n }\r\n\r\n /**\r\n * Creates a new submesh\r\n * @param materialIndex defines the material index to use\r\n * @param verticesStart defines vertex index start\r\n * @param verticesCount defines vertices count\r\n * @param indexStart defines index start\r\n * @param indexCount defines indices count\r\n * @param mesh defines the parent mesh\r\n * @param renderingMesh defines an optional rendering mesh\r\n * @param createBoundingBox defines if bounding box should be created for this submesh\r\n * @param addToMesh defines a boolean indicating that the submesh must be added to the mesh.subMeshes array (true by default)\r\n */\r\n constructor(\r\n /** the material index to use */\r\n public materialIndex: number,\r\n /** vertex index start */\r\n public verticesStart: number,\r\n /** vertices count */\r\n public verticesCount: number,\r\n /** index start */\r\n public indexStart: number,\r\n /** indices count */\r\n public indexCount: number,\r\n mesh: AbstractMesh,\r\n renderingMesh?: Mesh,\r\n createBoundingBox: boolean = true,\r\n addToMesh = true\r\n ) {\r\n this._mesh = mesh;\r\n this._renderingMesh = renderingMesh || <Mesh>mesh;\r\n if (addToMesh) {\r\n mesh.subMeshes.push(this);\r\n }\r\n\r\n this._engine = this._mesh.getScene().getEngine();\r\n this.resetDrawCache();\r\n this._trianglePlanes = [];\r\n\r\n this._id = mesh.subMeshes.length - 1;\r\n\r\n if (createBoundingBox) {\r\n this.refreshBoundingInfo();\r\n mesh.computeWorldMatrix(true);\r\n }\r\n }\r\n\r\n /**\r\n * Returns true if this submesh covers the entire parent mesh\r\n * @ignorenaming\r\n */\r\n // eslint-disable-next-line @typescript-eslint/naming-convention\r\n public get IsGlobal(): boolean {\r\n return this.verticesStart === 0 && this.verticesCount === this._mesh.getTotalVertices() && this.indexStart === 0 && this.indexCount === this._mesh.getTotalIndices();\r\n }\r\n\r\n /**\r\n * Returns the submesh BoundingInfo object\r\n * @returns current bounding info (or mesh's one if the submesh is global)\r\n */\r\n public getBoundingInfo(): BoundingInfo {\r\n if (this.IsGlobal || this._mesh.hasThinInstances) {\r\n return this._mesh.getBoundingInfo();\r\n }\r\n\r\n return this._boundingInfo;\r\n }\r\n\r\n /**\r\n * Sets the submesh BoundingInfo\r\n * @param boundingInfo defines the new bounding info to use\r\n * @returns the SubMesh\r\n */\r\n public setBoundingInfo(boundingInfo: BoundingInfo): SubMesh {\r\n this._boundingInfo = boundingInfo;\r\n return this;\r\n }\r\n\r\n /**\r\n * Returns the mesh of the current submesh\r\n * @returns the parent mesh\r\n */\r\n public getMesh(): AbstractMesh {\r\n return this._mesh;\r\n }\r\n\r\n /**\r\n * Returns the rendering mesh of the submesh\r\n * @returns the rendering mesh (could be different from parent mesh)\r\n */\r\n public getRenderingMesh(): Mesh {\r\n return this._renderingMesh;\r\n }\r\n\r\n /**\r\n * Returns the replacement mesh of the submesh\r\n * @returns the replacement mesh (could be different from parent mesh)\r\n */\r\n public getReplacementMesh(): Nullable<AbstractMesh> {\r\n return this._mesh._internalAbstractMeshDataInfo._actAsRegularMesh ? this._mesh : null;\r\n }\r\n\r\n /**\r\n * Returns the effective mesh of the submesh\r\n * @returns the effective mesh (could be different from parent mesh)\r\n */\r\n public getEffectiveMesh(): AbstractMesh {\r\n const replacementMesh = this._mesh._internalAbstractMeshDataInfo._actAsRegularMesh ? this._mesh : null;\r\n\r\n return replacementMesh ? replacementMesh : this._renderingMesh;\r\n }\r\n\r\n /**\r\n * Returns the submesh material\r\n * @param getDefaultMaterial Defines whether or not to get the default material if nothing has been defined.\r\n * @returns null or the current material\r\n */\r\n public getMaterial(getDefaultMaterial = true): Nullable<Material> {\r\n const rootMaterial = this._renderingMesh.getMaterialForRenderPass(this._engine.currentRenderPassId) ?? this._renderingMesh.material;\r\n\r\n if (!rootMaterial) {\r\n return getDefaultMaterial && this._mesh.getScene()._hasDefaultMaterial ? this._mesh.getScene().defaultMaterial : null;\r\n } else if (this._isMultiMaterial(rootMaterial)) {\r\n const effectiveMaterial = rootMaterial.getSubMaterial(this.materialIndex);\r\n\r\n if (this._currentMaterial !== effectiveMaterial) {\r\n this._currentMaterial = effectiveMaterial;\r\n this.resetDrawCache();\r\n }\r\n\r\n return effectiveMaterial;\r\n }\r\n\r\n return rootMaterial;\r\n }\r\n\r\n private _isMultiMaterial(material: Material): material is MultiMaterial {\r\n return (material as MultiMaterial).getSubMaterial !== undefined;\r\n }\r\n\r\n // Methods\r\n\r\n /**\r\n * Sets a new updated BoundingInfo object to the submesh\r\n * @param data defines an optional position array to use to determine the bounding info\r\n * @returns the SubMesh\r\n */\r\n public refreshBoundingInfo(data: Nullable<FloatArray> = null): SubMesh {\r\n this._lastColliderWorldVertices = null;\r\n\r\n if (this.IsGlobal || !this._renderingMesh || !this._renderingMesh.geometry) {\r\n return this;\r\n }\r\n\r\n if (!data) {\r\n data = this._renderingMesh.getVerticesData(VertexBuffer.PositionKind);\r\n }\r\n\r\n if (!data) {\r\n this._boundingInfo = this._mesh.getBoundingInfo();\r\n return this;\r\n }\r\n\r\n const indices = <IndicesArray>this._renderingMesh.getIndices();\r\n let extend: { minimum: Vector3; maximum: Vector3 };\r\n\r\n //is this the only submesh?\r\n if (this.indexStart === 0 && this.indexCount === indices.length) {\r\n const boundingInfo = this._renderingMesh.getBoundingInfo();\r\n\r\n //the rendering mesh's bounding info can be used, it is the standard submesh for all indices.\r\n extend = { minimum: boundingInfo.minimum.clone(), maximum: boundingInfo.maximum.clone() };\r\n } else {\r\n extend = extractMinAndMaxIndexed(data, indices, this.indexStart, this.indexCount, this._renderingMesh.geometry.boundingBias);\r\n }\r\n\r\n if (this._boundingInfo) {\r\n this._boundingInfo.reConstruct(extend.minimum, extend.maximum);\r\n } else {\r\n this._boundingInfo = new BoundingInfo(extend.minimum, extend.maximum);\r\n }\r\n return this;\r\n }\r\n\r\n /**\r\n * @internal\r\n */\r\n public _checkCollision(collider: Collider): boolean {\r\n const boundingInfo = this.getBoundingInfo();\r\n\r\n return boundingInfo._checkCollision(collider);\r\n }\r\n\r\n /**\r\n * Updates the submesh BoundingInfo\r\n * @param world defines the world matrix to use to update the bounding info\r\n * @returns the submesh\r\n */\r\n public updateBoundingInfo(world: DeepImmutable<Matrix>): SubMesh {\r\n let boundingInfo = this.getBoundingInfo();\r\n\r\n if (!boundingInfo) {\r\n this.refreshBoundingInfo();\r\n boundingInfo = this.getBoundingInfo();\r\n }\r\n if (boundingInfo) {\r\n (<BoundingInfo>boundingInfo).update(world);\r\n }\r\n return this;\r\n }\r\n\r\n /**\r\n * True is the submesh bounding box intersects the frustum defined by the passed array of planes.\r\n * @param frustumPlanes defines the frustum planes\r\n * @returns true if the submesh is intersecting with the frustum\r\n */\r\n public isInFrustum(frustumPlanes: Plane[]): boolean {\r\n const boundingInfo = this.getBoundingInfo();\r\n\r\n if (!boundingInfo) {\r\n return false;\r\n }\r\n return boundingInfo.isInFrustum(frustumPlanes, this._mesh.cullingStrategy);\r\n }\r\n\r\n /**\r\n * True is the submesh bounding box is completely inside the frustum defined by the passed array of planes\r\n * @param frustumPlanes defines the frustum planes\r\n * @returns true if the submesh is inside the frustum\r\n */\r\n public isCompletelyInFrustum(frustumPlanes: Plane[]): boolean {\r\n const boundingInfo = this.getBoundingInfo();\r\n\r\n if (!boundingInfo) {\r\n return false;\r\n }\r\n return boundingInfo.isCompletelyInFrustum(frustumPlanes);\r\n }\r\n\r\n /**\r\n * Renders the submesh\r\n * @param enableAlphaMode defines if alpha needs to be used\r\n * @returns the submesh\r\n */\r\n public render(enableAlphaMode: boolean): SubMesh {\r\n this._renderingMesh.render(this, enableAlphaMode, this._mesh._internalAbstractMeshDataInfo._actAsRegularMesh ? this._mesh : undefined);\r\n return this;\r\n }\r\n\r\n /**\r\n * @internal\r\n */\r\n public _getLinesIndexBuffer(indices: IndicesArray, engine: AbstractEngine): DataBuffer {\r\n if (!this._linesIndexBuffer) {\r\n const adjustedIndexCount = Math.floor(this.indexCount / 3) * 6;\r\n const shouldUseUint32 = this.verticesStart + this.verticesCount > 65535;\r\n const linesIndices = shouldUseUint32 ? new Uint32Array(adjustedIndexCount) : new Uint16Array(adjustedIndexCount);\r\n\r\n let offset = 0;\r\n if (indices.length === 0) {\r\n // Unindexed mesh\r\n for (let index = this.indexStart; index < this.indexStart + this.indexCount; index += 3) {\r\n linesIndices[offset++] = index;\r\n linesIndices[offset++] = index + 1;\r\n linesIndices[offset++] = index + 1;\r\n linesIndices[offset++] = index + 2;\r\n linesIndices[offset++] = index + 2;\r\n linesIndices[offset++] = index;\r\n }\r\n } else {\r\n for (let index = this.indexStart; index < this.indexStart + this.indexCount; index += 3) {\r\n linesIndices[offset++] = indices[index];\r\n linesIndices[offset++] = indices[index + 1];\r\n linesIndices[offset++] = indices[index + 1];\r\n linesIndices[offset++] = indices[index + 2];\r\n linesIndices[offset++] = indices[index + 2];\r\n linesIndices[offset++] = indices[index];\r\n }\r\n }\r\n\r\n this._linesIndexBuffer = engine.createIndexBuffer(linesIndices);\r\n this._linesIndexCount = linesIndices.length;\r\n }\r\n return this._linesIndexBuffer;\r\n }\r\n\r\n /**\r\n * Checks if the submesh intersects with a ray\r\n * @param ray defines the ray to test\r\n * @returns true is the passed ray intersects the submesh bounding box\r\n */\r\n public canIntersects(ray: Ray): boolean {\r\n const boundingInfo = this.getBoundingInfo();\r\n\r\n if (!boundingInfo) {\r\n return false;\r\n }\r\n return ray.intersectsBox(boundingInfo.boundingBox);\r\n }\r\n\r\n /**\r\n * Intersects current submesh with a ray\r\n * @param ray defines the ray to test\r\n * @param positions defines mesh's positions array\r\n * @param indices defines mesh's indices array\r\n * @param fastCheck defines if the first intersection will be used (and not the closest)\r\n * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected\r\n * @returns intersection info or null if no intersection\r\n */\r\n public intersects(ray: Ray, positions: Vector3[], indices: IndicesArray, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<IntersectionInfo> {\r\n const material = this.getMaterial();\r\n if (!material) {\r\n return null;\r\n }\r\n let step = 3;\r\n let checkStopper = false;\r\n\r\n switch (material.fillMode) {\r\n case Constants.MATERIAL_PointListDrawMode:\r\n case Constants.MATERIAL_LineLoopDrawMode:\r\n case Constants.MATERIAL_LineStripDrawMode:\r\n case Constants.MATERIAL_TriangleFanDrawMode:\r\n return null;\r\n case Constants.MATERIAL_TriangleStripDrawMode:\r\n step = 1;\r\n checkStopper = true;\r\n break;\r\n default:\r\n break;\r\n }\r\n\r\n // LineMesh first as it's also a Mesh...\r\n if (material.fillMode === Constants.MATERIAL_LineListDrawMode) {\r\n // Check if mesh is unindexed\r\n if (!indices.length) {\r\n return this._intersectUnIndexedLines(ray, positions, indices, (this._mesh as any).intersectionThreshold, fastCheck);\r\n }\r\n return this._intersectLines(ray, positions, indices, (this._mesh as any).intersectionThreshold, fastCheck);\r\n } else {\r\n // Check if mesh is unindexed\r\n if (!indices.length && this._mesh._unIndexed) {\r\n return this._intersectUnIndexedTriangles(ray, positions, indices, fastCheck, trianglePredicate);\r\n }\r\n\r\n return this._intersectTriangles(ray, positions, indices, step, checkStopper, fastCheck, trianglePredicate);\r\n }\r\n }\r\n\r\n /**\r\n * @internal\r\n */\r\n private _intersectLines(ray: Ray, positions: Vector3[], indices: IndicesArray, intersectionThreshold: number, fastCheck?: boolean): Nullable<IntersectionInfo> {\r\n let intersectInfo: Nullable<IntersectionInfo> = null;\r\n\r\n // Line test\r\n for (let index = this.indexStart; index < this.indexStart + this.indexCount; index += 2) {\r\n const p0 = positions[indices[index]];\r\n const p1 = positions[indices[index + 1]];\r\n\r\n const length = ray.intersectionSegment(p0, p1, intersectionThreshold);\r\n if (length < 0) {\r\n continue;\r\n }\r\n\r\n if (fastCheck || !intersectInfo || length < intersectInfo.distance) {\r\n intersectInfo = new IntersectionInfo(null, null, length);\r\n intersectInfo.faceId = index / 2;\r\n if (fastCheck) {\r\n break;\r\n }\r\n }\r\n }\r\n return intersectInfo;\r\n }\r\n\r\n /**\r\n * @internal\r\n */\r\n private _intersectUnIndexedLines(ray: Ray, positions: Vector3[], indices: IndicesArray, intersectionThreshold: number, fastCheck?: boolean): Nullable<IntersectionInfo> {\r\n let intersectInfo: Nullable<IntersectionInfo> = null;\r\n\r\n // Line test\r\n for (let index = this.verticesStart; index < this.verticesStart + this.verticesCount; index += 2) {\r\n const p0 = positions[index];\r\n const p1 = positions[index + 1];\r\n\r\n const length = ray.intersectionSegment(p0, p1, intersectionThreshold);\r\n if (length < 0) {\r\n continue;\r\n }\r\n\r\n if (fastCheck || !intersectInfo || length < intersectInfo.distance) {\r\n intersectInfo = new IntersectionInfo(null, null, length);\r\n intersectInfo.faceId = index / 2;\r\n if (fastCheck) {\r\n break;\r\n }\r\n }\r\n }\r\n\r\n return intersectInfo;\r\n }\r\n\r\n /**\r\n * @internal\r\n */\r\n private _intersectTriangles(\r\n ray: Ray,\r\n positions: Vector3[],\r\n indices: IndicesArray,\r\n step: number,\r\n checkStopper: boolean,\r\n fastCheck?: boolean,\r\n trianglePredicate?: TrianglePickingPredicate\r\n ): Nullable<IntersectionInfo> {\r\n let intersectInfo: Nullable<IntersectionInfo> = null;\r\n\r\n // Triangles test\r\n let faceId = -1;\r\n for (let index = this.indexStart; index < this.indexStart + this.indexCount - (3 - step); index += step) {\r\n faceId++;\r\n const indexA = indices[index];\r\n const indexB = indices[index + 1];\r\n const indexC = indices[index + 2];\r\n\r\n if (checkStopper && indexC === 0xffffffff) {\r\n index += 2;\r\n continue;\r\n }\r\n\r\n const p0 = positions[indexA];\r\n const p1 = positions[indexB];\r\n const p2 = positions[indexC];\r\n\r\n // stay defensive and don't check against undefined positions.\r\n if (!p0 || !p1 || !p2) {\r\n continue;\r\n }\r\n\r\n if (trianglePredicate && !trianglePredicate(p0, p1, p2, ray, indexA, indexB, indexC)) {\r\n continue;\r\n }\r\n\r\n const currentIntersectInfo = ray.intersectsTriangle(p0, p1, p2);\r\n\r\n if (currentIntersectInfo) {\r\n if (currentIntersectInfo.distance < 0) {\r\n continue;\r\n }\r\n\r\n if (fastCheck || !intersectInfo || currentIntersectInfo.distance < intersectInfo.distance) {\r\n intersectInfo = currentIntersectInfo;\r\n intersectInfo.faceId = faceId;\r\n\r\n if (fastCheck) {\r\n break;\r\n }\r\n }\r\n }\r\n }\r\n return intersectInfo;\r\n }\r\n\r\n /**\r\n * @internal\r\n */\r\n private _intersectUnIndexedTriangles(\r\n ray: Ray,\r\n positions: Vector3[],\r\n indices: IndicesArray,\r\n fastCheck?: boolean,\r\n trianglePredicate?: TrianglePickingPredicate\r\n ): Nullable<IntersectionInfo> {\r\n let intersectInfo: Nullable<IntersectionInfo> = null;\r\n // Triangles test\r\n for (let index = this.verticesStart; index < this.verticesStart + this.verticesCount; index += 3) {\r\n const p0 = positions[index];\r\n const p1 = positions[index + 1];\r\n const p2 = positions[index + 2];\r\n\r\n if (trianglePredicate && !trianglePredicate(p0, p1, p2, ray, -1, -1, -1)) {\r\n continue;\r\n }\r\n\r\n const currentIntersectInfo = ray.intersectsTriangle(p0, p1, p2);\r\n\r\n if (currentIntersectInfo) {\r\n if (currentIntersectInfo.distance < 0) {\r\n continue;\r\n }\r\n\r\n if (fastCheck || !intersectInfo || currentIntersectInfo.distance < intersectInfo.distance) {\r\n intersectInfo = currentIntersectInfo;\r\n intersectInfo.faceId = index / 3;\r\n\r\n if (fastCheck) {\r\n break;\r\n }\r\n }\r\n }\r\n }\r\n return intersectInfo;\r\n }\r\n\r\n /** @internal */\r\n public _rebuild(): void {\r\n if (this._linesIndexBuffer) {\r\n this._linesIndexBuffer = null;\r\n }\r\n }\r\n\r\n // Clone\r\n /**\r\n * Creates a new submesh from the passed mesh\r\n * @param newMesh defines the new hosting mesh\r\n * @param newRenderingMesh defines an optional rendering mesh\r\n * @returns the new submesh\r\n */\r\n public clone(newMesh: AbstractMesh, newRenderingMesh?: Mesh): SubMesh {\r\n const result = new SubMesh(this.materialIndex, this.verticesStart, this.verticesCount, this.indexStart, this.indexCount, newMesh, newRenderingMesh, false);\r\n\r\n if (!this.IsGlobal) {\r\n const boundingInfo = this.getBoundingInfo();\r\n\r\n if (!boundingInfo) {\r\n return result;\r\n }\r\n\r\n result._boundingInfo = new BoundingInfo(boundingInfo.minimum, boundingInfo.maximum);\r\n }\r\n\r\n return result;\r\n }\r\n\r\n // Dispose\r\n\r\n /**\r\n * Release associated resources\r\n * @param immediate If true, the effect will be disposed immediately (false by default)\r\n */\r\n public dispose(immediate = false): void {\r\n if (this._linesIndexBuffer) {\r\n this._mesh.getScene().getEngine()._releaseBuffer(this._linesIndexBuffer);\r\n this._linesIndexBuffer = null;\r\n }\r\n\r\n // Remove from mesh\r\n const index = this._mesh.subMeshes.indexOf(this);\r\n this._mesh.subMeshes.splice(index, 1);\r\n\r\n this.resetDrawCache(undefined, immediate);\r\n }\r\n\r\n /**\r\n * Gets the class name\r\n * @returns the string \"SubMesh\".\r\n */\r\n public getClassName(): string {\r\n return \"SubMesh\";\r\n }\r\n\r\n // Statics\r\n /**\r\n * Creates a new submesh from indices data\r\n * @param materialIndex the index of the main mesh material\r\n * @param startIndex the index where to start the copy in the mesh indices array\r\n * @param indexCount the number of indices to copy then from the startIndex\r\n * @param mesh the main mesh to create the submesh from\r\n * @param renderingMesh the optional rendering mesh\r\n * @param createBoundingBox defines if bounding box should be created for this submesh\r\n * @returns a new submesh\r\n */\r\n public static CreateFromIndices(\r\n materialIndex: number,\r\n startIndex: number,\r\n indexCount: number,\r\n mesh: AbstractMesh,\r\n renderingMesh?: Mesh,\r\n createBoundingBox: boolean = true\r\n ): SubMesh {\r\n let minVertexIndex = Number.MAX_VALUE;\r\n let maxVertexIndex = -Number.MAX_VALUE;\r\n\r\n const whatWillRender = renderingMesh || mesh;\r\n const indices = whatWillRender!.getIndices()!;\r\n\r\n for (let index = startIndex; index < startIndex + indexCount; index++) {\r\n const vertexIndex = indices[index];\r\n\r\n if (vertexIndex < minVertexIndex) {\r\n minVertexIndex = vertexIndex;\r\n }\r\n if (vertexIndex > maxVertexIndex) {\r\n maxVertexIndex = vertexIndex;\r\n }\r\n }\r\n\r\n return new SubMesh(materialIndex, minVertexIndex, maxVertexIndex - minVertexIndex + 1, startIndex, indexCount, mesh, renderingMesh, createBoundingBox);\r\n }\r\n}\r\n"]}
@@ -36,6 +36,7 @@ export interface CharacterSurfaceInfo {
36
36
  * Indicates whether the surface is dynamic.
37
37
  * A dynamic surface is one that can change its properties over time,
38
38
  * such as moving platforms or surfaces that can be affected by external forces.
39
+ * surfaceInfo.supportedState is always CharacterSupportedState.SUPPORTED when isSurfaceDynamic is true.
39
40
  */
40
41
  isSurfaceDynamic: boolean;
41
42
  /**
@@ -259,7 +260,7 @@ export declare class PhysicsCharacterController {
259
260
  private _getPointVelocityToRef;
260
261
  protected _compareContacts(contactA: Contact, contactB: Contact): number;
261
262
  protected _findContact(referenceContact: Contact, contactList: Contact[], threshold: number): number;
262
- _updateManifold(startCollector: any, castCollector: any, castPath: Vector3): number;
263
+ protected _updateManifold(startCollector: any, castCollector: any, castPath: Vector3): number;
263
264
  protected _createSurfaceConstraint(contact: Contact, timeTravelled: number): SurfaceConstraintInfo;
264
265
  protected _addMaxSlopePlane(maxSlopeCos: number, up: Vector3, index: number, constraints: SurfaceConstraintInfo[], allowedPenetration: number): boolean;
265
266
  protected _resolveConstraintPenetration(constraint: SurfaceConstraintInfo, penetrationRecoverySpeed: number): void;
@@ -270,7 +271,7 @@ export declare class PhysicsCharacterController {
270
271
  protected _simplexSolverSolve2d(info: SimplexSolverInfo, maxSurfaceVelocity: Vector3, sci0: SurfaceConstraintInfo, sci1: SurfaceConstraintInfo, velocityIn: Vector3, velocityOut: Vector3): void;
271
272
  protected _simplexSolverSolve3d(info: SimplexSolverInfo, maxSurfaceVelocity: Vector3, sci0: SurfaceConstraintInfo, sci1: SurfaceConstraintInfo, sci2: SurfaceConstraintInfo, allowResort: boolean, velocityIn: Vector3, velocityOut: Vector3): void;
272
273
  protected _simplexSolverExamineActivePlanes(info: SimplexSolverInfo, maxSurfaceVelocity: Vector3, velocityIn: Vector3, velocityOut: Vector3): void;
273
- _simplexSolverSolve(constraints: SurfaceConstraintInfo[], velocity: Vector3, deltaTime: number, minDeltaTime: number, up: Vector3, maxSurfaceVelocity: Vector3): SimplexSolverOutput;
274
+ protected _simplexSolverSolve(constraints: SurfaceConstraintInfo[], velocity: Vector3, deltaTime: number, minDeltaTime: number, up: Vector3, maxSurfaceVelocity: Vector3): SimplexSolverOutput;
274
275
  /**
275
276
  * Compute a CharacterSurfaceInfo from current state and a direction
276
277
  * @param deltaTime frame delta time in seconds. When using scene.deltaTime divide by 1000.0
@@ -896,6 +896,7 @@ export class PhysicsCharacterController {
896
896
  surfaceInfo.averageSurfaceVelocity.setAll(0);
897
897
  surfaceInfo.averageAngularSurfaceVelocity.setAll(0);
898
898
  surfaceInfo.averageSurfaceNormal.setAll(0);
899
+ surfaceInfo.isSurfaceDynamic = false;
899
900
  // If the constraints did not affect the character movement then it is unsupported and we can finish
900
901
  if (output.velocity.equalsWithEpsilon(direction, eps)) {
901
902
  surfaceInfo.supportedState = 0 /* CharacterSupportedState.UNSUPPORTED */;
@@ -931,6 +932,17 @@ export class PhysicsCharacterController {
931
932
  surfaceInfo.averageSurfaceVelocity.scaleInPlace(1 / numTouching);
932
933
  surfaceInfo.averageAngularSurfaceVelocity.scaleInPlace(1 / numTouching);
933
934
  }
935
+ // isSurfaceDynamic update
936
+ if (surfaceInfo.supportedState == 2 /* CharacterSupportedState.SUPPORTED */) {
937
+ for (let i = 0; i < this._manifold.length; i++) {
938
+ const manifold = this._manifold[i];
939
+ const bodyB = manifold.bodyB;
940
+ if (this._manifold[i].normal.dot(direction) < -0.08 && bodyB.body.getMotionType(0) == 2 /* PhysicsMotionType.DYNAMIC */) {
941
+ surfaceInfo.isSurfaceDynamic = true;
942
+ break;
943
+ }
944
+ }
945
+ }
934
946
  }
935
947
  _castWithCollectors(startPos, endPos, castCollector /*HP_CollectorId*/, startCollector /*HP_CollectorId*/) {
936
948
  const hk = this._scene.getPhysicsEngine().getPhysicsPlugin();