@babylonjs/core 6.22.0 → 6.23.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (98) hide show
  1. package/Animations/animationGroup.d.ts +1 -0
  2. package/Animations/animationGroup.js +5 -1
  3. package/Animations/animationGroup.js.map +1 -1
  4. package/Behaviors/Meshes/pointerDragBehavior.d.ts +4 -3
  5. package/Behaviors/Meshes/pointerDragBehavior.js +4 -3
  6. package/Behaviors/Meshes/pointerDragBehavior.js.map +1 -1
  7. package/Cameras/arcRotateCamera.js +8 -2
  8. package/Cameras/arcRotateCamera.js.map +1 -1
  9. package/Engines/WebGPU/webgpuCacheRenderPipeline.js +2 -2
  10. package/Engines/WebGPU/webgpuCacheRenderPipeline.js.map +1 -1
  11. package/Engines/WebGPU/webgpuConstants.d.ts +5 -4
  12. package/Engines/WebGPU/webgpuConstants.js +15 -15
  13. package/Engines/WebGPU/webgpuConstants.js.map +1 -1
  14. package/Engines/WebGPU/webgpuTextureHelper.d.ts +1 -0
  15. package/Engines/WebGPU/webgpuTextureHelper.js +27 -31
  16. package/Engines/WebGPU/webgpuTextureHelper.js.map +1 -1
  17. package/Engines/engine.d.ts +32 -32
  18. package/Engines/thinEngine.js +2 -2
  19. package/Engines/thinEngine.js.map +1 -1
  20. package/FlowGraph/Blocks/Event/flowGraphReceiveCustomEventBlock.js +2 -2
  21. package/FlowGraph/Blocks/Event/flowGraphReceiveCustomEventBlock.js.map +1 -1
  22. package/FlowGraph/Blocks/Execution/ControlFlow/{flowGraphConditionalBlock.js → flowGraphBranchBlock.js} +1 -1
  23. package/FlowGraph/Blocks/Execution/ControlFlow/flowGraphBranchBlock.js.map +1 -0
  24. package/FlowGraph/Blocks/Execution/ControlFlow/index.d.ts +1 -1
  25. package/FlowGraph/Blocks/Execution/ControlFlow/index.js +1 -1
  26. package/FlowGraph/Blocks/Execution/ControlFlow/index.js.map +1 -1
  27. package/FlowGraph/Blocks/Execution/flowGraphCustomFunctionBlock.d.ts +23 -0
  28. package/FlowGraph/Blocks/Execution/flowGraphCustomFunctionBlock.js +18 -0
  29. package/FlowGraph/Blocks/Execution/flowGraphCustomFunctionBlock.js.map +1 -0
  30. package/Gizmos/boundingBoxGizmo.js +13 -11
  31. package/Gizmos/boundingBoxGizmo.js.map +1 -1
  32. package/Gizmos/gizmo.js +3 -1
  33. package/Gizmos/gizmo.js.map +1 -1
  34. package/Gizmos/planeRotationGizmo.js +5 -0
  35. package/Gizmos/planeRotationGizmo.js.map +1 -1
  36. package/Gizmos/positionGizmo.d.ts +4 -0
  37. package/Gizmos/positionGizmo.js +6 -0
  38. package/Gizmos/positionGizmo.js.map +1 -1
  39. package/Gizmos/rotationGizmo.d.ts +4 -0
  40. package/Gizmos/rotationGizmo.js +6 -0
  41. package/Gizmos/rotationGizmo.js.map +1 -1
  42. package/Gizmos/scaleGizmo.d.ts +4 -0
  43. package/Gizmos/scaleGizmo.js +6 -0
  44. package/Gizmos/scaleGizmo.js.map +1 -1
  45. package/Materials/Textures/Procedurals/proceduralTexture.d.ts +4 -1
  46. package/Materials/Textures/Procedurals/proceduralTexture.js +10 -8
  47. package/Materials/Textures/Procedurals/proceduralTexture.js.map +1 -1
  48. package/Materials/uniformBuffer.js +1 -1
  49. package/Materials/uniformBuffer.js.map +1 -1
  50. package/Maths/math.vector.js +3 -3
  51. package/Maths/math.vector.js.map +1 -1
  52. package/Meshes/Node/Blocks/Instances/instantiateOnVolumeBlock.d.ts +4 -4
  53. package/Meshes/Node/Blocks/Instances/instantiateOnVolumeBlock.js +4 -4
  54. package/Meshes/Node/Blocks/Instances/instantiateOnVolumeBlock.js.map +1 -1
  55. package/Meshes/Node/Blocks/Sources/meshBlock.d.ts +4 -0
  56. package/Meshes/Node/Blocks/Sources/meshBlock.js +18 -0
  57. package/Meshes/Node/Blocks/Sources/meshBlock.js.map +1 -1
  58. package/Meshes/Node/Blocks/booleanGeometryBlock.d.ts +58 -0
  59. package/Meshes/Node/Blocks/booleanGeometryBlock.js +155 -0
  60. package/Meshes/Node/Blocks/booleanGeometryBlock.js.map +1 -0
  61. package/Meshes/Node/Blocks/mergeGeometryBlock.js +0 -2
  62. package/Meshes/Node/Blocks/mergeGeometryBlock.js.map +1 -1
  63. package/Meshes/Node/index.d.ts +1 -0
  64. package/Meshes/Node/index.js +1 -0
  65. package/Meshes/Node/index.js.map +1 -1
  66. package/Meshes/csg.d.ts +169 -1
  67. package/Meshes/csg.js +107 -43
  68. package/Meshes/csg.js.map +1 -1
  69. package/Meshes/mesh.d.ts +10 -0
  70. package/Meshes/mesh.js +33 -0
  71. package/Meshes/mesh.js.map +1 -1
  72. package/Misc/tools.d.ts +0 -1
  73. package/Misc/tools.js +1 -5
  74. package/Misc/tools.js.map +1 -1
  75. package/PostProcesses/RenderPipeline/Pipelines/ssao2RenderingPipeline.js +7 -0
  76. package/PostProcesses/RenderPipeline/Pipelines/ssao2RenderingPipeline.js.map +1 -1
  77. package/PostProcesses/RenderPipeline/Pipelines/ssrRenderingPipeline.js +6 -0
  78. package/PostProcesses/RenderPipeline/Pipelines/ssrRenderingPipeline.js.map +1 -1
  79. package/PostProcesses/screenSpaceCurvaturePostProcess.js +3 -0
  80. package/PostProcesses/screenSpaceCurvaturePostProcess.js.map +1 -1
  81. package/PostProcesses/screenSpaceReflectionPostProcess.js +6 -0
  82. package/PostProcesses/screenSpaceReflectionPostProcess.js.map +1 -1
  83. package/Rendering/depthPeelingRenderer.js +6 -0
  84. package/Rendering/depthPeelingRenderer.js.map +1 -1
  85. package/Rendering/geometryBufferRenderer.d.ts +4 -0
  86. package/Rendering/geometryBufferRenderer.js +7 -0
  87. package/Rendering/geometryBufferRenderer.js.map +1 -1
  88. package/Shaders/ShadersInclude/lightFragment.js +4 -4
  89. package/Shaders/ShadersInclude/lightFragment.js.map +1 -1
  90. package/Shaders/ShadersInclude/shadowsFragmentFunctions.js +41 -42
  91. package/Shaders/ShadersInclude/shadowsFragmentFunctions.js.map +1 -1
  92. package/Shaders/geometry.fragment.js +4 -0
  93. package/Shaders/geometry.fragment.js.map +1 -1
  94. package/Shaders/geometry.vertex.js +4 -0
  95. package/Shaders/geometry.vertex.js.map +1 -1
  96. package/package.json +1 -1
  97. package/FlowGraph/Blocks/Execution/ControlFlow/flowGraphConditionalBlock.js.map +0 -1
  98. /package/FlowGraph/Blocks/Execution/ControlFlow/{flowGraphConditionalBlock.d.ts → flowGraphBranchBlock.d.ts} +0 -0
@@ -13,8 +13,8 @@ export class FlowGraphReceiveCustomEventBlock extends FlowGraphEventBlock {
13
13
  }
