@babylonjs/core 7.11.2 → 7.11.3

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 (104) hide show
  1. package/Animations/animatable.d.ts +10 -10
  2. package/Animations/animatable.js +5 -5
  3. package/Animations/animatable.js.map +1 -1
  4. package/Animations/animationGroupMask.d.ts +2 -2
  5. package/Animations/animationGroupMask.js +1 -1
  6. package/Animations/animationGroupMask.js.map +1 -1
  7. package/Animations/easing.d.ts +2 -2
  8. package/Animations/easing.js +1 -1
  9. package/Animations/easing.js.map +1 -1
  10. package/Behaviors/Meshes/attachToBoxBehavior.d.ts +3 -3
  11. package/Behaviors/Meshes/attachToBoxBehavior.js +3 -3
  12. package/Behaviors/Meshes/attachToBoxBehavior.js.map +1 -1
  13. package/Cameras/Inputs/freeCameraMouseInput.d.ts +2 -2
  14. package/Cameras/Inputs/freeCameraMouseInput.js +1 -1
  15. package/Cameras/Inputs/freeCameraMouseInput.js.map +1 -1
  16. package/Cameras/Inputs/freeCameraTouchInput.d.ts +2 -2
  17. package/Cameras/Inputs/freeCameraTouchInput.js +1 -1
  18. package/Cameras/Inputs/freeCameraTouchInput.js.map +1 -1
  19. package/Culling/Helper/boundingInfoHelper.d.ts +28 -0
  20. package/Culling/Helper/boundingInfoHelper.js +178 -0
  21. package/Culling/Helper/boundingInfoHelper.js.map +1 -0
  22. package/Culling/Helper/webgl2BoundingHelper.d.ts +22 -0
  23. package/Culling/Helper/webgl2BoundingHelper.js +61 -0
  24. package/Culling/Helper/webgl2BoundingHelper.js.map +1 -0
  25. package/Culling/Octrees/octree.d.ts +2 -2
  26. package/Culling/Octrees/octree.js +1 -1
  27. package/Culling/Octrees/octree.js.map +1 -1
  28. package/Culling/index.d.ts +1 -0
  29. package/Culling/index.js +1 -0
  30. package/Culling/index.js.map +1 -1
  31. package/Culling/ray.d.ts +4 -4
  32. package/Culling/ray.js +2 -2
  33. package/Culling/ray.js.map +1 -1
  34. package/Debug/skeletonViewer.d.ts +6 -6
  35. package/Debug/skeletonViewer.js +3 -3
  36. package/Debug/skeletonViewer.js.map +1 -1
  37. package/DeviceInput/InputDevices/deviceSource.d.ts +2 -2
  38. package/DeviceInput/InputDevices/deviceSource.js +1 -1
  39. package/DeviceInput/InputDevices/deviceSource.js.map +1 -1
  40. package/Engines/Extensions/engine.transformFeedback.d.ts +5 -0
  41. package/Engines/Extensions/engine.transformFeedback.js +3 -0
  42. package/Engines/Extensions/engine.transformFeedback.js.map +1 -1
  43. package/Engines/abstractEngine.js +2 -2
  44. package/Engines/abstractEngine.js.map +1 -1
  45. package/Engines/nativeEngine.d.ts +7 -0
  46. package/Engines/nativeEngine.js +4 -1
  47. package/Engines/nativeEngine.js.map +1 -1
  48. package/Maths/math.color.d.ts +14 -14
  49. package/Maths/math.color.js +7 -7
  50. package/Maths/math.color.js.map +1 -1
  51. package/Maths/math.isovector.d.ts +4 -4
  52. package/Maths/math.isovector.js +2 -2
  53. package/Maths/math.isovector.js.map +1 -1
  54. package/Maths/math.vector.d.ts +12 -12
  55. package/Maths/math.vector.js +6 -6
  56. package/Maths/math.vector.js.map +1 -1
  57. package/Maths/math.vertexFormat.d.ts +10 -10
  58. package/Maths/math.vertexFormat.js +5 -5
  59. package/Maths/math.vertexFormat.js.map +1 -1
  60. package/Meshes/mesh.d.ts +4 -0
  61. package/Meshes/mesh.js +13 -4
  62. package/Meshes/mesh.js.map +1 -1
  63. package/Misc/observable.d.ts +6 -6
  64. package/Misc/observable.js +4 -4
  65. package/Misc/observable.js.map +1 -1
  66. package/Misc/sceneOptimizer.d.ts +3 -3
  67. package/Misc/sceneOptimizer.js +2 -2
  68. package/Misc/sceneOptimizer.js.map +1 -1
  69. package/Particles/EmitterTypes/coneParticleEmitter.d.ts +2 -2
  70. package/Particles/EmitterTypes/coneParticleEmitter.js +1 -1
  71. package/Particles/EmitterTypes/coneParticleEmitter.js.map +1 -1
  72. package/Particles/EmitterTypes/cylinderParticleEmitter.d.ts +8 -8
  73. package/Particles/EmitterTypes/cylinderParticleEmitter.js +4 -4
  74. package/Particles/EmitterTypes/cylinderParticleEmitter.js.map +1 -1
  75. package/Particles/EmitterTypes/hemisphericParticleEmitter.d.ts +6 -6
  76. package/Particles/EmitterTypes/hemisphericParticleEmitter.js +3 -3
  77. package/Particles/EmitterTypes/hemisphericParticleEmitter.js.map +1 -1
  78. package/Particles/EmitterTypes/sphereParticleEmitter.d.ts +6 -6
  79. package/Particles/EmitterTypes/sphereParticleEmitter.js +3 -3
  80. package/Particles/EmitterTypes/sphereParticleEmitter.js.map +1 -1
  81. package/Particles/pointsCloudSystem.d.ts +0 -1
  82. package/Particles/pointsCloudSystem.js +0 -1
  83. package/Particles/pointsCloudSystem.js.map +1 -1
  84. package/Shaders/gpuTransform.fragment.d.ts +5 -0
  85. package/Shaders/gpuTransform.fragment.js +11 -0
  86. package/Shaders/gpuTransform.fragment.js.map +1 -0
  87. package/Shaders/gpuTransform.vertex.d.ts +13 -0
  88. package/Shaders/gpuTransform.vertex.js +33 -0
  89. package/Shaders/gpuTransform.vertex.js.map +1 -0
  90. package/XR/features/WebXRBackgroundRemover.d.ts +2 -2
  91. package/XR/features/WebXRBackgroundRemover.js +1 -1
  92. package/XR/features/WebXRBackgroundRemover.js.map +1 -1
  93. package/XR/features/WebXRHitTest.d.ts +2 -2
  94. package/XR/features/WebXRHitTest.js +1 -1
  95. package/XR/features/WebXRHitTest.js.map +1 -1
  96. package/XR/features/WebXRHitTestLegacy.d.ts +2 -2
  97. package/XR/features/WebXRHitTestLegacy.js +1 -1
  98. package/XR/features/WebXRHitTestLegacy.js.map +1 -1
  99. package/XR/features/WebXRRawCameraAccess.js +0 -2
  100. package/XR/features/WebXRRawCameraAccess.js.map +1 -1
  101. package/XR/motionController/webXRAbstractMotionController.d.ts +2 -0
  102. package/XR/motionController/webXRAbstractMotionController.js +1 -0
  103. package/XR/motionController/webXRAbstractMotionController.js.map +1 -1
  104. package/package.json +1 -1
