@babylonjs/core 6.48.0 → 6.49.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (62) hide show
  1. package/Behaviors/Meshes/baseSixDofDragBehavior.js +6 -6
  2. package/Behaviors/Meshes/baseSixDofDragBehavior.js.map +1 -1
  3. package/Behaviors/Meshes/sixDofDragBehavior.d.ts +1 -0
  4. package/Behaviors/Meshes/sixDofDragBehavior.js +5 -1
  5. package/Behaviors/Meshes/sixDofDragBehavior.js.map +1 -1
  6. package/Engines/ICanvas.d.ts +10 -0
  7. package/Engines/ICanvas.js.map +1 -1
  8. package/Engines/Native/nativeDataStream.d.ts +2 -1
  9. package/Engines/Native/nativeDataStream.js.map +1 -1
  10. package/Engines/Native/nativePipelineContext.js.map +1 -1
  11. package/Engines/WebGL/webGLPipelineContext.js.map +1 -1
  12. package/Engines/WebGPU/webgpuShaderProcessorsWGSL.js +6 -4
  13. package/Engines/WebGPU/webgpuShaderProcessorsWGSL.js.map +1 -1
  14. package/Engines/nativeEngine.d.ts +2 -2
  15. package/Engines/nativeEngine.js.map +1 -1
  16. package/Engines/thinEngine.d.ts +2 -2
  17. package/Engines/thinEngine.js +2 -2
  18. package/Engines/thinEngine.js.map +1 -1
  19. package/Materials/PBR/pbrSubSurfaceConfiguration.js +6 -0
  20. package/Materials/PBR/pbrSubSurfaceConfiguration.js.map +1 -1
  21. package/Maths/math.like.d.ts +2 -2
  22. package/Maths/math.like.js.map +1 -1
  23. package/Maths/math.vector.d.ts +1 -1
  24. package/Maths/math.vector.js.map +1 -1
  25. package/Maths/tensor.d.ts +12 -8
  26. package/Maths/tensor.js.map +1 -1
  27. package/Meshes/Compression/dracoCompression.d.ts +12 -0
  28. package/Meshes/Compression/dracoCompression.js +20 -14
  29. package/Meshes/Compression/dracoCompression.js.map +1 -1
  30. package/Meshes/Node/Blocks/geometryDistanceBlock.js +1 -0
  31. package/Meshes/Node/Blocks/geometryDistanceBlock.js.map +1 -1
  32. package/Meshes/Node/Blocks/geometryDotBlock.js +1 -0
  33. package/Meshes/Node/Blocks/geometryDotBlock.js.map +1 -1
  34. package/Meshes/Node/Blocks/geometryLengthBlock.js +1 -0
  35. package/Meshes/Node/Blocks/geometryLengthBlock.js.map +1 -1
  36. package/Meshes/Node/Blocks/geometryTrigonometryBlock.js +1 -0
  37. package/Meshes/Node/Blocks/geometryTrigonometryBlock.js.map +1 -1
  38. package/Meshes/abstractMesh.d.ts +5 -2
  39. package/Meshes/abstractMesh.js +5 -2
  40. package/Meshes/abstractMesh.js.map +1 -1
  41. package/Meshes/thinInstanceMesh.d.ts +9 -0
  42. package/Meshes/thinInstanceMesh.js +31 -4
  43. package/Meshes/thinInstanceMesh.js.map +1 -1
  44. package/Particles/pointsCloudSystem.js +26 -29
  45. package/Particles/pointsCloudSystem.js.map +1 -1
  46. package/Rendering/GlobalIllumination/giRSMManager.d.ts +1 -1
  47. package/Rendering/GlobalIllumination/giRSMManager.js +1 -1
  48. package/Rendering/GlobalIllumination/giRSMManager.js.map +1 -1
  49. package/Rendering/reflectiveShadowMap.d.ts +5 -4
  50. package/Rendering/reflectiveShadowMap.js +1 -1
  51. package/Rendering/reflectiveShadowMap.js.map +1 -1
  52. package/Shaders/ShadersInclude/pbrDebug.js +1 -1
  53. package/Shaders/ShadersInclude/pbrDebug.js.map +1 -1
  54. package/Shaders/pbr.vertex.js +1 -1
  55. package/Shaders/pbr.vertex.js.map +1 -1
  56. package/XR/features/WebXRControllerPointerSelection.js +11 -0
  57. package/XR/features/WebXRControllerPointerSelection.js.map +1 -1
  58. package/assets/Basis/basis_transcoder.wasm +0 -0
  59. package/assets/Draco/draco_decoder_gltf.wasm +0 -0
  60. package/package.json +2 -1
  61. package/types.d.ts +1 -1
  62. package/types.js.map +1 -1
@@ -224,7 +224,7 @@ export class BaseSixDofDragBehavior {
224
224
  this._virtualMeshesInfo[pointerId] = this._createVirtualMeshInfo();
225
225
  }
226
226
  const virtualMeshesInfo = this._virtualMeshesInfo[pointerId];
