@babylonjs/core 6.3.0 → 6.4.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (73) hide show
  1. package/Audio/audioSceneComponent.js +2 -2
  2. package/Audio/audioSceneComponent.js.map +1 -1
  3. package/Cameras/Inputs/arcRotateCameraMouseWheelInput.js +10 -1
  4. package/Cameras/Inputs/arcRotateCameraMouseWheelInput.js.map +1 -1
  5. package/Culling/ray.d.ts +1 -1
  6. package/Culling/ray.js +1 -1
  7. package/Culling/ray.js.map +1 -1
  8. package/Debug/physicsViewer.d.ts +17 -0
  9. package/Debug/physicsViewer.js +153 -2
  10. package/Debug/physicsViewer.js.map +1 -1
  11. package/Engines/WebGPU/webgpuCacheRenderPipeline.js +2 -1
  12. package/Engines/WebGPU/webgpuCacheRenderPipeline.js.map +1 -1
  13. package/Engines/WebGPU/webgpuTextureHelper.d.ts +1 -1
  14. package/Engines/WebGPU/webgpuTextureHelper.js +28 -9
  15. package/Engines/WebGPU/webgpuTextureHelper.js.map +1 -1
  16. package/Engines/engine.d.ts +5 -0
  17. package/Engines/engine.js +0 -1
  18. package/Engines/engine.js.map +1 -1
  19. package/Engines/thinEngine.js +2 -2
  20. package/Engines/thinEngine.js.map +1 -1
  21. package/Engines/webgpuEngine.js +1 -1
  22. package/Engines/webgpuEngine.js.map +1 -1
  23. package/Instrumentation/sceneInstrumentation.js +25 -1
  24. package/Instrumentation/sceneInstrumentation.js.map +1 -1
  25. package/Materials/Node/Blocks/Dual/textureBlock.d.ts +6 -0
  26. package/Materials/Node/Blocks/Dual/textureBlock.js +16 -3
  27. package/Materials/Node/Blocks/Dual/textureBlock.js.map +1 -1
  28. package/Materials/PBR/pbrBaseMaterial.js +11 -2
  29. package/Materials/PBR/pbrBaseMaterial.js.map +1 -1
  30. package/Materials/Textures/htmlElementTexture.d.ts +1 -0
  31. package/Materials/Textures/htmlElementTexture.js +1 -0
  32. package/Materials/Textures/htmlElementTexture.js.map +1 -1
  33. package/Materials/Textures/texture.js +1 -1
  34. package/Materials/Textures/texture.js.map +1 -1
  35. package/Materials/Textures/videoTexture.js +16 -8
  36. package/Materials/Textures/videoTexture.js.map +1 -1
  37. package/Materials/material.js +0 -5
  38. package/Materials/material.js.map +1 -1
  39. package/Materials/materialPluginManager.js +7 -0
  40. package/Materials/materialPluginManager.js.map +1 -1
  41. package/Meshes/Builders/decalBuilder.js +146 -114
  42. package/Meshes/Builders/decalBuilder.js.map +1 -1
  43. package/Meshes/abstractMesh.d.ts +1 -1
  44. package/Meshes/abstractMesh.js +1 -1
  45. package/Meshes/abstractMesh.js.map +1 -1
  46. package/Meshes/mesh.d.ts +3 -0
  47. package/Meshes/mesh.js +3 -0
  48. package/Meshes/mesh.js.map +1 -1
  49. package/Meshes/meshUVSpaceRenderer.js +6 -3
  50. package/Meshes/meshUVSpaceRenderer.js.map +1 -1
  51. package/Misc/dumpTools.js +2 -1
  52. package/Misc/dumpTools.js.map +1 -1
  53. package/Misc/environmentTextureTools.js +9 -1
  54. package/Misc/environmentTextureTools.js.map +1 -1
  55. package/Misc/perfCounter.d.ts +5 -0
  56. package/Misc/perfCounter.js +7 -0
  57. package/Misc/perfCounter.js.map +1 -1
  58. package/Morph/morphTargetManager.js +3 -0
  59. package/Morph/morphTargetManager.js.map +1 -1
  60. package/Physics/v2/Plugins/havokPlugin.js +12 -2
  61. package/Physics/v2/Plugins/havokPlugin.js.map +1 -1
  62. package/Rendering/fluidRenderer/fluidRenderer.d.ts +1 -1
  63. package/Rendering/fluidRenderer/fluidRenderer.js.map +1 -1
  64. package/Shaders/screenSpaceReflection2.fragment.js +1 -1
  65. package/Shaders/screenSpaceReflection2.fragment.js.map +1 -1
  66. package/Sprites/spriteManager.js +5 -9
  67. package/Sprites/spriteManager.js.map +1 -1
  68. package/XR/webXRSessionManager.d.ts +6 -0
  69. package/XR/webXRSessionManager.js +9 -0
  70. package/XR/webXRSessionManager.js.map +1 -1
  71. package/package.json +1 -1
  72. package/scene.js +1 -0
  73. package/scene.js.map +1 -1