@@ -1 +1 @@
1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IACa,UAAU,CAAC,QAAgB;QACvC,OAAO,QAAQ,GAAG,QAAQ,GAAG,QAAQ,GAAG,QAAQ,GAAG,QAAQ,CAAC;IAChE,CAAC;CACJ;AAED;;;;GAIG;AACH,MAAM,OAAO,QAAS,SAAQ,cAAc;IACxC;;OAEG;IACa,UAAU,CAAC,QAAgB;QACvC,OAAO,GAAG,GAAG,IAAI,CAAC,GAAG,CAAC,kBAAkB,GAAG,CAAC,GAAG,GAAG,QAAQ,CAAC,CAAC,CAAC;IACjE,CAAC;CACJ;AAED;;;;GAIG;AACH,MAAM,OAAO,eAAgB,SAAQ,cAAc;IAC/C;;;;;;;OAOG;IACH;IACI,uEAAuE;IAChE,KAAa,CAAC;IACrB,uEAAuE;IAChE,KAAa,CAAC;IACrB,qEAAqE;IAC9D,KAAa,CAAC;IACrB,qEAAqE;IAC9D,KAAa,CAAC;QAErB,KAAK,EAAE,CAAC;QARD,OAAE,GAAF,EAAE,CAAY;QAEd,OAAE,GAAF,EAAE,CAAY;QAEd,OAAE,GAAF,EAAE,CAAY;QAEd,OAAE,GAAF,EAAE,CAAY;IAGzB,CAAC;IAED;;OAEG;IACa,UAAU,CAAC,QAAgB;QACvC,OAAO,WAAW,CAAC,WAAW,CAAC,QAAQ,EAAE,IAAI,CAAC,EAAE,EAAE,IAAI,CAAC,EAAE,EAAE,IAAI,CAAC,EAAE,EAAE,IAAI,CAAC,EAAE,CAAC,CAAC;IACjF,CAAC;CACJ","sourcesContent":["import { BezierCurve } from \"../Maths/math.path\";\r\n\r\n/**\r\n * This represents the main contract an easing function should follow.\r\n * Easing functions are used throughout the animation system.\r\n * @see https://doc.babylonjs.com/features/featuresDeepDive/animation/advanced_animations#easing-functions\r\n */\r\nexport interface IEasingFunction {\r\n /**\r\n * Given an input gradient between 0 and 1, this returns the corresponding value\r\n * of the easing function.\r\n * The link below provides some of the most common examples of easing functions.\r\n * @see https://easings.net/\r\n * @param gradient Defines the value between 0 and 1 we want the easing value for\r\n * @returns the corresponding value on the curve defined by the easing function\r\n */\r\n ease(gradient: number): number;\r\n}\r\n\r\n/**\r\n * Base class used for every default easing function.\r\n * @see https://doc.babylonjs.com/features/featuresDeepDive/animation/advanced_animations#easing-functions\r\n */\r\nexport class EasingFunction implements IEasingFunction {\r\n /**\r\n * Interpolation follows the mathematical formula associated with the easing function.\r\n */\r\n public static readonly EASINGMODE_EASEIN = 0;\r\n\r\n /**\r\n * Interpolation follows 100% interpolation minus the output of the formula associated with the easing function.\r\n */\r\n public static readonly EASINGMODE_EASEOUT = 1;\r\n\r\n /**\r\n * Interpolation uses EaseIn for the first half of the animation and EaseOut for the second half.\r\n */\r\n public static readonly EASINGMODE_EASEINOUT = 2;\r\n\r\n private _easingMode = EasingFunction.EASINGMODE_EASEIN;\r\n\r\n /**\r\n * Sets the easing mode of the current function.\r\n * @param easingMode Defines the willing mode (EASINGMODE_EASEIN, EASINGMODE_EASEOUT or EASINGMODE_EASEINOUT)\r\n */\r\n public setEasingMode(easingMode: number) {\r\n const n = Math.min(Math.max(easingMode, 0), 2);\r\n this._easingMode = n;\r\n }\r\n /**\r\n * Gets the current easing mode.\r\n * @returns the easing mode\r\n */\r\n public getEasingMode(): number {\r\n return this._easingMode;\r\n }\r\n\r\n /**\r\n * @internal\r\n */\r\n // eslint-disable-next-line @typescript-eslint/no-unused-vars\r\n public easeInCore(gradient: number): number {\r\n throw new Error(\"You must implement this method\");\r\n }\r\n\r\n /**\r\n * Given an input gradient between 0 and 1, this returns the corresponding value\r\n * of the easing function.\r\n * @param gradient Defines the value between 0 and 1 we want the easing value for\r\n * @returns the corresponding value on the curve defined by the easing function\r\n */\r\n public ease(gradient: number): number {\r\n switch (this._easingMode) {\r\n case EasingFunction.EASINGMODE_EASEIN:\r\n return this.easeInCore(gradient);\r\n case EasingFunction.EASINGMODE_EASEOUT:\r\n return 1 - this.easeInCore(1 - gradient);\r\n }\r\n\r\n if (gradient >= 0.5) {\r\n return (1 - this.easeInCore((1 - gradient) * 2)) * 0.5 + 0.5;\r\n }\r\n\r\n return this.easeInCore(gradient * 2) * 0.5;\r\n }\r\n}\r\n\r\n/**\r\n * Easing function with a circle shape (see link below).\r\n * @see https://easings.net/#easeInCirc\r\n * @see https://doc.babylonjs.com/features/featuresDeepDive/animation/advanced_animations#easing-functions\r\n */\r\nexport class CircleEase extends EasingFunction implements IEasingFunction {\r\n /**\r\n * @internal\r\n */\r\n public override easeInCore(gradient: number): number {\r\n gradient = Math.max(0, Math.min(1, gradient));\r\n return 1.0 - Math.sqrt(1.0 - gradient * gradient);\r\n }\r\n}\r\n\r\n/**\r\n * Easing function with a ease back shape (see link below).\r\n * @see https://easings.net/#easeInBack\r\n * @see https://doc.babylonjs.com/features/featuresDeepDive/animation/advanced_animations#easing-functions\r\n */\r\nexport class BackEase extends EasingFunction implements IEasingFunction {\r\n /**\r\n * Instantiates a back ease easing\r\n * @see https://easings.net/#easeInBack\r\n * @param amplitude Defines the amplitude of the function\r\n */\r\n constructor(\r\n /** Defines the amplitude of the function */\r\n public amplitude: number = 1\r\n ) {\r\n super();\r\n }\r\n\r\n /**\r\n * @internal\r\n */\r\n public override easeInCore(gradient: number): number {\r\n const num = Math.max(0, this.amplitude);\r\n return Math.pow(gradient, 3.0) - gradient * num * Math.sin(3.1415926535897931 * gradient);\r\n }\r\n}\r\n\r\n/**\r\n * Easing function with a bouncing shape (see link below).\r\n * @see https://easings.net/#easeInBounce\r\n * @see https://doc.babylonjs.com/features/featuresDeepDive/animation/advanced_animations#easing-functions\r\n */\r\nexport class BounceEase extends EasingFunction implements IEasingFunction {\r\n /**\r\n * Instantiates a bounce easing\r\n * @see https://easings.net/#easeInBounce\r\n * @param bounces Defines the number of bounces\r\n * @param bounciness Defines the amplitude of the bounce\r\n */\r\n constructor(\r\n /** Defines the number of bounces */\r\n public bounces: number = 3,\r\n /** Defines the amplitude of the bounce */\r\n public bounciness: number = 2\r\n ) {\r\n super();\r\n }\r\n\r\n /**\r\n * @internal\r\n */\r\n public override easeInCore(gradient: number): number {\r\n const y = Math.max(0.0, this.bounces);\r\n let bounciness = this.bounciness;\r\n if (bounciness <= 1.0) {\r\n bounciness = 1.001;\r\n }\r\n const num9 = Math.pow(bounciness, y);\r\n const num5 = 1.0 - bounciness;\r\n const num4 = (1.0 - num9) / num5 + num9 * 0.5;\r\n const num15 = gradient * num4;\r\n const num65 = Math.log(-num15 * (1.0 - bounciness) + 1.0) / Math.log(bounciness);\r\n const num3 = Math.floor(num65);\r\n const num13 = num3 + 1.0;\r\n const num8 = (1.0 - Math.pow(bounciness, num3)) / (num5 * num4);\r\n const num12 = (1.0 - Math.pow(bounciness, num13)) / (num5 * num4);\r\n const num7 = (num8 + num12) * 0.5;\r\n const num6 = gradient - num7;\r\n const num2 = num7 - num8;\r\n return (-Math.pow(1.0 / bounciness, y - num3) / (num2 * num2)) * (num6 - num2) * (num6 + num2);\r\n }\r\n}\r\n\r\n/**\r\n * Easing function with a power of 3 shape (see link below).\r\n * @see https://easings.net/#easeInCubic\r\n * @see https://doc.babylonjs.com/features/featuresDeepDive/animation/advanced_animations#easing-functions\r\n */\r\nexport class CubicEase extends EasingFunction implements IEasingFunction {\r\n /**\r\n * @internal\r\n */\r\n public override easeInCore(gradient: number): number {\r\n return gradient * gradient * gradient;\r\n }\r\n}\r\n\r\n/**\r\n * Easing function with an elastic shape (see link below).\r\n * @see https://easings.net/#easeInElastic\r\n * @see https://doc.babylonjs.com/features/featuresDeepDive/animation/advanced_animations#easing-functions\r\n */\r\nexport class ElasticEase extends EasingFunction implements IEasingFunction {\r\n /**\r\n * Instantiates an elastic easing function\r\n * @see https://easings.net/#easeInElastic\r\n * @param oscillations Defines the number of oscillations\r\n * @param springiness Defines the amplitude of the oscillations\r\n */\r\n constructor(\r\n /** Defines the number of oscillations*/\r\n public oscillations: number = 3,\r\n /** Defines the amplitude of the oscillations*/\r\n public springiness: number = 3\r\n ) {\r\n super();\r\n }\r\n\r\n /**\r\n * @internal\r\n */\r\n public override easeInCore(gradient: number): number {\r\n let num2;\r\n const num3 = Math.max(0.0, this.oscillations);\r\n const num = Math.max(0.0, this.springiness);\r\n\r\n if (num == 0) {\r\n num2 = gradient;\r\n } else {\r\n num2 = (Math.exp(num * gradient) - 1.0) / (Math.exp(num) - 1.0);\r\n }\r\n return num2 * Math.sin((6.2831853071795862 * num3 + 1.5707963267948966) * gradient);\r\n }\r\n}\r\n\r\n/**\r\n * Easing function with an exponential shape (see link below).\r\n * @see https://easings.net/#easeInExpo\r\n * @see https://doc.babylonjs.com/features/featuresDeepDive/animation/advanced_animations#easing-functions\r\n */\r\nexport class ExponentialEase extends EasingFunction implements IEasingFunction {\r\n /**\r\n * Instantiates an exponential easing function\r\n * @see https://easings.net/#easeInExpo\r\n * @param exponent Defines the exponent of the function\r\n */\r\n constructor(\r\n /** Defines the exponent of the function */\r\n public exponent: number = 2\r\n ) {\r\n super();\r\n }\r\n\r\n /**\r\n * @internal\r\n */\r\n public override easeInCore(gradient: number): number {\r\n if (this.exponent <= 0) {\r\n return gradient;\r\n }\r\n\r\n return (Math.exp(this.exponent * gradient) - 1.0) / (Math.exp(this.exponent) - 1.0);\r\n }\r\n}\r\n\r\n/**\r\n * Easing function with a power shape (see link below).\r\n * @see https://easings.net/#easeInQuad\r\n * @see https://doc.babylonjs.com/features/featuresDeepDive/animation/advanced_animations#easing-functions\r\n */\r\nexport class PowerEase extends EasingFunction implements IEasingFunction {\r\n /**\r\n * Instantiates an power base easing function\r\n * @see https://easings.net/#easeInQuad\r\n * @param power Defines the power of the function\r\n */\r\n constructor(\r\n /** Defines the power of the function */\r\n public power: number = 2\r\n ) {\r\n super();\r\n }\r\n\r\n /**\r\n * @internal\r\n */\r\n public override easeInCore(gradient: number): number {\r\n const y = Math.max(0.0, this.power);\r\n return Math.pow(gradient, y);\r\n }\r\n}\r\n\r\n/**\r\n * Easing function with a power of 2 shape (see link below).\r\n * @see https://easings.net/#easeInQuad\r\n * @see https://doc.babylonjs.com/features/featuresDeepDive/animation/advanced_animations#easing-functions\r\n */\r\nexport class QuadraticEase extends EasingFunction implements IEasingFunction {\r\n /**\r\n * @internal\r\n */\r\n public override easeInCore(gradient: number): number {\r\n return gradient * gradient;\r\n }\r\n}\r\n\r\n/**\r\n * Easing function with a power of 4 shape (see link below).\r\n * @see https://easings.net/#easeInQuart\r\n * @see https://doc.babylonjs.com/features/featuresDeepDive/animation/advanced_animations#easing-functions\r\n */\r\nexport class QuarticEase extends EasingFunction implements IEasingFunction {\r\n /**\r\n * @internal\r\n */\r\n public override easeInCore(gradient: number): number {\r\n return gradient * gradient * gradient * gradient;\r\n }\r\n}\r\n\r\n/**\r\n * Easing function with a power of 5 shape (see link below).\r\n * @see https://easings.net/#easeInQuint\r\n * @see https://doc.babylonjs.com/features/featuresDeepDive/animation/advanced_animations#easing-functions\r\n */\r\nexport class QuinticEase extends EasingFunction implements IEasingFunction {\r\n /**\r\n * @internal\r\n */\r\n public override easeInCore(gradient: number): number {\r\n return gradient * gradient * gradient * gradient * gradient;\r\n }\r\n}\r\n\r\n/**\r\n * Easing function with a sin shape (see link below).\r\n * @see https://easings.net/#easeInSine\r\n * @see https://doc.babylonjs.com/features/featuresDeepDive/animation/advanced_animations#easing-functions\r\n */\r\nexport class SineEase extends EasingFunction implements IEasingFunction {\r\n /**\r\n * @internal\r\n */\r\n public override easeInCore(gradient: number): number {\r\n return 1.0 - Math.sin(1.5707963267948966 * (1.0 - gradient));\r\n }\r\n}\r\n\r\n/**\r\n * Easing function with a bezier shape (see link below).\r\n * @see http://cubic-bezier.com/#.17,.67,.83,.67\r\n * @see https://doc.babylonjs.com/features/featuresDeepDive/animation/advanced_animations#easing-functions\r\n */\r\nexport class BezierCurveEase extends EasingFunction implements IEasingFunction {\r\n /**\r\n * Instantiates a bezier function\r\n * @see http://cubic-bezier.com/#.17,.67,.83,.67\r\n * @param x1 Defines the x component of the start tangent in the bezier curve\r\n * @param y1 Defines the y component of the start tangent in the bezier curve\r\n * @param x2 Defines the x component of the end tangent in the bezier curve\r\n * @param y2 Defines the y component of the end tangent in the bezier curve\r\n */\r\n constructor(\r\n /** Defines the x component of the start tangent in the bezier curve */\r\n public x1: number = 0,\r\n /** Defines the y component of the start tangent in the bezier curve */\r\n public y1: number = 0,\r\n /** Defines the x component of the end tangent in the bezier curve */\r\n public x2: number = 1,\r\n /** Defines the y component of the end tangent in the bezier curve */\r\n public y2: number = 1\r\n ) {\r\n super();\r\n }\r\n\r\n /**\r\n * @internal\r\n */\r\n public override easeInCore(gradient: number): number {\r\n return BezierCurve.Interpolate(gradient, this.x1, this.y1, this.x2, this.y2);\r\n }\r\n}\r\n"]}
1
+ {"version":3,"file":"easing.js","sourceRoot":"","sources":["../../../../dev/core/src/Animations/easing.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,oBAAoB,CAAC;AAmBjD;;;GAGG;AACH,MAAM,OAAO,cAAc;IAA3B;QAgBY,gBAAW,GAAG,cAAc,CAAC,iBAAiB,CAAC;IA8C3D,CAAC;IA5CG;;;OAGG;IACI,aAAa,CAAC,UAAkB;QACnC,MAAM,CAAC,GAAG,IAAI,CAAC,GAAG,CAAC,IAAI,CAAC,GAAG,CAAC,UAAU,EAAE,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC;QAC/C,IAAI,CAAC,WAAW,GAAG,CAAC,CAAC;IACzB,CAAC;IACD;;;OAGG;IACI,aAAa;QAChB,OAAO,IAAI,CAAC,WAAW,CAAC;IAC5B,CAAC;IAED;;OAEG;IACH,6DAA6D;IACtD,UAAU,CAAC,QAAgB;QAC9B,MAAM,IAAI,KAAK,CAAC,gCAAgC,CAAC,CAAC;IACtD,CAAC;IAED;;;;;OAKG;IACI,IAAI,CAAC,QAAgB;QACxB,QAAQ,IAAI,CAAC,WAAW,EAAE;YACtB,KAAK,cAAc,CAAC,iBAAiB;gBACjC,OAAO,IAAI,CAAC,UAAU,CAAC,QAAQ,CAAC,CAAC;YACrC,KAAK,cAAc,CAAC,kBAAkB;gBAClC,OAAO,CAAC,GAAG,IAAI,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AAE,CAAC,CAAC;IACjF,CAAC;CACJ","sourcesContent":["import { BezierCurve } from \"../Maths/math.path\";\r\n\r\n/**\r\n * This represents the main contract an easing function should follow.\r\n * Easing functions are used throughout the animation system.\r\n * @see https://doc.babylonjs.com/features/featuresDeepDive/animation/advanced_animations#easing-functions\r\n */\r\nexport interface IEasingFunction {\r\n /**\r\n * Given an input gradient between 0 and 1, this returns the corresponding value\r\n * of the easing function.\r\n * The link below provides some of the most common examples of easing functions.\r\n * @see https://easings.net/\r\n * @param gradient Defines the value between 0 and 1 we want the easing value for\r\n * @returns the corresponding value on the curve defined by the easing function\r\n */\r\n ease(gradient: number): number;\r\n}\r\n\r\n/**\r\n * Base class used for every default easing function.\r\n * @see https://doc.babylonjs.com/features/featuresDeepDive/animation/advanced_animations#easing-functions\r\n */\r\nexport class EasingFunction implements IEasingFunction {\r\n /**\r\n * Interpolation follows the mathematical formula associated with the easing function.\r\n */\r\n public static readonly EASINGMODE_EASEIN = 0;\r\n\r\n /**\r\n * Interpolation follows 100% interpolation minus the output of the formula associated with the easing function.\r\n */\r\n public static readonly EASINGMODE_EASEOUT = 1;\r\n\r\n /**\r\n * Interpolation uses EaseIn for the first half of the animation and EaseOut for the second half.\r\n */\r\n public static readonly EASINGMODE_EASEINOUT = 2;\r\n\r\n private _easingMode = EasingFunction.EASINGMODE_EASEIN;\r\n\r\n /**\r\n * Sets the easing mode of the current function.\r\n * @param easingMode Defines the willing mode (EASINGMODE_EASEIN, EASINGMODE_EASEOUT or EASINGMODE_EASEINOUT)\r\n */\r\n public setEasingMode(easingMode: number) {\r\n const n = Math.min(Math.max(easingMode, 0), 2);\r\n this._easingMode = n;\r\n }\r\n /**\r\n * Gets the current easing mode.\r\n * @returns the easing mode\r\n */\r\n public getEasingMode(): number {\r\n return this._easingMode;\r\n }\r\n\r\n /**\r\n * @internal\r\n */\r\n // eslint-disable-next-line @typescript-eslint/no-unused-vars\r\n public easeInCore(gradient: number): number {\r\n throw new Error(\"You must implement this method\");\r\n }\r\n\r\n /**\r\n * Given an input gradient between 0 and 1, this returns the corresponding value\r\n * of the easing function.\r\n * @param gradient Defines the value between 0 and 1 we want the easing value for\r\n * @returns the corresponding value on the curve defined by the easing function\r\n */\r\n public ease(gradient: number): number {\r\n switch (this._easingMode) {\r\n case EasingFunction.EASINGMODE_EASEIN:\r\n return this.easeInCore(gradient);\r\n case EasingFunction.EASINGMODE_EASEOUT:\r\n return 1 - this.easeInCore(1 - gradient);\r\n }\r\n\r\n if (gradient >= 0.5) {\r\n return (1 - this.easeInCore((1 - gradient) * 2)) * 0.5 + 0.5;\r\n }\r\n\r\n return this.easeInCore(gradient * 2) * 0.5;\r\n }\r\n}\r\n\r\n/**\r\n * Easing function with a circle shape (see link below).\r\n * @see https://easings.net/#easeInCirc\r\n * @see https://doc.babylonjs.com/features/featuresDeepDive/animation/advanced_animations#easing-functions\r\n */\r\nexport class CircleEase extends EasingFunction implements IEasingFunction {\r\n /**\r\n * @internal\r\n */\r\n public override easeInCore(gradient: number): number {\r\n gradient = Math.max(0, Math.min(1, gradient));\r\n return 1.0 - Math.sqrt(1.0 - gradient * gradient);\r\n }\r\n}\r\n\r\n/**\r\n * Easing function with a ease back shape (see link below).\r\n * @see https://easings.net/#easeInBack\r\n * @see https://doc.babylonjs.com/features/featuresDeepDive/animation/advanced_animations#easing-functions\r\n */\r\nexport class BackEase extends EasingFunction implements IEasingFunction {\r\n /**\r\n * Instantiates a back ease easing\r\n * @see https://easings.net/#easeInBack\r\n * @param amplitude Defines the amplitude of the function\r\n */\r\n constructor(\r\n /** [1] Defines the amplitude of the function */\r\n public amplitude: number = 1\r\n ) {\r\n super();\r\n }\r\n\r\n /**\r\n * @internal\r\n */\r\n public override easeInCore(gradient: number): number {\r\n const num = Math.max(0, this.amplitude);\r\n return Math.pow(gradient, 3.0) - gradient * num * Math.sin(3.1415926535897931 * gradient);\r\n }\r\n}\r\n\r\n/**\r\n * Easing function with a bouncing shape (see link below).\r\n * @see https://easings.net/#easeInBounce\r\n * @see https://doc.babylonjs.com/features/featuresDeepDive/animation/advanced_animations#easing-functions\r\n */\r\nexport class BounceEase extends EasingFunction implements IEasingFunction {\r\n /**\r\n * Instantiates a bounce easing\r\n * @see https://easings.net/#easeInBounce\r\n * @param bounces Defines the number of bounces\r\n * @param bounciness Defines the amplitude of the bounce\r\n */\r\n constructor(\r\n /** Defines the number of bounces */\r\n public bounces: number = 3,\r\n /** Defines the amplitude of the bounce */\r\n public bounciness: number = 2\r\n ) {\r\n super();\r\n }\r\n\r\n /**\r\n * @internal\r\n */\r\n public override easeInCore(gradient: number): number {\r\n const y = Math.max(0.0, this.bounces);\r\n let bounciness = this.bounciness;\r\n if (bounciness <= 1.0) {\r\n bounciness = 1.001;\r\n }\r\n const num9 = Math.pow(bounciness, y);\r\n const num5 = 1.0 - bounciness;\r\n const num4 = (1.0 - num9) / num5 + num9 * 0.5;\r\n const num15 = gradient * num4;\r\n const num65 = Math.log(-num15 * (1.0 - bounciness) + 1.0) / Math.log(bounciness);\r\n const num3 = Math.floor(num65);\r\n const num13 = num3 + 1.0;\r\n const num8 = (1.0 - Math.pow(bounciness, num3)) / (num5 * num4);\r\n const num12 = (1.0 - Math.pow(bounciness, num13)) / (num5 * num4);\r\n const num7 = (num8 + num12) * 0.5;\r\n const num6 = gradient - num7;\r\n const num2 = num7 - num8;\r\n return (-Math.pow(1.0 / bounciness, y - num3) / (num2 * num2)) * (num6 - num2) * (num6 + num2);\r\n }\r\n}\r\n\r\n/**\r\n * Easing function with a power of 3 shape (see link below).\r\n * @see https://easings.net/#easeInCubic\r\n * @see https://doc.babylonjs.com/features/featuresDeepDive/animation/advanced_animations#easing-functions\r\n */\r\nexport class CubicEase extends EasingFunction implements IEasingFunction {\r\n /**\r\n * @internal\r\n */\r\n public override easeInCore(gradient: number): number {\r\n return gradient * gradient * gradient;\r\n }\r\n}\r\n\r\n/**\r\n * Easing function with an elastic shape (see link below).\r\n * @see https://easings.net/#easeInElastic\r\n * @see https://doc.babylonjs.com/features/featuresDeepDive/animation/advanced_animations#easing-functions\r\n */\r\nexport class ElasticEase extends EasingFunction implements IEasingFunction {\r\n /**\r\n * Instantiates an elastic easing function\r\n * @see https://easings.net/#easeInElastic\r\n * @param oscillations Defines the number of oscillations\r\n * @param springiness Defines the amplitude of the oscillations\r\n */\r\n constructor(\r\n /** Defines the number of oscillations*/\r\n public oscillations: number = 3,\r\n /** Defines the amplitude of the oscillations*/\r\n public springiness: number = 3\r\n ) {\r\n super();\r\n }\r\n\r\n /**\r\n * @internal\r\n */\r\n public override easeInCore(gradient: number): number {\r\n let num2;\r\n const num3 = Math.max(0.0, this.oscillations);\r\n const num = Math.max(0.0, this.springiness);\r\n\r\n if (num == 0) {\r\n num2 = gradient;\r\n } else {\r\n num2 = (Math.exp(num * gradient) - 1.0) / (Math.exp(num) - 1.0);\r\n }\r\n return num2 * Math.sin((6.2831853071795862 * num3 + 1.5707963267948966) * gradient);\r\n }\r\n}\r\n\r\n/**\r\n * Easing function with an exponential shape (see link below).\r\n * @see https://easings.net/#easeInExpo\r\n * @see https://doc.babylonjs.com/features/featuresDeepDive/animation/advanced_animations#easing-functions\r\n */\r\nexport class ExponentialEase extends EasingFunction implements IEasingFunction {\r\n /**\r\n * Instantiates an exponential easing function\r\n * @see https://easings.net/#easeInExpo\r\n * @param exponent Defines the exponent of the function\r\n */\r\n constructor(\r\n /** Defines the exponent of the function */\r\n public exponent: number = 2\r\n ) {\r\n super();\r\n }\r\n\r\n /**\r\n * @internal\r\n */\r\n public override easeInCore(gradient: number): number {\r\n if (this.exponent <= 0) {\r\n return gradient;\r\n }\r\n\r\n return (Math.exp(this.exponent * gradient) - 1.0) / (Math.exp(this.exponent) - 1.0);\r\n }\r\n}\r\n\r\n/**\r\n * Easing function with a power shape (see link below).\r\n * @see https://easings.net/#easeInQuad\r\n * @see https://doc.babylonjs.com/features/featuresDeepDive/animation/advanced_animations#easing-functions\r\n */\r\nexport class PowerEase extends EasingFunction implements IEasingFunction {\r\n /**\r\n * Instantiates an power base easing function\r\n * @see https://easings.net/#easeInQuad\r\n * @param power Defines the power of the function\r\n */\r\n constructor(\r\n /** Defines the power of the function */\r\n public power: number = 2\r\n ) {\r\n super();\r\n }\r\n\r\n /**\r\n * @internal\r\n */\r\n public override easeInCore(gradient: number): number {\r\n const y = Math.max(0.0, this.power);\r\n return Math.pow(gradient, y);\r\n }\r\n}\r\n\r\n/**\r\n * Easing function with a power of 2 shape (see link below).\r\n * @see https://easings.net/#easeInQuad\r\n * @see https://doc.babylonjs.com/features/featuresDeepDive/animation/advanced_animations#easing-functions\r\n */\r\nexport class QuadraticEase extends EasingFunction implements IEasingFunction {\r\n /**\r\n * @internal\r\n */\r\n public override easeInCore(gradient: number): number {\r\n return gradient * gradient;\r\n }\r\n}\r\n\r\n/**\r\n * Easing function with a power of 4 shape (see link below).\r\n * @see https://easings.net/#easeInQuart\r\n * @see https://doc.babylonjs.com/features/featuresDeepDive/animation/advanced_animations#easing-functions\r\n */\r\nexport class QuarticEase extends EasingFunction implements IEasingFunction {\r\n /**\r\n * @internal\r\n */\r\n public override easeInCore(gradient: number): number {\r\n return gradient * gradient * gradient * gradient;\r\n }\r\n}\r\n\r\n/**\r\n * Easing function with a power of 5 shape (see link below).\r\n * @see https://easings.net/#easeInQuint\r\n * @see https://doc.babylonjs.com/features/featuresDeepDive/animation/advanced_animations#easing-functions\r\n */\r\nexport class QuinticEase extends EasingFunction implements IEasingFunction {\r\n /**\r\n * @internal\r\n */\r\n public override easeInCore(gradient: number): number {\r\n return gradient * gradient * gradient * gradient * gradient;\r\n }\r\n}\r\n\r\n/**\r\n * Easing function with a sin shape (see link below).\r\n * @see https://easings.net/#easeInSine\r\n * @see https://doc.babylonjs.com/features/featuresDeepDive/animation/advanced_animations#easing-functions\r\n */\r\nexport class SineEase extends EasingFunction implements IEasingFunction {\r\n /**\r\n * @internal\r\n */\r\n public override easeInCore(gradient: number): number {\r\n return 1.0 - Math.sin(1.5707963267948966 * (1.0 - gradient));\r\n }\r\n}\r\n\r\n/**\r\n * Easing function with a bezier shape (see link below).\r\n * @see http://cubic-bezier.com/#.17,.67,.83,.67\r\n * @see https://doc.babylonjs.com/features/featuresDeepDive/animation/advanced_animations#easing-functions\r\n */\r\nexport class BezierCurveEase extends EasingFunction implements IEasingFunction {\r\n /**\r\n * Instantiates a bezier function\r\n * @see http://cubic-bezier.com/#.17,.67,.83,.67\r\n * @param x1 Defines the x component of the start tangent in the bezier curve\r\n * @param y1 Defines the y component of the start tangent in the bezier curve\r\n * @param x2 Defines the x component of the end tangent in the bezier curve\r\n * @param y2 Defines the y component of the end tangent in the bezier curve\r\n */\r\n constructor(\r\n /** Defines the x component of the start tangent in the bezier curve */\r\n public x1: number = 0,\r\n /** Defines the y component of the start tangent in the bezier curve */\r\n public y1: number = 0,\r\n /** Defines the x component of the end tangent in the bezier curve */\r\n public x2: number = 1,\r\n /** Defines the y component of the end tangent in the bezier curve */\r\n public y2: number = 1\r\n ) {\r\n super();\r\n }\r\n\r\n /**\r\n * @internal\r\n */\r\n public override easeInCore(gradient: number): number {\r\n return BezierCurve.Interpolate(gradient, this.x1, this.y1, this.x2, this.y2);\r\n }\r\n}\r\n"]}
@@ -7,15 +7,15 @@ import type { Behavior } from "../../Behaviors/behavior";
7
7
  export declare class AttachToBoxBehavior implements Behavior<Mesh> {
8
8
  private _ui;
9
9
  /**
10
- * The name of the behavior
10
+ * ["AttachToBoxBehavior"] The name of the behavior
11
11
  */
12
12
  name: string;
13
13
  /**
14
- * The distance away from the face of the mesh that the UI should be attached to (default: 0.15)
14
+ * [0.15] The distance away from the face of the mesh that the UI should be attached to (default: 0.15)
15
15
  */
16
16
  distanceAwayFromFace: number;
17
17
  /**
18
- * The distance from the bottom of the face that the UI should be attached to (default: 0.15)
18
+ * [0.15] The distance from the bottom of the face that the UI should be attached to (default: 0.15)
19
19
  */
20
20
  distanceAwayFromBottomOfFace: number;
21
21
  private _faceVectors;
@@ -21,15 +21,15 @@ export class AttachToBoxBehavior {
21
21
  constructor(_ui) {
22
22
  this._ui = _ui;
23
23
  /**
24
- * The name of the behavior
24
+ * ["AttachToBoxBehavior"] The name of the behavior
25
25
  */
26
26
  this.name = "AttachToBoxBehavior";
27
27
  /**
28
- * The distance away from the face of the mesh that the UI should be attached to (default: 0.15)
28
+ * [0.15] The distance away from the face of the mesh that the UI should be attached to (default: 0.15)
29
29
  */
30
30
  this.distanceAwayFromFace = 0.15;
31
31
  /**
32
- * The distance from the bottom of the face that the UI should be attached to (default: 0.15)
32
+ * [0.15] The distance from the bottom of the face that the UI should be attached to (default: 0.15)
33
33
  */
34
34
  this.distanceAwayFromBottomOfFace = 0.15;
35
35
  this._faceVectors = [
@@ -1 +1 @@
1
- {"version":3,"file":"attachToBoxBehavior.js","sourceRoot":"","sources":["../../../../../dev/core/src/Behaviors/Meshes/attachToBoxBehavior.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,EAAE,UAAU,EAAE,MAAM,yBAAyB,CAAC;AAQtE;;GAEG;AACH,MAAM,iBAAiB;IACnB,YACW,SAAkB,EAClB,mBAAmB,IAAI,OAAO,EAAE,EAChC,OAAO,CAAC,EACR,SAAS,KAAK;QAHd,cAAS,GAAT,SAAS,CAAS;QAClB,qBAAgB,GAAhB,gBAAgB,CAAgB;QAChC,SAAI,GAAJ,IAAI,CAAI;QACR,WAAM,GAAN,MAAM,CAAQ;IACtB,CAAC;CACP;AAED;;GAEG;AACH,MAAM,OAAO,mBAAmB;IA2B5B;;;OAGG;IACH,YAAoB,GAAkB;QAAlB,QAAG,GAAH,GAAG,CAAe;QA9BtC;;WAEG;QACI,SAAI,GAAG,qBAAqB,CAAC;QACpC;;WAEG;QACI,yBAAoB,GAAG,IAAI,CAAC;QACnC;;WAEG;QACI,iCAA4B,GAAG,IAAI,CAAC;QACnC,iBAAY,GAAG;YACnB,IAAI,iBAAiB,CAAC,OAAO,CAAC,EAAE,EAAE,CAAC;YACnC,IAAI,iBAAiB,CAAC,OAAO,CAAC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,CAAC,QAAQ,CAAC,UAAU,CAAC,IAAI,CAAC,UAAU,CAAC,CAAC;QAClD,CAAC,CAAC,CAAC;IACP,CAAC;IAED;;OAEG;IACH,MAAM;QACF,IAAI,CAAC,MAAM,CAAC,wBAAwB,CAAC,MAAM,CAAC,IAAI,CAAC,iBAAiB,CAAC,CAAC;IACxE,CAAC;CACJ","sourcesContent":["import { Vector3, Matrix, Quaternion } from \"../../Maths/math.vector\";\r\nimport type { Mesh } from \"../../Meshes/mesh\";\r\nimport type { TransformNode } from \"../../Meshes/transformNode\";\r\nimport type { Scene } from \"../../scene\";\r\nimport type { Nullable } from \"../../types\";\r\nimport type { Observer } from \"../../Misc/observable\";\r\nimport type { Behavior } from \"../../Behaviors/behavior\";\r\n\r\n/**\r\n * @internal\r\n */\r\nclass FaceDirectionInfo {\r\n constructor(\r\n public direction: Vector3,\r\n public rotatedDirection = new Vector3(),\r\n public diff = 0,\r\n public ignore = false\r\n ) {}\r\n}\r\n\r\n/**\r\n * A behavior that when attached to a mesh will will place a specified node on the meshes face pointing towards the camera\r\n */\r\nexport class AttachToBoxBehavior implements Behavior<Mesh> {\r\n /**\r\n * The name of the behavior\r\n */\r\n public name = \"AttachToBoxBehavior\";\r\n /**\r\n * The distance away from the face of the mesh that the UI should be attached to (default: 0.15)\r\n */\r\n public distanceAwayFromFace = 0.15;\r\n /**\r\n * The distance from the bottom of the face that the UI should be attached to (default: 0.15)\r\n */\r\n public distanceAwayFromBottomOfFace = 0.15;\r\n private _faceVectors = [\r\n new FaceDirectionInfo(Vector3.Up()),\r\n new FaceDirectionInfo(Vector3.Down()),\r\n new FaceDirectionInfo(Vector3.Left()),\r\n new FaceDirectionInfo(Vector3.Right()),\r\n new FaceDirectionInfo(Vector3.Forward()),\r\n new FaceDirectionInfo(Vector3.Forward().scaleInPlace(-1)),\r\n ];\r\n private _target: Mesh;\r\n private _scene: Scene;\r\n private _onRenderObserver: Nullable<Observer<Scene>>;\r\n private _tmpMatrix = new Matrix();\r\n private _tmpVector = new Vector3();\r\n\r\n /**\r\n * Creates the AttachToBoxBehavior, used to attach UI to the closest face of the box to a camera\r\n * @param _ui The transform node that should be attached to the mesh\r\n */\r\n constructor(private _ui: TransformNode) {\r\n /* Does nothing */\r\n }\r\n\r\n /**\r\n * Initializes the behavior\r\n */\r\n public init() {\r\n /* Does nothing */\r\n }\r\n\r\n private _closestFace(targetDirection: Vector3) {\r\n // Go over each face and calculate the angle between the face's normal and targetDirection\r\n this._faceVectors.forEach((v) => {\r\n if (!this._target.rotationQuaternion) {\r\n this._target.rotationQuaternion = Quaternion.RotationYawPitchRoll(this._target.rotation.y, this._target.rotation.x, this._target.rotation.z);\r\n }\r\n this._target.rotationQuaternion.toRotationMatrix(this._tmpMatrix);\r\n Vector3.TransformCoordinatesToRef(v.direction, this._tmpMatrix, v.rotatedDirection);\r\n v.diff = Vector3.GetAngleBetweenVectors(v.rotatedDirection, targetDirection, Vector3.Cross(v.rotatedDirection, targetDirection));\r\n });\r\n // Return the face information of the one with the normal closest to target direction\r\n return this._faceVectors.reduce((min, p) => {\r\n if (min.ignore) {\r\n return p;\r\n } else if (p.ignore) {\r\n return min;\r\n } else {\r\n return min.diff < p.diff ? min : p;\r\n }\r\n }, this._faceVectors[0]);\r\n }\r\n\r\n private _zeroVector = Vector3.Zero();\r\n private _lookAtTmpMatrix = new Matrix();\r\n private _lookAtToRef(pos: Vector3, up = new Vector3(0, 1, 0), ref: Quaternion) {\r\n Matrix.LookAtLHToRef(this._zeroVector, pos, up, this._lookAtTmpMatrix);\r\n this._lookAtTmpMatrix.invert();\r\n Quaternion.FromRotationMatrixToRef(this._lookAtTmpMatrix, ref);\r\n }\r\n\r\n /**\r\n * Attaches the AttachToBoxBehavior to the passed in mesh\r\n * @param target The mesh that the specified node will be attached to\r\n */\r\n attach(target: Mesh) {\r\n this._target = target;\r\n this._scene = this._target.getScene();\r\n\r\n // Every frame, update the app bars position\r\n this._onRenderObserver = this._scene.onBeforeRenderObservable.add(() => {\r\n if (!this._scene.activeCamera) {\r\n return;\r\n }\r\n\r\n // Find the face closest to the cameras position\r\n let cameraPos = this._scene.activeCamera.position;\r\n if ((<any>this._scene.activeCamera).devicePosition) {\r\n cameraPos = (<any>this._scene.activeCamera).devicePosition;\r\n }\r\n const facing = this._closestFace(cameraPos.subtract(target.position));\r\n if (this._scene.activeCamera.leftCamera) {\r\n this._scene.activeCamera.leftCamera.computeWorldMatrix().getRotationMatrixToRef(this._tmpMatrix);\r\n } else {\r\n this._scene.activeCamera.computeWorldMatrix().getRotationMatrixToRef(this._tmpMatrix);\r\n }\r\n\r\n // Get camera up direction\r\n Vector3.TransformCoordinatesToRef(Vector3.Up(), this._tmpMatrix, this._tmpVector);\r\n // Ignore faces to not select a parallel face for the up vector of the UI\r\n this._faceVectors.forEach((v) => {\r\n if (facing.direction.x && v.direction.x) {\r\n v.ignore = true;\r\n }\r\n if (facing.direction.y && v.direction.y) {\r\n v.ignore = true;\r\n }\r\n if (facing.direction.z && v.direction.z) {\r\n v.ignore = true;\r\n }\r\n });\r\n const facingUp = this._closestFace(this._tmpVector);\r\n // Unignore faces\r\n this._faceVectors.forEach((v) => {\r\n v.ignore = false;\r\n });\r\n\r\n // Position the app bar on that face\r\n this._ui.position.copyFrom(target.position);\r\n if (facing.direction.x) {\r\n facing.rotatedDirection.scaleToRef(target.scaling.x / 2 + this.distanceAwayFromFace, this._tmpVector);\r\n this._ui.position.addInPlace(this._tmpVector);\r\n }\r\n if (facing.direction.y) {\r\n facing.rotatedDirection.scaleToRef(target.scaling.y / 2 + this.distanceAwayFromFace, this._tmpVector);\r\n this._ui.position.addInPlace(this._tmpVector);\r\n }\r\n if (facing.direction.z) {\r\n facing.rotatedDirection.scaleToRef(target.scaling.z / 2 + this.distanceAwayFromFace, this._tmpVector);\r\n this._ui.position.addInPlace(this._tmpVector);\r\n }\r\n\r\n // Rotate to be oriented properly to the camera\r\n if (!this._ui.rotationQuaternion) {\r\n this._ui.rotationQuaternion = Quaternion.RotationYawPitchRoll(this._ui.rotation.y, this._ui.rotation.x, this._ui.rotation.z);\r\n }\r\n facing.rotatedDirection.scaleToRef(-1, this._tmpVector);\r\n this._lookAtToRef(this._tmpVector, facingUp.rotatedDirection, this._ui.rotationQuaternion);\r\n\r\n // Place ui the correct distance from the bottom of the mesh\r\n if (facingUp.direction.x) {\r\n this._ui.up.scaleToRef(this.distanceAwayFromBottomOfFace - target.scaling.x / 2, this._tmpVector);\r\n }\r\n if (facingUp.direction.y) {\r\n this._ui.up.scaleToRef(this.distanceAwayFromBottomOfFace - target.scaling.y / 2, this._tmpVector);\r\n }\r\n if (facingUp.direction.z) {\r\n this._ui.up.scaleToRef(this.distanceAwayFromBottomOfFace - target.scaling.z / 2, this._tmpVector);\r\n }\r\n this._ui.position.addInPlace(this._tmpVector);\r\n });\r\n }\r\n\r\n /**\r\n * Detaches the behavior from the mesh\r\n */\r\n detach() {\r\n this._scene.onBeforeRenderObservable.remove(this._onRenderObserver);\r\n }\r\n}\r\n"]}
1
+ {"version":3,"file":"attachToBoxBehavior.js","sourceRoot":"","sources":["../../../../../dev/core/src/Behaviors/Meshes/attachToBoxBehavior.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,EAAE,UAAU,EAAE,MAAM,yBAAyB,CAAC;AAQtE;;GAEG;AACH,MAAM,iBAAiB;IACnB,YACW,SAAkB,EAClB,mBAAmB,IAAI,OAAO,EAAE,EAChC,OAAO,CAAC,EACR,SAAS,KAAK;QAHd,cAAS,GAAT,SAAS,CAAS;QAClB,qBAAgB,GAAhB,gBAAgB,CAAgB;QAChC,SAAI,GAAJ,IAAI,CAAI;QACR,WAAM,GAAN,MAAM,CAAQ;IACtB,CAAC;CACP;AAED;;GAEG;AACH,MAAM,OAAO,mBAAmB;IA2B5B;;;OAGG;IACH,YAAoB,GAAkB;QAAlB,QAAG,GAAH,GAAG,CAAe;QA9BtC;;WAEG;QACI,SAAI,GAAG,qBAAqB,CAAC;QACpC;;WAEG;QACI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ACtB,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,UAAU,CAAC,IAAI,CAAC,4BAA4B,GAAG,MAAM,CAAC,OAAO,CAAC,CAAC,GAAG,CAAC,EAAE,IAAI,CAAC,UAAU,CAAC,CAAC;aACrG;YACD,IAAI,CAAC,GAAG,CAAC,QAAQ,CAAC,UAAU,CAAC,IAAI,CAAC,UAAU,CAAC,CAAC;QAClD,CAAC,CAAC,CAAC;IACP,CAAC;IAED;;OAEG;IACH,MAAM;QACF,IAAI,CAAC,MAAM,CAAC,wBAAwB,CAAC,MAAM,CAAC,IAAI,CAAC,iBAAiB,CAAC,CAAC;IACxE,CAAC;CACJ","sourcesContent":["import { Vector3, Matrix, Quaternion } from \"../../Maths/math.vector\";\r\nimport type { Mesh } from \"../../Meshes/mesh\";\r\nimport type { TransformNode } from \"../../Meshes/transformNode\";\r\nimport type { Scene } from \"../../scene\";\r\nimport type { Nullable } from \"../../types\";\r\nimport type { Observer } from \"../../Misc/observable\";\r\nimport type { Behavior } from \"../../Behaviors/behavior\";\r\n\r\n/**\r\n * @internal\r\n */\r\nclass FaceDirectionInfo {\r\n constructor(\r\n public direction: Vector3,\r\n public rotatedDirection = new Vector3(),\r\n public diff = 0,\r\n public ignore = false\r\n ) {}\r\n}\r\n\r\n/**\r\n * A behavior that when attached to a mesh will will place a specified node on the meshes face pointing towards the camera\r\n */\r\nexport class AttachToBoxBehavior implements Behavior<Mesh> {\r\n /**\r\n * [\"AttachToBoxBehavior\"] The name of the behavior\r\n */\r\n public name = \"AttachToBoxBehavior\";\r\n /**\r\n * [0.15] The distance away from the face of the mesh that the UI should be attached to (default: 0.15)\r\n */\r\n public distanceAwayFromFace = 0.15;\r\n /**\r\n * [0.15] The distance from the bottom of the face that the UI should be attached to (default: 0.15)\r\n */\r\n public distanceAwayFromBottomOfFace = 0.15;\r\n private _faceVectors = [\r\n new FaceDirectionInfo(Vector3.Up()),\r\n new FaceDirectionInfo(Vector3.Down()),\r\n new FaceDirectionInfo(Vector3.Left()),\r\n new FaceDirectionInfo(Vector3.Right()),\r\n new FaceDirectionInfo(Vector3.Forward()),\r\n new FaceDirectionInfo(Vector3.Forward().scaleInPlace(-1)),\r\n ];\r\n private _target: Mesh;\r\n private _scene: Scene;\r\n private _onRenderObserver: Nullable<Observer<Scene>>;\r\n private _tmpMatrix = new Matrix();\r\n private _tmpVector = new Vector3();\r\n\r\n /**\r\n * Creates the AttachToBoxBehavior, used to attach UI to the closest face of the box to a camera\r\n * @param _ui The transform node that should be attached to the mesh\r\n */\r\n constructor(private _ui: TransformNode) {\r\n /* Does nothing */\r\n }\r\n\r\n /**\r\n * Initializes the behavior\r\n */\r\n public init() {\r\n /* Does nothing */\r\n }\r\n\r\n private _closestFace(targetDirection: Vector3) {\r\n // Go over each face and calculate the angle between the face's normal and targetDirection\r\n this._faceVectors.forEach((v) => {\r\n if (!this._target.rotationQuaternion) {\r\n this._target.rotationQuaternion = Quaternion.RotationYawPitchRoll(this._target.rotation.y, this._target.rotation.x, this._target.rotation.z);\r\n }\r\n this._target.rotationQuaternion.toRotationMatrix(this._tmpMatrix);\r\n Vector3.TransformCoordinatesToRef(v.direction, this._tmpMatrix, v.rotatedDirection);\r\n v.diff = Vector3.GetAngleBetweenVectors(v.rotatedDirection, targetDirection, Vector3.Cross(v.rotatedDirection, targetDirection));\r\n });\r\n // Return the face information of the one with the normal closest to target direction\r\n return this._faceVectors.reduce((min, p) => {\r\n if (min.ignore) {\r\n return p;\r\n } else if (p.ignore) {\r\n return min;\r\n } else {\r\n return min.diff < p.diff ? min : p;\r\n }\r\n }, this._faceVectors[0]);\r\n }\r\n\r\n private _zeroVector = Vector3.Zero();\r\n private _lookAtTmpMatrix = new Matrix();\r\n private _lookAtToRef(pos: Vector3, up = new Vector3(0, 1, 0), ref: Quaternion) {\r\n Matrix.LookAtLHToRef(this._zeroVector, pos, up, this._lookAtTmpMatrix);\r\n this._lookAtTmpMatrix.invert();\r\n Quaternion.FromRotationMatrixToRef(this._lookAtTmpMatrix, ref);\r\n }\r\n\r\n /**\r\n * Attaches the AttachToBoxBehavior to the passed in mesh\r\n * @param target The mesh that the specified node will be attached to\r\n */\r\n attach(target: Mesh) {\r\n this._target = target;\r\n this._scene = this._target.getScene();\r\n\r\n // Every frame, update the app bars position\r\n this._onRenderObserver = this._scene.onBeforeRenderObservable.add(() => {\r\n if (!this._scene.activeCamera) {\r\n return;\r\n }\r\n\r\n // Find the face closest to the cameras position\r\n let cameraPos = this._scene.activeCamera.position;\r\n if ((<any>this._scene.activeCamera).devicePosition) {\r\n cameraPos = (<any>this._scene.activeCamera).devicePosition;\r\n }\r\n const facing = this._closestFace(cameraPos.subtract(target.position));\r\n if (this._scene.activeCamera.leftCamera) {\r\n this._scene.activeCamera.leftCamera.computeWorldMatrix().getRotationMatrixToRef(this._tmpMatrix);\r\n } else {\r\n this._scene.activeCamera.computeWorldMatrix().getRotationMatrixToRef(this._tmpMatrix);\r\n }\r\n\r\n // Get camera up direction\r\n Vector3.TransformCoordinatesToRef(Vector3.Up(), this._tmpMatrix, this._tmpVector);\r\n // Ignore faces to not select a parallel face for the up vector of the UI\r\n this._faceVectors.forEach((v) => {\r\n if (facing.direction.x && v.direction.x) {\r\n v.ignore = true;\r\n }\r\n if (facing.direction.y && v.direction.y) {\r\n v.ignore = true;\r\n }\r\n if (facing.direction.z && v.direction.z) {\r\n v.ignore = true;\r\n }\r\n });\r\n const facingUp = this._closestFace(this._tmpVector);\r\n // Unignore faces\r\n this._faceVectors.forEach((v) => {\r\n v.ignore = false;\r\n });\r\n\r\n // Position the app bar on that face\r\n this._ui.position.copyFrom(target.position);\r\n if (facing.direction.x) {\r\n facing.rotatedDirection.scaleToRef(target.scaling.x / 2 + this.distanceAwayFromFace, this._tmpVector);\r\n this._ui.position.addInPlace(this._tmpVector);\r\n }\r\n if (facing.direction.y) {\r\n facing.rotatedDirection.scaleToRef(target.scaling.y / 2 + this.distanceAwayFromFace, this._tmpVector);\r\n this._ui.position.addInPlace(this._tmpVector);\r\n }\r\n if (facing.direction.z) {\r\n facing.rotatedDirection.scaleToRef(target.scaling.z / 2 + this.distanceAwayFromFace, this._tmpVector);\r\n this._ui.position.addInPlace(this._tmpVector);\r\n }\r\n\r\n // Rotate to be oriented properly to the camera\r\n if (!this._ui.rotationQuaternion) {\r\n this._ui.rotationQuaternion = Quaternion.RotationYawPitchRoll(this._ui.rotation.y, this._ui.rotation.x, this._ui.rotation.z);\r\n }\r\n facing.rotatedDirection.scaleToRef(-1, this._tmpVector);\r\n this._lookAtToRef(this._tmpVector, facingUp.rotatedDirection, this._ui.rotationQuaternion);\r\n\r\n // Place ui the correct distance from the bottom of the mesh\r\n if (facingUp.direction.x) {\r\n this._ui.up.scaleToRef(this.distanceAwayFromBottomOfFace - target.scaling.x / 2, this._tmpVector);\r\n }\r\n if (facingUp.direction.y) {\r\n this._ui.up.scaleToRef(this.distanceAwayFromBottomOfFace - target.scaling.y / 2, this._tmpVector);\r\n }\r\n if (facingUp.direction.z) {\r\n this._ui.up.scaleToRef(this.distanceAwayFromBottomOfFace - target.scaling.z / 2, this._tmpVector);\r\n }\r\n this._ui.position.addInPlace(this._tmpVector);\r\n });\r\n }\r\n\r\n /**\r\n * Detaches the behavior from the mesh\r\n */\r\n detach() {\r\n this._scene.onBeforeRenderObservable.remove(this._onRenderObserver);\r\n }\r\n}\r\n"]}
@@ -7,7 +7,7 @@ import type { FreeCamera } from "../../Cameras/freeCamera";
7
7
  */
8
8
  export declare class FreeCameraMouseInput implements ICameraInput<FreeCamera> {
9
9
  /**
10
- * Define if touch is enabled in the mouse input
10
+ * [true] Define if touch is enabled in the mouse input
11
11
  */
12
12
  touchEnabled: boolean;
13
13
  /**
@@ -48,7 +48,7 @@ export declare class FreeCameraMouseInput implements ICameraInput<FreeCamera> {
48
48
  */
49
49
  constructor(
50
50
  /**
51
- * Define if touch is enabled in the mouse input
51
+ * [true] Define if touch is enabled in the mouse input
52
52
  */
53
53
  touchEnabled?: boolean);
54
54
  /**
@@ -16,7 +16,7 @@ export class FreeCameraMouseInput {
16
16
  */
17
17
  constructor(
18
18
  /**
19
- * Define if touch is enabled in the mouse input
19
+ * [true] Define if touch is enabled in the mouse input
20
20
  */
21
21
  touchEnabled = true) {
22
22
  this.touchEnabled = touchEnabled;
@@ -1 +1 @@
1
- {"version":3,"file":"freeCameraMouseInput.js","sourceRoot":"","sources":["../../../../../dev/core/src/Cameras/Inputs/freeCameraMouseInput.ts"],"names":[],"mappings":";AACA,OAAO,EAAE,UAAU,EAAE,MAAM,uBAAuB,CAAC;AACnD,OAAO,EAAE,SAAS,EAAE,MAAM,uBAAuB,CAAC;AAGlD,OAAO,EAAE,gBAAgB,EAAE,MAAM,mCAAmC,CAAC;AAGrE,OAAO,EAAE,iBAAiB,EAAE,MAAM,4BAA4B,CAAC;AAC/D,OAAO,EAAE,KAAK,EAAE,MAAM,kBAAkB,CAAC;AAEzC;;;GAGG;AACH,MAAM,OAAO,oBAAoB;IAqC7B;;;;OAIG;IACH;IACI;;OAEG;IACI,eAAe,IAAI;QAAnB,iBAAY,GAAZ,YAAY,CAAO;QAxC9B;;WAEG;QAEI,YAAO,GAAG,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,CAAC,CAAC;QAE3B;;WAEG;QAEI,uBAAkB,GAAG,MAAM,CAAC;QAK3B,sBAAiB,GAAuC,IAAI,CAAC;QAErE;;WAEG;QACI,6BAAwB,GAAG,IAAI,UAAU,EAAwC,CAAC;QACzF;;;WAGG;QACI,yBAAoB,GAAG,IAAI,CAAC;QAE3B,yBAAoB,GAAW,CAAC,CAAC,CAAC;QAClC,qBAAgB,GAAW,CAAC,CAAC,CAAC;IAanC,CAAC;IAEJ;;;OAGG;IACI,aAAa,CAAC,gBAA0B;QAC3C,8CAA8C;QAC9C,gBAAgB,GAAG,KAAK,CAAC,gCAAgC,CAAC,SAAS,CAAC,CAAC;QACrE,MAAM,MAAM,GAAG,IAAI,CAAC,MAAM,CAAC,SAAS,EAAE,CAAC;QACvC,MAAM,OAA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AC,wBAAwB,EAAE;gBAC/B,IAAI,CAAC,wBAAwB,CAAC,KAAK,EAAE,CAAC;aACzC;YAED,IAAI,CAAC,SAAS,GAAG,IAAI,CAAC;YACtB,IAAI,CAAC,YAAY,GAAG,IAAI,CAAC;YACzB,IAAI,CAAC,iBAAiB,GAAG,IAAI,CAAC;SACjC;QAED,IAAI,CAAC,gBAAgB,GAAG,CAAC,CAAC,CAAC;QAC3B,IAAI,CAAC,oBAAoB,GAAG,CAAC,CAAC,CAAC;IACnC,CAAC;IAED;;;OAGG;IACI,YAAY;QACf,OAAO,sBAAsB,CAAC;IAClC,CAAC;IAED;;;OAGG;IACI,aAAa;QAChB,OAAO,OAAO,CAAC;IACnB,CAAC;CACJ;AA7NU;IADN,SAAS,EAAE;qDACe;AAMpB;IADN,SAAS,EAAE;gEACuB;AAyNjC,gBAAiB,CAAC,sBAAsB,CAAC,GAAG,oBAAoB,CAAC","sourcesContent":["import type { Observer, EventState } from \"../../Misc/observable\";\r\nimport { Observable } from \"../../Misc/observable\";\r\nimport { serialize } from \"../../Misc/decorators\";\r\nimport type { Nullable } from \"../../types\";\r\nimport type { ICameraInput } from \"../../Cameras/cameraInputsManager\";\r\nimport { CameraInputTypes } from \"../../Cameras/cameraInputsManager\";\r\nimport type { FreeCamera } from \"../../Cameras/freeCamera\";\r\nimport type { PointerInfo } from \"../../Events/pointerEvents\";\r\nimport { PointerEventTypes } from \"../../Events/pointerEvents\";\r\nimport { Tools } from \"../../Misc/tools\";\r\nimport type { IMouseEvent, IPointerEvent } from \"../../Events/deviceInputEvents\";\r\n/**\r\n * Manage the mouse inputs to control the movement of a free camera.\r\n * @see https://doc.babylonjs.com/features/featuresDeepDive/cameras/customizingCameraInputs\r\n */\r\nexport class FreeCameraMouseInput implements ICameraInput<FreeCamera> {\r\n /**\r\n * Defines the camera the input is attached to.\r\n */\r\n public camera: FreeCamera;\r\n\r\n /**\r\n * Defines the buttons associated with the input to handle camera move.\r\n */\r\n @serialize()\r\n public buttons = [0, 1, 2];\r\n\r\n /**\r\n * Defines the pointer angular sensibility along the X and Y axis or how fast is the camera rotating.\r\n */\r\n @serialize()\r\n public angularSensibility = 2000.0;\r\n\r\n private _pointerInput: (p: PointerInfo, s: EventState) => void;\r\n private _onMouseMove: Nullable<(e: IMouseEvent) => any>;\r\n private _observer: Nullable<Observer<PointerInfo>>;\r\n private _previousPosition: Nullable<{ x: number; y: number }> = null;\r\n\r\n /**\r\n * Observable for when a pointer move event occurs containing the move offset\r\n */\r\n public onPointerMovedObservable = new Observable<{ offsetX: number; offsetY: number }>();\r\n /**\r\n * @internal\r\n * If the camera should be rotated automatically based on pointer movement\r\n */\r\n public _allowCameraRotation = true;\r\n\r\n private _currentActiveButton: number = -1;\r\n private _activePointerId: number = -1;\r\n private _contextMenuBind: (evt: MouseEvent) => void;\r\n\r\n /**\r\n * Manage the mouse inputs to control the movement of a free camera.\r\n * @see https://doc.babylonjs.com/features/featuresDeepDive/cameras/customizingCameraInputs\r\n * @param touchEnabled Defines if touch is enabled or not\r\n */\r\n constructor(\r\n /**\r\n * Define if touch is enabled in the mouse input\r\n */\r\n public touchEnabled = true\r\n ) {}\r\n\r\n /**\r\n * Attach the input controls to a specific dom element to get the input from.\r\n * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)\r\n */\r\n public attachControl(noPreventDefault?: boolean): void {\r\n // eslint-disable-next-line prefer-rest-params\r\n noPreventDefault = Tools.BackCompatCameraNoPreventDefault(arguments);\r\n const engine = this.camera.getEngine();\r\n const element = engine.getInputElement();\r\n\r\n if (!this._pointerInput) {\r\n this._pointerInput = (p) => {\r\n const evt = <IPointerEvent>p.event;\r\n const isTouch = evt.pointerType === \"touch\";\r\n\r\n if (!this.touchEnabled && isTouch) {\r\n return;\r\n }\r\n\r\n if (p.type !== PointerEventTypes.POINTERMOVE && this.buttons.indexOf(evt.button) === -1) {\r\n return;\r\n }\r\n\r\n const srcElement = <HTMLElement>evt.target;\r\n\r\n if (p.type === PointerEventTypes.POINTERDOWN) {\r\n // If the input is touch with more than one touch OR if the input is mouse and there is already an active button, return\r\n if ((isTouch && this._activePointerId !== -1) || (!isTouch && this._currentActiveButton !== -1)) {\r\n return;\r\n }\r\n\r\n this._activePointerId = evt.pointerId;\r\n try {\r\n srcElement?.setPointerCapture(evt.pointerId);\r\n } catch (e) {\r\n //Nothing to do with the error. Execution will continue.\r\n }\r\n\r\n if (this._currentActiveButton === -1) {\r\n this._currentActiveButton = evt.button;\r\n }\r\n\r\n this._previousPosition = {\r\n x: evt.clientX,\r\n y: evt.clientY,\r\n };\r\n\r\n if (!noPreventDefault) {\r\n evt.preventDefault();\r\n element && element.focus();\r\n }\r\n\r\n // This is required to move while pointer button is down\r\n if (engine.isPointerLock && this._onMouseMove) {\r\n this._onMouseMove(p.event);\r\n }\r\n } else if (p.type === PointerEventTypes.POINTERUP) {\r\n // If input is touch with a different touch id OR if input is mouse with a different button, return\r\n if ((isTouch && this._activePointerId !== evt.pointerId) || (!isTouch && this._currentActiveButton !== evt.button)) {\r\n return;\r\n }\r\n\r\n try {\r\n srcElement?.releasePointerCapture(evt.pointerId);\r\n } catch (e) {\r\n //Nothing to do with the error.\r\n }\r\n this._currentActiveButton = -1;\r\n\r\n this._previousPosition = null;\r\n if (!noPreventDefault) {\r\n evt.preventDefault();\r\n }\r\n\r\n this._activePointerId = -1;\r\n } else if (p.type === PointerEventTypes.POINTERMOVE && (this._activePointerId === evt.pointerId || !isTouch)) {\r\n if (engine.isPointerLock && this._onMouseMove) {\r\n this._onMouseMove(p.event);\r\n } else if (this._previousPosition) {\r\n const handednessMultiplier = this.camera._calculateHandednessMultiplier();\r\n const offsetX = (evt.clientX - this._previousPosition.x) * handednessMultiplier;\r\n const offsetY = evt.clientY - this._previousPosition.y;\r\n\r\n if (this._allowCameraRotation) {\r\n this.camera.cameraRotation.y += offsetX / this.angularSensibility;\r\n this.camera.cameraRotation.x += offsetY / this.angularSensibility;\r\n }\r\n this.onPointerMovedObservable.notifyObservers({ offsetX: offsetX, offsetY: offsetY });\r\n\r\n this._previousPosition = {\r\n x: evt.clientX,\r\n y: evt.clientY,\r\n };\r\n\r\n if (!noPreventDefault) {\r\n evt.preventDefault();\r\n }\r\n }\r\n }\r\n };\r\n }\r\n\r\n this._onMouseMove = (evt) => {\r\n if (!engine.isPointerLock) {\r\n return;\r\n }\r\n\r\n const handednessMultiplier = this.camera._calculateHandednessMultiplier();\r\n const offsetX = evt.movementX * handednessMultiplier;\r\n\r\n this.camera.cameraRotation.y += offsetX / this.angularSensibility;\r\n\r\n const offsetY = evt.movementY;\r\n this.camera.cameraRotation.x += offsetY / this.angularSensibility;\r\n\r\n this._previousPosition = null;\r\n\r\n if (!noPreventDefault) {\r\n evt.preventDefault();\r\n }\r\n };\r\n\r\n this._observer = this.camera\r\n .getScene()\r\n ._inputManager._addCameraPointerObserver(this._pointerInput, PointerEventTypes.POINTERDOWN | PointerEventTypes.POINTERUP | PointerEventTypes.POINTERMOVE);\r\n\r\n if (element) {\r\n this._contextMenuBind = (evt: MouseEvent) => this.onContextMenu(evt as PointerEvent);\r\n element.addEventListener(\"contextmenu\", this._contextMenuBind, false); // TODO: We need to figure out how to handle this for Native\r\n }\r\n }\r\n\r\n /**\r\n * Called on JS contextmenu event.\r\n * Override this method to provide functionality.\r\n * @param evt the context menu event\r\n */\r\n public onContextMenu(evt: PointerEvent): void {\r\n evt.preventDefault();\r\n }\r\n\r\n /**\r\n * Detach the current controls from the specified dom element.\r\n */\r\n public detachControl(): void {\r\n if (this._observer) {\r\n this.camera.getScene()._inputManager._removeCameraPointerObserver(this._observer);\r\n\r\n if (this._contextMenuBind) {\r\n const engine = this.camera.getEngine();\r\n const element = engine.getInputElement();\r\n element && element.removeEventListener(\"contextmenu\", this._contextMenuBind);\r\n }\r\n\r\n if (this.onPointerMovedObservable) {\r\n this.onPointerMovedObservable.clear();\r\n }\r\n\r\n this._observer = null;\r\n this._onMouseMove = null;\r\n this._previousPosition = null;\r\n }\r\n\r\n this._activePointerId = -1;\r\n this._currentActiveButton = -1;\r\n }\r\n\r\n /**\r\n * Gets the class name of the current input.\r\n * @returns the class name\r\n */\r\n public getClassName(): string {\r\n return \"FreeCameraMouseInput\";\r\n }\r\n\r\n /**\r\n * Get the friendly name associated with the input class.\r\n * @returns the input friendly name\r\n */\r\n public getSimpleName(): string {\r\n return \"mouse\";\r\n }\r\n}\r\n\r\n(<any>CameraInputTypes)[\"FreeCameraMouseInput\"] = FreeCameraMouseInput;\r\n"]}
1
+ {"version":3,"file":"freeCameraMouseInput.js","sourceRoot":"","sources":["../../../../../dev/core/src/Cameras/Inputs/freeCameraMouseInput.ts"],"names":[],"mappings":";AACA,OAAO,EAAE,UAAU,EAAE,MAAM,uBAAuB,CAAC;AACnD,OAAO,EAAE,SAAS,EAAE,MAAM,uBAAuB,CAAC;AAGlD,OAAO,EAAE,gBAAgB,EAAE,MAAM,mCAAmC,CAAC;AAGrE,OAAO,EAAE,iBAAiB,EAAE,MAAM,4BAA4B,CAAC;AAC/D,OAAO,EAAE,KAAK,EAAE,MAAM,kBAAkB,CAAC;AAEzC;;;GAGG;AACH,MAAM,OAAO,oBAAoB;IAqC7B;;;;OAIG;IACH;IACI;;OAEG;IACI,eAAe,IAAI;QAAnB,iBAAY,GAAZ,YAAY,CAAO;QAxC9B;;WAEG;QAEI,YAAO,GAAG,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,CAAC,CAAC;QAE3B;;WAEG;QAEI,uBAAkB,GAAG,MAAM,CAAC;QAK3B,sBAAiB,GAAuC,IAAI,CAAC;QAErE;;WAEG;QACI,6BAAwB,GAAG,IAAI,UAAU,EAAwC,CAAC;QACzF;;;WAGG;QACI,yBAAoB,GAAG,IAAI,CAAC;QAE3B,yBAAoB,GAAW,CAAC,CAAC,CAAC;QAClC,qBAAgB,GAAW,CAAC,CAAC,CAAC;IAanC,CAAC;IAEJ;;;OAGG;IACI,aAAa,CAAC,gBAA0B;QAC3C,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AAO,GAAG,MAAM,CAAC,eAAe,EAAE,CAAC;gBACzC,OAAO,IAAI,OAAO,CAAC,mBAAmB,CAAC,aAAa,EAAE,IAAI,CAAC,gBAAgB,CAAC,CAAC;aAChF;YAED,IAAI,IAAI,CAAC,wBAAwB,EAAE;gBAC/B,IAAI,CAAC,wBAAwB,CAAC,KAAK,EAAE,CAAC;aACzC;YAED,IAAI,CAAC,SAAS,GAAG,IAAI,CAAC;YACtB,IAAI,CAAC,YAAY,GAAG,IAAI,CAAC;YACzB,IAAI,CAAC,iBAAiB,GAAG,IAAI,CAAC;SACjC;QAED,IAAI,CAAC,gBAAgB,GAAG,CAAC,CAAC,CAAC;QAC3B,IAAI,CAAC,oBAAoB,GAAG,CAAC,CAAC,CAAC;IACnC,CAAC;IAED;;;OAGG;IACI,YAAY;QACf,OAAO,sBAAsB,CAAC;IAClC,CAAC;IAED;;;OAGG;IACI,aAAa;QAChB,OAAO,OAAO,CAAC;IACnB,CAAC;CACJ;AA7NU;IADN,SAAS,EAAE;qDACe;AAMpB;IADN,SAAS,EAAE;gEACuB;AAyNjC,gBAAiB,CAAC,sBAAsB,CAAC,GAAG,oBAAoB,CAAC","sourcesContent":["import type { Observer, EventState } from \"../../Misc/observable\";\r\nimport { Observable } from \"../../Misc/observable\";\r\nimport { serialize } from \"../../Misc/decorators\";\r\nimport type { Nullable } from \"../../types\";\r\nimport type { ICameraInput } from \"../../Cameras/cameraInputsManager\";\r\nimport { CameraInputTypes } from \"../../Cameras/cameraInputsManager\";\r\nimport type { FreeCamera } from \"../../Cameras/freeCamera\";\r\nimport type { PointerInfo } from \"../../Events/pointerEvents\";\r\nimport { PointerEventTypes } from \"../../Events/pointerEvents\";\r\nimport { Tools } from \"../../Misc/tools\";\r\nimport type { IMouseEvent, IPointerEvent } from \"../../Events/deviceInputEvents\";\r\n/**\r\n * Manage the mouse inputs to control the movement of a free camera.\r\n * @see https://doc.babylonjs.com/features/featuresDeepDive/cameras/customizingCameraInputs\r\n */\r\nexport class FreeCameraMouseInput implements ICameraInput<FreeCamera> {\r\n /**\r\n * Defines the camera the input is attached to.\r\n */\r\n public camera: FreeCamera;\r\n\r\n /**\r\n * Defines the buttons associated with the input to handle camera move.\r\n */\r\n @serialize()\r\n public buttons = [0, 1, 2];\r\n\r\n /**\r\n * Defines the pointer angular sensibility along the X and Y axis or how fast is the camera rotating.\r\n */\r\n @serialize()\r\n public angularSensibility = 2000.0;\r\n\r\n private _pointerInput: (p: PointerInfo, s: EventState) => void;\r\n private _onMouseMove: Nullable<(e: IMouseEvent) => any>;\r\n private _observer: Nullable<Observer<PointerInfo>>;\r\n private _previousPosition: Nullable<{ x: number; y: number }> = null;\r\n\r\n /**\r\n * Observable for when a pointer move event occurs containing the move offset\r\n */\r\n public onPointerMovedObservable = new Observable<{ offsetX: number; offsetY: number }>();\r\n /**\r\n * @internal\r\n * If the camera should be rotated automatically based on pointer movement\r\n */\r\n public _allowCameraRotation = true;\r\n\r\n private _currentActiveButton: number = -1;\r\n private _activePointerId: number = -1;\r\n private _contextMenuBind: (evt: MouseEvent) => void;\r\n\r\n /**\r\n * Manage the mouse inputs to control the movement of a free camera.\r\n * @see https://doc.babylonjs.com/features/featuresDeepDive/cameras/customizingCameraInputs\r\n * @param touchEnabled Defines if touch is enabled or not\r\n */\r\n constructor(\r\n /**\r\n * [true] Define if touch is enabled in the mouse input\r\n */\r\n public touchEnabled = true\r\n ) {}\r\n\r\n /**\r\n * Attach the input controls to a specific dom element to get the input from.\r\n * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)\r\n */\r\n public attachControl(noPreventDefault?: boolean): void {\r\n // eslint-disable-next-line prefer-rest-params\r\n noPreventDefault = Tools.BackCompatCameraNoPreventDefault(arguments);\r\n const engine = this.camera.getEngine();\r\n const element = engine.getInputElement();\r\n\r\n if (!this._pointerInput) {\r\n this._pointerInput = (p) => {\r\n const evt = <IPointerEvent>p.event;\r\n const isTouch = evt.pointerType === \"touch\";\r\n\r\n if (!this.touchEnabled && isTouch) {\r\n return;\r\n }\r\n\r\n if (p.type !== PointerEventTypes.POINTERMOVE && this.buttons.indexOf(evt.button) === -1) {\r\n return;\r\n }\r\n\r\n const srcElement = <HTMLElement>evt.target;\r\n\r\n if (p.type === PointerEventTypes.POINTERDOWN) {\r\n // If the input is touch with more than one touch OR if the input is mouse and there is already an active button, return\r\n if ((isTouch && this._activePointerId !== -1) || (!isTouch && this._currentActiveButton !== -1)) {\r\n return;\r\n }\r\n\r\n this._activePointerId = evt.pointerId;\r\n try {\r\n srcElement?.setPointerCapture(evt.pointerId);\r\n } catch (e) {\r\n //Nothing to do with the error. Execution will continue.\r\n }\r\n\r\n if (this._currentActiveButton === -1) {\r\n this._currentActiveButton = evt.button;\r\n }\r\n\r\n this._previousPosition = {\r\n x: evt.clientX,\r\n y: evt.clientY,\r\n };\r\n\r\n if (!noPreventDefault) {\r\n evt.preventDefault();\r\n element && element.focus();\r\n }\r\n\r\n // This is required to move while pointer button is down\r\n if (engine.isPointerLock && this._onMouseMove) {\r\n this._onMouseMove(p.event);\r\n }\r\n } else if (p.type === PointerEventTypes.POINTERUP) {\r\n // If input is touch with a different touch id OR if input is mouse with a different button, return\r\n if ((isTouch && this._activePointerId !== evt.pointerId) || (!isTouch && this._currentActiveButton !== evt.button)) {\r\n return;\r\n }\r\n\r\n try {\r\n srcElement?.releasePointerCapture(evt.pointerId);\r\n } catch (e) {\r\n //Nothing to do with the error.\r\n }\r\n this._currentActiveButton = -1;\r\n\r\n this._previousPosition = null;\r\n if (!noPreventDefault) {\r\n evt.preventDefault();\r\n }\r\n\r\n this._activePointerId = -1;\r\n } else if (p.type === PointerEventTypes.POINTERMOVE && (this._activePointerId === evt.pointerId || !isTouch)) {\r\n if (engine.isPointerLock && this._onMouseMove) {\r\n this._onMouseMove(p.event);\r\n } else if (this._previousPosition) {\r\n const handednessMultiplier = this.camera._calculateHandednessMultiplier();\r\n const offsetX = (evt.clientX - this._previousPosition.x) * handednessMultiplier;\r\n const offsetY = evt.clientY - this._previousPosition.y;\r\n\r\n if (this._allowCameraRotation) {\r\n this.camera.cameraRotation.y += offsetX / this.angularSensibility;\r\n this.camera.cameraRotation.x += offsetY / this.angularSensibility;\r\n }\r\n this.onPointerMovedObservable.notifyObservers({ offsetX: offsetX, offsetY: offsetY });\r\n\r\n this._previousPosition = {\r\n x: evt.clientX,\r\n y: evt.clientY,\r\n };\r\n\r\n if (!noPreventDefault) {\r\n evt.preventDefault();\r\n }\r\n }\r\n }\r\n };\r\n }\r\n\r\n this._onMouseMove = (evt) => {\r\n if (!engine.isPointerLock) {\r\n return;\r\n }\r\n\r\n const handednessMultiplier = this.camera._calculateHandednessMultiplier();\r\n const offsetX = evt.movementX * handednessMultiplier;\r\n\r\n this.camera.cameraRotation.y += offsetX / this.angularSensibility;\r\n\r\n const offsetY = evt.movementY;\r\n this.camera.cameraRotation.x += offsetY / this.angularSensibility;\r\n\r\n this._previousPosition = null;\r\n\r\n if (!noPreventDefault) {\r\n evt.preventDefault();\r\n }\r\n };\r\n\r\n this._observer = this.camera\r\n .getScene()\r\n ._inputManager._addCameraPointerObserver(this._pointerInput, PointerEventTypes.POINTERDOWN | PointerEventTypes.POINTERUP | PointerEventTypes.POINTERMOVE);\r\n\r\n if (element) {\r\n this._contextMenuBind = (evt: MouseEvent) => this.onContextMenu(evt as PointerEvent);\r\n element.addEventListener(\"contextmenu\", this._contextMenuBind, false); // TODO: We need to figure out how to handle this for Native\r\n }\r\n }\r\n\r\n /**\r\n * Called on JS contextmenu event.\r\n * Override this method to provide functionality.\r\n * @param evt the context menu event\r\n */\r\n public onContextMenu(evt: PointerEvent): void {\r\n evt.preventDefault();\r\n }\r\n\r\n /**\r\n * Detach the current controls from the specified dom element.\r\n */\r\n public detachControl(): void {\r\n if (this._observer) {\r\n this.camera.getScene()._inputManager._removeCameraPointerObserver(this._observer);\r\n\r\n if (this._contextMenuBind) {\r\n const engine = this.camera.getEngine();\r\n const element = engine.getInputElement();\r\n element && element.removeEventListener(\"contextmenu\", this._contextMenuBind);\r\n }\r\n\r\n if (this.onPointerMovedObservable) {\r\n this.onPointerMovedObservable.clear();\r\n }\r\n\r\n this._observer = null;\r\n this._onMouseMove = null;\r\n this._previousPosition = null;\r\n }\r\n\r\n this._activePointerId = -1;\r\n this._currentActiveButton = -1;\r\n }\r\n\r\n /**\r\n * Gets the class name of the current input.\r\n * @returns the class name\r\n */\r\n public getClassName(): string {\r\n return \"FreeCameraMouseInput\";\r\n }\r\n\r\n /**\r\n * Get the friendly name associated with the input class.\r\n * @returns the input friendly name\r\n */\r\n public getSimpleName(): string {\r\n return \"mouse\";\r\n }\r\n}\r\n\r\n(<any>CameraInputTypes)[\"FreeCameraMouseInput\"] = FreeCameraMouseInput;\r\n"]}
@@ -6,7 +6,7 @@ import type { FreeCamera } from "../../Cameras/freeCamera";
6
6
  */
7
7
  export declare class FreeCameraTouchInput implements ICameraInput<FreeCamera> {
8
8
  /**
9
- * Define if mouse events can be treated as touch events
9
+ * [false] Define if mouse events can be treated as touch events
10
10
  */
11
11
  allowMouse: boolean;
12
12
  /**
@@ -41,7 +41,7 @@ export declare class FreeCameraTouchInput implements ICameraInput<FreeCamera> {
41
41
  */
42
42
  constructor(
43
43
  /**
44
- * Define if mouse events can be treated as touch events
44
+ * [false] Define if mouse events can be treated as touch events
45
45
  */
46
46
  allowMouse?: boolean);
47
47
  /**
@@ -16,7 +16,7 @@ export class FreeCameraTouchInput {
16
16
  */
17
17
  constructor(
18
18
  /**
19
- * Define if mouse events can be treated as touch events
19
+ * [false] Define if mouse events can be treated as touch events
20
20
  */
21
21
  allowMouse = false) {
22
22
  this.allowMouse = allowMouse;
@@ -1 +1 @@
1
- {"version":3,"file":"freeCameraTouchInput.js","sourceRoot":"","sources":["../../../../../dev/core/src/Cameras/Inputs/freeCameraTouchInput.ts"],"names":[],"mappings":";AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,uBAAuB,CAAC;AAIlD,OAAO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AC,EAAE,CAAC,EAAE,IAAI,CAAC,oBAAoB,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC,KAAK,GAAG,IAAI,CAAC,QAAQ,CAAC,GAAG,IAAI,CAAC,oBAAoB,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;YAE/H,MAAM,CAAC,yBAAyB,CAAC,MAAM,CAAC,QAAQ,CAAC,CAAC,EAAE,MAAM,CAAC,QAAQ,CAAC,CAAC,EAAE,CAAC,EAAE,MAAM,CAAC,qBAAqB,CAAC,CAAC;YACxG,MAAM,CAAC,eAAe,CAAC,UAAU,CAAC,OAAO,CAAC,oBAAoB,CAAC,SAAS,EAAE,MAAM,CAAC,qBAAqB,CAAC,CAAC,CAAC;SAC5G;IACL,CAAC;IAED;;;OAGG;IACI,YAAY;QACf,OAAO,sBAAsB,CAAC;IAClC,CAAC;IAED;;;OAGG;IACI,aAAa;QAChB,OAAO,OAAO,CAAC;IACnB,CAAC;CACJ;AAhMU;IADN,SAAS,EAAE;qEACsC;AAO3C;IADN,SAAS,EAAE;kEACgC;AA2L1C,gBAAiB,CAAC,sBAAsB,CAAC,GAAG,oBAAoB,CAAC","sourcesContent":["import { serialize } from \"../../Misc/decorators\";\r\nimport type { Observer, EventState } from \"../../Misc/observable\";\r\nimport type { Nullable } from \"../../types\";\r\nimport type { ICameraInput } from \"../../Cameras/cameraInputsManager\";\r\nimport { CameraInputTypes } from \"../../Cameras/cameraInputsManager\";\r\nimport type { FreeCamera } from \"../../Cameras/freeCamera\";\r\nimport type { PointerInfo } from \"../../Events/pointerEvents\";\r\nimport { PointerEventTypes } from \"../../Events/pointerEvents\";\r\nimport { Matrix, Vector3 } from \"../../Maths/math.vector\";\r\nimport { Tools } from \"../../Misc/tools\";\r\nimport type { IPointerEvent } from \"../../Events/deviceInputEvents\";\r\n/**\r\n * Manage the touch inputs to control the movement of a free camera.\r\n * @see https://doc.babylonjs.com/features/featuresDeepDive/cameras/customizingCameraInputs\r\n */\r\nexport class FreeCameraTouchInput implements ICameraInput<FreeCamera> {\r\n /**\r\n * Defines the camera the input is attached to.\r\n */\r\n public camera: FreeCamera;\r\n\r\n /**\r\n * Defines the touch sensibility for rotation.\r\n * The lower the faster.\r\n */\r\n @serialize()\r\n public touchAngularSensibility: number = 200000.0;\r\n\r\n /**\r\n * Defines the touch sensibility for move.\r\n * The lower the faster.\r\n */\r\n @serialize()\r\n public touchMoveSensibility: number = 250.0;\r\n\r\n /**\r\n * Swap touch actions so that one touch is used for rotation and multiple for movement\r\n */\r\n public singleFingerRotate: boolean = false;\r\n\r\n private _offsetX: Nullable<number> = null;\r\n private _offsetY: Nullable<number> = null;\r\n\r\n private _pointerPressed = new Array<number>();\r\n private _pointerInput?: (p: PointerInfo, s: EventState) => void;\r\n private _observer: Nullable<Observer<PointerInfo>>;\r\n private _onLostFocus: Nullable<(e: FocusEvent) => any>;\r\n private _isSafari: boolean;\r\n\r\n /**\r\n * Manage the touch inputs to control the movement of a free camera.\r\n * @see https://doc.babylonjs.com/features/featuresDeepDive/cameras/customizingCameraInputs\r\n * @param allowMouse Defines if mouse events can be treated as touch events\r\n */\r\n constructor(\r\n /**\r\n * Define if mouse events can be treated as touch events\r\n */\r\n public allowMouse = false\r\n ) {\r\n this._isSafari = Tools.IsSafari();\r\n }\r\n\r\n /**\r\n * Attach the input controls to a specific dom element to get the input from.\r\n * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)\r\n */\r\n public attachControl(noPreventDefault?: boolean): void {\r\n // eslint-disable-next-line prefer-rest-params\r\n noPreventDefault = Tools.BackCompatCameraNoPreventDefault(arguments);\r\n let previousPosition: Nullable<{ x: number; y: number }> = null;\r\n\r\n if (this._pointerInput === undefined) {\r\n this._onLostFocus = () => {\r\n this._offsetX = null;\r\n this._offsetY = null;\r\n };\r\n\r\n this._pointerInput = (p) => {\r\n const evt = <IPointerEvent>p.event;\r\n\r\n const isMouseEvent = evt.pointerType === \"mouse\" || (this._isSafari && typeof evt.pointerType === \"undefined\");\r\n\r\n if (!this.allowMouse && isMouseEvent) {\r\n return;\r\n }\r\n\r\n if (p.type === PointerEventTypes.POINTERDOWN) {\r\n if (!noPreventDefault) {\r\n evt.preventDefault();\r\n }\r\n\r\n this._pointerPressed.push(evt.pointerId);\r\n\r\n if (this._pointerPressed.length !== 1) {\r\n return;\r\n }\r\n\r\n previousPosition = {\r\n x: evt.clientX,\r\n y: evt.clientY,\r\n };\r\n } else if (p.type === PointerEventTypes.POINTERUP) {\r\n if (!noPreventDefault) {\r\n evt.preventDefault();\r\n }\r\n\r\n const index: number = this._pointerPressed.indexOf(evt.pointerId);\r\n\r\n if (index === -1) {\r\n return;\r\n }\r\n this._pointerPressed.splice(index, 1);\r\n\r\n if (index != 0) {\r\n return;\r\n }\r\n previousPosition = null;\r\n this._offsetX = null;\r\n this._offsetY = null;\r\n } else if (p.type === PointerEventTypes.POINTERMOVE) {\r\n if (!noPreventDefault) {\r\n evt.preventDefault();\r\n }\r\n\r\n if (!previousPosition) {\r\n return;\r\n }\r\n\r\n const index: number = this._pointerPressed.indexOf(evt.pointerId);\r\n\r\n if (index != 0) {\r\n return;\r\n }\r\n\r\n this._offsetX = evt.clientX - previousPosition.x;\r\n this._offsetY = -(evt.clientY - previousPosition.y);\r\n }\r\n };\r\n }\r\n\r\n this._observer = this.camera\r\n .getScene()\r\n ._inputManager._addCameraPointerObserver(this._pointerInput, PointerEventTypes.POINTERDOWN | PointerEventTypes.POINTERUP | PointerEventTypes.POINTERMOVE);\r\n\r\n if (this._onLostFocus) {\r\n const engine = this.camera.getEngine();\r\n const element = engine.getInputElement();\r\n element && element.addEventListener(\"blur\", this._onLostFocus);\r\n }\r\n }\r\n\r\n /**\r\n * Detach the current controls from the specified dom element.\r\n */\r\n public detachControl(): void {\r\n if (this._pointerInput) {\r\n if (this._observer) {\r\n this.camera.getScene()._inputManager._removeCameraPointerObserver(this._observer);\r\n this._observer = null;\r\n }\r\n\r\n if (this._onLostFocus) {\r\n const engine = this.camera.getEngine();\r\n const element = engine.getInputElement();\r\n element && element.removeEventListener(\"blur\", this._onLostFocus);\r\n this._onLostFocus = null;\r\n }\r\n this._pointerPressed.length = 0;\r\n this._offsetX = null;\r\n this._offsetY = null;\r\n }\r\n }\r\n\r\n /**\r\n * Update the current camera state depending on the inputs that have been used this frame.\r\n * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.\r\n */\r\n public checkInputs(): void {\r\n if (this._offsetX === null || this._offsetY === null) {\r\n return;\r\n }\r\n if (this._offsetX === 0 && this._offsetY === 0) {\r\n return;\r\n }\r\n\r\n const camera = this.camera;\r\n const handednessMultiplier = camera._calculateHandednessMultiplier();\r\n camera.cameraRotation.y = (handednessMultiplier * this._offsetX) / this.touchAngularSensibility;\r\n\r\n const rotateCamera = (this.singleFingerRotate && this._pointerPressed.length === 1) || (!this.singleFingerRotate && this._pointerPressed.length > 1);\r\n\r\n if (rotateCamera) {\r\n camera.cameraRotation.x = -this._offsetY / this.touchAngularSensibility;\r\n } else {\r\n const speed = camera._computeLocalCameraSpeed();\r\n const direction = new Vector3(0, 0, this.touchMoveSensibility !== 0 ? (speed * this._offsetY) / this.touchMoveSensibility : 0);\r\n\r\n Matrix.RotationYawPitchRollToRef(camera.rotation.y, camera.rotation.x, 0, camera._cameraRotationMatrix);\r\n camera.cameraDirection.addInPlace(Vector3.TransformCoordinates(direction, camera._cameraRotationMatrix));\r\n }\r\n }\r\n\r\n /**\r\n * Gets the class name of the current input.\r\n * @returns the class name\r\n */\r\n public getClassName(): string {\r\n return \"FreeCameraTouchInput\";\r\n }\r\n\r\n /**\r\n * Get the friendly name associated with the input class.\r\n * @returns the input friendly name\r\n */\r\n public getSimpleName(): string {\r\n return \"touch\";\r\n }\r\n}\r\n\r\n(<any>CameraInputTypes)[\"FreeCameraTouchInput\"] = FreeCameraTouchInput;\r\n"]}
1
+ {"version":3,"file":"freeCameraTouchInput.js","sourceRoot":"","sources":["../../../../../dev/core/src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;aAAM;YACH,MAAM,KAAK,GAAG,MAAM,CAAC,wBAAwB,EAAE,CAAC;YAChD,MAAM,SAAS,GAAG,IAAI,OAAO,CAAC,CAAC,EAAE,CAAC,EAAE,IAAI,CAAC,oBAAoB,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC,KAAK,GAAG,IAAI,CAAC,QAAQ,CAAC,GAAG,IAAI,CAAC,oBAAoB,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;YAE/H,MAAM,CAAC,yBAAyB,CAAC,MAAM,CAAC,QAAQ,CAAC,CAAC,EAAE,MAAM,CAAC,QAAQ,CAAC,CAAC,EAAE,CAAC,EAAE,MAAM,CAAC,qBAAqB,CAAC,CAAC;YACxG,MAAM,CAAC,eAAe,CAAC,UAAU,CAAC,OAAO,CAAC,oBAAoB,CAAC,SAAS,EAAE,MAAM,CAAC,qBAAqB,CAAC,CAAC,CAAC;SAC5G;IACL,CAAC;IAED;;;OAGG;IACI,YAAY;QACf,OAAO,sBAAsB,CAAC;IAClC,CAAC;IAED;;;OAGG;IACI,aAAa;QAChB,OAAO,OAAO,CAAC;IACnB,CAAC;CACJ;AAhMU;IADN,SAAS,EAAE;qEACsC;AAO3C;IADN,SAAS,EAAE;kEACgC;AA2L1C,gBAAiB,CAAC,sBAAsB,CAAC,GAAG,oBAAoB,CAAC","sourcesContent":["import { serialize } from \"../../Misc/decorators\";\r\nimport type { Observer, EventState } from \"../../Misc/observable\";\r\nimport type { Nullable } from \"../../types\";\r\nimport type { ICameraInput } from \"../../Cameras/cameraInputsManager\";\r\nimport { CameraInputTypes } from \"../../Cameras/cameraInputsManager\";\r\nimport type { FreeCamera } from \"../../Cameras/freeCamera\";\r\nimport type { PointerInfo } from \"../../Events/pointerEvents\";\r\nimport { PointerEventTypes } from \"../../Events/pointerEvents\";\r\nimport { Matrix, Vector3 } from \"../../Maths/math.vector\";\r\nimport { Tools } from \"../../Misc/tools\";\r\nimport type { IPointerEvent } from \"../../Events/deviceInputEvents\";\r\n/**\r\n * Manage the touch inputs to control the movement of a free camera.\r\n * @see https://doc.babylonjs.com/features/featuresDeepDive/cameras/customizingCameraInputs\r\n */\r\nexport class FreeCameraTouchInput implements ICameraInput<FreeCamera> {\r\n /**\r\n * Defines the camera the input is attached to.\r\n */\r\n public camera: FreeCamera;\r\n\r\n /**\r\n * Defines the touch sensibility for rotation.\r\n * The lower the faster.\r\n */\r\n @serialize()\r\n public touchAngularSensibility: number = 200000.0;\r\n\r\n /**\r\n * Defines the touch sensibility for move.\r\n * The lower the faster.\r\n */\r\n @serialize()\r\n public touchMoveSensibility: number = 250.0;\r\n\r\n /**\r\n * Swap touch actions so that one touch is used for rotation and multiple for movement\r\n */\r\n public singleFingerRotate: boolean = false;\r\n\r\n private _offsetX: Nullable<number> = null;\r\n private _offsetY: Nullable<number> = null;\r\n\r\n private _pointerPressed = new Array<number>();\r\n private _pointerInput?: (p: PointerInfo, s: EventState) => void;\r\n private _observer: Nullable<Observer<PointerInfo>>;\r\n private _onLostFocus: Nullable<(e: FocusEvent) => any>;\r\n private _isSafari: boolean;\r\n\r\n /**\r\n * Manage the touch inputs to control the movement of a free camera.\r\n * @see https://doc.babylonjs.com/features/featuresDeepDive/cameras/customizingCameraInputs\r\n * @param allowMouse Defines if mouse events can be treated as touch events\r\n */\r\n constructor(\r\n /**\r\n * [false] Define if mouse events can be treated as touch events\r\n */\r\n public allowMouse = false\r\n ) {\r\n this._isSafari = Tools.IsSafari();\r\n }\r\n\r\n /**\r\n * Attach the input controls to a specific dom element to get the input from.\r\n * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)\r\n */\r\n public attachControl(noPreventDefault?: boolean): void {\r\n // eslint-disable-next-line prefer-rest-params\r\n noPreventDefault = Tools.BackCompatCameraNoPreventDefault(arguments);\r\n let previousPosition: Nullable<{ x: number; y: number }> = null;\r\n\r\n if (this._pointerInput === undefined) {\r\n this._onLostFocus = () => {\r\n this._offsetX = null;\r\n this._offsetY = null;\r\n };\r\n\r\n this._pointerInput = (p) => {\r\n const evt = <IPointerEvent>p.event;\r\n\r\n const isMouseEvent = evt.pointerType === \"mouse\" || (this._isSafari && typeof evt.pointerType === \"undefined\");\r\n\r\n if (!this.allowMouse && isMouseEvent) {\r\n return;\r\n }\r\n\r\n if (p.type === PointerEventTypes.POINTERDOWN) {\r\n if (!noPreventDefault) {\r\n evt.preventDefault();\r\n }\r\n\r\n this._pointerPressed.push(evt.pointerId);\r\n\r\n if (this._pointerPressed.length !== 1) {\r\n return;\r\n }\r\n\r\n previousPosition = {\r\n x: evt.clientX,\r\n y: evt.clientY,\r\n };\r\n } else if (p.type === PointerEventTypes.POINTERUP) {\r\n if (!noPreventDefault) {\r\n evt.preventDefault();\r\n }\r\n\r\n const index: number = this._pointerPressed.indexOf(evt.pointerId);\r\n\r\n if (index === -1) {\r\n return;\r\n }\r\n this._pointerPressed.splice(index, 1);\r\n\r\n if (index != 0) {\r\n return;\r\n }\r\n previousPosition = null;\r\n this._offsetX = null;\r\n this._offsetY = null;\r\n } else if (p.type === PointerEventTypes.POINTERMOVE) {\r\n if (!noPreventDefault) {\r\n evt.preventDefault();\r\n }\r\n\r\n if (!previousPosition) {\r\n return;\r\n }\r\n\r\n const index: number = this._pointerPressed.indexOf(evt.pointerId);\r\n\r\n if (index != 0) {\r\n return;\r\n }\r\n\r\n this._offsetX = evt.clientX - previousPosition.x;\r\n this._offsetY = -(evt.clientY - previousPosition.y);\r\n }\r\n };\r\n }\r\n\r\n this._observer = this.camera\r\n .getScene()\r\n ._inputManager._addCameraPointerObserver(this._pointerInput, PointerEventTypes.POINTERDOWN | PointerEventTypes.POINTERUP | PointerEventTypes.POINTERMOVE);\r\n\r\n if (this._onLostFocus) {\r\n const engine = this.camera.getEngine();\r\n const element = engine.getInputElement();\r\n element && element.addEventListener(\"blur\", this._onLostFocus);\r\n }\r\n }\r\n\r\n /**\r\n * Detach the current controls from the specified dom element.\r\n */\r\n public detachControl(): void {\r\n if (this._pointerInput) {\r\n if (this._observer) {\r\n this.camera.getScene()._inputManager._removeCameraPointerObserver(this._observer);\r\n this._observer = null;\r\n }\r\n\r\n if (this._onLostFocus) {\r\n const engine = this.camera.getEngine();\r\n const element = engine.getInputElement();\r\n element && element.removeEventListener(\"blur\", this._onLostFocus);\r\n this._onLostFocus = null;\r\n }\r\n this._pointerPressed.length = 0;\r\n this._offsetX = null;\r\n this._offsetY = null;\r\n }\r\n }\r\n\r\n /**\r\n * Update the current camera state depending on the inputs that have been used this frame.\r\n * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.\r\n */\r\n public checkInputs(): void {\r\n if (this._offsetX === null || this._offsetY === null) {\r\n return;\r\n }\r\n if (this._offsetX === 0 && this._offsetY === 0) {\r\n return;\r\n }\r\n\r\n const camera = this.camera;\r\n const handednessMultiplier = camera._calculateHandednessMultiplier();\r\n camera.cameraRotation.y = (handednessMultiplier * this._offsetX) / this.touchAngularSensibility;\r\n\r\n const rotateCamera = (this.singleFingerRotate && this._pointerPressed.length === 1) || (!this.singleFingerRotate && this._pointerPressed.length > 1);\r\n\r\n if (rotateCamera) {\r\n camera.cameraRotation.x = -this._offsetY / this.touchAngularSensibility;\r\n } else {\r\n const speed = camera._computeLocalCameraSpeed();\r\n const direction = new Vector3(0, 0, this.touchMoveSensibility !== 0 ? (speed * this._offsetY) / this.touchMoveSensibility : 0);\r\n\r\n Matrix.RotationYawPitchRollToRef(camera.rotation.y, camera.rotation.x, 0, camera._cameraRotationMatrix);\r\n camera.cameraDirection.addInPlace(Vector3.TransformCoordinates(direction, camera._cameraRotationMatrix));\r\n }\r\n }\r\n\r\n /**\r\n * Gets the class name of the current input.\r\n * @returns the class name\r\n */\r\n public getClassName(): string {\r\n return \"FreeCameraTouchInput\";\r\n }\r\n\r\n /**\r\n * Get the friendly name associated with the input class.\r\n * @returns the input friendly name\r\n */\r\n public getSimpleName(): string {\r\n return \"touch\";\r\n }\r\n}\r\n\r\n(<any>CameraInputTypes)[\"FreeCameraTouchInput\"] = FreeCameraTouchInput;\r\n"]}
@@ -0,0 +1,28 @@
1
+ import type { Mesh } from "../../Meshes/mesh.js";
2
+ import type { AbstractEngine } from "../../Engines/abstractEngine.js";
3
+ /**
4
+ * Utility class to help with bounding info management
5
+ * #BCNJD4#5
6
+ * #BCNJD4#14
7
+ */
8
+ export declare class BoundingInfoHelper {
9
+ private _platform;
10
+ private _buffers;
11
+ private _effects;
12
+ /**
13
+ * Creates a new BoundingInfoHelper
14
+ * @param engine defines the engine to use
15
+ */
16
+ constructor(engine: AbstractEngine);
17
+ /**
18
+ * Compute the bounding info of a mesh using shaders
19
+ * @param mesh defines the mesh to update
20
+ * @returns a promise that resolves when the bounding info is computed
21
+ */
22
+ computeAsync(mesh: Mesh): Promise<void>;
23
+ private _updateBuffer;
24
+ /**
25
+ * Dispose and release associated resources
26
+ */
27
+ dispose(): void;
28
+ }