@babylonjs/core 6.44.0 → 6.45.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 (133) hide show
  1. package/Buffers/buffer.d.ts +22 -22
  2. package/Buffers/buffer.js +16 -15
  3. package/Buffers/buffer.js.map +1 -1
  4. package/Cameras/camera.d.ts +5 -5
  5. package/Cameras/camera.js +19 -19
  6. package/Cameras/camera.js.map +1 -1
  7. package/Engines/ICanvas.d.ts +2 -1
  8. package/Engines/ICanvas.js.map +1 -1
  9. package/Engines/constants.d.ts +96 -0
  10. package/Engines/constants.js +96 -0
  11. package/Engines/constants.js.map +1 -1
  12. package/Engines/thinEngine.js +2 -2
  13. package/Engines/thinEngine.js.map +1 -1
  14. package/Gizmos/gizmo.d.ts +14 -0
  15. package/Gizmos/gizmo.js +16 -0
  16. package/Gizmos/gizmo.js.map +1 -1
  17. package/Gizmos/gizmoManager.d.ts +12 -0
  18. package/Gizmos/gizmoManager.js +26 -0
  19. package/Gizmos/gizmoManager.js.map +1 -1
  20. package/Gizmos/positionGizmo.d.ts +16 -2
  21. package/Gizmos/positionGizmo.js +12 -2
  22. package/Gizmos/positionGizmo.js.map +1 -1
  23. package/Gizmos/rotationGizmo.d.ts +8 -0
  24. package/Gizmos/rotationGizmo.js +9 -0
  25. package/Gizmos/rotationGizmo.js.map +1 -1
  26. package/Gizmos/scaleGizmo.d.ts +15 -1
  27. package/Gizmos/scaleGizmo.js +11 -1
  28. package/Gizmos/scaleGizmo.js.map +1 -1
  29. package/Layers/effectLayer.js +4 -4
  30. package/Layers/effectLayer.js.map +1 -1
  31. package/Lights/Shadows/shadowGenerator.js +5 -5
  32. package/Lights/Shadows/shadowGenerator.js.map +1 -1
  33. package/Materials/Background/backgroundMaterial.js +16 -16
  34. package/Materials/Background/backgroundMaterial.js.map +1 -1
  35. package/Materials/GaussianSplatting/gaussianSplattingMaterial.js +8 -8
  36. package/Materials/GaussianSplatting/gaussianSplattingMaterial.js.map +1 -1
  37. package/Materials/Node/Blocks/Dual/fogBlock.js +2 -2
  38. package/Materials/Node/Blocks/Dual/fogBlock.js.map +1 -1
  39. package/Materials/Node/Blocks/Dual/lightBlock.js +6 -6
  40. package/Materials/Node/Blocks/Dual/lightBlock.js.map +1 -1
  41. package/Materials/Node/Blocks/Fragment/fragmentOutputBlock.js +2 -2
  42. package/Materials/Node/Blocks/Fragment/fragmentOutputBlock.js.map +1 -1
  43. package/Materials/Node/Blocks/PBR/pbrMetallicRoughnessBlock.js +7 -7
  44. package/Materials/Node/Blocks/PBR/pbrMetallicRoughnessBlock.js.map +1 -1
  45. package/Materials/Node/Blocks/Vertex/bonesBlock.js +3 -3
  46. package/Materials/Node/Blocks/Vertex/bonesBlock.js.map +1 -1
  47. package/Materials/Node/Blocks/Vertex/morphTargetsBlock.js +3 -3
  48. package/Materials/Node/Blocks/Vertex/morphTargetsBlock.js.map +1 -1
  49. package/Materials/Node/nodeMaterial.js +3 -3
  50. package/Materials/Node/nodeMaterial.js.map +1 -1
  51. package/Materials/PBR/pbrAnisotropicConfiguration.js +3 -3
  52. package/Materials/PBR/pbrAnisotropicConfiguration.js.map +1 -1
  53. package/Materials/PBR/pbrBaseMaterial.js +41 -41
  54. package/Materials/PBR/pbrBaseMaterial.js.map +1 -1
  55. package/Materials/PBR/pbrClearCoatConfiguration.js +10 -10
  56. package/Materials/PBR/pbrClearCoatConfiguration.js.map +1 -1
  57. package/Materials/PBR/pbrIridescenceConfiguration.js +6 -6
  58. package/Materials/PBR/pbrIridescenceConfiguration.js.map +1 -1
  59. package/Materials/PBR/pbrSheenConfiguration.js +6 -6
  60. package/Materials/PBR/pbrSheenConfiguration.js.map +1 -1
  61. package/Materials/PBR/pbrSubSurfaceConfiguration.js +7 -7
  62. package/Materials/PBR/pbrSubSurfaceConfiguration.js.map +1 -1
  63. package/Materials/Textures/Loaders/ktxTextureLoader.js +1 -1
  64. package/Materials/Textures/Loaders/ktxTextureLoader.js.map +1 -1
  65. package/Materials/Textures/dynamicTexture.js +1 -1
  66. package/Materials/Textures/dynamicTexture.js.map +1 -1
  67. package/Materials/Textures/texture.js +1 -1
  68. package/Materials/Textures/texture.js.map +1 -1
  69. package/Materials/index.d.ts +1 -0
  70. package/Materials/index.js +1 -0
  71. package/Materials/index.js.map +1 -1
  72. package/Materials/material.decalMapConfiguration.js +3 -3
  73. package/Materials/material.decalMapConfiguration.js.map +1 -1
  74. package/Materials/material.detailMapConfiguration.js +3 -3
  75. package/Materials/material.detailMapConfiguration.js.map +1 -1
  76. package/Materials/material.js +2 -2
  77. package/Materials/material.js.map +1 -1
  78. package/Materials/materialHelper.d.ts +1 -4
  79. package/Materials/materialHelper.functions.d.ts +275 -0
  80. package/Materials/materialHelper.functions.js +823 -0
  81. package/Materials/materialHelper.functions.js.map +1 -0
  82. package/Materials/materialHelper.js +64 -589
  83. package/Materials/materialHelper.js.map +1 -1
  84. package/Materials/materialPluginBase.d.ts +1 -1
  85. package/Materials/materialPluginBase.js +1 -1
  86. package/Materials/materialPluginBase.js.map +1 -1
  87. package/Materials/shaderMaterial.js +8 -8
  88. package/Materials/shaderMaterial.js.map +1 -1
  89. package/Materials/standardMaterial.js +33 -33
  90. package/Materials/standardMaterial.js.map +1 -1
  91. package/Meshes/Compression/dracoCompression.d.ts +23 -2
  92. package/Meshes/Compression/dracoCompression.js +76 -236
  93. package/Meshes/Compression/dracoCompression.js.map +1 -1
  94. package/Meshes/Compression/dracoCompressionWorker.d.ts +44 -0
  95. package/Meshes/Compression/dracoCompressionWorker.js +189 -0
  96. package/Meshes/Compression/dracoCompressionWorker.js.map +1 -0
  97. package/Meshes/trailMesh.js +1 -1
  98. package/Meshes/trailMesh.js.map +1 -1
  99. package/Misc/basis.d.ts +6 -1
  100. package/Misc/basis.js +11 -231
  101. package/Misc/basis.js.map +1 -1
  102. package/Misc/basisWorker.d.ts +13 -0
  103. package/Misc/basisWorker.js +249 -0
  104. package/Misc/basisWorker.js.map +1 -0
  105. package/Misc/khronosTextureContainer2.d.ts +25 -3
  106. package/Misc/khronosTextureContainer2.js +35 -106
  107. package/Misc/khronosTextureContainer2.js.map +1 -1
  108. package/Misc/khronosTextureContainer2Worker.d.ts +12 -0
  109. package/Misc/khronosTextureContainer2Worker.js +136 -0
  110. package/Misc/khronosTextureContainer2Worker.js.map +1 -0
  111. package/Navigation/Plugins/recastJSPlugin.d.ts +1 -1
  112. package/Navigation/Plugins/recastJSPlugin.js.map +1 -1
  113. package/Particles/gpuParticleSystem.js +3 -3
  114. package/Particles/gpuParticleSystem.js.map +1 -1
  115. package/Particles/particleSystem.js +7 -3
  116. package/Particles/particleSystem.js.map +1 -1
  117. package/Physics/v2/IPhysicsEnginePlugin.d.ts +8 -0
  118. package/Physics/v2/IPhysicsEnginePlugin.js +9 -0
  119. package/Physics/v2/IPhysicsEnginePlugin.js.map +1 -1
  120. package/Physics/v2/Plugins/havokPlugin.d.ts +7 -1
  121. package/Physics/v2/Plugins/havokPlugin.js +19 -1
  122. package/Physics/v2/Plugins/havokPlugin.js.map +1 -1
  123. package/PostProcesses/volumetricLightScatteringPostProcess.js +2 -2
  124. package/PostProcesses/volumetricLightScatteringPostProcess.js.map +1 -1
  125. package/Rendering/depthRenderer.js +4 -4
  126. package/Rendering/depthRenderer.js.map +1 -1
  127. package/Rendering/geometryBufferRenderer.js +5 -5
  128. package/Rendering/geometryBufferRenderer.js.map +1 -1
  129. package/Rendering/outlineRenderer.js +4 -4
  130. package/Rendering/outlineRenderer.js.map +1 -1
  131. package/package.json +1 -1
  132. package/scene.d.ts +4 -4
  133. package/scene.js.map +1 -1
package/Gizmos/gizmo.d.ts CHANGED
@@ -98,6 +98,12 @@ export interface IGizmo extends IDisposable {
98
98
  * @param mesh The mesh to replace the default mesh of the gizmo
99
99
  */
100
100
  setCustomMesh(mesh: Mesh): void;
101
+ /**
102
+ * Additional transform applied to the gizmo.
103
+ * It's useful when the gizmo is attached to a bone: if the bone is part of a skeleton attached to a mesh, you should define the mesh as additionalTransformNode if you want the gizmo to be displayed at the bone's correct location.
104
+ * Otherwise, as the gizmo is relative to the skeleton root, the mesh transformation will not be taken into account.
105
+ */
106
+ additionalTransformNode?: TransformNode;
101
107
  }
102
108
  /**
103
109
  * Renders gizmos on top of an existing scene which provide controls for position, rotation, etc.
@@ -112,6 +118,7 @@ export declare class Gizmo implements IGizmo {
112
118
  protected _attachedMesh: Nullable<AbstractMesh>;
113
119
  protected _attachedNode: Nullable<Node>;
114
120
  protected _customRotationQuaternion: Nullable<Quaternion>;
121
+ protected _additionalTransformNode?: TransformNode;
115
122
  /**
116
123
  * Ratio for the scale of the gizmo (Default: 1)
117
124
  */
