@codexo/exojs 0.7.13 → 0.8.2
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 +637 -124
- package/README.md +19 -19
- package/dist/esm/animation/Easing.js +13 -21
- package/dist/esm/animation/Easing.js.map +1 -1
- package/dist/esm/animation/Tween.d.ts +3 -3
- package/dist/esm/animation/Tween.js +7 -5
- package/dist/esm/animation/Tween.js.map +1 -1
- package/dist/esm/animation/TweenManager.js +1 -1
- package/dist/esm/animation/TweenManager.js.map +1 -1
- package/dist/esm/animation/types.js.map +1 -1
- package/dist/esm/audio/AbstractMedia.d.ts +1 -1
- package/dist/esm/audio/AbstractMedia.js +1 -1
- package/dist/esm/audio/AbstractMedia.js.map +1 -1
- package/dist/esm/audio/AudioAnalyser.d.ts +1 -1
- package/dist/esm/audio/AudioAnalyser.js +2 -2
- package/dist/esm/audio/AudioAnalyser.js.map +1 -1
- package/dist/esm/audio/AudioBus.d.ts +1 -1
- package/dist/esm/audio/AudioBus.js.map +1 -1
- package/dist/esm/audio/AudioFilter.js +3 -1
- package/dist/esm/audio/AudioFilter.js.map +1 -1
- package/dist/esm/audio/AudioListener.d.ts +1 -1
- package/dist/esm/audio/AudioListener.js +5 -3
- package/dist/esm/audio/AudioListener.js.map +1 -1
- package/dist/esm/audio/AudioManager.js.map +1 -1
- package/dist/esm/audio/BeatDetector.d.ts +4 -4
- package/dist/esm/audio/BeatDetector.js +68 -44
- package/dist/esm/audio/BeatDetector.js.map +1 -1
- package/dist/esm/audio/Envelope.d.ts +1 -1
- package/dist/esm/audio/Envelope.js +2 -2
- package/dist/esm/audio/Envelope.js.map +1 -1
- package/dist/esm/audio/Music.d.ts +1 -1
- package/dist/esm/audio/Music.js +1 -1
- package/dist/esm/audio/Music.js.map +1 -1
- package/dist/esm/audio/OscillatorSound.d.ts +2 -2
- package/dist/esm/audio/OscillatorSound.js.map +1 -1
- package/dist/esm/audio/Sound.d.ts +40 -2
- package/dist/esm/audio/Sound.js +69 -9
- package/dist/esm/audio/Sound.js.map +1 -1
- package/dist/esm/audio/audio-context.js +1 -1
- package/dist/esm/audio/audio-context.js.map +1 -1
- package/dist/esm/audio/crossFade.js +1 -1
- package/dist/esm/audio/crossFade.js.map +1 -1
- package/dist/esm/audio/dsp/mel.d.ts +2 -2
- package/dist/esm/audio/dsp/tempogram.d.ts +2 -2
- package/dist/esm/audio/filters/ChorusFilter.js +12 -4
- package/dist/esm/audio/filters/ChorusFilter.js.map +1 -1
- package/dist/esm/audio/filters/CompressorFilter.d.ts +9 -0
- package/dist/esm/audio/filters/CompressorFilter.js +11 -0
- package/dist/esm/audio/filters/CompressorFilter.js.map +1 -1
- package/dist/esm/audio/filters/DelayFilter.js.map +1 -1
- package/dist/esm/audio/filters/DuckingFilter.d.ts +1 -1
- package/dist/esm/audio/filters/DuckingFilter.js +13 -5
- package/dist/esm/audio/filters/DuckingFilter.js.map +1 -1
- package/dist/esm/audio/filters/EqualizerFilter.js.map +1 -1
- package/dist/esm/audio/filters/GranularFilter.js +30 -14
- package/dist/esm/audio/filters/GranularFilter.js.map +1 -1
- package/dist/esm/audio/filters/HighpassFilter.js.map +1 -1
- package/dist/esm/audio/filters/LowpassFilter.js.map +1 -1
- package/dist/esm/audio/filters/PitchShiftFilter.js +14 -10
- package/dist/esm/audio/filters/PitchShiftFilter.js.map +1 -1
- package/dist/esm/audio/filters/ReverbFilter.js.map +1 -1
- package/dist/esm/audio/filters/VocoderFilter.d.ts +2 -2
- package/dist/esm/audio/filters/VocoderFilter.js +20 -12
- package/dist/esm/audio/filters/VocoderFilter.js.map +1 -1
- package/dist/esm/audio/filters/WorkletFilter.js +5 -6
- package/dist/esm/audio/filters/WorkletFilter.js.map +1 -1
- package/dist/esm/audio/filters/index.d.ts +7 -7
- package/dist/esm/audio/index.d.ts +9 -9
- package/dist/esm/audio/worklet/registerWorklet.js +7 -3
- package/dist/esm/audio/worklet/registerWorklet.js.map +1 -1
- package/dist/esm/core/Application.d.ts +13 -13
- package/dist/esm/core/Application.js +24 -16
- package/dist/esm/core/Application.js.map +1 -1
- package/dist/esm/core/Bounds.d.ts +1 -1
- package/dist/esm/core/Bounds.js +1 -3
- package/dist/esm/core/Bounds.js.map +1 -1
- package/dist/esm/core/Clock.js +1 -1
- package/dist/esm/core/Clock.js.map +1 -1
- package/dist/esm/core/Color.js +2 -5
- package/dist/esm/core/Color.js.map +1 -1
- package/dist/esm/core/Scene.d.ts +10 -10
- package/dist/esm/core/Scene.js +1 -1
- package/dist/esm/core/Scene.js.map +1 -1
- package/dist/esm/core/SceneManager.d.ts +4 -4
- package/dist/esm/core/SceneManager.js +39 -33
- package/dist/esm/core/SceneManager.js.map +1 -1
- package/dist/esm/core/SceneNode.d.ts +8 -8
- package/dist/esm/core/SceneNode.js +39 -29
- package/dist/esm/core/SceneNode.js.map +1 -1
- package/dist/esm/core/Signal.d.ts +3 -3
- package/dist/esm/core/Signal.js +3 -3
- package/dist/esm/core/Signal.js.map +1 -1
- package/dist/esm/core/Time.js +6 -6
- package/dist/esm/core/Time.js.map +1 -1
- package/dist/esm/core/Timer.d.ts +1 -1
- package/dist/esm/core/Timer.js +1 -1
- package/dist/esm/core/Timer.js.map +1 -1
- package/dist/esm/core/capabilities.js +2 -4
- package/dist/esm/core/capabilities.js.map +1 -1
- package/dist/esm/core/index.d.ts +2 -2
- package/dist/esm/core/utils.d.ts +4 -4
- package/dist/esm/core/utils.js +10 -10
- package/dist/esm/core/utils.js.map +1 -1
- package/dist/esm/debug/BoundingBoxesLayer.d.ts +3 -3
- package/dist/esm/debug/BoundingBoxesLayer.js +6 -13
- package/dist/esm/debug/BoundingBoxesLayer.js.map +1 -1
- package/dist/esm/debug/DebugLayer.d.ts +1 -1
- package/dist/esm/debug/DebugLayer.js.map +1 -1
- package/dist/esm/debug/DebugOverlay.d.ts +2 -2
- package/dist/esm/debug/DebugOverlay.js +2 -2
- package/dist/esm/debug/DebugOverlay.js.map +1 -1
- package/dist/esm/debug/HitTestLayer.d.ts +3 -3
- package/dist/esm/debug/HitTestLayer.js +3 -10
- package/dist/esm/debug/HitTestLayer.js.map +1 -1
- package/dist/esm/debug/PerformanceLayer.d.ts +2 -2
- package/dist/esm/debug/PerformanceLayer.js +6 -6
- package/dist/esm/debug/PerformanceLayer.js.map +1 -1
- package/dist/esm/debug/PointerStackLayer.d.ts +3 -3
- package/dist/esm/debug/PointerStackLayer.js +3 -3
- package/dist/esm/debug/PointerStackLayer.js.map +1 -1
- package/dist/esm/debug/index.d.ts +3 -3
- package/dist/esm/debug/index.js +3 -3
- package/dist/esm/index.d.ts +1 -1
- package/dist/esm/index.js +106 -84
- package/dist/esm/index.js.map +1 -1
- package/dist/esm/input/ArcadeStickGamepadMapping.js.map +1 -1
- package/dist/esm/input/GameCubeGamepadMapping.d.ts +1 -1
- package/dist/esm/input/GameCubeGamepadMapping.js +1 -1
- package/dist/esm/input/GameCubeGamepadMapping.js.map +1 -1
- package/dist/esm/input/Gamepad.d.ts +7 -7
- package/dist/esm/input/Gamepad.js +10 -6
- package/dist/esm/input/Gamepad.js.map +1 -1
- package/dist/esm/input/GamepadAxis.js +1 -1
- package/dist/esm/input/GamepadAxis.js.map +1 -1
- package/dist/esm/input/GamepadButton.js +1 -1
- package/dist/esm/input/GamepadButton.js.map +1 -1
- package/dist/esm/input/GamepadDefinitions.d.ts +4 -4
- package/dist/esm/input/GamepadDefinitions.js +12 -14
- package/dist/esm/input/GamepadDefinitions.js.map +1 -1
- package/dist/esm/input/GamepadMapping.d.ts +5 -5
- package/dist/esm/input/GamepadMapping.js.map +1 -1
- package/dist/esm/input/GamepadPromptLayouts.d.ts +2 -2
- package/dist/esm/input/GamepadPromptLayouts.js +8 -8
- package/dist/esm/input/GamepadPromptLayouts.js.map +1 -1
- package/dist/esm/input/GenericDualAnalogGamepadMapping.js.map +1 -1
- package/dist/esm/input/GestureRecognizer.d.ts +1 -1
- package/dist/esm/input/GestureRecognizer.js.map +1 -1
- package/dist/esm/input/InputBinding.d.ts +3 -3
- package/dist/esm/input/InputBinding.js.map +1 -1
- package/dist/esm/input/InputManager.d.ts +9 -9
- package/dist/esm/input/InputManager.js +25 -16
- package/dist/esm/input/InputManager.js.map +1 -1
- package/dist/esm/input/InteractionEvent.d.ts +1 -1
- package/dist/esm/input/InteractionEvent.js.map +1 -1
- package/dist/esm/input/InteractionManager.d.ts +2 -2
- package/dist/esm/input/InteractionManager.js +25 -16
- package/dist/esm/input/InteractionManager.js.map +1 -1
- package/dist/esm/input/JoyConLeftGamepadMapping.js.map +1 -1
- package/dist/esm/input/JoyConRightGamepadMapping.js.map +1 -1
- package/dist/esm/input/PlayStationGamepadMapping.d.ts +1 -1
- package/dist/esm/input/PlayStationGamepadMapping.js +1 -1
- package/dist/esm/input/PlayStationGamepadMapping.js.map +1 -1
- package/dist/esm/input/Pointer.d.ts +2 -2
- package/dist/esm/input/Pointer.js +6 -6
- package/dist/esm/input/Pointer.js.map +1 -1
- package/dist/esm/input/SteamControllerGamepadMapping.d.ts +1 -1
- package/dist/esm/input/SteamControllerGamepadMapping.js +1 -1
- package/dist/esm/input/SteamControllerGamepadMapping.js.map +1 -1
- package/dist/esm/input/SteamDeckGamepadMapping.js.map +1 -1
- package/dist/esm/input/SwitchProGamepadMapping.d.ts +1 -1
- package/dist/esm/input/SwitchProGamepadMapping.js +1 -1
- package/dist/esm/input/SwitchProGamepadMapping.js.map +1 -1
- package/dist/esm/input/XboxGamepadMapping.d.ts +1 -1
- package/dist/esm/input/XboxGamepadMapping.js +1 -1
- package/dist/esm/input/XboxGamepadMapping.js.map +1 -1
- package/dist/esm/input/index.d.ts +16 -16
- package/dist/esm/input/interaction-hooks.js.map +1 -1
- package/dist/esm/input/types.js.map +1 -1
- package/dist/esm/math/AbstractVector.js +8 -9
- package/dist/esm/math/AbstractVector.js.map +1 -1
- package/dist/esm/math/Circle.d.ts +5 -5
- package/dist/esm/math/Circle.js +33 -21
- package/dist/esm/math/Circle.js.map +1 -1
- package/dist/esm/math/Collision.d.ts +2 -2
- package/dist/esm/math/Collision.js.map +1 -1
- package/dist/esm/math/Ellipse.d.ts +5 -5
- package/dist/esm/math/Ellipse.js +28 -19
- package/dist/esm/math/Ellipse.js.map +1 -1
- package/dist/esm/math/Flags.d.ts +4 -4
- package/dist/esm/math/Flags.js.map +1 -1
- package/dist/esm/math/Interval.js.map +1 -1
- package/dist/esm/math/Line.d.ts +5 -5
- package/dist/esm/math/Line.js +23 -15
- package/dist/esm/math/Line.js.map +1 -1
- package/dist/esm/math/Matrix.js +14 -16
- package/dist/esm/math/Matrix.js.map +1 -1
- package/dist/esm/math/ObservableSize.js.map +1 -1
- package/dist/esm/math/ObservableVector.d.ts +1 -1
- package/dist/esm/math/ObservableVector.js.map +1 -1
- package/dist/esm/math/PolarVector.js.map +1 -1
- package/dist/esm/math/Polygon.d.ts +11 -11
- package/dist/esm/math/Polygon.js +37 -26
- package/dist/esm/math/Polygon.js.map +1 -1
- package/dist/esm/math/PolygonLike.d.ts +1 -1
- package/dist/esm/math/Quadtree.js +2 -8
- package/dist/esm/math/Quadtree.js.map +1 -1
- package/dist/esm/math/Random.js +5 -5
- package/dist/esm/math/Random.js.map +1 -1
- package/dist/esm/math/Rectangle.d.ts +4 -4
- package/dist/esm/math/Rectangle.js +59 -41
- package/dist/esm/math/Rectangle.js.map +1 -1
- package/dist/esm/math/Segment.d.ts +1 -1
- package/dist/esm/math/Segment.js +4 -4
- package/dist/esm/math/Segment.js.map +1 -1
- package/dist/esm/math/ShapeLike.d.ts +1 -1
- package/dist/esm/math/Size.js +1 -2
- package/dist/esm/math/Size.js.map +1 -1
- package/dist/esm/math/Vector.d.ts +4 -4
- package/dist/esm/math/Vector.js +19 -13
- package/dist/esm/math/Vector.js.map +1 -1
- package/dist/esm/math/collision-detection.d.ts +3 -3
- package/dist/esm/math/collision-detection.js +49 -49
- package/dist/esm/math/collision-detection.js.map +1 -1
- package/dist/esm/math/collision-primitives.d.ts +8 -8
- package/dist/esm/math/collision-primitives.js +27 -33
- package/dist/esm/math/collision-primitives.js.map +1 -1
- package/dist/esm/math/geometry.d.ts +3 -3
- package/dist/esm/math/geometry.js +55 -48
- package/dist/esm/math/geometry.js.map +1 -1
- package/dist/esm/math/index.d.ts +16 -16
- package/dist/esm/math/swept-collision.d.ts +3 -3
- package/dist/esm/math/swept-collision.js +5 -8
- package/dist/esm/math/swept-collision.js.map +1 -1
- package/dist/esm/math/triangulate.js +34 -24
- package/dist/esm/math/triangulate.js.map +1 -1
- package/dist/esm/math/utils.d.ts +2 -2
- package/dist/esm/math/utils.js +7 -7
- package/dist/esm/math/utils.js.map +1 -1
- package/dist/esm/particles/ParticleSystem.d.ts +181 -84
- package/dist/esm/particles/ParticleSystem.js +460 -147
- package/dist/esm/particles/ParticleSystem.js.map +1 -1
- package/dist/esm/particles/distributions/BoxArea.d.ts +17 -0
- package/dist/esm/particles/distributions/BoxArea.js +48 -0
- package/dist/esm/particles/distributions/BoxArea.js.map +1 -0
- package/dist/esm/particles/distributions/CircleArea.d.ts +19 -0
- package/dist/esm/particles/distributions/CircleArea.js +33 -0
- package/dist/esm/particles/distributions/CircleArea.js.map +1 -0
- package/dist/esm/particles/distributions/ConeDirection.d.ts +28 -0
- package/dist/esm/particles/distributions/ConeDirection.js +44 -0
- package/dist/esm/particles/distributions/ConeDirection.js.map +1 -0
- package/dist/esm/particles/distributions/Constant.d.ts +17 -0
- package/dist/esm/particles/distributions/Constant.js +35 -0
- package/dist/esm/particles/distributions/Constant.js.map +1 -0
- package/dist/esm/particles/distributions/Curve.d.ts +30 -0
- package/dist/esm/particles/distributions/Curve.js +53 -0
- package/dist/esm/particles/distributions/Curve.js.map +1 -0
- package/dist/esm/particles/distributions/Distribution.d.ts +45 -0
- package/dist/esm/particles/distributions/Gradient.d.ts +40 -0
- package/dist/esm/particles/distributions/Gradient.js +72 -0
- package/dist/esm/particles/distributions/Gradient.js.map +1 -0
- package/dist/esm/particles/distributions/LineSegment.d.ts +15 -0
- package/dist/esm/particles/distributions/LineSegment.js +27 -0
- package/dist/esm/particles/distributions/LineSegment.js.map +1 -0
- package/dist/esm/particles/distributions/Range.d.ts +12 -0
- package/dist/esm/particles/distributions/Range.js +19 -0
- package/dist/esm/particles/distributions/Range.js.map +1 -0
- package/dist/esm/particles/distributions/VectorRange.d.ts +20 -0
- package/dist/esm/particles/distributions/VectorRange.js +31 -0
- package/dist/esm/particles/distributions/VectorRange.js.map +1 -0
- package/dist/esm/particles/distributions/index.d.ts +12 -0
- package/dist/esm/particles/gpu/ParticleGpuState.d.ts +57 -0
- package/dist/esm/particles/gpu/ParticleGpuState.js +535 -0
- package/dist/esm/particles/gpu/ParticleGpuState.js.map +1 -0
- package/dist/esm/particles/index.d.ts +2 -10
- package/dist/esm/particles/modules/AlphaFadeOverLifetime.d.ts +24 -0
- package/dist/esm/particles/modules/AlphaFadeOverLifetime.js +60 -0
- package/dist/esm/particles/modules/AlphaFadeOverLifetime.js.map +1 -0
- package/dist/esm/particles/modules/ApplyForce.d.ts +20 -0
- package/dist/esm/particles/modules/ApplyForce.js +48 -0
- package/dist/esm/particles/modules/ApplyForce.js.map +1 -0
- package/dist/esm/particles/modules/AttractToPoint.d.ts +27 -0
- package/dist/esm/particles/modules/AttractToPoint.js +73 -0
- package/dist/esm/particles/modules/AttractToPoint.js.map +1 -0
- package/dist/esm/particles/modules/BurstSpawn.d.ts +53 -0
- package/dist/esm/particles/modules/BurstSpawn.js +94 -0
- package/dist/esm/particles/modules/BurstSpawn.js.map +1 -0
- package/dist/esm/particles/modules/ColorOverLifetime.d.ts +22 -0
- package/dist/esm/particles/modules/ColorOverLifetime.js +65 -0
- package/dist/esm/particles/modules/ColorOverLifetime.js.map +1 -0
- package/dist/esm/particles/modules/ColorOverSpeed.d.ts +27 -0
- package/dist/esm/particles/modules/ColorOverSpeed.js +86 -0
- package/dist/esm/particles/modules/ColorOverSpeed.js.map +1 -0
- package/dist/esm/particles/modules/DeathModule.d.ts +24 -0
- package/dist/esm/particles/modules/DeathModule.js +25 -0
- package/dist/esm/particles/modules/DeathModule.js.map +1 -0
- package/dist/esm/particles/modules/Drag.d.ts +20 -0
- package/dist/esm/particles/modules/Drag.js +43 -0
- package/dist/esm/particles/modules/Drag.js.map +1 -0
- package/dist/esm/particles/modules/OrbitalForce.d.ts +28 -0
- package/dist/esm/particles/modules/OrbitalForce.js +65 -0
- package/dist/esm/particles/modules/OrbitalForce.js.map +1 -0
- package/dist/esm/particles/modules/RateSpawn.d.ts +41 -0
- package/dist/esm/particles/modules/RateSpawn.js +76 -0
- package/dist/esm/particles/modules/RateSpawn.js.map +1 -0
- package/dist/esm/particles/modules/RepelFromPoint.d.ts +24 -0
- package/dist/esm/particles/modules/RepelFromPoint.js +76 -0
- package/dist/esm/particles/modules/RepelFromPoint.js.map +1 -0
- package/dist/esm/particles/modules/RotateOverLifetime.d.ts +20 -0
- package/dist/esm/particles/modules/RotateOverLifetime.js +41 -0
- package/dist/esm/particles/modules/RotateOverLifetime.js.map +1 -0
- package/dist/esm/particles/modules/ScaleOverLifetime.d.ts +26 -0
- package/dist/esm/particles/modules/ScaleOverLifetime.js +59 -0
- package/dist/esm/particles/modules/ScaleOverLifetime.js.map +1 -0
- package/dist/esm/particles/modules/SpawnModule.d.ts +30 -0
- package/dist/esm/particles/modules/SpawnModule.js +31 -0
- package/dist/esm/particles/modules/SpawnModule.js.map +1 -0
- package/dist/esm/particles/modules/SpawnOnDeath.d.ts +24 -0
- package/dist/esm/particles/modules/SpawnOnDeath.js +47 -0
- package/dist/esm/particles/modules/SpawnOnDeath.js.map +1 -0
- package/dist/esm/particles/modules/Turbulence.d.ts +30 -0
- package/dist/esm/particles/modules/Turbulence.js +122 -0
- package/dist/esm/particles/modules/Turbulence.js.map +1 -0
- package/dist/esm/particles/modules/UpdateModule.d.ts +95 -0
- package/dist/esm/particles/modules/UpdateModule.js +66 -0
- package/dist/esm/particles/modules/UpdateModule.js.map +1 -0
- package/dist/esm/particles/modules/VelocityOverLifetime.d.ts +30 -0
- package/dist/esm/particles/modules/VelocityOverLifetime.js +84 -0
- package/dist/esm/particles/modules/VelocityOverLifetime.js.map +1 -0
- package/dist/esm/particles/modules/WgslContribution.d.ts +81 -0
- package/dist/esm/particles/modules/WgslContribution.js +34 -0
- package/dist/esm/particles/modules/WgslContribution.js.map +1 -0
- package/dist/esm/particles/modules/index.d.ts +22 -0
- package/dist/esm/rendering/CallbackRenderPass.js.map +1 -1
- package/dist/esm/rendering/Container.d.ts +2 -2
- package/dist/esm/rendering/Container.js +10 -11
- package/dist/esm/rendering/Container.js.map +1 -1
- package/dist/esm/rendering/Drawable.js.map +1 -1
- package/dist/esm/rendering/RenderBackend.d.ts +6 -6
- package/dist/esm/rendering/RenderBackendType.js.map +1 -1
- package/dist/esm/rendering/RenderNode.d.ts +10 -10
- package/dist/esm/rendering/RenderNode.js +31 -31
- package/dist/esm/rendering/RenderNode.js.map +1 -1
- package/dist/esm/rendering/RenderStats.js.map +1 -1
- package/dist/esm/rendering/RenderTarget.d.ts +2 -2
- package/dist/esm/rendering/RenderTarget.js +5 -5
- package/dist/esm/rendering/RenderTarget.js.map +1 -1
- package/dist/esm/rendering/RenderTargetPass.d.ts +3 -3
- package/dist/esm/rendering/RenderTargetPass.js.map +1 -1
- package/dist/esm/rendering/Renderer.d.ts +2 -2
- package/dist/esm/rendering/RendererRegistry.d.ts +3 -3
- package/dist/esm/rendering/RendererRegistry.js +2 -3
- package/dist/esm/rendering/RendererRegistry.js.map +1 -1
- package/dist/esm/rendering/View.d.ts +3 -3
- package/dist/esm/rendering/View.js +17 -20
- package/dist/esm/rendering/View.js.map +1 -1
- package/dist/esm/rendering/filters/BlurFilter.d.ts +1 -1
- package/dist/esm/rendering/filters/BlurFilter.js +4 -9
- package/dist/esm/rendering/filters/BlurFilter.js.map +1 -1
- package/dist/esm/rendering/filters/ColorFilter.d.ts +1 -1
- package/dist/esm/rendering/filters/ColorFilter.js +3 -9
- package/dist/esm/rendering/filters/ColorFilter.js.map +1 -1
- package/dist/esm/rendering/filters/Filter.d.ts +1 -1
- package/dist/esm/rendering/filters/Filter.js.map +1 -1
- package/dist/esm/rendering/filters/LutFilter.d.ts +87 -0
- package/dist/esm/rendering/filters/LutFilter.js +261 -0
- package/dist/esm/rendering/filters/LutFilter.js.map +1 -0
- package/dist/esm/rendering/filters/WebGl2ShaderFilter.d.ts +2 -2
- package/dist/esm/rendering/filters/WebGl2ShaderFilter.js +7 -14
- package/dist/esm/rendering/filters/WebGl2ShaderFilter.js.map +1 -1
- package/dist/esm/rendering/filters/WebGpuShaderFilter.d.ts +1 -1
- package/dist/esm/rendering/filters/WebGpuShaderFilter.js +11 -10
- package/dist/esm/rendering/filters/WebGpuShaderFilter.js.map +1 -1
- package/dist/esm/rendering/index.d.ts +28 -27
- package/dist/esm/rendering/mesh/Mesh.d.ts +49 -1
- package/dist/esm/rendering/mesh/Mesh.js +3 -1
- package/dist/esm/rendering/mesh/Mesh.js.map +1 -1
- package/dist/esm/rendering/primitives/Graphics.d.ts +3 -3
- package/dist/esm/rendering/primitives/Graphics.js +12 -12
- package/dist/esm/rendering/primitives/Graphics.js.map +1 -1
- package/dist/esm/rendering/shader/Shader.js.map +1 -1
- package/dist/esm/rendering/shader/ShaderAttribute.js.map +1 -1
- package/dist/esm/rendering/shader/ShaderUniform.js.map +1 -1
- package/dist/esm/rendering/shader/upgradeFragmentShaderToGl300.js +6 -8
- package/dist/esm/rendering/shader/upgradeFragmentShaderToGl300.js.map +1 -1
- package/dist/esm/rendering/sprite/AnimatedSprite.d.ts +3 -3
- package/dist/esm/rendering/sprite/AnimatedSprite.js.map +1 -1
- package/dist/esm/rendering/sprite/Sprite.d.ts +4 -4
- package/dist/esm/rendering/sprite/Sprite.js +51 -35
- package/dist/esm/rendering/sprite/Sprite.js.map +1 -1
- package/dist/esm/rendering/sprite/Spritesheet.d.ts +5 -9
- package/dist/esm/rendering/sprite/Spritesheet.js +1 -1
- package/dist/esm/rendering/sprite/Spritesheet.js.map +1 -1
- package/dist/esm/rendering/text/DynamicGlyphAtlas.js +3 -9
- package/dist/esm/rendering/text/DynamicGlyphAtlas.js.map +1 -1
- package/dist/esm/rendering/text/Text.js +9 -9
- package/dist/esm/rendering/text/Text.js.map +1 -1
- package/dist/esm/rendering/text/TextLayout.d.ts +2 -2
- package/dist/esm/rendering/text/TextLayout.js.map +1 -1
- package/dist/esm/rendering/text/TextStyle.js.map +1 -1
- package/dist/esm/rendering/text/atlas-singleton.js.map +1 -1
- package/dist/esm/rendering/texture/RenderTexture.d.ts +1 -1
- package/dist/esm/rendering/texture/RenderTexture.js +4 -1
- package/dist/esm/rendering/texture/RenderTexture.js.map +1 -1
- package/dist/esm/rendering/texture/Sampler.js.map +1 -1
- package/dist/esm/rendering/texture/Texture.d.ts +2 -2
- package/dist/esm/rendering/texture/Texture.js +8 -5
- package/dist/esm/rendering/texture/Texture.js.map +1 -1
- package/dist/esm/rendering/types.js.map +1 -1
- package/dist/esm/rendering/utils.js.map +1 -1
- package/dist/esm/rendering/video/Video.d.ts +3 -3
- package/dist/esm/rendering/video/Video.js +7 -6
- package/dist/esm/rendering/video/Video.js.map +1 -1
- package/dist/esm/rendering/webgl2/AbstractWebGl2BatchedRenderer.d.ts +6 -6
- package/dist/esm/rendering/webgl2/AbstractWebGl2BatchedRenderer.js +7 -10
- package/dist/esm/rendering/webgl2/AbstractWebGl2BatchedRenderer.js.map +1 -1
- package/dist/esm/rendering/webgl2/AbstractWebGl2Renderer.d.ts +1 -1
- package/dist/esm/rendering/webgl2/AbstractWebGl2Renderer.js +1 -2
- package/dist/esm/rendering/webgl2/AbstractWebGl2Renderer.js.map +1 -1
- package/dist/esm/rendering/webgl2/WebGl2Backend.d.ts +11 -11
- package/dist/esm/rendering/webgl2/WebGl2Backend.js +19 -21
- package/dist/esm/rendering/webgl2/WebGl2Backend.js.map +1 -1
- package/dist/esm/rendering/webgl2/WebGl2MaskCompositor.d.ts +2 -2
- package/dist/esm/rendering/webgl2/WebGl2MaskCompositor.js +6 -8
- package/dist/esm/rendering/webgl2/WebGl2MaskCompositor.js.map +1 -1
- package/dist/esm/rendering/webgl2/WebGl2MeshRenderer.d.ts +7 -4
- package/dist/esm/rendering/webgl2/WebGl2MeshRenderer.js +110 -43
- package/dist/esm/rendering/webgl2/WebGl2MeshRenderer.js.map +1 -1
- package/dist/esm/rendering/webgl2/WebGl2ParticleRenderer.d.ts +10 -15
- package/dist/esm/rendering/webgl2/WebGl2ParticleRenderer.js +100 -79
- package/dist/esm/rendering/webgl2/WebGl2ParticleRenderer.js.map +1 -1
- package/dist/esm/rendering/webgl2/WebGl2RenderBuffer.d.ts +1 -1
- package/dist/esm/rendering/webgl2/WebGl2RenderBuffer.js.map +1 -1
- package/dist/esm/rendering/webgl2/WebGl2ShaderBlock.js.map +1 -1
- package/dist/esm/rendering/webgl2/WebGl2ShaderMappings.js.map +1 -1
- package/dist/esm/rendering/webgl2/WebGl2ShaderProgram.js +54 -22
- package/dist/esm/rendering/webgl2/WebGl2ShaderProgram.js.map +1 -1
- package/dist/esm/rendering/webgl2/WebGl2SpriteRenderer.d.ts +1 -1
- package/dist/esm/rendering/webgl2/WebGl2SpriteRenderer.js +11 -14
- package/dist/esm/rendering/webgl2/WebGl2SpriteRenderer.js.map +1 -1
- package/dist/esm/rendering/webgl2/WebGl2VertexArrayObject.d.ts +1 -1
- package/dist/esm/rendering/webgl2/WebGl2VertexArrayObject.js.map +1 -1
- package/dist/esm/rendering/webgl2/glsl/particle.vert.js +1 -1
- package/dist/esm/rendering/webgpu/AbstractWebGpuRenderer.d.ts +1 -1
- package/dist/esm/rendering/webgpu/AbstractWebGpuRenderer.js +1 -2
- package/dist/esm/rendering/webgpu/AbstractWebGpuRenderer.js.map +1 -1
- package/dist/esm/rendering/webgpu/WebGpuBackend.d.ts +7 -7
- package/dist/esm/rendering/webgpu/WebGpuBackend.js +44 -30
- package/dist/esm/rendering/webgpu/WebGpuBackend.js.map +1 -1
- package/dist/esm/rendering/webgpu/WebGpuBlendState.js.map +1 -1
- package/dist/esm/rendering/webgpu/WebGpuMaskCompositor.d.ts +2 -2
- package/dist/esm/rendering/webgpu/WebGpuMaskCompositor.js +1 -3
- package/dist/esm/rendering/webgpu/WebGpuMaskCompositor.js.map +1 -1
- package/dist/esm/rendering/webgpu/WebGpuMeshRenderer.d.ts +2 -2
- package/dist/esm/rendering/webgpu/WebGpuMeshRenderer.js +25 -23
- package/dist/esm/rendering/webgpu/WebGpuMeshRenderer.js.map +1 -1
- package/dist/esm/rendering/webgpu/WebGpuParticleRenderer.d.ts +10 -1
- package/dist/esm/rendering/webgpu/WebGpuParticleRenderer.js +204 -76
- package/dist/esm/rendering/webgpu/WebGpuParticleRenderer.js.map +1 -1
- package/dist/esm/rendering/webgpu/WebGpuSpriteRenderer.d.ts +2 -2
- package/dist/esm/rendering/webgpu/WebGpuSpriteRenderer.js +45 -45
- package/dist/esm/rendering/webgpu/WebGpuSpriteRenderer.js.map +1 -1
- package/dist/esm/rendering/webgpu/compute/WebGpuComputePipeline.d.ts +52 -0
- package/dist/esm/rendering/webgpu/compute/WebGpuStorageBuffer.d.ts +29 -0
- package/dist/esm/rendering/webgpu/compute/index.d.ts +3 -0
- package/dist/esm/resources/AbstractAssetFactory.d.ts +1 -1
- package/dist/esm/resources/AbstractAssetFactory.js.map +1 -1
- package/dist/esm/resources/AssetManifest.d.ts +1 -1
- package/dist/esm/resources/AssetManifest.js +2 -2
- package/dist/esm/resources/AssetManifest.js.map +1 -1
- package/dist/esm/resources/CacheFirstStrategy.d.ts +2 -2
- package/dist/esm/resources/CacheFirstStrategy.js.map +1 -1
- package/dist/esm/resources/CacheStrategy.d.ts +1 -1
- package/dist/esm/resources/FactoryRegistry.d.ts +1 -1
- package/dist/esm/resources/FactoryRegistry.js +2 -3
- package/dist/esm/resources/FactoryRegistry.js.map +1 -1
- package/dist/esm/resources/IndexedDbDatabase.d.ts +1 -1
- package/dist/esm/resources/IndexedDbDatabase.js +11 -14
- package/dist/esm/resources/IndexedDbDatabase.js.map +1 -1
- package/dist/esm/resources/IndexedDbStore.d.ts +1 -1
- package/dist/esm/resources/IndexedDbStore.js +2 -7
- package/dist/esm/resources/IndexedDbStore.js.map +1 -1
- package/dist/esm/resources/Loader.d.ts +9 -9
- package/dist/esm/resources/Loader.js +48 -35
- package/dist/esm/resources/Loader.js.map +1 -1
- package/dist/esm/resources/NetworkOnlyStrategy.d.ts +2 -2
- package/dist/esm/resources/NetworkOnlyStrategy.js.map +1 -1
- package/dist/esm/resources/factories/BinaryFactory.js.map +1 -1
- package/dist/esm/resources/factories/FontFactory.js +1 -1
- package/dist/esm/resources/factories/FontFactory.js.map +1 -1
- package/dist/esm/resources/factories/ImageFactory.js +4 -4
- package/dist/esm/resources/factories/ImageFactory.js.map +1 -1
- package/dist/esm/resources/factories/JsonFactory.d.ts +1 -1
- package/dist/esm/resources/factories/JsonFactory.js +1 -1
- package/dist/esm/resources/factories/JsonFactory.js.map +1 -1
- package/dist/esm/resources/factories/MusicFactory.d.ts +1 -1
- package/dist/esm/resources/factories/MusicFactory.js +4 -4
- package/dist/esm/resources/factories/MusicFactory.js.map +1 -1
- package/dist/esm/resources/factories/SoundFactory.d.ts +1 -1
- package/dist/esm/resources/factories/SoundFactory.js +3 -3
- package/dist/esm/resources/factories/SoundFactory.js.map +1 -1
- package/dist/esm/resources/factories/SvgFactory.js +3 -3
- package/dist/esm/resources/factories/SvgFactory.js.map +1 -1
- package/dist/esm/resources/factories/TextFactory.js +1 -1
- package/dist/esm/resources/factories/TextFactory.js.map +1 -1
- package/dist/esm/resources/factories/TextureFactory.d.ts +1 -1
- package/dist/esm/resources/factories/TextureFactory.js +3 -3
- package/dist/esm/resources/factories/TextureFactory.js.map +1 -1
- package/dist/esm/resources/factories/VideoFactory.d.ts +2 -2
- package/dist/esm/resources/factories/VideoFactory.js +5 -5
- package/dist/esm/resources/factories/VideoFactory.js.map +1 -1
- package/dist/esm/resources/factories/VttFactory.d.ts +2 -2
- package/dist/esm/resources/factories/VttFactory.js +6 -6
- package/dist/esm/resources/factories/VttFactory.js.map +1 -1
- package/dist/esm/resources/factories/WasmFactory.js.map +1 -1
- package/dist/esm/resources/index.d.ts +11 -11
- package/dist/esm/resources/utils.js +30 -25
- package/dist/esm/resources/utils.js.map +1 -1
- package/dist/exo.esm.js +26438 -23869
- package/dist/exo.esm.js.map +1 -1
- package/package.json +15 -4
- package/dist/esm/particles/Particle.d.ts +0 -77
- package/dist/esm/particles/Particle.js +0 -143
- package/dist/esm/particles/Particle.js.map +0 -1
- package/dist/esm/particles/ParticleProperties.d.ts +0 -29
- package/dist/esm/particles/affectors/ColorAffector.d.ts +0 -30
- package/dist/esm/particles/affectors/ColorAffector.js +0 -55
- package/dist/esm/particles/affectors/ColorAffector.js.map +0 -1
- package/dist/esm/particles/affectors/ForceAffector.d.ts +0 -24
- package/dist/esm/particles/affectors/ForceAffector.js +0 -39
- package/dist/esm/particles/affectors/ForceAffector.js.map +0 -1
- package/dist/esm/particles/affectors/ParticleAffector.d.ts +0 -19
- package/dist/esm/particles/affectors/ScaleAffector.d.ts +0 -23
- package/dist/esm/particles/affectors/ScaleAffector.js +0 -38
- package/dist/esm/particles/affectors/ScaleAffector.js.map +0 -1
- package/dist/esm/particles/affectors/TorqueAffector.d.ts +0 -23
- package/dist/esm/particles/affectors/TorqueAffector.js +0 -37
- package/dist/esm/particles/affectors/TorqueAffector.js.map +0 -1
- package/dist/esm/particles/emitters/ParticleEmitter.d.ts +0 -19
- package/dist/esm/particles/emitters/ParticleOptions.d.ts +0 -62
- package/dist/esm/particles/emitters/ParticleOptions.js +0 -120
- package/dist/esm/particles/emitters/ParticleOptions.js.map +0 -1
- package/dist/esm/particles/emitters/UniversalEmitter.d.ts +0 -40
- package/dist/esm/particles/emitters/UniversalEmitter.js +0 -68
- package/dist/esm/particles/emitters/UniversalEmitter.js.map +0 -1
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Uniform random number in `[min, max]`. Each `sample()` returns a fresh
|
|
3
|
+
* roll; the bounds are inclusive on both ends (modulo the rounding bias
|
|
4
|
+
* inherent to `Math.random()`).
|
|
5
|
+
*/
|
|
6
|
+
class Range {
|
|
7
|
+
min;
|
|
8
|
+
max;
|
|
9
|
+
constructor(min, max) {
|
|
10
|
+
this.min = min;
|
|
11
|
+
this.max = max;
|
|
12
|
+
}
|
|
13
|
+
sample() {
|
|
14
|
+
return this.min + Math.random() * (this.max - this.min);
|
|
15
|
+
}
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
export { Range };
|
|
19
|
+
//# sourceMappingURL=Range.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Range.js","sources":["../../../../../src/particles/distributions/Range.ts"],"sourcesContent":[null],"names":[],"mappings":"AAEA;;;;AAIG;MACU,KAAK,CAAA;AAEP,IAAA,GAAA;AACA,IAAA,GAAA;IAFT,WAAA,CACS,GAAW,EACX,GAAW,EAAA;QADX,IAAA,CAAA,GAAG,GAAH,GAAG;QACH,IAAA,CAAA,GAAG,GAAH,GAAG;IACT;IAEI,MAAM,GAAA;AACX,QAAA,OAAO,IAAI,CAAC,GAAG,GAAG,IAAI,CAAC,MAAM,EAAE,IAAI,IAAI,CAAC,GAAG,GAAG,IAAI,CAAC,GAAG,CAAC;IACzD;AACD;;;;"}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { Vector } from '@/math/Vector';
|
|
2
|
+
import type { Distribution } from './Distribution';
|
|
3
|
+
/**
|
|
4
|
+
* Uniform random vector with each axis sampled independently in its own
|
|
5
|
+
* `[min, max]` range. Each `sample()` writes into the provided `out` Vector
|
|
6
|
+
* (or an internal scratch instance when `out` is omitted).
|
|
7
|
+
*
|
|
8
|
+
* @example
|
|
9
|
+
* const knockback = new VectorRange(-300, 300, -800, -200); // any X, upward Y
|
|
10
|
+
* knockback.sample(particle.velocity); // writes into existing instance, no alloc
|
|
11
|
+
*/
|
|
12
|
+
export declare class VectorRange implements Distribution<Vector> {
|
|
13
|
+
minX: number;
|
|
14
|
+
maxX: number;
|
|
15
|
+
minY: number;
|
|
16
|
+
maxY: number;
|
|
17
|
+
private readonly _scratch;
|
|
18
|
+
constructor(minX: number, maxX: number, minY: number, maxY: number);
|
|
19
|
+
sample(out?: Vector): Vector;
|
|
20
|
+
}
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import { Vector } from '../../math/Vector.js';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Uniform random vector with each axis sampled independently in its own
|
|
5
|
+
* `[min, max]` range. Each `sample()` writes into the provided `out` Vector
|
|
6
|
+
* (or an internal scratch instance when `out` is omitted).
|
|
7
|
+
*
|
|
8
|
+
* @example
|
|
9
|
+
* const knockback = new VectorRange(-300, 300, -800, -200); // any X, upward Y
|
|
10
|
+
* knockback.sample(particle.velocity); // writes into existing instance, no alloc
|
|
11
|
+
*/
|
|
12
|
+
class VectorRange {
|
|
13
|
+
minX;
|
|
14
|
+
maxX;
|
|
15
|
+
minY;
|
|
16
|
+
maxY;
|
|
17
|
+
_scratch = new Vector();
|
|
18
|
+
constructor(minX, maxX, minY, maxY) {
|
|
19
|
+
this.minX = minX;
|
|
20
|
+
this.maxX = maxX;
|
|
21
|
+
this.minY = minY;
|
|
22
|
+
this.maxY = maxY;
|
|
23
|
+
}
|
|
24
|
+
sample(out = this._scratch) {
|
|
25
|
+
out.set(this.minX + Math.random() * (this.maxX - this.minX), this.minY + Math.random() * (this.maxY - this.minY));
|
|
26
|
+
return out;
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
export { VectorRange };
|
|
31
|
+
//# sourceMappingURL=VectorRange.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"VectorRange.js","sources":["../../../../../src/particles/distributions/VectorRange.ts"],"sourcesContent":[null],"names":[],"mappings":";;AAIA;;;;;;;;AAQG;MACU,WAAW,CAAA;AAIb,IAAA,IAAA;AACA,IAAA,IAAA;AACA,IAAA,IAAA;AACA,IAAA,IAAA;AANQ,IAAA,QAAQ,GAAG,IAAI,MAAM,EAAE;AAExC,IAAA,WAAA,CACS,IAAY,EACZ,IAAY,EACZ,IAAY,EACZ,IAAY,EAAA;QAHZ,IAAA,CAAA,IAAI,GAAJ,IAAI;QACJ,IAAA,CAAA,IAAI,GAAJ,IAAI;QACJ,IAAA,CAAA,IAAI,GAAJ,IAAI;QACJ,IAAA,CAAA,IAAI,GAAJ,IAAI;IACV;AAEI,IAAA,MAAM,CAAC,GAAA,GAAc,IAAI,CAAC,QAAQ,EAAA;AACvC,QAAA,GAAG,CAAC,GAAG,CAAC,IAAI,CAAC,IAAI,GAAG,IAAI,CAAC,MAAM,EAAE,IAAI,IAAI,CAAC,IAAI,GAAG,IAAI,CAAC,IAAI,CAAC,EAAE,IAAI,CAAC,IAAI,GAAG,IAAI,CAAC,MAAM,EAAE,IAAI,IAAI,CAAC,IAAI,GAAG,IAAI,CAAC,IAAI,CAAC,CAAC;AAEjH,QAAA,OAAO,GAAG;IACZ;AACD;;;;"}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
export { BoxArea } from './BoxArea';
|
|
2
|
+
export { CircleArea } from './CircleArea';
|
|
3
|
+
export { ConeDirection } from './ConeDirection';
|
|
4
|
+
export { Constant } from './Constant';
|
|
5
|
+
export type { CurveKey } from './Curve';
|
|
6
|
+
export { Curve } from './Curve';
|
|
7
|
+
export type { Distribution, LifetimeFunction } from './Distribution';
|
|
8
|
+
export type { GradientKey } from './Gradient';
|
|
9
|
+
export { Gradient } from './Gradient';
|
|
10
|
+
export { LineSegment } from './LineSegment';
|
|
11
|
+
export { Range } from './Range';
|
|
12
|
+
export { VectorRange } from './VectorRange';
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
import type { Rectangle } from '@/math/Rectangle';
|
|
2
|
+
import type { UpdateModule } from '@/particles/modules/UpdateModule';
|
|
3
|
+
import type { ParticleSystem } from '@/particles/ParticleSystem';
|
|
4
|
+
import type { Texture } from '@/rendering/texture/Texture';
|
|
5
|
+
export declare class ParticleGpuState {
|
|
6
|
+
readonly device: GPUDevice;
|
|
7
|
+
readonly capacity: number;
|
|
8
|
+
/** GPU buffer holding interleaved per-instance vertex data, written by compute, read as VERTEX by the renderer. */
|
|
9
|
+
readonly instanceBuffer: GPUBuffer;
|
|
10
|
+
private readonly _positions;
|
|
11
|
+
private readonly _velocities;
|
|
12
|
+
private readonly _scales;
|
|
13
|
+
private readonly _rotInfo;
|
|
14
|
+
private readonly _timing;
|
|
15
|
+
private readonly _color;
|
|
16
|
+
private readonly _textureIndex;
|
|
17
|
+
private readonly _simUniformBuffer;
|
|
18
|
+
private readonly _simUniformData;
|
|
19
|
+
private readonly _simUniformView;
|
|
20
|
+
private readonly _moduleUniformBuffer;
|
|
21
|
+
private readonly _moduleUniformData;
|
|
22
|
+
private readonly _moduleUniformView;
|
|
23
|
+
private readonly _moduleSlots;
|
|
24
|
+
private readonly _framesUniformBuffer;
|
|
25
|
+
private readonly _framesUniformData;
|
|
26
|
+
private readonly _framesUniformView;
|
|
27
|
+
private readonly _frameCount;
|
|
28
|
+
private readonly _moduleTextures;
|
|
29
|
+
private readonly _samplerFiltering;
|
|
30
|
+
private readonly _samplerNonFiltering;
|
|
31
|
+
private readonly _pipeline;
|
|
32
|
+
private readonly _bindGroup0;
|
|
33
|
+
private readonly _bindGroup1;
|
|
34
|
+
constructor(device: GPUDevice, capacity: number, modules: readonly UpdateModule[], frames: readonly Rectangle[], texture: Texture);
|
|
35
|
+
dispatch(system: ParticleSystem, dt: number): void;
|
|
36
|
+
destroy(): void;
|
|
37
|
+
private _writeFrames;
|
|
38
|
+
/**
|
|
39
|
+
* Push the listed CPU SoA slots to the GPU. Called by `ParticleSystem`
|
|
40
|
+
* with newly-spawned slots and just-expired slots (lifetime sentinel).
|
|
41
|
+
* Slots not in the dirty set are left alone — GPU keeps the integrated
|
|
42
|
+
* state from previous compute dispatches.
|
|
43
|
+
*
|
|
44
|
+
* Each dirty slot triggers 7 small `queue.writeBuffer` calls (one per
|
|
45
|
+
* SoA channel). For typical spawn rates (≤200/s) this is negligible
|
|
46
|
+
* (≤1400 calls/s); contiguous-range batching is a future optimisation.
|
|
47
|
+
*/
|
|
48
|
+
uploadDirty(system: ParticleSystem, slots: Iterable<number>): void;
|
|
49
|
+
private readonly _dirtyScratchVec2;
|
|
50
|
+
private readonly _dirtyScratchU32;
|
|
51
|
+
private _writeSimUniforms;
|
|
52
|
+
private _writeModuleUniforms;
|
|
53
|
+
private _buildBindGroup0Layout;
|
|
54
|
+
private _buildBindGroup0;
|
|
55
|
+
private _buildShader;
|
|
56
|
+
private _renderModuleStruct;
|
|
57
|
+
}
|
|
@@ -0,0 +1,535 @@
|
|
|
1
|
+
import { wgslUniformByteSize } from '../modules/WgslContribution.js';
|
|
2
|
+
|
|
3
|
+
/// <reference types="@webgpu/types" />
|
|
4
|
+
/**
|
|
5
|
+
* GPU-side mirror of one {@link ParticleSystem}. Owns:
|
|
6
|
+
*
|
|
7
|
+
* - **8 packed storage buffers** for the per-particle SoA data:
|
|
8
|
+
* positions/velocities/scales/rotInfo/timing as `vec2<f32>`, color and
|
|
9
|
+
* textureIndex as `u32`, plus the instance output buffer. Sits at the
|
|
10
|
+
* default WebGPU `maxStorageBuffersPerShaderStage = 8` limit.
|
|
11
|
+
* - **One uniform buffer** for sim state (`dt`, `liveCount`).
|
|
12
|
+
* - **One uniform buffer** for module configs (concatenated per-module
|
|
13
|
+
* structs with WGSL std140-ish alignment).
|
|
14
|
+
* - **One uniform buffer** for frame UVs — `array<vec4<f32>, N>` where N
|
|
15
|
+
* is the system's frame count (or 1 when no atlas is declared). Each
|
|
16
|
+
* vec4 is `(uvMinX, uvMinY, uvMaxX, uvMaxY)` already flipY-adjusted.
|
|
17
|
+
* - **N 1D textures** for modules that use lookup tables (Curve / Gradient).
|
|
18
|
+
* - **Composite compute pipeline** built once at construction by
|
|
19
|
+
* concatenating the integration step + every registered module body +
|
|
20
|
+
* the pack-instances step into a single shader.
|
|
21
|
+
*
|
|
22
|
+
* The compute shader's pack-instances step reads `textureIndex[i]`, looks
|
|
23
|
+
* up the matching frame UV, and writes a 40-byte interleaved record into
|
|
24
|
+
* the instance output buffer (`STORAGE | VERTEX`). The renderer binds that
|
|
25
|
+
* buffer directly as instanced vertex source — no readback.
|
|
26
|
+
*/
|
|
27
|
+
const workgroupSize = 64;
|
|
28
|
+
const instanceBytes = 40; // 5 × f32 + 1 × u32 + 4 × f32 (uvMin.xy, uvMax.xy)
|
|
29
|
+
class ParticleGpuState {
|
|
30
|
+
device;
|
|
31
|
+
capacity;
|
|
32
|
+
/** GPU buffer holding interleaved per-instance vertex data, written by compute, read as VERTEX by the renderer. */
|
|
33
|
+
instanceBuffer;
|
|
34
|
+
_positions;
|
|
35
|
+
_velocities;
|
|
36
|
+
_scales;
|
|
37
|
+
_rotInfo;
|
|
38
|
+
_timing;
|
|
39
|
+
_color;
|
|
40
|
+
_textureIndex;
|
|
41
|
+
_simUniformBuffer;
|
|
42
|
+
_simUniformData = new ArrayBuffer(16);
|
|
43
|
+
_simUniformView;
|
|
44
|
+
_moduleUniformBuffer;
|
|
45
|
+
_moduleUniformData;
|
|
46
|
+
_moduleUniformView;
|
|
47
|
+
_moduleSlots;
|
|
48
|
+
_framesUniformBuffer;
|
|
49
|
+
_framesUniformData;
|
|
50
|
+
_framesUniformView;
|
|
51
|
+
_frameCount;
|
|
52
|
+
_moduleTextures = new Map();
|
|
53
|
+
_samplerFiltering;
|
|
54
|
+
_samplerNonFiltering;
|
|
55
|
+
_pipeline;
|
|
56
|
+
_bindGroup0;
|
|
57
|
+
_bindGroup1;
|
|
58
|
+
constructor(device, capacity, modules, frames, texture) {
|
|
59
|
+
this.device = device;
|
|
60
|
+
this.capacity = capacity;
|
|
61
|
+
for (const m of modules) {
|
|
62
|
+
if (!m.wgsl) {
|
|
63
|
+
throw new Error(`ParticleGpuState: module ${m.constructor.name} has no wgsl() — ` + 'all registered UpdateModules must be GPU-eligible.');
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
// Module uniform layout.
|
|
67
|
+
const slots = [];
|
|
68
|
+
let uniformOffset = 0;
|
|
69
|
+
for (const m of modules) {
|
|
70
|
+
const c = m.wgsl();
|
|
71
|
+
const fields = c.uniforms ?? [];
|
|
72
|
+
const size = wgslUniformByteSize(fields);
|
|
73
|
+
uniformOffset = Math.ceil(uniformOffset / 16) * 16;
|
|
74
|
+
slots.push({
|
|
75
|
+
module: m,
|
|
76
|
+
contribution: c,
|
|
77
|
+
uniformByteOffset: uniformOffset,
|
|
78
|
+
uniformByteSize: size,
|
|
79
|
+
});
|
|
80
|
+
uniformOffset += size;
|
|
81
|
+
}
|
|
82
|
+
const totalUniformBytes = Math.max(16, Math.ceil(uniformOffset / 16) * 16);
|
|
83
|
+
this._moduleSlots = slots;
|
|
84
|
+
if (uniformOffset > 0) {
|
|
85
|
+
this._moduleUniformData = new ArrayBuffer(totalUniformBytes);
|
|
86
|
+
this._moduleUniformView = new DataView(this._moduleUniformData);
|
|
87
|
+
this._moduleUniformBuffer = device.createBuffer({
|
|
88
|
+
label: 'particle-module-uniforms',
|
|
89
|
+
size: totalUniformBytes,
|
|
90
|
+
usage: GPUBufferUsage.UNIFORM | GPUBufferUsage.COPY_DST,
|
|
91
|
+
});
|
|
92
|
+
}
|
|
93
|
+
else {
|
|
94
|
+
this._moduleUniformData = null;
|
|
95
|
+
this._moduleUniformView = null;
|
|
96
|
+
this._moduleUniformBuffer = null;
|
|
97
|
+
}
|
|
98
|
+
// Frames uniform buffer.
|
|
99
|
+
this._frameCount = Math.max(1, frames.length);
|
|
100
|
+
this._framesUniformData = new ArrayBuffer(this._frameCount * 16);
|
|
101
|
+
this._framesUniformView = new Float32Array(this._framesUniformData);
|
|
102
|
+
this._framesUniformBuffer = device.createBuffer({
|
|
103
|
+
label: 'particle-frames-uniforms',
|
|
104
|
+
size: this._framesUniformData.byteLength,
|
|
105
|
+
usage: GPUBufferUsage.UNIFORM | GPUBufferUsage.COPY_DST,
|
|
106
|
+
});
|
|
107
|
+
this._writeFrames(frames, texture);
|
|
108
|
+
const vec2Bytes = capacity * 8;
|
|
109
|
+
const u32Bytes = capacity * 4;
|
|
110
|
+
this._positions = device.createBuffer({
|
|
111
|
+
label: 'particle-positions',
|
|
112
|
+
size: vec2Bytes,
|
|
113
|
+
usage: GPUBufferUsage.STORAGE | GPUBufferUsage.COPY_DST,
|
|
114
|
+
});
|
|
115
|
+
this._velocities = device.createBuffer({
|
|
116
|
+
label: 'particle-velocities',
|
|
117
|
+
size: vec2Bytes,
|
|
118
|
+
usage: GPUBufferUsage.STORAGE | GPUBufferUsage.COPY_DST,
|
|
119
|
+
});
|
|
120
|
+
this._scales = device.createBuffer({
|
|
121
|
+
label: 'particle-scales',
|
|
122
|
+
size: vec2Bytes,
|
|
123
|
+
usage: GPUBufferUsage.STORAGE | GPUBufferUsage.COPY_DST,
|
|
124
|
+
});
|
|
125
|
+
this._rotInfo = device.createBuffer({
|
|
126
|
+
label: 'particle-rotInfo',
|
|
127
|
+
size: vec2Bytes,
|
|
128
|
+
usage: GPUBufferUsage.STORAGE | GPUBufferUsage.COPY_DST,
|
|
129
|
+
});
|
|
130
|
+
this._timing = device.createBuffer({
|
|
131
|
+
label: 'particle-timing',
|
|
132
|
+
size: vec2Bytes,
|
|
133
|
+
usage: GPUBufferUsage.STORAGE | GPUBufferUsage.COPY_DST,
|
|
134
|
+
});
|
|
135
|
+
this._color = device.createBuffer({
|
|
136
|
+
label: 'particle-color',
|
|
137
|
+
size: u32Bytes,
|
|
138
|
+
usage: GPUBufferUsage.STORAGE | GPUBufferUsage.COPY_DST,
|
|
139
|
+
});
|
|
140
|
+
this._textureIndex = device.createBuffer({
|
|
141
|
+
label: 'particle-textureIndex',
|
|
142
|
+
size: u32Bytes,
|
|
143
|
+
usage: GPUBufferUsage.STORAGE | GPUBufferUsage.COPY_DST,
|
|
144
|
+
});
|
|
145
|
+
this.instanceBuffer = device.createBuffer({
|
|
146
|
+
label: 'particle-instance-output',
|
|
147
|
+
size: capacity * instanceBytes,
|
|
148
|
+
usage: GPUBufferUsage.STORAGE | GPUBufferUsage.VERTEX | GPUBufferUsage.COPY_DST,
|
|
149
|
+
});
|
|
150
|
+
this._simUniformView = new DataView(this._simUniformData);
|
|
151
|
+
this._simUniformBuffer = device.createBuffer({
|
|
152
|
+
label: 'particle-sim-uniforms',
|
|
153
|
+
size: 16,
|
|
154
|
+
usage: GPUBufferUsage.UNIFORM | GPUBufferUsage.COPY_DST,
|
|
155
|
+
});
|
|
156
|
+
// r32float textures aren't filterable in core WebGPU (would require
|
|
157
|
+
// the optional `float32-filterable` feature). Use `nearest` for
|
|
158
|
+
// r32float curve LUTs (256 taps is fine without interpolation) and
|
|
159
|
+
// `linear` for rgba8unorm gradients which support filtering natively.
|
|
160
|
+
this._samplerFiltering = device.createSampler({
|
|
161
|
+
label: 'particle-lookup-sampler-filtering',
|
|
162
|
+
minFilter: 'linear',
|
|
163
|
+
magFilter: 'linear',
|
|
164
|
+
addressModeU: 'clamp-to-edge',
|
|
165
|
+
});
|
|
166
|
+
this._samplerNonFiltering = device.createSampler({
|
|
167
|
+
label: 'particle-lookup-sampler-non-filtering',
|
|
168
|
+
minFilter: 'nearest',
|
|
169
|
+
magFilter: 'nearest',
|
|
170
|
+
addressModeU: 'clamp-to-edge',
|
|
171
|
+
});
|
|
172
|
+
// Allocate textures for modules that need them.
|
|
173
|
+
for (const slot of slots) {
|
|
174
|
+
const c = slot.contribution;
|
|
175
|
+
if (!c.textures)
|
|
176
|
+
continue;
|
|
177
|
+
for (const t of c.textures) {
|
|
178
|
+
const tex = device.createTexture({
|
|
179
|
+
label: `particle-tex-${c.key}-${t.name}`,
|
|
180
|
+
size: { width: 256, height: 1, depthOrArrayLayers: 1 },
|
|
181
|
+
format: t.format,
|
|
182
|
+
usage: GPUTextureUsage.TEXTURE_BINDING | GPUTextureUsage.COPY_DST,
|
|
183
|
+
dimension: '1d',
|
|
184
|
+
});
|
|
185
|
+
this._moduleTextures.set(`${c.key}_${t.name}`, tex);
|
|
186
|
+
}
|
|
187
|
+
}
|
|
188
|
+
const wgsl = this._buildShader(slots);
|
|
189
|
+
const bindGroup0Layout = this._buildBindGroup0Layout(slots);
|
|
190
|
+
const bindGroup1Layout = device.createBindGroupLayout({
|
|
191
|
+
label: 'particle-soa-bgl',
|
|
192
|
+
entries: [
|
|
193
|
+
{ binding: 0, visibility: GPUShaderStage.COMPUTE, buffer: { type: 'storage' } },
|
|
194
|
+
{ binding: 1, visibility: GPUShaderStage.COMPUTE, buffer: { type: 'storage' } },
|
|
195
|
+
{ binding: 2, visibility: GPUShaderStage.COMPUTE, buffer: { type: 'storage' } },
|
|
196
|
+
{ binding: 3, visibility: GPUShaderStage.COMPUTE, buffer: { type: 'storage' } },
|
|
197
|
+
{ binding: 4, visibility: GPUShaderStage.COMPUTE, buffer: { type: 'storage' } },
|
|
198
|
+
{ binding: 5, visibility: GPUShaderStage.COMPUTE, buffer: { type: 'storage' } },
|
|
199
|
+
{ binding: 6, visibility: GPUShaderStage.COMPUTE, buffer: { type: 'read-only-storage' } }, // textureIndex (matches WGSL `var<storage, read>`)
|
|
200
|
+
{ binding: 7, visibility: GPUShaderStage.COMPUTE, buffer: { type: 'storage' } },
|
|
201
|
+
],
|
|
202
|
+
});
|
|
203
|
+
const pipelineLayout = device.createPipelineLayout({
|
|
204
|
+
label: 'particle-compute-layout',
|
|
205
|
+
bindGroupLayouts: [bindGroup0Layout, bindGroup1Layout],
|
|
206
|
+
});
|
|
207
|
+
const shaderModule = device.createShaderModule({
|
|
208
|
+
label: 'particle-compute-shader',
|
|
209
|
+
code: wgsl,
|
|
210
|
+
});
|
|
211
|
+
this._pipeline = device.createComputePipeline({
|
|
212
|
+
label: 'particle-compute-pipeline',
|
|
213
|
+
layout: pipelineLayout,
|
|
214
|
+
compute: {
|
|
215
|
+
module: shaderModule,
|
|
216
|
+
entryPoint: 'main',
|
|
217
|
+
},
|
|
218
|
+
});
|
|
219
|
+
this._bindGroup0 = this._buildBindGroup0(bindGroup0Layout, slots);
|
|
220
|
+
this._bindGroup1 = device.createBindGroup({
|
|
221
|
+
label: 'particle-soa-bg',
|
|
222
|
+
layout: bindGroup1Layout,
|
|
223
|
+
entries: [
|
|
224
|
+
{ binding: 0, resource: { buffer: this._positions } },
|
|
225
|
+
{ binding: 1, resource: { buffer: this._velocities } },
|
|
226
|
+
{ binding: 2, resource: { buffer: this._scales } },
|
|
227
|
+
{ binding: 3, resource: { buffer: this._rotInfo } },
|
|
228
|
+
{ binding: 4, resource: { buffer: this._timing } },
|
|
229
|
+
{ binding: 5, resource: { buffer: this._color } },
|
|
230
|
+
{ binding: 6, resource: { buffer: this._textureIndex } },
|
|
231
|
+
{ binding: 7, resource: { buffer: this.instanceBuffer } },
|
|
232
|
+
],
|
|
233
|
+
});
|
|
234
|
+
// Modules upload their lookup textures.
|
|
235
|
+
for (const slot of slots) {
|
|
236
|
+
if (!slot.module.uploadTextures)
|
|
237
|
+
continue;
|
|
238
|
+
const moduleTextures = new Map();
|
|
239
|
+
for (const t of slot.contribution.textures ?? []) {
|
|
240
|
+
const tex = this._moduleTextures.get(`${slot.contribution.key}_${t.name}`);
|
|
241
|
+
if (tex !== undefined) {
|
|
242
|
+
moduleTextures.set(t.name, tex);
|
|
243
|
+
}
|
|
244
|
+
}
|
|
245
|
+
slot.module.uploadTextures(device, moduleTextures);
|
|
246
|
+
}
|
|
247
|
+
}
|
|
248
|
+
dispatch(system, dt) {
|
|
249
|
+
const liveCount = system.liveCount;
|
|
250
|
+
if (liveCount <= 0) {
|
|
251
|
+
return;
|
|
252
|
+
}
|
|
253
|
+
this._writeSimUniforms(dt, liveCount);
|
|
254
|
+
this._writeModuleUniforms(dt);
|
|
255
|
+
const encoder = this.device.createCommandEncoder({ label: 'particle-compute' });
|
|
256
|
+
const pass = encoder.beginComputePass({ label: 'particle-compute-pass' });
|
|
257
|
+
pass.setPipeline(this._pipeline);
|
|
258
|
+
pass.setBindGroup(0, this._bindGroup0);
|
|
259
|
+
pass.setBindGroup(1, this._bindGroup1);
|
|
260
|
+
pass.dispatchWorkgroups(Math.ceil(liveCount / workgroupSize));
|
|
261
|
+
pass.end();
|
|
262
|
+
this.device.queue.submit([encoder.finish()]);
|
|
263
|
+
}
|
|
264
|
+
destroy() {
|
|
265
|
+
this._positions.destroy();
|
|
266
|
+
this._velocities.destroy();
|
|
267
|
+
this._scales.destroy();
|
|
268
|
+
this._rotInfo.destroy();
|
|
269
|
+
this._timing.destroy();
|
|
270
|
+
this._color.destroy();
|
|
271
|
+
this._textureIndex.destroy();
|
|
272
|
+
this.instanceBuffer.destroy();
|
|
273
|
+
this._simUniformBuffer.destroy();
|
|
274
|
+
this._framesUniformBuffer.destroy();
|
|
275
|
+
this._moduleUniformBuffer?.destroy();
|
|
276
|
+
for (const tex of this._moduleTextures.values()) {
|
|
277
|
+
tex.destroy();
|
|
278
|
+
}
|
|
279
|
+
this._moduleTextures.clear();
|
|
280
|
+
}
|
|
281
|
+
_writeFrames(frames, texture) {
|
|
282
|
+
const view = this._framesUniformView;
|
|
283
|
+
const w = texture.width;
|
|
284
|
+
const h = texture.height;
|
|
285
|
+
const flipY = texture.flipY;
|
|
286
|
+
if (frames.length === 0) {
|
|
287
|
+
// Single-frame fallback — full texture.
|
|
288
|
+
view[0] = 0;
|
|
289
|
+
view[1] = flipY ? 1 : 0;
|
|
290
|
+
view[2] = 1;
|
|
291
|
+
view[3] = flipY ? 0 : 1;
|
|
292
|
+
}
|
|
293
|
+
else {
|
|
294
|
+
for (let i = 0; i < frames.length; i++) {
|
|
295
|
+
const f = frames[i];
|
|
296
|
+
const o = i * 4;
|
|
297
|
+
const minU = f.left / w;
|
|
298
|
+
const maxU = f.right / w;
|
|
299
|
+
const topV = f.top / h;
|
|
300
|
+
const bottomV = f.bottom / h;
|
|
301
|
+
view[o + 0] = minU;
|
|
302
|
+
view[o + 1] = flipY ? bottomV : topV;
|
|
303
|
+
view[o + 2] = maxU;
|
|
304
|
+
view[o + 3] = flipY ? topV : bottomV;
|
|
305
|
+
}
|
|
306
|
+
}
|
|
307
|
+
this.device.queue.writeBuffer(this._framesUniformBuffer, 0, this._framesUniformData);
|
|
308
|
+
}
|
|
309
|
+
/**
|
|
310
|
+
* Push the listed CPU SoA slots to the GPU. Called by `ParticleSystem`
|
|
311
|
+
* with newly-spawned slots and just-expired slots (lifetime sentinel).
|
|
312
|
+
* Slots not in the dirty set are left alone — GPU keeps the integrated
|
|
313
|
+
* state from previous compute dispatches.
|
|
314
|
+
*
|
|
315
|
+
* Each dirty slot triggers 7 small `queue.writeBuffer` calls (one per
|
|
316
|
+
* SoA channel). For typical spawn rates (≤200/s) this is negligible
|
|
317
|
+
* (≤1400 calls/s); contiguous-range batching is a future optimisation.
|
|
318
|
+
*/
|
|
319
|
+
uploadDirty(system, slots) {
|
|
320
|
+
const queue = this.device.queue;
|
|
321
|
+
const scratch2 = this._dirtyScratchVec2;
|
|
322
|
+
const scratch1 = this._dirtyScratchU32;
|
|
323
|
+
for (const slot of slots) {
|
|
324
|
+
const byteOffset2 = slot * 8;
|
|
325
|
+
const byteOffset1 = slot * 4;
|
|
326
|
+
scratch2[0] = system.posX[slot];
|
|
327
|
+
scratch2[1] = system.posY[slot];
|
|
328
|
+
queue.writeBuffer(this._positions, byteOffset2, scratch2.buffer, 0, 8);
|
|
329
|
+
scratch2[0] = system.velX[slot];
|
|
330
|
+
scratch2[1] = system.velY[slot];
|
|
331
|
+
queue.writeBuffer(this._velocities, byteOffset2, scratch2.buffer, 0, 8);
|
|
332
|
+
scratch2[0] = system.scaleX[slot];
|
|
333
|
+
scratch2[1] = system.scaleY[slot];
|
|
334
|
+
queue.writeBuffer(this._scales, byteOffset2, scratch2.buffer, 0, 8);
|
|
335
|
+
scratch2[0] = system.rotations[slot];
|
|
336
|
+
scratch2[1] = system.rotationSpeeds[slot];
|
|
337
|
+
queue.writeBuffer(this._rotInfo, byteOffset2, scratch2.buffer, 0, 8);
|
|
338
|
+
scratch2[0] = system.elapsed[slot];
|
|
339
|
+
scratch2[1] = system.lifetime[slot];
|
|
340
|
+
queue.writeBuffer(this._timing, byteOffset2, scratch2.buffer, 0, 8);
|
|
341
|
+
scratch1[0] = system.color[slot];
|
|
342
|
+
queue.writeBuffer(this._color, byteOffset1, scratch1.buffer, 0, 4);
|
|
343
|
+
scratch1[0] = system.textureIndex[slot];
|
|
344
|
+
queue.writeBuffer(this._textureIndex, byteOffset1, scratch1.buffer, 0, 4);
|
|
345
|
+
}
|
|
346
|
+
}
|
|
347
|
+
_dirtyScratchVec2 = new Float32Array(2);
|
|
348
|
+
_dirtyScratchU32 = new Uint32Array(1);
|
|
349
|
+
_writeSimUniforms(dt, liveCount) {
|
|
350
|
+
this._simUniformView.setFloat32(0, dt, true);
|
|
351
|
+
this._simUniformView.setUint32(4, liveCount, true);
|
|
352
|
+
this.device.queue.writeBuffer(this._simUniformBuffer, 0, this._simUniformData);
|
|
353
|
+
}
|
|
354
|
+
_writeModuleUniforms(dt) {
|
|
355
|
+
if (this._moduleUniformView === null || this._moduleUniformBuffer === null || this._moduleUniformData === null) {
|
|
356
|
+
return;
|
|
357
|
+
}
|
|
358
|
+
for (const slot of this._moduleSlots) {
|
|
359
|
+
slot.module.writeUniforms?.(this._moduleUniformView, slot.uniformByteOffset, dt);
|
|
360
|
+
}
|
|
361
|
+
this.device.queue.writeBuffer(this._moduleUniformBuffer, 0, this._moduleUniformData);
|
|
362
|
+
}
|
|
363
|
+
_buildBindGroup0Layout(slots) {
|
|
364
|
+
const entries = [
|
|
365
|
+
{ binding: 0, visibility: GPUShaderStage.COMPUTE, buffer: { type: 'uniform' } },
|
|
366
|
+
{ binding: 1, visibility: GPUShaderStage.COMPUTE, buffer: { type: 'uniform' } },
|
|
367
|
+
];
|
|
368
|
+
if (this._moduleUniformBuffer !== null) {
|
|
369
|
+
entries.push({ binding: 2, visibility: GPUShaderStage.COMPUTE, buffer: { type: 'uniform' } });
|
|
370
|
+
}
|
|
371
|
+
let textureBindingIndex = this._moduleUniformBuffer !== null ? 3 : 2;
|
|
372
|
+
for (const slot of slots) {
|
|
373
|
+
for (const t of slot.contribution.textures ?? []) {
|
|
374
|
+
const filterable = t.format !== 'r32float';
|
|
375
|
+
entries.push({
|
|
376
|
+
binding: textureBindingIndex++,
|
|
377
|
+
visibility: GPUShaderStage.COMPUTE,
|
|
378
|
+
texture: {
|
|
379
|
+
viewDimension: '1d',
|
|
380
|
+
sampleType: filterable ? 'float' : 'unfilterable-float',
|
|
381
|
+
},
|
|
382
|
+
});
|
|
383
|
+
entries.push({
|
|
384
|
+
binding: textureBindingIndex++,
|
|
385
|
+
visibility: GPUShaderStage.COMPUTE,
|
|
386
|
+
sampler: { type: filterable ? 'filtering' : 'non-filtering' },
|
|
387
|
+
});
|
|
388
|
+
}
|
|
389
|
+
}
|
|
390
|
+
return this.device.createBindGroupLayout({ label: 'particle-uniforms-bgl', entries });
|
|
391
|
+
}
|
|
392
|
+
_buildBindGroup0(layout, slots) {
|
|
393
|
+
const entries = [
|
|
394
|
+
{ binding: 0, resource: { buffer: this._simUniformBuffer } },
|
|
395
|
+
{ binding: 1, resource: { buffer: this._framesUniformBuffer } },
|
|
396
|
+
];
|
|
397
|
+
if (this._moduleUniformBuffer !== null) {
|
|
398
|
+
entries.push({ binding: 2, resource: { buffer: this._moduleUniformBuffer } });
|
|
399
|
+
}
|
|
400
|
+
let textureBindingIndex = this._moduleUniformBuffer !== null ? 3 : 2;
|
|
401
|
+
for (const slot of slots) {
|
|
402
|
+
for (const t of slot.contribution.textures ?? []) {
|
|
403
|
+
const tex = this._moduleTextures.get(`${slot.contribution.key}_${t.name}`);
|
|
404
|
+
const filterable = t.format !== 'r32float';
|
|
405
|
+
const sampler = filterable ? this._samplerFiltering : this._samplerNonFiltering;
|
|
406
|
+
entries.push({ binding: textureBindingIndex++, resource: tex.createView({ dimension: '1d' }) });
|
|
407
|
+
entries.push({ binding: textureBindingIndex++, resource: sampler });
|
|
408
|
+
}
|
|
409
|
+
}
|
|
410
|
+
return this.device.createBindGroup({ label: 'particle-uniforms-bg', layout, entries });
|
|
411
|
+
}
|
|
412
|
+
_buildShader(slots) {
|
|
413
|
+
const sections = [];
|
|
414
|
+
sections.push(`
|
|
415
|
+
struct SimUniforms {
|
|
416
|
+
dt: f32,
|
|
417
|
+
liveCount: u32,
|
|
418
|
+
_pad0: u32,
|
|
419
|
+
_pad1: u32,
|
|
420
|
+
}
|
|
421
|
+
|
|
422
|
+
struct FrameUniforms {
|
|
423
|
+
frames: array<vec4<f32>, ${this._frameCount}>,
|
|
424
|
+
}
|
|
425
|
+
|
|
426
|
+
@group(0) @binding(0) var<uniform> sim: SimUniforms;
|
|
427
|
+
@group(0) @binding(1) var<uniform> frameUv: FrameUniforms;
|
|
428
|
+
`);
|
|
429
|
+
const moduleStructFields = [];
|
|
430
|
+
for (const slot of slots) {
|
|
431
|
+
const c = slot.contribution;
|
|
432
|
+
const fields = c.uniforms ?? [];
|
|
433
|
+
if (fields.length === 0) {
|
|
434
|
+
continue;
|
|
435
|
+
}
|
|
436
|
+
sections.push(this._renderModuleStruct(c.key, fields));
|
|
437
|
+
moduleStructFields.push(`u_${c.key}: ${c.key}Uniforms,`);
|
|
438
|
+
}
|
|
439
|
+
if (moduleStructFields.length > 0) {
|
|
440
|
+
sections.push(`
|
|
441
|
+
struct ModuleUniforms {
|
|
442
|
+
${moduleStructFields.map(s => ` ${s}`).join('\n')}
|
|
443
|
+
}
|
|
444
|
+
|
|
445
|
+
@group(0) @binding(2) var<uniform> modules: ModuleUniforms;
|
|
446
|
+
`);
|
|
447
|
+
}
|
|
448
|
+
let textureBindingIndex = moduleStructFields.length > 0 ? 3 : 2;
|
|
449
|
+
for (const slot of slots) {
|
|
450
|
+
for (const t of slot.contribution.textures ?? []) {
|
|
451
|
+
sections.push(`
|
|
452
|
+
@group(0) @binding(${textureBindingIndex++}) var u_${slot.contribution.key}_${t.name}: texture_1d<f32>;
|
|
453
|
+
@group(0) @binding(${textureBindingIndex++}) var u_${slot.contribution.key}_${t.name}_sampler: sampler;
|
|
454
|
+
`);
|
|
455
|
+
}
|
|
456
|
+
}
|
|
457
|
+
sections.push(`
|
|
458
|
+
@group(1) @binding(0) var<storage, read_write> positions: array<vec2<f32>>;
|
|
459
|
+
@group(1) @binding(1) var<storage, read_write> velocities: array<vec2<f32>>;
|
|
460
|
+
@group(1) @binding(2) var<storage, read_write> scales: array<vec2<f32>>;
|
|
461
|
+
@group(1) @binding(3) var<storage, read_write> rotInfo: array<vec2<f32>>;
|
|
462
|
+
@group(1) @binding(4) var<storage, read_write> timing: array<vec2<f32>>;
|
|
463
|
+
@group(1) @binding(5) var<storage, read_write> color: array<u32>;
|
|
464
|
+
@group(1) @binding(6) var<storage, read> textureIndex: array<u32>;
|
|
465
|
+
@group(1) @binding(7) var<storage, read_write> instanceOutput: array<u32>;
|
|
466
|
+
`);
|
|
467
|
+
// Module preludes (helper functions/constants). Concatenated in
|
|
468
|
+
// registration order; modules sharing the same key are emitted only
|
|
469
|
+
// once (the contribution body strings are still inlined per-instance,
|
|
470
|
+
// but the prelude function definitions can't be duplicated).
|
|
471
|
+
const seenPreludeKeys = new Set();
|
|
472
|
+
for (const slot of slots) {
|
|
473
|
+
const prelude = slot.contribution.prelude;
|
|
474
|
+
if (prelude === undefined || prelude.trim() === '')
|
|
475
|
+
continue;
|
|
476
|
+
if (seenPreludeKeys.has(slot.contribution.key))
|
|
477
|
+
continue;
|
|
478
|
+
seenPreludeKeys.add(slot.contribution.key);
|
|
479
|
+
sections.push(prelude);
|
|
480
|
+
}
|
|
481
|
+
const moduleBodies = slots.map(s => s.contribution.body).join('\n');
|
|
482
|
+
const frameCountConst = this._frameCount;
|
|
483
|
+
sections.push(`
|
|
484
|
+
@compute @workgroup_size(${workgroupSize})
|
|
485
|
+
fn main(@builtin(global_invocation_id) gid: vec3<u32>) {
|
|
486
|
+
let idx = gid.x;
|
|
487
|
+
if (idx >= sim.liveCount) { return; }
|
|
488
|
+
|
|
489
|
+
let dt = sim.dt;
|
|
490
|
+
|
|
491
|
+
// Skip dead particles (lifetime sentinel < 0). Write zero-scale instance
|
|
492
|
+
// so the renderer doesn't accidentally draw them.
|
|
493
|
+
if (timing[idx].y < 0.0) {
|
|
494
|
+
let outBaseDead = idx * 10u;
|
|
495
|
+
for (var k: u32 = 0u; k < 10u; k++) { instanceOutput[outBaseDead + k] = 0u; }
|
|
496
|
+
return;
|
|
497
|
+
}
|
|
498
|
+
|
|
499
|
+
// Integration.
|
|
500
|
+
positions[idx] = positions[idx] + velocities[idx] * dt;
|
|
501
|
+
rotInfo[idx].x = rotInfo[idx].x + rotInfo[idx].y * dt;
|
|
502
|
+
timing[idx].x = timing[idx].x + dt;
|
|
503
|
+
|
|
504
|
+
// Module bodies (in registration order).
|
|
505
|
+
${moduleBodies}
|
|
506
|
+
|
|
507
|
+
// Resolve frame UVs.
|
|
508
|
+
let frameIndex = min(textureIndex[idx], ${frameCountConst}u - 1u);
|
|
509
|
+
let frameUvBounds = frameUv.frames[frameIndex];
|
|
510
|
+
|
|
511
|
+
// Pack interleaved instance data (10 u32s per particle):
|
|
512
|
+
// x, y, scaleX, scaleY, rotation (f32×5) + color (u32) + uvMin.xy (f32×2) + uvMax.xy (f32×2)
|
|
513
|
+
let outBase = idx * 10u;
|
|
514
|
+
instanceOutput[outBase + 0u] = bitcast<u32>(positions[idx].x);
|
|
515
|
+
instanceOutput[outBase + 1u] = bitcast<u32>(positions[idx].y);
|
|
516
|
+
instanceOutput[outBase + 2u] = bitcast<u32>(scales[idx].x);
|
|
517
|
+
instanceOutput[outBase + 3u] = bitcast<u32>(scales[idx].y);
|
|
518
|
+
instanceOutput[outBase + 4u] = bitcast<u32>(rotInfo[idx].x);
|
|
519
|
+
instanceOutput[outBase + 5u] = color[idx];
|
|
520
|
+
instanceOutput[outBase + 6u] = bitcast<u32>(frameUvBounds.x);
|
|
521
|
+
instanceOutput[outBase + 7u] = bitcast<u32>(frameUvBounds.y);
|
|
522
|
+
instanceOutput[outBase + 8u] = bitcast<u32>(frameUvBounds.z);
|
|
523
|
+
instanceOutput[outBase + 9u] = bitcast<u32>(frameUvBounds.w);
|
|
524
|
+
}
|
|
525
|
+
`);
|
|
526
|
+
return sections.join('\n\n');
|
|
527
|
+
}
|
|
528
|
+
_renderModuleStruct(key, fields) {
|
|
529
|
+
const lines = fields.map(f => ` ${f.name}: ${f.type},`).join('\n');
|
|
530
|
+
return `struct ${key}Uniforms {\n${lines}\n}`;
|
|
531
|
+
}
|
|
532
|
+
}
|
|
533
|
+
|
|
534
|
+
export { ParticleGpuState };
|
|
535
|
+
//# sourceMappingURL=ParticleGpuState.js.map
|