@codexo/exojs 0.8.4 → 0.9.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.
- package/CHANGELOG.md +55 -0
- package/README.md +26 -5
- package/dist/esm/animation/Tween.d.ts +20 -3
- package/dist/esm/animation/Tween.js +16 -8
- package/dist/esm/animation/Tween.js.map +1 -1
- package/dist/esm/animation/TweenManager.d.ts +16 -1
- package/dist/esm/animation/TweenManager.js +27 -2
- package/dist/esm/animation/TweenManager.js.map +1 -1
- package/dist/esm/audio/AudioAnalyser.d.ts +2 -0
- package/dist/esm/audio/AudioAnalyser.js +24 -9
- package/dist/esm/audio/AudioAnalyser.js.map +1 -1
- package/dist/esm/audio/AudioBus.d.ts +1 -0
- package/dist/esm/audio/AudioBus.js +8 -4
- package/dist/esm/audio/AudioBus.js.map +1 -1
- package/dist/esm/audio/AudioListener.d.ts +1 -0
- package/dist/esm/audio/AudioListener.js +7 -5
- package/dist/esm/audio/AudioListener.js.map +1 -1
- package/dist/esm/audio/AudioManager.d.ts +8 -2
- package/dist/esm/audio/AudioManager.js +14 -1
- package/dist/esm/audio/AudioManager.js.map +1 -1
- package/dist/esm/audio/BeatDetector.d.ts +2 -0
- package/dist/esm/audio/BeatDetector.js +27 -661
- package/dist/esm/audio/BeatDetector.js.map +1 -1
- package/dist/esm/audio/Music.d.ts +1 -0
- package/dist/esm/audio/Music.js +7 -3
- package/dist/esm/audio/Music.js.map +1 -1
- package/dist/esm/audio/OscillatorSound.d.ts +1 -0
- package/dist/esm/audio/OscillatorSound.js +7 -3
- package/dist/esm/audio/OscillatorSound.js.map +1 -1
- package/dist/esm/audio/Sound.d.ts +1 -0
- package/dist/esm/audio/Sound.js +7 -3
- package/dist/esm/audio/Sound.js.map +1 -1
- package/dist/esm/audio/audio-context.d.ts +2 -2
- package/dist/esm/audio/audio-context.js +4 -4
- package/dist/esm/audio/audio-context.js.map +1 -1
- package/dist/esm/audio/filters/ChorusFilter.d.ts +1 -0
- package/dist/esm/audio/filters/ChorusFilter.js +7 -3
- package/dist/esm/audio/filters/ChorusFilter.js.map +1 -1
- package/dist/esm/audio/filters/CompressorFilter.d.ts +1 -0
- package/dist/esm/audio/filters/CompressorFilter.js +7 -3
- package/dist/esm/audio/filters/CompressorFilter.js.map +1 -1
- package/dist/esm/audio/filters/DelayFilter.d.ts +1 -0
- package/dist/esm/audio/filters/DelayFilter.js +7 -3
- package/dist/esm/audio/filters/DelayFilter.js.map +1 -1
- package/dist/esm/audio/filters/EqualizerFilter.d.ts +1 -0
- package/dist/esm/audio/filters/EqualizerFilter.js +7 -3
- package/dist/esm/audio/filters/EqualizerFilter.js.map +1 -1
- package/dist/esm/audio/filters/GranularFilter.js +1 -86
- package/dist/esm/audio/filters/GranularFilter.js.map +1 -1
- package/dist/esm/audio/filters/HighpassFilter.d.ts +1 -0
- package/dist/esm/audio/filters/HighpassFilter.js +7 -3
- package/dist/esm/audio/filters/HighpassFilter.js.map +1 -1
- package/dist/esm/audio/filters/LowpassFilter.d.ts +1 -0
- package/dist/esm/audio/filters/LowpassFilter.js +7 -3
- package/dist/esm/audio/filters/LowpassFilter.js.map +1 -1
- package/dist/esm/audio/filters/PitchShiftFilter.js +1 -71
- package/dist/esm/audio/filters/PitchShiftFilter.js.map +1 -1
- package/dist/esm/audio/filters/ReverbFilter.d.ts +1 -0
- package/dist/esm/audio/filters/ReverbFilter.js +7 -3
- package/dist/esm/audio/filters/ReverbFilter.js.map +1 -1
- package/dist/esm/audio/filters/VocoderFilter.js +1 -89
- package/dist/esm/audio/filters/VocoderFilter.js.map +1 -1
- package/dist/esm/audio/filters/WorkletFilter.d.ts +2 -0
- package/dist/esm/audio/filters/WorkletFilter.js +10 -5
- package/dist/esm/audio/filters/WorkletFilter.js.map +1 -1
- package/dist/esm/audio/index.d.ts +15 -10
- package/dist/esm/audio/worklet/registerWorklet.d.ts +1 -1
- package/dist/esm/audio/worklet/registerWorklet.js +2 -2
- package/dist/esm/audio/worklet/registerWorklet.js.map +1 -1
- package/dist/esm/audio/worklets/beat-detector.worklet.d.ts +1 -0
- package/dist/esm/audio/worklets/beat-detector.worklet.js +647 -0
- package/dist/esm/audio/worklets/beat-detector.worklet.js.map +1 -0
- package/dist/esm/audio/worklets/granular.worklet.d.ts +1 -0
- package/dist/esm/audio/worklets/granular.worklet.js +89 -0
- package/dist/esm/audio/worklets/granular.worklet.js.map +1 -0
- package/dist/esm/audio/worklets/pitch-shift.worklet.d.ts +1 -0
- package/dist/esm/audio/worklets/pitch-shift.worklet.js +74 -0
- package/dist/esm/audio/worklets/pitch-shift.worklet.js.map +1 -0
- package/dist/esm/audio/worklets/vocoder.worklet.d.ts +1 -0
- package/dist/esm/audio/worklets/vocoder.worklet.js +92 -0
- package/dist/esm/audio/worklets/vocoder.worklet.js.map +1 -0
- package/dist/esm/core/Application.d.ts +62 -24
- package/dist/esm/core/Application.js +116 -40
- package/dist/esm/core/Application.js.map +1 -1
- package/dist/esm/core/Color.d.ts +0 -8
- package/dist/esm/core/Color.js +0 -24
- package/dist/esm/core/Color.js.map +1 -1
- package/dist/esm/core/Scene.d.ts +32 -72
- package/dist/esm/core/Scene.js +56 -36
- package/dist/esm/core/Scene.js.map +1 -1
- package/dist/esm/core/SceneManager.d.ts +11 -25
- package/dist/esm/core/SceneManager.js +37 -100
- package/dist/esm/core/SceneManager.js.map +1 -1
- package/dist/esm/core/SceneNode.d.ts +28 -14
- package/dist/esm/core/SceneNode.js +66 -33
- package/dist/esm/core/SceneNode.js.map +1 -1
- package/dist/esm/core/Signal.d.ts +24 -28
- package/dist/esm/core/Signal.js +64 -50
- package/dist/esm/core/Signal.js.map +1 -1
- package/dist/esm/core/Timer.d.ts +1 -0
- package/dist/esm/core/Timer.js +3 -0
- package/dist/esm/core/Timer.js.map +1 -1
- package/dist/esm/debug/BoundingBoxesLayer.js +1 -1
- package/dist/esm/debug/BoundingBoxesLayer.js.map +1 -1
- package/dist/esm/debug/HitTestLayer.js +1 -1
- package/dist/esm/debug/HitTestLayer.js.map +1 -1
- package/dist/esm/debug/PerformanceLayer.js +1 -2
- package/dist/esm/debug/PerformanceLayer.js.map +1 -1
- package/dist/esm/debug/PointerStackLayer.js +1 -2
- package/dist/esm/debug/PointerStackLayer.js.map +1 -1
- package/dist/esm/debug/RenderPassInspectorLayer.js +1 -2
- package/dist/esm/debug/RenderPassInspectorLayer.js.map +1 -1
- package/dist/esm/index.js +23 -7
- package/dist/esm/index.js.map +1 -1
- package/dist/esm/input/InputManager.d.ts +1 -0
- package/dist/esm/input/InputManager.js +30 -3
- package/dist/esm/input/InputManager.js.map +1 -1
- package/dist/esm/input/InteractionManager.d.ts +5 -2
- package/dist/esm/input/InteractionManager.js +29 -18
- package/dist/esm/input/InteractionManager.js.map +1 -1
- package/dist/esm/input/Pointer.js +3 -2
- package/dist/esm/input/Pointer.js.map +1 -1
- package/dist/esm/input/internal/interactionManagerRegistry.d.ts +9 -0
- package/dist/esm/input/internal/interactionManagerRegistry.js +10 -0
- package/dist/esm/input/internal/interactionManagerRegistry.js.map +1 -0
- package/dist/esm/math/AbstractVector.d.ts +1 -7
- package/dist/esm/math/AbstractVector.js +6 -20
- package/dist/esm/math/AbstractVector.js.map +1 -1
- package/dist/esm/math/Circle.js +0 -2
- package/dist/esm/math/Circle.js.map +1 -1
- package/dist/esm/math/Collision.d.ts +9 -3
- package/dist/esm/math/Ellipse.d.ts +2 -5
- package/dist/esm/math/Ellipse.js +10 -7
- package/dist/esm/math/Ellipse.js.map +1 -1
- package/dist/esm/math/ObservableVector.d.ts +1 -1
- package/dist/esm/math/ObservableVector.js +3 -3
- package/dist/esm/math/ObservableVector.js.map +1 -1
- package/dist/esm/math/Polygon.d.ts +0 -2
- package/dist/esm/math/Polygon.js +1 -9
- package/dist/esm/math/Polygon.js.map +1 -1
- package/dist/esm/math/Rectangle.js +0 -2
- package/dist/esm/math/Rectangle.js.map +1 -1
- package/dist/esm/math/collision-detection.d.ts +19 -4
- package/dist/esm/math/collision-detection.js +61 -4
- package/dist/esm/math/collision-detection.js.map +1 -1
- package/dist/esm/math/swept-collision.d.ts +16 -12
- package/dist/esm/math/swept-collision.js +109 -19
- package/dist/esm/math/swept-collision.js.map +1 -1
- package/dist/esm/particles/ParticleSystem.js +1 -1
- package/dist/esm/particles/ParticleSystem.js.map +1 -1
- package/dist/esm/particles/index.d.ts +1 -0
- package/dist/esm/rendering/CallbackRenderPass.d.ts +1 -0
- package/dist/esm/rendering/CallbackRenderPass.js +1 -0
- package/dist/esm/rendering/CallbackRenderPass.js.map +1 -1
- package/dist/esm/rendering/Container.d.ts +2 -1
- package/dist/esm/rendering/Container.js +17 -16
- package/dist/esm/rendering/Container.js.map +1 -1
- package/dist/esm/rendering/RenderBackend.d.ts +1 -0
- package/dist/esm/rendering/RenderNode.d.ts +1 -3
- package/dist/esm/rendering/RenderNode.js +12 -19
- package/dist/esm/rendering/RenderNode.js.map +1 -1
- package/dist/esm/rendering/RenderPass.d.ts +1 -0
- package/dist/esm/rendering/RenderStats.d.ts +9 -0
- package/dist/esm/rendering/RenderStats.js +2 -0
- package/dist/esm/rendering/RenderStats.js.map +1 -1
- package/dist/esm/rendering/RendererRegistry.d.ts +1 -0
- package/dist/esm/rendering/RendererRegistry.js +1 -0
- package/dist/esm/rendering/RendererRegistry.js.map +1 -1
- package/dist/esm/rendering/View.d.ts +23 -0
- package/dist/esm/rendering/View.js +42 -0
- package/dist/esm/rendering/View.js.map +1 -1
- package/dist/esm/rendering/index.d.ts +89 -59
- package/dist/esm/rendering/mesh/Mesh.js +1 -1
- package/dist/esm/rendering/mesh/Mesh.js.map +1 -1
- package/dist/esm/rendering/mesh/MeshShader.d.ts +1 -0
- package/dist/esm/rendering/mesh/MeshShader.js +1 -0
- package/dist/esm/rendering/mesh/MeshShader.js.map +1 -1
- package/dist/esm/rendering/shader/Shader.d.ts +1 -0
- package/dist/esm/rendering/shader/Shader.js +1 -0
- package/dist/esm/rendering/shader/Shader.js.map +1 -1
- package/dist/esm/rendering/shader/ShaderUniform.d.ts +1 -0
- package/dist/esm/rendering/shader/ShaderUniform.js +1 -0
- package/dist/esm/rendering/shader/ShaderUniform.js.map +1 -1
- package/dist/esm/rendering/sprite/Sprite.d.ts +3 -2
- package/dist/esm/rendering/sprite/Sprite.js +15 -13
- package/dist/esm/rendering/sprite/Sprite.js.map +1 -1
- package/dist/esm/rendering/text/AbstractText.d.ts +36 -0
- package/dist/esm/rendering/text/AbstractText.js +49 -0
- package/dist/esm/rendering/text/AbstractText.js.map +1 -0
- package/dist/esm/rendering/text/BitmapText.d.ts +97 -0
- package/dist/esm/rendering/text/BitmapText.js +220 -0
- package/dist/esm/rendering/text/BitmapText.js.map +1 -0
- package/dist/esm/rendering/text/BmFont.d.ts +50 -0
- package/dist/esm/rendering/text/BmFont.js +24 -0
- package/dist/esm/rendering/text/BmFont.js.map +1 -0
- package/dist/esm/rendering/text/GlyphAtlas.d.ts +104 -0
- package/dist/esm/rendering/text/GlyphAtlas.js +347 -0
- package/dist/esm/rendering/text/GlyphAtlas.js.map +1 -0
- package/dist/esm/rendering/text/GlyphAtlasPool.d.ts +40 -0
- package/dist/esm/rendering/text/GlyphAtlasPool.js +67 -0
- package/dist/esm/rendering/text/GlyphAtlasPool.js.map +1 -0
- package/dist/esm/rendering/text/GlyphSdf.d.ts +92 -0
- package/dist/esm/rendering/text/GlyphSdf.js +220 -0
- package/dist/esm/rendering/text/GlyphSdf.js.map +1 -0
- package/dist/esm/rendering/text/HTMLText.d.ts +107 -0
- package/dist/esm/rendering/text/HTMLText.js +284 -0
- package/dist/esm/rendering/text/HTMLText.js.map +1 -0
- package/dist/esm/rendering/text/LayoutOptions.d.ts +30 -0
- package/dist/esm/rendering/text/Text.d.ts +89 -20
- package/dist/esm/rendering/text/Text.js +176 -101
- package/dist/esm/rendering/text/Text.js.map +1 -1
- package/dist/esm/rendering/text/TextLayout.d.ts +20 -8
- package/dist/esm/rendering/text/TextLayout.js +234 -25
- package/dist/esm/rendering/text/TextLayout.js.map +1 -1
- package/dist/esm/rendering/text/TextStyle.d.ts +154 -87
- package/dist/esm/rendering/text/TextStyle.js +257 -203
- package/dist/esm/rendering/text/TextStyle.js.map +1 -1
- package/dist/esm/rendering/text/types.d.ts +73 -13
- package/dist/esm/rendering/texture/Texture.d.ts +1 -0
- package/dist/esm/rendering/texture/Texture.js +1 -0
- package/dist/esm/rendering/texture/Texture.js.map +1 -1
- package/dist/esm/rendering/types.d.ts +3 -1
- package/dist/esm/rendering/types.js +2 -0
- package/dist/esm/rendering/types.js.map +1 -1
- package/dist/esm/rendering/video/Video.d.ts +2 -1
- package/dist/esm/rendering/video/Video.js +9 -5
- package/dist/esm/rendering/video/Video.js.map +1 -1
- package/dist/esm/rendering/webgl2/WebGl2Backend.js +41 -5
- package/dist/esm/rendering/webgl2/WebGl2Backend.js.map +1 -1
- package/dist/esm/rendering/webgl2/WebGl2MeshRenderer.js +4 -4
- package/dist/esm/rendering/webgl2/WebGl2MeshRenderer.js.map +1 -1
- package/dist/esm/rendering/webgl2/WebGl2TextRenderer.d.ts +56 -0
- package/dist/esm/rendering/webgl2/WebGl2TextRenderer.js +482 -0
- package/dist/esm/rendering/webgl2/WebGl2TextRenderer.js.map +1 -0
- package/dist/esm/rendering/webgl2/glsl/text-color.frag.js +4 -0
- package/dist/esm/rendering/webgl2/glsl/text-color.frag.js.map +1 -0
- package/dist/esm/rendering/webgl2/glsl/text-msdf.frag.js +4 -0
- package/dist/esm/rendering/webgl2/glsl/text-msdf.frag.js.map +1 -0
- package/dist/esm/rendering/webgl2/glsl/text-sdf.frag.js +4 -0
- package/dist/esm/rendering/webgl2/glsl/text-sdf.frag.js.map +1 -0
- package/dist/esm/rendering/webgl2/glsl/text.vert.js +4 -0
- package/dist/esm/rendering/webgl2/glsl/text.vert.js.map +1 -0
- package/dist/esm/rendering/webgpu/WebGpuBackend.js +16 -8
- package/dist/esm/rendering/webgpu/WebGpuBackend.js.map +1 -1
- package/dist/esm/rendering/webgpu/WebGpuBlendState.js +26 -0
- package/dist/esm/rendering/webgpu/WebGpuBlendState.js.map +1 -1
- package/dist/esm/rendering/webgpu/WebGpuMeshRenderer.d.ts +2 -2
- package/dist/esm/rendering/webgpu/WebGpuMeshRenderer.js +23 -15
- package/dist/esm/rendering/webgpu/WebGpuMeshRenderer.js.map +1 -1
- package/dist/esm/rendering/webgpu/WebGpuSpriteRenderer.js +9 -1
- package/dist/esm/rendering/webgpu/WebGpuSpriteRenderer.js.map +1 -1
- package/dist/esm/rendering/webgpu/WebGpuTextRenderer.d.ts +70 -0
- package/dist/esm/rendering/webgpu/WebGpuTextRenderer.js +773 -0
- package/dist/esm/rendering/webgpu/WebGpuTextRenderer.js.map +1 -0
- package/dist/esm/rendering/webgpu/compute/WebGpuComputePipeline.js +96 -0
- package/dist/esm/rendering/webgpu/compute/WebGpuComputePipeline.js.map +1 -0
- package/dist/esm/rendering/webgpu/compute/WebGpuStorageBuffer.js +68 -0
- package/dist/esm/rendering/webgpu/compute/WebGpuStorageBuffer.js.map +1 -0
- package/dist/esm/resources/Asset.d.ts +23 -0
- package/dist/esm/resources/Asset.js +23 -0
- package/dist/esm/resources/Asset.js.map +1 -0
- package/dist/esm/resources/AssetDefinitions.d.ts +137 -0
- package/dist/esm/resources/Assets.d.ts +35 -0
- package/dist/esm/resources/Assets.js +32 -0
- package/dist/esm/resources/Assets.js.map +1 -0
- package/dist/esm/resources/IndexedDbDatabase.js +17 -1
- package/dist/esm/resources/IndexedDbDatabase.js.map +1 -1
- package/dist/esm/resources/IndexedDbStore.js +17 -1
- package/dist/esm/resources/IndexedDbStore.js.map +1 -1
- package/dist/esm/resources/Loader.d.ts +244 -18
- package/dist/esm/resources/Loader.js +456 -50
- package/dist/esm/resources/Loader.js.map +1 -1
- package/dist/esm/resources/LoadingQueue.d.ts +28 -0
- package/dist/esm/resources/LoadingQueue.js +59 -0
- package/dist/esm/resources/LoadingQueue.js.map +1 -0
- package/dist/esm/resources/factories/BmFontFactory.d.ts +25 -0
- package/dist/esm/resources/factories/BmFontFactory.js +96 -0
- package/dist/esm/resources/factories/BmFontFactory.js.map +1 -0
- package/dist/esm/resources/factories/CsvFactory.d.ts +35 -0
- package/dist/esm/resources/factories/CsvFactory.js +87 -0
- package/dist/esm/resources/factories/CsvFactory.js.map +1 -0
- package/dist/esm/resources/factories/MusicFactory.d.ts +8 -2
- package/dist/esm/resources/factories/MusicFactory.js +25 -14
- package/dist/esm/resources/factories/MusicFactory.js.map +1 -1
- package/dist/esm/resources/factories/SoundFactory.d.ts +2 -2
- package/dist/esm/resources/factories/SoundFactory.js.map +1 -1
- package/dist/esm/resources/factories/SubtitleFactory.d.ts +28 -0
- package/dist/esm/resources/factories/SubtitleFactory.js +203 -0
- package/dist/esm/resources/factories/SubtitleFactory.js.map +1 -0
- package/dist/esm/resources/factories/SvgFactory.d.ts +18 -1
- package/dist/esm/resources/factories/SvgFactory.js +21 -2
- package/dist/esm/resources/factories/SvgFactory.js.map +1 -1
- package/dist/esm/resources/factories/VideoFactory.d.ts +8 -2
- package/dist/esm/resources/factories/VideoFactory.js +27 -20
- package/dist/esm/resources/factories/VideoFactory.js.map +1 -1
- package/dist/esm/resources/factories/XmlFactory.d.ts +24 -0
- package/dist/esm/resources/factories/XmlFactory.js +37 -0
- package/dist/esm/resources/factories/XmlFactory.js.map +1 -0
- package/dist/esm/resources/index.d.ts +8 -1
- package/dist/esm/resources/tokens.d.ts +49 -3
- package/dist/esm/resources/tokens.js +50 -4
- package/dist/esm/resources/tokens.js.map +1 -1
- package/dist/exo.esm.js +6635 -2550
- package/dist/exo.esm.js.map +1 -1
- package/package.json +16 -4
- package/dist/esm/input/interaction-hooks.d.ts +0 -34
- package/dist/esm/input/interaction-hooks.js +0 -35
- package/dist/esm/input/interaction-hooks.js.map +0 -1
- package/dist/esm/rendering/text/DynamicGlyphAtlas.d.ts +0 -33
- package/dist/esm/rendering/text/DynamicGlyphAtlas.js +0 -134
- package/dist/esm/rendering/text/DynamicGlyphAtlas.js.map +0 -1
- package/dist/esm/rendering/text/atlas-singleton.d.ts +0 -7
- package/dist/esm/rendering/text/atlas-singleton.js +0 -17
- package/dist/esm/rendering/text/atlas-singleton.js.map +0 -1
- package/dist/esm/resources/factories/VttFactory.d.ts +0 -24
- package/dist/esm/resources/factories/VttFactory.js +0 -158
- package/dist/esm/resources/factories/VttFactory.js.map +0 -1
|
@@ -0,0 +1,89 @@
|
|
|
1
|
+
const granularWorkletSource = `
|
|
2
|
+
const sampleRate = globalThis.sampleRate;
|
|
3
|
+
|
|
4
|
+
class GranularProcessor extends AudioWorkletProcessor {
|
|
5
|
+
static get parameterDescriptors() {
|
|
6
|
+
return [
|
|
7
|
+
{ name: 'grainSize', defaultValue: 0.05, minValue: 0.005, maxValue: 0.5, automationRate: 'k-rate' },
|
|
8
|
+
{ name: 'density', defaultValue: 50, minValue: 1, maxValue: 500, automationRate: 'k-rate' },
|
|
9
|
+
{ name: 'spread', defaultValue: 0.5, minValue: 0, maxValue: 1.0, automationRate: 'k-rate' },
|
|
10
|
+
{ name: 'pitchMin', defaultValue: 1.0, minValue: 0.25, maxValue: 4.0, automationRate: 'k-rate' },
|
|
11
|
+
{ name: 'pitchMax', defaultValue: 1.0, minValue: 0.25, maxValue: 4.0, automationRate: 'k-rate' },
|
|
12
|
+
{ name: 'wet', defaultValue: 1.0, minValue: 0, maxValue: 1.0, automationRate: 'k-rate' },
|
|
13
|
+
];
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
constructor(options) {
|
|
17
|
+
super();
|
|
18
|
+
const opts = options.processorOptions ?? {};
|
|
19
|
+
const bufferSeconds = opts.bufferSeconds ?? 2;
|
|
20
|
+
this._bufferLength = Math.floor(bufferSeconds * sampleRate);
|
|
21
|
+
this._buffer = new Float32Array(this._bufferLength);
|
|
22
|
+
this._writePos = 0;
|
|
23
|
+
this._timeUntilNextGrainSamples = 0;
|
|
24
|
+
this._grains = []; // { startPos, ageSamples, lengthSamples, pitch }
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
process(inputs, outputs, parameters) {
|
|
28
|
+
const input = inputs[0]?.[0];
|
|
29
|
+
const output = outputs[0]?.[0];
|
|
30
|
+
if (!input || !output) return true;
|
|
31
|
+
|
|
32
|
+
const grainSize = parameters.grainSize[0];
|
|
33
|
+
const density = parameters.density[0];
|
|
34
|
+
const spread = parameters.spread[0];
|
|
35
|
+
const pitchMin = parameters.pitchMin[0];
|
|
36
|
+
const pitchMax = parameters.pitchMax[0];
|
|
37
|
+
const wet = parameters.wet[0];
|
|
38
|
+
|
|
39
|
+
const grainSizeSamples = Math.max(8, Math.floor(grainSize * sampleRate));
|
|
40
|
+
const samplesPerGrain = sampleRate / Math.max(1, density);
|
|
41
|
+
|
|
42
|
+
for (let i = 0; i < input.length; i++) {
|
|
43
|
+
// Write input to circular buffer
|
|
44
|
+
this._buffer[this._writePos] = input[i];
|
|
45
|
+
this._writePos = (this._writePos + 1) % this._bufferLength;
|
|
46
|
+
|
|
47
|
+
// Spawn new grain if scheduled
|
|
48
|
+
this._timeUntilNextGrainSamples -= 1;
|
|
49
|
+
if (this._timeUntilNextGrainSamples <= 0) {
|
|
50
|
+
// Random offset into recent past, biased by spread
|
|
51
|
+
const maxOffset = Math.floor(spread * this._bufferLength);
|
|
52
|
+
const offset = Math.floor(Math.random() * Math.max(1, maxOffset));
|
|
53
|
+
const startPos = (this._writePos - offset - grainSizeSamples + this._bufferLength) % this._bufferLength;
|
|
54
|
+
// Random pitch in [pitchMin, pitchMax]
|
|
55
|
+
const pitch = pitchMin + Math.random() * Math.max(0, pitchMax - pitchMin);
|
|
56
|
+
|
|
57
|
+
this._grains.push({ startPos, ageSamples: 0, lengthSamples: grainSizeSamples, pitch });
|
|
58
|
+
this._timeUntilNextGrainSamples = samplesPerGrain;
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
// Mix all active grains (apply Hann window)
|
|
62
|
+
let grainSum = 0;
|
|
63
|
+
for (let g = this._grains.length - 1; g >= 0; g--) {
|
|
64
|
+
const grain = this._grains[g];
|
|
65
|
+
if (grain.ageSamples >= grain.lengthSamples) {
|
|
66
|
+
this._grains.splice(g, 1);
|
|
67
|
+
continue;
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
const phase = grain.ageSamples / grain.lengthSamples;
|
|
71
|
+
const window = 0.5 * (1 - Math.cos(2 * Math.PI * phase));
|
|
72
|
+
const readPos = grain.startPos + grain.ageSamples * grain.pitch;
|
|
73
|
+
const sampleIndex = Math.floor(readPos) % this._bufferLength;
|
|
74
|
+
const safeIndex = (sampleIndex + this._bufferLength) % this._bufferLength;
|
|
75
|
+
grainSum += this._buffer[safeIndex] * window;
|
|
76
|
+
|
|
77
|
+
grain.ageSamples++;
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
output[i] = (1 - wet) * input[i] + wet * grainSum;
|
|
81
|
+
}
|
|
82
|
+
return true;
|
|
83
|
+
}
|
|
84
|
+
}
|
|
85
|
+
registerProcessor('exojs-granular', GranularProcessor);
|
|
86
|
+
`;
|
|
87
|
+
|
|
88
|
+
export { granularWorkletSource };
|
|
89
|
+
//# sourceMappingURL=granular.worklet.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"granular.worklet.js","sources":["../../../../../src/audio/worklets/granular.worklet.ts"],"sourcesContent":[null],"names":[],"mappings":"AAAO,MAAM,qBAAqB,GAAG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const pitchShiftWorkletSource = "\nclass PitchShiftProcessor extends AudioWorkletProcessor {\n static get parameterDescriptors() {\n return [\n { name: 'pitch', defaultValue: 1.0, minValue: 0.25, maxValue: 4.0, automationRate: 'k-rate' },\n { name: 'wet', defaultValue: 1.0, minValue: 0, maxValue: 1.0, automationRate: 'k-rate' },\n ];\n }\n\n constructor(options) {\n super();\n const grainSize = options.processorOptions?.grainSize ?? 1024;\n this._grainSize = grainSize;\n this._bufferLength = grainSize * 4;\n this._buffer = new Float32Array(this._bufferLength);\n this._writePos = 0;\n // Two staggered read positions for overlap-add\n this._readPosA = 0;\n this._readPosB = grainSize / 2;\n this._hannWindow = this._buildHannWindow(grainSize);\n }\n\n _buildHannWindow(n) {\n const w = new Float32Array(n);\n for (let i = 0; i < n; i++) {\n w[i] = 0.5 * (1 - Math.cos(2 * Math.PI * i / (n - 1)));\n }\n return w;\n }\n\n _readGrain(readPos) {\n const grainSize = this._grainSize;\n const sampleIndex = Math.floor(readPos);\n const phase = sampleIndex % grainSize; // position within the grain envelope\n const win = this._hannWindow[phase];\n const bufferIndex = ((this._writePos - this._bufferLength + sampleIndex) % this._bufferLength + this._bufferLength) % this._bufferLength;\n return this._buffer[bufferIndex] * win;\n }\n\n process(inputs, outputs, parameters) {\n const input = inputs[0]?.[0];\n const output = outputs[0]?.[0];\n if (!input || !output) return true;\n\n const pitch = parameters.pitch[0];\n const wet = parameters.wet[0];\n\n for (let i = 0; i < input.length; i++) {\n // Write to circular buffer\n this._buffer[this._writePos] = input[i];\n this._writePos = (this._writePos + 1) % this._bufferLength;\n\n // Read two grains and sum\n const grainA = this._readGrain(this._readPosA);\n const grainB = this._readGrain(this._readPosB);\n const shifted = grainA + grainB;\n\n // Mix with dry\n output[i] = (1 - wet) * input[i] + wet * shifted;\n\n // Advance read positions at pitch rate\n this._readPosA += pitch;\n this._readPosB += pitch;\n if (this._readPosA >= this._grainSize) this._readPosA -= this._grainSize;\n if (this._readPosB >= this._grainSize) this._readPosB -= this._grainSize;\n }\n return true;\n }\n}\nregisterProcessor('exojs-pitch-shift', PitchShiftProcessor);\n";
|
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
const pitchShiftWorkletSource = `
|
|
2
|
+
class PitchShiftProcessor extends AudioWorkletProcessor {
|
|
3
|
+
static get parameterDescriptors() {
|
|
4
|
+
return [
|
|
5
|
+
{ name: 'pitch', defaultValue: 1.0, minValue: 0.25, maxValue: 4.0, automationRate: 'k-rate' },
|
|
6
|
+
{ name: 'wet', defaultValue: 1.0, minValue: 0, maxValue: 1.0, automationRate: 'k-rate' },
|
|
7
|
+
];
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
constructor(options) {
|
|
11
|
+
super();
|
|
12
|
+
const grainSize = options.processorOptions?.grainSize ?? 1024;
|
|
13
|
+
this._grainSize = grainSize;
|
|
14
|
+
this._bufferLength = grainSize * 4;
|
|
15
|
+
this._buffer = new Float32Array(this._bufferLength);
|
|
16
|
+
this._writePos = 0;
|
|
17
|
+
// Two staggered read positions for overlap-add
|
|
18
|
+
this._readPosA = 0;
|
|
19
|
+
this._readPosB = grainSize / 2;
|
|
20
|
+
this._hannWindow = this._buildHannWindow(grainSize);
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
_buildHannWindow(n) {
|
|
24
|
+
const w = new Float32Array(n);
|
|
25
|
+
for (let i = 0; i < n; i++) {
|
|
26
|
+
w[i] = 0.5 * (1 - Math.cos(2 * Math.PI * i / (n - 1)));
|
|
27
|
+
}
|
|
28
|
+
return w;
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
_readGrain(readPos) {
|
|
32
|
+
const grainSize = this._grainSize;
|
|
33
|
+
const sampleIndex = Math.floor(readPos);
|
|
34
|
+
const phase = sampleIndex % grainSize; // position within the grain envelope
|
|
35
|
+
const win = this._hannWindow[phase];
|
|
36
|
+
const bufferIndex = ((this._writePos - this._bufferLength + sampleIndex) % this._bufferLength + this._bufferLength) % this._bufferLength;
|
|
37
|
+
return this._buffer[bufferIndex] * win;
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
process(inputs, outputs, parameters) {
|
|
41
|
+
const input = inputs[0]?.[0];
|
|
42
|
+
const output = outputs[0]?.[0];
|
|
43
|
+
if (!input || !output) return true;
|
|
44
|
+
|
|
45
|
+
const pitch = parameters.pitch[0];
|
|
46
|
+
const wet = parameters.wet[0];
|
|
47
|
+
|
|
48
|
+
for (let i = 0; i < input.length; i++) {
|
|
49
|
+
// Write to circular buffer
|
|
50
|
+
this._buffer[this._writePos] = input[i];
|
|
51
|
+
this._writePos = (this._writePos + 1) % this._bufferLength;
|
|
52
|
+
|
|
53
|
+
// Read two grains and sum
|
|
54
|
+
const grainA = this._readGrain(this._readPosA);
|
|
55
|
+
const grainB = this._readGrain(this._readPosB);
|
|
56
|
+
const shifted = grainA + grainB;
|
|
57
|
+
|
|
58
|
+
// Mix with dry
|
|
59
|
+
output[i] = (1 - wet) * input[i] + wet * shifted;
|
|
60
|
+
|
|
61
|
+
// Advance read positions at pitch rate
|
|
62
|
+
this._readPosA += pitch;
|
|
63
|
+
this._readPosB += pitch;
|
|
64
|
+
if (this._readPosA >= this._grainSize) this._readPosA -= this._grainSize;
|
|
65
|
+
if (this._readPosB >= this._grainSize) this._readPosB -= this._grainSize;
|
|
66
|
+
}
|
|
67
|
+
return true;
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
registerProcessor('exojs-pitch-shift', PitchShiftProcessor);
|
|
71
|
+
`;
|
|
72
|
+
|
|
73
|
+
export { pitchShiftWorkletSource };
|
|
74
|
+
//# sourceMappingURL=pitch-shift.worklet.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"pitch-shift.worklet.js","sources":["../../../../../src/audio/worklets/pitch-shift.worklet.ts"],"sourcesContent":[null],"names":[],"mappings":"AAAO,MAAM,uBAAuB,GAAG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const vocoderWorkletSource = "\nconst sampleRate = globalThis.sampleRate;\n\nclass VocoderProcessor extends AudioWorkletProcessor {\n static get parameterDescriptors() {\n return [\n { name: 'wet', defaultValue: 1.0, minValue: 0, maxValue: 1.0, automationRate: 'k-rate' },\n { name: 'envelopeSmoothing', defaultValue: 0.005, minValue: 0.0001, maxValue: 0.1, automationRate: 'k-rate' },\n ];\n }\n\n constructor(options) {\n super();\n const opts = options.processorOptions ?? {};\n const bandCount = opts.numBands ?? 16;\n const minHz = opts.minHz ?? 80;\n const maxHz = opts.maxHz ?? 8000;\n const Q = opts.bandQ ?? 4;\n\n // Log-spaced band centers + biquad coefficients\n this._bands = [];\n for (let i = 0; i < bandCount; i++) {\n const ratio = bandCount === 1 ? 0 : i / (bandCount - 1);\n const centerHz = minHz * Math.pow(maxHz / minHz, ratio);\n const omega = 2 * Math.PI * centerHz / sampleRate;\n const cos = Math.cos(omega);\n const sin = Math.sin(omega);\n const alpha = sin / (2 * Q);\n\n // Bandpass (constant 0 dB peak) biquad\n const a0 = 1 + alpha;\n const b0 = alpha / a0;\n const b1 = 0;\n const b2 = -alpha / a0;\n const a1 = (-2 * cos) / a0;\n const a2 = (1 - alpha) / a0;\n this._bands.push({ b0, b1, b2, a1, a2 });\n }\n\n // Per-band biquad state (one for carrier, one for modulator)\n this._carrierStates = this._bands.map(() => ({ x1: 0, x2: 0, y1: 0, y2: 0 }));\n this._modulatorStates = this._bands.map(() => ({ x1: 0, x2: 0, y1: 0, y2: 0 }));\n\n // Per-band envelope follower\n this._envelopes = new Float32Array(bandCount);\n }\n\n _processBiquad(state, coef, x) {\n const y = coef.b0 * x + coef.b1 * state.x1 + coef.b2 * state.x2 - coef.a1 * state.y1 - coef.a2 * state.y2;\n state.x2 = state.x1; state.x1 = x;\n state.y2 = state.y1; state.y1 = y;\n return y;\n }\n\n process(inputs, outputs, parameters) {\n const carrier = inputs[0]?.[0];\n const modulator = inputs[1]?.[0];\n const output = outputs[0]?.[0];\n if (!carrier || !output) return true;\n\n const wet = parameters.wet[0];\n const envSmoothing = parameters.envelopeSmoothing[0];\n const bandCount = this._bands.length;\n\n for (let i = 0; i < carrier.length; i++) {\n const carrierSample = carrier[i];\n const modulatorSample = modulator?.[i] ?? 0;\n\n let bandSum = 0;\n for (let b = 0; b < bandCount; b++) {\n const coef = this._bands[b];\n\n // Modulator band \u2192 envelope follower\n const modBand = this._processBiquad(this._modulatorStates[b], coef, modulatorSample);\n const target = Math.abs(modBand);\n this._envelopes[b] += (target - this._envelopes[b]) * envSmoothing;\n\n // Carrier band, scaled by modulator envelope\n const carBand = this._processBiquad(this._carrierStates[b], coef, carrierSample);\n bandSum += carBand * this._envelopes[b];\n }\n\n output[i] = (1 - wet) * carrierSample + wet * bandSum;\n }\n return true;\n }\n}\nregisterProcessor('exojs-vocoder', VocoderProcessor);\n";
|
|
@@ -0,0 +1,92 @@
|
|
|
1
|
+
const vocoderWorkletSource = `
|
|
2
|
+
const sampleRate = globalThis.sampleRate;
|
|
3
|
+
|
|
4
|
+
class VocoderProcessor extends AudioWorkletProcessor {
|
|
5
|
+
static get parameterDescriptors() {
|
|
6
|
+
return [
|
|
7
|
+
{ name: 'wet', defaultValue: 1.0, minValue: 0, maxValue: 1.0, automationRate: 'k-rate' },
|
|
8
|
+
{ name: 'envelopeSmoothing', defaultValue: 0.005, minValue: 0.0001, maxValue: 0.1, automationRate: 'k-rate' },
|
|
9
|
+
];
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
constructor(options) {
|
|
13
|
+
super();
|
|
14
|
+
const opts = options.processorOptions ?? {};
|
|
15
|
+
const bandCount = opts.numBands ?? 16;
|
|
16
|
+
const minHz = opts.minHz ?? 80;
|
|
17
|
+
const maxHz = opts.maxHz ?? 8000;
|
|
18
|
+
const Q = opts.bandQ ?? 4;
|
|
19
|
+
|
|
20
|
+
// Log-spaced band centers + biquad coefficients
|
|
21
|
+
this._bands = [];
|
|
22
|
+
for (let i = 0; i < bandCount; i++) {
|
|
23
|
+
const ratio = bandCount === 1 ? 0 : i / (bandCount - 1);
|
|
24
|
+
const centerHz = minHz * Math.pow(maxHz / minHz, ratio);
|
|
25
|
+
const omega = 2 * Math.PI * centerHz / sampleRate;
|
|
26
|
+
const cos = Math.cos(omega);
|
|
27
|
+
const sin = Math.sin(omega);
|
|
28
|
+
const alpha = sin / (2 * Q);
|
|
29
|
+
|
|
30
|
+
// Bandpass (constant 0 dB peak) biquad
|
|
31
|
+
const a0 = 1 + alpha;
|
|
32
|
+
const b0 = alpha / a0;
|
|
33
|
+
const b1 = 0;
|
|
34
|
+
const b2 = -alpha / a0;
|
|
35
|
+
const a1 = (-2 * cos) / a0;
|
|
36
|
+
const a2 = (1 - alpha) / a0;
|
|
37
|
+
this._bands.push({ b0, b1, b2, a1, a2 });
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
// Per-band biquad state (one for carrier, one for modulator)
|
|
41
|
+
this._carrierStates = this._bands.map(() => ({ x1: 0, x2: 0, y1: 0, y2: 0 }));
|
|
42
|
+
this._modulatorStates = this._bands.map(() => ({ x1: 0, x2: 0, y1: 0, y2: 0 }));
|
|
43
|
+
|
|
44
|
+
// Per-band envelope follower
|
|
45
|
+
this._envelopes = new Float32Array(bandCount);
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
_processBiquad(state, coef, x) {
|
|
49
|
+
const y = coef.b0 * x + coef.b1 * state.x1 + coef.b2 * state.x2 - coef.a1 * state.y1 - coef.a2 * state.y2;
|
|
50
|
+
state.x2 = state.x1; state.x1 = x;
|
|
51
|
+
state.y2 = state.y1; state.y1 = y;
|
|
52
|
+
return y;
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
process(inputs, outputs, parameters) {
|
|
56
|
+
const carrier = inputs[0]?.[0];
|
|
57
|
+
const modulator = inputs[1]?.[0];
|
|
58
|
+
const output = outputs[0]?.[0];
|
|
59
|
+
if (!carrier || !output) return true;
|
|
60
|
+
|
|
61
|
+
const wet = parameters.wet[0];
|
|
62
|
+
const envSmoothing = parameters.envelopeSmoothing[0];
|
|
63
|
+
const bandCount = this._bands.length;
|
|
64
|
+
|
|
65
|
+
for (let i = 0; i < carrier.length; i++) {
|
|
66
|
+
const carrierSample = carrier[i];
|
|
67
|
+
const modulatorSample = modulator?.[i] ?? 0;
|
|
68
|
+
|
|
69
|
+
let bandSum = 0;
|
|
70
|
+
for (let b = 0; b < bandCount; b++) {
|
|
71
|
+
const coef = this._bands[b];
|
|
72
|
+
|
|
73
|
+
// Modulator band → envelope follower
|
|
74
|
+
const modBand = this._processBiquad(this._modulatorStates[b], coef, modulatorSample);
|
|
75
|
+
const target = Math.abs(modBand);
|
|
76
|
+
this._envelopes[b] += (target - this._envelopes[b]) * envSmoothing;
|
|
77
|
+
|
|
78
|
+
// Carrier band, scaled by modulator envelope
|
|
79
|
+
const carBand = this._processBiquad(this._carrierStates[b], coef, carrierSample);
|
|
80
|
+
bandSum += carBand * this._envelopes[b];
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
output[i] = (1 - wet) * carrierSample + wet * bandSum;
|
|
84
|
+
}
|
|
85
|
+
return true;
|
|
86
|
+
}
|
|
87
|
+
}
|
|
88
|
+
registerProcessor('exojs-vocoder', VocoderProcessor);
|
|
89
|
+
`;
|
|
90
|
+
|
|
91
|
+
export { vocoderWorkletSource };
|
|
92
|
+
//# sourceMappingURL=vocoder.worklet.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"vocoder.worklet.js","sources":["../../../../../src/audio/worklets/vocoder.worklet.ts"],"sourcesContent":[null],"names":[],"mappings":"AAAO,MAAM,oBAAoB,GAAG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;"}
|
|
@@ -6,36 +6,55 @@ import { InputManager } from '@/input/InputManager';
|
|
|
6
6
|
import { InteractionManager } from '@/input/InteractionManager';
|
|
7
7
|
import type { RenderBackend } from '@/rendering/RenderBackend';
|
|
8
8
|
import { Texture } from '@/rendering/texture/Texture';
|
|
9
|
-
import type
|
|
10
|
-
import { Loader } from '@/resources/Loader';
|
|
9
|
+
import { Loader, type LoaderOptions } from '@/resources/Loader';
|
|
11
10
|
import { Capabilities } from './capabilities';
|
|
12
11
|
import { Color } from './Color';
|
|
13
12
|
import type { Scene } from './Scene';
|
|
14
13
|
import { SceneManager } from './SceneManager';
|
|
15
14
|
import { Signal } from './Signal';
|
|
16
|
-
import
|
|
15
|
+
import { Time } from './Time';
|
|
17
16
|
export declare enum ApplicationStatus {
|
|
18
17
|
Loading = 1,
|
|
19
18
|
Running = 2,
|
|
20
19
|
Halting = 3,
|
|
21
20
|
Stopped = 4
|
|
22
21
|
}
|
|
22
|
+
export interface CanvasApplicationOptions {
|
|
23
|
+
/** Existing canvas element to use. If omitted, Application creates one. */
|
|
24
|
+
element?: HTMLCanvasElement;
|
|
25
|
+
/** Logical canvas width. Default: 800. */
|
|
26
|
+
width?: number;
|
|
27
|
+
/** Logical canvas height. Default: 600. */
|
|
28
|
+
height?: number;
|
|
29
|
+
/** Device/render pixel ratio applied to the backing buffer. Default: 1. */
|
|
30
|
+
pixelRatio?: number;
|
|
31
|
+
/** Canvas tabIndex. Default: -1, preserving current behavior. */
|
|
32
|
+
tabIndex?: number;
|
|
33
|
+
/** CSS image-rendering hint applied to the canvas style. */
|
|
34
|
+
imageRendering?: 'auto' | 'pixelated' | 'crisp-edges';
|
|
35
|
+
}
|
|
36
|
+
export interface RenderingApplicationOptions {
|
|
37
|
+
/** WebGL2-only debug wrapper. Ignored by WebGPU. */
|
|
38
|
+
debug?: boolean;
|
|
39
|
+
/** WebGL2 context attributes. Ignored by WebGPU. */
|
|
40
|
+
webglAttributes?: WebGLContextAttributes;
|
|
41
|
+
/** WebGL2 sprite renderer batch size. Ignored by WebGPU. */
|
|
42
|
+
spriteRendererBatchSize?: number;
|
|
43
|
+
/** WebGL2 particle renderer batch size. Ignored by WebGPU. */
|
|
44
|
+
particleRendererBatchSize?: number;
|
|
45
|
+
}
|
|
46
|
+
export interface InputApplicationOptions {
|
|
47
|
+
gamepadDefinitions?: GamepadDefinition[];
|
|
48
|
+
gamepadSlotStrategy?: GamepadSlotStrategy;
|
|
49
|
+
pointerDistanceThreshold?: number;
|
|
50
|
+
}
|
|
23
51
|
export interface ApplicationOptions {
|
|
24
|
-
|
|
25
|
-
width: number;
|
|
26
|
-
height: number;
|
|
27
|
-
debug: boolean;
|
|
28
|
-
clearColor: Color;
|
|
29
|
-
spriteRendererBatchSize: number;
|
|
30
|
-
particleRendererBatchSize: number;
|
|
31
|
-
gamepadDefinitions: GamepadDefinition[];
|
|
32
|
-
gamepadSlotStrategy: GamepadSlotStrategy;
|
|
33
|
-
pointerDistanceThreshold: number;
|
|
34
|
-
webglAttributes: WebGLContextAttributes;
|
|
35
|
-
resourcePath: string;
|
|
36
|
-
requestOptions: RequestInit;
|
|
37
|
-
cache?: CacheStore | readonly CacheStore[];
|
|
52
|
+
clearColor?: Color;
|
|
38
53
|
backend?: BackendConfig;
|
|
54
|
+
canvas?: CanvasApplicationOptions;
|
|
55
|
+
loader?: LoaderOptions;
|
|
56
|
+
rendering?: RenderingApplicationOptions;
|
|
57
|
+
input?: InputApplicationOptions;
|
|
39
58
|
}
|
|
40
59
|
export interface WebGl2BackendConfig {
|
|
41
60
|
type: 'webgl2';
|
|
@@ -81,7 +100,7 @@ export declare class Application {
|
|
|
81
100
|
readonly loader: Loader;
|
|
82
101
|
readonly input: InputManager;
|
|
83
102
|
readonly interaction: InteractionManager;
|
|
84
|
-
readonly
|
|
103
|
+
readonly scene: SceneManager;
|
|
85
104
|
readonly tweens: TweenManager;
|
|
86
105
|
readonly onResize: Signal<[number, number, Application]>;
|
|
87
106
|
readonly onFrame: Signal<[Time]>;
|
|
@@ -95,6 +114,7 @@ export declare class Application {
|
|
|
95
114
|
private readonly _activeClock;
|
|
96
115
|
private readonly _frameClock;
|
|
97
116
|
private _status;
|
|
117
|
+
private _pixelRatio;
|
|
98
118
|
private _frameCount;
|
|
99
119
|
private _frameRequest;
|
|
100
120
|
private _backendType;
|
|
@@ -103,7 +123,7 @@ export declare class Application {
|
|
|
103
123
|
private _documentVisible;
|
|
104
124
|
private _cursor;
|
|
105
125
|
private readonly _visibilityChangeHandler;
|
|
106
|
-
constructor(appSettings?:
|
|
126
|
+
constructor(appSettings?: ApplicationOptions);
|
|
107
127
|
get status(): ApplicationStatus;
|
|
108
128
|
get startupTime(): Time;
|
|
109
129
|
get activeTime(): Time;
|
|
@@ -130,10 +150,27 @@ export declare class Application {
|
|
|
130
150
|
start(scene: Scene): Promise<this>;
|
|
131
151
|
/**
|
|
132
152
|
* One iteration of the per-frame loop. Invoked by `requestAnimationFrame`.
|
|
133
|
-
*
|
|
134
|
-
*
|
|
135
|
-
*
|
|
136
|
-
*
|
|
153
|
+
* When the document is hidden and `pauseOnHidden` is `true`, the frame
|
|
154
|
+
* clock is reset and the body is skipped — preventing a large delta spike
|
|
155
|
+
* on the first visible frame after resume.
|
|
156
|
+
*
|
|
157
|
+
* Each normal frame runs two distinct phases:
|
|
158
|
+
*
|
|
159
|
+
* **Update phase** — input and interaction flush, audio update, tween
|
|
160
|
+
* advancement, optional view runtime update, then `scene.update(delta)` for
|
|
161
|
+
* each participating scene in stack order.
|
|
162
|
+
*
|
|
163
|
+
* **Render phase** — `scene.draw(backend)` for each participating scene in
|
|
164
|
+
* stack order, followed by the transition overlay when active.
|
|
165
|
+
*
|
|
166
|
+
* **Frame dispatch / flush** — `onFrame` signal, backend GPU flush,
|
|
167
|
+
* frame-time stat write, RAF reschedule.
|
|
168
|
+
*
|
|
169
|
+
* The simulation `delta` forwarded to all update recipients is clamped to
|
|
170
|
+
* an internal maximum (100 ms) so that debugger pauses, device sleep/resume,
|
|
171
|
+
* or severe browser scheduling gaps cannot produce runaway animation
|
|
172
|
+
* advancement. Real wall-clock time and RAF cadence are unaffected; the raw
|
|
173
|
+
* elapsed delta is recorded separately in `backend.stats.rawFrameDeltaMs`.
|
|
137
174
|
*/
|
|
138
175
|
update(): this;
|
|
139
176
|
/**
|
|
@@ -164,6 +201,7 @@ export declare class Application {
|
|
|
164
201
|
private _onDocumentVisibilityChange;
|
|
165
202
|
private resolveInitialBackendType;
|
|
166
203
|
private createBackend;
|
|
167
|
-
private
|
|
204
|
+
private initializeBackend;
|
|
168
205
|
private canUseWebGpu;
|
|
206
|
+
private _applyCanvasSize;
|
|
169
207
|
}
|