@@ -161,6 +168,13 @@ export declare class Gizmo implements IGizmo {
161
168
  * @param mesh The mesh to replace the default mesh of the gizmo
162
169
  */
163
170
  setCustomMesh(mesh: Mesh): void;
171
+ /**
172
+ * Additional transform applied to the gizmo.
173
+ * It's useful when the gizmo is attached to a bone: if the bone is part of a skeleton attached to a mesh, you should define the mesh as additionalTransformNode if you want the gizmo to be displayed at the bone's correct location.
174
+ * Otherwise, as the gizmo is relative to the skeleton root, the mesh transformation will not be taken into account.
175
+ */
176
+ get additionalTransformNode(): TransformNode | undefined;
177
+ set additionalTransformNode(value: TransformNode | undefined);
164
178
  protected _updateGizmoRotationToMatchAttachedMesh: boolean;
165
179
  protected _updateGizmoPositionToMatchAttachedMesh: boolean;
166
180
  protected _anchorPoint: GizmoAnchorPoint;
package/Gizmos/gizmo.js CHANGED
@@ -84,6 +84,17 @@ export class Gizmo {
84
84
  mesh.parent = this._rootMesh;
85
85
  this._customMeshSet = true;
86
86
  }
87
+ /**
88
+ * Additional transform applied to the gizmo.
89
+ * It's useful when the gizmo is attached to a bone: if the bone is part of a skeleton attached to a mesh, you should define the mesh as additionalTransformNode if you want the gizmo to be displayed at the bone's correct location.
90
+ * Otherwise, as the gizmo is relative to the skeleton root, the mesh transformation will not be taken into account.
91
+ */
92
+ get additionalTransformNode() {
93
+ return this._additionalTransformNode;
94
+ }
95
+ set additionalTransformNode(value) {
96
+ this._additionalTransformNode = value;
97
+ }
87
98
  /**
88
99
  * If set the gizmo's rotation will be updated to match the attached mesh each frame (Default: true)
89
100
  * NOTE: This is only possible for meshes with uniform scaling, as otherwise it's not possible to decompose the rotation
@@ -250,6 +261,11 @@ export class Gizmo {
250
261
  this._rootMesh.scaling.setAll(this.scaleRatio);
251
262
  }
252
263
  }
264
+ if (this.additionalTransformNode) {
265
+ this._rootMesh.computeWorldMatrix(true);
266
+ this._rootMesh.getWorldMatrix().multiplyToRef(this.additionalTransformNode.getWorldMatrix(), TmpVectors.Matrix[0]);
267
+ TmpVectors.Matrix[0].decompose(this._rootMesh.scaling, this._rootMesh.rotationQuaternion, this._rootMesh.position);
268
+ }
253
269
  }
254
270
  /**
255
271
  * if transform has a pivot and is not using PostMultiplyPivotMatrix, then the worldMatrix contains the pivot matrix (it's not cancelled at the end)
@@ -1 +1 @@
1
- {"version":3,"file":"gizmo.js","sourceRoot":"","sources":["../../../../dev/core/src/Gizmos/gizmo.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,UAAU,EAAE,OAAO,EAAE,MAAM,EAAE,UAAU,EAAE,MAAM,sBAAsB,CAAC;AAE/E,OAAO,EAAE,IAAI,EAAE,MAAM,gBAAgB,CAAC;AACtC,OAAO,EAAE,MAAM,EAAE,MAAM,mBAAmB,CAAC;AAI3C,OAAO,EAAE,oBAAoB,EAAE,MAAM,mCAAmC,CAAC;AAIzE,OAAO,EAAE,iBAAiB,EAAE,MAAM,yBAAyB,CAAC;AAI5D,OAAO,EAAE,KAAK,EAAE,MAAM,iBAAiB,CAAC;AAsBxC;;GAEG;AACH,MAAM,CAAN,IAAY,gBAKX;AALD,WAAY,gBAAgB;IACxB,sCAAsC;IACtC,2DAAM,CAAA;IACN,0CAA0C;IAC1C,yDAAK,CAAA;AACT,CAAC,EALW,gBAAgB,KAAhB,gBAAgB,QAK3B;AAED;;GAEG;AACH,MAAM,CAAN,IAAY,oBAGX;AAHD,W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AAC,IAAI,KAAK,iBAAiB,CAAC,SAAS,EAAE;oBAClD,cAAc,CAAC,OAAO,CAAC,CAAC,KAAK,EAAE,EAAE;wBAC7B,KAAK,CAAC,MAAM,GAAG,KAAK,CAAC;wBACrB,QAAQ,GAAG,KAAK,CAAC;wBACjB,KAAK,CAAC,WAAW,CAAC,OAAO,CAAC,CAAC,CAAO,EAAE,EAAE;4BAClC,CAAC,CAAC,QAAQ,GAAG,KAAK,CAAC,YAAY,CAAC,OAAO,CAAC,CAAC,CAAC,KAAK,CAAC,QAAQ,CAAC,CAAC,CAAC,KAAK,CAAC,eAAe,CAAC;4BACjF,IAAK,CAAe,CAAC,KAAK,EAAE;gCACvB,CAAe,CAAC,KAAK,GAAG,KAAK,CAAC,QAAQ,CAAC,YAAY,CAAC;6BACxD;wBACL,CAAC,CAAC,CAAC;oBACP,CAAC,CAAC,CAAC;iBACN;aACJ;QACL,CAAC,CAAC,CAAC;QAEH,OAAO,eAAgB,CAAC;IAC5B,CAAC;IAED;;OAEG;IACI,OAAO;QACV,IAAI,CAAC,SAAS,CAAC,OAAO,EAAE,CAAC;QACzB,IAAI,IAAI,CAAC,qBAAqB,EAAE;YAC5B,IAAI,CAAC,UAAU,CAAC,iBAAiB,CAAC,wBAAwB,CAAC,MAAM,CAAC,IAAI,CAAC,qBAAqB,CAAC,CAAC;SACjG;IACL,CAAC;;AAlgBD;;;GAGG;AACW,qBAAe,GAAG,KAAK,AAAR,CAAS;AAEtC;;;;GAIG;AACW,wBAAkB,GAAG,IAAI,AAAP,CAAQ","sourcesContent":["import type { Observer } from \"../Misc/observable\";\r\nimport type { Nullable } from \"../types\";\r\nimport type { Scene, IDisposable } from \"../scene\";\r\nimport { Quaternion, Vector3, Matrix, TmpVectors } from \"../Maths/math.vector\";\r\nimport type { AbstractMesh } from \"../Meshes/abstractMesh\";\r\nimport { Mesh } from \"../Meshes/mesh\";\r\nimport { Camera } from \"../Cameras/camera\";\r\nimport type { TargetCamera } from \"../Cameras/targetCamera\";\r\nimport type { Node } from \"../node\";\r\nimport type { Bone } from \"../Bones/bone\";\r\nimport { UtilityLayerRenderer } from \"../Rendering/utilityLayerRenderer\";\r\nimport type { TransformNode } from \"../Meshes/transformNode\";\r\nimport type { StandardMaterial } from \"../Materials/standardMaterial\";\r\nimport type { PointerInfo } from \"../Events/pointerEvents\";\r\nimport { PointerEventTypes } from \"../Events/pointerEvents\";\r\nimport type { LinesMesh } from \"../Meshes/linesMesh\";\r\nimport type { PointerDragBehavior } from \"../Behaviors/Meshes/pointerDragBehavior\";\r\nimport type { ShadowLight } from \"../Lights/shadowLight\";\r\nimport { Light } from \"../Lights/light\";\r\n\r\n/**\r\n * Cache built by each axis. Used for managing state between all elements of gizmo for enhanced UI\r\n */\r\nexport interface GizmoAxisCache {\r\n /** Mesh used to render the Gizmo */\r\n gizmoMeshes: Mesh[];\r\n /** Mesh used to detect user interaction with Gizmo */\r\n colliderMeshes: Mesh[];\r\n /** Material used to indicate color of gizmo mesh */\r\n material: StandardMaterial;\r\n /** Material used to indicate hover state of the Gizmo */\r\n hoverMaterial: StandardMaterial;\r\n /** Material used to indicate disabled state of the Gizmo */\r\n disableMaterial: StandardMaterial;\r\n /** Used to indicate Active state of the Gizmo */\r\n active: boolean;\r\n /** DragBehavior */\r\n dragBehavior: PointerDragBehavior;\r\n}\r\n\r\n/**\r\n * Anchor options where the Gizmo can be positioned in relation to its anchored node\r\n */\r\nexport enum GizmoAnchorPoint {\r\n /** The origin of the attached node */\r\n Origin,\r\n /** The pivot point of the attached node*/\r\n Pivot,\r\n}\r\n\r\n/**\r\n * Coordinates mode: Local or World. Defines how axis is aligned: either on world axis or transform local axis\r\n */\r\nexport enum GizmoCoordinatesMode {\r\n World,\r\n Local,\r\n}\r\n\r\n/**\r\n * Interface for basic gizmo\r\n */\r\nexport interface IGizmo extends IDisposable {\r\n /** True when the mouse pointer is hovered a gizmo mesh */\r\n readonly isHovered: boolean;\r\n /** The root mesh of the gizmo */\r\n _rootMesh: Mesh;\r\n /** Ratio for the scale of the gizmo */\r\n scaleRatio: number;\r\n /**\r\n * Mesh that the gizmo will be attached to. (eg. on a drag gizmo the mesh that will be dragged)\r\n * * When set, interactions will be enabled\r\n */\r\n attachedMesh: Nullable<AbstractMesh>;\r\n /**\r\n * Node that the gizmo will be attached to. (eg. on a drag gizmo the mesh, bone or NodeTransform that will be dragged)\r\n * * When set, interactions will be enabled\r\n */\r\n attachedNode: Nullable<Node>;\r\n /**\r\n * If set the gizmo's rotation will be updated to match the attached mesh each frame (Default: true)\r\n */\r\n updateGizmoRotationToMatchAttachedMesh: boolean;\r\n /** The utility layer the gizmo will be added to */\r\n gizmoLayer: UtilityLayerRenderer;\r\n /**\r\n * If set the gizmo's position will be updated to match the attached mesh each frame (Default: true)\r\n */\r\n updateGizmoPositionToMatchAttachedMesh: boolean;\r\n /**\r\n * Defines where the gizmo will be positioned if `updateGizmoPositionToMatchAttachedMesh` is enabled.\r\n * (Default: GizmoAnchorPoint.Origin)\r\n */\r\n anchorPoint: GizmoAnchorPoint;\r\n\r\n /**\r\n * Set the coordinate mode to use. By default it's local.\r\n */\r\n coordinatesMode: GizmoCoordinatesMode;\r\n\r\n /**\r\n * When set, the gizmo will always appear the same size no matter where the camera is (default: true)\r\n */\r\n updateScale: boolean;\r\n /**\r\n * posture that the gizmo will be display\r\n * When set null, default value will be used (Quaternion(0, 0, 0, 1))\r\n */\r\n customRotationQuaternion: Nullable<Quaternion>;\r\n /**\r\n * Disposes and replaces the current meshes in the gizmo with the specified mesh\r\n * @param mesh The mesh to replace the default mesh of the gizmo\r\n */\r\n setCustomMesh(mesh: Mesh): void;\r\n}\r\n/**\r\n * Renders gizmos on top of an existing scene which provide controls for position, rotation, etc.\r\n */\r\nexport class Gizmo implements IGizmo {\r\n /**\r\n * The root mesh of the gizmo\r\n */\r\n public _rootMesh: Mesh;\r\n protected _attachedMesh: Nullable<AbstractMesh> = null;\r\n protected _attachedNode: Nullable<Node> = null;\r\n protected _customRotationQuaternion: Nullable<Quaternion> = null;\r\n /**\r\n * Ratio for the scale of the gizmo (Default: 1)\r\n */\r\n protected _scaleRatio = 1;\r\n\r\n /**\r\n * boolean updated by pointermove when a gizmo mesh is hovered\r\n */\r\n protected _isHovered = false;\r\n\r\n /**\r\n * When enabled, any gizmo operation will perserve scaling sign. Default is off.\r\n * Only valid for TransformNode derived classes (Mesh, AbstractMesh, ...)\r\n */\r\n public static PreserveScaling = false;\r\n\r\n /**\r\n * There are 2 ways to preserve scaling: using mesh scaling or absolute scaling. Depending of hierarchy, non uniform scaling and LH or RH coordinates. One is preferable than the other.\r\n * If the scaling to be preserved is the local scaling, then set this value to false.\r\n * Default is true which means scaling to be preserved is absolute one (with hierarchy applied)\r\n */\r\n public static UseAbsoluteScaling = true;\r\n\r\n /**\r\n * Ratio for the scale of the gizmo (Default: 1)\r\n */\r\n public set scaleRatio(value: number) {\r\n this._scaleRatio = value;\r\n }\r\n\r\n public get scaleRatio() {\r\n return this._scaleRatio;\r\n }\r\n\r\n /**\r\n * True when the mouse pointer is hovered a gizmo mesh\r\n */\r\n public get isHovered() {\r\n return this._isHovered;\r\n }\r\n\r\n /**\r\n * If a custom mesh has been set (Default: false)\r\n */\r\n protected _customMeshSet = false;\r\n /**\r\n * Mesh that the gizmo will be attached to. (eg. on a drag gizmo the mesh that will be dragged)\r\n * * When set, interactions will be enabled\r\n */\r\n public get attachedMesh() {\r\n return this._attachedMesh;\r\n }\r\n public set attachedMesh(value) {\r\n this._attachedMesh = value;\r\n if (value) {\r\n this._attachedNode = value;\r\n }\r\n this._rootMesh.setEnabled(value ? true : false);\r\n this._attachedNodeChanged(value);\r\n }\r\n /**\r\n * Node that the gizmo will be attached to. (eg. on a drag gizmo the mesh, bone or NodeTransform that will be dragged)\r\n * * When set, interactions will be enabled\r\n */\r\n public get attachedNode() {\r\n return this._attachedNode;\r\n }\r\n public set attachedNode(value) {\r\n this._attachedNode = value;\r\n this._attachedMesh = null;\r\n this._rootMesh.setEnabled(value ? true : false);\r\n this._attachedNodeChanged(value);\r\n }\r\n\r\n /**\r\n * Disposes and replaces the current meshes in the gizmo with the specified mesh\r\n * @param mesh The mesh to replace the default mesh of the gizmo\r\n */\r\n public setCustomMesh(mesh: Mesh) {\r\n if (mesh.getScene() != this.gizmoLayer.utilityLayerScene) {\r\n // eslint-disable-next-line no-throw-literal\r\n throw \"When setting a custom mesh on a gizmo, the custom meshes scene must be the same as the gizmos (eg. gizmo.gizmoLayer.utilityLayerScene)\";\r\n }\r\n this._rootMesh.getChildMeshes().forEach((c) => {\r\n c.dispose();\r\n });\r\n mesh.parent = this._rootMesh;\r\n this._customMeshSet = true;\r\n }\r\n\r\n protected _updateGizmoRotationToMatchAttachedMesh = true;\r\n protected _updateGizmoPositionToMatchAttachedMesh = true;\r\n protected _anchorPoint = GizmoAnchorPoint.Origin;\r\n protected _updateScale = true;\r\n protected _coordinatesMode = GizmoCoordinatesMode.Local;\r\n\r\n /**\r\n * If set the gizmo's rotation will be updated to match the attached mesh each frame (Default: true)\r\n * NOTE: This is only possible for meshes with uniform scaling, as otherwise it's not possible to decompose the rotation\r\n */\r\n public set updateGizmoRotationToMatchAttachedMesh(value: boolean) {\r\n this._updateGizmoRotationToMatchAttachedMesh = value;\r\n }\r\n public get updateGizmoRotationToMatchAttachedMesh() {\r\n return this._updateGizmoRotationToMatchAttachedMesh;\r\n }\r\n /**\r\n * If set the gizmo's position will be updated to match the attached mesh each frame (Default: true)\r\n */\r\n public set updateGizmoPositionToMatchAttachedMesh(value: boolean) {\r\n this._updateGizmoPositionToMatchAttachedMesh = value;\r\n }\r\n public get updateGizmoPositionToMatchAttachedMesh() {\r\n return this._updateGizmoPositionToMatchAttachedMesh;\r\n }\r\n\r\n /**\r\n * Defines where the gizmo will be positioned if `updateGizmoPositionToMatchAttachedMesh` is enabled.\r\n * (Default: GizmoAnchorPoint.Origin)\r\n */\r\n public set anchorPoint(value: GizmoAnchorPoint) {\r\n this._anchorPoint = value;\r\n }\r\n public get anchorPoint() {\r\n return this._anchorPoint;\r\n }\r\n\r\n /**\r\n * Set the coordinate system to use. By default it's local.\r\n * But it's possible for a user to tweak so its local for translation and world for rotation.\r\n * In that case, setting the coordinate system will change `updateGizmoRotationToMatchAttachedMesh` and `updateGizmoPositionToMatchAttachedMesh`\r\n */\r\n public set coordinatesMode(coordinatesMode: GizmoCoordinatesMode) {\r\n this._coordinatesMode = coordinatesMode;\r\n const local = coordinatesMode == GizmoCoordinatesMode.Local;\r\n this.updateGizmoRotationToMatchAttachedMesh = local;\r\n this.updateGizmoPositionToMatchAttachedMesh = true;\r\n }\r\n\r\n public get coordinatesMode() {\r\n return this._coordinatesMode;\r\n }\r\n\r\n /**\r\n * When set, the gizmo will always appear the same size no matter where the camera is (default: true)\r\n */\r\n\r\n public set updateScale(value: boolean) {\r\n this._updateScale = value;\r\n }\r\n public get updateScale() {\r\n return this._updateScale;\r\n }\r\n protected _interactionsEnabled = true;\r\n // eslint-disable-next-line @typescript-eslint/no-unused-vars\r\n protected _attachedNodeChanged(value: Nullable<Node>) {}\r\n\r\n protected _beforeRenderObserver: Nullable<Observer<Scene>>;\r\n private _rightHandtoLeftHandMatrix = Matrix.RotationY(Math.PI);\r\n\r\n /**\r\n * Creates a gizmo\r\n * @param gizmoLayer The utility layer the gizmo will be added to\r\n */\r\n constructor(\r\n /** The utility layer the gizmo will be added to */\r\n public gizmoLayer: UtilityLayerRenderer = UtilityLayerRenderer.DefaultUtilityLayer\r\n ) {\r\n this._rootMesh = new Mesh(\"gizmoRootNode\", gizmoLayer.utilityLayerScene);\r\n this._rootMesh.rotationQuaternion = Quaternion.Identity();\r\n\r\n this._beforeRenderObserver = this.gizmoLayer.utilityLayerScene.onBeforeRenderObservable.add(() => {\r\n this._update();\r\n });\r\n }\r\n\r\n /**\r\n * posture that the gizmo will be display\r\n * When set null, default value will be used (Quaternion(0, 0, 0, 1))\r\n */\r\n public get customRotationQuaternion(): Nullable<Quaternion> {\r\n return this._customRotationQuaternion;\r\n }\r\n\r\n public set customRotationQuaternion(customRotationQuaternion: Nullable<Quaternion>) {\r\n this._customRotationQuaternion = customRotationQuaternion;\r\n }\r\n\r\n /**\r\n * Updates the gizmo to match the attached mesh's position/rotation\r\n */\r\n protected _update() {\r\n if (this.attachedNode) {\r\n let effectiveNode = this.attachedNode;\r\n if (this.attachedMesh) {\r\n effectiveNode = this.attachedMesh || this.attachedNode;\r\n }\r\n\r\n // Position\r\n if (this.updateGizmoPositionToMatchAttachedMesh) {\r\n if (this.anchorPoint == GizmoAnchorPoint.Pivot && (<TransformNode>effectiveNode).getAbsolutePivotPoint) {\r\n const position = (<TransformNode>effectiveNode).getAbsolutePivotPoint();\r\n this._rootMesh.position.copyFrom(position);\r\n } else {\r\n const row = effectiveNode.getWorldMatrix().getRow(3);\r\n const position = row ? row.toVector3() : new Vector3(0, 0, 0);\r\n this._rootMesh.position.copyFrom(position);\r\n }\r\n }\r\n\r\n // Rotation\r\n if (this.updateGizmoRotationToMatchAttachedMesh) {\r\n const supportedNode =\r\n (<Mesh>effectiveNode)._isMesh ||\r\n effectiveNode.getClassName() === \"AbstractMesh\" ||\r\n effectiveNode.getClassName() === \"TransformNode\" ||\r\n effectiveNode.getClassName() === \"InstancedMesh\";\r\n const transformNode = supportedNode ? (effectiveNode as TransformNode) : undefined;\r\n effectiveNode.getWorldMatrix().decompose(undefined, this._rootMesh.rotationQuaternion!, undefined, Gizmo.PreserveScaling ? transformNode : undefined);\r\n this._rootMesh.rotationQuaternion!.normalize();\r\n } else {\r\n if (this._customRotationQuaternion) {\r\n this._rootMesh.rotationQuaternion!.copyFrom(this._customRotationQuaternion);\r\n } else {\r\n this._rootMesh.rotationQuaternion!.set(0, 0, 0, 1);\r\n }\r\n }\r\n\r\n // Scale\r\n if (this.updateScale) {\r\n const activeCamera = this.gizmoLayer.utilityLayerScene.activeCamera!;\r\n const cameraPosition = activeCamera.globalPosition;\r\n this._rootMesh.position.subtractToRef(cameraPosition, TmpVectors.Vector3[0]);\r\n let scale = this.scaleRatio;\r\n if (activeCamera.mode == Camera.ORTHOGRAPHIC_CAMERA) {\r\n if (activeCamera.orthoTop && activeCamera.orthoBottom) {\r\n const orthoHeight = activeCamera.orthoTop - activeCamera.orthoBottom;\r\n scale *= orthoHeight;\r\n }\r\n } else {\r\n const camForward = activeCamera.getScene().useRightHandedSystem ? Vector3.RightHandedForwardReadOnly : Vector3.LeftHandedForwardReadOnly;\r\n const direction = activeCamera.getDirection(camForward);\r\n scale *= Vector3.Dot(TmpVectors.Vector3[0], direction);\r\n }\r\n this._rootMesh.scaling.setAll(scale);\r\n\r\n // Account for handedness, similar to Matrix.decompose\r\n if (effectiveNode._getWorldMatrixDeterminant() < 0 && !Gizmo.PreserveScaling) {\r\n this._rootMesh.scaling.y *= -1;\r\n }\r\n } else {\r\n this._rootMesh.scaling.setAll(this.scaleRatio);\r\n }\r\n }\r\n }\r\n\r\n /**\r\n * if transform has a pivot and is not using PostMultiplyPivotMatrix, then the worldMatrix contains the pivot matrix (it's not cancelled at the end)\r\n * so, when extracting the world matrix component, the translation (and other components) is containing the pivot translation.\r\n * And the pivot is applied each frame. Removing it anyway here makes it applied only in computeWorldMatrix.\r\n * @param transform local transform that needs to be transform by the pivot inverse matrix\r\n * @param localMatrix local matrix that needs to be transform by the pivot inverse matrix\r\n * @param result resulting matrix transformed by pivot inverse if the transform node is using pivot without using post Multiply Pivot Matrix\r\n */\r\n protected _handlePivotMatrixInverse(transform: TransformNode, localMatrix: Matrix, result: Matrix): void {\r\n if (transform.isUsingPivotMatrix() && !transform.isUsingPostMultiplyPivotMatrix()) {\r\n transform.getPivotMatrix().invertToRef(TmpVectors.Matrix[5]);\r\n TmpVectors.Matrix[5].multiplyToRef(localMatrix, result);\r\n return;\r\n }\r\n result.copyFrom(localMatrix);\r\n }\r\n /**\r\n * computes the rotation/scaling/position of the transform once the Node world matrix has changed.\r\n */\r\n protected _matrixChanged() {\r\n if (!this._attachedNode) {\r\n return;\r\n }\r\n\r\n if ((<Camera>this._attachedNode)._isCamera) {\r\n const camera = this._attachedNode as Camera;\r\n let worldMatrix;\r\n let worldMatrixUC;\r\n if (camera.parent) {\r\n const parentInv = TmpVectors.Matrix[1];\r\n camera.parent._worldMatrix.invertToRef(parentInv);\r\n this._attachedNode._worldMatrix.multiplyToRef(parentInv, TmpVectors.Matrix[0]);\r\n worldMatrix = TmpVectors.Matrix[0];\r\n } else {\r\n worldMatrix = this._attachedNode._worldMatrix;\r\n }\r\n\r\n if (camera.getScene().useRightHandedSystem) {\r\n // avoid desync with RH matrix computation. Otherwise, rotation of PI around Y axis happens each frame resulting in axis flipped because worldMatrix is computed as inverse of viewMatrix.\r\n this._rightHandtoLeftHandMatrix.multiplyToRef(worldMatrix, TmpVectors.Matrix[1]);\r\n worldMatrixUC = TmpVectors.Matrix[1];\r\n } else {\r\n worldMatrixUC = worldMatrix;\r\n }\r\n\r\n worldMatrixUC.decompose(TmpVectors.Vector3[1], TmpVectors.Quaternion[0], TmpVectors.Vector3[0]);\r\n\r\n const inheritsTargetCamera =\r\n this._attachedNode.getClassName() === \"FreeCamera\" ||\r\n this._attachedNode.getClassName() === \"FlyCamera\" ||\r\n this._attachedNode.getClassName() === \"ArcFollowCamera\" ||\r\n this._attachedNode.getClassName() === \"TargetCamera\" ||\r\n this._attachedNode.getClassName() === \"TouchCamera\" ||\r\n this._attachedNode.getClassName() === \"UniversalCamera\";\r\n\r\n if (inheritsTargetCamera) {\r\n const targetCamera = this._attachedNode as TargetCamera;\r\n targetCamera.rotation = TmpVectors.Quaternion[0].toEulerAngles();\r\n\r\n if (targetCamera.rotationQuaternion) {\r\n targetCamera.rotationQuaternion.copyFrom(TmpVectors.Quaternion[0]);\r\n targetCamera.rotationQuaternion.normalize();\r\n }\r\n }\r\n\r\n camera.position.copyFrom(TmpVectors.Vector3[0]);\r\n } else if (\r\n (<Mesh>this._attachedNode)._isMesh ||\r\n this._attachedNode.getClassName() === \"AbstractMesh\" ||\r\n this._attachedNode.getClassName() === \"TransformNode\" ||\r\n this._attachedNode.getClassName() === \"InstancedMesh\"\r\n ) {\r\n const transform = this._attachedNode as TransformNode;\r\n if (transform.parent) {\r\n const parentInv = TmpVectors.Matrix[0];\r\n const localMat = TmpVectors.Matrix[1];\r\n transform.parent.getWorldMatrix().invertToRef(parentInv);\r\n this._attachedNode.getWorldMatrix().multiplyToRef(parentInv, localMat);\r\n const matrixToDecompose = TmpVectors.Matrix[4];\r\n this._handlePivotMatrixInverse(transform, localMat, matrixToDecompose);\r\n matrixToDecompose.decompose(\r\n TmpVectors.Vector3[0],\r\n TmpVectors.Quaternion[0],\r\n transform.position,\r\n Gizmo.PreserveScaling ? transform : undefined,\r\n Gizmo.UseAbsoluteScaling\r\n );\r\n TmpVectors.Quaternion[0].normalize();\r\n if (transform.isUsingPivotMatrix()) {\r\n // Calculate the local matrix without the translation.\r\n // Copied from TranslateNode.computeWorldMatrix\r\n const r = TmpVectors.Quaternion[1];\r\n Quaternion.RotationYawPitchRollToRef(transform.rotation.y, transform.rotation.x, transform.rotation.z, r);\r\n\r\n const scaleMatrix = TmpVectors.Matrix[2];\r\n Matrix.ScalingToRef(transform.scaling.x, transform.scaling.y, transform.scaling.z, scaleMatrix);\r\n\r\n const rotationMatrix = TmpVectors.Matrix[2];\r\n r.toRotationMatrix(rotationMatrix);\r\n\r\n const pivotMatrix = transform.getPivotMatrix();\r\n const invPivotMatrix = TmpVectors.Matrix[3];\r\n pivotMatrix.invertToRef(invPivotMatrix);\r\n\r\n pivotMatrix.multiplyToRef(scaleMatrix, TmpVectors.Matrix[4]);\r\n TmpVectors.Matrix[4].multiplyToRef(rotationMatrix, TmpVectors.Matrix[5]);\r\n TmpVectors.Matrix[5].multiplyToRef(invPivotMatrix, TmpVectors.Matrix[6]);\r\n\r\n TmpVectors.Matrix[6].getTranslationToRef(TmpVectors.Vector3[1]);\r\n\r\n transform.position.subtractInPlace(TmpVectors.Vector3[1]);\r\n }\r\n } else {\r\n const matrixToDecompose = TmpVectors.Matrix[4];\r\n this._handlePivotMatrixInverse(transform, this._attachedNode._worldMatrix, matrixToDecompose);\r\n matrixToDecompose.decompose(\r\n TmpVectors.Vector3[0],\r\n TmpVectors.Quaternion[0],\r\n transform.position,\r\n Gizmo.PreserveScaling ? transform : undefined,\r\n Gizmo.UseAbsoluteScaling\r\n );\r\n }\r\n TmpVectors.Vector3[0].scaleInPlace(1.0 / transform.scalingDeterminant);\r\n transform.scaling.copyFrom(TmpVectors.Vector3[0]);\r\n if (!transform.billboardMode) {\r\n if (transform.rotationQuaternion) {\r\n transform.rotationQuaternion.copyFrom(TmpVectors.Quaternion[0]);\r\n transform.rotationQuaternion.normalize();\r\n } else {\r\n transform.rotation = TmpVectors.Quaternion[0].toEulerAngles();\r\n }\r\n }\r\n } else if (this._attachedNode.getClassName() === \"Bone\") {\r\n const bone = this._attachedNode as Bone;\r\n const parent = bone.getParent();\r\n\r\n if (parent) {\r\n const invParent = TmpVectors.Matrix[0];\r\n const boneLocalMatrix = TmpVectors.Matrix[1];\r\n parent.getFinalMatrix().invertToRef(invParent);\r\n bone.getFinalMatrix().multiplyToRef(invParent, boneLocalMatrix);\r\n const lmat = bone.getLocalMatrix();\r\n lmat.copyFrom(boneLocalMatrix);\r\n } else {\r\n const lmat = bone.getLocalMatrix();\r\n lmat.copyFrom(bone.getFinalMatrix());\r\n }\r\n bone.markAsDirty();\r\n } else {\r\n const light = this._attachedNode as ShadowLight;\r\n if (light.getTypeID) {\r\n const type = light.getTypeID();\r\n if (type === Light.LIGHTTYPEID_DIRECTIONALLIGHT || type === Light.LIGHTTYPEID_SPOTLIGHT || type === Light.LIGHTTYPEID_POINTLIGHT) {\r\n const parent = light.parent;\r\n\r\n if (parent) {\r\n const invParent = TmpVectors.Matrix[0];\r\n const nodeLocalMatrix = TmpVectors.Matrix[1];\r\n parent.getWorldMatrix().invertToRef(invParent);\r\n light.getWorldMatrix().multiplyToRef(invParent, nodeLocalMatrix);\r\n nodeLocalMatrix.decompose(undefined, TmpVectors.Quaternion[0], TmpVectors.Vector3[0]);\r\n } else {\r\n this._attachedNode._worldMatrix.decompose(undefined, TmpVectors.Quaternion[0], TmpVectors.Vector3[0]);\r\n }\r\n // setter doesn't copy values. Need a new Vector3\r\n light.position = new Vector3(TmpVectors.Vector3[0].x, TmpVectors.Vector3[0].y, TmpVectors.Vector3[0].z);\r\n if (light.direction) {\r\n light.direction = new Vector3(light.direction.x, light.direction.y, light.direction.z);\r\n }\r\n }\r\n }\r\n }\r\n }\r\n\r\n /**\r\n * refresh gizmo mesh material\r\n * @param gizmoMeshes\r\n * @param material material to apply\r\n */\r\n protected _setGizmoMeshMaterial(gizmoMeshes: Mesh[], material: StandardMaterial) {\r\n if (gizmoMeshes) {\r\n gizmoMeshes.forEach((m: Mesh) => {\r\n m.material = material;\r\n if ((<LinesMesh>m).color) {\r\n (<LinesMesh>m).color = material.diffuseColor;\r\n }\r\n });\r\n }\r\n }\r\n\r\n /**\r\n * Subscribes to pointer up, down, and hover events. Used for responsive gizmos.\r\n * @param gizmoLayer The utility layer the gizmo will be added to\r\n * @param gizmoAxisCache Gizmo axis definition used for reactive gizmo UI\r\n * @returns {Observer<PointerInfo>} pointerObserver\r\n */\r\n public static GizmoAxisPointerObserver(gizmoLayer: UtilityLayerRenderer, gizmoAxisCache: Map<Mesh, GizmoAxisCache>): Observer<PointerInfo> {\r\n let dragging = false;\r\n\r\n const pointerObserver = gizmoLayer.utilityLayerScene.onPointerObservable.add((pointerInfo) => {\r\n if (pointerInfo.pickInfo) {\r\n // On Hover Logic\r\n if (pointerInfo.type === PointerEventTypes.POINTERMOVE) {\r\n if (dragging) {\r\n return;\r\n }\r\n gizmoAxisCache.forEach((cache) => {\r\n if (cache.colliderMeshes && cache.gizmoMeshes) {\r\n const isHovered = cache.colliderMeshes?.indexOf(pointerInfo?.pickInfo?.pickedMesh as Mesh) != -1;\r\n const material = cache.dragBehavior.enabled ? (isHovered || cache.active ? cache.hoverMaterial : cache.material) : cache.disableMaterial;\r\n cache.gizmoMeshes.forEach((m: Mesh) => {\r\n m.material = material;\r\n if ((m as LinesMesh).color) {\r\n (m as LinesMesh).color = material.diffuseColor;\r\n }\r\n });\r\n }\r\n });\r\n }\r\n\r\n // On Mouse Down\r\n if (pointerInfo.type === PointerEventTypes.POINTERDOWN) {\r\n // If user Clicked Gizmo\r\n if (gizmoAxisCache.has(pointerInfo.pickInfo.pickedMesh?.parent as Mesh)) {\r\n dragging = true;\r\n const statusMap = gizmoAxisCache.get(pointerInfo.pickInfo.pickedMesh?.parent as Mesh);\r\n statusMap!.active = true;\r\n gizmoAxisCache.forEach((cache) => {\r\n const isHovered = cache.colliderMeshes?.indexOf(pointerInfo?.pickInfo?.pickedMesh as Mesh) != -1;\r\n const material = (isHovered || cache.active) && cache.dragBehavior.enabled ? cache.hoverMaterial : cache.disableMaterial;\r\n cache.gizmoMeshes.forEach((m: Mesh) => {\r\n m.material = material;\r\n if ((m as LinesMesh).color) {\r\n (m as LinesMesh).color = material.diffuseColor;\r\n }\r\n });\r\n });\r\n }\r\n }\r\n\r\n // On Mouse Up\r\n if (pointerInfo.type === PointerEventTypes.POINTERUP) {\r\n gizmoAxisCache.forEach((cache) => {\r\n cache.active = false;\r\n dragging = false;\r\n cache.gizmoMeshes.forEach((m: Mesh) => {\r\n m.material = cache.dragBehavior.enabled ? cache.material : cache.disableMaterial;\r\n if ((m as LinesMesh).color) {\r\n (m as LinesMesh).color = cache.material.diffuseColor;\r\n }\r\n });\r\n });\r\n }\r\n }\r\n });\r\n\r\n return pointerObserver!;\r\n }\r\n\r\n /**\r\n * Disposes of the gizmo\r\n */\r\n public dispose() {\r\n this._rootMesh.dispose();\r\n if (this._beforeRenderObserver) {\r\n this.gizmoLayer.utilityLayerScene.onBeforeRenderObservable.remove(this._beforeRenderObserver);\r\n }\r\n }\r\n}\r\n"]}
1
+ {"version":3,"file":"gizmo.js","sourceRoot":"","sources":["../../../../dev/core/src/Gizmos/gizmo.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,UAAU,EAAE,OAAO,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AC,KAAK,EAAE,EAAE;wBAC7B,KAAK,CAAC,MAAM,GAAG,KAAK,CAAC;wBACrB,QAAQ,GAAG,KAAK,CAAC;wBACjB,KAAK,CAAC,WAAW,CAAC,OAAO,CAAC,CAAC,CAAO,EAAE,EAAE;4BAClC,CAAC,CAAC,QAAQ,GAAG,KAAK,CAAC,YAAY,CAAC,OAAO,CAAC,CAAC,CAAC,KAAK,CAAC,QAAQ,CAAC,CAAC,CAAC,KAAK,CAAC,eAAe,CAAC;4BACjF,IAAK,CAAe,CAAC,KAAK,EAAE;gCACvB,CAAe,CAAC,KAAK,GAAG,KAAK,CAAC,QAAQ,CAAC,YAAY,CAAC;6BACxD;wBACL,CAAC,CAAC,CAAC;oBACP,CAAC,CAAC,CAAC;iBACN;aACJ;QACL,CAAC,CAAC,CAAC;QAEH,OAAO,eAAgB,CAAC;IAC5B,CAAC;IAED;;OAEG;IACI,OAAO;QACV,IAAI,CAAC,SAAS,CAAC,OAAO,EAAE,CAAC;QACzB,IAAI,IAAI,CAAC,qBAAqB,EAAE;YAC5B,IAAI,CAAC,UAAU,CAAC,iBAAiB,CAAC,wBAAwB,CAAC,MAAM,CAAC,IAAI,CAAC,qBAAqB,CAAC,CAAC;SACjG;IACL,CAAC;;AArhBD;;;GAGG;AACW,qBAAe,GAAG,KAAK,AAAR,CAAS;AAEtC;;;;GAIG;AACW,wBAAkB,GAAG,IAAI,AAAP,CAAQ","sourcesContent":["import type { Observer } from \"../Misc/observable\";\r\nimport type { Nullable } from \"../types\";\r\nimport type { Scene, IDisposable } from \"../scene\";\r\nimport { Quaternion, Vector3, Matrix, TmpVectors } from \"../Maths/math.vector\";\r\nimport type { AbstractMesh } from \"../Meshes/abstractMesh\";\r\nimport { Mesh } from \"../Meshes/mesh\";\r\nimport { Camera } from \"../Cameras/camera\";\r\nimport type { TargetCamera } from \"../Cameras/targetCamera\";\r\nimport type { Node } from \"../node\";\r\nimport type { Bone } from \"../Bones/bone\";\r\nimport { UtilityLayerRenderer } from \"../Rendering/utilityLayerRenderer\";\r\nimport type { TransformNode } from \"../Meshes/transformNode\";\r\nimport type { StandardMaterial } from \"../Materials/standardMaterial\";\r\nimport type { PointerInfo } from \"../Events/pointerEvents\";\r\nimport { PointerEventTypes } from \"../Events/pointerEvents\";\r\nimport type { LinesMesh } from \"../Meshes/linesMesh\";\r\nimport type { PointerDragBehavior } from \"../Behaviors/Meshes/pointerDragBehavior\";\r\nimport type { ShadowLight } from \"../Lights/shadowLight\";\r\nimport { Light } from \"../Lights/light\";\r\n\r\n/**\r\n * Cache built by each axis. Used for managing state between all elements of gizmo for enhanced UI\r\n */\r\nexport interface GizmoAxisCache {\r\n /** Mesh used to render the Gizmo */\r\n gizmoMeshes: Mesh[];\r\n /** Mesh used to detect user interaction with Gizmo */\r\n colliderMeshes: Mesh[];\r\n /** Material used to indicate color of gizmo mesh */\r\n material: StandardMaterial;\r\n /** Material used to indicate hover state of the Gizmo */\r\n hoverMaterial: StandardMaterial;\r\n /** Material used to indicate disabled state of the Gizmo */\r\n disableMaterial: StandardMaterial;\r\n /** Used to indicate Active state of the Gizmo */\r\n active: boolean;\r\n /** DragBehavior */\r\n dragBehavior: PointerDragBehavior;\r\n}\r\n\r\n/**\r\n * Anchor options where the Gizmo can be positioned in relation to its anchored node\r\n */\r\nexport enum GizmoAnchorPoint {\r\n /** The origin of the attached node */\r\n Origin,\r\n /** The pivot point of the attached node*/\r\n Pivot,\r\n}\r\n\r\n/**\r\n * Coordinates mode: Local or World. Defines how axis is aligned: either on world axis or transform local axis\r\n */\r\nexport enum GizmoCoordinatesMode {\r\n World,\r\n Local,\r\n}\r\n\r\n/**\r\n * Interface for basic gizmo\r\n */\r\nexport interface IGizmo extends IDisposable {\r\n /** True when the mouse pointer is hovered a gizmo mesh */\r\n readonly isHovered: boolean;\r\n /** The root mesh of the gizmo */\r\n _rootMesh: Mesh;\r\n /** Ratio for the scale of the gizmo */\r\n scaleRatio: number;\r\n /**\r\n * Mesh that the gizmo will be attached to. (eg. on a drag gizmo the mesh that will be dragged)\r\n * * When set, interactions will be enabled\r\n */\r\n attachedMesh: Nullable<AbstractMesh>;\r\n /**\r\n * Node that the gizmo will be attached to. (eg. on a drag gizmo the mesh, bone or NodeTransform that will be dragged)\r\n * * When set, interactions will be enabled\r\n */\r\n attachedNode: Nullable<Node>;\r\n /**\r\n * If set the gizmo's rotation will be updated to match the attached mesh each frame (Default: true)\r\n */\r\n updateGizmoRotationToMatchAttachedMesh: boolean;\r\n /** The utility layer the gizmo will be added to */\r\n gizmoLayer: UtilityLayerRenderer;\r\n /**\r\n * If set the gizmo's position will be updated to match the attached mesh each frame (Default: true)\r\n */\r\n updateGizmoPositionToMatchAttachedMesh: boolean;\r\n /**\r\n * Defines where the gizmo will be positioned if `updateGizmoPositionToMatchAttachedMesh` is enabled.\r\n * (Default: GizmoAnchorPoint.Origin)\r\n */\r\n anchorPoint: GizmoAnchorPoint;\r\n\r\n /**\r\n * Set the coordinate mode to use. By default it's local.\r\n */\r\n coordinatesMode: GizmoCoordinatesMode;\r\n\r\n /**\r\n * When set, the gizmo will always appear the same size no matter where the camera is (default: true)\r\n */\r\n updateScale: boolean;\r\n /**\r\n * posture that the gizmo will be display\r\n * When set null, default value will be used (Quaternion(0, 0, 0, 1))\r\n */\r\n customRotationQuaternion: Nullable<Quaternion>;\r\n /**\r\n * Disposes and replaces the current meshes in the gizmo with the specified mesh\r\n * @param mesh The mesh to replace the default mesh of the gizmo\r\n */\r\n setCustomMesh(mesh: Mesh): void;\r\n\r\n /**\r\n * Additional transform applied to the gizmo.\r\n * It's useful when the gizmo is attached to a bone: if the bone is part of a skeleton attached to a mesh, you should define the mesh as additionalTransformNode if you want the gizmo to be displayed at the bone's correct location.\r\n * Otherwise, as the gizmo is relative to the skeleton root, the mesh transformation will not be taken into account.\r\n */\r\n additionalTransformNode?: TransformNode;\r\n}\r\n/**\r\n * Renders gizmos on top of an existing scene which provide controls for position, rotation, etc.\r\n */\r\nexport class Gizmo implements IGizmo {\r\n /**\r\n * The root mesh of the gizmo\r\n */\r\n public _rootMesh: Mesh;\r\n protected _attachedMesh: Nullable<AbstractMesh> = null;\r\n protected _attachedNode: Nullable<Node> = null;\r\n protected _customRotationQuaternion: Nullable<Quaternion> = null;\r\n protected _additionalTransformNode?: TransformNode;\r\n /**\r\n * Ratio for the scale of the gizmo (Default: 1)\r\n */\r\n protected _scaleRatio = 1;\r\n\r\n /**\r\n * boolean updated by pointermove when a gizmo mesh is hovered\r\n */\r\n protected _isHovered = false;\r\n\r\n /**\r\n * When enabled, any gizmo operation will perserve scaling sign. Default is off.\r\n * Only valid for TransformNode derived classes (Mesh, AbstractMesh, ...)\r\n */\r\n public static PreserveScaling = false;\r\n\r\n /**\r\n * There are 2 ways to preserve scaling: using mesh scaling or absolute scaling. Depending of hierarchy, non uniform scaling and LH or RH coordinates. One is preferable than the other.\r\n * If the scaling to be preserved is the local scaling, then set this value to false.\r\n * Default is true which means scaling to be preserved is absolute one (with hierarchy applied)\r\n */\r\n public static UseAbsoluteScaling = true;\r\n\r\n /**\r\n * Ratio for the scale of the gizmo (Default: 1)\r\n */\r\n public set scaleRatio(value: number) {\r\n this._scaleRatio = value;\r\n }\r\n\r\n public get scaleRatio() {\r\n return this._scaleRatio;\r\n }\r\n\r\n /**\r\n * True when the mouse pointer is hovered a gizmo mesh\r\n */\r\n public get isHovered() {\r\n return this._isHovered;\r\n }\r\n\r\n /**\r\n * If a custom mesh has been set (Default: false)\r\n */\r\n protected _customMeshSet = false;\r\n /**\r\n * Mesh that the gizmo will be attached to. (eg. on a drag gizmo the mesh that will be dragged)\r\n * * When set, interactions will be enabled\r\n */\r\n public get attachedMesh() {\r\n return this._attachedMesh;\r\n }\r\n public set attachedMesh(value) {\r\n this._attachedMesh = value;\r\n if (value) {\r\n this._attachedNode = value;\r\n }\r\n this._rootMesh.setEnabled(value ? true : false);\r\n this._attachedNodeChanged(value);\r\n }\r\n /**\r\n * Node that the gizmo will be attached to. (eg. on a drag gizmo the mesh, bone or NodeTransform that will be dragged)\r\n * * When set, interactions will be enabled\r\n */\r\n public get attachedNode() {\r\n return this._attachedNode;\r\n }\r\n public set attachedNode(value) {\r\n this._attachedNode = value;\r\n this._attachedMesh = null;\r\n this._rootMesh.setEnabled(value ? true : false);\r\n this._attachedNodeChanged(value);\r\n }\r\n\r\n /**\r\n * Disposes and replaces the current meshes in the gizmo with the specified mesh\r\n * @param mesh The mesh to replace the default mesh of the gizmo\r\n */\r\n public setCustomMesh(mesh: Mesh) {\r\n if (mesh.getScene() != this.gizmoLayer.utilityLayerScene) {\r\n // eslint-disable-next-line no-throw-literal\r\n throw \"When setting a custom mesh on a gizmo, the custom meshes scene must be the same as the gizmos (eg. gizmo.gizmoLayer.utilityLayerScene)\";\r\n }\r\n this._rootMesh.getChildMeshes().forEach((c) => {\r\n c.dispose();\r\n });\r\n mesh.parent = this._rootMesh;\r\n this._customMeshSet = true;\r\n }\r\n\r\n /**\r\n * Additional transform applied to the gizmo.\r\n * It's useful when the gizmo is attached to a bone: if the bone is part of a skeleton attached to a mesh, you should define the mesh as additionalTransformNode if you want the gizmo to be displayed at the bone's correct location.\r\n * Otherwise, as the gizmo is relative to the skeleton root, the mesh transformation will not be taken into account.\r\n */\r\n public get additionalTransformNode() {\r\n return this._additionalTransformNode;\r\n }\r\n\r\n public set additionalTransformNode(value: TransformNode | undefined) {\r\n this._additionalTransformNode = value;\r\n }\r\n\r\n protected _updateGizmoRotationToMatchAttachedMesh = true;\r\n protected _updateGizmoPositionToMatchAttachedMesh = true;\r\n protected _anchorPoint = GizmoAnchorPoint.Origin;\r\n protected _updateScale = true;\r\n protected _coordinatesMode = GizmoCoordinatesMode.Local;\r\n\r\n /**\r\n * If set the gizmo's rotation will be updated to match the attached mesh each frame (Default: true)\r\n * NOTE: This is only possible for meshes with uniform scaling, as otherwise it's not possible to decompose the rotation\r\n */\r\n public set updateGizmoRotationToMatchAttachedMesh(value: boolean) {\r\n this._updateGizmoRotationToMatchAttachedMesh = value;\r\n }\r\n public get updateGizmoRotationToMatchAttachedMesh() {\r\n return this._updateGizmoRotationToMatchAttachedMesh;\r\n }\r\n /**\r\n * If set the gizmo's position will be updated to match the attached mesh each frame (Default: true)\r\n */\r\n public set updateGizmoPositionToMatchAttachedMesh(value: boolean) {\r\n this._updateGizmoPositionToMatchAttachedMesh = value;\r\n }\r\n public get updateGizmoPositionToMatchAttachedMesh() {\r\n return this._updateGizmoPositionToMatchAttachedMesh;\r\n }\r\n\r\n /**\r\n * Defines where the gizmo will be positioned if `updateGizmoPositionToMatchAttachedMesh` is enabled.\r\n * (Default: GizmoAnchorPoint.Origin)\r\n */\r\n public set anchorPoint(value: GizmoAnchorPoint) {\r\n this._anchorPoint = value;\r\n }\r\n public get anchorPoint() {\r\n return this._anchorPoint;\r\n }\r\n\r\n /**\r\n * Set the coordinate system to use. By default it's local.\r\n * But it's possible for a user to tweak so its local for translation and world for rotation.\r\n * In that case, setting the coordinate system will change `updateGizmoRotationToMatchAttachedMesh` and `updateGizmoPositionToMatchAttachedMesh`\r\n */\r\n public set coordinatesMode(coordinatesMode: GizmoCoordinatesMode) {\r\n this._coordinatesMode = coordinatesMode;\r\n const local = coordinatesMode == GizmoCoordinatesMode.Local;\r\n this.updateGizmoRotationToMatchAttachedMesh = local;\r\n this.updateGizmoPositionToMatchAttachedMesh = true;\r\n }\r\n\r\n public get coordinatesMode() {\r\n return this._coordinatesMode;\r\n }\r\n\r\n /**\r\n * When set, the gizmo will always appear the same size no matter where the camera is (default: true)\r\n */\r\n\r\n public set updateScale(value: boolean) {\r\n this._updateScale = value;\r\n }\r\n public get updateScale() {\r\n return this._updateScale;\r\n }\r\n protected _interactionsEnabled = true;\r\n // eslint-disable-next-line @typescript-eslint/no-unused-vars\r\n protected _attachedNodeChanged(value: Nullable<Node>) {}\r\n\r\n protected _beforeRenderObserver: Nullable<Observer<Scene>>;\r\n private _rightHandtoLeftHandMatrix = Matrix.RotationY(Math.PI);\r\n\r\n /**\r\n * Creates a gizmo\r\n * @param gizmoLayer The utility layer the gizmo will be added to\r\n */\r\n constructor(\r\n /** The utility layer the gizmo will be added to */\r\n public gizmoLayer: UtilityLayerRenderer = UtilityLayerRenderer.DefaultUtilityLayer\r\n ) {\r\n this._rootMesh = new Mesh(\"gizmoRootNode\", gizmoLayer.utilityLayerScene);\r\n this._rootMesh.rotationQuaternion = Quaternion.Identity();\r\n\r\n this._beforeRenderObserver = this.gizmoLayer.utilityLayerScene.onBeforeRenderObservable.add(() => {\r\n this._update();\r\n });\r\n }\r\n\r\n /**\r\n * posture that the gizmo will be display\r\n * When set null, default value will be used (Quaternion(0, 0, 0, 1))\r\n */\r\n public get customRotationQuaternion(): Nullable<Quaternion> {\r\n return this._customRotationQuaternion;\r\n }\r\n\r\n public set customRotationQuaternion(customRotationQuaternion: Nullable<Quaternion>) {\r\n this._customRotationQuaternion = customRotationQuaternion;\r\n }\r\n\r\n /**\r\n * Updates the gizmo to match the attached mesh's position/rotation\r\n */\r\n protected _update() {\r\n if (this.attachedNode) {\r\n let effectiveNode = this.attachedNode;\r\n if (this.attachedMesh) {\r\n effectiveNode = this.attachedMesh || this.attachedNode;\r\n }\r\n\r\n // Position\r\n if (this.updateGizmoPositionToMatchAttachedMesh) {\r\n if (this.anchorPoint == GizmoAnchorPoint.Pivot && (<TransformNode>effectiveNode).getAbsolutePivotPoint) {\r\n const position = (<TransformNode>effectiveNode).getAbsolutePivotPoint();\r\n this._rootMesh.position.copyFrom(position);\r\n } else {\r\n const row = effectiveNode.getWorldMatrix().getRow(3);\r\n const position = row ? row.toVector3() : new Vector3(0, 0, 0);\r\n this._rootMesh.position.copyFrom(position);\r\n }\r\n }\r\n\r\n // Rotation\r\n if (this.updateGizmoRotationToMatchAttachedMesh) {\r\n const supportedNode =\r\n (<Mesh>effectiveNode)._isMesh ||\r\n effectiveNode.getClassName() === \"AbstractMesh\" ||\r\n effectiveNode.getClassName() === \"TransformNode\" ||\r\n effectiveNode.getClassName() === \"InstancedMesh\";\r\n const transformNode = supportedNode ? (effectiveNode as TransformNode) : undefined;\r\n effectiveNode.getWorldMatrix().decompose(undefined, this._rootMesh.rotationQuaternion!, undefined, Gizmo.PreserveScaling ? transformNode : undefined);\r\n this._rootMesh.rotationQuaternion!.normalize();\r\n } else {\r\n if (this._customRotationQuaternion) {\r\n this._rootMesh.rotationQuaternion!.copyFrom(this._customRotationQuaternion);\r\n } else {\r\n this._rootMesh.rotationQuaternion!.set(0, 0, 0, 1);\r\n }\r\n }\r\n\r\n // Scale\r\n if (this.updateScale) {\r\n const activeCamera = this.gizmoLayer.utilityLayerScene.activeCamera!;\r\n const cameraPosition = activeCamera.globalPosition;\r\n this._rootMesh.position.subtractToRef(cameraPosition, TmpVectors.Vector3[0]);\r\n let scale = this.scaleRatio;\r\n if (activeCamera.mode == Camera.ORTHOGRAPHIC_CAMERA) {\r\n if (activeCamera.orthoTop && activeCamera.orthoBottom) {\r\n const orthoHeight = activeCamera.orthoTop - activeCamera.orthoBottom;\r\n scale *= orthoHeight;\r\n }\r\n } else {\r\n const camForward = activeCamera.getScene().useRightHandedSystem ? Vector3.RightHandedForwardReadOnly : Vector3.LeftHandedForwardReadOnly;\r\n const direction = activeCamera.getDirection(camForward);\r\n scale *= Vector3.Dot(TmpVectors.Vector3[0], direction);\r\n }\r\n this._rootMesh.scaling.setAll(scale);\r\n\r\n // Account for handedness, similar to Matrix.decompose\r\n if (effectiveNode._getWorldMatrixDeterminant() < 0 && !Gizmo.PreserveScaling) {\r\n this._rootMesh.scaling.y *= -1;\r\n }\r\n } else {\r\n this._rootMesh.scaling.setAll(this.scaleRatio);\r\n }\r\n }\r\n\r\n if (this.additionalTransformNode) {\r\n this._rootMesh.computeWorldMatrix(true);\r\n this._rootMesh.getWorldMatrix().multiplyToRef(this.additionalTransformNode.getWorldMatrix(), TmpVectors.Matrix[0]);\r\n TmpVectors.Matrix[0].decompose(this._rootMesh.scaling, this._rootMesh.rotationQuaternion!, this._rootMesh.position);\r\n }\r\n }\r\n\r\n /**\r\n * if transform has a pivot and is not using PostMultiplyPivotMatrix, then the worldMatrix contains the pivot matrix (it's not cancelled at the end)\r\n * so, when extracting the world matrix component, the translation (and other components) is containing the pivot translation.\r\n * And the pivot is applied each frame. Removing it anyway here makes it applied only in computeWorldMatrix.\r\n * @param transform local transform that needs to be transform by the pivot inverse matrix\r\n * @param localMatrix local matrix that needs to be transform by the pivot inverse matrix\r\n * @param result resulting matrix transformed by pivot inverse if the transform node is using pivot without using post Multiply Pivot Matrix\r\n */\r\n protected _handlePivotMatrixInverse(transform: TransformNode, localMatrix: Matrix, result: Matrix): void {\r\n if (transform.isUsingPivotMatrix() && !transform.isUsingPostMultiplyPivotMatrix()) {\r\n transform.getPivotMatrix().invertToRef(TmpVectors.Matrix[5]);\r\n TmpVectors.Matrix[5].multiplyToRef(localMatrix, result);\r\n return;\r\n }\r\n result.copyFrom(localMatrix);\r\n }\r\n /**\r\n * computes the rotation/scaling/position of the transform once the Node world matrix has changed.\r\n */\r\n protected _matrixChanged() {\r\n if (!this._attachedNode) {\r\n return;\r\n }\r\n\r\n if ((<Camera>this._attachedNode)._isCamera) {\r\n const camera = this._attachedNode as Camera;\r\n let worldMatrix;\r\n let worldMatrixUC;\r\n if (camera.parent) {\r\n const parentInv = TmpVectors.Matrix[1];\r\n camera.parent._worldMatrix.invertToRef(parentInv);\r\n this._attachedNode._worldMatrix.multiplyToRef(parentInv, TmpVectors.Matrix[0]);\r\n worldMatrix = TmpVectors.Matrix[0];\r\n } else {\r\n worldMatrix = this._attachedNode._worldMatrix;\r\n }\r\n\r\n if (camera.getScene().useRightHandedSystem) {\r\n // avoid desync with RH matrix computation. Otherwise, rotation of PI around Y axis happens each frame resulting in axis flipped because worldMatrix is computed as inverse of viewMatrix.\r\n this._rightHandtoLeftHandMatrix.multiplyToRef(worldMatrix, TmpVectors.Matrix[1]);\r\n worldMatrixUC = TmpVectors.Matrix[1];\r\n } else {\r\n worldMatrixUC = worldMatrix;\r\n }\r\n\r\n worldMatrixUC.decompose(TmpVectors.Vector3[1], TmpVectors.Quaternion[0], TmpVectors.Vector3[0]);\r\n\r\n const inheritsTargetCamera =\r\n this._attachedNode.getClassName() === \"FreeCamera\" ||\r\n this._attachedNode.getClassName() === \"FlyCamera\" ||\r\n this._attachedNode.getClassName() === \"ArcFollowCamera\" ||\r\n this._attachedNode.getClassName() === \"TargetCamera\" ||\r\n this._attachedNode.getClassName() === \"TouchCamera\" ||\r\n this._attachedNode.getClassName() === \"UniversalCamera\";\r\n\r\n if (inheritsTargetCamera) {\r\n const targetCamera = this._attachedNode as TargetCamera;\r\n targetCamera.rotation = TmpVectors.Quaternion[0].toEulerAngles();\r\n\r\n if (targetCamera.rotationQuaternion) {\r\n targetCamera.rotationQuaternion.copyFrom(TmpVectors.Quaternion[0]);\r\n targetCamera.rotationQuaternion.normalize();\r\n }\r\n }\r\n\r\n camera.position.copyFrom(TmpVectors.Vector3[0]);\r\n } else if (\r\n (<Mesh>this._attachedNode)._isMesh ||\r\n this._attachedNode.getClassName() === \"AbstractMesh\" ||\r\n this._attachedNode.getClassName() === \"TransformNode\" ||\r\n this._attachedNode.getClassName() === \"InstancedMesh\"\r\n ) {\r\n const transform = this._attachedNode as TransformNode;\r\n if (transform.parent) {\r\n const parentInv = TmpVectors.Matrix[0];\r\n const localMat = TmpVectors.Matrix[1];\r\n transform.parent.getWorldMatrix().invertToRef(parentInv);\r\n this._attachedNode.getWorldMatrix().multiplyToRef(parentInv, localMat);\r\n const matrixToDecompose = TmpVectors.Matrix[4];\r\n this._handlePivotMatrixInverse(transform, localMat, matrixToDecompose);\r\n matrixToDecompose.decompose(\r\n TmpVectors.Vector3[0],\r\n TmpVectors.Quaternion[0],\r\n transform.position,\r\n Gizmo.PreserveScaling ? transform : undefined,\r\n Gizmo.UseAbsoluteScaling\r\n );\r\n TmpVectors.Quaternion[0].normalize();\r\n if (transform.isUsingPivotMatrix()) {\r\n // Calculate the local matrix without the translation.\r\n // Copied from TranslateNode.computeWorldMatrix\r\n const r = TmpVectors.Quaternion[1];\r\n Quaternion.RotationYawPitchRollToRef(transform.rotation.y, transform.rotation.x, transform.rotation.z, r);\r\n\r\n const scaleMatrix = TmpVectors.Matrix[2];\r\n Matrix.ScalingToRef(transform.scaling.x, transform.scaling.y, transform.scaling.z, scaleMatrix);\r\n\r\n const rotationMatrix = TmpVectors.Matrix[2];\r\n r.toRotationMatrix(rotationMatrix);\r\n\r\n const pivotMatrix = transform.getPivotMatrix();\r\n const invPivotMatrix = TmpVectors.Matrix[3];\r\n pivotMatrix.invertToRef(invPivotMatrix);\r\n\r\n pivotMatrix.multiplyToRef(scaleMatrix, TmpVectors.Matrix[4]);\r\n TmpVectors.Matrix[4].multiplyToRef(rotationMatrix, TmpVectors.Matrix[5]);\r\n TmpVectors.Matrix[5].multiplyToRef(invPivotMatrix, TmpVectors.Matrix[6]);\r\n\r\n TmpVectors.Matrix[6].getTranslationToRef(TmpVectors.Vector3[1]);\r\n\r\n transform.position.subtractInPlace(TmpVectors.Vector3[1]);\r\n }\r\n } else {\r\n const matrixToDecompose = TmpVectors.Matrix[4];\r\n this._handlePivotMatrixInverse(transform, this._attachedNode._worldMatrix, matrixToDecompose);\r\n matrixToDecompose.decompose(\r\n TmpVectors.Vector3[0],\r\n TmpVectors.Quaternion[0],\r\n transform.position,\r\n Gizmo.PreserveScaling ? transform : undefined,\r\n Gizmo.UseAbsoluteScaling\r\n );\r\n }\r\n TmpVectors.Vector3[0].scaleInPlace(1.0 / transform.scalingDeterminant);\r\n transform.scaling.copyFrom(TmpVectors.Vector3[0]);\r\n if (!transform.billboardMode) {\r\n if (transform.rotationQuaternion) {\r\n transform.rotationQuaternion.copyFrom(TmpVectors.Quaternion[0]);\r\n transform.rotationQuaternion.normalize();\r\n } else {\r\n transform.rotation = TmpVectors.Quaternion[0].toEulerAngles();\r\n }\r\n }\r\n } else if (this._attachedNode.getClassName() === \"Bone\") {\r\n const bone = this._attachedNode as Bone;\r\n const parent = bone.getParent();\r\n\r\n if (parent) {\r\n const invParent = TmpVectors.Matrix[0];\r\n const boneLocalMatrix = TmpVectors.Matrix[1];\r\n parent.getFinalMatrix().invertToRef(invParent);\r\n bone.getFinalMatrix().multiplyToRef(invParent, boneLocalMatrix);\r\n const lmat = bone.getLocalMatrix();\r\n lmat.copyFrom(boneLocalMatrix);\r\n } else {\r\n const lmat = bone.getLocalMatrix();\r\n lmat.copyFrom(bone.getFinalMatrix());\r\n }\r\n bone.markAsDirty();\r\n } else {\r\n const light = this._attachedNode as ShadowLight;\r\n if (light.getTypeID) {\r\n const type = light.getTypeID();\r\n if (type === Light.LIGHTTYPEID_DIRECTIONALLIGHT || type === Light.LIGHTTYPEID_SPOTLIGHT || type === Light.LIGHTTYPEID_POINTLIGHT) {\r\n const parent = light.parent;\r\n\r\n if (parent) {\r\n const invParent = TmpVectors.Matrix[0];\r\n const nodeLocalMatrix = TmpVectors.Matrix[1];\r\n parent.getWorldMatrix().invertToRef(invParent);\r\n light.getWorldMatrix().multiplyToRef(invParent, nodeLocalMatrix);\r\n nodeLocalMatrix.decompose(undefined, TmpVectors.Quaternion[0], TmpVectors.Vector3[0]);\r\n } else {\r\n this._attachedNode._worldMatrix.decompose(undefined, TmpVectors.Quaternion[0], TmpVectors.Vector3[0]);\r\n }\r\n // setter doesn't copy values. Need a new Vector3\r\n light.position = new Vector3(TmpVectors.Vector3[0].x, TmpVectors.Vector3[0].y, TmpVectors.Vector3[0].z);\r\n if (light.direction) {\r\n light.direction = new Vector3(light.direction.x, light.direction.y, light.direction.z);\r\n }\r\n }\r\n }\r\n }\r\n }\r\n\r\n /**\r\n * refresh gizmo mesh material\r\n * @param gizmoMeshes\r\n * @param material material to apply\r\n */\r\n protected _setGizmoMeshMaterial(gizmoMeshes: Mesh[], material: StandardMaterial) {\r\n if (gizmoMeshes) {\r\n gizmoMeshes.forEach((m: Mesh) => {\r\n m.material = material;\r\n if ((<LinesMesh>m).color) {\r\n (<LinesMesh>m).color = material.diffuseColor;\r\n }\r\n });\r\n }\r\n }\r\n\r\n /**\r\n * Subscribes to pointer up, down, and hover events. Used for responsive gizmos.\r\n * @param gizmoLayer The utility layer the gizmo will be added to\r\n * @param gizmoAxisCache Gizmo axis definition used for reactive gizmo UI\r\n * @returns {Observer<PointerInfo>} pointerObserver\r\n */\r\n public static GizmoAxisPointerObserver(gizmoLayer: UtilityLayerRenderer, gizmoAxisCache: Map<Mesh, GizmoAxisCache>): Observer<PointerInfo> {\r\n let dragging = false;\r\n\r\n const pointerObserver = gizmoLayer.utilityLayerScene.onPointerObservable.add((pointerInfo) => {\r\n if (pointerInfo.pickInfo) {\r\n // On Hover Logic\r\n if (pointerInfo.type === PointerEventTypes.POINTERMOVE) {\r\n if (dragging) {\r\n return;\r\n }\r\n gizmoAxisCache.forEach((cache) => {\r\n if (cache.colliderMeshes && cache.gizmoMeshes) {\r\n const isHovered = cache.colliderMeshes?.indexOf(pointerInfo?.pickInfo?.pickedMesh as Mesh) != -1;\r\n const material = cache.dragBehavior.enabled ? (isHovered || cache.active ? cache.hoverMaterial : cache.material) : cache.disableMaterial;\r\n cache.gizmoMeshes.forEach((m: Mesh) => {\r\n m.material = material;\r\n if ((m as LinesMesh).color) {\r\n (m as LinesMesh).color = material.diffuseColor;\r\n }\r\n });\r\n }\r\n });\r\n }\r\n\r\n // On Mouse Down\r\n if (pointerInfo.type === PointerEventTypes.POINTERDOWN) {\r\n // If user Clicked Gizmo\r\n if (gizmoAxisCache.has(pointerInfo.pickInfo.pickedMesh?.parent as Mesh)) {\r\n dragging = true;\r\n const statusMap = gizmoAxisCache.get(pointerInfo.pickInfo.pickedMesh?.parent as Mesh);\r\n statusMap!.active = true;\r\n gizmoAxisCache.forEach((cache) => {\r\n const isHovered = cache.colliderMeshes?.indexOf(pointerInfo?.pickInfo?.pickedMesh as Mesh) != -1;\r\n const material = (isHovered || cache.active) && cache.dragBehavior.enabled ? cache.hoverMaterial : cache.disableMaterial;\r\n cache.gizmoMeshes.forEach((m: Mesh) => {\r\n m.material = material;\r\n if ((m as LinesMesh).color) {\r\n (m as LinesMesh).color = material.diffuseColor;\r\n }\r\n });\r\n });\r\n }\r\n }\r\n\r\n // On Mouse Up\r\n if (pointerInfo.type === PointerEventTypes.POINTERUP) {\r\n gizmoAxisCache.forEach((cache) => {\r\n cache.active = false;\r\n dragging = false;\r\n cache.gizmoMeshes.forEach((m: Mesh) => {\r\n m.material = cache.dragBehavior.enabled ? cache.material : cache.disableMaterial;\r\n if ((m as LinesMesh).color) {\r\n (m as LinesMesh).color = cache.material.diffuseColor;\r\n }\r\n });\r\n });\r\n }\r\n }\r\n });\r\n\r\n return pointerObserver!;\r\n }\r\n\r\n /**\r\n * Disposes of the gizmo\r\n */\r\n public dispose() {\r\n this._rootMesh.dispose();\r\n if (this._beforeRenderObserver) {\r\n this.gizmoLayer.utilityLayerScene.onBeforeRenderObservable.remove(this._beforeRenderObserver);\r\n }\r\n }\r\n}\r\n"]}
@@ -15,6 +15,7 @@ import type { IRotationGizmo } from "./rotationGizmo";
15
15
  import type { IPositionGizmo } from "./positionGizmo";
16
16
  import type { IScaleGizmo } from "./scaleGizmo";
17
17
  import type { IBoundingBoxGizmo } from "./boundingBoxGizmo";
18
+ import type { TransformNode } from "../Meshes/transformNode";
18
19
  /**
19
20
  * Helps setup gizmo's in the scene to rotate/scale/position nodes
20
21
  */
@@ -52,6 +53,7 @@ export declare class GizmoManager implements IDisposable {
52
53
  protected _thickness: number;
53
54
  protected _scaleRatio: number;
54
55
  protected _coordinatesMode: GizmoCoordinatesMode;
56
+ protected _additionalTransformNode?: TransformNode;
55
57
  /** Node Caching for quick lookup */
56
58
  private _gizmoAxisCache;
57
59
  /**
@@ -106,6 +108,10 @@ export declare class GizmoManager implements IDisposable {
106
108
  * The node the gizmo's is attached to
107
109
  */
108
110
  get attachedNode(): Nullable<Node>;
111
+ /**
112
+ * Additional transform node that will be used to transform all the gizmos
113
+ */
114
+ get additionalTransformNode(): TransformNode | undefined;
109
115
  /**
110
116
  * Instantiates a gizmo manager
111
117
  * @param _scene the scene to overlay the gizmos on top of
@@ -151,6 +157,12 @@ export declare class GizmoManager implements IDisposable {
151
157
  */
152
158
  set boundingBoxGizmoEnabled(value: boolean);
153
159
  get boundingBoxGizmoEnabled(): boolean;
160
+ /**
161
+ * Sets the additional transform applied to all the gizmos.
162
+ * @See Gizmo.additionalTransformNode for more detail
163
+ */
164
+ set additionalTransformNode(node: TransformNode | undefined);
165
+ private _setAdditionalTransformNode;
154
166
  /**
155
167
  * Builds Gizmo Axis Cache to enable features such as hover state preservation and graying out other axis during manipulation
156
168
  * @param gizmoAxisCache Gizmo axis definition used for reactive gizmo UI
@@ -93,6 +93,12 @@ export class GizmoManager {
93
93
  get attachedNode() {
94
94
  return this._attachedNode;
95
95
  }
96
+ /**
97
+ * Additional transform node that will be used to transform all the gizmos
98
+ */
99
+ get additionalTransformNode() {
100
+ return this._additionalTransformNode;
101
+ }
96
102
  /**
97
103
  * Instantiates a gizmo manager
98
104
  * @param _scene the scene to overlay the gizmos on top of
@@ -268,6 +274,7 @@ export class GizmoManager {
268
274
  this.gizmos.positionGizmo.attachedNode = null;
269
275
  }
270
276
  this._gizmosEnabled.positionGizmo = value;
277
+ this._setAdditionalTransformNode();
271
278
  }
272
279
  get positionGizmoEnabled() {
273
280
  return this._gizmosEnabled.positionGizmo;
@@ -291,6 +298,7 @@ export class GizmoManager {
291
298
  this.gizmos.rotationGizmo.attachedNode = null;
292
299
  }
293
300
  this._gizmosEnabled.rotationGizmo = value;
301
+ this._setAdditionalTransformNode();
294
302
  }
295
303
  get rotationGizmoEnabled() {
296
304
  return this._gizmosEnabled.rotationGizmo;
@@ -312,6 +320,7 @@ export class GizmoManager {
312
320
  this.gizmos.scaleGizmo.attachedNode = null;
313
321
  }
314
322
  this._gizmosEnabled.scaleGizmo = value;
323
+ this._setAdditionalTransformNode();
315
324
  }
316
325
  get scaleGizmoEnabled() {
317
326
  return this._gizmosEnabled.scaleGizmo;
@@ -347,10 +356,27 @@ export class GizmoManager {
347
356
  this.gizmos.boundingBoxGizmo.attachedNode = null;
348
357
  }
349
358
  this._gizmosEnabled.boundingBoxGizmo = value;
359
+ this._setAdditionalTransformNode();
350
360
  }
351
361
  get boundingBoxGizmoEnabled() {
352
362
  return this._gizmosEnabled.boundingBoxGizmo;
353
363
  }
364
+ /**
365
+ * Sets the additional transform applied to all the gizmos.
366
+ * @See Gizmo.additionalTransformNode for more detail
367
+ */
368
+ set additionalTransformNode(node) {
369
+ this._additionalTransformNode = node;
370
+ this._setAdditionalTransformNode();
371
+ }
372
+ _setAdditionalTransformNode() {
373
+ for (const key in this.gizmos) {
374
+ const gizmo = this.gizmos[key];
375
+ if (gizmo && this._gizmosEnabled[key]) {
376
+ gizmo.additionalTransformNode = this._additionalTransformNode;
377
+ }
378
+ }
379
+ }
354
380
  /**
355
381
  * Builds Gizmo Axis Cache to enable features such as hover state preservation and graying out other axis during manipulation
356
382
  * @param gizmoAxisCache Gizmo axis definition used for reactive gizmo UI
@@ -1 +1 @@
1
- {"version":3,"file":"gizmoManager.js","sourceRoot":"","sources":["../../../../dev/core/src/Gizmos/gizmoManager.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,UAAU,EAAE,MAAM,oBAAoB,CAAC;AAGhD,OAAO,EAAE,iBAAiB,EAAE,MAAM,yBAAyB,CAAC;AAG5D,OAAO,EAAE,YAAY,EAAE,MAAM,wBAAwB,CAAC;AAEtD,OAAO,EAAE,oBAAoB,EAAE,MAAM,mCAAmC,CAAC;AACzE,OAAO,EAAE,MAAM,EAAE,MAAM,qBAAqB,CAAC;AAC7C,OAAO,EAAE,kBAAkB,EAAE,MAAM,wCAAwC,CAAC;AAE5E,OAAO,EAAE,KAAK,EAAE,oBAAoB,EAAE,MAAM,SAAS,CAAC;AAEtD,OAAO,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAC;AAEhD,OAAO,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAC;AAEhD,OAAO,EAAE,UAAU,EAAE,MAAM,cAAc,CAAC;AAE1C,OAA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C,QAAQ,CAAC,CAAC;QACrD,CAAC,CAAC,CAAC;QACH,KAAK,MAAM,GAAG,IAAI,IAAI,CAAC,MAAM,EAAE;YAC3B,MAAM,KAAK,GAA2B,IAAI,CAAC,MAAO,CAAC,GAAG,CAAC,CAAC;YACxD,IAAI,KAAK,EAAE;gBACP,KAAK,CAAC,OAAO,EAAE,CAAC;aACnB;SACJ;QACD,IAAI,IAAI,CAAC,6BAA6B,KAAK,oBAAoB,CAAC,6BAA6B,EAAE;YAC3F,IAAI,CAAC,6BAA6B,EAAE,OAAO,EAAE,CAAC;SACjD;QACD,IAAI,IAAI,CAAC,oBAAoB,KAAK,oBAAoB,CAAC,oBAAoB,EAAE;YACzE,IAAI,CAAC,oBAAoB,EAAE,OAAO,EAAE,CAAC;SACxC;QACD,IAAI,CAAC,uBAAuB,CAAC,MAAM,EAAE,CAAC;QACtC,IAAI,CAAC,0BAA0B,CAAC,KAAK,EAAE,CAAC;IAC5C,CAAC;CACJ","sourcesContent":["import type { Observer } from \"../Misc/observable\";\r\nimport { Observable } from \"../Misc/observable\";\r\nimport type { Nullable } from \"../types\";\r\nimport type { PointerInfo } from \"../Events/pointerEvents\";\r\nimport { PointerEventTypes } from \"../Events/pointerEvents\";\r\nimport type { Scene, IDisposable } from \"../scene\";\r\nimport type { Node } from \"../node\";\r\nimport { AbstractMesh } from \"../Meshes/abstractMesh\";\r\nimport type { Mesh } from \"../Meshes/mesh\";\r\nimport { UtilityLayerRenderer } from \"../Rendering/utilityLayerRenderer\";\r\nimport { Color3 } from \"../Maths/math.color\";\r\nimport { SixDofDragBehavior } from \"../Behaviors/Meshes/sixDofDragBehavior\";\r\nimport type { GizmoAxisCache, IGizmo } from \"./gizmo\";\r\nimport { Gizmo, GizmoCoordinatesMode } from \"./gizmo\";\r\nimport type { IRotationGizmo } from \"./rotationGizmo\";\r\nimport { RotationGizmo } from \"./rotationGizmo\";\r\nimport type { IPositionGizmo } from \"./positionGizmo\";\r\nimport { PositionGizmo } from \"./positionGizmo\";\r\nimport type { IScaleGizmo } from \"./scaleGizmo\";\r\nimport { ScaleGizmo } from \"./scaleGizmo\";\r\nimport type { IBoundingBoxGizmo } from \"./boundingBoxGizmo\";\r\nimport { BoundingBoxGizmo } from \"./boundingBoxGizmo\";\r\n\r\n/**\r\n * Helps setup gizmo's in the scene to rotate/scale/position nodes\r\n */\r\nexport class GizmoManager implements IDisposable {\r\n /**\r\n * Gizmo's created by the gizmo manager, gizmo will be null until gizmo has been enabled for the first time\r\n */\r\n public gizmos: {\r\n positionGizmo: Nullable<IPositionGizmo>;\r\n rotationGizmo: Nullable<IRotationGizmo>;\r\n scaleGizmo: Nullable<IScaleGizmo>;\r\n boundingBoxGizmo: Nullable<IBoundingBoxGizmo>;\r\n };\r\n\r\n /** When true, the gizmo will be detached from the current object when a pointer down occurs with an empty picked mesh */\r\n public clearGizmoOnEmptyPointerEvent = false;\r\n\r\n /** When true (default), picking to attach a new mesh is enabled. This works in sync with inspector autopicking. */\r\n public enableAutoPicking = true;\r\n\r\n /** Fires an event when the manager is attached to a mesh */\r\n public onAttachedToMeshObservable = new Observable<Nullable<AbstractMesh>>();\r\n\r\n /** Fires an event when the manager is attached to a node */\r\n public onAttachedToNodeObservable = new Observable<Nullable<Node>>();\r\n\r\n protected _gizmosEnabled = { positionGizmo: false, rotationGizmo: false, scaleGizmo: false, boundingBoxGizmo: false };\r\n protected _pointerObservers: Observer<PointerInfo>[] = [];\r\n protected _attachedMesh: Nullable<AbstractMesh> = null;\r\n protected _attachedNode: Nullable<Node> = null;\r\n protected _boundingBoxColor = Color3.FromHexString(\"#0984e3\");\r\n protected _defaultUtilityLayer: UtilityLayerRenderer;\r\n protected _defaultKeepDepthUtilityLayer: UtilityLayerRenderer;\r\n protected _thickness: number = 1;\r\n protected _scaleRatio: number = 1;\r\n protected _coordinatesMode = GizmoCoordinatesMode.Local;\r\n\r\n /** Node Caching for quick lookup */\r\n private _gizmoAxisCache: Map<Mesh, GizmoAxisCache> = new Map();\r\n /**\r\n * When bounding box gizmo is enabled, this can be used to track drag/end events\r\n */\r\n public boundingBoxDragBehavior = new SixDofDragBehavior();\r\n /**\r\n * Array of meshes which will have the gizmo attached when a pointer selected them. If null, all meshes are attachable. (Default: null)\r\n */\r\n public attachableMeshes: Nullable<Array<AbstractMesh>> = null;\r\n /**\r\n * Array of nodes which will have the gizmo attached when a pointer selected them. If null, all nodes are attachable. (Default: null)\r\n */\r\n public attachableNodes: Nullable<Array<Node>> = null;\r\n /**\r\n * If pointer events should perform attaching/detaching a gizmo, if false this can be done manually via attachToMesh/attachToNode. (Default: true)\r\n */\r\n public usePointerToAttachGizmos = true;\r\n\r\n /**\r\n * Utility layer that the bounding box gizmo belongs to\r\n */\r\n public get keepDepthUtilityLayer() {\r\n return this._defaultKeepDepthUtilityLayer;\r\n }\r\n\r\n /**\r\n * Utility layer that all gizmos besides bounding box belong to\r\n */\r\n public get utilityLayer() {\r\n return this._defaultUtilityLayer;\r\n }\r\n\r\n /**\r\n * True when the mouse pointer is hovering a gizmo mesh\r\n */\r\n public get isHovered() {\r\n let hovered = false;\r\n for (const key in this.gizmos) {\r\n const gizmo = <Nullable<IGizmo>>(<any>this.gizmos)[key];\r\n if (gizmo && gizmo.isHovered) {\r\n hovered = true;\r\n break;\r\n }\r\n }\r\n return hovered;\r\n }\r\n\r\n /**\r\n * True when the mouse pointer is dragging a gizmo mesh\r\n */\r\n public get isDragging() {\r\n let dragging = false;\r\n\r\n [this.gizmos.positionGizmo, this.gizmos.rotationGizmo, this.gizmos.scaleGizmo, this.gizmos.boundingBoxGizmo].forEach((gizmo) => {\r\n if (gizmo && gizmo.isDragging) {\r\n dragging = true;\r\n }\r\n });\r\n\r\n return dragging;\r\n }\r\n\r\n /**\r\n * Ratio for the scale of the gizmo (Default: 1)\r\n */\r\n public set scaleRatio(value: number) {\r\n this._scaleRatio = value;\r\n [this.gizmos.positionGizmo, this.gizmos.rotationGizmo, this.gizmos.scaleGizmo].forEach((gizmo) => {\r\n if (gizmo) {\r\n gizmo.scaleRatio = value;\r\n }\r\n });\r\n }\r\n public get scaleRatio() {\r\n return this._scaleRatio;\r\n }\r\n\r\n /**\r\n * Set the coordinate system to use. By default it's local.\r\n * But it's possible for a user to tweak so its local for translation and world for rotation.\r\n * In that case, setting the coordinate system will change `updateGizmoRotationToMatchAttachedMesh` and `updateGizmoPositionToMatchAttachedMesh`\r\n */\r\n public set coordinatesMode(coordinatesMode: GizmoCoordinatesMode) {\r\n this._coordinatesMode = coordinatesMode;\r\n [this.gizmos.positionGizmo, this.gizmos.rotationGizmo, this.gizmos.scaleGizmo].forEach((gizmo) => {\r\n if (gizmo) {\r\n gizmo.coordinatesMode = coordinatesMode;\r\n }\r\n });\r\n }\r\n\r\n public get coordinatesMode(): GizmoCoordinatesMode {\r\n return this._coordinatesMode;\r\n }\r\n\r\n /**\r\n * The mesh the gizmo's is attached to\r\n */\r\n public get attachedMesh() {\r\n return this._attachedMesh;\r\n }\r\n\r\n /**\r\n * The node the gizmo's is attached to\r\n */\r\n public get attachedNode() {\r\n return this._attachedNode;\r\n }\r\n\r\n /**\r\n * Instantiates a gizmo manager\r\n * @param _scene the scene to overlay the gizmos on top of\r\n * @param thickness display gizmo axis thickness\r\n * @param utilityLayer the layer where gizmos are rendered\r\n * @param keepDepthUtilityLayer the layer where occluded gizmos are rendered\r\n */\r\n constructor(\r\n private _scene: Scene,\r\n thickness: number = 1,\r\n utilityLayer: UtilityLayerRenderer = UtilityLayerRenderer.DefaultUtilityLayer,\r\n keepDepthUtilityLayer: UtilityLayerRenderer = UtilityLayerRenderer.DefaultKeepDepthUtilityLayer\r\n ) {\r\n this._defaultUtilityLayer = utilityLayer;\r\n this._defaultKeepDepthUtilityLayer = keepDepthUtilityLayer;\r\n this._defaultKeepDepthUtilityLayer.utilityLayerScene.autoClearDepthAndStencil = false;\r\n this._thickness = thickness;\r\n this.gizmos = { positionGizmo: null, rotationGizmo: null, scaleGizmo: null, boundingBoxGizmo: null };\r\n\r\n const attachToMeshPointerObserver = this._attachToMeshPointerObserver(_scene);\r\n const gizmoAxisPointerObserver = Gizmo.GizmoAxisPointerObserver(this._defaultUtilityLayer, this._gizmoAxisCache);\r\n this._pointerObservers = [attachToMeshPointerObserver, gizmoAxisPointerObserver];\r\n }\r\n\r\n /**\r\n * @internal\r\n * Subscribes to pointer down events, for attaching and detaching mesh\r\n * @param scene The scene layer the observer will be added to\r\n * @returns the pointer observer\r\n */\r\n private _attachToMeshPointerObserver(scene: Scene): Observer<PointerInfo> {\r\n // Instantiate/dispose gizmos based on pointer actions\r\n const pointerObserver = scene.onPointerObservable.add((pointerInfo) => {\r\n if (!this.usePointerToAttachGizmos) {\r\n return;\r\n }\r\n if (pointerInfo.type == PointerEventTypes.POINTERDOWN) {\r\n if (pointerInfo.pickInfo && pointerInfo.pickInfo.pickedMesh) {\r\n if (this.enableAutoPicking) {\r\n let node: Nullable<Node> = pointerInfo.pickInfo.pickedMesh;\r\n if (this.attachableMeshes == null) {\r\n // Attach to the most parent node\r\n while (node && node.parent != null) {\r\n node = node.parent;\r\n }\r\n } else {\r\n // Attach to the parent node that is an attachableMesh\r\n let found = false;\r\n this.attachableMeshes.forEach((mesh) => {\r\n if (node && (node == mesh || node.isDescendantOf(mesh))) {\r\n node = mesh;\r\n found = true;\r\n }\r\n });\r\n if (!found) {\r\n node = null;\r\n }\r\n }\r\n if (node instanceof AbstractMesh) {\r\n if (this._attachedMesh != node) {\r\n this.attachToMesh(node);\r\n }\r\n } else {\r\n if (this.clearGizmoOnEmptyPointerEvent) {\r\n this.attachToMesh(null);\r\n }\r\n }\r\n }\r\n } else {\r\n if (this.clearGizmoOnEmptyPointerEvent) {\r\n this.attachToMesh(null);\r\n }\r\n }\r\n }\r\n });\r\n return pointerObserver!;\r\n }\r\n\r\n /**\r\n * Attaches a set of gizmos to the specified mesh\r\n * @param mesh The mesh the gizmo's should be attached to\r\n */\r\n public attachToMesh(mesh: Nullable<AbstractMesh>) {\r\n if (this._attachedMesh) {\r\n this._attachedMesh.removeBehavior(this.boundingBoxDragBehavior);\r\n }\r\n if (this._attachedNode) {\r\n this._attachedNode.removeBehavior(this.boundingBoxDragBehavior);\r\n }\r\n this._attachedMesh = mesh;\r\n this._attachedNode = null;\r\n for (const key in this.gizmos) {\r\n const gizmo = <Nullable<IGizmo>>(<any>this.gizmos)[key];\r\n if (gizmo && (<any>this._gizmosEnabled)[key]) {\r\n gizmo.attachedMesh = mesh;\r\n }\r\n }\r\n if (this.boundingBoxGizmoEnabled && this._attachedMesh) {\r\n this._attachedMesh.addBehavior(this.boundingBoxDragBehavior);\r\n }\r\n this.onAttachedToMeshObservable.notifyObservers(mesh);\r\n }\r\n\r\n /**\r\n * Attaches a set of gizmos to the specified node\r\n * @param node The node the gizmo's should be attached to\r\n */\r\n public attachToNode(node: Nullable<Node>) {\r\n if (this._attachedMesh) {\r\n this._attachedMesh.removeBehavior(this.boundingBoxDragBehavior);\r\n }\r\n if (this._attachedNode) {\r\n this._attachedNode.removeBehavior(this.boundingBoxDragBehavior);\r\n }\r\n this._attachedMesh = null;\r\n this._attachedNode = node;\r\n for (const key in this.gizmos) {\r\n const gizmo = <Nullable<IGizmo>>(<any>this.gizmos)[key];\r\n if (gizmo && (<any>this._gizmosEnabled)[key]) {\r\n gizmo.attachedNode = node;\r\n }\r\n }\r\n if (this.boundingBoxGizmoEnabled && this._attachedNode) {\r\n this._attachedNode.addBehavior(this.boundingBoxDragBehavior);\r\n }\r\n this.onAttachedToNodeObservable.notifyObservers(node);\r\n }\r\n\r\n /**\r\n * If the position gizmo is enabled\r\n */\r\n public set positionGizmoEnabled(value: boolean) {\r\n if (value) {\r\n if (!this.gizmos.positionGizmo) {\r\n this.gizmos.positionGizmo = new PositionGizmo(this._defaultUtilityLayer, this._thickness, this);\r\n }\r\n if (this._attachedNode) {\r\n this.gizmos.positionGizmo.attachedNode = this._attachedNode;\r\n } else {\r\n this.gizmos.positionGizmo.attachedMesh = this._attachedMesh;\r\n }\r\n } else if (this.gizmos.positionGizmo) {\r\n this.gizmos.positionGizmo.attachedNode = null;\r\n }\r\n this._gizmosEnabled.positionGizmo = value;\r\n }\r\n public get positionGizmoEnabled(): boolean {\r\n return this._gizmosEnabled.positionGizmo;\r\n }\r\n /**\r\n * If the rotation gizmo is enabled\r\n */\r\n public set rotationGizmoEnabled(value: boolean) {\r\n if (value) {\r\n if (!this.gizmos.rotationGizmo) {\r\n this.gizmos.rotationGizmo = new RotationGizmo(this._defaultUtilityLayer, 32, false, this._thickness, this);\r\n }\r\n if (this._attachedNode) {\r\n this.gizmos.rotationGizmo.attachedNode = this._attachedNode;\r\n } else {\r\n this.gizmos.rotationGizmo.attachedMesh = this._attachedMesh;\r\n }\r\n } else if (this.gizmos.rotationGizmo) {\r\n this.gizmos.rotationGizmo.attachedNode = null;\r\n }\r\n this._gizmosEnabled.rotationGizmo = value;\r\n }\r\n public get rotationGizmoEnabled(): boolean {\r\n return this._gizmosEnabled.rotationGizmo;\r\n }\r\n /**\r\n * If the scale gizmo is enabled\r\n */\r\n public set scaleGizmoEnabled(value: boolean) {\r\n if (value) {\r\n this.gizmos.scaleGizmo = this.gizmos.scaleGizmo || new ScaleGizmo(this._defaultUtilityLayer, this._thickness, this);\r\n if (this._attachedNode) {\r\n this.gizmos.scaleGizmo.attachedNode = this._attachedNode;\r\n } else {\r\n this.gizmos.scaleGizmo.attachedMesh = this._attachedMesh;\r\n }\r\n } else if (this.gizmos.scaleGizmo) {\r\n this.gizmos.scaleGizmo.attachedNode = null;\r\n }\r\n this._gizmosEnabled.scaleGizmo = value;\r\n }\r\n public get scaleGizmoEnabled(): boolean {\r\n return this._gizmosEnabled.scaleGizmo;\r\n }\r\n /**\r\n * If the boundingBox gizmo is enabled\r\n */\r\n public set boundingBoxGizmoEnabled(value: boolean) {\r\n if (value) {\r\n this.gizmos.boundingBoxGizmo = this.gizmos.boundingBoxGizmo || new BoundingBoxGizmo(this._boundingBoxColor, this._defaultKeepDepthUtilityLayer);\r\n if (this._attachedMesh) {\r\n this.gizmos.boundingBoxGizmo.attachedMesh = this._attachedMesh;\r\n } else {\r\n this.gizmos.boundingBoxGizmo.attachedNode = this._attachedNode;\r\n }\r\n\r\n if (this._attachedMesh) {\r\n this._attachedMesh.removeBehavior(this.boundingBoxDragBehavior);\r\n this._attachedMesh.addBehavior(this.boundingBoxDragBehavior);\r\n } else if (this._attachedNode) {\r\n this._attachedNode.removeBehavior(this.boundingBoxDragBehavior);\r\n this._attachedNode.addBehavior(this.boundingBoxDragBehavior);\r\n }\r\n } else if (this.gizmos.boundingBoxGizmo) {\r\n if (this._attachedMesh) {\r\n this._attachedMesh.removeBehavior(this.boundingBoxDragBehavior);\r\n } else if (this._attachedNode) {\r\n this._attachedNode.removeBehavior(this.boundingBoxDragBehavior);\r\n }\r\n this.gizmos.boundingBoxGizmo.attachedNode = null;\r\n }\r\n this._gizmosEnabled.boundingBoxGizmo = value;\r\n }\r\n public get boundingBoxGizmoEnabled(): boolean {\r\n return this._gizmosEnabled.boundingBoxGizmo;\r\n }\r\n\r\n /**\r\n * Builds Gizmo Axis Cache to enable features such as hover state preservation and graying out other axis during manipulation\r\n * @param gizmoAxisCache Gizmo axis definition used for reactive gizmo UI\r\n */\r\n public addToAxisCache(gizmoAxisCache: Map<Mesh, GizmoAxisCache>) {\r\n if (gizmoAxisCache.size > 0) {\r\n gizmoAxisCache.forEach((v, k) => {\r\n this._gizmoAxisCache.set(k, v);\r\n });\r\n }\r\n }\r\n\r\n /**\r\n * Force release the drag action by code\r\n */\r\n public releaseDrag() {\r\n [this.gizmos.positionGizmo, this.gizmos.rotationGizmo, this.gizmos.scaleGizmo, this.gizmos.boundingBoxGizmo].forEach((gizmo) => {\r\n gizmo?.releaseDrag();\r\n });\r\n }\r\n\r\n /**\r\n * Disposes of the gizmo manager\r\n */\r\n public dispose() {\r\n this._pointerObservers.forEach((observer) => {\r\n this._scene.onPointerObservable.remove(observer);\r\n });\r\n for (const key in this.gizmos) {\r\n const gizmo = <Nullable<IGizmo>>(<any>this.gizmos)[key];\r\n if (gizmo) {\r\n gizmo.dispose();\r\n }\r\n }\r\n if (this._defaultKeepDepthUtilityLayer !== UtilityLayerRenderer._DefaultKeepDepthUtilityLayer) {\r\n this._defaultKeepDepthUtilityLayer?.dispose();\r\n }\r\n if (this._defaultUtilityLayer !== UtilityLayerRenderer._DefaultUtilityLayer) {\r\n this._defaultUtilityLayer?.dispose();\r\n }\r\n this.boundingBoxDragBehavior.detach();\r\n this.onAttachedToMeshObservable.clear();\r\n }\r\n}\r\n"]}
1
+ {"version":3,"file":"gizmoManager.js","sourceRoot":"","sources":["../../../../dev/core/src/Gizmos/gizmoManager.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,UAAU,EAAE,MAAM,oBAAoB,CAAC;AAGhD,OAAO,EAAE,iBAAiB,EAAE,MAAM,yBAAyB,CAAC;AAG5D,OAAO,EAAE,YAAY,EAAE,MAAM,wBAAwB,CAAC;AAEtD,OAAO,EAAE,oBAAoB,EAAE,MAAM,mCAAmC,CAAC;AACzE,OAAO,EAAE,MAAM,EAAE,MAAM,qBAAqB,CAAC;AAC7C,OAAO,EAAE,kBAAkB,EAAE,MAAM,wCAAwC,CAAC;AAE5E,OAAO,EAAE,KAAK,EAAE,oBAAoB,EAAE,MAAM,SAAS,CAAC;AAEtD,OAAO,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAC;AAEhD,OAAO,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAC;AAEhD,OAAO,EAAE,UAAU,EAAE,MAAM,cAAc,CAAC;AAE1C,OAAO,EAAE,gBAAgB,EAAE,MAAM,oBAAoB,CAAC;AAGtD;;GAEG;AACH,MAAM,OAAO,YAAY;IAsDrB;;OAEG;IACH,IAAW,qBAAqB;QAC5B,OAAO,IAAI,CAAC,6BAA6B,CAAC;IAC9C,CAAC;IAED;;OAEG;IACH,IAAW,YAAY;QACnB,OAAO,IAAI,CAAC,oBAAoB,CAAC;IACrC,CAAC;IAED;;OAEG;IACH,IAAW,SAAS;QA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CAAC,aAAa,EAAE,IAAI,CAAC,MAAM,CAAC,aAAa,EAAE,IAAI,CAAC,MAAM,CAAC,UAAU,EAAE,IAAI,CAAC,MAAM,CAAC,gBAAgB,CAAC,CAAC,OAAO,CAAC,CAAC,KAAK,EAAE,EAAE;YAC3H,KAAK,EAAE,WAAW,EAAE,CAAC;QACzB,CAAC,CAAC,CAAC;IACP,CAAC;IAED;;OAEG;IACI,OAAO;QACV,IAAI,CAAC,iBAAiB,CAAC,OAAO,CAAC,CAAC,QAAQ,EAAE,EAAE;YACxC,IAAI,CAAC,MAAM,CAAC,mBAAmB,CAAC,MAAM,CAAC,QAAQ,CAAC,CAAC;QACrD,CAAC,CAAC,CAAC;QACH,KAAK,MAAM,GAAG,IAAI,IAAI,CAAC,MAAM,EAAE;YAC3B,MAAM,KAAK,GAA2B,IAAI,CAAC,MAAO,CAAC,GAAG,CAAC,CAAC;YACxD,IAAI,KAAK,EAAE;gBACP,KAAK,CAAC,OAAO,EAAE,CAAC;aACnB;SACJ;QACD,IAAI,IAAI,CAAC,6BAA6B,KAAK,oBAAoB,CAAC,6BAA6B,EAAE;YAC3F,IAAI,CAAC,6BAA6B,EAAE,OAAO,EAAE,CAAC;SACjD;QACD,IAAI,IAAI,CAAC,oBAAoB,KAAK,oBAAoB,CAAC,oBAAoB,EAAE;YACzE,IAAI,CAAC,oBAAoB,EAAE,OAAO,EAAE,CAAC;SACxC;QACD,IAAI,CAAC,uBAAuB,CAAC,MAAM,EAAE,CAAC;QACtC,IAAI,CAAC,0BAA0B,CAAC,KAAK,EAAE,CAAC;IAC5C,CAAC;CACJ","sourcesContent":["import type { Observer } from \"../Misc/observable\";\r\nimport { Observable } from \"../Misc/observable\";\r\nimport type { Nullable } from \"../types\";\r\nimport type { PointerInfo } from \"../Events/pointerEvents\";\r\nimport { PointerEventTypes } from \"../Events/pointerEvents\";\r\nimport type { Scene, IDisposable } from \"../scene\";\r\nimport type { Node } from \"../node\";\r\nimport { AbstractMesh } from \"../Meshes/abstractMesh\";\r\nimport type { Mesh } from \"../Meshes/mesh\";\r\nimport { UtilityLayerRenderer } from \"../Rendering/utilityLayerRenderer\";\r\nimport { Color3 } from \"../Maths/math.color\";\r\nimport { SixDofDragBehavior } from \"../Behaviors/Meshes/sixDofDragBehavior\";\r\nimport type { GizmoAxisCache, IGizmo } from \"./gizmo\";\r\nimport { Gizmo, GizmoCoordinatesMode } from \"./gizmo\";\r\nimport type { IRotationGizmo } from \"./rotationGizmo\";\r\nimport { RotationGizmo } from \"./rotationGizmo\";\r\nimport type { IPositionGizmo } from \"./positionGizmo\";\r\nimport { PositionGizmo } from \"./positionGizmo\";\r\nimport type { IScaleGizmo } from \"./scaleGizmo\";\r\nimport { ScaleGizmo } from \"./scaleGizmo\";\r\nimport type { IBoundingBoxGizmo } from \"./boundingBoxGizmo\";\r\nimport { BoundingBoxGizmo } from \"./boundingBoxGizmo\";\r\nimport type { TransformNode } from \"../Meshes/transformNode\";\r\n\r\n/**\r\n * Helps setup gizmo's in the scene to rotate/scale/position nodes\r\n */\r\nexport class GizmoManager implements IDisposable {\r\n /**\r\n * Gizmo's created by the gizmo manager, gizmo will be null until gizmo has been enabled for the first time\r\n */\r\n public gizmos: {\r\n positionGizmo: Nullable<IPositionGizmo>;\r\n rotationGizmo: Nullable<IRotationGizmo>;\r\n scaleGizmo: Nullable<IScaleGizmo>;\r\n boundingBoxGizmo: Nullable<IBoundingBoxGizmo>;\r\n };\r\n\r\n /** When true, the gizmo will be detached from the current object when a pointer down occurs with an empty picked mesh */\r\n public clearGizmoOnEmptyPointerEvent = false;\r\n\r\n /** When true (default), picking to attach a new mesh is enabled. This works in sync with inspector autopicking. */\r\n public enableAutoPicking = true;\r\n\r\n /** Fires an event when the manager is attached to a mesh */\r\n public onAttachedToMeshObservable = new Observable<Nullable<AbstractMesh>>();\r\n\r\n /** Fires an event when the manager is attached to a node */\r\n public onAttachedToNodeObservable = new Observable<Nullable<Node>>();\r\n\r\n protected _gizmosEnabled = { positionGizmo: false, rotationGizmo: false, scaleGizmo: false, boundingBoxGizmo: false };\r\n protected _pointerObservers: Observer<PointerInfo>[] = [];\r\n protected _attachedMesh: Nullable<AbstractMesh> = null;\r\n protected _attachedNode: Nullable<Node> = null;\r\n protected _boundingBoxColor = Color3.FromHexString(\"#0984e3\");\r\n protected _defaultUtilityLayer: UtilityLayerRenderer;\r\n protected _defaultKeepDepthUtilityLayer: UtilityLayerRenderer;\r\n protected _thickness: number = 1;\r\n protected _scaleRatio: number = 1;\r\n protected _coordinatesMode = GizmoCoordinatesMode.Local;\r\n protected _additionalTransformNode?: TransformNode;\r\n\r\n /** Node Caching for quick lookup */\r\n private _gizmoAxisCache: Map<Mesh, GizmoAxisCache> = new Map();\r\n /**\r\n * When bounding box gizmo is enabled, this can be used to track drag/end events\r\n */\r\n public boundingBoxDragBehavior = new SixDofDragBehavior();\r\n /**\r\n * Array of meshes which will have the gizmo attached when a pointer selected them. If null, all meshes are attachable. (Default: null)\r\n */\r\n public attachableMeshes: Nullable<Array<AbstractMesh>> = null;\r\n /**\r\n * Array of nodes which will have the gizmo attached when a pointer selected them. If null, all nodes are attachable. (Default: null)\r\n */\r\n public attachableNodes: Nullable<Array<Node>> = null;\r\n /**\r\n * If pointer events should perform attaching/detaching a gizmo, if false this can be done manually via attachToMesh/attachToNode. (Default: true)\r\n */\r\n public usePointerToAttachGizmos = true;\r\n\r\n /**\r\n * Utility layer that the bounding box gizmo belongs to\r\n */\r\n public get keepDepthUtilityLayer() {\r\n return this._defaultKeepDepthUtilityLayer;\r\n }\r\n\r\n /**\r\n * Utility layer that all gizmos besides bounding box belong to\r\n */\r\n public get utilityLayer() {\r\n return this._defaultUtilityLayer;\r\n }\r\n\r\n /**\r\n * True when the mouse pointer is hovering a gizmo mesh\r\n */\r\n public get isHovered() {\r\n let hovered = false;\r\n for (const key in this.gizmos) {\r\n const gizmo = <Nullable<IGizmo>>(<any>this.gizmos)[key];\r\n if (gizmo && gizmo.isHovered) {\r\n hovered = true;\r\n break;\r\n }\r\n }\r\n return hovered;\r\n }\r\n\r\n /**\r\n * True when the mouse pointer is dragging a gizmo mesh\r\n */\r\n public get isDragging() {\r\n let dragging = false;\r\n\r\n [this.gizmos.positionGizmo, this.gizmos.rotationGizmo, this.gizmos.scaleGizmo, this.gizmos.boundingBoxGizmo].forEach((gizmo) => {\r\n if (gizmo && gizmo.isDragging) {\r\n dragging = true;\r\n }\r\n });\r\n\r\n return dragging;\r\n }\r\n\r\n /**\r\n * Ratio for the scale of the gizmo (Default: 1)\r\n */\r\n public set scaleRatio(value: number) {\r\n this._scaleRatio = value;\r\n [this.gizmos.positionGizmo, this.gizmos.rotationGizmo, this.gizmos.scaleGizmo].forEach((gizmo) => {\r\n if (gizmo) {\r\n gizmo.scaleRatio = value;\r\n }\r\n });\r\n }\r\n public get scaleRatio() {\r\n return this._scaleRatio;\r\n }\r\n\r\n /**\r\n * Set the coordinate system to use. By default it's local.\r\n * But it's possible for a user to tweak so its local for translation and world for rotation.\r\n * In that case, setting the coordinate system will change `updateGizmoRotationToMatchAttachedMesh` and `updateGizmoPositionToMatchAttachedMesh`\r\n */\r\n public set coordinatesMode(coordinatesMode: GizmoCoordinatesMode) {\r\n this._coordinatesMode = coordinatesMode;\r\n [this.gizmos.positionGizmo, this.gizmos.rotationGizmo, this.gizmos.scaleGizmo].forEach((gizmo) => {\r\n if (gizmo) {\r\n gizmo.coordinatesMode = coordinatesMode;\r\n }\r\n });\r\n }\r\n\r\n public get coordinatesMode(): GizmoCoordinatesMode {\r\n return this._coordinatesMode;\r\n }\r\n\r\n /**\r\n * The mesh the gizmo's is attached to\r\n */\r\n public get attachedMesh() {\r\n return this._attachedMesh;\r\n }\r\n\r\n /**\r\n * The node the gizmo's is attached to\r\n */\r\n public get attachedNode() {\r\n return this._attachedNode;\r\n }\r\n\r\n /**\r\n * Additional transform node that will be used to transform all the gizmos\r\n */\r\n public get additionalTransformNode() {\r\n return this._additionalTransformNode;\r\n }\r\n\r\n /**\r\n * Instantiates a gizmo manager\r\n * @param _scene the scene to overlay the gizmos on top of\r\n * @param thickness display gizmo axis thickness\r\n * @param utilityLayer the layer where gizmos are rendered\r\n * @param keepDepthUtilityLayer the layer where occluded gizmos are rendered\r\n */\r\n constructor(\r\n private _scene: Scene,\r\n thickness: number = 1,\r\n utilityLayer: UtilityLayerRenderer = UtilityLayerRenderer.DefaultUtilityLayer,\r\n keepDepthUtilityLayer: UtilityLayerRenderer = UtilityLayerRenderer.DefaultKeepDepthUtilityLayer\r\n ) {\r\n this._defaultUtilityLayer = utilityLayer;\r\n this._defaultKeepDepthUtilityLayer = keepDepthUtilityLayer;\r\n this._defaultKeepDepthUtilityLayer.utilityLayerScene.autoClearDepthAndStencil = false;\r\n this._thickness = thickness;\r\n this.gizmos = { positionGizmo: null, rotationGizmo: null, scaleGizmo: null, boundingBoxGizmo: null };\r\n\r\n const attachToMeshPointerObserver = this._attachToMeshPointerObserver(_scene);\r\n const gizmoAxisPointerObserver = Gizmo.GizmoAxisPointerObserver(this._defaultUtilityLayer, this._gizmoAxisCache);\r\n this._pointerObservers = [attachToMeshPointerObserver, gizmoAxisPointerObserver];\r\n }\r\n\r\n /**\r\n * @internal\r\n * Subscribes to pointer down events, for attaching and detaching mesh\r\n * @param scene The scene layer the observer will be added to\r\n * @returns the pointer observer\r\n */\r\n private _attachToMeshPointerObserver(scene: Scene): Observer<PointerInfo> {\r\n // Instantiate/dispose gizmos based on pointer actions\r\n const pointerObserver = scene.onPointerObservable.add((pointerInfo) => {\r\n if (!this.usePointerToAttachGizmos) {\r\n return;\r\n }\r\n if (pointerInfo.type == PointerEventTypes.POINTERDOWN) {\r\n if (pointerInfo.pickInfo && pointerInfo.pickInfo.pickedMesh) {\r\n if (this.enableAutoPicking) {\r\n let node: Nullable<Node> = pointerInfo.pickInfo.pickedMesh;\r\n if (this.attachableMeshes == null) {\r\n // Attach to the most parent node\r\n while (node && node.parent != null) {\r\n node = node.parent;\r\n }\r\n } else {\r\n // Attach to the parent node that is an attachableMesh\r\n let found = false;\r\n this.attachableMeshes.forEach((mesh) => {\r\n if (node && (node == mesh || node.isDescendantOf(mesh))) {\r\n node = mesh;\r\n found = true;\r\n }\r\n });\r\n if (!found) {\r\n node = null;\r\n }\r\n }\r\n if (node instanceof AbstractMesh) {\r\n if (this._attachedMesh != node) {\r\n this.attachToMesh(node);\r\n }\r\n } else {\r\n if (this.clearGizmoOnEmptyPointerEvent) {\r\n this.attachToMesh(null);\r\n }\r\n }\r\n }\r\n } else {\r\n if (this.clearGizmoOnEmptyPointerEvent) {\r\n this.attachToMesh(null);\r\n }\r\n }\r\n }\r\n });\r\n return pointerObserver!;\r\n }\r\n\r\n /**\r\n * Attaches a set of gizmos to the specified mesh\r\n * @param mesh The mesh the gizmo's should be attached to\r\n */\r\n public attachToMesh(mesh: Nullable<AbstractMesh>) {\r\n if (this._attachedMesh) {\r\n this._attachedMesh.removeBehavior(this.boundingBoxDragBehavior);\r\n }\r\n if (this._attachedNode) {\r\n this._attachedNode.removeBehavior(this.boundingBoxDragBehavior);\r\n }\r\n this._attachedMesh = mesh;\r\n this._attachedNode = null;\r\n for (const key in this.gizmos) {\r\n const gizmo = <Nullable<IGizmo>>(<any>this.gizmos)[key];\r\n if (gizmo && (<any>this._gizmosEnabled)[key]) {\r\n gizmo.attachedMesh = mesh;\r\n }\r\n }\r\n if (this.boundingBoxGizmoEnabled && this._attachedMesh) {\r\n this._attachedMesh.addBehavior(this.boundingBoxDragBehavior);\r\n }\r\n this.onAttachedToMeshObservable.notifyObservers(mesh);\r\n }\r\n\r\n /**\r\n * Attaches a set of gizmos to the specified node\r\n * @param node The node the gizmo's should be attached to\r\n */\r\n public attachToNode(node: Nullable<Node>) {\r\n if (this._attachedMesh) {\r\n this._attachedMesh.removeBehavior(this.boundingBoxDragBehavior);\r\n }\r\n if (this._attachedNode) {\r\n this._attachedNode.removeBehavior(this.boundingBoxDragBehavior);\r\n }\r\n this._attachedMesh = null;\r\n this._attachedNode = node;\r\n for (const key in this.gizmos) {\r\n const gizmo = <Nullable<IGizmo>>(<any>this.gizmos)[key];\r\n if (gizmo && (<any>this._gizmosEnabled)[key]) {\r\n gizmo.attachedNode = node;\r\n }\r\n }\r\n if (this.boundingBoxGizmoEnabled && this._attachedNode) {\r\n this._attachedNode.addBehavior(this.boundingBoxDragBehavior);\r\n }\r\n this.onAttachedToNodeObservable.notifyObservers(node);\r\n }\r\n\r\n /**\r\n * If the position gizmo is enabled\r\n */\r\n public set positionGizmoEnabled(value: boolean) {\r\n if (value) {\r\n if (!this.gizmos.positionGizmo) {\r\n this.gizmos.positionGizmo = new PositionGizmo(this._defaultUtilityLayer, this._thickness, this);\r\n }\r\n if (this._attachedNode) {\r\n this.gizmos.positionGizmo.attachedNode = this._attachedNode;\r\n } else {\r\n this.gizmos.positionGizmo.attachedMesh = this._attachedMesh;\r\n }\r\n } else if (this.gizmos.positionGizmo) {\r\n this.gizmos.positionGizmo.attachedNode = null;\r\n }\r\n this._gizmosEnabled.positionGizmo = value;\r\n this._setAdditionalTransformNode();\r\n }\r\n public get positionGizmoEnabled(): boolean {\r\n return this._gizmosEnabled.positionGizmo;\r\n }\r\n /**\r\n * If the rotation gizmo is enabled\r\n */\r\n public set rotationGizmoEnabled(value: boolean) {\r\n if (value) {\r\n if (!this.gizmos.rotationGizmo) {\r\n this.gizmos.rotationGizmo = new RotationGizmo(this._defaultUtilityLayer, 32, false, this._thickness, this);\r\n }\r\n if (this._attachedNode) {\r\n this.gizmos.rotationGizmo.attachedNode = this._attachedNode;\r\n } else {\r\n this.gizmos.rotationGizmo.attachedMesh = this._attachedMesh;\r\n }\r\n } else if (this.gizmos.rotationGizmo) {\r\n this.gizmos.rotationGizmo.attachedNode = null;\r\n }\r\n this._gizmosEnabled.rotationGizmo = value;\r\n this._setAdditionalTransformNode();\r\n }\r\n public get rotationGizmoEnabled(): boolean {\r\n return this._gizmosEnabled.rotationGizmo;\r\n }\r\n /**\r\n * If the scale gizmo is enabled\r\n */\r\n public set scaleGizmoEnabled(value: boolean) {\r\n if (value) {\r\n this.gizmos.scaleGizmo = this.gizmos.scaleGizmo || new ScaleGizmo(this._defaultUtilityLayer, this._thickness, this);\r\n if (this._attachedNode) {\r\n this.gizmos.scaleGizmo.attachedNode = this._attachedNode;\r\n } else {\r\n this.gizmos.scaleGizmo.attachedMesh = this._attachedMesh;\r\n }\r\n } else if (this.gizmos.scaleGizmo) {\r\n this.gizmos.scaleGizmo.attachedNode = null;\r\n }\r\n this._gizmosEnabled.scaleGizmo = value;\r\n this._setAdditionalTransformNode();\r\n }\r\n public get scaleGizmoEnabled(): boolean {\r\n return this._gizmosEnabled.scaleGizmo;\r\n }\r\n /**\r\n * If the boundingBox gizmo is enabled\r\n */\r\n public set boundingBoxGizmoEnabled(value: boolean) {\r\n if (value) {\r\n this.gizmos.boundingBoxGizmo = this.gizmos.boundingBoxGizmo || new BoundingBoxGizmo(this._boundingBoxColor, this._defaultKeepDepthUtilityLayer);\r\n if (this._attachedMesh) {\r\n this.gizmos.boundingBoxGizmo.attachedMesh = this._attachedMesh;\r\n } else {\r\n this.gizmos.boundingBoxGizmo.attachedNode = this._attachedNode;\r\n }\r\n\r\n if (this._attachedMesh) {\r\n this._attachedMesh.removeBehavior(this.boundingBoxDragBehavior);\r\n this._attachedMesh.addBehavior(this.boundingBoxDragBehavior);\r\n } else if (this._attachedNode) {\r\n this._attachedNode.removeBehavior(this.boundingBoxDragBehavior);\r\n this._attachedNode.addBehavior(this.boundingBoxDragBehavior);\r\n }\r\n } else if (this.gizmos.boundingBoxGizmo) {\r\n if (this._attachedMesh) {\r\n this._attachedMesh.removeBehavior(this.boundingBoxDragBehavior);\r\n } else if (this._attachedNode) {\r\n this._attachedNode.removeBehavior(this.boundingBoxDragBehavior);\r\n }\r\n this.gizmos.boundingBoxGizmo.attachedNode = null;\r\n }\r\n this._gizmosEnabled.boundingBoxGizmo = value;\r\n this._setAdditionalTransformNode();\r\n }\r\n public get boundingBoxGizmoEnabled(): boolean {\r\n return this._gizmosEnabled.boundingBoxGizmo;\r\n }\r\n\r\n /**\r\n * Sets the additional transform applied to all the gizmos.\r\n * @See Gizmo.additionalTransformNode for more detail\r\n */\r\n public set additionalTransformNode(node: TransformNode | undefined) {\r\n this._additionalTransformNode = node;\r\n this._setAdditionalTransformNode();\r\n }\r\n\r\n private _setAdditionalTransformNode() {\r\n for (const key in this.gizmos) {\r\n const gizmo = <Nullable<IGizmo>>(<any>this.gizmos)[key];\r\n if (gizmo && (<any>this._gizmosEnabled)[key]) {\r\n gizmo.additionalTransformNode = this._additionalTransformNode;\r\n }\r\n }\r\n }\r\n\r\n /**\r\n * Builds Gizmo Axis Cache to enable features such as hover state preservation and graying out other axis during manipulation\r\n * @param gizmoAxisCache Gizmo axis definition used for reactive gizmo UI\r\n */\r\n public addToAxisCache(gizmoAxisCache: Map<Mesh, GizmoAxisCache>) {\r\n if (gizmoAxisCache.size > 0) {\r\n gizmoAxisCache.forEach((v, k) => {\r\n this._gizmoAxisCache.set(k, v);\r\n });\r\n }\r\n }\r\n\r\n /**\r\n * Force release the drag action by code\r\n */\r\n public releaseDrag() {\r\n [this.gizmos.positionGizmo, this.gizmos.rotationGizmo, this.gizmos.scaleGizmo, this.gizmos.boundingBoxGizmo].forEach((gizmo) => {\r\n gizmo?.releaseDrag();\r\n });\r\n }\r\n\r\n /**\r\n * Disposes of the gizmo manager\r\n */\r\n public dispose() {\r\n this._pointerObservers.forEach((observer) => {\r\n this._scene.onPointerObservable.remove(observer);\r\n });\r\n for (const key in this.gizmos) {\r\n const gizmo = <Nullable<IGizmo>>(<any>this.gizmos)[key];\r\n if (gizmo) {\r\n gizmo.dispose();\r\n }\r\n }\r\n if (this._defaultKeepDepthUtilityLayer !== UtilityLayerRenderer._DefaultKeepDepthUtilityLayer) {\r\n this._defaultKeepDepthUtilityLayer?.dispose();\r\n }\r\n if (this._defaultUtilityLayer !== UtilityLayerRenderer._DefaultUtilityLayer) {\r\n this._defaultUtilityLayer?.dispose();\r\n }\r\n this.boundingBoxDragBehavior.detach();\r\n this.onAttachedToMeshObservable.clear();\r\n }\r\n}\r\n"]}
@@ -12,6 +12,7 @@ import type { IPlaneDragGizmo } from "./planeDragGizmo";
12
12
  import { UtilityLayerRenderer } from "../Rendering/utilityLayerRenderer";
13
13
  import type { PointerInfo } from "../Events/pointerEvents";
14
14
  import type { GizmoManager } from "./gizmoManager";
15
+ import type { TransformNode } from "../Meshes/transformNode";
15
16
  /**
16
17
  * Interface for position gizmo
17
18
  */
@@ -54,6 +55,16 @@ export interface IPositionGizmo extends IGizmo {
54
55
  */
55
56
  releaseDrag(): void;
56
57
  }
58
+ /**
59
+ * Additional options for the position gizmo
60
+ */
61
+ export interface PositionGizmoOptions {
62
+ /**
63
+ * Additional transform applied to the gizmo.
64
+ * @See Gizmo.additionalTransformNode for more detail
65
+ */
66
+ additionalTransformNode?: TransformNode;
67
+ }
57
68
  /**
58
69
  * Gizmo that enables dragging a mesh along 3 axis
59
70
  */
@@ -110,13 +121,16 @@ export declare class PositionGizmo extends Gizmo implements IPositionGizmo {
110
121
  */
111
122
  get isHovered(): boolean;
112
123
  get isDragging(): boolean;
124
+ get additionalTransformNode(): TransformNode | undefined;
125
+ set additionalTransformNode(transformNode: TransformNode | undefined);
113
126
  /**
114
127
  * Creates a PositionGizmo
115
128
  * @param gizmoLayer The utility layer the gizmo will be added to
116
- @param thickness display gizmo axis thickness
129
+ * @param thickness display gizmo axis thickness
117
130
  * @param gizmoManager
131
+ * @param options More options
118
132
  */
119
- constructor(gizmoLayer?: UtilityLayerRenderer, thickness?: number, gizmoManager?: GizmoManager);
133
+ constructor(gizmoLayer?: UtilityLayerRenderer, thickness?: number, gizmoManager?: GizmoManager, options?: PositionGizmoOptions);
120
134
  /**
121
135
  * If the planar drag gizmo is enabled
122
136
  * setting this will enable/disable XY, XZ and YZ planes regardless of individual gizmo settings.
@@ -54,13 +54,22 @@ export class PositionGizmo extends Gizmo {
54
54
  this.yPlaneGizmo.dragBehavior.dragging ||
55
55
  this.zPlaneGizmo.dragBehavior.dragging);
56
56
  }
57
+ get additionalTransformNode() {
58
+ return this._additionalTransformNode;
59
+ }
60
+ set additionalTransformNode(transformNode) {
61
+ [this.xGizmo, this.yGizmo, this.zGizmo, this.xPlaneGizmo, this.yPlaneGizmo, this.zPlaneGizmo].forEach((gizmo) => {
62
+ gizmo.additionalTransformNode = transformNode;
63
+ });
64
+ }
57
65
  /**
58
66
  * Creates a PositionGizmo
59
67
  * @param gizmoLayer The utility layer the gizmo will be added to
60
- @param thickness display gizmo axis thickness
68
+ * @param thickness display gizmo axis thickness
61
69
  * @param gizmoManager
70
+ * @param options More options
62
71
  */
63
- constructor(gizmoLayer = UtilityLayerRenderer.DefaultUtilityLayer, thickness = 1, gizmoManager) {
72
+ constructor(gizmoLayer = UtilityLayerRenderer.DefaultUtilityLayer, thickness = 1, gizmoManager, options) {
64
73
  super(gizmoLayer);
65
74
  /**
66
75
  * protected variables
@@ -86,6 +95,7 @@ export class PositionGizmo extends Gizmo {
86
95
  this.xPlaneGizmo = new PlaneDragGizmo(new Vector3(1, 0, 0), Color3.Red().scale(0.5), this.gizmoLayer, this);
87
96
  this.yPlaneGizmo = new PlaneDragGizmo(new Vector3(0, 1, 0), Color3.Green().scale(0.5), this.gizmoLayer, this);
88
97
  this.zPlaneGizmo = new PlaneDragGizmo(new Vector3(0, 0, 1), Color3.Blue().scale(0.5), this.gizmoLayer, this);
98
+ this.additionalTransformNode = options?.additionalTransformNode;
89
99
  // Relay drag events
90
100
  [this.xGizmo, this.yGizmo, this.zGizmo, this.xPlaneGizmo, this.yPlaneGizmo, this.zPlaneGizmo].forEach((gizmo) => {
91
101
  gizmo.dragBehavior.onDragStartObservable.add(() => {