@onerjs/core 8.30.7 → 8.30.8

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (47) hide show
  1. package/AudioV2/abstractAudio/audioEngineV2.d.ts +0 -4
  2. package/AudioV2/abstractAudio/audioEngineV2.js +0 -4
  3. package/AudioV2/abstractAudio/audioEngineV2.js.map +1 -1
  4. package/AudioV2/abstractAudio/subNodes/volumeAudioSubNode.js +1 -1
  5. package/AudioV2/abstractAudio/subNodes/volumeAudioSubNode.js.map +1 -1
  6. package/AudioV2/audioParameter.d.ts +5 -1
  7. package/AudioV2/audioParameter.js +4 -0
  8. package/AudioV2/audioParameter.js.map +1 -1
  9. package/AudioV2/webAudio/components/webAudioParameterComponent.d.ts +0 -18
  10. package/AudioV2/webAudio/components/webAudioParameterComponent.js +7 -67
  11. package/AudioV2/webAudio/components/webAudioParameterComponent.js.map +1 -1
  12. package/Particles/EmitterTypes/sphereParticleEmitter.d.ts +3 -1
  13. package/Particles/EmitterTypes/sphereParticleEmitter.js +7 -1
  14. package/Particles/EmitterTypes/sphereParticleEmitter.js.map +1 -1
  15. package/Particles/Node/Blocks/Emitters/boxShapeBlock.d.ts +1 -1
  16. package/Particles/Node/Blocks/Emitters/boxShapeBlock.js +2 -1
  17. package/Particles/Node/Blocks/Emitters/boxShapeBlock.js.map +1 -1
  18. package/Particles/Node/Blocks/Emitters/cylinderShapeBlock.d.ts +10 -1
  19. package/Particles/Node/Blocks/Emitters/cylinderShapeBlock.js +50 -17
  20. package/Particles/Node/Blocks/Emitters/cylinderShapeBlock.js.map +1 -1
  21. package/Particles/Node/Blocks/Emitters/emitters.functions.d.ts +6 -0
  22. package/Particles/Node/Blocks/Emitters/emitters.functions.js +13 -0
  23. package/Particles/Node/Blocks/Emitters/emitters.functions.js.map +1 -0
  24. package/Particles/Node/Blocks/Emitters/meshShapeBlock.d.ts +2 -2
  25. package/Particles/Node/Blocks/Emitters/meshShapeBlock.js +5 -1
  26. package/Particles/Node/Blocks/Emitters/meshShapeBlock.js.map +1 -1
  27. package/Particles/Node/Blocks/Emitters/pointShapeBlock.d.ts +1 -1
  28. package/Particles/Node/Blocks/Emitters/pointShapeBlock.js +3 -1
  29. package/Particles/Node/Blocks/Emitters/pointShapeBlock.js.map +1 -1
  30. package/Particles/Node/Blocks/Emitters/sphereShapeBlock.d.ts +10 -1
  31. package/Particles/Node/Blocks/Emitters/sphereShapeBlock.js +45 -13
  32. package/Particles/Node/Blocks/Emitters/sphereShapeBlock.js.map +1 -1
  33. package/Particles/Node/Blocks/particleInputBlock.js +1 -0
  34. package/Particles/Node/Blocks/particleInputBlock.js.map +1 -1
  35. package/Particles/Node/Enums/nodeParticleContextualSources.d.ts +3 -1
  36. package/Particles/Node/Enums/nodeParticleContextualSources.js +2 -0
  37. package/Particles/Node/Enums/nodeParticleContextualSources.js.map +1 -1
  38. package/Particles/Node/nodeParticleBuildState.js +5 -0
  39. package/Particles/Node/nodeParticleBuildState.js.map +1 -1
  40. package/Particles/Node/nodeParticleSystemSet.helper.js +35 -8
  41. package/Particles/Node/nodeParticleSystemSet.helper.js.map +1 -1
  42. package/Particles/thinParticleSystem.function.d.ts +2 -2
  43. package/Particles/thinParticleSystem.function.js +2 -2
  44. package/Particles/thinParticleSystem.function.js.map +1 -1
  45. package/Rendering/prePassRenderer.js +4 -1
  46. package/Rendering/prePassRenderer.js.map +1 -1
  47. package/package.json +1 -1