@@ -136,7 +136,7 @@ Object.defineProperty(Scene.prototype, "audioListenerPositionProvider", {
136
136
  compo = new AudioSceneComponent(this);
137
137
  this._addComponent(compo);
138
138
  }
139
- if (typeof value !== "function") {
139
+ if (value && typeof value !== "function") {
140
140
  throw new Error("The value passed to [Scene.audioListenerPositionProvider] must be a function that returns a Vector3");
141
141
  }
142
142
  else {
@@ -161,7 +161,7 @@ Object.defineProperty(Scene.prototype, "audioListenerRotationProvider", {
161
161
  compo = new AudioSceneComponent(this);
162
162
  this._addComponent(compo);
163
163
  }
164
- if (typeof value !== "function") {
164
+ if (value && typeof value !== "function") {
165
165
  throw new Error("The value passed to [Scene.audioListenerRotationProvider] must be a function that returns a Vector3");
166
166
  }
167
167
  else {
@@ -1 +1 @@
1
- {"version":3,"file":"audioSceneComponent.js","sourceRoot":"","sources":["../../../../lts/core/generated/Audio/audioSceneComponent.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAE,MAAM,SAAS,CAAC;AAChC,OAAO,EAAE,UAAU,EAAE,MAAM,cAAc,CAAC;AAC1C,OAAO,EAAE,MAAM,EAAE,MAAM,mBAAmB,CAAC;AAE3C,OAAO,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,sBAAsB,CAAC;AAEvD,OAAO,EAAE,uBAAuB,EAAE,MAAM,mBAAmB,CAAC;AAC5D,OAAO,EAAE,KAAK,EAAE,MAAM,UAAU,CAAC;AACjC,OAAO,EAAE,aAAa,EAAE,MAAM,kBAAkB,CAAC;AAGjD,OAAO,eAAe,CAAC;AACvB,OAAO,EAAE,aAAa,EAAE,MAAM,uBAAuB,CAAC;AACtD,OAAO,EAAE,WAAW,EAAE,MAAM,wBAAwB,CAAC;AAErD,wCAAwC;AACxC,aAAa,CAAC,SAAS,CAAC,uBAAuB,CAAC,UAAU,EAAE,CAAC,UAAe,EAAE,KAAY,EAAE,SAAyB,EAAE,OAAe,EAAE,EAAE;;IACtI,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AAI,KAAK,CAAC,oBAAoB,EAAE;oBAC5B,KAAK,CAAC,0BAA0B,EAAE,CAAC;iBACtC;aACJ;YACD,IAAI,KAAK,CAAC,WAAW,EAAE;gBACnB,KAAK,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,KAAK,CAAC,WAAW,CAAC,MAAM,EAAE,CAAC,EAAE,EAAE;oBAC3C,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,KAAK,CAAC,WAAW,CAAC,CAAC,CAAC,CAAC,eAAe,CAAC,MAAM,EAAE,CAAC,EAAE,EAAE;wBAClE,MAAM,KAAK,GAAG,KAAK,CAAC,WAAW,CAAC,CAAC,CAAC,CAAC,eAAe,CAAC,CAAC,CAAC,CAAC;wBACtD,IAAI,KAAK,CAAC,oBAAoB,EAAE;4BAC5B,KAAK,CAAC,0BAA0B,EAAE,CAAC;yBACtC;qBACJ;iBACJ;aACJ;SACJ;IACL,CAAC;;AAtUc,oCAAgB,GAAG,IAAI,OAAO,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC;AAyU5D,KAAK,CAAC,6BAA6B,GAAG,CAAC,KAAY,EAAE,EAAE;IACnD,IAAI,KAAK,GAAG,KAAK,CAAC,aAAa,CAAC,uBAAuB,CAAC,UAAU,CAAC,CAAC;IACpE,IAAI,CAAC,KAAK,EAAE;QACR,KAAK,GAAG,IAAI,mBAAmB,CAAC,KAAK,CAAC,CAAC;QACvC,KAAK,CAAC,aAAa,CAAC,KAAK,CAAC,CAAC;KAC9B;AACL,CAAC,CAAC","sourcesContent":["import { Sound } from \"./sound\";\r\nimport { SoundTrack } from \"./soundTrack\";\r\nimport { Engine } from \"../Engines/engine\";\r\nimport type { Nullable } from \"../types\";\r\nimport { Matrix, Vector3 } from \"../Maths/math.vector\";\r\nimport type { ISceneSerializableComponent } from \"../sceneComponent\";\r\nimport { SceneComponentConstants } from \"../sceneComponent\";\r\nimport { Scene } from \"../scene\";\r\nimport { AbstractScene } from \"../abstractScene\";\r\nimport type { AssetContainer } from \"../assetContainer\";\r\n\r\nimport \"./audioEngine\";\r\nimport { PrecisionDate } from \"../Misc/precisionDate\";\r\nimport { EngineStore } from \"../Engines/engineStore\";\r\n\r\n// Adds the parser to the scene parsers.\r\nAbstractScene.AddParser(SceneComponentConstants.NAME_AUDIO, (parsedData: any, scene: Scene, container: AssetContainer, rootUrl: string) => {\r\n // TODO: add sound\r\n let loadedSounds: Sound[] = [];\r\n let loadedSound: Sound;\r\n container.sounds = container.sounds || [];\r\n if (parsedData.sounds !== undefined && parsedData.sounds !== null) {\r\n for (let index = 0, cache = parsedData.sounds.length; index < cache; index++) {\r\n const parsedSound = parsedData.sounds[index];\r\n if (Engine.audioEngine?.canUseWebAudio) {\r\n if (!parsedSound.url) {\r\n parsedSound.url = parsedSound.name;\r\n }\r\n if (!loadedSounds[parsedSound.url]) {\r\n loadedSound = Sound.Parse(parsedSound, scene, rootUrl);\r\n loadedSounds[parsedSound.url] = loadedSound;\r\n container.sounds.push(loadedSound);\r\n } else {\r\n container.sounds.push(Sound.Parse(parsedSound, scene, rootUrl, loadedSounds[parsedSound.url]));\r\n }\r\n } else {\r\n container.sounds.push(new Sound(parsedSound.name, null, scene));\r\n }\r\n }\r\n }\r\n\r\n loadedSounds = [];\r\n});\r\n\r\ndeclare module \"../abstractScene\" {\r\n export interface AbstractScene {\r\n /**\r\n * The list of sounds used in the scene.\r\n */\r\n sounds: Nullable<Array<Sound>>;\r\n }\r\n}\r\n\r\ndeclare module \"../scene\" {\r\n export interface Scene {\r\n /**\r\n * @internal\r\n * Backing field\r\n */\r\n _mainSoundTrack: SoundTrack;\r\n /**\r\n * The main sound track played by the scene.\r\n * It contains your primary collection of sounds.\r\n */\r\n mainSoundTrack: SoundTrack;\r\n /**\r\n * The list of sound tracks added to the scene\r\n * @see https://doc.babylonjs.com/features/featuresDeepDive/audio/playingSoundsMusic\r\n */\r\n soundTracks: Nullable<Array<SoundTrack>>;\r\n\r\n /**\r\n * Gets a sound using a given name\r\n * @param name defines the name to search for\r\n * @returns the found sound or null if not found at all.\r\n */\r\n getSoundByName(name: string): Nullable<Sound>;\r\n\r\n /**\r\n * Gets or sets if audio support is enabled\r\n * @see https://doc.babylonjs.com/features/featuresDeepDive/audio/playingSoundsMusic\r\n */\r\n audioEnabled: boolean;\r\n\r\n /**\r\n * Gets or sets if audio will be output to headphones\r\n * @see https://doc.babylonjs.com/features/featuresDeepDive/audio/playingSoundsMusic\r\n */\r\n headphone: boolean;\r\n\r\n /**\r\n * Gets or sets custom audio listener position provider\r\n * @see https://doc.babylonjs.com/features/featuresDeepDive/audio/playingSoundsMusic\r\n */\r\n audioListenerPositionProvider: Nullable<() => Vector3>;\r\n\r\n /**\r\n * Gets or sets custom audio listener rotation provider\r\n * @see https://doc.babylonjs.com/features/featuresDeepDive/audio/playingSoundsMusic\r\n */\r\n audioListenerRotationProvider: Nullable<() => Vector3>;\r\n\r\n /**\r\n * Gets or sets a refresh rate when using 3D audio positioning\r\n */\r\n audioPositioningRefreshRate: number;\r\n }\r\n}\r\n\r\nObject.defineProperty(Scene.prototype, \"mainSoundTrack\", {\r\n get: function (this: Scene) {\r\n let compo = this._getComponent(SceneComponentConstants.NAME_AUDIO) as AudioSceneComponent;\r\n if (!compo) {\r\n compo = new AudioSceneComponent(this);\r\n this._addComponent(compo);\r\n }\r\n\r\n if (!this._mainSoundTrack) {\r\n this._mainSoundTrack = new SoundTrack(this, { mainTrack: true });\r\n }\r\n\r\n return this._mainSoundTrack;\r\n },\r\n enumerable: true,\r\n configurable: true,\r\n});\r\n\r\nScene.prototype.getSoundByName = function (name: string): Nullable<Sound> {\r\n let index: number;\r\n for (index = 0; index < this.mainSoundTrack.soundCollection.length; index++) {\r\n if (this.mainSoundTrack.soundCollection[index].name === name) {\r\n return this.mainSoundTrack.soundCollection[index];\r\n }\r\n }\r\n\r\n if (this.soundTracks) {\r\n for (let sdIndex = 0; sdIndex < this.soundTracks.length; sdIndex++) {\r\n for (index = 0; index < this.soundTracks[sdIndex].soundCollection.length; index++) {\r\n if (this.soundTracks[sdIndex].soundCollection[index].name === name) {\r\n return this.soundTracks[sdIndex].soundCollection[index];\r\n }\r\n }\r\n }\r\n }\r\n\r\n return null;\r\n};\r\n\r\nObject.defineProperty(Scene.prototype, \"audioEnabled\", {\r\n get: function (this: Scene) {\r\n let compo = this._getComponent(SceneComponentConstants.NAME_AUDIO) as AudioSceneComponent;\r\n if (!compo) {\r\n compo = new AudioSceneComponent(this);\r\n this._addComponent(compo);\r\n }\r\n\r\n return compo.audioEnabled;\r\n },\r\n set: function (this: Scene, value: boolean) {\r\n let compo = this._getComponent(SceneComponentConstants.NAME_AUDIO) as AudioSceneComponent;\r\n if (!compo) {\r\n compo = new AudioSceneComponent(this);\r\n this._addComponent(compo);\r\n }\r\n\r\n if (value) {\r\n compo.enableAudio();\r\n } else {\r\n compo.disableAudio();\r\n }\r\n },\r\n enumerable: true,\r\n configurable: true,\r\n});\r\n\r\nObject.defineProperty(Scene.prototype, \"headphone\", {\r\n get: function (this: Scene) {\r\n let compo = this._getComponent(SceneComponentConstants.NAME_AUDIO) as AudioSceneComponent;\r\n if (!compo) {\r\n compo = new AudioSceneComponent(this);\r\n this._addComponent(compo);\r\n }\r\n\r\n return compo.headphone;\r\n },\r\n set: function (this: Scene, value: boolean) {\r\n let compo = this._getComponent(SceneComponentConstants.NAME_AUDIO) as AudioSceneComponent;\r\n if (!compo) {\r\n compo = new AudioSceneComponent(this);\r\n this._addComponent(compo);\r\n }\r\n\r\n if (value) {\r\n compo.switchAudioModeForHeadphones();\r\n } else {\r\n compo.switchAudioModeForNormalSpeakers();\r\n }\r\n },\r\n enumerable: true,\r\n configurable: true,\r\n});\r\n\r\nObject.defineProperty(Scene.prototype, \"audioListenerPositionProvider\", {\r\n get: function (this: Scene) {\r\n let compo = this._getComponent(SceneComponentConstants.NAME_AUDIO) as AudioSceneComponent;\r\n if (!compo) {\r\n compo = new AudioSceneComponent(this);\r\n this._addComponent(compo);\r\n }\r\n\r\n return compo.audioListenerPositionProvider;\r\n },\r\n set: function (this: Scene, value: () => Vector3) {\r\n let compo = this._getComponent(SceneComponentConstants.NAME_AUDIO) as AudioSceneComponent;\r\n if (!compo) {\r\n compo = new AudioSceneComponent(this);\r\n this._addComponent(compo);\r\n }\r\n\r\n if (typeof value !== \"function\") {\r\n throw new Error(\"The value passed to [Scene.audioListenerPositionProvider] must be a function that returns a Vector3\");\r\n } else {\r\n compo.audioListenerPositionProvider = value;\r\n }\r\n },\r\n enumerable: true,\r\n configurable: true,\r\n});\r\n\r\nObject.defineProperty(Scene.prototype, \"audioListenerRotationProvider\", {\r\n get: function (this: Scene) {\r\n let compo = this._getComponent(SceneComponentConstants.NAME_AUDIO) as AudioSceneComponent;\r\n if (!compo) {\r\n compo = new AudioSceneComponent(this);\r\n this._addComponent(compo);\r\n }\r\n\r\n return compo.audioListenerRotationProvider;\r\n },\r\n set: function (this: Scene, value: () => Vector3) {\r\n let compo = this._getComponent(SceneComponentConstants.NAME_AUDIO) as AudioSceneComponent;\r\n if (!compo) {\r\n compo = new AudioSceneComponent(this);\r\n this._addComponent(compo);\r\n }\r\n\r\n if (typeof value !== \"function\") {\r\n throw new Error(\"The value passed to [Scene.audioListenerRotationProvider] must be a function that returns a Vector3\");\r\n } else {\r\n compo.audioListenerRotationProvider = value;\r\n }\r\n },\r\n enumerable: true,\r\n configurable: true,\r\n});\r\n\r\nObject.defineProperty(Scene.prototype, \"audioPositioningRefreshRate\", {\r\n get: function (this: Scene) {\r\n let compo = this._getComponent(SceneComponentConstants.NAME_AUDIO) as AudioSceneComponent;\r\n if (!compo) {\r\n compo = new AudioSceneComponent(this);\r\n this._addComponent(compo);\r\n }\r\n\r\n return compo.audioPositioningRefreshRate;\r\n },\r\n set: function (this: Scene, value: number) {\r\n let compo = this._getComponent(SceneComponentConstants.NAME_AUDIO) as AudioSceneComponent;\r\n if (!compo) {\r\n compo = new AudioSceneComponent(this);\r\n this._addComponent(compo);\r\n }\r\n\r\n compo.audioPositioningRefreshRate = value;\r\n },\r\n enumerable: true,\r\n configurable: true,\r\n});\r\n\r\n/**\r\n * Defines the sound scene component responsible to manage any sounds\r\n * in a given scene.\r\n */\r\nexport class AudioSceneComponent implements ISceneSerializableComponent {\r\n private static _CameraDirection = new Vector3(0, 0, -1);\r\n\r\n /**\r\n * The component name helpful to identify the component in the list of scene components.\r\n */\r\n public readonly name = SceneComponentConstants.NAME_AUDIO;\r\n\r\n /**\r\n * The scene the component belongs to.\r\n */\r\n public scene: Scene;\r\n\r\n private _audioEnabled = true;\r\n /**\r\n * Gets whether audio is enabled or not.\r\n * Please use related enable/disable method to switch state.\r\n */\r\n public get audioEnabled(): boolean {\r\n return this._audioEnabled;\r\n }\r\n\r\n private _headphone = false;\r\n /**\r\n * Gets whether audio is outputting to headphone or not.\r\n * Please use the according Switch methods to change output.\r\n */\r\n public get headphone(): boolean {\r\n return this._headphone;\r\n }\r\n\r\n /**\r\n * Gets or sets a refresh rate when using 3D audio positioning\r\n */\r\n public audioPositioningRefreshRate = 500;\r\n\r\n /**\r\n * Gets or Sets a custom listener position for all sounds in the scene\r\n * By default, this is the position of the first active camera\r\n */\r\n public audioListenerPositionProvider: Nullable<() => Vector3> = null;\r\n\r\n /**\r\n * Gets or Sets a custom listener rotation for all sounds in the scene\r\n * By default, this is the rotation of the first active camera\r\n */\r\n public audioListenerRotationProvider: Nullable<() => Vector3> = null;\r\n\r\n /**\r\n * Creates a new instance of the component for the given scene\r\n * @param scene Defines the scene to register the component in\r\n */\r\n constructor(scene?: Nullable<Scene>) {\r\n scene = scene || EngineStore.LastCreatedScene;\r\n if (!scene) {\r\n return;\r\n }\r\n this.scene = scene;\r\n\r\n scene.soundTracks = new Array<SoundTrack>();\r\n scene.sounds = new Array<Sound>();\r\n }\r\n\r\n /**\r\n * Registers the component in a given scene\r\n */\r\n public register(): void {\r\n this.scene._afterRenderStage.registerStep(SceneComponentConstants.STEP_AFTERRENDER_AUDIO, this, this._afterRender);\r\n }\r\n\r\n /**\r\n * Rebuilds the elements related to this component in case of\r\n * context lost for instance.\r\n */\r\n public rebuild(): void {\r\n // Nothing to do here. (Not rendering related)\r\n }\r\n\r\n /**\r\n * Serializes the component data to the specified json object\r\n * @param serializationObject The object to serialize to\r\n */\r\n public serialize(serializationObject: any): void {\r\n serializationObject.sounds = [];\r\n\r\n if (this.scene.soundTracks) {\r\n for (let index = 0; index < this.scene.soundTracks.length; index++) {\r\n const soundtrack = this.scene.soundTracks[index];\r\n\r\n for (let soundId = 0; soundId < soundtrack.soundCollection.length; soundId++) {\r\n serializationObject.sounds.push(soundtrack.soundCollection[soundId].serialize());\r\n }\r\n }\r\n }\r\n }\r\n\r\n /**\r\n * Adds all the elements from the container to the scene\r\n * @param container the container holding the elements\r\n */\r\n public addFromContainer(container: AbstractScene): void {\r\n if (!container.sounds) {\r\n return;\r\n }\r\n container.sounds.forEach((sound) => {\r\n sound.play();\r\n sound.autoplay = true;\r\n this.scene.mainSoundTrack.addSound(sound);\r\n });\r\n }\r\n\r\n /**\r\n * Removes all the elements in the container from the scene\r\n * @param container contains the elements to remove\r\n * @param dispose if the removed element should be disposed (default: false)\r\n */\r\n public removeFromContainer(container: AbstractScene, dispose = false): void {\r\n if (!container.sounds) {\r\n return;\r\n }\r\n container.sounds.forEach((sound) => {\r\n sound.stop();\r\n sound.autoplay = false;\r\n this.scene.mainSoundTrack.removeSound(sound);\r\n if (dispose) {\r\n sound.dispose();\r\n }\r\n });\r\n }\r\n\r\n /**\r\n * Disposes the component and the associated resources.\r\n */\r\n public dispose(): void {\r\n const scene = this.scene;\r\n if (scene._mainSoundTrack) {\r\n scene.mainSoundTrack.dispose();\r\n }\r\n\r\n if (scene.soundTracks) {\r\n for (let scIndex = 0; scIndex < scene.soundTracks.length; scIndex++) {\r\n scene.soundTracks[scIndex].dispose();\r\n }\r\n }\r\n }\r\n\r\n /**\r\n * Disables audio in the associated scene.\r\n */\r\n public disableAudio() {\r\n const scene = this.scene;\r\n this._audioEnabled = false;\r\n\r\n if (Engine.audioEngine && Engine.audioEngine.audioContext) {\r\n Engine.audioEngine.audioContext.suspend();\r\n }\r\n\r\n let i: number;\r\n for (i = 0; i < scene.mainSoundTrack.soundCollection.length; i++) {\r\n scene.mainSoundTrack.soundCollection[i].pause();\r\n }\r\n if (scene.soundTracks) {\r\n for (i = 0; i < scene.soundTracks.length; i++) {\r\n for (let j = 0; j < scene.soundTracks[i].soundCollection.length; j++) {\r\n scene.soundTracks[i].soundCollection[j].pause();\r\n }\r\n }\r\n }\r\n }\r\n\r\n /**\r\n * Enables audio in the associated scene.\r\n */\r\n public enableAudio() {\r\n const scene = this.scene;\r\n this._audioEnabled = true;\r\n\r\n if (Engine.audioEngine && Engine.audioEngine.audioContext) {\r\n Engine.audioEngine.audioContext.resume();\r\n }\r\n\r\n let i: number;\r\n for (i = 0; i < scene.mainSoundTrack.soundCollection.length; i++) {\r\n if (scene.mainSoundTrack.soundCollection[i].isPaused) {\r\n scene.mainSoundTrack.soundCollection[i].play();\r\n }\r\n }\r\n if (scene.soundTracks) {\r\n for (i = 0; i < scene.soundTracks.length; i++) {\r\n for (let j = 0; j < scene.soundTracks[i].soundCollection.length; j++) {\r\n if (scene.soundTracks[i].soundCollection[j].isPaused) {\r\n scene.soundTracks[i].soundCollection[j].play();\r\n }\r\n }\r\n }\r\n }\r\n }\r\n\r\n /**\r\n * Switch audio to headphone output.\r\n */\r\n public switchAudioModeForHeadphones() {\r\n const scene = this.scene;\r\n this._headphone = true;\r\n\r\n scene.mainSoundTrack.switchPanningModelToHRTF();\r\n if (scene.soundTracks) {\r\n for (let i = 0; i < scene.soundTracks.length; i++) {\r\n scene.soundTracks[i].switchPanningModelToHRTF();\r\n }\r\n }\r\n }\r\n\r\n /**\r\n * Switch audio to normal speakers.\r\n */\r\n public switchAudioModeForNormalSpeakers() {\r\n const scene = this.scene;\r\n this._headphone = false;\r\n\r\n scene.mainSoundTrack.switchPanningModelToEqualPower();\r\n\r\n if (scene.soundTracks) {\r\n for (let i = 0; i < scene.soundTracks.length; i++) {\r\n scene.soundTracks[i].switchPanningModelToEqualPower();\r\n }\r\n }\r\n }\r\n\r\n private _cachedCameraDirection = new Vector3();\r\n private _cachedCameraPosition = new Vector3();\r\n private _lastCheck = 0;\r\n private _invertMatrixTemp = new Matrix();\r\n private _cameraDirectionTemp = new Vector3();\r\n\r\n private _afterRender() {\r\n const now = PrecisionDate.Now;\r\n if (this._lastCheck && now - this._lastCheck < this.audioPositioningRefreshRate) {\r\n return;\r\n }\r\n\r\n this._lastCheck = now;\r\n\r\n const scene = this.scene;\r\n if (!this._audioEnabled || !scene._mainSoundTrack || !scene.soundTracks || (scene._mainSoundTrack.soundCollection.length === 0 && scene.soundTracks.length === 1)) {\r\n return;\r\n }\r\n\r\n const audioEngine = Engine.audioEngine;\r\n\r\n if (!audioEngine) {\r\n return;\r\n }\r\n\r\n if (audioEngine.audioContext) {\r\n let listeningCamera = scene.activeCamera;\r\n if (scene.activeCameras && scene.activeCameras.length > 0) {\r\n listeningCamera = scene.activeCameras[0];\r\n }\r\n\r\n // A custom listener position provider was set\r\n // Use the users provided position instead of camera's\r\n if (this.audioListenerPositionProvider) {\r\n const position: Vector3 = this.audioListenerPositionProvider();\r\n // Set the listener position\r\n audioEngine.audioContext.listener.setPosition(position.x || 0, position.y || 0, position.z || 0);\r\n // Check if there is a listening camera\r\n } else if (listeningCamera) {\r\n // Set the listener position to the listening camera global position\r\n if (!this._cachedCameraPosition.equals(listeningCamera.globalPosition)) {\r\n this._cachedCameraPosition.copyFrom(listeningCamera.globalPosition);\r\n audioEngine.audioContext.listener.setPosition(listeningCamera.globalPosition.x, listeningCamera.globalPosition.y, listeningCamera.globalPosition.z);\r\n }\r\n }\r\n // Otherwise set the listener position to 0, 0 ,0\r\n else {\r\n // Set the listener position\r\n audioEngine.audioContext.listener.setPosition(0, 0, 0);\r\n }\r\n\r\n // A custom listener rotation provider was set\r\n // Use the users provided rotation instead of camera's\r\n if (this.audioListenerRotationProvider) {\r\n const rotation: Vector3 = this.audioListenerRotationProvider();\r\n audioEngine.audioContext.listener.setOrientation(rotation.x || 0, rotation.y || 0, rotation.z || 0, 0, 1, 0);\r\n // Check if there is a listening camera\r\n } else if (listeningCamera) {\r\n // for VR cameras\r\n if (listeningCamera.rigCameras && listeningCamera.rigCameras.length > 0) {\r\n listeningCamera = listeningCamera.rigCameras[0];\r\n }\r\n\r\n listeningCamera.getViewMatrix().invertToRef(this._invertMatrixTemp);\r\n Vector3.TransformNormalToRef(AudioSceneComponent._CameraDirection, this._invertMatrixTemp, this._cameraDirectionTemp);\r\n this._cameraDirectionTemp.normalize();\r\n // To avoid some errors on GearVR\r\n if (!isNaN(this._cameraDirectionTemp.x) && !isNaN(this._cameraDirectionTemp.y) && !isNaN(this._cameraDirectionTemp.z)) {\r\n if (!this._cachedCameraDirection.equals(this._cameraDirectionTemp)) {\r\n this._cachedCameraDirection.copyFrom(this._cameraDirectionTemp);\r\n audioEngine.audioContext.listener.setOrientation(this._cameraDirectionTemp.x, this._cameraDirectionTemp.y, this._cameraDirectionTemp.z, 0, 1, 0);\r\n }\r\n }\r\n }\r\n // Otherwise set the listener rotation to 0, 0 ,0\r\n else {\r\n // Set the listener position\r\n audioEngine.audioContext.listener.setOrientation(0, 0, 0, 0, 1, 0);\r\n }\r\n\r\n let i: number;\r\n for (i = 0; i < scene.mainSoundTrack.soundCollection.length; i++) {\r\n const sound = scene.mainSoundTrack.soundCollection[i];\r\n if (sound.useCustomAttenuation) {\r\n sound.updateDistanceFromListener();\r\n }\r\n }\r\n if (scene.soundTracks) {\r\n for (i = 0; i < scene.soundTracks.length; i++) {\r\n for (let j = 0; j < scene.soundTracks[i].soundCollection.length; j++) {\r\n const sound = scene.soundTracks[i].soundCollection[j];\r\n if (sound.useCustomAttenuation) {\r\n sound.updateDistanceFromListener();\r\n }\r\n }\r\n }\r\n }\r\n }\r\n }\r\n}\r\n\r\nSound._SceneComponentInitialization = (scene: Scene) => {\r\n let compo = scene._getComponent(SceneComponentConstants.NAME_AUDIO);\r\n if (!compo) {\r\n compo = new AudioSceneComponent(scene);\r\n scene._addComponent(compo);\r\n }\r\n};\r\n"]}
1
+ {"version":3,"file":"audioSceneComponent.js","sourceRoot":"","sources":["../../../../lts/core/generated/Audio/audioSceneComponent.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAE,MAAM,SAAS,CAAC;AAChC,OAAO,EAAE,UAAU,EAAE,MAAM,cAAc,CAAC;AAC1C,OAAO,EAAE,MAAM,EAAE,MAAM,mBAAmB,CAAC;AAE3C,OAAO,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,sBAAsB,CAAC;AAEvD,OAAO,EAAE,uBAAuB,EAAE,MAAM,mBAAmB,CAAC;AAC5D,OAAO,EAAE,KAAK,EAAE,MAAM,UAAU,CAAC;AACjC,OAAO,EAAE,aAAa,EAAE,MAAM,kBAAkB,CAAC;AAGjD,OAAO,eAAe,CAAC;AACvB,OAAO,EAAE,aAAa,EAAE,MAAM,uBAAuB,CAAC;AACtD,OAAO,EAAE,WAAW,EAAE,MAAM,wBAAwB,CAAC;AAErD,wCAAwC;AACxC,aAAa,CAAC,SAAS,CAAC,uBAAuB,CAAC,UAAU,EAAE,CAAC,UAAe,EAAE,KAAY,EAAE,SAAyB,EAAE,OAAe,EAAE,EAAE;;IACtI,kBAAkB;IAClB,IAAI,YAAY,GAAY,EAAE,CAAC;IAC/B,IAAI,WAAkB,CAAC;IACvB,SAAS,CAAC,MAAM,GAAG,SAAS,CAAC,MAAM,IAAI,EAAE,CAAC;IAC1C,IAAI,UAAU,CAAC,MAAM,KAAK,SAAS,IAAI,UAAU,CAAC,MAAM,KAAK,IAAI,EAAE;QAC/D,KAAK,IAAI,KAAK,GAAG,CAAC,EAAE,KAAK,GAAG,UAAU,CAAC,MAAM,CAAC,MAAM,EAAE,KAAK,GAAG,KAAK,EAAE,KAAK,EAAE,EAAE;YAC1E,MAAM,WAAW,GAAG,UAAU,CAAC,MAAM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,KAAK,GAAG,KAAK,CAAC,WAAW,CAAC,CAAC,CAAC,CAAC,eAAe,CAAC,CAAC,CAAC,CAAC;wBACtD,IAAI,KAAK,CAAC,oBAAoB,EAAE;4BAC5B,KAAK,CAAC,0BAA0B,EAAE,CAAC;yBACtC;qBACJ;iBACJ;aACJ;SACJ;IACL,CAAC;;AAtUc,oCAAgB,GAAG,IAAI,OAAO,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC;AAyU5D,KAAK,CAAC,6BAA6B,GAAG,CAAC,KAAY,EAAE,EAAE;IACnD,IAAI,KAAK,GAAG,KAAK,CAAC,aAAa,CAAC,uBAAuB,CAAC,UAAU,CAAC,CAAC;IACpE,IAAI,CAAC,KAAK,EAAE;QACR,KAAK,GAAG,IAAI,mBAAmB,CAAC,KAAK,CAAC,CAAC;QACvC,KAAK,CAAC,aAAa,CAAC,KAAK,CAAC,CAAC;KAC9B;AACL,CAAC,CAAC","sourcesContent":["import { Sound } from \"./sound\";\r\nimport { SoundTrack } from \"./soundTrack\";\r\nimport { Engine } from \"../Engines/engine\";\r\nimport type { Nullable } from \"../types\";\r\nimport { Matrix, Vector3 } from \"../Maths/math.vector\";\r\nimport type { ISceneSerializableComponent } from \"../sceneComponent\";\r\nimport { SceneComponentConstants } from \"../sceneComponent\";\r\nimport { Scene } from \"../scene\";\r\nimport { AbstractScene } from \"../abstractScene\";\r\nimport type { AssetContainer } from \"../assetContainer\";\r\n\r\nimport \"./audioEngine\";\r\nimport { PrecisionDate } from \"../Misc/precisionDate\";\r\nimport { EngineStore } from \"../Engines/engineStore\";\r\n\r\n// Adds the parser to the scene parsers.\r\nAbstractScene.AddParser(SceneComponentConstants.NAME_AUDIO, (parsedData: any, scene: Scene, container: AssetContainer, rootUrl: string) => {\r\n // TODO: add sound\r\n let loadedSounds: Sound[] = [];\r\n let loadedSound: Sound;\r\n container.sounds = container.sounds || [];\r\n if (parsedData.sounds !== undefined && parsedData.sounds !== null) {\r\n for (let index = 0, cache = parsedData.sounds.length; index < cache; index++) {\r\n const parsedSound = parsedData.sounds[index];\r\n if (Engine.audioEngine?.canUseWebAudio) {\r\n if (!parsedSound.url) {\r\n parsedSound.url = parsedSound.name;\r\n }\r\n if (!loadedSounds[parsedSound.url]) {\r\n loadedSound = Sound.Parse(parsedSound, scene, rootUrl);\r\n loadedSounds[parsedSound.url] = loadedSound;\r\n container.sounds.push(loadedSound);\r\n } else {\r\n container.sounds.push(Sound.Parse(parsedSound, scene, rootUrl, loadedSounds[parsedSound.url]));\r\n }\r\n } else {\r\n container.sounds.push(new Sound(parsedSound.name, null, scene));\r\n }\r\n }\r\n }\r\n\r\n loadedSounds = [];\r\n});\r\n\r\ndeclare module \"../abstractScene\" {\r\n export interface AbstractScene {\r\n /**\r\n * The list of sounds used in the scene.\r\n */\r\n sounds: Nullable<Array<Sound>>;\r\n }\r\n}\r\n\r\ndeclare module \"../scene\" {\r\n export interface Scene {\r\n /**\r\n * @internal\r\n * Backing field\r\n */\r\n _mainSoundTrack: SoundTrack;\r\n /**\r\n * The main sound track played by the scene.\r\n * It contains your primary collection of sounds.\r\n */\r\n mainSoundTrack: SoundTrack;\r\n /**\r\n * The list of sound tracks added to the scene\r\n * @see https://doc.babylonjs.com/features/featuresDeepDive/audio/playingSoundsMusic\r\n */\r\n soundTracks: Nullable<Array<SoundTrack>>;\r\n\r\n /**\r\n * Gets a sound using a given name\r\n * @param name defines the name to search for\r\n * @returns the found sound or null if not found at all.\r\n */\r\n getSoundByName(name: string): Nullable<Sound>;\r\n\r\n /**\r\n * Gets or sets if audio support is enabled\r\n * @see https://doc.babylonjs.com/features/featuresDeepDive/audio/playingSoundsMusic\r\n */\r\n audioEnabled: boolean;\r\n\r\n /**\r\n * Gets or sets if audio will be output to headphones\r\n * @see https://doc.babylonjs.com/features/featuresDeepDive/audio/playingSoundsMusic\r\n */\r\n headphone: boolean;\r\n\r\n /**\r\n * Gets or sets custom audio listener position provider\r\n * @see https://doc.babylonjs.com/features/featuresDeepDive/audio/playingSoundsMusic\r\n */\r\n audioListenerPositionProvider: Nullable<() => Vector3>;\r\n\r\n /**\r\n * Gets or sets custom audio listener rotation provider\r\n * @see https://doc.babylonjs.com/features/featuresDeepDive/audio/playingSoundsMusic\r\n */\r\n audioListenerRotationProvider: Nullable<() => Vector3>;\r\n\r\n /**\r\n * Gets or sets a refresh rate when using 3D audio positioning\r\n */\r\n audioPositioningRefreshRate: number;\r\n }\r\n}\r\n\r\nObject.defineProperty(Scene.prototype, \"mainSoundTrack\", {\r\n get: function (this: Scene) {\r\n let compo = this._getComponent(SceneComponentConstants.NAME_AUDIO) as AudioSceneComponent;\r\n if (!compo) {\r\n compo = new AudioSceneComponent(this);\r\n this._addComponent(compo);\r\n }\r\n\r\n if (!this._mainSoundTrack) {\r\n this._mainSoundTrack = new SoundTrack(this, { mainTrack: true });\r\n }\r\n\r\n return this._mainSoundTrack;\r\n },\r\n enumerable: true,\r\n configurable: true,\r\n});\r\n\r\nScene.prototype.getSoundByName = function (name: string): Nullable<Sound> {\r\n let index: number;\r\n for (index = 0; index < this.mainSoundTrack.soundCollection.length; index++) {\r\n if (this.mainSoundTrack.soundCollection[index].name === name) {\r\n return this.mainSoundTrack.soundCollection[index];\r\n }\r\n }\r\n\r\n if (this.soundTracks) {\r\n for (let sdIndex = 0; sdIndex < this.soundTracks.length; sdIndex++) {\r\n for (index = 0; index < this.soundTracks[sdIndex].soundCollection.length; index++) {\r\n if (this.soundTracks[sdIndex].soundCollection[index].name === name) {\r\n return this.soundTracks[sdIndex].soundCollection[index];\r\n }\r\n }\r\n }\r\n }\r\n\r\n return null;\r\n};\r\n\r\nObject.defineProperty(Scene.prototype, \"audioEnabled\", {\r\n get: function (this: Scene) {\r\n let compo = this._getComponent(SceneComponentConstants.NAME_AUDIO) as AudioSceneComponent;\r\n if (!compo) {\r\n compo = new AudioSceneComponent(this);\r\n this._addComponent(compo);\r\n }\r\n\r\n return compo.audioEnabled;\r\n },\r\n set: function (this: Scene, value: boolean) {\r\n let compo = this._getComponent(SceneComponentConstants.NAME_AUDIO) as AudioSceneComponent;\r\n if (!compo) {\r\n compo = new AudioSceneComponent(this);\r\n this._addComponent(compo);\r\n }\r\n\r\n if (value) {\r\n compo.enableAudio();\r\n } else {\r\n compo.disableAudio();\r\n }\r\n },\r\n enumerable: true,\r\n configurable: true,\r\n});\r\n\r\nObject.defineProperty(Scene.prototype, \"headphone\", {\r\n get: function (this: Scene) {\r\n let compo = this._getComponent(SceneComponentConstants.NAME_AUDIO) as AudioSceneComponent;\r\n if (!compo) {\r\n compo = new AudioSceneComponent(this);\r\n this._addComponent(compo);\r\n }\r\n\r\n return compo.headphone;\r\n },\r\n set: function (this: Scene, value: boolean) {\r\n let compo = this._getComponent(SceneComponentConstants.NAME_AUDIO) as AudioSceneComponent;\r\n if (!compo) {\r\n compo = new AudioSceneComponent(this);\r\n this._addComponent(compo);\r\n }\r\n\r\n if (value) {\r\n compo.switchAudioModeForHeadphones();\r\n } else {\r\n compo.switchAudioModeForNormalSpeakers();\r\n }\r\n },\r\n enumerable: true,\r\n configurable: true,\r\n});\r\n\r\nObject.defineProperty(Scene.prototype, \"audioListenerPositionProvider\", {\r\n get: function (this: Scene) {\r\n let compo = this._getComponent(SceneComponentConstants.NAME_AUDIO) as AudioSceneComponent;\r\n if (!compo) {\r\n compo = new AudioSceneComponent(this);\r\n this._addComponent(compo);\r\n }\r\n\r\n return compo.audioListenerPositionProvider;\r\n },\r\n set: function (this: Scene, value: () => Vector3) {\r\n let compo = this._getComponent(SceneComponentConstants.NAME_AUDIO) as AudioSceneComponent;\r\n if (!compo) {\r\n compo = new AudioSceneComponent(this);\r\n this._addComponent(compo);\r\n }\r\n\r\n if (value && typeof value !== \"function\") {\r\n throw new Error(\"The value passed to [Scene.audioListenerPositionProvider] must be a function that returns a Vector3\");\r\n } else {\r\n compo.audioListenerPositionProvider = value;\r\n }\r\n },\r\n enumerable: true,\r\n configurable: true,\r\n});\r\n\r\nObject.defineProperty(Scene.prototype, \"audioListenerRotationProvider\", {\r\n get: function (this: Scene) {\r\n let compo = this._getComponent(SceneComponentConstants.NAME_AUDIO) as AudioSceneComponent;\r\n if (!compo) {\r\n compo = new AudioSceneComponent(this);\r\n this._addComponent(compo);\r\n }\r\n\r\n return compo.audioListenerRotationProvider;\r\n },\r\n set: function (this: Scene, value: () => Vector3) {\r\n let compo = this._getComponent(SceneComponentConstants.NAME_AUDIO) as AudioSceneComponent;\r\n if (!compo) {\r\n compo = new AudioSceneComponent(this);\r\n this._addComponent(compo);\r\n }\r\n\r\n if (value && typeof value !== \"function\") {\r\n throw new Error(\"The value passed to [Scene.audioListenerRotationProvider] must be a function that returns a Vector3\");\r\n } else {\r\n compo.audioListenerRotationProvider = value;\r\n }\r\n },\r\n enumerable: true,\r\n configurable: true,\r\n});\r\n\r\nObject.defineProperty(Scene.prototype, \"audioPositioningRefreshRate\", {\r\n get: function (this: Scene) {\r\n let compo = this._getComponent(SceneComponentConstants.NAME_AUDIO) as AudioSceneComponent;\r\n if (!compo) {\r\n compo = new AudioSceneComponent(this);\r\n this._addComponent(compo);\r\n }\r\n\r\n return compo.audioPositioningRefreshRate;\r\n },\r\n set: function (this: Scene, value: number) {\r\n let compo = this._getComponent(SceneComponentConstants.NAME_AUDIO) as AudioSceneComponent;\r\n if (!compo) {\r\n compo = new AudioSceneComponent(this);\r\n this._addComponent(compo);\r\n }\r\n\r\n compo.audioPositioningRefreshRate = value;\r\n },\r\n enumerable: true,\r\n configurable: true,\r\n});\r\n\r\n/**\r\n * Defines the sound scene component responsible to manage any sounds\r\n * in a given scene.\r\n */\r\nexport class AudioSceneComponent implements ISceneSerializableComponent {\r\n private static _CameraDirection = new Vector3(0, 0, -1);\r\n\r\n /**\r\n * The component name helpful to identify the component in the list of scene components.\r\n */\r\n public readonly name = SceneComponentConstants.NAME_AUDIO;\r\n\r\n /**\r\n * The scene the component belongs to.\r\n */\r\n public scene: Scene;\r\n\r\n private _audioEnabled = true;\r\n /**\r\n * Gets whether audio is enabled or not.\r\n * Please use related enable/disable method to switch state.\r\n */\r\n public get audioEnabled(): boolean {\r\n return this._audioEnabled;\r\n }\r\n\r\n private _headphone = false;\r\n /**\r\n * Gets whether audio is outputting to headphone or not.\r\n * Please use the according Switch methods to change output.\r\n */\r\n public get headphone(): boolean {\r\n return this._headphone;\r\n }\r\n\r\n /**\r\n * Gets or sets a refresh rate when using 3D audio positioning\r\n */\r\n public audioPositioningRefreshRate = 500;\r\n\r\n /**\r\n * Gets or Sets a custom listener position for all sounds in the scene\r\n * By default, this is the position of the first active camera\r\n */\r\n public audioListenerPositionProvider: Nullable<() => Vector3> = null;\r\n\r\n /**\r\n * Gets or Sets a custom listener rotation for all sounds in the scene\r\n * By default, this is the rotation of the first active camera\r\n */\r\n public audioListenerRotationProvider: Nullable<() => Vector3> = null;\r\n\r\n /**\r\n * Creates a new instance of the component for the given scene\r\n * @param scene Defines the scene to register the component in\r\n */\r\n constructor(scene?: Nullable<Scene>) {\r\n scene = scene || EngineStore.LastCreatedScene;\r\n if (!scene) {\r\n return;\r\n }\r\n this.scene = scene;\r\n\r\n scene.soundTracks = new Array<SoundTrack>();\r\n scene.sounds = new Array<Sound>();\r\n }\r\n\r\n /**\r\n * Registers the component in a given scene\r\n */\r\n public register(): void {\r\n this.scene._afterRenderStage.registerStep(SceneComponentConstants.STEP_AFTERRENDER_AUDIO, this, this._afterRender);\r\n }\r\n\r\n /**\r\n * Rebuilds the elements related to this component in case of\r\n * context lost for instance.\r\n */\r\n public rebuild(): void {\r\n // Nothing to do here. (Not rendering related)\r\n }\r\n\r\n /**\r\n * Serializes the component data to the specified json object\r\n * @param serializationObject The object to serialize to\r\n */\r\n public serialize(serializationObject: any): void {\r\n serializationObject.sounds = [];\r\n\r\n if (this.scene.soundTracks) {\r\n for (let index = 0; index < this.scene.soundTracks.length; index++) {\r\n const soundtrack = this.scene.soundTracks[index];\r\n\r\n for (let soundId = 0; soundId < soundtrack.soundCollection.length; soundId++) {\r\n serializationObject.sounds.push(soundtrack.soundCollection[soundId].serialize());\r\n }\r\n }\r\n }\r\n }\r\n\r\n /**\r\n * Adds all the elements from the container to the scene\r\n * @param container the container holding the elements\r\n */\r\n public addFromContainer(container: AbstractScene): void {\r\n if (!container.sounds) {\r\n return;\r\n }\r\n container.sounds.forEach((sound) => {\r\n sound.play();\r\n sound.autoplay = true;\r\n this.scene.mainSoundTrack.addSound(sound);\r\n });\r\n }\r\n\r\n /**\r\n * Removes all the elements in the container from the scene\r\n * @param container contains the elements to remove\r\n * @param dispose if the removed element should be disposed (default: false)\r\n */\r\n public removeFromContainer(container: AbstractScene, dispose = false): void {\r\n if (!container.sounds) {\r\n return;\r\n }\r\n container.sounds.forEach((sound) => {\r\n sound.stop();\r\n sound.autoplay = false;\r\n this.scene.mainSoundTrack.removeSound(sound);\r\n if (dispose) {\r\n sound.dispose();\r\n }\r\n });\r\n }\r\n\r\n /**\r\n * Disposes the component and the associated resources.\r\n */\r\n public dispose(): void {\r\n const scene = this.scene;\r\n if (scene._mainSoundTrack) {\r\n scene.mainSoundTrack.dispose();\r\n }\r\n\r\n if (scene.soundTracks) {\r\n for (let scIndex = 0; scIndex < scene.soundTracks.length; scIndex++) {\r\n scene.soundTracks[scIndex].dispose();\r\n }\r\n }\r\n }\r\n\r\n /**\r\n * Disables audio in the associated scene.\r\n */\r\n public disableAudio() {\r\n const scene = this.scene;\r\n this._audioEnabled = false;\r\n\r\n if (Engine.audioEngine && Engine.audioEngine.audioContext) {\r\n Engine.audioEngine.audioContext.suspend();\r\n }\r\n\r\n let i: number;\r\n for (i = 0; i < scene.mainSoundTrack.soundCollection.length; i++) {\r\n scene.mainSoundTrack.soundCollection[i].pause();\r\n }\r\n if (scene.soundTracks) {\r\n for (i = 0; i < scene.soundTracks.length; i++) {\r\n for (let j = 0; j < scene.soundTracks[i].soundCollection.length; j++) {\r\n scene.soundTracks[i].soundCollection[j].pause();\r\n }\r\n }\r\n }\r\n }\r\n\r\n /**\r\n * Enables audio in the associated scene.\r\n */\r\n public enableAudio() {\r\n const scene = this.scene;\r\n this._audioEnabled = true;\r\n\r\n if (Engine.audioEngine && Engine.audioEngine.audioContext) {\r\n Engine.audioEngine.audioContext.resume();\r\n }\r\n\r\n let i: number;\r\n for (i = 0; i < scene.mainSoundTrack.soundCollection.length; i++) {\r\n if (scene.mainSoundTrack.soundCollection[i].isPaused) {\r\n scene.mainSoundTrack.soundCollection[i].play();\r\n }\r\n }\r\n if (scene.soundTracks) {\r\n for (i = 0; i < scene.soundTracks.length; i++) {\r\n for (let j = 0; j < scene.soundTracks[i].soundCollection.length; j++) {\r\n if (scene.soundTracks[i].soundCollection[j].isPaused) {\r\n scene.soundTracks[i].soundCollection[j].play();\r\n }\r\n }\r\n }\r\n }\r\n }\r\n\r\n /**\r\n * Switch audio to headphone output.\r\n */\r\n public switchAudioModeForHeadphones() {\r\n const scene = this.scene;\r\n this._headphone = true;\r\n\r\n scene.mainSoundTrack.switchPanningModelToHRTF();\r\n if (scene.soundTracks) {\r\n for (let i = 0; i < scene.soundTracks.length; i++) {\r\n scene.soundTracks[i].switchPanningModelToHRTF();\r\n }\r\n }\r\n }\r\n\r\n /**\r\n * Switch audio to normal speakers.\r\n */\r\n public switchAudioModeForNormalSpeakers() {\r\n const scene = this.scene;\r\n this._headphone = false;\r\n\r\n scene.mainSoundTrack.switchPanningModelToEqualPower();\r\n\r\n if (scene.soundTracks) {\r\n for (let i = 0; i < scene.soundTracks.length; i++) {\r\n scene.soundTracks[i].switchPanningModelToEqualPower();\r\n }\r\n }\r\n }\r\n\r\n private _cachedCameraDirection = new Vector3();\r\n private _cachedCameraPosition = new Vector3();\r\n private _lastCheck = 0;\r\n private _invertMatrixTemp = new Matrix();\r\n private _cameraDirectionTemp = new Vector3();\r\n\r\n private _afterRender() {\r\n const now = PrecisionDate.Now;\r\n if (this._lastCheck && now - this._lastCheck < this.audioPositioningRefreshRate) {\r\n return;\r\n }\r\n\r\n this._lastCheck = now;\r\n\r\n const scene = this.scene;\r\n if (!this._audioEnabled || !scene._mainSoundTrack || !scene.soundTracks || (scene._mainSoundTrack.soundCollection.length === 0 && scene.soundTracks.length === 1)) {\r\n return;\r\n }\r\n\r\n const audioEngine = Engine.audioEngine;\r\n\r\n if (!audioEngine) {\r\n return;\r\n }\r\n\r\n if (audioEngine.audioContext) {\r\n let listeningCamera = scene.activeCamera;\r\n if (scene.activeCameras && scene.activeCameras.length > 0) {\r\n listeningCamera = scene.activeCameras[0];\r\n }\r\n\r\n // A custom listener position provider was set\r\n // Use the users provided position instead of camera's\r\n if (this.audioListenerPositionProvider) {\r\n const position: Vector3 = this.audioListenerPositionProvider();\r\n // Set the listener position\r\n audioEngine.audioContext.listener.setPosition(position.x || 0, position.y || 0, position.z || 0);\r\n // Check if there is a listening camera\r\n } else if (listeningCamera) {\r\n // Set the listener position to the listening camera global position\r\n if (!this._cachedCameraPosition.equals(listeningCamera.globalPosition)) {\r\n this._cachedCameraPosition.copyFrom(listeningCamera.globalPosition);\r\n audioEngine.audioContext.listener.setPosition(listeningCamera.globalPosition.x, listeningCamera.globalPosition.y, listeningCamera.globalPosition.z);\r\n }\r\n }\r\n // Otherwise set the listener position to 0, 0 ,0\r\n else {\r\n // Set the listener position\r\n audioEngine.audioContext.listener.setPosition(0, 0, 0);\r\n }\r\n\r\n // A custom listener rotation provider was set\r\n // Use the users provided rotation instead of camera's\r\n if (this.audioListenerRotationProvider) {\r\n const rotation: Vector3 = this.audioListenerRotationProvider();\r\n audioEngine.audioContext.listener.setOrientation(rotation.x || 0, rotation.y || 0, rotation.z || 0, 0, 1, 0);\r\n // Check if there is a listening camera\r\n } else if (listeningCamera) {\r\n // for VR cameras\r\n if (listeningCamera.rigCameras && listeningCamera.rigCameras.length > 0) {\r\n listeningCamera = listeningCamera.rigCameras[0];\r\n }\r\n\r\n listeningCamera.getViewMatrix().invertToRef(this._invertMatrixTemp);\r\n Vector3.TransformNormalToRef(AudioSceneComponent._CameraDirection, this._invertMatrixTemp, this._cameraDirectionTemp);\r\n this._cameraDirectionTemp.normalize();\r\n // To avoid some errors on GearVR\r\n if (!isNaN(this._cameraDirectionTemp.x) && !isNaN(this._cameraDirectionTemp.y) && !isNaN(this._cameraDirectionTemp.z)) {\r\n if (!this._cachedCameraDirection.equals(this._cameraDirectionTemp)) {\r\n this._cachedCameraDirection.copyFrom(this._cameraDirectionTemp);\r\n audioEngine.audioContext.listener.setOrientation(this._cameraDirectionTemp.x, this._cameraDirectionTemp.y, this._cameraDirectionTemp.z, 0, 1, 0);\r\n }\r\n }\r\n }\r\n // Otherwise set the listener rotation to 0, 0 ,0\r\n else {\r\n // Set the listener position\r\n audioEngine.audioContext.listener.setOrientation(0, 0, 0, 0, 1, 0);\r\n }\r\n\r\n let i: number;\r\n for (i = 0; i < scene.mainSoundTrack.soundCollection.length; i++) {\r\n const sound = scene.mainSoundTrack.soundCollection[i];\r\n if (sound.useCustomAttenuation) {\r\n sound.updateDistanceFromListener();\r\n }\r\n }\r\n if (scene.soundTracks) {\r\n for (i = 0; i < scene.soundTracks.length; i++) {\r\n for (let j = 0; j < scene.soundTracks[i].soundCollection.length; j++) {\r\n const sound = scene.soundTracks[i].soundCollection[j];\r\n if (sound.useCustomAttenuation) {\r\n sound.updateDistanceFromListener();\r\n }\r\n }\r\n }\r\n }\r\n }\r\n }\r\n}\r\n\r\nSound._SceneComponentInitialization = (scene: Scene) => {\r\n let compo = scene._getComponent(SceneComponentConstants.NAME_AUDIO);\r\n if (!compo) {\r\n compo = new AudioSceneComponent(scene);\r\n scene._addComponent(compo);\r\n }\r\n};\r\n"]}
@@ -92,7 +92,13 @@ export class ArcRotateCameraMouseWheelInput {
92
92
  }
93
93
  }
94
94
  if (delta) {
95
- if (this.zoomToMouseLocation && this._hitPlane) {
95
+ if (this.zoomToMouseLocation) {
96
+ // If we are zooming to the mouse location, then we need to get the hit plane at the start of the zoom gesture if it doesn't exist
97
+ // The hit plane is normally calculated after the first motion and each time there's motion so if we don't do this first,
98
+ // the first zoom will be to the center of the screen
99
+ if (!this._hitPlane) {
100
+ this._updateHitPlane();
101
+ }
96
102
  this._zoomToMouse(delta);
97
103
  }
98
104
  else {
@@ -170,6 +176,9 @@ export class ArcRotateCameraMouseWheelInput {
170
176
  // we don't have to worry about this ray shooting off to infinity. This ray creates
171
177
  // a vector defining where we want to zoom to.
172
178
  const ray = scene.createPickingRay(scene.pointerX, scene.pointerY, Matrix.Identity(), camera, false);
179
+ // Since the camera is the origin of the picking ray, we need to offset it by the camera's offset manually
180
+ ray.origin.x -= camera.targetScreenOffset.x;
181
+ ray.origin.y -= camera.targetScreenOffset.y;
173
182
  let distance = 0;
174
183
  if (this._hitPlane) {
175
184
  distance = (_a = ray.intersectsPlane(this._hitPlane)) !== null && _a !== void 0 ? _a : 0;
@@ -1 +1 @@
1
- {"version":3,"file":"arcRotateCameraMouseWheelInput.js","sourceRoot":"","sources":["../../../../../lts/core/generated/Cameras/Inputs/arcRotateCameraMouseWheelInput.ts"],"names":[],"mappings":";AACA,OAAO,EAAE,SAAS,EAAE,MAAM,uBAAuB,CAAC;AAIlD,OAAO,EAAE,gBAAgB,EAAE,MAAM,mCAAmC,CAAC;AAErE,OAAO,EAAE,iBAAiB,EAAE,MAAM,4BAA4B,CAAC;AAC/D,OAAO,EAAE,KAAK,EAAE,MAAM,wBAAwB,CAAC;AAC/C,OAAO,EAAE,OAAO,EAAE,MAAM,EAAE,UAAU,EAAE,MAAM,yBAAyB,CAAC;AACtE,OAAO,EAAE,OAAO,EAAE,MAAM,4BAA4B,CAAC;AAErD,OAAO,EAAE,cAAc,EAAE,MAAM,gCAAgC,CAAC;AAChE,OAAO,EAAE,MAAM,EAAE,MAAM,yBAAyB,CAAC;AACjD,OAAO,EAAE,KAAK,EAAE,MAAM,kBAAkB,CAAC;AAEzC;;;;;;GAMG;AACH,MAAM,YAAY,GAAG,EAAE,CAAC;AAExB;;;GAGG;AACH,MAAM,OAAO,8BAA8B;IAA3C;QAMI;;WAEG;QAEI,mBAAc,GAAG,GAAG,CAAC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AAY;QAC7B,IAAI,IAAI,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC,CAAC,GAAG,OAAO,EAAE;YAC3B,GAAG,CAAC,CAAC,GAAG,CAAC,CAAC;SACb;QACD,IAAI,IAAI,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC,CAAC,GAAG,OAAO,EAAE;YAC3B,GAAG,CAAC,CAAC,GAAG,CAAC,CAAC;SACb;QACD,IAAI,IAAI,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC,CAAC,GAAG,OAAO,EAAE;YAC3B,GAAG,CAAC,CAAC,GAAG,CAAC,CAAC;SACb;IACL,CAAC;CACJ;AA5NG;IADC,SAAS,EAAE;sEACgB;AAO5B;IADC,SAAS,EAAE;2EACuB;AAOnC;IADC,SAAS,EAAE;4EACoB;AAgN9B,gBAAiB,CAAC,gCAAgC,CAAC,GAAG,8BAA8B,CAAC","sourcesContent":["import type { Nullable } from \"../../types\";\r\nimport { serialize } from \"../../Misc/decorators\";\r\nimport type { EventState, Observer } from \"../../Misc/observable\";\r\nimport type { ArcRotateCamera } from \"../../Cameras/arcRotateCamera\";\r\nimport type { ICameraInput } from \"../../Cameras/cameraInputsManager\";\r\nimport { CameraInputTypes } from \"../../Cameras/cameraInputsManager\";\r\nimport type { PointerInfo } from \"../../Events/pointerEvents\";\r\nimport { PointerEventTypes } from \"../../Events/pointerEvents\";\r\nimport { Plane } from \"../../Maths/math.plane\";\r\nimport { Vector3, Matrix, TmpVectors } from \"../../Maths/math.vector\";\r\nimport { Epsilon } from \"../../Maths/math.constants\";\r\nimport type { IWheelEvent } from \"../../Events/deviceInputEvents\";\r\nimport { EventConstants } from \"../../Events/deviceInputEvents\";\r\nimport { Scalar } from \"../../Maths/math.scalar\";\r\nimport { Tools } from \"../../Misc/tools\";\r\n\r\n/**\r\n * Firefox uses a different scheme to report scroll distances to other\r\n * browsers. Rather than use complicated methods to calculate the exact\r\n * multiple we need to apply, let's just cheat and use a constant.\r\n * https://developer.mozilla.org/en-US/docs/Web/API/WheelEvent/deltaMode\r\n * https://stackoverflow.com/questions/20110224/what-is-the-height-of-a-line-in-a-wheel-event-deltamode-dom-delta-line\r\n */\r\nconst ffMultiplier = 40;\r\n\r\n/**\r\n * Manage the mouse wheel inputs to control an arc rotate camera.\r\n * @see https://doc.babylonjs.com/features/featuresDeepDive/cameras/customizingCameraInputs\r\n */\r\nexport class ArcRotateCameraMouseWheelInput implements ICameraInput<ArcRotateCamera> {\r\n /**\r\n * Defines the camera the input is attached to.\r\n */\r\n public camera: ArcRotateCamera;\r\n\r\n /**\r\n * Gets or Set the mouse wheel precision or how fast is the camera zooming.\r\n */\r\n @serialize()\r\n public wheelPrecision = 3.0;\r\n\r\n /**\r\n * Gets or Set the boolean value that controls whether or not the mouse wheel\r\n * zooms to the location of the mouse pointer or not. The default is false.\r\n */\r\n @serialize()\r\n public zoomToMouseLocation = false;\r\n\r\n /**\r\n * wheelDeltaPercentage will be used instead of wheelPrecision if different from 0.\r\n * It defines the percentage of current camera.radius to use as delta when wheel is used.\r\n */\r\n @serialize()\r\n public wheelDeltaPercentage = 0;\r\n\r\n /**\r\n * If set, this function will be used to set the radius delta that will be added to the current camera radius\r\n */\r\n public customComputeDeltaFromMouseWheel: Nullable<(wheelDelta: number, input: ArcRotateCameraMouseWheelInput, event: IWheelEvent) => number> = null;\r\n\r\n private _wheel: Nullable<(p: PointerInfo, s: EventState) => void>;\r\n private _observer: Nullable<Observer<PointerInfo>>;\r\n private _hitPlane: Nullable<Plane>;\r\n\r\n protected _computeDeltaFromMouseWheelLegacyEvent(mouseWheelDelta: number, radius: number) {\r\n let delta = 0;\r\n const wheelDelta = mouseWheelDelta * 0.01 * this.wheelDeltaPercentage * radius;\r\n if (mouseWheelDelta > 0) {\r\n delta = wheelDelta / (1.0 + this.wheelDeltaPercentage);\r\n } else {\r\n delta = wheelDelta * (1.0 + this.wheelDeltaPercentage);\r\n }\r\n return delta;\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 noPreventDefault = Tools.BackCompatCameraNoPreventDefault(arguments);\r\n this._wheel = (p) => {\r\n //sanity check - this should be a PointerWheel event.\r\n if (p.type !== PointerEventTypes.POINTERWHEEL) {\r\n return;\r\n }\r\n const event = <IWheelEvent>p.event;\r\n let delta = 0;\r\n const platformScale = event.deltaMode === EventConstants.DOM_DELTA_LINE ? ffMultiplier : 1; // If this happens to be set to DOM_DELTA_LINE, adjust accordingly\r\n\r\n const wheelDelta = -(event.deltaY * platformScale);\r\n\r\n if (this.customComputeDeltaFromMouseWheel) {\r\n delta = this.customComputeDeltaFromMouseWheel(wheelDelta, this, event);\r\n } else {\r\n if (this.wheelDeltaPercentage) {\r\n delta = this._computeDeltaFromMouseWheelLegacyEvent(wheelDelta, this.camera.radius);\r\n\r\n // If zooming in, estimate the target radius and use that to compute the delta for inertia\r\n // this will stop multiple scroll events zooming in from adding too much inertia\r\n if (delta > 0) {\r\n let estimatedTargetRadius = this.camera.radius;\r\n let targetInertia = this.camera.inertialRadiusOffset + delta;\r\n for (let i = 0; i < 20 && Math.abs(targetInertia) > 0.001; i++) {\r\n estimatedTargetRadius -= targetInertia;\r\n targetInertia *= this.camera.inertia;\r\n }\r\n estimatedTargetRadius = Scalar.Clamp(estimatedTargetRadius, 0, Number.MAX_VALUE);\r\n delta = this._computeDeltaFromMouseWheelLegacyEvent(wheelDelta, estimatedTargetRadius);\r\n }\r\n } else {\r\n delta = wheelDelta / (this.wheelPrecision * 40);\r\n }\r\n }\r\n\r\n if (delta) {\r\n if (this.zoomToMouseLocation && this._hitPlane) {\r\n this._zoomToMouse(delta);\r\n } else {\r\n this.camera.inertialRadiusOffset += delta;\r\n }\r\n }\r\n\r\n if (event.preventDefault) {\r\n if (!noPreventDefault) {\r\n event.preventDefault();\r\n }\r\n }\r\n };\r\n\r\n this._observer = this.camera.getScene()._inputManager._addCameraPointerObserver(this._wheel, PointerEventTypes.POINTERWHEEL);\r\n\r\n if (this.zoomToMouseLocation) {\r\n this._inertialPanning.setAll(0);\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._observer) {\r\n this.camera.getScene()._inputManager._removeCameraPointerObserver(this._observer);\r\n this._observer = null;\r\n this._wheel = 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.zoomToMouseLocation) {\r\n return;\r\n }\r\n\r\n const camera = this.camera;\r\n const motion = 0.0 + camera.inertialAlphaOffset + camera.inertialBetaOffset + camera.inertialRadiusOffset;\r\n if (motion) {\r\n // if zooming is still happening as a result of inertia, then we also need to update\r\n // the hit plane.\r\n this._updateHitPlane();\r\n\r\n // Note we cannot use arcRotateCamera.inertialPlanning here because arcRotateCamera panning\r\n // uses a different panningInertia which could cause this panning to get out of sync with\r\n // the zooming, and for this to work they must be exactly in sync.\r\n camera.target.addInPlace(this._inertialPanning);\r\n this._inertialPanning.scaleInPlace(camera.inertia);\r\n this._zeroIfClose(this._inertialPanning);\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 \"ArcRotateCameraMouseWheelInput\";\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 \"mousewheel\";\r\n }\r\n\r\n private _updateHitPlane() {\r\n const camera = this.camera;\r\n const direction = camera.target.subtract(camera.position);\r\n this._hitPlane = Plane.FromPositionAndNormal(camera.target, direction);\r\n }\r\n\r\n // Get position on the hit plane\r\n private _getPosition(): Vector3 {\r\n const camera = this.camera;\r\n const scene = camera.getScene();\r\n\r\n // since the _hitPlane is always updated to be orthogonal to the camera position vector\r\n // we don't have to worry about this ray shooting off to infinity. This ray creates\r\n // a vector defining where we want to zoom to.\r\n const ray = scene.createPickingRay(scene.pointerX, scene.pointerY, Matrix.Identity(), camera, false);\r\n let distance = 0;\r\n if (this._hitPlane) {\r\n distance = ray.intersectsPlane(this._hitPlane) ?? 0;\r\n }\r\n\r\n // not using this ray again, so modifying its vectors here is fine\r\n return ray.origin.addInPlace(ray.direction.scaleInPlace(distance));\r\n }\r\n\r\n private _inertialPanning: Vector3 = Vector3.Zero();\r\n\r\n private _zoomToMouse(delta: number) {\r\n const camera = this.camera;\r\n const inertiaComp = 1 - camera.inertia;\r\n if (camera.lowerRadiusLimit) {\r\n const lowerLimit = camera.lowerRadiusLimit ?? 0;\r\n if (camera.radius - (camera.inertialRadiusOffset + delta) / inertiaComp < lowerLimit) {\r\n delta = (camera.radius - lowerLimit) * inertiaComp - camera.inertialRadiusOffset;\r\n }\r\n }\r\n if (camera.upperRadiusLimit) {\r\n const upperLimit = camera.upperRadiusLimit ?? 0;\r\n if (camera.radius - (camera.inertialRadiusOffset + delta) / inertiaComp > upperLimit) {\r\n delta = (camera.radius - upperLimit) * inertiaComp - camera.inertialRadiusOffset;\r\n }\r\n }\r\n\r\n const zoomDistance = delta / inertiaComp;\r\n const ratio = zoomDistance / camera.radius;\r\n const vec = this._getPosition();\r\n\r\n // Now this vector tells us how much we also need to pan the camera\r\n // so the targeted mouse location becomes the center of zooming.\r\n\r\n const directionToZoomLocation = TmpVectors.Vector3[6];\r\n vec.subtractToRef(camera.target, directionToZoomLocation);\r\n directionToZoomLocation.scaleInPlace(ratio);\r\n directionToZoomLocation.scaleInPlace(inertiaComp);\r\n this._inertialPanning.addInPlace(directionToZoomLocation);\r\n\r\n camera.inertialRadiusOffset += delta;\r\n }\r\n\r\n // Sets x y or z of passed in vector to zero if less than Epsilon.\r\n private _zeroIfClose(vec: Vector3) {\r\n if (Math.abs(vec.x) < Epsilon) {\r\n vec.x = 0;\r\n }\r\n if (Math.abs(vec.y) < Epsilon) {\r\n vec.y = 0;\r\n }\r\n if (Math.abs(vec.z) < Epsilon) {\r\n vec.z = 0;\r\n }\r\n }\r\n}\r\n\r\n(<any>CameraInputTypes)[\"ArcRotateCameraMouseWheelInput\"] = ArcRotateCameraMouseWheelInput;\r\n"]}
1
+ {"version":3,"file":"arcRotateCameraMouseWheelInput.js","sourceRoot":"","sources":["../../../../../lts/core/generated/Cameras/Inputs/arcRotateCameraMouseWheelInput.ts"],"names":[],"mappings":";AACA,OAAO,EAAE,SAAS,EAAE,MAAM,uBAAuB,CAAC;AAIlD,OAAO,EAAE,gBAAgB,EAAE,MAAM,mCAAmC,CAAC;AAErE,OAAO,EAAE,iBAAiB,EAAE,MAAM,4BAA4B,CAAC;AAC/D,OAAO,EAAE,KAAK,EAAE,MAAM,wBAAwB,CAAC;AAC/C,OAAO,EAAE,OAAO,EAAE,MAAM,EAAE,UAAU,EAAE,MAAM,yBAAyB,CAAC;AACtE,OAAO,EAAE,OAAO,EAAE,MAAM,4BAA4B,CAAC;AAErD,OAAO,EAAE,cAAc,EAAE,MAAM,gCAAgC,CAAC;AAChE,OAAO,EAAE,MAAM,EAAE,MAAM,yBAAyB,CAAC;AACjD,OAAO,EAAE,KAAK,EAAE,MAAM,kBAAkB,CAAC;AAEzC;;;;;;GAMG;AACH,MAAM,YAAY,GAAG,EAAE,CAAC;AAExB;;;GAGG;AACH,MAAM,OAAO,8BAA8B;IAA3C;QAMI;;WAEG;QAEI,mBAAc,GAAG,GAAG,CAAC;QAE5B;;;WAGG;QAEI,wBAAmB,GAAG,KAAK,CAAC;QAEnC;;;WAGG;QAEI,yBAAoB,GAAG,CAAC,CAAC;QAEhC;;WAEG;QACI,qCAAgC,GAAwG,IAAI,CAAC;QAqK5I,qBAAgB,GAAY,OAAO,CAAC,IAAI,EAAE,CAAC;IA8CvD,CAAC;IA7Ma,sCAAsC,CAAC,eAAuB,EAAE,MAAc;QACpF,IAAI,KAA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;IAC1D,YAAY,CAAC,GAAY;QAC7B,IAAI,IAAI,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC,CAAC,GAAG,OAAO,EAAE;YAC3B,GAAG,CAAC,CAAC,GAAG,CAAC,CAAC;SACb;QACD,IAAI,IAAI,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC,CAAC,GAAG,OAAO,EAAE;YAC3B,GAAG,CAAC,CAAC,GAAG,CAAC,CAAC;SACb;QACD,IAAI,IAAI,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC,CAAC,GAAG,OAAO,EAAE;YAC3B,GAAG,CAAC,CAAC,GAAG,CAAC,CAAC;SACb;IACL,CAAC;CACJ;AAtOG;IADC,SAAS,EAAE;sEACgB;AAO5B;IADC,SAAS,EAAE;2EACuB;AAOnC;IADC,SAAS,EAAE;4EACoB;AA0N9B,gBAAiB,CAAC,gCAAgC,CAAC,GAAG,8BAA8B,CAAC","sourcesContent":["import type { Nullable } from \"../../types\";\r\nimport { serialize } from \"../../Misc/decorators\";\r\nimport type { EventState, Observer } from \"../../Misc/observable\";\r\nimport type { ArcRotateCamera } from \"../../Cameras/arcRotateCamera\";\r\nimport type { ICameraInput } from \"../../Cameras/cameraInputsManager\";\r\nimport { CameraInputTypes } from \"../../Cameras/cameraInputsManager\";\r\nimport type { PointerInfo } from \"../../Events/pointerEvents\";\r\nimport { PointerEventTypes } from \"../../Events/pointerEvents\";\r\nimport { Plane } from \"../../Maths/math.plane\";\r\nimport { Vector3, Matrix, TmpVectors } from \"../../Maths/math.vector\";\r\nimport { Epsilon } from \"../../Maths/math.constants\";\r\nimport type { IWheelEvent } from \"../../Events/deviceInputEvents\";\r\nimport { EventConstants } from \"../../Events/deviceInputEvents\";\r\nimport { Scalar } from \"../../Maths/math.scalar\";\r\nimport { Tools } from \"../../Misc/tools\";\r\n\r\n/**\r\n * Firefox uses a different scheme to report scroll distances to other\r\n * browsers. Rather than use complicated methods to calculate the exact\r\n * multiple we need to apply, let's just cheat and use a constant.\r\n * https://developer.mozilla.org/en-US/docs/Web/API/WheelEvent/deltaMode\r\n * https://stackoverflow.com/questions/20110224/what-is-the-height-of-a-line-in-a-wheel-event-deltamode-dom-delta-line\r\n */\r\nconst ffMultiplier = 40;\r\n\r\n/**\r\n * Manage the mouse wheel inputs to control an arc rotate camera.\r\n * @see https://doc.babylonjs.com/features/featuresDeepDive/cameras/customizingCameraInputs\r\n */\r\nexport class ArcRotateCameraMouseWheelInput implements ICameraInput<ArcRotateCamera> {\r\n /**\r\n * Defines the camera the input is attached to.\r\n */\r\n public camera: ArcRotateCamera;\r\n\r\n /**\r\n * Gets or Set the mouse wheel precision or how fast is the camera zooming.\r\n */\r\n @serialize()\r\n public wheelPrecision = 3.0;\r\n\r\n /**\r\n * Gets or Set the boolean value that controls whether or not the mouse wheel\r\n * zooms to the location of the mouse pointer or not. The default is false.\r\n */\r\n @serialize()\r\n public zoomToMouseLocation = false;\r\n\r\n /**\r\n * wheelDeltaPercentage will be used instead of wheelPrecision if different from 0.\r\n * It defines the percentage of current camera.radius to use as delta when wheel is used.\r\n */\r\n @serialize()\r\n public wheelDeltaPercentage = 0;\r\n\r\n /**\r\n * If set, this function will be used to set the radius delta that will be added to the current camera radius\r\n */\r\n public customComputeDeltaFromMouseWheel: Nullable<(wheelDelta: number, input: ArcRotateCameraMouseWheelInput, event: IWheelEvent) => number> = null;\r\n\r\n private _wheel: Nullable<(p: PointerInfo, s: EventState) => void>;\r\n private _observer: Nullable<Observer<PointerInfo>>;\r\n private _hitPlane: Nullable<Plane>;\r\n\r\n protected _computeDeltaFromMouseWheelLegacyEvent(mouseWheelDelta: number, radius: number) {\r\n let delta = 0;\r\n const wheelDelta = mouseWheelDelta * 0.01 * this.wheelDeltaPercentage * radius;\r\n if (mouseWheelDelta > 0) {\r\n delta = wheelDelta / (1.0 + this.wheelDeltaPercentage);\r\n } else {\r\n delta = wheelDelta * (1.0 + this.wheelDeltaPercentage);\r\n }\r\n return delta;\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 noPreventDefault = Tools.BackCompatCameraNoPreventDefault(arguments);\r\n this._wheel = (p) => {\r\n //sanity check - this should be a PointerWheel event.\r\n if (p.type !== PointerEventTypes.POINTERWHEEL) {\r\n return;\r\n }\r\n const event = <IWheelEvent>p.event;\r\n let delta = 0;\r\n const platformScale = event.deltaMode === EventConstants.DOM_DELTA_LINE ? ffMultiplier : 1; // If this happens to be set to DOM_DELTA_LINE, adjust accordingly\r\n\r\n const wheelDelta = -(event.deltaY * platformScale);\r\n\r\n if (this.customComputeDeltaFromMouseWheel) {\r\n delta = this.customComputeDeltaFromMouseWheel(wheelDelta, this, event);\r\n } else {\r\n if (this.wheelDeltaPercentage) {\r\n delta = this._computeDeltaFromMouseWheelLegacyEvent(wheelDelta, this.camera.radius);\r\n\r\n // If zooming in, estimate the target radius and use that to compute the delta for inertia\r\n // this will stop multiple scroll events zooming in from adding too much inertia\r\n if (delta > 0) {\r\n let estimatedTargetRadius = this.camera.radius;\r\n let targetInertia = this.camera.inertialRadiusOffset + delta;\r\n for (let i = 0; i < 20 && Math.abs(targetInertia) > 0.001; i++) {\r\n estimatedTargetRadius -= targetInertia;\r\n targetInertia *= this.camera.inertia;\r\n }\r\n estimatedTargetRadius = Scalar.Clamp(estimatedTargetRadius, 0, Number.MAX_VALUE);\r\n delta = this._computeDeltaFromMouseWheelLegacyEvent(wheelDelta, estimatedTargetRadius);\r\n }\r\n } else {\r\n delta = wheelDelta / (this.wheelPrecision * 40);\r\n }\r\n }\r\n\r\n if (delta) {\r\n if (this.zoomToMouseLocation) {\r\n // If we are zooming to the mouse location, then we need to get the hit plane at the start of the zoom gesture if it doesn't exist\r\n // The hit plane is normally calculated after the first motion and each time there's motion so if we don't do this first,\r\n // the first zoom will be to the center of the screen\r\n if (!this._hitPlane) {\r\n this._updateHitPlane();\r\n }\r\n\r\n this._zoomToMouse(delta);\r\n } else {\r\n this.camera.inertialRadiusOffset += delta;\r\n }\r\n }\r\n\r\n if (event.preventDefault) {\r\n if (!noPreventDefault) {\r\n event.preventDefault();\r\n }\r\n }\r\n };\r\n\r\n this._observer = this.camera.getScene()._inputManager._addCameraPointerObserver(this._wheel, PointerEventTypes.POINTERWHEEL);\r\n\r\n if (this.zoomToMouseLocation) {\r\n this._inertialPanning.setAll(0);\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._observer) {\r\n this.camera.getScene()._inputManager._removeCameraPointerObserver(this._observer);\r\n this._observer = null;\r\n this._wheel = 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.zoomToMouseLocation) {\r\n return;\r\n }\r\n\r\n const camera = this.camera;\r\n const motion = 0.0 + camera.inertialAlphaOffset + camera.inertialBetaOffset + camera.inertialRadiusOffset;\r\n if (motion) {\r\n // if zooming is still happening as a result of inertia, then we also need to update\r\n // the hit plane.\r\n this._updateHitPlane();\r\n\r\n // Note we cannot use arcRotateCamera.inertialPlanning here because arcRotateCamera panning\r\n // uses a different panningInertia which could cause this panning to get out of sync with\r\n // the zooming, and for this to work they must be exactly in sync.\r\n camera.target.addInPlace(this._inertialPanning);\r\n this._inertialPanning.scaleInPlace(camera.inertia);\r\n this._zeroIfClose(this._inertialPanning);\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 \"ArcRotateCameraMouseWheelInput\";\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 \"mousewheel\";\r\n }\r\n\r\n private _updateHitPlane() {\r\n const camera = this.camera;\r\n const direction = camera.target.subtract(camera.position);\r\n this._hitPlane = Plane.FromPositionAndNormal(camera.target, direction);\r\n }\r\n\r\n // Get position on the hit plane\r\n private _getPosition(): Vector3 {\r\n const camera = this.camera;\r\n const scene = camera.getScene();\r\n\r\n // since the _hitPlane is always updated to be orthogonal to the camera position vector\r\n // we don't have to worry about this ray shooting off to infinity. This ray creates\r\n // a vector defining where we want to zoom to.\r\n const ray = scene.createPickingRay(scene.pointerX, scene.pointerY, Matrix.Identity(), camera, false);\r\n // Since the camera is the origin of the picking ray, we need to offset it by the camera's offset manually\r\n ray.origin.x -= camera.targetScreenOffset.x;\r\n ray.origin.y -= camera.targetScreenOffset.y;\r\n let distance = 0;\r\n if (this._hitPlane) {\r\n distance = ray.intersectsPlane(this._hitPlane) ?? 0;\r\n }\r\n\r\n // not using this ray again, so modifying its vectors here is fine\r\n return ray.origin.addInPlace(ray.direction.scaleInPlace(distance));\r\n }\r\n\r\n private _inertialPanning: Vector3 = Vector3.Zero();\r\n\r\n private _zoomToMouse(delta: number) {\r\n const camera = this.camera;\r\n const inertiaComp = 1 - camera.inertia;\r\n if (camera.lowerRadiusLimit) {\r\n const lowerLimit = camera.lowerRadiusLimit ?? 0;\r\n if (camera.radius - (camera.inertialRadiusOffset + delta) / inertiaComp < lowerLimit) {\r\n delta = (camera.radius - lowerLimit) * inertiaComp - camera.inertialRadiusOffset;\r\n }\r\n }\r\n if (camera.upperRadiusLimit) {\r\n const upperLimit = camera.upperRadiusLimit ?? 0;\r\n if (camera.radius - (camera.inertialRadiusOffset + delta) / inertiaComp > upperLimit) {\r\n delta = (camera.radius - upperLimit) * inertiaComp - camera.inertialRadiusOffset;\r\n }\r\n }\r\n\r\n const zoomDistance = delta / inertiaComp;\r\n const ratio = zoomDistance / camera.radius;\r\n const vec = this._getPosition();\r\n\r\n // Now this vector tells us how much we also need to pan the camera\r\n // so the targeted mouse location becomes the center of zooming.\r\n\r\n const directionToZoomLocation = TmpVectors.Vector3[6];\r\n vec.subtractToRef(camera.target, directionToZoomLocation);\r\n directionToZoomLocation.scaleInPlace(ratio);\r\n directionToZoomLocation.scaleInPlace(inertiaComp);\r\n this._inertialPanning.addInPlace(directionToZoomLocation);\r\n\r\n camera.inertialRadiusOffset += delta;\r\n }\r\n\r\n // Sets x y or z of passed in vector to zero if less than Epsilon.\r\n private _zeroIfClose(vec: Vector3) {\r\n if (Math.abs(vec.x) < Epsilon) {\r\n vec.x = 0;\r\n }\r\n if (Math.abs(vec.y) < Epsilon) {\r\n vec.y = 0;\r\n }\r\n if (Math.abs(vec.z) < Epsilon) {\r\n vec.z = 0;\r\n }\r\n }\r\n}\r\n\r\n(<any>CameraInputTypes)[\"ArcRotateCameraMouseWheelInput\"] = ArcRotateCameraMouseWheelInput;\r\n"]}
package/Culling/ray.d.ts CHANGED
@@ -83,7 +83,7 @@ export declare class Ray {
83
83
  */
84
84
  intersectsAxis(axis: string, offset?: number): Nullable<Vector3>;
85
85
  /**
86
- * Checks if ray intersects a mesh
86
+ * Checks if ray intersects a mesh. The ray is defined in WORLD space.
87
87
  * @param mesh the mesh to check
88
88
  * @param fastCheck defines if the first intersection will be used (and not the closest)
89
89
  * @returns picking info of the intersection
package/Culling/ray.js CHANGED
@@ -252,7 +252,7 @@ export class Ray {
252
252
  }
253
253
  }
254
254
  /**
255
- * Checks if ray intersects a mesh
255
+ * Checks if ray intersects a mesh. The ray is defined in WORLD space.
256
256
  * @param mesh the mesh to check
257
257
  * @param fastCheck defines if the first intersection will be used (and not the closest)
258
258
  * @returns picking info of the intersection