14
14
  _preparePendingTasks(context) {
15
15
  const observable = context.graphVariables.eventCoordinator.getCustomEventObservable(this._params.eventId);
16
- this._eventObserver = observable.add((event) => {
17
- this.eventData.setValue(event === null || event === void 0 ? void 0 : event.data, context);
16
+ this._eventObserver = observable.add((eventData) => {
17
+ this.eventData.setValue(eventData, context);
18
18
  this._execute(context);
19
19
  });
20
20
  }
@@ -1 +1 @@
1
- {"version":3,"file":"flowGraphReceiveCustomEventBlock.js","sourceRoot":"","sources":["../../../../../../dev/core/src/FlowGraph/Blocks/Event/flowGraphReceiveCustomEventBlock.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,mBAAmB,EAAE,MAAM,2BAA2B,CAAC;AAGhE,OAAO,EAAE,KAAK,EAAE,MAAM,qBAAqB,CAAC;AAE5C,OAAO,EAAE,WAAW,EAAE,MAAM,0BAA0B,CAAC;AAUvD;;;GAGG;AACH,MAAM,OAAO,gCAAiC,SAAQ,mBAAmB;IAQrE,YAAoB,OAAoD;QACpE,KAAK,EAAE,CAAC;QADQ,YAAO,GAAP,OAAO,CAA6C;QAEpE,IAAI,CAAC,SAAS,GAAG,IAAI,CAAC,mBAAmB,CAAC,WAAW,EAAE,WAAW,CAAC,CAAC;IACxE,CAAC;IACM,oBAAoB,CAAC,OAAyB;QACjD,MAAM,UAAU,GAAG,OAAO,CAAC,cAAc,CAAC,gBAAgB,CAAC,wBAAwB,CAAC,IAAI,CAAC,OAAO,CAAC,OAAO,CAAC,CAAC;QAC1G,IAAI,CAAC,cAAc,GAAG,UAAU,CAAC,GAAG,CAAC,CAAC,KAAK,EAAE,EAAE;YAC3C,IAAI,CAAC,SAAS,CAAC,QAAQ,CAAC,KAAK,aAAL,KAAK,uBAAL,KAAK,CAAE,IAAI,EAAE,OAAO,CAAC,CAAC;YAC9C,IAAI,CAAC,QAAQ,CAAC,OAAO,CAAC,CAAC;QAC3B,CAAC,CAAC,CAAC;IACP,CAAC;IACM,mBAAmB,CAAC,OAAyB;QAChD,MAAM,UAAU,GAAG,OAAO,CAAC,cAAc,CAAC,gBAAgB,CAAC,wBAAwB,CAAC,IAAI,CAAC,OAAO,CAAC,OAAO,CAAC,CAAC;QAC1G,IAAI,UAAU,EAAE;YACZ,UAAU,CAAC,MAAM,CAAC,IAAI,CAAC,cAAc,CAAC,CAAC;SAC1C;aAAM;YACH,KAAK,CAAC,IAAI,CAAC,kEAAkE,IAAI,CAAC,OAAO,CAAC,OAAO,EAAE,CAAC,CAAC;SACxG;IACL,CAAC;CACJ","sourcesContent":["import type { Observer } from \"../../../Misc/observable\";\r\nimport type { FlowGraphContext } from \"../../flowGraphContext\";\r\nimport { FlowGraphEventBlock } from \"../../flowGraphEventBlock\";\r\nimport type { FlowGraphCustomEvent } from \"../../flowGraphCustomEvent\";\r\nimport type { Nullable } from \"../../../types\";\r\nimport { Tools } from \"../../../Misc/tools\";\r\nimport type { FlowGraphDataConnection } from \"../../flowGraphDataConnection\";\r\nimport { RichTypeAny } from \"../../flowGraphRichTypes\";\r\n\r\n/**\r\n * @experimental\r\n * Parameters used to create a FlowGraphReceiveCustomEventBlock.\r\n */\r\nexport interface IFlowGraphReceiveCustomEventBlockParameters {\r\n eventId: string;\r\n}\r\n\r\n/**\r\n * @experimental\r\n * A block that receives a custom event. It saves the data sent in the eventData output.\r\n */\r\nexport class FlowGraphReceiveCustomEventBlock extends FlowGraphEventBlock {\r\n private _eventObserver: Nullable<Observer<FlowGraphCustomEvent>>;\r\n\r\n /**\r\n * Output connection: The data sent with the event.\r\n */\r\n public eventData: FlowGraphDataConnection<any>;\r\n\r\n constructor(private _params: IFlowGraphReceiveCustomEventBlockParameters) {\r\n super();\r\n this.eventData = this._registerDataOutput(\"eventData\", RichTypeAny);\r\n }\r\n public _preparePendingTasks(context: FlowGraphContext): void {\r\n const observable = context.graphVariables.eventCoordinator.getCustomEventObservable(this._params.eventId);\r\n this._eventObserver = observable.add((event) => {\r\n this.eventData.setValue(event?.data, context);\r\n this._execute(context);\r\n });\r\n }\r\n public _cancelPendingTasks(context: FlowGraphContext): void {\r\n const observable = context.graphVariables.eventCoordinator.getCustomEventObservable(this._params.eventId);\r\n if (observable) {\r\n observable.remove(this._eventObserver);\r\n } else {\r\n Tools.Warn(`FlowGraphReceiveCustomEventBlock: Missing observable for event ${this._params.eventId}`);\r\n }\r\n }\r\n}\r\n"]}
1
+ {"version":3,"file":"flowGraphReceiveCustomEventBlock.js","sourceRoot":"","sources":["../../../../../../dev/core/src/FlowGraph/Blocks/Event/flowGraphReceiveCustomEventBlock.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,mBAAmB,EAAE,MAAM,2BAA2B,CAAC;AAGhE,OAAO,EAAE,KAAK,EAAE,MAAM,qBAAqB,CAAC;AAE5C,OAAO,EAAE,WAAW,EAAE,MAAM,0BAA0B,CAAC;AAUvD;;;GAGG;AACH,MAAM,OAAO,gCAAiC,SAAQ,mBAAmB;IAQrE,YAAoB,OAAoD;QACpE,KAAK,EAAE,CAAC;QADQ,YAAO,GAAP,OAAO,CAA6C;QAEpE,IAAI,CAAC,SAAS,GAAG,IAAI,CAAC,mBAAmB,CAAC,WAAW,EAAE,WAAW,CAAC,CAAC;IACxE,CAAC;IACM,oBAAoB,CAAC,OAAyB;QACjD,MAAM,UAAU,GAAG,OAAO,CAAC,cAAc,CAAC,gBAAgB,CAAC,wBAAwB,CAAC,IAAI,CAAC,OAAO,CAAC,OAAO,CAAC,CAAC;QAC1G,IAAI,CAAC,cAAc,GAAG,UAAU,CAAC,GAAG,CAAC,CAAC,SAAS,EAAE,EAAE;YAC/C,IAAI,CAAC,SAAS,CAAC,QAAQ,CAAC,SAAS,EAAE,OAAO,CAAC,CAAC;YAC5C,IAAI,CAAC,QAAQ,CAAC,OAAO,CAAC,CAAC;QAC3B,CAAC,CAAC,CAAC;IACP,CAAC;IACM,mBAAmB,CAAC,OAAyB;QAChD,MAAM,UAAU,GAAG,OAAO,CAAC,cAAc,CAAC,gBAAgB,CAAC,wBAAwB,CAAC,IAAI,CAAC,OAAO,CAAC,OAAO,CAAC,CAAC;QAC1G,IAAI,UAAU,EAAE;YACZ,UAAU,CAAC,MAAM,CAAC,IAAI,CAAC,cAAc,CAAC,CAAC;SAC1C;aAAM;YACH,KAAK,CAAC,IAAI,CAAC,kEAAkE,IAAI,CAAC,OAAO,CAAC,OAAO,EAAE,CAAC,CAAC;SACxG;IACL,CAAC;CACJ","sourcesContent":["import type { Observer } from \"../../../Misc/observable\";\r\nimport type { FlowGraphContext } from \"../../flowGraphContext\";\r\nimport { FlowGraphEventBlock } from \"../../flowGraphEventBlock\";\r\nimport type { FlowGraphCustomEvent } from \"../../flowGraphCustomEvent\";\r\nimport type { Nullable } from \"../../../types\";\r\nimport { Tools } from \"../../../Misc/tools\";\r\nimport type { FlowGraphDataConnection } from \"../../flowGraphDataConnection\";\r\nimport { RichTypeAny } from \"../../flowGraphRichTypes\";\r\n\r\n/**\r\n * @experimental\r\n * Parameters used to create a FlowGraphReceiveCustomEventBlock.\r\n */\r\nexport interface IFlowGraphReceiveCustomEventBlockParameters {\r\n eventId: string;\r\n}\r\n\r\n/**\r\n * @experimental\r\n * A block that receives a custom event. It saves the data sent in the eventData output.\r\n */\r\nexport class FlowGraphReceiveCustomEventBlock extends FlowGraphEventBlock {\r\n private _eventObserver: Nullable<Observer<FlowGraphCustomEvent>>;\r\n\r\n /**\r\n * Output connection: The data sent with the event.\r\n */\r\n public eventData: FlowGraphDataConnection<any>;\r\n\r\n constructor(private _params: IFlowGraphReceiveCustomEventBlockParameters) {\r\n super();\r\n this.eventData = this._registerDataOutput(\"eventData\", RichTypeAny);\r\n }\r\n public _preparePendingTasks(context: FlowGraphContext): void {\r\n const observable = context.graphVariables.eventCoordinator.getCustomEventObservable(this._params.eventId);\r\n this._eventObserver = observable.add((eventData) => {\r\n this.eventData.setValue(eventData, context);\r\n this._execute(context);\r\n });\r\n }\r\n public _cancelPendingTasks(context: FlowGraphContext): void {\r\n const observable = context.graphVariables.eventCoordinator.getCustomEventObservable(this._params.eventId);\r\n if (observable) {\r\n observable.remove(this._eventObserver);\r\n } else {\r\n Tools.Warn(`FlowGraphReceiveCustomEventBlock: Missing observable for event ${this._params.eventId}`);\r\n }\r\n }\r\n}\r\n"]}
@@ -20,4 +20,4 @@ export class FlowGraphBranchBlock extends FlowGraphExecutionBlock {
20
20
  }
21
21
  }
22
22
  }
23
- //# sourceMappingURL=flowGraphConditionalBlock.js.map
23
+ //# sourceMappingURL=flowGraphBranchBlock.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"flowGraphBranchBlock.js","sourceRoot":"","sources":["../../../../../../../dev/core/src/FlowGraph/Blocks/Execution/ControlFlow/flowGraphBranchBlock.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAE,MAAM,6BAA6B,CAAC;AAG9D,OAAO,EAAE,uBAAuB,EAAE,MAAM,kCAAkC,CAAC;AAG3E;;;GAGG;AACH,MAAM,OAAO,oBAAqB,SAAQ,uBAAuB;IAc7D;QACI,KAAK,EAAE,CAAC;QAER,IAAI,CAAC,SAAS,GAAG,IAAI,CAAC,kBAAkB,CAAC,WAAW,EAAE,eAAe,CAAC,CAAC;QAEvE,IAAI,CAAC,MAAM,GAAG,IAAI,CAAC,qBAAqB,CAAC,QAAQ,CAAC,CAAC;QACnD,IAAI,CAAC,OAAO,GAAG,IAAI,CAAC,qBAAqB,CAAC,SAAS,CAAC,CAAC;IACzD,CAAC;IAEM,QAAQ,CAAC,OAAyB;QACrC,IAAI,IAAI,CAAC,SAAS,CAAC,QAAQ,CAAC,OAAO,CAAC,EAAE;YAClC,IAAI,CAAC,MAAM,CAAC,eAAe,CAAC,OAAO,CAAC,CAAC;SACxC;aAAM;YACH,IAAI,CAAC,OAAO,CAAC,eAAe,CAAC,OAAO,CAAC,CAAC;SACzC;IACL,CAAC;CACJ","sourcesContent":["import { RichTypeBoolean } from \"../../../flowGraphRichTypes\";\r\nimport type { FlowGraphContext } from \"../../../flowGraphContext\";\r\nimport type { FlowGraphDataConnection } from \"../../../flowGraphDataConnection\";\r\nimport { FlowGraphExecutionBlock } from \"../../../flowGraphExecutionBlock\";\r\nimport type { FlowGraphSignalConnection } from \"../../../flowGraphSignalConnection\";\r\n\r\n/**\r\n * @experimental\r\n * A block that evaluates a condition and executes one of two branches.\r\n */\r\nexport class FlowGraphBranchBlock extends FlowGraphExecutionBlock {\r\n /**\r\n * Input connection: The condition to evaluate.\r\n */\r\n public readonly condition: FlowGraphDataConnection<boolean>;\r\n /**\r\n * Output connection: The branch to execute if the condition is true.\r\n */\r\n public readonly onTrue: FlowGraphSignalConnection;\r\n /**\r\n * Output connection: The branch to execute if the condition is false.\r\n */\r\n public readonly onFalse: FlowGraphSignalConnection;\r\n\r\n constructor() {\r\n super();\r\n\r\n this.condition = this._registerDataInput(\"condition\", RichTypeBoolean);\r\n\r\n this.onTrue = this._registerSignalOutput(\"onTrue\");\r\n this.onFalse = this._registerSignalOutput(\"onFalse\");\r\n }\r\n\r\n public _execute(context: FlowGraphContext): void {\r\n if (this.condition.getValue(context)) {\r\n this.onTrue._activateSignal(context);\r\n } else {\r\n this.onFalse._activateSignal(context);\r\n }\r\n }\r\n}\r\n"]}
@@ -1,4 +1,4 @@
1
- export * from "./flowGraphConditionalBlock";
1
+ export * from "./flowGraphBranchBlock";
2
2
  export * from "./flowGraphDoNBlock";
3
3
  export * from "./flowGraphForLoopBlock";
4
4
  export * from "./flowGraphThrottleBlock";
@@ -1,4 +1,4 @@
1
- export * from "./flowGraphConditionalBlock.js";
1
+ export * from "./flowGraphBranchBlock.js";
2
2
  export * from "./flowGraphDoNBlock.js";
3
3
  export * from "./flowGraphForLoopBlock.js";
4
4
  export * from "./flowGraphThrottleBlock.js";
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../../../../dev/core/src/FlowGraph/Blocks/Execution/ControlFlow/index.ts"],"names":[],"mappings":"AAAA,cAAc,6BAA6B,CAAC;AAC5C,cAAc,qBAAqB,CAAC;AACpC,cAAc,yBAAyB,CAAC;AACxC,cAAc,0BAA0B,CAAC;AACzC,cAAc,uBAAuB,CAAC;AACtC,cAAc,2BAA2B,CAAC;AAC1C,cAAc,wBAAwB,CAAC;AACvC,cAAc,yBAAyB,CAAC;AACxC,cAAc,yBAAyB,CAAC;AACxC,cAAc,2BAA2B,CAAC;AAC1C,cAAc,0BAA0B,CAAC;AACzC,cAAc,0BAA0B,CAAC","sourcesContent":["export * from \"./flowGraphConditionalBlock\";\r\nexport * from \"./flowGraphDoNBlock\";\r\nexport * from \"./flowGraphForLoopBlock\";\r\nexport * from \"./flowGraphThrottleBlock\";\r\nexport * from \"./flowGraphTimerBlock\";\r\nexport * from \"./flowGraphMultiGateBlock\";\r\nexport * from \"./flowGraphSwitchBlock\";\r\nexport * from \"./flowGraphWaitAllBlock\";\r\nexport * from \"./flowGraphCounterBlock\";\r\nexport * from \"./flowGraphWhileLoopBlock\";\r\nexport * from \"./flowGraphDebounceBlock\";\r\nexport * from \"./flowGraphFlipFlopBlock\";\r\n"]}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../../../../dev/core/src/FlowGraph/Blocks/Execution/ControlFlow/index.ts"],"names":[],"mappings":"AAAA,cAAc,wBAAwB,CAAC;AACvC,cAAc,qBAAqB,CAAC;AACpC,cAAc,yBAAyB,CAAC;AACxC,cAAc,0BAA0B,CAAC;AACzC,cAAc,uBAAuB,CAAC;AACtC,cAAc,2BAA2B,CAAC;AAC1C,cAAc,wBAAwB,CAAC;AACvC,cAAc,yBAAyB,CAAC;AACxC,cAAc,yBAAyB,CAAC;AACxC,cAAc,2BAA2B,CAAC;AAC1C,cAAc,0BAA0B,CAAC;AACzC,cAAc,0BAA0B,CAAC","sourcesContent":["export * from \"./flowGraphBranchBlock\";\r\nexport * from \"./flowGraphDoNBlock\";\r\nexport * from \"./flowGraphForLoopBlock\";\r\nexport * from \"./flowGraphThrottleBlock\";\r\nexport * from \"./flowGraphTimerBlock\";\r\nexport * from \"./flowGraphMultiGateBlock\";\r\nexport * from \"./flowGraphSwitchBlock\";\r\nexport * from \"./flowGraphWaitAllBlock\";\r\nexport * from \"./flowGraphCounterBlock\";\r\nexport * from \"./flowGraphWhileLoopBlock\";\r\nexport * from \"./flowGraphDebounceBlock\";\r\nexport * from \"./flowGraphFlipFlopBlock\";\r\n"]}
@@ -0,0 +1,23 @@
1
+ import type { FlowGraphDataConnection } from "../../flowGraphDataConnection";
2
+ import type { FlowGraphContext } from "../../flowGraphContext";
3
+ import { FlowGraphWithOnDoneExecutionBlock } from "../../flowGraphWithOnDoneExecutionBlock";
4
+ /**
5
+ * Configuration for a custom function block.
6
+ * @experimental
7
+ */
8
+ export interface IFlowGraphCustomFunctionBlockConfiguration {
9
+ /**
10
+ * The function to run.
11
+ */
12
+ customFunction: (value: any) => void;
13
+ }
14
+ /**
15
+ * Block that executes a user-defined function.
16
+ * @experimental
17
+ */
18
+ export declare class FlowGraphCustomFunctionBlock extends FlowGraphWithOnDoneExecutionBlock {
19
+ private _config;
20
+ readonly input: FlowGraphDataConnection<any>;
21
+ constructor(_config: IFlowGraphCustomFunctionBlockConfiguration);
22
+ _execute(context: FlowGraphContext): void;
23
+ }
@@ -0,0 +1,18 @@
1
+ import { FlowGraphWithOnDoneExecutionBlock } from "../../flowGraphWithOnDoneExecutionBlock.js";
2
+ import { RichTypeAny } from "../../flowGraphRichTypes.js";
3
+ /**
4
+ * Block that executes a user-defined function.
5
+ * @experimental
6
+ */
7
+ export class FlowGraphCustomFunctionBlock extends FlowGraphWithOnDoneExecutionBlock {
8
+ constructor(_config) {
9
+ super();
10
+ this._config = _config;
11
+ this.input = this._registerDataInput("input", RichTypeAny);
12
+ }
13
+ _execute(context) {
14
+ this._config.customFunction(this.input.getValue(context));
15
+ this.onDone._activateSignal(context);
16
+ }
17
+ }
18
+ //# sourceMappingURL=flowGraphCustomFunctionBlock.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"flowGraphCustomFunctionBlock.js","sourceRoot":"","sources":["../../../../../../dev/core/src/FlowGraph/Blocks/Execution/flowGraphCustomFunctionBlock.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,iCAAiC,EAAE,MAAM,yCAAyC,CAAC;AAC5F,OAAO,EAAE,WAAW,EAAE,MAAM,0BAA0B,CAAC;AAWvD;;;GAGG;AACH,MAAM,OAAO,4BAA6B,SAAQ,iCAAiC;IAG/E,YAAoB,OAAmD;QACnE,KAAK,EAAE,CAAC;QADQ,YAAO,GAAP,OAAO,CAA4C;QAGnE,IAAI,CAAC,KAAK,GAAG,IAAI,CAAC,kBAAkB,CAAC,OAAO,EAAE,WAAW,CAAC,CAAC;IAC/D,CAAC;IACM,QAAQ,CAAC,OAAyB;QACrC,IAAI,CAAC,OAAO,CAAC,cAAc,CAAC,IAAI,CAAC,KAAK,CAAC,QAAQ,CAAC,OAAO,CAAC,CAAC,CAAC;QAC1D,IAAI,CAAC,MAAM,CAAC,eAAe,CAAC,OAAO,CAAC,CAAC;IACzC,CAAC;CACJ","sourcesContent":["import type { FlowGraphDataConnection } from \"../../flowGraphDataConnection\";\r\nimport type { FlowGraphContext } from \"../../flowGraphContext\";\r\nimport { FlowGraphWithOnDoneExecutionBlock } from \"../../flowGraphWithOnDoneExecutionBlock\";\r\nimport { RichTypeAny } from \"../../flowGraphRichTypes\";\r\n/**\r\n * Configuration for a custom function block.\r\n * @experimental\r\n */\r\nexport interface IFlowGraphCustomFunctionBlockConfiguration {\r\n /**\r\n * The function to run.\r\n */\r\n customFunction: (value: any) => void;\r\n}\r\n/**\r\n * Block that executes a user-defined function.\r\n * @experimental\r\n */\r\nexport class FlowGraphCustomFunctionBlock extends FlowGraphWithOnDoneExecutionBlock {\r\n public readonly input: FlowGraphDataConnection<any>;\r\n\r\n constructor(private _config: IFlowGraphCustomFunctionBlockConfiguration) {\r\n super();\r\n\r\n this.input = this._registerDataInput(\"input\", RichTypeAny);\r\n }\r\n public _execute(context: FlowGraphContext): void {\r\n this._config.customFunction(this.input.getValue(context));\r\n this.onDone._activateSignal(context);\r\n }\r\n}\r\n"]}
@@ -289,13 +289,15 @@ export class BoundingBoxGizmo extends Gizmo {
289
289
  this._anchorMesh.position.copyFrom(this.attachedMesh.position);
290
290
  }
291
291
  // Rotate around center of bounding box
292
- this._anchorMesh.addChild(this.attachedMesh, Gizmo.PreserveScaling);
292
+ this._anchorMesh.addChild(this.attachedMesh);
293
293
  if (this._anchorMesh.getScene().useRightHandedSystem) {
294
294
  this._tmpQuaternion.conjugateInPlace();
295
295
  }
296
+ this._tmpQuaternion.normalize();
296
297
  this._anchorMesh.rotationQuaternion.multiplyToRef(this._tmpQuaternion, this._anchorMesh.rotationQuaternion);
297
- this._anchorMesh.removeChild(this.attachedMesh, Gizmo.PreserveScaling);
298
- this.attachedMesh.setParent(originalParent, Gizmo.PreserveScaling);
298
+ this._anchorMesh.rotationQuaternion.normalize();
299
+ this._anchorMesh.removeChild(this.attachedMesh);
300
+ this.attachedMesh.setParent(originalParent);
299
301
  }
300
302
  this.updateBoundingBox();
301
303
  PivotTools._RestorePivotPoint(this.attachedMesh);
@@ -384,13 +386,13 @@ export class BoundingBoxGizmo extends Gizmo {
384
386
  this._anchorMesh.position.subtractInPlace(this.attachedMesh.getPivotPoint());
385
387
  }
386
388
  }
387
- this._anchorMesh.addChild(this.attachedMesh, Gizmo.PreserveScaling);
389
+ this._anchorMesh.addChild(this.attachedMesh);
388
390
  this._anchorMesh.scaling.addInPlace(deltaScale);
389
391
  if (this._anchorMesh.scaling.x < 0 || this._anchorMesh.scaling.y < 0 || this._anchorMesh.scaling.z < 0) {
390
392
  this._anchorMesh.scaling.subtractInPlace(deltaScale);
391
393
  }
392
- this._anchorMesh.removeChild(this.attachedMesh, Gizmo.PreserveScaling);
393
- this.attachedMesh.setParent(originalParent, Gizmo.PreserveScaling);
394
+ this._anchorMesh.removeChild(this.attachedMesh);
395
+ this.attachedMesh.setParent(originalParent);
394
396
  PivotTools._RestorePivotPoint(this.attachedMesh);
395
397
  }
396
398
  this._updateDummy();
