6bd32f1d6d5479b3c7e6c021ad3555b4cebfcb2478be9de5fde643787cb0143c.json 67 KB

1
  1. {"ast":null,"code":"import { Mesh } from \"../../Meshes/mesh.js\";\nimport { Scene } from \"../../scene.js\";\nimport { Observable } from \"../../Misc/observable.js\";\nimport { TmpVectors, Vector3 } from \"../../Maths/math.vector.js\";\nimport { PointerEventTypes } from \"../../Events/pointerEvents.js\";\nimport { Ray } from \"../../Culling/ray.js\";\nimport { PivotTools } from \"../../Misc/pivotTools.js\";\nimport { CreatePlane } from \"../../Meshes/Builders/planeBuilder.js\";\nimport { Epsilon } from \"../../Maths/math.constants.js\";\n/**\n * A behavior that when attached to a mesh will allow the mesh to be dragged around the screen based on pointer events\n */\nexport class PointerDragBehavior {\n /**\n * Get or set the currentDraggingPointerId\n * @deprecated Please use currentDraggingPointerId instead\n */\n get currentDraggingPointerID() {\n return this.currentDraggingPointerId;\n }\n set currentDraggingPointerID(currentDraggingPointerID) {\n this.currentDraggingPointerId = currentDraggingPointerID;\n }\n /**\n * If the drag behavior will react to drag events (Default: true)\n */\n set enabled(value) {\n if (value != this._enabled) {\n this.onEnabledObservable.notifyObservers(value);\n }\n this._enabled = value;\n }\n get enabled() {\n return this._enabled;\n }\n /**\n * Gets the options used by the behavior\n */\n get options() {\n return this._options;\n }\n /**\n * Sets the options used by the behavior\n */\n set options(options) {\n this._options = options;\n }\n /**\n * Creates a pointer drag behavior that can be attached to a mesh\n * @param options The drag axis or normal of the plane that will be dragged across. If no options are specified the drag plane will always face the ray's origin (eg. camera)\n * @param options.dragAxis\n * @param options.dragPlaneNormal\n */\n constructor(options) {\n this._useAlternatePickedPointAboveMaxDragAngleDragSpeed = -1.1;\n this._activeDragButton = -1;\n /**\n * The maximum tolerated angle between the drag plane and dragging pointer rays to trigger pointer events. Set to 0 to allow any angle (default: 0)\n */\n this.maxDragAngle = 0;\n /**\n * Butttons that can be used to initiate a drag\n */\n this.dragButtons = [0, 1, 2];\n /**\n * @internal\n */\n this._useAlternatePickedPointAboveMaxDragAngle = false;\n /**\n * The id of the pointer that is currently interacting with the behavior (-1 when no pointer is active)\n */\n this.currentDraggingPointerId = -1;\n /**\n * If the behavior is currently in a dragging state\n */\n this.dragging = false;\n /**\n * The distance towards the target drag position to move each frame. This can be useful to avoid jitter. Set this to 1 for no delay. (Default: 0.2)\n */\n this.dragDeltaRatio = 0.2;\n /**\n * If the drag plane orientation should be updated during the dragging (Default: true)\n */\n this.updateDragPlane = true;\n // Debug mode will display drag planes to help visualize behavior\n this._debugMode = false;\n this._moving = false;\n /**\n * Fires each time the attached mesh is dragged with the pointer\n * * delta between last drag position and current drag position in world space\n * * dragDistance along the drag axis\n * * dragPlaneNormal normal of the current drag plane used during the drag\n * * dragPlanePoint in world space where the drag intersects the drag plane\n *\n * (if validatedDrag is used, the position of the attached mesh might not equal dragPlanePoint)\n */\n this.onDragObservable = new Observable();\n /**\n * Fires each time a drag begins (eg. mouse down on mesh)\n * * dragPlanePoint in world space where the drag intersects the drag plane\n *\n * (if validatedDrag is used, the position of the attached mesh might not equal dragPlanePoint)\n */\n this.onDragStartObservable = new Observable();\n /**\n * Fires each time a drag ends (eg. mouse release after drag)\n * * dragPlanePoint in world space where the drag intersects the drag plane\n *\n * (if validatedDrag is used, the position of the attached mesh might not equal dragPlanePoint)\n */\n this.onDragEndObservable = new Observable();\n /**\n * Fires each time behavior enabled state changes\n */\n this.onEnabledObservable = new Observable();\n /**\n * If the attached mesh should be moved when dragged\n */\n this.moveAttached = true;\n this._enabled = true;\n /**\n * If pointer events should start and release the drag (Default: true)\n */\n this.startAndReleaseDragOnPointerEvents = true;\n /**\n * If camera controls should be detached during the drag\n */\n this.detachCameraControls = true;\n /**\n * If set, the drag plane/axis will be rotated based on the attached mesh's world rotation (Default: true)\n */\n this.useObjectOrientationForDragging = true;\n /**\n * Predicate to determine if it is valid to move the object to a new position when it is moved.\n * In the case of rotation gizmo, target contains the angle.\n * @param target destination position or desired angle delta\n * @returns boolean for whether or not it is valid to move\n */\n // eslint-disable-next-line @typescript-eslint/no-unused-vars\n this.validateDrag = target => {\n return true;\n };\n this._tmpVector = new Vector3(0, 0, 0);\n this._alternatePickedPoint = new Vector3(0, 0, 0);\n this._worldDragAxis = new Vector3(0, 0, 0);\n this._targetPosition = new Vector3(0, 0, 0);\n this._attachedToElement = false;\n this._startDragRay = new Ray(new Vector3(), new Vector3());\n this._lastPointerRay = {};\n this._dragDelta = new Vector3();\n // Variables to avoid instantiation in the below method\n this._pointA = new Vector3(0, 0, 0);\n this._pointC = new Vector3(0, 0, 0);\n this._localAxis = new Vector3(0, 0, 0);\n this._lookAt = new Vector3(0, 0, 0);\n this._options = options ? options : {};\n let optionCount = 0;\n if (this._options.dragAxis) {\n optionCount++;\n }\n if (this._options.dragPlaneNormal) {\n optionCount++;\n }\n if (optionCount > 1) {\n // eslint-disable-next-line no-throw-literal\n throw \"Multiple drag modes specified in dragBehavior options. Only one expected\";\n }\n }\n /**\n * The name of the behavior\n */\n get name() {\n return \"PointerDrag\";\n }\n /**\n * Initializes the behavior\n */\n init() {}\n /**\n * Attaches the drag behavior the passed in mesh\n * @param ownerNode The mesh that will be dragged around once attached\n * @param predicate Predicate to use for pick filtering\n */\n attach(ownerNode, predicate) {\n this._scene = ownerNode.getScene();\n ownerNode.isNearGrabbable = true;\n this.attachedNode = ownerNode;\n // Initialize drag plane to not interfere with existing scene\n if (!PointerDragBehavior._PlaneScene) {\n if (this._debugMode) {\n PointerDragBehavior._PlaneScene = this._scene;\n } else {\n PointerDragBehavior._PlaneScene = new Scene(this._scene.getEngine(), {\n virtual: true\n });\n PointerDragBehavior._PlaneScene.detachControl();\n this._scene.onDisposeObservable.addOnce(() => {\n PointerDragBehavior._PlaneScene.dispose();\n PointerDragBehavior._PlaneScene = null;\n });\n }\n }\n this._dragPlane = CreatePlane(\"pointerDragPlane\", {\n size: this._debugMode ? 1 : 10000,\n updatable: false,\n sideOrientation: Mesh.DOUBLESIDE\n }, PointerDragBehavior._PlaneScene);\n // State of the drag\n this.lastDragPosition = new Vector3(0, 0, 0);\n const pickPredicate = predicate ? predicate : m => {\n return this.attachedNode == m || m.isDescendantOf(this.attachedNode);\n };\n this._pointerObserver = this._scene.onPointerObservable.add(pointerInfo => {\n if (!this.enabled) {\n // If behavior is disabled before releaseDrag is ever called, call it now.\n if (this._attachedToElement) {\n this.releaseDrag();\n }\n return;\n }\n if (pointerInfo.type == PointerEventTypes.POINTERDOWN) {\n if (this.startAndReleaseDragOnPointerEvents && !this.dragging && pointerInfo.pickInfo && pointerInfo.pickInfo.hit && pointerInfo.pickInfo.pickedMesh && pointerInfo.pickInfo.pickedPoint && pointerInfo.pickInfo.ray && pickPredicate(pointerInfo.pickInfo.pickedMesh)) {\n if (this._activeDragButton === -1 && this.dragButtons.indexOf(pointerInfo.event.button) !== -1) {\n this._activeDragButton = pointerInfo.event.button;\n this._activePointerInfo = pointerInfo;\n this._startDrag(pointerInfo.event.pointerId, pointerInfo.pickInfo.ray, pointerInfo.pickInfo.pickedPoint);\n }\n }\n } else if (pointerInfo.type == PointerEventTypes.POINTERUP) {\n if (this.startAndReleaseDragOnPointerEvents && this.currentDraggingPointerId == pointerInfo.event.pointerId && (this._activeDragButton === pointerInfo.event.button || this._activeDragButton === -1)) {\n this.releaseDrag();\n }\n } else if (pointerInfo.type == PointerEventTypes.POINTERMOVE) {\n const pointerId = pointerInfo.event.pointerId;\n // If drag was started with anyMouseID specified, set pointerID to the next mouse that moved\n if (this.currentDraggingPointerId === PointerDragBehavior._AnyMouseId && pointerId !== PointerDragBehavior._AnyMouseId) {\n const evt = pointerInfo.event;\n const isMouseEvent = evt.pointerType === \"mouse\" || !this._scene.getEngine().hostInformation.isMobile && evt instanceof MouseEvent;\n if (isMouseEvent) {\n if (this._lastPointerRay[this.currentDraggingPointerId]) {\n this._lastPointerRay[pointerId] = this._lastPointerRay[this.currentDraggingPointerId];\n delete this._lastPointerRay[this.currentDraggingPointerId];\n }\n this.currentDraggingPointerId = pointerId;\n }\n }\n // Keep track of last pointer ray, this is used simulating the start of a drag in startDrag()\n if (!this._lastPointerRay[pointerId]) {\n this._lastPointerRay[pointerId] = new Ray(new Vector3(), new Vector3());\n }\n if (pointerInfo.pickInfo && pointerInfo.pickInfo.ray) {\n this._lastPointerRay[pointerId].origin.copyFrom(pointerInfo.pickInfo.ray.origin);\n this._lastPointerRay[pointerId].direction.copyFrom(pointerInfo.pickInfo.ray.direction);\n if (this.currentDraggingPointerId == pointerId && this.dragging) {\n this._moveDrag(pointerInfo.pickInfo.ray);\n }\n }\n }\n });\n this._beforeRenderObserver = this._scene.onBeforeRenderObservable.add(() => {\n if (this._moving && this.moveAttached) {\n let needMatrixUpdate = false;\n PivotTools._RemoveAndStorePivotPoint(this.attachedNode);\n // Slowly move mesh to avoid jitter\n this._targetPosition.subtractToRef(this.attachedNode.absolutePosition, this._tmpVector);\n this._tmpVector.scaleInPlace(this.dragDeltaRatio);\n this.attachedNode.getAbsolutePosition().addToRef(this._tmpVector, this._tmpVector);\n if (this.validateDrag(this._tmpVector)) {\n this.attachedNode.setAbsolutePosition(this._tmpVector);\n needMatrixUpdate = true;\n }\n PivotTools._RestorePivotPoint(this.attachedNode);\n if (needMatrixUpdate) {\n this.attachedNode.computeWorldMatrix();\n }\n }\n });\n }\n /**\n * Force release the drag action by code.\n */\n releaseDrag() {\n if (this.dragging) {\n this.dragging = false;\n this.onDragEndObservable.notifyObservers({\n dragPlanePoint: this.lastDragPosition,\n pointerId: this.currentDraggingPointerId,\n pointerInfo: this._activePointerInfo\n });\n }\n this.currentDraggingPointerId = -1;\n this._activeDragButton = -1;\n this._activePointerInfo = null;\n this._moving = false;\n // Reattach camera controls\n if (this.detachCameraControls && this._attachedToElement && this._scene.activeCamera && !this._scene.activeCamera.leftCamera) {\n if (this._scene.activeCamera.getClassName() === \"ArcRotateCamera\") {\n const arcRotateCamera = this._scene.activeCamera;\n arcRotateCamera.attachControl(arcRotateCamera.inputs ? arcRotateCamera.inputs.noPreventDefault : true, arcRotateCamera._useCtrlForPanning, arcRotateCamera._panningMouseButton);\n } else {\n this._scene.activeCamera.attachControl(this._scene.activeCamera.inputs ? this._scene.activeCamera.inputs.noPreventDefault : true);\n }\n this._attachedToElement = false;\n }\n }\n /**\n * Simulates the start of a pointer drag event on the behavior\n * @param pointerId pointerID of the pointer that should be simulated (Default: Any mouse pointer ID)\n * @param fromRay initial ray of the pointer to be simulated (Default: Ray from camera to attached mesh)\n * @param startPickedPoint picked point of the pointer to be simulated (Default: attached mesh position)\n */\n startDrag(pointerId = PointerDragBehavior._AnyMouseId, fromRay, startPickedPoint) {\n this._startDrag(pointerId, fromRay, startPickedPoint);\n let lastRay = this._lastPointerRay[pointerId];\n if (pointerId === PointerDragBehavior._AnyMouseId) {\n lastRay = this._lastPointerRay[Object.keys(this._lastPointerRay)[0]];\n }\n if (lastRay) {\n // if there was a last pointer ray drag the object there\n this._moveDrag(lastRay);\n }\n }\n _startDrag(pointerId, fromRay, startPickedPoint) {\n if (!this._scene.activeCamera || this.dragging || !this.attachedNode) {\n return;\n }\n PivotTools._RemoveAndStorePivotPoint(this.attachedNode);\n // Create start ray from the camera to the object\n if (fromRay) {\n this._startDragRay.direction.copyFrom(fromRay.direction);\n this._startDragRay.origin.copyFrom(fromRay.origin);\n } else {\n this._startDragRay.origin.copyFrom(this._scene.activeCamera.position);\n this.attachedNode.getWorldMatrix().getTranslationToRef(this._tmpVector);\n this._tmpVector.subtractToRef(this._scene.activeCamera.position, this._startDragRay.direction);\n }\n this._updateDragPlanePosition(this._startDragRay, startPickedPoint ? startPickedPoint : this._tmpVector);\n const pickedPoint = this._pickWithRayOnDragPlane(this._startDragRay);\n if (pickedPoint) {\n this.dragging = true;\n this.currentDraggingPointerId = pointerId;\n this.lastDragPosition.copyFrom(pickedPoint);\n this.onDragStartObservable.notifyObservers({\n dragPlanePoint: pickedPoint,\n pointerId: this.currentDraggingPointerId,\n pointerInfo: this._activePointerInfo\n });\n this._targetPosition.copyFrom(this.attachedNode.getAbsolutePosition());\n // Detatch camera controls\n if (this.detachCameraControls && this._scene.activeCamera && this._scene.activeCamera.inputs && !this._scene.activeCamera.leftCamera) {\n if (this._scene.activeCamera.inputs.attachedToElement) {\n this._scene.activeCamera.detachControl();\n this._attachedToElement = true;\n } else {\n this._attachedToElement = false;\n }\n }\n } else {\n this.releaseDrag();\n }\n PivotTools._RestorePivotPoint(this.attachedNode);\n }\n _moveDrag(ray) {\n this._moving = true;\n const pickedPoint = this._pickWithRayOnDragPlane(ray);\n if (pickedPoint) {\n PivotTools._RemoveAndStorePivotPoint(this.attachedNode);\n if (this.updateDragPlane) {\n this._updateDragPlanePosition(ray, pickedPoint);\n }\n let dragLength = 0;\n // depending on the drag mode option drag accordingly\n if (this._options.dragAxis) {\n // Convert local drag axis to world if useObjectOrientationForDragging\n this.useObjectOrientationForDragging ? Vector3.TransformCoordinatesToRef(this._options.dragAxis, this.attachedNode.getWorldMatrix().getRotationMatrix(), this._worldDragAxis) : this._worldDragAxis.copyFrom(this._options.dragAxis);\n // Project delta drag from the drag plane onto the drag axis\n pickedPoint.subtractToRef(this.lastDragPosition, this._tmpVector);\n this._worldDragAxis.normalize();\n dragLength = Vector3.Dot(this._tmpVector, this._worldDragAxis);\n this._worldDragAxis.scaleToRef(dragLength, this._dragDelta);\n } else {\n dragLength = this._dragDelta.length();\n pickedPoint.subtractToRef(this.lastDragPosition, this._dragDelta);\n }\n this._targetPosition.addInPlace(this._dragDelta);\n this.onDragObservable.notifyObservers({\n dragDistance: dragLength,\n delta: this._dragDelta,\n dragPlanePoint: pickedPoint,\n dragPlaneNormal: this._dragPlane.forward,\n pointerId: this.currentDraggingPointerId,\n pointerInfo: this._activePointerInfo\n });\n this.lastDragPosition.copyFrom(pickedPoint);\n PivotTools._RestorePivotPoint(this.attachedNode);\n }\n }\n _pickWithRayOnDragPlane(ray) {\n if (!ray) {\n return null;\n }\n // Calculate angle between plane normal and ray\n let angle = Math.acos(Vector3.Dot(this._dragPlane.forward, ray.direction));\n // Correct if ray is casted from oposite side\n if (angle > Math.PI / 2) {\n angle = Math.PI - angle;\n }\n // If the angle is too perpendicular to the plane pick another point on the plane where it is looking\n if (this.maxDragAngle > 0 && angle > this.maxDragAngle) {\n if (this._useAlternatePickedPointAboveMaxDragAngle) {\n // Invert ray direction along the towards object axis\n this._tmpVector.copyFrom(ray.direction);\n this.attachedNode.absolutePosition.subtractToRef(ray.origin, this._alternatePickedPoint);\n this._alternatePickedPoint.normalize();\n this._alternatePickedPoint.scaleInPlace(this._useAlternatePickedPointAboveMaxDragAngleDragSpeed * Vector3.Dot(this._alternatePickedPoint, this._tmpVector));\n this._tmpVector.addInPlace(this._alternatePickedPoint);\n // Project resulting vector onto the drag plane and add it to the attached nodes absolute position to get a picked point\n const dot = Vector3.Dot(this._dragPlane.forward, this._tmpVector);\n this._dragPlane.forward.scaleToRef(-dot, this._alternatePickedPoint);\n this._alternatePickedPoint.addInPlace(this._tmpVector);\n this._alternatePickedPoint.addInPlace(this.attachedNode.absolutePosition);\n return this._alternatePickedPoint;\n } else {\n return null;\n }\n }\n // use an infinite plane instead of ray picking a mesh that must be updated every frame\n const planeNormal = this._dragPlane.forward;\n const planePosition = this._dragPlane.position;\n const dotProduct = ray.direction.dot(planeNormal);\n if (Math.abs(dotProduct) < Epsilon) {\n // Ray and plane are parallel, no intersection\n return null;\n }\n planePosition.subtractToRef(ray.origin, TmpVectors.Vector3[0]);\n const t = TmpVectors.Vector3[0].dot(planeNormal) / dotProduct;\n // Ensure the intersection point is in front of the ray (t must be positive)\n if (t < 0) {\n // Intersection point is behind the ray\n return null;\n }\n // Calculate the intersection point using the parameter t\n ray.direction.scaleToRef(t, TmpVectors.Vector3[0]);\n const intersectionPoint = ray.origin.add(TmpVectors.Vector3[0]);\n return intersectionPoint;\n }\n // Position the drag plane based on the attached mesh position, for single axis rotate the plane along the axis to face the camera\n _updateDragPlanePosition(ray, dragPlanePosition) {\n this._pointA.copyFrom(dragPlanePosition);\n if (this._options.dragAxis) {\n this.useObjectOrientationForDragging ? Vector3.TransformCoordinatesToRef(this._options.dragAxis, this.attachedNode.getWorldMatrix().getRotationMatrix(), this._localAxis) : this._localAxis.copyFrom(this._options.dragAxis);\n // Calculate plane normal that is the cross product of local axis and (eye-dragPlanePosition)\n ray.origin.subtractToRef(this._pointA, this._pointC);\n this._pointC.normalize();\n if (Math.abs(Vector3.Dot(this._localAxis, this._pointC)) > 0.999) {\n // the drag axis is colinear with the (eye to position) ray. The cross product will give jittered values.\n // A new axis vector need to be computed\n if (Math.abs(Vector3.Dot(Vector3.UpReadOnly, this._pointC)) > 0.999) {\n this._lookAt.copyFrom(Vector3.Right());\n } else {\n this._lookAt.copyFrom(Vector3.UpReadOnly);\n }\n } else {\n Vector3.CrossToRef(this._localAxis, this._pointC, this._lookAt);\n // Get perpendicular line from previous result and drag axis to adjust lineB to be perpendicular to camera\n Vector3.CrossToRef(this._localAxis, this._lookAt, this._lookAt);\n this._lookAt.normalize();\n }\n this._dragPlane.position.copyFrom(this._pointA);\n this._pointA.addToRef(this._lookAt, this._lookAt);\n this._dragPlane.lookAt(this._lookAt);\n } else if (this._options.dragPlaneNormal) {\n this.useObjectOrientationForDragging ? Vector3.TransformCoordinatesToRef(this._options.dragPlaneNormal, this.attachedNode.getWorldMatrix().getRotationMatrix(), this._localAxis) : this._localAxis.copyFrom(this._options.dragPlaneNormal);\n this._dragPlane.position.copyFrom(this._pointA);\n this._pointA.addToRef(this._localAxis, this._lookAt);\n this._dragPlane.lookAt(this._lookAt);\n } else {\n this._dragPlane.position.copyFrom(this._pointA);\n this._dragPlane.lookAt(ray.origin);\n }\n // Update the position of the drag plane so it doesn't get out of sync with the node (eg. when moving back and forth quickly)\n this._dragPlane.position.copyFrom(this.attachedNode.getAbsolutePosition());\n this._dragPlane.computeWorldMatrix(true);\n }\n /**\n * Detaches the behavior from the mesh\n */\n detach() {\n this._lastPointerRay = {};\n if (this.attachedNode) {\n this.attachedNode.isNearGrabbable = false;\n }\n if (this._pointerObserver) {\n this._scene.onPointerObservable.remove(this._pointerObserver);\n }\n if (this._beforeRenderObserver) {\n this._scene.onBeforeRenderObservable.remove(this._beforeRenderObserver);\n }\n if (this._dragPlane) {\n this._dragPlane.dispose();\n }\n this.releaseDrag();\n }\n}\nPointerDragBehavior._AnyMouseId = -2;","map":{"version":3,"names":["Mesh","Scene","Observable","TmpVectors","Vector3","PointerEventTypes","Ray","PivotTools","CreatePlane","Epsilon","PointerDragBehavior","currentDraggingPointerID","currentDraggingPointerId","enabled","value","_enabled","onEnabledObservable","notifyObservers","options","_options","constructor","_useAlternatePickedPointAboveMaxDragAngleDragSpeed","_activeDragButton","maxDragAngle","dragButtons","_useAlternatePickedPointAboveMaxDragAngle","dragging","dragDeltaRatio","updateDragPlane","_debugMode","_moving","onDragObservable","onDragStartObservable","onDragEndObservable","moveAttached","startAndReleaseDragOnPointerEvents","detachCameraControls","useObjectOrientationForDragging","validateDrag","target","_tmpVector","_alternatePickedPoint","_worldDragAxis","_targetPosition","_attachedToElement","_startDragRay","_lastPointerRay","_dragDelta","_pointA","_pointC","_localAxis","_lookAt","optionCount","dragAxis","dragPlaneNormal","name","init","attach","ownerNode","predicate","_scene","getScene","isNearGrabbable","attachedNode","_PlaneScene","getEngine","virtual","detachControl","onDisposeObservable","addOnce","dispose","_dragPlane","size","updatable","sideOrientation","DOUBLESIDE","lastDragPosition","pickPredicate","m","isDescendantOf","_pointerObserver","onPointerObservable","add","pointerInfo","releaseDrag","type","POINTERDOWN","pickInfo","hit","pickedMesh","pickedPoint","ray","indexOf","event","button","_activePointerInfo","_startDrag","pointerId","POINTERUP","POINTERMOVE","_AnyMouseId","evt","isMouseEvent","pointerType","hostInformation","isMobile","MouseEvent","origin","copyFrom","direction","_moveDrag","_beforeRenderObserver","onBeforeRenderObservable","needMatrixUpdate","_RemoveAndStorePivotPoint","subtractToRef","absolutePosition","scaleInPlace","getAbsolutePosition","addToRef","setAbsolutePosition","_RestorePivotPoint","computeWorldMatrix","dragPlanePoint","activeCamera","leftCamera","getClassName","arcRotateCamera","attachControl","inputs","noPreventDefault","_useCtrlForPanning","_panningMouseButton","startDrag","fromRay","startPickedPoint","lastRay","Object","keys","position","getWorldMatrix","getTranslationToRef","_updateDragPlanePosition","_pickWithRayOnDragPlane","attachedToElement","dragLength","TransformCoordinatesToRef","getRotationMatrix","normalize","Dot","scaleToRef","length","addInPlace","dragDistance","delta","forward","angle","Math","acos","PI","dot","planeNormal","planePosition","dotProduct","abs","t","intersectionPoint","dragPlanePosition","UpReadOnly","Right","CrossToRef","lookAt","detach","remove"],"sources":["F:/workspace/202226701027/huinongbao-app/node_modules/@babylonjs/core/Behaviors/Meshes/pointerDragBehavior.js"],"sourcesContent":["import { Mesh } from \"../../Meshes/mesh.js\";\nimport { Scene } from \"../../scene.js\";\nimport { Observable } from \"../../Misc/observable.js\";\nimport { TmpVectors, Vector3 } from \"../../Maths/math.vector.js\";\nimport { PointerEventTypes } from \"../../Events/pointerEvents.js\";\nimport { Ray } from \"../../Culling/ray.js\";\nimport { PivotTools } from \"../../Misc/pivotTools.js\";\nimport { CreatePlane } from \"../../Meshes/Builders/planeBuilder.js\";\nimport { Epsilon } from \"../../Maths/math.constants.js\";\n/**\n * A behavior that when attached to a mesh will allow the mesh to be dragged around the screen based on pointer events\n */\nexport class PointerDragBehavior {\n /**\n * Get or set the currentDraggingPointerId\n * @deprecated Please use currentDraggingPointerId instead\n */\n get currentDraggingPointerID() {\n return this.currentDraggingPointerId;\n }\n set currentDraggingPointerID(currentDraggingPointerID) {\n this.currentDraggingPointerId = currentDraggingPointerID;\n }\n /**\n * If the drag behavior will react to drag events (Default: true)\n */\n set enabled(value) {\n if (value != this._enabled) {\n this.onEnabledObservable.notifyObservers(value);\n }\n this._enabled = value;\n }\n get enabled() {\n return this._enabled;\n }\n /**\n * Gets the options used by the behavior\n */\n get options() {\n return this._options;\n }\n /**\n * Sets the options used by the behavior\n */\n set options(options) {\n this._options = options;\n }\n /**\n * Creates a pointer drag behavior that can be attached to a mesh\n * @param options The drag axis or normal of the plane that will be dragged across. If no options are specified the drag plane will always face the ray's origin (eg. camera)\n * @param options.dragAxis\n * @param options.dragPlaneNormal\n */\n constructor(options) {\n this._useAlternatePickedPointAboveMaxDragAngleDragSpeed = -1.1;\n this._activeDragButton = -1;\n /**\n * The maximum tolerated angle between the drag plane and dragging pointer rays to trigger pointer events. Set to 0 to allow any angle (default: 0)\n */\n this.maxDragAngle = 0;\n /**\n * Butttons that can be used to initiate a drag\n */\n this.dragButtons = [0, 1, 2];\n /**\n * @internal\n */\n this._useAlternatePickedPointAboveMaxDragAngle = false;\n /**\n * The id of the pointer that is currently interacting with the behavior (-1 when no pointer is active)\n */\n this.currentDraggingPointerId = -1;\n /**\n * If the behavior is currently in a dragging state\n */\n this.dragging = false;\n /**\n * The distance towards the target drag position to move each frame. This can be useful to avoid jitter. Set this to 1 for no delay. (Default: 0.2)\n */\n this.dragDeltaRatio = 0.2;\n /**\n * If the drag plane orientation should be updated during the dragging (Default: true)\n */\n this.updateDragPlane = true;\n // Debug mode will display drag planes to help visualize behavior\n this._debugMode = false;\n this._moving = false;\n /**\n * Fires each time the attached mesh is dragged with the pointer\n * * delta between last drag position and current drag position in world space\n * * dragDistance along the drag axis\n * * dragPlaneNormal normal of the current drag plane used during the drag\n * * dragPlanePoint in world space where the drag intersects the drag plane\n *\n * (if validatedDrag is used, the position of the attached mesh might not equal dragPlanePoint)\n */\n this.onDragObservable = new Observable();\n /**\n * Fires each time a drag begins (eg. mouse down on mesh)\n * * dragPlanePoint in world space where the drag intersects the drag plane\n *\n * (if validatedDrag is used, the position of the attached mesh might not equal dragPlanePoint)\n */\n this.onDragStartObservable = new Observable();\n /**\n * Fires each time a drag ends (eg. mouse release after drag)\n * * dragPlanePoint in world space where the drag intersects the drag plane\n *\n * (if validatedDrag is used, the position of the attached mesh might not equal dragPlanePoint)\n */\n this.onDragEndObservable = new Observable();\n /**\n * Fires each time behavior enabled state changes\n */\n this.onEnabledObservable = new Observable();\n /**\n * If the attached mesh should be moved when dragged\n */\n this.moveAttached = true;\n this._enabled = true;\n /**\n * If pointer events should start and release the drag (Default: true)\n */\n this.startAndReleaseDragOnPointerEvents = true;\n /**\n * If camera controls should be detached during the drag\n */\n this.detachCameraControls = true;\n /**\n * If set, the drag plane/axis will be rotated based on the attached mesh's world rotation (Default: true)\n */\n this.useObjectOrientationForDragging = true;\n /**\n * Predicate to determine if it is valid to move the object to a new position when it is moved.\n * In the case of rotation gizmo, target contains the angle.\n * @param target destination position or desired angle delta\n * @returns boolean for whether or not it is valid to move\n */\n // eslint-disable-next-line @typescript-eslint/no-unused-vars\n this.validateDrag = (target) => {\n return true;\n };\n this._tmpVector = new Vector3(0, 0, 0);\n this._alternatePickedPoint = new Vector3(0, 0, 0);\n this._worldDragAxis = new Vector3(0, 0, 0);\n this._targetPosition = new Vector3(0, 0, 0);\n this._attachedToElement = false;\n this._startDragRay = new Ray(new Vector3(), new Vector3());\n this._lastPointerRay = {};\n this._dragDelta = new Vector3();\n // Variables to avoid instantiation in the below method\n this._pointA = new Vector3(0, 0, 0);\n this._pointC = new Vector3(0, 0, 0);\n this._localAxis = new Vector3(0, 0, 0);\n this._lookAt = new Vector3(0, 0, 0);\n this._options = options ? options : {};\n let optionCount = 0;\n if (this._options.dragAxis) {\n optionCount++;\n }\n if (this._options.dragPlaneNormal) {\n optionCount++;\n }\n if (optionCount > 1) {\n // eslint-disable-next-line no-throw-literal\n throw \"Multiple drag modes specified in dragBehavior options. Only one expected\";\n }\n }\n /**\n * The name of the behavior\n */\n get name() {\n return \"PointerDrag\";\n }\n /**\n * Initializes the behavior\n */\n init() { }\n /**\n * Attaches the drag behavior the passed in mesh\n * @param ownerNode The mesh that will be dragged around once attached\n * @param predicate Predicate to use for pick filtering\n */\n attach(ownerNode, predicate) {\n this._scene = ownerNode.getScene();\n ownerNode.isNearGrabbable = true;\n this.attachedNode = ownerNode;\n // Initialize drag plane to not interfere with existing scene\n if (!PointerDragBehavior._PlaneScene) {\n if (this._debugMode) {\n PointerDragBehavior._PlaneScene = this._scene;\n }\n else {\n PointerDragBehavior._PlaneScene = new Scene(this._scene.getEngine(), { virtual: true });\n PointerDragBehavior._PlaneScene.detachControl();\n this._scene.onDisposeObservable.addOnce(() => {\n PointerDragBehavior._PlaneScene.dispose();\n PointerDragBehavior._PlaneScene = null;\n });\n }\n }\n this._dragPlane = CreatePlane(\"pointerDragPlane\", { size: this._debugMode ? 1 : 10000, updatable: false, sideOrientation: Mesh.DOUBLESIDE }, PointerDragBehavior._PlaneScene);\n // State of the drag\n this.lastDragPosition = new Vector3(0, 0, 0);\n const pickPredicate = predicate\n ? predicate\n : (m) => {\n return this.attachedNode == m || m.isDescendantOf(this.attachedNode);\n };\n this._pointerObserver = this._scene.onPointerObservable.add((pointerInfo) => {\n if (!this.enabled) {\n // If behavior is disabled before releaseDrag is ever called, call it now.\n if (this._attachedToElement) {\n this.releaseDrag();\n }\n return;\n }\n if (pointerInfo.type == PointerEventTypes.POINTERDOWN) {\n if (this.startAndReleaseDragOnPointerEvents &&\n !this.dragging &&\n pointerInfo.pickInfo &&\n pointerInfo.pickInfo.hit &&\n pointerInfo.pickInfo.pickedMesh &&\n pointerInfo.pickInfo.pickedPoint &&\n pointerInfo.pickInfo.ray &&\n pickPredicate(pointerInfo.pickInfo.pickedMesh)) {\n if (this._activeDragButton === -1 && this.dragButtons.indexOf(pointerInfo.event.button) !== -1) {\n this._activeDragButton = pointerInfo.event.button;\n this._activePointerInfo = pointerInfo;\n this._startDrag(pointerInfo.event.pointerId, pointerInfo.pickInfo.ray, pointerInfo.pickInfo.pickedPoint);\n }\n }\n }\n else if (pointerInfo.type == PointerEventTypes.POINTERUP) {\n if (this.startAndReleaseDragOnPointerEvents &&\n this.currentDraggingPointerId == pointerInfo.event.pointerId &&\n (this._activeDragButton === pointerInfo.event.button || this._activeDragButton === -1)) {\n this.releaseDrag();\n }\n }\n else if (pointerInfo.type == PointerEventTypes.POINTERMOVE) {\n const pointerId = pointerInfo.event.pointerId;\n // If drag was started with anyMouseID specified, set pointerID to the next mouse that moved\n if (this.currentDraggingPointerId === PointerDragBehavior._AnyMouseId && pointerId !== PointerDragBehavior._AnyMouseId) {\n const evt = pointerInfo.event;\n const isMouseEvent = evt.pointerType === \"mouse\" || (!this._scene.getEngine().hostInformation.isMobile && evt instanceof MouseEvent);\n if (isMouseEvent) {\n if (this._lastPointerRay[this.currentDraggingPointerId]) {\n this._lastPointerRay[pointerId] = this._lastPointerRay[this.currentDraggingPointerId];\n delete this._lastPointerRay[this.currentDraggingPointerId];\n }\n this.currentDraggingPointerId = pointerId;\n }\n }\n // Keep track of last pointer ray, this is used simulating the start of a drag in startDrag()\n if (!this._lastPointerRay[pointerId]) {\n this._lastPointerRay[pointerId] = new Ray(new Vector3(), new Vector3());\n }\n if (pointerInfo.pickInfo && pointerInfo.pickInfo.ray) {\n this._lastPointerRay[pointerId].origin.copyFrom(pointerInfo.pickInfo.ray.origin);\n this._lastPointerRay[pointerId].direction.copyFrom(pointerInfo.pickInfo.ray.direction);\n if (this.currentDraggingPointerId == pointerId && this.dragging) {\n this._moveDrag(pointerInfo.pickInfo.ray);\n }\n }\n }\n });\n this._beforeRenderObserver = this._scene.onBeforeRenderObservable.add(() => {\n if (this._moving && this.moveAttached) {\n let needMatrixUpdate = false;\n PivotTools._RemoveAndStorePivotPoint(this.attachedNode);\n // Slowly move mesh to avoid jitter\n this._targetPosition.subtractToRef(this.attachedNode.absolutePosition, this._tmpVector);\n this._tmpVector.scaleInPlace(this.dragDeltaRatio);\n this.attachedNode.getAbsolutePosition().addToRef(this._tmpVector, this._tmpVector);\n if (this.validateDrag(this._tmpVector)) {\n this.attachedNode.setAbsolutePosition(this._tmpVector);\n needMatrixUpdate = true;\n }\n PivotTools._RestorePivotPoint(this.attachedNode);\n if (needMatrixUpdate) {\n this.attachedNode.computeWorldMatrix();\n }\n }\n });\n }\n /**\n * Force release the drag action by code.\n */\n releaseDrag() {\n if (this.dragging) {\n this.dragging = false;\n this.onDragEndObservable.notifyObservers({ dragPlanePoint: this.lastDragPosition, pointerId: this.currentDraggingPointerId, pointerInfo: this._activePointerInfo });\n }\n this.currentDraggingPointerId = -1;\n this._activeDragButton = -1;\n this._activePointerInfo = null;\n this._moving = false;\n // Reattach camera controls\n if (this.detachCameraControls && this._attachedToElement && this._scene.activeCamera && !this._scene.activeCamera.leftCamera) {\n if (this._scene.activeCamera.getClassName() === \"ArcRotateCamera\") {\n const arcRotateCamera = this._scene.activeCamera;\n arcRotateCamera.attachControl(arcRotateCamera.inputs ? arcRotateCamera.inputs.noPreventDefault : true, arcRotateCamera._useCtrlForPanning, arcRotateCamera._panningMouseButton);\n }\n else {\n this._scene.activeCamera.attachControl(this._scene.activeCamera.inputs ? this._scene.activeCamera.inputs.noPreventDefault : true);\n }\n this._attachedToElement = false;\n }\n }\n /**\n * Simulates the start of a pointer drag event on the behavior\n * @param pointerId pointerID of the pointer that should be simulated (Default: Any mouse pointer ID)\n * @param fromRay initial ray of the pointer to be simulated (Default: Ray from camera to attached mesh)\n * @param startPickedPoint picked point of the pointer to be simulated (Default: attached mesh position)\n */\n startDrag(pointerId = PointerDragBehavior._AnyMouseId, fromRay, startPickedPoint) {\n this._startDrag(pointerId, fromRay, startPickedPoint);\n let lastRay = this._lastPointerRay[pointerId];\n if (pointerId === PointerDragBehavior._AnyMouseId) {\n lastRay = this._lastPointerRay[Object.keys(this._lastPointerRay)[0]];\n }\n if (lastRay) {\n // if there was a last pointer ray drag the object there\n this._moveDrag(lastRay);\n }\n }\n _startDrag(pointerId, fromRay, startPickedPoint) {\n if (!this._scene.activeCamera || this.dragging || !this.attachedNode) {\n return;\n }\n PivotTools._RemoveAndStorePivotPoint(this.attachedNode);\n // Create start ray from the camera to the object\n if (fromRay) {\n this._startDragRay.direction.copyFrom(fromRay.direction);\n this._startDragRay.origin.copyFrom(fromRay.origin);\n }\n else {\n this._startDragRay.origin.copyFrom(this._scene.activeCamera.position);\n this.attachedNode.getWorldMatrix().getTranslationToRef(this._tmpVector);\n this._tmpVector.subtractToRef(this._scene.activeCamera.position, this._startDragRay.direction);\n }\n this._updateDragPlanePosition(this._startDragRay, startPickedPoint ? startPickedPoint : this._tmpVector);\n const pickedPoint = this._pickWithRayOnDragPlane(this._startDragRay);\n if (pickedPoint) {\n this.dragging = true;\n this.currentDraggingPointerId = pointerId;\n this.lastDragPosition.copyFrom(pickedPoint);\n this.onDragStartObservable.notifyObservers({ dragPlanePoint: pickedPoint, pointerId: this.currentDraggingPointerId, pointerInfo: this._activePointerInfo });\n this._targetPosition.copyFrom(this.attachedNode.getAbsolutePosition());\n // Detatch camera controls\n if (this.detachCameraControls && this._scene.activeCamera && this._scene.activeCamera.inputs && !this._scene.activeCamera.leftCamera) {\n if (this._scene.activeCamera.inputs.attachedToElement) {\n this._scene.activeCamera.detachControl();\n this._attachedToElement = true;\n }\n else {\n this._attachedToElement = false;\n }\n }\n }\n else {\n this.releaseDrag();\n }\n PivotTools._RestorePivotPoint(this.attachedNode);\n }\n _moveDrag(ray) {\n this._moving = true;\n const pickedPoint = this._pickWithRayOnDragPlane(ray);\n if (pickedPoint) {\n PivotTools._RemoveAndStorePivotPoint(this.attachedNode);\n if (this.updateDragPlane) {\n this._updateDragPlanePosition(ray, pickedPoint);\n }\n let dragLength = 0;\n // depending on the drag mode option drag accordingly\n if (this._options.dragAxis) {\n // Convert local drag axis to world if useObjectOrientationForDragging\n this.useObjectOrientationForDragging\n ? Vector3.TransformCoordinatesToRef(this._options.dragAxis, this.attachedNode.getWorldMatrix().getRotationMatrix(), this._worldDragAxis)\n : this._worldDragAxis.copyFrom(this._options.dragAxis);\n // Project delta drag from the drag plane onto the drag axis\n pickedPoint.subtractToRef(this.lastDragPosition, this._tmpVector);\n this._worldDragAxis.normalize();\n dragLength = Vector3.Dot(this._tmpVector, this._worldDragAxis);\n this._worldDragAxis.scaleToRef(dragLength, this._dragDelta);\n }\n else {\n dragLength = this._dragDelta.length();\n pickedPoint.subtractToRef(this.lastDragPosition, this._dragDelta);\n }\n this._targetPosition.addInPlace(this._dragDelta);\n this.onDragObservable.notifyObservers({\n dragDistance: dragLength,\n delta: this._dragDelta,\n dragPlanePoint: pickedPoint,\n dragPlaneNormal: this._dragPlane.forward,\n pointerId: this.currentDraggingPointerId,\n pointerInfo: this._activePointerInfo,\n });\n this.lastDragPosition.copyFrom(pickedPoint);\n PivotTools._RestorePivotPoint(this.attachedNode);\n }\n }\n _pickWithRayOnDragPlane(ray) {\n if (!ray) {\n return null;\n }\n // Calculate angle between plane normal and ray\n let angle = Math.acos(Vector3.Dot(this._dragPlane.forward, ray.direction));\n // Correct if ray is casted from oposite side\n if (angle > Math.PI / 2) {\n angle = Math.PI - angle;\n }\n // If the angle is too perpendicular to the plane pick another point on the plane where it is looking\n if (this.maxDragAngle > 0 && angle > this.maxDragAngle) {\n if (this._useAlternatePickedPointAboveMaxDragAngle) {\n // Invert ray direction along the towards object axis\n this._tmpVector.copyFrom(ray.direction);\n this.attachedNode.absolutePosition.subtractToRef(ray.origin, this._alternatePickedPoint);\n this._alternatePickedPoint.normalize();\n this._alternatePickedPoint.scaleInPlace(this._useAlternatePickedPointAboveMaxDragAngleDragSpeed * Vector3.Dot(this._alternatePickedPoint, this._tmpVector));\n this._tmpVector.addInPlace(this._alternatePickedPoint);\n // Project resulting vector onto the drag plane and add it to the attached nodes absolute position to get a picked point\n const dot = Vector3.Dot(this._dragPlane.forward, this._tmpVector);\n this._dragPlane.forward.scaleToRef(-dot, this._alternatePickedPoint);\n this._alternatePickedPoint.addInPlace(this._tmpVector);\n this._alternatePickedPoint.addInPlace(this.attachedNode.absolutePosition);\n return this._alternatePickedPoint;\n }\n else {\n return null;\n }\n }\n // use an infinite plane instead of ray picking a mesh that must be updated every frame\n const planeNormal = this._dragPlane.forward;\n const planePosition = this._dragPlane.position;\n const dotProduct = ray.direction.dot(planeNormal);\n if (Math.abs(dotProduct) < Epsilon) {\n // Ray and plane are parallel, no intersection\n return null;\n }\n planePosition.subtractToRef(ray.origin, TmpVectors.Vector3[0]);\n const t = TmpVectors.Vector3[0].dot(planeNormal) / dotProduct;\n // Ensure the intersection point is in front of the ray (t must be positive)\n if (t < 0) {\n // Intersection point is behind the ray\n return null;\n }\n // Calculate the intersection point using the parameter t\n ray.direction.scaleToRef(t, TmpVectors.Vector3[0]);\n const intersectionPoint = ray.origin.add(TmpVectors.Vector3[0]);\n return intersectionPoint;\n }\n // Position the drag plane based on the attached mesh position, for single axis rotate the plane along the axis to face the camera\n _updateDragPlanePosition(ray, dragPlanePosition) {\n this._pointA.copyFrom(dragPlanePosition);\n if (this._options.dragAxis) {\n this.useObjectOrientationForDragging\n ? Vector3.TransformCoordinatesToRef(this._options.dragAxis, this.attachedNode.getWorldMatrix().getRotationMatrix(), this._localAxis)\n : this._localAxis.copyFrom(this._options.dragAxis);\n // Calculate plane normal that is the cross product of local axis and (eye-dragPlanePosition)\n ray.origin.subtractToRef(this._pointA, this._pointC);\n this._pointC.normalize();\n if (Math.abs(Vector3.Dot(this._localAxis, this._pointC)) > 0.999) {\n // the drag axis is colinear with the (eye to position) ray. The cross product will give jittered values.\n // A new axis vector need to be computed\n if (Math.abs(Vector3.Dot(Vector3.UpReadOnly, this._pointC)) > 0.999) {\n this._lookAt.copyFrom(Vector3.Right());\n }\n else {\n this._lookAt.copyFrom(Vector3.UpReadOnly);\n }\n }\n else {\n Vector3.CrossToRef(this._localAxis, this._pointC, this._lookAt);\n // Get perpendicular line from previous result and drag axis to adjust lineB to be perpendicular to camera\n Vector3.CrossToRef(this._localAxis, this._lookAt, this._lookAt);\n this._lookAt.normalize();\n }\n this._dragPlane.position.copyFrom(this._pointA);\n this._pointA.addToRef(this._lookAt, this._lookAt);\n this._dragPlane.lookAt(this._lookAt);\n }\n else if (this._options.dragPlaneNormal) {\n this.useObjectOrientationForDragging\n ? Vector3.TransformCoordinatesToRef(this._options.dragPlaneNormal, this.attachedNode.getWorldMatrix().getRotationMatrix(), this._localAxis)\n : this._localAxis.copyFrom(this._options.dragPlaneNormal);\n this._dragPlane.position.copyFrom(this._pointA);\n this._pointA.addToRef(this._localAxis, this._lookAt);\n this._dragPlane.lookAt(this._lookAt);\n }\n else {\n this._dragPlane.position.copyFrom(this._pointA);\n this._dragPlane.lookAt(ray.origin);\n }\n // Update the position of the drag plane so it doesn't get out of sync with the node (eg. when moving back and forth quickly)\n this._dragPlane.position.copyFrom(this.attachedNode.getAbsolutePosition());\n this._dragPlane.computeWorldMatrix(true);\n }\n /**\n * Detaches the behavior from the mesh\n */\n detach() {\n this._lastPointerRay = {};\n if (this.attachedNode) {\n this.attachedNode.isNearGrabbable = false;\n }\n if (this._pointerObserver) {\n this._scene.onPointerObservable.remove(this._pointerObserver);\n }\n if (this._beforeRenderObserver) {\n this._scene.onBeforeRenderObservable.remove(this._beforeRenderObserver);\n }\n if (this._dragPlane) {\n this._dragPlane.dispose();\n }\n this.releaseDrag();\n }\n}\nPointerDragBehavior._AnyMouseId = -2;\n"],"mappings":"AAAA,SAASA,IAAI,QAAQ,sBAAsB;AAC3C,SAASC,KAAK,QAAQ,gBAAgB;AACtC,SAASC,UAAU,QAAQ,0BAA0B;AACrD,SAASC,UAAU,EAAEC,OAAO,QAAQ,4BAA4B;AAChE,SAASC,iBAAiB,QAAQ,+BAA+B;AACjE,SAASC,GAAG,QAAQ,sBAAsB;AAC1C,SAASC,UAAU,QAAQ,0BAA0B;AACrD,SAASC,WAAW,QAAQ,uCAAuC;AACnE,SAASC,OAAO,QAAQ,+BAA+B;AACvD;AACA;AACA;AACA,OAAO,MAAMC,mBAAmB,CAAC;EAC7B;AACJ;AACA;AACA;EACI,IAAIC,wBAAwBA,CAAA,EAAG;IAC3B,OAAO,IAAI,CAACC,wBAAwB;EACxC;EACA,IAAID,wBAAwBA,CAACA,wBAAwB,EAAE;IACnD,IAAI,CAACC,wBAAwB,GAAGD,wBAAwB;EAC5D;EACA;AACJ;AACA;EACI,IAAIE,OAAOA,CAACC,KAAK,EAAE;IACf,IAAIA,KAAK,IAAI,IAAI,CAACC,QAAQ,EAAE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