@babylonjs/lite 1.4.0 → 1.5.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (122) hide show
  1. package/dist/index.js +381 -375
  2. package/dist/index.js.map +1 -1
  3. package/index.d.ts +757 -0
  4. package/lib/audio/analyzer.js +65 -0
  5. package/lib/audio/analyzer.js.map +1 -0
  6. package/lib/audio/audio-bus.js +38 -0
  7. package/lib/audio/audio-bus.js.map +1 -0
  8. package/lib/audio/audio-engine.js +188 -0
  9. package/lib/audio/audio-engine.js.map +1 -0
  10. package/lib/audio/audio-fetch.js +18 -0
  11. package/lib/audio/audio-fetch.js.map +1 -0
  12. package/lib/audio/audio-param.js +96 -0
  13. package/lib/audio/audio-param.js.map +1 -0
  14. package/lib/audio/audio-signal.js +46 -0
  15. package/lib/audio/audio-signal.js.map +1 -0
  16. package/lib/audio/bus.js +33 -0
  17. package/lib/audio/bus.js.map +1 -0
  18. package/lib/audio/host-types.js +2 -0
  19. package/lib/audio/host-types.js.map +1 -0
  20. package/lib/audio/index.js +12 -0
  21. package/lib/audio/index.js.map +1 -0
  22. package/lib/audio/sound-buffer.js +59 -0
  23. package/lib/audio/sound-buffer.js.map +1 -0
  24. package/lib/audio/sound-source.js +57 -0
  25. package/lib/audio/sound-source.js.map +1 -0
  26. package/lib/audio/sound-sub-graph.js +72 -0
  27. package/lib/audio/sound-sub-graph.js.map +1 -0
  28. package/lib/audio/spatial.js +466 -0
  29. package/lib/audio/spatial.js.map +1 -0
  30. package/lib/audio/static-sound.js +313 -0
  31. package/lib/audio/static-sound.js.map +1 -0
  32. package/lib/audio/stereo.js +40 -0
  33. package/lib/audio/stereo.js.map +1 -0
  34. package/lib/audio/streaming-sound.js +377 -0
  35. package/lib/audio/streaming-sound.js.map +1 -0
  36. package/lib/audio/unmute-ui.js +72 -0
  37. package/lib/audio/unmute-ui.js.map +1 -0
  38. package/lib/audio/visualizer.js +101 -0
  39. package/lib/audio/visualizer.js.map +1 -0
  40. package/lib/engine/engine.js +1 -1
  41. package/lib/index.js +11 -0
  42. package/lib/index.js.map +1 -1
  43. package/lib/light/types.js.map +1 -1
  44. package/lib/loader-gltf/animation-pointer-basecolor.js +25 -0
  45. package/lib/loader-gltf/animation-pointer-basecolor.js.map +1 -0
  46. package/lib/loader-gltf/animation-pointer-ext.js +244 -0
  47. package/lib/loader-gltf/animation-pointer-ext.js.map +1 -0
  48. package/lib/loader-gltf/animation-pointer-lights.js +46 -0
  49. package/lib/loader-gltf/animation-pointer-lights.js.map +1 -0
  50. package/lib/loader-gltf/animation-pointer.js +4 -1
  51. package/lib/loader-gltf/animation-pointer.js.map +1 -1
  52. package/lib/loader-gltf/gltf-animation.js +5 -3
  53. package/lib/loader-gltf/gltf-animation.js.map +1 -1
  54. package/lib/loader-gltf/gltf-color-normalize.js +10 -1
  55. package/lib/loader-gltf/gltf-color-normalize.js.map +1 -1
  56. package/lib/loader-gltf/gltf-feature-animation-pointer.js +67 -47
  57. package/lib/loader-gltf/gltf-feature-animation-pointer.js.map +1 -1
  58. package/lib/loader-gltf/gltf-feature-lights-punctual.js +51 -9
  59. package/lib/loader-gltf/gltf-feature-lights-punctual.js.map +1 -1
  60. package/lib/loader-gltf/gltf-feature-primitive.js +20 -0
  61. package/lib/loader-gltf/gltf-feature-primitive.js.map +1 -0
  62. package/lib/loader-gltf/gltf-feature-registry.js +25 -0
  63. package/lib/loader-gltf/gltf-feature-registry.js.map +1 -1
  64. package/lib/loader-gltf/gltf-feature-skeleton.js +18 -3
  65. package/lib/loader-gltf/gltf-feature-skeleton.js.map +1 -1
  66. package/lib/loader-gltf/gltf-interleave.js +3 -2
  67. package/lib/loader-gltf/gltf-interleave.js.map +1 -1
  68. package/lib/loader-gltf/gltf-light-pointer-state.js +18 -0
  69. package/lib/loader-gltf/gltf-light-pointer-state.js.map +1 -0
  70. package/lib/loader-gltf/gltf-parser.js +7 -1
  71. package/lib/loader-gltf/gltf-parser.js.map +1 -1
  72. package/lib/loader-gltf/gltf-pbr-builder-ext.js +1 -1
  73. package/lib/loader-gltf/gltf-pbr-builder-ext.js.map +1 -1
  74. package/lib/loader-gltf/gltf-pbr-builder.js +1 -1
  75. package/lib/loader-gltf/gltf-pbr-builder.js.map +1 -1
  76. package/lib/loader-gltf/gltf-sampler-denorm.js +20 -0
  77. package/lib/loader-gltf/gltf-sampler-denorm.js.map +1 -0
  78. package/lib/loader-gltf/gltf-sampler-desc.js +11 -2
  79. package/lib/loader-gltf/gltf-sampler-desc.js.map +1 -1
  80. package/lib/loader-gltf/gltf-uv-denorm.js +28 -0
  81. package/lib/loader-gltf/gltf-uv-denorm.js.map +1 -0
  82. package/lib/loader-gltf/load-gltf.js +15 -6
  83. package/lib/loader-gltf/load-gltf.js.map +1 -1
  84. package/lib/material/material-rebuild.js +4 -0
  85. package/lib/material/material-rebuild.js.map +1 -1
  86. package/lib/material/mesh-features.js +8 -1
  87. package/lib/material/mesh-features.js.map +1 -1
  88. package/lib/material/pbr/fragments/reflectance-fragment.js +1 -1
  89. package/lib/material/pbr/fragments/reflectance-fragment.js.map +1 -1
  90. package/lib/material/pbr/fragments/refraction-rtt-fragment.js +1 -1
  91. package/lib/material/pbr/fragments/refraction-rtt-fragment.js.map +1 -1
  92. package/lib/material/pbr/pbr-pipeline.js +7 -3
  93. package/lib/material/pbr/pbr-pipeline.js.map +1 -1
  94. package/lib/material/pbr/pbr-primitive-resolver.js +34 -0
  95. package/lib/material/pbr/pbr-primitive-resolver.js.map +1 -0
  96. package/lib/material/pbr/pbr-renderable.js +1 -1
  97. package/lib/material/pbr/pbr-renderable.js.map +1 -1
  98. package/lib/material/shader/shader-material.js +9 -5
  99. package/lib/material/shader/shader-material.js.map +1 -1
  100. package/lib/material/shader/shader-thin-instance.js +1 -1
  101. package/lib/material/shader/shader-thin-instance.js.map +1 -1
  102. package/lib/material/standard/standard-renderable.js +1 -1
  103. package/lib/material/standard/standard-renderable.js.map +1 -1
  104. package/lib/mesh/mesh-dispose.js +1 -0
  105. package/lib/mesh/mesh-dispose.js.map +1 -1
  106. package/lib/mesh/thin-instance-cull-binding.js +15 -6
  107. package/lib/mesh/thin-instance-cull-binding.js.map +1 -1
  108. package/lib/scene/scene-core.js +1 -0
  109. package/lib/scene/scene-core.js.map +1 -1
  110. package/lib/scene/scene-material-swap.js +2 -0
  111. package/lib/scene/scene-material-swap.js.map +1 -1
  112. package/lib/shadow/csm-shadow-task-hooks.js +67 -9
  113. package/lib/shadow/csm-shadow-task-hooks.js.map +1 -1
  114. package/lib/sprite/sprite-2d.js +4 -0
  115. package/lib/sprite/sprite-2d.js.map +1 -1
  116. package/lib/sprite/sprite-pipeline.js +25 -22
  117. package/lib/sprite/sprite-pipeline.js.map +1 -1
  118. package/lib/text/_gpu/text-pipeline.js +1 -1
  119. package/lib/text/_gpu/text-pipeline.js.map +1 -1
  120. package/lib/text/text-renderer.js +3 -1
  121. package/lib/text/text-renderer.js.map +1 -1
  122. package/package.json +3 -3