@@ -461,9 +463,9 @@ export class BoundingBoxGizmo extends Gizmo {
461
463
  this._anchorMesh.scaling.setAll(1);
462
464
  PivotTools._RemoveAndStorePivotPoint(value);
463
465
  const originalParent = value.parent;
464
- this._anchorMesh.addChild(value, Gizmo.PreserveScaling);
465
- this._anchorMesh.removeChild(value, Gizmo.PreserveScaling);
466
- value.setParent(originalParent, Gizmo.PreserveScaling);
466
+ this._anchorMesh.addChild(value);
467
+ this._anchorMesh.removeChild(value);
468
+ value.setParent(originalParent);
467
469
  PivotTools._RestorePivotPoint(value);
468
470
  this.updateBoundingBox();
469
471
  value.getChildMeshes(false).forEach((m) => {
@@ -502,7 +504,7 @@ export class BoundingBoxGizmo extends Gizmo {
502
504
  PivotTools._RemoveAndStorePivotPoint(this.attachedMesh);
503
505
  // Store original parent
504
506
  const originalParent = this.attachedMesh.parent;
505
- this.attachedMesh.setParent(null, Gizmo.PreserveScaling);
507
+ this.attachedMesh.setParent(null);
506
508
  this._update();
507
509
  // Rotate based on axis
508
510
  if (!this.attachedMesh.rotationQuaternion) {
@@ -533,7 +535,7 @@ export class BoundingBoxGizmo extends Gizmo {
533
535
  this.attachedMesh.rotationQuaternion.copyFrom(this._tmpQuaternion);
534
536
  this.attachedMesh.position.copyFrom(this._tmpVector);
535
537
  // Restore original parent
536
- this.attachedMesh.setParent(originalParent, Gizmo.PreserveScaling);
538
+ this.attachedMesh.setParent(originalParent);
537
539
  }
538
540
  this._updateRotationSpheres();
539
541
  this._updateScaleBoxes();
@@ -1 +1 @@
1
- {"version":3,"file":"boundingBoxGizmo.js","sourceRoot":"","sources":["../../../../dev/core/src/Gizmos/boundingBoxGizmo.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,UAAU,EAAE,MAAM,oBAAoB,CAAC;AAChD,OAAO,EAAE,MAAM,EAAE,MAAM,gBAAgB,CAAC;AAIxC,OAAO,EAAE,UAAU,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,sBAAsB,CAAC;AACnE,OAAO,EAAE,YAAY,EAAE,MAAM,wBAAwB,CAAC;AAEtD,OAAO,EAAE,YAAY,EAAE,MAAM,kCAAkC,CAAC;AAChE,OAAO,EAAE,SAAS,EAAE,MAAM,+BAA+B,CAAC;AAC1D,OAAO,EAAE,WAAW,EAAE,MAAM,iCAAiC,CAAC;AAC9D,OAAO,EAAE,mBAAmB,EAAE,MAAM,yCAAyC,CAAC;AAE9E,OAAO,EAAE,KAAK,EAAE,MAAM,SAAS,CAAC;AAChC,OAAO,EAAE,oBAAoB,EAAE,MAAM,mCAAmC,CAAC;AACzE,OAAO,EAAE,gBAAgB,EAAE,MAAM,+BAA+B,CAAC;AACjE,OAAO,EAAE,UAAU,EAAE,MAAM,oBAAoB,CAAC;AAChD,OAAO,EAAE,MAAM,EAAE,MAAM,qBAAqB,CAAC;AAE7C,OAAO,EAAE,OAAO,EAAE,MAAM,yBAAyB,CAAC;AAmFlD;;GAEG;AACH,MAAM,OAAO,gBAAiB,SAAQ,KAAK;IAgFvC;;;OAGG;IACH,IAAW,UAAU,CAAC,MAAe;QACjC,IAAI,CAAC,WAAW,GAAG,MAAM,CAAC;QAC1B,+BAA+B;QAC/B,MAAM,UAAU,GAAG,IAAI,CAAC,iBAAiB,CAAC,cAAc,EAAE,CAAC;QAC3D,IAAI,KAAK,GAAG,CAAC,CAAC;QACd,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,CAAC,EAAE,CAAC,EAAE,EAA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C7B,IAAI,CAAC,QAAQ,CAAC,GAAG,CAAC,CAAC;QACnB,IAAI,CAAC,kBAAkB,CAAC,QAAQ,CAAC,MAAM,CAAC,CAAC;QACzC,IAAI,CAAC,QAAQ,CAAC,QAAQ,CAAC,MAAM,CAAC,CAAC;QAE/B,oBAAoB;QACpB,IAAI,CAAC,WAAW,CAAC,GAAG,CAAC,CAAC;QAEtB,GAAG,CAAC,QAAQ,CAAC,IAAI,CAAC,CAAC;QACnB,GAAG,CAAC,UAAU,GAAG,CAAC,CAAC;QACnB,OAAO,GAAG,CAAC;IACf,CAAC;IACD;;OAEG;IACI,aAAa;QAChB,MAAM,CAAC,KAAK,CAAC,+CAA+C,CAAC,CAAC;IAClE,CAAC;CACJ","sourcesContent":["import type { Observer } from \"../Misc/observable\";\r\nimport { Observable } from \"../Misc/observable\";\r\nimport { Logger } from \"../Misc/logger\";\r\nimport type { Nullable } from \"../types\";\r\nimport type { PointerInfo } from \"../Events/pointerEvents\";\r\nimport type { Scene } from \"../scene\";\r\nimport { Quaternion, Matrix, Vector3 } from \"../Maths/math.vector\";\r\nimport { AbstractMesh } from \"../Meshes/abstractMesh\";\r\nimport type { Mesh } from \"../Meshes/mesh\";\r\nimport { CreateSphere } from \"../Meshes/Builders/sphereBuilder\";\r\nimport { CreateBox } from \"../Meshes/Builders/boxBuilder\";\r\nimport { CreateLines } from \"../Meshes/Builders/linesBuilder\";\r\nimport { PointerDragBehavior } from \"../Behaviors/Meshes/pointerDragBehavior\";\r\nimport type { IGizmo } from \"./gizmo\";\r\nimport { Gizmo } from \"./gizmo\";\r\nimport { UtilityLayerRenderer } from \"../Rendering/utilityLayerRenderer\";\r\nimport { StandardMaterial } from \"../Materials/standardMaterial\";\r\nimport { PivotTools } from \"../Misc/pivotTools\";\r\nimport { Color3 } from \"../Maths/math.color\";\r\nimport type { LinesMesh } from \"../Meshes/linesMesh\";\r\nimport { Epsilon } from \"../Maths/math.constants\";\r\nimport type { IPointerEvent } from \"../Events/deviceInputEvents\";\r\n\r\n/**\r\n * Interface for bounding box gizmo\r\n */\r\nexport interface IBoundingBoxGizmo extends IGizmo {\r\n /**\r\n * If child meshes should be ignored when calculating the bounding box. This should be set to true to avoid perf hits with heavily nested meshes.\r\n */\r\n ignoreChildren: boolean;\r\n /**\r\n * Returns true if a descendant should be included when computing the bounding box. When null, all descendants are included. If ignoreChildren is set this will be ignored.\r\n */\r\n includeChildPredicate: Nullable<(abstractMesh: AbstractMesh) => boolean>;\r\n /** The size of the rotation spheres attached to the bounding box */\r\n rotationSphereSize: number;\r\n /** The size of the scale boxes attached to the bounding box */\r\n scaleBoxSize: number;\r\n /**\r\n * If set, the rotation spheres and scale boxes will increase in size based on the distance away from the camera to have a consistent screen size\r\n * Note : fixedDragMeshScreenSize takes precedence over fixedDragMeshBoundsSize if both are true\r\n */\r\n fixedDragMeshScreenSize: boolean;\r\n /**\r\n * If set, the rotation spheres and scale boxes will increase in size based on the size of the bounding box\r\n * Note : fixedDragMeshScreenSize takes precedence over fixedDragMeshBoundsSize if both are true\r\n */\r\n fixedDragMeshBoundsSize: boolean;\r\n /**\r\n * The distance away from the object which the draggable meshes should appear world sized when fixedDragMeshScreenSize is set to true\r\n */\r\n fixedDragMeshScreenSizeDistanceFactor: number;\r\n /** Fired when a rotation sphere or scale box is dragged */\r\n onDragStartObservable: Observable<{}>;\r\n /** Fired when a scale box is dragged */\r\n onScaleBoxDragObservable: Observable<{}>;\r\n /** Fired when a scale box drag is ended */\r\n onScaleBoxDragEndObservable: Observable<{}>;\r\n /** Fired when a rotation sphere is dragged */\r\n onRotationSphereDragObservable: Observable<{}>;\r\n /** Fired when a rotation sphere drag is ended */\r\n onRotationSphereDragEndObservable: Observable<{}>;\r\n /** Relative bounding box pivot used when scaling the attached node. */\r\n scalePivot: Nullable<Vector3>;\r\n /** Scale factor vector used for masking some axis */\r\n axisFactor: Vector3;\r\n /** Scale factor scalar affecting all axes' drag speed */\r\n scaleDragSpeed: number;\r\n /**\r\n * Sets the color of the bounding box gizmo\r\n * @param color the color to set\r\n */\r\n setColor(color: Color3): void;\r\n /** Returns an array containing all boxes used for scaling (in increasing x, y and z orders) */\r\n getScaleBoxes(): AbstractMesh[];\r\n /** Updates the bounding box information for the Gizmo */\r\n updateBoundingBox(): void;\r\n /**\r\n * Enables rotation on the specified axis and disables rotation on the others\r\n * @param axis The list of axis that should be enabled (eg. \"xy\" or \"xyz\")\r\n */\r\n setEnabledRotationAxis(axis: string): void;\r\n /**\r\n * Enables/disables scaling\r\n * @param enable if scaling should be enabled\r\n * @param homogeneousScaling defines if scaling should only be homogeneous\r\n */\r\n setEnabledScaling(enable: boolean, homogeneousScaling?: boolean): void;\r\n /** Enables a pointer drag behavior on the bounding box of the gizmo */\r\n enableDragBehavior(): void;\r\n\r\n /** Default material used to render when gizmo is not disabled or hovered */\r\n coloredMaterial: StandardMaterial;\r\n /** Material used to render when gizmo is hovered with mouse*/\r\n hoverMaterial: StandardMaterial;\r\n\r\n /** Drag distance in babylon units that the gizmo will snap scaling to when dragged */\r\n scalingSnapDistance: number;\r\n /** Drag distance in babylon units that the gizmo will snap rotation to when dragged */\r\n rotationSnapDistance: number;\r\n}\r\n\r\n/**\r\n * Bounding box gizmo\r\n */\r\nexport class BoundingBoxGizmo extends Gizmo implements IBoundingBoxGizmo {\r\n protected _lineBoundingBox: AbstractMesh;\r\n protected _rotateSpheresParent: AbstractMesh;\r\n protected _scaleBoxesParent: AbstractMesh;\r\n protected _boundingDimensions = new Vector3(1, 1, 1);\r\n protected _renderObserver: Nullable<Observer<Scene>> = null;\r\n protected _pointerObserver: Nullable<Observer<PointerInfo>> = null;\r\n protected _scaleDragSpeed = 0.2;\r\n\r\n private _tmpQuaternion = new Quaternion();\r\n private _tmpVector = new Vector3(0, 0, 0);\r\n private _tmpRotationMatrix = new Matrix();\r\n /**\r\n * If child meshes should be ignored when calculating the bounding box. This should be set to true to avoid perf hits with heavily nested meshes (Default: false)\r\n */\r\n public ignoreChildren = false;\r\n /**\r\n * Returns true if a descendant should be included when computing the bounding box. When null, all descendants are included. If ignoreChildren is set this will be ignored. (Default: null)\r\n */\r\n public includeChildPredicate: Nullable<(abstractMesh: AbstractMesh) => boolean> = null;\r\n\r\n /**\r\n * The size of the rotation spheres attached to the bounding box (Default: 0.1)\r\n */\r\n public rotationSphereSize = 0.1;\r\n /**\r\n * The size of the scale boxes attached to the bounding box (Default: 0.1)\r\n */\r\n public scaleBoxSize = 0.1;\r\n /**\r\n * If set, the rotation spheres and scale boxes will increase in size based on the distance away from the camera to have a consistent screen size (Default: false)\r\n * Note : fixedDragMeshScreenSize takes precedence over fixedDragMeshBoundsSize if both are true\r\n */\r\n public fixedDragMeshScreenSize = false;\r\n /**\r\n * If set, the rotation spheres and scale boxes will increase in size based on the size of the bounding box\r\n * Note : fixedDragMeshScreenSize takes precedence over fixedDragMeshBoundsSize if both are true\r\n */\r\n public fixedDragMeshBoundsSize = false;\r\n /**\r\n * The distance away from the object which the draggable meshes should appear world sized when fixedDragMeshScreenSize is set to true (default: 10)\r\n */\r\n public fixedDragMeshScreenSizeDistanceFactor = 10;\r\n /**\r\n * Drag distance in babylon units that the gizmo will snap scaling to when dragged\r\n */\r\n public scalingSnapDistance = 0;\r\n /**\r\n * Drag distance in babylon units that the gizmo will snap rotation to when dragged\r\n */\r\n public rotationSnapDistance = 0;\r\n /**\r\n * Fired when a rotation sphere or scale box is dragged\r\n */\r\n public onDragStartObservable = new Observable<{}>();\r\n /**\r\n * Fired when a scale box is dragged\r\n */\r\n public onScaleBoxDragObservable = new Observable<{}>();\r\n /**\r\n * Fired when a scale box drag is ended\r\n */\r\n public onScaleBoxDragEndObservable = new Observable<{}>();\r\n /**\r\n * Fired when a rotation sphere is dragged\r\n */\r\n public onRotationSphereDragObservable = new Observable<{}>();\r\n /**\r\n * Fired when a rotation sphere drag is ended\r\n */\r\n public onRotationSphereDragEndObservable = new Observable<{}>();\r\n /**\r\n * Relative bounding box pivot used when scaling the attached node. When null object with scale from the opposite corner. 0.5,0.5,0.5 for center and 0.5,0,0.5 for bottom (Default: null)\r\n */\r\n public scalePivot: Nullable<Vector3> = null;\r\n /**\r\n * Scale factor used for masking some axis\r\n */\r\n protected _axisFactor = new Vector3(1, 1, 1);\r\n\r\n /**\r\n * Sets the axis factor\r\n * @param factor the Vector3 value\r\n */\r\n public set axisFactor(factor: Vector3) {\r\n this._axisFactor = factor;\r\n // update scale cube visibility\r\n const scaleBoxes = this._scaleBoxesParent.getChildMeshes();\r\n let index = 0;\r\n for (let i = 0; i < 3; i++) {\r\n for (let j = 0; j < 3; j++) {\r\n for (let k = 0; k < 3; k++) {\r\n const zeroAxisCount = (i === 1 ? 1 : 0) + (j === 1 ? 1 : 0) + (k === 1 ? 1 : 0);\r\n if (zeroAxisCount === 1 || zeroAxisCount === 3) {\r\n continue;\r\n }\r\n if (scaleBoxes[index]) {\r\n const dragAxis = new Vector3(i - 1, j - 1, k - 1);\r\n dragAxis.multiplyInPlace(this._axisFactor);\r\n scaleBoxes[index].setEnabled(dragAxis.lengthSquared() > Epsilon);\r\n }\r\n index++;\r\n }\r\n }\r\n }\r\n }\r\n\r\n /**\r\n * Gets the axis factor\r\n * @returns the Vector3 factor value\r\n */\r\n public get axisFactor(): Vector3 {\r\n return this._axisFactor;\r\n }\r\n\r\n /**\r\n * Sets scale drag speed value\r\n * @param value the new speed value\r\n */\r\n public set scaleDragSpeed(value: number) {\r\n this._scaleDragSpeed = value;\r\n }\r\n\r\n /**\r\n * Gets scale drag speed\r\n * @returns the scale speed number\r\n */\r\n public get scaleDragSpeed(): number {\r\n return this._scaleDragSpeed;\r\n }\r\n\r\n /**\r\n * Mesh used as a pivot to rotate the attached node\r\n */\r\n protected _anchorMesh: AbstractMesh;\r\n\r\n protected _existingMeshScale = new Vector3();\r\n\r\n // Dragging\r\n protected _dragMesh: Nullable<Mesh> = null;\r\n protected _pointerDragBehavior = new PointerDragBehavior();\r\n\r\n protected _coloredMaterial: StandardMaterial;\r\n protected _hoverColoredMaterial: StandardMaterial;\r\n\r\n /** Default material used to render when gizmo is not disabled or hovered */\r\n public get coloredMaterial() {\r\n return this._coloredMaterial;\r\n }\r\n\r\n /** Material used to render when gizmo is hovered with mouse*/\r\n public get hoverMaterial() {\r\n return this._hoverColoredMaterial;\r\n }\r\n /**\r\n * Get the pointerDragBehavior\r\n */\r\n public get pointerDragBehavior(): PointerDragBehavior {\r\n return this._pointerDragBehavior;\r\n }\r\n\r\n /**\r\n * Sets the color of the bounding box gizmo\r\n * @param color the color to set\r\n */\r\n public setColor(color: Color3) {\r\n this._coloredMaterial.emissiveColor = color;\r\n this._hoverColoredMaterial.emissiveColor = color.clone().add(new Color3(0.3, 0.3, 0.3));\r\n this._lineBoundingBox.getChildren().forEach((l) => {\r\n if ((l as LinesMesh).color) {\r\n (l as LinesMesh).color = color;\r\n }\r\n });\r\n }\r\n /**\r\n * Creates an BoundingBoxGizmo\r\n * @param color The color of the gizmo\r\n * @param gizmoLayer The utility layer the gizmo will be added to\r\n */\r\n constructor(color: Color3 = Color3.Gray(), gizmoLayer: UtilityLayerRenderer = UtilityLayerRenderer.DefaultKeepDepthUtilityLayer) {\r\n super(gizmoLayer);\r\n\r\n // Do not update the gizmo's scale so it has a fixed size to the object its attached to\r\n this.updateScale = false;\r\n\r\n this._anchorMesh = new AbstractMesh(\"anchor\", gizmoLayer.utilityLayerScene);\r\n // Create Materials\r\n this._coloredMaterial = new StandardMaterial(\"\", gizmoLayer.utilityLayerScene);\r\n this._coloredMaterial.disableLighting = true;\r\n this._hoverColoredMaterial = new StandardMaterial(\"\", gizmoLayer.utilityLayerScene);\r\n this._hoverColoredMaterial.disableLighting = true;\r\n\r\n // Build bounding box out of lines\r\n this._lineBoundingBox = new AbstractMesh(\"\", gizmoLayer.utilityLayerScene);\r\n this._lineBoundingBox.rotationQuaternion = new Quaternion();\r\n const lines = [];\r\n lines.push(CreateLines(\"lines\", { points: [new Vector3(0, 0, 0), new Vector3(this._boundingDimensions.x, 0, 0)] }, gizmoLayer.utilityLayerScene));\r\n lines.push(CreateLines(\"lines\", { points: [new Vector3(0, 0, 0), new Vector3(0, this._boundingDimensions.y, 0)] }, gizmoLayer.utilityLayerScene));\r\n lines.push(CreateLines(\"lines\", { points: [new Vector3(0, 0, 0), new Vector3(0, 0, this._boundingDimensions.z)] }, gizmoLayer.utilityLayerScene));\r\n lines.push(\r\n CreateLines(\r\n \"lines\",\r\n { points: [new Vector3(this._boundingDimensions.x, 0, 0), new Vector3(this._boundingDimensions.x, this._boundingDimensions.y, 0)] },\r\n gizmoLayer.utilityLayerScene\r\n )\r\n );\r\n lines.push(\r\n CreateLines(\r\n \"lines\",\r\n { points: [new Vector3(this._boundingDimensions.x, 0, 0), new Vector3(this._boundingDimensions.x, 0, this._boundingDimensions.z)] },\r\n gizmoLayer.utilityLayerScene\r\n )\r\n );\r\n lines.push(\r\n CreateLines(\r\n \"lines\",\r\n { points: [new Vector3(0, this._boundingDimensions.y, 0), new Vector3(this._boundingDimensions.x, this._boundingDimensions.y, 0)] },\r\n gizmoLayer.utilityLayerScene\r\n )\r\n );\r\n lines.push(\r\n CreateLines(\r\n \"lines\",\r\n { points: [new Vector3(0, this._boundingDimensions.y, 0), new Vector3(0, this._boundingDimensions.y, this._boundingDimensions.z)] },\r\n gizmoLayer.utilityLayerScene\r\n )\r\n );\r\n lines.push(\r\n CreateLines(\r\n \"lines\",\r\n { points: [new Vector3(0, 0, this._boundingDimensions.z), new Vector3(this._boundingDimensions.x, 0, this._boundingDimensions.z)] },\r\n gizmoLayer.utilityLayerScene\r\n )\r\n );\r\n lines.push(\r\n CreateLines(\r\n \"lines\",\r\n { points: [new Vector3(0, 0, this._boundingDimensions.z), new Vector3(0, this._boundingDimensions.y, this._boundingDimensions.z)] },\r\n gizmoLayer.utilityLayerScene\r\n )\r\n );\r\n lines.push(\r\n CreateLines(\r\n \"lines\",\r\n {\r\n points: [\r\n new Vector3(this._boundingDimensions.x, this._boundingDimensions.y, this._boundingDimensions.z),\r\n new Vector3(0, this._boundingDimensions.y, this._boundingDimensions.z),\r\n ],\r\n },\r\n gizmoLayer.utilityLayerScene\r\n )\r\n );\r\n lines.push(\r\n CreateLines(\r\n \"lines\",\r\n {\r\n points: [\r\n new Vector3(this._boundingDimensions.x, this._boundingDimensions.y, this._boundingDimensions.z),\r\n new Vector3(this._boundingDimensions.x, 0, this._boundingDimensions.z),\r\n ],\r\n },\r\n gizmoLayer.utilityLayerScene\r\n )\r\n );\r\n lines.push(\r\n CreateLines(\r\n \"lines\",\r\n {\r\n points: [\r\n new Vector3(this._boundingDimensions.x, this._boundingDimensions.y, this._boundingDimensions.z),\r\n new Vector3(this._boundingDimensions.x, this._boundingDimensions.y, 0),\r\n ],\r\n },\r\n gizmoLayer.utilityLayerScene\r\n )\r\n );\r\n lines.forEach((l) => {\r\n l.color = color;\r\n l.position.addInPlace(new Vector3(-this._boundingDimensions.x / 2, -this._boundingDimensions.y / 2, -this._boundingDimensions.z / 2));\r\n l.isPickable = false;\r\n this._lineBoundingBox.addChild(l);\r\n });\r\n this._rootMesh.addChild(this._lineBoundingBox);\r\n\r\n this.setColor(color);\r\n\r\n // Create rotation spheres\r\n this._rotateSpheresParent = new AbstractMesh(\"\", gizmoLayer.utilityLayerScene);\r\n this._rotateSpheresParent.rotationQuaternion = new Quaternion();\r\n for (let i = 0; i < 12; i++) {\r\n const sphere = CreateSphere(\"\", { diameter: 1 }, gizmoLayer.utilityLayerScene);\r\n sphere.rotationQuaternion = new Quaternion();\r\n sphere.material = this._coloredMaterial;\r\n sphere.isNearGrabbable = true;\r\n\r\n // Drag behavior\r\n const _dragBehavior = new PointerDragBehavior({});\r\n _dragBehavior.moveAttached = false;\r\n _dragBehavior.updateDragPlane = false;\r\n sphere.addBehavior(_dragBehavior);\r\n const startingTurnDirection = new Vector3(1, 0, 0);\r\n let totalTurnAmountOfDrag = 0;\r\n let previousProjectDist = 0;\r\n _dragBehavior.onDragStartObservable.add(() => {\r\n startingTurnDirection.copyFrom(sphere.forward);\r\n totalTurnAmountOfDrag = 0;\r\n previousProjectDist = 0;\r\n });\r\n _dragBehavior.onDragObservable.add((event) => {\r\n this.onRotationSphereDragObservable.notifyObservers({});\r\n if (this.attachedMesh) {\r\n const originalParent = this.attachedMesh.parent;\r\n if (originalParent && (originalParent as Mesh).scaling && (originalParent as Mesh).scaling.isNonUniformWithinEpsilon(0.001)) {\r\n Logger.Warn(\"BoundingBoxGizmo controls are not supported on child meshes with non-uniform parent scaling\");\r\n return;\r\n }\r\n PivotTools._RemoveAndStorePivotPoint(this.attachedMesh);\r\n\r\n const worldDragDirection = startingTurnDirection;\r\n\r\n // Project the world right on to the drag plane\r\n const toSub = event.dragPlaneNormal.scale(Vector3.Dot(event.dragPlaneNormal, worldDragDirection));\r\n const dragAxis = worldDragDirection.subtract(toSub).normalizeToNew();\r\n\r\n // project drag delta on to the resulting drag axis and rotate based on that\r\n let projectDist = Vector3.Dot(dragAxis, event.delta) < 0 ? Math.abs(event.delta.length()) : -Math.abs(event.delta.length());\r\n\r\n // Make rotation relative to size of mesh.\r\n projectDist = (projectDist / this._boundingDimensions.length()) * this._anchorMesh.scaling.length();\r\n\r\n // Rotate based on axis\r\n if (!this.attachedMesh.rotationQuaternion) {\r\n this.attachedMesh.rotationQuaternion = Quaternion.RotationYawPitchRoll(\r\n this.attachedMesh.rotation.y,\r\n this.attachedMesh.rotation.x,\r\n this.attachedMesh.rotation.z\r\n );\r\n }\r\n if (!this._anchorMesh.rotationQuaternion) {\r\n this._anchorMesh.rotationQuaternion = Quaternion.RotationYawPitchRoll(\r\n this._anchorMesh.rotation.y,\r\n this._anchorMesh.rotation.x,\r\n this._anchorMesh.rotation.z\r\n );\r\n }\r\n\r\n // Do not allow the object to turn more than a full circle\r\n totalTurnAmountOfDrag += projectDist;\r\n if (Math.abs(totalTurnAmountOfDrag) <= 2 * Math.PI) {\r\n if (this.rotationSnapDistance > 0) {\r\n const dragSteps = Math.floor(Math.abs(totalTurnAmountOfDrag) / this.rotationSnapDistance) * (totalTurnAmountOfDrag < 0 ? -1 : 1);\r\n const angle = this.rotationSnapDistance * dragSteps;\r\n projectDist = angle - previousProjectDist;\r\n previousProjectDist = angle;\r\n }\r\n if (i >= 8) {\r\n Quaternion.RotationYawPitchRollToRef(0, 0, projectDist, this._tmpQuaternion);\r\n } else if (i >= 4) {\r\n Quaternion.RotationYawPitchRollToRef(projectDist, 0, 0, this._tmpQuaternion);\r\n } else {\r\n Quaternion.RotationYawPitchRollToRef(0, projectDist, 0, this._tmpQuaternion);\r\n }\r\n\r\n // if using pivot, move anchor so mesh will be at relative (0,0,0) when parented\r\n if (this.attachedMesh.isUsingPivotMatrix()) {\r\n this._anchorMesh.position.copyFrom(this.attachedMesh.position);\r\n }\r\n // Rotate around center of bounding box\r\n this._anchorMesh.addChild(this.attachedMesh, Gizmo.PreserveScaling);\r\n if (this._anchorMesh.getScene().useRightHandedSystem) {\r\n this._tmpQuaternion.conjugateInPlace();\r\n }\r\n this._anchorMesh.rotationQuaternion!.multiplyToRef(this._tmpQuaternion, this._anchorMesh.rotationQuaternion!);\r\n this._anchorMesh.removeChild(this.attachedMesh, Gizmo.PreserveScaling);\r\n this.attachedMesh.setParent(originalParent, Gizmo.PreserveScaling);\r\n }\r\n this.updateBoundingBox();\r\n\r\n PivotTools._RestorePivotPoint(this.attachedMesh);\r\n }\r\n this._updateDummy();\r\n });\r\n\r\n // Selection/deselection\r\n _dragBehavior.onDragStartObservable.add(() => {\r\n this.onDragStartObservable.notifyObservers({});\r\n this._selectNode(sphere);\r\n });\r\n _dragBehavior.onDragEndObservable.add((event) => {\r\n this.onRotationSphereDragEndObservable.notifyObservers({});\r\n this._selectNode(null);\r\n this._updateDummy();\r\n this._unhoverMeshOnTouchUp(event.pointerInfo, sphere);\r\n });\r\n\r\n this._rotateSpheresParent.addChild(sphere);\r\n }\r\n this._rootMesh.addChild(this._rotateSpheresParent);\r\n\r\n // Create scale cubes\r\n this._scaleBoxesParent = new AbstractMesh(\"\", gizmoLayer.utilityLayerScene);\r\n this._scaleBoxesParent.rotationQuaternion = new Quaternion();\r\n for (let i = 0; i < 3; i++) {\r\n for (let j = 0; j < 3; j++) {\r\n for (let k = 0; k < 3; k++) {\r\n // create box for relevant axis\r\n const zeroAxisCount = (i === 1 ? 1 : 0) + (j === 1 ? 1 : 0) + (k === 1 ? 1 : 0);\r\n if (zeroAxisCount === 1 || zeroAxisCount === 3) {\r\n continue;\r\n }\r\n\r\n const box = CreateBox(\"\", { size: 1 }, gizmoLayer.utilityLayerScene);\r\n box.material = this._coloredMaterial;\r\n box._internalMetadata = zeroAxisCount === 2; // None homogenous scale handle\r\n box.isNearGrabbable = true;\r\n\r\n // Dragging logic\r\n const dragAxis = new Vector3(i - 1, j - 1, k - 1).normalize();\r\n const _dragBehavior = new PointerDragBehavior({ dragAxis: dragAxis });\r\n _dragBehavior.updateDragPlane = false;\r\n _dragBehavior.moveAttached = false;\r\n let totalRelativeDragDistance = 0;\r\n let previousScale = 0;\r\n box.addBehavior(_dragBehavior);\r\n _dragBehavior.onDragObservable.add((event) => {\r\n this.onScaleBoxDragObservable.notifyObservers({});\r\n if (this.attachedMesh) {\r\n const originalParent = this.attachedMesh.parent;\r\n if (originalParent && (originalParent as Mesh).scaling && (originalParent as Mesh).scaling.isNonUniformWithinEpsilon(0.001)) {\r\n Logger.Warn(\"BoundingBoxGizmo controls are not supported on child meshes with non-uniform parent scaling\");\r\n return;\r\n }\r\n PivotTools._RemoveAndStorePivotPoint(this.attachedMesh);\r\n let relativeDragDistance = (event.dragDistance / this._boundingDimensions.length()) * this._anchorMesh.scaling.length();\r\n totalRelativeDragDistance += relativeDragDistance;\r\n if (this.scalingSnapDistance > 0) {\r\n const dragSteps = Math.floor(Math.abs(totalRelativeDragDistance) / this.scalingSnapDistance) * (totalRelativeDragDistance < 0 ? -1 : 1);\r\n const scale = this.scalingSnapDistance * dragSteps;\r\n relativeDragDistance = scale - previousScale;\r\n previousScale = scale;\r\n }\r\n\r\n const deltaScale = new Vector3(relativeDragDistance, relativeDragDistance, relativeDragDistance);\r\n if (zeroAxisCount === 2) {\r\n // scale on 1 axis when using the anchor box in the face middle\r\n deltaScale.x *= Math.abs(dragAxis.x);\r\n deltaScale.y *= Math.abs(dragAxis.y);\r\n deltaScale.z *= Math.abs(dragAxis.z);\r\n }\r\n deltaScale.scaleInPlace(this._scaleDragSpeed);\r\n deltaScale.multiplyInPlace(this._axisFactor);\r\n this.updateBoundingBox();\r\n if (this.scalePivot) {\r\n this.attachedMesh.getWorldMatrix().getRotationMatrixToRef(this._tmpRotationMatrix);\r\n // Move anchor to desired pivot point (Bottom left corner + dimension/2)\r\n this._boundingDimensions.scaleToRef(0.5, this._tmpVector);\r\n Vector3.TransformCoordinatesToRef(this._tmpVector, this._tmpRotationMatrix, this._tmpVector);\r\n this._anchorMesh.position.subtractInPlace(this._tmpVector);\r\n this._boundingDimensions.multiplyToRef(this.scalePivot, this._tmpVector);\r\n Vector3.TransformCoordinatesToRef(this._tmpVector, this._tmpRotationMatrix, this._tmpVector);\r\n this._anchorMesh.position.addInPlace(this._tmpVector);\r\n } else {\r\n // Scale from the position of the opposite corner\r\n box.absolutePosition.subtractToRef(this._anchorMesh.position, this._tmpVector);\r\n this._anchorMesh.position.subtractInPlace(this._tmpVector);\r\n if (this.attachedMesh.isUsingPivotMatrix()) {\r\n this._anchorMesh.position.subtractInPlace(this.attachedMesh.getPivotPoint());\r\n }\r\n }\r\n\r\n this._anchorMesh.addChild(this.attachedMesh, Gizmo.PreserveScaling);\r\n this._anchorMesh.scaling.addInPlace(deltaScale);\r\n if (this._anchorMesh.scaling.x < 0 || this._anchorMesh.scaling.y < 0 || this._anchorMesh.scaling.z < 0) {\r\n this._anchorMesh.scaling.subtractInPlace(deltaScale);\r\n }\r\n this._anchorMesh.removeChild(this.attachedMesh, Gizmo.PreserveScaling);\r\n this.attachedMesh.setParent(originalParent, Gizmo.PreserveScaling);\r\n PivotTools._RestorePivotPoint(this.attachedMesh);\r\n }\r\n this._updateDummy();\r\n });\r\n\r\n // Selection/deselection\r\n _dragBehavior.onDragStartObservable.add(() => {\r\n this.onDragStartObservable.notifyObservers({});\r\n this._selectNode(box);\r\n totalRelativeDragDistance = 0;\r\n previousScale = 0;\r\n });\r\n _dragBehavior.onDragEndObservable.add((event) => {\r\n this.onScaleBoxDragEndObservable.notifyObservers({});\r\n this._selectNode(null);\r\n this._updateDummy();\r\n this._unhoverMeshOnTouchUp(event.pointerInfo, box);\r\n });\r\n\r\n this._scaleBoxesParent.addChild(box);\r\n }\r\n }\r\n }\r\n this._rootMesh.addChild(this._scaleBoxesParent);\r\n\r\n // Hover color change\r\n const pointerIds = new Array<AbstractMesh>();\r\n this._pointerObserver = gizmoLayer.utilityLayerScene.onPointerObservable.add((pointerInfo) => {\r\n if (!pointerIds[(<IPointerEvent>pointerInfo.event).pointerId]) {\r\n this._rotateSpheresParent\r\n .getChildMeshes()\r\n .concat(this._scaleBoxesParent.getChildMeshes())\r\n .forEach((mesh) => {\r\n if (pointerInfo.pickInfo && pointerInfo.pickInfo.pickedMesh == mesh) {\r\n pointerIds[(<IPointerEvent>pointerInfo.event).pointerId] = mesh;\r\n mesh.material = this._hoverColoredMaterial;\r\n this._isHovered = true;\r\n }\r\n });\r\n } else {\r\n if (pointerInfo.pickInfo && pointerInfo.pickInfo.pickedMesh != pointerIds[(<IPointerEvent>pointerInfo.event).pointerId]) {\r\n pointerIds[(<IPointerEvent>pointerInfo.event).pointerId].material = this._coloredMaterial;\r\n delete pointerIds[(<IPointerEvent>pointerInfo.event).pointerId];\r\n this._isHovered = false;\r\n }\r\n }\r\n });\r\n\r\n // Update bounding box positions\r\n this._renderObserver = this.gizmoLayer.originalScene.onBeforeRenderObservable.add(() => {\r\n // Only update the bounding box if scaling has changed\r\n if (this.attachedMesh && !this._existingMeshScale.equals(this.attachedMesh.scaling)) {\r\n this.updateBoundingBox();\r\n } else if (this.fixedDragMeshScreenSize || this.fixedDragMeshBoundsSize) {\r\n this._updateRotationSpheres();\r\n this._updateScaleBoxes();\r\n }\r\n\r\n // If drag mesh is enabled and dragging, update the attached mesh pose to match the drag mesh\r\n if (this._dragMesh && this.attachedMesh && this._pointerDragBehavior.dragging) {\r\n this._lineBoundingBox.position.rotateByQuaternionToRef(this._rootMesh.rotationQuaternion!, this._tmpVector);\r\n this.attachedMesh.setAbsolutePosition(this._dragMesh.position.add(this._tmpVector.scale(-1)));\r\n }\r\n });\r\n this.updateBoundingBox();\r\n }\r\n\r\n protected _attachedNodeChanged(value: Nullable<AbstractMesh>) {\r\n if (value) {\r\n // Reset anchor mesh to match attached mesh's scale\r\n // This is needed to avoid invalid box/sphere position on first drag\r\n this._anchorMesh.scaling.setAll(1);\r\n PivotTools._RemoveAndStorePivotPoint(value);\r\n const originalParent = value.parent;\r\n this._anchorMesh.addChild(value, Gizmo.PreserveScaling);\r\n this._anchorMesh.removeChild(value, Gizmo.PreserveScaling);\r\n value.setParent(originalParent, Gizmo.PreserveScaling);\r\n PivotTools._RestorePivotPoint(value);\r\n this.updateBoundingBox();\r\n value.getChildMeshes(false).forEach((m) => {\r\n m.markAsDirty(\"scaling\");\r\n });\r\n\r\n this.gizmoLayer.utilityLayerScene.onAfterRenderObservable.addOnce(() => {\r\n this._updateDummy();\r\n });\r\n }\r\n }\r\n\r\n protected _selectNode(selectedMesh: Nullable<Mesh>) {\r\n this._rotateSpheresParent\r\n .getChildMeshes()\r\n .concat(this._scaleBoxesParent.getChildMeshes())\r\n .forEach((m) => {\r\n m.isVisible = !selectedMesh || m == selectedMesh;\r\n });\r\n }\r\n\r\n protected _unhoverMeshOnTouchUp(pointerInfo: Nullable<PointerInfo>, selectedMesh: AbstractMesh) {\r\n // force unhover mesh if not a mouse event\r\n if (pointerInfo?.event instanceof PointerEvent && pointerInfo?.event.pointerType === \"touch\") {\r\n selectedMesh.material = this._coloredMaterial;\r\n }\r\n }\r\n\r\n /**\r\n * returns an array containing all boxes used for scaling (in increasing x, y and z orders)\r\n */\r\n public getScaleBoxes() {\r\n return this._scaleBoxesParent.getChildMeshes();\r\n }\r\n\r\n /**\r\n * Updates the bounding box information for the Gizmo\r\n */\r\n public updateBoundingBox() {\r\n if (this.attachedMesh) {\r\n PivotTools._RemoveAndStorePivotPoint(this.attachedMesh);\r\n\r\n // Store original parent\r\n const originalParent = this.attachedMesh.parent;\r\n this.attachedMesh.setParent(null, Gizmo.PreserveScaling);\r\n\r\n this._update();\r\n\r\n // Rotate based on axis\r\n if (!this.attachedMesh.rotationQuaternion) {\r\n this.attachedMesh.rotationQuaternion = Quaternion.RotationYawPitchRoll(this.attachedMesh.rotation.y, this.attachedMesh.rotation.x, this.attachedMesh.rotation.z);\r\n }\r\n if (!this._anchorMesh.rotationQuaternion) {\r\n this._anchorMesh.rotationQuaternion = Quaternion.RotationYawPitchRoll(this._anchorMesh.rotation.y, this._anchorMesh.rotation.x, this._anchorMesh.rotation.z);\r\n }\r\n this._anchorMesh.rotationQuaternion.copyFrom(this.attachedMesh.rotationQuaternion);\r\n\r\n // Store original position and reset mesh to origin before computing the bounding box\r\n this._tmpQuaternion.copyFrom(this.attachedMesh.rotationQuaternion);\r\n this._tmpVector.copyFrom(this.attachedMesh.position);\r\n this.attachedMesh.rotationQuaternion.set(0, 0, 0, 1);\r\n this.attachedMesh.position.set(0, 0, 0);\r\n\r\n // Update bounding dimensions/positions\r\n const boundingMinMax = this.attachedMesh.getHierarchyBoundingVectors(!this.ignoreChildren, this.includeChildPredicate);\r\n boundingMinMax.max.subtractToRef(boundingMinMax.min, this._boundingDimensions);\r\n\r\n // Update gizmo to match bounding box scaling and rotation\r\n // The position set here is the offset from the origin for the boundingbox when the attached mesh is at the origin\r\n // The position of the gizmo is then set to the attachedMesh in gizmo._update\r\n this._lineBoundingBox.scaling.copyFrom(this._boundingDimensions);\r\n this._lineBoundingBox.position.set(\r\n (boundingMinMax.max.x + boundingMinMax.min.x) / 2,\r\n (boundingMinMax.max.y + boundingMinMax.min.y) / 2,\r\n (boundingMinMax.max.z + boundingMinMax.min.z) / 2\r\n );\r\n this._rotateSpheresParent.position.copyFrom(this._lineBoundingBox.position);\r\n this._scaleBoxesParent.position.copyFrom(this._lineBoundingBox.position);\r\n this._lineBoundingBox.computeWorldMatrix();\r\n this._anchorMesh.position.copyFrom(this._lineBoundingBox.absolutePosition);\r\n\r\n // Restore position/rotation values\r\n this.attachedMesh.rotationQuaternion.copyFrom(this._tmpQuaternion);\r\n this.attachedMesh.position.copyFrom(this._tmpVector);\r\n\r\n // Restore original parent\r\n this.attachedMesh.setParent(originalParent, Gizmo.PreserveScaling);\r\n }\r\n\r\n this._updateRotationSpheres();\r\n this._updateScaleBoxes();\r\n\r\n if (this.attachedMesh) {\r\n this._existingMeshScale.copyFrom(this.attachedMesh.scaling);\r\n PivotTools._RestorePivotPoint(this.attachedMesh);\r\n }\r\n }\r\n\r\n protected _updateRotationSpheres() {\r\n const rotateSpheres = this._rotateSpheresParent.getChildMeshes();\r\n for (let i = 0; i < 3; i++) {\r\n for (let j = 0; j < 2; j++) {\r\n for (let k = 0; k < 2; k++) {\r\n const index = i * 4 + j * 2 + k;\r\n if (i == 0) {\r\n rotateSpheres[index].position.set(this._boundingDimensions.x / 2, this._boundingDimensions.y * j, this._boundingDimensions.z * k);\r\n rotateSpheres[index].position.addInPlace(new Vector3(-this._boundingDimensions.x / 2, -this._boundingDimensions.y / 2, -this._boundingDimensions.z / 2));\r\n rotateSpheres[index].lookAt(\r\n Vector3.Cross(rotateSpheres[index].position.normalizeToNew(), Vector3.Right()).normalizeToNew().add(rotateSpheres[index].position)\r\n );\r\n }\r\n if (i == 1) {\r\n rotateSpheres[index].position.set(this._boundingDimensions.x * j, this._boundingDimensions.y / 2, this._boundingDimensions.z * k);\r\n rotateSpheres[index].position.addInPlace(new Vector3(-this._boundingDimensions.x / 2, -this._boundingDimensions.y / 2, -this._boundingDimensions.z / 2));\r\n rotateSpheres[index].lookAt(\r\n Vector3.Cross(rotateSpheres[index].position.normalizeToNew(), Vector3.Up()).normalizeToNew().add(rotateSpheres[index].position)\r\n );\r\n }\r\n if (i == 2) {\r\n rotateSpheres[index].position.set(this._boundingDimensions.x * j, this._boundingDimensions.y * k, this._boundingDimensions.z / 2);\r\n rotateSpheres[index].position.addInPlace(new Vector3(-this._boundingDimensions.x / 2, -this._boundingDimensions.y / 2, -this._boundingDimensions.z / 2));\r\n rotateSpheres[index].lookAt(\r\n Vector3.Cross(rotateSpheres[index].position.normalizeToNew(), Vector3.Forward()).normalizeToNew().add(rotateSpheres[index].position)\r\n );\r\n }\r\n if (this.fixedDragMeshScreenSize && this.gizmoLayer.utilityLayerScene.activeCamera) {\r\n rotateSpheres[index].absolutePosition.subtractToRef(this.gizmoLayer.utilityLayerScene.activeCamera.position, this._tmpVector);\r\n const distanceFromCamera = (this.rotationSphereSize * this._tmpVector.length()) / this.fixedDragMeshScreenSizeDistanceFactor;\r\n rotateSpheres[index].scaling.set(distanceFromCamera, distanceFromCamera, distanceFromCamera);\r\n } else if (this.fixedDragMeshBoundsSize) {\r\n rotateSpheres[index].scaling.set(\r\n this.rotationSphereSize * this._boundingDimensions.x,\r\n this.rotationSphereSize * this._boundingDimensions.y,\r\n this.rotationSphereSize * this._boundingDimensions.z\r\n );\r\n } else {\r\n rotateSpheres[index].scaling.set(this.rotationSphereSize, this.rotationSphereSize, this.rotationSphereSize);\r\n }\r\n }\r\n }\r\n }\r\n }\r\n\r\n protected _updateScaleBoxes() {\r\n const scaleBoxes = this._scaleBoxesParent.getChildMeshes();\r\n let index = 0;\r\n for (let i = 0; i < 3; i++) {\r\n for (let j = 0; j < 3; j++) {\r\n for (let k = 0; k < 3; k++) {\r\n const zeroAxisCount = (i === 1 ? 1 : 0) + (j === 1 ? 1 : 0) + (k === 1 ? 1 : 0);\r\n if (zeroAxisCount === 1 || zeroAxisCount === 3) {\r\n continue;\r\n }\r\n if (scaleBoxes[index]) {\r\n scaleBoxes[index].position.set(this._boundingDimensions.x * (i / 2), this._boundingDimensions.y * (j / 2), this._boundingDimensions.z * (k / 2));\r\n scaleBoxes[index].position.addInPlace(new Vector3(-this._boundingDimensions.x / 2, -this._boundingDimensions.y / 2, -this._boundingDimensions.z / 2));\r\n if (this.fixedDragMeshScreenSize && this.gizmoLayer.utilityLayerScene.activeCamera) {\r\n scaleBoxes[index].absolutePosition.subtractToRef(this.gizmoLayer.utilityLayerScene.activeCamera.position, this._tmpVector);\r\n const distanceFromCamera = (this.scaleBoxSize * this._tmpVector.length()) / this.fixedDragMeshScreenSizeDistanceFactor;\r\n scaleBoxes[index].scaling.set(distanceFromCamera, distanceFromCamera, distanceFromCamera);\r\n } else if (this.fixedDragMeshBoundsSize) {\r\n scaleBoxes[index].scaling.set(\r\n this.scaleBoxSize * this._boundingDimensions.x,\r\n this.scaleBoxSize * this._boundingDimensions.y,\r\n this.scaleBoxSize * this._boundingDimensions.z\r\n );\r\n } else {\r\n scaleBoxes[index].scaling.set(this.scaleBoxSize, this.scaleBoxSize, this.scaleBoxSize);\r\n }\r\n }\r\n index++;\r\n }\r\n }\r\n }\r\n }\r\n\r\n /**\r\n * Enables rotation on the specified axis and disables rotation on the others\r\n * @param axis The list of axis that should be enabled (eg. \"xy\" or \"xyz\")\r\n */\r\n public setEnabledRotationAxis(axis: string) {\r\n this._rotateSpheresParent.getChildMeshes().forEach((m, i) => {\r\n if (i < 4) {\r\n m.setEnabled(axis.indexOf(\"x\") != -1);\r\n } else if (i < 8) {\r\n m.setEnabled(axis.indexOf(\"y\") != -1);\r\n } else {\r\n m.setEnabled(axis.indexOf(\"z\") != -1);\r\n }\r\n });\r\n }\r\n\r\n /**\r\n * Enables/disables scaling\r\n * @param enable if scaling should be enabled\r\n * @param homogeneousScaling defines if scaling should only be homogeneous\r\n */\r\n public setEnabledScaling(enable: boolean, homogeneousScaling = false) {\r\n this._scaleBoxesParent.getChildMeshes().forEach((m) => {\r\n let enableMesh = enable;\r\n // Disable heterogeneous scale handles if requested.\r\n if (homogeneousScaling && m._internalMetadata === true) {\r\n enableMesh = false;\r\n }\r\n m.setEnabled(enableMesh);\r\n });\r\n }\r\n\r\n protected _updateDummy() {\r\n if (this._dragMesh) {\r\n this._dragMesh.position.copyFrom(this._lineBoundingBox.getAbsolutePosition());\r\n this._dragMesh.scaling.copyFrom(this._lineBoundingBox.scaling);\r\n this._dragMesh.rotationQuaternion!.copyFrom(this._rootMesh.rotationQuaternion!);\r\n }\r\n }\r\n\r\n /**\r\n * Enables a pointer drag behavior on the bounding box of the gizmo\r\n */\r\n public enableDragBehavior() {\r\n this._dragMesh = CreateBox(\"dummy\", { size: 1 }, this.gizmoLayer.utilityLayerScene);\r\n this._dragMesh.visibility = 0;\r\n this._dragMesh.rotationQuaternion = new Quaternion();\r\n this._pointerDragBehavior.useObjectOrientationForDragging = false;\r\n this._dragMesh.addBehavior(this._pointerDragBehavior);\r\n }\r\n\r\n /**\r\n * Disposes of the gizmo\r\n */\r\n public dispose() {\r\n this.gizmoLayer.utilityLayerScene.onPointerObservable.remove(this._pointerObserver);\r\n this.gizmoLayer.originalScene.onBeforeRenderObservable.remove(this._renderObserver);\r\n this._lineBoundingBox.dispose();\r\n this._rotateSpheresParent.dispose();\r\n this._scaleBoxesParent.dispose();\r\n if (this._dragMesh) {\r\n this._dragMesh.dispose();\r\n }\r\n super.dispose();\r\n }\r\n\r\n /**\r\n * Makes a mesh not pickable and wraps the mesh inside of a bounding box mesh that is pickable. (This is useful to avoid picking within complex geometry)\r\n * @param mesh the mesh to wrap in the bounding box mesh and make not pickable\r\n * @returns the bounding box mesh with the passed in mesh as a child\r\n */\r\n public static MakeNotPickableAndWrapInBoundingBox(mesh: Mesh): Mesh {\r\n const makeNotPickable = (root: AbstractMesh) => {\r\n root.isPickable = false;\r\n root.getChildMeshes().forEach((c) => {\r\n makeNotPickable(c);\r\n });\r\n };\r\n makeNotPickable(mesh);\r\n\r\n // Reset position to get bounding box from origin with no rotation\r\n if (!mesh.rotationQuaternion) {\r\n mesh.rotationQuaternion = Quaternion.RotationYawPitchRoll(mesh.rotation.y, mesh.rotation.x, mesh.rotation.z);\r\n }\r\n const oldPos = mesh.position.clone();\r\n const oldRot = mesh.rotationQuaternion.clone();\r\n mesh.rotationQuaternion.set(0, 0, 0, 1);\r\n mesh.position.set(0, 0, 0);\r\n\r\n // Update bounding dimensions/positions\r\n const box = CreateBox(\"box\", { size: 1 }, mesh.getScene());\r\n const boundingMinMax = mesh.getHierarchyBoundingVectors();\r\n boundingMinMax.max.subtractToRef(boundingMinMax.min, box.scaling);\r\n\r\n // Adjust scale to avoid undefined behavior when adding child\r\n if (box.scaling.y === 0) {\r\n box.scaling.y = Epsilon;\r\n }\r\n if (box.scaling.x === 0) {\r\n box.scaling.x = Epsilon;\r\n }\r\n if (box.scaling.z === 0) {\r\n box.scaling.z = Epsilon;\r\n }\r\n\r\n box.position.set((boundingMinMax.max.x + boundingMinMax.min.x) / 2, (boundingMinMax.max.y + boundingMinMax.min.y) / 2, (boundingMinMax.max.z + boundingMinMax.min.z) / 2);\r\n\r\n // Restore original positions\r\n mesh.addChild(box);\r\n mesh.rotationQuaternion.copyFrom(oldRot);\r\n mesh.position.copyFrom(oldPos);\r\n\r\n // Reverse parenting\r\n mesh.removeChild(box);\r\n\r\n box.addChild(mesh);\r\n box.visibility = 0;\r\n return box;\r\n }\r\n /**\r\n * CustomMeshes are not supported by this gizmo\r\n */\r\n public setCustomMesh() {\r\n Logger.Error(\"Custom meshes are not supported on this gizmo\");\r\n }\r\n}\r\n"]}
1
+ {"version":3,"file":"boundingBoxGizmo.js","sourceRoot":"","sources":["../../../../dev/core/src/Gizmos/boundingBoxGizmo.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,UAAU,EAAE,MAAM,oBAAoB,CAAC;AAChD,OAAO,EAAE,MAAM,EAAE,MAAM,gBAAgB,CAAC;AAIxC,OAAO,EAAE,UAAU,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,sBAAsB,CAAC;AACnE,OAAO,EAAE,YAAY,EAAE,MAAM,wBAAwB,CAAC;AAEtD,OAAO,EAAE,YAAY,EAAE,MAAM,kCAAkC,CA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C,EAAE;YACrB,GAAG,CAAC,OAAO,CAAC,CAAC,GAAG,OAAO,CAAC;SAC3B;QACD,IAAI,GAAG,CAAC,OAAO,CAAC,CAAC,KAAK,CAAC,EAAE;YACrB,GAAG,CAAC,OAAO,CAAC,CAAC,GAAG,OAAO,CAAC;SAC3B;QACD,IAAI,GAAG,CAAC,OAAO,CAAC,CAAC,KAAK,CAAC,EAAE;YACrB,GAAG,CAAC,OAAO,CAAC,CAAC,GAAG,OAAO,CAAC;SAC3B;QAED,GAAG,CAAC,QAAQ,CAAC,GAAG,CAAC,CAAC,cAAc,CAAC,GAAG,CAAC,CAAC,GAAG,cAAc,CAAC,GAAG,CAAC,CAAC,CAAC,GAAG,CAAC,EAAE,CAAC,cAAc,CAAC,GAAG,CAAC,CAAC,GAAG,cAAc,CAAC,GAAG,CAAC,CAAC,CAAC,GAAG,CAAC,EAAE,CAAC,cAAc,CAAC,GAAG,CAAC,CAAC,GAAG,cAAc,CAAC,GAAG,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC;QAE1K,6BAA6B;QAC7B,IAAI,CAAC,QAAQ,CAAC,GAAG,CAAC,CAAC;QACnB,IAAI,CAAC,kBAAkB,CAAC,QAAQ,CAAC,MAAM,CAAC,CAAC;QACzC,IAAI,CAAC,QAAQ,CAAC,QAAQ,CAAC,MAAM,CAAC,CAAC;QAE/B,oBAAoB;QACpB,IAAI,CAAC,WAAW,CAAC,GAAG,CAAC,CAAC;QAEtB,GAAG,CAAC,QAAQ,CAAC,IAAI,CAAC,CAAC;QACnB,GAAG,CAAC,UAAU,GAAG,CAAC,CAAC;QACnB,OAAO,GAAG,CAAC;IACf,CAAC;IACD;;OAEG;IACI,aAAa;QAChB,MAAM,CAAC,KAAK,CAAC,+CAA+C,CAAC,CAAC;IAClE,CAAC;CACJ","sourcesContent":["import type { Observer } from \"../Misc/observable\";\r\nimport { Observable } from \"../Misc/observable\";\r\nimport { Logger } from \"../Misc/logger\";\r\nimport type { Nullable } from \"../types\";\r\nimport type { PointerInfo } from \"../Events/pointerEvents\";\r\nimport type { Scene } from \"../scene\";\r\nimport { Quaternion, Matrix, Vector3 } from \"../Maths/math.vector\";\r\nimport { AbstractMesh } from \"../Meshes/abstractMesh\";\r\nimport type { Mesh } from \"../Meshes/mesh\";\r\nimport { CreateSphere } from \"../Meshes/Builders/sphereBuilder\";\r\nimport { CreateBox } from \"../Meshes/Builders/boxBuilder\";\r\nimport { CreateLines } from \"../Meshes/Builders/linesBuilder\";\r\nimport { PointerDragBehavior } from \"../Behaviors/Meshes/pointerDragBehavior\";\r\nimport type { IGizmo } from \"./gizmo\";\r\nimport { Gizmo } from \"./gizmo\";\r\nimport { UtilityLayerRenderer } from \"../Rendering/utilityLayerRenderer\";\r\nimport { StandardMaterial } from \"../Materials/standardMaterial\";\r\nimport { PivotTools } from \"../Misc/pivotTools\";\r\nimport { Color3 } from \"../Maths/math.color\";\r\nimport type { LinesMesh } from \"../Meshes/linesMesh\";\r\nimport { Epsilon } from \"../Maths/math.constants\";\r\nimport type { IPointerEvent } from \"../Events/deviceInputEvents\";\r\n\r\n/**\r\n * Interface for bounding box gizmo\r\n */\r\nexport interface IBoundingBoxGizmo extends IGizmo {\r\n /**\r\n * If child meshes should be ignored when calculating the bounding box. This should be set to true to avoid perf hits with heavily nested meshes.\r\n */\r\n ignoreChildren: boolean;\r\n /**\r\n * Returns true if a descendant should be included when computing the bounding box. When null, all descendants are included. If ignoreChildren is set this will be ignored.\r\n */\r\n includeChildPredicate: Nullable<(abstractMesh: AbstractMesh) => boolean>;\r\n /** The size of the rotation spheres attached to the bounding box */\r\n rotationSphereSize: number;\r\n /** The size of the scale boxes attached to the bounding box */\r\n scaleBoxSize: number;\r\n /**\r\n * If set, the rotation spheres and scale boxes will increase in size based on the distance away from the camera to have a consistent screen size\r\n * Note : fixedDragMeshScreenSize takes precedence over fixedDragMeshBoundsSize if both are true\r\n */\r\n fixedDragMeshScreenSize: boolean;\r\n /**\r\n * If set, the rotation spheres and scale boxes will increase in size based on the size of the bounding box\r\n * Note : fixedDragMeshScreenSize takes precedence over fixedDragMeshBoundsSize if both are true\r\n */\r\n fixedDragMeshBoundsSize: boolean;\r\n /**\r\n * The distance away from the object which the draggable meshes should appear world sized when fixedDragMeshScreenSize is set to true\r\n */\r\n fixedDragMeshScreenSizeDistanceFactor: number;\r\n /** Fired when a rotation sphere or scale box is dragged */\r\n onDragStartObservable: Observable<{}>;\r\n /** Fired when a scale box is dragged */\r\n onScaleBoxDragObservable: Observable<{}>;\r\n /** Fired when a scale box drag is ended */\r\n onScaleBoxDragEndObservable: Observable<{}>;\r\n /** Fired when a rotation sphere is dragged */\r\n onRotationSphereDragObservable: Observable<{}>;\r\n /** Fired when a rotation sphere drag is ended */\r\n onRotationSphereDragEndObservable: Observable<{}>;\r\n /** Relative bounding box pivot used when scaling the attached node. */\r\n scalePivot: Nullable<Vector3>;\r\n /** Scale factor vector used for masking some axis */\r\n axisFactor: Vector3;\r\n /** Scale factor scalar affecting all axes' drag speed */\r\n scaleDragSpeed: number;\r\n /**\r\n * Sets the color of the bounding box gizmo\r\n * @param color the color to set\r\n */\r\n setColor(color: Color3): void;\r\n /** Returns an array containing all boxes used for scaling (in increasing x, y and z orders) */\r\n getScaleBoxes(): AbstractMesh[];\r\n /** Updates the bounding box information for the Gizmo */\r\n updateBoundingBox(): void;\r\n /**\r\n * Enables rotation on the specified axis and disables rotation on the others\r\n * @param axis The list of axis that should be enabled (eg. \"xy\" or \"xyz\")\r\n */\r\n setEnabledRotationAxis(axis: string): void;\r\n /**\r\n * Enables/disables scaling\r\n * @param enable if scaling should be enabled\r\n * @param homogeneousScaling defines if scaling should only be homogeneous\r\n */\r\n setEnabledScaling(enable: boolean, homogeneousScaling?: boolean): void;\r\n /** Enables a pointer drag behavior on the bounding box of the gizmo */\r\n enableDragBehavior(): void;\r\n\r\n /** Default material used to render when gizmo is not disabled or hovered */\r\n coloredMaterial: StandardMaterial;\r\n /** Material used to render when gizmo is hovered with mouse*/\r\n hoverMaterial: StandardMaterial;\r\n\r\n /** Drag distance in babylon units that the gizmo will snap scaling to when dragged */\r\n scalingSnapDistance: number;\r\n /** Drag distance in babylon units that the gizmo will snap rotation to when dragged */\r\n rotationSnapDistance: number;\r\n}\r\n\r\n/**\r\n * Bounding box gizmo\r\n */\r\nexport class BoundingBoxGizmo extends Gizmo implements IBoundingBoxGizmo {\r\n protected _lineBoundingBox: AbstractMesh;\r\n protected _rotateSpheresParent: AbstractMesh;\r\n protected _scaleBoxesParent: AbstractMesh;\r\n protected _boundingDimensions = new Vector3(1, 1, 1);\r\n protected _renderObserver: Nullable<Observer<Scene>> = null;\r\n protected _pointerObserver: Nullable<Observer<PointerInfo>> = null;\r\n protected _scaleDragSpeed = 0.2;\r\n\r\n private _tmpQuaternion = new Quaternion();\r\n private _tmpVector = new Vector3(0, 0, 0);\r\n private _tmpRotationMatrix = new Matrix();\r\n /**\r\n * If child meshes should be ignored when calculating the bounding box. This should be set to true to avoid perf hits with heavily nested meshes (Default: false)\r\n */\r\n public ignoreChildren = false;\r\n /**\r\n * Returns true if a descendant should be included when computing the bounding box. When null, all descendants are included. If ignoreChildren is set this will be ignored. (Default: null)\r\n */\r\n public includeChildPredicate: Nullable<(abstractMesh: AbstractMesh) => boolean> = null;\r\n\r\n /**\r\n * The size of the rotation spheres attached to the bounding box (Default: 0.1)\r\n */\r\n public rotationSphereSize = 0.1;\r\n /**\r\n * The size of the scale boxes attached to the bounding box (Default: 0.1)\r\n */\r\n public scaleBoxSize = 0.1;\r\n /**\r\n * If set, the rotation spheres and scale boxes will increase in size based on the distance away from the camera to have a consistent screen size (Default: false)\r\n * Note : fixedDragMeshScreenSize takes precedence over fixedDragMeshBoundsSize if both are true\r\n */\r\n public fixedDragMeshScreenSize = false;\r\n /**\r\n * If set, the rotation spheres and scale boxes will increase in size based on the size of the bounding box\r\n * Note : fixedDragMeshScreenSize takes precedence over fixedDragMeshBoundsSize if both are true\r\n */\r\n public fixedDragMeshBoundsSize = false;\r\n /**\r\n * The distance away from the object which the draggable meshes should appear world sized when fixedDragMeshScreenSize is set to true (default: 10)\r\n */\r\n public fixedDragMeshScreenSizeDistanceFactor = 10;\r\n /**\r\n * Drag distance in babylon units that the gizmo will snap scaling to when dragged\r\n */\r\n public scalingSnapDistance = 0;\r\n /**\r\n * Drag distance in babylon units that the gizmo will snap rotation to when dragged\r\n */\r\n public rotationSnapDistance = 0;\r\n /**\r\n * Fired when a rotation sphere or scale box is dragged\r\n */\r\n public onDragStartObservable = new Observable<{}>();\r\n /**\r\n * Fired when a scale box is dragged\r\n */\r\n public onScaleBoxDragObservable = new Observable<{}>();\r\n /**\r\n * Fired when a scale box drag is ended\r\n */\r\n public onScaleBoxDragEndObservable = new Observable<{}>();\r\n /**\r\n * Fired when a rotation sphere is dragged\r\n */\r\n public onRotationSphereDragObservable = new Observable<{}>();\r\n /**\r\n * Fired when a rotation sphere drag is ended\r\n */\r\n public onRotationSphereDragEndObservable = new Observable<{}>();\r\n /**\r\n * Relative bounding box pivot used when scaling the attached node. When null object with scale from the opposite corner. 0.5,0.5,0.5 for center and 0.5,0,0.5 for bottom (Default: null)\r\n */\r\n public scalePivot: Nullable<Vector3> = null;\r\n /**\r\n * Scale factor used for masking some axis\r\n */\r\n protected _axisFactor = new Vector3(1, 1, 1);\r\n\r\n /**\r\n * Sets the axis factor\r\n * @param factor the Vector3 value\r\n */\r\n public set axisFactor(factor: Vector3) {\r\n this._axisFactor = factor;\r\n // update scale cube visibility\r\n const scaleBoxes = this._scaleBoxesParent.getChildMeshes();\r\n let index = 0;\r\n for (let i = 0; i < 3; i++) {\r\n for (let j = 0; j < 3; j++) {\r\n for (let k = 0; k < 3; k++) {\r\n const zeroAxisCount = (i === 1 ? 1 : 0) + (j === 1 ? 1 : 0) + (k === 1 ? 1 : 0);\r\n if (zeroAxisCount === 1 || zeroAxisCount === 3) {\r\n continue;\r\n }\r\n if (scaleBoxes[index]) {\r\n const dragAxis = new Vector3(i - 1, j - 1, k - 1);\r\n dragAxis.multiplyInPlace(this._axisFactor);\r\n scaleBoxes[index].setEnabled(dragAxis.lengthSquared() > Epsilon);\r\n }\r\n index++;\r\n }\r\n }\r\n }\r\n }\r\n\r\n /**\r\n * Gets the axis factor\r\n * @returns the Vector3 factor value\r\n */\r\n public get axisFactor(): Vector3 {\r\n return this._axisFactor;\r\n }\r\n\r\n /**\r\n * Sets scale drag speed value\r\n * @param value the new speed value\r\n */\r\n public set scaleDragSpeed(value: number) {\r\n this._scaleDragSpeed = value;\r\n }\r\n\r\n /**\r\n * Gets scale drag speed\r\n * @returns the scale speed number\r\n */\r\n public get scaleDragSpeed(): number {\r\n return this._scaleDragSpeed;\r\n }\r\n\r\n /**\r\n * Mesh used as a pivot to rotate the attached node\r\n */\r\n protected _anchorMesh: AbstractMesh;\r\n\r\n protected _existingMeshScale = new Vector3();\r\n\r\n // Dragging\r\n protected _dragMesh: Nullable<Mesh> = null;\r\n protected _pointerDragBehavior = new PointerDragBehavior();\r\n\r\n protected _coloredMaterial: StandardMaterial;\r\n protected _hoverColoredMaterial: StandardMaterial;\r\n\r\n /** Default material used to render when gizmo is not disabled or hovered */\r\n public get coloredMaterial() {\r\n return this._coloredMaterial;\r\n }\r\n\r\n /** Material used to render when gizmo is hovered with mouse*/\r\n public get hoverMaterial() {\r\n return this._hoverColoredMaterial;\r\n }\r\n /**\r\n * Get the pointerDragBehavior\r\n */\r\n public get pointerDragBehavior(): PointerDragBehavior {\r\n return this._pointerDragBehavior;\r\n }\r\n\r\n /**\r\n * Sets the color of the bounding box gizmo\r\n * @param color the color to set\r\n */\r\n public setColor(color: Color3) {\r\n this._coloredMaterial.emissiveColor = color;\r\n this._hoverColoredMaterial.emissiveColor = color.clone().add(new Color3(0.3, 0.3, 0.3));\r\n this._lineBoundingBox.getChildren().forEach((l) => {\r\n if ((l as LinesMesh).color) {\r\n (l as LinesMesh).color = color;\r\n }\r\n });\r\n }\r\n /**\r\n * Creates an BoundingBoxGizmo\r\n * @param color The color of the gizmo\r\n * @param gizmoLayer The utility layer the gizmo will be added to\r\n */\r\n constructor(color: Color3 = Color3.Gray(), gizmoLayer: UtilityLayerRenderer = UtilityLayerRenderer.DefaultKeepDepthUtilityLayer) {\r\n super(gizmoLayer);\r\n\r\n // Do not update the gizmo's scale so it has a fixed size to the object its attached to\r\n this.updateScale = false;\r\n\r\n this._anchorMesh = new AbstractMesh(\"anchor\", gizmoLayer.utilityLayerScene);\r\n // Create Materials\r\n this._coloredMaterial = new StandardMaterial(\"\", gizmoLayer.utilityLayerScene);\r\n this._coloredMaterial.disableLighting = true;\r\n this._hoverColoredMaterial = new StandardMaterial(\"\", gizmoLayer.utilityLayerScene);\r\n this._hoverColoredMaterial.disableLighting = true;\r\n\r\n // Build bounding box out of lines\r\n this._lineBoundingBox = new AbstractMesh(\"\", gizmoLayer.utilityLayerScene);\r\n this._lineBoundingBox.rotationQuaternion = new Quaternion();\r\n const lines = [];\r\n lines.push(CreateLines(\"lines\", { points: [new Vector3(0, 0, 0), new Vector3(this._boundingDimensions.x, 0, 0)] }, gizmoLayer.utilityLayerScene));\r\n lines.push(CreateLines(\"lines\", { points: [new Vector3(0, 0, 0), new Vector3(0, this._boundingDimensions.y, 0)] }, gizmoLayer.utilityLayerScene));\r\n lines.push(CreateLines(\"lines\", { points: [new Vector3(0, 0, 0), new Vector3(0, 0, this._boundingDimensions.z)] }, gizmoLayer.utilityLayerScene));\r\n lines.push(\r\n CreateLines(\r\n \"lines\",\r\n { points: [new Vector3(this._boundingDimensions.x, 0, 0), new Vector3(this._boundingDimensions.x, this._boundingDimensions.y, 0)] },\r\n gizmoLayer.utilityLayerScene\r\n )\r\n );\r\n lines.push(\r\n CreateLines(\r\n \"lines\",\r\n { points: [new Vector3(this._boundingDimensions.x, 0, 0), new Vector3(this._boundingDimensions.x, 0, this._boundingDimensions.z)] },\r\n gizmoLayer.utilityLayerScene\r\n )\r\n );\r\n lines.push(\r\n CreateLines(\r\n \"lines\",\r\n { points: [new Vector3(0, this._boundingDimensions.y, 0), new Vector3(this._boundingDimensions.x, this._boundingDimensions.y, 0)] },\r\n gizmoLayer.utilityLayerScene\r\n )\r\n );\r\n lines.push(\r\n CreateLines(\r\n \"lines\",\r\n { points: [new Vector3(0, this._boundingDimensions.y, 0), new Vector3(0, this._boundingDimensions.y, this._boundingDimensions.z)] },\r\n gizmoLayer.utilityLayerScene\r\n )\r\n );\r\n lines.push(\r\n CreateLines(\r\n \"lines\",\r\n { points: [new Vector3(0, 0, this._boundingDimensions.z), new Vector3(this._boundingDimensions.x, 0, this._boundingDimensions.z)] },\r\n gizmoLayer.utilityLayerScene\r\n )\r\n );\r\n lines.push(\r\n CreateLines(\r\n \"lines\",\r\n { points: [new Vector3(0, 0, this._boundingDimensions.z), new Vector3(0, this._boundingDimensions.y, this._boundingDimensions.z)] },\r\n gizmoLayer.utilityLayerScene\r\n )\r\n );\r\n lines.push(\r\n CreateLines(\r\n \"lines\",\r\n {\r\n points: [\r\n new Vector3(this._boundingDimensions.x, this._boundingDimensions.y, this._boundingDimensions.z),\r\n new Vector3(0, this._boundingDimensions.y, this._boundingDimensions.z),\r\n ],\r\n },\r\n gizmoLayer.utilityLayerScene\r\n )\r\n );\r\n lines.push(\r\n CreateLines(\r\n \"lines\",\r\n {\r\n points: [\r\n new Vector3(this._boundingDimensions.x, this._boundingDimensions.y, this._boundingDimensions.z),\r\n new Vector3(this._boundingDimensions.x, 0, this._boundingDimensions.z),\r\n ],\r\n },\r\n gizmoLayer.utilityLayerScene\r\n )\r\n );\r\n lines.push(\r\n CreateLines(\r\n \"lines\",\r\n {\r\n points: [\r\n new Vector3(this._boundingDimensions.x, this._boundingDimensions.y, this._boundingDimensions.z),\r\n new Vector3(this._boundingDimensions.x, this._boundingDimensions.y, 0),\r\n ],\r\n },\r\n gizmoLayer.utilityLayerScene\r\n )\r\n );\r\n lines.forEach((l) => {\r\n l.color = color;\r\n l.position.addInPlace(new Vector3(-this._boundingDimensions.x / 2, -this._boundingDimensions.y / 2, -this._boundingDimensions.z / 2));\r\n l.isPickable = false;\r\n this._lineBoundingBox.addChild(l);\r\n });\r\n this._rootMesh.addChild(this._lineBoundingBox);\r\n\r\n this.setColor(color);\r\n\r\n // Create rotation spheres\r\n this._rotateSpheresParent = new AbstractMesh(\"\", gizmoLayer.utilityLayerScene);\r\n this._rotateSpheresParent.rotationQuaternion = new Quaternion();\r\n for (let i = 0; i < 12; i++) {\r\n const sphere = CreateSphere(\"\", { diameter: 1 }, gizmoLayer.utilityLayerScene);\r\n sphere.rotationQuaternion = new Quaternion();\r\n sphere.material = this._coloredMaterial;\r\n sphere.isNearGrabbable = true;\r\n\r\n // Drag behavior\r\n const _dragBehavior = new PointerDragBehavior({});\r\n _dragBehavior.moveAttached = false;\r\n _dragBehavior.updateDragPlane = false;\r\n sphere.addBehavior(_dragBehavior);\r\n const startingTurnDirection = new Vector3(1, 0, 0);\r\n let totalTurnAmountOfDrag = 0;\r\n let previousProjectDist = 0;\r\n _dragBehavior.onDragStartObservable.add(() => {\r\n startingTurnDirection.copyFrom(sphere.forward);\r\n totalTurnAmountOfDrag = 0;\r\n previousProjectDist = 0;\r\n });\r\n _dragBehavior.onDragObservable.add((event) => {\r\n this.onRotationSphereDragObservable.notifyObservers({});\r\n if (this.attachedMesh) {\r\n const originalParent = this.attachedMesh.parent;\r\n if (originalParent && (originalParent as Mesh).scaling && (originalParent as Mesh).scaling.isNonUniformWithinEpsilon(0.001)) {\r\n Logger.Warn(\"BoundingBoxGizmo controls are not supported on child meshes with non-uniform parent scaling\");\r\n return;\r\n }\r\n PivotTools._RemoveAndStorePivotPoint(this.attachedMesh);\r\n\r\n const worldDragDirection = startingTurnDirection;\r\n\r\n // Project the world right on to the drag plane\r\n const toSub = event.dragPlaneNormal.scale(Vector3.Dot(event.dragPlaneNormal, worldDragDirection));\r\n const dragAxis = worldDragDirection.subtract(toSub).normalizeToNew();\r\n\r\n // project drag delta on to the resulting drag axis and rotate based on that\r\n let projectDist = Vector3.Dot(dragAxis, event.delta) < 0 ? Math.abs(event.delta.length()) : -Math.abs(event.delta.length());\r\n\r\n // Make rotation relative to size of mesh.\r\n projectDist = (projectDist / this._boundingDimensions.length()) * this._anchorMesh.scaling.length();\r\n\r\n // Rotate based on axis\r\n if (!this.attachedMesh.rotationQuaternion) {\r\n this.attachedMesh.rotationQuaternion = Quaternion.RotationYawPitchRoll(\r\n this.attachedMesh.rotation.y,\r\n this.attachedMesh.rotation.x,\r\n this.attachedMesh.rotation.z\r\n );\r\n }\r\n if (!this._anchorMesh.rotationQuaternion) {\r\n this._anchorMesh.rotationQuaternion = Quaternion.RotationYawPitchRoll(\r\n this._anchorMesh.rotation.y,\r\n this._anchorMesh.rotation.x,\r\n this._anchorMesh.rotation.z\r\n );\r\n }\r\n\r\n // Do not allow the object to turn more than a full circle\r\n totalTurnAmountOfDrag += projectDist;\r\n if (Math.abs(totalTurnAmountOfDrag) <= 2 * Math.PI) {\r\n if (this.rotationSnapDistance > 0) {\r\n const dragSteps = Math.floor(Math.abs(totalTurnAmountOfDrag) / this.rotationSnapDistance) * (totalTurnAmountOfDrag < 0 ? -1 : 1);\r\n const angle = this.rotationSnapDistance * dragSteps;\r\n projectDist = angle - previousProjectDist;\r\n previousProjectDist = angle;\r\n }\r\n if (i >= 8) {\r\n Quaternion.RotationYawPitchRollToRef(0, 0, projectDist, this._tmpQuaternion);\r\n } else if (i >= 4) {\r\n Quaternion.RotationYawPitchRollToRef(projectDist, 0, 0, this._tmpQuaternion);\r\n } else {\r\n Quaternion.RotationYawPitchRollToRef(0, projectDist, 0, this._tmpQuaternion);\r\n }\r\n\r\n // if using pivot, move anchor so mesh will be at relative (0,0,0) when parented\r\n if (this.attachedMesh.isUsingPivotMatrix()) {\r\n this._anchorMesh.position.copyFrom(this.attachedMesh.position);\r\n }\r\n // Rotate around center of bounding box\r\n this._anchorMesh.addChild(this.attachedMesh);\r\n if (this._anchorMesh.getScene().useRightHandedSystem) {\r\n this._tmpQuaternion.conjugateInPlace();\r\n }\r\n this._tmpQuaternion.normalize();\r\n this._anchorMesh.rotationQuaternion!.multiplyToRef(this._tmpQuaternion, this._anchorMesh.rotationQuaternion!);\r\n this._anchorMesh.rotationQuaternion.normalize();\r\n this._anchorMesh.removeChild(this.attachedMesh);\r\n this.attachedMesh.setParent(originalParent);\r\n }\r\n this.updateBoundingBox();\r\n\r\n PivotTools._RestorePivotPoint(this.attachedMesh);\r\n }\r\n this._updateDummy();\r\n });\r\n\r\n // Selection/deselection\r\n _dragBehavior.onDragStartObservable.add(() => {\r\n this.onDragStartObservable.notifyObservers({});\r\n this._selectNode(sphere);\r\n });\r\n _dragBehavior.onDragEndObservable.add((event) => {\r\n this.onRotationSphereDragEndObservable.notifyObservers({});\r\n this._selectNode(null);\r\n this._updateDummy();\r\n this._unhoverMeshOnTouchUp(event.pointerInfo, sphere);\r\n });\r\n\r\n this._rotateSpheresParent.addChild(sphere);\r\n }\r\n this._rootMesh.addChild(this._rotateSpheresParent);\r\n\r\n // Create scale cubes\r\n this._scaleBoxesParent = new AbstractMesh(\"\", gizmoLayer.utilityLayerScene);\r\n this._scaleBoxesParent.rotationQuaternion = new Quaternion();\r\n for (let i = 0; i < 3; i++) {\r\n for (let j = 0; j < 3; j++) {\r\n for (let k = 0; k < 3; k++) {\r\n // create box for relevant axis\r\n const zeroAxisCount = (i === 1 ? 1 : 0) + (j === 1 ? 1 : 0) + (k === 1 ? 1 : 0);\r\n if (zeroAxisCount === 1 || zeroAxisCount === 3) {\r\n continue;\r\n }\r\n\r\n const box = CreateBox(\"\", { size: 1 }, gizmoLayer.utilityLayerScene);\r\n box.material = this._coloredMaterial;\r\n box._internalMetadata = zeroAxisCount === 2; // None homogenous scale handle\r\n box.isNearGrabbable = true;\r\n\r\n // Dragging logic\r\n const dragAxis = new Vector3(i - 1, j - 1, k - 1).normalize();\r\n const _dragBehavior = new PointerDragBehavior({ dragAxis: dragAxis });\r\n _dragBehavior.updateDragPlane = false;\r\n _dragBehavior.moveAttached = false;\r\n let totalRelativeDragDistance = 0;\r\n let previousScale = 0;\r\n box.addBehavior(_dragBehavior);\r\n _dragBehavior.onDragObservable.add((event) => {\r\n this.onScaleBoxDragObservable.notifyObservers({});\r\n if (this.attachedMesh) {\r\n const originalParent = this.attachedMesh.parent;\r\n if (originalParent && (originalParent as Mesh).scaling && (originalParent as Mesh).scaling.isNonUniformWithinEpsilon(0.001)) {\r\n Logger.Warn(\"BoundingBoxGizmo controls are not supported on child meshes with non-uniform parent scaling\");\r\n return;\r\n }\r\n PivotTools._RemoveAndStorePivotPoint(this.attachedMesh);\r\n let relativeDragDistance = (event.dragDistance / this._boundingDimensions.length()) * this._anchorMesh.scaling.length();\r\n totalRelativeDragDistance += relativeDragDistance;\r\n if (this.scalingSnapDistance > 0) {\r\n const dragSteps = Math.floor(Math.abs(totalRelativeDragDistance) / this.scalingSnapDistance) * (totalRelativeDragDistance < 0 ? -1 : 1);\r\n const scale = this.scalingSnapDistance * dragSteps;\r\n relativeDragDistance = scale - previousScale;\r\n previousScale = scale;\r\n }\r\n\r\n const deltaScale = new Vector3(relativeDragDistance, relativeDragDistance, relativeDragDistance);\r\n if (zeroAxisCount === 2) {\r\n // scale on 1 axis when using the anchor box in the face middle\r\n deltaScale.x *= Math.abs(dragAxis.x);\r\n deltaScale.y *= Math.abs(dragAxis.y);\r\n deltaScale.z *= Math.abs(dragAxis.z);\r\n }\r\n deltaScale.scaleInPlace(this._scaleDragSpeed);\r\n deltaScale.multiplyInPlace(this._axisFactor);\r\n this.updateBoundingBox();\r\n if (this.scalePivot) {\r\n this.attachedMesh.getWorldMatrix().getRotationMatrixToRef(this._tmpRotationMatrix);\r\n // Move anchor to desired pivot point (Bottom left corner + dimension/2)\r\n this._boundingDimensions.scaleToRef(0.5, this._tmpVector);\r\n Vector3.TransformCoordinatesToRef(this._tmpVector, this._tmpRotationMatrix, this._tmpVector);\r\n this._anchorMesh.position.subtractInPlace(this._tmpVector);\r\n this._boundingDimensions.multiplyToRef(this.scalePivot, this._tmpVector);\r\n Vector3.TransformCoordinatesToRef(this._tmpVector, this._tmpRotationMatrix, this._tmpVector);\r\n this._anchorMesh.position.addInPlace(this._tmpVector);\r\n } else {\r\n // Scale from the position of the opposite corner\r\n box.absolutePosition.subtractToRef(this._anchorMesh.position, this._tmpVector);\r\n this._anchorMesh.position.subtractInPlace(this._tmpVector);\r\n if (this.attachedMesh.isUsingPivotMatrix()) {\r\n this._anchorMesh.position.subtractInPlace(this.attachedMesh.getPivotPoint());\r\n }\r\n }\r\n\r\n this._anchorMesh.addChild(this.attachedMesh);\r\n this._anchorMesh.scaling.addInPlace(deltaScale);\r\n if (this._anchorMesh.scaling.x < 0 || this._anchorMesh.scaling.y < 0 || this._anchorMesh.scaling.z < 0) {\r\n this._anchorMesh.scaling.subtractInPlace(deltaScale);\r\n }\r\n this._anchorMesh.removeChild(this.attachedMesh);\r\n this.attachedMesh.setParent(originalParent);\r\n PivotTools._RestorePivotPoint(this.attachedMesh);\r\n }\r\n this._updateDummy();\r\n });\r\n\r\n // Selection/deselection\r\n _dragBehavior.onDragStartObservable.add(() => {\r\n this.onDragStartObservable.notifyObservers({});\r\n this._selectNode(box);\r\n totalRelativeDragDistance = 0;\r\n previousScale = 0;\r\n });\r\n _dragBehavior.onDragEndObservable.add((event) => {\r\n this.onScaleBoxDragEndObservable.notifyObservers({});\r\n this._selectNode(null);\r\n this._updateDummy();\r\n this._unhoverMeshOnTouchUp(event.pointerInfo, box);\r\n });\r\n\r\n this._scaleBoxesParent.addChild(box);\r\n }\r\n }\r\n }\r\n this._rootMesh.addChild(this._scaleBoxesParent);\r\n\r\n // Hover color change\r\n const pointerIds = new Array<AbstractMesh>();\r\n this._pointerObserver = gizmoLayer.utilityLayerScene.onPointerObservable.add((pointerInfo) => {\r\n if (!pointerIds[(<IPointerEvent>pointerInfo.event).pointerId]) {\r\n this._rotateSpheresParent\r\n .getChildMeshes()\r\n .concat(this._scaleBoxesParent.getChildMeshes())\r\n .forEach((mesh) => {\r\n if (pointerInfo.pickInfo && pointerInfo.pickInfo.pickedMesh == mesh) {\r\n pointerIds[(<IPointerEvent>pointerInfo.event).pointerId] = mesh;\r\n mesh.material = this._hoverColoredMaterial;\r\n this._isHovered = true;\r\n }\r\n });\r\n } else {\r\n if (pointerInfo.pickInfo && pointerInfo.pickInfo.pickedMesh != pointerIds[(<IPointerEvent>pointerInfo.event).pointerId]) {\r\n pointerIds[(<IPointerEvent>pointerInfo.event).pointerId].material = this._coloredMaterial;\r\n delete pointerIds[(<IPointerEvent>pointerInfo.event).pointerId];\r\n this._isHovered = false;\r\n }\r\n }\r\n });\r\n\r\n // Update bounding box positions\r\n this._renderObserver = this.gizmoLayer.originalScene.onBeforeRenderObservable.add(() => {\r\n // Only update the bounding box if scaling has changed\r\n if (this.attachedMesh && !this._existingMeshScale.equals(this.attachedMesh.scaling)) {\r\n this.updateBoundingBox();\r\n } else if (this.fixedDragMeshScreenSize || this.fixedDragMeshBoundsSize) {\r\n this._updateRotationSpheres();\r\n this._updateScaleBoxes();\r\n }\r\n\r\n // If drag mesh is enabled and dragging, update the attached mesh pose to match the drag mesh\r\n if (this._dragMesh && this.attachedMesh && this._pointerDragBehavior.dragging) {\r\n this._lineBoundingBox.position.rotateByQuaternionToRef(this._rootMesh.rotationQuaternion!, this._tmpVector);\r\n this.attachedMesh.setAbsolutePosition(this._dragMesh.position.add(this._tmpVector.scale(-1)));\r\n }\r\n });\r\n this.updateBoundingBox();\r\n }\r\n\r\n protected _attachedNodeChanged(value: Nullable<AbstractMesh>) {\r\n if (value) {\r\n // Reset anchor mesh to match attached mesh's scale\r\n // This is needed to avoid invalid box/sphere position on first drag\r\n this._anchorMesh.scaling.setAll(1);\r\n PivotTools._RemoveAndStorePivotPoint(value);\r\n const originalParent = value.parent;\r\n this._anchorMesh.addChild(value);\r\n this._anchorMesh.removeChild(value);\r\n value.setParent(originalParent);\r\n PivotTools._RestorePivotPoint(value);\r\n this.updateBoundingBox();\r\n value.getChildMeshes(false).forEach((m) => {\r\n m.markAsDirty(\"scaling\");\r\n });\r\n\r\n this.gizmoLayer.utilityLayerScene.onAfterRenderObservable.addOnce(() => {\r\n this._updateDummy();\r\n });\r\n }\r\n }\r\n\r\n protected _selectNode(selectedMesh: Nullable<Mesh>) {\r\n this._rotateSpheresParent\r\n .getChildMeshes()\r\n .concat(this._scaleBoxesParent.getChildMeshes())\r\n .forEach((m) => {\r\n m.isVisible = !selectedMesh || m == selectedMesh;\r\n });\r\n }\r\n\r\n protected _unhoverMeshOnTouchUp(pointerInfo: Nullable<PointerInfo>, selectedMesh: AbstractMesh) {\r\n // force unhover mesh if not a mouse event\r\n if (pointerInfo?.event instanceof PointerEvent && pointerInfo?.event.pointerType === \"touch\") {\r\n selectedMesh.material = this._coloredMaterial;\r\n }\r\n }\r\n\r\n /**\r\n * returns an array containing all boxes used for scaling (in increasing x, y and z orders)\r\n */\r\n public getScaleBoxes() {\r\n return this._scaleBoxesParent.getChildMeshes();\r\n }\r\n\r\n /**\r\n * Updates the bounding box information for the Gizmo\r\n */\r\n public updateBoundingBox() {\r\n if (this.attachedMesh) {\r\n PivotTools._RemoveAndStorePivotPoint(this.attachedMesh);\r\n\r\n // Store original parent\r\n const originalParent = this.attachedMesh.parent;\r\n this.attachedMesh.setParent(null);\r\n\r\n this._update();\r\n\r\n // Rotate based on axis\r\n if (!this.attachedMesh.rotationQuaternion) {\r\n this.attachedMesh.rotationQuaternion = Quaternion.RotationYawPitchRoll(this.attachedMesh.rotation.y, this.attachedMesh.rotation.x, this.attachedMesh.rotation.z);\r\n }\r\n if (!this._anchorMesh.rotationQuaternion) {\r\n this._anchorMesh.rotationQuaternion = Quaternion.RotationYawPitchRoll(this._anchorMesh.rotation.y, this._anchorMesh.rotation.x, this._anchorMesh.rotation.z);\r\n }\r\n this._anchorMesh.rotationQuaternion.copyFrom(this.attachedMesh.rotationQuaternion);\r\n\r\n // Store original position and reset mesh to origin before computing the bounding box\r\n this._tmpQuaternion.copyFrom(this.attachedMesh.rotationQuaternion);\r\n this._tmpVector.copyFrom(this.attachedMesh.position);\r\n this.attachedMesh.rotationQuaternion.set(0, 0, 0, 1);\r\n this.attachedMesh.position.set(0, 0, 0);\r\n\r\n // Update bounding dimensions/positions\r\n const boundingMinMax = this.attachedMesh.getHierarchyBoundingVectors(!this.ignoreChildren, this.includeChildPredicate);\r\n boundingMinMax.max.subtractToRef(boundingMinMax.min, this._boundingDimensions);\r\n\r\n // Update gizmo to match bounding box scaling and rotation\r\n // The position set here is the offset from the origin for the boundingbox when the attached mesh is at the origin\r\n // The position of the gizmo is then set to the attachedMesh in gizmo._update\r\n this._lineBoundingBox.scaling.copyFrom(this._boundingDimensions);\r\n this._lineBoundingBox.position.set(\r\n (boundingMinMax.max.x + boundingMinMax.min.x) / 2,\r\n (boundingMinMax.max.y + boundingMinMax.min.y) / 2,\r\n (boundingMinMax.max.z + boundingMinMax.min.z) / 2\r\n );\r\n this._rotateSpheresParent.position.copyFrom(this._lineBoundingBox.position);\r\n this._scaleBoxesParent.position.copyFrom(this._lineBoundingBox.position);\r\n this._lineBoundingBox.computeWorldMatrix();\r\n this._anchorMesh.position.copyFrom(this._lineBoundingBox.absolutePosition);\r\n\r\n // Restore position/rotation values\r\n this.attachedMesh.rotationQuaternion.copyFrom(this._tmpQuaternion);\r\n this.attachedMesh.position.copyFrom(this._tmpVector);\r\n\r\n // Restore original parent\r\n this.attachedMesh.setParent(originalParent);\r\n }\r\n\r\n this._updateRotationSpheres();\r\n this._updateScaleBoxes();\r\n\r\n if (this.attachedMesh) {\r\n this._existingMeshScale.copyFrom(this.attachedMesh.scaling);\r\n PivotTools._RestorePivotPoint(this.attachedMesh);\r\n }\r\n }\r\n\r\n protected _updateRotationSpheres() {\r\n const rotateSpheres = this._rotateSpheresParent.getChildMeshes();\r\n for (let i = 0; i < 3; i++) {\r\n for (let j = 0; j < 2; j++) {\r\n for (let k = 0; k < 2; k++) {\r\n const index = i * 4 + j * 2 + k;\r\n if (i == 0) {\r\n rotateSpheres[index].position.set(this._boundingDimensions.x / 2, this._boundingDimensions.y * j, this._boundingDimensions.z * k);\r\n rotateSpheres[index].position.addInPlace(new Vector3(-this._boundingDimensions.x / 2, -this._boundingDimensions.y / 2, -this._boundingDimensions.z / 2));\r\n rotateSpheres[index].lookAt(\r\n Vector3.Cross(rotateSpheres[index].position.normalizeToNew(), Vector3.Right()).normalizeToNew().add(rotateSpheres[index].position)\r\n );\r\n }\r\n if (i == 1) {\r\n rotateSpheres[index].position.set(this._boundingDimensions.x * j, this._boundingDimensions.y / 2, this._boundingDimensions.z * k);\r\n rotateSpheres[index].position.addInPlace(new Vector3(-this._boundingDimensions.x / 2, -this._boundingDimensions.y / 2, -this._boundingDimensions.z / 2));\r\n rotateSpheres[index].lookAt(\r\n Vector3.Cross(rotateSpheres[index].position.normalizeToNew(), Vector3.Up()).normalizeToNew().add(rotateSpheres[index].position)\r\n );\r\n }\r\n if (i == 2) {\r\n rotateSpheres[index].position.set(this._boundingDimensions.x * j, this._boundingDimensions.y * k, this._boundingDimensions.z / 2);\r\n rotateSpheres[index].position.addInPlace(new Vector3(-this._boundingDimensions.x / 2, -this._boundingDimensions.y / 2, -this._boundingDimensions.z / 2));\r\n rotateSpheres[index].lookAt(\r\n Vector3.Cross(rotateSpheres[index].position.normalizeToNew(), Vector3.Forward()).normalizeToNew().add(rotateSpheres[index].position)\r\n );\r\n }\r\n if (this.fixedDragMeshScreenSize && this.gizmoLayer.utilityLayerScene.activeCamera) {\r\n rotateSpheres[index].absolutePosition.subtractToRef(this.gizmoLayer.utilityLayerScene.activeCamera.position, this._tmpVector);\r\n const distanceFromCamera = (this.rotationSphereSize * this._tmpVector.length()) / this.fixedDragMeshScreenSizeDistanceFactor;\r\n rotateSpheres[index].scaling.set(distanceFromCamera, distanceFromCamera, distanceFromCamera);\r\n } else if (this.fixedDragMeshBoundsSize) {\r\n rotateSpheres[index].scaling.set(\r\n this.rotationSphereSize * this._boundingDimensions.x,\r\n this.rotationSphereSize * this._boundingDimensions.y,\r\n this.rotationSphereSize * this._boundingDimensions.z\r\n );\r\n } else {\r\n rotateSpheres[index].scaling.set(this.rotationSphereSize, this.rotationSphereSize, this.rotationSphereSize);\r\n }\r\n }\r\n }\r\n }\r\n }\r\n\r\n protected _updateScaleBoxes() {\r\n const scaleBoxes = this._scaleBoxesParent.getChildMeshes();\r\n let index = 0;\r\n for (let i = 0; i < 3; i++) {\r\n for (let j = 0; j < 3; j++) {\r\n for (let k = 0; k < 3; k++) {\r\n const zeroAxisCount = (i === 1 ? 1 : 0) + (j === 1 ? 1 : 0) + (k === 1 ? 1 : 0);\r\n if (zeroAxisCount === 1 || zeroAxisCount === 3) {\r\n continue;\r\n }\r\n if (scaleBoxes[index]) {\r\n scaleBoxes[index].position.set(this._boundingDimensions.x * (i / 2), this._boundingDimensions.y * (j / 2), this._boundingDimensions.z * (k / 2));\r\n scaleBoxes[index].position.addInPlace(new Vector3(-this._boundingDimensions.x / 2, -this._boundingDimensions.y / 2, -this._boundingDimensions.z / 2));\r\n if (this.fixedDragMeshScreenSize && this.gizmoLayer.utilityLayerScene.activeCamera) {\r\n scaleBoxes[index].absolutePosition.subtractToRef(this.gizmoLayer.utilityLayerScene.activeCamera.position, this._tmpVector);\r\n const distanceFromCamera = (this.scaleBoxSize * this._tmpVector.length()) / this.fixedDragMeshScreenSizeDistanceFactor;\r\n scaleBoxes[index].scaling.set(distanceFromCamera, distanceFromCamera, distanceFromCamera);\r\n } else if (this.fixedDragMeshBoundsSize) {\r\n scaleBoxes[index].scaling.set(\r\n this.scaleBoxSize * this._boundingDimensions.x,\r\n this.scaleBoxSize * this._boundingDimensions.y,\r\n this.scaleBoxSize * this._boundingDimensions.z\r\n );\r\n } else {\r\n scaleBoxes[index].scaling.set(this.scaleBoxSize, this.scaleBoxSize, this.scaleBoxSize);\r\n }\r\n }\r\n index++;\r\n }\r\n }\r\n }\r\n }\r\n\r\n /**\r\n * Enables rotation on the specified axis and disables rotation on the others\r\n * @param axis The list of axis that should be enabled (eg. \"xy\" or \"xyz\")\r\n */\r\n public setEnabledRotationAxis(axis: string) {\r\n this._rotateSpheresParent.getChildMeshes().forEach((m, i) => {\r\n if (i < 4) {\r\n m.setEnabled(axis.indexOf(\"x\") != -1);\r\n } else if (i < 8) {\r\n m.setEnabled(axis.indexOf(\"y\") != -1);\r\n } else {\r\n m.setEnabled(axis.indexOf(\"z\") != -1);\r\n }\r\n });\r\n }\r\n\r\n /**\r\n * Enables/disables scaling\r\n * @param enable if scaling should be enabled\r\n * @param homogeneousScaling defines if scaling should only be homogeneous\r\n */\r\n public setEnabledScaling(enable: boolean, homogeneousScaling = false) {\r\n this._scaleBoxesParent.getChildMeshes().forEach((m) => {\r\n let enableMesh = enable;\r\n // Disable heterogeneous scale handles if requested.\r\n if (homogeneousScaling && m._internalMetadata === true) {\r\n enableMesh = false;\r\n }\r\n m.setEnabled(enableMesh);\r\n });\r\n }\r\n\r\n protected _updateDummy() {\r\n if (this._dragMesh) {\r\n this._dragMesh.position.copyFrom(this._lineBoundingBox.getAbsolutePosition());\r\n this._dragMesh.scaling.copyFrom(this._lineBoundingBox.scaling);\r\n this._dragMesh.rotationQuaternion!.copyFrom(this._rootMesh.rotationQuaternion!);\r\n }\r\n }\r\n\r\n /**\r\n * Enables a pointer drag behavior on the bounding box of the gizmo\r\n */\r\n public enableDragBehavior() {\r\n this._dragMesh = CreateBox(\"dummy\", { size: 1 }, this.gizmoLayer.utilityLayerScene);\r\n this._dragMesh.visibility = 0;\r\n this._dragMesh.rotationQuaternion = new Quaternion();\r\n this._pointerDragBehavior.useObjectOrientationForDragging = false;\r\n this._dragMesh.addBehavior(this._pointerDragBehavior);\r\n }\r\n\r\n /**\r\n * Disposes of the gizmo\r\n */\r\n public dispose() {\r\n this.gizmoLayer.utilityLayerScene.onPointerObservable.remove(this._pointerObserver);\r\n this.gizmoLayer.originalScene.onBeforeRenderObservable.remove(this._renderObserver);\r\n this._lineBoundingBox.dispose();\r\n this._rotateSpheresParent.dispose();\r\n this._scaleBoxesParent.dispose();\r\n if (this._dragMesh) {\r\n this._dragMesh.dispose();\r\n }\r\n super.dispose();\r\n }\r\n\r\n /**\r\n * Makes a mesh not pickable and wraps the mesh inside of a bounding box mesh that is pickable. (This is useful to avoid picking within complex geometry)\r\n * @param mesh the mesh to wrap in the bounding box mesh and make not pickable\r\n * @returns the bounding box mesh with the passed in mesh as a child\r\n */\r\n public static MakeNotPickableAndWrapInBoundingBox(mesh: Mesh): Mesh {\r\n const makeNotPickable = (root: AbstractMesh) => {\r\n root.isPickable = false;\r\n root.getChildMeshes().forEach((c) => {\r\n makeNotPickable(c);\r\n });\r\n };\r\n makeNotPickable(mesh);\r\n\r\n // Reset position to get bounding box from origin with no rotation\r\n if (!mesh.rotationQuaternion) {\r\n mesh.rotationQuaternion = Quaternion.RotationYawPitchRoll(mesh.rotation.y, mesh.rotation.x, mesh.rotation.z);\r\n }\r\n const oldPos = mesh.position.clone();\r\n const oldRot = mesh.rotationQuaternion.clone();\r\n mesh.rotationQuaternion.set(0, 0, 0, 1);\r\n mesh.position.set(0, 0, 0);\r\n\r\n // Update bounding dimensions/positions\r\n const box = CreateBox(\"box\", { size: 1 }, mesh.getScene());\r\n const boundingMinMax = mesh.getHierarchyBoundingVectors();\r\n boundingMinMax.max.subtractToRef(boundingMinMax.min, box.scaling);\r\n\r\n // Adjust scale to avoid undefined behavior when adding child\r\n if (box.scaling.y === 0) {\r\n box.scaling.y = Epsilon;\r\n }\r\n if (box.scaling.x === 0) {\r\n box.scaling.x = Epsilon;\r\n }\r\n if (box.scaling.z === 0) {\r\n box.scaling.z = Epsilon;\r\n }\r\n\r\n box.position.set((boundingMinMax.max.x + boundingMinMax.min.x) / 2, (boundingMinMax.max.y + boundingMinMax.min.y) / 2, (boundingMinMax.max.z + boundingMinMax.min.z) / 2);\r\n\r\n // Restore original positions\r\n mesh.addChild(box);\r\n mesh.rotationQuaternion.copyFrom(oldRot);\r\n mesh.position.copyFrom(oldPos);\r\n\r\n // Reverse parenting\r\n mesh.removeChild(box);\r\n\r\n box.addChild(mesh);\r\n box.visibility = 0;\r\n return box;\r\n }\r\n /**\r\n * CustomMeshes are not supported by this gizmo\r\n */\r\n public setCustomMesh() {\r\n Logger.Error(\"Custom meshes are not supported on this gizmo\");\r\n }\r\n}\r\n"]}
package/Gizmos/gizmo.js CHANGED
@@ -212,6 +212,7 @@ export class Gizmo {
212
212
  effectiveNode.getClassName() === "InstancedMesh";
213
213
  const transformNode = supportedNode ? effectiveNode : undefined;
214
214
  effectiveNode.getWorldMatrix().decompose(undefined, this._rootMesh.rotationQuaternion, undefined, Gizmo.PreserveScaling ? transformNode : undefined);
215
+ this._rootMesh.rotationQuaternion.normalize();
215
216
  }
216
217
  else {
217
218
  if (this._customRotationQuaternion) {
@@ -307,7 +308,8 @@ export class Gizmo {
307
308
  const localMat = TmpVectors.Matrix[1];
308
309
  transform.parent.getWorldMatrix().invertToRef(parentInv);
309
310
  this._attachedNode.getWorldMatrix().multiplyToRef(parentInv, localMat);
310
- localMat.decompose(TmpVectors.Vector3[0], TmpVectors.Quaternion[0], transform.position, Gizmo.PreserveScaling ? transform : undefined);
311
+ localMat.decompose(TmpVectors.Vector3[0], TmpVectors.Quaternion[0], transform.position);
312
+ TmpVectors.Quaternion[0].normalize();
311
313
  if (transform.isUsingPivotMatrix()) {
312
314
  // Calculate the local matrix without the translation.
313
315
  // Copied from TranslateNode.computeWorldMatrix