@@ -83,10 +83,6 @@ export declare abstract class AudioEngineV2 {
83
83
  abstract volume: number;
84
84
  /**
85
85
  * The smoothing duration to use when changing audio parameters, in seconds. Defaults to `0.01` (10 milliseconds).
86
- *
87
- * Due to limitations in some browsers, it is not recommended to set this value to longer than `0.01` seconds.
88
- *
89
- * Setting this value to longer than `0.01` seconds may result in errors being throw when setting audio parameters.
90
86
  */
91
87
  get parameterRampDuration(): number;
92
88
  set parameterRampDuration(value: number);
@@ -45,10 +45,6 @@ export class AudioEngineV2 {
45
45
  }
46
46
  /**
47
47
  * The smoothing duration to use when changing audio parameters, in seconds. Defaults to `0.01` (10 milliseconds).
48
- *
49
- * Due to limitations in some browsers, it is not recommended to set this value to longer than `0.01` seconds.
50
- *
51
- * Setting this value to longer than `0.01` seconds may result in errors being throw when setting audio parameters.
52
48
  */
53
49
  get parameterRampDuration() {
54
50
  return this._parameterRampDuration;
@@ -1 +1 @@
1
- {"version":3,"file":"audioEngineV2.js","sourceRoot":"","sources":["../../../../../dev/core/src/AudioV2/abstractAudio/audioEngineV2.ts"],"names":[],"mappings":"AAYA,MAAM,SAAS,GAAoB,EAAE,CAAC;AAEtC;;;GAGG;AACH,MAAM,UAAU,sBAAsB;IAClC,IAAI,SAAS,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;QACzB,OAAO,IAAI,CAAC;IAChB,CAAC;IAED,OAAO,SAAS,CAAC,SAAS,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC;AAC3C,CAAC;AAsBD;;;;GAIG;AACH,MAAM,OAAgB,aAAa;IAa/B,YAAsB,OAAuC;QAZ7D,qFAAqF;QACpE,eAAU,GAAG,IAAI,GAAG,EAAgB,CAAC;QACrC,YAAO,GAAG,IAAI,GAAG,EAAiB,CAAC;QAC5C,iBAAY,GAAmC,IAAI,CAAC;QAE5D,2CAA2C;QAC1B,WAAM,GAAG,IAAI,GAAG,EAA0B,CAAC;QAEpD,oBAAe,GAA2B,IAAI,CAAC;QAE/C,2BAAsB,GAAW,IAAI,CAAC;QAG1C,SAAS,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;QAErB,IAAI,OAAO,OAAO,CAAC,qBAAqB,KAAK,QAAQ,EAAE,CAAC;YACpD,IAAI,CAAC,qBAAqB,GAAG,OAAO,CAAC,qBAAqB,CAAC;QAC/D,CAAC;IACL,CAAC;IAOD;;;;OAIG;IACH,IAAW,cAAc;QACrB,IAAI,IAAI,CAAC,UAAU,CAAC,IAAI,KAAK,CAAC,EAAE,CAAC;YAC7B,OAAO,IAAI,CAAC;QA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AO,MAAM,CAAC,gBAAgB,CAAC,IAAI,EAAE,MAAM,EAAE,OAAO,CAAC,CAAC;AAC1D,CAAC;AAED;;;;;;GAMG;AACH,MAAM,CAAC,KAAK,UAAU,sBAAsB,CACxC,MAAyE,EACzE,UAA8C,EAAE,EAChD,SAAkC,IAAI;IAEtC,MAAM,GAAG,eAAe,CAAC,MAAM,CAAC,CAAC;IACjC,OAAO,MAAM,MAAM,CAAC,sBAAsB,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;AAChE,CAAC;AAED;;;;;;;GAOG;AACH,2FAA2F;AAC3F,MAAM,UAAU,sBAAsB,CAClC,IAAY,EACZ,MAAiB,EACjB,UAAwC,EAAE,EAC1C,SAAkC,IAAI;IAEtC,MAAM,GAAG,eAAe,CAAC,MAAM,CAAC,CAAC;IACjC,OAAO,MAAM,CAAC,sBAAsB,CAAC,IAAI,EAAE,MAAM,EAAE,OAAO,CAAC,CAAC;AAChE,CAAC;AAED;;;;;;;GAOG;AACH,2FAA2F;AAC3F,MAAM,UAAU,yBAAyB,CACrC,IAAY,EACZ,MAA4C,EAC5C,UAA2C,EAAE,EAC7C,SAAkC,IAAI;IAEtC,MAAM,GAAG,eAAe,CAAC,MAAM,CAAC,CAAC;IACjC,OAAO,MAAM,CAAC,yBAAyB,CAAC,IAAI,EAAE,MAAM,EAAE,OAAO,CAAC,CAAC;AACnE,CAAC","sourcesContent":["import type { Nullable } from \"../../types\";\nimport type { IAudioParameterRampOptions } from \"../audioParameter\";\nimport type { AbstractAudioNode, AbstractNamedAudioNode } from \"./abstractAudioNode\";\nimport type { AbstractSound } from \"./abstractSound\";\nimport type { AbstractSoundSource, ISoundSourceOptions } from \"./abstractSoundSource\";\nimport type { AudioBus, IAudioBusOptions } from \"./audioBus\";\nimport type { IMainAudioBusOptions, MainAudioBus } from \"./mainAudioBus\";\nimport type { IStaticSoundOptions, StaticSound } from \"./staticSound\";\nimport type { IStaticSoundBufferOptions, StaticSoundBuffer } from \"./staticSoundBuffer\";\nimport type { IStreamingSoundOptions, StreamingSound } from \"./streamingSound\";\nimport type { AbstractSpatialAudioListener, ISpatialAudioListenerOptions } from \"./subProperties/abstractSpatialAudioListener\";\n\nconst Instances: AudioEngineV2[] = [];\n\n/**\n * Gets the most recently created v2 audio engine.\n * @returns The most recently created v2 audio engine.\n */\nexport function LastCreatedAudioEngine(): Nullable<AudioEngineV2> {\n if (Instances.length === 0) {\n return null;\n }\n\n return Instances[Instances.length - 1];\n}\n\n/**\n * Options for creating a v2 audio engine.\n */\nexport interface IAudioEngineV2Options extends ISpatialAudioListenerOptions {\n /**\n * The smoothing duration to use when changing audio parameters, in seconds. Defaults to `0.01` (10 milliseconds).\n */\n parameterRampDuration: number;\n /**\n * The initial output volume of the audio engine. Defaults to `1`.\n */\n volume: number;\n}\n\n/**\n * The state of a v2 audio engine.\n * @see {@link AudioEngineV2.state}\n */\nexport type AudioEngineV2State = \"closed\" | \"interrupted\" | \"running\" | \"suspended\";\n\n/**\n * Abstract base class for v2 audio engines.\n *\n * A v2 audio engine based on the WebAudio API can be created with the {@link CreateAudioEngineAsync} function.\n */\nexport abstract class AudioEngineV2 {\n /** Not owned, but all items should be in `_nodes` container, too, which is owned. */\n private readonly _mainBuses = new Set<MainAudioBus>();\n private readonly _sounds = new Set<AbstractSound>();\n private _soundsArray: Nullable<Array<AbstractSound>> = null;\n\n /** Owned top-level sound and bus nodes. */\n private readonly _nodes = new Set<AbstractNamedAudioNode>();\n\n private _defaultMainBus: Nullable<MainAudioBus> = null;\n\n private _parameterRampDuration: number = 0.01;\n\n protected constructor(options: Partial<IAudioEngineV2Options>) {\n Instances.push(this);\n\n if (typeof options.parameterRampDuration === \"number\") {\n this.parameterRampDuration = options.parameterRampDuration;\n }\n }\n\n /**\n * The elapsed time since the audio engine was started, in seconds.\n */\n public abstract readonly currentTime: number;\n\n /**\n * The default main bus that will be used for audio buses and sounds if their `outBus` option is not set.\n * @see {@link IAudioBusOptions.outBus}\n * @see {@link IAbstractSoundOptions.outBus}\n */\n public get defaultMainBus(): Nullable<MainAudioBus> {\n if (this._mainBuses.size === 0) {\n return null;\n }\n\n if (!this._defaultMainBus) {\n this._defaultMainBus = Array.from(this._mainBuses)[0];\n }\n\n return this._defaultMainBus;\n }\n\n /**\n * The spatial audio listener properties for the audio engine.\n * - Each audio engine has exactly one listener.\n */\n public abstract readonly listener: AbstractSpatialAudioListener;\n\n /**\n * The main output node.\n * - This is the last node in the audio graph before the audio is sent to the speakers.\n */\n public abstract readonly mainOut: AbstractAudioNode;\n\n /**\n * The current state of the audio engine.\n *\n * Possible values are:\n * - `\"closed\"`: The audio engine has been closed.\n * - `\"interrupted\"`: The audio engine has been interrupted and is not running.\n * - `\"running\"`: The audio engine is running normally.\n * - `\"suspended\"`: The audio engine is suspended and is not running.\n */\n public abstract readonly state: AudioEngineV2State;\n\n /**\n * The output volume of the audio engine.\n */\n public abstract volume: number;\n\n /**\n * The smoothing duration to use when changing audio parameters, in seconds. Defaults to `0.01` (10 milliseconds).\n *\n * Due to limitations in some browsers, it is not recommended to set this value to longer than `0.01` seconds.\n *\n * Setting this value to longer than `0.01` seconds may result in errors being throw when setting audio parameters.\n */\n public get parameterRampDuration(): number {\n return this._parameterRampDuration;\n }\n\n public set parameterRampDuration(value: number) {\n this._parameterRampDuration = Math.max(0, value);\n }\n\n /**\n * The list of static and streaming sounds created by the audio engine.\n */\n public get sounds(): ReadonlyArray<AbstractSound> {\n if (!this._soundsArray) {\n this._soundsArray = Array.from(this._sounds);\n }\n return this._soundsArray;\n }\n\n /**\n * Creates a new audio bus.\n * @param name - The name of the audio bus.\n * @param options - The options to use when creating the audio bus.\n * @returns A promise that resolves with the created audio bus.\n */\n public abstract createBusAsync(name: string, options?: Partial<IAudioBusOptions>): Promise<AudioBus>;\n\n /**\n * Creates a new main audio bus.\n * @param name - The name of the main audio bus.\n * @param options - The options to use when creating the main audio bus.\n * @returns A promise that resolves with the created main audio bus.\n */\n public abstract createMainBusAsync(name: string, options?: Partial<IMainAudioBusOptions>): Promise<MainAudioBus>;\n\n /**\n * Creates a new microphone sound source.\n * @param name - The name of the sound.\n * @param options - The options for the sound source.\n * @returns A promise that resolves to the created sound source.\n */\n public abstract createMicrophoneSoundSourceAsync(name: string, options?: Partial<ISoundSourceOptions>): Promise<AbstractSoundSource>;\n\n /**\n * Creates a new static sound.\n * @param name - The name of the sound.\n * @param source - The source of the sound.\n * @param options - The options for the static sound.\n * @returns A promise that resolves to the created static sound.\n */\n public abstract createSoundAsync(\n name: string,\n source: ArrayBuffer | AudioBuffer | StaticSoundBuffer | string | string[],\n options?: Partial<IStaticSoundOptions>\n ): Promise<StaticSound>;\n\n /**\n * Creates a new static sound buffer.\n * @param source - The source of the sound buffer.\n * @param options - The options for the static sound buffer.\n * @returns A promise that resolves to the created static sound buffer.\n */\n public abstract createSoundBufferAsync(\n source: ArrayBuffer | AudioBuffer | StaticSoundBuffer | string | string[],\n options?: Partial<IStaticSoundBufferOptions>\n ): Promise<StaticSoundBuffer>;\n\n /**\n * Creates a new sound source.\n * @param name - The name of the sound.\n * @param source - The source of the sound.\n * @param options - The options for the sound source.\n * @returns A promise that resolves to the created sound source.\n */\n public abstract createSoundSourceAsync(name: string, source: AudioNode, options?: Partial<ISoundSourceOptions>): Promise<AbstractSoundSource>;\n\n /**\n * Creates a new streaming sound.\n * @param name - The name of the sound.\n * @param source - The source of the sound.\n * @param options - The options for the streaming sound.\n * @returns A promise that resolves to the created streaming sound.\n */\n public abstract createStreamingSoundAsync(name: string, source: HTMLMediaElement | string | string[], options?: Partial<IStreamingSoundOptions>): Promise<StreamingSound>;\n\n /**\n * Releases associated resources.\n */\n public dispose(): void {\n if (Instances.includes(this)) {\n Instances.splice(Instances.indexOf(this), 1);\n }\n\n const nodeIt = this._nodes.values();\n for (let next = nodeIt.next(); !next.done; next = nodeIt.next()) {\n next.value.dispose();\n }\n\n this._mainBuses.clear();\n this._nodes.clear();\n this._sounds.clear();\n\n this._disposeSoundsArray();\n\n this._defaultMainBus = null;\n }\n\n /**\n * Checks if the specified format is valid.\n * @param format The format to check as an audio file extension like \"mp3\" or \"wav\".\n * @returns `true` if the format is valid; otherwise `false`.\n */\n public abstract isFormatValid(format: string): boolean;\n\n /**\n * Pauses the audio engine if it is running.\n * @returns A promise that resolves when the audio engine is paused.\n */\n public abstract pauseAsync(): Promise<void>;\n\n /**\n * Resumes the audio engine if it is not running.\n * @returns A promise that resolves when the audio engine is running.\n */\n public abstract resumeAsync(): Promise<void>;\n\n /**\n * Sets the audio output volume with optional ramping.\n * If the duration is 0 then the volume is set immediately, otherwise it is ramped to the new value over the given duration using the given shape.\n * If a ramp is already in progress then the volume is not set and an error is thrown.\n * @param value The value to set the volume to.\n * @param options The options to use for ramping the volume change.\n */\n public abstract setVolume(value: number, options?: Partial<IAudioParameterRampOptions>): void;\n\n /**\n * Unlocks the audio engine if it is locked.\n * - Note that the returned promise may already be resolved if the audio engine is already unlocked.\n * @returns A promise that is resolved when the audio engine is unlocked.\n */\n // eslint-disable-next-line @typescript-eslint/promise-function-async, no-restricted-syntax\n public unlockAsync(): Promise<void> {\n return this.resumeAsync();\n }\n\n protected _addMainBus(mainBus: MainAudioBus): void {\n this._mainBuses.add(mainBus);\n\n this._addNode(mainBus);\n }\n\n protected _removeMainBus(mainBus: MainAudioBus): void {\n this._mainBuses.delete(mainBus);\n this._defaultMainBus = null;\n\n this._removeNode(mainBus);\n }\n\n protected _addNode(node: AbstractNamedAudioNode): void {\n this._nodes.add(node);\n }\n\n protected _removeNode(node: AbstractNamedAudioNode): void {\n this._nodes.delete(node);\n }\n\n protected _addSound(sound: AbstractSound): void {\n this._disposeSoundsArray();\n this._sounds.add(sound);\n this._addNode(sound);\n }\n\n protected _removeSound(sound: AbstractSound): void {\n this._disposeSoundsArray();\n this._sounds.delete(sound);\n this._removeNode(sound);\n }\n\n private _disposeSoundsArray(): void {\n if (this._soundsArray) {\n this._soundsArray.length = 0;\n this._soundsArray = null;\n }\n }\n}\n\n/**\n * @internal\n * @param engine - The given audio engine. If `null` then the last created audio engine is used.\n * @returns the given audio engine or the last created audio engine.\n * @throws An error if the resulting engine is `null`.\n */\nexport function _GetAudioEngine(engine: Nullable<AudioEngineV2>): AudioEngineV2 {\n if (!engine) {\n engine = LastCreatedAudioEngine();\n }\n\n if (engine) {\n return engine;\n }\n\n throw new Error(\"No audio engine.\");\n}\n\n/**\n * Creates a new audio bus.\n * @param name - The name of the audio bus.\n * @param options - The options to use when creating the audio bus.\n * @param engine - The audio engine.\n * @returns A promise that resolves with the created audio bus.\n */\n// eslint-disable-next-line @typescript-eslint/promise-function-async, no-restricted-syntax\nexport function CreateAudioBusAsync(name: string, options: Partial<IAudioBusOptions> = {}, engine: Nullable<AudioEngineV2> = null): Promise<AudioBus> {\n engine = _GetAudioEngine(engine);\n return engine.createBusAsync(name, options);\n}\n\n/**\n * Creates a new main audio bus.\n * @param name - The name of the main audio bus.\n * @param options - The options to use when creating the main audio bus.\n * @param engine - The audio engine.\n * @returns A promise that resolves with the created main audio bus.\n */\n// eslint-disable-next-line @typescript-eslint/promise-function-async, no-restricted-syntax\nexport function CreateMainAudioBusAsync(name: string, options: Partial<IMainAudioBusOptions> = {}, engine: Nullable<AudioEngineV2> = null): Promise<MainAudioBus> {\n engine = _GetAudioEngine(engine);\n return engine.createMainBusAsync(name, options);\n}\n\n/**\n * Creates a new microphone sound source.\n * @param name - The name of the sound.\n * @param options - The options for the sound source.\n * @param engine - The audio engine.\n * @returns A promise that resolves to the created sound source.\n */\n// eslint-disable-next-line @typescript-eslint/promise-function-async, no-restricted-syntax\nexport function CreateMicrophoneSoundSourceAsync(name: string, options: Partial<ISoundSourceOptions> = {}, engine: Nullable<AudioEngineV2> = null): Promise<AbstractSoundSource> {\n engine = _GetAudioEngine(engine);\n return engine.createMicrophoneSoundSourceAsync(name, options);\n}\n\n/**\n * Creates a new static sound.\n * @param name - The name of the sound.\n * @param source - The source of the sound.\n * @param options - The options for the static sound.\n * @param engine - The audio engine.\n * @returns A promise that resolves to the created static sound.\n */\n// eslint-disable-next-line @typescript-eslint/promise-function-async, no-restricted-syntax\nexport function CreateSoundAsync(\n name: string,\n source: ArrayBuffer | AudioBuffer | StaticSoundBuffer | string | string[],\n options: Partial<IStaticSoundOptions> = {},\n engine: Nullable<AudioEngineV2> = null\n): Promise<StaticSound> {\n engine = _GetAudioEngine(engine);\n return engine.createSoundAsync(name, source, options);\n}\n\n/**\n * Creates a new static sound buffer.\n * @param source - The source of the sound buffer.\n * @param options - The options for the static sound buffer.\n * @param engine - The audio engine.\n * @returns A promise that resolves to the created static sound buffer.\n */\nexport async function CreateSoundBufferAsync(\n source: ArrayBuffer | AudioBuffer | StaticSoundBuffer | string | string[],\n options: Partial<IStaticSoundBufferOptions> = {},\n engine: Nullable<AudioEngineV2> = null\n): Promise<StaticSoundBuffer> {\n engine = _GetAudioEngine(engine);\n return await engine.createSoundBufferAsync(source, options);\n}\n\n/**\n * Creates a new sound source.\n * @param name - The name of the sound.\n * @param source - The source of the sound.\n * @param options - The options for the sound source.\n * @param engine - The audio engine.\n * @returns A promise that resolves to the created sound source.\n */\n// eslint-disable-next-line @typescript-eslint/promise-function-async, no-restricted-syntax\nexport function CreateSoundSourceAsync(\n name: string,\n source: AudioNode,\n options: Partial<ISoundSourceOptions> = {},\n engine: Nullable<AudioEngineV2> = null\n): Promise<AbstractSoundSource> {\n engine = _GetAudioEngine(engine);\n return engine.createSoundSourceAsync(name, source, options);\n}\n\n/**\n * Creates a new streaming sound.\n * @param name - The name of the sound.\n * @param source - The source of the sound.\n * @param options - The options for the streaming sound.\n * @param engine - The audio engine.\n * @returns A promise that resolves to the created streaming sound.\n */\n// eslint-disable-next-line @typescript-eslint/promise-function-async, no-restricted-syntax\nexport function CreateStreamingSoundAsync(\n name: string,\n source: HTMLMediaElement | string | string[],\n options: Partial<IStreamingSoundOptions> = {},\n engine: Nullable<AudioEngineV2> = null\n): Promise<StreamingSound> {\n engine = _GetAudioEngine(engine);\n return engine.createStreamingSoundAsync(name, source, options);\n}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AC,CAAC;IACjC,OAAO,MAAM,MAAM,CAAC,sBAAsB,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;AAChE,CAAC;AAED;;;;;;;GAOG;AACH,2FAA2F;AAC3F,MAAM,UAAU,sBAAsB,CAClC,IAAY,EACZ,MAAiB,EACjB,UAAwC,EAAE,EAC1C,SAAkC,IAAI;IAEtC,MAAM,GAAG,eAAe,CAAC,MAAM,CAAC,CAAC;IACjC,OAAO,MAAM,CAAC,sBAAsB,CAAC,IAAI,EAAE,MAAM,EAAE,OAAO,CAAC,CAAC;AAChE,CAAC;AAED;;;;;;;GAOG;AACH,2FAA2F;AAC3F,MAAM,UAAU,yBAAyB,CACrC,IAAY,EACZ,MAA4C,EAC5C,UAA2C,EAAE,EAC7C,SAAkC,IAAI;IAEtC,MAAM,GAAG,eAAe,CAAC,MAAM,CAAC,CAAC;IACjC,OAAO,MAAM,CAAC,yBAAyB,CAAC,IAAI,EAAE,MAAM,EAAE,OAAO,CAAC,CAAC;AACnE,CAAC","sourcesContent":["import type { Nullable } from \"../../types\";\nimport type { IAudioParameterRampOptions } from \"../audioParameter\";\nimport type { AbstractAudioNode, AbstractNamedAudioNode } from \"./abstractAudioNode\";\nimport type { AbstractSound } from \"./abstractSound\";\nimport type { AbstractSoundSource, ISoundSourceOptions } from \"./abstractSoundSource\";\nimport type { AudioBus, IAudioBusOptions } from \"./audioBus\";\nimport type { IMainAudioBusOptions, MainAudioBus } from \"./mainAudioBus\";\nimport type { IStaticSoundOptions, StaticSound } from \"./staticSound\";\nimport type { IStaticSoundBufferOptions, StaticSoundBuffer } from \"./staticSoundBuffer\";\nimport type { IStreamingSoundOptions, StreamingSound } from \"./streamingSound\";\nimport type { AbstractSpatialAudioListener, ISpatialAudioListenerOptions } from \"./subProperties/abstractSpatialAudioListener\";\n\nconst Instances: AudioEngineV2[] = [];\n\n/**\n * Gets the most recently created v2 audio engine.\n * @returns The most recently created v2 audio engine.\n */\nexport function LastCreatedAudioEngine(): Nullable<AudioEngineV2> {\n if (Instances.length === 0) {\n return null;\n }\n\n return Instances[Instances.length - 1];\n}\n\n/**\n * Options for creating a v2 audio engine.\n */\nexport interface IAudioEngineV2Options extends ISpatialAudioListenerOptions {\n /**\n * The smoothing duration to use when changing audio parameters, in seconds. Defaults to `0.01` (10 milliseconds).\n */\n parameterRampDuration: number;\n /**\n * The initial output volume of the audio engine. Defaults to `1`.\n */\n volume: number;\n}\n\n/**\n * The state of a v2 audio engine.\n * @see {@link AudioEngineV2.state}\n */\nexport type AudioEngineV2State = \"closed\" | \"interrupted\" | \"running\" | \"suspended\";\n\n/**\n * Abstract base class for v2 audio engines.\n *\n * A v2 audio engine based on the WebAudio API can be created with the {@link CreateAudioEngineAsync} function.\n */\nexport abstract class AudioEngineV2 {\n /** Not owned, but all items should be in `_nodes` container, too, which is owned. */\n private readonly _mainBuses = new Set<MainAudioBus>();\n private readonly _sounds = new Set<AbstractSound>();\n private _soundsArray: Nullable<Array<AbstractSound>> = null;\n\n /** Owned top-level sound and bus nodes. */\n private readonly _nodes = new Set<AbstractNamedAudioNode>();\n\n private _defaultMainBus: Nullable<MainAudioBus> = null;\n\n private _parameterRampDuration: number = 0.01;\n\n protected constructor(options: Partial<IAudioEngineV2Options>) {\n Instances.push(this);\n\n if (typeof options.parameterRampDuration === \"number\") {\n this.parameterRampDuration = options.parameterRampDuration;\n }\n }\n\n /**\n * The elapsed time since the audio engine was started, in seconds.\n */\n public abstract readonly currentTime: number;\n\n /**\n * The default main bus that will be used for audio buses and sounds if their `outBus` option is not set.\n * @see {@link IAudioBusOptions.outBus}\n * @see {@link IAbstractSoundOptions.outBus}\n */\n public get defaultMainBus(): Nullable<MainAudioBus> {\n if (this._mainBuses.size === 0) {\n return null;\n }\n\n if (!this._defaultMainBus) {\n this._defaultMainBus = Array.from(this._mainBuses)[0];\n }\n\n return this._defaultMainBus;\n }\n\n /**\n * The spatial audio listener properties for the audio engine.\n * - Each audio engine has exactly one listener.\n */\n public abstract readonly listener: AbstractSpatialAudioListener;\n\n /**\n * The main output node.\n * - This is the last node in the audio graph before the audio is sent to the speakers.\n */\n public abstract readonly mainOut: AbstractAudioNode;\n\n /**\n * The current state of the audio engine.\n *\n * Possible values are:\n * - `\"closed\"`: The audio engine has been closed.\n * - `\"interrupted\"`: The audio engine has been interrupted and is not running.\n * - `\"running\"`: The audio engine is running normally.\n * - `\"suspended\"`: The audio engine is suspended and is not running.\n */\n public abstract readonly state: AudioEngineV2State;\n\n /**\n * The output volume of the audio engine.\n */\n public abstract volume: number;\n\n /**\n * The smoothing duration to use when changing audio parameters, in seconds. Defaults to `0.01` (10 milliseconds).\n */\n public get parameterRampDuration(): number {\n return this._parameterRampDuration;\n }\n\n public set parameterRampDuration(value: number) {\n this._parameterRampDuration = Math.max(0, value);\n }\n\n /**\n * The list of static and streaming sounds created by the audio engine.\n */\n public get sounds(): ReadonlyArray<AbstractSound> {\n if (!this._soundsArray) {\n this._soundsArray = Array.from(this._sounds);\n }\n return this._soundsArray;\n }\n\n /**\n * Creates a new audio bus.\n * @param name - The name of the audio bus.\n * @param options - The options to use when creating the audio bus.\n * @returns A promise that resolves with the created audio bus.\n */\n public abstract createBusAsync(name: string, options?: Partial<IAudioBusOptions>): Promise<AudioBus>;\n\n /**\n * Creates a new main audio bus.\n * @param name - The name of the main audio bus.\n * @param options - The options to use when creating the main audio bus.\n * @returns A promise that resolves with the created main audio bus.\n */\n public abstract createMainBusAsync(name: string, options?: Partial<IMainAudioBusOptions>): Promise<MainAudioBus>;\n\n /**\n * Creates a new microphone sound source.\n * @param name - The name of the sound.\n * @param options - The options for the sound source.\n * @returns A promise that resolves to the created sound source.\n */\n public abstract createMicrophoneSoundSourceAsync(name: string, options?: Partial<ISoundSourceOptions>): Promise<AbstractSoundSource>;\n\n /**\n * Creates a new static sound.\n * @param name - The name of the sound.\n * @param source - The source of the sound.\n * @param options - The options for the static sound.\n * @returns A promise that resolves to the created static sound.\n */\n public abstract createSoundAsync(\n name: string,\n source: ArrayBuffer | AudioBuffer | StaticSoundBuffer | string | string[],\n options?: Partial<IStaticSoundOptions>\n ): Promise<StaticSound>;\n\n /**\n * Creates a new static sound buffer.\n * @param source - The source of the sound buffer.\n * @param options - The options for the static sound buffer.\n * @returns A promise that resolves to the created static sound buffer.\n */\n public abstract createSoundBufferAsync(\n source: ArrayBuffer | AudioBuffer | StaticSoundBuffer | string | string[],\n options?: Partial<IStaticSoundBufferOptions>\n ): Promise<StaticSoundBuffer>;\n\n /**\n * Creates a new sound source.\n * @param name - The name of the sound.\n * @param source - The source of the sound.\n * @param options - The options for the sound source.\n * @returns A promise that resolves to the created sound source.\n */\n public abstract createSoundSourceAsync(name: string, source: AudioNode, options?: Partial<ISoundSourceOptions>): Promise<AbstractSoundSource>;\n\n /**\n * Creates a new streaming sound.\n * @param name - The name of the sound.\n * @param source - The source of the sound.\n * @param options - The options for the streaming sound.\n * @returns A promise that resolves to the created streaming sound.\n */\n public abstract createStreamingSoundAsync(name: string, source: HTMLMediaElement | string | string[], options?: Partial<IStreamingSoundOptions>): Promise<StreamingSound>;\n\n /**\n * Releases associated resources.\n */\n public dispose(): void {\n if (Instances.includes(this)) {\n Instances.splice(Instances.indexOf(this), 1);\n }\n\n const nodeIt = this._nodes.values();\n for (let next = nodeIt.next(); !next.done; next = nodeIt.next()) {\n next.value.dispose();\n }\n\n this._mainBuses.clear();\n this._nodes.clear();\n this._sounds.clear();\n\n this._disposeSoundsArray();\n\n this._defaultMainBus = null;\n }\n\n /**\n * Checks if the specified format is valid.\n * @param format The format to check as an audio file extension like \"mp3\" or \"wav\".\n * @returns `true` if the format is valid; otherwise `false`.\n */\n public abstract isFormatValid(format: string): boolean;\n\n /**\n * Pauses the audio engine if it is running.\n * @returns A promise that resolves when the audio engine is paused.\n */\n public abstract pauseAsync(): Promise<void>;\n\n /**\n * Resumes the audio engine if it is not running.\n * @returns A promise that resolves when the audio engine is running.\n */\n public abstract resumeAsync(): Promise<void>;\n\n /**\n * Sets the audio output volume with optional ramping.\n * If the duration is 0 then the volume is set immediately, otherwise it is ramped to the new value over the given duration using the given shape.\n * If a ramp is already in progress then the volume is not set and an error is thrown.\n * @param value The value to set the volume to.\n * @param options The options to use for ramping the volume change.\n */\n public abstract setVolume(value: number, options?: Partial<IAudioParameterRampOptions>): void;\n\n /**\n * Unlocks the audio engine if it is locked.\n * - Note that the returned promise may already be resolved if the audio engine is already unlocked.\n * @returns A promise that is resolved when the audio engine is unlocked.\n */\n // eslint-disable-next-line @typescript-eslint/promise-function-async, no-restricted-syntax\n public unlockAsync(): Promise<void> {\n return this.resumeAsync();\n }\n\n protected _addMainBus(mainBus: MainAudioBus): void {\n this._mainBuses.add(mainBus);\n\n this._addNode(mainBus);\n }\n\n protected _removeMainBus(mainBus: MainAudioBus): void {\n this._mainBuses.delete(mainBus);\n this._defaultMainBus = null;\n\n this._removeNode(mainBus);\n }\n\n protected _addNode(node: AbstractNamedAudioNode): void {\n this._nodes.add(node);\n }\n\n protected _removeNode(node: AbstractNamedAudioNode): void {\n this._nodes.delete(node);\n }\n\n protected _addSound(sound: AbstractSound): void {\n this._disposeSoundsArray();\n this._sounds.add(sound);\n this._addNode(sound);\n }\n\n protected _removeSound(sound: AbstractSound): void {\n this._disposeSoundsArray();\n this._sounds.delete(sound);\n this._removeNode(sound);\n }\n\n private _disposeSoundsArray(): void {\n if (this._soundsArray) {\n this._soundsArray.length = 0;\n this._soundsArray = null;\n }\n }\n}\n\n/**\n * @internal\n * @param engine - The given audio engine. If `null` then the last created audio engine is used.\n * @returns the given audio engine or the last created audio engine.\n * @throws An error if the resulting engine is `null`.\n */\nexport function _GetAudioEngine(engine: Nullable<AudioEngineV2>): AudioEngineV2 {\n if (!engine) {\n engine = LastCreatedAudioEngine();\n }\n\n if (engine) {\n return engine;\n }\n\n throw new Error(\"No audio engine.\");\n}\n\n/**\n * Creates a new audio bus.\n * @param name - The name of the audio bus.\n * @param options - The options to use when creating the audio bus.\n * @param engine - The audio engine.\n * @returns A promise that resolves with the created audio bus.\n */\n// eslint-disable-next-line @typescript-eslint/promise-function-async, no-restricted-syntax\nexport function CreateAudioBusAsync(name: string, options: Partial<IAudioBusOptions> = {}, engine: Nullable<AudioEngineV2> = null): Promise<AudioBus> {\n engine = _GetAudioEngine(engine);\n return engine.createBusAsync(name, options);\n}\n\n/**\n * Creates a new main audio bus.\n * @param name - The name of the main audio bus.\n * @param options - The options to use when creating the main audio bus.\n * @param engine - The audio engine.\n * @returns A promise that resolves with the created main audio bus.\n */\n// eslint-disable-next-line @typescript-eslint/promise-function-async, no-restricted-syntax\nexport function CreateMainAudioBusAsync(name: string, options: Partial<IMainAudioBusOptions> = {}, engine: Nullable<AudioEngineV2> = null): Promise<MainAudioBus> {\n engine = _GetAudioEngine(engine);\n return engine.createMainBusAsync(name, options);\n}\n\n/**\n * Creates a new microphone sound source.\n * @param name - The name of the sound.\n * @param options - The options for the sound source.\n * @param engine - The audio engine.\n * @returns A promise that resolves to the created sound source.\n */\n// eslint-disable-next-line @typescript-eslint/promise-function-async, no-restricted-syntax\nexport function CreateMicrophoneSoundSourceAsync(name: string, options: Partial<ISoundSourceOptions> = {}, engine: Nullable<AudioEngineV2> = null): Promise<AbstractSoundSource> {\n engine = _GetAudioEngine(engine);\n return engine.createMicrophoneSoundSourceAsync(name, options);\n}\n\n/**\n * Creates a new static sound.\n * @param name - The name of the sound.\n * @param source - The source of the sound.\n * @param options - The options for the static sound.\n * @param engine - The audio engine.\n * @returns A promise that resolves to the created static sound.\n */\n// eslint-disable-next-line @typescript-eslint/promise-function-async, no-restricted-syntax\nexport function CreateSoundAsync(\n name: string,\n source: ArrayBuffer | AudioBuffer | StaticSoundBuffer | string | string[],\n options: Partial<IStaticSoundOptions> = {},\n engine: Nullable<AudioEngineV2> = null\n): Promise<StaticSound> {\n engine = _GetAudioEngine(engine);\n return engine.createSoundAsync(name, source, options);\n}\n\n/**\n * Creates a new static sound buffer.\n * @param source - The source of the sound buffer.\n * @param options - The options for the static sound buffer.\n * @param engine - The audio engine.\n * @returns A promise that resolves to the created static sound buffer.\n */\nexport async function CreateSoundBufferAsync(\n source: ArrayBuffer | AudioBuffer | StaticSoundBuffer | string | string[],\n options: Partial<IStaticSoundBufferOptions> = {},\n engine: Nullable<AudioEngineV2> = null\n): Promise<StaticSoundBuffer> {\n engine = _GetAudioEngine(engine);\n return await engine.createSoundBufferAsync(source, options);\n}\n\n/**\n * Creates a new sound source.\n * @param name - The name of the sound.\n * @param source - The source of the sound.\n * @param options - The options for the sound source.\n * @param engine - The audio engine.\n * @returns A promise that resolves to the created sound source.\n */\n// eslint-disable-next-line @typescript-eslint/promise-function-async, no-restricted-syntax\nexport function CreateSoundSourceAsync(\n name: string,\n source: AudioNode,\n options: Partial<ISoundSourceOptions> = {},\n engine: Nullable<AudioEngineV2> = null\n): Promise<AbstractSoundSource> {\n engine = _GetAudioEngine(engine);\n return engine.createSoundSourceAsync(name, source, options);\n}\n\n/**\n * Creates a new streaming sound.\n * @param name - The name of the sound.\n * @param source - The source of the sound.\n * @param options - The options for the streaming sound.\n * @param engine - The audio engine.\n * @returns A promise that resolves to the created streaming sound.\n */\n// eslint-disable-next-line @typescript-eslint/promise-function-async, no-restricted-syntax\nexport function CreateStreamingSoundAsync(\n name: string,\n source: HTMLMediaElement | string | string[],\n options: Partial<IStreamingSoundOptions> = {},\n engine: Nullable<AudioEngineV2> = null\n): Promise<StreamingSound> {\n engine = _GetAudioEngine(engine);\n return engine.createStreamingSoundAsync(name, source, options);\n}\n"]}
@@ -10,7 +10,7 @@ export class _VolumeAudioSubNode extends _AbstractAudioSubNode {
10
10
  }
11
11
  /** @internal */
12
12
  setOptions(options) {
13
- this.volume = options.volume ?? _VolumeAudioDefaults.volume;
13
+ this.setVolume(options.volume ?? _VolumeAudioDefaults.volume, { shape: "none" /* AudioParameterRampShape.None */ });
14
14
  }
15
15
  }
16
16
  /** @internal */
@@ -1 +1 @@
1
- {"version":3,"file":"volumeAudioSubNode.js","sourceRoot":"","sources":["../../../../../../dev/core/src/AudioV2/abstractAudio/subNodes/volumeAudioSubNode.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,qBAAqB,EAAE,MAAM,kCAAkC,CAAC;AAIzE,gBAAgB;AAChB,MAAM,CAAC,MAAM,oBAAoB,GAAG;IAChC,MAAM,EAAE,CAAW;CACb,CAAC;AAYX,gBAAgB;AAChB,MAAM,OAAgB,mBAAoB,SAAQ,qBAAqB;IACnE,YAAsB,MAAqB;QACvC,KAAK,qCAAsB,MAAM,CAAC,CAAC;IACvC,CAAC;IAID,gBAAgB;IACT,UAAU,CAAC,OAAqC;QACnD,IAAI,CAAC,MAAM,GAAG,OAAO,CAAC,MAAM,IAAI,oBAAoB,CAAC,MAAM,CAAC;IAChE,CAAC;CAIJ;AAED,gBAAgB;AAChB,MAAM,UAAU,sBAAsB,CAAC,QAAgC;IACnE,OAAO,QAAQ,CAAC,UAAU,oCAA0C,CAAC;AACzE,CAAC;AAED,gBAAgB;AAChB,MAAM,UAAU,uBAAuB,CAA8C,QAAgC,EAAE,QAAW;IAC9H,OAAO,sBAAsB,CAAC,QAAQ,CAAC,EAAE,CAAC,QAAQ,CAAC,IAAI,oBAAoB,CAAC,QAAQ,CAAC,CAAC;AAC1F,CAAC","sourcesContent":["import type { Nullable } from \"../../../types\";\nimport type { IAudioParameterRampOptions } from \"../../audioParameter\";\nimport type { AudioEngineV2 } from \"../audioEngineV2\";\nimport { _AbstractAudioSubNode } from \"../subNodes/abstractAudioSubNode\";\nimport { AudioSubNode } from \"../subNodes/audioSubNode\";\nimport type { _AbstractAudioSubGraph } from \"./abstractAudioSubGraph\";\n\n/** @internal */\nexport const _VolumeAudioDefaults = {\n volume: 1 as number,\n} as const;\n\n/**\n * Volume options.\n */\nexport interface IVolumeAudioOptions {\n /**\n * The volume/gain. Defaults to 1.\n */\n volume: number;\n}\n\n/** @internal */\nexport abstract class _VolumeAudioSubNode extends _AbstractAudioSubNode {\n protected constructor(engine: AudioEngineV2) {\n super(AudioSubNode.VOLUME, engine);\n }\n\n public abstract volume: number;\n\n /** @internal */\n public setOptions(options: Partial<IVolumeAudioOptions>): void {\n this.volume = options.volume ?? _VolumeAudioDefaults.volume;\n }\n\n /** @internal */\n public abstract setVolume(value: number, options?: Nullable<Partial<IAudioParameterRampOptions>>): void;\n}\n\n/** @internal */\nexport function _GetVolumeAudioSubNode(subGraph: _AbstractAudioSubGraph): Nullable<_VolumeAudioSubNode> {\n return subGraph.getSubNode<_VolumeAudioSubNode>(AudioSubNode.VOLUME);\n}\n\n/** @internal */\nexport function _GetVolumeAudioProperty<K extends keyof typeof _VolumeAudioDefaults>(subGraph: _AbstractAudioSubGraph, property: K): (typeof _VolumeAudioDefaults)[K] {\n return _GetVolumeAudioSubNode(subGraph)?.[property] ?? _VolumeAudioDefaults[property];\n}\n"]}
1
+ {"version":3,"file":"volumeAudioSubNode.js","sourceRoot":"","sources":["../../../../../../dev/core/src/AudioV2/abstractAudio/subNodes/volumeAudioSubNode.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,qBAAqB,EAAE,MAAM,kCAAkC,CAAC;AAIzE,gBAAgB;AAChB,MAAM,CAAC,MAAM,oBAAoB,GAAG;IAChC,MAAM,EAAE,CAAW;CACb,CAAC;AAYX,gBAAgB;AAChB,MAAM,OAAgB,mBAAoB,SAAQ,qBAAqB;IACnE,YAAsB,MAAqB;QACvC,KAAK,qCAAsB,MAAM,CAAC,CAAC;IACvC,CAAC;IAID,gBAAgB;IACT,UAAU,CAAC,OAAqC;QACnD,IAAI,CAAC,SAAS,CAAC,OAAO,CAAC,MAAM,IAAI,oBAAoB,CAAC,MAAM,EAAE,EAAE,KAAK,2CAA8B,EAAE,CAAC,CAAC;IAC3G,CAAC;CAIJ;AAED,gBAAgB;AAChB,MAAM,UAAU,sBAAsB,CAAC,QAAgC;IACnE,OAAO,QAAQ,CAAC,UAAU,oCAA0C,CAAC;AACzE,CAAC;AAED,gBAAgB;AAChB,MAAM,UAAU,uBAAuB,CAA8C,QAAgC,EAAE,QAAW;IAC9H,OAAO,sBAAsB,CAAC,QAAQ,CAAC,EAAE,CAAC,QAAQ,CAAC,IAAI,oBAAoB,CAAC,QAAQ,CAAC,CAAC;AAC1F,CAAC","sourcesContent":["import type { Nullable } from \"../../../types\";\nimport type { IAudioParameterRampOptions } from \"../../audioParameter\";\nimport { AudioParameterRampShape } from \"../../audioParameter\";\nimport type { AudioEngineV2 } from \"../audioEngineV2\";\nimport { _AbstractAudioSubNode } from \"../subNodes/abstractAudioSubNode\";\nimport { AudioSubNode } from \"../subNodes/audioSubNode\";\nimport type { _AbstractAudioSubGraph } from \"./abstractAudioSubGraph\";\n\n/** @internal */\nexport const _VolumeAudioDefaults = {\n volume: 1 as number,\n} as const;\n\n/**\n * Volume options.\n */\nexport interface IVolumeAudioOptions {\n /**\n * The volume/gain. Defaults to 1.\n */\n volume: number;\n}\n\n/** @internal */\nexport abstract class _VolumeAudioSubNode extends _AbstractAudioSubNode {\n protected constructor(engine: AudioEngineV2) {\n super(AudioSubNode.VOLUME, engine);\n }\n\n public abstract volume: number;\n\n /** @internal */\n public setOptions(options: Partial<IVolumeAudioOptions>): void {\n this.setVolume(options.volume ?? _VolumeAudioDefaults.volume, { shape: AudioParameterRampShape.None });\n }\n\n /** @internal */\n public abstract setVolume(value: number, options?: Nullable<Partial<IAudioParameterRampOptions>>): void;\n}\n\n/** @internal */\nexport function _GetVolumeAudioSubNode(subGraph: _AbstractAudioSubGraph): Nullable<_VolumeAudioSubNode> {\n return subGraph.getSubNode<_VolumeAudioSubNode>(AudioSubNode.VOLUME);\n}\n\n/** @internal */\nexport function _GetVolumeAudioProperty<K extends keyof typeof _VolumeAudioDefaults>(subGraph: _AbstractAudioSubGraph, property: K): (typeof _VolumeAudioDefaults)[K] {\n return _GetVolumeAudioSubNode(subGraph)?.[property] ?? _VolumeAudioDefaults[property];\n}\n"]}
@@ -13,7 +13,11 @@ export declare enum AudioParameterRampShape {
13
13
  /**
14
14
  * The ramp is logarithmic.
15
15
  */
16
- Logarithmic = "logarithmic"
16
+ Logarithmic = "logarithmic",
17
+ /**
18
+ * No ramp is used; the value is set immediately.
19
+ */
20
+ None = "none"
17
21
  }
18
22
  /**
19
23
  * Options for ramping an audio parameter's value.
@@ -15,5 +15,9 @@ export var AudioParameterRampShape;
15
15
  * The ramp is logarithmic.
16
16
  */
17
17
  AudioParameterRampShape["Logarithmic"] = "logarithmic";
18
+ /**
19
+ * No ramp is used; the value is set immediately.
20
+ */
21
+ AudioParameterRampShape["None"] = "none";
18
22
  })(AudioParameterRampShape || (AudioParameterRampShape = {}));
19
23
  //# sourceMappingURL=audioParameter.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"audioParameter.js","sourceRoot":"","sources":["../../../../dev/core/src/AudioV2/audioParameter.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,MAAM,CAAN,IAAkB,uBAajB;AAbD,WAAkB,uBAAuB;IACrC;;OAEG;IACH,4CAAiB,CAAA;IACjB;;OAEG;IACH,sDAA2B,CAAA;IAC3B;;OAEG;IACH,sDAA2B,CAAA;AAC/B,CAAC,EAbiB,uBAAuB,KAAvB,uBAAuB,QAaxC","sourcesContent":["/**\n * The shape of the audio ramp used to set an audio parameter's value, such as a sound's volume.\n */\nexport const enum AudioParameterRampShape {\n /**\n * The ramp is linear.\n */\n Linear = \"linear\",\n /**\n * The ramp is exponential.\n */\n Exponential = \"exponential\",\n /**\n * The ramp is logarithmic.\n */\n Logarithmic = \"logarithmic\",\n}\n\n/**\n * Options for ramping an audio parameter's value.\n */\nexport interface IAudioParameterRampOptions {\n /**\n * The ramp time, in seconds. Must be greater than 0. Defaults to 0.01 seconds.\n * The audio parameter's value will reach the target value at the end of the duration.\n */\n duration: number;\n /**\n * The shape of the ramp to use for the parameter change. Defaults to {@link AudioParameterRampShape.Linear}.\n */\n shape: AudioParameterRampShape;\n}\n"]}
1
+ {"version":3,"file":"audioParameter.js","sourceRoot":"","sources":["../../../../dev/core/src/AudioV2/audioParameter.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,MAAM,CAAN,IAAkB,uBAiBjB;AAjBD,WAAkB,uBAAuB;IACrC;;OAEG;IACH,4CAAiB,CAAA;IACjB;;OAEG;IACH,sDAA2B,CAAA;IAC3B;;OAEG;IACH,sDAA2B,CAAA;IAC3B;;OAEG;IACH,wCAAa,CAAA;AACjB,CAAC,EAjBiB,uBAAuB,KAAvB,uBAAuB,QAiBxC","sourcesContent":["/**\n * The shape of the audio ramp used to set an audio parameter's value, such as a sound's volume.\n */\nexport const enum AudioParameterRampShape {\n /**\n * The ramp is linear.\n */\n Linear = \"linear\",\n /**\n * The ramp is exponential.\n */\n Exponential = \"exponential\",\n /**\n * The ramp is logarithmic.\n */\n Logarithmic = \"logarithmic\",\n /**\n * No ramp is used; the value is set immediately.\n */\n None = \"none\",\n}\n\n/**\n * Options for ramping an audio parameter's value.\n */\nexport interface IAudioParameterRampOptions {\n /**\n * The ramp time, in seconds. Must be greater than 0. Defaults to 0.01 seconds.\n * The audio parameter's value will reach the target value at the end of the duration.\n */\n duration: number;\n /**\n * The shape of the ramp to use for the parameter change. Defaults to {@link AudioParameterRampShape.Linear}.\n */\n shape: AudioParameterRampShape;\n}\n"]}
@@ -3,9 +3,6 @@ import type { IAudioParameterRampOptions } from "../../audioParameter.js";
3
3
  import type { _WebAudioEngine } from "../webAudioEngine.js";
4
4
  /** @internal */
5
5
  export declare class _WebAudioParameterComponent {
6
- private _deferredRampOptions;
7
- private _deferredTargetValue;
8
- private _isObservingUpdates;
9
6
  private _rampEndTime;
10
7
  private _engine;
11
8
  private _param;
@@ -24,22 +21,7 @@ export declare class _WebAudioParameterComponent {
24
21
  /**
25
22
  * Sets the target value of the audio parameter with an optional ramping duration and shape.
26
23
  *
27
- * If a ramp is close to finishing, it will wait for the ramp to finish before setting the new value; otherwise it
28
- * will throw an error because of a bug in Firefox that prevents active ramps from being cancelled with
29
- * `cancelScheduledValues`. See https://bugzilla.mozilla.org/show_bug.cgi?id=1752775. Other browsers do not have
30
- * this issue, but we throw an error in all browsers to ensure consistent behavior.
31
- *
32
- * There are other similar WebAudio APIs for ramping parameters, (e.g. `linearRampToValueAtTime` and
33
- * `exponentialRampToValueAtTime`) but they don't work in Firefox and Meta Quest Chrome.
34
- *
35
- * It may be better in the long run to implement our own ramping logic with a WASM audio worklet instead of using
36
- * `setValueCurveAtTime`. Another alternative is to use `setValueAtTime` wtih a custom shape, but that will
37
- * probably be a performance hit to maintain quality at audio rates.
38
- *
39
24
  * @internal
40
25
  */
41
26
  setTargetValue(value: number, options?: Nullable<Partial<IAudioParameterRampOptions>>): void;
42
- private _deferRamp;
43
- private _applyDeferredRamp;
44
- private _clearDeferredRamp;
45
27
  }
@@ -1,16 +1,4 @@
1
1
  import { _GetAudioParamCurveValues } from "../../audioUtils.js";
2
- /**
3
- * Maximum time in seconds to wait for an active ramp to finish before starting a new ramp.
4
- *
5
- * New ramps will throw an error if the active ramp has more than this amount of time remaining.
6
- *
7
- * This is needed because short ramps are used to avoid pops and clicks when setting audio parameters, and we
8
- * don't want to throw an error if a short ramp is active.
9
- *
10
- * This constant is set to 11 milliseconds, which is short enough to avoid perceptual differences in most cases, but
11
- * long enough to allow for short ramps to be completed in a reasonable time frame.
12
- */
13
- const MaxWaitTime = 0.011;
14
2
  /**
15
3
  * Minimum duration in seconds for a ramp to be considered valid.
16
4
  *
@@ -22,18 +10,7 @@ const MinRampDuration = 0.000001;
22
10
  export class _WebAudioParameterComponent {
23
11
  /** @internal */
24
12
  constructor(engine, param) {
25
- this._deferredRampOptions = {
26
- duration: 0,
27
- shape: "linear" /* AudioParameterRampShape.Linear */,
28
- };
29
- this._deferredTargetValue = -1;
30
- this._isObservingUpdates = false;
31
13
  this._rampEndTime = 0;
32
- this._applyDeferredRamp = () => {
33
- if (0 < this._deferredRampOptions.duration && this._rampEndTime < this._engine.currentTime) {
34
- this.setTargetValue(this._deferredTargetValue, this._deferredRampOptions);
35
- }
36
- };
37
14
  this._engine = engine;
38
15
  this._param = param;
39
16
  this._targetValue = param.value;
@@ -55,68 +32,31 @@ export class _WebAudioParameterComponent {
55
32
  }
56
33
  /** @internal */
57
34
  dispose() {
58
- this._clearDeferredRamp();
59
35
  this._param = null;
60
36
  this._engine = null;
61
37
  }
62
38
  /**
63
39
  * Sets the target value of the audio parameter with an optional ramping duration and shape.
64
40
  *
65
- * If a ramp is close to finishing, it will wait for the ramp to finish before setting the new value; otherwise it
66
- * will throw an error because of a bug in Firefox that prevents active ramps from being cancelled with
67
- * `cancelScheduledValues`. See https://bugzilla.mozilla.org/show_bug.cgi?id=1752775. Other browsers do not have
68
- * this issue, but we throw an error in all browsers to ensure consistent behavior.
69
- *
70
- * There are other similar WebAudio APIs for ramping parameters, (e.g. `linearRampToValueAtTime` and
71
- * `exponentialRampToValueAtTime`) but they don't work in Firefox and Meta Quest Chrome.
72
- *
73
- * It may be better in the long run to implement our own ramping logic with a WASM audio worklet instead of using
74
- * `setValueCurveAtTime`. Another alternative is to use `setValueAtTime` wtih a custom shape, but that will
75
- * probably be a performance hit to maintain quality at audio rates.
76
- *
77
41
  * @internal
78
42
  */
79
43
  setTargetValue(value, options = null) {
80
- if (this._targetValue === value) {
81
- return;
82
- }
83
44
  const shape = typeof options?.shape === "string" ? options.shape : "linear" /* AudioParameterRampShape.Linear */;
84
- let duration = typeof options?.duration === "number" ? Math.max(options.duration, this._engine.parameterRampDuration) : this._engine.parameterRampDuration;
85
45
  const startTime = this._engine.currentTime;
86
- if (startTime < this._rampEndTime) {
87
- const timeLeft = this._rampEndTime - startTime;
88
- if (MaxWaitTime < timeLeft) {
89
- throw new Error("Audio parameter not set. Wait for current ramp to finish.");
90
- }
91
- else {
92
- this._deferRamp(value, duration, shape);
93
- return;
94
- }
46
+ if (shape === "none" /* AudioParameterRampShape.None */) {
47
+ this._param.cancelScheduledValues(startTime);
48
+ this._param.value = this._targetValue = value;
49
+ this._rampEndTime = startTime;
50
+ return;
95
51
  }
52
+ let duration = typeof options?.duration === "number" ? Math.max(options.duration, this._engine.parameterRampDuration) : this._engine.parameterRampDuration;
96
53
  if ((duration = Math.max(this._engine.parameterRampDuration, duration)) < MinRampDuration) {
97
54
  this._param.setValueAtTime((this._targetValue = value), startTime);
98
55
  return;
99
56
  }
100
57
  this._param.cancelScheduledValues(startTime);
101
- this._param.setValueCurveAtTime(_GetAudioParamCurveValues(shape, this._targetValue, (this._targetValue = value)), startTime, duration);
102
- this._clearDeferredRamp();
58
+ this._param.setValueCurveAtTime(_GetAudioParamCurveValues(shape, this._param.value, (this._targetValue = value)), startTime, duration);
103
59
  this._rampEndTime = startTime + duration;
104
60
  }
105
- _deferRamp(value, duration, shape) {
106
- this._deferredRampOptions.duration = duration;
107
- this._deferredRampOptions.shape = shape;
108
- this._deferredTargetValue = value;
109
- if (!this._isObservingUpdates) {
110
- this._engine._addUpdateObserver(this._applyDeferredRamp);
111
- this._isObservingUpdates = true;
112
- }
113
- }
114
- _clearDeferredRamp() {
115
- this._deferredRampOptions.duration = 0;
116
- if (this._isObservingUpdates) {
117
- this._engine._removeUpdateObserver(this._applyDeferredRamp);
118
- this._isObservingUpdates = false;
119
- }
120
- }
121
61
  }
122
62
  //# sourceMappingURL=webAudioParameterComponent.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"webAudioParameterComponent.js","sourceRoot":"","sources":["../../../../../../dev/core/src/AudioV2/webAudio/components/webAudioParameterComponent.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,yBAAyB,EAAE,MAAM,kBAAkB,CAAC;AAG7D;;;;;;;;;;GAUG;AACH,MAAM,WAAW,GAAG,KAAK,CAAC;AAE1B;;;;;GAKG;AACH,MAAM,eAAe,GAAG,QAAQ,CAAC;AAEjC,gBAAgB;AAChB,MAAM,OAAO,2BAA2B;IAYpC,gBAAgB;IAChB,YAAY,MAAuB,EAAE,KAAiB;QAZ9C,yBAAoB,GAAG;YAC3B,QAAQ,EAAE,CAAC;YACX,KAAK,+CAAgC;SACxC,CAAC;QACM,yBAAoB,GAAG,CAAC,CAAC,CAAC;QAC1B,wBAAmB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C,kBAAkB,EAAE,CAAC;QAE1B,IAAI,CAAC,YAAY,GAAG,SAAS,GAAG,QAAQ,CAAC;IAC7C,CAAC;IAEO,UAAU,CAAC,KAAa,EAAE,QAAgB,EAAE,KAA8B;QAC9E,IAAI,CAAC,oBAAoB,CAAC,QAAQ,GAAG,QAAQ,CAAC;QAC9C,IAAI,CAAC,oBAAoB,CAAC,KAAK,GAAG,KAAK,CAAC;QACxC,IAAI,CAAC,oBAAoB,GAAG,KAAK,CAAC;QAElC,IAAI,CAAC,IAAI,CAAC,mBAAmB,EAAE,CAAC;YAC5B,IAAI,CAAC,OAAO,CAAC,kBAAkB,CAAC,IAAI,CAAC,kBAAkB,CAAC,CAAC;YACzD,IAAI,CAAC,mBAAmB,GAAG,IAAI,CAAC;QACpC,CAAC;IACL,CAAC;IAQO,kBAAkB;QACtB,IAAI,CAAC,oBAAoB,CAAC,QAAQ,GAAG,CAAC,CAAC;QAEvC,IAAI,IAAI,CAAC,mBAAmB,EAAE,CAAC;YAC3B,IAAI,CAAC,OAAO,CAAC,qBAAqB,CAAC,IAAI,CAAC,kBAAkB,CAAC,CAAC;YAC5D,IAAI,CAAC,mBAAmB,GAAG,KAAK,CAAC;QACrC,CAAC;IACL,CAAC;CACJ","sourcesContent":["import type { Nullable } from \"../../../types\";\nimport type { IAudioParameterRampOptions } from \"../../audioParameter\";\nimport { AudioParameterRampShape } from \"../../audioParameter\";\nimport { _GetAudioParamCurveValues } from \"../../audioUtils\";\nimport type { _WebAudioEngine } from \"../webAudioEngine\";\n\n/**\n * Maximum time in seconds to wait for an active ramp to finish before starting a new ramp.\n *\n * New ramps will throw an error if the active ramp has more than this amount of time remaining.\n *\n * This is needed because short ramps are used to avoid pops and clicks when setting audio parameters, and we\n * don't want to throw an error if a short ramp is active.\n *\n * This constant is set to 11 milliseconds, which is short enough to avoid perceptual differences in most cases, but\n * long enough to allow for short ramps to be completed in a reasonable time frame.\n */\nconst MaxWaitTime = 0.011;\n\n/**\n * Minimum duration in seconds for a ramp to be considered valid.\n *\n * If the duration is less than this value, the value will be set immediately instead of being ramped smoothly since\n * there is no perceptual difference for such short durations, so a ramp is not needed.\n */\nconst MinRampDuration = 0.000001;\n\n/** @internal */\nexport class _WebAudioParameterComponent {\n private _deferredRampOptions = {\n duration: 0,\n shape: AudioParameterRampShape.Linear,\n };\n private _deferredTargetValue = -1;\n private _isObservingUpdates = false;\n private _rampEndTime: number = 0;\n private _engine: _WebAudioEngine;\n private _param: AudioParam;\n private _targetValue: number;\n\n /** @internal */\n constructor(engine: _WebAudioEngine, param: AudioParam) {\n this._engine = engine;\n this._param = param;\n this._targetValue = param.value;\n }\n\n /** @internal */\n public get isRamping(): boolean {\n return this._engine.currentTime < this._rampEndTime;\n }\n\n /** @internal */\n public get targetValue(): number {\n return this._targetValue;\n }\n\n public set targetValue(value: number) {\n this.setTargetValue(value);\n }\n\n /** @internal */\n public get value(): number {\n return this._param.value;\n }\n\n /** @internal */\n public dispose(): void {\n this._clearDeferredRamp();\n\n this._param = null!;\n this._engine = null!;\n }\n\n /**\n * Sets the target value of the audio parameter with an optional ramping duration and shape.\n *\n * If a ramp is close to finishing, it will wait for the ramp to finish before setting the new value; otherwise it\n * will throw an error because of a bug in Firefox that prevents active ramps from being cancelled with\n * `cancelScheduledValues`. See https://bugzilla.mozilla.org/show_bug.cgi?id=1752775. Other browsers do not have\n * this issue, but we throw an error in all browsers to ensure consistent behavior.\n *\n * There are other similar WebAudio APIs for ramping parameters, (e.g. `linearRampToValueAtTime` and\n * `exponentialRampToValueAtTime`) but they don't work in Firefox and Meta Quest Chrome.\n *\n * It may be better in the long run to implement our own ramping logic with a WASM audio worklet instead of using\n * `setValueCurveAtTime`. Another alternative is to use `setValueAtTime` wtih a custom shape, but that will\n * probably be a performance hit to maintain quality at audio rates.\n *\n * @internal\n */\n public setTargetValue(value: number, options: Nullable<Partial<IAudioParameterRampOptions>> = null): void {\n if (this._targetValue === value) {\n return;\n }\n\n const shape = typeof options?.shape === \"string\" ? options.shape : AudioParameterRampShape.Linear;\n\n let duration = typeof options?.duration === \"number\" ? Math.max(options.duration, this._engine.parameterRampDuration) : this._engine.parameterRampDuration;\n const startTime = this._engine.currentTime;\n\n if (startTime < this._rampEndTime) {\n const timeLeft = this._rampEndTime - startTime;\n\n if (MaxWaitTime < timeLeft) {\n throw new Error(\"Audio parameter not set. Wait for current ramp to finish.\");\n } else {\n this._deferRamp(value, duration, shape);\n return;\n }\n }\n\n if ((duration = Math.max(this._engine.parameterRampDuration, duration)) < MinRampDuration) {\n this._param.setValueAtTime((this._targetValue = value), startTime);\n return;\n }\n\n this._param.cancelScheduledValues(startTime);\n this._param.setValueCurveAtTime(_GetAudioParamCurveValues(shape, this._targetValue, (this._targetValue = value)), startTime, duration);\n\n this._clearDeferredRamp();\n\n this._rampEndTime = startTime + duration;\n }\n\n private _deferRamp(value: number, duration: number, shape: AudioParameterRampShape): void {\n this._deferredRampOptions.duration = duration;\n this._deferredRampOptions.shape = shape;\n this._deferredTargetValue = value;\n\n if (!this._isObservingUpdates) {\n this._engine._addUpdateObserver(this._applyDeferredRamp);\n this._isObservingUpdates = true;\n }\n }\n\n private _applyDeferredRamp = () => {\n if (0 < this._deferredRampOptions.duration && this._rampEndTime < this._engine.currentTime) {\n this.setTargetValue(this._deferredTargetValue, this._deferredRampOptions);\n }\n };\n\n private _clearDeferredRamp(): void {\n this._deferredRampOptions.duration = 0;\n\n if (this._isObservingUpdates) {\n this._engine._removeUpdateObserver(this._applyDeferredRamp);\n this._isObservingUpdates = false;\n }\n }\n}\n"]}
1
+ {"version":3,"file":"webAudioParameterComponent.js","sourceRoot":"","sources":["../../../../../../dev/core/src/AudioV2/webAudio/components/webAudioParameterComponent.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,yBAAyB,EAAE,MAAM,kBAAkB,CAAC;AAG7D;;;;;GAKG;AACH,MAAM,eAAe,GAAG,QAAQ,CAAC;AAEjC,gBAAgB;AAChB,MAAM,OAAO,2BAA2B;IAMpC,gBAA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,OAAO,OAAO,EAAE,QAAQ,KAAK,QAAQ,CAAC,CAAC,CAAC,IAAI,CAAC,GAAG,CAAC,OAAO,CAAC,QAAQ,EAAE,IAAI,CAAC,OAAO,CAAC,qBAAqB,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,OAAO,CAAC,qBAAqB,CAAC;QAE3J,IAAI,CAAC,QAAQ,GAAG,IAAI,CAAC,GAAG,CAAC,IAAI,CAAC,OAAO,CAAC,qBAAqB,EAAE,QAAQ,CAAC,CAAC,GAAG,eAAe,EAAE,CAAC;YACxF,IAAI,CAAC,MAAM,CAAC,cAAc,CAAC,CAAC,IAAI,CAAC,YAAY,GAAG,KAAK,CAAC,EAAE,SAAS,CAAC,CAAC;YACnE,OAAO;QACX,CAAC;QAED,IAAI,CAAC,MAAM,CAAC,qBAAqB,CAAC,SAAS,CAAC,CAAC;QAC7C,IAAI,CAAC,MAAM,CAAC,mBAAmB,CAAC,yBAAyB,CAAC,KAAK,EAAE,IAAI,CAAC,MAAM,CAAC,KAAK,EAAE,CAAC,IAAI,CAAC,YAAY,GAAG,KAAK,CAAC,CAAC,EAAE,SAAS,EAAE,QAAQ,CAAC,CAAC;QAEvI,IAAI,CAAC,YAAY,GAAG,SAAS,GAAG,QAAQ,CAAC;IAC7C,CAAC;CACJ","sourcesContent":["import type { Nullable } from \"../../../types\";\nimport type { IAudioParameterRampOptions } from \"../../audioParameter\";\nimport { AudioParameterRampShape } from \"../../audioParameter\";\nimport { _GetAudioParamCurveValues } from \"../../audioUtils\";\nimport type { _WebAudioEngine } from \"../webAudioEngine\";\n\n/**\n * Minimum duration in seconds for a ramp to be considered valid.\n *\n * If the duration is less than this value, the value will be set immediately instead of being ramped smoothly since\n * there is no perceptual difference for such short durations, so a ramp is not needed.\n */\nconst MinRampDuration = 0.000001;\n\n/** @internal */\nexport class _WebAudioParameterComponent {\n private _rampEndTime: number = 0;\n private _engine: _WebAudioEngine;\n private _param: AudioParam;\n private _targetValue: number;\n\n /** @internal */\n constructor(engine: _WebAudioEngine, param: AudioParam) {\n this._engine = engine;\n this._param = param;\n this._targetValue = param.value;\n }\n\n /** @internal */\n public get isRamping(): boolean {\n return this._engine.currentTime < this._rampEndTime;\n }\n\n /** @internal */\n public get targetValue(): number {\n return this._targetValue;\n }\n\n public set targetValue(value: number) {\n this.setTargetValue(value);\n }\n\n /** @internal */\n public get value(): number {\n return this._param.value;\n }\n\n /** @internal */\n public dispose(): void {\n this._param = null!;\n this._engine = null!;\n }\n\n /**\n * Sets the target value of the audio parameter with an optional ramping duration and shape.\n *\n * @internal\n */\n public setTargetValue(value: number, options: Nullable<Partial<IAudioParameterRampOptions>> = null): void {\n const shape = typeof options?.shape === \"string\" ? options.shape : AudioParameterRampShape.Linear;\n\n const startTime = this._engine.currentTime;\n\n if (shape === AudioParameterRampShape.None) {\n this._param.cancelScheduledValues(startTime);\n this._param.value = this._targetValue = value;\n this._rampEndTime = startTime;\n return;\n }\n\n let duration = typeof options?.duration === \"number\" ? Math.max(options.duration, this._engine.parameterRampDuration) : this._engine.parameterRampDuration;\n\n if ((duration = Math.max(this._engine.parameterRampDuration, duration)) < MinRampDuration) {\n this._param.setValueAtTime((this._targetValue = value), startTime);\n return;\n }\n\n this._param.cancelScheduledValues(startTime);\n this._param.setValueCurveAtTime(_GetAudioParamCurveValues(shape, this._param.value, (this._targetValue = value)), startTime, duration);\n\n this._rampEndTime = startTime + duration;\n }\n}\n"]}
@@ -124,8 +124,10 @@ export declare class SphereDirectedParticleEmitter extends SphereParticleEmitter
124
124
  * Called by the particle System when the direction is computed for the created particle.
125
125
  * @param worldMatrix is the world matrix of the particle system
126
126
  * @param directionToUpdate is the direction vector to update with the result
127
+ * @param particle is the particle we are computed the position for
128
+ * @param isLocal defines if the direction should be set in local space
127
129
  */
128
- startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3): void;
130
+ startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
129
131
  /**
130
132
  * Clones the current emitter and returns a copy of it
131
133
  * @returns the new emitter
@@ -163,11 +163,17 @@ export class SphereDirectedParticleEmitter extends SphereParticleEmitter {
163
163
  * Called by the particle System when the direction is computed for the created particle.
164
164
  * @param worldMatrix is the world matrix of the particle system
165
165
  * @param directionToUpdate is the direction vector to update with the result
166
+ * @param particle is the particle we are computed the position for
167
+ * @param isLocal defines if the direction should be set in local space
166
168
  */
167
- startDirectionFunction(worldMatrix, directionToUpdate) {
169
+ startDirectionFunction(worldMatrix, directionToUpdate, particle, isLocal) {
168
170
  const randX = RandomRange(this.direction1.x, this.direction2.x);
169
171
  const randY = RandomRange(this.direction1.y, this.direction2.y);
170
172
  const randZ = RandomRange(this.direction1.z, this.direction2.z);
173
+ if (isLocal) {
174
+ directionToUpdate.copyFromFloats(randX, randY, randZ);
175
+ return;
176
+ }
171
177
  Vector3.TransformNormalFromFloatsToRef(randX, randY, randZ, worldMatrix, directionToUpdate);
172
178
  }
173
179
  /**
@@ -1 +1 @@
1
- {"version":3,"file":"sphereParticleEmitter.js","sourceRoot":"","sources":["../../../../../dev/core/src/Particles/EmitterTypes/sphereParticleEmitter.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,OAAO,EAAE,MAAM,yBAAyB,CAAC;AAClD,OAAO,EAAE,WAAW,EAAE,MAAM,mCAAmC,CAAC;AAGhE,OAAO,EAAE,UAAU,EAAE,MAAM,uBAAuB,CAAC;AAGnD;;;GAGG;AACH,MAAM,OAAO,qBAAqB;IAC9B;;;;;OAKG;IACH;IACI;;OAEG;IACI,SAAS,CAAC;IACjB;;OAEG;IACI,cAAc,CAAC;IACtB;;OAEG;IACI,sBAAsB,CAAC;QARvB,WAAM,GAAN,MAAM,CAAI;QAIV,gBAAW,GAAX,WAAW,CAAI;QAIf,wBAAmB,GAAnB,mBAAmB,CAAI;IAC/B,CAAC;IAEJ;;;;;;OAMG;IACI,sBAAsB,CAAC,WAAmB,EAAE,iBAA0B,EAAE,QAAkB,EAAE,OAAgB;QAC/G,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G,CAAC,UAAU,CAAC,YAAY,EAAE,CAAC,CAAC,CAAC;IACpC,CAAC;IAED;;;OAGG;IACa,gBAAgB;QAC5B,OAAO,sDAAsD,CAAC;IAClE,CAAC;IAED;;;OAGG;IACa,YAAY;QACxB,OAAO,+BAA+B,CAAC;IAC3C,CAAC;IAED;;;OAGG;IACa,SAAS;QACrB,MAAM,mBAAmB,GAAG,KAAK,CAAC,SAAS,EAAE,CAAC;QAE9C,mBAAmB,CAAC,UAAU,GAAG,IAAI,CAAC,UAAU,CAAC,OAAO,EAAE,CAAC;QAC3D,mBAAmB,CAAC,UAAU,GAAG,IAAI,CAAC,UAAU,CAAC,OAAO,EAAE,CAAC;QAE3D,OAAO,mBAAmB,CAAC;IAC/B,CAAC;IAED;;;OAGG;IACa,KAAK,CAAC,mBAAwB;QAC1C,KAAK,CAAC,KAAK,CAAC,mBAAmB,CAAC,CAAC;QACjC,IAAI,CAAC,UAAU,CAAC,QAAQ,CAAC,mBAAmB,CAAC,UAAU,CAAC,CAAC;QACzD,IAAI,CAAC,UAAU,CAAC,QAAQ,CAAC,mBAAmB,CAAC,UAAU,CAAC,CAAC;IAC7D,CAAC;CACJ","sourcesContent":["import type { Matrix } from \"../../Maths/math.vector\";\r\nimport { Vector3 } from \"../../Maths/math.vector\";\r\nimport { RandomRange } from \"../../Maths/math.scalar.functions\";\r\nimport type { Particle } from \"../../Particles/particle\";\r\nimport type { IParticleEmitterType } from \"./IParticleEmitterType\";\r\nimport { DeepCopier } from \"../../Misc/deepCopier\";\r\nimport type { UniformBufferEffectCommonAccessor } from \"../../Materials/uniformBufferEffectCommonAccessor\";\r\nimport type { UniformBuffer } from \"../../Materials/uniformBuffer\";\r\n/**\r\n * Particle emitter emitting particles from the inside of a sphere.\r\n * It emits the particles alongside the sphere radius. The emission direction might be randomized.\r\n */\r\nexport class SphereParticleEmitter implements IParticleEmitterType {\r\n /**\r\n * Creates a new instance SphereParticleEmitter\r\n * @param radius the radius of the emission sphere (1 by default)\r\n * @param radiusRange the range of the emission sphere [0-1] 0 Surface only, 1 Entire Radius (1 by default)\r\n * @param directionRandomizer defines how much to randomize the particle direction [0-1]\r\n */\r\n constructor(\r\n /**\r\n * [1] The radius of the emission sphere.\r\n */\r\n public radius = 1,\r\n /**\r\n * [1] The range of emission [0-1] 0 Surface only, 1 Entire Radius.\r\n */\r\n public radiusRange = 1,\r\n /**\r\n * [0] How much to randomize the particle direction [0-1].\r\n */\r\n public directionRandomizer = 0\r\n ) {}\r\n\r\n /**\r\n * Called by the particle System when the direction is computed for the created particle.\r\n * @param worldMatrix is the world matrix of the particle system\r\n * @param directionToUpdate is the direction vector to update with the result\r\n * @param particle is the particle we are computed the direction for\r\n * @param isLocal defines if the direction should be set in local space\r\n */\r\n public startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void {\r\n const direction = particle.position.subtract(worldMatrix.getTranslation()).normalize();\r\n const randX = RandomRange(0, this.directionRandomizer);\r\n const randY = RandomRange(0, this.directionRandomizer);\r\n const randZ = RandomRange(0, this.directionRandomizer);\r\n direction.x += randX;\r\n direction.y += randY;\r\n direction.z += randZ;\r\n direction.normalize();\r\n\r\n if (isLocal) {\r\n directionToUpdate.copyFrom(direction);\r\n return;\r\n }\r\n\r\n Vector3.TransformNormalFromFloatsToRef(direction.x, direction.y, direction.z, worldMatrix, directionToUpdate);\r\n }\r\n\r\n /**\r\n * Called by the particle System when the position is computed for the created particle.\r\n * @param worldMatrix is the world matrix of the particle system\r\n * @param positionToUpdate is the position vector to update with the result\r\n * @param particle is the particle we are computed the position for\r\n * @param isLocal defines if the position should be set in local space\r\n */\r\n public startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void {\r\n const randRadius = this.radius - RandomRange(0, this.radius * this.radiusRange);\r\n const v = RandomRange(0, 1.0);\r\n const phi = RandomRange(0, 2 * Math.PI);\r\n const theta = Math.acos(2 * v - 1);\r\n const randX = randRadius * Math.cos(phi) * Math.sin(theta);\r\n const randY = randRadius * Math.cos(theta);\r\n const randZ = randRadius * Math.sin(phi) * Math.sin(theta);\r\n\r\n if (isLocal) {\r\n positionToUpdate.copyFromFloats(randX, randY, randZ);\r\n return;\r\n }\r\n\r\n Vector3.TransformCoordinatesFromFloatsToRef(randX, randY, randZ, worldMatrix, positionToUpdate);\r\n }\r\n\r\n /**\r\n * Clones the current emitter and returns a copy of it\r\n * @returns the new emitter\r\n */\r\n public clone(): SphereParticleEmitter {\r\n const newOne = new SphereParticleEmitter(this.radius, this.directionRandomizer);\r\n\r\n DeepCopier.DeepCopy(this, newOne);\r\n\r\n return newOne;\r\n }\r\n\r\n /**\r\n * Called by the GPUParticleSystem to setup the update shader\r\n * @param uboOrEffect defines the update shader\r\n */\r\n public applyToShader(uboOrEffect: UniformBufferEffectCommonAccessor): void {\r\n uboOrEffect.setFloat(\"radius\", this.radius);\r\n uboOrEffect.setFloat(\"radiusRange\", this.radiusRange);\r\n uboOrEffect.setFloat(\"directionRandomizer\", this.directionRandomizer);\r\n }\r\n\r\n /**\r\n * Creates the structure of the ubo for this particle emitter\r\n * @param ubo ubo to create the structure for\r\n */\r\n public buildUniformLayout(ubo: UniformBuffer): void {\r\n ubo.addUniform(\"radius\", 1);\r\n ubo.addUniform(\"radiusRange\", 1);\r\n ubo.addUniform(\"directionRandomizer\", 1);\r\n }\r\n\r\n /**\r\n * Returns a string to use to update the GPU particles update shader\r\n * @returns a string containing the defines string\r\n */\r\n public getEffectDefines(): string {\r\n return \"#define SPHEREEMITTER\";\r\n }\r\n\r\n /**\r\n * Returns the string \"SphereParticleEmitter\"\r\n * @returns a string containing the class name\r\n */\r\n public getClassName(): string {\r\n return \"SphereParticleEmitter\";\r\n }\r\n\r\n /**\r\n * Serializes the particle system to a JSON object.\r\n * @returns the JSON object\r\n */\r\n public serialize(): any {\r\n const serializationObject: any = {};\r\n serializationObject.type = this.getClassName();\r\n serializationObject.radius = this.radius;\r\n serializationObject.radiusRange = this.radiusRange;\r\n serializationObject.directionRandomizer = this.directionRandomizer;\r\n\r\n return serializationObject;\r\n }\r\n\r\n /**\r\n * Parse properties from a JSON object\r\n * @param serializationObject defines the JSON object\r\n */\r\n public parse(serializationObject: any): void {\r\n this.radius = serializationObject.radius;\r\n this.radiusRange = serializationObject.radiusRange;\r\n this.directionRandomizer = serializationObject.directionRandomizer;\r\n }\r\n}\r\n\r\n/**\r\n * Particle emitter emitting particles from the inside of a sphere.\r\n * It emits the particles randomly between two vectors.\r\n */\r\nexport class SphereDirectedParticleEmitter extends SphereParticleEmitter {\r\n /**\r\n * Creates a new instance SphereDirectedParticleEmitter\r\n * @param radius the radius of the emission sphere (1 by default)\r\n * @param direction1 the min limit of the emission direction (up vector by default)\r\n * @param direction2 the max limit of the emission direction (up vector by default)\r\n */\r\n constructor(\r\n radius = 1,\r\n /**\r\n * [Up vector] The min limit of the emission direction.\r\n */\r\n public direction1 = new Vector3(0, 1, 0),\r\n /**\r\n * [Up vector] The max limit of the emission direction.\r\n */\r\n public direction2 = new Vector3(0, 1, 0)\r\n ) {\r\n super(radius);\r\n }\r\n\r\n /**\r\n * Called by the particle System when the direction is computed for the created particle.\r\n * @param worldMatrix is the world matrix of the particle system\r\n * @param directionToUpdate is the direction vector to update with the result\r\n */\r\n public override startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3): void {\r\n const randX = RandomRange(this.direction1.x, this.direction2.x);\r\n const randY = RandomRange(this.direction1.y, this.direction2.y);\r\n const randZ = RandomRange(this.direction1.z, this.direction2.z);\r\n Vector3.TransformNormalFromFloatsToRef(randX, randY, randZ, worldMatrix, directionToUpdate);\r\n }\r\n\r\n /**\r\n * Clones the current emitter and returns a copy of it\r\n * @returns the new emitter\r\n */\r\n public override clone(): SphereDirectedParticleEmitter {\r\n const newOne = new SphereDirectedParticleEmitter(this.radius, this.direction1, this.direction2);\r\n\r\n DeepCopier.DeepCopy(this, newOne);\r\n\r\n return newOne;\r\n }\r\n\r\n /**\r\n * Called by the GPUParticleSystem to setup the update shader\r\n * @param uboOrEffect defines the update shader\r\n */\r\n public override applyToShader(uboOrEffect: UniformBufferEffectCommonAccessor): void {\r\n uboOrEffect.setFloat(\"radius\", this.radius);\r\n uboOrEffect.setFloat(\"radiusRange\", this.radiusRange);\r\n uboOrEffect.setVector3(\"direction1\", this.direction1);\r\n uboOrEffect.setVector3(\"direction2\", this.direction2);\r\n }\r\n\r\n /**\r\n * Creates the structure of the ubo for this particle emitter\r\n * @param ubo ubo to create the structure for\r\n */\r\n public override buildUniformLayout(ubo: UniformBuffer): void {\r\n ubo.addUniform(\"radius\", 1);\r\n ubo.addUniform(\"radiusRange\", 1);\r\n ubo.addUniform(\"direction1\", 3);\r\n ubo.addUniform(\"direction2\", 3);\r\n }\r\n\r\n /**\r\n * Returns a string to use to update the GPU particles update shader\r\n * @returns a string containing the defines string\r\n */\r\n public override getEffectDefines(): string {\r\n return \"#define SPHEREEMITTER\\n#define DIRECTEDSPHEREEMITTER\";\r\n }\r\n\r\n /**\r\n * Returns the string \"SphereDirectedParticleEmitter\"\r\n * @returns a string containing the class name\r\n */\r\n public override getClassName(): string {\r\n return \"SphereDirectedParticleEmitter\";\r\n }\r\n\r\n /**\r\n * Serializes the particle system to a JSON object.\r\n * @returns the JSON object\r\n */\r\n public override serialize(): any {\r\n const serializationObject = super.serialize();\r\n\r\n serializationObject.direction1 = this.direction1.asArray();\r\n serializationObject.direction2 = this.direction2.asArray();\r\n\r\n return serializationObject;\r\n }\r\n\r\n /**\r\n * Parse properties from a JSON object\r\n * @param serializationObject defines the JSON object\r\n */\r\n public override parse(serializationObject: any): void {\r\n super.parse(serializationObject);\r\n this.direction1.copyFrom(serializationObject.direction1);\r\n this.direction2.copyFrom(serializationObject.direction2);\r\n }\r\n}\r\n"]}
1
+ {"version":3,"file":"sphereParticleEmitter.js","sourceRoot":"","sources":["../../../../../dev/core/src/Particles/EmitterTypes/sphereParticleEmitter.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,OAAO,E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Q,CAAC,mBAAmB,CAAC,UAAU,CAAC,CAAC;QACzD,IAAI,CAAC,UAAU,CAAC,QAAQ,CAAC,mBAAmB,CAAC,UAAU,CAAC,CAAC;IAC7D,CAAC;CACJ","sourcesContent":["import type { Matrix } from \"../../Maths/math.vector\";\r\nimport { Vector3 } from \"../../Maths/math.vector\";\r\nimport { RandomRange } from \"../../Maths/math.scalar.functions\";\r\nimport type { Particle } from \"../../Particles/particle\";\r\nimport type { IParticleEmitterType } from \"./IParticleEmitterType\";\r\nimport { DeepCopier } from \"../../Misc/deepCopier\";\r\nimport type { UniformBufferEffectCommonAccessor } from \"../../Materials/uniformBufferEffectCommonAccessor\";\r\nimport type { UniformBuffer } from \"../../Materials/uniformBuffer\";\r\n/**\r\n * Particle emitter emitting particles from the inside of a sphere.\r\n * It emits the particles alongside the sphere radius. The emission direction might be randomized.\r\n */\r\nexport class SphereParticleEmitter implements IParticleEmitterType {\r\n /**\r\n * Creates a new instance SphereParticleEmitter\r\n * @param radius the radius of the emission sphere (1 by default)\r\n * @param radiusRange the range of the emission sphere [0-1] 0 Surface only, 1 Entire Radius (1 by default)\r\n * @param directionRandomizer defines how much to randomize the particle direction [0-1]\r\n */\r\n constructor(\r\n /**\r\n * [1] The radius of the emission sphere.\r\n */\r\n public radius = 1,\r\n /**\r\n * [1] The range of emission [0-1] 0 Surface only, 1 Entire Radius.\r\n */\r\n public radiusRange = 1,\r\n /**\r\n * [0] How much to randomize the particle direction [0-1].\r\n */\r\n public directionRandomizer = 0\r\n ) {}\r\n\r\n /**\r\n * Called by the particle System when the direction is computed for the created particle.\r\n * @param worldMatrix is the world matrix of the particle system\r\n * @param directionToUpdate is the direction vector to update with the result\r\n * @param particle is the particle we are computed the direction for\r\n * @param isLocal defines if the direction should be set in local space\r\n */\r\n public startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void {\r\n const direction = particle.position.subtract(worldMatrix.getTranslation()).normalize();\r\n const randX = RandomRange(0, this.directionRandomizer);\r\n const randY = RandomRange(0, this.directionRandomizer);\r\n const randZ = RandomRange(0, this.directionRandomizer);\r\n direction.x += randX;\r\n direction.y += randY;\r\n direction.z += randZ;\r\n direction.normalize();\r\n\r\n if (isLocal) {\r\n directionToUpdate.copyFrom(direction);\r\n return;\r\n }\r\n\r\n Vector3.TransformNormalFromFloatsToRef(direction.x, direction.y, direction.z, worldMatrix, directionToUpdate);\r\n }\r\n\r\n /**\r\n * Called by the particle System when the position is computed for the created particle.\r\n * @param worldMatrix is the world matrix of the particle system\r\n * @param positionToUpdate is the position vector to update with the result\r\n * @param particle is the particle we are computed the position for\r\n * @param isLocal defines if the position should be set in local space\r\n */\r\n public startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void {\r\n const randRadius = this.radius - RandomRange(0, this.radius * this.radiusRange);\r\n const v = RandomRange(0, 1.0);\r\n const phi = RandomRange(0, 2 * Math.PI);\r\n const theta = Math.acos(2 * v - 1);\r\n const randX = randRadius * Math.cos(phi) * Math.sin(theta);\r\n const randY = randRadius * Math.cos(theta);\r\n const randZ = randRadius * Math.sin(phi) * Math.sin(theta);\r\n\r\n if (isLocal) {\r\n positionToUpdate.copyFromFloats(randX, randY, randZ);\r\n return;\r\n }\r\n\r\n Vector3.TransformCoordinatesFromFloatsToRef(randX, randY, randZ, worldMatrix, positionToUpdate);\r\n }\r\n\r\n /**\r\n * Clones the current emitter and returns a copy of it\r\n * @returns the new emitter\r\n */\r\n public clone(): SphereParticleEmitter {\r\n const newOne = new SphereParticleEmitter(this.radius, this.directionRandomizer);\r\n\r\n DeepCopier.DeepCopy(this, newOne);\r\n\r\n return newOne;\r\n }\r\n\r\n /**\r\n * Called by the GPUParticleSystem to setup the update shader\r\n * @param uboOrEffect defines the update shader\r\n */\r\n public applyToShader(uboOrEffect: UniformBufferEffectCommonAccessor): void {\r\n uboOrEffect.setFloat(\"radius\", this.radius);\r\n uboOrEffect.setFloat(\"radiusRange\", this.radiusRange);\r\n uboOrEffect.setFloat(\"directionRandomizer\", this.directionRandomizer);\r\n }\r\n\r\n /**\r\n * Creates the structure of the ubo for this particle emitter\r\n * @param ubo ubo to create the structure for\r\n */\r\n public buildUniformLayout(ubo: UniformBuffer): void {\r\n ubo.addUniform(\"radius\", 1);\r\n ubo.addUniform(\"radiusRange\", 1);\r\n ubo.addUniform(\"directionRandomizer\", 1);\r\n }\r\n\r\n /**\r\n * Returns a string to use to update the GPU particles update shader\r\n * @returns a string containing the defines string\r\n */\r\n public getEffectDefines(): string {\r\n return \"#define SPHEREEMITTER\";\r\n }\r\n\r\n /**\r\n * Returns the string \"SphereParticleEmitter\"\r\n * @returns a string containing the class name\r\n */\r\n public getClassName(): string {\r\n return \"SphereParticleEmitter\";\r\n }\r\n\r\n /**\r\n * Serializes the particle system to a JSON object.\r\n * @returns the JSON object\r\n */\r\n public serialize(): any {\r\n const serializationObject: any = {};\r\n serializationObject.type = this.getClassName();\r\n serializationObject.radius = this.radius;\r\n serializationObject.radiusRange = this.radiusRange;\r\n serializationObject.directionRandomizer = this.directionRandomizer;\r\n\r\n return serializationObject;\r\n }\r\n\r\n /**\r\n * Parse properties from a JSON object\r\n * @param serializationObject defines the JSON object\r\n */\r\n public parse(serializationObject: any): void {\r\n this.radius = serializationObject.radius;\r\n this.radiusRange = serializationObject.radiusRange;\r\n this.directionRandomizer = serializationObject.directionRandomizer;\r\n }\r\n}\r\n\r\n/**\r\n * Particle emitter emitting particles from the inside of a sphere.\r\n * It emits the particles randomly between two vectors.\r\n */\r\nexport class SphereDirectedParticleEmitter extends SphereParticleEmitter {\r\n /**\r\n * Creates a new instance SphereDirectedParticleEmitter\r\n * @param radius the radius of the emission sphere (1 by default)\r\n * @param direction1 the min limit of the emission direction (up vector by default)\r\n * @param direction2 the max limit of the emission direction (up vector by default)\r\n */\r\n constructor(\r\n radius = 1,\r\n /**\r\n * [Up vector] The min limit of the emission direction.\r\n */\r\n public direction1 = new Vector3(0, 1, 0),\r\n /**\r\n * [Up vector] The max limit of the emission direction.\r\n */\r\n public direction2 = new Vector3(0, 1, 0)\r\n ) {\r\n super(radius);\r\n }\r\n\r\n /**\r\n * Called by the particle System when the direction is computed for the created particle.\r\n * @param worldMatrix is the world matrix of the particle system\r\n * @param directionToUpdate is the direction vector to update with the result\r\n * @param particle is the particle we are computed the position for\r\n * @param isLocal defines if the direction should be set in local space\r\n */\r\n public override startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void {\r\n const randX = RandomRange(this.direction1.x, this.direction2.x);\r\n const randY = RandomRange(this.direction1.y, this.direction2.y);\r\n const randZ = RandomRange(this.direction1.z, this.direction2.z);\r\n\r\n if (isLocal) {\r\n directionToUpdate.copyFromFloats(randX, randY, randZ);\r\n return;\r\n }\r\n\r\n Vector3.TransformNormalFromFloatsToRef(randX, randY, randZ, worldMatrix, directionToUpdate);\r\n }\r\n\r\n /**\r\n * Clones the current emitter and returns a copy of it\r\n * @returns the new emitter\r\n */\r\n public override clone(): SphereDirectedParticleEmitter {\r\n const newOne = new SphereDirectedParticleEmitter(this.radius, this.direction1, this.direction2);\r\n\r\n DeepCopier.DeepCopy(this, newOne);\r\n\r\n return newOne;\r\n }\r\n\r\n /**\r\n * Called by the GPUParticleSystem to setup the update shader\r\n * @param uboOrEffect defines the update shader\r\n */\r\n public override applyToShader(uboOrEffect: UniformBufferEffectCommonAccessor): void {\r\n uboOrEffect.setFloat(\"radius\", this.radius);\r\n uboOrEffect.setFloat(\"radiusRange\", this.radiusRange);\r\n uboOrEffect.setVector3(\"direction1\", this.direction1);\r\n uboOrEffect.setVector3(\"direction2\", this.direction2);\r\n }\r\n\r\n /**\r\n * Creates the structure of the ubo for this particle emitter\r\n * @param ubo ubo to create the structure for\r\n */\r\n public override buildUniformLayout(ubo: UniformBuffer): void {\r\n ubo.addUniform(\"radius\", 1);\r\n ubo.addUniform(\"radiusRange\", 1);\r\n ubo.addUniform(\"direction1\", 3);\r\n ubo.addUniform(\"direction2\", 3);\r\n }\r\n\r\n /**\r\n * Returns a string to use to update the GPU particles update shader\r\n * @returns a string containing the defines string\r\n */\r\n public override getEffectDefines(): string {\r\n return \"#define SPHEREEMITTER\\n#define DIRECTEDSPHEREEMITTER\";\r\n }\r\n\r\n /**\r\n * Returns the string \"SphereDirectedParticleEmitter\"\r\n * @returns a string containing the class name\r\n */\r\n public override getClassName(): string {\r\n return \"SphereDirectedParticleEmitter\";\r\n }\r\n\r\n /**\r\n * Serializes the particle system to a JSON object.\r\n * @returns the JSON object\r\n */\r\n public override serialize(): any {\r\n const serializationObject = super.serialize();\r\n\r\n serializationObject.direction1 = this.direction1.asArray();\r\n serializationObject.direction2 = this.direction2.asArray();\r\n\r\n return serializationObject;\r\n }\r\n\r\n /**\r\n * Parse properties from a JSON object\r\n * @param serializationObject defines the JSON object\r\n */\r\n public override parse(serializationObject: any): void {\r\n super.parse(serializationObject);\r\n this.direction1.copyFrom(serializationObject.direction1);\r\n this.direction2.copyFrom(serializationObject.direction2);\r\n }\r\n}\r\n"]}
@@ -1,7 +1,7 @@
1
1
  import type { NodeParticleConnectionPoint } from "../../nodeParticleBlockConnectionPoint.js";
2
2
  import type { NodeParticleBuildState } from "../../nodeParticleBuildState.js";
3
- import { NodeParticleBlock } from "../../nodeParticleBlock.js";
4
3
  import type { IShapeBlock } from "./IShapeBlock.js";
4
+ import { NodeParticleBlock } from "../../nodeParticleBlock.js";
5
5
  /**
6
6
  * Block used to provide a flow of particles emitted from a box shape.
7
7
  */
@@ -3,6 +3,7 @@ import { NodeParticleBlockConnectionPointTypes } from "../../Enums/nodeParticleB
3
3
  import { Vector3 } from "../../../../Maths/math.vector.js";
4
4
  import { NodeParticleBlock } from "../../nodeParticleBlock.js";
5
5
  import { RandomRange } from "../../../../Maths/math.scalar.functions.js";
6
+ import { _CreateLocalPositionData } from "./emitters.functions.js";
6
7
  /**
7
8
  * Block used to provide a flow of particles emitted from a box shape.
8
9
  */
@@ -95,11 +96,11 @@ export class BoxShapeBlock extends NodeParticleBlock {
95
96
  const randZ = RandomRange(minEmitBox.z, maxEmitBox.z);
96
97
  if (system.isLocal) {
97
98
  particle.position.copyFromFloats(randX, randY, randZ);
98
- particle.position.addInPlace(state.emitterPosition);
99
99
  }
100
100
  else {
101
101
  Vector3.TransformCoordinatesFromFloatsToRef(randX, randY, randZ, state.emitterWorldMatrix, particle.position);
102
102
  }
103
+ _CreateLocalPositionData(particle);
103
104
  };
104
105
  this.output._storedValue = system;
105
106
  }
@@ -1 +1 @@
1
- {"version":3,"file":"boxShapeBlock.js","sourceRoot":"","sources":["../../../../../../../dev/core/src/Particles/Node/Blocks/Emitters/boxShapeBlock.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,4BAA4B,CAAC;AAC3D,OAAO,EAAE,qCAAqC,EAAE,MAAM,mDAAmD,CAAC;AAE1G,OAAO,EAAE,OAAO,EAAE,yCAA+B;AAEjD,OAAO,EAAE,iBAAiB,EAAE,MAAM,yBAAyB,CAAC;AAE5D,OAAO,EAAE,WAAW,EAAE,mDAAyC;AAG/D;;GAEG;AACH,MAAM,OAAO,aAAc,SAAQ,iBAAiB;IAChD;;;OAGG;IACH,YAAmB,IAAY;QAC3B,KAAK,CAAC,IAAI,CAAC,CAAC;QAEZ,IAAI,CAAC,aAAa,CAAC,UAAU,EAAE,qCAAqC,CAAC,QAAQ,CAAC,CAAC;QAC/E,IAAI,CAAC,aAAa,CAAC,YAAY,EAAE,qCAAqC,CAAC,OAAO,EAAE,IAAI,EAAE,IAAI,OAAO,CAAC,CAAC,EAAE,GAAG,EAAE,CAAC,CAAC,CAAC,CAAC;QAC9G,IAAI,CAAC,aAAa,CAAC,YAAY,EAAE,qCAAqC,CAAC,OAAO,EAAE,IAAI,EAAE,IAAI,OAAO,CAAC,CAAC,EAAE,GAAG,EAAE,CAAC,CAAC,CAAC,CAAC;QAC9G,IAAI,CAAC,aAAa,CAAC,YAAY,EAAE,qCAAqC,CAAC,OA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AU,CAAC,CAAC,CAAC,CAAC;YACtD,MAAM,KAAK,GAAG,WAAW,CAAC,UAAU,CAAC,CAAC,EAAE,UAAU,CAAC,CAAC,CAAC,CAAC;YACtD,MAAM,KAAK,GAAG,WAAW,CAAC,UAAU,CAAC,CAAC,EAAE,UAAU,CAAC,CAAC,CAAC,CAAC;YAEtD,IAAI,MAAM,CAAC,OAAO,EAAE,CAAC;gBACjB,QAAQ,CAAC,QAAQ,CAAC,cAAc,CAAC,KAAK,EAAE,KAAK,EAAE,KAAK,CAAC,CAAC;gBACtD,QAAQ,CAAC,QAAQ,CAAC,UAAU,CAAC,KAAK,CAAC,eAAgB,CAAC,CAAC;YACzD,CAAC;iBAAM,CAAC;gBACJ,OAAO,CAAC,mCAAmC,CAAC,KAAK,EAAE,KAAK,EAAE,KAAK,EAAE,KAAK,CAAC,kBAAmB,EAAE,QAAQ,CAAC,QAAQ,CAAC,CAAC;YACnH,CAAC;QACL,CAAC,CAAC;QAEF,IAAI,CAAC,MAAM,CAAC,YAAY,GAAG,MAAM,CAAC;IACtC,CAAC;CACJ;AAED,aAAa,CAAC,uBAAuB,EAAE,aAAa,CAAC,CAAC","sourcesContent":["import { RegisterClass } from \"../../../../Misc/typeStore\";\r\nimport { NodeParticleBlockConnectionPointTypes } from \"../../Enums/nodeParticleBlockConnectionPointTypes\";\r\nimport type { NodeParticleConnectionPoint } from \"../../nodeParticleBlockConnectionPoint\";\r\nimport { Vector3 } from \"core/Maths/math.vector\";\r\nimport type { NodeParticleBuildState } from \"../../nodeParticleBuildState\";\r\nimport { NodeParticleBlock } from \"../../nodeParticleBlock\";\r\nimport type { Particle } from \"core/Particles/particle\";\r\nimport { RandomRange } from \"core/Maths/math.scalar.functions\";\r\nimport type { IShapeBlock } from \"./IShapeBlock\";\r\n\r\n/**\r\n * Block used to provide a flow of particles emitted from a box shape.\r\n */\r\nexport class BoxShapeBlock extends NodeParticleBlock implements IShapeBlock {\r\n /**\r\n * Create a new BoxShapeBlock\r\n * @param name defines the block name\r\n */\r\n public constructor(name: string) {\r\n super(name);\r\n\r\n this.registerInput(\"particle\", NodeParticleBlockConnectionPointTypes.Particle);\r\n this.registerInput(\"direction1\", NodeParticleBlockConnectionPointTypes.Vector3, true, new Vector3(0, 1.0, 0));\r\n this.registerInput(\"direction2\", NodeParticleBlockConnectionPointTypes.Vector3, true, new Vector3(0, 1.0, 0));\r\n this.registerInput(\"minEmitBox\", NodeParticleBlockConnectionPointTypes.Vector3, true, new Vector3(-0.5, -0.5, -0.5));\r\n this.registerInput(\"maxEmitBox\", NodeParticleBlockConnectionPointTypes.Vector3, true, new Vector3(0.5, 0.5, 0.5));\r\n this.registerOutput(\"output\", NodeParticleBlockConnectionPointTypes.Particle);\r\n }\r\n\r\n /**\r\n * Gets the current class name\r\n * @returns the class name\r\n */\r\n public override getClassName() {\r\n return \"BoxShapeBlock\";\r\n }\r\n\r\n /**\r\n * Gets the particle input component\r\n */\r\n public get particle(): NodeParticleConnectionPoint {\r\n return this._inputs[0];\r\n }\r\n\r\n /**\r\n * Gets the direction1 input component\r\n */\r\n public get direction1(): NodeParticleConnectionPoint {\r\n return this._inputs[1];\r\n }\r\n\r\n /**\r\n * Gets the direction2 input component\r\n */\r\n public get direction2(): NodeParticleConnectionPoint {\r\n return this._inputs[2];\r\n }\r\n\r\n /**\r\n * Gets the minEmitBox input component\r\n */\r\n public get minEmitBox(): NodeParticleConnectionPoint {\r\n return this._inputs[3];\r\n }\r\n\r\n /**\r\n * Gets the maxEmitBox input component\r\n */\r\n public get maxEmitBox(): NodeParticleConnectionPoint {\r\n return this._inputs[4];\r\n }\r\n\r\n /**\r\n * Gets the output component\r\n */\r\n public get output(): NodeParticleConnectionPoint {\r\n return this._outputs[0];\r\n }\r\n\r\n /**\r\n * Builds the block\r\n * @param state defines the build state\r\n */\r\n public override _build(state: NodeParticleBuildState) {\r\n const system = this.particle.getConnectedValue(state);\r\n\r\n system._directionCreation.process = (particle: Particle) => {\r\n state.particleContext = particle;\r\n state.systemContext = system;\r\n\r\n const direction1 = this.direction1.getConnectedValue(state) as Vector3;\r\n const direction2 = this.direction2.getConnectedValue(state) as Vector3;\r\n\r\n const randX = RandomRange(direction1.x, direction2.x);\r\n const randY = RandomRange(direction1.y, direction2.y);\r\n const randZ = RandomRange(direction1.z, direction2.z);\r\n\r\n if (system.isLocal) {\r\n particle.direction.copyFromFloats(randX, randY, randZ);\r\n } else {\r\n Vector3.TransformNormalFromFloatsToRef(randX, randY, randZ, state.emitterWorldMatrix!, particle.direction);\r\n }\r\n\r\n particle._initialDirection = particle.direction.clone();\r\n };\r\n\r\n system._positionCreation.process = (particle: Particle) => {\r\n state.particleContext = particle;\r\n state.systemContext = system;\r\n\r\n const minEmitBox = this.minEmitBox.getConnectedValue(state) as Vector3;\r\n const maxEmitBox = this.maxEmitBox.getConnectedValue(state) as Vector3;\r\n\r\n const randX = RandomRange(minEmitBox.x, maxEmitBox.x);\r\n const randY = RandomRange(minEmitBox.y, maxEmitBox.y);\r\n const randZ = RandomRange(minEmitBox.z, maxEmitBox.z);\r\n\r\n if (system.isLocal) {\r\n particle.position.copyFromFloats(randX, randY, randZ);\r\n particle.position.addInPlace(state.emitterPosition!);\r\n } else {\r\n Vector3.TransformCoordinatesFromFloatsToRef(randX, randY, randZ, state.emitterWorldMatrix!, particle.position);\r\n }\r\n };\r\n\r\n this.output._storedValue = system;\r\n }\r\n}\r\n\r\nRegisterClass(\"BABYLON.BoxShapeBlock\", BoxShapeBlock);\r\n"]}
1
+ {"version":3,"file":"boxShapeBlock.js","sourceRoot":"","sources":["../../../../../../../dev/core/src/Particles/Node/Blocks/Emitters/boxShapeBlock.ts"],"names":[],"mappings":"AAKA,OAAO,EAAE,aAAa,EAAE,MAAM,4BAA4B,CAAC;AAC3D,OAAO,EAAE,qCAAqC,EAAE,MAAM,mDAAmD,CAAC;AAC1G,OAAO,EAAE,OAAO,EAAE,yCAA+B;AACjD,OAAO,EAAE,iBAAiB,EAAE,MAAM,yBAAyB,CAAC;A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AM,CAAC,YAAY,GAAG,MAAM,CAAC;IACtC,CAAC;CACJ;AAED,aAAa,CAAC,uBAAuB,EAAE,aAAa,CAAC,CAAC","sourcesContent":["import type { NodeParticleConnectionPoint } from \"../../nodeParticleBlockConnectionPoint\";\r\nimport type { NodeParticleBuildState } from \"../../nodeParticleBuildState\";\r\nimport type { Particle } from \"core/Particles/particle\";\r\nimport type { IShapeBlock } from \"./IShapeBlock\";\r\n\r\nimport { RegisterClass } from \"../../../../Misc/typeStore\";\r\nimport { NodeParticleBlockConnectionPointTypes } from \"../../Enums/nodeParticleBlockConnectionPointTypes\";\r\nimport { Vector3 } from \"core/Maths/math.vector\";\r\nimport { NodeParticleBlock } from \"../../nodeParticleBlock\";\r\nimport { RandomRange } from \"core/Maths/math.scalar.functions\";\r\nimport { _CreateLocalPositionData } from \"./emitters.functions\";\r\n\r\n/**\r\n * Block used to provide a flow of particles emitted from a box shape.\r\n */\r\nexport class BoxShapeBlock extends NodeParticleBlock implements IShapeBlock {\r\n /**\r\n * Create a new BoxShapeBlock\r\n * @param name defines the block name\r\n */\r\n public constructor(name: string) {\r\n super(name);\r\n\r\n this.registerInput(\"particle\", NodeParticleBlockConnectionPointTypes.Particle);\r\n this.registerInput(\"direction1\", NodeParticleBlockConnectionPointTypes.Vector3, true, new Vector3(0, 1.0, 0));\r\n this.registerInput(\"direction2\", NodeParticleBlockConnectionPointTypes.Vector3, true, new Vector3(0, 1.0, 0));\r\n this.registerInput(\"minEmitBox\", NodeParticleBlockConnectionPointTypes.Vector3, true, new Vector3(-0.5, -0.5, -0.5));\r\n this.registerInput(\"maxEmitBox\", NodeParticleBlockConnectionPointTypes.Vector3, true, new Vector3(0.5, 0.5, 0.5));\r\n this.registerOutput(\"output\", NodeParticleBlockConnectionPointTypes.Particle);\r\n }\r\n\r\n /**\r\n * Gets the current class name\r\n * @returns the class name\r\n */\r\n public override getClassName() {\r\n return \"BoxShapeBlock\";\r\n }\r\n\r\n /**\r\n * Gets the particle input component\r\n */\r\n public get particle(): NodeParticleConnectionPoint {\r\n return this._inputs[0];\r\n }\r\n\r\n /**\r\n * Gets the direction1 input component\r\n */\r\n public get direction1(): NodeParticleConnectionPoint {\r\n return this._inputs[1];\r\n }\r\n\r\n /**\r\n * Gets the direction2 input component\r\n */\r\n public get direction2(): NodeParticleConnectionPoint {\r\n return this._inputs[2];\r\n }\r\n\r\n /**\r\n * Gets the minEmitBox input component\r\n */\r\n public get minEmitBox(): NodeParticleConnectionPoint {\r\n return this._inputs[3];\r\n }\r\n\r\n /**\r\n * Gets the maxEmitBox input component\r\n */\r\n public get maxEmitBox(): NodeParticleConnectionPoint {\r\n return this._inputs[4];\r\n }\r\n\r\n /**\r\n * Gets the output component\r\n */\r\n public get output(): NodeParticleConnectionPoint {\r\n return this._outputs[0];\r\n }\r\n\r\n /**\r\n * Builds the block\r\n * @param state defines the build state\r\n */\r\n public override _build(state: NodeParticleBuildState) {\r\n const system = this.particle.getConnectedValue(state);\r\n\r\n system._directionCreation.process = (particle: Particle) => {\r\n state.particleContext = particle;\r\n state.systemContext = system;\r\n\r\n const direction1 = this.direction1.getConnectedValue(state) as Vector3;\r\n const direction2 = this.direction2.getConnectedValue(state) as Vector3;\r\n\r\n const randX = RandomRange(direction1.x, direction2.x);\r\n const randY = RandomRange(direction1.y, direction2.y);\r\n const randZ = RandomRange(direction1.z, direction2.z);\r\n\r\n if (system.isLocal) {\r\n particle.direction.copyFromFloats(randX, randY, randZ);\r\n } else {\r\n Vector3.TransformNormalFromFloatsToRef(randX, randY, randZ, state.emitterWorldMatrix!, particle.direction);\r\n }\r\n\r\n particle._initialDirection = particle.direction.clone();\r\n };\r\n\r\n system._positionCreation.process = (particle: Particle) => {\r\n state.particleContext = particle;\r\n state.systemContext = system;\r\n\r\n const minEmitBox = this.minEmitBox.getConnectedValue(state) as Vector3;\r\n const maxEmitBox = this.maxEmitBox.getConnectedValue(state) as Vector3;\r\n\r\n const randX = RandomRange(minEmitBox.x, maxEmitBox.x);\r\n const randY = RandomRange(minEmitBox.y, maxEmitBox.y);\r\n const randZ = RandomRange(minEmitBox.z, maxEmitBox.z);\r\n\r\n if (system.isLocal) {\r\n particle.position.copyFromFloats(randX, randY, randZ);\r\n } else {\r\n Vector3.TransformCoordinatesFromFloatsToRef(randX, randY, randZ, state.emitterWorldMatrix!, particle.position);\r\n }\r\n\r\n _CreateLocalPositionData(particle);\r\n };\r\n\r\n this.output._storedValue = system;\r\n }\r\n}\r\n\r\nRegisterClass(\"BABYLON.BoxShapeBlock\", BoxShapeBlock);\r\n"]}
@@ -1,9 +1,10 @@
1
- import { NodeParticleBlock } from "../../nodeParticleBlock.js";
2
1
  import type { NodeParticleConnectionPoint } from "../../nodeParticleBlockConnectionPoint.js";
3
2
  import type { NodeParticleBuildState } from "../../nodeParticleBuildState.js";
4
3
  import type { IShapeBlock } from "./IShapeBlock.js";
4
+ import { NodeParticleBlock } from "../../nodeParticleBlock.js";
5
5
  /**
6
6
  * Block used to provide a flow of particles emitted from a cylinder shape.
7
+ * DirectionRandomizer will be used for the particles initial direction unless both direction1 and direction2 are connected.
7
8
  */
8
9
  export declare class CylinderShapeBlock extends NodeParticleBlock implements IShapeBlock {
9
10
  private _tempVector;
@@ -37,6 +38,14 @@ export declare class CylinderShapeBlock extends NodeParticleBlock implements ISh
37
38
  * Gets the directionRandomizer input component
38
39
  */
39
40
  get directionRandomizer(): NodeParticleConnectionPoint;
41
+ /**
42
+ * Gets the direction1 input component
43
+ */
44
+ get direction1(): NodeParticleConnectionPoint;
45
+ /**
46
+ * Gets the direction2 input component
47
+ */
48
+ get direction2(): NodeParticleConnectionPoint;
40
49
  /**
41
50
  * Gets the output component
42
51
  */