package/index.d.ts CHANGED
@@ -699,6 +699,16 @@ export declare function attachRotationGizmoToNode(gizmo: RotationGizmo, node: Sc
699
699
  /** Attach all scale sub-gizmos to a node, or detach them with `null`. */
700
700
  export declare function attachScaleGizmoToNode(gizmo: ScaleGizmo, node: SceneNode | null): void;
701
701
 
702
+ /**
703
+ * Attaches a spatial sound/bus — or the engine's listener — to a world
704
+ * transform. The position/rotation follow the target on each
705
+ * {@link updateSpatialAudio} (or auto-update) tick.
706
+ * @param target - A `StaticSound`, `AudioBus`, or the `AudioEngine` (listener).
707
+ * @param worldTarget - The transform to follow.
708
+ * @param type - Which transform components to follow. Defaults to `"positionAndRotation"`.
709
+ */
710
+ export declare function attachSpatialTarget(target: AudioGraphHost | AudioEngine, worldTarget: SpatialTarget, type?: SpatialAttachmentType): void;
711
+
702
712
  /**
703
713
  * Attaches a manager to a sprite renderer's update hooks so its animations advance each frame.
704
714
  * @param renderer - Sprite renderer whose update loop drives the manager.
@@ -729,6 +739,132 @@ export declare function attachSpriteAnimationsToScene(scene: SceneContext, manag
729
739
  */
730
740
  export declare function attachVat(engine: EngineContext, mesh: Mesh, baked: VatBakeResult, clip?: string): VatHandle;
731
741
 
742
+ /** Options for {@link enableAnalyzer}. */
743
+ export declare interface AudioAnalyzerOptions {
744
+ /** FFT window size (a power of two, `32`–`32768`). Defaults to `2048`. */
745
+ fftSize?: number;
746
+ /** Minimum power value for the dB range, in dBFS. Defaults to `-100`. */
747
+ minDecibels?: number;
748
+ /** Maximum power value for the dB range, in dBFS. Defaults to `-30`. */
749
+ maxDecibels?: number;
750
+ /** Time-averaging constant in `[0, 1]`. Defaults to `0.8`. */
751
+ smoothing?: number;
752
+ }
753
+
754
+ /** A generic mixer bus. Pure state — drive it with the bus functions. */
755
+ export declare interface AudioBus {
756
+ /** Bus name. */
757
+ readonly name: string;
758
+
759
+ /** Options for {@link createAudioBusAsync}. */
760
+ export declare interface AudioBusOptions {
761
+ /** Initial volume. Defaults to `1`. */
762
+ volume?: number;
763
+ /** Output bus. Defaults to the engine's default main bus. */
764
+ outBus?: PrimaryAudioBus;
765
+ }
766
+
767
+ /**
768
+ * A Babylon Lite audio engine. Pure state — operate on it with the audio
769
+ * functions (`createSoundAsync`, `setMasterVolume`, `disposeAudioEngine`, …).
770
+ */
771
+ export declare interface AudioEngine {
772
+ /** Current context state. Always `"running"` for an offline context. */
773
+ readonly state: AudioEngineState;
774
+ /** The audio context's current time, in seconds. */
775
+ readonly currentTime: number;
776
+ /** Fires whenever {@link state} changes. */
777
+ readonly onStateChanged: AudioSignal<AudioEngineState>;
778
+ /** Fires on every qualifying user gesture (click), not just the first. */
779
+ readonly onUserGesture: AudioSignal<void>;
780
+
781
+ /** Options for {@link createAudioEngineAsync}. */
782
+ export declare interface AudioEngineOptions {
783
+ /**
784
+ * The audio context to use. Pass an `OfflineAudioContext` for deterministic,
785
+ * faster-than-realtime rendering (used by the audio test suite). When omitted
786
+ * a real-time `AudioContext` is created.
787
+ */
788
+ audioContext?: BaseAudioContext;
789
+ /** Master output volume. Defaults to `1`. */
790
+ volume?: number;
791
+ /** Default parameter ramp smoothing, in seconds. Defaults to `0.01`. */
792
+ parameterRampDuration?: number;
793
+ /** Auto-resume the context on user interaction (click). Defaults to `true`. */
794
+ resumeOnInteraction?: boolean;
795
+ /** Auto-resume the context if the browser pauses playback. Defaults to `true`. */
796
+ resumeOnPause?: boolean;
797
+ /** Retry interval (ms) for `resumeOnPause`. Defaults to `1000`. */
798
+ resumeOnPauseRetryInterval?: number;
799
+ }
800
+
801
+ /** Audio context state, mirroring the Web Audio `AudioContextState` plus `"interrupted"`. */
802
+ export declare type AudioEngineState = "running" | "suspended" | "closed" | "interrupted";
803
+
804
+ /** A sound, source, or bus that can carry spatial, stereo, or analyzer sub-nodes. */
805
+ export declare type AudioGraphHost = StaticSound | StreamingSound | AudioBus | AudioInputSource;
806
+
807
+ /**
808
+ * A sound fed by a live or external Web Audio input node (e.g. a microphone).
809
+ * Accepted anywhere an {@link AudioGraphHost} is — enable spatial, stereo, or
810
+ * analyzer features on it directly.
811
+ */
812
+ export declare interface AudioInputSource {
813
+ /** The source name. */
814
+ readonly name: string;
815
+
816
+ /**
817
+ * Audio parameter ramping — faithful port of Babylon.js AudioV2
818
+ * `audioUtils._GetAudioParamCurveValues` + `_WebAudioParameterComponent`,
819
+ * re-shaped to pure functions + a small pure-state wrapper.
820
+ *
821
+ * The exponential/logarithmic normalized curves are cached via lazy-init
822
+ * (never at module scope) so this module has zero import-time side effects.
823
+ * The curve math is copied verbatim from AudioV2 to preserve identical output.
824
+ */
825
+ /** Ramp shape used when changing an audio parameter (volume, pan, position…). */
826
+ export declare type AudioRampShape = "none" | "linear" | "exponential" | "logarithmic";
827
+
828
+ /**
829
+ * Lightweight event signal — Babylon Lite's tree-shakable replacement for the
830
+ * core `Observable`. Pure state + standalone-ish callback set. No module-level
831
+ * side effects: the callback set is created lazily on first `add`.
832
+ *
833
+ * Behavioural parity with the subset of `Observable` the audio engine uses:
834
+ * `add`, `addOnce`, `removeCallback`, `notifyObservers`, `clear`, `hasObservers`.
835
+ */
836
+ /** Public read surface of a signal — consumers can only subscribe. */
837
+ export declare interface AudioSignal<T> {
838
+ /** Subscribe. Returns an unsubscribe function. */
839
+ add(callback: (value: T) => void): () => void;
840
+ /** Subscribe for a single notification. Returns an unsubscribe function. */
841
+ addOnce(callback: (value: T) => void): () => void;
842
+ }
843
+
844
+ /** Visualizer state. Pure state — driven by the visualizer functions. */
845
+ export declare interface AudioVisualizer {
846
+ /** The canvas being drawn to. */
847
+ readonly canvas: HTMLCanvasElement;
848
+
849
+ /** What to draw in the visualizer. */
850
+ export declare type AudioVisualizerMode = "bars" | "waveform" | "both";
851
+
852
+ /** Options for {@link createAudioVisualizer}. */
853
+ export declare interface AudioVisualizerOptions {
854
+ /** FFT window size (a power of two). Defaults to `2048`. */
855
+ fftSize?: number;
856
+ /** Analyzer time-averaging constant in `[0, 1]`. Defaults to `0.8`. */
857
+ smoothing?: number;
858
+ /** What to draw. Defaults to `"both"`. */
859
+ mode?: AudioVisualizerMode;
860
+ /** Canvas background fill. Defaults to `"#101014"`. */
861
+ backgroundColor?: string;
862
+ /** Frequency-bar color. Defaults to `"#4fc3f7"`. */
863
+ barColor?: string;
864
+ /** Waveform line color. Defaults to `"#ffffff"`. */
865
+ waveformColor?: string;
866
+ }
867
+
732
868
  /** A single arrow-shaped gizmo that translates its attached node along one axis. */
733
869
  export declare interface AxisDragGizmo {
734
870
  /** The root node — gizmo follows its `attachedNode` by copying world translation. */
@@ -1518,6 +1654,36 @@ export declare function createAnimationTask(update: AnimationTaskUpdate, options
1518
1654
  /** Create a bare ArcRotateCamera with given params. Pure data, no scene knowledge. */
1519
1655
  export declare function createArcRotateCamera(alpha: number, beta: number, radius: number, target: Vec3): ArcRotateCamera;
1520
1656
 
1657
+ /**
1658
+ * Creates a generic mixer bus routed to another bus (defaulting to the engine's
1659
+ * default main bus). Multiple sounds/buses can be routed through a bus to mix
1660
+ * and control their combined volume.
1661
+ * @param engine - The audio engine.
1662
+ * @param name - A name for the bus.
1663
+ * @param options - Bus options.
1664
+ * @returns A promise that resolves with the ready bus.
1665
+ */
1666
+ export declare function createAudioBusAsync(engine: AudioEngine, name: string, options?: AudioBusOptions): Promise<AudioBus>;
1667
+
1668
+ /**
1669
+ * Creates and initializes an audio engine.
1670
+ * @param options - Engine options.
1671
+ * @returns A promise that resolves with the ready-to-use engine.
1672
+ */
1673
+ export declare function createAudioEngineAsync(options?: AudioEngineOptions): Promise<AudioEngine>;
1674
+
1675
+ /**
1676
+ * Creates a real-time visualizer that taps the host's analyzer and draws to the
1677
+ * given canvas. Enables the analyzer on the host if it is not already enabled.
1678
+ * Call {@link startAudioVisualizer} to begin the animation loop.
1679
+ * @param host - A `StaticSound`, `StreamingSound`, `AudioBus`, or input source.
1680
+ * @param canvas - The destination 2D canvas.
1681
+ * @param options - Visualizer options.
1682
+ * @returns The visualizer handle; dispose it with {@link disposeAudioVisualizer}.
1683
+ * @throws If a 2D context cannot be obtained from the canvas.
1684
+ */
1685
+ export declare function createAudioVisualizer(host: AudioGraphHost, canvas: HTMLCanvasElement, options?: AudioVisualizerOptions): AudioVisualizer;
1686
+
1521
1687
  /** Build an axis-drag gizmo and attach it to the given utility layer. Call
1522
1688
  * `attachAxisDragGizmoToNode` to bind it to a node so it follows + drives it. */
1523
1689
  export declare function createAxisDragGizmo(engine: EngineContext, layer: UtilityLayer, options: AxisDragGizmoOptions): AxisDragGizmo;
@@ -1961,6 +2127,17 @@ export declare function createMeshFromCsg2(engine: EngineContext, solid: Csg2Sol
1961
2127
  * No material is assigned — the caller must set mesh.material before adding to scene. */
1962
2128
  export declare function createMeshFromData(engine: EngineContext, name: string, positions: Float32Array, normals: Float32Array, indices: Uint32Array, uvs?: Float32Array, uvs2?: Float32Array, tangents?: Float32Array, colors?: Float32Array): Mesh;
1963
2129
 
2130
+ /**
2131
+ * Requests microphone access and wraps the resulting stream as a sound source.
2132
+ * The source does not auto-connect to the main bus by default (to avoid
2133
+ * feedback); attach an analyzer or set an `outBus` to use it.
2134
+ * @param engine - The audio engine.
2135
+ * @param options - Source options.
2136
+ * @returns A promise that resolves with the ready microphone source.
2137
+ * @throws If microphone access is denied or unavailable.
2138
+ */
2139
+ export declare function createMicrophoneSoundSourceAsync(engine: AudioEngine, options?: SoundSourceOptions): Promise<AudioInputSource>;
2140
+
1964
2141
  /** Create morph target GPU data from parsed glTF targets.
1965
2142
  * @param engine - Engine context (provides GPU device)
1966
2143
  * @param targets - Array of `{positions, normals}` deltas per target
@@ -2264,6 +2441,35 @@ export declare function createShaderNormalMaterialView(source: ShaderMaterial, c
2264
2441
  * @returns A bilinear-sampled `Texture2D` backed by a tiny GPU texture. */
2265
2442
  export declare function createSolidTexture2D(engine: EngineContext, r: number, g: number, b: number, a?: number): Texture2D;
2266
2443
 
2444
+ /**
2445
+ * Creates a buffer-backed sound, routed to the given output bus (or the
2446
+ * engine's default main bus).
2447
+ * @param engine - The audio engine.
2448
+ * @param source - An `AudioBuffer`, `ArrayBuffer`, URL, URL list, or `SoundBuffer`.
2449
+ * @param options - Sound options.
2450
+ * @returns A promise that resolves with the ready sound.
2451
+ */
2452
+ export declare function createSoundAsync(engine: AudioEngine, source: SoundSource, options?: StaticSoundOptions): Promise<StaticSound>;
2453
+
2454
+ /**
2455
+ * Loads and decodes audio into a reusable {@link SoundBuffer}.
2456
+ * @param engine - The audio engine.
2457
+ * @param source - An `AudioBuffer`, `ArrayBuffer`, URL, or URL list.
2458
+ * @param options - Decode options.
2459
+ * @returns A promise that resolves with the decoded buffer.
2460
+ */
2461
+ export declare function createSoundBufferAsync(engine: AudioEngine, source: SoundSource, options?: SoundBufferOptions): Promise<SoundBuffer>;
2462
+
2463
+ /**
2464
+ * Wraps an arbitrary Web Audio node as a sound source, routed to the given
2465
+ * output bus (or the engine's default main bus).
2466
+ * @param engine - The audio engine.
2467
+ * @param node - The input node to wrap (its output is routed through the graph).
2468
+ * @param options - Source options.
2469
+ * @returns A promise that resolves with the ready source.
2470
+ */
2471
+ export declare function createSoundSourceAsync(engine: AudioEngine, node: AudioNode, options?: SoundSourceOptions): Promise<AudioInputSource>;
2472
+
2267
2473
  /** Create a sphere mesh. Caller must assign material. */
2268
2474
  export declare function createSphere(engine: EngineContext, options?: SphereOptions): Mesh;
2269
2475
 
@@ -2337,6 +2543,16 @@ export declare function createStandardMaterial(): StandardMaterialProps;
2337
2543
  * The view references the source; material state is never copied. */
2338
2544
  export declare function createStandardNoColorMaterialView(source: StandardMaterialProps): MaterialView;
2339
2545
 
2546
+ /**
2547
+ * Creates a streaming, media-element-backed sound routed to the given output bus
2548
+ * (or the engine's default main bus). Requires a real-time `AudioContext`.
2549
+ * @param engine - The audio engine.
2550
+ * @param source - A URL, a list of candidate URLs, or an `HTMLMediaElement`.
2551
+ * @param options - Streaming sound options.
2552
+ * @returns A promise that resolves with the ready sound.
2553
+ */
2554
+ export declare function createStreamingSoundAsync(engine: AudioEngine, source: StreamingSoundSource, options?: StreamingSoundOptions): Promise<StreamingSound>;
2555
+
2340
2556
  /**
2341
2557
  * Create an auxiliary rendering surface bound to an existing engine. The surface
2342
2558
  * configures its own `GPUCanvasContext` against `engine._device` and is appended to
@@ -2428,6 +2644,15 @@ export declare function createUniformEffectRenderTask(config: UniformEffectRende
2428
2644
  */
2429
2645
  export declare function createUniformEffectWrapper(engine: EngineContext, options: UniformEffectWrapperOptions): UniformEffectWrapper;
2430
2646
 
2647
+ /**
2648
+ * Creates and mounts the unmute button. It is shown while the engine's context
2649
+ * is not `"running"` and hidden once it resumes; clicking it unlocks the engine.
2650
+ * @param engine - The audio engine to unlock.
2651
+ * @param options - UI options (parent element).
2652
+ * @returns The UI handle; dispose it with {@link disposeUnmuteUI}.
2653
+ */
2654
+ export declare function createUnmuteUI(engine: AudioEngine, options?: UnmuteUIOptions): UnmuteUI;
2655
+
2431
2656
  /** Create a utility layer attached to the given engine + main scene.
2432
2657
  * The returned `scene` shares the main scene's camera so view + projection
2433
2658
  * remain in sync without manual mirroring. The utility scene renders with a
@@ -2636,6 +2861,13 @@ export declare interface DepthOfFieldPostProcessTaskConfig extends PostProcessTa
2636
2861
  depthNotNormalized?: boolean;
2637
2862
  }
2638
2863
 
2864
+ /**
2865
+ * Detaches a spatial sound/bus — or the engine's listener — from its world
2866
+ * transform.
2867
+ * @param target - A `StaticSound`, `AudioBus`, or the `AudioEngine` (listener).
2868
+ */
2869
+ export declare function detachSpatialTarget(target: AudioGraphHost | AudioEngine): void;
2870
+
2639
2871
  export declare interface DirectionalLight extends LightBase {
2640
2872
  readonly lightType: "directional";
2641
2873
  direction: ObservableVec3;
@@ -2653,6 +2885,23 @@ export declare interface DiscOptions {
2653
2885
  arc?: number;
2654
2886
  }
2655
2887
 
2888
+ /** Disposes a generic bus, releasing its sub-graph. */
2889
+ export declare function disposeAudioBus(bus: AudioBus): void;
2890
+
2891
+ /**
2892
+ * Disposes the audio engine: stops all sounds, tears down global hooks, and
2893
+ * closes the (non-offline) audio context.
2894
+ * @param engine - The audio engine to dispose.
2895
+ */
2896
+ export declare function disposeAudioEngine(engine: AudioEngine): void;
2897
+
2898
+ /**
2899
+ * Stops the render loop and releases the visualizer. The underlying analyzer tap
2900
+ * stays on the host (dispose the host to release it).
2901
+ * @param viz - The visualizer handle.
2902
+ */
2903
+ export declare function disposeAudioVisualizer(viz: AudioVisualizer): void;
2904
+
2656
2905
  /** Dispose the gizmo: remove meshes, unregister pointer-drag, drop materials. */
2657
2906
  export declare function disposeAxisDragGizmo(gizmo: AxisDragGizmo, layer: UtilityLayer): void;
2658
2907
 
@@ -2733,6 +2982,16 @@ export declare function disposeScaleGizmo(gizmo: ScaleGizmo, layer: UtilityLayer
2733
2982
  /** Release all GPU resources owned by this scene. */
2734
2983
  export declare function disposeScene(scene: SceneContext): void;
2735
2984
 
2985
+ /** Disposes the sound, stopping playback and releasing its graph. */
2986
+ export declare function disposeSound(sound: StaticSound): void;
2987
+
2988
+ /**
2989
+ * Disposes a sound source, stopping any microphone tracks and releasing its
2990
+ * graph.
2991
+ * @param source - The sound source.
2992
+ */
2993
+ export declare function disposeSoundSource(source: AudioInputSource): void;
2994
+
2736
2995
  /**
2737
2996
  * Detaches a binding created by {@link attachSpriteAnimationsToScene} or
2738
2997
  * {@link attachSpriteAnimationsToRenderer}. Safe to call more than once.
@@ -2748,6 +3007,9 @@ export declare function disposeSpriteAnimationBinding(binding: SpriteAnimationBi
2748
3007
  */
2749
3008
  export declare function disposeSpriteRenderer(sr: SpriteRenderer): void;
2750
3009
 
3010
+ /** Disposes the sound, stopping playback and releasing its graph and preloaded instances. */
3011
+ export declare function disposeStreamingSound(sound: StreamingSound): void;
3012
+
2751
3013
  /** Remove and unconfigure an auxiliary surface from its engine. Rendering contexts
2752
3014
  * registered on this surface are dropped from its list but not disposed — call their
2753
3015
  * own disposers (e.g. `disposeScene`) separately.
@@ -2770,6 +3032,12 @@ export declare function disposeTextRenderer(tr: TextRenderer): void;
2770
3032
  /** Destroy the uniform buffer and clear cached GPU objects owned by the uniform effect wrapper. */
2771
3033
  export declare function disposeUniformEffectWrapper(wrapper: UniformEffectWrapper): void;
2772
3034
 
3035
+ /**
3036
+ * Removes the unmute button and its styles and unsubscribes from engine state.
3037
+ * @param ui - The UI handle.
3038
+ */
3039
+ export declare function disposeUnmuteUI(ui: UnmuteUI): void;
3040
+
2773
3041
  /** Dispose the utility layer's underlying scene. Idempotent. */
2774
3042
  export declare function disposeUtilityLayer(utility: UtilityLayer): void;
2775
3043
 
@@ -2879,6 +3147,15 @@ export declare interface EffectWrapperOptions {
2879
3147
  blend?: GPUBlendState;
2880
3148
  }
2881
3149
 
3150
+ /**
3151
+ * Enables (or reconfigures) frequency/amplitude analysis on a sound or bus,
3152
+ * building the analyzer tap on first use. Pulls the analyzer module only when
3153
+ * called.
3154
+ * @param host - A `StaticSound`, `StreamingSound`, or `AudioBus`.
3155
+ * @param options - Analyzer options (fftSize, dB range, smoothing).
3156
+ */
3157
+ export declare function enableAnalyzer(host: AudioGraphHost, options?: AudioAnalyzerOptions): void;
3158
+
2882
3159
  /** Enable advanced animation blending for a manager. Kept opt-in so manual-only weights do not pay for skeletal mixing code. */
2883
3160
  export declare function enableAnimationBlending(manager: AnimationManager): void;
2884
3161
 
@@ -2993,6 +3270,22 @@ export declare function enableRenderTaskTransmission(task: RenderTask, engine: E
2993
3270
  /** Enable scene-color transmission for every render task currently registered in a scene. PBR materials are marked for linear transmission, and a trailing image-processing task is appended when needed. */
2994
3271
  export declare function enableSceneTransmission(scene: SceneContext, engine: EngineContext): void;
2995
3272
 
3273
+ /**
3274
+ * Enables (or reconfigures) 3D spatial audio on a sound or bus, building the
3275
+ * panner sub-node on first use. Pulls the spatial module only when called.
3276
+ * @param host - A `StaticSound` or `AudioBus`.
3277
+ * @param options - Spatial options (position, distance model, cone, attach, …).
3278
+ */
3279
+ export declare function enableSpatial(host: AudioGraphHost, options?: SpatialSoundOptions): void;
3280
+
3281
+ /**
3282
+ * Enables (or reconfigures) stereo panning on a sound or bus, building the
3283
+ * stereo sub-node on first use. Pulls the stereo module only when called.
3284
+ * @param host - A `StaticSound`, `StreamingSound`, or `AudioBus`.
3285
+ * @param options - Stereo options (pan).
3286
+ */
3287
+ export declare function enableStereo(host: AudioGraphHost, options?: StereoSoundOptions): void;
3288
+
2996
3289
  /** Enable or disable GPU frustum culling for an existing thin-instanced mesh.
2997
3290
  *
2998
3291
  * Call this after `setThinInstances()`/`addThinInstance()` and before `registerScene()`.
@@ -3533,6 +3826,24 @@ export declare function getBillboardSpriteHandleIndex(handle: BillboardSpriteHan
3533
3826
  * When several joints share a name, the first in joint order is returned. */
3534
3827
  export declare function getBoneByName(skeleton: Skeleton, name: string): Bone | undefined;
3535
3828
 
3829
+ /**
3830
+ * Writes the current frequency-domain data as unsigned bytes into `out`,
3831
+ * building the analyzer tap on first use. `out` should be sized to the
3832
+ * analyzer's `frequencyBinCount` (`fftSize / 2`).
3833
+ * @param host - A `StaticSound`, `StreamingSound`, or `AudioBus`.
3834
+ * @param out - Destination buffer; values are written in place.
3835
+ */
3836
+ export declare function getByteFrequencyData(host: AudioGraphHost, out: Uint8Array): void;
3837
+
3838
+ /**
3839
+ * Writes the current time-domain (waveform) data as unsigned bytes into `out`,
3840
+ * building the analyzer tap on first use. Each sample is centered on `128`.
3841
+ * `out` should be sized to the analyzer's `fftSize`.
3842
+ * @param host - A `StaticSound`, `StreamingSound`, or `AudioBus`.
3843
+ * @param out - Destination buffer; values are written in place.
3844
+ */
3845
+ export declare function getByteTimeDomainData(host: AudioGraphHost, out: Uint8Array): void;
3846
+
3536
3847
  /** Get the world-space position of a camera. */
3537
3848
  export declare function getCameraPosition(camera: Camera): Vec3;
3538
3849
 
@@ -3559,15 +3870,36 @@ export declare function getEffectiveAspectRatio(camera: Camera | null | undefine
3559
3870
  */
3560
3871
  export declare function getEffectivePitchMax(limits: GeospatialLimits, currentRadius: number): number;
3561
3872
 
3873
+ /**
3874
+ * Writes the current frequency-domain data as floats (in dBFS) into `out`,
3875
+ * building the analyzer tap on first use. `out` should be sized to the
3876
+ * analyzer's `frequencyBinCount` (`fftSize / 2`).
3877
+ * @param host - A `StaticSound`, `StreamingSound`, or `AudioBus`.
3878
+ * @param out - Destination buffer; values are written in place.
3879
+ */
3880
+ export declare function getFloatFrequencyData(host: AudioGraphHost, out: Float32Array): void;
3881
+
3562
3882
  /** Read the current floating-origin offset from a scene as a `Vec3`. The
3563
3883
  * offset is the active camera's world position. Returns the zero vector
3564
3884
  * when no camera is set (typical headless/precompute case). For non-LWR
3565
3885
  * engines this module is not imported, so the function is unreachable. */
3566
3886
  export declare function getFloatingOriginOffset(scene: SceneContext): Vec3;
3567
3887
 
3888
+ /**
3889
+ * Writes the current time-domain (waveform) data as floats in `[-1, 1]` into
3890
+ * `out`, building the analyzer tap on first use. `out` should be sized to the
3891
+ * analyzer's `fftSize`.
3892
+ * @param host - A `StaticSound`, `StreamingSound`, or `AudioBus`.
3893
+ * @param out - Destination buffer; values are written in place.
3894
+ */
3895
+ export declare function getFloatTimeDomainData(host: AudioGraphHost, out: Float32Array): void;
3896
+
3568
3897
  /** Get the scene's frame graph. Always non-null — created in `createSceneContext`. */
3569
3898
  export declare function getFrameGraph(scene: SceneContext): FrameGraph;
3570
3899
 
3900
+ /** The master output volume. */
3901
+ export declare function getMasterVolume(engine: AudioEngine): number;
3902
+
3571
3903
  /** Get the current seed used by Recast's randomized queries. */
3572
3904
  export declare function getNavigationRandomSeed(plugin: NavigationPlugin): number;
3573
3905
 
@@ -4307,6 +4639,11 @@ export declare function loadSPZ(scene: SceneContext, url: string): Promise<Gauss
4307
4639
  * @returns A promise resolving to the uploaded `Texture2D`. */
4308
4640
  export declare function loadTexture2D(engine: EngineContext, url: string, opts?: Texture2DOptions): Promise<Texture2D>;
4309
4641
 
4642
+ /** A main audio bus. Sounds route here by default. Pure state — drive it with the bus functions. */
4643
+ export declare interface MainBus {
4644
+ /** Bus name. */
4645
+ readonly name: string;
4646
+
4310
4647
  /** Force the container's GPU light state to re-upload next frame. Call after mutating a light's
4311
4648
  * position / range / intensity / diffuse in place (e.g. animated lights such as drifting fireflies),
4312
4649
  * since those edits don't bump the container version on their own. */
@@ -4978,6 +5315,12 @@ export declare interface Pass {
4978
5315
  /** Pause playback of an animation group. */
4979
5316
  export declare function pauseAnimation(group: AnimationGroup): void;
4980
5317
 
5318
+ /** Pauses all of the sound's instances. */
5319
+ export declare function pauseSound(sound: StaticSound): void;
5320
+
5321
+ /** Pauses all of the sound's instances. */
5322
+ export declare function pauseStreamingSound(sound: StreamingSound): void;
5323
+
4981
5324
  /** User-facing properties for a physically based (metallic-roughness) material.
4982
5325
  * Create one manually via `createPbrMaterial()` or let `loadGltf()` build it.
4983
5326
  * Optional sub-feature objects (clearcoat, sheen, anisotropy, subsurface) are
@@ -5649,6 +5992,14 @@ export declare function playBillboardSpriteAnimation(manager: SpriteAnimationMan
5649
5992
  */
5650
5993
  export declare function playBillboardSpriteIndexAnimation(manager: SpriteAnimationManager, system: BillboardSpriteSystem, index: number, from: number, to: number, loop: boolean, delayMs: number, options?: PlaySpriteAnimationOptions): SpriteFrameAnimation;
5651
5994
 
5995
+ /**
5996
+ * Plays the sound. Spawns a new instance per call (subject to `maxInstances`).
5997
+ * A paused sound is resumed instead.
5998
+ * @param sound - The sound to play.
5999
+ * @param options - Per-play overrides.
6000
+ */
6001
+ export declare function playSound(sound: StaticSound, options?: StaticSoundPlayOptions): void;
6002
+
5652
6003
  /**
5653
6004
  * Plays a frame animation on a 2D sprite addressed by its stable handle.
5654
6005
  * The handle is resolved each tick, so the animation survives swap-remove reindexing.
@@ -5683,6 +6034,15 @@ export declare interface PlaySpriteAnimationOptions {
5683
6034
  /** Replay an animation; omit options to keep callbacks/removal, pass options to overwrite them, or `{}` to clear them. */
5684
6035
  export declare function playSpriteFrameAnimation(animation: SpriteFrameAnimation, from?: number, to?: number, loop?: boolean, delayMs?: number, options?: PlaySpriteAnimationOptions): void;
5685
6036
 
6037
+ /**
6038
+ * Plays the streaming sound. Reuses a preloaded instance when available,
6039
+ * otherwise spawns a new one (subject to `maxInstances`). A paused sound is
6040
+ * resumed instead.
6041
+ * @param sound - The sound to play.
6042
+ * @param options - Per-play overrides.
6043
+ */
6044
+ export declare function playStreamingSound(sound: StreamingSound, options?: StreamingSoundPlayOptions): void;
6045
+
5686
6046
  /** A texture + sampler pair contributed by a plugin. `texture`/`sampler` are the
5687
6047
  * WGSL variable names used by the plugin's custom code; the engine wires up the
5688
6048
  * GPU bindings in declaration order from {@link MaterialPlugin.bindTextures}. */
@@ -5866,12 +6226,21 @@ declare interface PostProcessVec2_2 {
5866
6226
  y: number;
5867
6227
  }
5868
6228
 
6229
+ /** Preloads a single instance of the sound and resolves once it can play through. */
6230
+ export declare function preloadStreamingInstanceAsync(sound: StreamingSound): Promise<void>;
6231
+
6232
+ /** Preloads the given number of instances and resolves once all can play through. */
6233
+ export declare function preloadStreamingInstancesAsync(sound: StreamingSound, count: number): Promise<void>;
6234
+
5869
6235
  /** Something that runs before the main render pass (shadow maps, compute, etc.). */
5870
6236
  export declare interface PrePassRenderable {
5871
6237
  /** Execute pre-pass work (e.g., render shadow depth map + blur). Returns the number of GPU draw calls issued. */
5872
6238
  execute(encoder: GPUCommandEncoder, engine: EngineContext): number;
5873
6239
  }
5874
6240
 
6241
+ /** A bus that sounds or other buses can output to (the engine main bus or a generic {@link AudioBus}). */
6242
+ export declare type PrimaryAudioBus = AudioBus | MainBus;
6243
+
5875
6244
  /** A reusable, target-independent set of compiled property tracks with a total duration. */
5876
6245
  export declare interface PropertyAnimationClip {
5877
6246
  readonly name: string;
@@ -5942,6 +6311,14 @@ export declare function quatFromLookDirectionRH(forward: Vec3, up: Vec3): Quat;
5942
6311
  */
5943
6312
  export declare function quatFromRotationMatrix(matrix: Mat4): Quat;
5944
6313
 
6314
+ /** Options for ramping an audio parameter's value. */
6315
+ export declare interface RampOptions {
6316
+ /** Ramp time, in seconds. Clamped to at least the engine's `parameterRampDuration`. */
6317
+ duration?: number;
6318
+ /** Ramp shape. Defaults to `"linear"`. */
6319
+ shape?: AudioRampShape;
6320
+ }
6321
+
5945
6322
  /** A ray defined by origin, direction, and length. */
5946
6323
  declare interface Ray {
5947
6324
  origin: [number, number, number];
@@ -6175,6 +6552,14 @@ export declare interface Renderable {
6175
6552
  bind(engine: EngineContext, target: RenderTargetSignature): DrawBinding;
6176
6553
  }
6177
6554
 
6555
+ /**
6556
+ * Draws a single visualizer frame from the current analyzer data. Safe to call
6557
+ * directly (e.g. from a custom loop or a test) without starting the built-in
6558
+ * animation loop.
6559
+ * @param viz - The visualizer handle.
6560
+ */
6561
+ export declare function renderAudioVisualizerFrame(viz: AudioVisualizer): void;
6562
+
6178
6563
  /**
6179
6564
  * A surface Babylon Lite can render into. Either a DOM canvas (main thread) or an
6180
6565
  * `OffscreenCanvas` (e.g. one transferred to a Web Worker via
@@ -6384,6 +6769,12 @@ export declare function resizeSurface(surface: SurfaceContext): void;
6384
6769
  * Babylon viewport y is normalized from the bottom; WebGPU viewport/scissor y is from the top. */
6385
6770
  export declare function resolveCameraViewport(camera: Camera | null | undefined, targetWidth: number, targetHeight: number): PixelViewport;
6386
6771
 
6772
+ /** Resumes a paused sound. */
6773
+ export declare function resumeSound(sound: StaticSound, options?: StaticSoundPlayOptions): void;
6774
+
6775
+ /** Resumes a paused streaming sound. */
6776
+ export declare function resumeStreamingSound(sound: StreamingSound, options?: StreamingSoundPlayOptions): void;
6777
+
6387
6778
  /** Options for `createRibbonData`: a set of parallel paths joined into a strip. */
6388
6779
  export declare interface RibbonOptions {
6389
6780
  pathArray: Vec3[][];
@@ -6599,6 +6990,9 @@ export declare function setBoneScaling(skeleton: Skeleton, bone: Bone, x: number
6599
6990
  * so the bone returns to its animated / rest scale. */
6600
6991
  export declare function setBoneVisible(skeleton: Skeleton, bone: Bone, visible: boolean): void;
6601
6992
 
6993
+ /** Sets a bus's output volume, optionally ramping. Works on a generic bus or the main bus. */
6994
+ export declare function setBusVolume(bus: PrimaryAudioBus, value: number, options?: RampOptions): void;
6995
+
6602
6996
  /**
6603
6997
  * Configure orbit/zoom limits on an ArcRotateCamera. This is fully opt-in and
6604
6998
  * self-contained: cameras that never call it pay zero cost and bundle no clamping
@@ -6714,6 +7108,14 @@ export declare function setHierarchyInstanceMatrix(pool: HierarchyInstancePool,
6714
7108
  * modules it pulls). Call before the first KHR_texture_basisu texture loads. */
6715
7109
  export declare function setKtx2DecoderUrl(url: string, wasmUrls?: Record<string, Record<string, string>>): void;
6716
7110
 
7111
+ /**
7112
+ * Sets the master output volume, optionally ramping to the new value.
7113
+ * @param engine - The audio engine.
7114
+ * @param value - Target volume (1 = unchanged).
7115
+ * @param options - Optional ramp shape/duration.
7116
+ */
7117
+ export declare function setMasterVolume(engine: AudioEngine, value: number, options?: RampOptions): void;
7118
+
6717
7119
  /** Raise (or lower) the maximum number of scene lights in the shared lights UBO.
6718
7120
  * Must be called BEFORE scene pipelines are compiled — existing pipelines
6719
7121
  * and UBOs bake the cap into their WGSL/layout. */
@@ -6950,6 +7352,51 @@ export declare function setShaderVector3(material: ShaderMaterial, name: string,
6950
7352
  /** Register scene-owned shadow caster inputs for a generator. */
6951
7353
  export declare function setShadowTaskCasterMeshes(shadowGenerator: ShadowGenerator, casterMeshes: readonly Mesh[]): void;
6952
7354
 
7355
+ /**
7356
+ * Sets the source volume, optionally ramping.
7357
+ * @param source - The sound source.
7358
+ * @param value - Linear gain (`1` = unity).
7359
+ * @param options - Optional ramp options.
7360
+ */
7361
+ export declare function setSoundSourceVolume(source: AudioInputSource, value: number, options?: RampOptions): void;
7362
+
7363
+ /** Sets the sound's output volume, optionally ramping. */
7364
+ export declare function setSoundVolume(sound: StaticSound, value: number, options?: RampOptions): void;
7365
+
7366
+ /**
7367
+ * Toggles a `requestAnimationFrame`-driven loop that calls
7368
+ * {@link updateSpatialAudio} automatically.
7369
+ * @param engine - The audio engine.
7370
+ * @param enabled - Whether to run the auto-update loop.
7371
+ * @param minUpdateMs - Minimum time between updates, in milliseconds. Defaults to `0`.
7372
+ */
7373
+ export declare function setSpatialAutoUpdate(engine: AudioEngine, enabled: boolean, minUpdateMs?: number): void;
7374
+
7375
+ /**
7376
+ * Configures the spatial listener (the "ears"). Builds it on first use.
7377
+ * @param engine - The audio engine.
7378
+ * @param options - Listener options.
7379
+ */
7380
+ export declare function setSpatialListener(engine: AudioEngine, options?: SpatialListenerOptions): void;
7381
+
7382
+ /** Sets the listener world position, building the listener on first use. */
7383
+ export declare function setSpatialListenerPosition(engine: AudioEngine, position: Vec3): void;
7384
+
7385
+ /**
7386
+ * Sets the facing orientation of a spatial sound/bus.
7387
+ * @param host - A `StaticSound` or `AudioBus`.
7388
+ * @param orientation - Facing direction.
7389
+ */
7390
+ export declare function setSpatialOrientation(host: AudioGraphHost, orientation: Vec3): void;
7391
+
7392
+ /**
7393
+ * Sets the world position of a spatial sound/bus, building the panner sub-node
7394
+ * on first use.
7395
+ * @param host - A `StaticSound` or `AudioBus`.
7396
+ * @param position - World-space position.
7397
+ */
7398
+ export declare function setSpatialPosition(host: AudioGraphHost, position: Vec3): void;
7399
+
6953
7400
  /**
6954
7401
  * Sets the atlas frame of the sprite referenced by `handle`.
6955
7402
  * @param handle - Handle of the sprite to update.
@@ -6996,6 +7443,18 @@ export declare function setSprite2DUvOffset(layer: Sprite2DLayer, index: number,
6996
7443
  */
6997
7444
  export declare function setSpriteRendererTarget(sr: SpriteRenderer, target: Texture2D | null): void;
6998
7445
 
7446
+ /**
7447
+ * Sets the stereo pan of a sound or bus, building the stereo sub-node on first
7448
+ * use.
7449
+ * @param host - A `StaticSound`, `StreamingSound`, or `AudioBus`.
7450
+ * @param pan - Pan in the range `[-1, 1]` (`-1` = full left, `1` = full right).
7451
+ * @param options - Optional ramp options for a smooth transition.
7452
+ */
7453
+ export declare function setStereoPan(host: AudioGraphHost, pan: number, options?: RampOptions): void;
7454
+
7455
+ /** Sets the sound's output volume, optionally ramping. */
7456
+ export declare function setStreamingSoundVolume(sound: StreamingSound, value: number, options?: RampOptions): void;
7457
+
6999
7458
  /** Set `visible` on `node` and all descendants (via `node.children`). glTF
7000
7459
  * KHR_node_visibility specifies that children inherit their parent's
7001
7460
  * invisibility — we materialize this at set-time so the render hot-path
@@ -7045,6 +7504,14 @@ export declare function setThinInstances(mesh: Mesh, matrices: Float32Array | Fl
7045
7504
  */
7046
7505
  export declare function setUniformEffectUniforms(wrapper: UniformEffectWrapper, data: ArrayBuffer | ArrayBufferView): void;
7047
7506
 
7507
+ /**
7508
+ * Enables or disables the unmute button. When disabled it is hidden; when
7509
+ * enabled it is shown if the engine is not running.
7510
+ * @param ui - The UI handle.
7511
+ * @param enabled - Whether the button may be shown.
7512
+ */
7513
+ export declare function setUnmuteUIEnabled(ui: UnmuteUI, enabled: boolean): void;
7514
+
7048
7515
  /** Vertex attribute names a ShaderMaterial can bind. */
7049
7516
  export declare type ShaderAttributeName = "position" | "normal" | "uv" | "uv2" | "tangent" | "color";
7050
7517
 
@@ -7346,6 +7813,114 @@ declare interface SkeletonData {
7346
7813
  readonly weights1: Float32Array | null;
7347
7814
  }
7348
7815
 
7816
+ /** A decoded audio buffer ready to be played by one or more sounds. */
7817
+ export declare interface SoundBuffer {
7349
7818
  /** Duration in seconds. */
7819
+ readonly duration: number;
7820
+ /** Sample rate in Hz. */
7821
+ readonly sampleRate: number;
7822
+ /** Number of channels. */
7823
+ readonly channelCount: number;
7824
+ /** Length in samples. */
7825
+ readonly length: number;
7826
+ }
7827
+
7828
+ /** Options for {@link createSoundBufferAsync}. */
7829
+ export declare interface SoundBufferOptions {
7830
+ /** Skip the browser codec check when selecting among multiple URLs. */
7831
+ skipCodecCheck?: boolean;
7832
+ }
7833
+
7834
+ /** Source accepted when creating a sound or sound buffer. */
7835
+ export declare type SoundSource = ArrayBuffer | AudioBuffer | SoundBuffer | string | string[];
7836
+
7837
+ /** Options for {@link createSoundSourceAsync} and {@link createMicrophoneSoundSourceAsync}. */
7838
+ export declare interface SoundSourceOptions {
7839
+ /** Optional name. */
7840
+ name?: string;
7841
+ /** Output bus. Defaults to the engine's main bus unless {@link outBusAutoDefault} is `false`. */
7842
+ outBus?: PrimaryAudioBus;
7843
+ /**
7844
+ * Whether the output bus defaults to the engine's main bus when {@link outBus}
7845
+ * is not set. Defaults to `true` for {@link createSoundSourceAsync} and `false`
7846
+ * for {@link createMicrophoneSoundSourceAsync} (a mic is usually analyzed, not
7847
+ * played back, to avoid feedback).
7848
+ */
7849
+ outBusAutoDefault?: boolean;
7850
+ /** Initial volume. Defaults to `1`. */
7851
+ volume?: number;
7852
+ }
7853
+
7854
+ /** Playback state of a sound or sound instance. Values match Babylon.js exactly. */
7855
+ export declare const SoundState: {
7856
+ readonly Stopping: 0;
7857
+ readonly Stopped: 1;
7858
+ readonly Starting: 2;
7859
+ readonly Started: 3;
7860
+ readonly FailedToStart: 4;
7861
+ readonly Paused: 5;
7862
+ };
7863
+
7864
+ export declare type SoundState = (typeof SoundState)[keyof typeof SoundState];
7865
+
7866
+ /** Which components of a target's world transform drive the spatial node. */
7867
+ export declare type SpatialAttachmentType = "position" | "rotation" | "positionAndRotation";
7868
+
7869
+ /** Spatial listener options. The listener orientation is derived from its rotation quaternion. */
7870
+ export declare interface SpatialListenerOptions {
7871
+ /** Listener world position. Defaults to `(0, 0, 0)`. */
7872
+ position?: Vec3;
7873
+ /** Listener rotation. Drives the listener forward/up vectors. */
7874
+ rotationQuaternion?: Quat;
7875
+ /** Follow a world transform. */
7876
+ attachedTo?: SpatialTarget;
7877
+ /** Which transform components to follow. Defaults to `"positionAndRotation"`. */
7878
+ attachmentType?: SpatialAttachmentType;
7879
+ }
7880
+
7881
+ /** Spatial (3D) options for a sound or bus. All fields optional; defaults match Babylon.js. */
7882
+ export declare interface SpatialSoundOptions {
7883
+ /** World position of the source. Defaults to `(0, 0, 0)`. */
7884
+ position?: Vec3;
7885
+ /** Facing direction of the source. Defaults to `(1, 0, 0)`. */
7886
+ orientation?: Vec3;
7887
+ /** Source rotation as a quaternion. When set, drives {@link orientation}. */
7888
+ rotationQuaternion?: Quat;
7889
+ /** Pan between left/right channels. Defaults to `true`. */
7890
+ panningEnabled?: boolean;
7891
+ /** Panning algorithm. Defaults to `"equalpower"`. */
7892
+ panningModel?: PanningModelType;
7893
+ /** Distance attenuation model. Defaults to `"linear"`. */
7894
+ distanceModel?: DistanceModelType;
7895
+ /** Reference distance for attenuation. Defaults to `1`. */
7896
+ minDistance?: number;
7897
+ /** Max distance (linear model). Defaults to `10000`. */
7898
+ maxDistance?: number;
7899
+ /** Attenuation roll-off factor. Defaults to `1`. */
7900
+ rolloffFactor?: number;
7901
+ /** Cone inner angle, in radians. Defaults to `2π`. */
7902
+ coneInnerAngle?: number;
7903
+ /** Cone outer angle, in radians. Defaults to `2π`. */
7904
+ coneOuterAngle?: number;
7905
+ /** Volume outside the cone outer angle. Defaults to `0`. */
7906
+ coneOuterVolume?: number;
7907
+ /** Follow a world transform's position and/or rotation. */
7908
+ attachedTo?: SpatialTarget;
7909
+ /** Which transform components to follow. Defaults to `"positionAndRotation"`. */
7910
+ attachmentType?: SpatialAttachmentType;
7911
+ }
7912
+
7913
+ /**
7914
+ * Anything exposing a world transform — typically a Lite `Mesh` or camera.
7915
+ * The spatial node reads `worldMatrix` each update; if `onDispose` is provided,
7916
+ * the node auto-detaches when the target is disposed.
7917
+ */
7918
+ export declare interface SpatialTarget {
7919
+ /** Column-major world matrix of the target. */
7920
+ readonly worldMatrix: Mat4;
7921
+ /** Optional dispose signal — firing it auto-detaches the spatial node. */
7922
+ readonly onDispose?: AudioSignal<unknown>;
7923
+ }
7924
+
7350
7925
  /** Procedural UV sphere — matches Babylon MeshBuilder.CreateSphere defaults.
7351
7926
  * Generates vertex positions, normals, and indices for a unit sphere.
7352
7927
  * Left-handed winding (CCW front face) to match Babylon. */
@@ -7408,6 +7983,10 @@ export declare interface Sprite2DLayer {
7408
7983
  readonly atlas: SpriteAtlas;
7409
7984
  readonly depth: Sprite2DDepthMode;
7410
7985
  readonly blendMode: SpriteBlendMode;
7411
7986
  opacity: number;
7987
+ /** Coverage gamma applied to anti-aliased edges; see `Sprite2DLayerOptions.coverageGamma`.
7988
+ * Default 1 (no-op). Read each frame into the layer UBO. Mutating it live changes the
7989
+ * thickness, but the per-fragment `pow` only runs on layers created with `coverageGamma !== 1`. */
7990
+ coverageGamma: number;
7412
7991
  visible: boolean;
7413
7992
  order: number;
7414
7993
  view: Sprite2DView;
@@ -7433,6 +8012,20 @@ export declare interface Sprite2DLayerOptions {
7433
8012
  capacity?: number;
7434
8013
  blendMode?: SpriteBlendMode;
7435
8014
  opacity?: number;
8015
+ /**
8016
+ * Coverage gamma for anti-aliased edges (text rendering). When set to a value other than 1,
8017
+ * the sampled texture alpha is raised to `1/coverageGamma` in the fragment shader, thickening
8018
+ * anti-aliased edges to mimic the gamma-space blending of native text rasterizers
8019
+ * (DirectWrite/CoreText "stem darkening"). Intended for glyph-atlas (bitmap text) layers drawn
8020
+ * into an sRGB (linear-blended) surface, where correct linear AA otherwise makes text look
8021
+ * lighter/thinner. Values \>1 thicken; 1 (default) is a no-op and ships the base fragment.
8022
+ *
8023
+ * The per-fragment `pow` is gated on this create-time opt-in (like `uvScroll`), so only gamma
8024
+ * layers run it. The plumbing (one extra `Layer` UBO `vec4`, the gamma shader permutation, and
8025
+ * this option field) is, however, in the always-loaded sprite path, so it adds a small fixed
8026
+ * cost (~0.3 KB raw) to every sprite scene — reflected in the sprite-scene bundle ceilings.
8027
+ */
8028
+ coverageGamma?: number;
7436
8029
  visible?: boolean;
7437
8030
  order?: number;
7438
8031
  view?: Partial<Sprite2DView>;
@@ -7803,6 +8396,13 @@ export declare interface StandardMaterialProps extends Material {
7803
8396
  * @throws If `requestAnimationFrame` is unavailable in the host environment. */
7804
8397
  export declare function startAnimationManager(manager: AnimationManager): void;
7805
8398
 
8399
+ /**
8400
+ * Starts the `requestAnimationFrame` render loop. No-op if already running or if
8401
+ * `requestAnimationFrame` is unavailable (e.g. a non-browser environment).
8402
+ * @param viz - The visualizer handle.
8403
+ */
8404
+ export declare function startAudioVisualizer(viz: AudioVisualizer): void;
8405
+
7806
8406
  /**
7807
8407
  * Start the render loop. Resolves after the first frame has been rendered.
7808
8408
  * Scenes registered via `registerScene()` before this call are included in
@@ -7817,6 +8417,69 @@ export declare function startEngine(engine: EngineContext): Promise<void>;
7817
8417
  */
7818
8418
  export declare function startSpriteAnimationManager(manager: SpriteAnimationManager): void;
7819
8419
 
8420
+ /** A buffer-backed sound. Pure state — drive it with the sound functions. */
8421
+ export declare interface StaticSound {
8422
+ /** Optional name. */
8423
+ readonly name?: string;
8424
+ /** The decoded buffer this sound plays. */
8425
+ readonly buffer: SoundBuffer;
8426
+ /** Current playback state. */
8427
+ readonly state: SoundState;
8428
+ /** Number of live instances. */
8429
+ readonly instanceCount: number;
8430
+ /** Fires when the sound finishes (all instances ended). */
8431
+ readonly onEnded: AudioSignal<StaticSound>;
8432
+
8433
+ /** Options for {@link createSoundAsync}. */
8434
+ export declare interface StaticSoundOptions extends SoundBufferOptions {
8435
+ /** Play immediately once ready. Defaults to `false`. */
8436
+ autoplay?: boolean;
8437
+ /** Play duration in seconds (`0` = full buffer). Defaults to `0`. */
8438
+ duration?: number;
8439
+ /** Loop playback. Defaults to `false`. */
8440
+ loop?: boolean;
8441
+ /** Loop end point in seconds. Defaults to `0`. */
8442
+ loopEnd?: number;
8443
+ /** Loop start point in seconds. Defaults to `0`. */
8444
+ loopStart?: number;
8445
+ /** Maximum simultaneous instances. Defaults to `Infinity`. */
8446
+ maxInstances?: number;
8447
+ /** Output bus. Defaults to the engine's default main bus. */
8448
+ outBus?: PrimaryAudioBus;
8449
+ /** Detune in cents. Defaults to `0`. */
8450
+ pitch?: number;
8451
+ /** Playback rate multiplier. Defaults to `1`. */
8452
+ playbackRate?: number;
8453
+ /** Start offset in seconds. Defaults to `0`. */
8454
+ startOffset?: number;
8455
+ /** Initial volume. Defaults to `1`. */
8456
+ volume?: number;
8457
+ }
8458
+
8459
+ /** Per-play overrides for {@link playSound}. */
8460
+ export declare interface StaticSoundPlayOptions {
8461
+ /** Play duration in seconds (`0` = full buffer). */
8462
+ duration?: number;
8463
+ /** Loop playback. */
8464
+ loop?: boolean;
8465
+ /** Loop end point in seconds. */
8466
+ loopEnd?: number;
8467
+ /** Loop start point in seconds. */
8468
+ loopStart?: number;
8469
+ /** Start offset in seconds. */
8470
+ startOffset?: number;
8471
+ /** Per-instance volume. */
8472
+ volume?: number;
8473
+ /** Delay before playback starts, in seconds. */
8474
+ waitTime?: number;
8475
+ }
8476
+
8477
+ /** Options for {@link stopSound}. */
8478
+ export declare interface StaticSoundStopOptions {
8479
+ /** Delay before stopping, in seconds. */
8480
+ waitTime?: number;
8481
+ }
8482
+
7820
8483
  /** Optional stencil-test state baked into a material's main-pass pipeline. Shared by every concrete material kind
7821
8484
  * (Standard, PBR, Shader) so none has to depend on another. Lets one material WRITE the stencil buffer where it
7822
8485
  * draws (a mask) and another DISCARD fragments where the stencil was written — with NO dynamic stencil reference:
@@ -7840,15 +8503,30 @@ export declare interface StencilState {
7840
8503
  readonly writeMask?: number;
7841
8504
  }
7842
8505
 
8506
+ /** Options for {@link enableStereo}. */
8507
+ export declare interface StereoSoundOptions {
8508
+ /** Stereo pan in the range `[-1, 1]` (`-1` = full left, `1` = full right). Defaults to `0`. */
8509
+ pan?: number;
8510
+ }
8511
+
7843
8512
  /** Stop playback and reset to frame 0. */
7844
8513
  export declare function stopAnimation(group: AnimationGroup): void;
7845
8514
 
7846
8515
  /** Stops the manager's autonomous requestAnimationFrame loop. No-op if not running. */
7847
8516
  export declare function stopAnimationManager(manager: AnimationManager): void;
7848
8517
 
8518
+ /**
8519
+ * Stops the render loop if it is running.
8520
+ * @param viz - The visualizer handle.
8521
+ */
8522
+ export declare function stopAudioVisualizer(viz: AudioVisualizer): void;
8523
+
7849
8524
  /** Stop the render loop. */
7850
8525
  export declare function stopEngine(engine: EngineContext): void;
7851
8526
 
8527
+ /** Stops the sound (and all its instances). */
8528
+ export declare function stopSound(sound: StaticSound, options?: StaticSoundStopOptions): void;
8529
+
7852
8530
  /**
7853
8531
  * Pauses an animation without removing it; it can be resumed with `playSpriteFrameAnimation`.
7854
8532
  * @param animation - Animation to stop.
@@ -7861,6 +8539,53 @@ export declare function stopSpriteAnimation(animation: SpriteFrameAnimation): vo
7861
8539
  */
7862
8540
  export declare function stopSpriteAnimationManager(manager: SpriteAnimationManager): void;
7863
8541
 
8542
+ /** Stops the sound (and all its instances). */
8543
+ export declare function stopStreamingSound(sound: StreamingSound): void;
8544
+
8545
+ /** A streaming, media-element-backed sound. Pure state — drive it with the streaming-sound functions. */
8546
+ export declare interface StreamingSound {
8547
+ /** Optional name. */
8548
+ readonly name?: string;
8549
+ /** Current playback state. */
8550
+ readonly state: SoundState;
8551
+ /** Number of live instances. */
8552
+ readonly instanceCount: number;
8553
+ /** Number of instances that have finished preloading. */
8554
+ readonly preloadCompletedCount: number;
8555
+ /** Fires when the sound finishes (all instances ended). */
8556
+ readonly onEnded: AudioSignal<StreamingSound>;
8557
+
8558
+ /** Options for {@link createStreamingSoundAsync}. */
8559
+ export declare interface StreamingSoundOptions {
8560
+ /** Play immediately once ready. Defaults to `false`. */
8561
+ autoplay?: boolean;
8562
+ /** Loop playback. Defaults to `false`. */
8563
+ loop?: boolean;
8564
+ /** Maximum simultaneous instances. Defaults to `Infinity`. */
8565
+ maxInstances?: number;
8566
+ /** Output bus. Defaults to the engine's default main bus. */
8567
+ outBus?: PrimaryAudioBus;
8568
+ /** Number of instances to preload. Defaults to `1`. */
8569
+ preloadCount?: number;
8570
+ /** Start offset in seconds. Defaults to `0`. */
8571
+ startOffset?: number;
8572
+ /** Initial volume. Defaults to `1`. */
8573
+ volume?: number;
8574
+ }
8575
+
8576
+ /** Per-play overrides for {@link playStreamingSound}. */
8577
+ export declare interface StreamingSoundPlayOptions {
8578
+ /** Loop playback. */
8579
+ loop?: boolean;
8580
+ /** Start offset in seconds. */
8581
+ startOffset?: number;
8582
+ /** Per-instance volume. */
8583
+ volume?: number;
8584
+ }
8585
+
8586
+ /** A streaming sound source: a URL, a list of candidate URLs, or an existing media element. */
8587
+ export declare type StreamingSoundSource = string | string[] | HTMLMediaElement;
8588
+
7864
8589
  /** Subsurface configuration. Nested sub-features — presence = enabled. */
7865
8590
  export declare interface SubSurfaceProps {
7866
8591
  /** Translucency: light passing through thin surfaces. */
@@ -8032,6 +8757,8 @@ export declare interface TextLayer {
8032
8757
  readonly data: TextData;
8033
8758
  scale: number;
8034
8759
  order: number;
8035
8760
  opacity: number;
8761
+ /** Coverage gamma for anti-aliased edges (see `TextLayerOptions.coverageGamma`). Default 1. */
8762
+ coverageGamma: number;
8036
8763
  visible: boolean;
8037
8764
 
8038
8765
  /** Initial placement and compositing options for a 2D text layer in a standalone text renderer. */
@@ -8049,6 +8776,13 @@ export declare interface TextLayerOptions {
8049
8776
  readonly order?: number;
8050
8777
  /** Alpha multiplier in [0, 1]. Default 1. */
8051
8778
  readonly opacity?: number;
8779
+ /** Coverage gamma for anti-aliased edges. Raises per-pixel coverage to `1/coverageGamma`
8780
+ * before compositing, darkening/thickening anti-aliased edges to mimic the gamma-space
8781
+ * blending used by native text renderers (DirectWrite/CoreText "stem darkening"). Only
8782
+ * meaningful when rendering into an sRGB (linear-blended) surface, where correct linear
8783
+ * AA otherwise makes text look lighter/thinner than gamma-space rasterizers. Values \>1
8784
+ * thicken; 1 (default) is a no-op. Typical text values are ~1.8–2.2. */
8785
+ readonly coverageGamma?: number;
8052
8786
  /** Default true. */
8053
8787
  readonly visible?: boolean;
8054
8788
  }
@@ -8326,6 +9060,22 @@ export declare interface UniformEffectWrapperOptions {
8326
9060
  uniformByteLength: number;
8327
9061
  }
8328
9062
 
9063
+ /**
9064
+ * Unlocks (resumes) the audio engine. Browsers require a user gesture before a
9065
+ * real-time context can produce sound; call this from a click/tap handler.
9066
+ * @param engine - The audio engine.
9067
+ */
9068
+ export declare function unlockAudioEngineAsync(engine: AudioEngine): Promise<void>;
9069
+
9070
+ /** Unmute UI handle. Pure state — driven by the unmute-UI functions. */
9071
+ export declare interface UnmuteUI {
9072
+
9073
+ /** Options for {@link createUnmuteUI}. */
9074
+ export declare interface UnmuteUIOptions {
9075
+ /** Parent element for the button. Defaults to `document.body`. */
9076
+ parentElement?: HTMLElement;
9077
+ }
9078
+
8329
9079
  /** Unregister the effect renderer from its surface. No-op if not registered. */
8330
9080
  export declare function unregisterEffectRenderer(er: EffectRenderer): void;
8331
9081
 
@@ -8416,6 +9166,13 @@ export declare function updateNavCrowd(crowd: NavCrowd, dt: number): void;
8416
9166
  /** Run `tileCache.update()` until all pending obstacle requests are resolved. */
8417
9167
  export declare function updateNavMeshObstacles(plugin: NavigationPlugin): void;
8418
9168
 
9169
+ /**
9170
+ * Pumps one spatial update for every attached node and the listener. Call this
9171
+ * from your render loop, or enable {@link setSpatialAutoUpdate}.
9172
+ * @param engine - The audio engine.
9173
+ */
9174
+ export declare function updateSpatialAudio(engine: AudioEngine): void;
9175
+
8419
9176
  /**
8420
9177
  * Updates the properties of the sprite referenced by `handle`.
8421
9178
  * @param handle - Handle of the sprite to update.