1 |
- {"ast":null,"code":"import { Observable } from \"../Misc/observable.js\";\nimport { Logger } from \"../Misc/logger.js\";\nimport { Quaternion, Matrix, Vector3, TmpVectors } from \"../Maths/math.vector.js\";\nimport { Mesh } from \"../Meshes/mesh.js\";\nimport { CreateBox } from \"../Meshes/Builders/boxBuilder.js\";\nimport { CreateLines } from \"../Meshes/Builders/linesBuilder.js\";\nimport { PointerDragBehavior } from \"../Behaviors/Meshes/pointerDragBehavior.js\";\nimport { Gizmo } from \"./gizmo.js\";\nimport { UtilityLayerRenderer } from \"../Rendering/utilityLayerRenderer.js\";\nimport { StandardMaterial } from \"../Materials/standardMaterial.js\";\nimport { PivotTools } from \"../Misc/pivotTools.js\";\nimport { Color3 } from \"../Maths/math.color.js\";\nimport { Epsilon } from \"../Maths/math.constants.js\";\nimport { TransformNode } from \"../Meshes/transformNode.js\";\n/**\n * Dragging operation in observable\n */\nexport var DragOperation;\n(function (DragOperation) {\n DragOperation[DragOperation[\"Rotation\"] = 0] = \"Rotation\";\n DragOperation[DragOperation[\"Scaling\"] = 1] = \"Scaling\";\n})(DragOperation || (DragOperation = {}));\n/**\n * Bounding box gizmo\n */\nexport class BoundingBoxGizmo extends Gizmo {\n /**\n * Sets the axis factor\n * @param factor the Vector3 value\n */\n set axisFactor(factor) {\n this._axisFactor = factor;\n // update scale cube visibility\n const scaleBoxes = this._scaleBoxesParent.getChildMeshes();\n let index = 0;\n for (let i = 0; i < 3; i++) {\n for (let j = 0; j < 3; j++) {\n for (let k = 0; k < 3; k++) {\n const zeroAxisCount = (i === 1 ? 1 : 0) + (j === 1 ? 1 : 0) + (k === 1 ? 1 : 0);\n if (zeroAxisCount === 1 || zeroAxisCount === 3) {\n continue;\n }\n if (scaleBoxes[index]) {\n const dragAxis = new Vector3(i - 1, j - 1, k - 1);\n dragAxis.multiplyInPlace(this._axisFactor);\n scaleBoxes[index].setEnabled(dragAxis.lengthSquared() > Epsilon);\n }\n index++;\n }\n }\n }\n }\n /**\n * Gets the axis factor\n * @returns the Vector3 factor value\n */\n get axisFactor() {\n return this._axisFactor;\n }\n /**\n * Sets scale drag speed value\n * @param value the new speed value\n */\n set scaleDragSpeed(value) {\n this._scaleDragSpeed = value;\n }\n /**\n * Gets scale drag speed\n * @returns the scale speed number\n */\n get scaleDragSpeed() {\n return this._scaleDragSpeed;\n }\n /** Default material used to render when gizmo is not disabled or hovered */\n get coloredMaterial() {\n return this._coloredMaterial;\n }\n /** Material used to render when gizmo is hovered with mouse*/\n get hoverMaterial() {\n return this._hoverColoredMaterial;\n }\n /**\n * Get the pointerDragBehavior\n */\n get pointerDragBehavior() {\n return this._pointerDragBehavior;\n }\n /** True when a rotation anchor or scale box or a attached mesh is dragged */\n get isDragging() {\n return this._dragging || this._pointerDragBehavior.dragging;\n }\n /**\n * Sets the color of the bounding box gizmo\n * @param color the color to set\n */\n setColor(color) {\n this._coloredMaterial.emissiveColor = color;\n this._hoverColoredMaterial.emissiveColor = color.clone().add(new Color3(0.3, 0.3, 0.3));\n this._lineBoundingBox.getChildren().forEach(l => {\n if (l.color) {\n l.color = color;\n }\n });\n }\n /**\n * Creates an BoundingBoxGizmo\n * @param color The color of the gizmo\n * @param gizmoLayer The utility layer the gizmo will be added to\n */\n constructor(color = Color3.Gray(), gizmoLayer = UtilityLayerRenderer.DefaultKeepDepthUtilityLayer) {\n super(gizmoLayer);\n this._boundingDimensions = new Vector3(1, 1, 1);\n this._renderObserver = null;\n this._pointerObserver = null;\n this._scaleDragSpeed = 0.2;\n this._rotateAnchorsDragBehaviors = [];\n this._scaleBoxesDragBehaviors = [];\n /**\n * boolean updated when a rotation anchor or scale box is dragged\n */\n this._dragging = false;\n this._tmpQuaternion = new Quaternion();\n this._tmpVector = new Vector3(0, 0, 0);\n this._tmpRotationMatrix = new Matrix();\n this._incrementalStartupValue = Vector3.Zero();\n this._incrementalAnchorStartupValue = Vector3.Zero();\n /**\n * If child meshes should be ignored when calculating the bounding box. This should be set to true to avoid perf hits with heavily nested meshes (Default: false)\n */\n this.ignoreChildren = false;\n /**\n * Returns true if a descendant should be included when computing the bounding box. When null, all descendants are included. If ignoreChildren is set this will be ignored. (Default: null)\n */\n this.includeChildPredicate = null;\n /**\n * The size of the rotation anchors attached to the bounding box (Default: 0.1)\n */\n this.rotationSphereSize = 0.1;\n /**\n * The size of the scale boxes attached to the bounding box (Default: 0.1)\n */\n this.scaleBoxSize = 0.1;\n /**\n * If set, the rotation anchors and scale boxes will increase in size based on the distance away from the camera to have a consistent screen size (Default: false)\n * Note : fixedDragMeshScreenSize takes precedence over fixedDragMeshBoundsSize if both are true\n */\n this.fixedDragMeshScreenSize = false;\n /**\n * If set, the rotation anchors and scale boxes will increase in size based on the size of the bounding box\n * Note : fixedDragMeshScreenSize takes precedence over fixedDragMeshBoundsSize if both are true\n */\n this.fixedDragMeshBoundsSize = false;\n /**\n * The distance away from the object which the draggable meshes should appear world sized when fixedDragMeshScreenSize is set to true (default: 10)\n */\n this.fixedDragMeshScreenSizeDistanceFactor = 10;\n /**\n * Drag distance in babylon units that the gizmo will snap scaling to when dragged\n */\n this.scalingSnapDistance = 0;\n /**\n * Drag distance in babylon units that the gizmo will snap rotation to when dragged\n */\n this.rotationSnapDistance = 0;\n /**\n * Fired when a rotation anchor or scale box is dragged\n */\n this.onDragStartObservable = new Observable();\n /**\n * Fired when the gizmo mesh hovering starts\n */\n this.onHoverStartObservable = new Observable();\n /**\n * Fired when the gizmo mesh hovering ends\n */\n this.onHoverEndObservable = new Observable();\n /**\n * Fired when a scale box is dragged\n */\n this.onScaleBoxDragObservable = new Observable();\n /**\n * Fired when a scale box drag is ended\n */\n this.onScaleBoxDragEndObservable = new Observable();\n /**\n * Fired when a rotation anchor is dragged\n */\n this.onRotationSphereDragObservable = new Observable();\n /**\n * Fired when a rotation anchor drag is ended\n */\n this.onRotationSphereDragEndObservable = new Observable();\n /**\n * Relative bounding box pivot used when scaling the attached node. When null object with scale from the opposite corner. 0.5,0.5,0.5 for center and 0.5,0,0.5 for bottom (Default: null)\n */\n this.scalePivot = null;\n /**\n * Scale factor used for masking some axis\n */\n this._axisFactor = new Vector3(1, 1, 1);\n /**\n * Incremental snap scaling (default is false). When true, with a snapDistance of 0.1, scaling will be 1.1,1.2,1.3 instead of, when false: 1.1,1.21,1.33,...\n */\n this.incrementalSnap = false;\n this._existingMeshScale = new Vector3();\n // Dragging\n this._dragMesh = null;\n this._pointerDragBehavior = new PointerDragBehavior();\n // HL2 style corner mesh\n this._cornerMesh = null;\n // Do not update the gizmo's scale so it has a fixed size to the object its attached to\n this.updateScale = false;\n this._anchorMesh = new TransformNode(\"anchor\", gizmoLayer.utilityLayerScene);\n // Create Materials\n this._coloredMaterial = new StandardMaterial(\"\", gizmoLayer.utilityLayerScene);\n this._coloredMaterial.disableLighting = true;\n this._hoverColoredMaterial = new StandardMaterial(\"\", gizmoLayer.utilityLayerScene);\n this._hoverColoredMaterial.disableLighting = true;\n // Build bounding box out of lines\n this._lineBoundingBox = new TransformNode(\"\", gizmoLayer.utilityLayerScene);\n this._lineBoundingBox.rotationQuaternion = new Quaternion();\n const lines = [];\n lines.push(CreateLines(\"lines\", {\n points: [new Vector3(0, 0, 0), new Vector3(this._boundingDimensions.x, 0, 0)]\n }, gizmoLayer.utilityLayerScene));\n lines.push(CreateLines(\"lines\", {\n points: [new Vector3(0, 0, 0), new Vector3(0, this._boundingDimensions.y, 0)]\n }, gizmoLayer.utilityLayerScene));\n lines.push(CreateLines(\"lines\", {\n points: [new Vector3(0, 0, 0), new Vector3(0, 0, this._boundingDimensions.z)]\n }, gizmoLayer.utilityLayerScene));\n lines.push(CreateLines(\"lines\", {\n points: [new Vector3(this._boundingDimensions.x, 0, 0), new Vector3(this._boundingDimensions.x, this._boundingDimensions.y, 0)]\n }, gizmoLayer.utilityLayerScene));\n lines.push(CreateLines(\"lines\", {\n points: [new Vector3(this._boundingDimensions.x, 0, 0), new Vector3(this._boundingDimensions.x, 0, this._boundingDimensions.z)]\n }, gizmoLayer.utilityLayerScene));\n lines.push(CreateLines(\"lines\", {\n points: [new Vector3(0, this._boundingDimensions.y, 0), new Vector3(this._boundingDimensions.x, this._boundingDimensions.y, 0)]\n }, gizmoLayer.utilityLayerScene));\n lines.push(CreateLines(\"lines\", {\n points: [new Vector3(0, this._boundingDimensions.y, 0), new Vector3(0, this._boundingDimensions.y, this._boundingDimensions.z)]\n }, gizmoLayer.utilityLayerScene));\n lines.push(CreateLines(\"lines\", {\n points: [new Vector3(0, 0, this._boundingDimensions.z), new Vector3(this._boundingDimensions.x, 0, this._boundingDimensions.z)]\n }, gizmoLayer.utilityLayerScene));\n lines.push(CreateLines(\"lines\", {\n points: [new Vector3(0, 0, this._boundingDimensions.z), new Vector3(0, this._boundingDimensions.y, this._boundingDimensions.z)]\n }, gizmoLayer.utilityLayerScene));\n lines.push(CreateLines(\"lines\", {\n points: [new Vector3(this._boundingDimensions.x, this._boundingDimensions.y, this._boundingDimensions.z), new Vector3(0, this._boundingDimensions.y, this._boundingDimensions.z)]\n }, gizmoLayer.utilityLayerScene));\n lines.push(CreateLines(\"lines\", {\n points: [new Vector3(this._boundingDimensions.x, this._boundingDimensions.y, this._boundingDimensions.z), new Vector3(this._boundingDimensions.x, 0, this._boundingDimensions.z)]\n }, gizmoLayer.utilityLayerScene));\n lines.push(CreateLines(\"lines\", {\n points: [new Vector3(this._boundingDimensions.x, this._boundingDimensions.y, this._boundingDimensions.z), new Vector3(this._boundingDimensions.x, this._boundingDimensions.y, 0)]\n }, gizmoLayer.utilityLayerScene));\n lines.forEach(l => {\n l.color = color;\n l.position.addInPlace(new Vector3(-this._boundingDimensions.x / 2, -this._boundingDimensions.y / 2, -this._boundingDimensions.z / 2));\n l.isPickable = false;\n this._lineBoundingBox.addChild(l);\n });\n this._rootMesh.addChild(this._lineBoundingBox);\n this.setColor(color);\n // Create rotation anchors\n this._rotateAnchorsParent = new TransformNode(\"\", gizmoLayer.utilityLayerScene);\n this._rotateAnchorsParent.rotationQuaternion = new Quaternion();\n for (let i = 0; i < 12; i++) {\n const anchor = CreateBox(\"\", {\n width: i < 4 || i >= 8 ? 1.6 : 0.4,\n height: i >= 4 && i < 8 ? 1.6 : 0.4,\n depth: 0.4\n }, gizmoLayer.utilityLayerScene);\n anchor.rotation.x = i < 4 || i >= 8 ? Math.PI * 0.25 : 0;\n anchor.rotation.y = i >= 4 && i < 8 ? Math.PI * 0.25 : 0;\n anchor.bakeTransformIntoVertices(anchor.computeWorldMatrix(true));\n anchor.rotationQuaternion = new Quaternion();\n anchor.material = this._coloredMaterial;\n anchor.isNearGrabbable = true;\n // Drag behavior\n const rotateAnchorsDragBehavior = new PointerDragBehavior({});\n rotateAnchorsDragBehavior.moveAttached = false;\n rotateAnchorsDragBehavior.updateDragPlane = false;\n anchor.addBehavior(rotateAnchorsDragBehavior);\n const startingTurnDirection = new Vector3(1, 0, 0);\n let totalTurnAmountOfDrag = 0;\n let previousProjectDist = 0;\n rotateAnchorsDragBehavior.onDragStartObservable.add(() => {\n startingTurnDirection.copyFrom(anchor.forward);\n totalTurnAmountOfDrag = 0;\n previousProjectDist = 0;\n });\n const computeAxis = function () {\n const dragAxisIndex = Math.floor(i / 4);\n TmpVectors.Vector3[0].set(dragAxisIndex == 0 ? 1 : 0, dragAxisIndex == 1 ? 1 : 0, dragAxisIndex == 2 ? 1 : 0);\n return TmpVectors.Vector3[0];\n };\n rotateAnchorsDragBehavior.onDragObservable.add(event => {\n this.onRotationSphereDragObservable.notifyObservers({\n dragOperation: 0 /* DragOperation.Rotation */,\n dragAxis: computeAxis().clone()\n });\n if (this.attachedMesh) {\n const originalParent = this.attachedMesh.parent;\n if (originalParent && originalParent.scaling && originalParent.scaling.isNonUniformWithinEpsilon(0.001)) {\n Logger.Warn(\"BoundingBoxGizmo controls are not supported on child meshes with non-uniform parent scaling\");\n return;\n }\n PivotTools._RemoveAndStorePivotPoint(this.attachedMesh);\n const worldDragDirection = startingTurnDirection;\n // Project the world right on to the drag plane\n const toSub = event.dragPlaneNormal.scale(Vector3.Dot(event.dragPlaneNormal, worldDragDirection));\n const dragAxis = worldDragDirection.subtract(toSub).normalizeToNew();\n // project drag delta on to the resulting drag axis and rotate based on that\n let projectDist = Vector3.Dot(dragAxis, event.delta) < 0 ? Math.abs(event.delta.length()) : -Math.abs(event.delta.length());\n // Make rotation relative to size of mesh.\n projectDist = projectDist / this._boundingDimensions.length() * this._anchorMesh.scaling.length();\n // Rotate based on axis\n if (!this.attachedMesh.rotationQuaternion) {\n this.attachedMesh.rotationQuaternion = Quaternion.RotationYawPitchRoll(this.attachedMesh.rotation.y, this.attachedMesh.rotation.x, this.attachedMesh.rotation.z);\n }\n if (!this._anchorMesh.rotationQuaternion) {\n this._anchorMesh.rotationQuaternion = Quaternion.RotationYawPitchRoll(this._anchorMesh.rotation.y, this._anchorMesh.rotation.x, this._anchorMesh.rotation.z);\n }\n // Do not allow the object to turn more than a full circle\n totalTurnAmountOfDrag += projectDist;\n if (Math.abs(totalTurnAmountOfDrag) <= 2 * Math.PI) {\n if (this.rotationSnapDistance > 0) {\n const dragSteps = Math.floor(Math.abs(totalTurnAmountOfDrag) / this.rotationSnapDistance) * (totalTurnAmountOfDrag < 0 ? -1 : 1);\n const angle = this.rotationSnapDistance * dragSteps;\n projectDist = angle - previousProjectDist;\n previousProjectDist = angle;\n }\n if (i >= 8) {\n Quaternion.RotationYawPitchRollToRef(0, 0, projectDist, this._tmpQuaternion);\n } else if (i >= 4) {\n Quaternion.RotationYawPitchRollToRef(projectDist, 0, 0, this._tmpQuaternion);\n } else {\n Quaternion.RotationYawPitchRollToRef(0, projectDist, 0, this._tmpQuaternion);\n }\n // if using pivot, move anchor so mesh will be at relative (0,0,0) when parented\n if (this.attachedMesh.isUsingPivotMatrix()) {\n this._anchorMesh.position.copyFrom(this.attachedMesh.position);\n }\n // Rotate around center of bounding box\n this._anchorMesh.addChild(this.attachedMesh);\n if (this._anchorMesh.getScene().useRightHandedSystem) {\n this._tmpQuaternion.conjugateInPlace();\n }\n this._tmpQuaternion.normalize();\n this._anchorMesh.rotationQuaternion.multiplyToRef(this._tmpQuaternion, this._anchorMesh.rotationQuaternion);\n this._anchorMesh.rotationQuaternion.normalize();\n this._anchorMesh.removeChild(this.attachedMesh);\n this.attachedMesh.setParent(originalParent);\n }\n this.updateBoundingBox();\n PivotTools._RestorePivotPoint(this.attachedMesh);\n }\n this._updateDummy();\n });\n // Selection/deselection\n rotateAnchorsDragBehavior.onDragStartObservable.add(() => {\n this.onDragStartObservable.notifyObservers({\n dragOperation: 0 /* DragOperation.Rotation */,\n dragAxis: computeAxis().clone()\n });\n this._dragging = true;\n this._selectNode(anchor);\n });\n rotateAnchorsDragBehavior.onDragEndObservable.add(event => {\n this.onRotationSphereDragEndObservable.notifyObservers({\n dragOperation: 0 /* DragOperation.Rotation */,\n dragAxis: computeAxis().clone()\n });\n this._dragging = false;\n this._selectNode(null);\n this._updateDummy();\n this._unhoverMeshOnTouchUp(event.pointerInfo, anchor);\n });\n this._rotateAnchorsDragBehaviors.push(rotateAnchorsDragBehavior);\n this._rotateAnchorsParent.addChild(anchor);\n }\n this._rootMesh.addChild(this._rotateAnchorsParent);\n // Create scale cubes\n this._scaleBoxesParent = new TransformNode(\"\", gizmoLayer.utilityLayerScene);\n this._scaleBoxesParent.rotationQuaternion = new Quaternion();\n for (let i = 0; i < 3; i++) {\n for (let j = 0; j < 3; j++) {\n for (let k = 0; k < 3; k++) {\n // create box for relevant axis\n const zeroAxisCount = (i === 1 ? 1 : 0) + (j === 1 ? 1 : 0) + (k === 1 ? 1 : 0);\n if (zeroAxisCount === 1 || zeroAxisCount === 3) {\n continue;\n }\n const box = zeroAxisCount === 2 ? CreateBox(\"\", {\n size: 1\n }, gizmoLayer.utilityLayerScene) : this._getCornerMesh(gizmoLayer);\n if (zeroAxisCount === 0) {\n box.rotationQuaternion = Quaternion.FromEulerAngles(j * 0.25 * Math.PI, (k + 3 * i - i * k) * 0.25 * Math.PI, 0);\n }\n box.material = this._coloredMaterial;\n box._internalMetadata = zeroAxisCount === 2; // None homogenous scale handle\n box.isNearGrabbable = true;\n // box is oriented so, transform world desired axis to local one\n TmpVectors.Vector3[0].set(i - 1, j - 1, k - 1);\n TmpVectors.Vector3[0].normalize();\n box.computeWorldMatrix(true).invertToRef(TmpVectors.Matrix[0]);\n const dragAxis = Vector3.TransformCoordinates(TmpVectors.Vector3[0], TmpVectors.Matrix[0]);\n dragAxis.normalize();\n // Dragging logic\n const scaleBoxesDragBehavior = new PointerDragBehavior({\n dragAxis: dragAxis\n });\n scaleBoxesDragBehavior.updateDragPlane = false;\n scaleBoxesDragBehavior.moveAttached = false;\n let totalRelativeDragDistance = 0;\n let previousScale = 0;\n box.addBehavior(scaleBoxesDragBehavior);\n scaleBoxesDragBehavior.onDragObservable.add(event => {\n this.onScaleBoxDragObservable.notifyObservers({\n dragOperation: 1 /* DragOperation.Scaling */,\n dragAxis: new Vector3(i - 1, j - 1, k - 1)\n });\n if (this.attachedMesh) {\n const originalParent = this.attachedMesh.parent;\n if (originalParent && originalParent.scaling && originalParent.scaling.isNonUniformWithinEpsilon(0.001)) {\n Logger.Warn(\"BoundingBoxGizmo controls are not supported on child meshes with non-uniform parent scaling\");\n return;\n }\n PivotTools._RemoveAndStorePivotPoint(this.attachedMesh);\n let relativeDragDistance = event.dragDistance / this._boundingDimensions.length() * this._anchorMesh.scaling.length();\n totalRelativeDragDistance += relativeDragDistance;\n if (this.scalingSnapDistance > 0) {\n const dragSteps = Math.floor(Math.abs(totalRelativeDragDistance) / this.scalingSnapDistance) * (totalRelativeDragDistance < 0 ? -1 : 1);\n const scale = this.scalingSnapDistance * dragSteps;\n relativeDragDistance = scale - previousScale;\n previousScale = scale;\n }\n const deltaScale = new Vector3(relativeDragDistance, relativeDragDistance, relativeDragDistance);\n const fullScale = new Vector3(previousScale, previousScale, previousScale);\n if (zeroAxisCount === 2) {\n // scale on 1 axis when using the anchor box in the face middle\n deltaScale.x *= Math.abs(dragAxis.x);\n deltaScale.y *= Math.abs(dragAxis.y);\n deltaScale.z *= Math.abs(dragAxis.z);\n }\n deltaScale.scaleInPlace(this._scaleDragSpeed);\n deltaScale.multiplyInPlace(this._axisFactor);\n fullScale.scaleInPlace(this._scaleDragSpeed);\n fullScale.multiplyInPlace(this._axisFactor);\n fullScale.addInPlace(this._incrementalStartupValue);\n this.updateBoundingBox();\n if (this.scalePivot) {\n this.attachedMesh.getWorldMatrix().getRotationMatrixToRef(this._tmpRotationMatrix);\n // Move anchor to desired pivot point (Bottom left corner + dimension/2)\n this._boundingDimensions.scaleToRef(0.5, this._tmpVector);\n Vector3.TransformCoordinatesToRef(this._tmpVector, this._tmpRotationMatrix, this._tmpVector);\n this._anchorMesh.position.subtractInPlace(this._tmpVector);\n this._boundingDimensions.multiplyToRef(this.scalePivot, this._tmpVector);\n Vector3.TransformCoordinatesToRef(this._tmpVector, this._tmpRotationMatrix, this._tmpVector);\n this._anchorMesh.position.addInPlace(this._tmpVector);\n } else {\n // Scale from the position of the opposite corner\n box.absolutePosition.subtractToRef(this._anchorMesh.position, this._tmpVector);\n this._anchorMesh.position.subtractInPlace(this._tmpVector);\n if (this.attachedMesh.isUsingPivotMatrix()) {\n this._anchorMesh.position.subtractInPlace(this.attachedMesh.getPivotPoint());\n }\n }\n this._anchorMesh.addChild(this.attachedMesh);\n if (this.incrementalSnap) {\n fullScale.x /= Math.abs(this._incrementalStartupValue.x) < Epsilon ? 1 : this._incrementalStartupValue.x;\n fullScale.y /= Math.abs(this._incrementalStartupValue.y) < Epsilon ? 1 : this._incrementalStartupValue.y;\n fullScale.z /= Math.abs(this._incrementalStartupValue.z) < Epsilon ? 1 : this._incrementalStartupValue.z;\n fullScale.x = Math.max(this._incrementalAnchorStartupValue.x * fullScale.x, this.scalingSnapDistance);\n fullScale.y = Math.max(this._incrementalAnchorStartupValue.y * fullScale.y, this.scalingSnapDistance);\n fullScale.z = Math.max(this._incrementalAnchorStartupValue.z * fullScale.z, this.scalingSnapDistance);\n this._anchorMesh.scaling.x += (fullScale.x - this._anchorMesh.scaling.x) * Math.abs(dragAxis.x);\n this._anchorMesh.scaling.y += (fullScale.y - this._anchorMesh.scaling.y) * Math.abs(dragAxis.y);\n this._anchorMesh.scaling.z += (fullScale.z - this._anchorMesh.scaling.z) * Math.abs(dragAxis.z);\n } else {\n this._anchorMesh.scaling.addInPlace(deltaScale);\n if (this._anchorMesh.scaling.x < 0 || this._anchorMesh.scaling.y < 0 || this._anchorMesh.scaling.z < 0) {\n this._anchorMesh.scaling.subtractInPlace(deltaScale);\n }\n }\n this._anchorMesh.removeChild(this.attachedMesh);\n this.attachedMesh.setParent(originalParent);\n PivotTools._RestorePivotPoint(this.attachedMesh);\n }\n this._updateDummy();\n });\n // Selection/deselection\n scaleBoxesDragBehavior.onDragStartObservable.add(() => {\n this.onDragStartObservable.notifyObservers({\n dragOperation: 1 /* DragOperation.Scaling */,\n dragAxis: new Vector3(i - 1, j - 1, k - 1)\n });\n this._dragging = true;\n this._selectNode(box);\n totalRelativeDragDistance = 0;\n previousScale = 0;\n this._incrementalStartupValue.copyFrom(this.attachedMesh.scaling);\n this._incrementalAnchorStartupValue.copyFrom(this._anchorMesh.scaling);\n });\n scaleBoxesDragBehavior.onDragEndObservable.add(event => {\n this.onScaleBoxDragEndObservable.notifyObservers({\n dragOperation: 1 /* DragOperation.Scaling */,\n dragAxis: new Vector3(i - 1, j - 1, k - 1)\n });\n this._dragging = false;\n this._selectNode(null);\n this._updateDummy();\n this._unhoverMeshOnTouchUp(event.pointerInfo, box);\n });\n this._scaleBoxesParent.addChild(box);\n this._scaleBoxesDragBehaviors.push(scaleBoxesDragBehavior);\n }\n }\n }\n this._rootMesh.addChild(this._scaleBoxesParent);\n // Hover color change\n const pointerIds = [];\n this._pointerObserver = gizmoLayer.utilityLayerScene.onPointerObservable.add(pointerInfo => {\n if (!pointerIds[pointerInfo.event.pointerId]) {\n this._rotateAnchorsParent.getChildMeshes().concat(this._scaleBoxesParent.getChildMeshes()).forEach(mesh => {\n if (pointerInfo.pickInfo && pointerInfo.pickInfo.pickedMesh == mesh) {\n pointerIds[pointerInfo.event.pointerId] = mesh;\n mesh.material = this._hoverColoredMaterial;\n this.onHoverStartObservable.notifyObservers();\n this._isHovered = true;\n }\n });\n } else {\n if (pointerInfo.pickInfo && pointerInfo.pickInfo.pickedMesh != pointerIds[pointerInfo.event.pointerId]) {\n pointerIds[pointerInfo.event.pointerId].material = this._coloredMaterial;\n delete pointerIds[pointerInfo.event.pointerId];\n this.onHoverEndObservable.notifyObservers();\n this._isHovered = false;\n }\n }\n });\n // Update bounding box positions\n this._renderObserver = this.gizmoLayer.originalScene.onBeforeRenderObservable.add(() => {\n // Only update the bounding box if scaling has changed\n if (this.attachedMesh && !this._existingMeshScale.equals(this.attachedMesh.scaling)) {\n this.updateBoundingBox();\n } else if (this.fixedDragMeshScreenSize || this.fixedDragMeshBoundsSize) {\n this._updateRotationAnchors();\n this._updateScaleBoxes();\n }\n // If drag mesh is enabled and dragging, update the attached mesh pose to match the drag mesh\n if (this._dragMesh && this.attachedMesh && this._pointerDragBehavior.dragging) {\n this._lineBoundingBox.position.rotateByQuaternionToRef(this._rootMesh.rotationQuaternion, this._tmpVector);\n this.attachedMesh.setAbsolutePosition(this._dragMesh.position.add(this._tmpVector.scale(-1)));\n }\n });\n this.updateBoundingBox();\n }\n _getCornerMesh(gizmoLayer) {\n if (!this._cornerMesh) {\n const boxZ = CreateBox(\"\", {\n width: 0.4,\n height: 0.4,\n depth: 1.6\n }, gizmoLayer.utilityLayerScene);\n boxZ.position.z = 0.6;\n const boxY = CreateBox(\"\", {\n width: 0.4,\n height: 1.6,\n depth: 0.4\n }, gizmoLayer.utilityLayerScene);\n boxY.position.y = 0.6;\n const boxX = CreateBox(\"\", {\n width: 1.6,\n height: 0.4,\n depth: 0.4\n }, gizmoLayer.utilityLayerScene);\n boxX.position.x = 0.6;\n this._cornerMesh = Mesh.MergeMeshes([boxX, boxY, boxZ], true);\n return this._cornerMesh;\n }\n return this._cornerMesh.clone();\n }\n _attachedNodeChanged(value) {\n if (value) {\n // Reset anchor mesh to match attached mesh's scale\n // This is needed to avoid invalid box/anchor position on first drag\n this._anchorMesh.scaling.setAll(1);\n PivotTools._RemoveAndStorePivotPoint(value);\n const originalParent = value.parent;\n this._anchorMesh.addChild(value);\n this._anchorMesh.removeChild(value);\n value.setParent(originalParent);\n PivotTools._RestorePivotPoint(value);\n this.updateBoundingBox();\n value.getChildMeshes(false).forEach(m => {\n m.markAsDirty(\"scaling\");\n });\n this.gizmoLayer.utilityLayerScene.onAfterRenderObservable.addOnce(() => {\n this._updateDummy();\n });\n }\n }\n _selectNode(selectedMesh) {\n this._rotateAnchorsParent.getChildMeshes().concat(this._scaleBoxesParent.getChildMeshes()).forEach(m => {\n m.isVisible = !selectedMesh || m == selectedMesh;\n });\n }\n _unhoverMeshOnTouchUp(pointerInfo, selectedMesh) {\n // force unhover mesh if not a mouse event\n if ((pointerInfo === null || pointerInfo === void 0 ? void 0 : pointerInfo.event) instanceof PointerEvent && (pointerInfo === null || pointerInfo === void 0 ? void 0 : pointerInfo.event.pointerType) === \"touch\") {\n selectedMesh.material = this._coloredMaterial;\n }\n }\n /**\n * returns an array containing all boxes used for scaling (in increasing x, y and z orders)\n * @returns array of scaling boxes\n */\n getScaleBoxes() {\n return this._scaleBoxesParent.getChildMeshes();\n }\n /**\n * Updates the bounding box information for the Gizmo\n */\n updateBoundingBox() {\n if (this.attachedMesh) {\n PivotTools._RemoveAndStorePivotPoint(this.attachedMesh);\n // Store original parent\n const originalParent = this.attachedMesh.parent;\n this.attachedMesh.setParent(null);\n this._update();\n // Rotate based on axis\n if (!this.attachedMesh.rotationQuaternion) {\n this.attachedMesh.rotationQuaternion = Quaternion.RotationYawPitchRoll(this.attachedMesh.rotation.y, this.attachedMesh.rotation.x, this.attachedMesh.rotation.z);\n }\n if (!this._anchorMesh.rotationQuaternion) {\n this._anchorMesh.rotationQuaternion = Quaternion.RotationYawPitchRoll(this._anchorMesh.rotation.y, this._anchorMesh.rotation.x, this._anchorMesh.rotation.z);\n }\n this._anchorMesh.rotationQuaternion.copyFrom(this.attachedMesh.rotationQuaternion);\n // Store original position and reset mesh to origin before computing the bounding box\n this._tmpQuaternion.copyFrom(this.attachedMesh.rotationQuaternion);\n this._tmpVector.copyFrom(this.attachedMesh.position);\n this.attachedMesh.rotationQuaternion.set(0, 0, 0, 1);\n this.attachedMesh.position.set(0, 0, 0);\n // Update bounding dimensions/positions\n const boundingMinMax = this.attachedMesh.getHierarchyBoundingVectors(!this.ignoreChildren, this.includeChildPredicate);\n boundingMinMax.max.subtractToRef(boundingMinMax.min, this._boundingDimensions);\n // Update gizmo to match bounding box scaling and rotation\n // The position set here is the offset from the origin for the boundingbox when the attached mesh is at the origin\n // The position of the gizmo is then set to the attachedMesh in gizmo._update\n this._lineBoundingBox.scaling.copyFrom(this._boundingDimensions);\n this._lineBoundingBox.position.set((boundingMinMax.max.x + boundingMinMax.min.x) / 2, (boundingMinMax.max.y + boundingMinMax.min.y) / 2, (boundingMinMax.max.z + boundingMinMax.min.z) / 2);\n this._rotateAnchorsParent.position.copyFrom(this._lineBoundingBox.position);\n this._scaleBoxesParent.position.copyFrom(this._lineBoundingBox.position);\n this._lineBoundingBox.computeWorldMatrix();\n this._anchorMesh.position.copyFrom(this._lineBoundingBox.absolutePosition);\n // Restore position/rotation values\n this.attachedMesh.rotationQuaternion.copyFrom(this._tmpQuaternion);\n this.attachedMesh.position.copyFrom(this._tmpVector);\n // Restore original parent\n this.attachedMesh.setParent(originalParent);\n }\n this._updateRotationAnchors();\n this._updateScaleBoxes();\n if (this.attachedMesh) {\n this._existingMeshScale.copyFrom(this.attachedMesh.scaling);\n PivotTools._RestorePivotPoint(this.attachedMesh);\n }\n }\n _updateRotationAnchors() {\n const rotateAnchors = this._rotateAnchorsParent.getChildMeshes();\n for (let i = 0; i < 3; i++) {\n for (let j = 0; j < 2; j++) {\n for (let k = 0; k < 2; k++) {\n const index = i * 4 + j * 2 + k;\n rotateAnchors[index].position.normalizeToRef(TmpVectors.Vector3[0]);\n if (i == 0) {\n rotateAnchors[index].position.set(0, this._boundingDimensions.y * (j - 0.5), this._boundingDimensions.z * (k - 0.5));\n TmpVectors.Vector3[1].set(1, 0, 0);\n }\n if (i == 1) {\n rotateAnchors[index].position.set(this._boundingDimensions.x * (j - 0.5), 0, this._boundingDimensions.z * (k - 0.5));\n TmpVectors.Vector3[1].set(0, 1, 0);\n }\n if (i == 2) {\n rotateAnchors[index].position.set(this._boundingDimensions.x * (j - 0.5), this._boundingDimensions.y * (k - 0.5), 0);\n TmpVectors.Vector3[1].set(0, 0, 1);\n }\n const target = TmpVectors.Vector3[2];\n Vector3.CrossToRef(TmpVectors.Vector3[0], TmpVectors.Vector3[1], target);\n target.normalize();\n target.addInPlace(rotateAnchors[index].position);\n rotateAnchors[index].lookAt(target);\n if (this.fixedDragMeshScreenSize && this.gizmoLayer.utilityLayerScene.activeCamera) {\n rotateAnchors[index].absolutePosition.subtractToRef(this.gizmoLayer.utilityLayerScene.activeCamera.position, this._tmpVector);\n const distanceFromCamera = this.rotationSphereSize * this._tmpVector.length() / this.fixedDragMeshScreenSizeDistanceFactor;\n rotateAnchors[index].scaling.set(distanceFromCamera, distanceFromCamera, distanceFromCamera);\n } else if (this.fixedDragMeshBoundsSize) {\n rotateAnchors[index].scaling.set(this.rotationSphereSize * this._boundingDimensions.x, this.rotationSphereSize * this._boundingDimensions.y, this.rotationSphereSize * this._boundingDimensions.z);\n } else {\n rotateAnchors[index].scaling.set(this.rotationSphereSize, this.rotationSphereSize, this.rotationSphereSize);\n }\n }\n }\n }\n }\n _updateScaleBoxes() {\n const scaleBoxes = this._scaleBoxesParent.getChildMeshes();\n let index = 0;\n for (let i = 0; i < 3; i++) {\n for (let j = 0; j < 3; j++) {\n for (let k = 0; k < 3; k++) {\n const zeroAxisCount = (i === 1 ? 1 : 0) + (j === 1 ? 1 : 0) + (k === 1 ? 1 : 0);\n if (zeroAxisCount === 1 || zeroAxisCount === 3) {\n continue;\n }\n if (scaleBoxes[index]) {\n scaleBoxes[index].position.set(this._boundingDimensions.x * (i / 2), this._boundingDimensions.y * (j / 2), this._boundingDimensions.z * (k / 2));\n scaleBoxes[index].position.addInPlace(new Vector3(-this._boundingDimensions.x / 2, -this._boundingDimensions.y / 2, -this._boundingDimensions.z / 2));\n if (this.fixedDragMeshScreenSize && this.gizmoLayer.utilityLayerScene.activeCamera) {\n scaleBoxes[index].absolutePosition.subtractToRef(this.gizmoLayer.utilityLayerScene.activeCamera.globalPosition, this._tmpVector);\n const distanceFromCamera = this.scaleBoxSize * this._tmpVector.length() / this.fixedDragMeshScreenSizeDistanceFactor;\n scaleBoxes[index].scaling.set(distanceFromCamera, distanceFromCamera, distanceFromCamera);\n } else if (this.fixedDragMeshBoundsSize) {\n scaleBoxes[index].scaling.set(this.scaleBoxSize * this._boundingDimensions.x, this.scaleBoxSize * this._boundingDimensions.y, this.scaleBoxSize * this._boundingDimensions.z);\n } else {\n scaleBoxes[index].scaling.set(this.scaleBoxSize, this.scaleBoxSize, this.scaleBoxSize);\n }\n }\n index++;\n }\n }\n }\n }\n /**\n * Enables rotation on the specified axis and disables rotation on the others\n * @param axis The list of axis that should be enabled (eg. \"xy\" or \"xyz\")\n */\n setEnabledRotationAxis(axis) {\n this._rotateAnchorsParent.getChildMeshes().forEach((m, i) => {\n if (i < 4) {\n m.setEnabled(axis.indexOf(\"x\") != -1);\n } else if (i < 8) {\n m.setEnabled(axis.indexOf(\"y\") != -1);\n } else {\n m.setEnabled(axis.indexOf(\"z\") != -1);\n }\n });\n }\n /**\n * Enables/disables scaling\n * @param enable if scaling should be enabled\n * @param homogeneousScaling defines if scaling should only be homogeneous\n */\n setEnabledScaling(enable, homogeneousScaling = false) {\n this._scaleBoxesParent.getChildMeshes().forEach(m => {\n let enableMesh = enable;\n // Disable heterogeneous scale handles if requested.\n if (homogeneousScaling && m._internalMetadata === true) {\n enableMesh = false;\n }\n m.setEnabled(enableMesh);\n });\n }\n _updateDummy() {\n if (this._dragMesh) {\n this._dragMesh.position.copyFrom(this._lineBoundingBox.getAbsolutePosition());\n this._dragMesh.scaling.copyFrom(this._lineBoundingBox.scaling);\n this._dragMesh.rotationQuaternion.copyFrom(this._rootMesh.rotationQuaternion);\n }\n }\n /**\n * Enables a pointer drag behavior on the bounding box of the gizmo\n */\n enableDragBehavior() {\n this._dragMesh = CreateBox(\"dummy\", {\n size: 1\n }, this.gizmoLayer.utilityLayerScene);\n this._dragMesh.visibility = 0;\n this._dragMesh.rotationQuaternion = new Quaternion();\n this._pointerDragBehavior.useObjectOrientationForDragging = false;\n this._dragMesh.addBehavior(this._pointerDragBehavior);\n }\n /**\n * Force release the drag action by code\n */\n releaseDrag() {\n this._scaleBoxesDragBehaviors.forEach(dragBehavior => {\n dragBehavior.releaseDrag();\n });\n this._rotateAnchorsDragBehaviors.forEach(dragBehavior => {\n dragBehavior.releaseDrag();\n });\n this._pointerDragBehavior.releaseDrag();\n }\n /**\n * Disposes of the gizmo\n */\n dispose() {\n this.gizmoLayer.utilityLayerScene.onPointerObservable.remove(this._pointerObserver);\n this.gizmoLayer.originalScene.onBeforeRenderObservable.remove(this._renderObserver);\n this._lineBoundingBox.dispose();\n this._rotateAnchorsParent.dispose();\n this._scaleBoxesParent.dispose();\n if (this._dragMesh) {\n this._dragMesh.dispose();\n }\n this._scaleBoxesDragBehaviors.length = 0;\n this._rotateAnchorsDragBehaviors.length = 0;\n this.onDragStartObservable.clear();\n this.onHoverStartObservable.clear();\n this.onHoverEndObservable.clear();\n this.onScaleBoxDragObservable.clear();\n this.onScaleBoxDragEndObservable.clear();\n this.onRotationSphereDragObservable.clear();\n this.onRotationSphereDragEndObservable.clear();\n super.dispose();\n }\n /**\n * Makes a mesh not pickable and wraps the mesh inside of a bounding box mesh that is pickable. (This is useful to avoid picking within complex geometry)\n * @param mesh the mesh to wrap in the bounding box mesh and make not pickable\n * @returns the bounding box mesh with the passed in mesh as a child\n */\n static MakeNotPickableAndWrapInBoundingBox(mesh) {\n const makeNotPickable = root => {\n root.isPickable = false;\n root.getChildMeshes().forEach(c => {\n makeNotPickable(c);\n });\n };\n makeNotPickable(mesh);\n // Reset position to get bounding box from origin with no rotation\n if (!mesh.rotationQuaternion) {\n mesh.rotationQuaternion = Quaternion.RotationYawPitchRoll(mesh.rotation.y, mesh.rotation.x, mesh.rotation.z);\n }\n const oldPos = mesh.position.clone();\n const oldRot = mesh.rotationQuaternion.clone();\n mesh.rotationQuaternion.set(0, 0, 0, 1);\n mesh.position.set(0, 0, 0);\n // Update bounding dimensions/positions\n const box = CreateBox(\"box\", {\n size: 1\n }, mesh.getScene());\n const boundingMinMax = mesh.getHierarchyBoundingVectors();\n boundingMinMax.max.subtractToRef(boundingMinMax.min, box.scaling);\n // Adjust scale to avoid undefined behavior when adding child\n if (box.scaling.y === 0) {\n box.scaling.y = Epsilon;\n }\n if (box.scaling.x === 0) {\n box.scaling.x = Epsilon;\n }\n if (box.scaling.z === 0) {\n box.scaling.z = Epsilon;\n }\n box.position.set((boundingMinMax.max.x + boundingMinMax.min.x) / 2, (boundingMinMax.max.y + boundingMinMax.min.y) / 2, (boundingMinMax.max.z + boundingMinMax.min.z) / 2);\n // Restore original positions\n mesh.addChild(box);\n mesh.rotationQuaternion.copyFrom(oldRot);\n mesh.position.copyFrom(oldPos);\n // Reverse parenting\n mesh.removeChild(box);\n box.addChild(mesh);\n box.visibility = 0;\n return box;\n }\n /**\n * CustomMeshes are not supported by this gizmo\n */\n setCustomMesh() {\n Logger.Error(\"Custom meshes are not supported on this gizmo\");\n }\n}","map":{"version":3,"names":["Observable","Logger","Quaternion","Matrix","Vector3","TmpVectors","Mesh","CreateBox","CreateLines","PointerDragBehavior","Gizmo","UtilityLayerRenderer","StandardMaterial","PivotTools","Color3","Epsilon","TransformNode","DragOperation","BoundingBoxGizmo","axisFactor","factor","_axisFactor","scaleBoxes","_scaleBoxesParent","getChildMeshes","index","i","j","k","zeroAxisCount","dragAxis","multiplyInPlace","setEnabled","lengthSquared","scaleDragSpeed","value","_scaleDragSpeed","coloredMaterial","_coloredMaterial","hoverMaterial","_hoverColoredMaterial","pointerDragBehavior","_pointerDragBehavior","isDragging","_dragging","dragging","setColor","color","emissiveColor","clone","add","_lineBoundingBox","getChildren","forEach","l","constructor","Gray","gizmoLayer","DefaultKeepDepthUtilityLayer","_boundingDimensions","_renderObserver","_pointerObserver","_rotateAnchorsDragBehaviors","_scaleBoxesDragBehaviors","_tmpQuaternion","_tmpVector","_tmpRotationMatrix","_incrementalStartupValue","Zero","_incrementalAnchorStartupValue","ignoreChildren","includeChildPredicate","rotationSphereSize","scaleBoxSize","fixedDragMeshScreenSize","fixedDragMeshBoundsSize","fixedDragMeshScreenSizeDistanceFactor","scalingSnapDistance","rotationSnapDistance","onDragStartObservable","onHoverStartObservable","onHoverEndObservable","onScaleBoxDragObservable","onScaleBoxDragEndObservable","onRotationSphereDragObservable","onRotationSphereDragEndObservable","scalePivot","incrementalSnap","_existingMeshScale","_dragMesh","_cornerMesh","updateScale","_anchorMesh","utilityLayerScene","disableLighting","rotationQuaternion","lines","push","points","x","y","z","position","addInPlace","isPickable","addChild","_rootMesh","_rotateAnchorsParent","anchor","width","height","depth","rotation","Math","PI","bakeTransformIntoVertices","computeWorldMatrix","material","isNearGrabbable","rotateAnchorsDragBehavior","moveAttached","updateDragPlane","addBehavior","startingTurnDirection","totalTurnAmountOfDrag","previousProjectDist","copyFrom","forward","computeAxis","dragAxisIndex","floor","set","onDragObservable","event","notifyObservers","dragOperation","attachedMesh","originalParent","parent","scaling","isNonUniformWithinEpsilon","Warn","_RemoveAndStorePivotPoint","worldDragDirection","toSub","dragPlaneNormal","scale","Dot","subtract","normalizeToNew","projectDist","delta","abs","length","RotationYawPitchRoll","dragSteps","angle","RotationYawPitchRollToRef","isUsingPivotMatrix","getScene","useRightHandedSystem","conjugateInPlace","normalize","multiplyToRef","removeChild","setParent","updateBoundingBox","_RestorePivotPoint","_updateDummy","_selectNode","onDragEndObservable","_unhoverMeshOnTouchUp","pointerInfo","box","size","_getCornerMesh","FromEulerAngles","_internalMetadata","invertToRef","TransformCoordinates","scaleBoxesDragBehavior","totalRelativeDragDistance","previousScale","relativeDragDistance","dragDistance","deltaScale","fullScale","scaleInPlace","getWorldMatrix","getRotationMatrixToRef","scaleToRef","TransformCoordinatesToRef","subtractInPlace","absolutePosition","subtractToRef","getPivotPoint","max","pointerIds","onPointerObservable","pointerId","concat","mesh","pickInfo","pickedMesh","_isHovered","originalScene","onBeforeRenderObservable","equals","_updateRotationAnchors","_updateScaleBoxes","rotateByQuaternionToRef","setAbsolutePosition","boxZ","boxY","boxX","MergeMeshes","_attachedNodeChanged","setAll","m","markAsDirty","onAfterRenderObservable","addOnce","selectedMesh","isVisible","PointerEvent","pointerType","getScaleBoxes","_update","boundingMinMax","getHierarchyBoundingVectors","min","rotateAnchors","normalizeToRef","target","CrossToRef","lookAt","activeCamera","distanceFromCamera","globalPosition","setEnabledRotationAxis","axis","indexOf","setEnabledScaling","enable","homogeneousScaling","enableMesh","getAbsolutePosition","enableDragBehavior","visibility","useObjectOrientationForDragging","releaseDrag","dragBehavior","dispose","remove","clear","MakeNotPickableAndWrapInBoundingBox","makeNotPickable","root","c","oldPos","oldRot","setCustomMesh","Error"],"sources":["F:/workspace/202226701027/huinongbao-app/node_modules/@babylonjs/core/Gizmos/boundingBoxGizmo.js"],"sourcesContent":["import { Observable } from \"../Misc/observable.js\";\nimport { Logger } from \"../Misc/logger.js\";\nimport { Quaternion, Matrix, Vector3, TmpVectors } from \"../Maths/math.vector.js\";\nimport { Mesh } from \"../Meshes/mesh.js\";\nimport { CreateBox } from \"../Meshes/Builders/boxBuilder.js\";\nimport { CreateLines } from \"../Meshes/Builders/linesBuilder.js\";\nimport { PointerDragBehavior } from \"../Behaviors/Meshes/pointerDragBehavior.js\";\nimport { Gizmo } from \"./gizmo.js\";\nimport { UtilityLayerRenderer } from \"../Rendering/utilityLayerRenderer.js\";\nimport { StandardMaterial } from \"../Materials/standardMaterial.js\";\nimport { PivotTools } from \"../Misc/pivotTools.js\";\nimport { Color3 } from \"../Maths/math.color.js\";\nimport { Epsilon } from \"../Maths/math.constants.js\";\nimport { TransformNode } from \"../Meshes/transformNode.js\";\n/**\n * Dragging operation in observable\n */\nexport var DragOperation;\n(function (DragOperation) {\n DragOperation[DragOperation[\"Rotation\"] = 0] = \"Rotation\";\n DragOperation[DragOperation[\"Scaling\"] = 1] = \"Scaling\";\n})(DragOperation || (DragOperation = {}));\n/**\n * Bounding box gizmo\n */\nexport class BoundingBoxGizmo extends Gizmo {\n /**\n * Sets the axis factor\n * @param factor the Vector3 value\n */\n set axisFactor(factor) {\n this._axisFactor = factor;\n // update scale cube visibility\n const scaleBoxes = this._scaleBoxesParent.getChildMeshes();\n let index = 0;\n for (let i = 0; i < 3; i++) {\n for (let j = 0; j < 3; j++) {\n for (let k = 0; k < 3; k++) {\n const zeroAxisCount = (i === 1 ? 1 : 0) + (j === 1 ? 1 : 0) + (k === 1 ? 1 : 0);\n if (zeroAxisCount === 1 || zeroAxisCount === 3) {\n continue;\n }\n if (scaleBoxes[index]) {\n const dragAxis = new Vector3(i - 1, j - 1, k - 1);\n dragAxis.multiplyInPlace(this._axisFactor);\n scaleBoxes[index].setEnabled(dragAxis.lengthSquared() > Epsilon);\n }\n index++;\n }\n }\n }\n }\n /**\n * Gets the axis factor\n * @returns the Vector3 factor value\n */\n get axisFactor() {\n return this._axisFactor;\n }\n /**\n * Sets scale drag speed value\n * @param value the new speed value\n */\n set scaleDragSpeed(value) {\n this._scaleDragSpeed = value;\n }\n /**\n * Gets scale drag speed\n * @returns the scale speed number\n */\n get scaleDragSpeed() {\n return this._scaleDragSpeed;\n }\n /** Default material used to render when gizmo is not disabled or hovered */\n get coloredMaterial() {\n return this._coloredMaterial;\n }\n /** Material used to render when gizmo is hovered with mouse*/\n get hoverMaterial() {\n return this._hoverColoredMaterial;\n }\n /**\n * Get the pointerDragBehavior\n */\n get pointerDragBehavior() {\n return this._pointerDragBehavior;\n }\n /** True when a rotation anchor or scale box or a attached mesh is dragged */\n get isDragging() {\n return this._dragging || this._pointerDragBehavior.dragging;\n }\n /**\n * Sets the color of the bounding box gizmo\n * @param color the color to set\n */\n setColor(color) {\n this._coloredMaterial.emissiveColor = color;\n this._hoverColoredMaterial.emissiveColor = color.clone().add(new Color3(0.3, 0.3, 0.3));\n this._lineBoundingBox.getChildren().forEach((l) => {\n if (l.color) {\n l.color = color;\n }\n });\n }\n /**\n * Creates an BoundingBoxGizmo\n * @param color The color of the gizmo\n * @param gizmoLayer The utility layer the gizmo will be added to\n */\n constructor(color = Color3.Gray(), gizmoLayer = UtilityLayerRenderer.DefaultKeepDepthUtilityLayer) {\n super(gizmoLayer);\n this._boundingDimensions = new Vector3(1, 1, 1);\n this._renderObserver = null;\n this._pointerObserver = null;\n this._scaleDragSpeed = 0.2;\n this._rotateAnchorsDragBehaviors = [];\n this._scaleBoxesDragBehaviors = [];\n /**\n * boolean updated when a rotation anchor or scale box is dragged\n */\n this._dragging = false;\n this._tmpQuaternion = new Quaternion();\n this._tmpVector = new Vector3(0, 0, 0);\n this._tmpRotationMatrix = new Matrix();\n this._incrementalStartupValue = Vector3.Zero();\n this._incrementalAnchorStartupValue = Vector3.Zero();\n /**\n * If child meshes should be ignored when calculating the bounding box. This should be set to true to avoid perf hits with heavily nested meshes (Default: false)\n */\n this.ignoreChildren = false;\n /**\n * Returns true if a descendant should be included when computing the bounding box. When null, all descendants are included. If ignoreChildren is set this will be ignored. (Default: null)\n */\n this.includeChildPredicate = null;\n /**\n * The size of the rotation anchors attached to the bounding box (Default: 0.1)\n */\n this.rotationSphereSize = 0.1;\n /**\n * The size of the scale boxes attached to the bounding box (Default: 0.1)\n */\n this.scaleBoxSize = 0.1;\n /**\n * If set, the rotation anchors and scale boxes will increase in size based on the distance away from the camera to have a consistent screen size (Default: false)\n * Note : fixedDragMeshScreenSize takes precedence over fixedDragMeshBoundsSize if both are true\n */\n this.fixedDragMeshScreenSize = false;\n /**\n * If set, the rotation anchors and scale boxes will increase in size based on the size of the bounding box\n * Note : fixedDragMeshScreenSize takes precedence over fixedDragMeshBoundsSize if both are true\n */\n this.fixedDragMeshBoundsSize = false;\n /**\n * The distance away from the object which the draggable meshes should appear world sized when fixedDragMeshScreenSize is set to true (default: 10)\n */\n this.fixedDragMeshScreenSizeDistanceFactor = 10;\n /**\n * Drag distance in babylon units that the gizmo will snap scaling to when dragged\n */\n this.scalingSnapDistance = 0;\n /**\n * Drag distance in babylon units that the gizmo will snap rotation to when dragged\n */\n this.rotationSnapDistance = 0;\n /**\n * Fired when a rotation anchor or scale box is dragged\n */\n this.onDragStartObservable = new Observable();\n /**\n * Fired when the gizmo mesh hovering starts\n */\n this.onHoverStartObservable = new Observable();\n /**\n * Fired when the gizmo mesh hovering ends\n */\n this.onHoverEndObservable = new Observable();\n /**\n * Fired when a scale box is dragged\n */\n this.onScaleBoxDragObservable = new Observable();\n /**\n * Fired when a scale box drag is ended\n */\n this.onScaleBoxDragEndObservable = new Observable();\n /**\n * Fired when a rotation anchor is dragged\n */\n this.onRotationSphereDragObservable = new Observable();\n /**\n * Fired when a rotation anchor drag is ended\n */\n this.onRotationSphereDragEndObservable = new Observable();\n /**\n * Relative bounding box pivot used when scaling the attached node. When null object with scale from the opposite corner. 0.5,0.5,0.5 for center and 0.5,0,0.5 for bottom (Default: null)\n */\n this.scalePivot = null;\n /**\n * Scale factor used for masking some axis\n */\n this._axisFactor = new Vector3(1, 1, 1);\n /**\n * Incremental snap scaling (default is false). When true, with a snapDistance of 0.1, scaling will be 1.1,1.2,1.3 instead of, when false: 1.1,1.21,1.33,...\n */\n this.incrementalSnap = false;\n this._existingMeshScale = new Vector3();\n // Dragging\n this._dragMesh = null;\n this._pointerDragBehavior = new PointerDragBehavior();\n // HL2 style corner mesh\n this._cornerMesh = null;\n // Do not update the gizmo's scale so it has a fixed size to the object its attached to\n this.updateScale = false;\n this._anchorMesh = new TransformNode(\"anchor\", gizmoLayer.utilityLayerScene);\n // Create Materials\n this._coloredMaterial = new StandardMaterial(\"\", gizmoLayer.utilityLayerScene);\n this._coloredMaterial.disableLighting = true;\n this._hoverColoredMaterial = new StandardMaterial(\"\", gizmoLayer.utilityLayerScene);\n this._hoverColoredMaterial.disableLighting = true;\n // Build bounding box out of lines\n this._lineBoundingBox = new TransformNode(\"\", gizmoLayer.utilityLayerScene);\n this._lineBoundingBox.rotationQuaternion = new Quaternion();\n const lines = [];\n lines.push(CreateLines(\"lines\", { points: [new Vector3(0, 0, 0), new Vector3(this._boundingDimensions.x, 0, 0)] }, gizmoLayer.utilityLayerScene));\n lines.push(CreateLines(\"lines\", { points: [new Vector3(0, 0, 0), new Vector3(0, this._boundingDimensions.y, 0)] }, gizmoLayer.utilityLayerScene));\n lines.push(CreateLines(\"lines\", { points: [new Vector3(0, 0, 0), new Vector3(0, 0, this._boundingDimensions.z)] }, gizmoLayer.utilityLayerScene));\n lines.push(CreateLines(\"lines\", { points: [new Vector3(this._boundingDimensions.x, 0, 0), new Vector3(this._boundingDimensions.x, this._boundingDimensions.y, 0)] }, gizmoLayer.utilityLayerScene));\n lines.push(CreateLines(\"lines\", { points: [new Vector3(this._boundingDimensions.x, 0, 0), new Vector3(this._boundingDimensions.x, 0, this._boundingDimensions.z)] }, gizmoLayer.utilityLayerScene));\n lines.push(CreateLines(\"lines\", { points: [new Vector3(0, this._boundingDimensions.y, 0), new Vector3(this._boundingDimensions.x, this._boundingDimensions.y, 0)] }, gizmoLayer.utilityLayerScene));\n lines.push(CreateLines(\"lines\", { points: [new Vector3(0, this._boundingDimensions.y, 0), new Vector3(0, this._boundingDimensions.y, this._boundingDimensions.z)] }, gizmoLayer.utilityLayerScene));\n lines.push(CreateLines(\"lines\", { points: [new Vector3(0, 0, this._boundingDimensions.z), new Vector3(this._boundingDimensions.x, 0, this._boundingDimensions.z)] }, gizmoLayer.utilityLayerScene));\n lines.push(CreateLines(\"lines\", { points: [new Vector3(0, 0, this._boundingDimensions.z), new Vector3(0, this._boundingDimensions.y, this._boundingDimensions.z)] }, gizmoLayer.utilityLayerScene));\n lines.push(CreateLines(\"lines\", {\n points: [\n new Vector3(this._boundingDimensions.x, this._boundingDimensions.y, this._boundingDimensions.z),\n new Vector3(0, this._boundingDimensions.y, this._boundingDimensions.z),\n ],\n }, gizmoLayer.utilityLayerScene));\n lines.push(CreateLines(\"lines\", {\n points: [\n new Vector3(this._boundingDimensions.x, this._boundingDimensions.y, this._boundingDimensions.z),\n new Vector3(this._boundingDimensions.x, 0, this._boundingDimensions.z),\n ],\n }, gizmoLayer.utilityLayerScene));\n lines.push(CreateLines(\"lines\", {\n points: [\n new Vector3(this._boundingDimensions.x, this._boundingDimensions.y, this._boundingDimensions.z),\n new Vector3(this._boundingDimensions.x, this._boundingDimensions.y, 0),\n ],\n }, gizmoLayer.utilityLayerScene));\n lines.forEach((l) => {\n l.color = color;\n l.position.addInPlace(new Vector3(-this._boundingDimensions.x / 2, -this._boundingDimensions.y / 2, -this._boundingDimensions.z / 2));\n l.isPickable = false;\n this._lineBoundingBox.addChild(l);\n });\n this._rootMesh.addChild(this._lineBoundingBox);\n this.setColor(color);\n // Create rotation anchors\n this._rotateAnchorsParent = new TransformNode(\"\", gizmoLayer.utilityLayerScene);\n this._rotateAnchorsParent.rotationQuaternion = new Quaternion();\n for (let i = 0; i < 12; i++) {\n const anchor = CreateBox(\"\", { width: i < 4 || i >= 8 ? 1.6 : 0.4, height: i >= 4 && i < 8 ? 1.6 : 0.4, depth: 0.4 }, gizmoLayer.utilityLayerScene);\n anchor.rotation.x = i < 4 || i >= 8 ? Math.PI * 0.25 : 0;\n anchor.rotation.y = i >= 4 && i < 8 ? Math.PI * 0.25 : 0;\n anchor.bakeTransformIntoVertices(anchor.computeWorldMatrix(true));\n anchor.rotationQuaternion = new Quaternion();\n anchor.material = this._coloredMaterial;\n anchor.isNearGrabbable = true;\n // Drag behavior\n const rotateAnchorsDragBehavior = new PointerDragBehavior({});\n rotateAnchorsDragBehavior.moveAttached = false;\n rotateAnchorsDragBehavior.updateDragPlane = false;\n anchor.addBehavior(rotateAnchorsDragBehavior);\n const startingTurnDirection = new Vector3(1, 0, 0);\n let totalTurnAmountOfDrag = 0;\n let previousProjectDist = 0;\n rotateAnchorsDragBehavior.onDragStartObservable.add(() => {\n startingTurnDirection.copyFrom(anchor.forward);\n totalTurnAmountOfDrag = 0;\n previousProjectDist = 0;\n });\n const computeAxis = function () {\n const dragAxisIndex = Math.floor(i / 4);\n TmpVectors.Vector3[0].set(dragAxisIndex == 0 ? 1 : 0, dragAxisIndex == 1 ? 1 : 0, dragAxisIndex == 2 ? 1 : 0);\n return TmpVectors.Vector3[0];\n };\n rotateAnchorsDragBehavior.onDragObservable.add((event) => {\n this.onRotationSphereDragObservable.notifyObservers({ dragOperation: 0 /* DragOperation.Rotation */, dragAxis: computeAxis().clone() });\n if (this.attachedMesh) {\n const originalParent = this.attachedMesh.parent;\n if (originalParent && originalParent.scaling && originalParent.scaling.isNonUniformWithinEpsilon(0.001)) {\n Logger.Warn(\"BoundingBoxGizmo controls are not supported on child meshes with non-uniform parent scaling\");\n return;\n }\n PivotTools._RemoveAndStorePivotPoint(this.attachedMesh);\n const worldDragDirection = startingTurnDirection;\n // Project the world right on to the drag plane\n const toSub = event.dragPlaneNormal.scale(Vector3.Dot(event.dragPlaneNormal, worldDragDirection));\n const dragAxis = worldDragDirection.subtract(toSub).normalizeToNew();\n // project drag delta on to the resulting drag axis and rotate based on that\n let projectDist = Vector3.Dot(dragAxis, event.delta) < 0 ? Math.abs(event.delta.length()) : -Math.abs(event.delta.length());\n // Make rotation relative to size of mesh.\n projectDist = (projectDist / this._boundingDimensions.length()) * this._anchorMesh.scaling.length();\n // Rotate based on axis\n if (!this.attachedMesh.rotationQuaternion) {\n this.attachedMesh.rotationQuaternion = Quaternion.RotationYawPitchRoll(this.attachedMesh.rotation.y, this.attachedMesh.rotation.x, this.attachedMesh.rotation.z);\n }\n if (!this._anchorMesh.rotationQuaternion) {\n this._anchorMesh.rotationQuaternion = Quaternion.RotationYawPitchRoll(this._anchorMesh.rotation.y, this._anchorMesh.rotation.x, this._anchorMesh.rotation.z);\n }\n // Do not allow the object to turn more than a full circle\n totalTurnAmountOfDrag += projectDist;\n if (Math.abs(totalTurnAmountOfDrag) <= 2 * Math.PI) {\n if (this.rotationSnapDistance > 0) {\n const dragSteps = Math.floor(Math.abs(totalTurnAmountOfDrag) / this.rotationSnapDistance) * (totalTurnAmountOfDrag < 0 ? -1 : 1);\n const angle = this.rotationSnapDistance * dragSteps;\n projectDist = angle - previousProjectDist;\n previousProjectDist = angle;\n }\n if (i >= 8) {\n Quaternion.RotationYawPitchRollToRef(0, 0, projectDist, this._tmpQuaternion);\n }\n else if (i >= 4) {\n Quaternion.RotationYawPitchRollToRef(projectDist, 0, 0, this._tmpQuaternion);\n }\n else {\n Quaternion.RotationYawPitchRollToRef(0, projectDist, 0, this._tmpQuaternion);\n }\n // if using pivot, move anchor so mesh will be at relative (0,0,0) when parented\n if (this.attachedMesh.isUsingPivotMatrix()) {\n this._anchorMesh.position.copyFrom(this.attachedMesh.position);\n }\n // Rotate around center of bounding box\n this._anchorMesh.addChild(this.attachedMesh);\n if (this._anchorMesh.getScene().useRightHandedSystem) {\n this._tmpQuaternion.conjugateInPlace();\n }\n this._tmpQuaternion.normalize();\n this._anchorMesh.rotationQuaternion.multiplyToRef(this._tmpQuaternion, this._anchorMesh.rotationQuaternion);\n this._anchorMesh.rotationQuaternion.normalize();\n this._anchorMesh.removeChild(this.attachedMesh);\n this.attachedMesh.setParent(originalParent);\n }\n this.updateBoundingBox();\n PivotTools._RestorePivotPoint(this.attachedMesh);\n }\n this._updateDummy();\n });\n // Selection/deselection\n rotateAnchorsDragBehavior.onDragStartObservable.add(() => {\n this.onDragStartObservable.notifyObservers({ dragOperation: 0 /* DragOperation.Rotation */, dragAxis: computeAxis().clone() });\n this._dragging = true;\n this._selectNode(anchor);\n });\n rotateAnchorsDragBehavior.onDragEndObservable.add((event) => {\n this.onRotationSphereDragEndObservable.notifyObservers({ dragOperation: 0 /* DragOperation.Rotation */, dragAxis: computeAxis().clone() });\n this._dragging = false;\n this._selectNode(null);\n this._updateDummy();\n this._unhoverMeshOnTouchUp(event.pointerInfo, anchor);\n });\n this._rotateAnchorsDragBehaviors.push(rotateAnchorsDragBehavior);\n this._rotateAnchorsParent.addChild(anchor);\n }\n this._rootMesh.addChild(this._rotateAnchorsParent);\n // Create scale cubes\n this._scaleBoxesParent = new TransformNode(\"\", gizmoLayer.utilityLayerScene);\n this._scaleBoxesParent.rotationQuaternion = new Quaternion();\n for (let i = 0; i < 3; i++) {\n for (let j = 0; j < 3; j++) {\n for (let k = 0; k < 3; k++) {\n // create box for relevant axis\n const zeroAxisCount = (i === 1 ? 1 : 0) + (j === 1 ? 1 : 0) + (k === 1 ? 1 : 0);\n if (zeroAxisCount === 1 || zeroAxisCount === 3) {\n continue;\n }\n const box = zeroAxisCount === 2 ? CreateBox(\"\", { size: 1 }, gizmoLayer.utilityLayerScene) : this._getCornerMesh(gizmoLayer);\n if (zeroAxisCount === 0) {\n box.rotationQuaternion = Quaternion.FromEulerAngles(j * 0.25 * Math.PI, (k + 3 * i - i * k) * 0.25 * Math.PI, 0);\n }\n box.material = this._coloredMaterial;\n box._internalMetadata = zeroAxisCount === 2; // None homogenous scale handle\n box.isNearGrabbable = true;\n // box is oriented so, transform world desired axis to local one\n TmpVectors.Vector3[0].set(i - 1, j - 1, k - 1);\n TmpVectors.Vector3[0].normalize();\n box.computeWorldMatrix(true).invertToRef(TmpVectors.Matrix[0]);\n const dragAxis = Vector3.TransformCoordinates(TmpVectors.Vector3[0], TmpVectors.Matrix[0]);\n dragAxis.normalize();\n // Dragging logic\n const scaleBoxesDragBehavior = new PointerDragBehavior({ dragAxis: dragAxis });\n scaleBoxesDragBehavior.updateDragPlane = false;\n scaleBoxesDragBehavior.moveAttached = false;\n let totalRelativeDragDistance = 0;\n let previousScale = 0;\n box.addBehavior(scaleBoxesDragBehavior);\n scaleBoxesDragBehavior.onDragObservable.add((event) => {\n this.onScaleBoxDragObservable.notifyObservers({ dragOperation: 1 /* DragOperation.Scaling */, dragAxis: new Vector3(i - 1, j - 1, k - 1) });\n if (this.attachedMesh) {\n const originalParent = this.attachedMesh.parent;\n if (originalParent && originalParent.scaling && originalParent.scaling.isNonUniformWithinEpsilon(0.001)) {\n Logger.Warn(\"BoundingBoxGizmo controls are not supported on child meshes with non-uniform parent scaling\");\n return;\n }\n PivotTools._RemoveAndStorePivotPoint(this.attachedMesh);\n let relativeDragDistance = (event.dragDistance / this._boundingDimensions.length()) * this._anchorMesh.scaling.length();\n totalRelativeDragDistance += relativeDragDistance;\n if (this.scalingSnapDistance > 0) {\n const dragSteps = Math.floor(Math.abs(totalRelativeDragDistance) / this.scalingSnapDistance) * (totalRelativeDragDistance < 0 ? -1 : 1);\n const scale = this.scalingSnapDistance * dragSteps;\n relativeDragDistance = scale - previousScale;\n previousScale = scale;\n }\n const deltaScale = new Vector3(relativeDragDistance, relativeDragDistance, relativeDragDistance);\n const fullScale = new Vector3(previousScale, previousScale, previousScale);\n if (zeroAxisCount === 2) {\n // scale on 1 axis when using the anchor box in the face middle\n deltaScale.x *= Math.abs(dragAxis.x);\n deltaScale.y *= Math.abs(dragAxis.y);\n deltaScale.z *= Math.abs(dragAxis.z);\n }\n deltaScale.scaleInPlace(this._scaleDragSpeed);\n deltaScale.multiplyInPlace(this._axisFactor);\n fullScale.scaleInPlace(this._scaleDragSpeed);\n fullScale.multiplyInPlace(this._axisFactor);\n fullScale.addInPlace(this._incrementalStartupValue);\n this.updateBoundingBox();\n if (this.scalePivot) {\n this.attachedMesh.getWorldMatrix().getRotationMatrixToRef(this._tmpRotationMatrix);\n // Move anchor to desired pivot point (Bottom left corner + dimension/2)\n this._boundingDimensions.scaleToRef(0.5, this._tmpVector);\n Vector3.TransformCoordinatesToRef(this._tmpVector, this._tmpRotationMatrix, this._tmpVector);\n this._anchorMesh.position.subtractInPlace(this._tmpVector);\n this._boundingDimensions.multiplyToRef(this.scalePivot, this._tmpVector);\n Vector3.TransformCoordinatesToRef(this._tmpVector, this._tmpRotationMatrix, this._tmpVector);\n this._anchorMesh.position.addInPlace(this._tmpVector);\n }\n else {\n // Scale from the position of the opposite corner\n box.absolutePosition.subtractToRef(this._anchorMesh.position, this._tmpVector);\n this._anchorMesh.position.subtractInPlace(this._tmpVector);\n if (this.attachedMesh.isUsingPivotMatrix()) {\n this._anchorMesh.position.subtractInPlace(this.attachedMesh.getPivotPoint());\n }\n }\n this._anchorMesh.addChild(this.attachedMesh);\n if (this.incrementalSnap) {\n fullScale.x /= Math.abs(this._incrementalStartupValue.x) < Epsilon ? 1 : this._incrementalStartupValue.x;\n fullScale.y /= Math.abs(this._incrementalStartupValue.y) < Epsilon ? 1 : this._incrementalStartupValue.y;\n fullScale.z /= Math.abs(this._incrementalStartupValue.z) < Epsilon ? 1 : this._incrementalStartupValue.z;\n fullScale.x = Math.max(this._incrementalAnchorStartupValue.x * fullScale.x, this.scalingSnapDistance);\n fullScale.y = Math.max(this._incrementalAnchorStartupValue.y * fullScale.y, this.scalingSnapDistance);\n fullScale.z = Math.max(this._incrementalAnchorStartupValue.z * fullScale.z, this.scalingSnapDistance);\n this._anchorMesh.scaling.x += (fullScale.x - this._anchorMesh.scaling.x) * Math.abs(dragAxis.x);\n this._anchorMesh.scaling.y += (fullScale.y - this._anchorMesh.scaling.y) * Math.abs(dragAxis.y);\n this._anchorMesh.scaling.z += (fullScale.z - this._anchorMesh.scaling.z) * Math.abs(dragAxis.z);\n }\n else {\n this._anchorMesh.scaling.addInPlace(deltaScale);\n if (this._anchorMesh.scaling.x < 0 || this._anchorMesh.scaling.y < 0 || this._anchorMesh.scaling.z < 0) {\n this._anchorMesh.scaling.subtractInPlace(deltaScale);\n }\n }\n this._anchorMesh.removeChild(this.attachedMesh);\n this.attachedMesh.setParent(originalParent);\n PivotTools._RestorePivotPoint(this.attachedMesh);\n }\n this._updateDummy();\n });\n // Selection/deselection\n scaleBoxesDragBehavior.onDragStartObservable.add(() => {\n this.onDragStartObservable.notifyObservers({ dragOperation: 1 /* DragOperation.Scaling */, dragAxis: new Vector3(i - 1, j - 1, k - 1) });\n this._dragging = true;\n this._selectNode(box);\n totalRelativeDragDistance = 0;\n previousScale = 0;\n this._incrementalStartupValue.copyFrom(this.attachedMesh.scaling);\n this._incrementalAnchorStartupValue.copyFrom(this._anchorMesh.scaling);\n });\n scaleBoxesDragBehavior.onDragEndObservable.add((event) => {\n this.onScaleBoxDragEndObservable.notifyObservers({ dragOperation: 1 /* DragOperation.Scaling */, dragAxis: new Vector3(i - 1, j - 1, k - 1) });\n this._dragging = false;\n this._selectNode(null);\n this._updateDummy();\n this._unhoverMeshOnTouchUp(event.pointerInfo, box);\n });\n this._scaleBoxesParent.addChild(box);\n this._scaleBoxesDragBehaviors.push(scaleBoxesDragBehavior);\n }\n }\n }\n this._rootMesh.addChild(this._scaleBoxesParent);\n // Hover color change\n const pointerIds = [];\n this._pointerObserver = gizmoLayer.utilityLayerScene.onPointerObservable.add((pointerInfo) => {\n if (!pointerIds[pointerInfo.event.pointerId]) {\n this._rotateAnchorsParent\n .getChildMeshes()\n .concat(this._scaleBoxesParent.getChildMeshes())\n .forEach((mesh) => {\n if (pointerInfo.pickInfo && pointerInfo.pickInfo.pickedMesh == mesh) {\n pointerIds[pointerInfo.event.pointerId] = mesh;\n mesh.material = this._hoverColoredMaterial;\n this.onHoverStartObservable.notifyObservers();\n this._isHovered = true;\n }\n });\n }\n else {\n if (pointerInfo.pickInfo && pointerInfo.pickInfo.pickedMesh != pointerIds[pointerInfo.event.pointerId]) {\n pointerIds[pointerInfo.event.pointerId].material = this._coloredMaterial;\n delete pointerIds[pointerInfo.event.pointerId];\n this.onHoverEndObservable.notifyObservers();\n this._isHovered = false;\n }\n }\n });\n // Update bounding box positions\n this._renderObserver = this.gizmoLayer.originalScene.onBeforeRenderObservable.add(() => {\n // Only update the bounding box if scaling has changed\n if (this.attachedMesh && !this._existingMeshScale.equals(this.attachedMesh.scaling)) {\n this.updateBoundingBox();\n }\n else if (this.fixedDragMeshScreenSize || this.fixedDragMeshBoundsSize) {\n this._updateRotationAnchors();\n this._updateScaleBoxes();\n }\n // If drag mesh is enabled and dragging, update the attached mesh pose to match the drag mesh\n if (this._dragMesh && this.attachedMesh && this._pointerDragBehavior.dragging) {\n this._lineBoundingBox.position.rotateByQuaternionToRef(this._rootMesh.rotationQuaternion, this._tmpVector);\n this.attachedMesh.setAbsolutePosition(this._dragMesh.position.add(this._tmpVector.scale(-1)));\n }\n });\n this.updateBoundingBox();\n }\n _getCornerMesh(gizmoLayer) {\n if (!this._cornerMesh) {\n const boxZ = CreateBox(\"\", { width: 0.4, height: 0.4, depth: 1.6 }, gizmoLayer.utilityLayerScene);\n boxZ.position.z = 0.6;\n const boxY = CreateBox(\"\", { width: 0.4, height: 1.6, depth: 0.4 }, gizmoLayer.utilityLayerScene);\n boxY.position.y = 0.6;\n const boxX = CreateBox(\"\", { width: 1.6, height: 0.4, depth: 0.4 }, gizmoLayer.utilityLayerScene);\n boxX.position.x = 0.6;\n this._cornerMesh = Mesh.MergeMeshes([boxX, boxY, boxZ], true);\n return this._cornerMesh;\n }\n return this._cornerMesh.clone();\n }\n _attachedNodeChanged(value) {\n if (value) {\n // Reset anchor mesh to match attached mesh's scale\n // This is needed to avoid invalid box/anchor position on first drag\n this._anchorMesh.scaling.setAll(1);\n PivotTools._RemoveAndStorePivotPoint(value);\n const originalParent = value.parent;\n this._anchorMesh.addChild(value);\n this._anchorMesh.removeChild(value);\n value.setParent(originalParent);\n PivotTools._RestorePivotPoint(value);\n this.updateBoundingBox();\n value.getChildMeshes(false).forEach((m) => {\n m.markAsDirty(\"scaling\");\n });\n this.gizmoLayer.utilityLayerScene.onAfterRenderObservable.addOnce(() => {\n this._updateDummy();\n });\n }\n }\n _selectNode(selectedMesh) {\n this._rotateAnchorsParent\n .getChildMeshes()\n .concat(this._scaleBoxesParent.getChildMeshes())\n .forEach((m) => {\n m.isVisible = !selectedMesh || m == selectedMesh;\n });\n }\n _unhoverMeshOnTouchUp(pointerInfo, selectedMesh) {\n // force unhover mesh if not a mouse event\n if (pointerInfo?.event instanceof PointerEvent && pointerInfo?.event.pointerType === \"touch\") {\n selectedMesh.material = this._coloredMaterial;\n }\n }\n /**\n * returns an array containing all boxes used for scaling (in increasing x, y and z orders)\n * @returns array of scaling boxes\n */\n getScaleBoxes() {\n return this._scaleBoxesParent.getChildMeshes();\n }\n /**\n * Updates the bounding box information for the Gizmo\n */\n updateBoundingBox() {\n if (this.attachedMesh) {\n PivotTools._RemoveAndStorePivotPoint(this.attachedMesh);\n // Store original parent\n const originalParent = this.attachedMesh.parent;\n this.attachedMesh.setParent(null);\n this._update();\n // Rotate based on axis\n if (!this.attachedMesh.rotationQuaternion) {\n this.attachedMesh.rotationQuaternion = Quaternion.RotationYawPitchRoll(this.attachedMesh.rotation.y, this.attachedMesh.rotation.x, this.attachedMesh.rotation.z);\n }\n if (!this._anchorMesh.rotationQuaternion) {\n this._anchorMesh.rotationQuaternion = Quaternion.RotationYawPitchRoll(this._anchorMesh.rotation.y, this._anchorMesh.rotation.x, this._anchorMesh.rotation.z);\n }\n this._anchorMesh.rotationQuaternion.copyFrom(this.attachedMesh.rotationQuaternion);\n // Store original position and reset mesh to origin before computing the bounding box\n this._tmpQuaternion.copyFrom(this.attachedMesh.rotationQuaternion);\n this._tmpVector.copyFrom(this.attachedMesh.position);\n this.attachedMesh.rotationQuaternion.set(0, 0, 0, 1);\n this.attachedMesh.position.set(0, 0, 0);\n // Update bounding dimensions/positions\n const boundingMinMax = this.attachedMesh.getHierarchyBoundingVectors(!this.ignoreChildren, this.includeChildPredicate);\n boundingMinMax.max.subtractToRef(boundingMinMax.min, this._boundingDimensions);\n // Update gizmo to match bounding box scaling and rotation\n // The position set here is the offset from the origin for the boundingbox when the attached mesh is at the origin\n // The position of the gizmo is then set to the attachedMesh in gizmo._update\n this._lineBoundingBox.scaling.copyFrom(this._boundingDimensions);\n this._lineBoundingBox.position.set((boundingMinMax.max.x + boundingMinMax.min.x) / 2, (boundingMinMax.max.y + boundingMinMax.min.y) / 2, (boundingMinMax.max.z + boundingMinMax.min.z) / 2);\n this._rotateAnchorsParent.position.copyFrom(this._lineBoundingBox.position);\n this._scaleBoxesParent.position.copyFrom(this._lineBoundingBox.position);\n this._lineBoundingBox.computeWorldMatrix();\n this._anchorMesh.position.copyFrom(this._lineBoundingBox.absolutePosition);\n // Restore position/rotation values\n this.attachedMesh.rotationQuaternion.copyFrom(this._tmpQuaternion);\n this.attachedMesh.position.copyFrom(this._tmpVector);\n // Restore original parent\n this.attachedMesh.setParent(originalParent);\n }\n this._updateRotationAnchors();\n this._updateScaleBoxes();\n if (this.attachedMesh) {\n this._existingMeshScale.copyFrom(this.attachedMesh.scaling);\n PivotTools._RestorePivotPoint(this.attachedMesh);\n }\n }\n _updateRotationAnchors() {\n const rotateAnchors = this._rotateAnchorsParent.getChildMeshes();\n for (let i = 0; i < 3; i++) {\n for (let j = 0; j < 2; j++) {\n for (let k = 0; k < 2; k++) {\n const index = i * 4 + j * 2 + k;\n rotateAnchors[index].position.normalizeToRef(TmpVectors.Vector3[0]);\n if (i == 0) {\n rotateAnchors[index].position.set(0, this._boundingDimensions.y * (j - 0.5), this._boundingDimensions.z * (k - 0.5));\n TmpVectors.Vector3[1].set(1, 0, 0);\n }\n if (i == 1) {\n rotateAnchors[index].position.set(this._boundingDimensions.x * (j - 0.5), 0, this._boundingDimensions.z * (k - 0.5));\n TmpVectors.Vector3[1].set(0, 1, 0);\n }\n if (i == 2) {\n rotateAnchors[index].position.set(this._boundingDimensions.x * (j - 0.5), this._boundingDimensions.y * (k - 0.5), 0);\n TmpVectors.Vector3[1].set(0, 0, 1);\n }\n const target = TmpVectors.Vector3[2];\n Vector3.CrossToRef(TmpVectors.Vector3[0], TmpVectors.Vector3[1], target);\n target.normalize();\n target.addInPlace(rotateAnchors[index].position);\n rotateAnchors[index].lookAt(target);\n if (this.fixedDragMeshScreenSize && this.gizmoLayer.utilityLayerScene.activeCamera) {\n rotateAnchors[index].absolutePosition.subtractToRef(this.gizmoLayer.utilityLayerScene.activeCamera.position, this._tmpVector);\n const distanceFromCamera = (this.rotationSphereSize * this._tmpVector.length()) / this.fixedDragMeshScreenSizeDistanceFactor;\n rotateAnchors[index].scaling.set(distanceFromCamera, distanceFromCamera, distanceFromCamera);\n }\n else if (this.fixedDragMeshBoundsSize) {\n rotateAnchors[index].scaling.set(this.rotationSphereSize * this._boundingDimensions.x, this.rotationSphereSize * this._boundingDimensions.y, this.rotationSphereSize * this._boundingDimensions.z);\n }\n else {\n rotateAnchors[index].scaling.set(this.rotationSphereSize, this.rotationSphereSize, this.rotationSphereSize);\n }\n }\n }\n }\n }\n _updateScaleBoxes() {\n const scaleBoxes = this._scaleBoxesParent.getChildMeshes();\n let index = 0;\n for (let i = 0; i < 3; i++) {\n for (let j = 0; j < 3; j++) {\n for (let k = 0; k < 3; k++) {\n const zeroAxisCount = (i === 1 ? 1 : 0) + (j === 1 ? 1 : 0) + (k === 1 ? 1 : 0);\n if (zeroAxisCount === 1 || zeroAxisCount === 3) {\n continue;\n }\n if (scaleBoxes[index]) {\n scaleBoxes[index].position.set(this._boundingDimensions.x * (i / 2), this._boundingDimensions.y * (j / 2), this._boundingDimensions.z * (k / 2));\n scaleBoxes[index].position.addInPlace(new Vector3(-this._boundingDimensions.x / 2, -this._boundingDimensions.y / 2, -this._boundingDimensions.z / 2));\n if (this.fixedDragMeshScreenSize && this.gizmoLayer.utilityLayerScene.activeCamera) {\n scaleBoxes[index].absolutePosition.subtractToRef(this.gizmoLayer.utilityLayerScene.activeCamera.globalPosition, this._tmpVector);\n const distanceFromCamera = (this.scaleBoxSize * this._tmpVector.length()) / this.fixedDragMeshScreenSizeDistanceFactor;\n scaleBoxes[index].scaling.set(distanceFromCamera, distanceFromCamera, distanceFromCamera);\n }\n else if (this.fixedDragMeshBoundsSize) {\n scaleBoxes[index].scaling.set(this.scaleBoxSize * this._boundingDimensions.x, this.scaleBoxSize * this._boundingDimensions.y, this.scaleBoxSize * this._boundingDimensions.z);\n }\n else {\n scaleBoxes[index].scaling.set(this.scaleBoxSize, this.scaleBoxSize, this.scaleBoxSize);\n }\n }\n index++;\n }\n }\n }\n }\n /**\n * Enables rotation on the specified axis and disables rotation on the others\n * @param axis The list of axis that should be enabled (eg. \"xy\" or \"xyz\")\n */\n setEnabledRotationAxis(axis) {\n this._rotateAnchorsParent.getChildMeshes().forEach((m, i) => {\n if (i < 4) {\n m.setEnabled(axis.indexOf(\"x\") != -1);\n }\n else if (i < 8) {\n m.setEnabled(axis.indexOf(\"y\") != -1);\n }\n else {\n m.setEnabled(axis.indexOf(\"z\") != -1);\n }\n });\n }\n /**\n * Enables/disables scaling\n * @param enable if scaling should be enabled\n * @param homogeneousScaling defines if scaling should only be homogeneous\n */\n setEnabledScaling(enable, homogeneousScaling = false) {\n this._scaleBoxesParent.getChildMeshes().forEach((m) => {\n let enableMesh = enable;\n // Disable heterogeneous scale handles if requested.\n if (homogeneousScaling && m._internalMetadata === true) {\n enableMesh = false;\n }\n m.setEnabled(enableMesh);\n });\n }\n _updateDummy() {\n if (this._dragMesh) {\n this._dragMesh.position.copyFrom(this._lineBoundingBox.getAbsolutePosition());\n this._dragMesh.scaling.copyFrom(this._lineBoundingBox.scaling);\n this._dragMesh.rotationQuaternion.copyFrom(this._rootMesh.rotationQuaternion);\n }\n }\n /**\n * Enables a pointer drag behavior on the bounding box of the gizmo\n */\n enableDragBehavior() {\n this._dragMesh = CreateBox(\"dummy\", { size: 1 }, this.gizmoLayer.utilityLayerScene);\n this._dragMesh.visibility = 0;\n this._dragMesh.rotationQuaternion = new Quaternion();\n this._pointerDragBehavior.useObjectOrientationForDragging = false;\n this._dragMesh.addBehavior(this._pointerDragBehavior);\n }\n /**\n * Force release the drag action by code\n */\n releaseDrag() {\n this._scaleBoxesDragBehaviors.forEach((dragBehavior) => {\n dragBehavior.releaseDrag();\n });\n this._rotateAnchorsDragBehaviors.forEach((dragBehavior) => {\n dragBehavior.releaseDrag();\n });\n this._pointerDragBehavior.releaseDrag();\n }\n /**\n * Disposes of the gizmo\n */\n dispose() {\n this.gizmoLayer.utilityLayerScene.onPointerObservable.remove(this._pointerObserver);\n this.gizmoLayer.originalScene.onBeforeRenderObservable.remove(this._renderObserver);\n this._lineBoundingBox.dispose();\n this._rotateAnchorsParent.dispose();\n this._scaleBoxesParent.dispose();\n if (this._dragMesh) {\n this._dragMesh.dispose();\n }\n this._scaleBoxesDragBehaviors.length = 0;\n this._rotateAnchorsDragBehaviors.length = 0;\n this.onDragStartObservable.clear();\n this.onHoverStartObservable.clear();\n this.onHoverEndObservable.clear();\n this.onScaleBoxDragObservable.clear();\n this.onScaleBoxDragEndObservable.clear();\n this.onRotationSphereDragObservable.clear();\n this.onRotationSphereDragEndObservable.clear();\n super.dispose();\n }\n /**\n * Makes a mesh not pickable and wraps the mesh inside of a bounding box mesh that is pickable. (This is useful to avoid picking within complex geometry)\n * @param mesh the mesh to wrap in the bounding box mesh and make not pickable\n * @returns the bounding box mesh with the passed in mesh as a child\n */\n static MakeNotPickableAndWrapInBoundingBox(mesh) {\n const makeNotPickable = (root) => {\n root.isPickable = false;\n root.getChildMeshes().forEach((c) => {\n makeNotPickable(c);\n });\n };\n makeNotPickable(mesh);\n // Reset position to get bounding box from origin with no rotation\n if (!mesh.rotationQuaternion) {\n mesh.rotationQuaternion = Quaternion.RotationYawPitchRoll(mesh.rotation.y, mesh.rotation.x, mesh.rotation.z);\n }\n const oldPos = mesh.position.clone();\n const oldRot = mesh.rotationQuaternion.clone();\n mesh.rotationQuaternion.set(0, 0, 0, 1);\n mesh.position.set(0, 0, 0);\n // Update bounding dimensions/positions\n const box = CreateBox(\"box\", { size: 1 }, mesh.getScene());\n const boundingMinMax = mesh.getHierarchyBoundingVectors();\n boundingMinMax.max.subtractToRef(boundingMinMax.min, box.scaling);\n // Adjust scale to avoid undefined behavior when adding child\n if (box.scaling.y === 0) {\n box.scaling.y = Epsilon;\n }\n if (box.scaling.x === 0) {\n box.scaling.x = Epsilon;\n }\n if (box.scaling.z === 0) {\n box.scaling.z = Epsilon;\n }\n box.position.set((boundingMinMax.max.x + boundingMinMax.min.x) / 2, (boundingMinMax.max.y + boundingMinMax.min.y) / 2, (boundingMinMax.max.z + boundingMinMax.min.z) / 2);\n // Restore original positions\n mesh.addChild(box);\n mesh.rotationQuaternion.copyFrom(oldRot);\n mesh.position.copyFrom(oldPos);\n // Reverse parenting\n mesh.removeChild(box);\n box.addChild(mesh);\n box.visibility = 0;\n return box;\n }\n /**\n * CustomMeshes are not supported by this gizmo\n */\n setCustomMesh() {\n Logger.Error(\"Custom meshes are not supported on this gizmo\");\n }\n}\n"],"mappings":"AAAA,SAASA,UAAU,QAAQ,uBAAuB;AAClD,SAASC,MAAM,QAAQ,mBAAmB;AAC1C,SAASC,UAAU,EAAEC,MAAM,EAAEC,OAAO,EAAEC,UAAU,QAAQ,yBAAyB;AACjF,SAASC,IAAI,QAAQ,mBAAmB;AACxC,SAASC,SAAS,QAAQ,kCAAkC;AAC5D,SAASC,WAAW,QAAQ,oCAAoC;AAChE,SAASC,mBAAmB,QAAQ,4CAA4C;AAChF,SAASC,KAAK,QAAQ,YAAY;AAClC,SAASC,oBAAoB,QAAQ,sCAAsC;AAC3E,SAASC,gBAAgB,QAAQ,kCAAkC;AACnE,SAASC,UAAU,QAAQ,uBAAuB;AAClD,SAASC,MAAM,QAAQ,wBAAwB;AAC/C,SAASC,OAAO,QAAQ,4BAA4B;AACpD,SAASC,aAAa,QAAQ,4BAA4B;AAC1D;AACA;AACA;AACA,OAAO,IAAIC,aAAa;AACxB,CAAC,UAAUA,aAAa,EAAE;EACtBA,aAAa,CAACA,aAAa,CAAC,UAAU,CAAC,GAAG,CAAC,CAAC,GAAG,UAAU;EACzDA,aAAa,CAACA,aAAa,CAAC,SAAS,CAAC,GAAG,CAAC,CAAC,GAAG,SAAS;AAC3D,CAAC,EAAEA,aAAa,KAAKA,aAAa,GAAG,CAAC,CAAC,CAAC,CAAC;AACzC;AAC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