@onerjs/core 8.31.5 → 8.31.7

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 (72) hide show
  1. package/Animations/animation.d.ts +3 -1
  2. package/Animations/animation.js +5 -4
  3. package/Animations/animation.js.map +1 -1
  4. package/Behaviors/Cameras/interpolatingBehavior.d.ts +2 -1
  5. package/Behaviors/Cameras/interpolatingBehavior.js +11 -4
  6. package/Behaviors/Cameras/interpolatingBehavior.js.map +1 -1
  7. package/Cameras/Inputs/geospatialCameraKeyboardInput.js +2 -0
  8. package/Cameras/Inputs/geospatialCameraKeyboardInput.js.map +1 -1
  9. package/Cameras/Inputs/geospatialCameraPointersInput.js +3 -5
  10. package/Cameras/Inputs/geospatialCameraPointersInput.js.map +1 -1
  11. package/Cameras/geospatialCamera.d.ts +20 -1
  12. package/Cameras/geospatialCamera.js +105 -28
  13. package/Cameras/geospatialCamera.js.map +1 -1
  14. package/Cameras/geospatialCameraMovement.d.ts +7 -2
  15. package/Cameras/geospatialCameraMovement.js +46 -10
  16. package/Cameras/geospatialCameraMovement.js.map +1 -1
  17. package/Engines/abstractEngine.js +2 -2
  18. package/Engines/abstractEngine.js.map +1 -1
  19. package/Engines/thinEngine.js +1 -1
  20. package/Engines/thinEngine.js.map +1 -1
  21. package/FrameGraph/Node/nodeRenderGraph.d.ts +22 -5
  22. package/FrameGraph/Node/nodeRenderGraph.js +39 -18
  23. package/FrameGraph/Node/nodeRenderGraph.js.map +1 -1
  24. package/FrameGraph/Passes/pass.d.ts +2 -0
  25. package/FrameGraph/Passes/pass.js +2 -0
  26. package/FrameGraph/Passes/pass.js.map +1 -1
  27. package/FrameGraph/Passes/renderPass.d.ts +2 -0
  28. package/FrameGraph/Passes/renderPass.js +4 -0
  29. package/FrameGraph/Passes/renderPass.js.map +1 -1
  30. package/FrameGraph/frameGraph.d.ts +13 -4
  31. package/FrameGraph/frameGraph.js +45 -5
  32. package/FrameGraph/frameGraph.js.map +1 -1
  33. package/FrameGraph/frameGraphRenderTarget.d.ts +1 -0
  34. package/FrameGraph/frameGraphRenderTarget.js +3 -0
  35. package/FrameGraph/frameGraphRenderTarget.js.map +1 -1
  36. package/FrameGraph/frameGraphTask.d.ts +6 -0
  37. package/FrameGraph/frameGraphTask.js +15 -0
  38. package/FrameGraph/frameGraphTask.js.map +1 -1
  39. package/FrameGraph/frameGraphTypes.d.ts +2 -0
  40. package/FrameGraph/frameGraphTypes.js.map +1 -1
  41. package/Materials/Node/nodeMaterial.js +3 -0
  42. package/Materials/Node/nodeMaterial.js.map +1 -1
  43. package/Materials/materialHelper.functions.d.ts +29 -7
  44. package/Materials/materialHelper.functions.js +59 -24
  45. package/Materials/materialHelper.functions.js.map +1 -1
  46. package/Materials/shaderMaterial.d.ts +1 -0
  47. package/Materials/shaderMaterial.js +6 -17
  48. package/Materials/shaderMaterial.js.map +1 -1
  49. package/Meshes/mesh.js +1 -1
  50. package/Meshes/mesh.js.map +1 -1
  51. package/Misc/screenshotTools.js +2 -8
  52. package/Misc/screenshotTools.js.map +1 -1
  53. package/Particles/Node/Blocks/index.d.ts +1 -0
  54. package/Particles/Node/Blocks/index.js +1 -0
  55. package/Particles/Node/Blocks/index.js.map +1 -1
  56. package/Particles/Node/Blocks/particleFloatToIntBlock.d.ts +46 -0
  57. package/Particles/Node/Blocks/particleFloatToIntBlock.js +120 -0
  58. package/Particles/Node/Blocks/particleFloatToIntBlock.js.map +1 -0
  59. package/Particles/Node/Blocks/systemBlock.d.ts +4 -4
  60. package/Particles/Node/Blocks/systemBlock.js +22 -16
  61. package/Particles/Node/Blocks/systemBlock.js.map +1 -1
  62. package/Particles/Node/nodeParticleBuildState.js +1 -1
  63. package/Particles/Node/nodeParticleBuildState.js.map +1 -1
  64. package/Particles/Node/nodeParticleSystemSet.helper.js +61 -30
  65. package/Particles/Node/nodeParticleSystemSet.helper.js.map +1 -1
  66. package/Particles/thinParticleSystem.d.ts +6 -0
  67. package/Particles/thinParticleSystem.js +21 -12
  68. package/Particles/thinParticleSystem.js.map +1 -1
  69. package/ShadersWGSL/iblVoxelGrid.vertex.d.ts +1 -0
  70. package/ShadersWGSL/iblVoxelGrid.vertex.js +53 -64
  71. package/ShadersWGSL/iblVoxelGrid.vertex.js.map +1 -1
  72. package/package.json +1 -1
@@ -76,7 +76,7 @@ export class InterpolatingBehavior {
76
76
  }
77
77
  });
78
78
  }
