@codexo/exojs 2.1.1 → 2.1.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 +13 -0
- package/README.md +2 -0
- package/dist/esm/audio/AbstractMedia.d.ts +3 -3
- package/dist/esm/audio/AbstractMedia.js +7 -2
- package/dist/esm/audio/AbstractMedia.js.map +1 -1
- package/dist/esm/audio/AudioAnalyser.d.ts +1 -1
- package/dist/esm/audio/AudioAnalyser.js +13 -3
- package/dist/esm/audio/AudioAnalyser.js.map +1 -1
- package/dist/esm/audio/Media.d.ts +1 -1
- package/dist/esm/audio/Music.d.ts +2 -2
- package/dist/esm/audio/Music.js +2 -1
- package/dist/esm/audio/Music.js.map +1 -1
- package/dist/esm/audio/Sound.d.ts +2 -2
- package/dist/esm/audio/Sound.js +10 -9
- package/dist/esm/audio/Sound.js.map +1 -1
- package/dist/esm/audio/audio-context.d.ts +1 -1
- package/dist/esm/core/Application.d.ts +5 -5
- package/dist/esm/core/Application.js +15 -7
- package/dist/esm/core/Application.js.map +1 -1
- package/dist/esm/core/Bounds.d.ts +2 -2
- package/dist/esm/core/Bounds.js +6 -8
- package/dist/esm/core/Bounds.js.map +1 -1
- package/dist/esm/core/Clock.js +3 -2
- package/dist/esm/core/Clock.js.map +1 -1
- package/dist/esm/core/Color.d.ts +1 -1
- package/dist/esm/core/Color.js +148 -144
- package/dist/esm/core/Color.js.map +1 -1
- package/dist/esm/core/Quadtree.d.ts +2 -2
- package/dist/esm/core/Quadtree.js +6 -4
- package/dist/esm/core/Quadtree.js.map +1 -1
- package/dist/esm/core/Scene.d.ts +5 -5
- package/dist/esm/core/Scene.js +5 -6
- package/dist/esm/core/Scene.js.map +1 -1
- package/dist/esm/core/SceneManager.js +42 -41
- package/dist/esm/core/SceneManager.js.map +1 -1
- package/dist/esm/core/SceneNode.d.ts +11 -11
- package/dist/esm/core/SceneNode.js +22 -24
- package/dist/esm/core/SceneNode.js.map +1 -1
- package/dist/esm/core/Signal.js +6 -4
- package/dist/esm/core/Signal.js.map +1 -1
- package/dist/esm/core/Time.d.ts +1 -1
- package/dist/esm/core/Time.js +10 -9
- 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 -0
- package/dist/esm/core/Timer.js.map +1 -1
- package/dist/esm/core/types.d.ts +1 -1
- package/dist/esm/core/utils.d.ts +3 -3
- package/dist/esm/index.js +3 -2
- package/dist/esm/index.js.map +1 -1
- package/dist/esm/input/ArcadeStickGamepadMapping.js +1 -1
- package/dist/esm/input/ArcadeStickGamepadMapping.js.map +1 -1
- package/dist/esm/input/GameCubeGamepadMapping.js +1 -4
- package/dist/esm/input/GameCubeGamepadMapping.js.map +1 -1
- package/dist/esm/input/Gamepad.d.ts +1 -1
- package/dist/esm/input/Gamepad.js +19 -15
- package/dist/esm/input/Gamepad.js.map +1 -1
- package/dist/esm/input/GamepadChannels.js +2 -0
- package/dist/esm/input/GamepadChannels.js.map +1 -1
- package/dist/esm/input/GamepadControl.js +5 -0
- package/dist/esm/input/GamepadControl.js.map +1 -1
- package/dist/esm/input/GamepadMapping.js +2 -0
- package/dist/esm/input/GamepadMapping.js.map +1 -1
- package/dist/esm/input/GamepadPromptLayouts.js +19 -19
- package/dist/esm/input/GamepadPromptLayouts.js.map +1 -1
- package/dist/esm/input/GenericDualAnalogGamepadMapping.js +1 -1
- package/dist/esm/input/GenericDualAnalogGamepadMapping.js.map +1 -1
- package/dist/esm/input/Input.d.ts +2 -2
- package/dist/esm/input/Input.js +8 -7
- package/dist/esm/input/Input.js.map +1 -1
- package/dist/esm/input/InputManager.d.ts +3 -3
- package/dist/esm/input/InputManager.js +43 -39
- package/dist/esm/input/InputManager.js.map +1 -1
- package/dist/esm/input/JoyConLeftGamepadMapping.js +1 -4
- package/dist/esm/input/JoyConLeftGamepadMapping.js.map +1 -1
- package/dist/esm/input/JoyConRightGamepadMapping.js +1 -4
- package/dist/esm/input/JoyConRightGamepadMapping.js.map +1 -1
- package/dist/esm/input/PlayStationGamepadMapping.js +1 -4
- package/dist/esm/input/PlayStationGamepadMapping.js.map +1 -1
- package/dist/esm/input/Pointer.d.ts +3 -3
- package/dist/esm/input/Pointer.js +12 -3
- package/dist/esm/input/Pointer.js.map +1 -1
- package/dist/esm/input/SteamControllerGamepadMapping.js +1 -4
- package/dist/esm/input/SteamControllerGamepadMapping.js.map +1 -1
- package/dist/esm/input/SwitchProGamepadMapping.js +1 -4
- package/dist/esm/input/SwitchProGamepadMapping.js.map +1 -1
- package/dist/esm/input/XboxGamepadMapping.js +1 -4
- package/dist/esm/input/XboxGamepadMapping.js.map +1 -1
- package/dist/esm/input/types.js +7 -1
- package/dist/esm/input/types.js.map +1 -1
- package/dist/esm/math/AbstractVector.d.ts +1 -1
- package/dist/esm/math/Circle.d.ts +6 -6
- package/dist/esm/math/Circle.js +17 -14
- package/dist/esm/math/Circle.js.map +1 -1
- package/dist/esm/math/Collision.d.ts +2 -2
- package/dist/esm/math/Collision.js +13 -0
- package/dist/esm/math/Collision.js.map +1 -0
- package/dist/esm/math/Ellipse.d.ts +6 -6
- package/dist/esm/math/Ellipse.js +11 -8
- package/dist/esm/math/Ellipse.js.map +1 -1
- package/dist/esm/math/Flags.d.ts +1 -1
- package/dist/esm/math/Flags.js +1 -1
- package/dist/esm/math/Flags.js.map +1 -1
- package/dist/esm/math/Interval.d.ts +1 -1
- package/dist/esm/math/Interval.js +3 -1
- package/dist/esm/math/Interval.js.map +1 -1
- package/dist/esm/math/Line.d.ts +6 -6
- package/dist/esm/math/Line.js +11 -8
- package/dist/esm/math/Line.js.map +1 -1
- package/dist/esm/math/Matrix.d.ts +1 -1
- package/dist/esm/math/Matrix.js +11 -2
- package/dist/esm/math/Matrix.js.map +1 -1
- package/dist/esm/math/ObservableSize.js +1 -0
- package/dist/esm/math/ObservableSize.js.map +1 -1
- package/dist/esm/math/ObservableVector.d.ts +1 -1
- package/dist/esm/math/ObservableVector.js +3 -0
- package/dist/esm/math/ObservableVector.js.map +1 -1
- package/dist/esm/math/PolarVector.d.ts +1 -1
- package/dist/esm/math/PolarVector.js +2 -0
- package/dist/esm/math/PolarVector.js.map +1 -1
- package/dist/esm/math/Polygon.d.ts +6 -6
- package/dist/esm/math/Polygon.js +17 -15
- package/dist/esm/math/Polygon.js.map +1 -1
- package/dist/esm/math/PolygonLike.d.ts +1 -1
- package/dist/esm/math/Random.js +4 -4
- package/dist/esm/math/Random.js.map +1 -1
- package/dist/esm/math/Rectangle.d.ts +7 -7
- package/dist/esm/math/Rectangle.js +17 -14
- package/dist/esm/math/Rectangle.js.map +1 -1
- package/dist/esm/math/Segment.d.ts +2 -2
- package/dist/esm/math/Segment.js +2 -0
- package/dist/esm/math/Segment.js.map +1 -1
- package/dist/esm/math/ShapeLike.d.ts +2 -2
- package/dist/esm/math/Size.d.ts +1 -1
- package/dist/esm/math/Size.js +3 -1
- package/dist/esm/math/Size.js.map +1 -1
- package/dist/esm/math/Transformable.js +9 -11
- package/dist/esm/math/Transformable.js.map +1 -1
- package/dist/esm/math/Vector.d.ts +5 -5
- package/dist/esm/math/Vector.js +13 -10
- package/dist/esm/math/Vector.js.map +1 -1
- package/dist/esm/math/collision-detection.d.ts +7 -7
- package/dist/esm/math/collision-detection.js +9 -9
- package/dist/esm/math/collision-detection.js.map +1 -1
- package/dist/esm/math/collision-primitives.d.ts +2 -2
- package/dist/esm/math/collision-primitives.js +4 -4
- package/dist/esm/math/collision-primitives.js.map +1 -1
- package/dist/esm/math/geometry.d.ts +1 -1
- package/dist/esm/math/utils.d.ts +1 -1
- package/dist/esm/math/utils.js +17 -11
- package/dist/esm/math/utils.js.map +1 -1
- package/dist/esm/particles/Particle.d.ts +4 -4
- package/dist/esm/particles/Particle.js +9 -11
- package/dist/esm/particles/Particle.js.map +1 -1
- package/dist/esm/particles/ParticleProperties.d.ts +3 -3
- package/dist/esm/particles/ParticleSystem.d.ts +6 -6
- package/dist/esm/particles/ParticleSystem.js +10 -9
- package/dist/esm/particles/ParticleSystem.js.map +1 -1
- package/dist/esm/particles/affectors/ColorAffector.d.ts +4 -4
- package/dist/esm/particles/affectors/ColorAffector.js +2 -0
- package/dist/esm/particles/affectors/ColorAffector.js.map +1 -1
- package/dist/esm/particles/affectors/ForceAffector.d.ts +4 -4
- package/dist/esm/particles/affectors/ForceAffector.js +1 -0
- package/dist/esm/particles/affectors/ForceAffector.js.map +1 -1
- package/dist/esm/particles/affectors/ParticleAffector.d.ts +2 -2
- package/dist/esm/particles/affectors/ScaleAffector.d.ts +4 -4
- package/dist/esm/particles/affectors/ScaleAffector.js +1 -0
- package/dist/esm/particles/affectors/ScaleAffector.js.map +1 -1
- package/dist/esm/particles/affectors/TorqueAffector.d.ts +3 -3
- package/dist/esm/particles/affectors/TorqueAffector.js +1 -0
- package/dist/esm/particles/affectors/TorqueAffector.js.map +1 -1
- package/dist/esm/particles/emitters/ParticleEmitter.d.ts +2 -2
- package/dist/esm/particles/emitters/ParticleOptions.d.ts +4 -4
- package/dist/esm/particles/emitters/ParticleOptions.js +9 -0
- package/dist/esm/particles/emitters/ParticleOptions.js.map +1 -1
- package/dist/esm/particles/emitters/UniversalEmitter.d.ts +4 -4
- package/dist/esm/particles/emitters/UniversalEmitter.js +3 -1
- package/dist/esm/particles/emitters/UniversalEmitter.js.map +1 -1
- package/dist/esm/physics/RapierPhysicsWorld.d.ts +4 -4
- package/dist/esm/physics/RapierPhysicsWorld.js +19 -8
- package/dist/esm/physics/RapierPhysicsWorld.js.map +1 -1
- package/dist/esm/rendering/CallbackRenderPass.js +1 -0
- package/dist/esm/rendering/CallbackRenderPass.js.map +1 -1
- package/dist/esm/rendering/Container.d.ts +1 -1
- package/dist/esm/rendering/Container.js +4 -7
- package/dist/esm/rendering/Container.js.map +1 -1
- package/dist/esm/rendering/Drawable.d.ts +2 -2
- package/dist/esm/rendering/Drawable.js +2 -5
- package/dist/esm/rendering/Drawable.js.map +1 -1
- package/dist/esm/rendering/RenderNode.d.ts +6 -6
- package/dist/esm/rendering/RenderNode.js +9 -12
- package/dist/esm/rendering/RenderNode.js.map +1 -1
- package/dist/esm/rendering/RenderTarget.d.ts +3 -3
- package/dist/esm/rendering/RenderTarget.js +7 -3
- package/dist/esm/rendering/RenderTarget.js.map +1 -1
- package/dist/esm/rendering/RenderTargetPass.d.ts +1 -1
- package/dist/esm/rendering/RenderTargetPass.js +4 -0
- package/dist/esm/rendering/RenderTargetPass.js.map +1 -1
- package/dist/esm/rendering/RendererRegistry.js +2 -4
- package/dist/esm/rendering/RendererRegistry.js.map +1 -1
- package/dist/esm/rendering/SceneRenderRuntime.d.ts +2 -2
- package/dist/esm/rendering/View.d.ts +4 -4
- package/dist/esm/rendering/View.js +28 -24
- package/dist/esm/rendering/View.js.map +1 -1
- package/dist/esm/rendering/filters/BlurFilter.d.ts +2 -2
- package/dist/esm/rendering/filters/BlurFilter.js +4 -4
- package/dist/esm/rendering/filters/BlurFilter.js.map +1 -1
- package/dist/esm/rendering/filters/ColorFilter.d.ts +3 -3
- package/dist/esm/rendering/filters/ColorFilter.js +2 -1
- package/dist/esm/rendering/filters/ColorFilter.js.map +1 -1
- package/dist/esm/rendering/filters/Filter.d.ts +2 -2
- package/dist/esm/rendering/primitives/DrawableShape.d.ts +4 -4
- package/dist/esm/rendering/primitives/DrawableShape.js +3 -0
- package/dist/esm/rendering/primitives/DrawableShape.js.map +1 -1
- package/dist/esm/rendering/primitives/Geometry.js +3 -0
- package/dist/esm/rendering/primitives/Geometry.js.map +1 -1
- package/dist/esm/rendering/primitives/Graphics.d.ts +4 -4
- package/dist/esm/rendering/primitives/Graphics.js +4 -7
- package/dist/esm/rendering/primitives/Graphics.js.map +1 -1
- package/dist/esm/rendering/shader/Shader.js +5 -3
- package/dist/esm/rendering/shader/Shader.js.map +1 -1
- package/dist/esm/rendering/shader/ShaderAttribute.js +5 -1
- package/dist/esm/rendering/shader/ShaderAttribute.js.map +1 -1
- package/dist/esm/rendering/shader/ShaderUniform.d.ts +1 -1
- package/dist/esm/rendering/shader/ShaderUniform.js +6 -1
- package/dist/esm/rendering/shader/ShaderUniform.js.map +1 -1
- package/dist/esm/rendering/sprite/AnimatedSprite.d.ts +5 -5
- package/dist/esm/rendering/sprite/AnimatedSprite.js +8 -8
- package/dist/esm/rendering/sprite/AnimatedSprite.js.map +1 -1
- package/dist/esm/rendering/sprite/Sprite.d.ts +6 -6
- package/dist/esm/rendering/sprite/Sprite.js +4 -4
- package/dist/esm/rendering/sprite/Sprite.js.map +1 -1
- package/dist/esm/rendering/sprite/Spritesheet.d.ts +1 -1
- package/dist/esm/rendering/sprite/Spritesheet.js +4 -3
- package/dist/esm/rendering/sprite/Spritesheet.js.map +1 -1
- package/dist/esm/rendering/text/Text.d.ts +2 -2
- package/dist/esm/rendering/text/Text.js +5 -1
- package/dist/esm/rendering/text/Text.js.map +1 -1
- package/dist/esm/rendering/text/TextStyle.js +14 -1
- package/dist/esm/rendering/text/TextStyle.js.map +1 -1
- package/dist/esm/rendering/texture/RenderTexture.d.ts +3 -3
- package/dist/esm/rendering/texture/RenderTexture.js +14 -9
- package/dist/esm/rendering/texture/RenderTexture.js.map +1 -1
- package/dist/esm/rendering/texture/Sampler.d.ts +1 -1
- package/dist/esm/rendering/texture/Sampler.js +7 -0
- package/dist/esm/rendering/texture/Sampler.js.map +1 -1
- package/dist/esm/rendering/texture/Texture.d.ts +3 -3
- package/dist/esm/rendering/texture/Texture.js +19 -17
- package/dist/esm/rendering/texture/Texture.js.map +1 -1
- package/dist/esm/rendering/video/Video.d.ts +3 -3
- package/dist/esm/rendering/video/Video.js +15 -10
- package/dist/esm/rendering/video/Video.js.map +1 -1
- package/dist/esm/rendering/webgl2/AbstractWebGl2BatchedRenderer.d.ts +1 -1
- package/dist/esm/rendering/webgl2/AbstractWebGl2BatchedRenderer.js +16 -9
- package/dist/esm/rendering/webgl2/AbstractWebGl2BatchedRenderer.js.map +1 -1
- package/dist/esm/rendering/webgl2/AbstractWebGl2Renderer.js +2 -4
- package/dist/esm/rendering/webgl2/AbstractWebGl2Renderer.js.map +1 -1
- package/dist/esm/rendering/webgl2/WebGl2ParticleRenderer.d.ts +1 -1
- package/dist/esm/rendering/webgl2/WebGl2PrimitiveRenderer.js +11 -5
- package/dist/esm/rendering/webgl2/WebGl2PrimitiveRenderer.js.map +1 -1
- package/dist/esm/rendering/webgl2/WebGl2RenderBuffer.d.ts +2 -2
- package/dist/esm/rendering/webgl2/WebGl2RenderBuffer.js +5 -3
- package/dist/esm/rendering/webgl2/WebGl2RenderBuffer.js.map +1 -1
- package/dist/esm/rendering/webgl2/WebGl2RenderManager.d.ts +4 -4
- package/dist/esm/rendering/webgl2/WebGl2RenderManager.js +28 -20
- package/dist/esm/rendering/webgl2/WebGl2RenderManager.js.map +1 -1
- package/dist/esm/rendering/webgl2/WebGl2RendererRuntime.d.ts +1 -1
- package/dist/esm/rendering/webgl2/WebGl2ShaderBlock.js +9 -1
- package/dist/esm/rendering/webgl2/WebGl2ShaderBlock.js.map +1 -1
- package/dist/esm/rendering/webgl2/WebGl2VertexArrayObject.d.ts +1 -1
- package/dist/esm/rendering/webgl2/WebGl2VertexArrayObject.js +5 -4
- package/dist/esm/rendering/webgl2/WebGl2VertexArrayObject.js.map +1 -1
- package/dist/esm/rendering/webgpu/AbstractWebGpuRenderer.js +2 -4
- package/dist/esm/rendering/webgpu/AbstractWebGpuRenderer.js.map +1 -1
- package/dist/esm/rendering/webgpu/WebGpuBlendState.d.ts +1 -1
- package/dist/esm/rendering/webgpu/WebGpuParticleRenderer.d.ts +3 -3
- package/dist/esm/rendering/webgpu/WebGpuParticleRenderer.js +19 -22
- package/dist/esm/rendering/webgpu/WebGpuParticleRenderer.js.map +1 -1
- package/dist/esm/rendering/webgpu/WebGpuPrimitiveRenderer.d.ts +3 -3
- package/dist/esm/rendering/webgpu/WebGpuPrimitiveRenderer.js +18 -21
- package/dist/esm/rendering/webgpu/WebGpuPrimitiveRenderer.js.map +1 -1
- package/dist/esm/rendering/webgpu/WebGpuRenderManager.d.ts +4 -4
- package/dist/esm/rendering/webgpu/WebGpuRenderManager.js +29 -26
- package/dist/esm/rendering/webgpu/WebGpuRenderManager.js.map +1 -1
- package/dist/esm/rendering/webgpu/WebGpuSpriteRenderer.d.ts +3 -3
- package/dist/esm/rendering/webgpu/WebGpuSpriteRenderer.js +133 -136
- package/dist/esm/rendering/webgpu/WebGpuSpriteRenderer.js.map +1 -1
- package/dist/esm/resources/AbstractAssetFactory.js +1 -3
- package/dist/esm/resources/AbstractAssetFactory.js.map +1 -1
- package/dist/esm/resources/AssetManifest.js +2 -0
- package/dist/esm/resources/AssetManifest.js.map +1 -1
- package/dist/esm/resources/FactoryRegistry.js +1 -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 +7 -3
- package/dist/esm/resources/IndexedDbDatabase.js.map +1 -1
- package/dist/esm/resources/IndexedDbStore.js +1 -0
- package/dist/esm/resources/IndexedDbStore.js.map +1 -1
- package/dist/esm/resources/Loader.d.ts +1 -1
- package/dist/esm/resources/Loader.js +21 -17
- package/dist/esm/resources/Loader.js.map +1 -1
- package/dist/esm/resources/factories/BinaryFactory.d.ts +1 -1
- package/dist/esm/resources/factories/BinaryFactory.js +1 -4
- package/dist/esm/resources/factories/BinaryFactory.js.map +1 -1
- package/dist/esm/resources/factories/FontFactory.d.ts +1 -1
- package/dist/esm/resources/factories/FontFactory.js +2 -5
- package/dist/esm/resources/factories/FontFactory.js.map +1 -1
- package/dist/esm/resources/factories/ImageFactory.d.ts +1 -1
- package/dist/esm/resources/factories/ImageFactory.js +1 -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 -4
- package/dist/esm/resources/factories/JsonFactory.js.map +1 -1
- package/dist/esm/resources/factories/MusicFactory.d.ts +3 -3
- package/dist/esm/resources/factories/MusicFactory.js +2 -5
- package/dist/esm/resources/factories/MusicFactory.js.map +1 -1
- package/dist/esm/resources/factories/SoundFactory.d.ts +3 -3
- package/dist/esm/resources/factories/SoundFactory.js +1 -4
- package/dist/esm/resources/factories/SoundFactory.js.map +1 -1
- package/dist/esm/resources/factories/SvgFactory.d.ts +1 -1
- package/dist/esm/resources/factories/SvgFactory.js +1 -4
- package/dist/esm/resources/factories/SvgFactory.js.map +1 -1
- package/dist/esm/resources/factories/TextFactory.d.ts +1 -1
- package/dist/esm/resources/factories/TextFactory.js +1 -4
- package/dist/esm/resources/factories/TextFactory.js.map +1 -1
- package/dist/esm/resources/factories/TextureFactory.d.ts +3 -3
- package/dist/esm/resources/factories/TextureFactory.js +1 -4
- package/dist/esm/resources/factories/TextureFactory.js.map +1 -1
- package/dist/esm/resources/factories/VideoFactory.d.ts +4 -4
- package/dist/esm/resources/factories/VideoFactory.js +2 -5
- package/dist/esm/resources/factories/VideoFactory.js.map +1 -1
- package/dist/esm/resources/factories/VttFactory.d.ts +1 -1
- package/dist/esm/resources/factories/VttFactory.js +1 -4
- package/dist/esm/resources/factories/VttFactory.js.map +1 -1
- package/dist/esm/resources/factories/WasmFactory.d.ts +1 -1
- package/dist/esm/resources/factories/WasmFactory.js +1 -4
- package/dist/esm/resources/factories/WasmFactory.js.map +1 -1
- package/dist/esm/resources/utils.js +5 -5
- package/dist/esm/resources/utils.js.map +1 -1
- package/dist/exo.esm.js +1737 -1641
- package/dist/exo.esm.js.map +1 -1
- package/dist/exo.esm.min.js +1 -1
- package/dist/exo.esm.min.js.map +1 -1
- package/dist/exo.global.js +1737 -1641
- package/dist/exo.global.js.map +1 -1
- package/dist/exo.global.min.js +1 -1
- package/dist/exo.global.min.js.map +1 -1
- package/package.json +96 -98
- package/dist/exo.d.ts +0 -4755
package/dist/exo.global.js
CHANGED
|
@@ -3,6 +3,8 @@ var Exo = (function (exports) {
|
|
|
3
3
|
|
|
4
4
|
let temp$9 = null;
|
|
5
5
|
class Size {
|
|
6
|
+
_width;
|
|
7
|
+
_height;
|
|
6
8
|
constructor(width = 0, height = 0) {
|
|
7
9
|
this._width = width;
|
|
8
10
|
this._height = height;
|
|
@@ -59,6 +61,7 @@ var Exo = (function (exports) {
|
|
|
59
61
|
destroy() {
|
|
60
62
|
// todo - check if destroy is needed
|
|
61
63
|
}
|
|
64
|
+
static zero = new Size(0, 0);
|
|
62
65
|
static get temp() {
|
|
63
66
|
if (temp$9 === null) {
|
|
64
67
|
temp$9 = new Size();
|
|
@@ -66,15 +69,14 @@ var Exo = (function (exports) {
|
|
|
66
69
|
return temp$9;
|
|
67
70
|
}
|
|
68
71
|
}
|
|
69
|
-
Size.zero = new Size(0, 0);
|
|
70
72
|
|
|
71
73
|
const limit = (2 ** 32) - 1;
|
|
72
74
|
class Random {
|
|
75
|
+
_state = new Uint32Array(624);
|
|
76
|
+
_iteration = 0;
|
|
77
|
+
_seed = 0;
|
|
78
|
+
_value = 0;
|
|
73
79
|
constructor(seed = Date.now()) {
|
|
74
|
-
this._state = new Uint32Array(624);
|
|
75
|
-
this._iteration = 0;
|
|
76
|
-
this._seed = 0;
|
|
77
|
-
this._value = 0;
|
|
78
80
|
this.setSeed(seed);
|
|
79
81
|
this._twist();
|
|
80
82
|
}
|
|
@@ -140,6 +142,7 @@ var Exo = (function (exports) {
|
|
|
140
142
|
|
|
141
143
|
let temp$8 = null;
|
|
142
144
|
class Time {
|
|
145
|
+
_milliseconds;
|
|
143
146
|
constructor(time = 0, factor = Time.milliseconds) {
|
|
144
147
|
this._milliseconds = time * factor;
|
|
145
148
|
}
|
|
@@ -225,6 +228,15 @@ var Exo = (function (exports) {
|
|
|
225
228
|
destroy() {
|
|
226
229
|
// todo - check if destroy is needed
|
|
227
230
|
}
|
|
231
|
+
static milliseconds = 1;
|
|
232
|
+
static seconds = 1000;
|
|
233
|
+
static minutes = 60000;
|
|
234
|
+
static hours = 3600000;
|
|
235
|
+
static zero = new Time(0);
|
|
236
|
+
static oneMillisecond = new Time(1);
|
|
237
|
+
static oneSecond = new Time(1, Time.seconds);
|
|
238
|
+
static oneMinute = new Time(1, Time.minutes);
|
|
239
|
+
static oneHour = new Time(1, Time.hours);
|
|
228
240
|
static get temp() {
|
|
229
241
|
if (temp$8 === null) {
|
|
230
242
|
temp$8 = new Time();
|
|
@@ -232,15 +244,6 @@ var Exo = (function (exports) {
|
|
|
232
244
|
return temp$8;
|
|
233
245
|
}
|
|
234
246
|
}
|
|
235
|
-
Time.milliseconds = 1;
|
|
236
|
-
Time.seconds = 1000;
|
|
237
|
-
Time.minutes = 60000;
|
|
238
|
-
Time.hours = 3600000;
|
|
239
|
-
Time.zero = new Time(0);
|
|
240
|
-
Time.oneMillisecond = new Time(1);
|
|
241
|
-
Time.oneSecond = new Time(1, Time.seconds);
|
|
242
|
-
Time.oneMinute = new Time(1, Time.minutes);
|
|
243
|
-
Time.oneHour = new Time(1, Time.hours);
|
|
244
247
|
|
|
245
248
|
const codecNotSupportedPattern = /^no$/;
|
|
246
249
|
let internalAudioElement = null;
|
|
@@ -373,9 +376,10 @@ var Exo = (function (exports) {
|
|
|
373
376
|
};
|
|
374
377
|
|
|
375
378
|
class Clock {
|
|
379
|
+
_startTime;
|
|
380
|
+
_elapsedTime = new Time(0);
|
|
381
|
+
_running = false;
|
|
376
382
|
constructor(startTime = Time.zero, autoStart = false) {
|
|
377
|
-
this._elapsedTime = new Time(0);
|
|
378
|
-
this._running = false;
|
|
379
383
|
this._startTime = startTime.clone();
|
|
380
384
|
if (autoStart) {
|
|
381
385
|
this.start();
|
|
@@ -435,9 +439,7 @@ var Exo = (function (exports) {
|
|
|
435
439
|
}
|
|
436
440
|
|
|
437
441
|
class Signal {
|
|
438
|
-
|
|
439
|
-
this._bindings = new Array();
|
|
440
|
-
}
|
|
442
|
+
_bindings = new Array();
|
|
441
443
|
get bindings() {
|
|
442
444
|
return this._bindings;
|
|
443
445
|
}
|
|
@@ -478,7 +480,11 @@ var Exo = (function (exports) {
|
|
|
478
480
|
}
|
|
479
481
|
dispatch(...params) {
|
|
480
482
|
if (this._bindings.length) {
|
|
481
|
-
|
|
483
|
+
// Snapshot bindings because handlers may mutate the array mid-dispatch
|
|
484
|
+
// (notably `once()` wrappers that remove themselves), which would otherwise
|
|
485
|
+
// cause the iterator to skip the binding shifted into the vacated slot.
|
|
486
|
+
const bindings = this._bindings.slice();
|
|
487
|
+
for (const binding of bindings) {
|
|
482
488
|
if (binding.handler.call(binding.context, ...params) === false) {
|
|
483
489
|
break;
|
|
484
490
|
}
|
|
@@ -494,6 +500,12 @@ var Exo = (function (exports) {
|
|
|
494
500
|
const tau = Math.PI * 2;
|
|
495
501
|
const radiansPerDegree = Math.PI / 180;
|
|
496
502
|
const degreesPerRadian = 180 / Math.PI;
|
|
503
|
+
exports.VoronoiRegion = void 0;
|
|
504
|
+
(function (VoronoiRegion) {
|
|
505
|
+
VoronoiRegion[VoronoiRegion["left"] = -1] = "left";
|
|
506
|
+
VoronoiRegion[VoronoiRegion["middle"] = 0] = "middle";
|
|
507
|
+
VoronoiRegion[VoronoiRegion["right"] = 1] = "right";
|
|
508
|
+
})(exports.VoronoiRegion || (exports.VoronoiRegion = {}));
|
|
497
509
|
const trimRotation = (degrees) => {
|
|
498
510
|
const rotation = degrees % 360;
|
|
499
511
|
return rotation < 0 ? rotation + 360 : rotation;
|
|
@@ -501,7 +513,7 @@ var Exo = (function (exports) {
|
|
|
501
513
|
const degreesToRadians = (degree) => degree * radiansPerDegree;
|
|
502
514
|
const radiansToDegrees = (radian) => radian * degreesPerRadian;
|
|
503
515
|
const clamp = (value, min, max) => Math.min(max, Math.max(min, value));
|
|
504
|
-
const sign = (value) => (value && (value < 0 ? -1 : 1));
|
|
516
|
+
const sign$1 = (value) => (value && (value < 0 ? -1 : 1));
|
|
505
517
|
const lerp = (startValue, endValue, ratio) => (((1 - ratio) * startValue) + (ratio * endValue));
|
|
506
518
|
const isPowerOfTwo = (value) => ((value !== 0) && ((value & (value - 1)) === 0));
|
|
507
519
|
const inRange = (value, min, max) => (value >= Math.min(min, max) && value <= Math.max(min, max));
|
|
@@ -512,13 +524,13 @@ var Exo = (function (exports) {
|
|
|
512
524
|
};
|
|
513
525
|
const bezierCurveTo = (fromX, fromY, cpX1, cpY1, cpX2, cpY2, toX, toY, path = [], len = 20) => {
|
|
514
526
|
path.push(fromX, fromY);
|
|
515
|
-
for (let i = 1
|
|
516
|
-
j = i / len;
|
|
517
|
-
dt1 = (1 - j);
|
|
518
|
-
dt2 = dt1 * dt1;
|
|
519
|
-
dt3 = dt2 * dt1;
|
|
520
|
-
t2 = j * j;
|
|
521
|
-
t3 = t2 * j;
|
|
527
|
+
for (let i = 1; i <= len; i++) {
|
|
528
|
+
const j = i / len;
|
|
529
|
+
const dt1 = (1 - j);
|
|
530
|
+
const dt2 = dt1 * dt1;
|
|
531
|
+
const dt3 = dt2 * dt1;
|
|
532
|
+
const t2 = j * j;
|
|
533
|
+
const t3 = t2 * j;
|
|
522
534
|
path.push((dt3 * fromX) + (3 * dt2 * j * cpX1) + (3 * dt1 * t2 * cpX2) + (t3 * toX), (dt3 * fromY) + (3 * dt2 * j * cpY1) + (3 * dt1 * t2 * cpY2) + (t3 * toY));
|
|
523
535
|
}
|
|
524
536
|
return path;
|
|
@@ -533,20 +545,24 @@ var Exo = (function (exports) {
|
|
|
533
545
|
const getVoronoiRegion$1 = (line, point) => {
|
|
534
546
|
const product = point.dot(line.x, line.y);
|
|
535
547
|
if (product < 0) {
|
|
536
|
-
return
|
|
548
|
+
return exports.VoronoiRegion.left;
|
|
537
549
|
}
|
|
538
550
|
else if (product > line.lengthSq) {
|
|
539
|
-
return
|
|
551
|
+
return exports.VoronoiRegion.right;
|
|
540
552
|
}
|
|
541
553
|
else {
|
|
542
|
-
return
|
|
554
|
+
return exports.VoronoiRegion.middle;
|
|
543
555
|
}
|
|
544
556
|
};
|
|
545
557
|
|
|
546
558
|
class Color {
|
|
559
|
+
_r;
|
|
560
|
+
_g;
|
|
561
|
+
_b;
|
|
562
|
+
_a;
|
|
563
|
+
_rgba = null;
|
|
564
|
+
_array = null;
|
|
547
565
|
constructor(r = 0, g = 0, b = 0, a = 1) {
|
|
548
|
-
this._rgba = null;
|
|
549
|
-
this._array = null;
|
|
550
566
|
this._r = r & 255;
|
|
551
567
|
this._g = g & 255;
|
|
552
568
|
this._b = b & 255;
|
|
@@ -656,149 +672,149 @@ var Exo = (function (exports) {
|
|
|
656
672
|
this._array = null;
|
|
657
673
|
}
|
|
658
674
|
}
|
|
675
|
+
static aliceBlue = new Color(240, 248, 255, 1);
|
|
676
|
+
static antiqueWhite = new Color(250, 235, 215, 1);
|
|
677
|
+
static aqua = new Color(0, 255, 255, 1);
|
|
678
|
+
static aquamarine = new Color(127, 255, 212, 1);
|
|
679
|
+
static azure = new Color(240, 255, 255, 1);
|
|
680
|
+
static beige = new Color(245, 245, 220, 1);
|
|
681
|
+
static bisque = new Color(255, 228, 196, 1);
|
|
682
|
+
static black = new Color(0, 0, 0, 1);
|
|
683
|
+
static blanchedAlmond = new Color(255, 235, 205, 1);
|
|
684
|
+
static blue = new Color(0, 0, 255, 1);
|
|
685
|
+
static blueViolet = new Color(138, 43, 226, 1);
|
|
686
|
+
static brown = new Color(165, 42, 42, 1);
|
|
687
|
+
static burlyWood = new Color(222, 184, 135, 1);
|
|
688
|
+
static cadetBlue = new Color(95, 158, 160, 1);
|
|
689
|
+
static chartreuse = new Color(127, 255, 0, 1);
|
|
690
|
+
static chocolate = new Color(210, 105, 30, 1);
|
|
691
|
+
static coral = new Color(255, 127, 80, 1);
|
|
692
|
+
static cornflowerBlue = new Color(100, 149, 237, 1);
|
|
693
|
+
static cornsilk = new Color(255, 248, 220, 1);
|
|
694
|
+
static crimson = new Color(220, 20, 60, 1);
|
|
695
|
+
static cyan = new Color(0, 255, 255, 1);
|
|
696
|
+
static darkBlue = new Color(0, 0, 139, 1);
|
|
697
|
+
static darkCyan = new Color(0, 139, 139, 1);
|
|
698
|
+
static darkGoldenrod = new Color(184, 134, 11, 1);
|
|
699
|
+
static darkGray = new Color(169, 169, 169, 1);
|
|
700
|
+
static darkGreen = new Color(0, 100, 0, 1);
|
|
701
|
+
static darkKhaki = new Color(189, 183, 107, 1);
|
|
702
|
+
static darkMagenta = new Color(139, 0, 139, 1);
|
|
703
|
+
static darkOliveGreen = new Color(85, 107, 47, 1);
|
|
704
|
+
static darkOrange = new Color(255, 140, 0, 1);
|
|
705
|
+
static darkOrchid = new Color(153, 50, 204, 1);
|
|
706
|
+
static darkRed = new Color(139, 0, 0, 1);
|
|
707
|
+
static darkSalmon = new Color(233, 150, 122, 1);
|
|
708
|
+
static darkSeaGreen = new Color(143, 188, 139, 1);
|
|
709
|
+
static darkSlateBlue = new Color(72, 61, 139, 1);
|
|
710
|
+
static darkSlateGray = new Color(47, 79, 79, 1);
|
|
711
|
+
static darkTurquoise = new Color(0, 206, 209, 1);
|
|
712
|
+
static darkViolet = new Color(148, 0, 211, 1);
|
|
713
|
+
static deepPink = new Color(255, 20, 147, 1);
|
|
714
|
+
static deepSkyBlue = new Color(0, 191, 255, 1);
|
|
715
|
+
static dimGray = new Color(105, 105, 105, 1);
|
|
716
|
+
static dodgerBlue = new Color(30, 144, 255, 1);
|
|
717
|
+
static firebrick = new Color(178, 34, 34, 1);
|
|
718
|
+
static floralWhite = new Color(255, 250, 240, 1);
|
|
719
|
+
static forestGreen = new Color(34, 139, 34, 1);
|
|
720
|
+
static fuchsia = new Color(255, 0, 255, 1);
|
|
721
|
+
static gainsboro = new Color(220, 220, 220, 1);
|
|
722
|
+
static ghostWhite = new Color(248, 248, 255, 1);
|
|
723
|
+
static gold = new Color(255, 215, 0, 1);
|
|
724
|
+
static goldenrod = new Color(218, 165, 32, 1);
|
|
725
|
+
static gray = new Color(128, 128, 128, 1);
|
|
726
|
+
static green = new Color(0, 128, 0, 1);
|
|
727
|
+
static greenYellow = new Color(173, 255, 47, 1);
|
|
728
|
+
static honeydew = new Color(240, 255, 240, 1);
|
|
729
|
+
static hotPink = new Color(255, 105, 180, 1);
|
|
730
|
+
static indianRed = new Color(205, 92, 92, 1);
|
|
731
|
+
static indigo = new Color(75, 0, 130, 1);
|
|
732
|
+
static ivory = new Color(255, 255, 240, 1);
|
|
733
|
+
static khaki = new Color(240, 230, 140, 1);
|
|
734
|
+
static lavender = new Color(230, 230, 250, 1);
|
|
735
|
+
static lavenderBlush = new Color(255, 240, 245, 1);
|
|
736
|
+
static lawnGreen = new Color(124, 252, 0, 1);
|
|
737
|
+
static lemonChiffon = new Color(255, 250, 205, 1);
|
|
738
|
+
static lightBlue = new Color(173, 216, 230, 1);
|
|
739
|
+
static lightCoral = new Color(240, 128, 128, 1);
|
|
740
|
+
static lightCyan = new Color(224, 255, 255, 1);
|
|
741
|
+
static lightGoldenrodYellow = new Color(250, 250, 210, 1);
|
|
742
|
+
static lightGray = new Color(211, 211, 211, 1);
|
|
743
|
+
static lightGreen = new Color(144, 238, 144, 1);
|
|
744
|
+
static lightPink = new Color(255, 182, 193, 1);
|
|
745
|
+
static lightSalmon = new Color(255, 160, 122, 1);
|
|
746
|
+
static lightSeaGreen = new Color(32, 178, 170, 1);
|
|
747
|
+
static lightSkyBlue = new Color(135, 206, 250, 1);
|
|
748
|
+
static lightSlateGray = new Color(119, 136, 153, 1);
|
|
749
|
+
static lightSteelBlue = new Color(176, 196, 222, 1);
|
|
750
|
+
static lightYellow = new Color(255, 255, 224, 1);
|
|
751
|
+
static lime = new Color(0, 255, 0, 1);
|
|
752
|
+
static limeGreen = new Color(50, 205, 50, 1);
|
|
753
|
+
static linen = new Color(250, 240, 230, 1);
|
|
754
|
+
static magenta = new Color(255, 0, 255, 1);
|
|
755
|
+
static maroon = new Color(128, 0, 0, 1);
|
|
756
|
+
static mediumAquamarine = new Color(102, 205, 170, 1);
|
|
757
|
+
static mediumBlue = new Color(0, 0, 205, 1);
|
|
758
|
+
static mediumOrchid = new Color(186, 85, 211, 1);
|
|
759
|
+
static mediumPurple = new Color(147, 112, 219, 1);
|
|
760
|
+
static mediumSeaGreen = new Color(60, 179, 113, 1);
|
|
761
|
+
static mediumSlateBlue = new Color(123, 104, 238, 1);
|
|
762
|
+
static mediumSpringGreen = new Color(0, 250, 154, 1);
|
|
763
|
+
static mediumTurquoise = new Color(72, 209, 204, 1);
|
|
764
|
+
static mediumVioletRed = new Color(199, 21, 133, 1);
|
|
765
|
+
static midnightBlue = new Color(25, 25, 112, 1);
|
|
766
|
+
static mintCream = new Color(245, 255, 250, 1);
|
|
767
|
+
static mistyRose = new Color(255, 228, 225, 1);
|
|
768
|
+
static moccasin = new Color(255, 228, 181, 1);
|
|
769
|
+
static navajoWhite = new Color(255, 222, 173, 1);
|
|
770
|
+
static navy = new Color(0, 0, 128, 1);
|
|
771
|
+
static oldLace = new Color(253, 245, 230, 1);
|
|
772
|
+
static olive = new Color(128, 128, 0, 1);
|
|
773
|
+
static oliveDrab = new Color(107, 142, 35, 1);
|
|
774
|
+
static orange = new Color(255, 165, 0, 1);
|
|
775
|
+
static orangeRed = new Color(255, 69, 0, 1);
|
|
776
|
+
static orchid = new Color(218, 112, 214, 1);
|
|
777
|
+
static paleGoldenrod = new Color(238, 232, 170, 1);
|
|
778
|
+
static paleGreen = new Color(152, 251, 152, 1);
|
|
779
|
+
static paleTurquoise = new Color(175, 238, 238, 1);
|
|
780
|
+
static paleVioletRed = new Color(219, 112, 147, 1);
|
|
781
|
+
static papayaWhip = new Color(255, 239, 213, 1);
|
|
782
|
+
static peachPuff = new Color(255, 218, 185, 1);
|
|
783
|
+
static peru = new Color(205, 133, 63, 1);
|
|
784
|
+
static pink = new Color(255, 192, 203, 1);
|
|
785
|
+
static plum = new Color(221, 160, 221, 1);
|
|
786
|
+
static powderBlue = new Color(176, 224, 230, 1);
|
|
787
|
+
static purple = new Color(128, 0, 128, 1);
|
|
788
|
+
static red = new Color(255, 0, 0, 1);
|
|
789
|
+
static rosyBrown = new Color(188, 143, 143, 1);
|
|
790
|
+
static royalBlue = new Color(65, 105, 225, 1);
|
|
791
|
+
static saddleBrown = new Color(139, 69, 19, 1);
|
|
792
|
+
static salmon = new Color(250, 128, 114, 1);
|
|
793
|
+
static sandyBrown = new Color(244, 164, 96, 1);
|
|
794
|
+
static seaGreen = new Color(46, 139, 87, 1);
|
|
795
|
+
static seaShell = new Color(255, 245, 238, 1);
|
|
796
|
+
static sienna = new Color(160, 82, 45, 1);
|
|
797
|
+
static silver = new Color(192, 192, 192, 1);
|
|
798
|
+
static skyBlue = new Color(135, 206, 235, 1);
|
|
799
|
+
static slateBlue = new Color(106, 90, 205, 1);
|
|
800
|
+
static slateGray = new Color(112, 128, 144, 1);
|
|
801
|
+
static snow = new Color(255, 250, 250, 1);
|
|
802
|
+
static springGreen = new Color(0, 255, 127, 1);
|
|
803
|
+
static steelBlue = new Color(70, 130, 180, 1);
|
|
804
|
+
static tan = new Color(210, 180, 140, 1);
|
|
805
|
+
static teal = new Color(0, 128, 128, 1);
|
|
806
|
+
static thistle = new Color(216, 191, 216, 1);
|
|
807
|
+
static tomato = new Color(255, 99, 71, 1);
|
|
808
|
+
static transparentBlack = new Color(0, 0, 0, 0);
|
|
809
|
+
static transparentWhite = new Color(255, 255, 255, 0);
|
|
810
|
+
static turquoise = new Color(64, 224, 208, 1);
|
|
811
|
+
static violet = new Color(238, 130, 238, 1);
|
|
812
|
+
static wheat = new Color(245, 222, 179, 1);
|
|
813
|
+
static white = new Color(255, 255, 255, 1);
|
|
814
|
+
static whiteSmoke = new Color(245, 245, 245, 1);
|
|
815
|
+
static yellow = new Color(255, 255, 0, 1);
|
|
816
|
+
static yellowGreen = new Color(154, 205, 50, 1);
|
|
659
817
|
}
|
|
660
|
-
Color.aliceBlue = new Color(240, 248, 255, 1);
|
|
661
|
-
Color.antiqueWhite = new Color(250, 235, 215, 1);
|
|
662
|
-
Color.aqua = new Color(0, 255, 255, 1);
|
|
663
|
-
Color.aquamarine = new Color(127, 255, 212, 1);
|
|
664
|
-
Color.azure = new Color(240, 255, 255, 1);
|
|
665
|
-
Color.beige = new Color(245, 245, 220, 1);
|
|
666
|
-
Color.bisque = new Color(255, 228, 196, 1);
|
|
667
|
-
Color.black = new Color(0, 0, 0, 1);
|
|
668
|
-
Color.blanchedAlmond = new Color(255, 235, 205, 1);
|
|
669
|
-
Color.blue = new Color(0, 0, 255, 1);
|
|
670
|
-
Color.blueViolet = new Color(138, 43, 226, 1);
|
|
671
|
-
Color.brown = new Color(165, 42, 42, 1);
|
|
672
|
-
Color.burlyWood = new Color(222, 184, 135, 1);
|
|
673
|
-
Color.cadetBlue = new Color(95, 158, 160, 1);
|
|
674
|
-
Color.chartreuse = new Color(127, 255, 0, 1);
|
|
675
|
-
Color.chocolate = new Color(210, 105, 30, 1);
|
|
676
|
-
Color.coral = new Color(255, 127, 80, 1);
|
|
677
|
-
Color.cornflowerBlue = new Color(100, 149, 237, 1);
|
|
678
|
-
Color.cornsilk = new Color(255, 248, 220, 1);
|
|
679
|
-
Color.crimson = new Color(220, 20, 60, 1);
|
|
680
|
-
Color.cyan = new Color(0, 255, 255, 1);
|
|
681
|
-
Color.darkBlue = new Color(0, 0, 139, 1);
|
|
682
|
-
Color.darkCyan = new Color(0, 139, 139, 1);
|
|
683
|
-
Color.darkGoldenrod = new Color(184, 134, 11, 1);
|
|
684
|
-
Color.darkGray = new Color(169, 169, 169, 1);
|
|
685
|
-
Color.darkGreen = new Color(0, 100, 0, 1);
|
|
686
|
-
Color.darkKhaki = new Color(189, 183, 107, 1);
|
|
687
|
-
Color.darkMagenta = new Color(139, 0, 139, 1);
|
|
688
|
-
Color.darkOliveGreen = new Color(85, 107, 47, 1);
|
|
689
|
-
Color.darkOrange = new Color(255, 140, 0, 1);
|
|
690
|
-
Color.darkOrchid = new Color(153, 50, 204, 1);
|
|
691
|
-
Color.darkRed = new Color(139, 0, 0, 1);
|
|
692
|
-
Color.darkSalmon = new Color(233, 150, 122, 1);
|
|
693
|
-
Color.darkSeaGreen = new Color(143, 188, 139, 1);
|
|
694
|
-
Color.darkSlateBlue = new Color(72, 61, 139, 1);
|
|
695
|
-
Color.darkSlateGray = new Color(47, 79, 79, 1);
|
|
696
|
-
Color.darkTurquoise = new Color(0, 206, 209, 1);
|
|
697
|
-
Color.darkViolet = new Color(148, 0, 211, 1);
|
|
698
|
-
Color.deepPink = new Color(255, 20, 147, 1);
|
|
699
|
-
Color.deepSkyBlue = new Color(0, 191, 255, 1);
|
|
700
|
-
Color.dimGray = new Color(105, 105, 105, 1);
|
|
701
|
-
Color.dodgerBlue = new Color(30, 144, 255, 1);
|
|
702
|
-
Color.firebrick = new Color(178, 34, 34, 1);
|
|
703
|
-
Color.floralWhite = new Color(255, 250, 240, 1);
|
|
704
|
-
Color.forestGreen = new Color(34, 139, 34, 1);
|
|
705
|
-
Color.fuchsia = new Color(255, 0, 255, 1);
|
|
706
|
-
Color.gainsboro = new Color(220, 220, 220, 1);
|
|
707
|
-
Color.ghostWhite = new Color(248, 248, 255, 1);
|
|
708
|
-
Color.gold = new Color(255, 215, 0, 1);
|
|
709
|
-
Color.goldenrod = new Color(218, 165, 32, 1);
|
|
710
|
-
Color.gray = new Color(128, 128, 128, 1);
|
|
711
|
-
Color.green = new Color(0, 128, 0, 1);
|
|
712
|
-
Color.greenYellow = new Color(173, 255, 47, 1);
|
|
713
|
-
Color.honeydew = new Color(240, 255, 240, 1);
|
|
714
|
-
Color.hotPink = new Color(255, 105, 180, 1);
|
|
715
|
-
Color.indianRed = new Color(205, 92, 92, 1);
|
|
716
|
-
Color.indigo = new Color(75, 0, 130, 1);
|
|
717
|
-
Color.ivory = new Color(255, 255, 240, 1);
|
|
718
|
-
Color.khaki = new Color(240, 230, 140, 1);
|
|
719
|
-
Color.lavender = new Color(230, 230, 250, 1);
|
|
720
|
-
Color.lavenderBlush = new Color(255, 240, 245, 1);
|
|
721
|
-
Color.lawnGreen = new Color(124, 252, 0, 1);
|
|
722
|
-
Color.lemonChiffon = new Color(255, 250, 205, 1);
|
|
723
|
-
Color.lightBlue = new Color(173, 216, 230, 1);
|
|
724
|
-
Color.lightCoral = new Color(240, 128, 128, 1);
|
|
725
|
-
Color.lightCyan = new Color(224, 255, 255, 1);
|
|
726
|
-
Color.lightGoldenrodYellow = new Color(250, 250, 210, 1);
|
|
727
|
-
Color.lightGray = new Color(211, 211, 211, 1);
|
|
728
|
-
Color.lightGreen = new Color(144, 238, 144, 1);
|
|
729
|
-
Color.lightPink = new Color(255, 182, 193, 1);
|
|
730
|
-
Color.lightSalmon = new Color(255, 160, 122, 1);
|
|
731
|
-
Color.lightSeaGreen = new Color(32, 178, 170, 1);
|
|
732
|
-
Color.lightSkyBlue = new Color(135, 206, 250, 1);
|
|
733
|
-
Color.lightSlateGray = new Color(119, 136, 153, 1);
|
|
734
|
-
Color.lightSteelBlue = new Color(176, 196, 222, 1);
|
|
735
|
-
Color.lightYellow = new Color(255, 255, 224, 1);
|
|
736
|
-
Color.lime = new Color(0, 255, 0, 1);
|
|
737
|
-
Color.limeGreen = new Color(50, 205, 50, 1);
|
|
738
|
-
Color.linen = new Color(250, 240, 230, 1);
|
|
739
|
-
Color.magenta = new Color(255, 0, 255, 1);
|
|
740
|
-
Color.maroon = new Color(128, 0, 0, 1);
|
|
741
|
-
Color.mediumAquamarine = new Color(102, 205, 170, 1);
|
|
742
|
-
Color.mediumBlue = new Color(0, 0, 205, 1);
|
|
743
|
-
Color.mediumOrchid = new Color(186, 85, 211, 1);
|
|
744
|
-
Color.mediumPurple = new Color(147, 112, 219, 1);
|
|
745
|
-
Color.mediumSeaGreen = new Color(60, 179, 113, 1);
|
|
746
|
-
Color.mediumSlateBlue = new Color(123, 104, 238, 1);
|
|
747
|
-
Color.mediumSpringGreen = new Color(0, 250, 154, 1);
|
|
748
|
-
Color.mediumTurquoise = new Color(72, 209, 204, 1);
|
|
749
|
-
Color.mediumVioletRed = new Color(199, 21, 133, 1);
|
|
750
|
-
Color.midnightBlue = new Color(25, 25, 112, 1);
|
|
751
|
-
Color.mintCream = new Color(245, 255, 250, 1);
|
|
752
|
-
Color.mistyRose = new Color(255, 228, 225, 1);
|
|
753
|
-
Color.moccasin = new Color(255, 228, 181, 1);
|
|
754
|
-
Color.navajoWhite = new Color(255, 222, 173, 1);
|
|
755
|
-
Color.navy = new Color(0, 0, 128, 1);
|
|
756
|
-
Color.oldLace = new Color(253, 245, 230, 1);
|
|
757
|
-
Color.olive = new Color(128, 128, 0, 1);
|
|
758
|
-
Color.oliveDrab = new Color(107, 142, 35, 1);
|
|
759
|
-
Color.orange = new Color(255, 165, 0, 1);
|
|
760
|
-
Color.orangeRed = new Color(255, 69, 0, 1);
|
|
761
|
-
Color.orchid = new Color(218, 112, 214, 1);
|
|
762
|
-
Color.paleGoldenrod = new Color(238, 232, 170, 1);
|
|
763
|
-
Color.paleGreen = new Color(152, 251, 152, 1);
|
|
764
|
-
Color.paleTurquoise = new Color(175, 238, 238, 1);
|
|
765
|
-
Color.paleVioletRed = new Color(219, 112, 147, 1);
|
|
766
|
-
Color.papayaWhip = new Color(255, 239, 213, 1);
|
|
767
|
-
Color.peachPuff = new Color(255, 218, 185, 1);
|
|
768
|
-
Color.peru = new Color(205, 133, 63, 1);
|
|
769
|
-
Color.pink = new Color(255, 192, 203, 1);
|
|
770
|
-
Color.plum = new Color(221, 160, 221, 1);
|
|
771
|
-
Color.powderBlue = new Color(176, 224, 230, 1);
|
|
772
|
-
Color.purple = new Color(128, 0, 128, 1);
|
|
773
|
-
Color.red = new Color(255, 0, 0, 1);
|
|
774
|
-
Color.rosyBrown = new Color(188, 143, 143, 1);
|
|
775
|
-
Color.royalBlue = new Color(65, 105, 225, 1);
|
|
776
|
-
Color.saddleBrown = new Color(139, 69, 19, 1);
|
|
777
|
-
Color.salmon = new Color(250, 128, 114, 1);
|
|
778
|
-
Color.sandyBrown = new Color(244, 164, 96, 1);
|
|
779
|
-
Color.seaGreen = new Color(46, 139, 87, 1);
|
|
780
|
-
Color.seaShell = new Color(255, 245, 238, 1);
|
|
781
|
-
Color.sienna = new Color(160, 82, 45, 1);
|
|
782
|
-
Color.silver = new Color(192, 192, 192, 1);
|
|
783
|
-
Color.skyBlue = new Color(135, 206, 235, 1);
|
|
784
|
-
Color.slateBlue = new Color(106, 90, 205, 1);
|
|
785
|
-
Color.slateGray = new Color(112, 128, 144, 1);
|
|
786
|
-
Color.snow = new Color(255, 250, 250, 1);
|
|
787
|
-
Color.springGreen = new Color(0, 255, 127, 1);
|
|
788
|
-
Color.steelBlue = new Color(70, 130, 180, 1);
|
|
789
|
-
Color.tan = new Color(210, 180, 140, 1);
|
|
790
|
-
Color.teal = new Color(0, 128, 128, 1);
|
|
791
|
-
Color.thistle = new Color(216, 191, 216, 1);
|
|
792
|
-
Color.tomato = new Color(255, 99, 71, 1);
|
|
793
|
-
Color.transparentBlack = new Color(0, 0, 0, 0);
|
|
794
|
-
Color.transparentWhite = new Color(255, 255, 255, 0);
|
|
795
|
-
Color.turquoise = new Color(64, 224, 208, 1);
|
|
796
|
-
Color.violet = new Color(238, 130, 238, 1);
|
|
797
|
-
Color.wheat = new Color(245, 222, 179, 1);
|
|
798
|
-
Color.white = new Color(255, 255, 255, 1);
|
|
799
|
-
Color.whiteSmoke = new Color(245, 245, 245, 1);
|
|
800
|
-
Color.yellow = new Color(255, 255, 0, 1);
|
|
801
|
-
Color.yellowGreen = new Color(154, 205, 50, 1);
|
|
802
818
|
|
|
803
819
|
exports.BlendModes = void 0;
|
|
804
820
|
(function (BlendModes) {
|
|
@@ -980,6 +996,9 @@ var Exo = (function (exports) {
|
|
|
980
996
|
}
|
|
981
997
|
|
|
982
998
|
class ObservableVector extends AbstractVector {
|
|
999
|
+
_x;
|
|
1000
|
+
_y;
|
|
1001
|
+
_callback;
|
|
983
1002
|
constructor(callback, x = 0, y = 0) {
|
|
984
1003
|
super();
|
|
985
1004
|
this._x = x;
|
|
@@ -1053,8 +1072,17 @@ var Exo = (function (exports) {
|
|
|
1053
1072
|
* | e | f | z |
|
|
1054
1073
|
*/
|
|
1055
1074
|
class Matrix {
|
|
1075
|
+
a;
|
|
1076
|
+
b;
|
|
1077
|
+
x;
|
|
1078
|
+
c;
|
|
1079
|
+
d;
|
|
1080
|
+
y;
|
|
1081
|
+
e;
|
|
1082
|
+
f;
|
|
1083
|
+
z;
|
|
1084
|
+
_array = null;
|
|
1056
1085
|
constructor(a = 1, b = 0, x = 0, c = 0, d = 1, y = 0, e = 0, f = 0, z = 1) {
|
|
1057
|
-
this._array = null;
|
|
1058
1086
|
this.a = a;
|
|
1059
1087
|
this.b = b;
|
|
1060
1088
|
this.x = x;
|
|
@@ -1158,6 +1186,7 @@ var Exo = (function (exports) {
|
|
|
1158
1186
|
this._array = null;
|
|
1159
1187
|
}
|
|
1160
1188
|
}
|
|
1189
|
+
static identity = new Matrix(1, 0, 0, 0, 1, 0, 0, 0, 1);
|
|
1161
1190
|
static get temp() {
|
|
1162
1191
|
if (temp$7 === null) {
|
|
1163
1192
|
temp$7 = new Matrix();
|
|
@@ -1165,14 +1194,13 @@ var Exo = (function (exports) {
|
|
|
1165
1194
|
return temp$7;
|
|
1166
1195
|
}
|
|
1167
1196
|
}
|
|
1168
|
-
Matrix.identity = new Matrix(1, 0, 0, 0, 1, 0, 0, 0, 1);
|
|
1169
1197
|
|
|
1170
1198
|
class Flags {
|
|
1199
|
+
_value = 0;
|
|
1171
1200
|
get value() {
|
|
1172
1201
|
return this._value;
|
|
1173
1202
|
}
|
|
1174
1203
|
constructor(...flags) {
|
|
1175
|
-
this._value = 0;
|
|
1176
1204
|
if (flags.length) {
|
|
1177
1205
|
this.push(...flags);
|
|
1178
1206
|
}
|
|
@@ -1217,16 +1245,14 @@ var Exo = (function (exports) {
|
|
|
1217
1245
|
TransformableFlags[TransformableFlags["TransformInverse"] = 16] = "TransformInverse";
|
|
1218
1246
|
})(exports.TransformableFlags || (exports.TransformableFlags = {}));
|
|
1219
1247
|
class Transformable {
|
|
1220
|
-
|
|
1221
|
-
|
|
1222
|
-
|
|
1223
|
-
|
|
1224
|
-
|
|
1225
|
-
|
|
1226
|
-
|
|
1227
|
-
|
|
1228
|
-
this._cos = 1;
|
|
1229
|
-
}
|
|
1248
|
+
flags = new Flags(exports.TransformableFlags.Transform);
|
|
1249
|
+
_transform = new Matrix();
|
|
1250
|
+
_position = new ObservableVector(this._setPositionDirty.bind(this), 0, 0);
|
|
1251
|
+
_scale = new ObservableVector(this._setScalingDirty.bind(this), 1, 1);
|
|
1252
|
+
_origin = new ObservableVector(this._setOriginDirty.bind(this), 0, 0);
|
|
1253
|
+
_rotation = 0;
|
|
1254
|
+
_sin = 0;
|
|
1255
|
+
_cos = 1;
|
|
1230
1256
|
get position() {
|
|
1231
1257
|
return this._position;
|
|
1232
1258
|
}
|
|
@@ -1343,6 +1369,8 @@ var Exo = (function (exports) {
|
|
|
1343
1369
|
|
|
1344
1370
|
let temp$6 = null;
|
|
1345
1371
|
class Interval {
|
|
1372
|
+
min;
|
|
1373
|
+
max;
|
|
1346
1374
|
constructor(min = 0, max = min) {
|
|
1347
1375
|
this.min = min;
|
|
1348
1376
|
this.max = max;
|
|
@@ -1373,6 +1401,7 @@ var Exo = (function (exports) {
|
|
|
1373
1401
|
destroy() {
|
|
1374
1402
|
// todo - check if destroy is needed
|
|
1375
1403
|
}
|
|
1404
|
+
static zero = new Interval(0, 0);
|
|
1376
1405
|
static get temp() {
|
|
1377
1406
|
if (temp$6 === null) {
|
|
1378
1407
|
temp$6 = new Interval();
|
|
@@ -1380,7 +1409,17 @@ var Exo = (function (exports) {
|
|
|
1380
1409
|
return temp$6;
|
|
1381
1410
|
}
|
|
1382
1411
|
}
|
|
1383
|
-
|
|
1412
|
+
|
|
1413
|
+
exports.CollisionType = void 0;
|
|
1414
|
+
(function (CollisionType) {
|
|
1415
|
+
CollisionType[CollisionType["Point"] = 0] = "Point";
|
|
1416
|
+
CollisionType[CollisionType["Line"] = 1] = "Line";
|
|
1417
|
+
CollisionType[CollisionType["Rectangle"] = 2] = "Rectangle";
|
|
1418
|
+
CollisionType[CollisionType["Circle"] = 3] = "Circle";
|
|
1419
|
+
CollisionType[CollisionType["Ellipse"] = 4] = "Ellipse";
|
|
1420
|
+
CollisionType[CollisionType["Polygon"] = 5] = "Polygon";
|
|
1421
|
+
CollisionType[CollisionType["SceneNode"] = 6] = "SceneNode";
|
|
1422
|
+
})(exports.CollisionType || (exports.CollisionType = {}));
|
|
1384
1423
|
|
|
1385
1424
|
const epsilon = 1e-10;
|
|
1386
1425
|
const getCurveSegments = (radiusA, radiusB = radiusA) => (Math.max(16, Math.ceil(Math.sqrt(Math.max(radiusA, radiusB)) * 8)));
|
|
@@ -1534,12 +1573,12 @@ var Exo = (function (exports) {
|
|
|
1534
1573
|
const product = getDotProduct(pointX, pointY, lineX, lineY);
|
|
1535
1574
|
const lengthSq = getVectorLengthSquared(lineX, lineY);
|
|
1536
1575
|
if (product < 0) {
|
|
1537
|
-
return
|
|
1576
|
+
return exports.VoronoiRegion.left;
|
|
1538
1577
|
}
|
|
1539
1578
|
if (product > lengthSq) {
|
|
1540
|
-
return
|
|
1579
|
+
return exports.VoronoiRegion.right;
|
|
1541
1580
|
}
|
|
1542
|
-
return
|
|
1581
|
+
return exports.VoronoiRegion.middle;
|
|
1543
1582
|
};
|
|
1544
1583
|
|
|
1545
1584
|
/**
|
|
@@ -1654,18 +1693,18 @@ var Exo = (function (exports) {
|
|
|
1654
1693
|
const intersectionCircleCircle = ({ x: x1, y: y1, radius: r1 }, { x: x2, y: y2, radius: r2 }) => (getDistance(x1, y1, x2, y2) <= (r1 + r2));
|
|
1655
1694
|
const intersectionCircleEllipse = (circle, ellipse) => (polygonsIntersect(buildCirclePoints(circle), buildEllipsePoints(ellipse)));
|
|
1656
1695
|
const shouldExcludeLeftVoronoi = (circleX, circleY, prevPoint, prevEdge, pointX, pointY, radius, edgeX, edgeY) => {
|
|
1657
|
-
if (getVoronoiRegion(edgeX, edgeY, pointX, pointY) !==
|
|
1696
|
+
if (getVoronoiRegion(edgeX, edgeY, pointX, pointY) !== exports.VoronoiRegion.left) {
|
|
1658
1697
|
return false;
|
|
1659
1698
|
}
|
|
1660
1699
|
const region = getVoronoiRegion(prevEdge.x, prevEdge.y, circleX - prevPoint.x, circleY - prevPoint.y);
|
|
1661
|
-
return region ===
|
|
1700
|
+
return region === exports.VoronoiRegion.right && getVectorLength(pointX, pointY) > radius;
|
|
1662
1701
|
};
|
|
1663
1702
|
const shouldExcludeRightVoronoi = (circleX, circleY, nextPoint, nextEdge, pointX, pointY, radius, edgeX, edgeY) => {
|
|
1664
|
-
if (getVoronoiRegion(edgeX, edgeY, pointX, pointY) !==
|
|
1703
|
+
if (getVoronoiRegion(edgeX, edgeY, pointX, pointY) !== exports.VoronoiRegion.right) {
|
|
1665
1704
|
return false;
|
|
1666
1705
|
}
|
|
1667
1706
|
const region = getVoronoiRegion(nextEdge.x, nextEdge.y, circleX - nextPoint.x, circleY - nextPoint.y);
|
|
1668
|
-
return region ===
|
|
1707
|
+
return region === exports.VoronoiRegion.left && getVectorLength(pointX, pointY) > radius;
|
|
1669
1708
|
};
|
|
1670
1709
|
const shouldExcludeMiddleVoronoi = (pointX, pointY, radius, edgeX, edgeY) => {
|
|
1671
1710
|
const normalX = edgeY;
|
|
@@ -1789,13 +1828,13 @@ var Exo = (function (exports) {
|
|
|
1789
1828
|
if (pointDistanceA > radius) {
|
|
1790
1829
|
containsA = false;
|
|
1791
1830
|
}
|
|
1792
|
-
if (region ===
|
|
1831
|
+
if (region === exports.VoronoiRegion.left) {
|
|
1793
1832
|
const prev = points[i === 0 ? len - 1 : i - 1];
|
|
1794
1833
|
const edgeBx = pointA.x - prev.x;
|
|
1795
1834
|
const edgeBy = pointA.y - prev.y;
|
|
1796
1835
|
const positionBx = x - prev.x;
|
|
1797
1836
|
const positionBy = y - prev.y;
|
|
1798
|
-
if (getVoronoiRegion(edgeBx, edgeBy, positionBx, positionBy) ===
|
|
1837
|
+
if (getVoronoiRegion(edgeBx, edgeBy, positionBx, positionBy) === exports.VoronoiRegion.right) {
|
|
1799
1838
|
if (pointDistanceA > radius) {
|
|
1800
1839
|
projection.destroy();
|
|
1801
1840
|
return null;
|
|
@@ -1808,14 +1847,14 @@ var Exo = (function (exports) {
|
|
|
1808
1847
|
containsB = false;
|
|
1809
1848
|
}
|
|
1810
1849
|
}
|
|
1811
|
-
else if (region ===
|
|
1850
|
+
else if (region === exports.VoronoiRegion.right) {
|
|
1812
1851
|
const next = points[(i + 2) % len];
|
|
1813
1852
|
const edgeBx = next.x - pointB.x;
|
|
1814
1853
|
const edgeBy = next.y - pointB.y;
|
|
1815
1854
|
const positionBx = x - pointB.x;
|
|
1816
1855
|
const positionBy = y - pointB.y;
|
|
1817
1856
|
const pointDistanceB = getVectorLength(positionBx, positionBy);
|
|
1818
|
-
if (getVoronoiRegion(edgeBx, edgeBy, positionBx, positionBy) ===
|
|
1857
|
+
if (getVoronoiRegion(edgeBx, edgeBy, positionBx, positionBy) === exports.VoronoiRegion.left) {
|
|
1819
1858
|
if (pointDistanceB > radius) {
|
|
1820
1859
|
projection.destroy();
|
|
1821
1860
|
return null;
|
|
@@ -1934,10 +1973,12 @@ var Exo = (function (exports) {
|
|
|
1934
1973
|
const noop = () => { };
|
|
1935
1974
|
const tempPoint = new ObservableVector(noop);
|
|
1936
1975
|
class Rectangle {
|
|
1976
|
+
collisionType = exports.CollisionType.Rectangle;
|
|
1977
|
+
_position;
|
|
1978
|
+
_size;
|
|
1979
|
+
_normals = null;
|
|
1980
|
+
_normalsDirty = false;
|
|
1937
1981
|
constructor(x = 0, y = x, width = 0, height = width) {
|
|
1938
|
-
this.collisionType = 2 /* CollisionType.Rectangle */;
|
|
1939
|
-
this._normals = null;
|
|
1940
|
-
this._normalsDirty = false;
|
|
1941
1982
|
this._position = new ObservableVector(() => {
|
|
1942
1983
|
this._normalsDirty = true;
|
|
1943
1984
|
}, x, y);
|
|
@@ -2078,28 +2119,28 @@ var Exo = (function (exports) {
|
|
|
2078
2119
|
}
|
|
2079
2120
|
intersectsWith(target) {
|
|
2080
2121
|
switch (target.collisionType) {
|
|
2081
|
-
case
|
|
2122
|
+
case exports.CollisionType.SceneNode:
|
|
2082
2123
|
return target.isAlignedBox
|
|
2083
2124
|
? intersectionRectRect(this, target.getBounds())
|
|
2084
2125
|
: intersectionSat(this, target);
|
|
2085
|
-
case
|
|
2086
|
-
case
|
|
2087
|
-
case
|
|
2088
|
-
case
|
|
2089
|
-
case
|
|
2090
|
-
case
|
|
2126
|
+
case exports.CollisionType.Rectangle: return intersectionRectRect(this, target);
|
|
2127
|
+
case exports.CollisionType.Polygon: return intersectionRectPoly(this, target);
|
|
2128
|
+
case exports.CollisionType.Circle: return intersectionRectCircle(this, target);
|
|
2129
|
+
case exports.CollisionType.Ellipse: return intersectionRectEllipse(this, target);
|
|
2130
|
+
case exports.CollisionType.Line: return intersectionLineRect(target, this);
|
|
2131
|
+
case exports.CollisionType.Point: return intersectionPointRect(target, this);
|
|
2091
2132
|
default: return false;
|
|
2092
2133
|
}
|
|
2093
2134
|
}
|
|
2094
2135
|
collidesWith(target) {
|
|
2095
2136
|
switch (target.collisionType) {
|
|
2096
|
-
case
|
|
2137
|
+
case exports.CollisionType.SceneNode:
|
|
2097
2138
|
return target.isAlignedBox
|
|
2098
2139
|
? getCollisionRectangleRectangle(this, target.getBounds())
|
|
2099
2140
|
: getCollisionSat(this, target);
|
|
2100
|
-
case
|
|
2101
|
-
case
|
|
2102
|
-
case
|
|
2141
|
+
case exports.CollisionType.Rectangle: return getCollisionRectangleRectangle(this, target);
|
|
2142
|
+
case exports.CollisionType.Polygon: return getCollisionSat(this, target);
|
|
2143
|
+
case exports.CollisionType.Circle: return getCollisionCircleRectangle(target, this, true);
|
|
2103
2144
|
// case CollisionType.Ellipse: return intersectionRectEllipse(this, target as Ellipse);
|
|
2104
2145
|
// case CollisionType.Line: return intersectionLineRect(target as Line, this);
|
|
2105
2146
|
// case CollisionType.Point: return intersectionPointRect(target as Vector, this);
|
|
@@ -2128,14 +2169,12 @@ var Exo = (function (exports) {
|
|
|
2128
2169
|
}
|
|
2129
2170
|
|
|
2130
2171
|
class Bounds {
|
|
2131
|
-
|
|
2132
|
-
|
|
2133
|
-
|
|
2134
|
-
|
|
2135
|
-
|
|
2136
|
-
|
|
2137
|
-
this._rect = new Rectangle();
|
|
2138
|
-
}
|
|
2172
|
+
_minX = Infinity;
|
|
2173
|
+
_minY = Infinity;
|
|
2174
|
+
_maxX = -Infinity;
|
|
2175
|
+
_maxY = -Infinity;
|
|
2176
|
+
_dirty = true;
|
|
2177
|
+
_rect = new Rectangle();
|
|
2139
2178
|
get minX() {
|
|
2140
2179
|
return this._minX;
|
|
2141
2180
|
}
|
|
@@ -2185,19 +2224,16 @@ var Exo = (function (exports) {
|
|
|
2185
2224
|
}
|
|
2186
2225
|
|
|
2187
2226
|
class SceneNode extends Transformable {
|
|
2188
|
-
|
|
2189
|
-
|
|
2190
|
-
|
|
2191
|
-
|
|
2192
|
-
|
|
2193
|
-
|
|
2194
|
-
|
|
2195
|
-
|
|
2196
|
-
|
|
2197
|
-
|
|
2198
|
-
this._childOrder = 0;
|
|
2199
|
-
this._cullable = true;
|
|
2200
|
-
}
|
|
2227
|
+
collisionType = exports.CollisionType.SceneNode;
|
|
2228
|
+
_bounds = new Bounds();
|
|
2229
|
+
_visible = true;
|
|
2230
|
+
_globalTransform = new Matrix();
|
|
2231
|
+
_localBounds = new Rectangle();
|
|
2232
|
+
_anchor = new ObservableVector(this._updateOrigin.bind(this), 0, 0);
|
|
2233
|
+
_parentNode = null;
|
|
2234
|
+
_zIndex = 0;
|
|
2235
|
+
_childOrder = 0;
|
|
2236
|
+
_cullable = true;
|
|
2201
2237
|
get anchor() {
|
|
2202
2238
|
return this._anchor;
|
|
2203
2239
|
}
|
|
@@ -2302,13 +2338,13 @@ var Exo = (function (exports) {
|
|
|
2302
2338
|
return this.getBounds().intersectsWith(target);
|
|
2303
2339
|
}
|
|
2304
2340
|
switch (target.collisionType) {
|
|
2305
|
-
case
|
|
2306
|
-
case
|
|
2307
|
-
case
|
|
2308
|
-
case
|
|
2309
|
-
case
|
|
2310
|
-
case
|
|
2311
|
-
case
|
|
2341
|
+
case exports.CollisionType.SceneNode: return intersectionSat(this, target);
|
|
2342
|
+
case exports.CollisionType.Rectangle: return intersectionSat(this, target);
|
|
2343
|
+
case exports.CollisionType.Polygon: return intersectionSat(this, target);
|
|
2344
|
+
case exports.CollisionType.Circle: return intersectionRectCircle(this.getBounds(), target);
|
|
2345
|
+
case exports.CollisionType.Ellipse: return intersectionRectEllipse(this.getBounds(), target);
|
|
2346
|
+
case exports.CollisionType.Line: return intersectionLineRect(target, this.getBounds());
|
|
2347
|
+
case exports.CollisionType.Point: return intersectionPointRect(target, this.getBounds());
|
|
2312
2348
|
default: return false;
|
|
2313
2349
|
}
|
|
2314
2350
|
}
|
|
@@ -2317,10 +2353,10 @@ var Exo = (function (exports) {
|
|
|
2317
2353
|
return this.getBounds().collidesWith(target);
|
|
2318
2354
|
}
|
|
2319
2355
|
switch (target.collisionType) {
|
|
2320
|
-
case
|
|
2321
|
-
case
|
|
2322
|
-
case
|
|
2323
|
-
case
|
|
2356
|
+
case exports.CollisionType.SceneNode: return getCollisionSat(this, target);
|
|
2357
|
+
case exports.CollisionType.Rectangle: return getCollisionSat(this, target);
|
|
2358
|
+
case exports.CollisionType.Polygon: return getCollisionSat(this, target);
|
|
2359
|
+
case exports.CollisionType.Circle: return getCollisionSat(this, target);
|
|
2324
2360
|
default: return null;
|
|
2325
2361
|
}
|
|
2326
2362
|
}
|
|
@@ -2351,6 +2387,7 @@ var Exo = (function (exports) {
|
|
|
2351
2387
|
}
|
|
2352
2388
|
|
|
2353
2389
|
class ObservableSize extends Size {
|
|
2390
|
+
_callback;
|
|
2354
2391
|
constructor(callback, width = 0, height = 0) {
|
|
2355
2392
|
super(width, height);
|
|
2356
2393
|
this._callback = callback;
|
|
@@ -2415,30 +2452,34 @@ var Exo = (function (exports) {
|
|
|
2415
2452
|
ViewFlags[ViewFlags["VertexTint"] = 128] = "VertexTint";
|
|
2416
2453
|
})(exports.ViewFlags || (exports.ViewFlags = {}));
|
|
2417
2454
|
class View {
|
|
2455
|
+
_center;
|
|
2456
|
+
_size;
|
|
2457
|
+
_viewport = new Rectangle(0, 0, 1, 1);
|
|
2458
|
+
_transform = new Matrix();
|
|
2459
|
+
_inverseTransform = new Matrix();
|
|
2460
|
+
_bounds = new Bounds();
|
|
2461
|
+
_flags = new Flags();
|
|
2462
|
+
_rotation = 0;
|
|
2463
|
+
_sin = 0;
|
|
2464
|
+
_cos = 1;
|
|
2465
|
+
_zoomLevel = 1;
|
|
2466
|
+
_zoomBaseWidth;
|
|
2467
|
+
_zoomBaseHeight;
|
|
2468
|
+
_followTarget = null;
|
|
2469
|
+
_followLerp = 1;
|
|
2470
|
+
_followOffsetX = 0;
|
|
2471
|
+
_followOffsetY = 0;
|
|
2472
|
+
_boundsConstraint = null;
|
|
2473
|
+
_shakeIntensity = 0;
|
|
2474
|
+
_shakeDurationMs = 0;
|
|
2475
|
+
_shakeElapsedMs = 0;
|
|
2476
|
+
_shakeFrequency = 16;
|
|
2477
|
+
_shakeDecay = true;
|
|
2478
|
+
_shakePhase = 0;
|
|
2479
|
+
_shakeOffsetX = 0;
|
|
2480
|
+
_shakeOffsetY = 0;
|
|
2481
|
+
_updateId = 0;
|
|
2418
2482
|
constructor(centerX, centerY, width, height) {
|
|
2419
|
-
this._viewport = new Rectangle(0, 0, 1, 1);
|
|
2420
|
-
this._transform = new Matrix();
|
|
2421
|
-
this._inverseTransform = new Matrix();
|
|
2422
|
-
this._bounds = new Bounds();
|
|
2423
|
-
this._flags = new Flags();
|
|
2424
|
-
this._rotation = 0;
|
|
2425
|
-
this._sin = 0;
|
|
2426
|
-
this._cos = 1;
|
|
2427
|
-
this._zoomLevel = 1;
|
|
2428
|
-
this._followTarget = null;
|
|
2429
|
-
this._followLerp = 1;
|
|
2430
|
-
this._followOffsetX = 0;
|
|
2431
|
-
this._followOffsetY = 0;
|
|
2432
|
-
this._boundsConstraint = null;
|
|
2433
|
-
this._shakeIntensity = 0;
|
|
2434
|
-
this._shakeDurationMs = 0;
|
|
2435
|
-
this._shakeElapsedMs = 0;
|
|
2436
|
-
this._shakeFrequency = 16;
|
|
2437
|
-
this._shakeDecay = true;
|
|
2438
|
-
this._shakePhase = 0;
|
|
2439
|
-
this._shakeOffsetX = 0;
|
|
2440
|
-
this._shakeOffsetY = 0;
|
|
2441
|
-
this._updateId = 0;
|
|
2442
2483
|
this._center = new ObservableVector(this._setPositionDirty.bind(this), centerX, centerY);
|
|
2443
2484
|
this._size = new ObservableSize(this._setScalingDirty.bind(this), width, height);
|
|
2444
2485
|
this._zoomBaseWidth = width;
|
|
@@ -2753,9 +2794,11 @@ var Exo = (function (exports) {
|
|
|
2753
2794
|
|
|
2754
2795
|
let temp$4 = null;
|
|
2755
2796
|
class Vector extends AbstractVector {
|
|
2797
|
+
collisionType = exports.CollisionType.Point;
|
|
2798
|
+
x;
|
|
2799
|
+
y;
|
|
2756
2800
|
constructor(x = 0, y = 0) {
|
|
2757
2801
|
super();
|
|
2758
|
-
this.collisionType = 0 /* CollisionType.Point */;
|
|
2759
2802
|
this.x = x;
|
|
2760
2803
|
this.y = y;
|
|
2761
2804
|
}
|
|
@@ -2769,13 +2812,13 @@ var Exo = (function (exports) {
|
|
|
2769
2812
|
}
|
|
2770
2813
|
intersectsWith(target) {
|
|
2771
2814
|
switch (target.collisionType) {
|
|
2772
|
-
case
|
|
2773
|
-
case
|
|
2774
|
-
case
|
|
2775
|
-
case
|
|
2776
|
-
case
|
|
2777
|
-
case
|
|
2778
|
-
case
|
|
2815
|
+
case exports.CollisionType.SceneNode: return intersectionPointRect(this, target.getBounds());
|
|
2816
|
+
case exports.CollisionType.Rectangle: return intersectionPointRect(this, target);
|
|
2817
|
+
case exports.CollisionType.Polygon: return intersectionPointPoly(this, target);
|
|
2818
|
+
case exports.CollisionType.Circle: return intersectionPointCircle(this, target);
|
|
2819
|
+
case exports.CollisionType.Ellipse: return intersectionPointEllipse(this, target);
|
|
2820
|
+
case exports.CollisionType.Line: return intersectionPointLine(this, target);
|
|
2821
|
+
case exports.CollisionType.Point: return intersectionPointPoint(this, target);
|
|
2779
2822
|
default: return false;
|
|
2780
2823
|
}
|
|
2781
2824
|
}
|
|
@@ -2805,6 +2848,8 @@ var Exo = (function (exports) {
|
|
|
2805
2848
|
}
|
|
2806
2849
|
return temp$4;
|
|
2807
2850
|
}
|
|
2851
|
+
static zero = new Vector(0, 0);
|
|
2852
|
+
static one = new Vector(1, 1);
|
|
2808
2853
|
static add(v1, v2) {
|
|
2809
2854
|
return new Vector(v1.x + v2.x, v1.y + v2.y);
|
|
2810
2855
|
}
|
|
@@ -2818,14 +2863,16 @@ var Exo = (function (exports) {
|
|
|
2818
2863
|
return new Vector(v1.x / v2.x, v1.y / v2.y);
|
|
2819
2864
|
}
|
|
2820
2865
|
}
|
|
2821
|
-
Vector.zero = new Vector(0, 0);
|
|
2822
|
-
Vector.one = new Vector(1, 1);
|
|
2823
2866
|
|
|
2824
2867
|
class RenderTarget {
|
|
2868
|
+
_root;
|
|
2869
|
+
_destroyListeners = new Set();
|
|
2870
|
+
_version = 0;
|
|
2871
|
+
_size;
|
|
2872
|
+
_viewport = new Rectangle();
|
|
2873
|
+
_defaultView;
|
|
2874
|
+
_view;
|
|
2825
2875
|
constructor(width, height, root = false) {
|
|
2826
|
-
this._destroyListeners = new Set();
|
|
2827
|
-
this._version = 0;
|
|
2828
|
-
this._viewport = new Rectangle();
|
|
2829
2876
|
this._size = new Size(width, height);
|
|
2830
2877
|
this._root = root;
|
|
2831
2878
|
this._defaultView = new View(width / 2, height / 2, width, height);
|
|
@@ -2920,10 +2967,22 @@ var Exo = (function (exports) {
|
|
|
2920
2967
|
}
|
|
2921
2968
|
|
|
2922
2969
|
class RenderTexture extends RenderTarget {
|
|
2970
|
+
static defaultSamplerOptions = {
|
|
2971
|
+
scaleMode: exports.ScaleModes.Linear,
|
|
2972
|
+
wrapMode: exports.WrapModes.ClampToEdge,
|
|
2973
|
+
premultiplyAlpha: true,
|
|
2974
|
+
generateMipMap: false,
|
|
2975
|
+
flipY: true,
|
|
2976
|
+
};
|
|
2977
|
+
_source = null;
|
|
2978
|
+
_textureVersion = 0;
|
|
2979
|
+
_scaleMode;
|
|
2980
|
+
_wrapMode;
|
|
2981
|
+
_premultiplyAlpha;
|
|
2982
|
+
_generateMipMap;
|
|
2983
|
+
_flipY;
|
|
2923
2984
|
constructor(width, height, options) {
|
|
2924
2985
|
super(width, height, false);
|
|
2925
|
-
this._source = null;
|
|
2926
|
-
this._textureVersion = 0;
|
|
2927
2986
|
const { scaleMode, wrapMode, premultiplyAlpha, generateMipMap, flipY } = { ...RenderTexture.defaultSamplerOptions, ...options };
|
|
2928
2987
|
this._scaleMode = scaleMode;
|
|
2929
2988
|
this._wrapMode = wrapMode;
|
|
@@ -3023,15 +3082,12 @@ var Exo = (function (exports) {
|
|
|
3023
3082
|
this._textureVersion++;
|
|
3024
3083
|
}
|
|
3025
3084
|
}
|
|
3026
|
-
RenderTexture.defaultSamplerOptions = {
|
|
3027
|
-
scaleMode: exports.ScaleModes.Linear,
|
|
3028
|
-
wrapMode: exports.WrapModes.ClampToEdge,
|
|
3029
|
-
premultiplyAlpha: true,
|
|
3030
|
-
generateMipMap: false,
|
|
3031
|
-
flipY: true,
|
|
3032
|
-
};
|
|
3033
3085
|
|
|
3034
3086
|
class RenderTargetPass {
|
|
3087
|
+
_callback;
|
|
3088
|
+
_target;
|
|
3089
|
+
_view;
|
|
3090
|
+
_clearColor;
|
|
3035
3091
|
constructor(callback, options = {}) {
|
|
3036
3092
|
this._callback = callback;
|
|
3037
3093
|
this._target = options.target ?? null;
|
|
@@ -3058,17 +3114,15 @@ var Exo = (function (exports) {
|
|
|
3058
3114
|
|
|
3059
3115
|
const isDestroyableFilter = (filter) => ('destroy' in filter && typeof filter.destroy === 'function');
|
|
3060
3116
|
class RenderNode extends SceneNode {
|
|
3061
|
-
|
|
3062
|
-
|
|
3063
|
-
|
|
3064
|
-
|
|
3065
|
-
|
|
3066
|
-
|
|
3067
|
-
|
|
3068
|
-
|
|
3069
|
-
|
|
3070
|
-
this._cacheTexture = null;
|
|
3071
|
-
}
|
|
3117
|
+
static _spriteFactory = null;
|
|
3118
|
+
_filters = [];
|
|
3119
|
+
_cacheBounds = new Rectangle();
|
|
3120
|
+
_cacheSprite = null;
|
|
3121
|
+
_captureView = null;
|
|
3122
|
+
_mask = null;
|
|
3123
|
+
_cacheAsBitmap = false;
|
|
3124
|
+
_cacheDirty = true;
|
|
3125
|
+
_cacheTexture = null;
|
|
3072
3126
|
get filters() {
|
|
3073
3127
|
return this._filters;
|
|
3074
3128
|
}
|
|
@@ -3282,14 +3336,10 @@ var Exo = (function (exports) {
|
|
|
3282
3336
|
return this._cacheSprite;
|
|
3283
3337
|
}
|
|
3284
3338
|
}
|
|
3285
|
-
RenderNode._spriteFactory = null;
|
|
3286
3339
|
|
|
3287
3340
|
class Drawable extends RenderNode {
|
|
3288
|
-
|
|
3289
|
-
|
|
3290
|
-
this._tint = Color.white.clone();
|
|
3291
|
-
this._blendMode = exports.BlendModes.Normal;
|
|
3292
|
-
}
|
|
3341
|
+
_tint = Color.white.clone();
|
|
3342
|
+
_blendMode = exports.BlendModes.Normal;
|
|
3293
3343
|
get tint() {
|
|
3294
3344
|
return this._tint;
|
|
3295
3345
|
}
|
|
@@ -3336,6 +3386,9 @@ var Exo = (function (exports) {
|
|
|
3336
3386
|
}
|
|
3337
3387
|
|
|
3338
3388
|
class DrawableShape extends Drawable {
|
|
3389
|
+
geometry;
|
|
3390
|
+
drawMode;
|
|
3391
|
+
color;
|
|
3339
3392
|
constructor(geometry, color, drawMode = exports.RenderingPrimitives.Triangles) {
|
|
3340
3393
|
super();
|
|
3341
3394
|
this.geometry = geometry;
|
|
@@ -3349,6 +3402,9 @@ var Exo = (function (exports) {
|
|
|
3349
3402
|
}
|
|
3350
3403
|
|
|
3351
3404
|
class Geometry {
|
|
3405
|
+
vertices;
|
|
3406
|
+
indices;
|
|
3407
|
+
points;
|
|
3352
3408
|
constructor({ vertices = [], indices = [], points = [], } = {}) {
|
|
3353
3409
|
this.vertices = new Float32Array(vertices);
|
|
3354
3410
|
this.indices = new Uint16Array(indices);
|
|
@@ -3374,47 +3430,15 @@ var Exo = (function (exports) {
|
|
|
3374
3430
|
});
|
|
3375
3431
|
const defaultFadeTransitionDuration = 220;
|
|
3376
3432
|
class SceneManager {
|
|
3433
|
+
_app;
|
|
3434
|
+
_stack = [];
|
|
3435
|
+
_transitionOverlay = new TransitionOverlayShape(createOverlayGeometry(), Color.black, exports.RenderingPrimitives.TriangleStrip);
|
|
3436
|
+
_transition = null;
|
|
3437
|
+
onChangeScene = new Signal();
|
|
3438
|
+
onStartScene = new Signal();
|
|
3439
|
+
onUpdateScene = new Signal();
|
|
3440
|
+
onStopScene = new Signal();
|
|
3377
3441
|
constructor(app) {
|
|
3378
|
-
this._stack = [];
|
|
3379
|
-
this._transitionOverlay = new TransitionOverlayShape(createOverlayGeometry(), Color.black, exports.RenderingPrimitives.TriangleStrip);
|
|
3380
|
-
this._transition = null;
|
|
3381
|
-
this.onChangeScene = new Signal();
|
|
3382
|
-
this.onStartScene = new Signal();
|
|
3383
|
-
this.onUpdateScene = new Signal();
|
|
3384
|
-
this.onStopScene = new Signal();
|
|
3385
|
-
this._handleKeyDown = (channel) => {
|
|
3386
|
-
this._dispatchInput({ type: 'keyDown', channel });
|
|
3387
|
-
};
|
|
3388
|
-
this._handleKeyUp = (channel) => {
|
|
3389
|
-
this._dispatchInput({ type: 'keyUp', channel });
|
|
3390
|
-
};
|
|
3391
|
-
this._handlePointerEnter = (pointer) => {
|
|
3392
|
-
this._dispatchInput({ type: 'pointerEnter', pointer });
|
|
3393
|
-
};
|
|
3394
|
-
this._handlePointerLeave = (pointer) => {
|
|
3395
|
-
this._dispatchInput({ type: 'pointerLeave', pointer });
|
|
3396
|
-
};
|
|
3397
|
-
this._handlePointerDown = (pointer) => {
|
|
3398
|
-
this._dispatchInput({ type: 'pointerDown', pointer });
|
|
3399
|
-
};
|
|
3400
|
-
this._handlePointerMove = (pointer) => {
|
|
3401
|
-
this._dispatchInput({ type: 'pointerMove', pointer });
|
|
3402
|
-
};
|
|
3403
|
-
this._handlePointerUp = (pointer) => {
|
|
3404
|
-
this._dispatchInput({ type: 'pointerUp', pointer });
|
|
3405
|
-
};
|
|
3406
|
-
this._handlePointerTap = (pointer) => {
|
|
3407
|
-
this._dispatchInput({ type: 'pointerTap', pointer });
|
|
3408
|
-
};
|
|
3409
|
-
this._handlePointerSwipe = (pointer) => {
|
|
3410
|
-
this._dispatchInput({ type: 'pointerSwipe', pointer });
|
|
3411
|
-
};
|
|
3412
|
-
this._handlePointerCancel = (pointer) => {
|
|
3413
|
-
this._dispatchInput({ type: 'pointerCancel', pointer });
|
|
3414
|
-
};
|
|
3415
|
-
this._handleMouseWheel = (wheel) => {
|
|
3416
|
-
this._dispatchInput({ type: 'mouseWheel', wheel });
|
|
3417
|
-
};
|
|
3418
3442
|
this._app = app;
|
|
3419
3443
|
this._subscribeInputRouting();
|
|
3420
3444
|
}
|
|
@@ -3529,7 +3553,7 @@ var Exo = (function (exports) {
|
|
|
3529
3553
|
if (cleanupError) {
|
|
3530
3554
|
const initMessage = error instanceof Error ? error.message : String(error);
|
|
3531
3555
|
const cleanupMessage = cleanupError instanceof Error ? cleanupError.message : String(cleanupError);
|
|
3532
|
-
throw new Error(`Failed to initialize scene: ${initMessage}. Cleanup also failed: ${cleanupMessage}
|
|
3556
|
+
throw new Error(`Failed to initialize scene: ${initMessage}. Cleanup also failed: ${cleanupMessage}.`, { cause: error });
|
|
3533
3557
|
}
|
|
3534
3558
|
throw error;
|
|
3535
3559
|
}
|
|
@@ -3639,6 +3663,39 @@ var Exo = (function (exports) {
|
|
|
3639
3663
|
}
|
|
3640
3664
|
}
|
|
3641
3665
|
}
|
|
3666
|
+
_handleKeyDown = (channel) => {
|
|
3667
|
+
this._dispatchInput({ type: 'keyDown', channel });
|
|
3668
|
+
};
|
|
3669
|
+
_handleKeyUp = (channel) => {
|
|
3670
|
+
this._dispatchInput({ type: 'keyUp', channel });
|
|
3671
|
+
};
|
|
3672
|
+
_handlePointerEnter = (pointer) => {
|
|
3673
|
+
this._dispatchInput({ type: 'pointerEnter', pointer });
|
|
3674
|
+
};
|
|
3675
|
+
_handlePointerLeave = (pointer) => {
|
|
3676
|
+
this._dispatchInput({ type: 'pointerLeave', pointer });
|
|
3677
|
+
};
|
|
3678
|
+
_handlePointerDown = (pointer) => {
|
|
3679
|
+
this._dispatchInput({ type: 'pointerDown', pointer });
|
|
3680
|
+
};
|
|
3681
|
+
_handlePointerMove = (pointer) => {
|
|
3682
|
+
this._dispatchInput({ type: 'pointerMove', pointer });
|
|
3683
|
+
};
|
|
3684
|
+
_handlePointerUp = (pointer) => {
|
|
3685
|
+
this._dispatchInput({ type: 'pointerUp', pointer });
|
|
3686
|
+
};
|
|
3687
|
+
_handlePointerTap = (pointer) => {
|
|
3688
|
+
this._dispatchInput({ type: 'pointerTap', pointer });
|
|
3689
|
+
};
|
|
3690
|
+
_handlePointerSwipe = (pointer) => {
|
|
3691
|
+
this._dispatchInput({ type: 'pointerSwipe', pointer });
|
|
3692
|
+
};
|
|
3693
|
+
_handlePointerCancel = (pointer) => {
|
|
3694
|
+
this._dispatchInput({ type: 'pointerCancel', pointer });
|
|
3695
|
+
};
|
|
3696
|
+
_handleMouseWheel = (wheel) => {
|
|
3697
|
+
this._dispatchInput({ type: 'mouseWheel', wheel });
|
|
3698
|
+
};
|
|
3642
3699
|
async _runWithTransition(action, transition) {
|
|
3643
3700
|
if (!transition || transition.type !== 'fade') {
|
|
3644
3701
|
await action();
|
|
@@ -4905,11 +4962,12 @@ var Exo = (function (exports) {
|
|
|
4905
4962
|
}();
|
|
4906
4963
|
|
|
4907
4964
|
class WebGl2VertexArrayObject {
|
|
4965
|
+
_attributes = [];
|
|
4966
|
+
_indexBuffer = null;
|
|
4967
|
+
_drawMode;
|
|
4968
|
+
_runtime = null;
|
|
4969
|
+
_version = 0;
|
|
4908
4970
|
constructor(drawMode = exports.RenderingPrimitives.Triangles) {
|
|
4909
|
-
this._attributes = [];
|
|
4910
|
-
this._indexBuffer = null;
|
|
4911
|
-
this._runtime = null;
|
|
4912
|
-
this._version = 0;
|
|
4913
4971
|
this._drawMode = drawMode;
|
|
4914
4972
|
}
|
|
4915
4973
|
get attributes() {
|
|
@@ -4987,10 +5045,8 @@ var Exo = (function (exports) {
|
|
|
4987
5045
|
* - flush(): submit any batched draw calls to the GPU
|
|
4988
5046
|
*/
|
|
4989
5047
|
class AbstractWebGl2Renderer {
|
|
4990
|
-
|
|
4991
|
-
|
|
4992
|
-
this._runtime = null;
|
|
4993
|
-
}
|
|
5048
|
+
backendType = exports.RenderBackendType.WebGl2;
|
|
5049
|
+
_runtime = null;
|
|
4994
5050
|
connect(runtime) {
|
|
4995
5051
|
if (this._runtime !== null) {
|
|
4996
5052
|
return;
|
|
@@ -5030,10 +5086,12 @@ var Exo = (function (exports) {
|
|
|
5030
5086
|
}
|
|
5031
5087
|
|
|
5032
5088
|
class Shader {
|
|
5089
|
+
attributes = new Map();
|
|
5090
|
+
uniforms = new Map();
|
|
5091
|
+
_vertexSource;
|
|
5092
|
+
_fragmentSource;
|
|
5093
|
+
_runtime = null;
|
|
5033
5094
|
constructor(vertexSource, fragmentSource) {
|
|
5034
|
-
this.attributes = new Map();
|
|
5035
|
-
this.uniforms = new Map();
|
|
5036
|
-
this._runtime = null;
|
|
5037
5095
|
this._vertexSource = vertexSource;
|
|
5038
5096
|
this._fragmentSource = fragmentSource;
|
|
5039
5097
|
}
|
|
@@ -5144,8 +5202,12 @@ var Exo = (function (exports) {
|
|
|
5144
5202
|
};
|
|
5145
5203
|
|
|
5146
5204
|
class ShaderAttribute {
|
|
5205
|
+
index;
|
|
5206
|
+
name;
|
|
5207
|
+
type;
|
|
5208
|
+
size;
|
|
5209
|
+
location = -1;
|
|
5147
5210
|
constructor(index, name, type) {
|
|
5148
|
-
this.location = -1;
|
|
5149
5211
|
this.index = index;
|
|
5150
5212
|
this.name = name;
|
|
5151
5213
|
this.type = type;
|
|
@@ -5157,8 +5219,13 @@ var Exo = (function (exports) {
|
|
|
5157
5219
|
}
|
|
5158
5220
|
|
|
5159
5221
|
class ShaderUniform {
|
|
5222
|
+
index;
|
|
5223
|
+
type;
|
|
5224
|
+
size;
|
|
5225
|
+
name;
|
|
5226
|
+
_value;
|
|
5227
|
+
_dirty = true;
|
|
5160
5228
|
constructor(index, type, size, name, data) {
|
|
5161
|
-
this._dirty = true;
|
|
5162
5229
|
this.name = name.replace(/\[.*?]/, '');
|
|
5163
5230
|
this.index = index;
|
|
5164
5231
|
this.type = type;
|
|
@@ -5188,8 +5255,16 @@ var Exo = (function (exports) {
|
|
|
5188
5255
|
}
|
|
5189
5256
|
|
|
5190
5257
|
class WebGl2ShaderBlock {
|
|
5258
|
+
index;
|
|
5259
|
+
name;
|
|
5260
|
+
binding;
|
|
5261
|
+
dataSize;
|
|
5262
|
+
_context;
|
|
5263
|
+
_program;
|
|
5264
|
+
_blockData;
|
|
5265
|
+
_uniformBuffer;
|
|
5266
|
+
_uniforms = new Map();
|
|
5191
5267
|
constructor(gl, program, index) {
|
|
5192
|
-
this._uniforms = new Map();
|
|
5193
5268
|
this._context = gl;
|
|
5194
5269
|
this._program = program;
|
|
5195
5270
|
this.index = index;
|
|
@@ -5391,10 +5466,12 @@ var Exo = (function (exports) {
|
|
|
5391
5466
|
}
|
|
5392
5467
|
|
|
5393
5468
|
class WebGl2RenderBuffer {
|
|
5469
|
+
_type;
|
|
5470
|
+
_usage;
|
|
5471
|
+
_runtime = null;
|
|
5472
|
+
_data = emptyArrayBuffer;
|
|
5473
|
+
_version = 0;
|
|
5394
5474
|
constructor(type, data, usage) {
|
|
5395
|
-
this._runtime = null;
|
|
5396
|
-
this._data = emptyArrayBuffer;
|
|
5397
|
-
this._version = 0;
|
|
5398
5475
|
this._type = type;
|
|
5399
5476
|
this._usage = usage;
|
|
5400
5477
|
if (data) {
|
|
@@ -5476,17 +5553,24 @@ var Exo = (function (exports) {
|
|
|
5476
5553
|
};
|
|
5477
5554
|
|
|
5478
5555
|
class AbstractWebGl2BatchedRenderer extends AbstractWebGl2Renderer {
|
|
5556
|
+
attributeCount;
|
|
5557
|
+
batchSize;
|
|
5558
|
+
indexData;
|
|
5559
|
+
vertexData;
|
|
5560
|
+
float32View;
|
|
5561
|
+
uint32View;
|
|
5562
|
+
shader;
|
|
5563
|
+
batchIndex = 0;
|
|
5564
|
+
currentTexture = null;
|
|
5565
|
+
currentBlendMode = null;
|
|
5566
|
+
currentView = null;
|
|
5567
|
+
currentViewId = -1;
|
|
5568
|
+
vao = null;
|
|
5569
|
+
indexBuffer = null;
|
|
5570
|
+
vertexBuffer = null;
|
|
5571
|
+
connection = null;
|
|
5479
5572
|
constructor(batchSize, attributeCount, vertexSource, fragmentSource) {
|
|
5480
5573
|
super();
|
|
5481
|
-
this.batchIndex = 0;
|
|
5482
|
-
this.currentTexture = null;
|
|
5483
|
-
this.currentBlendMode = null;
|
|
5484
|
-
this.currentView = null;
|
|
5485
|
-
this.currentViewId = -1;
|
|
5486
|
-
this.vao = null;
|
|
5487
|
-
this.indexBuffer = null;
|
|
5488
|
-
this.vertexBuffer = null;
|
|
5489
|
-
this.connection = null;
|
|
5490
5574
|
this.batchSize = batchSize;
|
|
5491
5575
|
this.attributeCount = attributeCount;
|
|
5492
5576
|
this.vertexData = new ArrayBuffer(batchSize * attributeCount * 4);
|
|
@@ -5828,13 +5912,19 @@ var Exo = (function (exports) {
|
|
|
5828
5912
|
const vertexStrideBytes$2 = 12;
|
|
5829
5913
|
const vertexStrideWords = vertexStrideBytes$2 / 4;
|
|
5830
5914
|
class WebGl2PrimitiveRenderer extends AbstractWebGl2Renderer {
|
|
5915
|
+
_vertexCapacity;
|
|
5916
|
+
_indexCapacity;
|
|
5917
|
+
_vertexData;
|
|
5918
|
+
_indexData;
|
|
5919
|
+
_float32View;
|
|
5920
|
+
_uint32View;
|
|
5921
|
+
_shader = new Shader(vertexSource, fragmentSource);
|
|
5922
|
+
_connection = null;
|
|
5923
|
+
_currentBlendMode = null;
|
|
5924
|
+
_currentView = null;
|
|
5925
|
+
_viewId = -1;
|
|
5831
5926
|
constructor(batchSize) {
|
|
5832
5927
|
super();
|
|
5833
|
-
this._shader = new Shader(vertexSource, fragmentSource);
|
|
5834
|
-
this._connection = null;
|
|
5835
|
-
this._currentBlendMode = null;
|
|
5836
|
-
this._currentView = null;
|
|
5837
|
-
this._viewId = -1;
|
|
5838
5928
|
this._vertexCapacity = Math.max(minBatchVertexSize, batchSize);
|
|
5839
5929
|
this._indexCapacity = Math.max(6, this._vertexCapacity * 3);
|
|
5840
5930
|
this._vertexData = new ArrayBuffer(this._vertexCapacity * vertexStrideBytes$2);
|
|
@@ -6038,12 +6128,12 @@ var Exo = (function (exports) {
|
|
|
6038
6128
|
SpriteFlags[SpriteFlags["VertexTint"] = 128] = "VertexTint";
|
|
6039
6129
|
})(exports.SpriteFlags || (exports.SpriteFlags = {}));
|
|
6040
6130
|
class Sprite extends Drawable {
|
|
6131
|
+
_texture = null;
|
|
6132
|
+
_textureFrame = new Rectangle();
|
|
6133
|
+
_vertices = new Float32Array(8);
|
|
6134
|
+
_texCoords = new Uint32Array(4);
|
|
6041
6135
|
constructor(texture) {
|
|
6042
6136
|
super();
|
|
6043
|
-
this._texture = null;
|
|
6044
|
-
this._textureFrame = new Rectangle();
|
|
6045
|
-
this._vertices = new Float32Array(8);
|
|
6046
|
-
this._texCoords = new Uint32Array(4);
|
|
6047
6137
|
if (texture !== null) {
|
|
6048
6138
|
this.setTexture(texture);
|
|
6049
6139
|
}
|
|
@@ -6186,17 +6276,15 @@ var Exo = (function (exports) {
|
|
|
6186
6276
|
RenderNode.setInternalSpriteFactory(() => new Sprite(null));
|
|
6187
6277
|
|
|
6188
6278
|
class Particle {
|
|
6189
|
-
|
|
6190
|
-
|
|
6191
|
-
|
|
6192
|
-
|
|
6193
|
-
|
|
6194
|
-
|
|
6195
|
-
|
|
6196
|
-
|
|
6197
|
-
|
|
6198
|
-
this._tint = Color.white.clone();
|
|
6199
|
-
}
|
|
6279
|
+
_totalLifetime = Time.oneSecond.clone();
|
|
6280
|
+
_elapsedLifetime = Time.zero.clone();
|
|
6281
|
+
_position = Vector.zero.clone();
|
|
6282
|
+
_velocity = Vector.zero.clone();
|
|
6283
|
+
_scale = Vector.one.clone();
|
|
6284
|
+
_rotation = 0;
|
|
6285
|
+
_rotationSpeed = 0;
|
|
6286
|
+
_textureIndex = 0;
|
|
6287
|
+
_tint = Color.white.clone();
|
|
6200
6288
|
get totalLifetime() {
|
|
6201
6289
|
return this._totalLifetime;
|
|
6202
6290
|
}
|
|
@@ -6287,17 +6375,18 @@ var Exo = (function (exports) {
|
|
|
6287
6375
|
}
|
|
6288
6376
|
|
|
6289
6377
|
class ParticleSystem extends Drawable {
|
|
6378
|
+
_emitters = [];
|
|
6379
|
+
_affectors = [];
|
|
6380
|
+
_particles = [];
|
|
6381
|
+
_graveyard = [];
|
|
6382
|
+
_texture;
|
|
6383
|
+
_textureFrame = new Rectangle();
|
|
6384
|
+
_vertices = new Float32Array(4);
|
|
6385
|
+
_texCoords = new Uint32Array(4);
|
|
6386
|
+
_updateTexCoords = true;
|
|
6387
|
+
_updateVertices = true;
|
|
6290
6388
|
constructor(texture) {
|
|
6291
6389
|
super();
|
|
6292
|
-
this._emitters = [];
|
|
6293
|
-
this._affectors = [];
|
|
6294
|
-
this._particles = [];
|
|
6295
|
-
this._graveyard = [];
|
|
6296
|
-
this._textureFrame = new Rectangle();
|
|
6297
|
-
this._vertices = new Float32Array(4);
|
|
6298
|
-
this._texCoords = new Uint32Array(4);
|
|
6299
|
-
this._updateTexCoords = true;
|
|
6300
|
-
this._updateVertices = true;
|
|
6301
6390
|
this._texture = texture;
|
|
6302
6391
|
this.resetTextureFrame();
|
|
6303
6392
|
}
|
|
@@ -6466,6 +6555,16 @@ var Exo = (function (exports) {
|
|
|
6466
6555
|
}
|
|
6467
6556
|
|
|
6468
6557
|
class Texture {
|
|
6558
|
+
static _black = null;
|
|
6559
|
+
static _white = null;
|
|
6560
|
+
static defaultSamplerOptions = {
|
|
6561
|
+
scaleMode: exports.ScaleModes.Linear,
|
|
6562
|
+
wrapMode: exports.WrapModes.ClampToEdge,
|
|
6563
|
+
premultiplyAlpha: true,
|
|
6564
|
+
generateMipMap: true,
|
|
6565
|
+
flipY: false,
|
|
6566
|
+
};
|
|
6567
|
+
static empty = new Texture(null);
|
|
6469
6568
|
static get black() {
|
|
6470
6569
|
if (Texture._black === null) {
|
|
6471
6570
|
Texture._black = new Texture(createCanvas({ fillStyle: '#000' }));
|
|
@@ -6478,14 +6577,16 @@ var Exo = (function (exports) {
|
|
|
6478
6577
|
}
|
|
6479
6578
|
return Texture._white;
|
|
6480
6579
|
}
|
|
6580
|
+
_version = 0;
|
|
6581
|
+
_source = null;
|
|
6582
|
+
_size = new Size(0, 0);
|
|
6583
|
+
_destroyListeners = new Set();
|
|
6584
|
+
_scaleMode;
|
|
6585
|
+
_wrapMode;
|
|
6586
|
+
_premultiplyAlpha = false;
|
|
6587
|
+
_generateMipMap = false;
|
|
6588
|
+
_flipY = false;
|
|
6481
6589
|
constructor(source = null, options) {
|
|
6482
|
-
this._version = 0;
|
|
6483
|
-
this._source = null;
|
|
6484
|
-
this._size = new Size(0, 0);
|
|
6485
|
-
this._destroyListeners = new Set();
|
|
6486
|
-
this._premultiplyAlpha = false;
|
|
6487
|
-
this._generateMipMap = false;
|
|
6488
|
-
this._flipY = false;
|
|
6489
6590
|
const { scaleMode, wrapMode, premultiplyAlpha, generateMipMap, flipY } = { ...Texture.defaultSamplerOptions, ...options };
|
|
6490
6591
|
this._scaleMode = scaleMode;
|
|
6491
6592
|
this._wrapMode = wrapMode;
|
|
@@ -6617,16 +6718,6 @@ var Exo = (function (exports) {
|
|
|
6617
6718
|
this._version++;
|
|
6618
6719
|
}
|
|
6619
6720
|
}
|
|
6620
|
-
Texture._black = null;
|
|
6621
|
-
Texture._white = null;
|
|
6622
|
-
Texture.defaultSamplerOptions = {
|
|
6623
|
-
scaleMode: exports.ScaleModes.Linear,
|
|
6624
|
-
wrapMode: exports.WrapModes.ClampToEdge,
|
|
6625
|
-
premultiplyAlpha: true,
|
|
6626
|
-
generateMipMap: true,
|
|
6627
|
-
flipY: false,
|
|
6628
|
-
};
|
|
6629
|
-
Texture.empty = new Texture(null);
|
|
6630
6721
|
|
|
6631
6722
|
/**
|
|
6632
6723
|
* Instance-based renderer registry.
|
|
@@ -6642,10 +6733,8 @@ var Exo = (function (exports) {
|
|
|
6642
6733
|
* custom renderer registration.
|
|
6643
6734
|
*/
|
|
6644
6735
|
class RendererRegistry {
|
|
6645
|
-
|
|
6646
|
-
|
|
6647
|
-
this._runtime = null;
|
|
6648
|
-
}
|
|
6736
|
+
_renderers = new Map();
|
|
6737
|
+
_runtime = null;
|
|
6649
6738
|
/**
|
|
6650
6739
|
* Register a renderer for a specific drawable type.
|
|
6651
6740
|
*
|
|
@@ -6754,27 +6843,35 @@ var Exo = (function (exports) {
|
|
|
6754
6843
|
validateNoneOfTheArgsAreUndefined(functionName, args);
|
|
6755
6844
|
};
|
|
6756
6845
|
class WebGl2RenderManager {
|
|
6846
|
+
backendType = exports.RenderBackendType.WebGl2;
|
|
6847
|
+
rendererRegistry = new RendererRegistry();
|
|
6848
|
+
_context;
|
|
6849
|
+
_rootRenderTarget;
|
|
6850
|
+
_onContextLostHandler;
|
|
6851
|
+
_onContextRestoredHandler;
|
|
6852
|
+
_textureStates = new Map();
|
|
6853
|
+
_renderTargetStates = new Map();
|
|
6854
|
+
_textureDestroyHandlers = new Map();
|
|
6855
|
+
_renderTargetDestroyHandlers = new Map();
|
|
6856
|
+
_temporaryRenderTextures = [];
|
|
6857
|
+
_maskStack = [];
|
|
6858
|
+
_maskPixelStack = [];
|
|
6859
|
+
_maskPointA = new Vector();
|
|
6860
|
+
_maskPointB = new Vector();
|
|
6861
|
+
_canvas;
|
|
6862
|
+
_contextLost;
|
|
6863
|
+
_renderTarget;
|
|
6864
|
+
_renderer = null;
|
|
6865
|
+
_shader = null;
|
|
6866
|
+
_blendMode = null;
|
|
6867
|
+
_texture = null;
|
|
6868
|
+
_textureUnit = 0;
|
|
6869
|
+
_vao = null;
|
|
6870
|
+
_clearColor = new Color();
|
|
6871
|
+
_cursor;
|
|
6872
|
+
_boundFramebuffer = null;
|
|
6873
|
+
_stats = createRenderStats();
|
|
6757
6874
|
constructor(app) {
|
|
6758
|
-
this.backendType = exports.RenderBackendType.WebGl2;
|
|
6759
|
-
this.rendererRegistry = new RendererRegistry();
|
|
6760
|
-
this._textureStates = new Map();
|
|
6761
|
-
this._renderTargetStates = new Map();
|
|
6762
|
-
this._textureDestroyHandlers = new Map();
|
|
6763
|
-
this._renderTargetDestroyHandlers = new Map();
|
|
6764
|
-
this._temporaryRenderTextures = [];
|
|
6765
|
-
this._maskStack = [];
|
|
6766
|
-
this._maskPixelStack = [];
|
|
6767
|
-
this._maskPointA = new Vector();
|
|
6768
|
-
this._maskPointB = new Vector();
|
|
6769
|
-
this._renderer = null;
|
|
6770
|
-
this._shader = null;
|
|
6771
|
-
this._blendMode = null;
|
|
6772
|
-
this._texture = null;
|
|
6773
|
-
this._textureUnit = 0;
|
|
6774
|
-
this._vao = null;
|
|
6775
|
-
this._clearColor = new Color();
|
|
6776
|
-
this._boundFramebuffer = null;
|
|
6777
|
-
this._stats = createRenderStats();
|
|
6778
6875
|
const { width, height, clearColor, webglAttributes, debug, spriteRendererBatchSize, particleRendererBatchSize, primitiveRendererBatchSize, } = app.options;
|
|
6779
6876
|
this._canvas = app.canvas;
|
|
6780
6877
|
const gl = this._createContext(webglAttributes);
|
|
@@ -7322,10 +7419,8 @@ var Exo = (function (exports) {
|
|
|
7322
7419
|
* - flush(): encode and submit command buffers for all collected draw calls
|
|
7323
7420
|
*/
|
|
7324
7421
|
class AbstractWebGpuRenderer {
|
|
7325
|
-
|
|
7326
|
-
|
|
7327
|
-
this._runtime = null;
|
|
7328
|
-
}
|
|
7422
|
+
backendType = exports.RenderBackendType.WebGpu;
|
|
7423
|
+
_runtime = null;
|
|
7329
7424
|
connect(runtime) {
|
|
7330
7425
|
if (this._runtime !== null) {
|
|
7331
7426
|
return;
|
|
@@ -7466,27 +7561,24 @@ fn fragmentMain(input: VertexOutput) -> @location(0) vec4<f32> {
|
|
|
7466
7561
|
const vertexStrideBytes$1 = 20;
|
|
7467
7562
|
const wordsPerVertex$1 = vertexStrideBytes$1 / Uint32Array.BYTES_PER_ELEMENT;
|
|
7468
7563
|
class WebGpuPrimitiveRenderer extends AbstractWebGpuRenderer {
|
|
7469
|
-
|
|
7470
|
-
|
|
7471
|
-
|
|
7472
|
-
|
|
7473
|
-
|
|
7474
|
-
|
|
7475
|
-
|
|
7476
|
-
|
|
7477
|
-
|
|
7478
|
-
|
|
7479
|
-
|
|
7480
|
-
|
|
7481
|
-
|
|
7482
|
-
|
|
7483
|
-
|
|
7484
|
-
|
|
7485
|
-
|
|
7486
|
-
|
|
7487
|
-
this._generatedIndexData = new Uint16Array(0);
|
|
7488
|
-
this._sequentialIndexData = new Uint16Array(0);
|
|
7489
|
-
}
|
|
7564
|
+
_combinedTransform = new Matrix();
|
|
7565
|
+
_drawCalls = [];
|
|
7566
|
+
_drawCallCount = 0;
|
|
7567
|
+
_pipelines = new Map();
|
|
7568
|
+
_renderManager = null;
|
|
7569
|
+
_device = null;
|
|
7570
|
+
_shaderModule = null;
|
|
7571
|
+
_pipelineLayout = null;
|
|
7572
|
+
_vertexBuffer = null;
|
|
7573
|
+
_indexBuffer = null;
|
|
7574
|
+
_vertexBufferCapacity = 0;
|
|
7575
|
+
_indexBufferCapacity = 0;
|
|
7576
|
+
_vertexData = new ArrayBuffer(0);
|
|
7577
|
+
_float32View = new Float32Array(this._vertexData);
|
|
7578
|
+
_uint32View = new Uint32Array(this._vertexData);
|
|
7579
|
+
_packedIndexData = new Uint16Array(0);
|
|
7580
|
+
_generatedIndexData = new Uint16Array(0);
|
|
7581
|
+
_sequentialIndexData = new Uint16Array(0);
|
|
7490
7582
|
render(shape) {
|
|
7491
7583
|
const runtime = this._renderManager;
|
|
7492
7584
|
if (runtime === null) {
|
|
@@ -7917,121 +8009,121 @@ fn fragmentMain(input: VertexOutput) -> @location(0) vec4<f32> {
|
|
|
7917
8009
|
}
|
|
7918
8010
|
|
|
7919
8011
|
/// <reference types="@webgpu/types" />
|
|
7920
|
-
const spriteShaderSource = `
|
|
7921
|
-
struct ProjectionUniforms {
|
|
7922
|
-
matrix: mat4x4<f32>,
|
|
7923
|
-
};
|
|
7924
|
-
|
|
7925
|
-
@group(0) @binding(0)
|
|
7926
|
-
var<uniform> projection: ProjectionUniforms;
|
|
7927
|
-
|
|
7928
|
-
@group(1) @binding(0)
|
|
7929
|
-
var spriteTexture0: texture_2d<f32>;
|
|
7930
|
-
@group(1) @binding(1)
|
|
7931
|
-
var spriteTexture1: texture_2d<f32>;
|
|
7932
|
-
@group(1) @binding(2)
|
|
7933
|
-
var spriteTexture2: texture_2d<f32>;
|
|
7934
|
-
@group(1) @binding(3)
|
|
7935
|
-
var spriteTexture3: texture_2d<f32>;
|
|
7936
|
-
@group(1) @binding(4)
|
|
7937
|
-
var spriteTexture4: texture_2d<f32>;
|
|
7938
|
-
@group(1) @binding(5)
|
|
7939
|
-
var spriteTexture5: texture_2d<f32>;
|
|
7940
|
-
@group(1) @binding(6)
|
|
7941
|
-
var spriteTexture6: texture_2d<f32>;
|
|
7942
|
-
@group(1) @binding(7)
|
|
7943
|
-
var spriteTexture7: texture_2d<f32>;
|
|
7944
|
-
|
|
7945
|
-
@group(1) @binding(8)
|
|
7946
|
-
var spriteSampler0: sampler;
|
|
7947
|
-
@group(1) @binding(9)
|
|
7948
|
-
var spriteSampler1: sampler;
|
|
7949
|
-
@group(1) @binding(10)
|
|
7950
|
-
var spriteSampler2: sampler;
|
|
7951
|
-
@group(1) @binding(11)
|
|
7952
|
-
var spriteSampler3: sampler;
|
|
7953
|
-
@group(1) @binding(12)
|
|
7954
|
-
var spriteSampler4: sampler;
|
|
7955
|
-
@group(1) @binding(13)
|
|
7956
|
-
var spriteSampler5: sampler;
|
|
7957
|
-
@group(1) @binding(14)
|
|
7958
|
-
var spriteSampler6: sampler;
|
|
7959
|
-
@group(1) @binding(15)
|
|
7960
|
-
var spriteSampler7: sampler;
|
|
7961
|
-
|
|
7962
|
-
struct VertexInput {
|
|
7963
|
-
@location(0) position: vec2<f32>,
|
|
7964
|
-
@location(1) texcoord: vec2<f32>,
|
|
7965
|
-
@location(2) color: vec4<f32>,
|
|
7966
|
-
@location(3) premultiplySample: u32,
|
|
7967
|
-
@location(4) textureSlot: u32,
|
|
7968
|
-
};
|
|
7969
|
-
|
|
7970
|
-
struct VertexOutput {
|
|
7971
|
-
@builtin(position) position: vec4<f32>,
|
|
7972
|
-
@location(0) texcoord: vec2<f32>,
|
|
7973
|
-
@location(1) color: vec4<f32>,
|
|
7974
|
-
@location(2) @interpolate(flat) premultiplySample: u32,
|
|
7975
|
-
@location(3) @interpolate(flat) textureSlot: u32,
|
|
7976
|
-
};
|
|
7977
|
-
|
|
7978
|
-
@vertex
|
|
7979
|
-
fn vertexMain(input: VertexInput) -> VertexOutput {
|
|
7980
|
-
var output: VertexOutput;
|
|
7981
|
-
|
|
7982
|
-
output.position = projection.matrix * vec4<f32>(input.position, 0.0, 1.0);
|
|
7983
|
-
output.texcoord = input.texcoord;
|
|
7984
|
-
output.color = vec4(input.color.rgb * input.color.a, input.color.a);
|
|
7985
|
-
output.premultiplySample = input.premultiplySample;
|
|
7986
|
-
output.textureSlot = input.textureSlot;
|
|
7987
|
-
|
|
7988
|
-
return output;
|
|
7989
|
-
}
|
|
7990
|
-
|
|
7991
|
-
fn sampleTexture(slot: u32, uv: vec2<f32>, ddx: vec2<f32>, ddy: vec2<f32>) -> vec4<f32> {
|
|
7992
|
-
switch slot {
|
|
7993
|
-
case 0u: {
|
|
7994
|
-
return textureSampleGrad(spriteTexture0, spriteSampler0, uv, ddx, ddy);
|
|
7995
|
-
}
|
|
7996
|
-
case 1u: {
|
|
7997
|
-
return textureSampleGrad(spriteTexture1, spriteSampler1, uv, ddx, ddy);
|
|
7998
|
-
}
|
|
7999
|
-
case 2u: {
|
|
8000
|
-
return textureSampleGrad(spriteTexture2, spriteSampler2, uv, ddx, ddy);
|
|
8001
|
-
}
|
|
8002
|
-
case 3u: {
|
|
8003
|
-
return textureSampleGrad(spriteTexture3, spriteSampler3, uv, ddx, ddy);
|
|
8004
|
-
}
|
|
8005
|
-
case 4u: {
|
|
8006
|
-
return textureSampleGrad(spriteTexture4, spriteSampler4, uv, ddx, ddy);
|
|
8007
|
-
}
|
|
8008
|
-
case 5u: {
|
|
8009
|
-
return textureSampleGrad(spriteTexture5, spriteSampler5, uv, ddx, ddy);
|
|
8010
|
-
}
|
|
8011
|
-
case 6u: {
|
|
8012
|
-
return textureSampleGrad(spriteTexture6, spriteSampler6, uv, ddx, ddy);
|
|
8013
|
-
}
|
|
8014
|
-
default: {
|
|
8015
|
-
return textureSampleGrad(spriteTexture7, spriteSampler7, uv, ddx, ddy);
|
|
8016
|
-
}
|
|
8017
|
-
}
|
|
8018
|
-
}
|
|
8019
|
-
|
|
8020
|
-
@fragment
|
|
8021
|
-
fn fragmentMain(input: VertexOutput) -> @location(0) vec4<f32> {
|
|
8022
|
-
// Compute screen-space derivatives in uniform control flow before the
|
|
8023
|
-
// per-slot switch. WGSL requires textureSample (implicit LOD) to run in
|
|
8024
|
-
// uniform control flow, which multi-texture batching breaks because the
|
|
8025
|
-
// slot varies per fragment. textureSampleGrad takes explicit derivatives
|
|
8026
|
-
// and is valid regardless of control-flow uniformity, while preserving
|
|
8027
|
-
// mipmap-correct LOD when sprites use mipmapped textures.
|
|
8028
|
-
let ddx = dpdx(input.texcoord);
|
|
8029
|
-
let ddy = dpdy(input.texcoord);
|
|
8030
|
-
let sample = sampleTexture(input.textureSlot, input.texcoord, ddx, ddy);
|
|
8031
|
-
let resolvedSample = select(sample, vec4(sample.rgb * sample.a, sample.a), input.premultiplySample == 1u);
|
|
8032
|
-
|
|
8033
|
-
return resolvedSample * input.color;
|
|
8034
|
-
}
|
|
8012
|
+
const spriteShaderSource = `
|
|
8013
|
+
struct ProjectionUniforms {
|
|
8014
|
+
matrix: mat4x4<f32>,
|
|
8015
|
+
};
|
|
8016
|
+
|
|
8017
|
+
@group(0) @binding(0)
|
|
8018
|
+
var<uniform> projection: ProjectionUniforms;
|
|
8019
|
+
|
|
8020
|
+
@group(1) @binding(0)
|
|
8021
|
+
var spriteTexture0: texture_2d<f32>;
|
|
8022
|
+
@group(1) @binding(1)
|
|
8023
|
+
var spriteTexture1: texture_2d<f32>;
|
|
8024
|
+
@group(1) @binding(2)
|
|
8025
|
+
var spriteTexture2: texture_2d<f32>;
|
|
8026
|
+
@group(1) @binding(3)
|
|
8027
|
+
var spriteTexture3: texture_2d<f32>;
|
|
8028
|
+
@group(1) @binding(4)
|
|
8029
|
+
var spriteTexture4: texture_2d<f32>;
|
|
8030
|
+
@group(1) @binding(5)
|
|
8031
|
+
var spriteTexture5: texture_2d<f32>;
|
|
8032
|
+
@group(1) @binding(6)
|
|
8033
|
+
var spriteTexture6: texture_2d<f32>;
|
|
8034
|
+
@group(1) @binding(7)
|
|
8035
|
+
var spriteTexture7: texture_2d<f32>;
|
|
8036
|
+
|
|
8037
|
+
@group(1) @binding(8)
|
|
8038
|
+
var spriteSampler0: sampler;
|
|
8039
|
+
@group(1) @binding(9)
|
|
8040
|
+
var spriteSampler1: sampler;
|
|
8041
|
+
@group(1) @binding(10)
|
|
8042
|
+
var spriteSampler2: sampler;
|
|
8043
|
+
@group(1) @binding(11)
|
|
8044
|
+
var spriteSampler3: sampler;
|
|
8045
|
+
@group(1) @binding(12)
|
|
8046
|
+
var spriteSampler4: sampler;
|
|
8047
|
+
@group(1) @binding(13)
|
|
8048
|
+
var spriteSampler5: sampler;
|
|
8049
|
+
@group(1) @binding(14)
|
|
8050
|
+
var spriteSampler6: sampler;
|
|
8051
|
+
@group(1) @binding(15)
|
|
8052
|
+
var spriteSampler7: sampler;
|
|
8053
|
+
|
|
8054
|
+
struct VertexInput {
|
|
8055
|
+
@location(0) position: vec2<f32>,
|
|
8056
|
+
@location(1) texcoord: vec2<f32>,
|
|
8057
|
+
@location(2) color: vec4<f32>,
|
|
8058
|
+
@location(3) premultiplySample: u32,
|
|
8059
|
+
@location(4) textureSlot: u32,
|
|
8060
|
+
};
|
|
8061
|
+
|
|
8062
|
+
struct VertexOutput {
|
|
8063
|
+
@builtin(position) position: vec4<f32>,
|
|
8064
|
+
@location(0) texcoord: vec2<f32>,
|
|
8065
|
+
@location(1) color: vec4<f32>,
|
|
8066
|
+
@location(2) @interpolate(flat) premultiplySample: u32,
|
|
8067
|
+
@location(3) @interpolate(flat) textureSlot: u32,
|
|
8068
|
+
};
|
|
8069
|
+
|
|
8070
|
+
@vertex
|
|
8071
|
+
fn vertexMain(input: VertexInput) -> VertexOutput {
|
|
8072
|
+
var output: VertexOutput;
|
|
8073
|
+
|
|
8074
|
+
output.position = projection.matrix * vec4<f32>(input.position, 0.0, 1.0);
|
|
8075
|
+
output.texcoord = input.texcoord;
|
|
8076
|
+
output.color = vec4(input.color.rgb * input.color.a, input.color.a);
|
|
8077
|
+
output.premultiplySample = input.premultiplySample;
|
|
8078
|
+
output.textureSlot = input.textureSlot;
|
|
8079
|
+
|
|
8080
|
+
return output;
|
|
8081
|
+
}
|
|
8082
|
+
|
|
8083
|
+
fn sampleTexture(slot: u32, uv: vec2<f32>, ddx: vec2<f32>, ddy: vec2<f32>) -> vec4<f32> {
|
|
8084
|
+
switch slot {
|
|
8085
|
+
case 0u: {
|
|
8086
|
+
return textureSampleGrad(spriteTexture0, spriteSampler0, uv, ddx, ddy);
|
|
8087
|
+
}
|
|
8088
|
+
case 1u: {
|
|
8089
|
+
return textureSampleGrad(spriteTexture1, spriteSampler1, uv, ddx, ddy);
|
|
8090
|
+
}
|
|
8091
|
+
case 2u: {
|
|
8092
|
+
return textureSampleGrad(spriteTexture2, spriteSampler2, uv, ddx, ddy);
|
|
8093
|
+
}
|
|
8094
|
+
case 3u: {
|
|
8095
|
+
return textureSampleGrad(spriteTexture3, spriteSampler3, uv, ddx, ddy);
|
|
8096
|
+
}
|
|
8097
|
+
case 4u: {
|
|
8098
|
+
return textureSampleGrad(spriteTexture4, spriteSampler4, uv, ddx, ddy);
|
|
8099
|
+
}
|
|
8100
|
+
case 5u: {
|
|
8101
|
+
return textureSampleGrad(spriteTexture5, spriteSampler5, uv, ddx, ddy);
|
|
8102
|
+
}
|
|
8103
|
+
case 6u: {
|
|
8104
|
+
return textureSampleGrad(spriteTexture6, spriteSampler6, uv, ddx, ddy);
|
|
8105
|
+
}
|
|
8106
|
+
default: {
|
|
8107
|
+
return textureSampleGrad(spriteTexture7, spriteSampler7, uv, ddx, ddy);
|
|
8108
|
+
}
|
|
8109
|
+
}
|
|
8110
|
+
}
|
|
8111
|
+
|
|
8112
|
+
@fragment
|
|
8113
|
+
fn fragmentMain(input: VertexOutput) -> @location(0) vec4<f32> {
|
|
8114
|
+
// Compute screen-space derivatives in uniform control flow before the
|
|
8115
|
+
// per-slot switch. WGSL requires textureSample (implicit LOD) to run in
|
|
8116
|
+
// uniform control flow, which multi-texture batching breaks because the
|
|
8117
|
+
// slot varies per fragment. textureSampleGrad takes explicit derivatives
|
|
8118
|
+
// and is valid regardless of control-flow uniformity, while preserving
|
|
8119
|
+
// mipmap-correct LOD when sprites use mipmapped textures.
|
|
8120
|
+
let ddx = dpdx(input.texcoord);
|
|
8121
|
+
let ddy = dpdy(input.texcoord);
|
|
8122
|
+
let sample = sampleTexture(input.textureSlot, input.texcoord, ddx, ddy);
|
|
8123
|
+
let resolvedSample = select(sample, vec4(sample.rgb * sample.a, sample.a), input.premultiplySample == 1u);
|
|
8124
|
+
|
|
8125
|
+
return resolvedSample * input.color;
|
|
8126
|
+
}
|
|
8035
8127
|
`;
|
|
8036
8128
|
const vertexStrideBytes = 28;
|
|
8037
8129
|
const spriteVertexCount = 4;
|
|
@@ -8041,27 +8133,24 @@ fn fragmentMain(input: VertexOutput) -> @location(0) vec4<f32> {
|
|
|
8041
8133
|
const wordsPerVertex = vertexStrideBytes / Uint32Array.BYTES_PER_ELEMENT;
|
|
8042
8134
|
const maxBatchTextures = 8;
|
|
8043
8135
|
class WebGpuSpriteRenderer extends AbstractWebGpuRenderer {
|
|
8044
|
-
|
|
8045
|
-
|
|
8046
|
-
|
|
8047
|
-
|
|
8048
|
-
|
|
8049
|
-
|
|
8050
|
-
|
|
8051
|
-
|
|
8052
|
-
|
|
8053
|
-
|
|
8054
|
-
|
|
8055
|
-
|
|
8056
|
-
|
|
8057
|
-
|
|
8058
|
-
|
|
8059
|
-
|
|
8060
|
-
|
|
8061
|
-
|
|
8062
|
-
this._uint32View = new Uint32Array(this._vertexData);
|
|
8063
|
-
this._pipelines = new Map();
|
|
8064
|
-
}
|
|
8136
|
+
_drawCalls = [];
|
|
8137
|
+
_drawCallCount = 0;
|
|
8138
|
+
_projectionData = new Float32Array(projectionByteLength / Float32Array.BYTES_PER_ELEMENT);
|
|
8139
|
+
_renderManager = null;
|
|
8140
|
+
_device = null;
|
|
8141
|
+
_shaderModule = null;
|
|
8142
|
+
_uniformBindGroupLayout = null;
|
|
8143
|
+
_textureBindGroupLayout = null;
|
|
8144
|
+
_pipelineLayout = null;
|
|
8145
|
+
_uniformBuffer = null;
|
|
8146
|
+
_uniformBindGroup = null;
|
|
8147
|
+
_vertexBuffer = null;
|
|
8148
|
+
_indexBuffer = null;
|
|
8149
|
+
_vertexCapacity = 0;
|
|
8150
|
+
_vertexData = new ArrayBuffer(0);
|
|
8151
|
+
_float32View = new Float32Array(this._vertexData);
|
|
8152
|
+
_uint32View = new Uint32Array(this._vertexData);
|
|
8153
|
+
_pipelines = new Map();
|
|
8065
8154
|
onConnect(runtime) {
|
|
8066
8155
|
if (!this._renderManager) {
|
|
8067
8156
|
this._renderManager = runtime;
|
|
@@ -8520,28 +8609,25 @@ fn fragmentMain(input: VertexOutput) -> @location(0) vec4<f32> {
|
|
|
8520
8609
|
0, 2, 3,
|
|
8521
8610
|
]);
|
|
8522
8611
|
class WebGpuParticleRenderer extends AbstractWebGpuRenderer {
|
|
8523
|
-
|
|
8524
|
-
|
|
8525
|
-
|
|
8526
|
-
|
|
8527
|
-
|
|
8528
|
-
|
|
8529
|
-
|
|
8530
|
-
|
|
8531
|
-
|
|
8532
|
-
|
|
8533
|
-
|
|
8534
|
-
|
|
8535
|
-
|
|
8536
|
-
|
|
8537
|
-
|
|
8538
|
-
|
|
8539
|
-
|
|
8540
|
-
|
|
8541
|
-
|
|
8542
|
-
this._uint32View = new Uint32Array(this._instanceData);
|
|
8543
|
-
this._pipelines = new Map();
|
|
8544
|
-
}
|
|
8612
|
+
_drawCalls = [];
|
|
8613
|
+
_drawCallCount = 0;
|
|
8614
|
+
_uniformData = new Float32Array(uniformByteLength / Float32Array.BYTES_PER_ELEMENT);
|
|
8615
|
+
_renderManager = null;
|
|
8616
|
+
_device = null;
|
|
8617
|
+
_shaderModule = null;
|
|
8618
|
+
_uniformBindGroupLayout = null;
|
|
8619
|
+
_textureBindGroupLayout = null;
|
|
8620
|
+
_pipelineLayout = null;
|
|
8621
|
+
_uniformBuffer = null;
|
|
8622
|
+
_uniformBindGroup = null;
|
|
8623
|
+
_staticVertexBuffer = null;
|
|
8624
|
+
_instanceBuffer = null;
|
|
8625
|
+
_indexBuffer = null;
|
|
8626
|
+
_instanceBufferByteLength = 0;
|
|
8627
|
+
_instanceData = new ArrayBuffer(instanceStrideBytes * initialParticleCapacity);
|
|
8628
|
+
_float32View = new Float32Array(this._instanceData);
|
|
8629
|
+
_uint32View = new Uint32Array(this._instanceData);
|
|
8630
|
+
_pipelines = new Map();
|
|
8545
8631
|
render(system) {
|
|
8546
8632
|
const runtime = this._renderManager;
|
|
8547
8633
|
const texture = system.texture;
|
|
@@ -8883,33 +8969,36 @@ fn fragmentMain(input: VertexOutput) -> @location(0) vec4<f32> {
|
|
|
8883
8969
|
/// <reference types="@webgpu/types" />
|
|
8884
8970
|
const managedTextureFormat = 'rgba8unorm';
|
|
8885
8971
|
class WebGpuRenderManager {
|
|
8972
|
+
backendType = exports.RenderBackendType.WebGpu;
|
|
8973
|
+
rendererRegistry = new RendererRegistry();
|
|
8974
|
+
_canvas;
|
|
8975
|
+
_rootRenderTarget;
|
|
8976
|
+
_clearColor = new Color();
|
|
8977
|
+
_textureStates = new Map();
|
|
8978
|
+
_textureDestroyHandlers = new Map();
|
|
8979
|
+
_renderTargetDestroyHandlers = new Map();
|
|
8980
|
+
_temporaryRenderTextures = [];
|
|
8981
|
+
_maskStack = [];
|
|
8982
|
+
_maskPixelStack = [];
|
|
8983
|
+
_maskPointA = new Vector();
|
|
8984
|
+
_maskPointB = new Vector();
|
|
8985
|
+
_mipmapShaderModule = null;
|
|
8986
|
+
_mipmapBindGroupLayout = null;
|
|
8987
|
+
_mipmapPipelineLayout = null;
|
|
8988
|
+
_mipmapPipeline = null;
|
|
8989
|
+
_mipmapSampler = null;
|
|
8990
|
+
_context = null;
|
|
8991
|
+
_device = null;
|
|
8992
|
+
_format = null;
|
|
8993
|
+
_initializePromise = null;
|
|
8994
|
+
_renderTarget;
|
|
8995
|
+
_renderer = null;
|
|
8996
|
+
_blendMode = null;
|
|
8997
|
+
_texture = null;
|
|
8998
|
+
_clearRequested = false;
|
|
8999
|
+
_hasPresentedFrame = false;
|
|
9000
|
+
_stats = createRenderStats();
|
|
8886
9001
|
constructor(app) {
|
|
8887
|
-
this.backendType = exports.RenderBackendType.WebGpu;
|
|
8888
|
-
this.rendererRegistry = new RendererRegistry();
|
|
8889
|
-
this._clearColor = new Color();
|
|
8890
|
-
this._textureStates = new Map();
|
|
8891
|
-
this._textureDestroyHandlers = new Map();
|
|
8892
|
-
this._renderTargetDestroyHandlers = new Map();
|
|
8893
|
-
this._temporaryRenderTextures = [];
|
|
8894
|
-
this._maskStack = [];
|
|
8895
|
-
this._maskPixelStack = [];
|
|
8896
|
-
this._maskPointA = new Vector();
|
|
8897
|
-
this._maskPointB = new Vector();
|
|
8898
|
-
this._mipmapShaderModule = null;
|
|
8899
|
-
this._mipmapBindGroupLayout = null;
|
|
8900
|
-
this._mipmapPipelineLayout = null;
|
|
8901
|
-
this._mipmapPipeline = null;
|
|
8902
|
-
this._mipmapSampler = null;
|
|
8903
|
-
this._context = null;
|
|
8904
|
-
this._device = null;
|
|
8905
|
-
this._format = null;
|
|
8906
|
-
this._initializePromise = null;
|
|
8907
|
-
this._renderer = null;
|
|
8908
|
-
this._blendMode = null;
|
|
8909
|
-
this._texture = null;
|
|
8910
|
-
this._clearRequested = false;
|
|
8911
|
-
this._hasPresentedFrame = false;
|
|
8912
|
-
this._stats = createRenderStats();
|
|
8913
9002
|
const { width, height, clearColor, } = app.options;
|
|
8914
9003
|
this._canvas = app.canvas;
|
|
8915
9004
|
this._rootRenderTarget = new RenderTarget(width, height, true);
|
|
@@ -9643,6 +9732,12 @@ fn fragmentMain(input: VertexOutput) -> @location(0) vec4<f32> {
|
|
|
9643
9732
|
ChannelSize[ChannelSize["Category"] = 256] = "Category";
|
|
9644
9733
|
ChannelSize[ChannelSize["Gamepad"] = 64] = "Gamepad";
|
|
9645
9734
|
})(exports.ChannelSize || (exports.ChannelSize = {}));
|
|
9735
|
+
exports.ChannelOffset = void 0;
|
|
9736
|
+
(function (ChannelOffset) {
|
|
9737
|
+
ChannelOffset[ChannelOffset["Keyboard"] = 0] = "Keyboard";
|
|
9738
|
+
ChannelOffset[ChannelOffset["Pointers"] = 256] = "Pointers";
|
|
9739
|
+
ChannelOffset[ChannelOffset["Gamepads"] = 512] = "Gamepads";
|
|
9740
|
+
})(exports.ChannelOffset || (exports.ChannelOffset = {}));
|
|
9646
9741
|
exports.Keyboard = void 0;
|
|
9647
9742
|
(function (Keyboard) {
|
|
9648
9743
|
Keyboard[Keyboard["Backspace"] = 8] = "Backspace";
|
|
@@ -9747,24 +9842,28 @@ fn fragmentMain(input: VertexOutput) -> @location(0) vec4<f32> {
|
|
|
9747
9842
|
})(exports.Keyboard || (exports.Keyboard = {}));
|
|
9748
9843
|
|
|
9749
9844
|
class Gamepad {
|
|
9845
|
+
onConnect = new Signal();
|
|
9846
|
+
onDisconnect = new Signal();
|
|
9847
|
+
onUpdate = new Signal();
|
|
9848
|
+
indexValue;
|
|
9849
|
+
channelsValue;
|
|
9850
|
+
channelOffset;
|
|
9851
|
+
mappingValue;
|
|
9852
|
+
browserGamepad = null;
|
|
9853
|
+
info = {
|
|
9854
|
+
name: 'Generic Gamepad',
|
|
9855
|
+
label: 'Generic Gamepad',
|
|
9856
|
+
vendorId: null,
|
|
9857
|
+
productId: null,
|
|
9858
|
+
productKey: null,
|
|
9859
|
+
};
|
|
9750
9860
|
constructor(indexOrGamepad, channels, mappingOrDefinition) {
|
|
9751
|
-
this.onConnect = new Signal();
|
|
9752
|
-
this.onDisconnect = new Signal();
|
|
9753
|
-
this.onUpdate = new Signal();
|
|
9754
|
-
this.browserGamepad = null;
|
|
9755
|
-
this.info = {
|
|
9756
|
-
name: 'Generic Gamepad',
|
|
9757
|
-
label: 'Generic Gamepad',
|
|
9758
|
-
vendorId: null,
|
|
9759
|
-
productId: null,
|
|
9760
|
-
productKey: null,
|
|
9761
|
-
};
|
|
9762
9861
|
const isBrowserGamepad = typeof indexOrGamepad !== 'number';
|
|
9763
9862
|
const gamepad = isBrowserGamepad ? indexOrGamepad : null;
|
|
9764
9863
|
const index = isBrowserGamepad ? indexOrGamepad.index : indexOrGamepad;
|
|
9765
9864
|
this.indexValue = index;
|
|
9766
9865
|
this.channelsValue = channels;
|
|
9767
|
-
this.channelOffset =
|
|
9866
|
+
this.channelOffset = exports.ChannelOffset.Gamepads + (index * exports.ChannelSize.Gamepad);
|
|
9768
9867
|
this.mappingValue = gamepad
|
|
9769
9868
|
? mappingOrDefinition.mapping
|
|
9770
9869
|
: mappingOrDefinition;
|
|
@@ -9876,10 +9975,10 @@ fn fragmentMain(input: VertexOutput) -> @location(0) vec4<f32> {
|
|
|
9876
9975
|
this.onUpdate.destroy();
|
|
9877
9976
|
}
|
|
9878
9977
|
resolveChannelOffset(channel) {
|
|
9879
|
-
return this.channelOffset + (channel ^
|
|
9978
|
+
return this.channelOffset + (channel ^ exports.ChannelOffset.Gamepads);
|
|
9880
9979
|
}
|
|
9881
9980
|
static resolveChannelOffset(gamepadIndex, channel) {
|
|
9882
|
-
return
|
|
9981
|
+
return exports.ChannelOffset.Gamepads + (gamepadIndex * exports.ChannelSize.Gamepad) + (channel ^ exports.ChannelOffset.Gamepads);
|
|
9883
9982
|
}
|
|
9884
9983
|
clearMappedChannels() {
|
|
9885
9984
|
for (const control of this.mappingValue.buttons) {
|
|
@@ -9912,10 +10011,19 @@ fn fragmentMain(input: VertexOutput) -> @location(0) vec4<f32> {
|
|
|
9912
10011
|
PointerState[PointerState["Cancelled"] = 6] = "Cancelled";
|
|
9913
10012
|
})(exports.PointerState || (exports.PointerState = {}));
|
|
9914
10013
|
class Pointer {
|
|
10014
|
+
id;
|
|
10015
|
+
type;
|
|
10016
|
+
position;
|
|
10017
|
+
startPos = new Vector(-1, -1);
|
|
10018
|
+
size;
|
|
10019
|
+
tilt;
|
|
10020
|
+
stateFlags = new Flags();
|
|
10021
|
+
_canvas;
|
|
10022
|
+
_buttons;
|
|
10023
|
+
_pressure;
|
|
10024
|
+
_rotation;
|
|
10025
|
+
_currentState = exports.PointerState.Unknown;
|
|
9915
10026
|
constructor(event, canvas) {
|
|
9916
|
-
this.startPos = new Vector(-1, -1);
|
|
9917
|
-
this.stateFlags = new Flags();
|
|
9918
|
-
this._currentState = exports.PointerState.Unknown;
|
|
9919
10027
|
const { pointerId, pointerType, clientX, clientY, width, height, tiltX, tiltY, buttons, pressure, twist } = event;
|
|
9920
10028
|
const { left, top } = canvas.getBoundingClientRect();
|
|
9921
10029
|
this._canvas = canvas;
|
|
@@ -10045,6 +10153,11 @@ fn fragmentMain(input: VertexOutput) -> @location(0) vec4<f32> {
|
|
|
10045
10153
|
})(exports.GamepadChannel || (exports.GamepadChannel = {}));
|
|
10046
10154
|
|
|
10047
10155
|
class GamepadControl {
|
|
10156
|
+
index;
|
|
10157
|
+
channel;
|
|
10158
|
+
invert;
|
|
10159
|
+
normalize;
|
|
10160
|
+
threshold;
|
|
10048
10161
|
constructor(index, channel, options = {}) {
|
|
10049
10162
|
this.index = index;
|
|
10050
10163
|
this.channel = channel;
|
|
@@ -10077,6 +10190,8 @@ fn fragmentMain(input: VertexOutput) -> @location(0) vec4<f32> {
|
|
|
10077
10190
|
GamepadMappingFamily["ArcadeStick"] = "arcadeStick";
|
|
10078
10191
|
})(exports.GamepadMappingFamily || (exports.GamepadMappingFamily = {}));
|
|
10079
10192
|
class GamepadMapping {
|
|
10193
|
+
buttons;
|
|
10194
|
+
axes;
|
|
10080
10195
|
constructor(buttons, axes) {
|
|
10081
10196
|
this.buttons = buttons;
|
|
10082
10197
|
this.axes = axes;
|
|
@@ -10108,9 +10223,9 @@ fn fragmentMain(input: VertexOutput) -> @location(0) vec4<f32> {
|
|
|
10108
10223
|
[16, exports.GamepadChannel.Guide],
|
|
10109
10224
|
];
|
|
10110
10225
|
class ArcadeStickGamepadMapping extends GamepadMapping {
|
|
10226
|
+
family = exports.GamepadMappingFamily.ArcadeStick;
|
|
10111
10227
|
constructor() {
|
|
10112
10228
|
super(GamepadMapping.createControls(arcadeStickButtonDefinitions), []);
|
|
10113
|
-
this.family = exports.GamepadMappingFamily.ArcadeStick;
|
|
10114
10229
|
}
|
|
10115
10230
|
}
|
|
10116
10231
|
|
|
@@ -10156,59 +10271,38 @@ fn fragmentMain(input: VertexOutput) -> @location(0) vec4<f32> {
|
|
|
10156
10271
|
[7, exports.GamepadChannel.AuxiliaryAxis3Positive],
|
|
10157
10272
|
];
|
|
10158
10273
|
class GenericDualAnalogGamepadMapping extends GamepadMapping {
|
|
10274
|
+
family = exports.GamepadMappingFamily.GenericDualAnalog;
|
|
10159
10275
|
constructor() {
|
|
10160
10276
|
super(GamepadMapping.createControls(genericDualAnalogButtonDefinitions), GamepadMapping.createControls(genericDualAnalogAxisDefinitions));
|
|
10161
|
-
this.family = exports.GamepadMappingFamily.GenericDualAnalog;
|
|
10162
10277
|
}
|
|
10163
10278
|
}
|
|
10164
10279
|
|
|
10165
10280
|
class GameCubeGamepadMapping extends GenericDualAnalogGamepadMapping {
|
|
10166
|
-
|
|
10167
|
-
super(...arguments);
|
|
10168
|
-
this.family = exports.GamepadMappingFamily.GameCube;
|
|
10169
|
-
}
|
|
10281
|
+
family = exports.GamepadMappingFamily.GameCube;
|
|
10170
10282
|
}
|
|
10171
10283
|
|
|
10172
10284
|
class JoyConLeftGamepadMapping extends GenericDualAnalogGamepadMapping {
|
|
10173
|
-
|
|
10174
|
-
super(...arguments);
|
|
10175
|
-
this.family = exports.GamepadMappingFamily.JoyConLeft;
|
|
10176
|
-
}
|
|
10285
|
+
family = exports.GamepadMappingFamily.JoyConLeft;
|
|
10177
10286
|
}
|
|
10178
10287
|
|
|
10179
10288
|
class JoyConRightGamepadMapping extends GenericDualAnalogGamepadMapping {
|
|
10180
|
-
|
|
10181
|
-
super(...arguments);
|
|
10182
|
-
this.family = exports.GamepadMappingFamily.JoyConRight;
|
|
10183
|
-
}
|
|
10289
|
+
family = exports.GamepadMappingFamily.JoyConRight;
|
|
10184
10290
|
}
|
|
10185
10291
|
|
|
10186
10292
|
class PlayStationGamepadMapping extends GenericDualAnalogGamepadMapping {
|
|
10187
|
-
|
|
10188
|
-
super(...arguments);
|
|
10189
|
-
this.family = exports.GamepadMappingFamily.PlayStation;
|
|
10190
|
-
}
|
|
10293
|
+
family = exports.GamepadMappingFamily.PlayStation;
|
|
10191
10294
|
}
|
|
10192
10295
|
|
|
10193
10296
|
class SteamControllerGamepadMapping extends GenericDualAnalogGamepadMapping {
|
|
10194
|
-
|
|
10195
|
-
super(...arguments);
|
|
10196
|
-
this.family = exports.GamepadMappingFamily.SteamController;
|
|
10197
|
-
}
|
|
10297
|
+
family = exports.GamepadMappingFamily.SteamController;
|
|
10198
10298
|
}
|
|
10199
10299
|
|
|
10200
10300
|
class SwitchProGamepadMapping extends GenericDualAnalogGamepadMapping {
|
|
10201
|
-
|
|
10202
|
-
super(...arguments);
|
|
10203
|
-
this.family = exports.GamepadMappingFamily.SwitchPro;
|
|
10204
|
-
}
|
|
10301
|
+
family = exports.GamepadMappingFamily.SwitchPro;
|
|
10205
10302
|
}
|
|
10206
10303
|
|
|
10207
10304
|
class XboxGamepadMapping extends GenericDualAnalogGamepadMapping {
|
|
10208
|
-
|
|
10209
|
-
super(...arguments);
|
|
10210
|
-
this.family = exports.GamepadMappingFamily.Xbox;
|
|
10211
|
-
}
|
|
10305
|
+
family = exports.GamepadMappingFamily.Xbox;
|
|
10212
10306
|
}
|
|
10213
10307
|
|
|
10214
10308
|
const vendorProductPattern = /vendor[:\s]*([0-9a-f]{4})\s*product[:\s]*([0-9a-f]{4})/i;
|
|
@@ -10383,43 +10477,47 @@ fn fragmentMain(input: VertexOutput) -> @location(0) vec4<f32> {
|
|
|
10383
10477
|
InputManagerFlag[InputManagerFlag["PointerUpdate"] = 8] = "PointerUpdate";
|
|
10384
10478
|
})(InputManagerFlag || (InputManagerFlag = {}));
|
|
10385
10479
|
class InputManager {
|
|
10480
|
+
canvas;
|
|
10481
|
+
channels = new Float32Array(exports.ChannelSize.Container);
|
|
10482
|
+
inputs = new Set();
|
|
10483
|
+
pointers = {};
|
|
10484
|
+
gamepadsValue = [];
|
|
10485
|
+
gamepadsByIndex = new Map();
|
|
10486
|
+
gamepadSlotsActive = new Uint8Array(exports.ChannelSize.Category / exports.ChannelSize.Gamepad);
|
|
10487
|
+
wheelOffset = new Vector();
|
|
10488
|
+
flags = new Flags();
|
|
10489
|
+
channelsPressed = [];
|
|
10490
|
+
channelsReleased = [];
|
|
10491
|
+
gamepadDefinitions;
|
|
10492
|
+
canvasFocusedValue;
|
|
10493
|
+
pointerDistanceThreshold;
|
|
10494
|
+
keyDownHandler = this.handleKeyDown.bind(this);
|
|
10495
|
+
keyUpHandler = this.handleKeyUp.bind(this);
|
|
10496
|
+
canvasFocusHandler = this.handleCanvasFocus.bind(this);
|
|
10497
|
+
canvasBlurHandler = this.handleCanvasBlur.bind(this);
|
|
10498
|
+
windowBlurHandler = this.handleWindowBlur.bind(this);
|
|
10499
|
+
mouseWheelHandler = this.handleMouseWheel.bind(this);
|
|
10500
|
+
pointerOverHandler = this.handlePointerOver.bind(this);
|
|
10501
|
+
pointerLeaveHandler = this.handlePointerLeave.bind(this);
|
|
10502
|
+
pointerDownHandler = this.handlePointerDown.bind(this);
|
|
10503
|
+
pointerMoveHandler = this.handlePointerMove.bind(this);
|
|
10504
|
+
pointerUpHandler = this.handlePointerUp.bind(this);
|
|
10505
|
+
pointerCancelHandler = this.handlePointerCancel.bind(this);
|
|
10506
|
+
onPointerEnter = new Signal();
|
|
10507
|
+
onPointerLeave = new Signal();
|
|
10508
|
+
onPointerDown = new Signal();
|
|
10509
|
+
onPointerMove = new Signal();
|
|
10510
|
+
onPointerUp = new Signal();
|
|
10511
|
+
onPointerTap = new Signal();
|
|
10512
|
+
onPointerSwipe = new Signal();
|
|
10513
|
+
onPointerCancel = new Signal();
|
|
10514
|
+
onMouseWheel = new Signal();
|
|
10515
|
+
onKeyDown = new Signal();
|
|
10516
|
+
onKeyUp = new Signal();
|
|
10517
|
+
onGamepadConnected = new Signal();
|
|
10518
|
+
onGamepadDisconnected = new Signal();
|
|
10519
|
+
onGamepadUpdated = new Signal();
|
|
10386
10520
|
constructor(app) {
|
|
10387
|
-
this.channels = new Float32Array(exports.ChannelSize.Container);
|
|
10388
|
-
this.inputs = new Set();
|
|
10389
|
-
this.pointers = {};
|
|
10390
|
-
this.gamepadsValue = [];
|
|
10391
|
-
this.gamepadsByIndex = new Map();
|
|
10392
|
-
this.gamepadSlotsActive = new Uint8Array(exports.ChannelSize.Category / exports.ChannelSize.Gamepad);
|
|
10393
|
-
this.wheelOffset = new Vector();
|
|
10394
|
-
this.flags = new Flags();
|
|
10395
|
-
this.channelsPressed = [];
|
|
10396
|
-
this.channelsReleased = [];
|
|
10397
|
-
this.keyDownHandler = this.handleKeyDown.bind(this);
|
|
10398
|
-
this.keyUpHandler = this.handleKeyUp.bind(this);
|
|
10399
|
-
this.canvasFocusHandler = this.handleCanvasFocus.bind(this);
|
|
10400
|
-
this.canvasBlurHandler = this.handleCanvasBlur.bind(this);
|
|
10401
|
-
this.windowBlurHandler = this.handleWindowBlur.bind(this);
|
|
10402
|
-
this.mouseWheelHandler = this.handleMouseWheel.bind(this);
|
|
10403
|
-
this.pointerOverHandler = this.handlePointerOver.bind(this);
|
|
10404
|
-
this.pointerLeaveHandler = this.handlePointerLeave.bind(this);
|
|
10405
|
-
this.pointerDownHandler = this.handlePointerDown.bind(this);
|
|
10406
|
-
this.pointerMoveHandler = this.handlePointerMove.bind(this);
|
|
10407
|
-
this.pointerUpHandler = this.handlePointerUp.bind(this);
|
|
10408
|
-
this.pointerCancelHandler = this.handlePointerCancel.bind(this);
|
|
10409
|
-
this.onPointerEnter = new Signal();
|
|
10410
|
-
this.onPointerLeave = new Signal();
|
|
10411
|
-
this.onPointerDown = new Signal();
|
|
10412
|
-
this.onPointerMove = new Signal();
|
|
10413
|
-
this.onPointerUp = new Signal();
|
|
10414
|
-
this.onPointerTap = new Signal();
|
|
10415
|
-
this.onPointerSwipe = new Signal();
|
|
10416
|
-
this.onPointerCancel = new Signal();
|
|
10417
|
-
this.onMouseWheel = new Signal();
|
|
10418
|
-
this.onKeyDown = new Signal();
|
|
10419
|
-
this.onKeyUp = new Signal();
|
|
10420
|
-
this.onGamepadConnected = new Signal();
|
|
10421
|
-
this.onGamepadDisconnected = new Signal();
|
|
10422
|
-
this.onGamepadUpdated = new Signal();
|
|
10423
10521
|
const { gamepadDefinitions = [], pointerDistanceThreshold } = app.options;
|
|
10424
10522
|
this.canvas = app.canvas;
|
|
10425
10523
|
this.canvasFocusedValue = document.activeElement === this.canvas;
|
|
@@ -10506,13 +10604,13 @@ fn fragmentMain(input: VertexOutput) -> @location(0) vec4<f32> {
|
|
|
10506
10604
|
this.onGamepadUpdated.destroy();
|
|
10507
10605
|
}
|
|
10508
10606
|
handleKeyDown(event) {
|
|
10509
|
-
const channel =
|
|
10607
|
+
const channel = exports.ChannelOffset.Keyboard + event.keyCode;
|
|
10510
10608
|
this.channels[channel] = 1;
|
|
10511
10609
|
this.channelsPressed.push(channel);
|
|
10512
10610
|
this.flags.push(InputManagerFlag.KeyDown);
|
|
10513
10611
|
}
|
|
10514
10612
|
handleKeyUp(event) {
|
|
10515
|
-
const channel =
|
|
10613
|
+
const channel = exports.ChannelOffset.Keyboard + event.keyCode;
|
|
10516
10614
|
this.channels[channel] = 0;
|
|
10517
10615
|
this.channelsReleased.push(channel);
|
|
10518
10616
|
this.flags.push(InputManagerFlag.KeyUp);
|
|
@@ -10705,6 +10803,13 @@ fn fragmentMain(input: VertexOutput) -> @location(0) vec4<f32> {
|
|
|
10705
10803
|
}
|
|
10706
10804
|
|
|
10707
10805
|
class AbstractMedia {
|
|
10806
|
+
onStart = new Signal();
|
|
10807
|
+
onStop = new Signal();
|
|
10808
|
+
_duration;
|
|
10809
|
+
_volume;
|
|
10810
|
+
_playbackRate;
|
|
10811
|
+
_loop;
|
|
10812
|
+
_muted;
|
|
10708
10813
|
get duration() {
|
|
10709
10814
|
return this._duration;
|
|
10710
10815
|
}
|
|
@@ -10755,8 +10860,6 @@ fn fragmentMain(input: VertexOutput) -> @location(0) vec4<f32> {
|
|
|
10755
10860
|
}
|
|
10756
10861
|
}
|
|
10757
10862
|
constructor(initialState) {
|
|
10758
|
-
this.onStart = new Signal();
|
|
10759
|
-
this.onStop = new Signal();
|
|
10760
10863
|
const { duration, volume, playbackRate, loop, muted } = initialState;
|
|
10761
10864
|
this._duration = duration;
|
|
10762
10865
|
this._volume = volume;
|
|
@@ -10910,9 +11013,10 @@ fn fragmentMain(input: VertexOutput) -> @location(0) vec4<f32> {
|
|
|
10910
11013
|
const decodeAudioData = async (arrayBuffer) => getOrCreateOfflineAudioContext().decodeAudioData(arrayBuffer);
|
|
10911
11014
|
|
|
10912
11015
|
class Music extends AbstractMedia {
|
|
11016
|
+
_audioElement;
|
|
11017
|
+
_audioSetup = null;
|
|
10913
11018
|
constructor(audioElement, options) {
|
|
10914
11019
|
super(audioElement);
|
|
10915
|
-
this._audioSetup = null;
|
|
10916
11020
|
this._audioElement = audioElement;
|
|
10917
11021
|
if (options) {
|
|
10918
11022
|
this.applyOptions(options);
|
|
@@ -11022,6 +11126,16 @@ fn fragmentMain(input: VertexOutput) -> @location(0) vec4<f32> {
|
|
|
11022
11126
|
}
|
|
11023
11127
|
|
|
11024
11128
|
class Sound extends AbstractMedia {
|
|
11129
|
+
_audioBuffer;
|
|
11130
|
+
_pooledSources = [];
|
|
11131
|
+
_queuedPooledPlays = [];
|
|
11132
|
+
_sprites = new Map();
|
|
11133
|
+
_audioSetup = null;
|
|
11134
|
+
_paused = true;
|
|
11135
|
+
_startTime = 0;
|
|
11136
|
+
_currentTime = 0;
|
|
11137
|
+
_sourceNode = null;
|
|
11138
|
+
_poolSize = 1;
|
|
11025
11139
|
get paused() {
|
|
11026
11140
|
return this._paused;
|
|
11027
11141
|
}
|
|
@@ -11050,15 +11164,6 @@ fn fragmentMain(input: VertexOutput) -> @location(0) vec4<f32> {
|
|
|
11050
11164
|
loop: false,
|
|
11051
11165
|
muted: false,
|
|
11052
11166
|
});
|
|
11053
|
-
this._pooledSources = [];
|
|
11054
|
-
this._queuedPooledPlays = [];
|
|
11055
|
-
this._sprites = new Map();
|
|
11056
|
-
this._audioSetup = null;
|
|
11057
|
-
this._paused = true;
|
|
11058
|
-
this._startTime = 0;
|
|
11059
|
-
this._currentTime = 0;
|
|
11060
|
-
this._sourceNode = null;
|
|
11061
|
-
this._poolSize = 1;
|
|
11062
11167
|
this._audioBuffer = audioBuffer;
|
|
11063
11168
|
const { poolSize, sprites, ...playbackOptions } = options;
|
|
11064
11169
|
this._poolSize = Math.max(1, Math.floor(poolSize ?? 1));
|
|
@@ -11409,18 +11514,23 @@ fn fragmentMain(input: VertexOutput) -> @location(0) vec4<f32> {
|
|
|
11409
11514
|
}
|
|
11410
11515
|
|
|
11411
11516
|
class Video extends Sprite {
|
|
11517
|
+
onStart = new Signal();
|
|
11518
|
+
onStop = new Signal();
|
|
11519
|
+
_videoElement;
|
|
11520
|
+
_duration;
|
|
11521
|
+
_volume = 1;
|
|
11522
|
+
_playbackRate = 1;
|
|
11523
|
+
_loop = false;
|
|
11524
|
+
_muted = false;
|
|
11525
|
+
_audioSetup = null;
|
|
11526
|
+
_textureDirty = true;
|
|
11527
|
+
_lastVideoTime = Number.NaN;
|
|
11528
|
+
_videoFrameCallbackHandle = null;
|
|
11529
|
+
_onMetadataHandler;
|
|
11530
|
+
_onResizeHandler;
|
|
11531
|
+
_onVideoFrameHandler;
|
|
11412
11532
|
constructor(videoElement, playbackOptions, samplerOptions) {
|
|
11413
11533
|
super(new Texture(videoElement, samplerOptions));
|
|
11414
|
-
this.onStart = new Signal();
|
|
11415
|
-
this.onStop = new Signal();
|
|
11416
|
-
this._volume = 1;
|
|
11417
|
-
this._playbackRate = 1;
|
|
11418
|
-
this._loop = false;
|
|
11419
|
-
this._muted = false;
|
|
11420
|
-
this._audioSetup = null;
|
|
11421
|
-
this._textureDirty = true;
|
|
11422
|
-
this._lastVideoTime = Number.NaN;
|
|
11423
|
-
this._videoFrameCallbackHandle = null;
|
|
11424
11534
|
const { duration, volume, playbackRate, loop, muted } = videoElement;
|
|
11425
11535
|
this._videoElement = videoElement;
|
|
11426
11536
|
this._duration = duration;
|
|
@@ -11719,9 +11829,7 @@ fn fragmentMain(input: VertexOutput) -> @location(0) vec4<f32> {
|
|
|
11719
11829
|
}
|
|
11720
11830
|
|
|
11721
11831
|
class FactoryRegistry {
|
|
11722
|
-
|
|
11723
|
-
this._factories = new Map();
|
|
11724
|
-
}
|
|
11832
|
+
_factories = new Map();
|
|
11725
11833
|
register(type, factory) {
|
|
11726
11834
|
this._factories.set(type, factory);
|
|
11727
11835
|
}
|
|
@@ -11761,9 +11869,7 @@ fn fragmentMain(input: VertexOutput) -> @location(0) vec4<f32> {
|
|
|
11761
11869
|
}
|
|
11762
11870
|
|
|
11763
11871
|
class AbstractAssetFactory {
|
|
11764
|
-
|
|
11765
|
-
this._objectUrls = [];
|
|
11766
|
-
}
|
|
11872
|
+
_objectUrls = [];
|
|
11767
11873
|
createObjectUrl(blob) {
|
|
11768
11874
|
const objectUrl = URL.createObjectURL(blob);
|
|
11769
11875
|
this._objectUrls.push(objectUrl);
|
|
@@ -11785,11 +11891,8 @@ fn fragmentMain(input: VertexOutput) -> @location(0) vec4<f32> {
|
|
|
11785
11891
|
}
|
|
11786
11892
|
|
|
11787
11893
|
class FontFactory extends AbstractAssetFactory {
|
|
11788
|
-
|
|
11789
|
-
|
|
11790
|
-
this.storageName = 'font';
|
|
11791
|
-
this._addedFontFaces = [];
|
|
11792
|
-
}
|
|
11894
|
+
storageName = 'font';
|
|
11895
|
+
_addedFontFaces = [];
|
|
11793
11896
|
async process(response) {
|
|
11794
11897
|
return await response.arrayBuffer();
|
|
11795
11898
|
}
|
|
@@ -11861,27 +11964,27 @@ fn fragmentMain(input: VertexOutput) -> @location(0) vec4<f32> {
|
|
|
11861
11964
|
mask: [0xFF, 0xFF, 0xFF],
|
|
11862
11965
|
},
|
|
11863
11966
|
{
|
|
11864
|
-
mimeType: 'audio/basic',
|
|
11967
|
+
mimeType: '@/audio/basic',
|
|
11865
11968
|
pattern: [0x2E, 0x73, 0x6E, 0x64],
|
|
11866
11969
|
mask: [0xFF, 0xFF, 0xFF, 0xFF],
|
|
11867
11970
|
},
|
|
11868
11971
|
{
|
|
11869
|
-
mimeType: 'audio/mpeg',
|
|
11972
|
+
mimeType: '@/audio/mpeg',
|
|
11870
11973
|
pattern: [0x49, 0x44, 0x33],
|
|
11871
11974
|
mask: [0xFF, 0xFF, 0xFF],
|
|
11872
11975
|
},
|
|
11873
11976
|
{
|
|
11874
|
-
mimeType: 'audio/wave',
|
|
11977
|
+
mimeType: '@/audio/wave',
|
|
11875
11978
|
pattern: [0x52, 0x49, 0x46, 0x46, 0x00, 0x00, 0x00, 0x00, 0x57, 0x41, 0x56, 0x45],
|
|
11876
11979
|
mask: [0xFF, 0xFF, 0xFF, 0xFF, 0x00, 0x00, 0x00, 0x00, 0xFF, 0xFF, 0xFF, 0xFF],
|
|
11877
11980
|
},
|
|
11878
11981
|
{
|
|
11879
|
-
mimeType: 'audio/midi',
|
|
11982
|
+
mimeType: '@/audio/midi',
|
|
11880
11983
|
pattern: [0x4D, 0x54, 0x68, 0x64, 0x00, 0x00, 0x00, 0x06],
|
|
11881
11984
|
mask: [0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF],
|
|
11882
11985
|
},
|
|
11883
11986
|
{
|
|
11884
|
-
mimeType: 'audio/aiff',
|
|
11987
|
+
mimeType: '@/audio/aiff',
|
|
11885
11988
|
pattern: [0x46, 0x4F, 0x52, 0x4D, 0x00, 0x00, 0x00, 0x00, 0x41, 0x49, 0x46, 0x46],
|
|
11886
11989
|
mask: [0xFF, 0xFF, 0xFF, 0xFF, 0x00, 0x00, 0x00, 0x00, 0xFF, 0xFF, 0xFF, 0xFF],
|
|
11887
11990
|
},
|
|
@@ -11947,10 +12050,7 @@ fn fragmentMain(input: VertexOutput) -> @location(0) vec4<f32> {
|
|
|
11947
12050
|
};
|
|
11948
12051
|
|
|
11949
12052
|
class ImageFactory extends AbstractAssetFactory {
|
|
11950
|
-
|
|
11951
|
-
super(...arguments);
|
|
11952
|
-
this.storageName = 'image';
|
|
11953
|
-
}
|
|
12053
|
+
storageName = 'image';
|
|
11954
12054
|
async process(response) {
|
|
11955
12055
|
return await response.arrayBuffer();
|
|
11956
12056
|
}
|
|
@@ -11980,10 +12080,7 @@ fn fragmentMain(input: VertexOutput) -> @location(0) vec4<f32> {
|
|
|
11980
12080
|
}
|
|
11981
12081
|
|
|
11982
12082
|
class JsonFactory extends AbstractAssetFactory {
|
|
11983
|
-
|
|
11984
|
-
super(...arguments);
|
|
11985
|
-
this.storageName = 'json';
|
|
11986
|
-
}
|
|
12083
|
+
storageName = 'json';
|
|
11987
12084
|
async process(response) {
|
|
11988
12085
|
return await response.json();
|
|
11989
12086
|
}
|
|
@@ -11994,11 +12091,8 @@ fn fragmentMain(input: VertexOutput) -> @location(0) vec4<f32> {
|
|
|
11994
12091
|
|
|
11995
12092
|
const onceListenerOption$1 = { once: true };
|
|
11996
12093
|
class MusicFactory extends AbstractAssetFactory {
|
|
11997
|
-
|
|
11998
|
-
|
|
11999
|
-
this.storageName = 'music';
|
|
12000
|
-
this._audioElements = [];
|
|
12001
|
-
}
|
|
12094
|
+
storageName = 'music';
|
|
12095
|
+
_audioElements = [];
|
|
12002
12096
|
async process(response) {
|
|
12003
12097
|
return await response.arrayBuffer();
|
|
12004
12098
|
}
|
|
@@ -12027,10 +12121,7 @@ fn fragmentMain(input: VertexOutput) -> @location(0) vec4<f32> {
|
|
|
12027
12121
|
}
|
|
12028
12122
|
|
|
12029
12123
|
class SoundFactory extends AbstractAssetFactory {
|
|
12030
|
-
|
|
12031
|
-
super(...arguments);
|
|
12032
|
-
this.storageName = 'sound';
|
|
12033
|
-
}
|
|
12124
|
+
storageName = 'sound';
|
|
12034
12125
|
async process(response) {
|
|
12035
12126
|
return await response.arrayBuffer();
|
|
12036
12127
|
}
|
|
@@ -12046,10 +12137,7 @@ fn fragmentMain(input: VertexOutput) -> @location(0) vec4<f32> {
|
|
|
12046
12137
|
}
|
|
12047
12138
|
|
|
12048
12139
|
class TextFactory extends AbstractAssetFactory {
|
|
12049
|
-
|
|
12050
|
-
super(...arguments);
|
|
12051
|
-
this.storageName = 'text';
|
|
12052
|
-
}
|
|
12140
|
+
storageName = 'text';
|
|
12053
12141
|
async process(response) {
|
|
12054
12142
|
return await response.text();
|
|
12055
12143
|
}
|
|
@@ -12059,10 +12147,7 @@ fn fragmentMain(input: VertexOutput) -> @location(0) vec4<f32> {
|
|
|
12059
12147
|
}
|
|
12060
12148
|
|
|
12061
12149
|
class TextureFactory extends AbstractAssetFactory {
|
|
12062
|
-
|
|
12063
|
-
super(...arguments);
|
|
12064
|
-
this.storageName = 'texture';
|
|
12065
|
-
}
|
|
12150
|
+
storageName = 'texture';
|
|
12066
12151
|
async process(response) {
|
|
12067
12152
|
return await response.arrayBuffer();
|
|
12068
12153
|
}
|
|
@@ -12094,11 +12179,8 @@ fn fragmentMain(input: VertexOutput) -> @location(0) vec4<f32> {
|
|
|
12094
12179
|
|
|
12095
12180
|
const onceListenerOption = { once: true };
|
|
12096
12181
|
class VideoFactory extends AbstractAssetFactory {
|
|
12097
|
-
|
|
12098
|
-
|
|
12099
|
-
this.storageName = 'video';
|
|
12100
|
-
this._videoElements = [];
|
|
12101
|
-
}
|
|
12182
|
+
storageName = 'video';
|
|
12183
|
+
_videoElements = [];
|
|
12102
12184
|
async process(response) {
|
|
12103
12185
|
return await response.arrayBuffer();
|
|
12104
12186
|
}
|
|
@@ -12130,10 +12212,7 @@ fn fragmentMain(input: VertexOutput) -> @location(0) vec4<f32> {
|
|
|
12130
12212
|
}
|
|
12131
12213
|
|
|
12132
12214
|
class SvgFactory extends AbstractAssetFactory {
|
|
12133
|
-
|
|
12134
|
-
super(...arguments);
|
|
12135
|
-
this.storageName = 'svg';
|
|
12136
|
-
}
|
|
12215
|
+
storageName = 'svg';
|
|
12137
12216
|
async process(response) {
|
|
12138
12217
|
return await response.text();
|
|
12139
12218
|
}
|
|
@@ -12163,10 +12242,7 @@ fn fragmentMain(input: VertexOutput) -> @location(0) vec4<f32> {
|
|
|
12163
12242
|
}
|
|
12164
12243
|
|
|
12165
12244
|
class BinaryFactory extends AbstractAssetFactory {
|
|
12166
|
-
|
|
12167
|
-
super(...arguments);
|
|
12168
|
-
this.storageName = 'binary';
|
|
12169
|
-
}
|
|
12245
|
+
storageName = 'binary';
|
|
12170
12246
|
async process(response) {
|
|
12171
12247
|
return response.arrayBuffer();
|
|
12172
12248
|
}
|
|
@@ -12176,10 +12252,7 @@ fn fragmentMain(input: VertexOutput) -> @location(0) vec4<f32> {
|
|
|
12176
12252
|
}
|
|
12177
12253
|
|
|
12178
12254
|
class WasmFactory extends AbstractAssetFactory {
|
|
12179
|
-
|
|
12180
|
-
super(...arguments);
|
|
12181
|
-
this.storageName = 'wasm';
|
|
12182
|
-
}
|
|
12255
|
+
storageName = 'wasm';
|
|
12183
12256
|
async process(response) {
|
|
12184
12257
|
return response.arrayBuffer();
|
|
12185
12258
|
}
|
|
@@ -12203,10 +12276,7 @@ fn fragmentMain(input: VertexOutput) -> @location(0) vec4<f32> {
|
|
|
12203
12276
|
return seconds;
|
|
12204
12277
|
};
|
|
12205
12278
|
class VttFactory extends AbstractAssetFactory {
|
|
12206
|
-
|
|
12207
|
-
super(...arguments);
|
|
12208
|
-
this.storageName = 'vtt';
|
|
12209
|
-
}
|
|
12279
|
+
storageName = 'vtt';
|
|
12210
12280
|
async process(response) {
|
|
12211
12281
|
return response.text();
|
|
12212
12282
|
}
|
|
@@ -12245,6 +12315,8 @@ fn fragmentMain(input: VertexOutput) -> @location(0) vec4<f32> {
|
|
|
12245
12315
|
}
|
|
12246
12316
|
|
|
12247
12317
|
class BundleLoadError extends Error {
|
|
12318
|
+
bundle;
|
|
12319
|
+
failures;
|
|
12248
12320
|
constructor(bundle, failures) {
|
|
12249
12321
|
super(`Failed to load bundle "${bundle}" (${failures.length} failure${failures.length === 1 ? '' : 's'}).`);
|
|
12250
12322
|
this.name = 'BundleLoadError';
|
|
@@ -12310,24 +12382,28 @@ fn fragmentMain(input: VertexOutput) -> @location(0) vec4<f32> {
|
|
|
12310
12382
|
// Loader
|
|
12311
12383
|
// ---------------------------------------------------------------------------
|
|
12312
12384
|
class Loader {
|
|
12385
|
+
_registry = new FactoryRegistry();
|
|
12386
|
+
_resources = new Map();
|
|
12387
|
+
_manifest = new Map();
|
|
12388
|
+
_bundles = new Map();
|
|
12389
|
+
_inFlight = new Map();
|
|
12390
|
+
_typeIds = new WeakMap();
|
|
12391
|
+
_preventStoreKeys = new Set();
|
|
12392
|
+
_stores;
|
|
12393
|
+
_resourcePath;
|
|
12394
|
+
_requestOptions;
|
|
12395
|
+
_concurrency;
|
|
12396
|
+
_nextTypeId = 1;
|
|
12397
|
+
_backgroundQueue = [];
|
|
12398
|
+
_backgroundActive = 0;
|
|
12399
|
+
_backgroundTotal = 0;
|
|
12400
|
+
_backgroundLoaded = 0;
|
|
12401
|
+
_backgroundResolve = null;
|
|
12402
|
+
onProgress = new Signal();
|
|
12403
|
+
onBundleProgress = new Signal();
|
|
12404
|
+
onLoaded = new Signal();
|
|
12405
|
+
onError = new Signal();
|
|
12313
12406
|
constructor(options = {}) {
|
|
12314
|
-
this._registry = new FactoryRegistry();
|
|
12315
|
-
this._resources = new Map();
|
|
12316
|
-
this._manifest = new Map();
|
|
12317
|
-
this._bundles = new Map();
|
|
12318
|
-
this._inFlight = new Map();
|
|
12319
|
-
this._typeIds = new WeakMap();
|
|
12320
|
-
this._preventStoreKeys = new Set();
|
|
12321
|
-
this._nextTypeId = 1;
|
|
12322
|
-
this._backgroundQueue = [];
|
|
12323
|
-
this._backgroundActive = 0;
|
|
12324
|
-
this._backgroundTotal = 0;
|
|
12325
|
-
this._backgroundLoaded = 0;
|
|
12326
|
-
this._backgroundResolve = null;
|
|
12327
|
-
this.onProgress = new Signal();
|
|
12328
|
-
this.onBundleProgress = new Signal();
|
|
12329
|
-
this.onLoaded = new Signal();
|
|
12330
|
-
this.onError = new Signal();
|
|
12331
12407
|
this._resourcePath = options.resourcePath ?? '';
|
|
12332
12408
|
this._requestOptions = options.requestOptions ?? {};
|
|
12333
12409
|
this._concurrency = options.concurrency ?? 6;
|
|
@@ -12917,14 +12993,22 @@ fn fragmentMain(input: VertexOutput) -> @location(0) vec4<f32> {
|
|
|
12917
12993
|
backend: defaultBackendConfig,
|
|
12918
12994
|
};
|
|
12919
12995
|
class Application {
|
|
12996
|
+
options;
|
|
12997
|
+
canvas;
|
|
12998
|
+
loader;
|
|
12999
|
+
inputManager;
|
|
13000
|
+
sceneManager;
|
|
13001
|
+
onResize = new Signal();
|
|
13002
|
+
_updateHandler;
|
|
13003
|
+
_startupClock = new Clock();
|
|
13004
|
+
_activeClock = new Clock();
|
|
13005
|
+
_frameClock = new Clock();
|
|
13006
|
+
_status = exports.ApplicationStatus.Stopped;
|
|
13007
|
+
_frameCount = 0;
|
|
13008
|
+
_frameRequest = 0;
|
|
13009
|
+
_backendType;
|
|
13010
|
+
_renderManager;
|
|
12920
13011
|
constructor(appSettings) {
|
|
12921
|
-
this.onResize = new Signal();
|
|
12922
|
-
this._startupClock = new Clock();
|
|
12923
|
-
this._activeClock = new Clock();
|
|
12924
|
-
this._frameClock = new Clock();
|
|
12925
|
-
this._status = exports.ApplicationStatus.Stopped;
|
|
12926
|
-
this._frameCount = 0;
|
|
12927
|
-
this._frameRequest = 0;
|
|
12928
13012
|
this.options = {
|
|
12929
13013
|
canvas: appSettings?.canvas ?? createDefaultCanvas(),
|
|
12930
13014
|
...defaultAppSettings,
|
|
@@ -13068,9 +13152,13 @@ fn fragmentMain(input: VertexOutput) -> @location(0) vec4<f32> {
|
|
|
13068
13152
|
}
|
|
13069
13153
|
|
|
13070
13154
|
class Quadtree {
|
|
13155
|
+
static maxSceneNodes = 50;
|
|
13156
|
+
static maxLevel = 5;
|
|
13157
|
+
level;
|
|
13158
|
+
_bounds;
|
|
13159
|
+
_quadTrees = new Map();
|
|
13160
|
+
_sceneNodes = new Set();
|
|
13071
13161
|
constructor(bounds, level = 0) {
|
|
13072
|
-
this._quadTrees = new Map();
|
|
13073
|
-
this._sceneNodes = new Set();
|
|
13074
13162
|
this._bounds = bounds.clone();
|
|
13075
13163
|
this.level = level;
|
|
13076
13164
|
}
|
|
@@ -13144,17 +13232,12 @@ fn fragmentMain(input: VertexOutput) -> @location(0) vec4<f32> {
|
|
|
13144
13232
|
}
|
|
13145
13233
|
}
|
|
13146
13234
|
}
|
|
13147
|
-
Quadtree.maxSceneNodes = 50;
|
|
13148
|
-
Quadtree.maxLevel = 5;
|
|
13149
13235
|
|
|
13150
13236
|
class Container extends RenderNode {
|
|
13151
|
-
|
|
13152
|
-
|
|
13153
|
-
|
|
13154
|
-
|
|
13155
|
-
this._sortDirty = false;
|
|
13156
|
-
this._nextChildOrder = 0;
|
|
13157
|
-
}
|
|
13237
|
+
_children = [];
|
|
13238
|
+
_sortableChildren = false;
|
|
13239
|
+
_sortDirty = false;
|
|
13240
|
+
_nextChildOrder = 0;
|
|
13158
13241
|
get children() {
|
|
13159
13242
|
return this._children;
|
|
13160
13243
|
}
|
|
@@ -13343,15 +13426,14 @@ fn fragmentMain(input: VertexOutput) -> @location(0) vec4<f32> {
|
|
|
13343
13426
|
}
|
|
13344
13427
|
|
|
13345
13428
|
class Scene {
|
|
13429
|
+
_app = null;
|
|
13430
|
+
_root = new Container();
|
|
13431
|
+
_stackMode = 'overlay';
|
|
13432
|
+
_inputMode = 'capture';
|
|
13346
13433
|
static create(definition) {
|
|
13347
13434
|
return Object.assign(new Scene(), definition);
|
|
13348
13435
|
}
|
|
13349
|
-
constructor() {
|
|
13350
|
-
this._app = null;
|
|
13351
|
-
this._root = new Container();
|
|
13352
|
-
this._stackMode = 'overlay';
|
|
13353
|
-
this._inputMode = 'capture';
|
|
13354
|
-
}
|
|
13436
|
+
constructor() { }
|
|
13355
13437
|
get app() {
|
|
13356
13438
|
return this._app;
|
|
13357
13439
|
}
|
|
@@ -13421,6 +13503,7 @@ fn fragmentMain(input: VertexOutput) -> @location(0) vec4<f32> {
|
|
|
13421
13503
|
}
|
|
13422
13504
|
|
|
13423
13505
|
class Timer extends Clock {
|
|
13506
|
+
_limit;
|
|
13424
13507
|
constructor(limit, autoStart = false) {
|
|
13425
13508
|
super();
|
|
13426
13509
|
this._limit = limit.clone();
|
|
@@ -13449,10 +13532,20 @@ fn fragmentMain(input: VertexOutput) -> @location(0) vec4<f32> {
|
|
|
13449
13532
|
}
|
|
13450
13533
|
|
|
13451
13534
|
class AudioAnalyser {
|
|
13535
|
+
_media;
|
|
13536
|
+
_fftSize;
|
|
13537
|
+
_minDecibels;
|
|
13538
|
+
_maxDecibels;
|
|
13539
|
+
_smoothingTimeConstant;
|
|
13540
|
+
_frequencyBinCount;
|
|
13541
|
+
_timeDomainData;
|
|
13542
|
+
_frequencyData;
|
|
13543
|
+
_preciseTimeDomainData;
|
|
13544
|
+
_preciseFrequencyData;
|
|
13545
|
+
_analyser = null;
|
|
13546
|
+
_audioContext = null;
|
|
13547
|
+
_analyserTarget = null;
|
|
13452
13548
|
constructor(media, options = {}) {
|
|
13453
|
-
this._analyser = null;
|
|
13454
|
-
this._audioContext = null;
|
|
13455
|
-
this._analyserTarget = null;
|
|
13456
13549
|
const { fftSize, minDecibels, maxDecibels, smoothingTimeConstant } = options;
|
|
13457
13550
|
this._media = media;
|
|
13458
13551
|
this._fftSize = fftSize ?? 2048;
|
|
@@ -13631,6 +13724,25 @@ fn fragmentMain(input: VertexOutput) -> @location(0) vec4<f32> {
|
|
|
13631
13724
|
[exports.GamepadMappingFamily.ArcadeStick, genericLabels],
|
|
13632
13725
|
]);
|
|
13633
13726
|
class GamepadPromptLayouts {
|
|
13727
|
+
static controls = [
|
|
13728
|
+
'DPad',
|
|
13729
|
+
'DPadUp',
|
|
13730
|
+
'DPadDown',
|
|
13731
|
+
'DPadLeft',
|
|
13732
|
+
'DPadRight',
|
|
13733
|
+
'ButtonNorth',
|
|
13734
|
+
'ButtonWest',
|
|
13735
|
+
'ButtonEast',
|
|
13736
|
+
'ButtonSouth',
|
|
13737
|
+
'LeftShoulder',
|
|
13738
|
+
'RightShoulder',
|
|
13739
|
+
'LeftTrigger',
|
|
13740
|
+
'RightTrigger',
|
|
13741
|
+
'Select',
|
|
13742
|
+
'Start',
|
|
13743
|
+
'LeftStick',
|
|
13744
|
+
'RightStick',
|
|
13745
|
+
];
|
|
13634
13746
|
static getControlPosition(control) {
|
|
13635
13747
|
return basePositions.get(control) ?? [0.5, 0.5];
|
|
13636
13748
|
}
|
|
@@ -13641,34 +13753,17 @@ fn fragmentMain(input: VertexOutput) -> @location(0) vec4<f32> {
|
|
|
13641
13753
|
return channelMap;
|
|
13642
13754
|
}
|
|
13643
13755
|
}
|
|
13644
|
-
GamepadPromptLayouts.controls = [
|
|
13645
|
-
'DPad',
|
|
13646
|
-
'DPadUp',
|
|
13647
|
-
'DPadDown',
|
|
13648
|
-
'DPadLeft',
|
|
13649
|
-
'DPadRight',
|
|
13650
|
-
'ButtonNorth',
|
|
13651
|
-
'ButtonWest',
|
|
13652
|
-
'ButtonEast',
|
|
13653
|
-
'ButtonSouth',
|
|
13654
|
-
'LeftShoulder',
|
|
13655
|
-
'RightShoulder',
|
|
13656
|
-
'LeftTrigger',
|
|
13657
|
-
'RightTrigger',
|
|
13658
|
-
'Select',
|
|
13659
|
-
'Start',
|
|
13660
|
-
'LeftStick',
|
|
13661
|
-
'RightStick',
|
|
13662
|
-
];
|
|
13663
13756
|
|
|
13664
13757
|
class Input {
|
|
13758
|
+
static triggerThreshold = 300;
|
|
13759
|
+
channels = new Set();
|
|
13760
|
+
triggerTimer;
|
|
13761
|
+
valueState = 0;
|
|
13762
|
+
onStart = new Signal();
|
|
13763
|
+
onStop = new Signal();
|
|
13764
|
+
onActive = new Signal();
|
|
13765
|
+
onTrigger = new Signal();
|
|
13665
13766
|
constructor(channels, { onStart, onStop, onActive, onTrigger, context, threshold } = {}) {
|
|
13666
|
-
this.channels = new Set();
|
|
13667
|
-
this.valueState = 0;
|
|
13668
|
-
this.onStart = new Signal();
|
|
13669
|
-
this.onStop = new Signal();
|
|
13670
|
-
this.onActive = new Signal();
|
|
13671
|
-
this.onTrigger = new Signal();
|
|
13672
13767
|
this.channels = new Set(Array.isArray(channels) ? channels : [channels]);
|
|
13673
13768
|
this.triggerTimer = new Timer(milliseconds(threshold ?? Input.triggerThreshold));
|
|
13674
13769
|
if (onStart) {
|
|
@@ -13720,704 +13815,638 @@ fn fragmentMain(input: VertexOutput) -> @location(0) vec4<f32> {
|
|
|
13720
13815
|
this.onTrigger.destroy();
|
|
13721
13816
|
}
|
|
13722
13817
|
}
|
|
13723
|
-
Input.triggerThreshold = 300;
|
|
13724
13818
|
|
|
13725
|
-
function
|
|
13726
|
-
|
|
13819
|
+
function earcut(data, holeIndices, dim = 2) {
|
|
13820
|
+
|
|
13821
|
+
const hasHoles = holeIndices && holeIndices.length;
|
|
13822
|
+
const outerLen = hasHoles ? holeIndices[0] * dim : data.length;
|
|
13823
|
+
let outerNode = linkedList(data, 0, outerLen, dim, true);
|
|
13824
|
+
const triangles = [];
|
|
13825
|
+
|
|
13826
|
+
if (!outerNode || outerNode.next === outerNode.prev) return triangles;
|
|
13827
|
+
|
|
13828
|
+
let minX, minY, invSize;
|
|
13829
|
+
|
|
13830
|
+
if (hasHoles) outerNode = eliminateHoles(data, holeIndices, outerNode, dim);
|
|
13831
|
+
|
|
13832
|
+
// if the shape is not too simple, we'll use z-order curve hash later; calculate polygon bbox
|
|
13833
|
+
if (data.length > 80 * dim) {
|
|
13834
|
+
minX = data[0];
|
|
13835
|
+
minY = data[1];
|
|
13836
|
+
let maxX = minX;
|
|
13837
|
+
let maxY = minY;
|
|
13838
|
+
|
|
13839
|
+
for (let i = dim; i < outerLen; i += dim) {
|
|
13840
|
+
const x = data[i];
|
|
13841
|
+
const y = data[i + 1];
|
|
13842
|
+
if (x < minX) minX = x;
|
|
13843
|
+
if (y < minY) minY = y;
|
|
13844
|
+
if (x > maxX) maxX = x;
|
|
13845
|
+
if (y > maxY) maxY = y;
|
|
13846
|
+
}
|
|
13847
|
+
|
|
13848
|
+
// minX, minY and invSize are later used to transform coords into integers for z-order calculation
|
|
13849
|
+
invSize = Math.max(maxX - minX, maxY - minY);
|
|
13850
|
+
invSize = invSize !== 0 ? 32767 / invSize : 0;
|
|
13851
|
+
}
|
|
13852
|
+
|
|
13853
|
+
earcutLinked(outerNode, triangles, dim, minX, minY, invSize, 0);
|
|
13854
|
+
|
|
13855
|
+
return triangles;
|
|
13856
|
+
}
|
|
13857
|
+
|
|
13858
|
+
// create a circular doubly linked list from polygon points in the specified winding order
|
|
13859
|
+
function linkedList(data, start, end, dim, clockwise) {
|
|
13860
|
+
let last;
|
|
13861
|
+
|
|
13862
|
+
if (clockwise === (signedArea(data, start, end, dim) > 0)) {
|
|
13863
|
+
for (let i = start; i < end; i += dim) last = insertNode(i / dim | 0, data[i], data[i + 1], last);
|
|
13864
|
+
} else {
|
|
13865
|
+
for (let i = end - dim; i >= start; i -= dim) last = insertNode(i / dim | 0, data[i], data[i + 1], last);
|
|
13866
|
+
}
|
|
13867
|
+
|
|
13868
|
+
if (last && equals(last, last.next)) {
|
|
13869
|
+
removeNode(last);
|
|
13870
|
+
last = last.next;
|
|
13871
|
+
}
|
|
13872
|
+
|
|
13873
|
+
return last;
|
|
13874
|
+
}
|
|
13875
|
+
|
|
13876
|
+
// eliminate colinear or duplicate points
|
|
13877
|
+
function filterPoints(start, end) {
|
|
13878
|
+
if (!start) return start;
|
|
13879
|
+
if (!end) end = start;
|
|
13880
|
+
|
|
13881
|
+
let p = start,
|
|
13882
|
+
again;
|
|
13883
|
+
do {
|
|
13884
|
+
again = false;
|
|
13885
|
+
|
|
13886
|
+
if (!p.steiner && (equals(p, p.next) || area(p.prev, p, p.next) === 0)) {
|
|
13887
|
+
removeNode(p);
|
|
13888
|
+
p = end = p.prev;
|
|
13889
|
+
if (p === p.next) break;
|
|
13890
|
+
again = true;
|
|
13891
|
+
|
|
13892
|
+
} else {
|
|
13893
|
+
p = p.next;
|
|
13894
|
+
}
|
|
13895
|
+
} while (again || p !== end);
|
|
13896
|
+
|
|
13897
|
+
return end;
|
|
13727
13898
|
}
|
|
13728
13899
|
|
|
13729
|
-
|
|
13900
|
+
// main ear slicing loop which triangulates a polygon (given as a linked list)
|
|
13901
|
+
function earcutLinked(ear, triangles, dim, minX, minY, invSize, pass) {
|
|
13902
|
+
if (!ear) return;
|
|
13903
|
+
|
|
13904
|
+
// interlink polygon nodes in z-order
|
|
13905
|
+
if (!pass && invSize) indexCurve(ear, minX, minY, invSize);
|
|
13906
|
+
|
|
13907
|
+
let stop = ear;
|
|
13908
|
+
|
|
13909
|
+
// iterate through ears, slicing them one by one
|
|
13910
|
+
while (ear.prev !== ear.next) {
|
|
13911
|
+
const prev = ear.prev;
|
|
13912
|
+
const next = ear.next;
|
|
13913
|
+
|
|
13914
|
+
if (invSize ? isEarHashed(ear, minX, minY, invSize) : isEar(ear)) {
|
|
13915
|
+
triangles.push(prev.i, ear.i, next.i); // cut off the triangle
|
|
13916
|
+
|
|
13917
|
+
removeNode(ear);
|
|
13918
|
+
|
|
13919
|
+
// skipping the next vertex leads to less sliver triangles
|
|
13920
|
+
ear = next.next;
|
|
13921
|
+
stop = next.next;
|
|
13922
|
+
|
|
13923
|
+
continue;
|
|
13924
|
+
}
|
|
13925
|
+
|
|
13926
|
+
ear = next;
|
|
13730
13927
|
|
|
13731
|
-
|
|
13928
|
+
// if we looped through the whole remaining polygon and can't find any more ears
|
|
13929
|
+
if (ear === stop) {
|
|
13930
|
+
// try filtering points and slicing again
|
|
13931
|
+
if (!pass) {
|
|
13932
|
+
earcutLinked(filterPoints(ear), triangles, dim, minX, minY, invSize, 1);
|
|
13732
13933
|
|
|
13733
|
-
|
|
13734
|
-
|
|
13735
|
-
|
|
13934
|
+
// if this didn't work, try curing all small self-intersections locally
|
|
13935
|
+
} else if (pass === 1) {
|
|
13936
|
+
ear = cureLocalIntersections(filterPoints(ear), triangles);
|
|
13937
|
+
earcutLinked(ear, triangles, dim, minX, minY, invSize, 2);
|
|
13938
|
+
|
|
13939
|
+
// as a last resort, try splitting the remaining polygon into two
|
|
13940
|
+
} else if (pass === 2) {
|
|
13941
|
+
splitEarcut(ear, triangles, dim, minX, minY, invSize);
|
|
13942
|
+
}
|
|
13736
13943
|
|
|
13737
|
-
|
|
13738
|
-
|
|
13944
|
+
break;
|
|
13945
|
+
}
|
|
13946
|
+
}
|
|
13947
|
+
}
|
|
13739
13948
|
|
|
13740
|
-
|
|
13949
|
+
// check whether a polygon node forms a valid ear with adjacent nodes
|
|
13950
|
+
function isEar(ear) {
|
|
13951
|
+
const a = ear.prev,
|
|
13952
|
+
b = ear,
|
|
13953
|
+
c = ear.next;
|
|
13741
13954
|
|
|
13742
|
-
|
|
13955
|
+
if (area(a, b, c) >= 0) return false; // reflex, can't be an ear
|
|
13743
13956
|
|
|
13744
|
-
|
|
13745
|
-
|
|
13746
|
-
outerNode = linkedList(data, 0, outerLen, dim, true),
|
|
13747
|
-
triangles = [];
|
|
13957
|
+
// now make sure we don't have other points inside the potential ear
|
|
13958
|
+
const ax = a.x, bx = b.x, cx = c.x, ay = a.y, by = b.y, cy = c.y;
|
|
13748
13959
|
|
|
13749
|
-
|
|
13960
|
+
// triangle bbox
|
|
13961
|
+
const x0 = Math.min(ax, bx, cx),
|
|
13962
|
+
y0 = Math.min(ay, by, cy),
|
|
13963
|
+
x1 = Math.max(ax, bx, cx),
|
|
13964
|
+
y1 = Math.max(ay, by, cy);
|
|
13750
13965
|
|
|
13751
|
-
|
|
13966
|
+
let p = c.next;
|
|
13967
|
+
while (p !== a) {
|
|
13968
|
+
if (p.x >= x0 && p.x <= x1 && p.y >= y0 && p.y <= y1 &&
|
|
13969
|
+
pointInTriangleExceptFirst(ax, ay, bx, by, cx, cy, p.x, p.y) &&
|
|
13970
|
+
area(p.prev, p, p.next) >= 0) return false;
|
|
13971
|
+
p = p.next;
|
|
13972
|
+
}
|
|
13752
13973
|
|
|
13753
|
-
|
|
13974
|
+
return true;
|
|
13975
|
+
}
|
|
13754
13976
|
|
|
13755
|
-
|
|
13756
|
-
|
|
13757
|
-
|
|
13758
|
-
|
|
13977
|
+
function isEarHashed(ear, minX, minY, invSize) {
|
|
13978
|
+
const a = ear.prev,
|
|
13979
|
+
b = ear,
|
|
13980
|
+
c = ear.next;
|
|
13759
13981
|
|
|
13760
|
-
|
|
13761
|
-
x = data[i];
|
|
13762
|
-
y = data[i + 1];
|
|
13763
|
-
if (x < minX) minX = x;
|
|
13764
|
-
if (y < minY) minY = y;
|
|
13765
|
-
if (x > maxX) maxX = x;
|
|
13766
|
-
if (y > maxY) maxY = y;
|
|
13767
|
-
}
|
|
13982
|
+
if (area(a, b, c) >= 0) return false; // reflex, can't be an ear
|
|
13768
13983
|
|
|
13769
|
-
|
|
13770
|
-
invSize = Math.max(maxX - minX, maxY - minY);
|
|
13771
|
-
invSize = invSize !== 0 ? 32767 / invSize : 0;
|
|
13772
|
-
}
|
|
13984
|
+
const ax = a.x, bx = b.x, cx = c.x, ay = a.y, by = b.y, cy = c.y;
|
|
13773
13985
|
|
|
13774
|
-
|
|
13986
|
+
// triangle bbox
|
|
13987
|
+
const x0 = Math.min(ax, bx, cx),
|
|
13988
|
+
y0 = Math.min(ay, by, cy),
|
|
13989
|
+
x1 = Math.max(ax, bx, cx),
|
|
13990
|
+
y1 = Math.max(ay, by, cy);
|
|
13775
13991
|
|
|
13776
|
-
|
|
13777
|
-
|
|
13992
|
+
// z-order range for the current triangle bbox;
|
|
13993
|
+
const minZ = zOrder(x0, y0, minX, minY, invSize),
|
|
13994
|
+
maxZ = zOrder(x1, y1, minX, minY, invSize);
|
|
13778
13995
|
|
|
13779
|
-
|
|
13780
|
-
|
|
13781
|
-
var i, last;
|
|
13996
|
+
let p = ear.prevZ,
|
|
13997
|
+
n = ear.nextZ;
|
|
13782
13998
|
|
|
13783
|
-
|
|
13784
|
-
|
|
13785
|
-
|
|
13786
|
-
|
|
13787
|
-
|
|
13999
|
+
// look for points inside the triangle in both directions
|
|
14000
|
+
while (p && p.z >= minZ && n && n.z <= maxZ) {
|
|
14001
|
+
if (p.x >= x0 && p.x <= x1 && p.y >= y0 && p.y <= y1 && p !== a && p !== c &&
|
|
14002
|
+
pointInTriangleExceptFirst(ax, ay, bx, by, cx, cy, p.x, p.y) && area(p.prev, p, p.next) >= 0) return false;
|
|
14003
|
+
p = p.prevZ;
|
|
13788
14004
|
|
|
13789
|
-
|
|
13790
|
-
|
|
13791
|
-
|
|
13792
|
-
|
|
14005
|
+
if (n.x >= x0 && n.x <= x1 && n.y >= y0 && n.y <= y1 && n !== a && n !== c &&
|
|
14006
|
+
pointInTriangleExceptFirst(ax, ay, bx, by, cx, cy, n.x, n.y) && area(n.prev, n, n.next) >= 0) return false;
|
|
14007
|
+
n = n.nextZ;
|
|
14008
|
+
}
|
|
13793
14009
|
|
|
13794
|
-
|
|
13795
|
-
|
|
14010
|
+
// look for remaining points in decreasing z-order
|
|
14011
|
+
while (p && p.z >= minZ) {
|
|
14012
|
+
if (p.x >= x0 && p.x <= x1 && p.y >= y0 && p.y <= y1 && p !== a && p !== c &&
|
|
14013
|
+
pointInTriangleExceptFirst(ax, ay, bx, by, cx, cy, p.x, p.y) && area(p.prev, p, p.next) >= 0) return false;
|
|
14014
|
+
p = p.prevZ;
|
|
14015
|
+
}
|
|
13796
14016
|
|
|
13797
|
-
|
|
13798
|
-
|
|
13799
|
-
|
|
13800
|
-
|
|
14017
|
+
// look for remaining points in increasing z-order
|
|
14018
|
+
while (n && n.z <= maxZ) {
|
|
14019
|
+
if (n.x >= x0 && n.x <= x1 && n.y >= y0 && n.y <= y1 && n !== a && n !== c &&
|
|
14020
|
+
pointInTriangleExceptFirst(ax, ay, bx, by, cx, cy, n.x, n.y) && area(n.prev, n, n.next) >= 0) return false;
|
|
14021
|
+
n = n.nextZ;
|
|
14022
|
+
}
|
|
13801
14023
|
|
|
13802
|
-
|
|
13803
|
-
|
|
13804
|
-
do {
|
|
13805
|
-
again = false;
|
|
14024
|
+
return true;
|
|
14025
|
+
}
|
|
13806
14026
|
|
|
13807
|
-
|
|
13808
|
-
|
|
13809
|
-
|
|
13810
|
-
|
|
13811
|
-
|
|
14027
|
+
// go through all polygon nodes and cure small local self-intersections
|
|
14028
|
+
function cureLocalIntersections(start, triangles) {
|
|
14029
|
+
let p = start;
|
|
14030
|
+
do {
|
|
14031
|
+
const a = p.prev,
|
|
14032
|
+
b = p.next.next;
|
|
13812
14033
|
|
|
13813
|
-
|
|
13814
|
-
p = p.next;
|
|
13815
|
-
}
|
|
13816
|
-
} while (again || p !== end);
|
|
14034
|
+
if (!equals(a, b) && intersects(a, p, p.next, b) && locallyInside(a, b) && locallyInside(b, a)) {
|
|
13817
14035
|
|
|
13818
|
-
|
|
13819
|
-
}
|
|
14036
|
+
triangles.push(a.i, p.i, b.i);
|
|
13820
14037
|
|
|
13821
|
-
|
|
13822
|
-
|
|
13823
|
-
|
|
14038
|
+
// remove two nodes involved
|
|
14039
|
+
removeNode(p);
|
|
14040
|
+
removeNode(p.next);
|
|
13824
14041
|
|
|
13825
|
-
|
|
13826
|
-
|
|
14042
|
+
p = start = b;
|
|
14043
|
+
}
|
|
14044
|
+
p = p.next;
|
|
14045
|
+
} while (p !== start);
|
|
13827
14046
|
|
|
13828
|
-
|
|
13829
|
-
|
|
14047
|
+
return filterPoints(p);
|
|
14048
|
+
}
|
|
13830
14049
|
|
|
13831
|
-
|
|
13832
|
-
|
|
13833
|
-
|
|
13834
|
-
|
|
13835
|
-
|
|
13836
|
-
|
|
13837
|
-
|
|
13838
|
-
|
|
13839
|
-
|
|
13840
|
-
|
|
13841
|
-
|
|
13842
|
-
|
|
13843
|
-
|
|
13844
|
-
|
|
13845
|
-
|
|
13846
|
-
|
|
13847
|
-
|
|
13848
|
-
|
|
13849
|
-
|
|
13850
|
-
|
|
13851
|
-
|
|
13852
|
-
|
|
13853
|
-
|
|
13854
|
-
|
|
13855
|
-
// try filtering points and slicing again
|
|
13856
|
-
if (!pass) {
|
|
13857
|
-
earcutLinked(filterPoints(ear), triangles, dim, minX, minY, invSize, 1);
|
|
13858
|
-
|
|
13859
|
-
// if this didn't work, try curing all small self-intersections locally
|
|
13860
|
-
} else if (pass === 1) {
|
|
13861
|
-
ear = cureLocalIntersections(filterPoints(ear), triangles, dim);
|
|
13862
|
-
earcutLinked(ear, triangles, dim, minX, minY, invSize, 2);
|
|
13863
|
-
|
|
13864
|
-
// as a last resort, try splitting the remaining polygon into two
|
|
13865
|
-
} else if (pass === 2) {
|
|
13866
|
-
splitEarcut(ear, triangles, dim, minX, minY, invSize);
|
|
13867
|
-
}
|
|
13868
|
-
|
|
13869
|
-
break;
|
|
13870
|
-
}
|
|
13871
|
-
}
|
|
13872
|
-
}
|
|
13873
|
-
|
|
13874
|
-
// check whether a polygon node forms a valid ear with adjacent nodes
|
|
13875
|
-
function isEar(ear) {
|
|
13876
|
-
var a = ear.prev,
|
|
13877
|
-
b = ear,
|
|
13878
|
-
c = ear.next;
|
|
13879
|
-
|
|
13880
|
-
if (area(a, b, c) >= 0) return false; // reflex, can't be an ear
|
|
13881
|
-
|
|
13882
|
-
// now make sure we don't have other points inside the potential ear
|
|
13883
|
-
var ax = a.x, bx = b.x, cx = c.x, ay = a.y, by = b.y, cy = c.y;
|
|
13884
|
-
|
|
13885
|
-
// triangle bbox; min & max are calculated like this for speed
|
|
13886
|
-
var x0 = ax < bx ? (ax < cx ? ax : cx) : (bx < cx ? bx : cx),
|
|
13887
|
-
y0 = ay < by ? (ay < cy ? ay : cy) : (by < cy ? by : cy),
|
|
13888
|
-
x1 = ax > bx ? (ax > cx ? ax : cx) : (bx > cx ? bx : cx),
|
|
13889
|
-
y1 = ay > by ? (ay > cy ? ay : cy) : (by > cy ? by : cy);
|
|
13890
|
-
|
|
13891
|
-
var p = c.next;
|
|
13892
|
-
while (p !== a) {
|
|
13893
|
-
if (p.x >= x0 && p.x <= x1 && p.y >= y0 && p.y <= y1 &&
|
|
13894
|
-
pointInTriangle(ax, ay, bx, by, cx, cy, p.x, p.y) &&
|
|
13895
|
-
area(p.prev, p, p.next) >= 0) return false;
|
|
13896
|
-
p = p.next;
|
|
13897
|
-
}
|
|
13898
|
-
|
|
13899
|
-
return true;
|
|
13900
|
-
}
|
|
13901
|
-
|
|
13902
|
-
function isEarHashed(ear, minX, minY, invSize) {
|
|
13903
|
-
var a = ear.prev,
|
|
13904
|
-
b = ear,
|
|
13905
|
-
c = ear.next;
|
|
13906
|
-
|
|
13907
|
-
if (area(a, b, c) >= 0) return false; // reflex, can't be an ear
|
|
13908
|
-
|
|
13909
|
-
var ax = a.x, bx = b.x, cx = c.x, ay = a.y, by = b.y, cy = c.y;
|
|
13910
|
-
|
|
13911
|
-
// triangle bbox; min & max are calculated like this for speed
|
|
13912
|
-
var x0 = ax < bx ? (ax < cx ? ax : cx) : (bx < cx ? bx : cx),
|
|
13913
|
-
y0 = ay < by ? (ay < cy ? ay : cy) : (by < cy ? by : cy),
|
|
13914
|
-
x1 = ax > bx ? (ax > cx ? ax : cx) : (bx > cx ? bx : cx),
|
|
13915
|
-
y1 = ay > by ? (ay > cy ? ay : cy) : (by > cy ? by : cy);
|
|
13916
|
-
|
|
13917
|
-
// z-order range for the current triangle bbox;
|
|
13918
|
-
var minZ = zOrder(x0, y0, minX, minY, invSize),
|
|
13919
|
-
maxZ = zOrder(x1, y1, minX, minY, invSize);
|
|
13920
|
-
|
|
13921
|
-
var p = ear.prevZ,
|
|
13922
|
-
n = ear.nextZ;
|
|
13923
|
-
|
|
13924
|
-
// look for points inside the triangle in both directions
|
|
13925
|
-
while (p && p.z >= minZ && n && n.z <= maxZ) {
|
|
13926
|
-
if (p.x >= x0 && p.x <= x1 && p.y >= y0 && p.y <= y1 && p !== a && p !== c &&
|
|
13927
|
-
pointInTriangle(ax, ay, bx, by, cx, cy, p.x, p.y) && area(p.prev, p, p.next) >= 0) return false;
|
|
13928
|
-
p = p.prevZ;
|
|
13929
|
-
|
|
13930
|
-
if (n.x >= x0 && n.x <= x1 && n.y >= y0 && n.y <= y1 && n !== a && n !== c &&
|
|
13931
|
-
pointInTriangle(ax, ay, bx, by, cx, cy, n.x, n.y) && area(n.prev, n, n.next) >= 0) return false;
|
|
13932
|
-
n = n.nextZ;
|
|
13933
|
-
}
|
|
13934
|
-
|
|
13935
|
-
// look for remaining points in decreasing z-order
|
|
13936
|
-
while (p && p.z >= minZ) {
|
|
13937
|
-
if (p.x >= x0 && p.x <= x1 && p.y >= y0 && p.y <= y1 && p !== a && p !== c &&
|
|
13938
|
-
pointInTriangle(ax, ay, bx, by, cx, cy, p.x, p.y) && area(p.prev, p, p.next) >= 0) return false;
|
|
13939
|
-
p = p.prevZ;
|
|
13940
|
-
}
|
|
13941
|
-
|
|
13942
|
-
// look for remaining points in increasing z-order
|
|
13943
|
-
while (n && n.z <= maxZ) {
|
|
13944
|
-
if (n.x >= x0 && n.x <= x1 && n.y >= y0 && n.y <= y1 && n !== a && n !== c &&
|
|
13945
|
-
pointInTriangle(ax, ay, bx, by, cx, cy, n.x, n.y) && area(n.prev, n, n.next) >= 0) return false;
|
|
13946
|
-
n = n.nextZ;
|
|
13947
|
-
}
|
|
13948
|
-
|
|
13949
|
-
return true;
|
|
13950
|
-
}
|
|
13951
|
-
|
|
13952
|
-
// go through all polygon nodes and cure small local self-intersections
|
|
13953
|
-
function cureLocalIntersections(start, triangles, dim) {
|
|
13954
|
-
var p = start;
|
|
13955
|
-
do {
|
|
13956
|
-
var a = p.prev,
|
|
13957
|
-
b = p.next.next;
|
|
13958
|
-
|
|
13959
|
-
if (!equals(a, b) && intersects(a, p, p.next, b) && locallyInside(a, b) && locallyInside(b, a)) {
|
|
13960
|
-
|
|
13961
|
-
triangles.push(a.i / dim | 0);
|
|
13962
|
-
triangles.push(p.i / dim | 0);
|
|
13963
|
-
triangles.push(b.i / dim | 0);
|
|
13964
|
-
|
|
13965
|
-
// remove two nodes involved
|
|
13966
|
-
removeNode(p);
|
|
13967
|
-
removeNode(p.next);
|
|
13968
|
-
|
|
13969
|
-
p = start = b;
|
|
13970
|
-
}
|
|
13971
|
-
p = p.next;
|
|
13972
|
-
} while (p !== start);
|
|
13973
|
-
|
|
13974
|
-
return filterPoints(p);
|
|
13975
|
-
}
|
|
13976
|
-
|
|
13977
|
-
// try splitting polygon into two and triangulate them independently
|
|
13978
|
-
function splitEarcut(start, triangles, dim, minX, minY, invSize) {
|
|
13979
|
-
// look for a valid diagonal that divides the polygon into two
|
|
13980
|
-
var a = start;
|
|
13981
|
-
do {
|
|
13982
|
-
var b = a.next.next;
|
|
13983
|
-
while (b !== a.prev) {
|
|
13984
|
-
if (a.i !== b.i && isValidDiagonal(a, b)) {
|
|
13985
|
-
// split the polygon in two by the diagonal
|
|
13986
|
-
var c = splitPolygon(a, b);
|
|
13987
|
-
|
|
13988
|
-
// filter colinear points around the cuts
|
|
13989
|
-
a = filterPoints(a, a.next);
|
|
13990
|
-
c = filterPoints(c, c.next);
|
|
13991
|
-
|
|
13992
|
-
// run earcut on each half
|
|
13993
|
-
earcutLinked(a, triangles, dim, minX, minY, invSize, 0);
|
|
13994
|
-
earcutLinked(c, triangles, dim, minX, minY, invSize, 0);
|
|
13995
|
-
return;
|
|
13996
|
-
}
|
|
13997
|
-
b = b.next;
|
|
13998
|
-
}
|
|
13999
|
-
a = a.next;
|
|
14000
|
-
} while (a !== start);
|
|
14001
|
-
}
|
|
14002
|
-
|
|
14003
|
-
// link every hole into the outer loop, producing a single-ring polygon without holes
|
|
14004
|
-
function eliminateHoles(data, holeIndices, outerNode, dim) {
|
|
14005
|
-
var queue = [],
|
|
14006
|
-
i, len, start, end, list;
|
|
14007
|
-
|
|
14008
|
-
for (i = 0, len = holeIndices.length; i < len; i++) {
|
|
14009
|
-
start = holeIndices[i] * dim;
|
|
14010
|
-
end = i < len - 1 ? holeIndices[i + 1] * dim : data.length;
|
|
14011
|
-
list = linkedList(data, start, end, dim, false);
|
|
14012
|
-
if (list === list.next) list.steiner = true;
|
|
14013
|
-
queue.push(getLeftmost(list));
|
|
14014
|
-
}
|
|
14015
|
-
|
|
14016
|
-
queue.sort(compareX);
|
|
14017
|
-
|
|
14018
|
-
// process holes from left to right
|
|
14019
|
-
for (i = 0; i < queue.length; i++) {
|
|
14020
|
-
outerNode = eliminateHole(queue[i], outerNode);
|
|
14021
|
-
}
|
|
14022
|
-
|
|
14023
|
-
return outerNode;
|
|
14024
|
-
}
|
|
14025
|
-
|
|
14026
|
-
function compareX(a, b) {
|
|
14027
|
-
return a.x - b.x;
|
|
14028
|
-
}
|
|
14029
|
-
|
|
14030
|
-
// find a bridge between vertices that connects hole with an outer ring and and link it
|
|
14031
|
-
function eliminateHole(hole, outerNode) {
|
|
14032
|
-
var bridge = findHoleBridge(hole, outerNode);
|
|
14033
|
-
if (!bridge) {
|
|
14034
|
-
return outerNode;
|
|
14035
|
-
}
|
|
14036
|
-
|
|
14037
|
-
var bridgeReverse = splitPolygon(bridge, hole);
|
|
14038
|
-
|
|
14039
|
-
// filter collinear points around the cuts
|
|
14040
|
-
filterPoints(bridgeReverse, bridgeReverse.next);
|
|
14041
|
-
return filterPoints(bridge, bridge.next);
|
|
14042
|
-
}
|
|
14043
|
-
|
|
14044
|
-
// David Eberly's algorithm for finding a bridge between hole and outer polygon
|
|
14045
|
-
function findHoleBridge(hole, outerNode) {
|
|
14046
|
-
var p = outerNode,
|
|
14047
|
-
hx = hole.x,
|
|
14048
|
-
hy = hole.y,
|
|
14049
|
-
qx = -Infinity,
|
|
14050
|
-
m;
|
|
14051
|
-
|
|
14052
|
-
// find a segment intersected by a ray from the hole's leftmost point to the left;
|
|
14053
|
-
// segment's endpoint with lesser x will be potential connection point
|
|
14054
|
-
do {
|
|
14055
|
-
if (hy <= p.y && hy >= p.next.y && p.next.y !== p.y) {
|
|
14056
|
-
var x = p.x + (hy - p.y) * (p.next.x - p.x) / (p.next.y - p.y);
|
|
14057
|
-
if (x <= hx && x > qx) {
|
|
14058
|
-
qx = x;
|
|
14059
|
-
m = p.x < p.next.x ? p : p.next;
|
|
14060
|
-
if (x === hx) return m; // hole touches outer segment; pick leftmost endpoint
|
|
14061
|
-
}
|
|
14062
|
-
}
|
|
14063
|
-
p = p.next;
|
|
14064
|
-
} while (p !== outerNode);
|
|
14065
|
-
|
|
14066
|
-
if (!m) return null;
|
|
14067
|
-
|
|
14068
|
-
// look for points inside the triangle of hole point, segment intersection and endpoint;
|
|
14069
|
-
// if there are no points found, we have a valid connection;
|
|
14070
|
-
// otherwise choose the point of the minimum angle with the ray as connection point
|
|
14071
|
-
|
|
14072
|
-
var stop = m,
|
|
14073
|
-
mx = m.x,
|
|
14074
|
-
my = m.y,
|
|
14075
|
-
tanMin = Infinity,
|
|
14076
|
-
tan;
|
|
14077
|
-
|
|
14078
|
-
p = m;
|
|
14079
|
-
|
|
14080
|
-
do {
|
|
14081
|
-
if (hx >= p.x && p.x >= mx && hx !== p.x &&
|
|
14082
|
-
pointInTriangle(hy < my ? hx : qx, hy, mx, my, hy < my ? qx : hx, hy, p.x, p.y)) {
|
|
14083
|
-
|
|
14084
|
-
tan = Math.abs(hy - p.y) / (hx - p.x); // tangential
|
|
14085
|
-
|
|
14086
|
-
if (locallyInside(p, hole) &&
|
|
14087
|
-
(tan < tanMin || (tan === tanMin && (p.x > m.x || (p.x === m.x && sectorContainsSector(m, p)))))) {
|
|
14088
|
-
m = p;
|
|
14089
|
-
tanMin = tan;
|
|
14090
|
-
}
|
|
14091
|
-
}
|
|
14092
|
-
|
|
14093
|
-
p = p.next;
|
|
14094
|
-
} while (p !== stop);
|
|
14095
|
-
|
|
14096
|
-
return m;
|
|
14097
|
-
}
|
|
14098
|
-
|
|
14099
|
-
// whether sector in vertex m contains sector in vertex p in the same coordinates
|
|
14100
|
-
function sectorContainsSector(m, p) {
|
|
14101
|
-
return area(m.prev, m, p.prev) < 0 && area(p.next, m, m.next) < 0;
|
|
14102
|
-
}
|
|
14103
|
-
|
|
14104
|
-
// interlink polygon nodes in z-order
|
|
14105
|
-
function indexCurve(start, minX, minY, invSize) {
|
|
14106
|
-
var p = start;
|
|
14107
|
-
do {
|
|
14108
|
-
if (p.z === 0) p.z = zOrder(p.x, p.y, minX, minY, invSize);
|
|
14109
|
-
p.prevZ = p.prev;
|
|
14110
|
-
p.nextZ = p.next;
|
|
14111
|
-
p = p.next;
|
|
14112
|
-
} while (p !== start);
|
|
14113
|
-
|
|
14114
|
-
p.prevZ.nextZ = null;
|
|
14115
|
-
p.prevZ = null;
|
|
14116
|
-
|
|
14117
|
-
sortLinked(p);
|
|
14118
|
-
}
|
|
14119
|
-
|
|
14120
|
-
// Simon Tatham's linked list merge sort algorithm
|
|
14121
|
-
// http://www.chiark.greenend.org.uk/~sgtatham/algorithms/listsort.html
|
|
14122
|
-
function sortLinked(list) {
|
|
14123
|
-
var i, p, q, e, tail, numMerges, pSize, qSize,
|
|
14124
|
-
inSize = 1;
|
|
14125
|
-
|
|
14126
|
-
do {
|
|
14127
|
-
p = list;
|
|
14128
|
-
list = null;
|
|
14129
|
-
tail = null;
|
|
14130
|
-
numMerges = 0;
|
|
14131
|
-
|
|
14132
|
-
while (p) {
|
|
14133
|
-
numMerges++;
|
|
14134
|
-
q = p;
|
|
14135
|
-
pSize = 0;
|
|
14136
|
-
for (i = 0; i < inSize; i++) {
|
|
14137
|
-
pSize++;
|
|
14138
|
-
q = q.nextZ;
|
|
14139
|
-
if (!q) break;
|
|
14140
|
-
}
|
|
14141
|
-
qSize = inSize;
|
|
14142
|
-
|
|
14143
|
-
while (pSize > 0 || (qSize > 0 && q)) {
|
|
14144
|
-
|
|
14145
|
-
if (pSize !== 0 && (qSize === 0 || !q || p.z <= q.z)) {
|
|
14146
|
-
e = p;
|
|
14147
|
-
p = p.nextZ;
|
|
14148
|
-
pSize--;
|
|
14149
|
-
} else {
|
|
14150
|
-
e = q;
|
|
14151
|
-
q = q.nextZ;
|
|
14152
|
-
qSize--;
|
|
14153
|
-
}
|
|
14154
|
-
|
|
14155
|
-
if (tail) tail.nextZ = e;
|
|
14156
|
-
else list = e;
|
|
14157
|
-
|
|
14158
|
-
e.prevZ = tail;
|
|
14159
|
-
tail = e;
|
|
14160
|
-
}
|
|
14161
|
-
|
|
14162
|
-
p = q;
|
|
14163
|
-
}
|
|
14164
|
-
|
|
14165
|
-
tail.nextZ = null;
|
|
14166
|
-
inSize *= 2;
|
|
14167
|
-
|
|
14168
|
-
} while (numMerges > 1);
|
|
14169
|
-
|
|
14170
|
-
return list;
|
|
14171
|
-
}
|
|
14172
|
-
|
|
14173
|
-
// z-order of a point given coords and inverse of the longer side of data bbox
|
|
14174
|
-
function zOrder(x, y, minX, minY, invSize) {
|
|
14175
|
-
// coords are transformed into non-negative 15-bit integer range
|
|
14176
|
-
x = (x - minX) * invSize | 0;
|
|
14177
|
-
y = (y - minY) * invSize | 0;
|
|
14178
|
-
|
|
14179
|
-
x = (x | (x << 8)) & 0x00FF00FF;
|
|
14180
|
-
x = (x | (x << 4)) & 0x0F0F0F0F;
|
|
14181
|
-
x = (x | (x << 2)) & 0x33333333;
|
|
14182
|
-
x = (x | (x << 1)) & 0x55555555;
|
|
14183
|
-
|
|
14184
|
-
y = (y | (y << 8)) & 0x00FF00FF;
|
|
14185
|
-
y = (y | (y << 4)) & 0x0F0F0F0F;
|
|
14186
|
-
y = (y | (y << 2)) & 0x33333333;
|
|
14187
|
-
y = (y | (y << 1)) & 0x55555555;
|
|
14188
|
-
|
|
14189
|
-
return x | (y << 1);
|
|
14190
|
-
}
|
|
14191
|
-
|
|
14192
|
-
// find the leftmost node of a polygon ring
|
|
14193
|
-
function getLeftmost(start) {
|
|
14194
|
-
var p = start,
|
|
14195
|
-
leftmost = start;
|
|
14196
|
-
do {
|
|
14197
|
-
if (p.x < leftmost.x || (p.x === leftmost.x && p.y < leftmost.y)) leftmost = p;
|
|
14198
|
-
p = p.next;
|
|
14199
|
-
} while (p !== start);
|
|
14200
|
-
|
|
14201
|
-
return leftmost;
|
|
14202
|
-
}
|
|
14203
|
-
|
|
14204
|
-
// check if a point lies within a convex triangle
|
|
14205
|
-
function pointInTriangle(ax, ay, bx, by, cx, cy, px, py) {
|
|
14206
|
-
return (cx - px) * (ay - py) >= (ax - px) * (cy - py) &&
|
|
14207
|
-
(ax - px) * (by - py) >= (bx - px) * (ay - py) &&
|
|
14208
|
-
(bx - px) * (cy - py) >= (cx - px) * (by - py);
|
|
14209
|
-
}
|
|
14210
|
-
|
|
14211
|
-
// check if a diagonal between two polygon nodes is valid (lies in polygon interior)
|
|
14212
|
-
function isValidDiagonal(a, b) {
|
|
14213
|
-
return a.next.i !== b.i && a.prev.i !== b.i && !intersectsPolygon(a, b) && // dones't intersect other edges
|
|
14214
|
-
(locallyInside(a, b) && locallyInside(b, a) && middleInside(a, b) && // locally visible
|
|
14215
|
-
(area(a.prev, a, b.prev) || area(a, b.prev, b)) || // does not create opposite-facing sectors
|
|
14216
|
-
equals(a, b) && area(a.prev, a, a.next) > 0 && area(b.prev, b, b.next) > 0); // special zero-length case
|
|
14217
|
-
}
|
|
14218
|
-
|
|
14219
|
-
// signed area of a triangle
|
|
14220
|
-
function area(p, q, r) {
|
|
14221
|
-
return (q.y - p.y) * (r.x - q.x) - (q.x - p.x) * (r.y - q.y);
|
|
14222
|
-
}
|
|
14223
|
-
|
|
14224
|
-
// check if two points are equal
|
|
14225
|
-
function equals(p1, p2) {
|
|
14226
|
-
return p1.x === p2.x && p1.y === p2.y;
|
|
14227
|
-
}
|
|
14228
|
-
|
|
14229
|
-
// check if two segments intersect
|
|
14230
|
-
function intersects(p1, q1, p2, q2) {
|
|
14231
|
-
var o1 = sign(area(p1, q1, p2));
|
|
14232
|
-
var o2 = sign(area(p1, q1, q2));
|
|
14233
|
-
var o3 = sign(area(p2, q2, p1));
|
|
14234
|
-
var o4 = sign(area(p2, q2, q1));
|
|
14235
|
-
|
|
14236
|
-
if (o1 !== o2 && o3 !== o4) return true; // general case
|
|
14237
|
-
|
|
14238
|
-
if (o1 === 0 && onSegment(p1, p2, q1)) return true; // p1, q1 and p2 are collinear and p2 lies on p1q1
|
|
14239
|
-
if (o2 === 0 && onSegment(p1, q2, q1)) return true; // p1, q1 and q2 are collinear and q2 lies on p1q1
|
|
14240
|
-
if (o3 === 0 && onSegment(p2, p1, q2)) return true; // p2, q2 and p1 are collinear and p1 lies on p2q2
|
|
14241
|
-
if (o4 === 0 && onSegment(p2, q1, q2)) return true; // p2, q2 and q1 are collinear and q1 lies on p2q2
|
|
14242
|
-
|
|
14243
|
-
return false;
|
|
14244
|
-
}
|
|
14245
|
-
|
|
14246
|
-
// for collinear points p, q, r, check if point q lies on segment pr
|
|
14247
|
-
function onSegment(p, q, r) {
|
|
14248
|
-
return q.x <= Math.max(p.x, r.x) && q.x >= Math.min(p.x, r.x) && q.y <= Math.max(p.y, r.y) && q.y >= Math.min(p.y, r.y);
|
|
14249
|
-
}
|
|
14250
|
-
|
|
14251
|
-
function sign(num) {
|
|
14252
|
-
return num > 0 ? 1 : num < 0 ? -1 : 0;
|
|
14253
|
-
}
|
|
14254
|
-
|
|
14255
|
-
// check if a polygon diagonal intersects any polygon segments
|
|
14256
|
-
function intersectsPolygon(a, b) {
|
|
14257
|
-
var p = a;
|
|
14258
|
-
do {
|
|
14259
|
-
if (p.i !== a.i && p.next.i !== a.i && p.i !== b.i && p.next.i !== b.i &&
|
|
14260
|
-
intersects(p, p.next, a, b)) return true;
|
|
14261
|
-
p = p.next;
|
|
14262
|
-
} while (p !== a);
|
|
14263
|
-
|
|
14264
|
-
return false;
|
|
14265
|
-
}
|
|
14266
|
-
|
|
14267
|
-
// check if a polygon diagonal is locally inside the polygon
|
|
14268
|
-
function locallyInside(a, b) {
|
|
14269
|
-
return area(a.prev, a, a.next) < 0 ?
|
|
14270
|
-
area(a, b, a.next) >= 0 && area(a, a.prev, b) >= 0 :
|
|
14271
|
-
area(a, b, a.prev) < 0 || area(a, a.next, b) < 0;
|
|
14272
|
-
}
|
|
14273
|
-
|
|
14274
|
-
// check if the middle point of a polygon diagonal is inside the polygon
|
|
14275
|
-
function middleInside(a, b) {
|
|
14276
|
-
var p = a,
|
|
14277
|
-
inside = false,
|
|
14278
|
-
px = (a.x + b.x) / 2,
|
|
14279
|
-
py = (a.y + b.y) / 2;
|
|
14280
|
-
do {
|
|
14281
|
-
if (((p.y > py) !== (p.next.y > py)) && p.next.y !== p.y &&
|
|
14282
|
-
(px < (p.next.x - p.x) * (py - p.y) / (p.next.y - p.y) + p.x))
|
|
14283
|
-
inside = !inside;
|
|
14284
|
-
p = p.next;
|
|
14285
|
-
} while (p !== a);
|
|
14286
|
-
|
|
14287
|
-
return inside;
|
|
14288
|
-
}
|
|
14289
|
-
|
|
14290
|
-
// link two polygon vertices with a bridge; if the vertices belong to the same ring, it splits polygon into two;
|
|
14291
|
-
// if one belongs to the outer ring and another to a hole, it merges it into a single ring
|
|
14292
|
-
function splitPolygon(a, b) {
|
|
14293
|
-
var a2 = new Node(a.i, a.x, a.y),
|
|
14294
|
-
b2 = new Node(b.i, b.x, b.y),
|
|
14295
|
-
an = a.next,
|
|
14296
|
-
bp = b.prev;
|
|
14297
|
-
|
|
14298
|
-
a.next = b;
|
|
14299
|
-
b.prev = a;
|
|
14300
|
-
|
|
14301
|
-
a2.next = an;
|
|
14302
|
-
an.prev = a2;
|
|
14303
|
-
|
|
14304
|
-
b2.next = a2;
|
|
14305
|
-
a2.prev = b2;
|
|
14306
|
-
|
|
14307
|
-
bp.next = b2;
|
|
14308
|
-
b2.prev = bp;
|
|
14309
|
-
|
|
14310
|
-
return b2;
|
|
14311
|
-
}
|
|
14312
|
-
|
|
14313
|
-
// create a node and optionally link it with previous one (in a circular doubly linked list)
|
|
14314
|
-
function insertNode(i, x, y, last) {
|
|
14315
|
-
var p = new Node(i, x, y);
|
|
14316
|
-
|
|
14317
|
-
if (!last) {
|
|
14318
|
-
p.prev = p;
|
|
14319
|
-
p.next = p;
|
|
14320
|
-
|
|
14321
|
-
} else {
|
|
14322
|
-
p.next = last.next;
|
|
14323
|
-
p.prev = last;
|
|
14324
|
-
last.next.prev = p;
|
|
14325
|
-
last.next = p;
|
|
14326
|
-
}
|
|
14327
|
-
return p;
|
|
14328
|
-
}
|
|
14329
|
-
|
|
14330
|
-
function removeNode(p) {
|
|
14331
|
-
p.next.prev = p.prev;
|
|
14332
|
-
p.prev.next = p.next;
|
|
14333
|
-
|
|
14334
|
-
if (p.prevZ) p.prevZ.nextZ = p.nextZ;
|
|
14335
|
-
if (p.nextZ) p.nextZ.prevZ = p.prevZ;
|
|
14336
|
-
}
|
|
14337
|
-
|
|
14338
|
-
function Node(i, x, y) {
|
|
14339
|
-
// vertex index in coordinates array
|
|
14340
|
-
this.i = i;
|
|
14341
|
-
|
|
14342
|
-
// vertex coordinates
|
|
14343
|
-
this.x = x;
|
|
14344
|
-
this.y = y;
|
|
14345
|
-
|
|
14346
|
-
// previous and next vertex nodes in a polygon ring
|
|
14347
|
-
this.prev = null;
|
|
14348
|
-
this.next = null;
|
|
14349
|
-
|
|
14350
|
-
// z-order curve value
|
|
14351
|
-
this.z = 0;
|
|
14352
|
-
|
|
14353
|
-
// previous and next nodes in z-order
|
|
14354
|
-
this.prevZ = null;
|
|
14355
|
-
this.nextZ = null;
|
|
14356
|
-
|
|
14357
|
-
// indicates whether this is a steiner point
|
|
14358
|
-
this.steiner = false;
|
|
14359
|
-
}
|
|
14360
|
-
|
|
14361
|
-
// return a percentage difference between the polygon area and its triangulation area;
|
|
14362
|
-
// used to verify correctness of triangulation
|
|
14363
|
-
earcut.deviation = function (data, holeIndices, dim, triangles) {
|
|
14364
|
-
var hasHoles = holeIndices && holeIndices.length;
|
|
14365
|
-
var outerLen = hasHoles ? holeIndices[0] * dim : data.length;
|
|
14366
|
-
|
|
14367
|
-
var polygonArea = Math.abs(signedArea(data, 0, outerLen, dim));
|
|
14368
|
-
if (hasHoles) {
|
|
14369
|
-
for (var i = 0, len = holeIndices.length; i < len; i++) {
|
|
14370
|
-
var start = holeIndices[i] * dim;
|
|
14371
|
-
var end = i < len - 1 ? holeIndices[i + 1] * dim : data.length;
|
|
14372
|
-
polygonArea -= Math.abs(signedArea(data, start, end, dim));
|
|
14373
|
-
}
|
|
14374
|
-
}
|
|
14375
|
-
|
|
14376
|
-
var trianglesArea = 0;
|
|
14377
|
-
for (i = 0; i < triangles.length; i += 3) {
|
|
14378
|
-
var a = triangles[i] * dim;
|
|
14379
|
-
var b = triangles[i + 1] * dim;
|
|
14380
|
-
var c = triangles[i + 2] * dim;
|
|
14381
|
-
trianglesArea += Math.abs(
|
|
14382
|
-
(data[a] - data[c]) * (data[b + 1] - data[a + 1]) -
|
|
14383
|
-
(data[a] - data[b]) * (data[c + 1] - data[a + 1]));
|
|
14384
|
-
}
|
|
14385
|
-
|
|
14386
|
-
return polygonArea === 0 && trianglesArea === 0 ? 0 :
|
|
14387
|
-
Math.abs((trianglesArea - polygonArea) / polygonArea);
|
|
14388
|
-
};
|
|
14389
|
-
|
|
14390
|
-
function signedArea(data, start, end, dim) {
|
|
14391
|
-
var sum = 0;
|
|
14392
|
-
for (var i = start, j = end - dim; i < end; i += dim) {
|
|
14393
|
-
sum += (data[j] - data[i]) * (data[i + 1] + data[j + 1]);
|
|
14394
|
-
j = i;
|
|
14395
|
-
}
|
|
14396
|
-
return sum;
|
|
14397
|
-
}
|
|
14398
|
-
|
|
14399
|
-
// turn a polygon in a multi-dimensional array form (e.g. as in GeoJSON) into a form Earcut accepts
|
|
14400
|
-
earcut.flatten = function (data) {
|
|
14401
|
-
var dim = data[0][0].length,
|
|
14402
|
-
result = {vertices: [], holes: [], dimensions: dim},
|
|
14403
|
-
holeIndex = 0;
|
|
14404
|
-
|
|
14405
|
-
for (var i = 0; i < data.length; i++) {
|
|
14406
|
-
for (var j = 0; j < data[i].length; j++) {
|
|
14407
|
-
for (var d = 0; d < dim; d++) result.vertices.push(data[i][j][d]);
|
|
14408
|
-
}
|
|
14409
|
-
if (i > 0) {
|
|
14410
|
-
holeIndex += data[i - 1].length;
|
|
14411
|
-
result.holes.push(holeIndex);
|
|
14412
|
-
}
|
|
14413
|
-
}
|
|
14414
|
-
return result;
|
|
14415
|
-
};
|
|
14416
|
-
return earcut$1.exports;
|
|
14050
|
+
// try splitting polygon into two and triangulate them independently
|
|
14051
|
+
function splitEarcut(start, triangles, dim, minX, minY, invSize) {
|
|
14052
|
+
// look for a valid diagonal that divides the polygon into two
|
|
14053
|
+
let a = start;
|
|
14054
|
+
do {
|
|
14055
|
+
let b = a.next.next;
|
|
14056
|
+
while (b !== a.prev) {
|
|
14057
|
+
if (a.i !== b.i && isValidDiagonal(a, b)) {
|
|
14058
|
+
// split the polygon in two by the diagonal
|
|
14059
|
+
let c = splitPolygon(a, b);
|
|
14060
|
+
|
|
14061
|
+
// filter colinear points around the cuts
|
|
14062
|
+
a = filterPoints(a, a.next);
|
|
14063
|
+
c = filterPoints(c, c.next);
|
|
14064
|
+
|
|
14065
|
+
// run earcut on each half
|
|
14066
|
+
earcutLinked(a, triangles, dim, minX, minY, invSize, 0);
|
|
14067
|
+
earcutLinked(c, triangles, dim, minX, minY, invSize, 0);
|
|
14068
|
+
return;
|
|
14069
|
+
}
|
|
14070
|
+
b = b.next;
|
|
14071
|
+
}
|
|
14072
|
+
a = a.next;
|
|
14073
|
+
} while (a !== start);
|
|
14417
14074
|
}
|
|
14418
14075
|
|
|
14419
|
-
|
|
14420
|
-
|
|
14076
|
+
// link every hole into the outer loop, producing a single-ring polygon without holes
|
|
14077
|
+
function eliminateHoles(data, holeIndices, outerNode, dim) {
|
|
14078
|
+
const queue = [];
|
|
14079
|
+
|
|
14080
|
+
for (let i = 0, len = holeIndices.length; i < len; i++) {
|
|
14081
|
+
const start = holeIndices[i] * dim;
|
|
14082
|
+
const end = i < len - 1 ? holeIndices[i + 1] * dim : data.length;
|
|
14083
|
+
const list = linkedList(data, start, end, dim, false);
|
|
14084
|
+
if (list === list.next) list.steiner = true;
|
|
14085
|
+
queue.push(getLeftmost(list));
|
|
14086
|
+
}
|
|
14087
|
+
|
|
14088
|
+
queue.sort(compareXYSlope);
|
|
14089
|
+
|
|
14090
|
+
// process holes from left to right
|
|
14091
|
+
for (let i = 0; i < queue.length; i++) {
|
|
14092
|
+
outerNode = eliminateHole(queue[i], outerNode);
|
|
14093
|
+
}
|
|
14094
|
+
|
|
14095
|
+
return outerNode;
|
|
14096
|
+
}
|
|
14097
|
+
|
|
14098
|
+
function compareXYSlope(a, b) {
|
|
14099
|
+
let result = a.x - b.x;
|
|
14100
|
+
// when the left-most point of 2 holes meet at a vertex, sort the holes counterclockwise so that when we find
|
|
14101
|
+
// the bridge to the outer shell is always the point that they meet at.
|
|
14102
|
+
if (result === 0) {
|
|
14103
|
+
result = a.y - b.y;
|
|
14104
|
+
if (result === 0) {
|
|
14105
|
+
const aSlope = (a.next.y - a.y) / (a.next.x - a.x);
|
|
14106
|
+
const bSlope = (b.next.y - b.y) / (b.next.x - b.x);
|
|
14107
|
+
result = aSlope - bSlope;
|
|
14108
|
+
}
|
|
14109
|
+
}
|
|
14110
|
+
return result;
|
|
14111
|
+
}
|
|
14112
|
+
|
|
14113
|
+
// find a bridge between vertices that connects hole with an outer ring and link it
|
|
14114
|
+
function eliminateHole(hole, outerNode) {
|
|
14115
|
+
const bridge = findHoleBridge(hole, outerNode);
|
|
14116
|
+
if (!bridge) {
|
|
14117
|
+
return outerNode;
|
|
14118
|
+
}
|
|
14119
|
+
|
|
14120
|
+
const bridgeReverse = splitPolygon(bridge, hole);
|
|
14121
|
+
|
|
14122
|
+
// filter collinear points around the cuts
|
|
14123
|
+
filterPoints(bridgeReverse, bridgeReverse.next);
|
|
14124
|
+
return filterPoints(bridge, bridge.next);
|
|
14125
|
+
}
|
|
14126
|
+
|
|
14127
|
+
// David Eberly's algorithm for finding a bridge between hole and outer polygon
|
|
14128
|
+
function findHoleBridge(hole, outerNode) {
|
|
14129
|
+
let p = outerNode;
|
|
14130
|
+
const hx = hole.x;
|
|
14131
|
+
const hy = hole.y;
|
|
14132
|
+
let qx = -Infinity;
|
|
14133
|
+
let m;
|
|
14134
|
+
|
|
14135
|
+
// find a segment intersected by a ray from the hole's leftmost point to the left;
|
|
14136
|
+
// segment's endpoint with lesser x will be potential connection point
|
|
14137
|
+
// unless they intersect at a vertex, then choose the vertex
|
|
14138
|
+
if (equals(hole, p)) return p;
|
|
14139
|
+
do {
|
|
14140
|
+
if (equals(hole, p.next)) return p.next;
|
|
14141
|
+
else if (hy <= p.y && hy >= p.next.y && p.next.y !== p.y) {
|
|
14142
|
+
const x = p.x + (hy - p.y) * (p.next.x - p.x) / (p.next.y - p.y);
|
|
14143
|
+
if (x <= hx && x > qx) {
|
|
14144
|
+
qx = x;
|
|
14145
|
+
m = p.x < p.next.x ? p : p.next;
|
|
14146
|
+
if (x === hx) return m; // hole touches outer segment; pick leftmost endpoint
|
|
14147
|
+
}
|
|
14148
|
+
}
|
|
14149
|
+
p = p.next;
|
|
14150
|
+
} while (p !== outerNode);
|
|
14151
|
+
|
|
14152
|
+
if (!m) return null;
|
|
14153
|
+
|
|
14154
|
+
// look for points inside the triangle of hole point, segment intersection and endpoint;
|
|
14155
|
+
// if there are no points found, we have a valid connection;
|
|
14156
|
+
// otherwise choose the point of the minimum angle with the ray as connection point
|
|
14157
|
+
|
|
14158
|
+
const stop = m;
|
|
14159
|
+
const mx = m.x;
|
|
14160
|
+
const my = m.y;
|
|
14161
|
+
let tanMin = Infinity;
|
|
14162
|
+
|
|
14163
|
+
p = m;
|
|
14164
|
+
|
|
14165
|
+
do {
|
|
14166
|
+
if (hx >= p.x && p.x >= mx && hx !== p.x &&
|
|
14167
|
+
pointInTriangle(hy < my ? hx : qx, hy, mx, my, hy < my ? qx : hx, hy, p.x, p.y)) {
|
|
14168
|
+
|
|
14169
|
+
const tan = Math.abs(hy - p.y) / (hx - p.x); // tangential
|
|
14170
|
+
|
|
14171
|
+
if (locallyInside(p, hole) &&
|
|
14172
|
+
(tan < tanMin || (tan === tanMin && (p.x > m.x || (p.x === m.x && sectorContainsSector(m, p)))))) {
|
|
14173
|
+
m = p;
|
|
14174
|
+
tanMin = tan;
|
|
14175
|
+
}
|
|
14176
|
+
}
|
|
14177
|
+
|
|
14178
|
+
p = p.next;
|
|
14179
|
+
} while (p !== stop);
|
|
14180
|
+
|
|
14181
|
+
return m;
|
|
14182
|
+
}
|
|
14183
|
+
|
|
14184
|
+
// whether sector in vertex m contains sector in vertex p in the same coordinates
|
|
14185
|
+
function sectorContainsSector(m, p) {
|
|
14186
|
+
return area(m.prev, m, p.prev) < 0 && area(p.next, m, m.next) < 0;
|
|
14187
|
+
}
|
|
14188
|
+
|
|
14189
|
+
// interlink polygon nodes in z-order
|
|
14190
|
+
function indexCurve(start, minX, minY, invSize) {
|
|
14191
|
+
let p = start;
|
|
14192
|
+
do {
|
|
14193
|
+
if (p.z === 0) p.z = zOrder(p.x, p.y, minX, minY, invSize);
|
|
14194
|
+
p.prevZ = p.prev;
|
|
14195
|
+
p.nextZ = p.next;
|
|
14196
|
+
p = p.next;
|
|
14197
|
+
} while (p !== start);
|
|
14198
|
+
|
|
14199
|
+
p.prevZ.nextZ = null;
|
|
14200
|
+
p.prevZ = null;
|
|
14201
|
+
|
|
14202
|
+
sortLinked(p);
|
|
14203
|
+
}
|
|
14204
|
+
|
|
14205
|
+
// Simon Tatham's linked list merge sort algorithm
|
|
14206
|
+
// http://www.chiark.greenend.org.uk/~sgtatham/algorithms/listsort.html
|
|
14207
|
+
function sortLinked(list) {
|
|
14208
|
+
let numMerges;
|
|
14209
|
+
let inSize = 1;
|
|
14210
|
+
|
|
14211
|
+
do {
|
|
14212
|
+
let p = list;
|
|
14213
|
+
let e;
|
|
14214
|
+
list = null;
|
|
14215
|
+
let tail = null;
|
|
14216
|
+
numMerges = 0;
|
|
14217
|
+
|
|
14218
|
+
while (p) {
|
|
14219
|
+
numMerges++;
|
|
14220
|
+
let q = p;
|
|
14221
|
+
let pSize = 0;
|
|
14222
|
+
for (let i = 0; i < inSize; i++) {
|
|
14223
|
+
pSize++;
|
|
14224
|
+
q = q.nextZ;
|
|
14225
|
+
if (!q) break;
|
|
14226
|
+
}
|
|
14227
|
+
let qSize = inSize;
|
|
14228
|
+
|
|
14229
|
+
while (pSize > 0 || (qSize > 0 && q)) {
|
|
14230
|
+
|
|
14231
|
+
if (pSize !== 0 && (qSize === 0 || !q || p.z <= q.z)) {
|
|
14232
|
+
e = p;
|
|
14233
|
+
p = p.nextZ;
|
|
14234
|
+
pSize--;
|
|
14235
|
+
} else {
|
|
14236
|
+
e = q;
|
|
14237
|
+
q = q.nextZ;
|
|
14238
|
+
qSize--;
|
|
14239
|
+
}
|
|
14240
|
+
|
|
14241
|
+
if (tail) tail.nextZ = e;
|
|
14242
|
+
else list = e;
|
|
14243
|
+
|
|
14244
|
+
e.prevZ = tail;
|
|
14245
|
+
tail = e;
|
|
14246
|
+
}
|
|
14247
|
+
|
|
14248
|
+
p = q;
|
|
14249
|
+
}
|
|
14250
|
+
|
|
14251
|
+
tail.nextZ = null;
|
|
14252
|
+
inSize *= 2;
|
|
14253
|
+
|
|
14254
|
+
} while (numMerges > 1);
|
|
14255
|
+
|
|
14256
|
+
return list;
|
|
14257
|
+
}
|
|
14258
|
+
|
|
14259
|
+
// z-order of a point given coords and inverse of the longer side of data bbox
|
|
14260
|
+
function zOrder(x, y, minX, minY, invSize) {
|
|
14261
|
+
// coords are transformed into non-negative 15-bit integer range
|
|
14262
|
+
x = (x - minX) * invSize | 0;
|
|
14263
|
+
y = (y - minY) * invSize | 0;
|
|
14264
|
+
|
|
14265
|
+
x = (x | (x << 8)) & 0x00FF00FF;
|
|
14266
|
+
x = (x | (x << 4)) & 0x0F0F0F0F;
|
|
14267
|
+
x = (x | (x << 2)) & 0x33333333;
|
|
14268
|
+
x = (x | (x << 1)) & 0x55555555;
|
|
14269
|
+
|
|
14270
|
+
y = (y | (y << 8)) & 0x00FF00FF;
|
|
14271
|
+
y = (y | (y << 4)) & 0x0F0F0F0F;
|
|
14272
|
+
y = (y | (y << 2)) & 0x33333333;
|
|
14273
|
+
y = (y | (y << 1)) & 0x55555555;
|
|
14274
|
+
|
|
14275
|
+
return x | (y << 1);
|
|
14276
|
+
}
|
|
14277
|
+
|
|
14278
|
+
// find the leftmost node of a polygon ring
|
|
14279
|
+
function getLeftmost(start) {
|
|
14280
|
+
let p = start,
|
|
14281
|
+
leftmost = start;
|
|
14282
|
+
do {
|
|
14283
|
+
if (p.x < leftmost.x || (p.x === leftmost.x && p.y < leftmost.y)) leftmost = p;
|
|
14284
|
+
p = p.next;
|
|
14285
|
+
} while (p !== start);
|
|
14286
|
+
|
|
14287
|
+
return leftmost;
|
|
14288
|
+
}
|
|
14289
|
+
|
|
14290
|
+
// check if a point lies within a convex triangle
|
|
14291
|
+
function pointInTriangle(ax, ay, bx, by, cx, cy, px, py) {
|
|
14292
|
+
return (cx - px) * (ay - py) >= (ax - px) * (cy - py) &&
|
|
14293
|
+
(ax - px) * (by - py) >= (bx - px) * (ay - py) &&
|
|
14294
|
+
(bx - px) * (cy - py) >= (cx - px) * (by - py);
|
|
14295
|
+
}
|
|
14296
|
+
|
|
14297
|
+
// check if a point lies within a convex triangle but false if its equal to the first point of the triangle
|
|
14298
|
+
function pointInTriangleExceptFirst(ax, ay, bx, by, cx, cy, px, py) {
|
|
14299
|
+
return !(ax === px && ay === py) && pointInTriangle(ax, ay, bx, by, cx, cy, px, py);
|
|
14300
|
+
}
|
|
14301
|
+
|
|
14302
|
+
// check if a diagonal between two polygon nodes is valid (lies in polygon interior)
|
|
14303
|
+
function isValidDiagonal(a, b) {
|
|
14304
|
+
return a.next.i !== b.i && a.prev.i !== b.i && !intersectsPolygon(a, b) && // doesn't intersect other edges
|
|
14305
|
+
(locallyInside(a, b) && locallyInside(b, a) && middleInside(a, b) && // locally visible
|
|
14306
|
+
(area(a.prev, a, b.prev) || area(a, b.prev, b)) || // does not create opposite-facing sectors
|
|
14307
|
+
equals(a, b) && area(a.prev, a, a.next) > 0 && area(b.prev, b, b.next) > 0); // special zero-length case
|
|
14308
|
+
}
|
|
14309
|
+
|
|
14310
|
+
// signed area of a triangle
|
|
14311
|
+
function area(p, q, r) {
|
|
14312
|
+
return (q.y - p.y) * (r.x - q.x) - (q.x - p.x) * (r.y - q.y);
|
|
14313
|
+
}
|
|
14314
|
+
|
|
14315
|
+
// check if two points are equal
|
|
14316
|
+
function equals(p1, p2) {
|
|
14317
|
+
return p1.x === p2.x && p1.y === p2.y;
|
|
14318
|
+
}
|
|
14319
|
+
|
|
14320
|
+
// check if two segments intersect
|
|
14321
|
+
function intersects(p1, q1, p2, q2) {
|
|
14322
|
+
const o1 = sign(area(p1, q1, p2));
|
|
14323
|
+
const o2 = sign(area(p1, q1, q2));
|
|
14324
|
+
const o3 = sign(area(p2, q2, p1));
|
|
14325
|
+
const o4 = sign(area(p2, q2, q1));
|
|
14326
|
+
|
|
14327
|
+
if (o1 !== o2 && o3 !== o4) return true; // general case
|
|
14328
|
+
|
|
14329
|
+
if (o1 === 0 && onSegment(p1, p2, q1)) return true; // p1, q1 and p2 are collinear and p2 lies on p1q1
|
|
14330
|
+
if (o2 === 0 && onSegment(p1, q2, q1)) return true; // p1, q1 and q2 are collinear and q2 lies on p1q1
|
|
14331
|
+
if (o3 === 0 && onSegment(p2, p1, q2)) return true; // p2, q2 and p1 are collinear and p1 lies on p2q2
|
|
14332
|
+
if (o4 === 0 && onSegment(p2, q1, q2)) return true; // p2, q2 and q1 are collinear and q1 lies on p2q2
|
|
14333
|
+
|
|
14334
|
+
return false;
|
|
14335
|
+
}
|
|
14336
|
+
|
|
14337
|
+
// for collinear points p, q, r, check if point q lies on segment pr
|
|
14338
|
+
function onSegment(p, q, r) {
|
|
14339
|
+
return q.x <= Math.max(p.x, r.x) && q.x >= Math.min(p.x, r.x) && q.y <= Math.max(p.y, r.y) && q.y >= Math.min(p.y, r.y);
|
|
14340
|
+
}
|
|
14341
|
+
|
|
14342
|
+
function sign(num) {
|
|
14343
|
+
return num > 0 ? 1 : num < 0 ? -1 : 0;
|
|
14344
|
+
}
|
|
14345
|
+
|
|
14346
|
+
// check if a polygon diagonal intersects any polygon segments
|
|
14347
|
+
function intersectsPolygon(a, b) {
|
|
14348
|
+
let p = a;
|
|
14349
|
+
do {
|
|
14350
|
+
if (p.i !== a.i && p.next.i !== a.i && p.i !== b.i && p.next.i !== b.i &&
|
|
14351
|
+
intersects(p, p.next, a, b)) return true;
|
|
14352
|
+
p = p.next;
|
|
14353
|
+
} while (p !== a);
|
|
14354
|
+
|
|
14355
|
+
return false;
|
|
14356
|
+
}
|
|
14357
|
+
|
|
14358
|
+
// check if a polygon diagonal is locally inside the polygon
|
|
14359
|
+
function locallyInside(a, b) {
|
|
14360
|
+
return area(a.prev, a, a.next) < 0 ?
|
|
14361
|
+
area(a, b, a.next) >= 0 && area(a, a.prev, b) >= 0 :
|
|
14362
|
+
area(a, b, a.prev) < 0 || area(a, a.next, b) < 0;
|
|
14363
|
+
}
|
|
14364
|
+
|
|
14365
|
+
// check if the middle point of a polygon diagonal is inside the polygon
|
|
14366
|
+
function middleInside(a, b) {
|
|
14367
|
+
let p = a;
|
|
14368
|
+
let inside = false;
|
|
14369
|
+
const px = (a.x + b.x) / 2;
|
|
14370
|
+
const py = (a.y + b.y) / 2;
|
|
14371
|
+
do {
|
|
14372
|
+
if (((p.y > py) !== (p.next.y > py)) && p.next.y !== p.y &&
|
|
14373
|
+
(px < (p.next.x - p.x) * (py - p.y) / (p.next.y - p.y) + p.x))
|
|
14374
|
+
inside = !inside;
|
|
14375
|
+
p = p.next;
|
|
14376
|
+
} while (p !== a);
|
|
14377
|
+
|
|
14378
|
+
return inside;
|
|
14379
|
+
}
|
|
14380
|
+
|
|
14381
|
+
// link two polygon vertices with a bridge; if the vertices belong to the same ring, it splits polygon into two;
|
|
14382
|
+
// if one belongs to the outer ring and another to a hole, it merges it into a single ring
|
|
14383
|
+
function splitPolygon(a, b) {
|
|
14384
|
+
const a2 = createNode(a.i, a.x, a.y),
|
|
14385
|
+
b2 = createNode(b.i, b.x, b.y),
|
|
14386
|
+
an = a.next,
|
|
14387
|
+
bp = b.prev;
|
|
14388
|
+
|
|
14389
|
+
a.next = b;
|
|
14390
|
+
b.prev = a;
|
|
14391
|
+
|
|
14392
|
+
a2.next = an;
|
|
14393
|
+
an.prev = a2;
|
|
14394
|
+
|
|
14395
|
+
b2.next = a2;
|
|
14396
|
+
a2.prev = b2;
|
|
14397
|
+
|
|
14398
|
+
bp.next = b2;
|
|
14399
|
+
b2.prev = bp;
|
|
14400
|
+
|
|
14401
|
+
return b2;
|
|
14402
|
+
}
|
|
14403
|
+
|
|
14404
|
+
// create a node and optionally link it with previous one (in a circular doubly linked list)
|
|
14405
|
+
function insertNode(i, x, y, last) {
|
|
14406
|
+
const p = createNode(i, x, y);
|
|
14407
|
+
|
|
14408
|
+
if (!last) {
|
|
14409
|
+
p.prev = p;
|
|
14410
|
+
p.next = p;
|
|
14411
|
+
|
|
14412
|
+
} else {
|
|
14413
|
+
p.next = last.next;
|
|
14414
|
+
p.prev = last;
|
|
14415
|
+
last.next.prev = p;
|
|
14416
|
+
last.next = p;
|
|
14417
|
+
}
|
|
14418
|
+
return p;
|
|
14419
|
+
}
|
|
14420
|
+
|
|
14421
|
+
function removeNode(p) {
|
|
14422
|
+
p.next.prev = p.prev;
|
|
14423
|
+
p.prev.next = p.next;
|
|
14424
|
+
|
|
14425
|
+
if (p.prevZ) p.prevZ.nextZ = p.nextZ;
|
|
14426
|
+
if (p.nextZ) p.nextZ.prevZ = p.prevZ;
|
|
14427
|
+
}
|
|
14428
|
+
|
|
14429
|
+
function createNode(i, x, y) {
|
|
14430
|
+
return {
|
|
14431
|
+
i, // vertex index in coordinates array
|
|
14432
|
+
x, y, // vertex coordinates
|
|
14433
|
+
prev: null, // previous and next vertex nodes in a polygon ring
|
|
14434
|
+
next: null,
|
|
14435
|
+
z: 0, // z-order curve value
|
|
14436
|
+
prevZ: null, // previous and next nodes in z-order
|
|
14437
|
+
nextZ: null,
|
|
14438
|
+
steiner: false // indicates whether this is a steiner point
|
|
14439
|
+
};
|
|
14440
|
+
}
|
|
14441
|
+
|
|
14442
|
+
function signedArea(data, start, end, dim) {
|
|
14443
|
+
let sum = 0;
|
|
14444
|
+
for (let i = start, j = end - dim; i < end; i += dim) {
|
|
14445
|
+
sum += (data[j] - data[i]) * (data[i + 1] + data[j + 1]);
|
|
14446
|
+
j = i;
|
|
14447
|
+
}
|
|
14448
|
+
return sum;
|
|
14449
|
+
}
|
|
14421
14450
|
|
|
14422
14451
|
const buildLine = (startX, startY, endX, endY, width, vertices = [], indices = []) => {
|
|
14423
14452
|
const points = [startX, startY, endX, endY];
|
|
@@ -14609,8 +14638,10 @@ fn fragmentMain(input: VertexOutput) -> @location(0) vec4<f32> {
|
|
|
14609
14638
|
|
|
14610
14639
|
let temp$3 = null;
|
|
14611
14640
|
class Line {
|
|
14641
|
+
collisionType = exports.CollisionType.Line;
|
|
14642
|
+
_fromPosition;
|
|
14643
|
+
_toPosition;
|
|
14612
14644
|
constructor(x1 = 0, y1 = 0, x2 = 0, y2 = 0) {
|
|
14613
|
-
this.collisionType = 1 /* CollisionType.Line */;
|
|
14614
14645
|
this._fromPosition = new Vector(x1, y1);
|
|
14615
14646
|
this._toPosition = new Vector(x2, y2);
|
|
14616
14647
|
}
|
|
@@ -14677,13 +14708,13 @@ fn fragmentMain(input: VertexOutput) -> @location(0) vec4<f32> {
|
|
|
14677
14708
|
}
|
|
14678
14709
|
intersectsWith(target) {
|
|
14679
14710
|
switch (target.collisionType) {
|
|
14680
|
-
case
|
|
14681
|
-
case
|
|
14682
|
-
case
|
|
14683
|
-
case
|
|
14684
|
-
case
|
|
14685
|
-
case
|
|
14686
|
-
case
|
|
14711
|
+
case exports.CollisionType.SceneNode: return intersectionLineRect(this, target.getBounds());
|
|
14712
|
+
case exports.CollisionType.Rectangle: return intersectionLineRect(this, target);
|
|
14713
|
+
case exports.CollisionType.Polygon: return intersectionLinePoly(this, target);
|
|
14714
|
+
case exports.CollisionType.Circle: return intersectionLineCircle(this, target);
|
|
14715
|
+
case exports.CollisionType.Ellipse: return intersectionLineEllipse(this, target);
|
|
14716
|
+
case exports.CollisionType.Line: return intersectionLineLine(this, target);
|
|
14717
|
+
case exports.CollisionType.Point: return intersectionPointLine(target, this);
|
|
14687
14718
|
default: return false;
|
|
14688
14719
|
}
|
|
14689
14720
|
}
|
|
@@ -14713,9 +14744,12 @@ fn fragmentMain(input: VertexOutput) -> @location(0) vec4<f32> {
|
|
|
14713
14744
|
|
|
14714
14745
|
let temp$2 = null;
|
|
14715
14746
|
class Circle {
|
|
14747
|
+
static collisionSegments = 32;
|
|
14748
|
+
collisionType = exports.CollisionType.Circle;
|
|
14749
|
+
_position;
|
|
14750
|
+
_collisionVertices = null;
|
|
14751
|
+
_radius;
|
|
14716
14752
|
constructor(x = 0, y = 0, radius = 0) {
|
|
14717
|
-
this.collisionType = 3 /* CollisionType.Circle */;
|
|
14718
|
-
this._collisionVertices = null;
|
|
14719
14753
|
this._position = new Vector(x, y);
|
|
14720
14754
|
this._radius = radius;
|
|
14721
14755
|
}
|
|
@@ -14789,22 +14823,22 @@ fn fragmentMain(input: VertexOutput) -> @location(0) vec4<f32> {
|
|
|
14789
14823
|
}
|
|
14790
14824
|
intersectsWith(target) {
|
|
14791
14825
|
switch (target.collisionType) {
|
|
14792
|
-
case
|
|
14793
|
-
case
|
|
14794
|
-
case
|
|
14795
|
-
case
|
|
14796
|
-
case
|
|
14797
|
-
case
|
|
14798
|
-
case
|
|
14826
|
+
case exports.CollisionType.SceneNode: return intersectionRectCircle(target.getBounds(), this);
|
|
14827
|
+
case exports.CollisionType.Rectangle: return intersectionRectCircle(target, this);
|
|
14828
|
+
case exports.CollisionType.Polygon: return intersectionCirclePoly(this, target);
|
|
14829
|
+
case exports.CollisionType.Circle: return intersectionCircleCircle(this, target);
|
|
14830
|
+
case exports.CollisionType.Ellipse: return intersectionCircleEllipse(this, target);
|
|
14831
|
+
case exports.CollisionType.Line: return intersectionLineCircle(target, this);
|
|
14832
|
+
case exports.CollisionType.Point: return intersectionPointCircle(target, this);
|
|
14799
14833
|
default: return false;
|
|
14800
14834
|
}
|
|
14801
14835
|
}
|
|
14802
14836
|
collidesWith(target) {
|
|
14803
14837
|
switch (target.collisionType) {
|
|
14804
|
-
case
|
|
14805
|
-
case
|
|
14806
|
-
case
|
|
14807
|
-
case
|
|
14838
|
+
case exports.CollisionType.SceneNode: return getCollisionCircleRectangle(this, target.getBounds());
|
|
14839
|
+
case exports.CollisionType.Rectangle: return getCollisionCircleRectangle(this, target);
|
|
14840
|
+
case exports.CollisionType.Polygon: return getCollisionPolygonCircle(target, this, true);
|
|
14841
|
+
case exports.CollisionType.Circle: return getCollisionCircleCircle(this, target);
|
|
14808
14842
|
// case CollisionType.Ellipse: return intersectionCircleEllipse(this, target as Ellipse);
|
|
14809
14843
|
// case CollisionType.Line: return intersectionLineCircle(target as Line, this);
|
|
14810
14844
|
// case CollisionType.Point: return intersectionPointCircle(target as Vector, this);
|
|
@@ -14836,11 +14870,12 @@ fn fragmentMain(input: VertexOutput) -> @location(0) vec4<f32> {
|
|
|
14836
14870
|
return temp$2;
|
|
14837
14871
|
}
|
|
14838
14872
|
}
|
|
14839
|
-
Circle.collisionSegments = 32;
|
|
14840
14873
|
|
|
14841
14874
|
class Ellipse {
|
|
14875
|
+
collisionType = exports.CollisionType.Ellipse;
|
|
14876
|
+
_position;
|
|
14877
|
+
_radius;
|
|
14842
14878
|
constructor(x = 0, y = 0, halfWidth = 0, halfHeight = halfWidth) {
|
|
14843
|
-
this.collisionType = 4 /* CollisionType.Ellipse */;
|
|
14844
14879
|
this._position = new Vector(x, y);
|
|
14845
14880
|
this._radius = new Vector(halfWidth, halfHeight);
|
|
14846
14881
|
}
|
|
@@ -14912,13 +14947,13 @@ fn fragmentMain(input: VertexOutput) -> @location(0) vec4<f32> {
|
|
|
14912
14947
|
}
|
|
14913
14948
|
intersectsWith(target) {
|
|
14914
14949
|
switch (target.collisionType) {
|
|
14915
|
-
case
|
|
14916
|
-
case
|
|
14917
|
-
case
|
|
14918
|
-
case
|
|
14919
|
-
case
|
|
14920
|
-
case
|
|
14921
|
-
case
|
|
14950
|
+
case exports.CollisionType.SceneNode: return intersectionRectEllipse(target.getBounds(), this);
|
|
14951
|
+
case exports.CollisionType.Rectangle: return intersectionRectEllipse(target, this);
|
|
14952
|
+
case exports.CollisionType.Polygon: return intersectionEllipsePoly(this, target);
|
|
14953
|
+
case exports.CollisionType.Circle: return intersectionCircleEllipse(target, this);
|
|
14954
|
+
case exports.CollisionType.Ellipse: return intersectionEllipseEllipse(this, target);
|
|
14955
|
+
case exports.CollisionType.Line: return intersectionLineEllipse(target, this);
|
|
14956
|
+
case exports.CollisionType.Point: return intersectionPointEllipse(target, this);
|
|
14922
14957
|
default: return false;
|
|
14923
14958
|
}
|
|
14924
14959
|
}
|
|
@@ -14942,11 +14977,12 @@ fn fragmentMain(input: VertexOutput) -> @location(0) vec4<f32> {
|
|
|
14942
14977
|
|
|
14943
14978
|
let temp$1 = null;
|
|
14944
14979
|
class Polygon {
|
|
14980
|
+
collisionType = exports.CollisionType.Polygon;
|
|
14981
|
+
_position;
|
|
14982
|
+
_points = [];
|
|
14983
|
+
_edges = [];
|
|
14984
|
+
_normals = [];
|
|
14945
14985
|
constructor(points = [], x = 0, y = 0) {
|
|
14946
|
-
this.collisionType = 5 /* CollisionType.Polygon */;
|
|
14947
|
-
this._points = [];
|
|
14948
|
-
this._edges = [];
|
|
14949
|
-
this._normals = [];
|
|
14950
14986
|
this._position = new Vector(x, y);
|
|
14951
14987
|
this.setPoints(points);
|
|
14952
14988
|
}
|
|
@@ -15057,22 +15093,22 @@ fn fragmentMain(input: VertexOutput) -> @location(0) vec4<f32> {
|
|
|
15057
15093
|
}
|
|
15058
15094
|
intersectsWith(target) {
|
|
15059
15095
|
switch (target.collisionType) {
|
|
15060
|
-
case
|
|
15061
|
-
case
|
|
15062
|
-
case
|
|
15063
|
-
case
|
|
15064
|
-
case
|
|
15065
|
-
case
|
|
15066
|
-
case
|
|
15096
|
+
case exports.CollisionType.SceneNode: return intersectionRectPoly(target.getBounds(), this);
|
|
15097
|
+
case exports.CollisionType.Rectangle: return intersectionRectPoly(target, this);
|
|
15098
|
+
case exports.CollisionType.Polygon: return intersectionPolyPoly(this, target);
|
|
15099
|
+
case exports.CollisionType.Circle: return intersectionCirclePoly(target, this);
|
|
15100
|
+
case exports.CollisionType.Ellipse: return intersectionEllipsePoly(target, this);
|
|
15101
|
+
case exports.CollisionType.Line: return intersectionLinePoly(target, this);
|
|
15102
|
+
case exports.CollisionType.Point: return intersectionPointPoly(target, this);
|
|
15067
15103
|
default: return false;
|
|
15068
15104
|
}
|
|
15069
15105
|
}
|
|
15070
15106
|
collidesWith(target) {
|
|
15071
15107
|
switch (target.collisionType) {
|
|
15072
|
-
case
|
|
15073
|
-
case
|
|
15074
|
-
case
|
|
15075
|
-
case
|
|
15108
|
+
case exports.CollisionType.SceneNode: return getCollisionSat(this, target);
|
|
15109
|
+
case exports.CollisionType.Rectangle: return getCollisionSat(this, target);
|
|
15110
|
+
case exports.CollisionType.Polygon: return getCollisionSat(this, target);
|
|
15111
|
+
case exports.CollisionType.Circle: return getCollisionPolygonCircle(this, target);
|
|
15076
15112
|
// case CollisionType.Ellipse: return intersectionEllipsePoly(target as Ellipse, this);
|
|
15077
15113
|
// case CollisionType.Line: return intersectionLinePoly(target as Line, this);
|
|
15078
15114
|
// case CollisionType.Point: return intersectionPointPoly(target as Vector, this);
|
|
@@ -15096,6 +15132,8 @@ fn fragmentMain(input: VertexOutput) -> @location(0) vec4<f32> {
|
|
|
15096
15132
|
|
|
15097
15133
|
let temp = null;
|
|
15098
15134
|
class Segment {
|
|
15135
|
+
_startPoint;
|
|
15136
|
+
_endPoint;
|
|
15099
15137
|
constructor(startX = 0, startY = 0, endX = 0, endY = 0) {
|
|
15100
15138
|
this._startPoint = new Vector(startX, startY);
|
|
15101
15139
|
this._endPoint = new Vector(endX, endY);
|
|
@@ -15168,6 +15206,8 @@ fn fragmentMain(input: VertexOutput) -> @location(0) vec4<f32> {
|
|
|
15168
15206
|
}
|
|
15169
15207
|
|
|
15170
15208
|
class PolarVector {
|
|
15209
|
+
radius;
|
|
15210
|
+
phi;
|
|
15171
15211
|
constructor(radius = 0, angle = 0) {
|
|
15172
15212
|
this.radius = radius;
|
|
15173
15213
|
this.phi = angle;
|
|
@@ -15181,6 +15221,8 @@ fn fragmentMain(input: VertexOutput) -> @location(0) vec4<f32> {
|
|
|
15181
15221
|
}
|
|
15182
15222
|
|
|
15183
15223
|
class ColorAffector {
|
|
15224
|
+
_fromColor;
|
|
15225
|
+
_toColor;
|
|
15184
15226
|
constructor(fromColor, toColor) {
|
|
15185
15227
|
this._fromColor = fromColor.clone();
|
|
15186
15228
|
this._toColor = toColor.clone();
|
|
@@ -15219,6 +15261,7 @@ fn fragmentMain(input: VertexOutput) -> @location(0) vec4<f32> {
|
|
|
15219
15261
|
}
|
|
15220
15262
|
|
|
15221
15263
|
class ForceAffector {
|
|
15264
|
+
_acceleration;
|
|
15222
15265
|
constructor(accelerationX, accelerationY) {
|
|
15223
15266
|
this._acceleration = new Vector(accelerationX, accelerationY);
|
|
15224
15267
|
}
|
|
@@ -15242,6 +15285,7 @@ fn fragmentMain(input: VertexOutput) -> @location(0) vec4<f32> {
|
|
|
15242
15285
|
}
|
|
15243
15286
|
|
|
15244
15287
|
class ScaleAffector {
|
|
15288
|
+
_scaleFactor;
|
|
15245
15289
|
constructor(factorX, factorY) {
|
|
15246
15290
|
this._scaleFactor = new Vector(factorX, factorY);
|
|
15247
15291
|
}
|
|
@@ -15265,6 +15309,7 @@ fn fragmentMain(input: VertexOutput) -> @location(0) vec4<f32> {
|
|
|
15265
15309
|
}
|
|
15266
15310
|
|
|
15267
15311
|
class TorqueAffector {
|
|
15312
|
+
_angularAcceleration;
|
|
15268
15313
|
constructor(angularAcceleration) {
|
|
15269
15314
|
this._angularAcceleration = angularAcceleration;
|
|
15270
15315
|
}
|
|
@@ -15288,6 +15333,15 @@ fn fragmentMain(input: VertexOutput) -> @location(0) vec4<f32> {
|
|
|
15288
15333
|
}
|
|
15289
15334
|
|
|
15290
15335
|
class ParticleOptions {
|
|
15336
|
+
_totalLifetime;
|
|
15337
|
+
_elapsedLifetime;
|
|
15338
|
+
_position;
|
|
15339
|
+
_velocity;
|
|
15340
|
+
_scale;
|
|
15341
|
+
_tint;
|
|
15342
|
+
_rotation;
|
|
15343
|
+
_rotationSpeed;
|
|
15344
|
+
_textureIndex;
|
|
15291
15345
|
constructor(options = {}) {
|
|
15292
15346
|
const { totalLifetime, elapsedLifetime, position, velocity, scale, rotation, rotationSpeed, textureIndex, tint, } = options;
|
|
15293
15347
|
this._totalLifetime = (totalLifetime ?? Time.oneSecond).clone();
|
|
@@ -15376,8 +15430,10 @@ fn fragmentMain(input: VertexOutput) -> @location(0) vec4<f32> {
|
|
|
15376
15430
|
}
|
|
15377
15431
|
|
|
15378
15432
|
class UniversalEmitter {
|
|
15433
|
+
_emissionRate;
|
|
15434
|
+
_particleOptions;
|
|
15435
|
+
_emissionDelta = 0;
|
|
15379
15436
|
constructor(emissionRate, particleOptions) {
|
|
15380
|
-
this._emissionDelta = 0;
|
|
15381
15437
|
this._emissionRate = emissionRate;
|
|
15382
15438
|
this._particleOptions = particleOptions ?? new ParticleOptions();
|
|
15383
15439
|
}
|
|
@@ -15432,13 +15488,10 @@ fn fragmentMain(input: VertexOutput) -> @location(0) vec4<f32> {
|
|
|
15432
15488
|
}
|
|
15433
15489
|
|
|
15434
15490
|
class Graphics extends Container {
|
|
15435
|
-
|
|
15436
|
-
|
|
15437
|
-
|
|
15438
|
-
|
|
15439
|
-
this._fillColor = new Color();
|
|
15440
|
-
this._currentPoint = new Vector(0, 0);
|
|
15441
|
-
}
|
|
15491
|
+
_lineWidth = 0;
|
|
15492
|
+
_lineColor = new Color();
|
|
15493
|
+
_fillColor = new Color();
|
|
15494
|
+
_currentPoint = new Vector(0, 0);
|
|
15442
15495
|
get lineWidth() {
|
|
15443
15496
|
return this._lineWidth;
|
|
15444
15497
|
}
|
|
@@ -15632,10 +15685,11 @@ fn fragmentMain(input: VertexOutput) -> @location(0) vec4<f32> {
|
|
|
15632
15685
|
}
|
|
15633
15686
|
|
|
15634
15687
|
class Spritesheet {
|
|
15688
|
+
texture;
|
|
15689
|
+
frames = new Map();
|
|
15690
|
+
sprites = new Map();
|
|
15691
|
+
animations = new Map();
|
|
15635
15692
|
constructor(texture, data) {
|
|
15636
|
-
this.frames = new Map();
|
|
15637
|
-
this.sprites = new Map();
|
|
15638
|
-
this.animations = new Map();
|
|
15639
15693
|
this.texture = texture;
|
|
15640
15694
|
this.parse(data);
|
|
15641
15695
|
}
|
|
@@ -15715,16 +15769,16 @@ fn fragmentMain(input: VertexOutput) -> @location(0) vec4<f32> {
|
|
|
15715
15769
|
|
|
15716
15770
|
const defaultClipFps = 12;
|
|
15717
15771
|
class AnimatedSprite extends Sprite {
|
|
15772
|
+
_clips = new Map();
|
|
15773
|
+
_currentClipName = null;
|
|
15774
|
+
_currentFrameIndex = 0;
|
|
15775
|
+
_playing = false;
|
|
15776
|
+
_loopOverride = null;
|
|
15777
|
+
_elapsedFrameTimeMs = 0;
|
|
15778
|
+
onComplete = new Signal();
|
|
15779
|
+
onFrame = new Signal();
|
|
15718
15780
|
constructor(texture, clips) {
|
|
15719
15781
|
super(texture);
|
|
15720
|
-
this._clips = new Map();
|
|
15721
|
-
this._currentClipName = null;
|
|
15722
|
-
this._currentFrameIndex = 0;
|
|
15723
|
-
this._playing = false;
|
|
15724
|
-
this._loopOverride = null;
|
|
15725
|
-
this._elapsedFrameTimeMs = 0;
|
|
15726
|
-
this.onComplete = new Signal();
|
|
15727
|
-
this.onFrame = new Signal();
|
|
15728
15782
|
if (clips) {
|
|
15729
15783
|
this.setClips(clips);
|
|
15730
15784
|
}
|
|
@@ -15886,8 +15940,21 @@ fn fragmentMain(input: VertexOutput) -> @location(0) vec4<f32> {
|
|
|
15886
15940
|
}
|
|
15887
15941
|
|
|
15888
15942
|
class TextStyle {
|
|
15943
|
+
_align;
|
|
15944
|
+
_fill;
|
|
15945
|
+
_stroke;
|
|
15946
|
+
_strokeThickness;
|
|
15947
|
+
_fontSize;
|
|
15948
|
+
_fontWeight;
|
|
15949
|
+
_fontFamily;
|
|
15950
|
+
_wordWrap;
|
|
15951
|
+
_wordWrapWidth;
|
|
15952
|
+
_baseline;
|
|
15953
|
+
_lineJoin;
|
|
15954
|
+
_miterLimit;
|
|
15955
|
+
_padding;
|
|
15956
|
+
_dirty = true;
|
|
15889
15957
|
constructor(options = {}) {
|
|
15890
|
-
this._dirty = true;
|
|
15891
15958
|
this._align = options.align ?? 'left';
|
|
15892
15959
|
this._fill = options.fill ?? 'black';
|
|
15893
15960
|
this._stroke = options.stroke ?? 'black';
|
|
@@ -16064,9 +16131,13 @@ fn fragmentMain(input: VertexOutput) -> @location(0) vec4<f32> {
|
|
|
16064
16131
|
|
|
16065
16132
|
const newLinePattern = /(?:\r\n|\r|\n)/;
|
|
16066
16133
|
class Text extends Sprite {
|
|
16134
|
+
_text;
|
|
16135
|
+
_style;
|
|
16136
|
+
_canvas;
|
|
16137
|
+
_context;
|
|
16138
|
+
_dirty = true;
|
|
16067
16139
|
constructor(text, style, samplerOptions, canvas = document.createElement('canvas')) {
|
|
16068
16140
|
super(new Texture(canvas, samplerOptions));
|
|
16069
|
-
this._dirty = true;
|
|
16070
16141
|
this._text = text;
|
|
16071
16142
|
this._style = (style && style instanceof TextStyle) ? style : new TextStyle(style);
|
|
16072
16143
|
this._canvas = canvas;
|
|
@@ -16181,6 +16252,13 @@ fn fragmentMain(input: VertexOutput) -> @location(0) vec4<f32> {
|
|
|
16181
16252
|
}
|
|
16182
16253
|
|
|
16183
16254
|
class Sampler {
|
|
16255
|
+
_context;
|
|
16256
|
+
_sampler;
|
|
16257
|
+
_scaleMode;
|
|
16258
|
+
_wrapMode;
|
|
16259
|
+
_premultiplyAlpha;
|
|
16260
|
+
_generateMipMap;
|
|
16261
|
+
_flipY;
|
|
16184
16262
|
constructor(gl, options) {
|
|
16185
16263
|
const { scaleMode, wrapMode, premultiplyAlpha, generateMipMap, flipY } = options;
|
|
16186
16264
|
this._context = gl;
|
|
@@ -16248,6 +16326,7 @@ fn fragmentMain(input: VertexOutput) -> @location(0) vec4<f32> {
|
|
|
16248
16326
|
}
|
|
16249
16327
|
|
|
16250
16328
|
class CallbackRenderPass {
|
|
16329
|
+
_callback;
|
|
16251
16330
|
constructor(callback) {
|
|
16252
16331
|
this._callback = callback;
|
|
16253
16332
|
}
|
|
@@ -16260,12 +16339,12 @@ fn fragmentMain(input: VertexOutput) -> @location(0) vec4<f32> {
|
|
|
16260
16339
|
}
|
|
16261
16340
|
|
|
16262
16341
|
class BlurFilter extends Filter {
|
|
16342
|
+
_sprite = new Sprite(null);
|
|
16343
|
+
_sampleTint = Color.white.clone();
|
|
16344
|
+
_radius = 2;
|
|
16345
|
+
_quality = 1;
|
|
16263
16346
|
constructor(options = {}) {
|
|
16264
16347
|
super();
|
|
16265
|
-
this._sprite = new Sprite(null);
|
|
16266
|
-
this._sampleTint = Color.white.clone();
|
|
16267
|
-
this._radius = 2;
|
|
16268
|
-
this._quality = 1;
|
|
16269
16348
|
this._radius = Math.max(0, options.radius ?? 2);
|
|
16270
16349
|
this._quality = Math.max(1, Math.floor(options.quality ?? 1));
|
|
16271
16350
|
}
|
|
@@ -16320,9 +16399,10 @@ fn fragmentMain(input: VertexOutput) -> @location(0) vec4<f32> {
|
|
|
16320
16399
|
}
|
|
16321
16400
|
|
|
16322
16401
|
class ColorFilter extends Filter {
|
|
16402
|
+
_color;
|
|
16403
|
+
_sprite = new Sprite(null);
|
|
16323
16404
|
constructor(color = Color.white) {
|
|
16324
16405
|
super();
|
|
16325
|
-
this._sprite = new Sprite(null);
|
|
16326
16406
|
this._color = color.clone();
|
|
16327
16407
|
}
|
|
16328
16408
|
get color() {
|
|
@@ -16399,13 +16479,17 @@ fn fragmentMain(input: VertexOutput) -> @location(0) vec4<f32> {
|
|
|
16399
16479
|
'text', 'svg', 'json', 'binary', 'wasm', 'vtt',
|
|
16400
16480
|
];
|
|
16401
16481
|
class IndexedDbDatabase {
|
|
16482
|
+
name;
|
|
16483
|
+
version;
|
|
16484
|
+
_storeNames;
|
|
16485
|
+
_migrations;
|
|
16486
|
+
_onCloseHandler = this.disconnect.bind(this);
|
|
16487
|
+
_connected = false;
|
|
16488
|
+
_database = null;
|
|
16402
16489
|
get connected() {
|
|
16403
16490
|
return this._connected;
|
|
16404
16491
|
}
|
|
16405
16492
|
constructor(name, version = 1, storeNames = defaultStoreNames, migrations) {
|
|
16406
|
-
this._onCloseHandler = this.disconnect.bind(this);
|
|
16407
|
-
this._connected = false;
|
|
16408
|
-
this._database = null;
|
|
16409
16493
|
if (!supportsIndexedDb) {
|
|
16410
16494
|
throw new Error('This browser does not support indexedDB!');
|
|
16411
16495
|
}
|
|
@@ -16530,6 +16614,7 @@ fn fragmentMain(input: VertexOutput) -> @location(0) vec4<f32> {
|
|
|
16530
16614
|
}
|
|
16531
16615
|
|
|
16532
16616
|
class IndexedDbStore {
|
|
16617
|
+
_db;
|
|
16533
16618
|
constructor(nameOrOptions) {
|
|
16534
16619
|
const options = typeof nameOrOptions === 'string'
|
|
16535
16620
|
? { name: nameOrOptions }
|
|
@@ -16675,6 +16760,14 @@ fn fragmentMain(input: VertexOutput) -> @location(0) vec4<f32> {
|
|
|
16675
16760
|
toPackedCollisionGroups(options.collisionFilter);
|
|
16676
16761
|
};
|
|
16677
16762
|
class RapierPhysicsBinding {
|
|
16763
|
+
_world;
|
|
16764
|
+
_body;
|
|
16765
|
+
_collider;
|
|
16766
|
+
_syncMode;
|
|
16767
|
+
node;
|
|
16768
|
+
bodyType;
|
|
16769
|
+
shape;
|
|
16770
|
+
trigger;
|
|
16678
16771
|
constructor(world, node, body, collider, options) {
|
|
16679
16772
|
this._world = world;
|
|
16680
16773
|
this.node = node;
|
|
@@ -16740,14 +16833,17 @@ fn fragmentMain(input: VertexOutput) -> @location(0) vec4<f32> {
|
|
|
16740
16833
|
}
|
|
16741
16834
|
}
|
|
16742
16835
|
class RapierPhysicsWorld {
|
|
16836
|
+
onCollisionEnter = new Signal();
|
|
16837
|
+
onCollisionExit = new Signal();
|
|
16838
|
+
onTriggerEnter = new Signal();
|
|
16839
|
+
onTriggerExit = new Signal();
|
|
16840
|
+
_rapier;
|
|
16841
|
+
_world;
|
|
16842
|
+
_eventQueue;
|
|
16843
|
+
_bindings = new Set();
|
|
16844
|
+
_nodeBindings = new Map();
|
|
16845
|
+
_colliderBindings = new Map();
|
|
16743
16846
|
constructor(rapier, world, eventQueue) {
|
|
16744
|
-
this.onCollisionEnter = new Signal();
|
|
16745
|
-
this.onCollisionExit = new Signal();
|
|
16746
|
-
this.onTriggerEnter = new Signal();
|
|
16747
|
-
this.onTriggerExit = new Signal();
|
|
16748
|
-
this._bindings = new Set();
|
|
16749
|
-
this._nodeBindings = new Map();
|
|
16750
|
-
this._colliderBindings = new Map();
|
|
16751
16847
|
this._rapier = rapier;
|
|
16752
16848
|
this._world = world;
|
|
16753
16849
|
this._eventQueue = eventQueue;
|
|
@@ -16760,7 +16856,7 @@ fn fragmentMain(input: VertexOutput) -> @location(0) vec4<f32> {
|
|
|
16760
16856
|
}
|
|
16761
16857
|
catch (error) {
|
|
16762
16858
|
const message = error instanceof Error ? error.message : String(error);
|
|
16763
|
-
throw new Error(`Rapier physics module is unavailable. Install "${rapierModuleName}" or provide a custom module loader. Original error: ${message}
|
|
16859
|
+
throw new Error(`Rapier physics module is unavailable. Install "${rapierModuleName}" or provide a custom module loader. Original error: ${message}`, { cause: error });
|
|
16764
16860
|
}
|
|
16765
16861
|
const rapier = resolveRapierModule(loadedModule);
|
|
16766
16862
|
if (typeof rapier.init === 'function') {
|
|
@@ -17212,7 +17308,7 @@ fn fragmentMain(input: VertexOutput) -> @location(0) vec4<f32> {
|
|
|
17212
17308
|
exports.resolveDefinition = resolveDefinition;
|
|
17213
17309
|
exports.resolveGamepadDefinition = resolveGamepadDefinition;
|
|
17214
17310
|
exports.seconds = seconds;
|
|
17215
|
-
exports.sign = sign;
|
|
17311
|
+
exports.sign = sign$1;
|
|
17216
17312
|
exports.stopEvent = stopEvent;
|
|
17217
17313
|
exports.supportsCodec = supportsCodec;
|
|
17218
17314
|
exports.supportsEventOptions = supportsEventOptions;
|