227
- const isXRNearPointer = pointerInfo.event.pointerType === "xr-near";
227
+ const isXRPointer = pointerInfo.event.pointerType === "xr-near" || pointerInfo.event.pointerType === "xr";
228
228
  if (pointerInfo.type == PointerEventTypes.POINTERDOWN) {
229
229
  if (!virtualMeshesInfo.dragging &&
230
230
  pointerInfo.pickInfo &&
@@ -232,9 +232,9 @@ export class BaseSixDofDragBehavior {
232
232
  pointerInfo.pickInfo.pickedMesh &&
233
233
  pointerInfo.pickInfo.pickedPoint &&
234
234
  pointerInfo.pickInfo.ray &&
235
- (!isXRNearPointer || pointerInfo.pickInfo.aimTransform) &&
235
+ (!isXRPointer || pointerInfo.pickInfo.aimTransform) &&
236
236
  pickPredicate(pointerInfo.pickInfo.pickedMesh)) {
237
- if (!this.allowMultiPointer && this.currentDraggingPointerIds.length > 0) {
237
+ if ((!this.allowMultiPointer || isXRPointer) && this.currentDraggingPointerIds.length > 0) {
238
238
  return;
239
239
  }
240
240
  if (this._pointerCamera &&
@@ -245,7 +245,7 @@ export class BaseSixDofDragBehavior {
245
245
  }
246
246
  this._ownerNode.computeWorldMatrix(true);
247
247
  const virtualMeshesInfo = this._virtualMeshesInfo[pointerId];
248
- if (isXRNearPointer) {
248
+ if (isXRPointer) {
249
249
  this._dragging = pointerInfo.pickInfo.originMesh ? this._dragType.NEAR_DRAG : this._dragType.DRAG_WITH_CONTROLLER;
250
250
  virtualMeshesInfo.originMesh.position.copyFrom(pointerInfo.pickInfo.aimTransform.position);
251
251
  if (this._dragging === this._dragType.NEAR_DRAG && pointerInfo.pickInfo.gripTransform) {
@@ -268,7 +268,7 @@ export class BaseSixDofDragBehavior {
268
268
  virtualMeshesInfo.startingPivotPosition.copyFrom(virtualMeshesInfo.pivotMesh.position);
269
269
  virtualMeshesInfo.startingOrientation.copyFrom(virtualMeshesInfo.dragMesh.rotationQuaternion);
270
270
  virtualMeshesInfo.startingPivotOrientation.copyFrom(virtualMeshesInfo.pivotMesh.rotationQuaternion);
271
- if (isXRNearPointer) {
271
+ if (isXRPointer) {
272
272
  virtualMeshesInfo.originMesh.addChild(virtualMeshesInfo.dragMesh);
273
273
  virtualMeshesInfo.originMesh.addChild(virtualMeshesInfo.pivotMesh);
274
274
  }
@@ -325,7 +325,7 @@ export class BaseSixDofDragBehavior {
325
325
  zDragFactor = 0;
326
326
  }
327
327
  this._ownerNode.computeWorldMatrix(true);
328
- if (!isXRNearPointer) {
328
+ if (!isXRPointer) {
329
329
  this._pointerUpdate2D(pointerInfo.pickInfo.ray, pointerId, zDragFactor);
330
330
  }
331
331
  else {
@@ -1 +1 @@
1
- {"version":3,"file":"baseSixDofDragBehavior.js","sourceRoot":"","sources":["../../../../../dev/core/src/Behaviors/Meshes/baseSixDofDragBehavior.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,YAAY,EAAE,MAAM,2BAA2B,CAAC;AACzD,OAAO,EAAE,KAAK,EAAE,MAAM,aAAa,CAAC;AAGpC,OAAO,EAAE,iBAAiB,EAAE,MAAM,4BAA4B,CAAC;AAC/D,OAAO,EAAE,OAAO,EAAE,UAAU,EAAE,UAAU,EAAE,MAAM,yBAAyB,CAAC;AAE1E,OAAO,EAAE,UAAU,EAAE,MAAM,uBAAuB,CAAC;AAGnD,OAAO,EAAE,MAAM,EAAE,MAAM,sBAAsB,CAAC;AAsB9C;;;;GAIG;AACH,MAAM,OAAO,sBAAsB;IAAnC;QAGY,uBAAkB,GAAY,KAAK,CAAC;QAClC,uBAAkB,GAExB,EAAE,CAAC;QAEC,eAAU,GAAY,IAAI,OAAO,EAAE,CAAC;QACpC,mBAAc,GAAe,IAAI,UAAU,EAAE,CAAC;QAE5C,cAAS,GAAG;YAClB,IAAI,EAAE,CAAC;YACP,IAAI,EAAE,CAAC;YACP,oBAAoB,EAAE,CAAC;YACvB,SAAS,EAAE,CAAC;SACf,CAAC;QAGQ,YAAO,GAAG,KAAK,CAAC;QAEhB,cAAS,GAAG,IAAI,CAAC,SAAS,CAAC,IAAI,CAA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I,CAAC,CAAC;aACtH;SACJ;IACL,CAAC;IAED;;OAEG;IACI,MAAM;QACT,IAAI,IAAI,CAAC,MAAM,EAAE;YACb,IAAI,IAAI,CAAC,oBAAoB,IAAI,IAAI,CAAC,kBAAkB,IAAI,IAAI,CAAC,cAAc,IAAI,CAAC,IAAI,CAAC,cAAc,CAAC,UAAU,EAAE;gBAChH,IAAI,CAAC,uBAAuB,EAAE,CAAC;gBAC/B,IAAI,CAAC,kBAAkB,GAAG,KAAK,CAAC;aACnC;YACD,IAAI,CAAC,MAAM,CAAC,mBAAmB,CAAC,MAAM,CAAC,IAAI,CAAC,gBAAgB,CAAC,CAAC;SACjE;QAED,KAAK,MAAM,SAAS,IAAI,IAAI,CAAC,kBAAkB,EAAE;YAC7C,IAAI,CAAC,kBAAkB,CAAC,SAAS,CAAC,CAAC,UAAU,CAAC,OAAO,EAAE,CAAC;YACxD,IAAI,CAAC,kBAAkB,CAAC,SAAS,CAAC,CAAC,QAAQ,CAAC,OAAO,EAAE,CAAC;SACzD;QAED,IAAI,CAAC,mBAAmB,CAAC,KAAK,EAAE,CAAC;QACjC,IAAI,CAAC,gBAAgB,CAAC,KAAK,EAAE,CAAC;QAC9B,IAAI,CAAC,qBAAqB,CAAC,KAAK,EAAE,CAAC;IACvC,CAAC;CACJ","sourcesContent":["/* eslint-disable @typescript-eslint/naming-convention */\r\n/* eslint-disable @typescript-eslint/no-unused-vars */\r\nimport type { Behavior } from \"../../Behaviors/behavior\";\r\nimport type { Mesh } from \"../../Meshes/mesh\";\r\nimport { AbstractMesh } from \"../../Meshes/abstractMesh\";\r\nimport { Scene } from \"../../scene\";\r\nimport type { Nullable } from \"../../types\";\r\nimport type { PointerInfo } from \"../../Events/pointerEvents\";\r\nimport { PointerEventTypes } from \"../../Events/pointerEvents\";\r\nimport { Vector3, Quaternion, TmpVectors } from \"../../Maths/math.vector\";\r\nimport type { Observer } from \"../../Misc/observable\";\r\nimport { Observable } from \"../../Misc/observable\";\r\nimport type { TransformNode } from \"../../Meshes/transformNode\";\r\nimport type { PickingInfo } from \"../../Collisions/pickingInfo\";\r\nimport { Camera } from \"../../Cameras/camera\";\r\nimport type { Ray } from \"../../Culling/ray\";\r\nimport type { IPointerEvent } from \"../../Events/deviceInputEvents\";\r\nimport type { ArcRotateCamera } from \"../../Cameras/arcRotateCamera\";\r\n\r\n/**\r\n * Data store to track virtual pointers movement\r\n */\r\ntype VirtualMeshInfo = {\r\n dragging: boolean;\r\n moving: boolean;\r\n dragMesh: AbstractMesh;\r\n originMesh: AbstractMesh;\r\n pivotMesh: AbstractMesh;\r\n startingPivotPosition: Vector3;\r\n startingPivotOrientation: Quaternion;\r\n startingPosition: Vector3;\r\n startingOrientation: Quaternion;\r\n lastOriginPosition: Vector3;\r\n lastDragPosition: Vector3;\r\n};\r\n\r\n/**\r\n * Base behavior for six degrees of freedom interactions in XR experiences.\r\n * Creates virtual meshes that are dragged around\r\n * And observables for position/rotation changes\r\n */\r\nexport class BaseSixDofDragBehavior implements Behavior<Mesh> {\r\n protected static _virtualScene: Scene;\r\n private _pointerObserver: Nullable<Observer<PointerInfo>>;\r\n private _attachedToElement: boolean = false;\r\n protected _virtualMeshesInfo: {\r\n [id: number]: VirtualMeshInfo;\r\n } = {};\r\n\r\n private _tmpVector: Vector3 = new Vector3();\r\n private _tmpQuaternion: Quaternion = new Quaternion();\r\n\r\n protected _dragType = {\r\n NONE: 0,\r\n DRAG: 1,\r\n DRAG_WITH_CONTROLLER: 2,\r\n NEAR_DRAG: 3,\r\n };\r\n\r\n protected _scene: Scene;\r\n protected _moving = false;\r\n protected _ownerNode: TransformNode;\r\n protected _dragging = this._dragType.NONE;\r\n\r\n /**\r\n * The list of child meshes that can receive drag events\r\n * If `null`, all child meshes will receive drag event\r\n */\r\n public draggableMeshes: Nullable<AbstractMesh[]> = null;\r\n\r\n /**\r\n * How much faster the object should move when the controller is moving towards it. This is useful to bring objects that are far away from the user to them faster. Set this to 0 to avoid any speed increase. (Default: 3)\r\n */\r\n public zDragFactor = 3;\r\n /**\r\n * The id of the pointer that is currently interacting with the behavior (-1 when no pointer is active)\r\n */\r\n public get currentDraggingPointerId() {\r\n if (this.currentDraggingPointerIds[0] !== undefined) {\r\n return this.currentDraggingPointerIds[0];\r\n }\r\n return -1;\r\n }\r\n\r\n public set currentDraggingPointerId(value: number) {\r\n this.currentDraggingPointerIds[0] = value;\r\n }\r\n\r\n /**\r\n * In case of multipointer interaction, all pointer ids currently active are stored here\r\n */\r\n public currentDraggingPointerIds: number[] = [];\r\n\r\n /**\r\n * Get or set the currentDraggingPointerId\r\n * @deprecated Please use currentDraggingPointerId instead\r\n */\r\n public get currentDraggingPointerID(): number {\r\n return this.currentDraggingPointerId;\r\n }\r\n public set currentDraggingPointerID(currentDraggingPointerID: number) {\r\n this.currentDraggingPointerId = currentDraggingPointerID;\r\n }\r\n /**\r\n /**\r\n * If camera controls should be detached during the drag\r\n */\r\n public detachCameraControls = true;\r\n\r\n /**\r\n * Fires each time a drag starts\r\n */\r\n public onDragStartObservable = new Observable<{ position: Vector3 }>();\r\n /**\r\n * Fires each time a drag happens\r\n */\r\n public onDragObservable = new Observable<{ delta: Vector3; position: Vector3; pickInfo: PickingInfo }>();\r\n /**\r\n * Fires each time a drag ends (eg. mouse release after drag)\r\n */\r\n public onDragEndObservable = new Observable<{}>();\r\n\r\n /**\r\n * Should the behavior allow simultaneous pointers to interact with the owner node.\r\n */\r\n public allowMultiPointer: boolean = true;\r\n\r\n /**\r\n * The name of the behavior\r\n */\r\n public get name(): string {\r\n return \"BaseSixDofDrag\";\r\n }\r\n\r\n /**\r\n * Returns true if the attached mesh is currently moving with this behavior\r\n */\r\n public get isMoving(): boolean {\r\n return this._moving;\r\n }\r\n\r\n /**\r\n * Initializes the behavior\r\n */\r\n public init() {}\r\n\r\n /**\r\n * In the case of multiple active cameras, the cameraToUseForPointers should be used if set instead of active camera\r\n */\r\n private get _pointerCamera() {\r\n if (this._scene.cameraToUseForPointers) {\r\n return this._scene.cameraToUseForPointers;\r\n } else {\r\n return this._scene.activeCamera;\r\n }\r\n }\r\n\r\n private _createVirtualMeshInfo() {\r\n // Setup virtual meshes to be used for dragging without dirtying the existing scene\r\n\r\n const dragMesh = new AbstractMesh(\"\", BaseSixDofDragBehavior._virtualScene);\r\n dragMesh.rotationQuaternion = new Quaternion();\r\n const originMesh = new AbstractMesh(\"\", BaseSixDofDragBehavior._virtualScene);\r\n originMesh.rotationQuaternion = new Quaternion();\r\n const pivotMesh = new AbstractMesh(\"\", BaseSixDofDragBehavior._virtualScene);\r\n pivotMesh.rotationQuaternion = new Quaternion();\r\n\r\n return {\r\n dragging: false,\r\n moving: false,\r\n dragMesh,\r\n originMesh,\r\n pivotMesh,\r\n startingPivotPosition: new Vector3(),\r\n startingPivotOrientation: new Quaternion(),\r\n startingPosition: new Vector3(),\r\n startingOrientation: new Quaternion(),\r\n lastOriginPosition: new Vector3(),\r\n lastDragPosition: new Vector3(),\r\n };\r\n }\r\n\r\n protected _resetVirtualMeshesPosition() {\r\n for (let i = 0; i < this.currentDraggingPointerIds.length; i++) {\r\n this._virtualMeshesInfo[this.currentDraggingPointerIds[i]].pivotMesh.position.copyFrom(this._ownerNode.getAbsolutePivotPoint());\r\n this._virtualMeshesInfo[this.currentDraggingPointerIds[i]].pivotMesh.rotationQuaternion!.copyFrom(this._ownerNode.rotationQuaternion!);\r\n this._virtualMeshesInfo[this.currentDraggingPointerIds[i]].startingPivotPosition.copyFrom(\r\n this._virtualMeshesInfo[this.currentDraggingPointerIds[i]].pivotMesh.position\r\n );\r\n this._virtualMeshesInfo[this.currentDraggingPointerIds[i]].startingPivotOrientation.copyFrom(\r\n this._virtualMeshesInfo[this.currentDraggingPointerIds[i]].pivotMesh.rotationQuaternion!\r\n );\r\n this._virtualMeshesInfo[this.currentDraggingPointerIds[i]].startingPosition.copyFrom(this._virtualMeshesInfo[this.currentDraggingPointerIds[i]].dragMesh.position);\r\n this._virtualMeshesInfo[this.currentDraggingPointerIds[i]].startingOrientation.copyFrom(\r\n this._virtualMeshesInfo[this.currentDraggingPointerIds[i]].dragMesh.rotationQuaternion!\r\n );\r\n }\r\n }\r\n\r\n private _pointerUpdate2D(ray: Ray, pointerId: number, zDragFactor: number) {\r\n if (this._pointerCamera && this._pointerCamera.cameraRigMode == Camera.RIG_MODE_NONE && !this._pointerCamera._isLeftCamera && !this._pointerCamera._isRightCamera) {\r\n ray.origin.copyFrom(this._pointerCamera!.globalPosition);\r\n zDragFactor = 0;\r\n }\r\n\r\n const virtualMeshesInfo = this._virtualMeshesInfo[pointerId];\r\n\r\n // Calculate controller drag distance in controller space\r\n const originDragDifference = TmpVectors.Vector3[0];\r\n ray.origin.subtractToRef(virtualMeshesInfo.lastOriginPosition, originDragDifference);\r\n virtualMeshesInfo.lastOriginPosition.copyFrom(ray.origin);\r\n const localOriginDragDifference = -Vector3.Dot(originDragDifference, ray.direction);\r\n\r\n virtualMeshesInfo.originMesh.addChild(virtualMeshesInfo.dragMesh);\r\n virtualMeshesInfo.originMesh.addChild(virtualMeshesInfo.pivotMesh);\r\n\r\n this._applyZOffset(virtualMeshesInfo.dragMesh, localOriginDragDifference, zDragFactor);\r\n this._applyZOffset(virtualMeshesInfo.pivotMesh, localOriginDragDifference, zDragFactor);\r\n\r\n // Update the controller position\r\n virtualMeshesInfo.originMesh.position.copyFrom(ray.origin);\r\n const lookAt = TmpVectors.Vector3[0];\r\n ray.origin.addToRef(ray.direction, lookAt);\r\n virtualMeshesInfo.originMesh.lookAt(lookAt);\r\n\r\n virtualMeshesInfo.originMesh.removeChild(virtualMeshesInfo.dragMesh);\r\n virtualMeshesInfo.originMesh.removeChild(virtualMeshesInfo.pivotMesh);\r\n }\r\n\r\n private _pointerUpdateXR(controllerAimTransform: TransformNode, controllerGripTransform: Nullable<TransformNode>, pointerId: number, zDragFactor: number) {\r\n const virtualMeshesInfo = this._virtualMeshesInfo[pointerId];\r\n virtualMeshesInfo.originMesh.position.copyFrom(controllerAimTransform.position);\r\n if (this._dragging === this._dragType.NEAR_DRAG && controllerGripTransform) {\r\n virtualMeshesInfo.originMesh.rotationQuaternion!.copyFrom(controllerGripTransform.rotationQuaternion!);\r\n } else {\r\n virtualMeshesInfo.originMesh.rotationQuaternion!.copyFrom(controllerAimTransform.rotationQuaternion!);\r\n }\r\n\r\n virtualMeshesInfo.pivotMesh.computeWorldMatrix(true);\r\n virtualMeshesInfo.dragMesh.computeWorldMatrix(true);\r\n\r\n // Z scaling logic\r\n if (zDragFactor !== 0) {\r\n // Camera.getForwardRay modifies TmpVectors.Vector[0-3], so cache it in advance\r\n const cameraForwardVec = TmpVectors.Vector3[0];\r\n const originDragDirection = TmpVectors.Vector3[1];\r\n cameraForwardVec.copyFrom(this._pointerCamera!.getForwardRay().direction);\r\n virtualMeshesInfo.originMesh.position.subtractToRef(virtualMeshesInfo.lastOriginPosition, originDragDirection);\r\n virtualMeshesInfo.lastOriginPosition.copyFrom(virtualMeshesInfo.originMesh.position);\r\n const controllerDragDistance = originDragDirection.length();\r\n originDragDirection.normalize();\r\n\r\n const cameraToDrag = TmpVectors.Vector3[2];\r\n const controllerToDrag = TmpVectors.Vector3[3];\r\n virtualMeshesInfo.dragMesh.absolutePosition.subtractToRef(this._pointerCamera!.globalPosition, cameraToDrag);\r\n virtualMeshesInfo.dragMesh.absolutePosition.subtractToRef(virtualMeshesInfo.originMesh.position, controllerToDrag);\r\n const controllerToDragDistance = controllerToDrag.length();\r\n cameraToDrag.normalize();\r\n controllerToDrag.normalize();\r\n\r\n const controllerDragScaling = Math.abs(Vector3.Dot(originDragDirection, controllerToDrag)) * Vector3.Dot(originDragDirection, cameraForwardVec);\r\n let zOffsetScaling = controllerDragScaling * zDragFactor * controllerDragDistance * controllerToDragDistance;\r\n\r\n // Prevent pulling the mesh through the controller\r\n const minDistanceFromControllerToDragMesh = 0.01;\r\n if (zOffsetScaling < 0 && minDistanceFromControllerToDragMesh - controllerToDragDistance > zOffsetScaling) {\r\n zOffsetScaling = Math.min(minDistanceFromControllerToDragMesh - controllerToDragDistance, 0);\r\n }\r\n controllerToDrag.scaleInPlace(zOffsetScaling);\r\n\r\n controllerToDrag.addToRef(virtualMeshesInfo.pivotMesh.absolutePosition, this._tmpVector);\r\n virtualMeshesInfo.pivotMesh.setAbsolutePosition(this._tmpVector);\r\n controllerToDrag.addToRef(virtualMeshesInfo.dragMesh.absolutePosition, this._tmpVector);\r\n virtualMeshesInfo.dragMesh.setAbsolutePosition(this._tmpVector);\r\n }\r\n }\r\n\r\n /**\r\n * Attaches the scale behavior the passed in mesh\r\n * @param ownerNode The mesh that will be scaled around once attached\r\n */\r\n public attach(ownerNode: TransformNode): void {\r\n this._ownerNode = ownerNode;\r\n this._scene = this._ownerNode.getScene();\r\n if (!BaseSixDofDragBehavior._virtualScene) {\r\n BaseSixDofDragBehavior._virtualScene = new Scene(this._scene.getEngine(), { virtual: true });\r\n BaseSixDofDragBehavior._virtualScene.detachControl();\r\n }\r\n\r\n const pickPredicate = (m: AbstractMesh) => {\r\n return this._ownerNode === m || (m.isDescendantOf(this._ownerNode) && (!this.draggableMeshes || this.draggableMeshes.indexOf(m) !== -1));\r\n };\r\n\r\n this._pointerObserver = this._scene.onPointerObservable.add((pointerInfo) => {\r\n const pointerId = (<IPointerEvent>pointerInfo.event).pointerId;\r\n if (!this._virtualMeshesInfo[pointerId]) {\r\n this._virtualMeshesInfo[pointerId] = this._createVirtualMeshInfo();\r\n }\r\n const virtualMeshesInfo = this._virtualMeshesInfo[pointerId];\r\n const isXRNearPointer = (<IPointerEvent>pointerInfo.event).pointerType === \"xr-near\";\r\n\r\n if (pointerInfo.type == PointerEventTypes.POINTERDOWN) {\r\n if (\r\n !virtualMeshesInfo.dragging &&\r\n pointerInfo.pickInfo &&\r\n pointerInfo.pickInfo.hit &&\r\n pointerInfo.pickInfo.pickedMesh &&\r\n pointerInfo.pickInfo.pickedPoint &&\r\n pointerInfo.pickInfo.ray &&\r\n (!isXRNearPointer || pointerInfo.pickInfo.aimTransform) &&\r\n pickPredicate(pointerInfo.pickInfo.pickedMesh)\r\n ) {\r\n if (!this.allowMultiPointer && this.currentDraggingPointerIds.length > 0) {\r\n return;\r\n }\r\n\r\n if (\r\n this._pointerCamera &&\r\n this._pointerCamera.cameraRigMode === Camera.RIG_MODE_NONE &&\r\n !this._pointerCamera._isLeftCamera &&\r\n !this._pointerCamera._isRightCamera\r\n ) {\r\n pointerInfo.pickInfo.ray.origin.copyFrom(this._pointerCamera!.globalPosition);\r\n }\r\n\r\n this._ownerNode.computeWorldMatrix(true);\r\n const virtualMeshesInfo = this._virtualMeshesInfo[pointerId];\r\n\r\n if (isXRNearPointer) {\r\n this._dragging = pointerInfo.pickInfo.originMesh ? this._dragType.NEAR_DRAG : this._dragType.DRAG_WITH_CONTROLLER;\r\n virtualMeshesInfo.originMesh.position.copyFrom(pointerInfo.pickInfo.aimTransform!.position);\r\n if (this._dragging === this._dragType.NEAR_DRAG && pointerInfo.pickInfo.gripTransform) {\r\n virtualMeshesInfo.originMesh.rotationQuaternion!.copyFrom(pointerInfo.pickInfo.gripTransform.rotationQuaternion!);\r\n } else {\r\n virtualMeshesInfo.originMesh.rotationQuaternion!.copyFrom(pointerInfo.pickInfo.aimTransform!.rotationQuaternion!);\r\n }\r\n } else {\r\n this._dragging = this._dragType.DRAG;\r\n virtualMeshesInfo.originMesh.position.copyFrom(pointerInfo.pickInfo.ray.origin);\r\n }\r\n\r\n virtualMeshesInfo.lastOriginPosition.copyFrom(virtualMeshesInfo.originMesh.position);\r\n\r\n virtualMeshesInfo.dragMesh.position.copyFrom(pointerInfo.pickInfo.pickedPoint);\r\n virtualMeshesInfo.lastDragPosition.copyFrom(pointerInfo.pickInfo.pickedPoint);\r\n\r\n virtualMeshesInfo.pivotMesh.position.copyFrom(this._ownerNode.getAbsolutePivotPoint());\r\n virtualMeshesInfo.pivotMesh.rotationQuaternion!.copyFrom(this._ownerNode.absoluteRotationQuaternion);\r\n\r\n virtualMeshesInfo.startingPosition.copyFrom(virtualMeshesInfo.dragMesh.position);\r\n virtualMeshesInfo.startingPivotPosition.copyFrom(virtualMeshesInfo.pivotMesh.position);\r\n virtualMeshesInfo.startingOrientation.copyFrom(virtualMeshesInfo.dragMesh.rotationQuaternion!);\r\n virtualMeshesInfo.startingPivotOrientation.copyFrom(virtualMeshesInfo.pivotMesh.rotationQuaternion!);\r\n\r\n if (isXRNearPointer) {\r\n virtualMeshesInfo.originMesh.addChild(virtualMeshesInfo.dragMesh);\r\n virtualMeshesInfo.originMesh.addChild(virtualMeshesInfo.pivotMesh);\r\n } else {\r\n virtualMeshesInfo.originMesh.lookAt(virtualMeshesInfo.dragMesh.position);\r\n }\r\n\r\n // Update state\r\n virtualMeshesInfo.dragging = true;\r\n\r\n if (this.currentDraggingPointerIds.indexOf(pointerId) === -1) {\r\n this.currentDraggingPointerIds.push(pointerId);\r\n }\r\n\r\n // Detach camera controls\r\n if (this.detachCameraControls && this._pointerCamera && !this._pointerCamera.leftCamera) {\r\n if (this._pointerCamera.inputs && this._pointerCamera.inputs.attachedToElement) {\r\n this._pointerCamera.detachControl();\r\n this._attachedToElement = true;\r\n } else if (!this.allowMultiPointer || this.currentDraggingPointerIds.length === 0) {\r\n this._attachedToElement = false;\r\n }\r\n }\r\n\r\n this._targetDragStart(virtualMeshesInfo.pivotMesh.position, virtualMeshesInfo.pivotMesh.rotationQuaternion!, pointerId);\r\n this.onDragStartObservable.notifyObservers({ position: virtualMeshesInfo.pivotMesh.position });\r\n }\r\n } else if (pointerInfo.type == PointerEventTypes.POINTERUP || pointerInfo.type == PointerEventTypes.POINTERDOUBLETAP) {\r\n const registeredPointerIndex = this.currentDraggingPointerIds.indexOf(pointerId);\r\n\r\n // Update state\r\n virtualMeshesInfo.dragging = false;\r\n\r\n if (registeredPointerIndex !== -1) {\r\n this.currentDraggingPointerIds.splice(registeredPointerIndex, 1);\r\n if (this.currentDraggingPointerIds.length === 0) {\r\n this._moving = false;\r\n this._dragging = this._dragType.NONE;\r\n\r\n // Reattach camera controls\r\n if (this.detachCameraControls && this._attachedToElement && this._pointerCamera && !this._pointerCamera.leftCamera) {\r\n this._reattachCameraControls();\r\n this._attachedToElement = false;\r\n }\r\n }\r\n\r\n virtualMeshesInfo.originMesh.removeChild(virtualMeshesInfo.dragMesh);\r\n virtualMeshesInfo.originMesh.removeChild(virtualMeshesInfo.pivotMesh);\r\n this._targetDragEnd(pointerId);\r\n this.onDragEndObservable.notifyObservers({});\r\n }\r\n } else if (pointerInfo.type == PointerEventTypes.POINTERMOVE) {\r\n const registeredPointerIndex = this.currentDraggingPointerIds.indexOf(pointerId);\r\n\r\n if (registeredPointerIndex !== -1 && virtualMeshesInfo.dragging && pointerInfo.pickInfo && (pointerInfo.pickInfo.ray || pointerInfo.pickInfo.aimTransform)) {\r\n let zDragFactor = this.zDragFactor;\r\n\r\n // 2 pointer interaction should not have a z axis drag factor\r\n // as well as near interaction\r\n if (this.currentDraggingPointerIds.length > 1 || pointerInfo.pickInfo.originMesh) {\r\n zDragFactor = 0;\r\n }\r\n\r\n this._ownerNode.computeWorldMatrix(true);\r\n if (!isXRNearPointer) {\r\n this._pointerUpdate2D(pointerInfo.pickInfo.ray!, pointerId, zDragFactor);\r\n } else {\r\n this._pointerUpdateXR(pointerInfo.pickInfo.aimTransform!, pointerInfo.pickInfo.gripTransform, pointerId, zDragFactor);\r\n }\r\n\r\n // Get change in rotation\r\n this._tmpQuaternion.copyFrom(virtualMeshesInfo.startingPivotOrientation);\r\n this._tmpQuaternion.x = -this._tmpQuaternion.x;\r\n this._tmpQuaternion.y = -this._tmpQuaternion.y;\r\n this._tmpQuaternion.z = -this._tmpQuaternion.z;\r\n virtualMeshesInfo.pivotMesh.absoluteRotationQuaternion!.multiplyToRef(this._tmpQuaternion, this._tmpQuaternion);\r\n virtualMeshesInfo.pivotMesh.absolutePosition.subtractToRef(virtualMeshesInfo.startingPivotPosition, this._tmpVector);\r\n\r\n this.onDragObservable.notifyObservers({ delta: this._tmpVector, position: virtualMeshesInfo.pivotMesh.position, pickInfo: pointerInfo.pickInfo });\r\n\r\n // Notify herited methods and observables\r\n this._targetDrag(this._tmpVector, this._tmpQuaternion, pointerId);\r\n virtualMeshesInfo.lastDragPosition.copyFrom(virtualMeshesInfo.dragMesh.absolutePosition);\r\n\r\n this._moving = true;\r\n }\r\n }\r\n });\r\n }\r\n\r\n private _applyZOffset(node: TransformNode, localOriginDragDifference: number, zDragFactor: number) {\r\n // Determine how much the controller moved to/away towards the dragged object and use this to move the object further when its further away\r\n node.position.z -= node.position.z < 1 ? localOriginDragDifference * zDragFactor : localOriginDragDifference * zDragFactor * node.position.z;\r\n if (node.position.z < 0) {\r\n node.position.z = 0;\r\n }\r\n }\r\n\r\n // eslint-disable-next-line @typescript-eslint/no-unused-vars\r\n protected _targetDragStart(worldPosition: Vector3, worldRotation: Quaternion, pointerId: number) {\r\n // Herited classes can override that\r\n }\r\n\r\n protected _targetDrag(worldDeltaPosition: Vector3, worldDeltaRotation: Quaternion, pointerId: number) {\r\n // Herited classes can override that\r\n }\r\n\r\n protected _targetDragEnd(pointerId: number) {\r\n // Herited classes can override that\r\n }\r\n\r\n protected _reattachCameraControls() {\r\n if (this._pointerCamera) {\r\n // If the camera is an ArcRotateCamera, preserve the settings from the camera\r\n // when reattaching control\r\n if (this._pointerCamera.getClassName() === \"ArcRotateCamera\") {\r\n const arcRotateCamera = this._pointerCamera as ArcRotateCamera;\r\n arcRotateCamera.attachControl(\r\n arcRotateCamera.inputs ? arcRotateCamera.inputs.noPreventDefault : true,\r\n arcRotateCamera._useCtrlForPanning,\r\n arcRotateCamera._panningMouseButton\r\n );\r\n } else {\r\n // preserve the settings from the camera when reattaching control\r\n this._pointerCamera.attachControl(this._pointerCamera.inputs ? this._pointerCamera.inputs.noPreventDefault : true);\r\n }\r\n }\r\n }\r\n\r\n /**\r\n * Detaches the behavior from the mesh\r\n */\r\n public detach(): void {\r\n if (this._scene) {\r\n if (this.detachCameraControls && this._attachedToElement && this._pointerCamera && !this._pointerCamera.leftCamera) {\r\n this._reattachCameraControls();\r\n this._attachedToElement = false;\r\n }\r\n this._scene.onPointerObservable.remove(this._pointerObserver);\r\n }\r\n\r\n for (const pointerId in this._virtualMeshesInfo) {\r\n this._virtualMeshesInfo[pointerId].originMesh.dispose();\r\n this._virtualMeshesInfo[pointerId].dragMesh.dispose();\r\n }\r\n\r\n this.onDragEndObservable.clear();\r\n this.onDragObservable.clear();\r\n this.onDragStartObservable.clear();\r\n }\r\n}\r\n"]}
1
+ {"version":3,"file":"baseSixDofDragBehavior.js","sourceRoot":"","sources":["../../../../../dev/core/src/Behaviors/Meshes/baseSixDofDragBehavior.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,YAAY,EAAE,MAAM,2BAA2B,CAAC;AACzD,OAAO,EAAE,KAAK,EAAE,MAAM,aAAa,CAAC;AAGpC,OAAO,EAAE,iBAAiB,EAAE,MAAM,4BAA4B,CAAC;AAC/D,OAAO,EAAE,OAAO,EAAE,UAAU,EAAE,UAAU,EAAE,MAAM,yBAAyB,CAAC;AAE1E,OAAO,EAAE,UAAU,EAAE,MAAM,uBAAuB,CAAC;AAGnD,OAAO,EAAE,MAAM,EAAE,MAAM,sBAAsB,CAAC;AAsB9C;;;;GAIG;AACH,MAAM,OAAO,sBAAsB;IAAnC;QAGY,uBAAkB,GAAY,KAAK,CAAC;QAClC,uBAAkB,GAExB,EAAE,CAAC;QAEC,eAAU,GAAY,IAAI,OAAO,EAAE,CAAC;QACpC,mBAAc,GAAe,IAAI,UAAU,EAAE,CAAC;QAE5C,cAAS,GAAG;YAClB,IAAI,EAAE,CAAC;YACP,IAAI,EAAE,CAAC;YACP,oBAAoB,EAAE,CAAC;YACvB,SAAS,EAAE,CAAC;SACf,CAAC;QAGQ,YAAO,GAAG,KAAK,CAAC;QAEhB,cAAS,GAAG,IAAI,CAAC,SAAS,CAAC,IAAI,CAAC;QAE1C;;;WAGG;QACI,oBAAe,GAA6B,IAAI,CAAC;QAExD;;WAEG;QACI,gBAAW,GAAG,CAAC,CAAC;QAevB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IACL,CAAC;IAED;;OAEG;IACI,MAAM;QACT,IAAI,IAAI,CAAC,MAAM,EAAE;YACb,IAAI,IAAI,CAAC,oBAAoB,IAAI,IAAI,CAAC,kBAAkB,IAAI,IAAI,CAAC,cAAc,IAAI,CAAC,IAAI,CAAC,cAAc,CAAC,UAAU,EAAE;gBAChH,IAAI,CAAC,uBAAuB,EAAE,CAAC;gBAC/B,IAAI,CAAC,kBAAkB,GAAG,KAAK,CAAC;aACnC;YACD,IAAI,CAAC,MAAM,CAAC,mBAAmB,CAAC,MAAM,CAAC,IAAI,CAAC,gBAAgB,CAAC,CAAC;SACjE;QAED,KAAK,MAAM,SAAS,IAAI,IAAI,CAAC,kBAAkB,EAAE;YAC7C,IAAI,CAAC,kBAAkB,CAAC,SAAS,CAAC,CAAC,UAAU,CAAC,OAAO,EAAE,CAAC;YACxD,IAAI,CAAC,kBAAkB,CAAC,SAAS,CAAC,CAAC,QAAQ,CAAC,OAAO,EAAE,CAAC;SACzD;QAED,IAAI,CAAC,mBAAmB,CAAC,KAAK,EAAE,CAAC;QACjC,IAAI,CAAC,gBAAgB,CAAC,KAAK,EAAE,CAAC;QAC9B,IAAI,CAAC,qBAAqB,CAAC,KAAK,EAAE,CAAC;IACvC,CAAC;CACJ","sourcesContent":["/* eslint-disable @typescript-eslint/naming-convention */\r\n/* eslint-disable @typescript-eslint/no-unused-vars */\r\nimport type { Behavior } from \"../../Behaviors/behavior\";\r\nimport type { Mesh } from \"../../Meshes/mesh\";\r\nimport { AbstractMesh } from \"../../Meshes/abstractMesh\";\r\nimport { Scene } from \"../../scene\";\r\nimport type { Nullable } from \"../../types\";\r\nimport type { PointerInfo } from \"../../Events/pointerEvents\";\r\nimport { PointerEventTypes } from \"../../Events/pointerEvents\";\r\nimport { Vector3, Quaternion, TmpVectors } from \"../../Maths/math.vector\";\r\nimport type { Observer } from \"../../Misc/observable\";\r\nimport { Observable } from \"../../Misc/observable\";\r\nimport type { TransformNode } from \"../../Meshes/transformNode\";\r\nimport type { PickingInfo } from \"../../Collisions/pickingInfo\";\r\nimport { Camera } from \"../../Cameras/camera\";\r\nimport type { Ray } from \"../../Culling/ray\";\r\nimport type { IPointerEvent } from \"../../Events/deviceInputEvents\";\r\nimport type { ArcRotateCamera } from \"../../Cameras/arcRotateCamera\";\r\n\r\n/**\r\n * Data store to track virtual pointers movement\r\n */\r\ntype VirtualMeshInfo = {\r\n dragging: boolean;\r\n moving: boolean;\r\n dragMesh: AbstractMesh;\r\n originMesh: AbstractMesh;\r\n pivotMesh: AbstractMesh;\r\n startingPivotPosition: Vector3;\r\n startingPivotOrientation: Quaternion;\r\n startingPosition: Vector3;\r\n startingOrientation: Quaternion;\r\n lastOriginPosition: Vector3;\r\n lastDragPosition: Vector3;\r\n};\r\n\r\n/**\r\n * Base behavior for six degrees of freedom interactions in XR experiences.\r\n * Creates virtual meshes that are dragged around\r\n * And observables for position/rotation changes\r\n */\r\nexport class BaseSixDofDragBehavior implements Behavior<Mesh> {\r\n protected static _virtualScene: Scene;\r\n private _pointerObserver: Nullable<Observer<PointerInfo>>;\r\n private _attachedToElement: boolean = false;\r\n protected _virtualMeshesInfo: {\r\n [id: number]: VirtualMeshInfo;\r\n } = {};\r\n\r\n private _tmpVector: Vector3 = new Vector3();\r\n private _tmpQuaternion: Quaternion = new Quaternion();\r\n\r\n protected _dragType = {\r\n NONE: 0,\r\n DRAG: 1,\r\n DRAG_WITH_CONTROLLER: 2,\r\n NEAR_DRAG: 3,\r\n };\r\n\r\n protected _scene: Scene;\r\n protected _moving = false;\r\n protected _ownerNode: TransformNode;\r\n protected _dragging = this._dragType.NONE;\r\n\r\n /**\r\n * The list of child meshes that can receive drag events\r\n * If `null`, all child meshes will receive drag event\r\n */\r\n public draggableMeshes: Nullable<AbstractMesh[]> = null;\r\n\r\n /**\r\n * How much faster the object should move when the controller is moving towards it. This is useful to bring objects that are far away from the user to them faster. Set this to 0 to avoid any speed increase. (Default: 3)\r\n */\r\n public zDragFactor = 3;\r\n /**\r\n * The id of the pointer that is currently interacting with the behavior (-1 when no pointer is active)\r\n */\r\n public get currentDraggingPointerId() {\r\n if (this.currentDraggingPointerIds[0] !== undefined) {\r\n return this.currentDraggingPointerIds[0];\r\n }\r\n return -1;\r\n }\r\n\r\n public set currentDraggingPointerId(value: number) {\r\n this.currentDraggingPointerIds[0] = value;\r\n }\r\n\r\n /**\r\n * In case of multipointer interaction, all pointer ids currently active are stored here\r\n */\r\n public currentDraggingPointerIds: number[] = [];\r\n\r\n /**\r\n * Get or set the currentDraggingPointerId\r\n * @deprecated Please use currentDraggingPointerId instead\r\n */\r\n public get currentDraggingPointerID(): number {\r\n return this.currentDraggingPointerId;\r\n }\r\n public set currentDraggingPointerID(currentDraggingPointerID: number) {\r\n this.currentDraggingPointerId = currentDraggingPointerID;\r\n }\r\n /**\r\n /**\r\n * If camera controls should be detached during the drag\r\n */\r\n public detachCameraControls = true;\r\n\r\n /**\r\n * Fires each time a drag starts\r\n */\r\n public onDragStartObservable = new Observable<{ position: Vector3 }>();\r\n /**\r\n * Fires each time a drag happens\r\n */\r\n public onDragObservable = new Observable<{ delta: Vector3; position: Vector3; pickInfo: PickingInfo }>();\r\n /**\r\n * Fires each time a drag ends (eg. mouse release after drag)\r\n */\r\n public onDragEndObservable = new Observable<{}>();\r\n\r\n /**\r\n * Should the behavior allow simultaneous pointers to interact with the owner node.\r\n */\r\n public allowMultiPointer: boolean = true;\r\n\r\n /**\r\n * The name of the behavior\r\n */\r\n public get name(): string {\r\n return \"BaseSixDofDrag\";\r\n }\r\n\r\n /**\r\n * Returns true if the attached mesh is currently moving with this behavior\r\n */\r\n public get isMoving(): boolean {\r\n return this._moving;\r\n }\r\n\r\n /**\r\n * Initializes the behavior\r\n */\r\n public init() {}\r\n\r\n /**\r\n * In the case of multiple active cameras, the cameraToUseForPointers should be used if set instead of active camera\r\n */\r\n private get _pointerCamera() {\r\n if (this._scene.cameraToUseForPointers) {\r\n return this._scene.cameraToUseForPointers;\r\n } else {\r\n return this._scene.activeCamera;\r\n }\r\n }\r\n\r\n private _createVirtualMeshInfo() {\r\n // Setup virtual meshes to be used for dragging without dirtying the existing scene\r\n\r\n const dragMesh = new AbstractMesh(\"\", BaseSixDofDragBehavior._virtualScene);\r\n dragMesh.rotationQuaternion = new Quaternion();\r\n const originMesh = new AbstractMesh(\"\", BaseSixDofDragBehavior._virtualScene);\r\n originMesh.rotationQuaternion = new Quaternion();\r\n const pivotMesh = new AbstractMesh(\"\", BaseSixDofDragBehavior._virtualScene);\r\n pivotMesh.rotationQuaternion = new Quaternion();\r\n\r\n return {\r\n dragging: false,\r\n moving: false,\r\n dragMesh,\r\n originMesh,\r\n pivotMesh,\r\n startingPivotPosition: new Vector3(),\r\n startingPivotOrientation: new Quaternion(),\r\n startingPosition: new Vector3(),\r\n startingOrientation: new Quaternion(),\r\n lastOriginPosition: new Vector3(),\r\n lastDragPosition: new Vector3(),\r\n };\r\n }\r\n\r\n protected _resetVirtualMeshesPosition() {\r\n for (let i = 0; i < this.currentDraggingPointerIds.length; i++) {\r\n this._virtualMeshesInfo[this.currentDraggingPointerIds[i]].pivotMesh.position.copyFrom(this._ownerNode.getAbsolutePivotPoint());\r\n this._virtualMeshesInfo[this.currentDraggingPointerIds[i]].pivotMesh.rotationQuaternion!.copyFrom(this._ownerNode.rotationQuaternion!);\r\n this._virtualMeshesInfo[this.currentDraggingPointerIds[i]].startingPivotPosition.copyFrom(\r\n this._virtualMeshesInfo[this.currentDraggingPointerIds[i]].pivotMesh.position\r\n );\r\n this._virtualMeshesInfo[this.currentDraggingPointerIds[i]].startingPivotOrientation.copyFrom(\r\n this._virtualMeshesInfo[this.currentDraggingPointerIds[i]].pivotMesh.rotationQuaternion!\r\n );\r\n this._virtualMeshesInfo[this.currentDraggingPointerIds[i]].startingPosition.copyFrom(this._virtualMeshesInfo[this.currentDraggingPointerIds[i]].dragMesh.position);\r\n this._virtualMeshesInfo[this.currentDraggingPointerIds[i]].startingOrientation.copyFrom(\r\n this._virtualMeshesInfo[this.currentDraggingPointerIds[i]].dragMesh.rotationQuaternion!\r\n );\r\n }\r\n }\r\n\r\n private _pointerUpdate2D(ray: Ray, pointerId: number, zDragFactor: number) {\r\n if (this._pointerCamera && this._pointerCamera.cameraRigMode == Camera.RIG_MODE_NONE && !this._pointerCamera._isLeftCamera && !this._pointerCamera._isRightCamera) {\r\n ray.origin.copyFrom(this._pointerCamera!.globalPosition);\r\n zDragFactor = 0;\r\n }\r\n\r\n const virtualMeshesInfo = this._virtualMeshesInfo[pointerId];\r\n\r\n // Calculate controller drag distance in controller space\r\n const originDragDifference = TmpVectors.Vector3[0];\r\n ray.origin.subtractToRef(virtualMeshesInfo.lastOriginPosition, originDragDifference);\r\n virtualMeshesInfo.lastOriginPosition.copyFrom(ray.origin);\r\n const localOriginDragDifference = -Vector3.Dot(originDragDifference, ray.direction);\r\n\r\n virtualMeshesInfo.originMesh.addChild(virtualMeshesInfo.dragMesh);\r\n virtualMeshesInfo.originMesh.addChild(virtualMeshesInfo.pivotMesh);\r\n\r\n this._applyZOffset(virtualMeshesInfo.dragMesh, localOriginDragDifference, zDragFactor);\r\n this._applyZOffset(virtualMeshesInfo.pivotMesh, localOriginDragDifference, zDragFactor);\r\n\r\n // Update the controller position\r\n virtualMeshesInfo.originMesh.position.copyFrom(ray.origin);\r\n const lookAt = TmpVectors.Vector3[0];\r\n ray.origin.addToRef(ray.direction, lookAt);\r\n virtualMeshesInfo.originMesh.lookAt(lookAt);\r\n\r\n virtualMeshesInfo.originMesh.removeChild(virtualMeshesInfo.dragMesh);\r\n virtualMeshesInfo.originMesh.removeChild(virtualMeshesInfo.pivotMesh);\r\n }\r\n\r\n private _pointerUpdateXR(controllerAimTransform: TransformNode, controllerGripTransform: Nullable<TransformNode>, pointerId: number, zDragFactor: number) {\r\n const virtualMeshesInfo = this._virtualMeshesInfo[pointerId];\r\n virtualMeshesInfo.originMesh.position.copyFrom(controllerAimTransform.position);\r\n if (this._dragging === this._dragType.NEAR_DRAG && controllerGripTransform) {\r\n virtualMeshesInfo.originMesh.rotationQuaternion!.copyFrom(controllerGripTransform.rotationQuaternion!);\r\n } else {\r\n virtualMeshesInfo.originMesh.rotationQuaternion!.copyFrom(controllerAimTransform.rotationQuaternion!);\r\n }\r\n\r\n virtualMeshesInfo.pivotMesh.computeWorldMatrix(true);\r\n virtualMeshesInfo.dragMesh.computeWorldMatrix(true);\r\n\r\n // Z scaling logic\r\n if (zDragFactor !== 0) {\r\n // Camera.getForwardRay modifies TmpVectors.Vector[0-3], so cache it in advance\r\n const cameraForwardVec = TmpVectors.Vector3[0];\r\n const originDragDirection = TmpVectors.Vector3[1];\r\n cameraForwardVec.copyFrom(this._pointerCamera!.getForwardRay().direction);\r\n virtualMeshesInfo.originMesh.position.subtractToRef(virtualMeshesInfo.lastOriginPosition, originDragDirection);\r\n virtualMeshesInfo.lastOriginPosition.copyFrom(virtualMeshesInfo.originMesh.position);\r\n const controllerDragDistance = originDragDirection.length();\r\n originDragDirection.normalize();\r\n\r\n const cameraToDrag = TmpVectors.Vector3[2];\r\n const controllerToDrag = TmpVectors.Vector3[3];\r\n virtualMeshesInfo.dragMesh.absolutePosition.subtractToRef(this._pointerCamera!.globalPosition, cameraToDrag);\r\n virtualMeshesInfo.dragMesh.absolutePosition.subtractToRef(virtualMeshesInfo.originMesh.position, controllerToDrag);\r\n const controllerToDragDistance = controllerToDrag.length();\r\n cameraToDrag.normalize();\r\n controllerToDrag.normalize();\r\n\r\n const controllerDragScaling = Math.abs(Vector3.Dot(originDragDirection, controllerToDrag)) * Vector3.Dot(originDragDirection, cameraForwardVec);\r\n let zOffsetScaling = controllerDragScaling * zDragFactor * controllerDragDistance * controllerToDragDistance;\r\n\r\n // Prevent pulling the mesh through the controller\r\n const minDistanceFromControllerToDragMesh = 0.01;\r\n if (zOffsetScaling < 0 && minDistanceFromControllerToDragMesh - controllerToDragDistance > zOffsetScaling) {\r\n zOffsetScaling = Math.min(minDistanceFromControllerToDragMesh - controllerToDragDistance, 0);\r\n }\r\n controllerToDrag.scaleInPlace(zOffsetScaling);\r\n\r\n controllerToDrag.addToRef(virtualMeshesInfo.pivotMesh.absolutePosition, this._tmpVector);\r\n virtualMeshesInfo.pivotMesh.setAbsolutePosition(this._tmpVector);\r\n controllerToDrag.addToRef(virtualMeshesInfo.dragMesh.absolutePosition, this._tmpVector);\r\n virtualMeshesInfo.dragMesh.setAbsolutePosition(this._tmpVector);\r\n }\r\n }\r\n\r\n /**\r\n * Attaches the scale behavior the passed in mesh\r\n * @param ownerNode The mesh that will be scaled around once attached\r\n */\r\n public attach(ownerNode: TransformNode): void {\r\n this._ownerNode = ownerNode;\r\n this._scene = this._ownerNode.getScene();\r\n if (!BaseSixDofDragBehavior._virtualScene) {\r\n BaseSixDofDragBehavior._virtualScene = new Scene(this._scene.getEngine(), { virtual: true });\r\n BaseSixDofDragBehavior._virtualScene.detachControl();\r\n }\r\n\r\n const pickPredicate = (m: AbstractMesh) => {\r\n return this._ownerNode === m || (m.isDescendantOf(this._ownerNode) && (!this.draggableMeshes || this.draggableMeshes.indexOf(m) !== -1));\r\n };\r\n\r\n this._pointerObserver = this._scene.onPointerObservable.add((pointerInfo) => {\r\n const pointerId = (<IPointerEvent>pointerInfo.event).pointerId;\r\n if (!this._virtualMeshesInfo[pointerId]) {\r\n this._virtualMeshesInfo[pointerId] = this._createVirtualMeshInfo();\r\n }\r\n const virtualMeshesInfo = this._virtualMeshesInfo[pointerId];\r\n const isXRPointer = (<IPointerEvent>pointerInfo.event).pointerType === \"xr-near\" || (<IPointerEvent>pointerInfo.event).pointerType === \"xr\";\r\n\r\n if (pointerInfo.type == PointerEventTypes.POINTERDOWN) {\r\n if (\r\n !virtualMeshesInfo.dragging &&\r\n pointerInfo.pickInfo &&\r\n pointerInfo.pickInfo.hit &&\r\n pointerInfo.pickInfo.pickedMesh &&\r\n pointerInfo.pickInfo.pickedPoint &&\r\n pointerInfo.pickInfo.ray &&\r\n (!isXRPointer || pointerInfo.pickInfo.aimTransform) &&\r\n pickPredicate(pointerInfo.pickInfo.pickedMesh)\r\n ) {\r\n if ((!this.allowMultiPointer || isXRPointer) && this.currentDraggingPointerIds.length > 0) {\r\n return;\r\n }\r\n\r\n if (\r\n this._pointerCamera &&\r\n this._pointerCamera.cameraRigMode === Camera.RIG_MODE_NONE &&\r\n !this._pointerCamera._isLeftCamera &&\r\n !this._pointerCamera._isRightCamera\r\n ) {\r\n pointerInfo.pickInfo.ray.origin.copyFrom(this._pointerCamera!.globalPosition);\r\n }\r\n\r\n this._ownerNode.computeWorldMatrix(true);\r\n const virtualMeshesInfo = this._virtualMeshesInfo[pointerId];\r\n\r\n if (isXRPointer) {\r\n this._dragging = pointerInfo.pickInfo.originMesh ? this._dragType.NEAR_DRAG : this._dragType.DRAG_WITH_CONTROLLER;\r\n virtualMeshesInfo.originMesh.position.copyFrom(pointerInfo.pickInfo.aimTransform!.position);\r\n if (this._dragging === this._dragType.NEAR_DRAG && pointerInfo.pickInfo.gripTransform) {\r\n virtualMeshesInfo.originMesh.rotationQuaternion!.copyFrom(pointerInfo.pickInfo.gripTransform.rotationQuaternion!);\r\n } else {\r\n virtualMeshesInfo.originMesh.rotationQuaternion!.copyFrom(pointerInfo.pickInfo.aimTransform!.rotationQuaternion!);\r\n }\r\n } else {\r\n this._dragging = this._dragType.DRAG;\r\n virtualMeshesInfo.originMesh.position.copyFrom(pointerInfo.pickInfo.ray.origin);\r\n }\r\n\r\n virtualMeshesInfo.lastOriginPosition.copyFrom(virtualMeshesInfo.originMesh.position);\r\n\r\n virtualMeshesInfo.dragMesh.position.copyFrom(pointerInfo.pickInfo.pickedPoint);\r\n virtualMeshesInfo.lastDragPosition.copyFrom(pointerInfo.pickInfo.pickedPoint);\r\n\r\n virtualMeshesInfo.pivotMesh.position.copyFrom(this._ownerNode.getAbsolutePivotPoint());\r\n virtualMeshesInfo.pivotMesh.rotationQuaternion!.copyFrom(this._ownerNode.absoluteRotationQuaternion);\r\n\r\n virtualMeshesInfo.startingPosition.copyFrom(virtualMeshesInfo.dragMesh.position);\r\n virtualMeshesInfo.startingPivotPosition.copyFrom(virtualMeshesInfo.pivotMesh.position);\r\n virtualMeshesInfo.startingOrientation.copyFrom(virtualMeshesInfo.dragMesh.rotationQuaternion!);\r\n virtualMeshesInfo.startingPivotOrientation.copyFrom(virtualMeshesInfo.pivotMesh.rotationQuaternion!);\r\n\r\n if (isXRPointer) {\r\n virtualMeshesInfo.originMesh.addChild(virtualMeshesInfo.dragMesh);\r\n virtualMeshesInfo.originMesh.addChild(virtualMeshesInfo.pivotMesh);\r\n } else {\r\n virtualMeshesInfo.originMesh.lookAt(virtualMeshesInfo.dragMesh.position);\r\n }\r\n\r\n // Update state\r\n virtualMeshesInfo.dragging = true;\r\n\r\n if (this.currentDraggingPointerIds.indexOf(pointerId) === -1) {\r\n this.currentDraggingPointerIds.push(pointerId);\r\n }\r\n\r\n // Detach camera controls\r\n if (this.detachCameraControls && this._pointerCamera && !this._pointerCamera.leftCamera) {\r\n if (this._pointerCamera.inputs && this._pointerCamera.inputs.attachedToElement) {\r\n this._pointerCamera.detachControl();\r\n this._attachedToElement = true;\r\n } else if (!this.allowMultiPointer || this.currentDraggingPointerIds.length === 0) {\r\n this._attachedToElement = false;\r\n }\r\n }\r\n\r\n this._targetDragStart(virtualMeshesInfo.pivotMesh.position, virtualMeshesInfo.pivotMesh.rotationQuaternion!, pointerId);\r\n this.onDragStartObservable.notifyObservers({ position: virtualMeshesInfo.pivotMesh.position });\r\n }\r\n } else if (pointerInfo.type == PointerEventTypes.POINTERUP || pointerInfo.type == PointerEventTypes.POINTERDOUBLETAP) {\r\n const registeredPointerIndex = this.currentDraggingPointerIds.indexOf(pointerId);\r\n\r\n // Update state\r\n virtualMeshesInfo.dragging = false;\r\n\r\n if (registeredPointerIndex !== -1) {\r\n this.currentDraggingPointerIds.splice(registeredPointerIndex, 1);\r\n if (this.currentDraggingPointerIds.length === 0) {\r\n this._moving = false;\r\n this._dragging = this._dragType.NONE;\r\n\r\n // Reattach camera controls\r\n if (this.detachCameraControls && this._attachedToElement && this._pointerCamera && !this._pointerCamera.leftCamera) {\r\n this._reattachCameraControls();\r\n this._attachedToElement = false;\r\n }\r\n }\r\n\r\n virtualMeshesInfo.originMesh.removeChild(virtualMeshesInfo.dragMesh);\r\n virtualMeshesInfo.originMesh.removeChild(virtualMeshesInfo.pivotMesh);\r\n this._targetDragEnd(pointerId);\r\n this.onDragEndObservable.notifyObservers({});\r\n }\r\n } else if (pointerInfo.type == PointerEventTypes.POINTERMOVE) {\r\n const registeredPointerIndex = this.currentDraggingPointerIds.indexOf(pointerId);\r\n\r\n if (registeredPointerIndex !== -1 && virtualMeshesInfo.dragging && pointerInfo.pickInfo && (pointerInfo.pickInfo.ray || pointerInfo.pickInfo.aimTransform)) {\r\n let zDragFactor = this.zDragFactor;\r\n\r\n // 2 pointer interaction should not have a z axis drag factor\r\n // as well as near interaction\r\n if (this.currentDraggingPointerIds.length > 1 || pointerInfo.pickInfo.originMesh) {\r\n zDragFactor = 0;\r\n }\r\n\r\n this._ownerNode.computeWorldMatrix(true);\r\n if (!isXRPointer) {\r\n this._pointerUpdate2D(pointerInfo.pickInfo.ray!, pointerId, zDragFactor);\r\n } else {\r\n this._pointerUpdateXR(pointerInfo.pickInfo.aimTransform!, pointerInfo.pickInfo.gripTransform, pointerId, zDragFactor);\r\n }\r\n\r\n // Get change in rotation\r\n this._tmpQuaternion.copyFrom(virtualMeshesInfo.startingPivotOrientation);\r\n this._tmpQuaternion.x = -this._tmpQuaternion.x;\r\n this._tmpQuaternion.y = -this._tmpQuaternion.y;\r\n this._tmpQuaternion.z = -this._tmpQuaternion.z;\r\n virtualMeshesInfo.pivotMesh.absoluteRotationQuaternion!.multiplyToRef(this._tmpQuaternion, this._tmpQuaternion);\r\n virtualMeshesInfo.pivotMesh.absolutePosition.subtractToRef(virtualMeshesInfo.startingPivotPosition, this._tmpVector);\r\n\r\n this.onDragObservable.notifyObservers({ delta: this._tmpVector, position: virtualMeshesInfo.pivotMesh.position, pickInfo: pointerInfo.pickInfo });\r\n\r\n // Notify herited methods and observables\r\n this._targetDrag(this._tmpVector, this._tmpQuaternion, pointerId);\r\n virtualMeshesInfo.lastDragPosition.copyFrom(virtualMeshesInfo.dragMesh.absolutePosition);\r\n\r\n this._moving = true;\r\n }\r\n }\r\n });\r\n }\r\n\r\n private _applyZOffset(node: TransformNode, localOriginDragDifference: number, zDragFactor: number) {\r\n // Determine how much the controller moved to/away towards the dragged object and use this to move the object further when its further away\r\n node.position.z -= node.position.z < 1 ? localOriginDragDifference * zDragFactor : localOriginDragDifference * zDragFactor * node.position.z;\r\n if (node.position.z < 0) {\r\n node.position.z = 0;\r\n }\r\n }\r\n\r\n // eslint-disable-next-line @typescript-eslint/no-unused-vars\r\n protected _targetDragStart(worldPosition: Vector3, worldRotation: Quaternion, pointerId: number) {\r\n // Herited classes can override that\r\n }\r\n\r\n protected _targetDrag(worldDeltaPosition: Vector3, worldDeltaRotation: Quaternion, pointerId: number) {\r\n // Herited classes can override that\r\n }\r\n\r\n protected _targetDragEnd(pointerId: number) {\r\n // Herited classes can override that\r\n }\r\n\r\n protected _reattachCameraControls() {\r\n if (this._pointerCamera) {\r\n // If the camera is an ArcRotateCamera, preserve the settings from the camera\r\n // when reattaching control\r\n if (this._pointerCamera.getClassName() === \"ArcRotateCamera\") {\r\n const arcRotateCamera = this._pointerCamera as ArcRotateCamera;\r\n arcRotateCamera.attachControl(\r\n arcRotateCamera.inputs ? arcRotateCamera.inputs.noPreventDefault : true,\r\n arcRotateCamera._useCtrlForPanning,\r\n arcRotateCamera._panningMouseButton\r\n );\r\n } else {\r\n // preserve the settings from the camera when reattaching control\r\n this._pointerCamera.attachControl(this._pointerCamera.inputs ? this._pointerCamera.inputs.noPreventDefault : true);\r\n }\r\n }\r\n }\r\n\r\n /**\r\n * Detaches the behavior from the mesh\r\n */\r\n public detach(): void {\r\n if (this._scene) {\r\n if (this.detachCameraControls && this._attachedToElement && this._pointerCamera && !this._pointerCamera.leftCamera) {\r\n this._reattachCameraControls();\r\n this._attachedToElement = false;\r\n }\r\n this._scene.onPointerObservable.remove(this._pointerObserver);\r\n }\r\n\r\n for (const pointerId in this._virtualMeshesInfo) {\r\n this._virtualMeshesInfo[pointerId].originMesh.dispose();\r\n this._virtualMeshesInfo[pointerId].dragMesh.dispose();\r\n }\r\n\r\n this.onDragEndObservable.clear();\r\n this.onDragObservable.clear();\r\n this.onDragStartObservable.clear();\r\n }\r\n}\r\n"]}
@@ -50,6 +50,7 @@ export declare class SixDofDragBehavior extends BaseSixDofDragBehavior {
50
50
  faceCameraOnDragStart: boolean;
51
51
  /**
52
52
  * Attaches the six DoF drag behavior
53
+ * In XR mode the mesh and its children will have their isNearGrabbable property set to true
53
54
  * @param ownerNode The mesh that will be dragged around once attached
54
55
  */
55
56
  attach(ownerNode: Mesh): void;
@@ -53,11 +53,16 @@ export class SixDofDragBehavior extends BaseSixDofDragBehavior {
53
53
  }
54
54
  /**
55
55
  * Attaches the six DoF drag behavior
56
+ * In XR mode the mesh and its children will have their isNearGrabbable property set to true
56
57
  * @param ownerNode The mesh that will be dragged around once attached
57
58
  */
58
59
  attach(ownerNode) {
59
60
  super.attach(ownerNode);
60
61
  ownerNode.isNearGrabbable = true;
62
+ // if it has children, make sure they are grabbable too
63
+ ownerNode.getChildMeshes().forEach((m) => {
64
+ m.isNearGrabbable = true;
65
+ });
61
66
  // Node that will save the owner's transform
62
67
  this._virtualTransformNode = new TransformNode("virtual_sixDof", BaseSixDofDragBehavior._virtualScene);
63
68
  this._virtualTransformNode.rotationQuaternion = Quaternion.Identity();
@@ -218,7 +223,6 @@ export class SixDofDragBehavior extends BaseSixDofDragBehavior {
218
223
  detach() {
219
224
  super.detach();
220
225
  if (this._ownerNode) {
221
- this._ownerNode.isNearGrabbable = false;
222
226
  this._ownerNode.getScene().onBeforeRenderObservable.remove(this._sceneRenderObserver);
223
227
  }
224
228
  if (this._virtualTransformNode) {
@@ -1 +1 @@
1
- {"version":3,"file":"sixDofDragBehav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M,KAAK,CAAC,EAAE;YAC7C,mGAAmG;YACnG,IAAI,CAAC,2BAA2B,EAAE,CAAC;YACnC,MAAM,sBAAsB,GAAG,IAAI,CAAC,qBAAqB,CAAC;YAC1D,IAAI,CAAC,qBAAqB,GAAG,KAAK,CAAC;YACnC,IAAI,CAAC,gBAAgB,EAAE,CAAC;YACxB,IAAI,CAAC,qBAAqB,GAAG,sBAAsB,CAAC;SACvD;IACL,CAAC;IAED;;OAEG;IACI,MAAM;QACT,KAAK,CAAC,MAAM,EAAE,CAAC;QAEf,IAAI,IAAI,CAAC,UAAU,EAAE;YAChB,IAAI,CAAC,UAAmB,CAAC,eAAe,GAAG,KAAK,CAAC;YAClD,IAAI,CAAC,UAAU,CAAC,QAAQ,EAAE,CAAC,wBAAwB,CAAC,MAAM,CAAC,IAAI,CAAC,oBAAoB,CAAC,CAAC;SACzF;QAED,IAAI,IAAI,CAAC,qBAAqB,EAAE;YAC5B,IAAI,CAAC,qBAAqB,CAAC,OAAO,EAAE,CAAC;SACxC;IACL,CAAC;CACJ","sourcesContent":["import type { Mesh } from \"../../Meshes/mesh\";\r\nimport type { Scene } from \"../../scene\";\r\nimport type { Nullable } from \"../../types\";\r\nimport { Vector3, Quaternion, Matrix, TmpVectors } from \"../../Maths/math.vector\";\r\nimport type { Observer } from \"../../Misc/observable\";\r\nimport { Observable } from \"../../Misc/observable\";\r\nimport { BaseSixDofDragBehavior } from \"./baseSixDofDragBehavior\";\r\nimport { TransformNode } from \"../../Meshes/transformNode\";\r\nimport { Space } from \"../../Maths/math.axis\";\r\n\r\n/**\r\n * A behavior that when attached to a mesh will allow the mesh to be dragged around based on directions and origin of the pointer's ray\r\n */\r\nexport class SixDofDragBehavior extends BaseSixDofDragBehavior {\r\n private _sceneRenderObserver: Nullable<Observer<Scene>> = null;\r\n private _virtualTransformNode: TransformNode;\r\n\r\n protected _targetPosition = new Vector3(0, 0, 0);\r\n protected _targetOrientation = new Quaternion();\r\n protected _targetScaling = new Vector3(1, 1, 1);\r\n protected _startingPosition = new Vector3(0, 0, 0);\r\n protected _startingOrientation = new Quaternion();\r\n protected _startingScaling = new Vector3(1, 1, 1);\r\n\r\n /**\r\n * Fires when position is updated\r\n */\r\n public onPositionChangedObservable = new Observable<{ position: Vector3 }>();\r\n\r\n /**\r\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)\r\n */\r\n public dragDeltaRatio = 0.2;\r\n\r\n /**\r\n * If the object should rotate to face the drag origin\r\n */\r\n public rotateDraggedObject = true;\r\n\r\n /**\r\n * If `rotateDraggedObject` is set to `true`, this parameter determines if we are only rotating around the y axis (yaw)\r\n */\r\n public rotateAroundYOnly = false;\r\n\r\n /**\r\n * Should the behavior rotate 1:1 with the motion controller, when one is used.\r\n */\r\n public rotateWithMotionController = true;\r\n\r\n /**\r\n * The name of the behavior\r\n */\r\n public get name(): string {\r\n return \"SixDofDrag\";\r\n }\r\n\r\n /**\r\n * Use this flag to update the target but not move the owner node towards the target\r\n */\r\n public disableMovement: boolean = false;\r\n\r\n /**\r\n * Should the object rotate towards the camera when we start dragging it\r\n */\r\n public faceCameraOnDragStart = false;\r\n\r\n /**\r\n * Attaches the six DoF drag behavior\r\n * @param ownerNode The mesh that will be dragged around once attached\r\n */\r\n public attach(ownerNode: Mesh): void {\r\n super.attach(ownerNode);\r\n\r\n ownerNode.isNearGrabbable = true;\r\n\r\n // Node that will save the owner's transform\r\n this._virtualTransformNode = new TransformNode(\"virtual_sixDof\", BaseSixDofDragBehavior._virtualScene);\r\n this._virtualTransformNode.rotationQuaternion = Quaternion.Identity();\r\n\r\n // On every frame move towards target scaling to avoid jitter caused by vr controllers\r\n this._sceneRenderObserver = ownerNode.getScene().onBeforeRenderObservable.add(() => {\r\n if (this.currentDraggingPointerIds.length === 1 && this._moving && !this.disableMovement) {\r\n // 1 pointer only drags mesh\r\n const deltaToAdd = TmpVectors.Vector3[0];\r\n deltaToAdd.copyFrom(this._targetPosition).subtractInPlace(ownerNode.absolutePosition).scaleInPlace(this.dragDeltaRatio);\r\n const deltaToAddTransformed = TmpVectors.Vector3[1];\r\n deltaToAddTransformed.copyFrom(deltaToAdd);\r\n // If the node has a parent, transform the delta to local space, so it can be added to the\r\n // position in local space\r\n if (ownerNode.parent) {\r\n const parentRotationMatrixInverse = TmpVectors.Matrix[0];\r\n (ownerNode.parent as TransformNode).absoluteRotationQuaternion.toRotationMatrix(parentRotationMatrixInverse);\r\n parentRotationMatrixInverse.invert();\r\n Vector3.TransformNormalToRef(deltaToAdd, parentRotationMatrixInverse, deltaToAddTransformed);\r\n }\r\n ownerNode.position.addInPlace(deltaToAddTransformed);\r\n\r\n this.onPositionChangedObservable.notifyObservers({ position: ownerNode.absolutePosition });\r\n\r\n // Only rotate the mesh if it's parent has uniform scaling\r\n if (!ownerNode.parent || ((ownerNode.parent as TransformNode).scaling && !(ownerNode.parent as TransformNode).scaling.isNonUniformWithinEpsilon(0.001))) {\r\n const rotationToApply = TmpVectors.Quaternion[0];\r\n rotationToApply.copyFrom(this._targetOrientation);\r\n if (ownerNode.parent) {\r\n const parentRotationInverse = TmpVectors.Quaternion[0];\r\n parentRotationInverse.copyFrom((ownerNode.parent as TransformNode).absoluteRotationQuaternion);\r\n parentRotationInverse.invertInPlace();\r\n parentRotationInverse.multiplyToRef(this._targetOrientation, rotationToApply);\r\n }\r\n Quaternion.SlerpToRef(ownerNode.rotationQuaternion!, rotationToApply, this.dragDeltaRatio, ownerNode.rotationQuaternion!);\r\n }\r\n }\r\n });\r\n }\r\n\r\n private _getPositionOffsetAround(transformationLocalOrigin: Vector3, scaling: number, rotation: Quaternion): Vector3 {\r\n const translationMatrix = TmpVectors.Matrix[0]; // T\r\n const translationMatrixInv = TmpVectors.Matrix[1]; // T'\r\n const rotationMatrix = TmpVectors.Matrix[2]; // R\r\n const scaleMatrix = TmpVectors.Matrix[3]; // S\r\n const finalMatrix = TmpVectors.Matrix[4]; // T' x R x S x T\r\n\r\n Matrix.TranslationToRef(transformationLocalOrigin.x, transformationLocalOrigin.y, transformationLocalOrigin.z, translationMatrix); // T\r\n Matrix.TranslationToRef(-transformationLocalOrigin.x, -transformationLocalOrigin.y, -transformationLocalOrigin.z, translationMatrixInv); // T'\r\n Matrix.FromQuaternionToRef(rotation, rotationMatrix); // R\r\n Matrix.ScalingToRef(scaling, scaling, scaling, scaleMatrix);\r\n translationMatrixInv.multiplyToRef(rotationMatrix, finalMatrix); // T' x R\r\n finalMatrix.multiplyToRef(scaleMatrix, finalMatrix); // T' x R x S\r\n finalMatrix.multiplyToRef(translationMatrix, finalMatrix); // T' x R x S x T\r\n\r\n return finalMatrix.getTranslation();\r\n }\r\n\r\n private _onePointerPositionUpdated(worldDeltaPosition: Vector3, worldDeltaRotation: Quaternion) {\r\n const pointerDelta = TmpVectors.Vector3[0];\r\n pointerDelta.setAll(0);\r\n\r\n if (this._dragging === this._dragType.DRAG) {\r\n if (this.rotateDraggedObject) {\r\n if (this.rotateAroundYOnly) {\r\n // Convert change in rotation to only y axis rotation\r\n Quaternion.RotationYawPitchRollToRef(worldDeltaRotation.toEulerAngles().y, 0, 0, TmpVectors.Quaternion[0]);\r\n } else {\r\n TmpVectors.Quaternion[0].copyFrom(worldDeltaRotation);\r\n }\r\n TmpVectors.Quaternion[0].multiplyToRef(this._startingOrientation, this._targetOrientation);\r\n }\r\n } else if (this._dragging === this._dragType.NEAR_DRAG || (this._dragging === this._dragType.DRAG_WITH_CONTROLLER && this.rotateWithMotionController)) {\r\n worldDeltaRotation.multiplyToRef(this._startingOrientation, this._targetOrientation);\r\n }\r\n\r\n this._targetPosition.copyFrom(this._startingPosition).addInPlace(worldDeltaPosition);\r\n }\r\n\r\n private _twoPointersPositionUpdated() {\r\n const startingPosition0 = this._virtualMeshesInfo[this.currentDraggingPointerIds[0]].startingPosition;\r\n const startingPosition1 = this._virtualMeshesInfo[this.currentDraggingPointerIds[1]].startingPosition;\r\n const startingCenter = TmpVectors.Vector3[0];\r\n startingPosition0.addToRef(startingPosition1, startingCenter);\r\n startingCenter.scaleInPlace(0.5);\r\n const startingVector = TmpVectors.Vector3[1];\r\n startingPosition1.subtractToRef(startingPosition0, startingVector);\r\n\r\n const currentPosition0 = this._virtualMeshesInfo[this.currentDraggingPointerIds[0]].dragMesh.absolutePosition;\r\n const currentPosition1 = this._virtualMeshesInfo[this.currentDraggingPointerIds[1]].dragMesh.absolutePosition;\r\n const currentCenter = TmpVectors.Vector3[2];\r\n currentPosition0.addToRef(currentPosition1, currentCenter);\r\n currentCenter.scaleInPlace(0.5);\r\n const currentVector = TmpVectors.Vector3[3];\r\n currentPosition1.subtractToRef(currentPosition0, currentVector);\r\n\r\n const scaling = currentVector.length() / startingVector.length();\r\n const translation = currentCenter.subtract(startingCenter);\r\n const rotationQuaternion = Quaternion.FromEulerAngles(\r\n 0,\r\n Vector3.GetAngleBetweenVectorsOnPlane(startingVector.normalize(), currentVector.normalize(), Vector3.UpReadOnly),\r\n 0\r\n );\r\n\r\n const oldParent = this._ownerNode.parent;\r\n this._ownerNode.setParent(null);\r\n\r\n const positionOffset = this._getPositionOffsetAround(startingCenter.subtract(this._virtualTransformNode.getAbsolutePivotPoint()), scaling, rotationQuaternion);\r\n this._virtualTransformNode.rotationQuaternion!.multiplyToRef(rotationQuaternion, this._ownerNode.rotationQuaternion!);\r\n this._virtualTransformNode.scaling.scaleToRef(scaling, this._ownerNode.scaling);\r\n this._virtualTransformNode.position.addToRef(translation.addInPlace(positionOffset), this._ownerNode.position);\r\n this.onPositionChangedObservable.notifyObservers({ position: this._ownerNode.position });\r\n\r\n this._ownerNode.setParent(oldParent);\r\n }\r\n\r\n protected _targetDragStart() {\r\n const pointerCount = this.currentDraggingPointerIds.length;\r\n\r\n if (!this._ownerNode.rotationQuaternion) {\r\n this._ownerNode.rotationQuaternion = Quaternion.RotationYawPitchRoll(this._ownerNode.rotation.y, this._ownerNode.rotation.x, this._ownerNode.rotation.z);\r\n }\r\n const worldPivot = this._ownerNode.getAbsolutePivotPoint();\r\n\r\n if (pointerCount === 1) {\r\n this._targetPosition.copyFrom(this._ownerNode.absolutePosition);\r\n this._targetOrientation.copyFrom(this._ownerNode.absoluteRotationQuaternion);\r\n this._targetScaling.copyFrom(this._ownerNode.absoluteScaling);\r\n\r\n if (this.faceCameraOnDragStart && this._scene.activeCamera) {\r\n const toCamera = TmpVectors.Vector3[0];\r\n this._scene.activeCamera.position.subtractToRef(worldPivot, toCamera);\r\n toCamera.normalize();\r\n const quat = TmpVectors.Quaternion[0];\r\n if (this._scene.useRightHandedSystem) {\r\n Quaternion.FromLookDirectionRHToRef(toCamera, new Vector3(0, 1, 0), quat);\r\n } else {\r\n Quaternion.FromLookDirectionLHToRef(toCamera, new Vector3(0, 1, 0), quat);\r\n }\r\n quat.normalize();\r\n Quaternion.RotationYawPitchRollToRef(quat.toEulerAngles().y, 0, 0, TmpVectors.Quaternion[0]);\r\n this._targetOrientation.copyFrom(TmpVectors.Quaternion[0]);\r\n }\r\n this._startingPosition.copyFrom(this._targetPosition);\r\n this._startingOrientation.copyFrom(this._targetOrientation);\r\n this._startingScaling.copyFrom(this._targetScaling);\r\n } else if (pointerCount === 2) {\r\n this._virtualTransformNode.setPivotPoint(new Vector3(0, 0, 0), Space.LOCAL);\r\n this._virtualTransformNode.position.copyFrom(this._ownerNode.absolutePosition);\r\n this._virtualTransformNode.scaling.copyFrom(this._ownerNode.absoluteScaling);\r\n this._virtualTransformNode.rotationQuaternion!.copyFrom(this._ownerNode.absoluteRotationQuaternion);\r\n this._virtualTransformNode.setPivotPoint(worldPivot, Space.WORLD);\r\n this._resetVirtualMeshesPosition();\r\n }\r\n }\r\n\r\n protected _targetDrag(worldDeltaPosition: Vector3, worldDeltaRotation: Quaternion) {\r\n if (this.currentDraggingPointerIds.length === 1) {\r\n this._onePointerPositionUpdated(worldDeltaPosition, worldDeltaRotation);\r\n } else if (this.currentDraggingPointerIds.length === 2) {\r\n this._twoPointersPositionUpdated();\r\n }\r\n }\r\n\r\n protected _targetDragEnd() {\r\n if (this.currentDraggingPointerIds.length === 1) {\r\n // We still have 1 active pointer, we must simulate a dragstart with a reseted position/orientation\r\n this._resetVirtualMeshesPosition();\r\n const previousFaceCameraFlag = this.faceCameraOnDragStart;\r\n this.faceCameraOnDragStart = false;\r\n this._targetDragStart();\r\n this.faceCameraOnDragStart = previousFaceCameraFlag;\r\n }\r\n }\r\n\r\n /**\r\n * Detaches the behavior from the mesh\r\n */\r\n public detach(): void {\r\n super.detach();\r\n\r\n if (this._ownerNode) {\r\n (this._ownerNode as Mesh).isNearGrabbable = false;\r\n this._ownerNode.getScene().onBeforeRenderObservable.remove(this._sceneRenderObserver);\r\n }\r\n\r\n if (this._virtualTransformNode) {\r\n this._virtualTransformNode.dispose();\r\n }\r\n }\r\n}\r\n"]}
1
+ {"version":3,"file":"sixDofDragBehavior.js","sourceRoot":"","sources":["../../../../../dev/core/src/Behaviors/Meshes/sixDofDragBehavior.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,OAAO,EAAE,UAAU,EAAE,MAAM,EAAE,UAAU,EAAE,MAAM,yBAAyB,CAAC;AAElF,OAAO,EAAE,UAAU,EAAE,MAAM,uBAAuB,CAAC;AACnD,OAAO,EAAE,sBAAsB,EAAE,MAAM,0BAA0B,CAAC;AAClE,OAAO,EAAE,aAAa,EAAE,MAAM,4BAA4B,CAAC;AAC3D,OAAO,EAAE,KAAK,EAAE,MAAM,uBAAuB,CAAC;AAE9C;;GAEG;AACH,MAAM,OAAO,kBAAmB,SAAQ,sBAAsB;IAA9D;;QACY,yBAAoB,GAA8B,IAAI,CAAC;QAGrD,oBAAe,GAAG,IAAI,OAAO,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,CAAC,CAAC;QACvC,uBAAkB,GAAG,IAAI,UAAU,EAAE,CAAC;QACtC,mBAAc,GAAG,IAAI,OAAO,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,CAAC,CAAC;QACtC,sBAAiB,GAAG,IAAI,OAAO,CAAC,CAAC,EAAE,CA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;SACxC;IACL,CAAC;CACJ","sourcesContent":["import type { Mesh } from \"../../Meshes/mesh\";\r\nimport type { Scene } from \"../../scene\";\r\nimport type { Nullable } from \"../../types\";\r\nimport { Vector3, Quaternion, Matrix, TmpVectors } from \"../../Maths/math.vector\";\r\nimport type { Observer } from \"../../Misc/observable\";\r\nimport { Observable } from \"../../Misc/observable\";\r\nimport { BaseSixDofDragBehavior } from \"./baseSixDofDragBehavior\";\r\nimport { TransformNode } from \"../../Meshes/transformNode\";\r\nimport { Space } from \"../../Maths/math.axis\";\r\n\r\n/**\r\n * A behavior that when attached to a mesh will allow the mesh to be dragged around based on directions and origin of the pointer's ray\r\n */\r\nexport class SixDofDragBehavior extends BaseSixDofDragBehavior {\r\n private _sceneRenderObserver: Nullable<Observer<Scene>> = null;\r\n private _virtualTransformNode: TransformNode;\r\n\r\n protected _targetPosition = new Vector3(0, 0, 0);\r\n protected _targetOrientation = new Quaternion();\r\n protected _targetScaling = new Vector3(1, 1, 1);\r\n protected _startingPosition = new Vector3(0, 0, 0);\r\n protected _startingOrientation = new Quaternion();\r\n protected _startingScaling = new Vector3(1, 1, 1);\r\n\r\n /**\r\n * Fires when position is updated\r\n */\r\n public onPositionChangedObservable = new Observable<{ position: Vector3 }>();\r\n\r\n /**\r\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)\r\n */\r\n public dragDeltaRatio = 0.2;\r\n\r\n /**\r\n * If the object should rotate to face the drag origin\r\n */\r\n public rotateDraggedObject = true;\r\n\r\n /**\r\n * If `rotateDraggedObject` is set to `true`, this parameter determines if we are only rotating around the y axis (yaw)\r\n */\r\n public rotateAroundYOnly = false;\r\n\r\n /**\r\n * Should the behavior rotate 1:1 with the motion controller, when one is used.\r\n */\r\n public rotateWithMotionController = true;\r\n\r\n /**\r\n * The name of the behavior\r\n */\r\n public get name(): string {\r\n return \"SixDofDrag\";\r\n }\r\n\r\n /**\r\n * Use this flag to update the target but not move the owner node towards the target\r\n */\r\n public disableMovement: boolean = false;\r\n\r\n /**\r\n * Should the object rotate towards the camera when we start dragging it\r\n */\r\n public faceCameraOnDragStart = false;\r\n\r\n /**\r\n * Attaches the six DoF drag behavior\r\n * In XR mode the mesh and its children will have their isNearGrabbable property set to true\r\n * @param ownerNode The mesh that will be dragged around once attached\r\n */\r\n public attach(ownerNode: Mesh): void {\r\n super.attach(ownerNode);\r\n\r\n ownerNode.isNearGrabbable = true;\r\n // if it has children, make sure they are grabbable too\r\n ownerNode.getChildMeshes().forEach((m) => {\r\n m.isNearGrabbable = true;\r\n });\r\n\r\n // Node that will save the owner's transform\r\n this._virtualTransformNode = new TransformNode(\"virtual_sixDof\", BaseSixDofDragBehavior._virtualScene);\r\n this._virtualTransformNode.rotationQuaternion = Quaternion.Identity();\r\n\r\n // On every frame move towards target scaling to avoid jitter caused by vr controllers\r\n this._sceneRenderObserver = ownerNode.getScene().onBeforeRenderObservable.add(() => {\r\n if (this.currentDraggingPointerIds.length === 1 && this._moving && !this.disableMovement) {\r\n // 1 pointer only drags mesh\r\n const deltaToAdd = TmpVectors.Vector3[0];\r\n deltaToAdd.copyFrom(this._targetPosition).subtractInPlace(ownerNode.absolutePosition).scaleInPlace(this.dragDeltaRatio);\r\n const deltaToAddTransformed = TmpVectors.Vector3[1];\r\n deltaToAddTransformed.copyFrom(deltaToAdd);\r\n // If the node has a parent, transform the delta to local space, so it can be added to the\r\n // position in local space\r\n if (ownerNode.parent) {\r\n const parentRotationMatrixInverse = TmpVectors.Matrix[0];\r\n (ownerNode.parent as TransformNode).absoluteRotationQuaternion.toRotationMatrix(parentRotationMatrixInverse);\r\n parentRotationMatrixInverse.invert();\r\n Vector3.TransformNormalToRef(deltaToAdd, parentRotationMatrixInverse, deltaToAddTransformed);\r\n }\r\n ownerNode.position.addInPlace(deltaToAddTransformed);\r\n\r\n this.onPositionChangedObservable.notifyObservers({ position: ownerNode.absolutePosition });\r\n\r\n // Only rotate the mesh if it's parent has uniform scaling\r\n if (!ownerNode.parent || ((ownerNode.parent as TransformNode).scaling && !(ownerNode.parent as TransformNode).scaling.isNonUniformWithinEpsilon(0.001))) {\r\n const rotationToApply = TmpVectors.Quaternion[0];\r\n rotationToApply.copyFrom(this._targetOrientation);\r\n if (ownerNode.parent) {\r\n const parentRotationInverse = TmpVectors.Quaternion[0];\r\n parentRotationInverse.copyFrom((ownerNode.parent as TransformNode).absoluteRotationQuaternion);\r\n parentRotationInverse.invertInPlace();\r\n parentRotationInverse.multiplyToRef(this._targetOrientation, rotationToApply);\r\n }\r\n Quaternion.SlerpToRef(ownerNode.rotationQuaternion!, rotationToApply, this.dragDeltaRatio, ownerNode.rotationQuaternion!);\r\n }\r\n }\r\n });\r\n }\r\n\r\n private _getPositionOffsetAround(transformationLocalOrigin: Vector3, scaling: number, rotation: Quaternion): Vector3 {\r\n const translationMatrix = TmpVectors.Matrix[0]; // T\r\n const translationMatrixInv = TmpVectors.Matrix[1]; // T'\r\n const rotationMatrix = TmpVectors.Matrix[2]; // R\r\n const scaleMatrix = TmpVectors.Matrix[3]; // S\r\n const finalMatrix = TmpVectors.Matrix[4]; // T' x R x S x T\r\n\r\n Matrix.TranslationToRef(transformationLocalOrigin.x, transformationLocalOrigin.y, transformationLocalOrigin.z, translationMatrix); // T\r\n Matrix.TranslationToRef(-transformationLocalOrigin.x, -transformationLocalOrigin.y, -transformationLocalOrigin.z, translationMatrixInv); // T'\r\n Matrix.FromQuaternionToRef(rotation, rotationMatrix); // R\r\n Matrix.ScalingToRef(scaling, scaling, scaling, scaleMatrix);\r\n translationMatrixInv.multiplyToRef(rotationMatrix, finalMatrix); // T' x R\r\n finalMatrix.multiplyToRef(scaleMatrix, finalMatrix); // T' x R x S\r\n finalMatrix.multiplyToRef(translationMatrix, finalMatrix); // T' x R x S x T\r\n\r\n return finalMatrix.getTranslation();\r\n }\r\n\r\n private _onePointerPositionUpdated(worldDeltaPosition: Vector3, worldDeltaRotation: Quaternion) {\r\n const pointerDelta = TmpVectors.Vector3[0];\r\n pointerDelta.setAll(0);\r\n\r\n if (this._dragging === this._dragType.DRAG) {\r\n if (this.rotateDraggedObject) {\r\n if (this.rotateAroundYOnly) {\r\n // Convert change in rotation to only y axis rotation\r\n Quaternion.RotationYawPitchRollToRef(worldDeltaRotation.toEulerAngles().y, 0, 0, TmpVectors.Quaternion[0]);\r\n } else {\r\n TmpVectors.Quaternion[0].copyFrom(worldDeltaRotation);\r\n }\r\n TmpVectors.Quaternion[0].multiplyToRef(this._startingOrientation, this._targetOrientation);\r\n }\r\n } else if (this._dragging === this._dragType.NEAR_DRAG || (this._dragging === this._dragType.DRAG_WITH_CONTROLLER && this.rotateWithMotionController)) {\r\n worldDeltaRotation.multiplyToRef(this._startingOrientation, this._targetOrientation);\r\n }\r\n\r\n this._targetPosition.copyFrom(this._startingPosition).addInPlace(worldDeltaPosition);\r\n }\r\n\r\n private _twoPointersPositionUpdated() {\r\n const startingPosition0 = this._virtualMeshesInfo[this.currentDraggingPointerIds[0]].startingPosition;\r\n const startingPosition1 = this._virtualMeshesInfo[this.currentDraggingPointerIds[1]].startingPosition;\r\n const startingCenter = TmpVectors.Vector3[0];\r\n startingPosition0.addToRef(startingPosition1, startingCenter);\r\n startingCenter.scaleInPlace(0.5);\r\n const startingVector = TmpVectors.Vector3[1];\r\n startingPosition1.subtractToRef(startingPosition0, startingVector);\r\n\r\n const currentPosition0 = this._virtualMeshesInfo[this.currentDraggingPointerIds[0]].dragMesh.absolutePosition;\r\n const currentPosition1 = this._virtualMeshesInfo[this.currentDraggingPointerIds[1]].dragMesh.absolutePosition;\r\n const currentCenter = TmpVectors.Vector3[2];\r\n currentPosition0.addToRef(currentPosition1, currentCenter);\r\n currentCenter.scaleInPlace(0.5);\r\n const currentVector = TmpVectors.Vector3[3];\r\n currentPosition1.subtractToRef(currentPosition0, currentVector);\r\n\r\n const scaling = currentVector.length() / startingVector.length();\r\n const translation = currentCenter.subtract(startingCenter);\r\n const rotationQuaternion = Quaternion.FromEulerAngles(\r\n 0,\r\n Vector3.GetAngleBetweenVectorsOnPlane(startingVector.normalize(), currentVector.normalize(), Vector3.UpReadOnly),\r\n 0\r\n );\r\n\r\n const oldParent = this._ownerNode.parent;\r\n this._ownerNode.setParent(null);\r\n\r\n const positionOffset = this._getPositionOffsetAround(startingCenter.subtract(this._virtualTransformNode.getAbsolutePivotPoint()), scaling, rotationQuaternion);\r\n this._virtualTransformNode.rotationQuaternion!.multiplyToRef(rotationQuaternion, this._ownerNode.rotationQuaternion!);\r\n this._virtualTransformNode.scaling.scaleToRef(scaling, this._ownerNode.scaling);\r\n this._virtualTransformNode.position.addToRef(translation.addInPlace(positionOffset), this._ownerNode.position);\r\n this.onPositionChangedObservable.notifyObservers({ position: this._ownerNode.position });\r\n\r\n this._ownerNode.setParent(oldParent);\r\n }\r\n\r\n protected _targetDragStart() {\r\n const pointerCount = this.currentDraggingPointerIds.length;\r\n\r\n if (!this._ownerNode.rotationQuaternion) {\r\n this._ownerNode.rotationQuaternion = Quaternion.RotationYawPitchRoll(this._ownerNode.rotation.y, this._ownerNode.rotation.x, this._ownerNode.rotation.z);\r\n }\r\n const worldPivot = this._ownerNode.getAbsolutePivotPoint();\r\n\r\n if (pointerCount === 1) {\r\n this._targetPosition.copyFrom(this._ownerNode.absolutePosition);\r\n this._targetOrientation.copyFrom(this._ownerNode.absoluteRotationQuaternion);\r\n this._targetScaling.copyFrom(this._ownerNode.absoluteScaling);\r\n\r\n if (this.faceCameraOnDragStart && this._scene.activeCamera) {\r\n const toCamera = TmpVectors.Vector3[0];\r\n this._scene.activeCamera.position.subtractToRef(worldPivot, toCamera);\r\n toCamera.normalize();\r\n const quat = TmpVectors.Quaternion[0];\r\n if (this._scene.useRightHandedSystem) {\r\n Quaternion.FromLookDirectionRHToRef(toCamera, new Vector3(0, 1, 0), quat);\r\n } else {\r\n Quaternion.FromLookDirectionLHToRef(toCamera, new Vector3(0, 1, 0), quat);\r\n }\r\n quat.normalize();\r\n Quaternion.RotationYawPitchRollToRef(quat.toEulerAngles().y, 0, 0, TmpVectors.Quaternion[0]);\r\n this._targetOrientation.copyFrom(TmpVectors.Quaternion[0]);\r\n }\r\n this._startingPosition.copyFrom(this._targetPosition);\r\n this._startingOrientation.copyFrom(this._targetOrientation);\r\n this._startingScaling.copyFrom(this._targetScaling);\r\n } else if (pointerCount === 2) {\r\n this._virtualTransformNode.setPivotPoint(new Vector3(0, 0, 0), Space.LOCAL);\r\n this._virtualTransformNode.position.copyFrom(this._ownerNode.absolutePosition);\r\n this._virtualTransformNode.scaling.copyFrom(this._ownerNode.absoluteScaling);\r\n this._virtualTransformNode.rotationQuaternion!.copyFrom(this._ownerNode.absoluteRotationQuaternion);\r\n this._virtualTransformNode.setPivotPoint(worldPivot, Space.WORLD);\r\n this._resetVirtualMeshesPosition();\r\n }\r\n }\r\n\r\n protected _targetDrag(worldDeltaPosition: Vector3, worldDeltaRotation: Quaternion) {\r\n if (this.currentDraggingPointerIds.length === 1) {\r\n this._onePointerPositionUpdated(worldDeltaPosition, worldDeltaRotation);\r\n } else if (this.currentDraggingPointerIds.length === 2) {\r\n this._twoPointersPositionUpdated();\r\n }\r\n }\r\n\r\n protected _targetDragEnd() {\r\n if (this.currentDraggingPointerIds.length === 1) {\r\n // We still have 1 active pointer, we must simulate a dragstart with a reseted position/orientation\r\n this._resetVirtualMeshesPosition();\r\n const previousFaceCameraFlag = this.faceCameraOnDragStart;\r\n this.faceCameraOnDragStart = false;\r\n this._targetDragStart();\r\n this.faceCameraOnDragStart = previousFaceCameraFlag;\r\n }\r\n }\r\n\r\n /**\r\n * Detaches the behavior from the mesh\r\n */\r\n public detach(): void {\r\n super.detach();\r\n\r\n if (this._ownerNode) {\r\n this._ownerNode.getScene().onBeforeRenderObservable.remove(this._sceneRenderObserver);\r\n }\r\n\r\n if (this._virtualTransformNode) {\r\n this._virtualTransformNode.dispose();\r\n }\r\n }\r\n}\r\n"]}
@@ -101,6 +101,16 @@ export interface ITextMetrics {
101
101
  * property to the right side of the bounding rectangle of the given text
102
102
  */
103
103
  readonly actualBoundingBoxRight: number;
104
+ /**
105
+ * distance (in pixels) from the horizontal line indicated by the CanvasRenderingContext2D.textBaseline
106
+ * property to the top side of the bounding rectangle of the given text
107
+ */
108
+ readonly actualBoundingBoxAscent: number;
109
+ /**
110
+ * distance (in pixels) from the horizontal line indicated by the CanvasRenderingContext2D.textBaseline
111
+ * property to the bottom side of the bounding rectangle of the given text
112
+ */
113
+ readonly actualBoundingBoxDescent: number;
104
114
  }
105
115
  /**
106
116
  * Class used to abstract a matrix
@@ -1 +1 @@
1
- {"version":3,"file":"ICanvas.js","sourceRoot":"","sources":["../../../../dev/core/src/Engines/ICanvas.ts"],"names":[],"mappings":"","sourcesContent":["/**\r\n * Class used to abstract a canvas\r\n */\r\nexport interface ICanvas {\r\n /**\r\n * Canvas width.\r\n */\r\n width: number;\r\n\r\n /**\r\n * Canvas height.\r\n */\r\n height: number;\r\n\r\n /**\r\n * returns a drawing context on the canvas.\r\n * @param contextType context identifier.\r\n * @param contextAttributes context attributes.\r\n * @returns ICanvasRenderingContext object.\r\n */\r\n getContext(contextType: string, contextAttributes?: any): ICanvasRenderingContext;\r\n\r\n /**\r\n * returns a data URI containing a representation of the image in the format specified by the type parameter.\r\n * @param mime the image format.\r\n * @returns string containing the requested data URI.\r\n */\r\n toDataURL(mime: string): string;\r\n\r\n /**\r\n * Removes the canvas from the document.\r\n * Offscreen canvases don't have the remove function, so we need to make it optional.\r\n */\r\n remove?(): void;\r\n}\r\n\r\n/**\r\n * Class used to abstract am image to use with the canvas and its context\r\n */\r\nexport interface IImage {\r\n /**\r\n * onload callback.\r\n */\r\n onload: ((this: GlobalEventHandlers, ev: Event) => any) | null;\r\n\r\n /**\r\n * Error callback.\r\n */\r\n onerror: ((this: GlobalEventHandlers, ev: Event) => any) | null;\r\n\r\n /**\r\n * Image source.\r\n */\r\n src: string;\r\n\r\n /**\r\n * Image width.\r\n */\r\n readonly width: number;\r\n\r\n /**\r\n * Image height.\r\n */\r\n readonly height: number;\r\n\r\n /**\r\n * The original height of the image resource before sizing.\r\n */\r\n readonly naturalHeight: number;\r\n\r\n /**\r\n * The original width of the image resource before sizing.\r\n */\r\n readonly naturalWidth: number;\r\n\r\n /**\r\n * provides support for CORS, defining how the element handles crossorigin requests,\r\n * thereby enabling the configuration of the CORS requests for the element's fetched data.\r\n */\r\n crossOrigin: string | null;\r\n\r\n /**\r\n * provides support for referrer policy on xhr load request,\r\n * it is used to control the request header.\r\n */\r\n referrerPolicy: string;\r\n}\r\n\r\n/**\r\n * Class used to abstract a canvas gradient\r\n */\r\nexport interface ICanvasGradient {\r\n /**\r\n * adds a new color stop, defined by an offset and a color, to a given canvas gradient.\r\n * @param offset A number between 0 and 1, inclusive, representing the position of the color stop. 0 represents the start of the gradient and 1 represents the end.\r\n * @param color value representing the color of the stop.\r\n */\r\n addColorStop(offset: number, color: string): void;\r\n}\r\n\r\n/**\r\n * Class used to abstract a text measurement\r\n */\r\nexport interface ITextMetrics {\r\n /**\r\n * Text width.\r\n */\r\n readonly width: number;\r\n /**\r\n * distance (in pixels) parallel to the baseline from the alignment point given by the CanvasRenderingContext2D.textAlign\r\n * property to the left side of the bounding rectangle of the given text\r\n */\r\n readonly actualBoundingBoxLeft: number;\r\n /**\r\n * distance (in pixels) parallel to the baseline from the alignment point given by the CanvasRenderingContext2D.textAlign\r\n * property to the right side of the bounding rectangle of the given text\r\n */\r\n readonly actualBoundingBoxRight: number;\r\n}\r\n\r\n/**\r\n * Class used to abstract a matrix\r\n */\r\nexport interface DOMMatrix {\r\n /**\r\n * A Boolean flag whose value is true if the matrix was initialized as a 2D matrix. If false, the matrix is 3D.\r\n */\r\n is2D: boolean;\r\n /**\r\n * A Boolean whose value is true if the matrix is the identity matrix. The identity matrix is one in which every value is 0 except those on the main diagonal from top-left to bottom-right corner (in other words, where the offsets in each direction are equal).\r\n */\r\n isIdentity: boolean;\r\n /**\r\n * The following double-precision floating-point values represent the components of a matrix which are required in order to perform 2D rotations and translations.\r\n */\r\n a: number;\r\n /**\r\n * The following double-precision floating-point values represent the components of a matrix which are required in order to perform 2D rotations and translations.\r\n */\r\n b: number;\r\n /**\r\n * The following double-precision floating-point values represent the components of a matrix which are required in order to perform 2D rotations and translations.\r\n */\r\n c: number;\r\n /**\r\n * The following double-precision floating-point values represent the components of a matrix which are required in order to perform 2D rotations and translations.\r\n */\r\n d: number;\r\n /**\r\n * The following double-precision floating-point values represent the components of a matrix which are required in order to perform 2D rotations and translations.\r\n */\r\n e: number;\r\n /**\r\n * The following double-precision floating-point values represent the components of a matrix which are required in order to perform 2D rotations and translations.\r\n */\r\n f: number;\r\n /**\r\n * The following are double-precision floating-point values representing each component of a 4×4 matrix, where m11 through m14 are the first column, m21 through m24 are the second column, and so forth.\r\n */\r\n m11: number;\r\n /**\r\n * The following are double-precision floating-point values representing each component of a 4×4 matrix, where m11 through m14 are the first column, m21 through m24 are the second column, and so forth.\r\n */\r\n m12: number;\r\n /**\r\n * The following are double-precision floating-point values representing each component of a 4×4 matrix, where m11 through m14 are the first column, m21 through m24 are the second column, and so forth.\r\n */\r\n m13: number;\r\n /**\r\n * The following are double-precision floating-point values representing each component of a 4×4 matrix, where m11 through m14 are the first column, m21 through m24 are the second column, and so forth.\r\n */\r\n m14: number;\r\n /**\r\n * The following are double-precision floating-point values representing each component of a 4×4 matrix, where m11 through m14 are the first column, m21 through m24 are the second column, and so forth.\r\n */\r\n m21: number;\r\n /**\r\n * The following are double-precision floating-point values representing each component of a 4×4 matrix, where m11 through m14 are the first column, m21 through m24 are the second column, and so forth.\r\n */\r\n m22: number;\r\n /**\r\n * The following are double-precision floating-point values representing each component of a 4×4 matrix, where m11 through m14 are the first column, m21 through m24 are the second column, and so forth.\r\n */\r\n m23: number;\r\n /**\r\n * The following are double-precision floating-point values representing each component of a 4×4 matrix, where m11 through m14 are the first column, m21 through m24 are the second column, and so forth.\r\n */\r\n m24: number;\r\n /**\r\n * The following are double-precision floating-point values representing each component of a 4×4 matrix, where m11 through m14 are the first column, m21 through m24 are the second column, and so forth.\r\n */\r\n m31: number;\r\n /**\r\n * The following are double-precision floating-point values representing each component of a 4×4 matrix, where m11 through m14 are the first column, m21 through m24 are the second column, and so forth.\r\n */\r\n m32: number;\r\n /**\r\n * The following are double-precision floating-point values representing each component of a 4×4 matrix, where m11 through m14 are the first column, m21 through m24 are the second column, and so forth.\r\n */\r\n m33: number;\r\n /**\r\n * The following are double-precision floating-point values representing each component of a 4×4 matrix, where m11 through m14 are the first column, m21 through m24 are the second column, and so forth.\r\n */\r\n m34: number;\r\n /**\r\n * The following are double-precision floating-point values representing each component of a 4×4 matrix, where m11 through m14 are the first column, m21 through m24 are the second column, and so forth.\r\n */\r\n m41: number;\r\n /**\r\n * The following are double-precision floating-point values representing each component of a 4×4 matrix, where m11 through m14 are the first column, m21 through m24 are the second column, and so forth.\r\n */\r\n m42: number;\r\n /**\r\n * The following are double-precision floating-point values representing each component of a 4×4 matrix, where m11 through m14 are the first column, m21 through m24 are the second column, and so forth.\r\n */\r\n m43: number;\r\n /**\r\n * The following are double-precision floating-point values representing each component of a 4×4 matrix, where m11 through m14 are the first column, m21 through m24 are the second column, and so forth.\r\n */\r\n m44: number;\r\n}\r\n\r\n/**\r\n * Class used to abstract canvas rendering\r\n */\r\nexport interface ICanvasRenderingContext {\r\n /**\r\n * Defines the type of corners where two lines meet. Possible values: round, bevel, miter (default).\r\n */\r\n lineJoin: string;\r\n\r\n /**\r\n * Miter limit ratio. Default 10.\r\n */\r\n miterLimit: number;\r\n\r\n /**\r\n * Font setting. Default value 10px sans-serif.\r\n */\r\n font: string;\r\n\r\n /**\r\n * Color or style to use for the lines around shapes. Default #000 (black).\r\n */\r\n strokeStyle: string | ICanvasGradient;\r\n\r\n /**\r\n * Color or style to use inside shapes. Default #000 (black).\r\n */\r\n fillStyle: string | ICanvasGradient;\r\n\r\n /**\r\n * Alpha value that is applied to shapes and images before they are composited onto the canvas. Default 1.0 (opaque).\r\n */\r\n globalAlpha: number;\r\n\r\n /**\r\n * Color of the shadow. Default: fully-transparent black.\r\n */\r\n shadowColor: string;\r\n\r\n /**\r\n * Specifies the blurring effect. Default: 0.\r\n */\r\n shadowBlur: number;\r\n\r\n /**\r\n * Horizontal distance the shadow will be offset. Default: 0.\r\n */\r\n shadowOffsetX: number;\r\n\r\n /**\r\n * Vertical distance the shadow will be offset. Default: 0.\r\n */\r\n shadowOffsetY: number;\r\n\r\n /**\r\n * Width of lines. Default 1.0.\r\n */\r\n lineWidth: number;\r\n\r\n /**\r\n * canvas is a read-only reference to ICanvas.\r\n */\r\n readonly canvas: ICanvas;\r\n\r\n /**\r\n * Sets all pixels in the rectangle defined by starting point (x, y) and size (width, height) to transparent black, erasing any previously drawn content.\r\n * @param x The x-axis coordinate of the rectangle's starting point.\r\n * @param y The y-axis coordinate of the rectangle's starting point.\r\n * @param width The rectangle's width. Positive values are to the right, and negative to the left.\r\n * @param height The rectangle's height. Positive values are down, and negative are up.\r\n */\r\n clearRect(x: number, y: number, width: number, height: number): void;\r\n\r\n /**\r\n * Saves the current drawing style state using a stack so you can revert any change you make to it using restore().\r\n */\r\n save(): void;\r\n\r\n /**\r\n * Restores the drawing style state to the last element on the 'state stack' saved by save().\r\n */\r\n restore(): void;\r\n\r\n /**\r\n * Draws a filled rectangle at (x, y) position whose size is determined by width and height.\r\n * @param x The x-axis coordinate of the rectangle's starting point.\r\n * @param y The y-axis coordinate of the rectangle's starting point.\r\n * @param width The rectangle's width. Positive values are to the right, and negative to the left.\r\n * @param height The rectangle's height. Positive values are down, and negative are up.\r\n */\r\n fillRect(x: number, y: number, width: number, height: number): void;\r\n\r\n /**\r\n * Adds a scaling transformation to the canvas units by x horizontally and by y vertically.\r\n * @param x Scaling factor in the horizontal direction. A negative value flips pixels across the vertical axis. A value of 1 results in no horizontal scaling.\r\n * @param y Scaling factor in the vertical direction. A negative value flips pixels across the horizontal axis. A value of 1 results in no vertical scaling.\r\n */\r\n scale(x: number, y: number): void;\r\n\r\n /**\r\n * Adds a rotation to the transformation matrix. The angle argument represents a clockwise rotation angle and is expressed in radians.\r\n * @param angle The rotation angle, clockwise in radians. You can use degree * Math.PI / 180 to calculate a radian from a degree.\r\n */\r\n rotate(angle: number): void;\r\n\r\n /**\r\n * Adds a translation transformation by moving the canvas and its origin x horizontally and y vertically on the grid.\r\n * @param x Distance to move in the horizontal direction. Positive values are to the right, and negative to the left.\r\n * @param y Distance to move in the vertical direction. Positive values are down, and negative are up.\r\n */\r\n translate(x: number, y: number): void;\r\n\r\n /**\r\n * Paints a rectangle which has a starting point at (x, y) and has a w width and an h height onto the canvas, using the current stroke style.\r\n * @param x The x-axis coordinate of the rectangle's starting point.\r\n * @param y The y-axis coordinate of the rectangle's starting point.\r\n * @param width The rectangle's width. Positive values are to the right, and negative to the left.\r\n * @param height The rectangle's height. Positive values are down, and negative are up.\r\n */\r\n strokeRect(x: number, y: number, width: number, height: number): void;\r\n\r\n /**\r\n * Creates a path for a rectangle at position (x, y) with a size that is determined by width and height.\r\n * @param x The x-axis coordinate of the rectangle's starting point.\r\n * @param y The y-axis coordinate of the rectangle's starting point.\r\n * @param width The rectangle's width. Positive values are to the right, and negative to the left.\r\n * @param height The rectangle's height. Positive values are down, and negative are up.\r\n */\r\n rect(x: number, y: number, width: number, height: number): void;\r\n\r\n /**\r\n * Creates a clipping path from the current sub-paths. Everything drawn after clip() is called appears inside the clipping path only.\r\n */\r\n clip(): void;\r\n\r\n /**\r\n * Paints data from the given ImageData object onto the bitmap. If a dirty rectangle is provided, only the pixels from that rectangle are painted.\r\n * @param imageData An ImageData object containing the array of pixel values.\r\n * @param dx Horizontal position (x coordinate) at which to place the image data in the destination canvas.\r\n * @param dy Vertical position (y coordinate) at which to place the image data in the destination canvas.\r\n */\r\n putImageData(imageData: ImageData, dx: number, dy: number): void;\r\n\r\n /**\r\n * Adds a circular arc to the current path.\r\n * @param x The horizontal coordinate of the arc's center.\r\n * @param y The vertical coordinate of the arc's center.\r\n * @param radius The arc's radius. Must be positive.\r\n * @param startAngle The angle at which the arc starts in radians, measured from the positive x-axis.\r\n * @param endAngle The angle at which the arc ends in radians, measured from the positive x-axis.\r\n * @param anticlockwise An optional Boolean. If true, draws the arc counter-clockwise between the start and end angles. The default is false (clockwise).\r\n */\r\n arc(x: number, y: number, radius: number, startAngle: number, endAngle: number, anticlockwise?: boolean): void;\r\n\r\n /**\r\n * Starts a new path by emptying the list of sub-paths. Call this method when you want to create a new path.\r\n */\r\n beginPath(): void;\r\n\r\n /**\r\n * Causes the point of the pen to move back to the start of the current sub-path. It tries to draw a straight line from the current point to the start.\r\n * If the shape has already been closed or has only one point, this function does nothing.\r\n */\r\n closePath(): void;\r\n\r\n /**\r\n * Moves the starting point of a new sub-path to the (x, y) coordinates.\r\n * @param x The x-axis (horizontal) coordinate of the point.\r\n * @param y The y-axis (vertical) coordinate of the point.\r\n */\r\n moveTo(x: number, y: number): void;\r\n\r\n /**\r\n * Connects the last point in the current sub-path to the specified (x, y) coordinates with a straight line.\r\n * @param x The x-axis coordinate of the line's end point.\r\n * @param y The y-axis coordinate of the line's end point.\r\n */\r\n lineTo(x: number, y: number): void;\r\n\r\n /**\r\n * Adds a quadratic Bézier curve to the current path.\r\n * @param cpx The x-axis coordinate of the control point.\r\n * @param cpy The y-axis coordinate of the control point.\r\n * @param x The x-axis coordinate of the end point.\r\n * @param y The y-axis coordinate of the end point.\r\n */\r\n quadraticCurveTo(cpx: number, cpy: number, x: number, y: number): void;\r\n\r\n /**\r\n * Returns a TextMetrics object.\r\n * @param text The text String to measure.\r\n * @returns ITextMetrics A ITextMetrics object.\r\n */\r\n measureText(text: string): ITextMetrics;\r\n\r\n /**\r\n * Strokes the current sub-paths with the current stroke style.\r\n */\r\n stroke(): void;\r\n\r\n /**\r\n * Fills the current sub-paths with the current fill style.\r\n */\r\n fill(): void;\r\n\r\n /**\r\n * Draws the specified image. This method is available in multiple formats, providing a great deal of flexibility in its use.\r\n * @param image An element to draw into the context.\r\n * @param sx The x-axis coordinate of the top left corner of the sub-rectangle of the source image to draw into the destination context.\r\n * @param sy The y-axis coordinate of the top left corner of the sub-rectangle of the source image to draw into the destination context.\r\n * @param sWidth The width of the sub-rectangle of the source image to draw into the destination context. If not specified, the entire rectangle from the coordinates specified by sx and sy to the bottom-right corner of the image is used.\r\n * @param sHeight The height of the sub-rectangle of the source image to draw into the destination context.\r\n * @param dx The x-axis coordinate in the destination canvas at which to place the top-left corner of the source image.\r\n * @param dy The y-axis coordinate in the destination canvas at which to place the top-left corner of the source image.\r\n * @param dWidth The width to draw the image in the destination canvas. This allows scaling of the drawn image. If not specified, the image is not scaled in width when drawn.\r\n * @param dHeight The height to draw the image in the destination canvas. This allows scaling of the drawn image. If not specified, the image is not scaled in height when drawn.\r\n */\r\n\r\n drawImage(image: any, sx: number, sy: number, sWidth: number, sHeight: number, dx: number, dy: number, dWidth: number, dHeight: number): void;\r\n /**\r\n * Draws the specified image. This method is available in multiple formats, providing a great deal of flexibility in its use.\r\n * @param image An element to draw into the context.\r\n * @param dx The x-axis coordinate in the destination canvas at which to place the top-left corner of the source image.\r\n * @param dy The y-axis coordinate in the destination canvas at which to place the top-left corner of the source image.\r\n * @param dWidth The width to draw the image in the destination canvas. This allows scaling of the drawn image. If not specified, the image is not scaled in width when drawn.\r\n * @param dHeight The height to draw the image in the destination canvas. This allows scaling of the drawn image. If not specified, the image is not scaled in height when drawn.\r\n */\r\n drawImage(image: any, dx: number, dy: number, dWidth: number, dHeight: number): void;\r\n\r\n /**\r\n * Draws the specified image. This method is available in multiple formats, providing a great deal of flexibility in its use.\r\n * @param image An element to draw into the context.\r\n * @param dx The x-axis coordinate in the destination canvas at which to place the top-left corner of the source image.\r\n * @param dy The y-axis coordinate in the destination canvas at which to place the top-left corner of the source image.\r\n */\r\n drawImage(image: any, dx: number, dy: number): void;\r\n\r\n /**\r\n * Returns an ImageData object representing the underlying pixel data for the area of the canvas denoted by the rectangle which starts at (sx, sy) and has an sw width and sh height.\r\n * @param sx The x-axis coordinate of the top-left corner of the rectangle from which the ImageData will be extracted.\r\n * @param sy The y-axis coordinate of the top-left corner of the rectangle from which the ImageData will be extracted.\r\n * @param sw The width of the rectangle from which the ImageData will be extracted. Positive values are to the right, and negative to the left.\r\n * @param sh The height of the rectangle from which the ImageData will be extracted. Positive values are down, and negative are up.\r\n * @returns ImageData An ImageData object containing the image data for the rectangle of the canvas specified.\r\n */\r\n getImageData(sx: number, sy: number, sw: number, sh: number): ImageData;\r\n\r\n /**\r\n * Sets the current line dash pattern.\r\n * @param segments An Array of numbers that specify distances to alternately draw a line and a gap (in coordinate space units).\r\n */\r\n setLineDash(segments: Array<number>): void;\r\n\r\n /**\r\n * Draws (fills) a given text at the given (x, y) position.\r\n * @param text A String specifying the text string to render into the context. The text is rendered using the settings specified by font, textAlign, textBaseline, and direction.\r\n * @param x The x-axis coordinate of the point at which to begin drawing the text, in pixels.\r\n * @param y The y-axis coordinate of the baseline on which to begin drawing the text, in pixels.\r\n * @param maxWidth The maximum number of pixels wide the text may be once rendered. If not specified, there is no limit to the width of the text.\r\n */\r\n fillText(text: string, x: number, y: number, maxWidth?: number): void;\r\n\r\n /**\r\n * Draws (strokes) a given text at the given (x, y) position.\r\n * @param text A String specifying the text string to render into the context. The text is rendered using the settings specified by font, textAlign, textBaseline, and direction.\r\n * @param x The x-axis coordinate of the point at which to begin drawing the text, in pixels.\r\n * @param y The y-axis coordinate of the baseline on which to begin drawing the text, in pixels.\r\n * @param maxWidth The maximum number of pixels wide the text may be once rendered. If not specified, there is no limit to the width of the text.\r\n */\r\n strokeText(text: string, x: number, y: number, maxWidth?: number): void;\r\n\r\n /**\r\n * Creates a linear gradient along the line given by the coordinates represented by the parameters.\r\n * @param x0 The x-axis coordinate of the start point.\r\n * @param y0 The y-axis coordinate of the start point.\r\n * @param x1 The x-axis coordinate of the end point.\r\n * @param y1 The y-axis coordinate of the end point.\r\n * @returns ICanvasGradient A linear ICanvasGradient initialized with the specified line.\r\n */\r\n createLinearGradient(x0: number, y0: number, x1: number, y1: number): ICanvasGradient;\r\n\r\n /**\r\n * Creates a linear gradient along the line given by the coordinates represented by the parameters.\r\n * @param x0 The x-axis coordinate of the start circle.\r\n * @param y0 The y-axis coordinate of the start circle.\r\n * @param r0 The radius of the start circle. Must be non-negative and finite.\r\n * @param x1 The x-axis coordinate of the end point.\r\n * @param y1 The y-axis coordinate of the end point.\r\n * @param r1 The radius of the end circle. Must be non-negative and finite.\r\n * @returns ICanvasGradient A linear ICanvasGradient initialized with the two specified circles.\r\n */\r\n createRadialGradient(x0: number, y0: number, r0: number, x1: number, y1: number, r1: number): ICanvasGradient;\r\n\r\n /**\r\n * Resets the current transform to matrix composed with a, b, c, d, e, f.\r\n * @param a Horizontal scaling. A value of 1 results in no scaling.\r\n * @param b Vertical skewing.\r\n * @param c Horizontal skewing.\r\n * @param d Vertical scaling. A value of 1 results in no scaling.\r\n * @param e Horizontal translation (moving).\r\n * @param f Vertical translation (moving).\r\n */\r\n setTransform(a: number, b: number, c: number, d: number, e: number, f: number): void;\r\n\r\n /**\r\n * Retrieves the current transformation matrix being applied to the context.\r\n */\r\n getTransform(): DOMMatrix;\r\n}\r\n"]}
1
+ {"version":3,"file":"ICanvas.js","sourceRoot":"","sources":["../../../../dev/core/src/Engines/ICanvas.ts"],"names":[],"mappings":"","sourcesContent":["/**\r\n * Class used to abstract a canvas\r\n */\r\nexport interface ICanvas {\r\n /**\r\n * Canvas width.\r\n */\r\n width: number;\r\n\r\n /**\r\n * Canvas height.\r\n */\r\n height: number;\r\n\r\n /**\r\n * returns a drawing context on the canvas.\r\n * @param contextType context identifier.\r\n * @param contextAttributes context attributes.\r\n * @returns ICanvasRenderingContext object.\r\n */\r\n getContext(contextType: string, contextAttributes?: any): ICanvasRenderingContext;\r\n\r\n /**\r\n * returns a data URI containing a representation of the image in the format specified by the type parameter.\r\n * @param mime the image format.\r\n * @returns string containing the requested data URI.\r\n */\r\n toDataURL(mime: string): string;\r\n\r\n /**\r\n * Removes the canvas from the document.\r\n * Offscreen canvases don't have the remove function, so we need to make it optional.\r\n */\r\n remove?(): void;\r\n}\r\n\r\n/**\r\n * Class used to abstract am image to use with the canvas and its context\r\n */\r\nexport interface IImage {\r\n /**\r\n * onload callback.\r\n */\r\n onload: ((this: GlobalEventHandlers, ev: Event) => any) | null;\r\n\r\n /**\r\n * Error callback.\r\n */\r\n onerror: ((this: GlobalEventHandlers, ev: Event) => any) | null;\r\n\r\n /**\r\n * Image source.\r\n */\r\n src: string;\r\n\r\n /**\r\n * Image width.\r\n */\r\n readonly width: number;\r\n\r\n /**\r\n * Image height.\r\n */\r\n readonly height: number;\r\n\r\n /**\r\n * The original height of the image resource before sizing.\r\n */\r\n readonly naturalHeight: number;\r\n\r\n /**\r\n * The original width of the image resource before sizing.\r\n */\r\n readonly naturalWidth: number;\r\n\r\n /**\r\n * provides support for CORS, defining how the element handles crossorigin requests,\r\n * thereby enabling the configuration of the CORS requests for the element's fetched data.\r\n */\r\n crossOrigin: string | null;\r\n\r\n /**\r\n * provides support for referrer policy on xhr load request,\r\n * it is used to control the request header.\r\n */\r\n referrerPolicy: string;\r\n}\r\n\r\n/**\r\n * Class used to abstract a canvas gradient\r\n */\r\nexport interface ICanvasGradient {\r\n /**\r\n * adds a new color stop, defined by an offset and a color, to a given canvas gradient.\r\n * @param offset A number between 0 and 1, inclusive, representing the position of the color stop. 0 represents the start of the gradient and 1 represents the end.\r\n * @param color value representing the color of the stop.\r\n */\r\n addColorStop(offset: number, color: string): void;\r\n}\r\n\r\n/**\r\n * Class used to abstract a text measurement\r\n */\r\nexport interface ITextMetrics {\r\n /**\r\n * Text width.\r\n */\r\n readonly width: number;\r\n /**\r\n * distance (in pixels) parallel to the baseline from the alignment point given by the CanvasRenderingContext2D.textAlign\r\n * property to the left side of the bounding rectangle of the given text\r\n */\r\n readonly actualBoundingBoxLeft: number;\r\n /**\r\n * distance (in pixels) parallel to the baseline from the alignment point given by the CanvasRenderingContext2D.textAlign\r\n * property to the right side of the bounding rectangle of the given text\r\n */\r\n readonly actualBoundingBoxRight: number;\r\n /**\r\n * distance (in pixels) from the horizontal line indicated by the CanvasRenderingContext2D.textBaseline\r\n * property to the top side of the bounding rectangle of the given text\r\n */\r\n readonly actualBoundingBoxAscent: number;\r\n /**\r\n * distance (in pixels) from the horizontal line indicated by the CanvasRenderingContext2D.textBaseline\r\n * property to the bottom side of the bounding rectangle of the given text\r\n */\r\n readonly actualBoundingBoxDescent: number;\r\n}\r\n\r\n/**\r\n * Class used to abstract a matrix\r\n */\r\nexport interface DOMMatrix {\r\n /**\r\n * A Boolean flag whose value is true if the matrix was initialized as a 2D matrix. If false, the matrix is 3D.\r\n */\r\n is2D: boolean;\r\n /**\r\n * A Boolean whose value is true if the matrix is the identity matrix. The identity matrix is one in which every value is 0 except those on the main diagonal from top-left to bottom-right corner (in other words, where the offsets in each direction are equal).\r\n */\r\n isIdentity: boolean;\r\n /**\r\n * The following double-precision floating-point values represent the components of a matrix which are required in order to perform 2D rotations and translations.\r\n */\r\n a: number;\r\n /**\r\n * The following double-precision floating-point values represent the components of a matrix which are required in order to perform 2D rotations and translations.\r\n */\r\n b: number;\r\n /**\r\n * The following double-precision floating-point values represent the components of a matrix which are required in order to perform 2D rotations and translations.\r\n */\r\n c: number;\r\n /**\r\n * The following double-precision floating-point values represent the components of a matrix which are required in order to perform 2D rotations and translations.\r\n */\r\n d: number;\r\n /**\r\n * The following double-precision floating-point values represent the components of a matrix which are required in order to perform 2D rotations and translations.\r\n */\r\n e: number;\r\n /**\r\n * The following double-precision floating-point values represent the components of a matrix which are required in order to perform 2D rotations and translations.\r\n */\r\n f: number;\r\n /**\r\n * The following are double-precision floating-point values representing each component of a 4×4 matrix, where m11 through m14 are the first column, m21 through m24 are the second column, and so forth.\r\n */\r\n m11: number;\r\n /**\r\n * The following are double-precision floating-point values representing each component of a 4×4 matrix, where m11 through m14 are the first column, m21 through m24 are the second column, and so forth.\r\n */\r\n m12: number;\r\n /**\r\n * The following are double-precision floating-point values representing each component of a 4×4 matrix, where m11 through m14 are the first column, m21 through m24 are the second column, and so forth.\r\n */\r\n m13: number;\r\n /**\r\n * The following are double-precision floating-point values representing each component of a 4×4 matrix, where m11 through m14 are the first column, m21 through m24 are the second column, and so forth.\r\n */\r\n m14: number;\r\n /**\r\n * The following are double-precision floating-point values representing each component of a 4×4 matrix, where m11 through m14 are the first column, m21 through m24 are the second column, and so forth.\r\n */\r\n m21: number;\r\n /**\r\n * The following are double-precision floating-point values representing each component of a 4×4 matrix, where m11 through m14 are the first column, m21 through m24 are the second column, and so forth.\r\n */\r\n m22: number;\r\n /**\r\n * The following are double-precision floating-point values representing each component of a 4×4 matrix, where m11 through m14 are the first column, m21 through m24 are the second column, and so forth.\r\n */\r\n m23: number;\r\n /**\r\n * The following are double-precision floating-point values representing each component of a 4×4 matrix, where m11 through m14 are the first column, m21 through m24 are the second column, and so forth.\r\n */\r\n m24: number;\r\n /**\r\n * The following are double-precision floating-point values representing each component of a 4×4 matrix, where m11 through m14 are the first column, m21 through m24 are the second column, and so forth.\r\n */\r\n m31: number;\r\n /**\r\n * The following are double-precision floating-point values representing each component of a 4×4 matrix, where m11 through m14 are the first column, m21 through m24 are the second column, and so forth.\r\n */\r\n m32: number;\r\n /**\r\n * The following are double-precision floating-point values representing each component of a 4×4 matrix, where m11 through m14 are the first column, m21 through m24 are the second column, and so forth.\r\n */\r\n m33: number;\r\n /**\r\n * The following are double-precision floating-point values representing each component of a 4×4 matrix, where m11 through m14 are the first column, m21 through m24 are the second column, and so forth.\r\n */\r\n m34: number;\r\n /**\r\n * The following are double-precision floating-point values representing each component of a 4×4 matrix, where m11 through m14 are the first column, m21 through m24 are the second column, and so forth.\r\n */\r\n m41: number;\r\n /**\r\n * The following are double-precision floating-point values representing each component of a 4×4 matrix, where m11 through m14 are the first column, m21 through m24 are the second column, and so forth.\r\n */\r\n m42: number;\r\n /**\r\n * The following are double-precision floating-point values representing each component of a 4×4 matrix, where m11 through m14 are the first column, m21 through m24 are the second column, and so forth.\r\n */\r\n m43: number;\r\n /**\r\n * The following are double-precision floating-point values representing each component of a 4×4 matrix, where m11 through m14 are the first column, m21 through m24 are the second column, and so forth.\r\n */\r\n m44: number;\r\n}\r\n\r\n/**\r\n * Class used to abstract canvas rendering\r\n */\r\nexport interface ICanvasRenderingContext {\r\n /**\r\n * Defines the type of corners where two lines meet. Possible values: round, bevel, miter (default).\r\n */\r\n lineJoin: string;\r\n\r\n /**\r\n * Miter limit ratio. Default 10.\r\n */\r\n miterLimit: number;\r\n\r\n /**\r\n * Font setting. Default value 10px sans-serif.\r\n */\r\n font: string;\r\n\r\n /**\r\n * Color or style to use for the lines around shapes. Default #000 (black).\r\n */\r\n strokeStyle: string | ICanvasGradient;\r\n\r\n /**\r\n * Color or style to use inside shapes. Default #000 (black).\r\n */\r\n fillStyle: string | ICanvasGradient;\r\n\r\n /**\r\n * Alpha value that is applied to shapes and images before they are composited onto the canvas. Default 1.0 (opaque).\r\n */\r\n globalAlpha: number;\r\n\r\n /**\r\n * Color of the shadow. Default: fully-transparent black.\r\n */\r\n shadowColor: string;\r\n\r\n /**\r\n * Specifies the blurring effect. Default: 0.\r\n */\r\n shadowBlur: number;\r\n\r\n /**\r\n * Horizontal distance the shadow will be offset. Default: 0.\r\n */\r\n shadowOffsetX: number;\r\n\r\n /**\r\n * Vertical distance the shadow will be offset. Default: 0.\r\n */\r\n shadowOffsetY: number;\r\n\r\n /**\r\n * Width of lines. Default 1.0.\r\n */\r\n lineWidth: number;\r\n\r\n /**\r\n * canvas is a read-only reference to ICanvas.\r\n */\r\n readonly canvas: ICanvas;\r\n\r\n /**\r\n * Sets all pixels in the rectangle defined by starting point (x, y) and size (width, height) to transparent black, erasing any previously drawn content.\r\n * @param x The x-axis coordinate of the rectangle's starting point.\r\n * @param y The y-axis coordinate of the rectangle's starting point.\r\n * @param width The rectangle's width. Positive values are to the right, and negative to the left.\r\n * @param height The rectangle's height. Positive values are down, and negative are up.\r\n */\r\n clearRect(x: number, y: number, width: number, height: number): void;\r\n\r\n /**\r\n * Saves the current drawing style state using a stack so you can revert any change you make to it using restore().\r\n */\r\n save(): void;\r\n\r\n /**\r\n * Restores the drawing style state to the last element on the 'state stack' saved by save().\r\n */\r\n restore(): void;\r\n\r\n /**\r\n * Draws a filled rectangle at (x, y) position whose size is determined by width and height.\r\n * @param x The x-axis coordinate of the rectangle's starting point.\r\n * @param y The y-axis coordinate of the rectangle's starting point.\r\n * @param width The rectangle's width. Positive values are to the right, and negative to the left.\r\n * @param height The rectangle's height. Positive values are down, and negative are up.\r\n */\r\n fillRect(x: number, y: number, width: number, height: number): void;\r\n\r\n /**\r\n * Adds a scaling transformation to the canvas units by x horizontally and by y vertically.\r\n * @param x Scaling factor in the horizontal direction. A negative value flips pixels across the vertical axis. A value of 1 results in no horizontal scaling.\r\n * @param y Scaling factor in the vertical direction. A negative value flips pixels across the horizontal axis. A value of 1 results in no vertical scaling.\r\n */\r\n scale(x: number, y: number): void;\r\n\r\n /**\r\n * Adds a rotation to the transformation matrix. The angle argument represents a clockwise rotation angle and is expressed in radians.\r\n * @param angle The rotation angle, clockwise in radians. You can use degree * Math.PI / 180 to calculate a radian from a degree.\r\n */\r\n rotate(angle: number): void;\r\n\r\n /**\r\n * Adds a translation transformation by moving the canvas and its origin x horizontally and y vertically on the grid.\r\n * @param x Distance to move in the horizontal direction. Positive values are to the right, and negative to the left.\r\n * @param y Distance to move in the vertical direction. Positive values are down, and negative are up.\r\n */\r\n translate(x: number, y: number): void;\r\n\r\n /**\r\n * Paints a rectangle which has a starting point at (x, y) and has a w width and an h height onto the canvas, using the current stroke style.\r\n * @param x The x-axis coordinate of the rectangle's starting point.\r\n * @param y The y-axis coordinate of the rectangle's starting point.\r\n * @param width The rectangle's width. Positive values are to the right, and negative to the left.\r\n * @param height The rectangle's height. Positive values are down, and negative are up.\r\n */\r\n strokeRect(x: number, y: number, width: number, height: number): void;\r\n\r\n /**\r\n * Creates a path for a rectangle at position (x, y) with a size that is determined by width and height.\r\n * @param x The x-axis coordinate of the rectangle's starting point.\r\n * @param y The y-axis coordinate of the rectangle's starting point.\r\n * @param width The rectangle's width. Positive values are to the right, and negative to the left.\r\n * @param height The rectangle's height. Positive values are down, and negative are up.\r\n */\r\n rect(x: number, y: number, width: number, height: number): void;\r\n\r\n /**\r\n * Creates a clipping path from the current sub-paths. Everything drawn after clip() is called appears inside the clipping path only.\r\n */\r\n clip(): void;\r\n\r\n /**\r\n * Paints data from the given ImageData object onto the bitmap. If a dirty rectangle is provided, only the pixels from that rectangle are painted.\r\n * @param imageData An ImageData object containing the array of pixel values.\r\n * @param dx Horizontal position (x coordinate) at which to place the image data in the destination canvas.\r\n * @param dy Vertical position (y coordinate) at which to place the image data in the destination canvas.\r\n */\r\n putImageData(imageData: ImageData, dx: number, dy: number): void;\r\n\r\n /**\r\n * Adds a circular arc to the current path.\r\n * @param x The horizontal coordinate of the arc's center.\r\n * @param y The vertical coordinate of the arc's center.\r\n * @param radius The arc's radius. Must be positive.\r\n * @param startAngle The angle at which the arc starts in radians, measured from the positive x-axis.\r\n * @param endAngle The angle at which the arc ends in radians, measured from the positive x-axis.\r\n * @param anticlockwise An optional Boolean. If true, draws the arc counter-clockwise between the start and end angles. The default is false (clockwise).\r\n */\r\n arc(x: number, y: number, radius: number, startAngle: number, endAngle: number, anticlockwise?: boolean): void;\r\n\r\n /**\r\n * Starts a new path by emptying the list of sub-paths. Call this method when you want to create a new path.\r\n */\r\n beginPath(): void;\r\n\r\n /**\r\n * Causes the point of the pen to move back to the start of the current sub-path. It tries to draw a straight line from the current point to the start.\r\n * If the shape has already been closed or has only one point, this function does nothing.\r\n */\r\n closePath(): void;\r\n\r\n /**\r\n * Moves the starting point of a new sub-path to the (x, y) coordinates.\r\n * @param x The x-axis (horizontal) coordinate of the point.\r\n * @param y The y-axis (vertical) coordinate of the point.\r\n */\r\n moveTo(x: number, y: number): void;\r\n\r\n /**\r\n * Connects the last point in the current sub-path to the specified (x, y) coordinates with a straight line.\r\n * @param x The x-axis coordinate of the line's end point.\r\n * @param y The y-axis coordinate of the line's end point.\r\n */\r\n lineTo(x: number, y: number): void;\r\n\r\n /**\r\n * Adds a quadratic Bézier curve to the current path.\r\n * @param cpx The x-axis coordinate of the control point.\r\n * @param cpy The y-axis coordinate of the control point.\r\n * @param x The x-axis coordinate of the end point.\r\n * @param y The y-axis coordinate of the end point.\r\n */\r\n quadraticCurveTo(cpx: number, cpy: number, x: number, y: number): void;\r\n\r\n /**\r\n * Returns a TextMetrics object.\r\n * @param text The text String to measure.\r\n * @returns ITextMetrics A ITextMetrics object.\r\n */\r\n measureText(text: string): ITextMetrics;\r\n\r\n /**\r\n * Strokes the current sub-paths with the current stroke style.\r\n */\r\n stroke(): void;\r\n\r\n /**\r\n * Fills the current sub-paths with the current fill style.\r\n */\r\n fill(): void;\r\n\r\n /**\r\n * Draws the specified image. This method is available in multiple formats, providing a great deal of flexibility in its use.\r\n * @param image An element to draw into the context.\r\n * @param sx The x-axis coordinate of the top left corner of the sub-rectangle of the source image to draw into the destination context.\r\n * @param sy The y-axis coordinate of the top left corner of the sub-rectangle of the source image to draw into the destination context.\r\n * @param sWidth The width of the sub-rectangle of the source image to draw into the destination context. If not specified, the entire rectangle from the coordinates specified by sx and sy to the bottom-right corner of the image is used.\r\n * @param sHeight The height of the sub-rectangle of the source image to draw into the destination context.\r\n * @param dx The x-axis coordinate in the destination canvas at which to place the top-left corner of the source image.\r\n * @param dy The y-axis coordinate in the destination canvas at which to place the top-left corner of the source image.\r\n * @param dWidth The width to draw the image in the destination canvas. This allows scaling of the drawn image. If not specified, the image is not scaled in width when drawn.\r\n * @param dHeight The height to draw the image in the destination canvas. This allows scaling of the drawn image. If not specified, the image is not scaled in height when drawn.\r\n */\r\n\r\n drawImage(image: any, sx: number, sy: number, sWidth: number, sHeight: number, dx: number, dy: number, dWidth: number, dHeight: number): void;\r\n /**\r\n * Draws the specified image. This method is available in multiple formats, providing a great deal of flexibility in its use.\r\n * @param image An element to draw into the context.\r\n * @param dx The x-axis coordinate in the destination canvas at which to place the top-left corner of the source image.\r\n * @param dy The y-axis coordinate in the destination canvas at which to place the top-left corner of the source image.\r\n * @param dWidth The width to draw the image in the destination canvas. This allows scaling of the drawn image. If not specified, the image is not scaled in width when drawn.\r\n * @param dHeight The height to draw the image in the destination canvas. This allows scaling of the drawn image. If not specified, the image is not scaled in height when drawn.\r\n */\r\n drawImage(image: any, dx: number, dy: number, dWidth: number, dHeight: number): void;\r\n\r\n /**\r\n * Draws the specified image. This method is available in multiple formats, providing a great deal of flexibility in its use.\r\n * @param image An element to draw into the context.\r\n * @param dx The x-axis coordinate in the destination canvas at which to place the top-left corner of the source image.\r\n * @param dy The y-axis coordinate in the destination canvas at which to place the top-left corner of the source image.\r\n */\r\n drawImage(image: any, dx: number, dy: number): void;\r\n\r\n /**\r\n * Returns an ImageData object representing the underlying pixel data for the area of the canvas denoted by the rectangle which starts at (sx, sy) and has an sw width and sh height.\r\n * @param sx The x-axis coordinate of the top-left corner of the rectangle from which the ImageData will be extracted.\r\n * @param sy The y-axis coordinate of the top-left corner of the rectangle from which the ImageData will be extracted.\r\n * @param sw The width of the rectangle from which the ImageData will be extracted. Positive values are to the right, and negative to the left.\r\n * @param sh The height of the rectangle from which the ImageData will be extracted. Positive values are down, and negative are up.\r\n * @returns ImageData An ImageData object containing the image data for the rectangle of the canvas specified.\r\n */\r\n getImageData(sx: number, sy: number, sw: number, sh: number): ImageData;\r\n\r\n /**\r\n * Sets the current line dash pattern.\r\n * @param segments An Array of numbers that specify distances to alternately draw a line and a gap (in coordinate space units).\r\n */\r\n setLineDash(segments: Array<number>): void;\r\n\r\n /**\r\n * Draws (fills) a given text at the given (x, y) position.\r\n * @param text A String specifying the text string to render into the context. The text is rendered using the settings specified by font, textAlign, textBaseline, and direction.\r\n * @param x The x-axis coordinate of the point at which to begin drawing the text, in pixels.\r\n * @param y The y-axis coordinate of the baseline on which to begin drawing the text, in pixels.\r\n * @param maxWidth The maximum number of pixels wide the text may be once rendered. If not specified, there is no limit to the width of the text.\r\n */\r\n fillText(text: string, x: number, y: number, maxWidth?: number): void;\r\n\r\n /**\r\n * Draws (strokes) a given text at the given (x, y) position.\r\n * @param text A String specifying the text string to render into the context. The text is rendered using the settings specified by font, textAlign, textBaseline, and direction.\r\n * @param x The x-axis coordinate of the point at which to begin drawing the text, in pixels.\r\n * @param y The y-axis coordinate of the baseline on which to begin drawing the text, in pixels.\r\n * @param maxWidth The maximum number of pixels wide the text may be once rendered. If not specified, there is no limit to the width of the text.\r\n */\r\n strokeText(text: string, x: number, y: number, maxWidth?: number): void;\r\n\r\n /**\r\n * Creates a linear gradient along the line given by the coordinates represented by the parameters.\r\n * @param x0 The x-axis coordinate of the start point.\r\n * @param y0 The y-axis coordinate of the start point.\r\n * @param x1 The x-axis coordinate of the end point.\r\n * @param y1 The y-axis coordinate of the end point.\r\n * @returns ICanvasGradient A linear ICanvasGradient initialized with the specified line.\r\n */\r\n createLinearGradient(x0: number, y0: number, x1: number, y1: number): ICanvasGradient;\r\n\r\n /**\r\n * Creates a linear gradient along the line given by the coordinates represented by the parameters.\r\n * @param x0 The x-axis coordinate of the start circle.\r\n * @param y0 The y-axis coordinate of the start circle.\r\n * @param r0 The radius of the start circle. Must be non-negative and finite.\r\n * @param x1 The x-axis coordinate of the end point.\r\n * @param y1 The y-axis coordinate of the end point.\r\n * @param r1 The radius of the end circle. Must be non-negative and finite.\r\n * @returns ICanvasGradient A linear ICanvasGradient initialized with the two specified circles.\r\n */\r\n createRadialGradient(x0: number, y0: number, r0: number, x1: number, y1: number, r1: number): ICanvasGradient;\r\n\r\n /**\r\n * Resets the current transform to matrix composed with a, b, c, d, e, f.\r\n * @param a Horizontal scaling. A value of 1 results in no scaling.\r\n * @param b Vertical skewing.\r\n * @param c Horizontal skewing.\r\n * @param d Vertical scaling. A value of 1 results in no scaling.\r\n * @param e Horizontal translation (moving).\r\n * @param f Vertical translation (moving).\r\n */\r\n setTransform(a: number, b: number, c: number, d: number, e: number, f: number): void;\r\n\r\n /**\r\n * Retrieves the current transformation matrix being applied to the context.\r\n */\r\n getTransform(): DOMMatrix;\r\n}\r\n"]}
@@ -1,3 +1,4 @@
1
+ import type { DeepImmutable, FloatArray } from "../../types";
1
2
  /** @internal */
2
3
  export type NativeData = Uint32Array;
3
4
  /** @internal */
@@ -39,7 +40,7 @@ export declare class NativeDataStream {
39
40
  * Writes a float32 array to the stream
40
41
  * @param values the values to write
41
42
  */
42
- writeFloat32Array(values: Float32Array): void;
43
+ writeFloat32Array(values: DeepImmutable<FloatArray>): void;
43
44
  /**
44
45
  * Writes native data to the stream
45
46
  * @param handle the handle to the native data
@@ -1 +1 @@
1
- {"version":3,"file":"nativeDataStream.js","sourceRoot":"","sources":["../../../../../dev/core/src/Engines/Native/nativeDataStream.ts"],"names":[],"mappings":"AAOA,gBAAgB;AAChB,MAAM,OAAO,gBAAgB;IAYzB;QACI,MAAM,MAAM,GAAG,IAAI,WAAW,CAAC,gBAAgB,CAAC,mBAAmB,CAAC,CAAC;QACrE,IAAI,CAAC,QAAQ,GAAG,IAAI,WAAW,CAAC,MAAM,CAAC,CAAC;QACxC,IAAI,CAAC,OAAO,GAAG,IAAI,UAAU,CAAC,MAAM,CAAC,CAAC;QACtC,IAAI,CAAC,SAAS,GAAG,IAAI,YAAY,CAAC,MAAM,CAAC,CAAC;QAE1C,IAAI,CAAC,OAAO,GAAG,gBAAgB,CAAC,mBAAmB,GAAG,CAAC,CAAC;QACxD,IAAI,CAAC,SAAS,GAAG,CAAC,CAAC;QAEnB,IAAI,CAAC,iBAAiB,GAAG,IAAI,OAAO,CAAC,gBAAgB,CAAC,GAAG,EAAE;YACvD,IAAI,CAAC,MAAM,EAAE,CAAC;QAClB,CAAC,CAAC,CAAC;IACP,CAAC;IAED;;;OAGG;IACI,WAAW,CAAC,KAAa;QAC5B,IAAI,CAAC,iBAAiB,CAAC,CAAC,CAAC,CAAC;QAC1B,IAAI,CAAC,QAAQ,CAAC,IAAI,CAAC,SAAS,EAAE,CAAC,GAAG,KAAK,CAAC;IAC5C,CAAC;IAED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AAS,EAAE,CAAC,GAAG,MAAM,CAAC,MAAM,CAAC;QAChD,IAAI,CAAC,SAAS,CAAC,GAAG,CAAC,MAAM,EAAE,IAAI,CAAC,SAAS,CAAC,CAAC;QAC3C,IAAI,CAAC,SAAS,IAAI,MAAM,CAAC,MAAM,CAAC;IACpC,CAAC;IAED;;;OAGG;IACI,eAAe,CAAC,MAAkB;QACrC,IAAI,CAAC,iBAAiB,CAAC,MAAM,CAAC,MAAM,CAAC,CAAC;QACtC,IAAI,CAAC,QAAQ,CAAC,GAAG,CAAC,MAAM,EAAE,IAAI,CAAC,SAAS,CAAC,CAAC;QAC1C,IAAI,CAAC,SAAS,IAAI,MAAM,CAAC,MAAM,CAAC;IACpC,CAAC;IAED;;;OAGG;IACI,YAAY,CAAC,KAAc;QAC9B,IAAI,CAAC,WAAW,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;IACpC,CAAC;IAEO,iBAAiB,CAAC,QAAgB;QACtC,IAAI,IAAI,CAAC,SAAS,GAAG,QAAQ,GAAG,IAAI,CAAC,OAAO,EAAE;YAC1C,IAAI,CAAC,MAAM,EAAE,CAAC;SACjB;IACL,CAAC;IAEO,MAAM;QACV,IAAI,CAAC,iBAAiB,CAAC,WAAW,CAAC,IAAI,CAAC,QAAQ,CAAC,MAAM,EAAE,IAAI,CAAC,SAAS,CAAC,CAAC;QACzE,IAAI,CAAC,SAAS,GAAG,CAAC,CAAC;IACvB,CAAC;;AAzGD,yBAAyB;AACzB,gEAAgE;AACxC,oCAAmB,GAAG,KAAK,CAAC","sourcesContent":["import type { INative, INativeDataStream } from \"./nativeInterfaces\";\r\n\r\ndeclare const _native: INative;\r\n\r\n/** @internal */\r\nexport type NativeData = Uint32Array;\r\n\r\n/** @internal */\r\nexport class NativeDataStream {\r\n private readonly _uint32s: Uint32Array;\r\n private readonly _int32s: Int32Array;\r\n private readonly _float32s: Float32Array;\r\n private readonly _length: number;\r\n private _position: number;\r\n private readonly _nativeDataStream: INativeDataStream;\r\n\r\n // Must be multiple of 4!\r\n // eslint-disable-next-line @typescript-eslint/naming-convention\r\n private static readonly DEFAULT_BUFFER_SIZE = 65536;\r\n\r\n constructor() {\r\n const buffer = new ArrayBuffer(NativeDataStream.DEFAULT_BUFFER_SIZE);\r\n this._uint32s = new Uint32Array(buffer);\r\n this._int32s = new Int32Array(buffer);\r\n this._float32s = new Float32Array(buffer);\r\n\r\n this._length = NativeDataStream.DEFAULT_BUFFER_SIZE / 4;\r\n this._position = 0;\r\n\r\n this._nativeDataStream = new _native.NativeDataStream(() => {\r\n this._flush();\r\n });\r\n }\r\n\r\n /**\r\n * Writes a uint32 to the stream\r\n * @param value the value to write\r\n */\r\n public writeUint32(value: number): void {\r\n this._flushIfNecessary(1);\r\n this._uint32s[this._position++] = value;\r\n }\r\n\r\n /**\r\n * Writes an int32 to the stream\r\n * @param value the value to write\r\n */\r\n public writeInt32(value: number): void {\r\n this._flushIfNecessary(1);\r\n this._int32s[this._position++] = value;\r\n }\r\n\r\n /**\r\n * Writes a float32 to the stream\r\n * @param value the value to write\r\n */\r\n public writeFloat32(value: number): void {\r\n this._flushIfNecessary(1);\r\n this._float32s[this._position++] = value;\r\n }\r\n\r\n /**\r\n * Writes a uint32 array to the stream\r\n * @param values the values to write\r\n */\r\n public writeUint32Array(values: Uint32Array): void {\r\n this._flushIfNecessary(1 + values.length);\r\n this._uint32s[this._position++] = values.length;\r\n this._uint32s.set(values, this._position);\r\n this._position += values.length;\r\n }\r\n\r\n /**\r\n * Writes an int32 array to the stream\r\n * @param values the values to write\r\n */\r\n public writeInt32Array(values: Int32Array): void {\r\n this._flushIfNecessary(1 + values.length);\r\n this._uint32s[this._position++] = values.length;\r\n this._int32s.set(values, this._position);\r\n this._position += values.length;\r\n }\r\n\r\n /**\r\n * Writes a float32 array to the stream\r\n * @param values the values to write\r\n */\r\n public writeFloat32Array(values: Float32Array): void {\r\n this._flushIfNecessary(1 + values.length);\r\n this._uint32s[this._position++] = values.length;\r\n this._float32s.set(values, this._position);\r\n this._position += values.length;\r\n }\r\n\r\n /**\r\n * Writes native data to the stream\r\n * @param handle the handle to the native data\r\n */\r\n public writeNativeData(handle: NativeData) {\r\n this._flushIfNecessary(handle.length);\r\n this._uint32s.set(handle, this._position);\r\n this._position += handle.length;\r\n }\r\n\r\n /**\r\n * Writes a boolean to the stream\r\n * @param value the value to write\r\n */\r\n public writeBoolean(value: boolean) {\r\n this.writeUint32(value ? 1 : 0);\r\n }\r\n\r\n private _flushIfNecessary(required: number): void {\r\n if (this._position + required > this._length) {\r\n this._flush();\r\n }\r\n }\r\n\r\n private _flush(): void {\r\n this._nativeDataStream.writeBuffer(this._uint32s.buffer, this._position);\r\n this._position = 0;\r\n }\r\n}\r\n"]}
1
+ {"version":3,"file":"nativeDataStream.js","sourceRoot":"","sources":["../../../../../dev/core/src/Engines/Native/nativeDataStream.ts"],"names":[],"mappings":"AAQA,gBAAgB;AAChB,MAAM,OAAO,gBAAgB;IAYzB;QACI,MAAM,MAAM,GAAG,IAAI,WAAW,CAAC,gBAAgB,CAAC,mBAAmB,CAAC,CAAC;QACrE,IAAI,CAAC,QAAQ,GAAG,IAAI,WAAW,CAAC,MAAM,CAAC,CAAC;QACxC,IAAI,CAAC,OAAO,GAAG,IAAI,UAAU,CAAC,MAAM,CAAC,CAAC;QACtC,IAAI,CAAC,SAAS,GAAG,IAAI,YAAY,CAAC,MAAM,CAAC,CAAC;QAE1C,IAAI,CAAC,OAAO,GAAG,gBAAgB,CAAC,mBAAmB,GAAG,CAAC,CAAC;QACxD,IAAI,CAAC,SAAS,GAAG,CAAC,CAAC;QAEnB,IAAI,CAAC,iBAAiB,GAAG,IAAI,OAAO,CAAC,gBAAgB,CAAC,GAAG,EAAE;YACvD,IAAI,CAAC,MAAM,EAAE,CAAC;QAClB,CAAC,CAAC,CAAC;IACP,CAAC;IAED;;;OAGG;IACI,WAAW,CAAC,KAAa;QAC5B,IAAI,CAAC,iBAAiB,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;QACtD,IAAI,CAAC,iBAAiB,CAAC,CAAC,GAAG,MAAM,CAAC,MAAM,CAAC,CAAC;QAC1C,IAAI,CAAC,QAAQ,CAAC,IAAI,CAAC,SAAS,EAAE,CAAC,GAAG,MAAM,CAAC,MAAM,CAAC;QAChD,IAAI,CAAC,SAAS,CAAC,GAAG,CAAC,MAAM,EAAE,IAAI,CAAC,SAAS,CAAC,CAAC;QAC3C,IAAI,CAAC,SAAS,IAAI,MAAM,CAAC,MAAM,CAAC;IACpC,CAAC;IAED;;;OAGG;IACI,eAAe,CAAC,MAAkB;QACrC,IAAI,CAAC,iBAAiB,CAAC,MAAM,CAAC,MAAM,CAAC,CAAC;QACtC,IAAI,CAAC,QAAQ,CAAC,GAAG,CAAC,MAAM,EAAE,IAAI,CAAC,SAAS,CAAC,CAAC;QAC1C,IAAI,CAAC,SAAS,IAAI,MAAM,CAAC,MAAM,CAAC;IACpC,CAAC;IAED;;;OAGG;IACI,YAAY,CAAC,KAAc;QAC9B,IAAI,CAAC,WAAW,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;IACpC,CAAC;IAEO,iBAAiB,CAAC,QAAgB;QACtC,IAAI,IAAI,CAAC,SAAS,GAAG,QAAQ,GAAG,IAAI,CAAC,OAAO,EAAE;YAC1C,IAAI,CAAC,MAAM,EAAE,CAAC;SACjB;IACL,CAAC;IAEO,MAAM;QACV,IAAI,CAAC,iBAAiB,CAAC,WAAW,CAAC,IAAI,CAAC,QAAQ,CAAC,MAAM,EAAE,IAAI,CAAC,SAAS,CAAC,CAAC;QACzE,IAAI,CAAC,SAAS,GAAG,CAAC,CAAC;IACvB,CAAC;;AAzGD,yBAAyB;AACzB,gEAAgE;AACxC,oCAAmB,GAAG,KAAK,CAAC","sourcesContent":["import type { DeepImmutable, FloatArray } from \"../../types\";\r\nimport type { INative, INativeDataStream } from \"./nativeInterfaces\";\r\n\r\ndeclare const _native: INative;\r\n\r\n/** @internal */\r\nexport type NativeData = Uint32Array;\r\n\r\n/** @internal */\r\nexport class NativeDataStream {\r\n private readonly _uint32s: Uint32Array;\r\n private readonly _int32s: Int32Array;\r\n private readonly _float32s: Float32Array;\r\n private readonly _length: number;\r\n private _position: number;\r\n private readonly _nativeDataStream: INativeDataStream;\r\n\r\n // Must be multiple of 4!\r\n // eslint-disable-next-line @typescript-eslint/naming-convention\r\n private static readonly DEFAULT_BUFFER_SIZE = 65536;\r\n\r\n constructor() {\r\n const buffer = new ArrayBuffer(NativeDataStream.DEFAULT_BUFFER_SIZE);\r\n this._uint32s = new Uint32Array(buffer);\r\n this._int32s = new Int32Array(buffer);\r\n this._float32s = new Float32Array(buffer);\r\n\r\n this._length = NativeDataStream.DEFAULT_BUFFER_SIZE / 4;\r\n this._position = 0;\r\n\r\n this._nativeDataStream = new _native.NativeDataStream(() => {\r\n this._flush();\r\n });\r\n }\r\n\r\n /**\r\n * Writes a uint32 to the stream\r\n * @param value the value to write\r\n */\r\n public writeUint32(value: number): void {\r\n this._flushIfNecessary(1);\r\n this._uint32s[this._position++] = value;\r\n }\r\n\r\n /**\r\n * Writes an int32 to the stream\r\n * @param value the value to write\r\n */\r\n public writeInt32(value: number): void {\r\n this._flushIfNecessary(1);\r\n this._int32s[this._position++] = value;\r\n }\r\n\r\n /**\r\n * Writes a float32 to the stream\r\n * @param value the value to write\r\n */\r\n public writeFloat32(value: number): void {\r\n this._flushIfNecessary(1);\r\n this._float32s[this._position++] = value;\r\n }\r\n\r\n /**\r\n * Writes a uint32 array to the stream\r\n * @param values the values to write\r\n */\r\n public writeUint32Array(values: Uint32Array): void {\r\n this._flushIfNecessary(1 + values.length);\r\n this._uint32s[this._position++] = values.length;\r\n this._uint32s.set(values, this._position);\r\n this._position += values.length;\r\n }\r\n\r\n /**\r\n * Writes an int32 array to the stream\r\n * @param values the values to write\r\n */\r\n public writeInt32Array(values: Int32Array): void {\r\n this._flushIfNecessary(1 + values.length);\r\n this._uint32s[this._position++] = values.length;\r\n this._int32s.set(values, this._position);\r\n this._position += values.length;\r\n }\r\n\r\n /**\r\n * Writes a float32 array to the stream\r\n * @param values the values to write\r\n */\r\n public writeFloat32Array(values: DeepImmutable<FloatArray>): void {\r\n this._flushIfNecessary(1 + values.length);\r\n this._uint32s[this._position++] = values.length;\r\n this._float32s.set(values, this._position);\r\n this._position += values.length;\r\n }\r\n\r\n /**\r\n * Writes native data to the stream\r\n * @param handle the handle to the native data\r\n */\r\n public writeNativeData(handle: NativeData) {\r\n this._flushIfNecessary(handle.length);\r\n this._uint32s.set(handle, this._position);\r\n this._position += handle.length;\r\n }\r\n\r\n /**\r\n * Writes a boolean to the stream\r\n * @param value the value to write\r\n */\r\n public writeBoolean(value: boolean) {\r\n this.writeUint32(value ? 1 : 0);\r\n }\r\n\r\n private _flushIfNecessary(required: number): void {\r\n if (this._position + required > this._length) {\r\n this._flush();\r\n }\r\n }\r\n\r\n private _flush(): void {\r\n this._nativeDataStream.writeBuffer(this._uint32s.buffer, this._position);\r\n this._position = 0;\r\n }\r\n}\r\n"]}