79
- async animatePropertiesAsync(properties, transitionDuration = this.transitionDuration, easingFn = this.easingFunction) {
79
+ async animatePropertiesAsync(properties, transitionDuration = this.transitionDuration, easingFn = this.easingFunction, customKeys) {
80
80
  const promise = new Promise((resolve) => {
81
81
  this._promiseResolve = resolve;
82
82
  this.stopAllAnimations();
@@ -86,8 +86,14 @@ export class InterpolatingBehavior {
86
86
  }
87
87
  const camera = this._attachedCamera;
88
88
  const scene = camera.getScene();
89
- const checkClear = (animation) => {
90
- this._animatables.delete(animation);
89
+ const checkClear = (propertyName) => {
90
+ // Remove the associated animation from camera once the transition to target is complete so that property animations don't accumulate
91
+ for (let i = camera.animations.length - 1; i >= 0; --i) {
92
+ if (camera.animations[i].name === propertyName + "Animation") {
93
+ camera.animations.splice(i, 1);
94
+ }
95
+ }
96
+ this._animatables.delete(propertyName);
91
97
  if (this._animatables.size === 0) {
92
98
  this._promiseResolve = undefined;
93
99
  resolve();
@@ -97,7 +103,8 @@ export class InterpolatingBehavior {
97
103
  if (value !== undefined) {
98
104
  const propertyName = String(key);
99
105
  const animation = Animation.CreateAnimation(propertyName, GetAnimationType(value), 60, easingFn);
100
- const animatable = Animation.TransitionTo(propertyName, value, camera, scene, 60, animation, transitionDuration, () => checkClear(propertyName));
106
+ // Pass false for stopCurrent so that we can interpolate multiple properties at once
107
+ const animatable = Animation.TransitionTo(propertyName, value, camera, scene, 60, animation, transitionDuration, () => checkClear(propertyName), false, customKeys?.get(key));
101
108
  if (animatable) {
102
109
  this._animatables.set(propertyName, animatable);
103
110
  }
@@ -1 +1 @@
1
- {"version":3,"file":"interpolatingBehavior.js","sourceRoot":"","sources":["../../../../../dev/core/src/Behaviors/Cameras/interpolatingBehavior.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,SAAS,EAAE,cAAc,EAAE,MAAM,yBAAyB,CAAC;AAGpE,OAAO,EAAE,SAAS,EAAE,MAAM,4BAA4B,CAAC;AAMvD;;;GAGG;AACH,MAAM,OAAO,qBAAqB;IAC9B;;OAEG;IACH,IAAW,IAAI;QACX,OAAO,eAAe,CAAC;IAC3B,CAAC;IAqBD;;OAEG;IACH;QAtBA;;WAEG;QACI,mBAAc,GAAmB,IAAI,SAAS,EAAE,CAAC;QAExD;;WAEG;QACI,eAAU,GAAG,cAAc,CAAC,oBAAoB,CAAC;QAExD;;WAEG;QACI,uBAAkB,GAAG,GAAG,CAAC;QAExB,oBAAe,GAAgB,IAAI,CAAC;QACpC,iBAAY,GAA4B,IAAI,GAAG,EAAsB,CAAC;QAO1E,IAAI,CAAC,cAAc,CAAC,aAAa,CAAC,IAAI,CAAC,UAAU,CAAC,CAAC;IACvD,CAAC;IAED;;OAEG;IACI,IAAI;QACP,wBAAwB;IAC5B,CAAC;IAED;;;OAGG;IACI,MAAM,CAAC,MAAS;QACnB,IAAI,CAAC,eAAe,GAAG,MAAM,CAAC;IAClC,CAAC;IAED;;OAEG;IACI,MAAM;QACT,IAAI,CAAC,IAAI,CAAC,eAAe,EAAE,CAAC;YACxB,OAAO;QACX,CAAC;QAED,IAAI,CAAC,iBAAiB,EAAE,CAAC;QACzB,IAAI,CAAC,eAAe,GAAG,IAAI,CAAC;IAChC,CAAC;IAED,IAAW,eAAe;QACtB,OAAO,IAAI,CAAC,YAAY,CAAC,IAAI,GAAG,CAAC,CAAC;IACtC,CAAC;IAED;;OAEG;IACI,iBAAiB;QACpB,IAAI,IAAI,CAAC,eAAe,EAAE,CAAC;YACvB,IAAI,CAAC,YAAY,CAAC,OAAO,CAAC,CAAC,UAAU,EAAE,EAAE,CAAC,UAAU,CAAC,IAAI,EAAE,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C;IACD,IAAI,aAAa,CAAC,KAAK,CAAC,EAAE,CAAC;QACvB,OAAO,SAAS,CAAC,qBAAqB,CAAC;IAC3C,CAAC;IACD,IAAI,aAAa,CAAC,KAAK,CAAC,EAAE,CAAC;QACvB,OAAO,SAAS,CAAC,qBAAqB,CAAC;IAC3C,CAAC;IACD,IAAI,YAAY,CAAC,KAAK,CAAC,EAAE,CAAC;QACtB,OAAO,SAAS,CAAC,oBAAoB,CAAC;IAC1C,CAAC;IACD,IAAI,YAAY,CAAC,KAAK,CAAC,EAAE,CAAC;QACtB,OAAO,SAAS,CAAC,oBAAoB,CAAC;IAC1C,CAAC;IACD,IAAI,UAAU,CAAC,KAAK,CAAC,EAAE,CAAC;QACpB,OAAO,SAAS,CAAC,kBAAkB,CAAC;IACxC,CAAC;IAED,mDAAmD;IACnD,OAAO,SAAS,CAAC,mBAAmB,CAAC;AACzC,CAAC,CAAC","sourcesContent":["import type { Behavior } from \"../behavior\";\r\nimport { CubicEase, EasingFunction } from \"../../Animations/easing\";\r\nimport type { Nullable } from \"../../types\";\r\nimport type { Animatable } from \"../../Animations/animatable.core\";\r\nimport { Animation } from \"../../Animations/animation\";\r\nimport type { Camera } from \"../../Cameras/camera\";\r\nimport type { IColor3Like, IColor4Like, IMatrixLike, IQuaternionLike, IVector2Like, IVector3Like } from \"../../Maths/math.like\";\r\n\r\nexport type AllowedAnimValue = number | IVector2Like | IVector3Like | IQuaternionLike | IMatrixLike | IColor3Like | IColor4Like | SizeLike | undefined;\r\n\r\n/**\r\n * Animate camera property changes with an interpolation effect\r\n * @see https://doc.babylonjs.com/features/featuresDeepDive/behaviors/cameraBehaviors\r\n */\r\nexport class InterpolatingBehavior<C extends Camera = Camera> implements Behavior<C> {\r\n /**\r\n * Gets the name of the behavior.\r\n */\r\n public get name(): string {\r\n return \"Interpolating\";\r\n }\r\n\r\n /**\r\n * The easing function to use for interpolation\r\n */\r\n public easingFunction: EasingFunction = new CubicEase();\r\n\r\n /**\r\n * The easing mode (default is EASINGMODE_EASEINOUT)\r\n */\r\n public easingMode = EasingFunction.EASINGMODE_EASEINOUT;\r\n\r\n /**\r\n * Duration of the animation in milliseconds\r\n */\r\n public transitionDuration = 450;\r\n\r\n private _attachedCamera: Nullable<C> = null;\r\n private _animatables: Map<string, Animatable> = new Map<string, Animatable>();\r\n private _promiseResolve?: () => void;\r\n\r\n /**\r\n * Initializes the behavior\r\n */\r\n constructor() {\r\n this.easingFunction.setEasingMode(this.easingMode);\r\n }\r\n\r\n /**\r\n * Initializes the behavior\r\n */\r\n public init(): void {\r\n // Nothing to do on init\r\n }\r\n\r\n /**\r\n * Attaches the behavior to a camera\r\n * @param camera The camera to attach to\r\n */\r\n public attach(camera: C): void {\r\n this._attachedCamera = camera;\r\n }\r\n\r\n /**\r\n * Detaches the behavior from the camera\r\n */\r\n public detach(): void {\r\n if (!this._attachedCamera) {\r\n return;\r\n }\r\n\r\n this.stopAllAnimations();\r\n this._attachedCamera = null;\r\n }\r\n\r\n public get isInterpolating(): boolean {\r\n return this._animatables.size > 0;\r\n }\r\n\r\n /**\r\n * Stops and removes all animations\r\n */\r\n public stopAllAnimations(): void {\r\n if (this._attachedCamera) {\r\n this._animatables.forEach((animatable) => animatable.stop());\r\n }\r\n this._animatables.clear();\r\n this._promiseResolve?.();\r\n this._promiseResolve = undefined;\r\n }\r\n\r\n public updateProperties<K extends keyof C>(properties: Map<K, AllowedAnimValue>): void {\r\n properties.forEach((value, key) => {\r\n if (value !== undefined) {\r\n const animatable = this._animatables.get(String(key));\r\n animatable && (animatable.target = value as unknown as any);\r\n }\r\n });\r\n }\r\n\r\n public async animatePropertiesAsync<K extends keyof C>(\r\n properties: Map<K, AllowedAnimValue>,\r\n transitionDuration: number = this.transitionDuration,\r\n easingFn: EasingFunction = this.easingFunction\r\n ): Promise<void> {\r\n const promise = new Promise<void>((resolve) => {\r\n this._promiseResolve = resolve;\r\n this.stopAllAnimations();\r\n if (!this._attachedCamera) {\r\n this._promiseResolve = undefined;\r\n return resolve();\r\n }\r\n const camera = this._attachedCamera;\r\n const scene = camera.getScene();\r\n\r\n const checkClear = (animation: string) => {\r\n this._animatables.delete(animation);\r\n if (this._animatables.size === 0) {\r\n this._promiseResolve = undefined;\r\n resolve();\r\n }\r\n };\r\n\r\n properties.forEach((value, key) => {\r\n if (value !== undefined) {\r\n const propertyName = String(key);\r\n const animation = Animation.CreateAnimation(propertyName, GetAnimationType(value), 60, easingFn);\r\n const animatable = Animation.TransitionTo(propertyName, value, camera, scene, 60, animation, transitionDuration, () => checkClear(propertyName));\r\n if (animatable) {\r\n this._animatables.set(propertyName, animatable);\r\n }\r\n }\r\n });\r\n });\r\n return await promise;\r\n }\r\n}\r\n\r\n// Structural type-guards (no instanceof)\r\nfunction IsQuaternionLike(v: any): v is IQuaternionLike {\r\n return v != null && typeof v.x === \"number\" && typeof v.y === \"number\" && typeof v.z === \"number\" && typeof v.w === \"number\";\r\n}\r\n\r\nfunction IsMatrixLike(v: any): v is IMatrixLike {\r\n return v != null && (Array.isArray((v as any).m) || typeof (v as any).m === \"object\");\r\n}\r\n\r\nfunction IsVector3Like(v: any): v is IVector3Like {\r\n return v != null && typeof v.x === \"number\" && typeof v.y === \"number\" && typeof v.z === \"number\";\r\n}\r\n\r\nfunction IsVector2Like(v: any): v is IVector2Like {\r\n return v != null && typeof v.x === \"number\" && typeof v.y === \"number\";\r\n}\r\n\r\nfunction IsColor3Like(v: any): v is IColor3Like {\r\n return v != null && typeof v.r === \"number\" && typeof v.g === \"number\" && typeof v.b === \"number\";\r\n}\r\n\r\nfunction IsColor4Like(v: any): v is IColor4Like {\r\n return v != null && typeof v.r === \"number\" && typeof v.g === \"number\" && typeof v.b === \"number\" && typeof v.a === \"number\";\r\n}\r\n\r\nexport type SizeLike = { width: number; height: number };\r\n\r\nfunction IsSizeLike(v: any): v is SizeLike {\r\n return v != null && typeof v.width === \"number\" && typeof v.height === \"number\";\r\n}\r\n\r\nconst GetAnimationType = (value: AllowedAnimValue): number => {\r\n if (IsQuaternionLike(value)) {\r\n return Animation.ANIMATIONTYPE_QUATERNION;\r\n }\r\n if (IsMatrixLike(value)) {\r\n return Animation.ANIMATIONTYPE_MATRIX;\r\n }\r\n if (IsVector3Like(value)) {\r\n return Animation.ANIMATIONTYPE_VECTOR3;\r\n }\r\n if (IsVector2Like(value)) {\r\n return Animation.ANIMATIONTYPE_VECTOR2;\r\n }\r\n if (IsColor3Like(value)) {\r\n return Animation.ANIMATIONTYPE_COLOR3;\r\n }\r\n if (IsColor4Like(value)) {\r\n return Animation.ANIMATIONTYPE_COLOR4;\r\n }\r\n if (IsSizeLike(value)) {\r\n return Animation.ANIMATIONTYPE_SIZE;\r\n }\r\n\r\n // Fallback to float for numbers and unknown shapes\r\n return Animation.ANIMATIONTYPE_FLOAT;\r\n};\r\n"]}
1
+ {"version":3,"file":"interpolatingBehavior.js","sourceRoot":"","sources":["../../../../../dev/core/src/Behaviors/Cameras/interpolatingBehavior.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,SAAS,EAAE,cAAc,EAAE,MAAM,yBAAyB,CAAC;AAGpE,OAAO,EAAE,SAAS,EAAE,MAAM,4BAA4B,CAAC;AAOvD;;;GAGG;AACH,MAAM,OAAO,qBAAqB;IAC9B;;OAEG;IACH,IAAW,IAAI;QACX,OAAO,eAAe,CAAC;IAC3B,CAAC;IAqBD;;OAEG;IACH;QAtBA;;WAEG;QACI,mBAAc,GAAmB,IAAI,SAAS,EAAE,CAAC;QAExD;;WAEG;QACI,eAAU,GAAG,cAAc,CAAC,oBAAoB,CAAC;QAExD;;WAEG;QACI,uBAAkB,GAAG,GAAG,CAAC;QAExB,oBAAe,GAAgB,IAAI,CAAC;QACpC,iBAAY,GAA4B,IAAI,GAAG,EAAsB,CAAC;QAO1E,IAAI,CAAC,cAAc,CAAC,aAAa,CAAC,IAAI,CAAC,UAAU,CAAC,CAAC;IACvD,CAAC;IAED;;OAEG;IACI,IAAI;QACP,wBAAwB;IAC5B,CAAC;IAED;;;OAGG;I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AAI,YAAY,CAAC,KAAK,CAAC,EAAE,CAAC;QACtB,OAAO,SAAS,CAAC,oBAAoB,CAAC;IAC1C,CAAC;IACD,IAAI,UAAU,CAAC,KAAK,CAAC,EAAE,CAAC;QACpB,OAAO,SAAS,CAAC,kBAAkB,CAAC;IACxC,CAAC;IAED,mDAAmD;IACnD,OAAO,SAAS,CAAC,mBAAmB,CAAC;AACzC,CAAC,CAAC","sourcesContent":["import type { Behavior } from \"../behavior\";\r\nimport { CubicEase, EasingFunction } from \"../../Animations/easing\";\r\nimport type { Nullable } from \"../../types\";\r\nimport type { Animatable } from \"../../Animations/animatable.core\";\r\nimport { Animation } from \"../../Animations/animation\";\r\nimport type { Camera } from \"../../Cameras/camera\";\r\nimport type { IColor3Like, IColor4Like, IMatrixLike, IQuaternionLike, IVector2Like, IVector3Like } from \"../../Maths/math.like\";\r\nimport type { IAnimationKey } from \"../../Animations/animationKey\";\r\n\r\nexport type AllowedAnimValue = number | IVector2Like | IVector3Like | IQuaternionLike | IMatrixLike | IColor3Like | IColor4Like | SizeLike | undefined;\r\n\r\n/**\r\n * Animate camera property changes with an interpolation effect\r\n * @see https://doc.babylonjs.com/features/featuresDeepDive/behaviors/cameraBehaviors\r\n */\r\nexport class InterpolatingBehavior<C extends Camera = Camera> implements Behavior<C> {\r\n /**\r\n * Gets the name of the behavior.\r\n */\r\n public get name(): string {\r\n return \"Interpolating\";\r\n }\r\n\r\n /**\r\n * The easing function to use for interpolation\r\n */\r\n public easingFunction: EasingFunction = new CubicEase();\r\n\r\n /**\r\n * The easing mode (default is EASINGMODE_EASEINOUT)\r\n */\r\n public easingMode = EasingFunction.EASINGMODE_EASEINOUT;\r\n\r\n /**\r\n * Duration of the animation in milliseconds\r\n */\r\n public transitionDuration = 450;\r\n\r\n private _attachedCamera: Nullable<C> = null;\r\n private _animatables: Map<string, Animatable> = new Map<string, Animatable>();\r\n private _promiseResolve?: () => void;\r\n\r\n /**\r\n * Initializes the behavior\r\n */\r\n constructor() {\r\n this.easingFunction.setEasingMode(this.easingMode);\r\n }\r\n\r\n /**\r\n * Initializes the behavior\r\n */\r\n public init(): void {\r\n // Nothing to do on init\r\n }\r\n\r\n /**\r\n * Attaches the behavior to a camera\r\n * @param camera The camera to attach to\r\n */\r\n public attach(camera: C): void {\r\n this._attachedCamera = camera;\r\n }\r\n\r\n /**\r\n * Detaches the behavior from the camera\r\n */\r\n public detach(): void {\r\n if (!this._attachedCamera) {\r\n return;\r\n }\r\n\r\n this.stopAllAnimations();\r\n this._attachedCamera = null;\r\n }\r\n\r\n public get isInterpolating(): boolean {\r\n return this._animatables.size > 0;\r\n }\r\n\r\n /**\r\n * Stops and removes all animations\r\n */\r\n public stopAllAnimations(): void {\r\n if (this._attachedCamera) {\r\n this._animatables.forEach((animatable) => animatable.stop());\r\n }\r\n this._animatables.clear();\r\n this._promiseResolve?.();\r\n this._promiseResolve = undefined;\r\n }\r\n\r\n public updateProperties<K extends keyof C>(properties: Map<K, AllowedAnimValue>): void {\r\n properties.forEach((value, key) => {\r\n if (value !== undefined) {\r\n const animatable = this._animatables.get(String(key));\r\n animatable && (animatable.target = value as unknown as any);\r\n }\r\n });\r\n }\r\n\r\n public async animatePropertiesAsync<K extends keyof C>(\r\n properties: Map<K, AllowedAnimValue>,\r\n transitionDuration: number = this.transitionDuration,\r\n easingFn: EasingFunction = this.easingFunction,\r\n customKeys?: Map<K, IAnimationKey[]>\r\n ): Promise<void> {\r\n const promise = new Promise<void>((resolve) => {\r\n this._promiseResolve = resolve;\r\n this.stopAllAnimations();\r\n if (!this._attachedCamera) {\r\n this._promiseResolve = undefined;\r\n return resolve();\r\n }\r\n const camera = this._attachedCamera;\r\n const scene = camera.getScene();\r\n\r\n const checkClear = (propertyName: string) => {\r\n // Remove the associated animation from camera once the transition to target is complete so that property animations don't accumulate\r\n for (let i = camera.animations.length - 1; i >= 0; --i) {\r\n if (camera.animations[i].name === propertyName + \"Animation\") {\r\n camera.animations.splice(i, 1);\r\n }\r\n }\r\n\r\n this._animatables.delete(propertyName);\r\n if (this._animatables.size === 0) {\r\n this._promiseResolve = undefined;\r\n resolve();\r\n }\r\n };\r\n\r\n properties.forEach((value, key) => {\r\n if (value !== undefined) {\r\n const propertyName = String(key);\r\n const animation = Animation.CreateAnimation(propertyName, GetAnimationType(value), 60, easingFn);\r\n // Pass false for stopCurrent so that we can interpolate multiple properties at once\r\n const animatable = Animation.TransitionTo(\r\n propertyName,\r\n value,\r\n camera,\r\n scene,\r\n 60,\r\n animation,\r\n transitionDuration,\r\n () => checkClear(propertyName),\r\n false,\r\n customKeys?.get(key)\r\n );\r\n if (animatable) {\r\n this._animatables.set(propertyName, animatable);\r\n }\r\n }\r\n });\r\n });\r\n return await promise;\r\n }\r\n}\r\n\r\n// Structural type-guards (no instanceof)\r\nfunction IsQuaternionLike(v: any): v is IQuaternionLike {\r\n return v != null && typeof v.x === \"number\" && typeof v.y === \"number\" && typeof v.z === \"number\" && typeof v.w === \"number\";\r\n}\r\n\r\nfunction IsMatrixLike(v: any): v is IMatrixLike {\r\n return v != null && (Array.isArray((v as any).m) || typeof (v as any).m === \"object\");\r\n}\r\n\r\nfunction IsVector3Like(v: any): v is IVector3Like {\r\n return v != null && typeof v.x === \"number\" && typeof v.y === \"number\" && typeof v.z === \"number\";\r\n}\r\n\r\nfunction IsVector2Like(v: any): v is IVector2Like {\r\n return v != null && typeof v.x === \"number\" && typeof v.y === \"number\";\r\n}\r\n\r\nfunction IsColor3Like(v: any): v is IColor3Like {\r\n return v != null && typeof v.r === \"number\" && typeof v.g === \"number\" && typeof v.b === \"number\";\r\n}\r\n\r\nfunction IsColor4Like(v: any): v is IColor4Like {\r\n return v != null && typeof v.r === \"number\" && typeof v.g === \"number\" && typeof v.b === \"number\" && typeof v.a === \"number\";\r\n}\r\n\r\nexport type SizeLike = { width: number; height: number };\r\n\r\nfunction IsSizeLike(v: any): v is SizeLike {\r\n return v != null && typeof v.width === \"number\" && typeof v.height === \"number\";\r\n}\r\n\r\nconst GetAnimationType = (value: AllowedAnimValue): number => {\r\n if (IsQuaternionLike(value)) {\r\n return Animation.ANIMATIONTYPE_QUATERNION;\r\n }\r\n if (IsMatrixLike(value)) {\r\n return Animation.ANIMATIONTYPE_MATRIX;\r\n }\r\n if (IsVector3Like(value)) {\r\n return Animation.ANIMATIONTYPE_VECTOR3;\r\n }\r\n if (IsVector2Like(value)) {\r\n return Animation.ANIMATIONTYPE_VECTOR2;\r\n }\r\n if (IsColor3Like(value)) {\r\n return Animation.ANIMATIONTYPE_COLOR3;\r\n }\r\n if (IsColor4Like(value)) {\r\n return Animation.ANIMATIONTYPE_COLOR4;\r\n }\r\n if (IsSizeLike(value)) {\r\n return Animation.ANIMATIONTYPE_SIZE;\r\n }\r\n\r\n // Fallback to float for numbers and unknown shapes\r\n return Animation.ANIMATIONTYPE_FLOAT;\r\n};\r\n"]}
@@ -60,6 +60,8 @@ export class GeospatialCameraKeyboardInput {
60
60
  if (this._onCanvasBlurObserver) {
61
61
  return;
62
62
  }
63
+ this._scene = this.camera.getScene();
64
+ this._engine = this._scene.getEngine();
63
65
  this._onCanvasBlurObserver = this._engine.onCanvasBlurObservable.add(() => {
64
66
  this._keys.length = 0;
65
67
  });
@@ -1 +1 @@
1
- {"version":3,"file":"geospatialCameraKeyboardInput.js","sourceRoot":"","sources":["../../../../../dev/core/src/Cameras/Inputs/geospatialCameraKeyboardInput.ts"],"names":[],"mappings":";AACA,OAAO,EAAE,SAAS,EAAE,MAAM,uBAAuB,CAAC;AAKlD,OAAO,EAAE,gBAAgB,EAAE,MAAM,wBAAwB,CAAC;AAE1D,OAAO,EAAE,kBAAkB,EAAE,MAAM,6BAA6B,CAAC;AACjE,OAAO,EAAE,KAAK,EAAE,MAAM,kBAAkB,CAAC;AAGzC;;;GAGG;AACH,MAAM,OAAO,6BAA6B;IAA1C;QAMI;;WAEG;QAEI,WAAM,GAAG,CAAC,EAAE,CAAC,CAAC;QAErB;;WAEG;QAEI,aAAQ,GAAG,CAAC,EAAE,CAAC,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AO,GAAG,IAAI,CAAC,cAAc,CAAC,CAAC;wBACvE,CAAC;wBACD,MAAM,CAAC,QAAQ,CAAC,QAAQ,EAAE,CAAC;oBAC/B,CAAC;gBACL,CAAC;YACL,CAAC;QACL,CAAC;IACL,CAAC;IAED;;;OAGG;IACI,YAAY;QACf,OAAO,+BAA+B,CAAC;IAC3C,CAAC;IAED;;;OAGG;IACI,aAAa;QAChB,OAAO,UAAU,CAAC;IACtB,CAAC;CACJ;AAjNU;IADN,SAAS,EAAE;6DACS;AAMd;IADN,SAAS,EAAE;+DACW;AAMhB;IADN,SAAS,EAAE;+DACW;AAMhB;IADN,SAAS,EAAE;gEACY;AAMjB;IADN,SAAS,EAAE;iEACmB;AAMxB;IADN,SAAS,EAAE;kEACoB;AAOzB;IADN,SAAS,EAAE;0EACqB;AAO1B;IADN,SAAS,EAAE;qEACwB;AAO7B;IADN,SAAS,EAAE;sEACyB;AAgKnC,gBAAiB,CAAC,+BAA+B,CAAC,GAAG,6BAA6B,CAAC","sourcesContent":["import type { Nullable } from \"../../types\";\r\nimport { serialize } from \"../../Misc/decorators\";\r\nimport type { Observer } from \"../../Misc/observable\";\r\nimport type { Scene } from \"../../scene\";\r\nimport type { GeospatialCamera } from \"../geospatialCamera\";\r\nimport type { ICameraInput } from \"../cameraInputsManager\";\r\nimport { CameraInputTypes } from \"../cameraInputsManager\";\r\nimport type { KeyboardInfo } from \"../../Events/keyboardEvents\";\r\nimport { KeyboardEventTypes } from \"../../Events/keyboardEvents\";\r\nimport { Tools } from \"../../Misc/tools\";\r\nimport type { AbstractEngine } from \"../../Engines/abstractEngine\";\r\n\r\n/**\r\n * Manage the keyboard inputs to control the movement of a geospatial camera.\r\n * @see https://doc.babylonjs.com/features/featuresDeepDive/cameras/customizingCameraInputs\r\n */\r\nexport class GeospatialCameraKeyboardInput implements ICameraInput<GeospatialCamera> {\r\n /**\r\n * Defines the camera the input is attached to.\r\n */\r\n public camera: GeospatialCamera;\r\n\r\n /**\r\n * Defines the list of key codes associated with the up action (pan up)\r\n */\r\n @serialize()\r\n public keysUp = [38];\r\n\r\n /**\r\n * Defines the list of key codes associated with the down action (pan down)\r\n */\r\n @serialize()\r\n public keysDown = [40];\r\n\r\n /**\r\n * Defines the list of key codes associated with the left action (pan left)\r\n */\r\n @serialize()\r\n public keysLeft = [37];\r\n\r\n /**\r\n * Defines the list of key codes associated with the right action (pan right)\r\n */\r\n @serialize()\r\n public keysRight = [39];\r\n\r\n /**\r\n * Defines the list of key codes associated with zoom in (+ or =)\r\n */\r\n @serialize()\r\n public keysZoomIn = [187, 107]; // 187 = + key, 107 = numpad +\r\n\r\n /**\r\n * Defines the list of key codes associated with zoom out (-)\r\n */\r\n @serialize()\r\n public keysZoomOut = [189, 109]; // 189 = - key, 109 = numpad -\r\n\r\n /**\r\n * Defines the rotation sensitivity of the inputs.\r\n * (How many pixels of pointer input to apply per keypress, before rotation speed factor is applied by movement class)\r\n */\r\n @serialize()\r\n public rotationSensitivity = 1.0;\r\n\r\n /**\r\n * Defines the panning sensitivity of the inputs.\r\n * (How many pixels of pointer input to apply per keypress, before pan speed factor is applied by movement class)\r\n */\r\n @serialize()\r\n public panSensitivity: number = 1.0;\r\n\r\n /**\r\n * Defines the zooming sensitivity of the inputs.\r\n * (How many pixels of pointer input to apply per keypress, before zoom speed factor is applied by movement class)\r\n */\r\n @serialize()\r\n public zoomSensitivity: number = 1.0;\r\n\r\n private _keys = new Array<number>();\r\n private _ctrlPressed: boolean;\r\n private _onCanvasBlurObserver: Nullable<Observer<AbstractEngine>>;\r\n private _onKeyboardObserver: Nullable<Observer<KeyboardInfo>>;\r\n private _engine: AbstractEngine;\r\n private _scene: Scene;\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 // was there a second variable defined?\r\n noPreventDefault = Tools.BackCompatCameraNoPreventDefault(arguments);\r\n\r\n if (this._onCanvasBlurObserver) {\r\n return;\r\n }\r\n\r\n this._onCanvasBlurObserver = this._engine.onCanvasBlurObservable.add(() => {\r\n this._keys.length = 0;\r\n });\r\n\r\n this._onKeyboardObserver = this._scene.onKeyboardObservable.add((info) => {\r\n const evt = info.event;\r\n if (!evt.metaKey) {\r\n if (info.type === KeyboardEventTypes.KEYDOWN) {\r\n this._ctrlPressed = evt.ctrlKey;\r\n\r\n if (\r\n this.keysUp.indexOf(evt.keyCode) !== -1 ||\r\n this.keysDown.indexOf(evt.keyCode) !== -1 ||\r\n this.keysLeft.indexOf(evt.keyCode) !== -1 ||\r\n this.keysRight.indexOf(evt.keyCode) !== -1 ||\r\n this.keysZoomIn.indexOf(evt.keyCode) !== -1 ||\r\n this.keysZoomOut.indexOf(evt.keyCode) !== -1\r\n ) {\r\n const index = this._keys.indexOf(evt.keyCode);\r\n\r\n if (index === -1) {\r\n this._keys.push(evt.keyCode);\r\n }\r\n\r\n if (evt.preventDefault) {\r\n if (!noPreventDefault) {\r\n evt.preventDefault();\r\n }\r\n }\r\n }\r\n } else {\r\n if (\r\n this.keysUp.indexOf(evt.keyCode) !== -1 ||\r\n this.keysDown.indexOf(evt.keyCode) !== -1 ||\r\n this.keysLeft.indexOf(evt.keyCode) !== -1 ||\r\n this.keysRight.indexOf(evt.keyCode) !== -1 ||\r\n this.keysZoomIn.indexOf(evt.keyCode) !== -1 ||\r\n this.keysZoomOut.indexOf(evt.keyCode) !== -1\r\n ) {\r\n const index = this._keys.indexOf(evt.keyCode);\r\n\r\n if (index >= 0) {\r\n this._keys.splice(index, 1);\r\n }\r\n\r\n if (evt.preventDefault) {\r\n if (!noPreventDefault) {\r\n evt.preventDefault();\r\n }\r\n }\r\n }\r\n }\r\n }\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._scene) {\r\n if (this._onKeyboardObserver) {\r\n this._scene.onKeyboardObservable.remove(this._onKeyboardObserver);\r\n }\r\n if (this._onCanvasBlurObserver) {\r\n this._engine.onCanvasBlurObservable.remove(this._onCanvasBlurObserver);\r\n }\r\n this._onKeyboardObserver = null;\r\n this._onCanvasBlurObserver = null;\r\n }\r\n\r\n this._keys.length = 0;\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._onKeyboardObserver) {\r\n const camera = this.camera;\r\n\r\n for (let index = 0; index < this._keys.length; index++) {\r\n const keyCode = this._keys[index];\r\n if (this._ctrlPressed) {\r\n // Rotation\r\n if (this.keysLeft.indexOf(keyCode) !== -1) {\r\n camera.movement.rotationAccumulatedPixels.y -= this.rotationSensitivity;\r\n } else if (this.keysRight.indexOf(keyCode) !== -1) {\r\n camera.movement.rotationAccumulatedPixels.y += this.rotationSensitivity;\r\n } else if (this.keysUp.indexOf(keyCode) !== -1) {\r\n camera.movement.rotationAccumulatedPixels.x -= this.rotationSensitivity;\r\n } else if (this.keysDown.indexOf(keyCode) !== -1) {\r\n camera.movement.rotationAccumulatedPixels.x += this.rotationSensitivity;\r\n }\r\n } else {\r\n // Zoom\r\n if (this.keysZoomIn.indexOf(keyCode) !== -1) {\r\n camera.movement.zoomAccumulatedPixels += this.zoomSensitivity;\r\n } else if (this.keysZoomOut.indexOf(keyCode) !== -1) {\r\n camera.movement.zoomAccumulatedPixels -= this.zoomSensitivity;\r\n } else {\r\n // Call into movement class handleDrag so that behavior matches that of pointer input, simulating drag from center of screen\r\n const centerX = this._engine.getRenderWidth() / 2;\r\n const centerY = this._engine.getRenderHeight() / 2;\r\n camera.movement.startDrag(centerX, centerY);\r\n if (this.keysLeft.indexOf(keyCode) !== -1) {\r\n camera.movement.handleDrag(centerX - this.panSensitivity, centerY);\r\n } else if (this.keysRight.indexOf(keyCode) !== -1) {\r\n camera.movement.handleDrag(centerX + this.panSensitivity, centerY);\r\n } else if (this.keysUp.indexOf(keyCode) !== -1) {\r\n camera.movement.handleDrag(centerX, centerY + this.panSensitivity);\r\n } else if (this.keysDown.indexOf(keyCode) !== -1) {\r\n camera.movement.handleDrag(centerX, centerY - this.panSensitivity);\r\n }\r\n camera.movement.stopDrag();\r\n }\r\n }\r\n }\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 \"GeospatialCameraKeyboardInput\";\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 \"keyboard\";\r\n }\r\n}\r\n\r\n(<any>CameraInputTypes)[\"GeospatialCameraKeyboardInput\"] = GeospatialCameraKeyboardInput;\r\n"]}
1
+ {"version":3,"file":"geospatialCameraKeyboardInput.js","sourceRoot":"","sources":["../../../../../dev/core/src/Cameras/Inputs/geospatialCameraKeyboardInput.ts"],"names":[],"mappings":";AACA,OAAO,EAAE,SAAS,EAAE,MAAM,uBAAuB,CAAC;AAKlD,OAAO,EAAE,gBAAgB,EAAE,MAAM,wBAAwB,CAAC;AAE1D,OAAO,EAAE,kBAAkB,EAAE,MAAM,6BAA6B,CAAC;AACjE,OAAO,EAAE,KAAK,EAAE,MAAM,kBAAkB,CAAC;AAGzC;;;GAGG;AACH,MAAM,OAAO,6BAA6B;IAA1C;QAMI;;WAEG;QAEI,WAAM,GAAG,CAAC,EAAE,CAAC,CAAC;QAErB;;WAEG;QAEI,aAAQ,GAAG,CAAC,EAAE,CAAC,CAAC;QAEvB;;WAEG;QAEI,aAAQ,GAAG,CAAC,EAAE,CAAC,CAAC;QAEvB;;WAEG;QAEI,cAAS,GAAG,CAAC,EAAE,CAAC,CAAC;QAExB;;WAEG;QAEI,eAAU,GAAG,CAAC,GAAG,EAAE,GAAG,CAAC,CAAC,CAAC,8BAA8B;QAE9D;;WAEG;QAEI,gBAAW,GAAG,CAAC,GAAG,E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C;oBAC/B,CAAC;gBACL,CAAC;YACL,CAAC;QACL,CAAC;IACL,CAAC;IAED;;;OAGG;IACI,YAAY;QACf,OAAO,+BAA+B,CAAC;IAC3C,CAAC;IAED;;;OAGG;IACI,aAAa;QAChB,OAAO,UAAU,CAAC;IACtB,CAAC;CACJ;AApNU;IADN,SAAS,EAAE;6DACS;AAMd;IADN,SAAS,EAAE;+DACW;AAMhB;IADN,SAAS,EAAE;+DACW;AAMhB;IADN,SAAS,EAAE;gEACY;AAMjB;IADN,SAAS,EAAE;iEACmB;AAMxB;IADN,SAAS,EAAE;kEACoB;AAOzB;IADN,SAAS,EAAE;0EACqB;AAO1B;IADN,SAAS,EAAE;qEACwB;AAO7B;IADN,SAAS,EAAE;sEACyB;AAmKnC,gBAAiB,CAAC,+BAA+B,CAAC,GAAG,6BAA6B,CAAC","sourcesContent":["import type { Nullable } from \"../../types\";\r\nimport { serialize } from \"../../Misc/decorators\";\r\nimport type { Observer } from \"../../Misc/observable\";\r\nimport type { Scene } from \"../../scene\";\r\nimport type { GeospatialCamera } from \"../geospatialCamera\";\r\nimport type { ICameraInput } from \"../cameraInputsManager\";\r\nimport { CameraInputTypes } from \"../cameraInputsManager\";\r\nimport type { KeyboardInfo } from \"../../Events/keyboardEvents\";\r\nimport { KeyboardEventTypes } from \"../../Events/keyboardEvents\";\r\nimport { Tools } from \"../../Misc/tools\";\r\nimport type { AbstractEngine } from \"../../Engines/abstractEngine\";\r\n\r\n/**\r\n * Manage the keyboard inputs to control the movement of a geospatial camera.\r\n * @see https://doc.babylonjs.com/features/featuresDeepDive/cameras/customizingCameraInputs\r\n */\r\nexport class GeospatialCameraKeyboardInput implements ICameraInput<GeospatialCamera> {\r\n /**\r\n * Defines the camera the input is attached to.\r\n */\r\n public camera: GeospatialCamera;\r\n\r\n /**\r\n * Defines the list of key codes associated with the up action (pan up)\r\n */\r\n @serialize()\r\n public keysUp = [38];\r\n\r\n /**\r\n * Defines the list of key codes associated with the down action (pan down)\r\n */\r\n @serialize()\r\n public keysDown = [40];\r\n\r\n /**\r\n * Defines the list of key codes associated with the left action (pan left)\r\n */\r\n @serialize()\r\n public keysLeft = [37];\r\n\r\n /**\r\n * Defines the list of key codes associated with the right action (pan right)\r\n */\r\n @serialize()\r\n public keysRight = [39];\r\n\r\n /**\r\n * Defines the list of key codes associated with zoom in (+ or =)\r\n */\r\n @serialize()\r\n public keysZoomIn = [187, 107]; // 187 = + key, 107 = numpad +\r\n\r\n /**\r\n * Defines the list of key codes associated with zoom out (-)\r\n */\r\n @serialize()\r\n public keysZoomOut = [189, 109]; // 189 = - key, 109 = numpad -\r\n\r\n /**\r\n * Defines the rotation sensitivity of the inputs.\r\n * (How many pixels of pointer input to apply per keypress, before rotation speed factor is applied by movement class)\r\n */\r\n @serialize()\r\n public rotationSensitivity = 1.0;\r\n\r\n /**\r\n * Defines the panning sensitivity of the inputs.\r\n * (How many pixels of pointer input to apply per keypress, before pan speed factor is applied by movement class)\r\n */\r\n @serialize()\r\n public panSensitivity: number = 1.0;\r\n\r\n /**\r\n * Defines the zooming sensitivity of the inputs.\r\n * (How many pixels of pointer input to apply per keypress, before zoom speed factor is applied by movement class)\r\n */\r\n @serialize()\r\n public zoomSensitivity: number = 1.0;\r\n\r\n private _keys = new Array<number>();\r\n private _ctrlPressed: boolean;\r\n private _onCanvasBlurObserver: Nullable<Observer<AbstractEngine>>;\r\n private _onKeyboardObserver: Nullable<Observer<KeyboardInfo>>;\r\n private _engine: AbstractEngine;\r\n private _scene: Scene;\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 // was there a second variable defined?\r\n noPreventDefault = Tools.BackCompatCameraNoPreventDefault(arguments);\r\n\r\n if (this._onCanvasBlurObserver) {\r\n return;\r\n }\r\n\r\n this._scene = this.camera.getScene();\r\n this._engine = this._scene.getEngine();\r\n\r\n this._onCanvasBlurObserver = this._engine.onCanvasBlurObservable.add(() => {\r\n this._keys.length = 0;\r\n });\r\n\r\n this._onKeyboardObserver = this._scene.onKeyboardObservable.add((info) => {\r\n const evt = info.event;\r\n if (!evt.metaKey) {\r\n if (info.type === KeyboardEventTypes.KEYDOWN) {\r\n this._ctrlPressed = evt.ctrlKey;\r\n\r\n if (\r\n this.keysUp.indexOf(evt.keyCode) !== -1 ||\r\n this.keysDown.indexOf(evt.keyCode) !== -1 ||\r\n this.keysLeft.indexOf(evt.keyCode) !== -1 ||\r\n this.keysRight.indexOf(evt.keyCode) !== -1 ||\r\n this.keysZoomIn.indexOf(evt.keyCode) !== -1 ||\r\n this.keysZoomOut.indexOf(evt.keyCode) !== -1\r\n ) {\r\n const index = this._keys.indexOf(evt.keyCode);\r\n\r\n if (index === -1) {\r\n this._keys.push(evt.keyCode);\r\n }\r\n\r\n if (evt.preventDefault) {\r\n if (!noPreventDefault) {\r\n evt.preventDefault();\r\n }\r\n }\r\n }\r\n } else {\r\n if (\r\n this.keysUp.indexOf(evt.keyCode) !== -1 ||\r\n this.keysDown.indexOf(evt.keyCode) !== -1 ||\r\n this.keysLeft.indexOf(evt.keyCode) !== -1 ||\r\n this.keysRight.indexOf(evt.keyCode) !== -1 ||\r\n this.keysZoomIn.indexOf(evt.keyCode) !== -1 ||\r\n this.keysZoomOut.indexOf(evt.keyCode) !== -1\r\n ) {\r\n const index = this._keys.indexOf(evt.keyCode);\r\n\r\n if (index >= 0) {\r\n this._keys.splice(index, 1);\r\n }\r\n\r\n if (evt.preventDefault) {\r\n if (!noPreventDefault) {\r\n evt.preventDefault();\r\n }\r\n }\r\n }\r\n }\r\n }\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._scene) {\r\n if (this._onKeyboardObserver) {\r\n this._scene.onKeyboardObservable.remove(this._onKeyboardObserver);\r\n }\r\n if (this._onCanvasBlurObserver) {\r\n this._engine.onCanvasBlurObservable.remove(this._onCanvasBlurObserver);\r\n }\r\n this._onKeyboardObserver = null;\r\n this._onCanvasBlurObserver = null;\r\n }\r\n\r\n this._keys.length = 0;\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._onKeyboardObserver) {\r\n const camera = this.camera;\r\n\r\n for (let index = 0; index < this._keys.length; index++) {\r\n const keyCode = this._keys[index];\r\n if (this._ctrlPressed) {\r\n // Rotation\r\n if (this.keysLeft.indexOf(keyCode) !== -1) {\r\n camera.movement.rotationAccumulatedPixels.y -= this.rotationSensitivity;\r\n } else if (this.keysRight.indexOf(keyCode) !== -1) {\r\n camera.movement.rotationAccumulatedPixels.y += this.rotationSensitivity;\r\n } else if (this.keysUp.indexOf(keyCode) !== -1) {\r\n camera.movement.rotationAccumulatedPixels.x -= this.rotationSensitivity;\r\n } else if (this.keysDown.indexOf(keyCode) !== -1) {\r\n camera.movement.rotationAccumulatedPixels.x += this.rotationSensitivity;\r\n }\r\n } else {\r\n // Zoom\r\n if (this.keysZoomIn.indexOf(keyCode) !== -1) {\r\n camera.movement.zoomAccumulatedPixels += this.zoomSensitivity;\r\n } else if (this.keysZoomOut.indexOf(keyCode) !== -1) {\r\n camera.movement.zoomAccumulatedPixels -= this.zoomSensitivity;\r\n } else {\r\n // Call into movement class handleDrag so that behavior matches that of pointer input, simulating drag from center of screen\r\n const centerX = this._engine.getRenderWidth() / 2;\r\n const centerY = this._engine.getRenderHeight() / 2;\r\n camera.movement.startDrag(centerX, centerY);\r\n if (this.keysLeft.indexOf(keyCode) !== -1) {\r\n camera.movement.handleDrag(centerX - this.panSensitivity, centerY);\r\n } else if (this.keysRight.indexOf(keyCode) !== -1) {\r\n camera.movement.handleDrag(centerX + this.panSensitivity, centerY);\r\n } else if (this.keysUp.indexOf(keyCode) !== -1) {\r\n camera.movement.handleDrag(centerX, centerY + this.panSensitivity);\r\n } else if (this.keysDown.indexOf(keyCode) !== -1) {\r\n camera.movement.handleDrag(centerX, centerY - this.panSensitivity);\r\n }\r\n camera.movement.stopDrag();\r\n }\r\n }\r\n }\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 \"GeospatialCameraKeyboardInput\";\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 \"keyboard\";\r\n }\r\n}\r\n\r\n(<any>CameraInputTypes)[\"GeospatialCameraKeyboardInput\"] = GeospatialCameraKeyboardInput;\r\n"]}
@@ -71,11 +71,9 @@ export class GeospatialCameraPointersInput extends OrbitCameraPointersInput {
71
71
  }
72
72
  }
73
73
  onDoubleTap(type) {
74
- const scene = this.camera.getScene();
75
- const pickResult = scene.pick(scene.pointerX, scene.pointerY, this.camera.pickPredicate);
76
- if (pickResult.hit && pickResult.pickedPoint) {
77
- const newRadius = this.camera.radius * 0.5; // Zoom to 50% of current distance
78
- void this.camera.flyToAsync(undefined, undefined, newRadius, pickResult.pickedPoint);
74
+ const pickResult = this.camera._scene.pick(this.camera._scene.pointerX, this.camera._scene.pointerY, this.camera.pickPredicate);
75
+ if (pickResult.pickedPoint) {
76
+ void this.camera.flyToPointAsync(pickResult.pickedPoint);
79
77
  }
80
78
  }
81
79
  onMultiTouch(pointA, pointB, previousPinchSquaredDistance, pinchSquaredDistance, previousMultiTouchPanPosition, multiTouchPanPosition) {
@@ -1 +1 @@
1
- {"version":3,"file":"geospatialCameraPointersInput.js","sourceRoot":"","sources":["../../../../../dev/core/src/Cameras/Inputs/geospatialCameraPointersInput.ts"],"names":[],"mappings":"AAKA,OAAO,EAAE,wBAAwB,EAAE,MAAM,4BAA4B,CAAC;AAEtE;;;;;;;;;;;;GAYG;AACH,MAAM,OAAO,6BAA8B,SAAQ,wBAAwB;IAG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fo\";\r\nimport type { IPointerEvent } from \"../../Events/deviceInputEvents\";\r\nimport type { PointerTouch } from \"../../Events/pointerEvents\";\r\nimport type { Nullable } from \"../../types\";\r\nimport { OrbitCameraPointersInput } from \"./orbitCameraPointersInput\";\r\n\r\n/**\r\n * @experimental\r\n * Geospatial camera inputs can simulate dragging the globe around or tilting the camera around some point on the globe\r\n * This class will update the GeospatialCameraMovement class's movementDeltaCurrentFrame, and the camera is responsible for using these updates to calculate viewMatrix appropriately\r\n *\r\n * As of right now, the camera correction logic (to keep the camera geospatially oriented around the globe) is happening within the camera class when calculating viewmatrix\r\n * As this is experimental, it is possible we move that correction step to live within the input class (to enable non-corrected translations in the future), say if we want to allow the camera to move outside of the globe's orbit\r\n *\r\n * Left mouse button: drag globe\r\n * Middle mouse button: tilt globe around cursor location\r\n * Right mouse button: tilt globe around center of screen\r\n *\r\n */\r\nexport class GeospatialCameraPointersInput extends OrbitCameraPointersInput {\r\n public camera: GeospatialCamera;\r\n\r\n public override getClassName(): string {\r\n return \"GeospatialCameraPointersInput\";\r\n }\r\n\r\n public override onButtonDown(evt: IPointerEvent): void {\r\n this.camera.movement.activeInput = true;\r\n const scene = this.camera.getScene();\r\n let pickResult: Nullable<PickingInfo>;\r\n switch (evt.button) {\r\n case 0: // Left button - drag/pan globe under cursor\r\n this.camera.movement.startDrag(scene.pointerX, scene.pointerY);\r\n break;\r\n case 1: // Middle button - tilt camera around cursor\r\n pickResult = scene.pick(scene.pointerX, scene.pointerY, this.camera.pickPredicate);\r\n pickResult.pickedPoint && (this.camera.movement.alternateRotationPt = pickResult.pickedPoint);\r\n break;\r\n case 2: // Right button - tilt camera around center of screen, already the default\r\n this.camera.movement.alternateRotationPt = this.camera.center;\r\n break;\r\n default:\r\n return;\r\n }\r\n }\r\n\r\n public override onTouch(point: Nullable<PointerTouch>, offsetX: number, offsetY: number): void {\r\n // Single finger touch (no button property) or left button (button 0) = drag\r\n const button = point?.button ?? 0; // Default to button 0 (drag) if undefined\r\n const scene = this.camera.getScene();\r\n switch (button) {\r\n case 0: // Left button / single touch - drag/pan globe under cursor\r\n this.camera.movement.handleDrag(scene.pointerX, scene.pointerY);\r\n break;\r\n case 1: // Middle button - tilt camera\r\n case 2: // Right button - tilt camera\r\n this._handleTilt(offsetX, offsetY);\r\n break;\r\n }\r\n }\r\n\r\n /**\r\n * Move camera from multitouch (pinch) zoom distances.\r\n * @param previousPinchSquaredDistance\r\n * @param pinchSquaredDistance\r\n */\r\n protected override _computePinchZoom(previousPinchSquaredDistance: number, pinchSquaredDistance: number): void {\r\n this.camera.radius = (this.camera.radius * Math.sqrt(previousPinchSquaredDistance)) / Math.sqrt(pinchSquaredDistance);\r\n }\r\n\r\n /**\r\n * Move camera from multi touch panning positions.\r\n * In geospatialcamera, multi touch panning tilts the globe (whereas single touch will pan/drag it)\r\n * @param previousMultiTouchPanPosition\r\n * @param multiTouchPanPosition\r\n */\r\n protected override _computeMultiTouchPanning(previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void {\r\n if (previousMultiTouchPanPosition && multiTouchPanPosition) {\r\n const moveDeltaX = multiTouchPanPosition.x - previousMultiTouchPanPosition.x;\r\n const moveDeltaY = multiTouchPanPosition.y - previousMultiTouchPanPosition.y;\r\n this._handleTilt(moveDeltaX, moveDeltaY);\r\n }\r\n }\r\n\r\n public override onDoubleTap(type: string): void {\r\n const scene = this.camera.getScene();\r\n const pickResult = scene.pick(scene.pointerX, scene.pointerY, this.camera.pickPredicate);\r\n\r\n if (pickResult.hit && pickResult.pickedPoint) {\r\n const newRadius = this.camera.radius * 0.5; // Zoom to 50% of current distance\r\n void this.camera.flyToAsync(undefined, undefined, newRadius, pickResult.pickedPoint);\r\n }\r\n }\r\n\r\n public override onMultiTouch(\r\n pointA: Nullable<PointerTouch>,\r\n pointB: Nullable<PointerTouch>,\r\n previousPinchSquaredDistance: number,\r\n pinchSquaredDistance: number,\r\n previousMultiTouchPanPosition: Nullable<PointerTouch>,\r\n multiTouchPanPosition: Nullable<PointerTouch>\r\n ): void {\r\n this._shouldStartPinchZoom =\r\n this._twoFingerActivityCount < 20 && Math.abs(Math.sqrt(pinchSquaredDistance) - Math.sqrt(previousPinchSquaredDistance)) > this.camera.limits.pinchToPanMax;\r\n super.onMultiTouch(pointA, pointB, previousPinchSquaredDistance, pinchSquaredDistance, previousMultiTouchPanPosition, multiTouchPanPosition);\r\n }\r\n\r\n public override onButtonUp(_evt: IPointerEvent): void {\r\n this.camera.movement.stopDrag();\r\n this.camera.movement.alternateRotationPt = undefined;\r\n this.camera.movement.activeInput = false;\r\n super.onButtonUp(_evt);\r\n }\r\n\r\n private _handleTilt(deltaX: number, deltaY: number): void {\r\n this.camera.movement.rotationAccumulatedPixels.y -= deltaX; // yaw - looking side to side\r\n this.camera.movement.rotationAccumulatedPixels.x -= deltaY; // pitch - look up towards sky / down towards ground\r\n }\r\n}\r\n"]}
1
+ {"version":3,"file":"geospatialCameraPointersInput.js","sourceRoot":"","sources":["../../../../../dev/core/src/Cameras/Inputs/geospatialCameraPointersInput.ts"],"names":[],"mappings":"AAKA,OAAO,EAAE,wBAAwB,EAAE,MAAM,4BAA4B,CAAC;AAEtE;;;;;;;;;;;;GAYG;AACH,MAAM,OAAO,6BAA8B,SAAQ,wBAAwB;IAGvD,YAAY;QACxB,OAAO,+BAA+B,CAAC;IAC3C,CAAC;IAEe,YAAY,CAAC,GAAkB;QAC3C,IAAI,CAAC,MAAM,CAAC,QAAQ,CAAC,WAAW,GAAG,IAAI,CAAC;QACxC,MAAM,KAAK,GAAG,IAAI,CAAC,MAAM,CAAC,QAAQ,EAAE,CAAC;QACrC,IAAI,UAAiC,CAAC;QACtC,QAAQ,GAAG,CAAC,MAAM,EAAE,CAAC;YACjB,KAAK,CAAC,EAAE,4CAA4C;gBAChD,IAAI,CAAC,MAAM,CAAC,QAAQ,CAAC,SAAS,CAAC,KAAK,CAAC,QAAQ,EAAE,KAAK,CAAC,QAAQ,CAAC,CAAC;g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A6B,EAAE,qBAAqB,CAAC,CAAC;IACjJ,CAAC;IAEe,UAAU,CAAC,IAAmB;QAC1C,IAAI,CAAC,MAAM,CAAC,QAAQ,CAAC,QAAQ,EAAE,CAAC;QAChC,IAAI,CAAC,MAAM,CAAC,QAAQ,CAAC,mBAAmB,GAAG,SAAS,CAAC;QACrD,IAAI,CAAC,MAAM,CAAC,QAAQ,CAAC,WAAW,GAAG,KAAK,CAAC;QACzC,KAAK,CAAC,UAAU,CAAC,IAAI,CAAC,CAAC;IAC3B,CAAC;IAEO,WAAW,CAAC,MAAc,EAAE,MAAc;QAC9C,IAAI,CAAC,MAAM,CAAC,QAAQ,CAAC,yBAAyB,CAAC,CAAC,IAAI,MAAM,CAAC,CAAC,6BAA6B;QACzF,IAAI,CAAC,MAAM,CAAC,QAAQ,CAAC,yBAAyB,CAAC,CAAC,IAAI,MAAM,CAAC,CAAC,oDAAoD;IACpH,CAAC;CACJ","sourcesContent":["import type { GeospatialCamera } from \"../../Cameras/geospatialCamera\";\r\nimport type { PickingInfo } from \"../../Collisions/pickingInfo\";\r\nimport type { IPointerEvent } from \"../../Events/deviceInputEvents\";\r\nimport type { PointerTouch } from \"../../Events/pointerEvents\";\r\nimport type { Nullable } from \"../../types\";\r\nimport { OrbitCameraPointersInput } from \"./orbitCameraPointersInput\";\r\n\r\n/**\r\n * @experimental\r\n * Geospatial camera inputs can simulate dragging the globe around or tilting the camera around some point on the globe\r\n * This class will update the GeospatialCameraMovement class's movementDeltaCurrentFrame, and the camera is responsible for using these updates to calculate viewMatrix appropriately\r\n *\r\n * As of right now, the camera correction logic (to keep the camera geospatially oriented around the globe) is happening within the camera class when calculating viewmatrix\r\n * As this is experimental, it is possible we move that correction step to live within the input class (to enable non-corrected translations in the future), say if we want to allow the camera to move outside of the globe's orbit\r\n *\r\n * Left mouse button: drag globe\r\n * Middle mouse button: tilt globe around cursor location\r\n * Right mouse button: tilt globe around center of screen\r\n *\r\n */\r\nexport class GeospatialCameraPointersInput extends OrbitCameraPointersInput {\r\n public camera: GeospatialCamera;\r\n\r\n public override getClassName(): string {\r\n return \"GeospatialCameraPointersInput\";\r\n }\r\n\r\n public override onButtonDown(evt: IPointerEvent): void {\r\n this.camera.movement.activeInput = true;\r\n const scene = this.camera.getScene();\r\n let pickResult: Nullable<PickingInfo>;\r\n switch (evt.button) {\r\n case 0: // Left button - drag/pan globe under cursor\r\n this.camera.movement.startDrag(scene.pointerX, scene.pointerY);\r\n break;\r\n case 1: // Middle button - tilt camera around cursor\r\n pickResult = scene.pick(scene.pointerX, scene.pointerY, this.camera.pickPredicate);\r\n pickResult.pickedPoint && (this.camera.movement.alternateRotationPt = pickResult.pickedPoint);\r\n break;\r\n case 2: // Right button - tilt camera around center of screen, already the default\r\n this.camera.movement.alternateRotationPt = this.camera.center;\r\n break;\r\n default:\r\n return;\r\n }\r\n }\r\n\r\n public override onTouch(point: Nullable<PointerTouch>, offsetX: number, offsetY: number): void {\r\n // Single finger touch (no button property) or left button (button 0) = drag\r\n const button = point?.button ?? 0; // Default to button 0 (drag) if undefined\r\n const scene = this.camera.getScene();\r\n switch (button) {\r\n case 0: // Left button / single touch - drag/pan globe under cursor\r\n this.camera.movement.handleDrag(scene.pointerX, scene.pointerY);\r\n break;\r\n case 1: // Middle button - tilt camera\r\n case 2: // Right button - tilt camera\r\n this._handleTilt(offsetX, offsetY);\r\n break;\r\n }\r\n }\r\n\r\n /**\r\n * Move camera from multitouch (pinch) zoom distances.\r\n * @param previousPinchSquaredDistance\r\n * @param pinchSquaredDistance\r\n */\r\n protected override _computePinchZoom(previousPinchSquaredDistance: number, pinchSquaredDistance: number): void {\r\n this.camera.radius = (this.camera.radius * Math.sqrt(previousPinchSquaredDistance)) / Math.sqrt(pinchSquaredDistance);\r\n }\r\n\r\n /**\r\n * Move camera from multi touch panning positions.\r\n * In geospatialcamera, multi touch panning tilts the globe (whereas single touch will pan/drag it)\r\n * @param previousMultiTouchPanPosition\r\n * @param multiTouchPanPosition\r\n */\r\n protected override _computeMultiTouchPanning(previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void {\r\n if (previousMultiTouchPanPosition && multiTouchPanPosition) {\r\n const moveDeltaX = multiTouchPanPosition.x - previousMultiTouchPanPosition.x;\r\n const moveDeltaY = multiTouchPanPosition.y - previousMultiTouchPanPosition.y;\r\n this._handleTilt(moveDeltaX, moveDeltaY);\r\n }\r\n }\r\n\r\n public override onDoubleTap(type: string): void {\r\n const pickResult = this.camera._scene.pick(this.camera._scene.pointerX, this.camera._scene.pointerY, this.camera.pickPredicate);\r\n if (pickResult.pickedPoint) {\r\n void this.camera.flyToPointAsync(pickResult.pickedPoint);\r\n }\r\n }\r\n\r\n public override onMultiTouch(\r\n pointA: Nullable<PointerTouch>,\r\n pointB: Nullable<PointerTouch>,\r\n previousPinchSquaredDistance: number,\r\n pinchSquaredDistance: number,\r\n previousMultiTouchPanPosition: Nullable<PointerTouch>,\r\n multiTouchPanPosition: Nullable<PointerTouch>\r\n ): void {\r\n this._shouldStartPinchZoom =\r\n this._twoFingerActivityCount < 20 && Math.abs(Math.sqrt(pinchSquaredDistance) - Math.sqrt(previousPinchSquaredDistance)) > this.camera.limits.pinchToPanMax;\r\n super.onMultiTouch(pointA, pointB, previousPinchSquaredDistance, pinchSquaredDistance, previousMultiTouchPanPosition, multiTouchPanPosition);\r\n }\r\n\r\n public override onButtonUp(_evt: IPointerEvent): void {\r\n this.camera.movement.stopDrag();\r\n this.camera.movement.alternateRotationPt = undefined;\r\n this.camera.movement.activeInput = false;\r\n super.onButtonUp(_evt);\r\n }\r\n\r\n private _handleTilt(deltaX: number, deltaY: number): void {\r\n this.camera.movement.rotationAccumulatedPixels.y -= deltaX; // yaw - looking side to side\r\n this.camera.movement.rotationAccumulatedPixels.x -= deltaY; // pitch - look up towards sky / down towards ground\r\n }\r\n}\r\n"]}
@@ -23,6 +23,7 @@ export declare class GeospatialCamera extends Camera {
23
23
  /** Movement controller that turns input pixelDeltas into currentFrameDeltas used by camera*/
24
24
  readonly movement: GeospatialCameraMovement;
25
25
  private _tempPosition;
26
+ private _tempCenter;
26
27
  private _viewMatrix;
27
28
  private _isViewMatrixDirty;
28
29
  private _lookAtVector;
@@ -87,6 +88,7 @@ export declare class GeospatialCamera extends Camera {
87
88
  * @param targetCenter
88
89
  */
89
90
  updateFlyToDestination(targetYaw?: number, targetPitch?: number, targetRadius?: number, targetCenter?: Vector3): void;
91
+ private _customKeys;
90
92
  /**
91
93
  * Animate camera towards passed in property values. If undefined, will use current value
92
94
  * @param targetYaw
@@ -95,9 +97,19 @@ export declare class GeospatialCamera extends Camera {
95
97
  * @param targetCenter
96
98
  * @param flightDurationMs
97
99
  * @param easingFunction
100
+ * @param overshootRadiusScale If defined, will first fly to radius*scale before flying to targetRadius to create a "bounce" effect
98
101
  * @returns Promise that will return when the animation is complete (or interuppted by pointer input)
99
102
  */
100
- flyToAsync(targetYaw?: number, targetPitch?: number, targetRadius?: number, targetCenter?: Vector3, flightDurationMs?: number, easingFunction?: EasingFunction): Promise<void>;
103
+ flyToAsync(targetYaw?: number, targetPitch?: number, targetRadius?: number, targetCenter?: Vector3, flightDurationMs?: number, easingFunction?: EasingFunction, overshootRadiusScale?: number): Promise<void>;
104
+ /**
105
+ * Helper function to move camera towards a given point by radiusScale% of radius (by default 50%)
106
+ * @param destination point to move towards
107
+ * @param radiusScale value between 0 and 1, % of radius to move
108
+ * @param durationMs duration of flight, default 1s
109
+ * @param easingFn optional easing function for flight interpolation of properties
110
+ * @param overshootRadiusScale optional scale to apply to the current radius to achieve a 'hop' animation
111
+ */
112
+ flyToPointAsync(destination: Vector3, radiusScale?: number, durationMs?: number, easingFn?: EasingFunction, overshootRadiusScale?: number): Promise<void>;
101
113
  private _limits;
102
114
  get limits(): GeospatialLimits;
103
115
  private _resetToDefault;
@@ -110,8 +122,15 @@ export declare class GeospatialCamera extends Camera {
110
122
  * This rotation keeps the camera oriented towards the globe as it orbits around it. This is different from cameraCentricRotation which is when the camera rotates around its own axis
111
123
  */
112
124
  private _applyGeocentricRotation;
125
+ private _getCenterAndRadiusFromZoomToPoint;
126
+ /**
127
+ * Apply zoom by moving the camera toward/away from a target point.
128
+ */
113
129
  private _applyZoom;
130
+ private _zoomToPoint;
131
+ private _zoomAlongLookAt;
114
132
  _checkInputs(): void;
133
+ private _recalculateCenter;
115
134
  attachControl(noPreventDefault?: boolean): void;
116
135
  detachControl(): void;
117
136
  }
@@ -3,8 +3,8 @@ import { Vector3, Matrix, TmpVectors } from "../Maths/math.vector.js";
3
3
  import { Epsilon } from "../Maths/math.constants.js";
4
4
  import { Camera } from "./camera.js";
5
5
  import { GeospatialLimits } from "./Limits/geospatialLimits.js";
6
- import { ComputeLocalBasisToRefs, GeospatialCameraMovement } from "./geospatialCameraMovement.js";
7
- import { Vector3CopyToRef, Vector3Dot } from "../Maths/math.vector.functions.js";
6
+ import { ClampCenterFromPolesInPlace, ComputeLocalBasisToRefs, GeospatialCameraMovement } from "./geospatialCameraMovement.js";
7
+ import { Vector3CopyToRef } from "../Maths/math.vector.functions.js";
8
8
  import { Clamp } from "../Maths/math.scalar.functions.js";
9
9
  import { InterpolatingBehavior } from "../Behaviors/Cameras/interpolatingBehavior.js";
10
10
  /**
@@ -18,6 +18,7 @@ export class GeospatialCamera extends Camera {
18
18
  super(name, new Vector3(), scene);
19
19
  // Temp vars
20
20
  this._tempPosition = new Vector3();
21
+ this._tempCenter = new Vector3();
21
22
  this._viewMatrix = new Matrix();
22
23
  this._lookAtVector = new Vector3();
23
24
  this._flyToTargets = new Map();
@@ -29,11 +30,12 @@ export class GeospatialCamera extends Camera {
29
30
  this._tempEast = new Vector3();
30
31
  this._tempNorth = new Vector3();
31
32
  this._tempUp = new Vector3();
33
+ this._customKeys = new Map();
32
34
  this._limits = new GeospatialLimits(options.planetRadius);
33
35
  this._resetToDefault(this._limits);
34
36
  this._flyingBehavior = new InterpolatingBehavior();
35
37
  this.addBehavior(this._flyingBehavior);
36
- this.movement = new GeospatialCameraMovement(scene, this._limits, this.position, this.center, this._lookAtVector, pickPredicate);
38
+ this.movement = new GeospatialCameraMovement(scene, this._limits, this.position, this.center, this._lookAtVector, pickPredicate, this._flyingBehavior);
37
39
  this.pickPredicate = pickPredicate;
38
40
  this.inputs = new GeospatialCameraInputsManager(this);
39
41
  this.inputs.addMouse().addMouseWheel().addKeyboard();
@@ -95,6 +97,7 @@ export class GeospatialCamera extends Camera {
95
97
  this._yaw = Clamp(this._yaw, limits.yawMin, limits.yawMax);
96
98
  this._pitch = Clamp(this._pitch, limits.pitchMin, limits.pitchMax);
97
99
  this._radius = Clamp(this._radius, limits.radiusMin, limits.radiusMax);
100
+ this._center = ClampCenterFromPolesInPlace(this._center);
98
101
  }
99
102
  _setOrientation(yaw, pitch, radius, center) {
100
103
  this._yaw = yaw;
@@ -160,15 +163,43 @@ export class GeospatialCamera extends Camera {
160
163
  * @param targetCenter
161
164
  * @param flightDurationMs
162
165
  * @param easingFunction
166
+ * @param overshootRadiusScale If defined, will first fly to radius*scale before flying to targetRadius to create a "bounce" effect
163
167
  * @returns Promise that will return when the animation is complete (or interuppted by pointer input)
164
168
  */
165
- async flyToAsync(targetYaw, targetPitch, targetRadius, targetCenter, flightDurationMs = 1000, easingFunction) {
169
+ async flyToAsync(targetYaw, targetPitch, targetRadius, targetCenter, flightDurationMs = 1000, easingFunction, overshootRadiusScale) {
166
170
  this._flyToTargets.clear();
171
+ this._customKeys.clear();
167
172
  this._flyToTargets.set("yaw", targetYaw);
168
173
  this._flyToTargets.set("pitch", targetPitch);
169
174
  this._flyToTargets.set("radius", targetRadius);
170
175
  this._flyToTargets.set("center", targetCenter);
171
- return await this._flyingBehavior.animatePropertiesAsync(this._flyToTargets, flightDurationMs, easingFunction);
176
+ const overshootRadius = overshootRadiusScale !== undefined ? this.radius * overshootRadiusScale : undefined;
177
+ if (overshootRadius !== undefined && overshootRadius !== targetRadius) {
178
+ // Start the animation with overshoot radius
179
+ const frameRate = 60;
180
+ const totalFrames = (flightDurationMs / 1000) * frameRate;
181
+ const midFrame = totalFrames / 2;
182
+ this._customKeys.set("radius", [
183
+ { frame: 0, value: this.radius },
184
+ { frame: midFrame, value: overshootRadius },
185
+ { frame: totalFrames, value: targetRadius },
186
+ ]);
187
+ }
188
+ return await this._flyingBehavior.animatePropertiesAsync(this._flyToTargets, flightDurationMs, easingFunction, this._customKeys);
189
+ }
190
+ /**
191
+ * Helper function to move camera towards a given point by radiusScale% of radius (by default 50%)
192
+ * @param destination point to move towards
193
+ * @param radiusScale value between 0 and 1, % of radius to move
194
+ * @param durationMs duration of flight, default 1s
195
+ * @param easingFn optional easing function for flight interpolation of properties
196
+ * @param overshootRadiusScale optional scale to apply to the current radius to achieve a 'hop' animation
197
+ */
198
+ async flyToPointAsync(destination, radiusScale = 0.5, durationMs = 1000, easingFn, overshootRadiusScale) {
199
+ // Zoom to radiusScale% of radius towards the given destination point
200
+ const zoomDistance = this.radius * radiusScale;
201
+ const newRadius = this._getCenterAndRadiusFromZoomToPoint(destination, zoomDistance, this._tempCenter);
202
+ await this.flyToAsync(undefined, undefined, newRadius, this._tempCenter, durationMs, easingFn, overshootRadiusScale);
172
203
  }
173
204
  get limits() {
174
205
  return this._limits;
@@ -236,47 +267,93 @@ export class GeospatialCamera extends Camera {
236
267
  this._setOrientation(yaw, pitch, this._radius, this._geocentricRotationPt);
237
268
  }
238
269
  }
239
- _applyZoom(zoomVector, distance) {
240
- // TODO this function will be re-worked shortly after checkin, becuase today it breaks down if you zoom to a point past the center
241
- // (ex: tilted view zooming towards cursor near horizon where the center is closer than the cursor point).
242
- // Project zoom vector onto lookAt vector to find the amount the camera-to-center distance should change.
243
- // - zoom vector is normalized
244
- // - distance is how much to move in this call
245
- const directionDotLookAt = Vector3Dot(zoomVector, this._lookAtVector);
246
- const hasRadialComponent = Math.abs(directionDotLookAt) > Epsilon;
247
- const requestedRadius = hasRadialComponent ? this._radius - distance * directionDotLookAt : this._radius;
270
+ _getCenterAndRadiusFromZoomToPoint(targetPoint, distance, newCenter) {
271
+ // Clamp new radius to limits
272
+ const requestedRadius = this._radius - distance;
248
273
  const newRadius = Clamp(requestedRadius, this.limits.radiusMin, this.limits.radiusMax);
249
- const actualRadiusChange = newRadius - this._radius;
250
- const actualDistanceChange = hasRadialComponent ? actualRadiusChange / directionDotLookAt : 0;
251
- // Use this to compute new camera position and new center position.
252
- const newCameraPosition = this._position.add(zoomVector.scale(-actualDistanceChange));
253
- const newCenter = newCameraPosition.add(this._lookAtVector.scaleToRef(newRadius, TmpVectors.Vector3[3]));
254
- // Rescale new center to maintain same altitude as the old center.
274
+ const actualDistance = this._radius - newRadius;
275
+ const actualRatio = actualDistance / this._radius;
276
+ // Direction from current center to target point
277
+ const directionToTarget = TmpVectors.Vector3[0];
278
+ targetPoint.subtractToRef(this._center, directionToTarget);
279
+ // Move center toward target by the ratio amount
280
+ const centerOffset = TmpVectors.Vector3[1];
281
+ directionToTarget.scaleToRef(actualRatio, centerOffset);
282
+ // Calculate new center
283
+ this._center.addToRef(centerOffset, newCenter);
284
+ // Preserve center altitude (distance from planet origin)
255
285
  const currentCenterRadius = this._center.length();
256
286
  const newCenterRadius = newCenter.length();
257
- const newCenterRescale = currentCenterRadius / newCenterRadius;
258
- newCenter.scaleInPlace(newCenterRescale);
259
- // Apply changes
260
- this._setOrientation(this._yaw, this._pitch, newRadius, newCenter);
287
+ if (newCenterRadius > Epsilon) {
288
+ newCenter.scaleInPlace(currentCenterRadius / newCenterRadius);
289
+ }
290
+ return newRadius;
291
+ }
292
+ /**
293
+ * Apply zoom by moving the camera toward/away from a target point.
294
+ */
295
+ _applyZoom() {
296
+ const zoomDelta = this.movement.zoomDeltaCurrentFrame;
297
+ const pickedPoint = this.movement.computedPerFrameZoomPickPoint;
298
+ if (pickedPoint) {
299
+ // Zoom toward the picked point under cursor
300
+ this._zoomToPoint(pickedPoint, zoomDelta);
301
+ }
302
+ else {
303
+ // Zoom along lookAt vector (fallback when no surface under cursor)
304
+ this._zoomAlongLookAt(zoomDelta);
305
+ }
306
+ }
307
+ _zoomToPoint(targetPoint, distance) {
308
+ const newRadius = this._getCenterAndRadiusFromZoomToPoint(targetPoint, distance, this._tempCenter);
309
+ // Apply the new orientation
310
+ this._setOrientation(this._yaw, this._pitch, newRadius, this._tempCenter);
311
+ }
312
+ _zoomAlongLookAt(distance) {
313
+ // Clamp radius to limits
314
+ const requestedRadius = this._radius - distance;
315
+ const newRadius = Clamp(requestedRadius, this.limits.radiusMin, this.limits.radiusMax);
316
+ // Simply change radius without moving center
317
+ this._setOrientation(this._yaw, this._pitch, newRadius, this._center);
261
318
  }
262
319
  _checkInputs() {
263
320
  this.inputs.checkInputs();
264
321
  // Let movement class handle all per-frame logic
265
322
  this.movement.computeCurrentFrameDeltas();
323
+ let recalculateCenter = false;
266
324
  if (this.movement.panDeltaCurrentFrame.lengthSquared() > 0) {
267
325
  this._applyGeocentricTranslation();
268
- this._isViewMatrixDirty = true;
326
+ recalculateCenter = true;
269
327
  }
270
328
  if (this.movement.rotationDeltaCurrentFrame.lengthSquared() > 0) {
271
329
  this._applyGeocentricRotation();
272
- this._isViewMatrixDirty = true;
273
330
  }
274
331
  if (Math.abs(this.movement.zoomDeltaCurrentFrame) > Epsilon) {
275
- this._applyZoom(this.movement.computedPerFrameZoomVector, this.movement.zoomDeltaCurrentFrame);
276
- this._isViewMatrixDirty = true;
332
+ this._applyZoom();
333
+ recalculateCenter = true;
277
334
  }
335
+ // After a movement impacting center or radius, recalculate the center point to ensure it's still on the surface.
336
+ recalculateCenter && this._recalculateCenter();
278
337
  super._checkInputs();
279
338
  }
339
+ _recalculateCenter() {
340
+ // Wait until dragging is complete to avoid wasted raycasting
341
+ if (!this.movement.isDragging) {
342
+ const newCenter = this.movement.pickAlongVector(this._lookAtVector);
343
+ if (newCenter?.pickedPoint) {
344
+ // Direction from new center to origin
345
+ const centerToOrigin = TmpVectors.Vector3[4];
346
+ centerToOrigin.copyFrom(newCenter.pickedPoint).negateInPlace().normalize();
347
+ // Check if this direction aligns with camera's lookAt vector
348
+ const dotProduct = Vector3.Dot(this._lookAtVector, centerToOrigin);
349
+ // Only update if the center is looking toward the origin (dot product > 0) to avoid a center on the opposite side of globe
350
+ if (dotProduct > 0) {
351
+ const newRadius = Vector3.Distance(this.position, newCenter.pickedPoint);
352
+ this._setOrientation(this._yaw, this._pitch, newRadius, newCenter.pickedPoint);
353
+ }
354
+ }
355
+ }
356
+ }
280
357
  attachControl(noPreventDefault) {
281
358
  this.inputs.attachElement(noPreventDefault);
282
359
  }