@babylonjs/core 8.12.1 → 8.13.1
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.
- package/AudioV2/abstractAudio/abstractAudioBus.d.ts +4 -21
- package/AudioV2/abstractAudio/abstractAudioBus.js +2 -34
- package/AudioV2/abstractAudio/abstractAudioBus.js.map +1 -1
- package/AudioV2/abstractAudio/abstractAudioOutNode.d.ts +40 -0
- package/AudioV2/abstractAudio/abstractAudioOutNode.js +56 -0
- package/AudioV2/abstractAudio/abstractAudioOutNode.js.map +1 -0
- package/AudioV2/abstractAudio/abstractSoundSource.d.ts +5 -16
- package/AudioV2/abstractAudio/abstractSoundSource.js +2 -27
- package/AudioV2/abstractAudio/abstractSoundSource.js.map +1 -1
- package/AudioV2/abstractAudio/audioEngineV2.d.ts +13 -0
- package/AudioV2/abstractAudio/audioEngineV2.js +4 -0
- package/AudioV2/abstractAudio/audioEngineV2.js.map +1 -1
- package/AudioV2/abstractAudio/index.d.ts +1 -0
- package/AudioV2/abstractAudio/index.js +1 -0
- package/AudioV2/abstractAudio/index.js.map +1 -1
- package/AudioV2/abstractAudio/subNodes/volumeAudioSubNode.d.ts +3 -0
- package/AudioV2/abstractAudio/subNodes/volumeAudioSubNode.js.map +1 -1
- package/AudioV2/audioParameter.d.ts +31 -0
- package/AudioV2/audioParameter.js +19 -0
- package/AudioV2/audioParameter.js.map +1 -0
- package/AudioV2/audioUtils.d.ts +3 -0
- package/AudioV2/audioUtils.js +61 -0
- package/AudioV2/audioUtils.js.map +1 -1
- package/AudioV2/index.d.ts +1 -0
- package/AudioV2/index.js +1 -0
- package/AudioV2/index.js.map +1 -1
- package/AudioV2/webAudio/components/webAudioParameterComponent.d.ts +37 -0
- package/AudioV2/webAudio/components/webAudioParameterComponent.js +89 -0
- package/AudioV2/webAudio/components/webAudioParameterComponent.js.map +1 -0
- package/AudioV2/webAudio/subNodes/spatialWebAudioSubNode.d.ts +8 -0
- package/AudioV2/webAudio/subNodes/spatialWebAudioSubNode.js +24 -6
- package/AudioV2/webAudio/subNodes/spatialWebAudioSubNode.js.map +1 -1
- package/AudioV2/webAudio/subNodes/stereoWebAudioSubNode.d.ts +2 -0
- package/AudioV2/webAudio/subNodes/stereoWebAudioSubNode.js +9 -4
- package/AudioV2/webAudio/subNodes/stereoWebAudioSubNode.js.map +1 -1
- package/AudioV2/webAudio/subNodes/volumeWebAudioSubNode.d.ts +7 -1
- package/AudioV2/webAudio/subNodes/volumeWebAudioSubNode.js +14 -5
- package/AudioV2/webAudio/subNodes/volumeWebAudioSubNode.js.map +1 -1
- package/AudioV2/webAudio/subProperties/spatialWebAudioListener.js +92 -30
- package/AudioV2/webAudio/subProperties/spatialWebAudioListener.js.map +1 -1
- package/AudioV2/webAudio/webAudioEngine.d.ts +4 -2
- package/AudioV2/webAudio/webAudioEngine.js +9 -4
- package/AudioV2/webAudio/webAudioEngine.js.map +1 -1
- package/AudioV2/webAudio/webAudioMainOut.d.ts +6 -2
- package/AudioV2/webAudio/webAudioMainOut.js +15 -10
- package/AudioV2/webAudio/webAudioMainOut.js.map +1 -1
- package/AudioV2/webAudio/webAudioStaticSound.d.ts +4 -2
- package/AudioV2/webAudio/webAudioStaticSound.js +17 -14
- package/AudioV2/webAudio/webAudioStaticSound.js.map +1 -1
- package/BakedVertexAnimation/vertexAnimationBaker.d.ts +10 -2
- package/BakedVertexAnimation/vertexAnimationBaker.js +48 -2
- package/BakedVertexAnimation/vertexAnimationBaker.js.map +1 -1
- package/Behaviors/Meshes/pointerDragBehavior.d.ts +5 -0
- package/Behaviors/Meshes/pointerDragBehavior.js +7 -1
- package/Behaviors/Meshes/pointerDragBehavior.js.map +1 -1
- package/Cameras/camera.d.ts +6 -0
- package/Cameras/camera.js +8 -0
- package/Cameras/camera.js.map +1 -1
- package/Engines/abstractEngine.js +2 -2
- package/Engines/abstractEngine.js.map +1 -1
- package/FlowGraph/Blocks/Data/Math/flowGraphMathBlocks.d.ts +1 -1
- package/FlowGraph/Blocks/Data/Math/flowGraphMathBlocks.js +27 -18
- package/FlowGraph/Blocks/Data/Math/flowGraphMathBlocks.js.map +1 -1
- package/FlowGraph/Blocks/Data/Math/flowGraphVectorMathBlocks.d.ts +55 -3
- package/FlowGraph/Blocks/Data/Math/flowGraphVectorMathBlocks.js +83 -2
- package/FlowGraph/Blocks/Data/Math/flowGraphVectorMathBlocks.js.map +1 -1
- package/FlowGraph/Blocks/Event/flowGraphMeshPickEventBlock.js.map +1 -1
- package/FlowGraph/Blocks/Event/flowGraphReceiveCustomEventBlock.js.map +1 -1
- package/FlowGraph/Blocks/Event/flowGraphSceneTickEventBlock.js.map +1 -1
- package/FlowGraph/Blocks/Execution/Animation/flowGraphPlayAnimationBlock.js.map +1 -1
- package/FlowGraph/Blocks/Execution/ControlFlow/flowGraphSetDelayBlock.js.map +1 -1
- package/FlowGraph/Blocks/Execution/flowGraphSetPropertyBlock.d.ts +1 -0
- package/FlowGraph/Blocks/Execution/flowGraphSetPropertyBlock.js +23 -2
- package/FlowGraph/Blocks/Execution/flowGraphSetPropertyBlock.js.map +1 -1
- package/FlowGraph/Blocks/Execution/flowGraphSetVariableBlock.js +5 -5
- package/FlowGraph/Blocks/Execution/flowGraphSetVariableBlock.js.map +1 -1
- package/FlowGraph/Blocks/flowGraphBlockFactory.js +10 -0
- package/FlowGraph/Blocks/flowGraphBlockFactory.js.map +1 -1
- package/FlowGraph/Blocks/flowGraphBlockNames.d.ts +5 -0
- package/FlowGraph/Blocks/flowGraphBlockNames.js +5 -0
- package/FlowGraph/Blocks/flowGraphBlockNames.js.map +1 -1
- package/FlowGraph/flowGraphRichTypes.js +10 -8
- package/FlowGraph/flowGraphRichTypes.js.map +1 -1
- package/FlowGraph/utils.d.ts +3 -3
- package/FlowGraph/utils.js +5 -4
- package/FlowGraph/utils.js.map +1 -1
- package/Gizmos/boundingBoxGizmo.d.ts +6 -0
- package/Gizmos/boundingBoxGizmo.js +16 -1
- package/Gizmos/boundingBoxGizmo.js.map +1 -1
- package/Instrumentation/engineInstrumentation.d.ts +2 -2
- package/Instrumentation/engineInstrumentation.js +5 -0
- package/Instrumentation/engineInstrumentation.js.map +1 -1
- package/Instrumentation/sceneInstrumentation.d.ts +1 -0
- package/Instrumentation/sceneInstrumentation.js +5 -0
- package/Instrumentation/sceneInstrumentation.js.map +1 -1
- package/Materials/GaussianSplatting/gaussianSplattingMaterial.js +2 -0
- package/Materials/GaussianSplatting/gaussianSplattingMaterial.js.map +1 -1
- package/Materials/Node/Blocks/Dual/smartFilterTextureBlock.d.ts +2 -5
- package/Materials/Node/Blocks/Dual/smartFilterTextureBlock.js +8 -71
- package/Materials/Node/Blocks/Dual/smartFilterTextureBlock.js.map +1 -1
- package/Materials/Node/Blocks/Fragment/fragmentOutputBlock.d.ts +2 -0
- package/Materials/Node/Blocks/Fragment/fragmentOutputBlock.js +7 -8
- package/Materials/Node/Blocks/Fragment/fragmentOutputBlock.js.map +1 -1
- package/Materials/Node/Blocks/Fragment/index.d.ts +1 -0
- package/Materials/Node/Blocks/Fragment/index.js +1 -0
- package/Materials/Node/Blocks/Fragment/index.js.map +1 -1
- package/Materials/Node/Blocks/Fragment/smartFilterFragmentOutputBlock.d.ts +29 -0
- package/Materials/Node/Blocks/Fragment/smartFilterFragmentOutputBlock.js +100 -0
- package/Materials/Node/Blocks/Fragment/smartFilterFragmentOutputBlock.js.map +1 -0
- package/Materials/Node/Blocks/GaussianSplatting/gaussianSplattingBlock.js +3 -1
- package/Materials/Node/Blocks/GaussianSplatting/gaussianSplattingBlock.js.map +1 -1
- package/Materials/Node/Blocks/PBR/pbrMetallicRoughnessBlock.js +1 -0
- package/Materials/Node/Blocks/PBR/pbrMetallicRoughnessBlock.js.map +1 -1
- package/Materials/Node/Blocks/PBR/subSurfaceBlock.js +5 -5
- package/Materials/Node/Blocks/PBR/subSurfaceBlock.js.map +1 -1
- package/Materials/Node/nodeMaterial.js +1 -1
- package/Materials/Node/nodeMaterial.js.map +1 -1
- package/Materials/Node/nodeMaterialBuildState.d.ts +0 -2
- package/Materials/Node/nodeMaterialBuildState.js +0 -2
- package/Materials/Node/nodeMaterialBuildState.js.map +1 -1
- package/Materials/Node/nodeMaterialDefault.js +2 -1
- package/Materials/Node/nodeMaterialDefault.js.map +1 -1
- package/Materials/PBR/pbrSubSurfaceConfiguration.d.ts +10 -3
- package/Materials/PBR/pbrSubSurfaceConfiguration.js +16 -5
- package/Materials/PBR/pbrSubSurfaceConfiguration.js.map +1 -1
- package/Maths/math.vector.d.ts +14 -0
- package/Maths/math.vector.functions.d.ts +25 -1
- package/Maths/math.vector.functions.js +35 -0
- package/Maths/math.vector.functions.js.map +1 -1
- package/Maths/math.vector.js +28 -0
- package/Maths/math.vector.js.map +1 -1
- package/Meshes/GaussianSplatting/gaussianSplattingMesh.d.ts +6 -0
- package/Meshes/GaussianSplatting/gaussianSplattingMesh.js +11 -4
- package/Meshes/GaussianSplatting/gaussianSplattingMesh.js.map +1 -1
- package/Meshes/csg2.js +1 -1
- package/Meshes/csg2.js.map +1 -1
- package/Meshes/linesMesh.d.ts +4 -12
- package/Meshes/linesMesh.js +15 -24
- package/Meshes/linesMesh.js.map +1 -1
- package/Misc/environmentTextureTools.d.ts +4 -1
- package/Misc/environmentTextureTools.js +9 -2
- package/Misc/environmentTextureTools.js.map +1 -1
- package/Morph/morphTargetManager.d.ts +5 -0
- package/Morph/morphTargetManager.js +8 -0
- package/Morph/morphTargetManager.js.map +1 -1
- package/Particles/Node/Blocks/particleDebugBlock.d.ts +6 -0
- package/Particles/Node/Blocks/particleDebugBlock.js +10 -0
- package/Particles/Node/Blocks/particleDebugBlock.js.map +1 -1
- package/Shaders/ShadersInclude/hdrFilteringFunctions.js +16 -2
- package/Shaders/ShadersInclude/hdrFilteringFunctions.js.map +1 -1
- package/Shaders/gaussianSplatting.vertex.js +2 -3
- package/Shaders/gaussianSplatting.vertex.js.map +1 -1
- package/ShadersWGSL/ShadersInclude/hdrFilteringFunctions.js +17 -2
- package/ShadersWGSL/ShadersInclude/hdrFilteringFunctions.js.map +1 -1
- package/ShadersWGSL/gaussianSplatting.vertex.js +2 -3
- package/ShadersWGSL/gaussianSplatting.vertex.js.map +1 -1
- package/XR/features/WebXRControllerPointerSelection.js +3 -3
- package/XR/features/WebXRControllerPointerSelection.js.map +1 -1
- package/package.json +1 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"webAudioStaticSound.js","sourceRoot":"","sources":["../../../../../dev/core/src/AudioV2/webAudio/webAudioStaticSound.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,WAAW,EAAE,MAAM,8BAA8B,CAAC;AAE3D,OAAO,EAAE,iBAAiB,EAAE,MAAM,oCAAoC,CAAC;AAEvE,OAAO,EAAE,oBAAoB,EAAE,MAAM,sCAAsC,CAAC;AAC5E,OAAO,EAAE,uBAAuB,EAAE,MAAM,qDAAqD,CAAC;AAE9F,OAAO,EAAE,YAAY,EAAE,MAAM,4CAA4C,CAAC;AAC1E,OAAO,EAAE,SAAS,EAAE,mBAAmB,EAAE,MAAM,eAAe,CAAC;AAE/D,OAAO,EAAE,4BAA4B,EAAE,MAAM,wCAAwC,CAAC;AACtF,OAAO,EAAE,gBAAgB,EAAE,MAAM,iCAAiC,CAAC;AAMnE,gBAAgB;AAChB,MAAM,OAAO,oBAAqB,SAAQ,WAAW;IAgBjD,gBAAgB;IAChB,YAAmB,IAAY,EAAE,MAAuB,EAAE,OAAqC;QAC3F,KAAK,CAAC,IAAI,EAAE,MAAM,CAAC,CAAC;QAhBhB,aAAQ,GAA+B,IAAI,CAAC;QACnC,uBAAkB,GAAY,IAAI,CAAC;QACnC,0BAAqB,GAAW,CAAC,CAAC;QAC3C,YAAO,GAA2B,IAAI,CAAC;QAe3C,IAAI,OAAO,OAAO,CAAC,iBAAiB,KAAK,SAAS,EAAE,CAAC;YACjD,IAAI,CAAC,kBAAkB,GAAG,OAAO,CAAC,iBAAiB,CAAC;QACxD,CAAC;QAED,IAAI,OAAO,OAAO,CAAC,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CAAC,KAAK,GAAG,IAAI,CAAC,MAAM,CAAC,KAAK,CAAC;QACtC,IAAI,CAAC,IAAI,GAAG,IAAI,CAAC,QAAQ,CAAC,IAAI,CAAC;QAC/B,IAAI,CAAC,OAAO,GAAG,IAAI,CAAC,QAAQ,CAAC,OAAO,CAAC;QACrC,IAAI,CAAC,SAAS,GAAG,IAAI,CAAC,QAAQ,CAAC,SAAS,CAAC;QACzC,IAAI,CAAC,YAAY,CAAC,KAAK,GAAG,IAAI,CAAC,MAAM,CAAC,YAAY,CAAC;IACvD,CAAC;CAaJ","sourcesContent":["import type { Nullable } from \"../../types\";\nimport type { AbstractAudioNode } from \"../abstractAudio/abstractAudioNode\";\nimport type { IStaticSoundCloneOptions, IStaticSoundOptions, IStaticSoundPlayOptions, IStaticSoundStopOptions, IStaticSoundStoredOptions } from \"../abstractAudio/staticSound\";\nimport { StaticSound } from \"../abstractAudio/staticSound\";\nimport type { IStaticSoundBufferCloneOptions, IStaticSoundBufferOptions } from \"../abstractAudio/staticSoundBuffer\";\nimport { StaticSoundBuffer } from \"../abstractAudio/staticSoundBuffer\";\nimport type { IStaticSoundInstanceOptions } from \"../abstractAudio/staticSoundInstance\";\nimport { _StaticSoundInstance } from \"../abstractAudio/staticSoundInstance\";\nimport { _HasSpatialAudioOptions } from \"../abstractAudio/subProperties/abstractSpatialAudio\";\nimport type { _SpatialAudio } from \"../abstractAudio/subProperties/spatialAudio\";\nimport { _StereoAudio } from \"../abstractAudio/subProperties/stereoAudio\";\nimport { _CleanUrl, _FileExtensionRegex } from \"../audioUtils\";\nimport { SoundState } from \"../soundState\";\nimport { _WebAudioBusAndSoundSubGraph } from \"./subNodes/webAudioBusAndSoundSubGraph\";\nimport { _SpatialWebAudio } from \"./subProperties/spatialWebAudio\";\nimport type { _WebAudioEngine } from \"./webAudioEngine\";\nimport type { IWebAudioInNode, IWebAudioOutNode, IWebAudioSuperNode } from \"./webAudioNode\";\n\ntype StaticSoundSourceType = ArrayBuffer | AudioBuffer | StaticSoundBuffer | string | string[];\n\n/** @internal */\nexport class _WebAudioStaticSound extends StaticSound implements IWebAudioSuperNode {\n private _buffer: _WebAudioStaticSoundBuffer;\n private _spatial: Nullable<_SpatialWebAudio> = null;\n private readonly _spatialAutoUpdate: boolean = true;\n private readonly _spatialMinUpdateTime: number = 0;\n private _stereo: Nullable<_StereoAudio> = null;\n\n protected override readonly _options: IStaticSoundStoredOptions;\n protected _subGraph: _WebAudioBusAndSoundSubGraph;\n\n /** @internal */\n public _audioContext: AudioContext | OfflineAudioContext;\n\n /** @internal */\n public override readonly engine: _WebAudioEngine;\n\n /** @internal */\n public constructor(name: string, engine: _WebAudioEngine, options: Partial<IStaticSoundOptions>) {\n super(name, engine);\n\n if (typeof options.spatialAutoUpdate === \"boolean\") {\n this._spatialAutoUpdate = options.spatialAutoUpdate;\n }\n\n if (typeof options.spatialMinUpdateTime === \"number\") {\n this._spatialMinUpdateTime = options.spatialMinUpdateTime;\n }\n\n this._options = {\n autoplay: options.autoplay ?? false,\n duration: options.duration ?? 0,\n loop: options.loop ?? false,\n loopEnd: options.loopEnd ?? 0,\n loopStart: options.loopStart ?? 0,\n maxInstances: options.maxInstances ?? Infinity,\n pitch: options.pitch ?? 0,\n playbackRate: options.playbackRate ?? 1,\n startOffset: options.startOffset ?? 0,\n };\n\n this._subGraph = new _WebAudioStaticSound._SubGraph(this);\n }\n\n /** @internal */\n public async _initAsync(source: StaticSoundSourceType, options: Partial<IStaticSoundOptions>): Promise<void> {\n this._audioContext = this.engine._audioContext;\n\n if (source instanceof _WebAudioStaticSoundBuffer) {\n this._buffer = source;\n } else if (typeof source === \"string\" || Array.isArray(source) || source instanceof ArrayBuffer || source instanceof AudioBuffer) {\n this._buffer = (await this.engine.createSoundBufferAsync(source, options)) as _WebAudioStaticSoundBuffer;\n }\n\n if (options.outBus) {\n this.outBus = options.outBus;\n } else if (options.outBusAutoDefault !== false) {\n await this.engine.isReadyPromise;\n this.outBus = this.engine.defaultMainBus;\n }\n\n await this._subGraph.initAsync(options);\n\n if (_HasSpatialAudioOptions(options)) {\n this._initSpatialProperty();\n }\n\n if (options.autoplay) {\n this.play();\n }\n\n this.engine._addNode(this);\n }\n\n /** @internal */\n public get buffer(): _WebAudioStaticSoundBuffer {\n return this._buffer;\n }\n\n /** @internal */\n public get _inNode() {\n return this._subGraph._inNode;\n }\n\n /** @internal */\n public get _outNode() {\n return this._subGraph._outNode;\n }\n\n /** @internal */\n public override get spatial(): _SpatialAudio {\n if (this._spatial) {\n return this._spatial;\n }\n return this._initSpatialProperty();\n }\n\n /** @internal */\n public override get stereo(): _StereoAudio {\n return this._stereo ?? (this._stereo = new _StereoAudio(this._subGraph));\n }\n\n /** @internal */\n public override async cloneAsync(options: Nullable<Partial<IStaticSoundCloneOptions>> = null): Promise<StaticSound> {\n const clone = await this.engine.createSoundAsync(this.name, options?.cloneBuffer ? this.buffer.clone() : this.buffer, this._options);\n\n clone.outBus = options?.outBus ? options.outBus : this.outBus;\n\n return clone;\n }\n\n /** @internal */\n public override dispose(): void {\n super.dispose();\n\n this._spatial?.dispose();\n this._spatial = null;\n\n this._stereo = null;\n\n this._subGraph.dispose();\n\n this.engine._removeNode(this);\n }\n\n /** @internal */\n public getClassName(): string {\n return \"_WebAudioStaticSound\";\n }\n\n protected _createInstance(): _WebAudioStaticSoundInstance {\n return new _WebAudioStaticSoundInstance(this, this._options);\n }\n\n protected override _connect(node: IWebAudioInNode): boolean {\n const connected = super._connect(node);\n\n if (!connected) {\n return false;\n }\n\n // If the wrapped node is not available now, it will be connected later by the subgraph.\n if (node._inNode) {\n this._outNode?.connect(node._inNode);\n }\n\n return true;\n }\n\n protected override _disconnect(node: IWebAudioInNode): boolean {\n const disconnected = super._disconnect(node);\n\n if (!disconnected) {\n return false;\n }\n\n if (node._inNode) {\n this._outNode?.disconnect(node._inNode);\n }\n\n return true;\n }\n\n private _initSpatialProperty(): _SpatialAudio {\n if (!this._spatial) {\n this._spatial = new _SpatialWebAudio(this._subGraph, this._spatialAutoUpdate, this._spatialMinUpdateTime);\n }\n\n return this._spatial;\n }\n\n private static _SubGraph = class extends _WebAudioBusAndSoundSubGraph {\n protected override _owner: _WebAudioStaticSound;\n\n protected get _downstreamNodes(): Nullable<Set<AbstractAudioNode>> {\n return this._owner._downstreamNodes ?? null;\n }\n\n protected get _upstreamNodes(): Nullable<Set<AbstractAudioNode>> {\n return this._owner._upstreamNodes ?? null;\n }\n };\n}\n\n/** @internal */\nexport class _WebAudioStaticSoundBuffer extends StaticSoundBuffer {\n /** @internal */\n public _audioBuffer: AudioBuffer;\n\n /** @internal */\n public override readonly engine: _WebAudioEngine;\n\n /** @internal */\n public constructor(engine: _WebAudioEngine) {\n super(engine);\n }\n\n public async _initAsync(source: StaticSoundSourceType, options: Partial<IStaticSoundBufferOptions>): Promise<void> {\n if (source instanceof AudioBuffer) {\n this._audioBuffer = source;\n } else if (typeof source === \"string\") {\n await this._initFromUrlAsync(source);\n } else if (Array.isArray(source)) {\n await this._initFromUrlsAsync(source, options.skipCodecCheck ?? false);\n } else if (source instanceof ArrayBuffer) {\n await this._initFromArrayBufferAsync(source);\n }\n }\n\n /** @internal */\n public get channelCount(): number {\n return this._audioBuffer.numberOfChannels;\n }\n\n /** @internal */\n public get duration(): number {\n return this._audioBuffer.duration;\n }\n\n /** @internal */\n public get length(): number {\n return this._audioBuffer.length;\n }\n\n /** @internal */\n public get sampleRate(): number {\n return this._audioBuffer.sampleRate;\n }\n\n /** @internal */\n public override clone(options: Nullable<Partial<IStaticSoundBufferCloneOptions>> = null): StaticSoundBuffer {\n const audioBuffer = new AudioBuffer({\n length: this._audioBuffer.length,\n numberOfChannels: this._audioBuffer.numberOfChannels,\n sampleRate: this._audioBuffer.sampleRate,\n });\n\n for (let i = 0; i < this._audioBuffer.numberOfChannels; i++) {\n audioBuffer.copyToChannel(this._audioBuffer.getChannelData(i), i);\n }\n\n const buffer = new _WebAudioStaticSoundBuffer(this.engine);\n buffer._audioBuffer = audioBuffer;\n buffer.name = options?.name ? options.name : this.name;\n\n return buffer;\n }\n\n private async _initFromArrayBufferAsync(arrayBuffer: ArrayBuffer): Promise<void> {\n this._audioBuffer = await this.engine._audioContext.decodeAudioData(arrayBuffer);\n }\n\n private async _initFromUrlAsync(url: string): Promise<void> {\n url = _CleanUrl(url);\n await this._initFromArrayBufferAsync(await (await fetch(url)).arrayBuffer());\n }\n\n private async _initFromUrlsAsync(urls: string[], skipCodecCheck: boolean): Promise<void> {\n for (const url of urls) {\n if (skipCodecCheck) {\n // eslint-disable-next-line no-await-in-loop\n await this._initFromUrlAsync(url);\n } else {\n const matches = url.match(_FileExtensionRegex);\n const format = matches?.at(1);\n if (format && this.engine.isFormatValid(format)) {\n try {\n // eslint-disable-next-line no-await-in-loop\n await this._initFromUrlAsync(url);\n } catch {\n if (format && 0 < format.length) {\n this.engine.flagInvalidFormat(format);\n }\n }\n }\n }\n\n if (this._audioBuffer) {\n break;\n }\n }\n }\n}\n\n/** @internal */\nclass _WebAudioStaticSoundInstance extends _StaticSoundInstance implements IWebAudioOutNode {\n private _enginePlayTime: number = 0;\n private _enginePauseTime: number = 0;\n private _sourceNode: Nullable<AudioBufferSourceNode> = null;\n private _volumeNode: GainNode;\n\n protected override readonly _options: IStaticSoundInstanceOptions;\n protected override _sound: _WebAudioStaticSound;\n\n /** @internal */\n public override readonly engine: _WebAudioEngine;\n\n public constructor(sound: _WebAudioStaticSound, options: IStaticSoundInstanceOptions) {\n super(sound);\n\n this._options = options;\n\n this._volumeNode = new GainNode(sound._audioContext);\n this._initSourceNode();\n }\n\n /** @internal */\n public get currentTime(): number {\n if (this._state === SoundState.Stopped) {\n return 0;\n }\n\n const timeSinceLastStart = this._state === SoundState.Paused ? 0 : this.engine.currentTime - this._enginePlayTime;\n return this._enginePauseTime + timeSinceLastStart + this._options.startOffset;\n }\n\n public set currentTime(value: number) {\n const restart = this._state === SoundState.Starting || this._state === SoundState.Started;\n\n if (restart) {\n this.stop();\n this._deinitSourceNode();\n }\n\n this._options.startOffset = value;\n\n if (restart) {\n this.play();\n }\n }\n\n public get _outNode(): Nullable<AudioNode> {\n return this._volumeNode;\n }\n\n /** @internal */\n public set pitch(value: number) {\n if (this._sourceNode) {\n this.engine._setAudioParam(this._sourceNode.detune, value);\n }\n }\n\n /** @internal */\n public set playbackRate(value: number) {\n if (this._sourceNode) {\n this.engine._setAudioParam(this._sourceNode.playbackRate, value);\n }\n }\n\n /** @internal */\n public get startTime(): number {\n if (this._state === SoundState.Stopped) {\n return 0;\n }\n\n return this._enginePlayTime;\n }\n\n /** @internal */\n public override dispose(): void {\n super.dispose();\n\n this._sourceNode = null;\n\n this.stop();\n\n this._deinitSourceNode();\n\n this.engine.stateChangedObservable.removeCallback(this._onEngineStateChanged);\n }\n\n /** @internal */\n public getClassName(): string {\n return \"_WebAudioStaticSoundInstance\";\n }\n\n /** @internal */\n public play(options: Partial<IStaticSoundPlayOptions> = {}): void {\n if (this._state === SoundState.Started) {\n return;\n }\n\n if (options.duration !== undefined) {\n this._options.duration = options.duration;\n }\n if (options.loop !== undefined) {\n this._options.loop = options.loop;\n }\n if (options.loopStart !== undefined) {\n this._options.loopStart = options.loopStart;\n }\n if (options.loopEnd !== undefined) {\n this._options.loopEnd = options.loopEnd;\n }\n if (options.startOffset !== undefined) {\n this._options.startOffset = options.startOffset;\n }\n\n let startOffset = this._options.startOffset;\n\n if (this._state === SoundState.Paused) {\n startOffset += this.currentTime;\n startOffset %= this._sound.buffer.duration;\n }\n\n this._enginePlayTime = this.engine.currentTime + (options.waitTime ?? 0);\n\n this._volumeNode.gain.value = options.volume ?? 1;\n\n this._initSourceNode();\n\n if (this.engine.state === \"running\") {\n this._setState(SoundState.Started);\n this._sourceNode?.start(this._enginePlayTime, startOffset, this._options.duration > 0 ? this._options.duration : undefined);\n } else if (this._options.loop) {\n this._setState(SoundState.Starting);\n this.engine.stateChangedObservable.add(this._onEngineStateChanged);\n }\n }\n\n /** @internal */\n public pause(): void {\n if (this._state === SoundState.Paused) {\n return;\n }\n\n this._setState(SoundState.Paused);\n this._enginePauseTime += this.engine.currentTime - this._enginePlayTime;\n\n this._sourceNode?.stop();\n this._deinitSourceNode();\n }\n\n /** @internal */\n public resume(): void {\n if (this._state === SoundState.Paused) {\n this.play();\n }\n }\n\n /** @internal */\n public stop(options: Partial<IStaticSoundStopOptions> = {}): void {\n if (this._state === SoundState.Stopped) {\n return;\n }\n\n this._setState(SoundState.Stopped);\n\n const engineStopTime = this.engine.currentTime + (options.waitTime ?? 0);\n this._sourceNode?.stop(engineStopTime);\n\n this.engine.stateChangedObservable.removeCallback(this._onEngineStateChanged);\n }\n\n protected override _connect(node: AbstractAudioNode): boolean {\n const connected = super._connect(node);\n\n if (!connected) {\n return false;\n }\n\n // If the wrapped node is not available now, it will be connected later by the sound's subgraph.\n if (node instanceof _WebAudioStaticSound && node._inNode) {\n this._outNode?.connect(node._inNode);\n }\n\n return true;\n }\n\n protected override _disconnect(node: AbstractAudioNode): boolean {\n const disconnected = super._disconnect(node);\n\n if (!disconnected) {\n return false;\n }\n\n if (node instanceof _WebAudioStaticSound && node._inNode) {\n this._outNode?.disconnect(node._inNode);\n }\n\n return true;\n }\n\n protected _onEnded = () => {\n this._enginePlayTime = 0;\n\n this.onEndedObservable.notifyObservers(this);\n this._deinitSourceNode();\n };\n\n private _deinitSourceNode(): void {\n if (!this._sourceNode) {\n return;\n }\n\n if (!this._disconnect(this._sound)) {\n throw new Error(\"Disconnect failed\");\n }\n\n this._sourceNode.disconnect(this._volumeNode);\n this._sourceNode.removeEventListener(\"ended\", this._onEnded);\n\n this._sourceNode = null;\n }\n\n private _initSourceNode(): void {\n if (!this._sourceNode) {\n this._sourceNode = new AudioBufferSourceNode(this._sound._audioContext, { buffer: this._sound.buffer._audioBuffer });\n\n this._sourceNode.addEventListener(\"ended\", this._onEnded, { once: true });\n this._sourceNode.connect(this._volumeNode);\n\n if (!this._connect(this._sound)) {\n throw new Error(\"Connect failed\");\n }\n }\n\n const node = this._sourceNode;\n node.detune.value = this._sound.pitch;\n node.loop = this._options.loop;\n node.loopEnd = this._options.loopEnd;\n node.loopStart = this._options.loopStart;\n node.playbackRate.value = this._sound.playbackRate;\n }\n\n private _onEngineStateChanged = () => {\n if (this.engine.state !== \"running\") {\n return;\n }\n\n if (this._options.loop && this.state === SoundState.Starting) {\n this.play();\n }\n\n this.engine.stateChangedObservable.removeCallback(this._onEngineStateChanged);\n };\n}\n"]}
|
|
1
|
+
{"version":3,"file":"webAudioStaticSound.js","sourceRoot":"","sources":["../../../../../dev/core/src/AudioV2/webAudio/webAudioStaticSound.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,WAAW,EAAE,MAAM,8BAA8B,CAAC;AAE3D,OAAO,EAAE,iBAAiB,EAAE,MAAM,oCAAoC,CAAC;AAEvE,OAAO,EAAE,oBAAoB,EAAE,MAAM,sCAAsC,CAAC;AAC5E,OAAO,EAAE,uBAAuB,EAAE,MAAM,qDAAqD,CAAC;AAE9F,OAAO,EAAE,YAAY,EAAE,MAAM,4CAA4C,CAAC;AAC1E,OAAO,EAAE,SAAS,EAAE,mBAAmB,EAAE,MAAM,eAAe,CAAC;AAE/D,OAAO,EAAE,2BAA2B,EAAE,MAAM,yCAAyC,CAAC;AACtF,OAAO,EAAE,4BAA4B,EAAE,MAAM,wCAAwC,CAAC;AACtF,OAAO,EAAE,gBAAgB,EAAE,MAAM,iCAAiC,CAAC;AAMnE,gBAAgB;AAChB,MAAM,OAAO,oBAAqB,SAAQ,WAAW;IAgBjD,gBAAgB;IAChB,YAAmB,IAAY,EAAE,MAAuB,EAAE,OAAqC;QAC3F,KAAK,CAAC,IAAI,EAAE,MAAM,CAAC,CAAC;QAhBhB,aAAQ,GAA+B,IAAI,CAAC;QACnC,uBAAkB,GAAY,IAAI,CAAC;QACnC,0BAAqB,GAAW,CAAC,CAAC;QAC3C,YAAO,GAA2B,IAAI,CAAC;QAe3C,IAAI,OAAO,OAAO,CAAC,iBAAiB,KAAK,SAAS,EAAE,CAAC;YACjD,IAAI,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CAAC,MAAM,GAAG,IAAI,2BAA2B,CAAC,IAAI,CAAC,MAAM,EAAE,IAAI,CAAC,WAAW,CAAC,MAAM,CAAC,CAAC;YACpF,IAAI,CAAC,aAAa,GAAG,IAAI,2BAA2B,CAAC,IAAI,CAAC,MAAM,EAAE,IAAI,CAAC,WAAW,CAAC,YAAY,CAAC,CAAC;QACrG,CAAC;QAED,MAAM,IAAI,GAAG,IAAI,CAAC,WAAW,CAAC;QAC9B,IAAI,CAAC,MAAM,CAAC,KAAK,GAAG,IAAI,CAAC,MAAM,CAAC,KAAK,CAAC;QACtC,IAAI,CAAC,IAAI,GAAG,IAAI,CAAC,QAAQ,CAAC,IAAI,CAAC;QAC/B,IAAI,CAAC,OAAO,GAAG,IAAI,CAAC,QAAQ,CAAC,OAAO,CAAC;QACrC,IAAI,CAAC,SAAS,GAAG,IAAI,CAAC,QAAQ,CAAC,SAAS,CAAC;QACzC,IAAI,CAAC,YAAY,CAAC,KAAK,GAAG,IAAI,CAAC,MAAM,CAAC,YAAY,CAAC;IACvD,CAAC;CAaJ","sourcesContent":["import type { Nullable } from \"../../types\";\nimport type { AbstractAudioNode } from \"../abstractAudio/abstractAudioNode\";\nimport type { IStaticSoundCloneOptions, IStaticSoundOptions, IStaticSoundPlayOptions, IStaticSoundStopOptions, IStaticSoundStoredOptions } from \"../abstractAudio/staticSound\";\nimport { StaticSound } from \"../abstractAudio/staticSound\";\nimport type { IStaticSoundBufferCloneOptions, IStaticSoundBufferOptions } from \"../abstractAudio/staticSoundBuffer\";\nimport { StaticSoundBuffer } from \"../abstractAudio/staticSoundBuffer\";\nimport type { IStaticSoundInstanceOptions } from \"../abstractAudio/staticSoundInstance\";\nimport { _StaticSoundInstance } from \"../abstractAudio/staticSoundInstance\";\nimport { _HasSpatialAudioOptions } from \"../abstractAudio/subProperties/abstractSpatialAudio\";\nimport type { _SpatialAudio } from \"../abstractAudio/subProperties/spatialAudio\";\nimport { _StereoAudio } from \"../abstractAudio/subProperties/stereoAudio\";\nimport { _CleanUrl, _FileExtensionRegex } from \"../audioUtils\";\nimport { SoundState } from \"../soundState\";\nimport { _WebAudioParameterComponent } from \"./components/webAudioParameterComponent\";\nimport { _WebAudioBusAndSoundSubGraph } from \"./subNodes/webAudioBusAndSoundSubGraph\";\nimport { _SpatialWebAudio } from \"./subProperties/spatialWebAudio\";\nimport type { _WebAudioEngine } from \"./webAudioEngine\";\nimport type { IWebAudioInNode, IWebAudioOutNode, IWebAudioSuperNode } from \"./webAudioNode\";\n\ntype StaticSoundSourceType = ArrayBuffer | AudioBuffer | StaticSoundBuffer | string | string[];\n\n/** @internal */\nexport class _WebAudioStaticSound extends StaticSound implements IWebAudioSuperNode {\n private _buffer: _WebAudioStaticSoundBuffer;\n private _spatial: Nullable<_SpatialWebAudio> = null;\n private readonly _spatialAutoUpdate: boolean = true;\n private readonly _spatialMinUpdateTime: number = 0;\n private _stereo: Nullable<_StereoAudio> = null;\n\n protected override readonly _options: IStaticSoundStoredOptions;\n protected _subGraph: _WebAudioBusAndSoundSubGraph;\n\n /** @internal */\n public _audioContext: AudioContext | OfflineAudioContext;\n\n /** @internal */\n public override readonly engine: _WebAudioEngine;\n\n /** @internal */\n public constructor(name: string, engine: _WebAudioEngine, options: Partial<IStaticSoundOptions>) {\n super(name, engine);\n\n if (typeof options.spatialAutoUpdate === \"boolean\") {\n this._spatialAutoUpdate = options.spatialAutoUpdate;\n }\n\n if (typeof options.spatialMinUpdateTime === \"number\") {\n this._spatialMinUpdateTime = options.spatialMinUpdateTime;\n }\n\n this._options = {\n autoplay: options.autoplay ?? false,\n duration: options.duration ?? 0,\n loop: options.loop ?? false,\n loopEnd: options.loopEnd ?? 0,\n loopStart: options.loopStart ?? 0,\n maxInstances: options.maxInstances ?? Infinity,\n pitch: options.pitch ?? 0,\n playbackRate: options.playbackRate ?? 1,\n startOffset: options.startOffset ?? 0,\n };\n\n this._subGraph = new _WebAudioStaticSound._SubGraph(this);\n }\n\n /** @internal */\n public async _initAsync(source: StaticSoundSourceType, options: Partial<IStaticSoundOptions>): Promise<void> {\n this._audioContext = this.engine._audioContext;\n\n if (source instanceof _WebAudioStaticSoundBuffer) {\n this._buffer = source;\n } else if (typeof source === \"string\" || Array.isArray(source) || source instanceof ArrayBuffer || source instanceof AudioBuffer) {\n this._buffer = (await this.engine.createSoundBufferAsync(source, options)) as _WebAudioStaticSoundBuffer;\n }\n\n if (options.outBus) {\n this.outBus = options.outBus;\n } else if (options.outBusAutoDefault !== false) {\n await this.engine.isReadyPromise;\n this.outBus = this.engine.defaultMainBus;\n }\n\n await this._subGraph.initAsync(options);\n\n if (_HasSpatialAudioOptions(options)) {\n this._initSpatialProperty();\n }\n\n if (options.autoplay) {\n this.play();\n }\n\n this.engine._addNode(this);\n }\n\n /** @internal */\n public get buffer(): _WebAudioStaticSoundBuffer {\n return this._buffer;\n }\n\n /** @internal */\n public get _inNode() {\n return this._subGraph._inNode;\n }\n\n /** @internal */\n public get _outNode() {\n return this._subGraph._outNode;\n }\n\n /** @internal */\n public override get spatial(): _SpatialAudio {\n if (this._spatial) {\n return this._spatial;\n }\n return this._initSpatialProperty();\n }\n\n /** @internal */\n public override get stereo(): _StereoAudio {\n return this._stereo ?? (this._stereo = new _StereoAudio(this._subGraph));\n }\n\n /** @internal */\n public override async cloneAsync(options: Nullable<Partial<IStaticSoundCloneOptions>> = null): Promise<StaticSound> {\n const clone = await this.engine.createSoundAsync(this.name, options?.cloneBuffer ? this.buffer.clone() : this.buffer, this._options);\n\n clone.outBus = options?.outBus ? options.outBus : this.outBus;\n\n return clone;\n }\n\n /** @internal */\n public override dispose(): void {\n super.dispose();\n\n this._spatial?.dispose();\n this._spatial = null;\n\n this._stereo = null;\n\n this._subGraph.dispose();\n\n this.engine._removeNode(this);\n }\n\n /** @internal */\n public getClassName(): string {\n return \"_WebAudioStaticSound\";\n }\n\n protected _createInstance(): _WebAudioStaticSoundInstance {\n return new _WebAudioStaticSoundInstance(this, this._options);\n }\n\n protected override _connect(node: IWebAudioInNode): boolean {\n const connected = super._connect(node);\n\n if (!connected) {\n return false;\n }\n\n // If the wrapped node is not available now, it will be connected later by the subgraph.\n if (node._inNode) {\n this._outNode?.connect(node._inNode);\n }\n\n return true;\n }\n\n protected override _disconnect(node: IWebAudioInNode): boolean {\n const disconnected = super._disconnect(node);\n\n if (!disconnected) {\n return false;\n }\n\n if (node._inNode) {\n this._outNode?.disconnect(node._inNode);\n }\n\n return true;\n }\n\n private _initSpatialProperty(): _SpatialAudio {\n if (!this._spatial) {\n this._spatial = new _SpatialWebAudio(this._subGraph, this._spatialAutoUpdate, this._spatialMinUpdateTime);\n }\n\n return this._spatial;\n }\n\n private static _SubGraph = class extends _WebAudioBusAndSoundSubGraph {\n protected override _owner: _WebAudioStaticSound;\n\n protected get _downstreamNodes(): Nullable<Set<AbstractAudioNode>> {\n return this._owner._downstreamNodes ?? null;\n }\n\n protected get _upstreamNodes(): Nullable<Set<AbstractAudioNode>> {\n return this._owner._upstreamNodes ?? null;\n }\n };\n}\n\n/** @internal */\nexport class _WebAudioStaticSoundBuffer extends StaticSoundBuffer {\n /** @internal */\n public _audioBuffer: AudioBuffer;\n\n /** @internal */\n public override readonly engine: _WebAudioEngine;\n\n /** @internal */\n public constructor(engine: _WebAudioEngine) {\n super(engine);\n }\n\n public async _initAsync(source: StaticSoundSourceType, options: Partial<IStaticSoundBufferOptions>): Promise<void> {\n if (source instanceof AudioBuffer) {\n this._audioBuffer = source;\n } else if (typeof source === \"string\") {\n await this._initFromUrlAsync(source);\n } else if (Array.isArray(source)) {\n await this._initFromUrlsAsync(source, options.skipCodecCheck ?? false);\n } else if (source instanceof ArrayBuffer) {\n await this._initFromArrayBufferAsync(source);\n }\n }\n\n /** @internal */\n public get channelCount(): number {\n return this._audioBuffer.numberOfChannels;\n }\n\n /** @internal */\n public get duration(): number {\n return this._audioBuffer.duration;\n }\n\n /** @internal */\n public get length(): number {\n return this._audioBuffer.length;\n }\n\n /** @internal */\n public get sampleRate(): number {\n return this._audioBuffer.sampleRate;\n }\n\n /** @internal */\n public override clone(options: Nullable<Partial<IStaticSoundBufferCloneOptions>> = null): StaticSoundBuffer {\n const audioBuffer = new AudioBuffer({\n length: this._audioBuffer.length,\n numberOfChannels: this._audioBuffer.numberOfChannels,\n sampleRate: this._audioBuffer.sampleRate,\n });\n\n for (let i = 0; i < this._audioBuffer.numberOfChannels; i++) {\n audioBuffer.copyToChannel(this._audioBuffer.getChannelData(i), i);\n }\n\n const buffer = new _WebAudioStaticSoundBuffer(this.engine);\n buffer._audioBuffer = audioBuffer;\n buffer.name = options?.name ? options.name : this.name;\n\n return buffer;\n }\n\n private async _initFromArrayBufferAsync(arrayBuffer: ArrayBuffer): Promise<void> {\n this._audioBuffer = await this.engine._audioContext.decodeAudioData(arrayBuffer);\n }\n\n private async _initFromUrlAsync(url: string): Promise<void> {\n url = _CleanUrl(url);\n await this._initFromArrayBufferAsync(await (await fetch(url)).arrayBuffer());\n }\n\n private async _initFromUrlsAsync(urls: string[], skipCodecCheck: boolean): Promise<void> {\n for (const url of urls) {\n if (skipCodecCheck) {\n // eslint-disable-next-line no-await-in-loop\n await this._initFromUrlAsync(url);\n } else {\n const matches = url.match(_FileExtensionRegex);\n const format = matches?.at(1);\n if (format && this.engine.isFormatValid(format)) {\n try {\n // eslint-disable-next-line no-await-in-loop\n await this._initFromUrlAsync(url);\n } catch {\n if (format && 0 < format.length) {\n this.engine.flagInvalidFormat(format);\n }\n }\n }\n }\n\n if (this._audioBuffer) {\n break;\n }\n }\n }\n}\n\n/** @internal */\nclass _WebAudioStaticSoundInstance extends _StaticSoundInstance implements IWebAudioOutNode {\n private _enginePlayTime: number = 0;\n private _enginePauseTime: number = 0;\n private _pitch: Nullable<_WebAudioParameterComponent> = null;\n private _playbackRate: Nullable<_WebAudioParameterComponent> = null;\n private _sourceNode: Nullable<AudioBufferSourceNode> = null;\n private _volumeNode: GainNode;\n\n protected override readonly _options: IStaticSoundInstanceOptions;\n protected override _sound: _WebAudioStaticSound;\n\n /** @internal */\n public override readonly engine: _WebAudioEngine;\n\n public constructor(sound: _WebAudioStaticSound, options: IStaticSoundInstanceOptions) {\n super(sound);\n\n this._options = options;\n\n this._volumeNode = new GainNode(sound._audioContext);\n this._initSourceNode();\n }\n\n /** @internal */\n public override dispose(): void {\n super.dispose();\n\n this._pitch?.dispose();\n this._playbackRate?.dispose();\n\n this._sourceNode = null;\n\n this.stop();\n\n this._deinitSourceNode();\n\n this.engine.stateChangedObservable.removeCallback(this._onEngineStateChanged);\n }\n\n /** @internal */\n public get currentTime(): number {\n if (this._state === SoundState.Stopped) {\n return 0;\n }\n\n const timeSinceLastStart = this._state === SoundState.Paused ? 0 : this.engine.currentTime - this._enginePlayTime;\n return this._enginePauseTime + timeSinceLastStart + this._options.startOffset;\n }\n\n public set currentTime(value: number) {\n const restart = this._state === SoundState.Starting || this._state === SoundState.Started;\n\n if (restart) {\n this.stop();\n this._deinitSourceNode();\n }\n\n this._options.startOffset = value;\n\n if (restart) {\n this.play();\n }\n }\n\n public get _outNode(): Nullable<AudioNode> {\n return this._volumeNode;\n }\n\n /** @internal */\n public set pitch(value: number) {\n this._pitch?.setTargetValue(value);\n }\n\n /** @internal */\n public set playbackRate(value: number) {\n this._playbackRate?.setTargetValue(value);\n }\n\n /** @internal */\n public get startTime(): number {\n if (this._state === SoundState.Stopped) {\n return 0;\n }\n\n return this._enginePlayTime;\n }\n\n /** @internal */\n public getClassName(): string {\n return \"_WebAudioStaticSoundInstance\";\n }\n\n /** @internal */\n public play(options: Partial<IStaticSoundPlayOptions> = {}): void {\n if (this._state === SoundState.Started) {\n return;\n }\n\n if (options.duration !== undefined) {\n this._options.duration = options.duration;\n }\n if (options.loop !== undefined) {\n this._options.loop = options.loop;\n }\n if (options.loopStart !== undefined) {\n this._options.loopStart = options.loopStart;\n }\n if (options.loopEnd !== undefined) {\n this._options.loopEnd = options.loopEnd;\n }\n if (options.startOffset !== undefined) {\n this._options.startOffset = options.startOffset;\n }\n\n let startOffset = this._options.startOffset;\n\n if (this._state === SoundState.Paused) {\n startOffset += this.currentTime;\n startOffset %= this._sound.buffer.duration;\n }\n\n this._enginePlayTime = this.engine.currentTime + (options.waitTime ?? 0);\n\n this._volumeNode.gain.value = options.volume ?? 1;\n\n this._initSourceNode();\n\n if (this.engine.state === \"running\") {\n this._setState(SoundState.Started);\n this._sourceNode?.start(this._enginePlayTime, startOffset, this._options.duration > 0 ? this._options.duration : undefined);\n } else if (this._options.loop) {\n this._setState(SoundState.Starting);\n this.engine.stateChangedObservable.add(this._onEngineStateChanged);\n }\n }\n\n /** @internal */\n public pause(): void {\n if (this._state === SoundState.Paused) {\n return;\n }\n\n this._setState(SoundState.Paused);\n this._enginePauseTime += this.engine.currentTime - this._enginePlayTime;\n\n this._sourceNode?.stop();\n this._deinitSourceNode();\n }\n\n /** @internal */\n public resume(): void {\n if (this._state === SoundState.Paused) {\n this.play();\n }\n }\n\n /** @internal */\n public stop(options: Partial<IStaticSoundStopOptions> = {}): void {\n if (this._state === SoundState.Stopped) {\n return;\n }\n\n this._setState(SoundState.Stopped);\n\n const engineStopTime = this.engine.currentTime + (options.waitTime ?? 0);\n this._sourceNode?.stop(engineStopTime);\n\n this.engine.stateChangedObservable.removeCallback(this._onEngineStateChanged);\n }\n\n protected override _connect(node: AbstractAudioNode): boolean {\n const connected = super._connect(node);\n\n if (!connected) {\n return false;\n }\n\n // If the wrapped node is not available now, it will be connected later by the sound's subgraph.\n if (node instanceof _WebAudioStaticSound && node._inNode) {\n this._outNode?.connect(node._inNode);\n }\n\n return true;\n }\n\n protected override _disconnect(node: AbstractAudioNode): boolean {\n const disconnected = super._disconnect(node);\n\n if (!disconnected) {\n return false;\n }\n\n if (node instanceof _WebAudioStaticSound && node._inNode) {\n this._outNode?.disconnect(node._inNode);\n }\n\n return true;\n }\n\n protected _onEnded = () => {\n this._enginePlayTime = 0;\n\n this.onEndedObservable.notifyObservers(this);\n this._deinitSourceNode();\n };\n\n private _deinitSourceNode(): void {\n if (!this._sourceNode) {\n return;\n }\n\n if (!this._disconnect(this._sound)) {\n throw new Error(\"Disconnect failed\");\n }\n\n this._sourceNode.disconnect(this._volumeNode);\n this._sourceNode.removeEventListener(\"ended\", this._onEnded);\n\n this._sourceNode = null;\n }\n\n private _initSourceNode(): void {\n if (!this._sourceNode) {\n this._sourceNode = new AudioBufferSourceNode(this._sound._audioContext, { buffer: this._sound.buffer._audioBuffer });\n\n this._sourceNode.addEventListener(\"ended\", this._onEnded, { once: true });\n this._sourceNode.connect(this._volumeNode);\n\n if (!this._connect(this._sound)) {\n throw new Error(\"Connect failed\");\n }\n\n this._pitch = new _WebAudioParameterComponent(this.engine, this._sourceNode.detune);\n this._playbackRate = new _WebAudioParameterComponent(this.engine, this._sourceNode.playbackRate);\n }\n\n const node = this._sourceNode;\n node.detune.value = this._sound.pitch;\n node.loop = this._options.loop;\n node.loopEnd = this._options.loopEnd;\n node.loopStart = this._options.loopStart;\n node.playbackRate.value = this._sound.playbackRate;\n }\n\n private _onEngineStateChanged = () => {\n if (this.engine.state !== \"running\") {\n return;\n }\n\n if (this._options.loop && this.state === SoundState.Starting) {\n this.play();\n }\n\n this.engine.stateChangedObservable.removeCallback(this._onEngineStateChanged);\n };\n}\n"]}
|
|
@@ -17,6 +17,13 @@ export declare class VertexAnimationBaker {
|
|
|
17
17
|
* @param meshOrSkeleton Defines the skeleton or the mesh from which to retrieve the skeleton from.
|
|
18
18
|
*/
|
|
19
19
|
constructor(scene: Scene, meshOrSkeleton: Mesh | Skeleton);
|
|
20
|
+
/**
|
|
21
|
+
*
|
|
22
|
+
* @param ranges Defines the ranges in the animation that will be baked.
|
|
23
|
+
* @param halfFloat If true, the vertex data will be returned as half-float (Uint16Array), otherwise as full float (Float32Array).
|
|
24
|
+
* @returns The array of matrix transforms for each vertex (columns) and frame (rows), as a Float32Array or Uint16Array.
|
|
25
|
+
*/
|
|
26
|
+
bakeVertexDataSync(ranges: AnimationRange[], halfFloat: boolean): Float32Array | Uint16Array;
|
|
20
27
|
/**
|
|
21
28
|
* Bakes the animation into the texture. This should be called once, when the
|
|
22
29
|
* scene starts, so the VAT is generated and associated to the mesh.
|
|
@@ -35,10 +42,11 @@ export declare class VertexAnimationBaker {
|
|
|
35
42
|
private _executeAnimationFrameAsync;
|
|
36
43
|
/**
|
|
37
44
|
* Builds a vertex animation texture given the vertexData in an array.
|
|
38
|
-
* @param vertexData The vertex animation data. You can generate it with bakeVertexData().
|
|
45
|
+
* @param vertexData The vertex animation data. You can generate it with bakeVertexData(). You can pass in a Float32Array to return a full precision texture, or a Uint16Array to return a half-float texture.
|
|
46
|
+
* If you pass in a Uint16Array, make sure your device supports half-float textures
|
|
39
47
|
* @returns The vertex animation texture to be used with BakedVertexAnimationManager.
|
|
40
48
|
*/
|
|
41
|
-
textureFromBakedVertexData(vertexData: Float32Array): RawTexture;
|
|
49
|
+
textureFromBakedVertexData(vertexData: Float32Array | Uint16Array): RawTexture;
|
|
42
50
|
/**
|
|
43
51
|
* Serializes our vertexData to an object, with a nice string for the vertexData.
|
|
44
52
|
* @param vertexData The vertex array data.
|
|
@@ -3,6 +3,8 @@ import { Texture } from "../Materials/Textures/texture.js";
|
|
|
3
3
|
import { EncodeArrayBufferToBase64, DecodeBase64ToBinary } from "../Misc/stringTools.js";
|
|
4
4
|
|
|
5
5
|
import { Skeleton } from "../Bones/skeleton.js";
|
|
6
|
+
import { ToHalfFloat } from "../Misc/textureTools.js";
|
|
7
|
+
import { Logger } from "../Misc/logger.js";
|
|
6
8
|
/**
|
|
7
9
|
* Class to bake vertex animation textures.
|
|
8
10
|
* @since 5.0
|
|
@@ -24,6 +26,44 @@ export class VertexAnimationBaker {
|
|
|
24
26
|
this._skeleton = meshOrSkeleton.skeleton;
|
|
25
27
|
}
|
|
26
28
|
}
|
|
29
|
+
/**
|
|
30
|
+
*
|
|
31
|
+
* @param ranges Defines the ranges in the animation that will be baked.
|
|
32
|
+
* @param halfFloat If true, the vertex data will be returned as half-float (Uint16Array), otherwise as full float (Float32Array).
|
|
33
|
+
* @returns The array of matrix transforms for each vertex (columns) and frame (rows), as a Float32Array or Uint16Array.
|
|
34
|
+
*/
|
|
35
|
+
bakeVertexDataSync(ranges, halfFloat) {
|
|
36
|
+
if (!this._skeleton) {
|
|
37
|
+
throw new Error("No skeleton provided.");
|
|
38
|
+
}
|
|
39
|
+
const bones = this._skeleton.bones.length;
|
|
40
|
+
const floatsPerFrame = (bones + 1) * 16;
|
|
41
|
+
const totalFrames = ranges.reduce((sum, r) => sum + (Math.floor(r.to) - Math.floor(r.from) + 1), 0);
|
|
42
|
+
const vertexData = halfFloat ? new Uint16Array(floatsPerFrame * totalFrames) : new Float32Array(floatsPerFrame * totalFrames);
|
|
43
|
+
let frameIdx = 0;
|
|
44
|
+
this._skeleton.returnToRest();
|
|
45
|
+
for (const range of ranges) {
|
|
46
|
+
for (let f = Math.floor(range.from); f <= Math.floor(range.to); f++) {
|
|
47
|
+
this._scene.beginAnimation(this._skeleton, f, f, false, 1.0);
|
|
48
|
+
this._scene.render();
|
|
49
|
+
this._skeleton.computeAbsoluteMatrices(true);
|
|
50
|
+
const matrices = this._skeleton.getTransformMatrices(this._mesh);
|
|
51
|
+
const base = frameIdx * floatsPerFrame;
|
|
52
|
+
if (halfFloat) {
|
|
53
|
+
matrices.forEach((val, i) => {
|
|
54
|
+
vertexData[base + i] = ToHalfFloat(val);
|
|
55
|
+
});
|
|
56
|
+
}
|
|
57
|
+
else {
|
|
58
|
+
matrices.forEach((val, i) => {
|
|
59
|
+
vertexData[base + i] = val;
|
|
60
|
+
});
|
|
61
|
+
}
|
|
62
|
+
frameIdx++;
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
return vertexData;
|
|
66
|
+
}
|
|
27
67
|
/**
|
|
28
68
|
* Bakes the animation into the texture. This should be called once, when the
|
|
29
69
|
* scene starts, so the VAT is generated and associated to the mesh.
|
|
@@ -77,7 +117,8 @@ export class VertexAnimationBaker {
|
|
|
77
117
|
}
|
|
78
118
|
/**
|
|
79
119
|
* Builds a vertex animation texture given the vertexData in an array.
|
|
80
|
-
* @param vertexData The vertex animation data. You can generate it with bakeVertexData().
|
|
120
|
+
* @param vertexData The vertex animation data. You can generate it with bakeVertexData(). You can pass in a Float32Array to return a full precision texture, or a Uint16Array to return a half-float texture.
|
|
121
|
+
* If you pass in a Uint16Array, make sure your device supports half-float textures
|
|
81
122
|
* @returns The vertex animation texture to be used with BakedVertexAnimationManager.
|
|
82
123
|
*/
|
|
83
124
|
textureFromBakedVertexData(vertexData) {
|
|
@@ -85,7 +126,12 @@ export class VertexAnimationBaker {
|
|
|
85
126
|
throw new Error("No skeleton provided.");
|
|
86
127
|
}
|
|
87
128
|
const boneCount = this._skeleton.bones.length;
|
|
88
|
-
|
|
129
|
+
if (vertexData instanceof Uint16Array) {
|
|
130
|
+
if (!this._scene.getEngine().getCaps().textureHalfFloatRender) {
|
|
131
|
+
Logger.Warn("VertexAnimationBaker: Half-float textures are not supported on this device");
|
|
132
|
+
}
|
|
133
|
+
}
|
|
134
|
+
const texture = RawTexture.CreateRGBATexture(vertexData, (boneCount + 1) * 4, vertexData.length / ((boneCount + 1) * 4 * 4), this._scene, false, false, Texture.NEAREST_NEAREST, vertexData instanceof Float32Array ? 1 : 2);
|
|
89
135
|
texture.name = "VAT" + this._skeleton.name;
|
|
90
136
|
return texture;
|
|
91
137
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"vertexAnimationBaker.js","sourceRoot":"","sources":["../../../../dev/core/src/BakedVertexAnimation/vertexAnimationBaker.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,UAAU,EAAE,MAAM,kCAAkC,CAAC;AAC9D,OAAO,EAAE,OAAO,EAAE,MAAM,+BAA+B,CAAC;AAExD,OAAO,EAAE,yBAAyB,EAAE,oBAAoB,EAAE,MAAM,qBAAqB,CAAC;AAEtF,OAAO,EAAE,SAAS,EAAE,MAAM,sBAAsB,CAAC;AACjD,OAAO,EAAE,QAAQ,EAAE,6BAA4B;AAG/C;;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AAC,CAAC;IAC7E,CAAC;IACD;;;;OAIG;IACI,2BAA2B,CAAC,IAAY;QAC3C,OAAO,IAAI,CAAC,6BAA6B,CAAC,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC,CAAC;IAChE,CAAC;CACJ","sourcesContent":["import type { AnimationRange } from \"../Animations/animationRange\";\r\nimport { RawTexture } from \"../Materials/Textures/rawTexture\";\r\nimport { Texture } from \"../Materials/Textures/texture\";\r\nimport type { Mesh } from \"../Meshes/mesh\";\r\nimport { EncodeArrayBufferToBase64, DecodeBase64ToBinary } from \"../Misc/stringTools\";\r\nimport type { Scene } from \"../scene\";\r\nimport { Constants } from \"../Engines/constants\";\r\nimport { Skeleton } from \"core/Bones/skeleton\";\r\nimport type { Nullable } from \"core/types\";\r\n\r\n/**\r\n * Class to bake vertex animation textures.\r\n * @since 5.0\r\n */\r\nexport class VertexAnimationBaker {\r\n private _scene: Scene;\r\n private _mesh: Nullable<Mesh>;\r\n private _skeleton: Nullable<Skeleton>;\r\n\r\n /**\r\n * Create a new VertexAnimationBaker object which can help baking animations into a texture.\r\n * @param scene Defines the scene the VAT belongs to\r\n * @param meshOrSkeleton Defines the skeleton or the mesh from which to retrieve the skeleton from.\r\n */\r\n constructor(scene: Scene, meshOrSkeleton: Mesh | Skeleton) {\r\n this._scene = scene;\r\n if (meshOrSkeleton instanceof Skeleton) {\r\n this._skeleton = meshOrSkeleton;\r\n this._mesh = null;\r\n } else {\r\n this._mesh = meshOrSkeleton;\r\n this._skeleton = meshOrSkeleton.skeleton;\r\n }\r\n }\r\n\r\n /**\r\n * Bakes the animation into the texture. This should be called once, when the\r\n * scene starts, so the VAT is generated and associated to the mesh.\r\n * @param ranges Defines the ranges in the animation that will be baked.\r\n * @returns The array of matrix transforms for each vertex (columns) and frame (rows), as a Float32Array.\r\n */\r\n // async function, without Async suffix, to avoid breaking the API\r\n // eslint-disable-next-line @typescript-eslint/naming-convention\r\n public async bakeVertexData(ranges: AnimationRange[]): Promise<Float32Array> {\r\n if (!this._skeleton) {\r\n throw new Error(\"No skeleton provided.\");\r\n }\r\n const boneCount = this._skeleton.bones.length;\r\n\r\n /** total number of frames in our animations */\r\n const frameCount = ranges.reduce((previous: number, current: AnimationRange) => previous + current.to - current.from + 1, 0);\r\n\r\n if (isNaN(frameCount)) {\r\n throw new Error(\"Invalid animation ranges.\");\r\n }\r\n\r\n // reset our loop data\r\n let textureIndex = 0;\r\n const textureSize = (boneCount + 1) * 4 * 4 * frameCount;\r\n const vertexData = new Float32Array(textureSize);\r\n this._scene.stopAnimation(this._skeleton);\r\n this._skeleton.returnToRest();\r\n\r\n // render all frames from our slices\r\n for (const range of ranges) {\r\n for (let frameIndex = range.from; frameIndex <= range.to; frameIndex++) {\r\n // eslint-disable-next-line no-await-in-loop\r\n await this._executeAnimationFrameAsync(vertexData, frameIndex, textureIndex++);\r\n }\r\n }\r\n\r\n return vertexData;\r\n }\r\n\r\n /**\r\n * Runs an animation frame and stores its vertex data\r\n *\r\n * @param vertexData The array to save data to.\r\n * @param frameIndex Current frame in the skeleton animation to render.\r\n * @param textureIndex Current index of the texture data.\r\n * @returns A promise that resolves when the animation frame is done.\r\n */\r\n private async _executeAnimationFrameAsync(vertexData: Float32Array, frameIndex: number, textureIndex: number): Promise<void> {\r\n return await new Promise<void>((resolve, _reject) => {\r\n this._scene.beginAnimation(this._skeleton, frameIndex, frameIndex, false, 1.0, () => {\r\n // generate matrices\r\n const skeletonMatrices = this._skeleton!.getTransformMatrices(this._mesh);\r\n vertexData.set(skeletonMatrices, textureIndex * skeletonMatrices.length);\r\n\r\n resolve();\r\n });\r\n });\r\n }\r\n /**\r\n * Builds a vertex animation texture given the vertexData in an array.\r\n * @param vertexData The vertex animation data. You can generate it with bakeVertexData().\r\n * @returns The vertex animation texture to be used with BakedVertexAnimationManager.\r\n */\r\n public textureFromBakedVertexData(vertexData: Float32Array): RawTexture {\r\n if (!this._skeleton) {\r\n throw new Error(\"No skeleton provided.\");\r\n }\r\n const boneCount = this._skeleton.bones.length;\r\n\r\n const texture = RawTexture.CreateRGBATexture(\r\n vertexData,\r\n (boneCount + 1) * 4,\r\n vertexData.length / ((boneCount + 1) * 4 * 4),\r\n this._scene,\r\n false,\r\n false,\r\n Texture.NEAREST_NEAREST,\r\n Constants.TEXTURETYPE_FLOAT\r\n );\r\n texture.name = \"VAT\" + this._skeleton.name;\r\n return texture;\r\n }\r\n /**\r\n * Serializes our vertexData to an object, with a nice string for the vertexData.\r\n * @param vertexData The vertex array data.\r\n * @returns This object serialized to a JS dict.\r\n */\r\n public serializeBakedVertexDataToObject(vertexData: Float32Array): Record<string, any> {\r\n if (!this._skeleton) {\r\n throw new Error(\"No skeleton provided.\");\r\n }\r\n\r\n // this converts the float array to a serialized base64 string, ~1.3x larger\r\n // than the original.\r\n const boneCount = this._skeleton.bones.length;\r\n const width = (boneCount + 1) * 4;\r\n const height = vertexData.length / ((boneCount + 1) * 4 * 4);\r\n const data = {\r\n vertexData: EncodeArrayBufferToBase64(vertexData),\r\n width,\r\n height,\r\n };\r\n return data;\r\n }\r\n /**\r\n * Loads previously baked data.\r\n * @param data The object as serialized by serializeBakedVertexDataToObject()\r\n * @returns The array of matrix transforms for each vertex (columns) and frame (rows), as a Float32Array.\r\n */\r\n public loadBakedVertexDataFromObject(data: Record<string, any>): Float32Array {\r\n return new Float32Array(DecodeBase64ToBinary(data.vertexData));\r\n }\r\n /**\r\n * Serializes our vertexData to a JSON string, with a nice string for the vertexData.\r\n * Should be called right after bakeVertexData().\r\n * @param vertexData The vertex array data.\r\n * @returns This object serialized to a safe string.\r\n */\r\n public serializeBakedVertexDataToJSON(vertexData: Float32Array): string {\r\n return JSON.stringify(this.serializeBakedVertexDataToObject(vertexData));\r\n }\r\n /**\r\n * Loads previously baked data in string format.\r\n * @param json The json string as serialized by serializeBakedVertexDataToJSON().\r\n * @returns The array of matrix transforms for each vertex (columns) and frame (rows), as a Float32Array.\r\n */\r\n public loadBakedVertexDataFromJSON(json: string): Float32Array {\r\n return this.loadBakedVertexDataFromObject(JSON.parse(json));\r\n }\r\n}\r\n"]}
|
|
1
|
+
{"version":3,"file":"vertexAnimationBaker.js","sourceRoot":"","sources":["../../../../dev/core/src/BakedVertexAnimation/vertexAnimationBaker.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,UAAU,EAAE,MAAM,kCAAkC,CAAC;AAC9D,OAAO,EAAE,OAAO,EAAE,MAAM,+BAA+B,CAAC;AAExD,OAAO,EAAE,yBAAyB,EAAE,oBAAoB,EAAE,MAAM,qBAAqB,CAAC;AAEtF,OAAO,EAAE,SAAS,EAAE,MAAM,sBAAsB,CAAC;AACjD,OAAO,EAAE,QAAQ,EAAE,6BAA4B;AAE/C,OAAO,EAAE,WAAW,EAAE,MAAM,sBAAsB,CAAC;AACnD,OAAO,EAAE,MAAM,EAAE,MAAM,gBAAgB,CAAC;AAExC;;;GAGG;AACH,MAAM,OAAO,oBAAoB;IAK7B;;;;OAIG;IACH,YAAY,KAAY,EAAE,cAA+B;QACrD,IAAI,CAAC,MAAM,GAAG,KAAK,CAAC;QACpB,IAAI,cAAc,YAAY,QAAQ,EAAE,CAAC;YACrC,IAAI,CAAC,SAAS,GAAG,cAAc,CAAC;YAChC,IAAI,CAAC,KAAK,GAAG,IAAI,CAAC;QACtB,CAAC;aAAM,CAAC;YACJ,IAAI,CAAC,KAAK,GAAG,cAAc,CAAC;YAC5B,IAAI,CAAC,SAAS,GAAG,cAAc,CAAC,QAAQ,CAAC;QAC7C,CAAC;IACL,CAAC;IAED;;;;;OAKG;IACI,kBAAkB,CAAC,MAAwB,EAAE,SAAkB;QAClE,IAAI,CAAC,IAAI,CAAC,SAAS,EAAE,CAAC;YAClB,MAAM,IAAI,KAAK,CAAC,uBAAuB,CAAC,CAAC;QAC7C,CAAC;QACD,MAAM,KAAK,GAAG,IAAI,CAAC,SAAS,CAAC,KAAK,CAAC,MAAM,CAAC;QAC1C,MAAM,cAAc,GAAG,CAAC,KAAK,GAAG,CAAC,CAAC,GAAG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B,CAAC;IACD;;;;OAIG;IACI,6BAA6B,CAAC,IAAyB;QAC1D,OAAO,IAAI,YAAY,CAAC,oBAAoB,CAAC,IAAI,CAAC,UAAU,CAAC,CAAC,CAAC;IACnE,CAAC;IACD;;;;;OAKG;IACI,8BAA8B,CAAC,UAAwB;QAC1D,OAAO,IAAI,CAAC,SAAS,CAAC,IAAI,CAAC,gCAAgC,CAAC,UAAU,CAAC,CAAC,CAAC;IAC7E,CAAC;IACD;;;;OAIG;IACI,2BAA2B,CAAC,IAAY;QAC3C,OAAO,IAAI,CAAC,6BAA6B,CAAC,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC,CAAC;IAChE,CAAC;CACJ","sourcesContent":["import type { AnimationRange } from \"../Animations/animationRange\";\r\nimport { RawTexture } from \"../Materials/Textures/rawTexture\";\r\nimport { Texture } from \"../Materials/Textures/texture\";\r\nimport type { Mesh } from \"../Meshes/mesh\";\r\nimport { EncodeArrayBufferToBase64, DecodeBase64ToBinary } from \"../Misc/stringTools\";\r\nimport type { Scene } from \"../scene\";\r\nimport { Constants } from \"../Engines/constants\";\r\nimport { Skeleton } from \"core/Bones/skeleton\";\r\nimport type { Nullable } from \"core/types\";\r\nimport { ToHalfFloat } from \"../Misc/textureTools\";\r\nimport { Logger } from \"../Misc/logger\";\r\n\r\n/**\r\n * Class to bake vertex animation textures.\r\n * @since 5.0\r\n */\r\nexport class VertexAnimationBaker {\r\n private _scene: Scene;\r\n private _mesh: Nullable<Mesh>;\r\n private _skeleton: Nullable<Skeleton>;\r\n\r\n /**\r\n * Create a new VertexAnimationBaker object which can help baking animations into a texture.\r\n * @param scene Defines the scene the VAT belongs to\r\n * @param meshOrSkeleton Defines the skeleton or the mesh from which to retrieve the skeleton from.\r\n */\r\n constructor(scene: Scene, meshOrSkeleton: Mesh | Skeleton) {\r\n this._scene = scene;\r\n if (meshOrSkeleton instanceof Skeleton) {\r\n this._skeleton = meshOrSkeleton;\r\n this._mesh = null;\r\n } else {\r\n this._mesh = meshOrSkeleton;\r\n this._skeleton = meshOrSkeleton.skeleton;\r\n }\r\n }\r\n\r\n /**\r\n *\r\n * @param ranges Defines the ranges in the animation that will be baked.\r\n * @param halfFloat If true, the vertex data will be returned as half-float (Uint16Array), otherwise as full float (Float32Array).\r\n * @returns The array of matrix transforms for each vertex (columns) and frame (rows), as a Float32Array or Uint16Array.\r\n */\r\n public bakeVertexDataSync(ranges: AnimationRange[], halfFloat: boolean): Float32Array | Uint16Array {\r\n if (!this._skeleton) {\r\n throw new Error(\"No skeleton provided.\");\r\n }\r\n const bones = this._skeleton.bones.length;\r\n const floatsPerFrame = (bones + 1) * 16;\r\n const totalFrames = ranges.reduce((sum, r) => sum + (Math.floor(r.to) - Math.floor(r.from) + 1), 0);\r\n\r\n const vertexData = halfFloat ? new Uint16Array(floatsPerFrame * totalFrames) : new Float32Array(floatsPerFrame * totalFrames);\r\n\r\n let frameIdx = 0;\r\n\r\n this._skeleton.returnToRest();\r\n\r\n for (const range of ranges) {\r\n for (let f = Math.floor(range.from); f <= Math.floor(range.to); f++) {\r\n this._scene.beginAnimation(this._skeleton, f, f, false, 1.0);\r\n this._scene.render();\r\n this._skeleton.computeAbsoluteMatrices(true);\r\n const matrices = this._skeleton.getTransformMatrices(this._mesh);\r\n const base = frameIdx * floatsPerFrame;\r\n if (halfFloat) {\r\n matrices.forEach((val, i) => {\r\n vertexData[base + i] = ToHalfFloat(val);\r\n });\r\n } else {\r\n matrices.forEach((val, i) => {\r\n vertexData[base + i] = val;\r\n });\r\n }\r\n frameIdx++;\r\n }\r\n }\r\n\r\n return vertexData;\r\n }\r\n\r\n /**\r\n * Bakes the animation into the texture. This should be called once, when the\r\n * scene starts, so the VAT is generated and associated to the mesh.\r\n * @param ranges Defines the ranges in the animation that will be baked.\r\n * @returns The array of matrix transforms for each vertex (columns) and frame (rows), as a Float32Array.\r\n */\r\n // async function, without Async suffix, to avoid breaking the API\r\n // eslint-disable-next-line @typescript-eslint/naming-convention\r\n public async bakeVertexData(ranges: AnimationRange[]): Promise<Float32Array> {\r\n if (!this._skeleton) {\r\n throw new Error(\"No skeleton provided.\");\r\n }\r\n const boneCount = this._skeleton.bones.length;\r\n\r\n /** total number of frames in our animations */\r\n const frameCount = ranges.reduce((previous: number, current: AnimationRange) => previous + current.to - current.from + 1, 0);\r\n\r\n if (isNaN(frameCount)) {\r\n throw new Error(\"Invalid animation ranges.\");\r\n }\r\n\r\n // reset our loop data\r\n let textureIndex = 0;\r\n const textureSize = (boneCount + 1) * 4 * 4 * frameCount;\r\n const vertexData = new Float32Array(textureSize);\r\n this._scene.stopAnimation(this._skeleton);\r\n this._skeleton.returnToRest();\r\n\r\n // render all frames from our slices\r\n for (const range of ranges) {\r\n for (let frameIndex = range.from; frameIndex <= range.to; frameIndex++) {\r\n // eslint-disable-next-line no-await-in-loop\r\n await this._executeAnimationFrameAsync(vertexData, frameIndex, textureIndex++);\r\n }\r\n }\r\n\r\n return vertexData;\r\n }\r\n\r\n /**\r\n * Runs an animation frame and stores its vertex data\r\n *\r\n * @param vertexData The array to save data to.\r\n * @param frameIndex Current frame in the skeleton animation to render.\r\n * @param textureIndex Current index of the texture data.\r\n * @returns A promise that resolves when the animation frame is done.\r\n */\r\n private async _executeAnimationFrameAsync(vertexData: Float32Array, frameIndex: number, textureIndex: number): Promise<void> {\r\n return await new Promise<void>((resolve, _reject) => {\r\n this._scene.beginAnimation(this._skeleton, frameIndex, frameIndex, false, 1.0, () => {\r\n // generate matrices\r\n const skeletonMatrices = this._skeleton!.getTransformMatrices(this._mesh);\r\n vertexData.set(skeletonMatrices, textureIndex * skeletonMatrices.length);\r\n\r\n resolve();\r\n });\r\n });\r\n }\r\n /**\r\n * Builds a vertex animation texture given the vertexData in an array.\r\n * @param vertexData The vertex animation data. You can generate it with bakeVertexData(). You can pass in a Float32Array to return a full precision texture, or a Uint16Array to return a half-float texture.\r\n * If you pass in a Uint16Array, make sure your device supports half-float textures\r\n * @returns The vertex animation texture to be used with BakedVertexAnimationManager.\r\n */\r\n public textureFromBakedVertexData(vertexData: Float32Array | Uint16Array): RawTexture {\r\n if (!this._skeleton) {\r\n throw new Error(\"No skeleton provided.\");\r\n }\r\n const boneCount = this._skeleton.bones.length;\r\n\r\n if (vertexData instanceof Uint16Array) {\r\n if (!this._scene.getEngine().getCaps().textureHalfFloatRender) {\r\n Logger.Warn(\"VertexAnimationBaker: Half-float textures are not supported on this device\");\r\n }\r\n }\r\n\r\n const texture = RawTexture.CreateRGBATexture(\r\n vertexData,\r\n (boneCount + 1) * 4,\r\n vertexData.length / ((boneCount + 1) * 4 * 4),\r\n this._scene,\r\n false,\r\n false,\r\n Texture.NEAREST_NEAREST,\r\n vertexData instanceof Float32Array ? Constants.TEXTURETYPE_FLOAT : Constants.TEXTURETYPE_HALF_FLOAT\r\n );\r\n texture.name = \"VAT\" + this._skeleton.name;\r\n return texture;\r\n }\r\n /**\r\n * Serializes our vertexData to an object, with a nice string for the vertexData.\r\n * @param vertexData The vertex array data.\r\n * @returns This object serialized to a JS dict.\r\n */\r\n public serializeBakedVertexDataToObject(vertexData: Float32Array): Record<string, any> {\r\n if (!this._skeleton) {\r\n throw new Error(\"No skeleton provided.\");\r\n }\r\n\r\n // this converts the float array to a serialized base64 string, ~1.3x larger\r\n // than the original.\r\n const boneCount = this._skeleton.bones.length;\r\n const width = (boneCount + 1) * 4;\r\n const height = vertexData.length / ((boneCount + 1) * 4 * 4);\r\n const data = {\r\n vertexData: EncodeArrayBufferToBase64(vertexData),\r\n width,\r\n height,\r\n };\r\n return data;\r\n }\r\n /**\r\n * Loads previously baked data.\r\n * @param data The object as serialized by serializeBakedVertexDataToObject()\r\n * @returns The array of matrix transforms for each vertex (columns) and frame (rows), as a Float32Array.\r\n */\r\n public loadBakedVertexDataFromObject(data: Record<string, any>): Float32Array {\r\n return new Float32Array(DecodeBase64ToBinary(data.vertexData));\r\n }\r\n /**\r\n * Serializes our vertexData to a JSON string, with a nice string for the vertexData.\r\n * Should be called right after bakeVertexData().\r\n * @param vertexData The vertex array data.\r\n * @returns This object serialized to a safe string.\r\n */\r\n public serializeBakedVertexDataToJSON(vertexData: Float32Array): string {\r\n return JSON.stringify(this.serializeBakedVertexDataToObject(vertexData));\r\n }\r\n /**\r\n * Loads previously baked data in string format.\r\n * @param json The json string as serialized by serializeBakedVertexDataToJSON().\r\n * @returns The array of matrix transforms for each vertex (columns) and frame (rows), as a Float32Array.\r\n */\r\n public loadBakedVertexDataFromJSON(json: string): Float32Array {\r\n return this.loadBakedVertexDataFromObject(JSON.parse(json));\r\n }\r\n}\r\n"]}
|
|
@@ -128,6 +128,11 @@ export declare class PointerDragBehavior implements Behavior<AbstractMesh> {
|
|
|
128
128
|
* If set, the drag plane/axis will be rotated based on the attached mesh's world rotation (Default: true)
|
|
129
129
|
*/
|
|
130
130
|
useObjectOrientationForDragging: boolean;
|
|
131
|
+
/**
|
|
132
|
+
* Normally a drag is canceled when the user presses another button on the same pointer. If this is set to true,
|
|
133
|
+
* the drag will continue even if another button is pressed on the same pointer.
|
|
134
|
+
*/
|
|
135
|
+
allowOtherButtonsDuringDrag: boolean;
|
|
131
136
|
private _options;
|
|
132
137
|
/**
|
|
133
138
|
* Gets the options used by the behavior
|
|
@@ -132,6 +132,11 @@ export class PointerDragBehavior {
|
|
|
132
132
|
* If set, the drag plane/axis will be rotated based on the attached mesh's world rotation (Default: true)
|
|
133
133
|
*/
|
|
134
134
|
this.useObjectOrientationForDragging = true;
|
|
135
|
+
/**
|
|
136
|
+
* Normally a drag is canceled when the user presses another button on the same pointer. If this is set to true,
|
|
137
|
+
* the drag will continue even if another button is pressed on the same pointer.
|
|
138
|
+
*/
|
|
139
|
+
this.allowOtherButtonsDuringDrag = false;
|
|
135
140
|
/**
|
|
136
141
|
* Predicate to determine if it is valid to move the object to a new position when it is moved.
|
|
137
142
|
* In the case of rotation gizmo, target contains the angle.
|
|
@@ -223,7 +228,8 @@ export class PointerDragBehavior {
|
|
|
223
228
|
if (this.dragging &&
|
|
224
229
|
this.currentDraggingPointerId == pointerInfo.event.pointerId &&
|
|
225
230
|
pointerInfo.event.button !== -1 &&
|
|
226
|
-
pointerInfo.event.button !== this._activeDragButton
|
|
231
|
+
pointerInfo.event.button !== this._activeDragButton &&
|
|
232
|
+
!this.allowOtherButtonsDuringDrag) {
|
|
227
233
|
this.releaseDrag();
|
|
228
234
|
return;
|
|
229
235
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"pointerDragBehavior.js","sourceRoot":"","sources":["../../../../../dev/core/src/Behaviors/Meshes/pointerDragBehavior.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,IAAI,EAAE,MAAM,mBAAmB,CAAC;AAEzC,OAAO,EAAE,KAAK,EAAE,MAAM,aAAa,CAAC;AAGpC,OAAO,EAAE,UAAU,EAAE,MAAM,uBAAuB,CAAC;AACnD,OAAO,EAAE,UAAU,EAAE,OAAO,EAAE,MAAM,yBAAyB,CAAC;AAE9D,OAAO,EAAE,iBAAiB,EAAE,MAAM,4BAA4B,CAAC;AAC/D,OAAO,EAAE,GAAG,EAAE,MAAM,mBAAmB,CAAC;AACxC,OAAO,EAAE,UAAU,EAAE,MAAM,uBAAuB,CAAC;AAEnD,OAAO,EAAE,WAAW,EAAE,MAAM,oCAAoC,CAAC;AAGjE,OAAO,EAAE,OAAO,EAAE,MAAM,4BAA4B,CAAC;AAErD;;GAEG;AACH,MAAM,OAAO,mBAAmB;IA0B5B;;;OAGG;IACH,gEAAgE;IAChE,IAAW,wBAAwB;QAC/B,OAAO,IAAI,CAAC,wBAAwB,CAAC;IACzC,CAAC;IACD,gEAAgE;IAChE,IAAW,wBAAwB,CAAC,wBAAgC;QAChE,IAAI,CAAC,wBAAwB,GAAG,wBAAwB,CAAC;IAC7D,CAAC;IAiED;;OAEG;IACH,IAAW,OAAO,CAAC,KAAc;QAC7B,IAAI,KAAK,IAAI,IAAI,CAAC,QAAQ,EAAE,CAAC;YACzB,IAAI,CAAC,mBAAmB,CAAC,eAAe,CAAC,K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AAC,QAAQ,CAAC,IAAI,CAAC,YAAY,CAAC,mBAAmB,EAAE,CAAC,CAAC;QAE3E,IAAI,CAAC,UAAU,CAAC,kBAAkB,CAAC,IAAI,CAAC,CAAC;IAC7C,CAAC;IAED;;OAEG;IACI,MAAM;QACT,IAAI,CAAC,eAAe,GAAG,EAAE,CAAC;QAC1B,IAAI,IAAI,CAAC,YAAY,EAAE,CAAC;YACpB,IAAI,CAAC,YAAY,CAAC,eAAe,GAAG,KAAK,CAAC;QAC9C,CAAC;QACD,IAAI,IAAI,CAAC,gBAAgB,EAAE,CAAC;YACxB,IAAI,CAAC,MAAM,CAAC,mBAAmB,CAAC,MAAM,CAAC,IAAI,CAAC,gBAAgB,CAAC,CAAC;QAClE,CAAC;QACD,IAAI,IAAI,CAAC,qBAAqB,EAAE,CAAC;YAC7B,IAAI,CAAC,MAAM,CAAC,wBAAwB,CAAC,MAAM,CAAC,IAAI,CAAC,qBAAqB,CAAC,CAAC;QAC5E,CAAC;QACD,IAAI,IAAI,CAAC,UAAU,EAAE,CAAC;YAClB,IAAI,CAAC,UAAU,CAAC,OAAO,EAAE,CAAC;QAC9B,CAAC;QACD,IAAI,CAAC,WAAW,EAAE,CAAC;IACvB,CAAC;;AArlBc,+BAAW,GAAG,CAAC,CAAC,AAAL,CAAM","sourcesContent":["import type { Behavior } from \"../../Behaviors/behavior\";\r\nimport { Mesh } from \"../../Meshes/mesh\";\r\nimport type { AbstractMesh } from \"../../Meshes/abstractMesh\";\r\nimport { Scene } from \"../../scene\";\r\nimport type { Nullable } from \"../../types\";\r\nimport type { Observer } from \"../../Misc/observable\";\r\nimport { Observable } from \"../../Misc/observable\";\r\nimport { TmpVectors, Vector3 } from \"../../Maths/math.vector\";\r\nimport type { PointerInfo } from \"../../Events/pointerEvents\";\r\nimport { PointerEventTypes } from \"../../Events/pointerEvents\";\r\nimport { Ray } from \"../../Culling/ray\";\r\nimport { PivotTools } from \"../../Misc/pivotTools\";\r\nimport type { ArcRotateCamera } from \"../../Cameras/arcRotateCamera\";\r\nimport { CreatePlane } from \"../../Meshes/Builders/planeBuilder\";\r\n\r\nimport type { IPointerEvent } from \"../../Events/deviceInputEvents\";\r\nimport { Epsilon } from \"../../Maths/math.constants\";\r\n\r\n/**\r\n * A behavior that when attached to a mesh will allow the mesh to be dragged around the screen based on pointer events\r\n */\r\nexport class PointerDragBehavior implements Behavior<AbstractMesh> {\r\n private static _AnyMouseId = -2;\r\n /**\r\n * Abstract mesh the behavior is set on\r\n */\r\n public attachedNode: AbstractMesh;\r\n protected _dragPlane: Mesh;\r\n private _scene: Scene;\r\n private _pointerObserver: Nullable<Observer<PointerInfo>>;\r\n private _beforeRenderObserver: Nullable<Observer<Scene>>;\r\n private static _PlaneScene: Scene;\r\n private _useAlternatePickedPointAboveMaxDragAngleDragSpeed = -1.1;\r\n private _activeDragButton: number = -1;\r\n private _activePointerInfo: Nullable<PointerInfo>;\r\n /**\r\n * The maximum tolerated angle between the drag plane and dragging pointer rays to trigger pointer events. Set to 0 to allow any angle (default: 0)\r\n */\r\n public maxDragAngle = 0;\r\n /**\r\n * Butttons that can be used to initiate a drag\r\n */\r\n public dragButtons = [0, 1, 2];\r\n /**\r\n * @internal\r\n */\r\n public _useAlternatePickedPointAboveMaxDragAngle = false;\r\n /**\r\n * Get or set the currentDraggingPointerId\r\n * @deprecated Please use currentDraggingPointerId instead\r\n */\r\n // eslint-disable-next-line @typescript-eslint/naming-convention\r\n public get currentDraggingPointerID(): number {\r\n return this.currentDraggingPointerId;\r\n }\r\n // eslint-disable-next-line @typescript-eslint/naming-convention\r\n public set currentDraggingPointerID(currentDraggingPointerId: number) {\r\n this.currentDraggingPointerId = currentDraggingPointerId;\r\n }\r\n /**\r\n * The id of the pointer that is currently interacting with the behavior (-1 when no pointer is active)\r\n */\r\n public currentDraggingPointerId = -1;\r\n /**\r\n * The last position where the pointer hit the drag plane in world space\r\n */\r\n public lastDragPosition: Vector3;\r\n /**\r\n * If the behavior is currently in a dragging state\r\n */\r\n public dragging = false;\r\n /**\r\n * The distance towards the target drag position to move each frame. This can be useful to avoid jitter. Set this to 1 for no delay. (Default: 0.2)\r\n */\r\n public dragDeltaRatio = 0.2;\r\n /**\r\n * If the drag plane orientation should be updated during the dragging (Default: true)\r\n */\r\n public updateDragPlane = true;\r\n // Debug mode will display drag planes to help visualize behavior\r\n private _debugMode = false;\r\n private _moving = false;\r\n /**\r\n * Fires each time the attached mesh is dragged with the pointer\r\n * * delta between last drag position and current drag position in world space\r\n * * dragDistance along the drag axis\r\n * * dragPlaneNormal normal of the current drag plane used during the drag\r\n * * dragPlanePoint in world space where the drag intersects the drag plane\r\n *\r\n * (if validatedDrag is used, the position of the attached mesh might not equal dragPlanePoint)\r\n */\r\n public onDragObservable = new Observable<{\r\n delta: Vector3;\r\n dragPlanePoint: Vector3;\r\n dragPlaneNormal: Vector3;\r\n dragDistance: number;\r\n pointerId: number;\r\n pointerInfo: Nullable<PointerInfo>;\r\n }>();\r\n /**\r\n * Fires each time a drag begins (eg. mouse down on mesh)\r\n * * dragPlanePoint in world space where the drag intersects the drag plane\r\n *\r\n * (if validatedDrag is used, the position of the attached mesh might not equal dragPlanePoint)\r\n */\r\n public onDragStartObservable = new Observable<{ dragPlanePoint: Vector3; pointerId: number; pointerInfo: Nullable<PointerInfo> }>();\r\n /**\r\n * Fires each time a drag ends (eg. mouse release after drag)\r\n * * dragPlanePoint in world space where the drag intersects the drag plane\r\n *\r\n * (if validatedDrag is used, the position of the attached mesh might not equal dragPlanePoint)\r\n */\r\n public onDragEndObservable = new Observable<{ dragPlanePoint: Vector3; pointerId: number; pointerInfo: Nullable<PointerInfo> }>();\r\n /**\r\n * Fires each time behavior enabled state changes\r\n */\r\n public onEnabledObservable = new Observable<boolean>();\r\n\r\n /**\r\n * If the attached mesh should be moved when dragged\r\n */\r\n public moveAttached = true;\r\n\r\n /**\r\n * If the drag behavior will react to drag events (Default: true)\r\n */\r\n public set enabled(value: boolean) {\r\n if (value != this._enabled) {\r\n this.onEnabledObservable.notifyObservers(value);\r\n }\r\n this._enabled = value;\r\n }\r\n\r\n public get enabled() {\r\n return this._enabled;\r\n }\r\n private _enabled = true;\r\n\r\n /**\r\n * If pointer events should start and release the drag (Default: true)\r\n */\r\n public startAndReleaseDragOnPointerEvents = true;\r\n /**\r\n * If camera controls should be detached during the drag\r\n */\r\n public detachCameraControls = true;\r\n\r\n /**\r\n * If set, the drag plane/axis will be rotated based on the attached mesh's world rotation (Default: true)\r\n */\r\n public useObjectOrientationForDragging = true;\r\n\r\n private _options: { dragAxis?: Vector3; dragPlaneNormal?: Vector3 };\r\n\r\n /**\r\n * Gets the options used by the behavior\r\n */\r\n public get options(): { dragAxis?: Vector3; dragPlaneNormal?: Vector3 } {\r\n return this._options;\r\n }\r\n\r\n /**\r\n * Sets the options used by the behavior\r\n */\r\n public set options(options: { dragAxis?: Vector3; dragPlaneNormal?: Vector3 }) {\r\n this._options = options;\r\n }\r\n\r\n /**\r\n * Creates a pointer drag behavior that can be attached to a mesh\r\n * @param options The drag axis or normal of the plane that will be dragged across. If no options are specified the drag plane will always face the ray's origin (eg. camera)\r\n * @param options.dragAxis\r\n * @param options.dragPlaneNormal\r\n */\r\n constructor(options?: { dragAxis?: Vector3; dragPlaneNormal?: Vector3 }) {\r\n this._options = options ? options : {};\r\n\r\n let optionCount = 0;\r\n if (this._options.dragAxis) {\r\n optionCount++;\r\n }\r\n if (this._options.dragPlaneNormal) {\r\n optionCount++;\r\n }\r\n if (optionCount > 1) {\r\n // eslint-disable-next-line no-throw-literal\r\n throw \"Multiple drag modes specified in dragBehavior options. Only one expected\";\r\n }\r\n }\r\n\r\n /**\r\n * Predicate to determine if it is valid to move the object to a new position when it is moved.\r\n * In the case of rotation gizmo, target contains the angle.\r\n * @param target destination position or desired angle delta\r\n * @returns boolean for whether or not it is valid to move\r\n */\r\n // eslint-disable-next-line @typescript-eslint/no-unused-vars\r\n public validateDrag = (target: Vector3) => {\r\n return true;\r\n };\r\n\r\n /**\r\n * The name of the behavior\r\n */\r\n public get name(): string {\r\n return \"PointerDrag\";\r\n }\r\n\r\n /**\r\n * Initializes the behavior\r\n */\r\n public init() {}\r\n\r\n private _tmpVector = new Vector3(0, 0, 0);\r\n private _alternatePickedPoint = new Vector3(0, 0, 0);\r\n private _worldDragAxis = new Vector3(0, 0, 0);\r\n private _targetPosition = new Vector3(0, 0, 0);\r\n private _attachedToElement: boolean = false;\r\n /**\r\n * Attaches the drag behavior the passed in mesh\r\n * @param ownerNode The mesh that will be dragged around once attached\r\n * @param predicate Predicate to use for pick filtering\r\n */\r\n public attach(ownerNode: AbstractMesh, predicate?: (m: AbstractMesh) => boolean): void {\r\n this._scene = ownerNode.getScene();\r\n ownerNode.isNearGrabbable = true;\r\n this.attachedNode = ownerNode;\r\n\r\n // Initialize drag plane to not interfere with existing scene\r\n if (!PointerDragBehavior._PlaneScene) {\r\n if (this._debugMode) {\r\n PointerDragBehavior._PlaneScene = this._scene;\r\n } else {\r\n PointerDragBehavior._PlaneScene = new Scene(this._scene.getEngine(), { virtual: true });\r\n PointerDragBehavior._PlaneScene.detachControl();\r\n this._scene.onDisposeObservable.addOnce(() => {\r\n PointerDragBehavior._PlaneScene.dispose();\r\n (<any>PointerDragBehavior._PlaneScene) = null;\r\n });\r\n }\r\n }\r\n this._dragPlane = CreatePlane(\r\n \"pointerDragPlane\",\r\n { size: this._debugMode ? 1 : 10000, updatable: false, sideOrientation: Mesh.DOUBLESIDE },\r\n PointerDragBehavior._PlaneScene\r\n );\r\n\r\n // State of the drag\r\n this.lastDragPosition = new Vector3(0, 0, 0);\r\n\r\n const pickPredicate = predicate\r\n ? predicate\r\n : (m: AbstractMesh) => {\r\n return this.attachedNode == m || m.isDescendantOf(this.attachedNode);\r\n };\r\n\r\n this._pointerObserver = this._scene.onPointerObservable.add((pointerInfo) => {\r\n if (!this.enabled) {\r\n // If behavior is disabled before releaseDrag is ever called, call it now.\r\n if (this._attachedToElement) {\r\n this.releaseDrag();\r\n }\r\n\r\n return;\r\n }\r\n\r\n // If we are dragging and the user presses another button on the same pointer, end the drag. Otherwise,\r\n // tracking when the drag should end becomes very complex.\r\n // gizmo.ts has similar behavior.\r\n if (\r\n this.dragging &&\r\n this.currentDraggingPointerId == (<IPointerEvent>pointerInfo.event).pointerId &&\r\n pointerInfo.event.button !== -1 &&\r\n pointerInfo.event.button !== this._activeDragButton\r\n ) {\r\n this.releaseDrag();\r\n return;\r\n }\r\n\r\n if (pointerInfo.type == PointerEventTypes.POINTERDOWN) {\r\n if (\r\n this.startAndReleaseDragOnPointerEvents &&\r\n !this.dragging &&\r\n pointerInfo.pickInfo &&\r\n pointerInfo.pickInfo.hit &&\r\n pointerInfo.pickInfo.pickedMesh &&\r\n pointerInfo.pickInfo.pickedPoint &&\r\n pointerInfo.pickInfo.ray &&\r\n pickPredicate(pointerInfo.pickInfo.pickedMesh)\r\n ) {\r\n if (this._activeDragButton === -1 && this.dragButtons.indexOf(pointerInfo.event.button) !== -1) {\r\n this._activeDragButton = pointerInfo.event.button;\r\n this._activePointerInfo = pointerInfo;\r\n this._startDrag((<IPointerEvent>pointerInfo.event).pointerId, pointerInfo.pickInfo.ray, pointerInfo.pickInfo.pickedPoint);\r\n }\r\n }\r\n } else if (pointerInfo.type == PointerEventTypes.POINTERUP) {\r\n if (\r\n this.startAndReleaseDragOnPointerEvents &&\r\n this.currentDraggingPointerId == (<IPointerEvent>pointerInfo.event).pointerId &&\r\n (this._activeDragButton === pointerInfo.event.button || this._activeDragButton === -1)\r\n ) {\r\n this.releaseDrag();\r\n }\r\n } else if (pointerInfo.type == PointerEventTypes.POINTERMOVE) {\r\n const pointerId = (<IPointerEvent>pointerInfo.event).pointerId;\r\n\r\n // If drag was started with anyMouseID specified, set pointerID to the next mouse that moved\r\n if (this.currentDraggingPointerId === PointerDragBehavior._AnyMouseId && pointerId !== PointerDragBehavior._AnyMouseId) {\r\n const evt = <IPointerEvent>pointerInfo.event;\r\n const isMouseEvent = evt.pointerType === \"mouse\" || (!this._scene.getEngine().hostInformation.isMobile && evt instanceof MouseEvent);\r\n if (isMouseEvent) {\r\n if (this._lastPointerRay[this.currentDraggingPointerId]) {\r\n this._lastPointerRay[pointerId] = this._lastPointerRay[this.currentDraggingPointerId];\r\n delete this._lastPointerRay[this.currentDraggingPointerId];\r\n }\r\n this.currentDraggingPointerId = pointerId;\r\n }\r\n }\r\n\r\n // Keep track of last pointer ray, this is used simulating the start of a drag in startDrag()\r\n if (!this._lastPointerRay[pointerId]) {\r\n this._lastPointerRay[pointerId] = new Ray(new Vector3(), new Vector3());\r\n }\r\n if (pointerInfo.pickInfo && pointerInfo.pickInfo.ray) {\r\n this._lastPointerRay[pointerId].origin.copyFrom(pointerInfo.pickInfo.ray.origin);\r\n this._lastPointerRay[pointerId].direction.copyFrom(pointerInfo.pickInfo.ray.direction);\r\n\r\n if (this.currentDraggingPointerId == pointerId && this.dragging) {\r\n this._moveDrag(pointerInfo.pickInfo.ray);\r\n }\r\n }\r\n }\r\n });\r\n\r\n this._beforeRenderObserver = this._scene.onBeforeRenderObservable.add(() => {\r\n if (this._moving && this.moveAttached) {\r\n let needMatrixUpdate = false;\r\n PivotTools._RemoveAndStorePivotPoint(this.attachedNode);\r\n // Slowly move mesh to avoid jitter\r\n this._targetPosition.subtractToRef(this.attachedNode.absolutePosition, this._tmpVector);\r\n this._tmpVector.scaleInPlace(this.dragDeltaRatio);\r\n this.attachedNode.getAbsolutePosition().addToRef(this._tmpVector, this._tmpVector);\r\n if (this.validateDrag(this._tmpVector)) {\r\n this.attachedNode.setAbsolutePosition(this._tmpVector);\r\n needMatrixUpdate = true;\r\n }\r\n PivotTools._RestorePivotPoint(this.attachedNode);\r\n if (needMatrixUpdate) {\r\n this.attachedNode.computeWorldMatrix();\r\n }\r\n }\r\n });\r\n }\r\n\r\n /**\r\n * Force release the drag action by code.\r\n */\r\n public releaseDrag() {\r\n if (this.dragging) {\r\n this.dragging = false;\r\n this.onDragEndObservable.notifyObservers({ dragPlanePoint: this.lastDragPosition, pointerId: this.currentDraggingPointerId, pointerInfo: this._activePointerInfo });\r\n }\r\n\r\n this.currentDraggingPointerId = -1;\r\n this._activeDragButton = -1;\r\n this._activePointerInfo = null;\r\n this._moving = false;\r\n\r\n // Reattach camera controls\r\n if (this.detachCameraControls && this._attachedToElement && this._scene.activeCamera && !this._scene.activeCamera.leftCamera) {\r\n if (this._scene.activeCamera.getClassName() === \"ArcRotateCamera\") {\r\n const arcRotateCamera = this._scene.activeCamera as ArcRotateCamera;\r\n arcRotateCamera.attachControl(\r\n arcRotateCamera.inputs ? arcRotateCamera.inputs.noPreventDefault : true,\r\n arcRotateCamera._useCtrlForPanning,\r\n arcRotateCamera._panningMouseButton\r\n );\r\n } else {\r\n this._scene.activeCamera.attachControl(this._scene.activeCamera.inputs ? this._scene.activeCamera.inputs.noPreventDefault : true);\r\n }\r\n this._attachedToElement = false;\r\n }\r\n }\r\n\r\n private _startDragRay = new Ray(new Vector3(), new Vector3());\r\n private _lastPointerRay: { [key: number]: Ray } = {};\r\n /**\r\n * Simulates the start of a pointer drag event on the behavior\r\n * @param pointerId pointerID of the pointer that should be simulated (Default: Any mouse pointer ID)\r\n * @param fromRay initial ray of the pointer to be simulated (Default: Ray from camera to attached mesh)\r\n * @param startPickedPoint picked point of the pointer to be simulated (Default: attached mesh position)\r\n */\r\n public startDrag(pointerId: number = PointerDragBehavior._AnyMouseId, fromRay?: Ray, startPickedPoint?: Vector3) {\r\n this._startDrag(pointerId, fromRay, startPickedPoint);\r\n\r\n let lastRay = this._lastPointerRay[pointerId];\r\n if (pointerId === PointerDragBehavior._AnyMouseId) {\r\n lastRay = this._lastPointerRay[<any>Object.keys(this._lastPointerRay)[0]];\r\n }\r\n\r\n if (lastRay) {\r\n // if there was a last pointer ray drag the object there\r\n this._moveDrag(lastRay);\r\n }\r\n }\r\n\r\n protected _startDrag(pointerId: number, fromRay?: Ray, startPickedPoint?: Vector3) {\r\n if (!this._scene.activeCamera || this.dragging || !this.attachedNode) {\r\n return;\r\n }\r\n\r\n PivotTools._RemoveAndStorePivotPoint(this.attachedNode);\r\n // Create start ray from the camera to the object\r\n if (fromRay) {\r\n this._startDragRay.direction.copyFrom(fromRay.direction);\r\n this._startDragRay.origin.copyFrom(fromRay.origin);\r\n } else {\r\n this._startDragRay.origin.copyFrom(this._scene.activeCamera.position);\r\n this.attachedNode.getWorldMatrix().getTranslationToRef(this._tmpVector);\r\n this._tmpVector.subtractToRef(this._scene.activeCamera.position, this._startDragRay.direction);\r\n }\r\n\r\n this._updateDragPlanePosition(this._startDragRay, startPickedPoint ? startPickedPoint : this._tmpVector);\r\n\r\n const pickedPoint = this._pickWithRayOnDragPlane(this._startDragRay);\r\n if (pickedPoint) {\r\n this.dragging = true;\r\n this.currentDraggingPointerId = pointerId;\r\n this.lastDragPosition.copyFrom(pickedPoint);\r\n this.onDragStartObservable.notifyObservers({ dragPlanePoint: pickedPoint, pointerId: this.currentDraggingPointerId, pointerInfo: this._activePointerInfo });\r\n this._targetPosition.copyFrom(this.attachedNode.getAbsolutePosition());\r\n\r\n // Detatch camera controls\r\n if (this.detachCameraControls && this._scene.activeCamera && this._scene.activeCamera.inputs && !this._scene.activeCamera.leftCamera) {\r\n if (this._scene.activeCamera.inputs.attachedToElement) {\r\n this._scene.activeCamera.detachControl();\r\n this._attachedToElement = true;\r\n } else {\r\n this._attachedToElement = false;\r\n }\r\n }\r\n } else {\r\n this.releaseDrag();\r\n }\r\n PivotTools._RestorePivotPoint(this.attachedNode);\r\n }\r\n\r\n private _dragDelta = new Vector3();\r\n protected _moveDrag(ray: Ray) {\r\n this._moving = true;\r\n const pickedPoint = this._pickWithRayOnDragPlane(ray);\r\n\r\n if (pickedPoint) {\r\n PivotTools._RemoveAndStorePivotPoint(this.attachedNode);\r\n\r\n if (this.updateDragPlane) {\r\n this._updateDragPlanePosition(ray, pickedPoint);\r\n }\r\n let dragLength = 0;\r\n // depending on the drag mode option drag accordingly\r\n if (this._options.dragAxis) {\r\n // Convert local drag axis to world if useObjectOrientationForDragging\r\n this.useObjectOrientationForDragging\r\n ? Vector3.TransformCoordinatesToRef(this._options.dragAxis, this.attachedNode.getWorldMatrix().getRotationMatrix(), this._worldDragAxis)\r\n : this._worldDragAxis.copyFrom(this._options.dragAxis);\r\n // Project delta drag from the drag plane onto the drag axis\r\n pickedPoint.subtractToRef(this.lastDragPosition, this._tmpVector);\r\n\r\n this._worldDragAxis.normalize();\r\n dragLength = Vector3.Dot(this._tmpVector, this._worldDragAxis);\r\n this._worldDragAxis.scaleToRef(dragLength, this._dragDelta);\r\n } else {\r\n dragLength = this._dragDelta.length();\r\n pickedPoint.subtractToRef(this.lastDragPosition, this._dragDelta);\r\n }\r\n this._targetPosition.addInPlace(this._dragDelta);\r\n this.onDragObservable.notifyObservers({\r\n dragDistance: dragLength,\r\n delta: this._dragDelta,\r\n dragPlanePoint: pickedPoint,\r\n dragPlaneNormal: this._dragPlane.forward,\r\n pointerId: this.currentDraggingPointerId,\r\n pointerInfo: this._activePointerInfo,\r\n });\r\n this.lastDragPosition.copyFrom(pickedPoint);\r\n\r\n PivotTools._RestorePivotPoint(this.attachedNode);\r\n }\r\n }\r\n\r\n private _pickWithRayOnDragPlane(ray: Nullable<Ray>) {\r\n if (!ray) {\r\n return null;\r\n }\r\n\r\n // Calculate angle between plane normal and ray\r\n let angle = Math.acos(Vector3.Dot(this._dragPlane.forward, ray.direction));\r\n // Correct if ray is casted from oposite side\r\n if (angle > Math.PI / 2) {\r\n angle = Math.PI - angle;\r\n }\r\n\r\n // If the angle is too perpendicular to the plane pick another point on the plane where it is looking\r\n if (this.maxDragAngle > 0 && angle > this.maxDragAngle) {\r\n if (this._useAlternatePickedPointAboveMaxDragAngle) {\r\n // Invert ray direction along the towards object axis\r\n this._tmpVector.copyFrom(ray.direction);\r\n this.attachedNode.absolutePosition.subtractToRef(ray.origin, this._alternatePickedPoint);\r\n this._alternatePickedPoint.normalize();\r\n this._alternatePickedPoint.scaleInPlace(this._useAlternatePickedPointAboveMaxDragAngleDragSpeed * Vector3.Dot(this._alternatePickedPoint, this._tmpVector));\r\n this._tmpVector.addInPlace(this._alternatePickedPoint);\r\n\r\n // Project resulting vector onto the drag plane and add it to the attached nodes absolute position to get a picked point\r\n const dot = Vector3.Dot(this._dragPlane.forward, this._tmpVector);\r\n this._dragPlane.forward.scaleToRef(-dot, this._alternatePickedPoint);\r\n this._alternatePickedPoint.addInPlace(this._tmpVector);\r\n this._alternatePickedPoint.addInPlace(this.attachedNode.absolutePosition);\r\n return this._alternatePickedPoint;\r\n } else {\r\n return null;\r\n }\r\n }\r\n\r\n // use an infinite plane instead of ray picking a mesh that must be updated every frame\r\n const planeNormal = this._dragPlane.forward;\r\n const planePosition = this._dragPlane.position;\r\n const dotProduct = ray.direction.dot(planeNormal);\r\n if (Math.abs(dotProduct) < Epsilon) {\r\n // Ray and plane are parallel, no intersection\r\n return null;\r\n }\r\n\r\n planePosition.subtractToRef(ray.origin, TmpVectors.Vector3[0]);\r\n const t = TmpVectors.Vector3[0].dot(planeNormal) / dotProduct;\r\n // Ensure the intersection point is in front of the ray (t must be positive)\r\n if (t < 0) {\r\n // Intersection point is behind the ray\r\n return null;\r\n }\r\n\r\n // Calculate the intersection point using the parameter t\r\n ray.direction.scaleToRef(t, TmpVectors.Vector3[0]);\r\n const intersectionPoint = ray.origin.add(TmpVectors.Vector3[0]);\r\n return intersectionPoint;\r\n }\r\n\r\n // Variables to avoid instantiation in the below method\r\n private _pointA = new Vector3(0, 0, 0);\r\n private _pointC = new Vector3(0, 0, 0);\r\n private _localAxis = new Vector3(0, 0, 0);\r\n private _lookAt = new Vector3(0, 0, 0);\r\n // Position the drag plane based on the attached mesh position, for single axis rotate the plane along the axis to face the camera\r\n private _updateDragPlanePosition(ray: Ray, dragPlanePosition: Vector3) {\r\n this._pointA.copyFrom(dragPlanePosition);\r\n if (this._options.dragAxis) {\r\n this.useObjectOrientationForDragging\r\n ? Vector3.TransformCoordinatesToRef(this._options.dragAxis, this.attachedNode.getWorldMatrix().getRotationMatrix(), this._localAxis)\r\n : this._localAxis.copyFrom(this._options.dragAxis);\r\n\r\n // Calculate plane normal that is the cross product of local axis and (eye-dragPlanePosition)\r\n ray.origin.subtractToRef(this._pointA, this._pointC);\r\n this._pointC.normalize();\r\n if (Math.abs(Vector3.Dot(this._localAxis, this._pointC)) > 0.999) {\r\n // the drag axis is colinear with the (eye to position) ray. The cross product will give jittered values.\r\n // A new axis vector need to be computed\r\n if (Math.abs(Vector3.Dot(Vector3.UpReadOnly, this._pointC)) > 0.999) {\r\n this._lookAt.copyFrom(Vector3.Right());\r\n } else {\r\n this._lookAt.copyFrom(Vector3.UpReadOnly);\r\n }\r\n } else {\r\n Vector3.CrossToRef(this._localAxis, this._pointC, this._lookAt);\r\n // Get perpendicular line from previous result and drag axis to adjust lineB to be perpendicular to camera\r\n Vector3.CrossToRef(this._localAxis, this._lookAt, this._lookAt);\r\n this._lookAt.normalize();\r\n }\r\n\r\n this._dragPlane.position.copyFrom(this._pointA);\r\n this._pointA.addToRef(this._lookAt, this._lookAt);\r\n this._dragPlane.lookAt(this._lookAt);\r\n } else if (this._options.dragPlaneNormal) {\r\n this.useObjectOrientationForDragging\r\n ? Vector3.TransformCoordinatesToRef(this._options.dragPlaneNormal, this.attachedNode.getWorldMatrix().getRotationMatrix(), this._localAxis)\r\n : this._localAxis.copyFrom(this._options.dragPlaneNormal);\r\n this._dragPlane.position.copyFrom(this._pointA);\r\n this._pointA.addToRef(this._localAxis, this._lookAt);\r\n this._dragPlane.lookAt(this._lookAt);\r\n } else {\r\n if (this._scene.activeCamera) {\r\n this._scene.activeCamera.getForwardRay().direction.normalizeToRef(this._localAxis);\r\n }\r\n this._dragPlane.position.copyFrom(this._pointA);\r\n this._dragPlane.lookAt(this._pointA.add(this._localAxis));\r\n }\r\n // Update the position of the drag plane so it doesn't get out of sync with the node (eg. when moving back and forth quickly)\r\n this._dragPlane.position.copyFrom(this.attachedNode.getAbsolutePosition());\r\n\r\n this._dragPlane.computeWorldMatrix(true);\r\n }\r\n\r\n /**\r\n * Detaches the behavior from the mesh\r\n */\r\n public detach(): void {\r\n this._lastPointerRay = {};\r\n if (this.attachedNode) {\r\n this.attachedNode.isNearGrabbable = false;\r\n }\r\n if (this._pointerObserver) {\r\n this._scene.onPointerObservable.remove(this._pointerObserver);\r\n }\r\n if (this._beforeRenderObserver) {\r\n this._scene.onBeforeRenderObservable.remove(this._beforeRenderObserver);\r\n }\r\n if (this._dragPlane) {\r\n this._dragPlane.dispose();\r\n }\r\n this.releaseDrag();\r\n }\r\n}\r\n"]}
|
|
1
|
+
{"version":3,"file":"pointerDragBehavior.js","sourceRoot":"","sources":["../../../../../dev/core/src/Behaviors/Meshes/pointerDragBehavior.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,IAAI,EAAE,MAAM,mBAAmB,CAAC;AAEzC,OAAO,EAAE,KAAK,EAAE,MAAM,aAAa,CAAC;AAGpC,OAAO,EAAE,UAAU,EAAE,MAAM,uBAAuB,CAAC;AACnD,OAAO,EAAE,UAAU,EAAE,OAAO,EAAE,MAAM,yBAAyB,CAAC;AAE9D,OAAO,EAAE,iBAAiB,EAAE,MAAM,4BAA4B,CAAC;AAC/D,OAAO,EAAE,GAAG,EAAE,MAAM,mBAAmB,CAAC;AACxC,OAAO,EAAE,UAAU,EAAE,MAAM,uBAAuB,CAAC;AAEnD,OAAO,EAAE,WAAW,EAAE,MAAM,oCAAoC,CAAC;AAGjE,OAAO,EAAE,OAAO,EAAE,MAAM,4BAA4B,CAAC;AAErD;;GAEG;AACH,MAAM,OAAO,mBAAmB;IA0B5B;;;OAGG;IACH,gEAAgE;IAChE,IAAW,wBAAwB;QAC/B,OAAO,IAAI,CAAC,wBAAwB,CAAC;IACzC,CAAC;IACD,gEAAgE;IAChE,IAAW,wBAAwB,CAAC,wBAAgC;QAChE,IAAI,CAAC,wBAAwB,GAAG,wBAAwB,CAAC;IAC7D,CAAC;IAiED;;OAEG;IACH,IAAW,OAAO,CAAC,KAAc;QAC7B,IAAI,KAA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AC,UAAU,CAAC,MAAM,CAAC,IAAI,CAAC,OAAO,CAAC,GAAG,CAAC,IAAI,CAAC,UAAU,CAAC,CAAC,CAAC;QAC9D,CAAC;QACD,6HAA6H;QAC7H,IAAI,CAAC,UAAU,CAAC,QAAQ,CAAC,QAAQ,CAAC,IAAI,CAAC,YAAY,CAAC,mBAAmB,EAAE,CAAC,CAAC;QAE3E,IAAI,CAAC,UAAU,CAAC,kBAAkB,CAAC,IAAI,CAAC,CAAC;IAC7C,CAAC;IAED;;OAEG;IACI,MAAM;QACT,IAAI,CAAC,eAAe,GAAG,EAAE,CAAC;QAC1B,IAAI,IAAI,CAAC,YAAY,EAAE,CAAC;YACpB,IAAI,CAAC,YAAY,CAAC,eAAe,GAAG,KAAK,CAAC;QAC9C,CAAC;QACD,IAAI,IAAI,CAAC,gBAAgB,EAAE,CAAC;YACxB,IAAI,CAAC,MAAM,CAAC,mBAAmB,CAAC,MAAM,CAAC,IAAI,CAAC,gBAAgB,CAAC,CAAC;QAClE,CAAC;QACD,IAAI,IAAI,CAAC,qBAAqB,EAAE,CAAC;YAC7B,IAAI,CAAC,MAAM,CAAC,wBAAwB,CAAC,MAAM,CAAC,IAAI,CAAC,qBAAqB,CAAC,CAAC;QAC5E,CAAC;QACD,IAAI,IAAI,CAAC,UAAU,EAAE,CAAC;YAClB,IAAI,CAAC,UAAU,CAAC,OAAO,EAAE,CAAC;QAC9B,CAAC;QACD,IAAI,CAAC,WAAW,EAAE,CAAC;IACvB,CAAC;;AA5lBc,+BAAW,GAAG,CAAC,CAAC,AAAL,CAAM","sourcesContent":["import type { Behavior } from \"../../Behaviors/behavior\";\r\nimport { Mesh } from \"../../Meshes/mesh\";\r\nimport type { AbstractMesh } from \"../../Meshes/abstractMesh\";\r\nimport { Scene } from \"../../scene\";\r\nimport type { Nullable } from \"../../types\";\r\nimport type { Observer } from \"../../Misc/observable\";\r\nimport { Observable } from \"../../Misc/observable\";\r\nimport { TmpVectors, Vector3 } from \"../../Maths/math.vector\";\r\nimport type { PointerInfo } from \"../../Events/pointerEvents\";\r\nimport { PointerEventTypes } from \"../../Events/pointerEvents\";\r\nimport { Ray } from \"../../Culling/ray\";\r\nimport { PivotTools } from \"../../Misc/pivotTools\";\r\nimport type { ArcRotateCamera } from \"../../Cameras/arcRotateCamera\";\r\nimport { CreatePlane } from \"../../Meshes/Builders/planeBuilder\";\r\n\r\nimport type { IPointerEvent } from \"../../Events/deviceInputEvents\";\r\nimport { Epsilon } from \"../../Maths/math.constants\";\r\n\r\n/**\r\n * A behavior that when attached to a mesh will allow the mesh to be dragged around the screen based on pointer events\r\n */\r\nexport class PointerDragBehavior implements Behavior<AbstractMesh> {\r\n private static _AnyMouseId = -2;\r\n /**\r\n * Abstract mesh the behavior is set on\r\n */\r\n public attachedNode: AbstractMesh;\r\n protected _dragPlane: Mesh;\r\n private _scene: Scene;\r\n private _pointerObserver: Nullable<Observer<PointerInfo>>;\r\n private _beforeRenderObserver: Nullable<Observer<Scene>>;\r\n private static _PlaneScene: Scene;\r\n private _useAlternatePickedPointAboveMaxDragAngleDragSpeed = -1.1;\r\n private _activeDragButton: number = -1;\r\n private _activePointerInfo: Nullable<PointerInfo>;\r\n /**\r\n * The maximum tolerated angle between the drag plane and dragging pointer rays to trigger pointer events. Set to 0 to allow any angle (default: 0)\r\n */\r\n public maxDragAngle = 0;\r\n /**\r\n * Butttons that can be used to initiate a drag\r\n */\r\n public dragButtons = [0, 1, 2];\r\n /**\r\n * @internal\r\n */\r\n public _useAlternatePickedPointAboveMaxDragAngle = false;\r\n /**\r\n * Get or set the currentDraggingPointerId\r\n * @deprecated Please use currentDraggingPointerId instead\r\n */\r\n // eslint-disable-next-line @typescript-eslint/naming-convention\r\n public get currentDraggingPointerID(): number {\r\n return this.currentDraggingPointerId;\r\n }\r\n // eslint-disable-next-line @typescript-eslint/naming-convention\r\n public set currentDraggingPointerID(currentDraggingPointerId: number) {\r\n this.currentDraggingPointerId = currentDraggingPointerId;\r\n }\r\n /**\r\n * The id of the pointer that is currently interacting with the behavior (-1 when no pointer is active)\r\n */\r\n public currentDraggingPointerId = -1;\r\n /**\r\n * The last position where the pointer hit the drag plane in world space\r\n */\r\n public lastDragPosition: Vector3;\r\n /**\r\n * If the behavior is currently in a dragging state\r\n */\r\n public dragging = false;\r\n /**\r\n * The distance towards the target drag position to move each frame. This can be useful to avoid jitter. Set this to 1 for no delay. (Default: 0.2)\r\n */\r\n public dragDeltaRatio = 0.2;\r\n /**\r\n * If the drag plane orientation should be updated during the dragging (Default: true)\r\n */\r\n public updateDragPlane = true;\r\n // Debug mode will display drag planes to help visualize behavior\r\n private _debugMode = false;\r\n private _moving = false;\r\n /**\r\n * Fires each time the attached mesh is dragged with the pointer\r\n * * delta between last drag position and current drag position in world space\r\n * * dragDistance along the drag axis\r\n * * dragPlaneNormal normal of the current drag plane used during the drag\r\n * * dragPlanePoint in world space where the drag intersects the drag plane\r\n *\r\n * (if validatedDrag is used, the position of the attached mesh might not equal dragPlanePoint)\r\n */\r\n public onDragObservable = new Observable<{\r\n delta: Vector3;\r\n dragPlanePoint: Vector3;\r\n dragPlaneNormal: Vector3;\r\n dragDistance: number;\r\n pointerId: number;\r\n pointerInfo: Nullable<PointerInfo>;\r\n }>();\r\n /**\r\n * Fires each time a drag begins (eg. mouse down on mesh)\r\n * * dragPlanePoint in world space where the drag intersects the drag plane\r\n *\r\n * (if validatedDrag is used, the position of the attached mesh might not equal dragPlanePoint)\r\n */\r\n public onDragStartObservable = new Observable<{ dragPlanePoint: Vector3; pointerId: number; pointerInfo: Nullable<PointerInfo> }>();\r\n /**\r\n * Fires each time a drag ends (eg. mouse release after drag)\r\n * * dragPlanePoint in world space where the drag intersects the drag plane\r\n *\r\n * (if validatedDrag is used, the position of the attached mesh might not equal dragPlanePoint)\r\n */\r\n public onDragEndObservable = new Observable<{ dragPlanePoint: Vector3; pointerId: number; pointerInfo: Nullable<PointerInfo> }>();\r\n /**\r\n * Fires each time behavior enabled state changes\r\n */\r\n public onEnabledObservable = new Observable<boolean>();\r\n\r\n /**\r\n * If the attached mesh should be moved when dragged\r\n */\r\n public moveAttached = true;\r\n\r\n /**\r\n * If the drag behavior will react to drag events (Default: true)\r\n */\r\n public set enabled(value: boolean) {\r\n if (value != this._enabled) {\r\n this.onEnabledObservable.notifyObservers(value);\r\n }\r\n this._enabled = value;\r\n }\r\n\r\n public get enabled() {\r\n return this._enabled;\r\n }\r\n private _enabled = true;\r\n\r\n /**\r\n * If pointer events should start and release the drag (Default: true)\r\n */\r\n public startAndReleaseDragOnPointerEvents = true;\r\n /**\r\n * If camera controls should be detached during the drag\r\n */\r\n public detachCameraControls = true;\r\n\r\n /**\r\n * If set, the drag plane/axis will be rotated based on the attached mesh's world rotation (Default: true)\r\n */\r\n public useObjectOrientationForDragging = true;\r\n\r\n /**\r\n * Normally a drag is canceled when the user presses another button on the same pointer. If this is set to true,\r\n * the drag will continue even if another button is pressed on the same pointer.\r\n */\r\n public allowOtherButtonsDuringDrag = false;\r\n\r\n private _options: { dragAxis?: Vector3; dragPlaneNormal?: Vector3 };\r\n\r\n /**\r\n * Gets the options used by the behavior\r\n */\r\n public get options(): { dragAxis?: Vector3; dragPlaneNormal?: Vector3 } {\r\n return this._options;\r\n }\r\n\r\n /**\r\n * Sets the options used by the behavior\r\n */\r\n public set options(options: { dragAxis?: Vector3; dragPlaneNormal?: Vector3 }) {\r\n this._options = options;\r\n }\r\n\r\n /**\r\n * Creates a pointer drag behavior that can be attached to a mesh\r\n * @param options The drag axis or normal of the plane that will be dragged across. If no options are specified the drag plane will always face the ray's origin (eg. camera)\r\n * @param options.dragAxis\r\n * @param options.dragPlaneNormal\r\n */\r\n constructor(options?: { dragAxis?: Vector3; dragPlaneNormal?: Vector3 }) {\r\n this._options = options ? options : {};\r\n\r\n let optionCount = 0;\r\n if (this._options.dragAxis) {\r\n optionCount++;\r\n }\r\n if (this._options.dragPlaneNormal) {\r\n optionCount++;\r\n }\r\n if (optionCount > 1) {\r\n // eslint-disable-next-line no-throw-literal\r\n throw \"Multiple drag modes specified in dragBehavior options. Only one expected\";\r\n }\r\n }\r\n\r\n /**\r\n * Predicate to determine if it is valid to move the object to a new position when it is moved.\r\n * In the case of rotation gizmo, target contains the angle.\r\n * @param target destination position or desired angle delta\r\n * @returns boolean for whether or not it is valid to move\r\n */\r\n // eslint-disable-next-line @typescript-eslint/no-unused-vars\r\n public validateDrag = (target: Vector3) => {\r\n return true;\r\n };\r\n\r\n /**\r\n * The name of the behavior\r\n */\r\n public get name(): string {\r\n return \"PointerDrag\";\r\n }\r\n\r\n /**\r\n * Initializes the behavior\r\n */\r\n public init() {}\r\n\r\n private _tmpVector = new Vector3(0, 0, 0);\r\n private _alternatePickedPoint = new Vector3(0, 0, 0);\r\n private _worldDragAxis = new Vector3(0, 0, 0);\r\n private _targetPosition = new Vector3(0, 0, 0);\r\n private _attachedToElement: boolean = false;\r\n /**\r\n * Attaches the drag behavior the passed in mesh\r\n * @param ownerNode The mesh that will be dragged around once attached\r\n * @param predicate Predicate to use for pick filtering\r\n */\r\n public attach(ownerNode: AbstractMesh, predicate?: (m: AbstractMesh) => boolean): void {\r\n this._scene = ownerNode.getScene();\r\n ownerNode.isNearGrabbable = true;\r\n this.attachedNode = ownerNode;\r\n\r\n // Initialize drag plane to not interfere with existing scene\r\n if (!PointerDragBehavior._PlaneScene) {\r\n if (this._debugMode) {\r\n PointerDragBehavior._PlaneScene = this._scene;\r\n } else {\r\n PointerDragBehavior._PlaneScene = new Scene(this._scene.getEngine(), { virtual: true });\r\n PointerDragBehavior._PlaneScene.detachControl();\r\n this._scene.onDisposeObservable.addOnce(() => {\r\n PointerDragBehavior._PlaneScene.dispose();\r\n (<any>PointerDragBehavior._PlaneScene) = null;\r\n });\r\n }\r\n }\r\n this._dragPlane = CreatePlane(\r\n \"pointerDragPlane\",\r\n { size: this._debugMode ? 1 : 10000, updatable: false, sideOrientation: Mesh.DOUBLESIDE },\r\n PointerDragBehavior._PlaneScene\r\n );\r\n\r\n // State of the drag\r\n this.lastDragPosition = new Vector3(0, 0, 0);\r\n\r\n const pickPredicate = predicate\r\n ? predicate\r\n : (m: AbstractMesh) => {\r\n return this.attachedNode == m || m.isDescendantOf(this.attachedNode);\r\n };\r\n\r\n this._pointerObserver = this._scene.onPointerObservable.add((pointerInfo) => {\r\n if (!this.enabled) {\r\n // If behavior is disabled before releaseDrag is ever called, call it now.\r\n if (this._attachedToElement) {\r\n this.releaseDrag();\r\n }\r\n\r\n return;\r\n }\r\n\r\n // If we are dragging and the user presses another button on the same pointer, end the drag. Otherwise,\r\n // tracking when the drag should end becomes very complex.\r\n // gizmo.ts has similar behavior.\r\n if (\r\n this.dragging &&\r\n this.currentDraggingPointerId == (<IPointerEvent>pointerInfo.event).pointerId &&\r\n pointerInfo.event.button !== -1 &&\r\n pointerInfo.event.button !== this._activeDragButton &&\r\n !this.allowOtherButtonsDuringDrag\r\n ) {\r\n this.releaseDrag();\r\n return;\r\n }\r\n\r\n if (pointerInfo.type == PointerEventTypes.POINTERDOWN) {\r\n if (\r\n this.startAndReleaseDragOnPointerEvents &&\r\n !this.dragging &&\r\n pointerInfo.pickInfo &&\r\n pointerInfo.pickInfo.hit &&\r\n pointerInfo.pickInfo.pickedMesh &&\r\n pointerInfo.pickInfo.pickedPoint &&\r\n pointerInfo.pickInfo.ray &&\r\n pickPredicate(pointerInfo.pickInfo.pickedMesh)\r\n ) {\r\n if (this._activeDragButton === -1 && this.dragButtons.indexOf(pointerInfo.event.button) !== -1) {\r\n this._activeDragButton = pointerInfo.event.button;\r\n this._activePointerInfo = pointerInfo;\r\n this._startDrag((<IPointerEvent>pointerInfo.event).pointerId, pointerInfo.pickInfo.ray, pointerInfo.pickInfo.pickedPoint);\r\n }\r\n }\r\n } else if (pointerInfo.type == PointerEventTypes.POINTERUP) {\r\n if (\r\n this.startAndReleaseDragOnPointerEvents &&\r\n this.currentDraggingPointerId == (<IPointerEvent>pointerInfo.event).pointerId &&\r\n (this._activeDragButton === pointerInfo.event.button || this._activeDragButton === -1)\r\n ) {\r\n this.releaseDrag();\r\n }\r\n } else if (pointerInfo.type == PointerEventTypes.POINTERMOVE) {\r\n const pointerId = (<IPointerEvent>pointerInfo.event).pointerId;\r\n\r\n // If drag was started with anyMouseID specified, set pointerID to the next mouse that moved\r\n if (this.currentDraggingPointerId === PointerDragBehavior._AnyMouseId && pointerId !== PointerDragBehavior._AnyMouseId) {\r\n const evt = <IPointerEvent>pointerInfo.event;\r\n const isMouseEvent = evt.pointerType === \"mouse\" || (!this._scene.getEngine().hostInformation.isMobile && evt instanceof MouseEvent);\r\n if (isMouseEvent) {\r\n if (this._lastPointerRay[this.currentDraggingPointerId]) {\r\n this._lastPointerRay[pointerId] = this._lastPointerRay[this.currentDraggingPointerId];\r\n delete this._lastPointerRay[this.currentDraggingPointerId];\r\n }\r\n this.currentDraggingPointerId = pointerId;\r\n }\r\n }\r\n\r\n // Keep track of last pointer ray, this is used simulating the start of a drag in startDrag()\r\n if (!this._lastPointerRay[pointerId]) {\r\n this._lastPointerRay[pointerId] = new Ray(new Vector3(), new Vector3());\r\n }\r\n if (pointerInfo.pickInfo && pointerInfo.pickInfo.ray) {\r\n this._lastPointerRay[pointerId].origin.copyFrom(pointerInfo.pickInfo.ray.origin);\r\n this._lastPointerRay[pointerId].direction.copyFrom(pointerInfo.pickInfo.ray.direction);\r\n\r\n if (this.currentDraggingPointerId == pointerId && this.dragging) {\r\n this._moveDrag(pointerInfo.pickInfo.ray);\r\n }\r\n }\r\n }\r\n });\r\n\r\n this._beforeRenderObserver = this._scene.onBeforeRenderObservable.add(() => {\r\n if (this._moving && this.moveAttached) {\r\n let needMatrixUpdate = false;\r\n PivotTools._RemoveAndStorePivotPoint(this.attachedNode);\r\n // Slowly move mesh to avoid jitter\r\n this._targetPosition.subtractToRef(this.attachedNode.absolutePosition, this._tmpVector);\r\n this._tmpVector.scaleInPlace(this.dragDeltaRatio);\r\n this.attachedNode.getAbsolutePosition().addToRef(this._tmpVector, this._tmpVector);\r\n if (this.validateDrag(this._tmpVector)) {\r\n this.attachedNode.setAbsolutePosition(this._tmpVector);\r\n needMatrixUpdate = true;\r\n }\r\n PivotTools._RestorePivotPoint(this.attachedNode);\r\n if (needMatrixUpdate) {\r\n this.attachedNode.computeWorldMatrix();\r\n }\r\n }\r\n });\r\n }\r\n\r\n /**\r\n * Force release the drag action by code.\r\n */\r\n public releaseDrag() {\r\n if (this.dragging) {\r\n this.dragging = false;\r\n this.onDragEndObservable.notifyObservers({ dragPlanePoint: this.lastDragPosition, pointerId: this.currentDraggingPointerId, pointerInfo: this._activePointerInfo });\r\n }\r\n\r\n this.currentDraggingPointerId = -1;\r\n this._activeDragButton = -1;\r\n this._activePointerInfo = null;\r\n this._moving = false;\r\n\r\n // Reattach camera controls\r\n if (this.detachCameraControls && this._attachedToElement && this._scene.activeCamera && !this._scene.activeCamera.leftCamera) {\r\n if (this._scene.activeCamera.getClassName() === \"ArcRotateCamera\") {\r\n const arcRotateCamera = this._scene.activeCamera as ArcRotateCamera;\r\n arcRotateCamera.attachControl(\r\n arcRotateCamera.inputs ? arcRotateCamera.inputs.noPreventDefault : true,\r\n arcRotateCamera._useCtrlForPanning,\r\n arcRotateCamera._panningMouseButton\r\n );\r\n } else {\r\n this._scene.activeCamera.attachControl(this._scene.activeCamera.inputs ? this._scene.activeCamera.inputs.noPreventDefault : true);\r\n }\r\n this._attachedToElement = false;\r\n }\r\n }\r\n\r\n private _startDragRay = new Ray(new Vector3(), new Vector3());\r\n private _lastPointerRay: { [key: number]: Ray } = {};\r\n /**\r\n * Simulates the start of a pointer drag event on the behavior\r\n * @param pointerId pointerID of the pointer that should be simulated (Default: Any mouse pointer ID)\r\n * @param fromRay initial ray of the pointer to be simulated (Default: Ray from camera to attached mesh)\r\n * @param startPickedPoint picked point of the pointer to be simulated (Default: attached mesh position)\r\n */\r\n public startDrag(pointerId: number = PointerDragBehavior._AnyMouseId, fromRay?: Ray, startPickedPoint?: Vector3) {\r\n this._startDrag(pointerId, fromRay, startPickedPoint);\r\n\r\n let lastRay = this._lastPointerRay[pointerId];\r\n if (pointerId === PointerDragBehavior._AnyMouseId) {\r\n lastRay = this._lastPointerRay[<any>Object.keys(this._lastPointerRay)[0]];\r\n }\r\n\r\n if (lastRay) {\r\n // if there was a last pointer ray drag the object there\r\n this._moveDrag(lastRay);\r\n }\r\n }\r\n\r\n protected _startDrag(pointerId: number, fromRay?: Ray, startPickedPoint?: Vector3) {\r\n if (!this._scene.activeCamera || this.dragging || !this.attachedNode) {\r\n return;\r\n }\r\n\r\n PivotTools._RemoveAndStorePivotPoint(this.attachedNode);\r\n // Create start ray from the camera to the object\r\n if (fromRay) {\r\n this._startDragRay.direction.copyFrom(fromRay.direction);\r\n this._startDragRay.origin.copyFrom(fromRay.origin);\r\n } else {\r\n this._startDragRay.origin.copyFrom(this._scene.activeCamera.position);\r\n this.attachedNode.getWorldMatrix().getTranslationToRef(this._tmpVector);\r\n this._tmpVector.subtractToRef(this._scene.activeCamera.position, this._startDragRay.direction);\r\n }\r\n\r\n this._updateDragPlanePosition(this._startDragRay, startPickedPoint ? startPickedPoint : this._tmpVector);\r\n\r\n const pickedPoint = this._pickWithRayOnDragPlane(this._startDragRay);\r\n if (pickedPoint) {\r\n this.dragging = true;\r\n this.currentDraggingPointerId = pointerId;\r\n this.lastDragPosition.copyFrom(pickedPoint);\r\n this.onDragStartObservable.notifyObservers({ dragPlanePoint: pickedPoint, pointerId: this.currentDraggingPointerId, pointerInfo: this._activePointerInfo });\r\n this._targetPosition.copyFrom(this.attachedNode.getAbsolutePosition());\r\n\r\n // Detatch camera controls\r\n if (this.detachCameraControls && this._scene.activeCamera && this._scene.activeCamera.inputs && !this._scene.activeCamera.leftCamera) {\r\n if (this._scene.activeCamera.inputs.attachedToElement) {\r\n this._scene.activeCamera.detachControl();\r\n this._attachedToElement = true;\r\n } else {\r\n this._attachedToElement = false;\r\n }\r\n }\r\n } else {\r\n this.releaseDrag();\r\n }\r\n PivotTools._RestorePivotPoint(this.attachedNode);\r\n }\r\n\r\n private _dragDelta = new Vector3();\r\n protected _moveDrag(ray: Ray) {\r\n this._moving = true;\r\n const pickedPoint = this._pickWithRayOnDragPlane(ray);\r\n\r\n if (pickedPoint) {\r\n PivotTools._RemoveAndStorePivotPoint(this.attachedNode);\r\n\r\n if (this.updateDragPlane) {\r\n this._updateDragPlanePosition(ray, pickedPoint);\r\n }\r\n let dragLength = 0;\r\n // depending on the drag mode option drag accordingly\r\n if (this._options.dragAxis) {\r\n // Convert local drag axis to world if useObjectOrientationForDragging\r\n this.useObjectOrientationForDragging\r\n ? Vector3.TransformCoordinatesToRef(this._options.dragAxis, this.attachedNode.getWorldMatrix().getRotationMatrix(), this._worldDragAxis)\r\n : this._worldDragAxis.copyFrom(this._options.dragAxis);\r\n // Project delta drag from the drag plane onto the drag axis\r\n pickedPoint.subtractToRef(this.lastDragPosition, this._tmpVector);\r\n\r\n this._worldDragAxis.normalize();\r\n dragLength = Vector3.Dot(this._tmpVector, this._worldDragAxis);\r\n this._worldDragAxis.scaleToRef(dragLength, this._dragDelta);\r\n } else {\r\n dragLength = this._dragDelta.length();\r\n pickedPoint.subtractToRef(this.lastDragPosition, this._dragDelta);\r\n }\r\n this._targetPosition.addInPlace(this._dragDelta);\r\n this.onDragObservable.notifyObservers({\r\n dragDistance: dragLength,\r\n delta: this._dragDelta,\r\n dragPlanePoint: pickedPoint,\r\n dragPlaneNormal: this._dragPlane.forward,\r\n pointerId: this.currentDraggingPointerId,\r\n pointerInfo: this._activePointerInfo,\r\n });\r\n this.lastDragPosition.copyFrom(pickedPoint);\r\n\r\n PivotTools._RestorePivotPoint(this.attachedNode);\r\n }\r\n }\r\n\r\n private _pickWithRayOnDragPlane(ray: Nullable<Ray>) {\r\n if (!ray) {\r\n return null;\r\n }\r\n\r\n // Calculate angle between plane normal and ray\r\n let angle = Math.acos(Vector3.Dot(this._dragPlane.forward, ray.direction));\r\n // Correct if ray is casted from oposite side\r\n if (angle > Math.PI / 2) {\r\n angle = Math.PI - angle;\r\n }\r\n\r\n // If the angle is too perpendicular to the plane pick another point on the plane where it is looking\r\n if (this.maxDragAngle > 0 && angle > this.maxDragAngle) {\r\n if (this._useAlternatePickedPointAboveMaxDragAngle) {\r\n // Invert ray direction along the towards object axis\r\n this._tmpVector.copyFrom(ray.direction);\r\n this.attachedNode.absolutePosition.subtractToRef(ray.origin, this._alternatePickedPoint);\r\n this._alternatePickedPoint.normalize();\r\n this._alternatePickedPoint.scaleInPlace(this._useAlternatePickedPointAboveMaxDragAngleDragSpeed * Vector3.Dot(this._alternatePickedPoint, this._tmpVector));\r\n this._tmpVector.addInPlace(this._alternatePickedPoint);\r\n\r\n // Project resulting vector onto the drag plane and add it to the attached nodes absolute position to get a picked point\r\n const dot = Vector3.Dot(this._dragPlane.forward, this._tmpVector);\r\n this._dragPlane.forward.scaleToRef(-dot, this._alternatePickedPoint);\r\n this._alternatePickedPoint.addInPlace(this._tmpVector);\r\n this._alternatePickedPoint.addInPlace(this.attachedNode.absolutePosition);\r\n return this._alternatePickedPoint;\r\n } else {\r\n return null;\r\n }\r\n }\r\n\r\n // use an infinite plane instead of ray picking a mesh that must be updated every frame\r\n const planeNormal = this._dragPlane.forward;\r\n const planePosition = this._dragPlane.position;\r\n const dotProduct = ray.direction.dot(planeNormal);\r\n if (Math.abs(dotProduct) < Epsilon) {\r\n // Ray and plane are parallel, no intersection\r\n return null;\r\n }\r\n\r\n planePosition.subtractToRef(ray.origin, TmpVectors.Vector3[0]);\r\n const t = TmpVectors.Vector3[0].dot(planeNormal) / dotProduct;\r\n // Ensure the intersection point is in front of the ray (t must be positive)\r\n if (t < 0) {\r\n // Intersection point is behind the ray\r\n return null;\r\n }\r\n\r\n // Calculate the intersection point using the parameter t\r\n ray.direction.scaleToRef(t, TmpVectors.Vector3[0]);\r\n const intersectionPoint = ray.origin.add(TmpVectors.Vector3[0]);\r\n return intersectionPoint;\r\n }\r\n\r\n // Variables to avoid instantiation in the below method\r\n private _pointA = new Vector3(0, 0, 0);\r\n private _pointC = new Vector3(0, 0, 0);\r\n private _localAxis = new Vector3(0, 0, 0);\r\n private _lookAt = new Vector3(0, 0, 0);\r\n // Position the drag plane based on the attached mesh position, for single axis rotate the plane along the axis to face the camera\r\n private _updateDragPlanePosition(ray: Ray, dragPlanePosition: Vector3) {\r\n this._pointA.copyFrom(dragPlanePosition);\r\n if (this._options.dragAxis) {\r\n this.useObjectOrientationForDragging\r\n ? Vector3.TransformCoordinatesToRef(this._options.dragAxis, this.attachedNode.getWorldMatrix().getRotationMatrix(), this._localAxis)\r\n : this._localAxis.copyFrom(this._options.dragAxis);\r\n\r\n // Calculate plane normal that is the cross product of local axis and (eye-dragPlanePosition)\r\n ray.origin.subtractToRef(this._pointA, this._pointC);\r\n this._pointC.normalize();\r\n if (Math.abs(Vector3.Dot(this._localAxis, this._pointC)) > 0.999) {\r\n // the drag axis is colinear with the (eye to position) ray. The cross product will give jittered values.\r\n // A new axis vector need to be computed\r\n if (Math.abs(Vector3.Dot(Vector3.UpReadOnly, this._pointC)) > 0.999) {\r\n this._lookAt.copyFrom(Vector3.Right());\r\n } else {\r\n this._lookAt.copyFrom(Vector3.UpReadOnly);\r\n }\r\n } else {\r\n Vector3.CrossToRef(this._localAxis, this._pointC, this._lookAt);\r\n // Get perpendicular line from previous result and drag axis to adjust lineB to be perpendicular to camera\r\n Vector3.CrossToRef(this._localAxis, this._lookAt, this._lookAt);\r\n this._lookAt.normalize();\r\n }\r\n\r\n this._dragPlane.position.copyFrom(this._pointA);\r\n this._pointA.addToRef(this._lookAt, this._lookAt);\r\n this._dragPlane.lookAt(this._lookAt);\r\n } else if (this._options.dragPlaneNormal) {\r\n this.useObjectOrientationForDragging\r\n ? Vector3.TransformCoordinatesToRef(this._options.dragPlaneNormal, this.attachedNode.getWorldMatrix().getRotationMatrix(), this._localAxis)\r\n : this._localAxis.copyFrom(this._options.dragPlaneNormal);\r\n this._dragPlane.position.copyFrom(this._pointA);\r\n this._pointA.addToRef(this._localAxis, this._lookAt);\r\n this._dragPlane.lookAt(this._lookAt);\r\n } else {\r\n if (this._scene.activeCamera) {\r\n this._scene.activeCamera.getForwardRay().direction.normalizeToRef(this._localAxis);\r\n }\r\n this._dragPlane.position.copyFrom(this._pointA);\r\n this._dragPlane.lookAt(this._pointA.add(this._localAxis));\r\n }\r\n // Update the position of the drag plane so it doesn't get out of sync with the node (eg. when moving back and forth quickly)\r\n this._dragPlane.position.copyFrom(this.attachedNode.getAbsolutePosition());\r\n\r\n this._dragPlane.computeWorldMatrix(true);\r\n }\r\n\r\n /**\r\n * Detaches the behavior from the mesh\r\n */\r\n public detach(): void {\r\n this._lastPointerRay = {};\r\n if (this.attachedNode) {\r\n this.attachedNode.isNearGrabbable = false;\r\n }\r\n if (this._pointerObserver) {\r\n this._scene.onPointerObservable.remove(this._pointerObserver);\r\n }\r\n if (this._beforeRenderObserver) {\r\n this._scene.onBeforeRenderObservable.remove(this._beforeRenderObserver);\r\n }\r\n if (this._dragPlane) {\r\n this._dragPlane.dispose();\r\n }\r\n this.releaseDrag();\r\n }\r\n}\r\n"]}
|