@egret/engine 0.0.0-stage → 7.0.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/LICENSE +201 -0
- package/NOTICE +21 -0
- package/README.md +101 -2
- package/README.zh-CN.md +102 -0
- package/dist/Engine.d.ts +77 -0
- package/dist/Engine.js +469 -0
- package/dist/animation/index.d.ts +6 -0
- package/dist/animation/index.js +5 -0
- package/dist/animation/sequenceController.d.ts +22 -0
- package/dist/animation/sequenceController.js +618 -0
- package/dist/animation/sequenceCoordinator.d.ts +26 -0
- package/dist/animation/sequenceCoordinator.js +161 -0
- package/dist/animation/sequenceInput.d.ts +25 -0
- package/dist/animation/sequenceInput.js +108 -0
- package/dist/animation/sequenceMath.d.ts +35 -0
- package/dist/animation/sequenceMath.js +164 -0
- package/dist/animation/sequenceResetSlot.d.ts +7 -0
- package/dist/animation/sequenceResetSlot.js +367 -0
- package/dist/animation/sequenceResetTypes.d.ts +48 -0
- package/dist/animation/sequenceResetTypes.js +2 -0
- package/dist/animation/types.d.ts +75 -0
- package/dist/animation/types.js +2 -0
- package/dist/assetBundle.d.ts +54 -0
- package/dist/assetBundle.js +173 -0
- package/dist/assetGroup.d.ts +17 -0
- package/dist/assetGroup.js +332 -0
- package/dist/assetGroupTypes.d.ts +17 -0
- package/dist/assetGroupTypes.js +2 -0
- package/dist/audio.d.ts +4 -0
- package/dist/audio.js +4 -0
- package/dist/audioCues.d.ts +47 -0
- package/dist/audioCues.js +127 -0
- package/dist/audioMixer.d.ts +7 -0
- package/dist/audioMixer.js +785 -0
- package/dist/audioTypes.d.ts +246 -0
- package/dist/audioTypes.js +3 -0
- package/dist/bitmapBindingTicket.d.ts +24 -0
- package/dist/bitmapBindingTicket.js +215 -0
- package/dist/bitmapButton.d.ts +4 -0
- package/dist/bitmapButton.js +407 -0
- package/dist/bitmapButtonTypes.d.ts +31 -0
- package/dist/bitmapButtonTypes.js +2 -0
- package/dist/bitmapFontParse.d.ts +10 -0
- package/dist/bitmapFontParse.js +246 -0
- package/dist/bitmapFontTypes.d.ts +112 -0
- package/dist/bitmapFontTypes.js +2 -0
- package/dist/bitmapResourceSlot.d.ts +26 -0
- package/dist/bitmapResourceSlot.js +340 -0
- package/dist/bitmapText.d.ts +6 -0
- package/dist/bitmapText.js +320 -0
- package/dist/bitmapfont.d.ts +5 -0
- package/dist/bitmapfont.js +5 -0
- package/dist/camera.d.ts +4 -0
- package/dist/camera.js +4 -0
- package/dist/camera2d.d.ts +7 -0
- package/dist/camera2d.js +419 -0
- package/dist/cameraTypes.d.ts +126 -0
- package/dist/cameraTypes.js +2 -0
- package/dist/closeHost.d.ts +4 -0
- package/dist/closeHost.js +66 -0
- package/dist/contentArtifacts.d.ts +12 -0
- package/dist/contentArtifacts.js +153 -0
- package/dist/contentAtlasPages.d.ts +13 -0
- package/dist/contentAtlasPages.js +117 -0
- package/dist/contentLoader.d.ts +6 -0
- package/dist/contentLoader.js +327 -0
- package/dist/contentTypes.d.ts +35 -0
- package/dist/contentTypes.js +2 -0
- package/dist/createEngine.d.ts +7 -0
- package/dist/createEngine.js +25 -0
- package/dist/createEngineForProfile.d.ts +5 -0
- package/dist/createEngineForProfile.js +45 -0
- package/dist/displaySubtreeTicket.d.ts +25 -0
- package/dist/displaySubtreeTicket.js +76 -0
- package/dist/fontContentLoader.d.ts +6 -0
- package/dist/fontContentLoader.js +298 -0
- package/dist/fontContentTypes.d.ts +39 -0
- package/dist/fontContentTypes.js +2 -0
- package/dist/gameClock.d.ts +24 -0
- package/dist/gameClock.js +246 -0
- package/dist/gameClockTypes.d.ts +37 -0
- package/dist/gameClockTypes.js +2 -0
- package/dist/gameRun.d.ts +53 -0
- package/dist/gameRun.js +97 -0
- package/dist/gamepad.d.ts +5 -0
- package/dist/gamepad.js +5 -0
- package/dist/gamepadInput.d.ts +4 -0
- package/dist/gamepadInput.js +281 -0
- package/dist/gamepadKeys.d.ts +4 -0
- package/dist/gamepadKeys.js +205 -0
- package/dist/gamepadTypes.d.ts +142 -0
- package/dist/gamepadTypes.js +3 -0
- package/dist/hover.d.ts +4 -0
- package/dist/hover.js +4 -0
- package/dist/hoverInput.d.ts +8 -0
- package/dist/hoverInput.js +503 -0
- package/dist/hoverInputTypes.d.ts +129 -0
- package/dist/hoverInputTypes.js +2 -0
- package/dist/index.d.ts +52 -0
- package/dist/index.js +21 -0
- package/dist/input.d.ts +6 -0
- package/dist/input.js +5 -0
- package/dist/inputActions.d.ts +86 -0
- package/dist/inputActions.js +330 -0
- package/dist/internal/contentFactoryState.d.ts +19 -0
- package/dist/internal/contentFactoryState.js +42 -0
- package/dist/internal/mouseInputFactoryState.d.ts +57 -0
- package/dist/internal/mouseInputFactoryState.js +125 -0
- package/dist/internal/sequenceControllerFactoryState.d.ts +42 -0
- package/dist/internal/sequenceControllerFactoryState.js +98 -0
- package/dist/internal/textFieldFactoryState.d.ts +11 -0
- package/dist/internal/textFieldFactoryState.js +32 -0
- package/dist/internal/texturedFrameState.d.ts +4 -0
- package/dist/internal/texturedFrameState.js +12 -0
- package/dist/internal/uiFactoryState.d.ts +68 -0
- package/dist/internal/uiFactoryState.js +173 -0
- package/dist/internal/uiRootState.d.ts +67 -0
- package/dist/internal/uiRootState.js +103 -0
- package/dist/keyboardInput.d.ts +13 -0
- package/dist/keyboardInput.js +579 -0
- package/dist/keyboardInputTypes.d.ts +93 -0
- package/dist/keyboardInputTypes.js +2 -0
- package/dist/kit.d.ts +16 -0
- package/dist/kit.js +10 -0
- package/dist/layout.d.ts +5 -0
- package/dist/layout.js +132 -0
- package/dist/layoutTypes.d.ts +28 -0
- package/dist/layoutTypes.js +2 -0
- package/dist/manifestAssetGroup.d.ts +10 -0
- package/dist/manifestAssetGroup.js +477 -0
- package/dist/manifestResourceState.d.ts +17 -0
- package/dist/manifestResourceState.js +58 -0
- package/dist/manifestResourceTypes.d.ts +26 -0
- package/dist/manifestResourceTypes.js +2 -0
- package/dist/motion.d.ts +35 -0
- package/dist/motion.js +206 -0
- package/dist/mouseInput.d.ts +102 -0
- package/dist/mouseInput.js +562 -0
- package/dist/mouseInputTypes.d.ts +41 -0
- package/dist/mouseInputTypes.js +2 -0
- package/dist/paragraph.d.ts +8 -0
- package/dist/paragraph.js +7 -0
- package/dist/particleEmitter.d.ts +4 -0
- package/dist/particleEmitter.js +300 -0
- package/dist/particleTypes.d.ts +115 -0
- package/dist/particleTypes.js +2 -0
- package/dist/particles.d.ts +4 -0
- package/dist/particles.js +4 -0
- package/dist/physics2d.d.ts +4 -0
- package/dist/physics2d.js +4 -0
- package/dist/physics2dGeometry.d.ts +39 -0
- package/dist/physics2dGeometry.js +230 -0
- package/dist/physics2dTypes.d.ts +221 -0
- package/dist/physics2dTypes.js +2 -0
- package/dist/physics2dWorld.d.ts +4 -0
- package/dist/physics2dWorld.js +823 -0
- package/dist/pointerInput.d.ts +12 -0
- package/dist/pointerInput.js +300 -0
- package/dist/pointerInputTypes.d.ts +41 -0
- package/dist/pointerInputTypes.js +2 -0
- package/dist/random.d.ts +30 -0
- package/dist/random.js +131 -0
- package/dist/rendering/ownedPreparationFailure2D.d.ts +5 -0
- package/dist/rendering/ownedPreparationFailure2D.js +33 -0
- package/dist/rendering/packSharedDraws2D.d.ts +50 -0
- package/dist/rendering/packSharedDraws2D.js +379 -0
- package/dist/rendering/packedOrientation.d.ts +4 -0
- package/dist/rendering/packedOrientation.js +7 -0
- package/dist/rendering/prepareRectangles2D.d.ts +92 -0
- package/dist/rendering/prepareRectangles2D.js +481 -0
- package/dist/rendering/prepareSharedDraws2D.d.ts +90 -0
- package/dist/rendering/prepareSharedDraws2D.js +663 -0
- package/dist/rendering/preparedBatches2D.d.ts +17 -0
- package/dist/rendering/preparedBatches2D.js +30 -0
- package/dist/rendering/preparedSharedBatches2D.d.ts +44 -0
- package/dist/rendering/preparedSharedBatches2D.js +247 -0
- package/dist/rendering/sharedColor2D.d.ts +52 -0
- package/dist/rendering/sharedColor2D.js +191 -0
- package/dist/rendering/sharedEffects2D.d.ts +23 -0
- package/dist/rendering/sharedEffects2D.js +126 -0
- package/dist/rendering/sharedPreparationRetention2D.d.ts +120 -0
- package/dist/rendering/sharedPreparationRetention2D.js +357 -0
- package/dist/rendering/srgbBytes.d.ts +3 -0
- package/dist/rendering/srgbBytes.js +64 -0
- package/dist/rendering/texturedPreparationBudget2D.d.ts +31 -0
- package/dist/rendering/texturedPreparationBudget2D.js +81 -0
- package/dist/rendering/world3d/Animation3D.d.ts +104 -0
- package/dist/rendering/world3d/Animation3D.js +384 -0
- package/dist/rendering/world3d/AnimationTexture3D.d.ts +163 -0
- package/dist/rendering/world3d/AnimationTexture3D.js +603 -0
- package/dist/rendering/world3d/Batch3D.d.ts +75 -0
- package/dist/rendering/world3d/Batch3D.js +332 -0
- package/dist/rendering/world3d/Camera3D.d.ts +62 -0
- package/dist/rendering/world3d/Camera3D.js +132 -0
- package/dist/rendering/world3d/Character3D.d.ts +127 -0
- package/dist/rendering/world3d/Character3D.js +305 -0
- package/dist/rendering/world3d/Cloth3D.d.ts +130 -0
- package/dist/rendering/world3d/Cloth3D.js +503 -0
- package/dist/rendering/world3d/Compression3D.d.ts +22 -0
- package/dist/rendering/world3d/Compression3D.js +703 -0
- package/dist/rendering/world3d/Curves3D.d.ts +119 -0
- package/dist/rendering/world3d/Curves3D.js +460 -0
- package/dist/rendering/world3d/Decal3D.d.ts +43 -0
- package/dist/rendering/world3d/Decal3D.js +242 -0
- package/dist/rendering/world3d/Export3D.d.ts +13 -0
- package/dist/rendering/world3d/Export3D.js +263 -0
- package/dist/rendering/world3d/Geometry3D.d.ts +95 -0
- package/dist/rendering/world3d/Geometry3D.js +335 -0
- package/dist/rendering/world3d/GeometryBuilder3D.d.ts +53 -0
- package/dist/rendering/world3d/GeometryBuilder3D.js +196 -0
- package/dist/rendering/world3d/Gizmo3D.d.ts +80 -0
- package/dist/rendering/world3d/Gizmo3D.js +514 -0
- package/dist/rendering/world3d/Gltf3D.d.ts +73 -0
- package/dist/rendering/world3d/Gltf3D.js +996 -0
- package/dist/rendering/world3d/GpuParticles3D.d.ts +109 -0
- package/dist/rendering/world3d/GpuParticles3D.js +401 -0
- package/dist/rendering/world3d/Hdr3D.d.ts +35 -0
- package/dist/rendering/world3d/Hdr3D.js +191 -0
- package/dist/rendering/world3d/Jelly3D.d.ts +77 -0
- package/dist/rendering/world3d/Jelly3D.js +267 -0
- package/dist/rendering/world3d/Ktx23D.d.ts +30 -0
- package/dist/rendering/world3d/Ktx23D.js +112 -0
- package/dist/rendering/world3d/Light3D.d.ts +84 -0
- package/dist/rendering/world3d/Light3D.js +97 -0
- package/dist/rendering/world3d/Material3D.d.ts +253 -0
- package/dist/rendering/world3d/Material3D.js +269 -0
- package/dist/rendering/world3d/Mesh3D.d.ts +112 -0
- package/dist/rendering/world3d/Mesh3D.js +337 -0
- package/dist/rendering/world3d/Meshopt3D.d.ts +15 -0
- package/dist/rendering/world3d/Meshopt3D.js +276 -0
- package/dist/rendering/world3d/Navigation3D.d.ts +213 -0
- package/dist/rendering/world3d/Navigation3D.js +1043 -0
- package/dist/rendering/world3d/Object3D.d.ts +118 -0
- package/dist/rendering/world3d/Object3D.js +315 -0
- package/dist/rendering/world3d/Particles3D.d.ts +90 -0
- package/dist/rendering/world3d/Particles3D.js +277 -0
- package/dist/rendering/world3d/Physics3D.d.ts +430 -0
- package/dist/rendering/world3d/Physics3D.js +2840 -0
- package/dist/rendering/world3d/PhysicsHull3D.d.ts +37 -0
- package/dist/rendering/world3d/PhysicsHull3D.js +229 -0
- package/dist/rendering/world3d/PhysicsMesh3D.d.ts +41 -0
- package/dist/rendering/world3d/PhysicsMesh3D.js +340 -0
- package/dist/rendering/world3d/PhysicsQueries3D.d.ts +24 -0
- package/dist/rendering/world3d/PhysicsQueries3D.js +323 -0
- package/dist/rendering/world3d/PhysicsRemote3D.d.ts +179 -0
- package/dist/rendering/world3d/PhysicsRemote3D.js +536 -0
- package/dist/rendering/world3d/Ragdoll3D.d.ts +74 -0
- package/dist/rendering/world3d/Ragdoll3D.js +202 -0
- package/dist/rendering/world3d/Raycast3D.d.ts +40 -0
- package/dist/rendering/world3d/Raycast3D.js +247 -0
- package/dist/rendering/world3d/RenderList3D.d.ts +91 -0
- package/dist/rendering/world3d/RenderList3D.js +502 -0
- package/dist/rendering/world3d/Retarget3D.d.ts +21 -0
- package/dist/rendering/world3d/Retarget3D.js +185 -0
- package/dist/rendering/world3d/Rig3D.d.ts +57 -0
- package/dist/rendering/world3d/Rig3D.js +219 -0
- package/dist/rendering/world3d/Sdf3D.d.ts +181 -0
- package/dist/rendering/world3d/Sdf3D.js +1136 -0
- package/dist/rendering/world3d/SdfLod3D.d.ts +17 -0
- package/dist/rendering/world3d/SdfLod3D.js +56 -0
- package/dist/rendering/world3d/Serialize3D.d.ts +66 -0
- package/dist/rendering/world3d/Serialize3D.js +629 -0
- package/dist/rendering/world3d/Simplify3D.d.ts +29 -0
- package/dist/rendering/world3d/Simplify3D.js +426 -0
- package/dist/rendering/world3d/StateMachine3D.d.ts +87 -0
- package/dist/rendering/world3d/StateMachine3D.js +280 -0
- package/dist/rendering/world3d/SurfaceMaterial3D.d.ts +26 -0
- package/dist/rendering/world3d/SurfaceMaterial3D.js +138 -0
- package/dist/rendering/world3d/Terrain3D.d.ts +248 -0
- package/dist/rendering/world3d/Terrain3D.js +827 -0
- package/dist/rendering/world3d/Text3D.d.ts +95 -0
- package/dist/rendering/world3d/Text3D.js +560 -0
- package/dist/rendering/world3d/Texture3D.d.ts +148 -0
- package/dist/rendering/world3d/Texture3D.js +270 -0
- package/dist/rendering/world3d/Trail3D.d.ts +62 -0
- package/dist/rendering/world3d/Trail3D.js +195 -0
- package/dist/rendering/world3d/Vehicle3D.d.ts +102 -0
- package/dist/rendering/world3d/Vehicle3D.js +228 -0
- package/dist/rendering/world3d/VolumetricFog3D.d.ts +57 -0
- package/dist/rendering/world3d/VolumetricFog3D.js +230 -0
- package/dist/rendering/world3d/Water3D.d.ts +165 -0
- package/dist/rendering/world3d/Water3D.js +607 -0
- package/dist/rendering/world3d/core3D.d.ts +36 -0
- package/dist/rendering/world3d/core3D.js +99 -0
- package/dist/rendering/world3d/debug3D.d.ts +69 -0
- package/dist/rendering/world3d/debug3D.js +262 -0
- package/dist/rendering/world3d/decoders3D.d.ts +42 -0
- package/dist/rendering/world3d/decoders3D.js +133 -0
- package/dist/rendering/world3d/geometries3D.d.ts +111 -0
- package/dist/rendering/world3d/geometries3D.js +610 -0
- package/dist/rendering/world3d/helpers3D.d.ts +67 -0
- package/dist/rendering/world3d/helpers3D.js +178 -0
- package/dist/rendering/world3d/index.d.ts +103 -0
- package/dist/rendering/world3d/index.js +62 -0
- package/dist/rendering/world3d/math3D.d.ts +114 -0
- package/dist/rendering/world3d/math3D.js +675 -0
- package/dist/rendering/world3d/primitives3D.d.ts +67 -0
- package/dist/rendering/world3d/primitives3D.js +197 -0
- package/dist/resources.d.ts +8 -0
- package/dist/resources.js +6 -0
- package/dist/saveStore.d.ts +71 -0
- package/dist/saveStore.js +182 -0
- package/dist/semanticList.d.ts +126 -0
- package/dist/semanticList.js +175 -0
- package/dist/semanticTree.d.ts +10 -0
- package/dist/semanticTree.js +539 -0
- package/dist/semanticTypes.d.ts +175 -0
- package/dist/semanticTypes.js +2 -0
- package/dist/semantics.d.ts +6 -0
- package/dist/semantics.js +5 -0
- package/dist/sequencePlayback.d.ts +19 -0
- package/dist/sequencePlayback.js +391 -0
- package/dist/sequencePlaybackTypes.d.ts +24 -0
- package/dist/sequencePlaybackTypes.js +2 -0
- package/dist/sequenceTargetClaims.d.ts +10 -0
- package/dist/sequenceTargetClaims.js +31 -0
- package/dist/srgbBytes.d.ts +3 -0
- package/dist/srgbBytes.js +64 -0
- package/dist/startEngine.d.ts +5 -0
- package/dist/startEngine.js +31 -0
- package/dist/surfaceOwnership.d.ts +3 -0
- package/dist/surfaceOwnership.js +15 -0
- package/dist/text.d.ts +24 -0
- package/dist/text.js +4 -0
- package/dist/textField.d.ts +6 -0
- package/dist/textField.js +6 -0
- package/dist/textTable.d.ts +41 -0
- package/dist/textTable.js +114 -0
- package/dist/tileMapDraw.d.ts +7 -0
- package/dist/tileMapDraw.js +310 -0
- package/dist/tiledImport.d.ts +9 -0
- package/dist/tiledImport.js +357 -0
- package/dist/tilemap.d.ts +5 -0
- package/dist/tilemap.js +5 -0
- package/dist/tilemapTypes.d.ts +182 -0
- package/dist/tilemapTypes.js +2 -0
- package/dist/timer.d.ts +34 -0
- package/dist/timer.js +119 -0
- package/dist/tween.d.ts +15 -0
- package/dist/tween.js +329 -0
- package/dist/tweenTypes.d.ts +31 -0
- package/dist/tweenTypes.js +2 -0
- package/dist/ui/controlKeys.d.ts +113 -0
- package/dist/ui/controlKeys.js +250 -0
- package/dist/ui/controls.d.ts +58 -0
- package/dist/ui/controls.js +290 -0
- package/dist/ui/editing.d.ts +3 -0
- package/dist/ui/editing.js +3 -0
- package/dist/ui/index.d.ts +19 -0
- package/dist/ui/index.js +11 -0
- package/dist/ui/keyboardFocus.d.ts +32 -0
- package/dist/ui/keyboardFocus.js +146 -0
- package/dist/ui/layerTypes.d.ts +98 -0
- package/dist/ui/layerTypes.js +2 -0
- package/dist/ui/layers.d.ts +4 -0
- package/dist/ui/layers.js +586 -0
- package/dist/ui/leafContent.d.ts +21 -0
- package/dist/ui/leafContent.js +136 -0
- package/dist/ui/rangeControl.d.ts +53 -0
- package/dist/ui/rangeControl.js +168 -0
- package/dist/ui/scrollControl.d.ts +84 -0
- package/dist/ui/scrollControl.js +222 -0
- package/dist/ui/stateControls.d.ts +90 -0
- package/dist/ui/stateControls.js +331 -0
- package/dist/ui/textEditor.d.ts +54 -0
- package/dist/ui/textEditor.js +371 -0
- package/dist/ui/textEditorTypes.d.ts +85 -0
- package/dist/ui/textEditorTypes.js +2 -0
- package/dist/ui/textFieldControl.d.ts +100 -0
- package/dist/ui/textFieldControl.js +260 -0
- package/dist/ui/theme.d.ts +64 -0
- package/dist/ui/theme.js +166 -0
- package/dist/ui/types.d.ts +285 -0
- package/dist/ui/types.js +2 -0
- package/dist/ui/uiRoot.d.ts +4 -0
- package/dist/ui/uiRoot.js +1526 -0
- package/dist/ui/uiRootDisplay.d.ts +46 -0
- package/dist/ui/uiRootDisplay.js +148 -0
- package/dist/ui/uiRootModel.d.ts +114 -0
- package/dist/ui/uiRootModel.js +66 -0
- package/dist/ui/virtualList.d.ts +20 -0
- package/dist/ui/virtualList.js +105 -0
- package/dist/video.d.ts +4 -0
- package/dist/video.js +4 -0
- package/dist/videoPlayer.d.ts +4 -0
- package/dist/videoPlayer.js +215 -0
- package/dist/videoTypes.d.ts +77 -0
- package/dist/videoTypes.js +2 -0
- package/dist/web/BrowserAssetBundle.d.ts +41 -0
- package/dist/web/BrowserAssetBundle.js +136 -0
- package/dist/web/BrowserAudio.d.ts +74 -0
- package/dist/web/BrowserAudio.js +503 -0
- package/dist/web/BrowserFrameLoop.d.ts +69 -0
- package/dist/web/BrowserFrameLoop.js +125 -0
- package/dist/web/BrowserGame.d.ts +174 -0
- package/dist/web/BrowserGame.js +473 -0
- package/dist/web/BrowserGamepadInput.d.ts +38 -0
- package/dist/web/BrowserGamepadInput.js +134 -0
- package/dist/web/BrowserHoverInput.d.ts +25 -0
- package/dist/web/BrowserHoverInput.js +266 -0
- package/dist/web/BrowserImageTextures.d.ts +72 -0
- package/dist/web/BrowserImageTextures.js +169 -0
- package/dist/web/BrowserInputActions.d.ts +63 -0
- package/dist/web/BrowserInputActions.js +345 -0
- package/dist/web/BrowserKeyboardInput.d.ts +4 -0
- package/dist/web/BrowserKeyboardInput.js +223 -0
- package/dist/web/BrowserPlay.d.ts +417 -0
- package/dist/web/BrowserPlay.js +1648 -0
- package/dist/web/BrowserPointerInput.d.ts +4 -0
- package/dist/web/BrowserPointerInput.js +511 -0
- package/dist/web/BrowserPreferences.d.ts +10 -0
- package/dist/web/BrowserPreferences.js +39 -0
- package/dist/web/BrowserSemantics.d.ts +36 -0
- package/dist/web/BrowserSemantics.js +418 -0
- package/dist/web/BrowserStatsPanel.d.ts +56 -0
- package/dist/web/BrowserStatsPanel.js +143 -0
- package/dist/web/BrowserStorage.d.ts +35 -0
- package/dist/web/BrowserStorage.js +132 -0
- package/dist/web/BrowserTextEditor.d.ts +52 -0
- package/dist/web/BrowserTextEditor.js +839 -0
- package/dist/web/BrowserTextInput.d.ts +89 -0
- package/dist/web/BrowserTextInput.js +524 -0
- package/dist/web/BrowserTextureProvider.d.ts +58 -0
- package/dist/web/BrowserTextureProvider.js +935 -0
- package/dist/web/BrowserVideo.d.ts +40 -0
- package/dist/web/BrowserVideo.js +237 -0
- package/dist/web/CanvasKitFontSetProvider.d.ts +32 -0
- package/dist/web/CanvasKitFontSetProvider.js +215 -0
- package/dist/web/CanvasKitParagraphProvider.d.ts +173 -0
- package/dist/web/CanvasKitParagraphProvider.js +692 -0
- package/dist/web/CanvasTextRasterProvider.d.ts +4 -0
- package/dist/web/CanvasTextRasterProvider.js +312 -0
- package/dist/web/ManifestByteSource.d.ts +151 -0
- package/dist/web/ManifestByteSource.js +975 -0
- package/dist/web/ManifestFontContentLoader.d.ts +13 -0
- package/dist/web/ManifestFontContentLoader.js +30 -0
- package/dist/web/MouseInput.d.ts +4 -0
- package/dist/web/MouseInput.js +218 -0
- package/dist/web/WebGL2Host.d.ts +5 -0
- package/dist/web/WebGL2Host.js +2711 -0
- package/dist/web/WebGPUHost.d.ts +100 -0
- package/dist/web/WebGPUHost.js +3430 -0
- package/dist/web/audio.d.ts +3 -0
- package/dist/web/audio.js +4 -0
- package/dist/web/canvasKitParagraphGeometry.d.ts +27 -0
- package/dist/web/canvasKitParagraphGeometry.js +83 -0
- package/dist/web/editing.d.ts +5 -0
- package/dist/web/editing.js +4 -0
- package/dist/web/editorFonts.d.ts +54 -0
- package/dist/web/editorFonts.js +297 -0
- package/dist/web/game.d.ts +5 -0
- package/dist/web/game.js +6 -0
- package/dist/web/gamepad.d.ts +3 -0
- package/dist/web/gamepad.js +4 -0
- package/dist/web/hover.d.ts +3 -0
- package/dist/web/hover.js +4 -0
- package/dist/web/image.d.ts +4 -0
- package/dist/web/image.js +4 -0
- package/dist/web/imageProjections2D.d.ts +16 -0
- package/dist/web/imageProjections2D.js +2 -0
- package/dist/web/input.d.ts +6 -0
- package/dist/web/input.js +4 -0
- package/dist/web/keyboard.d.ts +3 -0
- package/dist/web/keyboard.js +3 -0
- package/dist/web/kit.d.ts +11 -0
- package/dist/web/kit.js +8 -0
- package/dist/web/loop.d.ts +3 -0
- package/dist/web/loop.js +4 -0
- package/dist/web/paragraph.d.ts +6 -0
- package/dist/web/paragraph.js +4 -0
- package/dist/web/play.d.ts +10 -0
- package/dist/web/play.js +9 -0
- package/dist/web/playMusic.d.ts +33 -0
- package/dist/web/playMusic.js +194 -0
- package/dist/web/playSfx.d.ts +36 -0
- package/dist/web/playSfx.js +112 -0
- package/dist/web/playTouch.d.ts +45 -0
- package/dist/web/playTouch.js +141 -0
- package/dist/web/playWidgets.d.ts +71 -0
- package/dist/web/playWidgets.js +431 -0
- package/dist/web/pointer.d.ts +3 -0
- package/dist/web/pointer.js +3 -0
- package/dist/web/prepareSharedSubmission2D.d.ts +27 -0
- package/dist/web/prepareSharedSubmission2D.js +63 -0
- package/dist/web/resources.d.ts +29 -0
- package/dist/web/resources.js +96 -0
- package/dist/web/semantics.d.ts +3 -0
- package/dist/web/semantics.js +4 -0
- package/dist/web/sharedDeviceSession.d.ts +64 -0
- package/dist/web/sharedDeviceSession.js +2 -0
- package/dist/web/sharedEffectShaders.d.ts +13 -0
- package/dist/web/sharedEffectShaders.js +181 -0
- package/dist/web/sharedFrameUpload.d.ts +25 -0
- package/dist/web/sharedFrameUpload.js +2 -0
- package/dist/web/sharedHostDeferred.d.ts +7 -0
- package/dist/web/sharedHostDeferred.js +12 -0
- package/dist/web/sharedRetentionLedger.d.ts +85 -0
- package/dist/web/sharedRetentionLedger.js +391 -0
- package/dist/web/sharedSubmissionStorage2D.d.ts +56 -0
- package/dist/web/sharedSubmissionStorage2D.js +73 -0
- package/dist/web/sharedWebGL2Arena.d.ts +40 -0
- package/dist/web/sharedWebGL2Arena.js +77 -0
- package/dist/web/sharedWebGL2Options.d.ts +33 -0
- package/dist/web/sharedWebGL2Options.js +102 -0
- package/dist/web/sharedWebGL2Shaders.d.ts +33 -0
- package/dist/web/sharedWebGL2Shaders.js +408 -0
- package/dist/web/sharedWebGPUOptions.d.ts +41 -0
- package/dist/web/sharedWebGPUOptions.js +130 -0
- package/dist/web/text.d.ts +3 -0
- package/dist/web/text.js +3 -0
- package/dist/web/textInput.d.ts +3 -0
- package/dist/web/textInput.js +3 -0
- package/dist/web/video.d.ts +3 -0
- package/dist/web/video.js +4 -0
- package/dist/web/webgl2.d.ts +7 -0
- package/dist/web/webgl2.js +4 -0
- package/dist/web/webgl2LayerState.d.ts +50 -0
- package/dist/web/webgl2LayerState.js +102 -0
- package/dist/web/webgl2Native.d.ts +72 -0
- package/dist/web/webgl2Native.js +572 -0
- package/dist/web/webgl2Types.d.ts +150 -0
- package/dist/web/webgl2Types.js +2 -0
- package/dist/web/webgpu.d.ts +6 -0
- package/dist/web/webgpu.js +2 -0
- package/dist/web/webgpuBindingCache.d.ts +26 -0
- package/dist/web/webgpuBindingCache.js +223 -0
- package/dist/web/webgpuBufferPool.d.ts +51 -0
- package/dist/web/webgpuBufferPool.js +58 -0
- package/dist/web/webgpuImageResidency.d.ts +56 -0
- package/dist/web/webgpuImageResidency.js +65 -0
- package/dist/web/webgpuLifetime.d.ts +45 -0
- package/dist/web/webgpuLifetime.js +64 -0
- package/dist/web/webgpuRetentionPool.d.ts +66 -0
- package/dist/web/webgpuRetentionPool.js +85 -0
- package/dist/web/webgpuSharedPass.d.ts +7 -0
- package/dist/web/webgpuSharedPass.js +293 -0
- package/dist/web/webgpuSharedResolvePass.d.ts +3 -0
- package/dist/web/webgpuSharedResolvePass.js +34 -0
- package/dist/web/world3d/Audio3D.d.ts +85 -0
- package/dist/web/world3d/Audio3D.js +271 -0
- package/dist/web/world3d/BrowserPlay3D.d.ts +295 -0
- package/dist/web/world3d/BrowserPlay3D.js +1256 -0
- package/dist/web/world3d/FlyControls3D.d.ts +59 -0
- package/dist/web/world3d/FlyControls3D.js +162 -0
- package/dist/web/world3d/FollowControls3D.d.ts +31 -0
- package/dist/web/world3d/FollowControls3D.js +119 -0
- package/dist/web/world3d/OrbitControls3D.d.ts +58 -0
- package/dist/web/world3d/OrbitControls3D.js +189 -0
- package/dist/web/world3d/TransformControls3D.d.ts +37 -0
- package/dist/web/world3d/TransformControls3D.js +128 -0
- package/dist/web/world3d/WebGL2Renderer3D.d.ts +136 -0
- package/dist/web/world3d/WebGL2Renderer3D.js +1175 -0
- package/dist/web/world3d/WebGPURenderer3D.d.ts +112 -0
- package/dist/web/world3d/WebGPURenderer3D.js +1916 -0
- package/dist/web/world3d/World3DView.d.ts +54 -0
- package/dist/web/world3d/World3DView.js +79 -0
- package/dist/web/world3d/app3D.d.ts +143 -0
- package/dist/web/world3d/app3D.js +305 -0
- package/dist/web/world3d/assets3D.d.ts +39 -0
- package/dist/web/world3d/assets3D.js +112 -0
- package/dist/web/world3d/atmosphere3D.d.ts +56 -0
- package/dist/web/world3d/atmosphere3D.js +193 -0
- package/dist/web/world3d/canvasFont3D.d.ts +21 -0
- package/dist/web/world3d/canvasFont3D.js +165 -0
- package/dist/web/world3d/frame3D.d.ts +144 -0
- package/dist/web/world3d/frame3D.js +388 -0
- package/dist/web/world3d/gpuResources3D.d.ts +98 -0
- package/dist/web/world3d/gpuResources3D.js +901 -0
- package/dist/web/world3d/host3D.d.ts +24 -0
- package/dist/web/world3d/host3D.js +61 -0
- package/dist/web/world3d/index.d.ts +40 -0
- package/dist/web/world3d/index.js +24 -0
- package/dist/web/world3d/loaders3D.d.ts +27 -0
- package/dist/web/world3d/loaders3D.js +138 -0
- package/dist/web/world3d/markers3D.d.ts +53 -0
- package/dist/web/world3d/markers3D.js +130 -0
- package/dist/web/world3d/materialWebGL23D.d.ts +34 -0
- package/dist/web/world3d/materialWebGL23D.js +218 -0
- package/dist/web/world3d/overlay3D.d.ts +47 -0
- package/dist/web/world3d/overlay3D.js +187 -0
- package/dist/web/world3d/post3D.d.ts +116 -0
- package/dist/web/world3d/post3D.js +462 -0
- package/dist/web/world3d/postWebGL23D.d.ts +24 -0
- package/dist/web/world3d/postWebGL23D.js +237 -0
- package/dist/web/world3d/postWebGPU3D.d.ts +23 -0
- package/dist/web/world3d/postWebGPU3D.js +255 -0
- package/dist/web/world3d/probe3D.d.ts +15 -0
- package/dist/web/world3d/probe3D.js +66 -0
- package/dist/web/world3d/shaders3D.d.ts +43 -0
- package/dist/web/world3d/shaders3D.js +851 -0
- package/dist/web/world3d/stats3D.d.ts +34 -0
- package/dist/web/world3d/stats3D.js +81 -0
- package/dist/web/world3d/webGL2FrameMetrics3D.d.ts +71 -0
- package/dist/web/world3d/webGL2FrameMetrics3D.js +185 -0
- package/dist/web/world3d/webgpu.d.ts +37 -0
- package/dist/web/world3d/webgpu.js +23 -0
- package/dist/web/world3d/webgpuPacking3D.d.ts +13 -0
- package/dist/web/world3d/webgpuPacking3D.js +85 -0
- package/dist/web/world3d/wgsl3D.d.ts +68 -0
- package/dist/web/world3d/wgsl3D.js +781 -0
- package/package.json +220 -4
|
@@ -0,0 +1,109 @@
|
|
|
1
|
+
import { type Blending3D, type ColorInput3D } from './Material3D.js';
|
|
2
|
+
import { InstancedMesh3D } from './Mesh3D.js';
|
|
3
|
+
import type { Texture3D } from './Texture3D.js';
|
|
4
|
+
type Range = number | readonly [number, number];
|
|
5
|
+
/** GPU particles to make: how many and how long they live, how they move, grow, turn and fade, where they come from and how they blend. */
|
|
6
|
+
export interface GpuParticlesOptions3D {
|
|
7
|
+
/** Number of particles. Default 10000. */
|
|
8
|
+
readonly count?: number;
|
|
9
|
+
/** Seconds each particle lives: a fixed value or a [min, max] range. Default 2. */
|
|
10
|
+
readonly lifetime?: Range;
|
|
11
|
+
/** Launch speed. Default 1. */
|
|
12
|
+
readonly speed?: Range;
|
|
13
|
+
/** Mean launch direction in the emitter's space. Default +Y. */
|
|
14
|
+
readonly direction?: readonly [number, number, number];
|
|
15
|
+
/** Half angle in radians of the cone around `direction`; PI launches in every direction. */
|
|
16
|
+
readonly spread?: number;
|
|
17
|
+
/** Constant acceleration in the emitter's space. */
|
|
18
|
+
readonly gravity?: readonly [number, number, number];
|
|
19
|
+
/** Fraction of velocity lost per second. */
|
|
20
|
+
readonly drag?: number;
|
|
21
|
+
readonly startSize?: Range;
|
|
22
|
+
/** Size at the end of life as a multiple of the start size. Default 1. */
|
|
23
|
+
readonly endScale?: number;
|
|
24
|
+
/** Start angle of the sprite and its turn rate, in radians and radians per second. */
|
|
25
|
+
readonly rotation?: Range;
|
|
26
|
+
readonly spin?: Range;
|
|
27
|
+
readonly startColor?: ColorInput3D;
|
|
28
|
+
readonly endColor?: ColorInput3D;
|
|
29
|
+
readonly startOpacity?: number;
|
|
30
|
+
readonly endOpacity?: number;
|
|
31
|
+
/** Shares of a particle's life spent fading in and out. Defaults: 0.1 and 0.3. */
|
|
32
|
+
readonly fadeIn?: number;
|
|
33
|
+
readonly fadeOut?: number;
|
|
34
|
+
/** Volume particles start in: a point, a sphere of `radius`, or a box of half `extents`. */
|
|
35
|
+
readonly shape?: 'point' | 'sphere' | 'box';
|
|
36
|
+
readonly radius?: number;
|
|
37
|
+
readonly extents?: readonly [number, number, number];
|
|
38
|
+
/**
|
|
39
|
+
* true: a steady stream, each particle reborn when its life ends, already
|
|
40
|
+
* running at time 0. false: one burst, emitted over `duration` seconds.
|
|
41
|
+
*/
|
|
42
|
+
readonly loop?: boolean;
|
|
43
|
+
readonly duration?: number;
|
|
44
|
+
readonly map?: Texture3D;
|
|
45
|
+
readonly blending?: Blending3D;
|
|
46
|
+
/** Distance over which particles fade where they meet solid geometry; 0 leaves hard edges. */
|
|
47
|
+
readonly softness?: number;
|
|
48
|
+
readonly seed?: number;
|
|
49
|
+
/**
|
|
50
|
+
* Height of a level floor particles bounce off once, in the emitter's
|
|
51
|
+
* space, or in the world for world-space particles. With a floor, drag is
|
|
52
|
+
* not applied.
|
|
53
|
+
*/
|
|
54
|
+
readonly floor?: number;
|
|
55
|
+
/** Share of its speed a particle keeps when it bounces. Default 0.4. */
|
|
56
|
+
readonly bounce?: number;
|
|
57
|
+
/**
|
|
58
|
+
* 'local' (default) moves every particle with the emitter's node. 'world'
|
|
59
|
+
* leaves particles where they were emitted, as smoke behind a moving
|
|
60
|
+
* torch does; each update then looks at every particle to see whether it
|
|
61
|
+
* was reborn.
|
|
62
|
+
*/
|
|
63
|
+
readonly space?: 'local' | 'world';
|
|
64
|
+
/** Draw far particles first, as alpha-blended smoke needs. Sorting runs on the CPU before every draw. */
|
|
65
|
+
readonly sorted?: boolean;
|
|
66
|
+
}
|
|
67
|
+
/**
|
|
68
|
+
* An instanced, camera-facing quad per particle. The instance matrix slots
|
|
69
|
+
* do not hold matrices: they carry each particle's start and birth time,
|
|
70
|
+
* velocity and lifetime, and sizes and angles. Particles move with the
|
|
71
|
+
* emitter's node. Call `update(deltaSeconds)` each frame, or set `time`.
|
|
72
|
+
*/
|
|
73
|
+
export declare class GpuParticles3D extends InstancedMesh3D {
|
|
74
|
+
#private;
|
|
75
|
+
readonly loop: boolean;
|
|
76
|
+
/** Seconds until the last particle of a burst has died; Infinity for a stream. */
|
|
77
|
+
readonly duration: number;
|
|
78
|
+
readonly space: 'local' | 'world';
|
|
79
|
+
/** Sort far to near before drawing. Disabling restores the logical instance order. */
|
|
80
|
+
get sorted(): boolean;
|
|
81
|
+
set sorted(value: boolean);
|
|
82
|
+
constructor(options?: GpuParticlesOptions3D);
|
|
83
|
+
/** Seconds since the emitter started. */
|
|
84
|
+
get time(): number;
|
|
85
|
+
set time(value: number);
|
|
86
|
+
/** True once every particle of a burst has died. */
|
|
87
|
+
get isFinished(): boolean;
|
|
88
|
+
update(deltaSeconds: number): void;
|
|
89
|
+
/** Where a particle is now, in the emitter's space, or in the world for world-space particles; false while it is not alive. */
|
|
90
|
+
positionAt(index: number, out: number[] | Float32Array): boolean;
|
|
91
|
+
private positionInSlot;
|
|
92
|
+
/** Start a burst again from its first particle. */
|
|
93
|
+
restart(): void;
|
|
94
|
+
private slotOf;
|
|
95
|
+
/** World mode: a particle starting a new life takes the emitter's place and heading of this moment. */
|
|
96
|
+
private respawn;
|
|
97
|
+
/** Before a draw: reorder the drawn arrays so the farthest particle comes first. */
|
|
98
|
+
private arrange;
|
|
99
|
+
private reorderSlots;
|
|
100
|
+
private restoreOrder;
|
|
101
|
+
/** Everywhere a particle can be during its life, in world space. */
|
|
102
|
+
get worldBoundingSphere(): Float32Array;
|
|
103
|
+
/** Release the geometry and the material. */
|
|
104
|
+
dispose(): void;
|
|
105
|
+
}
|
|
106
|
+
/** Makes particles simulated on the GPU. */
|
|
107
|
+
export declare function createGpuParticles3D(options?: GpuParticlesOptions3D): GpuParticles3D;
|
|
108
|
+
export {};
|
|
109
|
+
//# sourceMappingURL=GpuParticles3D.d.ts.map
|
|
@@ -0,0 +1,401 @@
|
|
|
1
|
+
// SPDX-License-Identifier: Apache-2.0
|
|
2
|
+
// Particles whose motion is computed in the vertex stage. Every particle is
|
|
3
|
+
// given its birth time, start, velocity and look once; from then on the only
|
|
4
|
+
// thing that changes per frame is one number, the time. Hundreds of thousands
|
|
5
|
+
// of particles cost the CPU nothing, at the price of motion that must follow
|
|
6
|
+
// a formula: launch, gravity and drag, one bounce off a level floor, and no
|
|
7
|
+
// forces that vary over time. Two things cost the CPU a pass over the particles
|
|
8
|
+
// when asked for: leaving particles behind a moving emitter, and drawing them
|
|
9
|
+
// back to front. DOM-free; both backends run the same formula.
|
|
10
|
+
import { World3DError, requireCount3D, requireFinite3D } from './core3D.js';
|
|
11
|
+
import { createSpriteMaterial3D, setColor3D } from './Material3D.js';
|
|
12
|
+
import { InstancedMesh3D, MESH3D_LIMITS } from './Mesh3D.js';
|
|
13
|
+
import { sphereTransform } from './math3D.js';
|
|
14
|
+
import { createQuadGeometry3D } from './primitives3D.js';
|
|
15
|
+
const pair = (value, fallback, field) => {
|
|
16
|
+
if (value === undefined)
|
|
17
|
+
return [fallback, fallback];
|
|
18
|
+
if (typeof value === 'number')
|
|
19
|
+
return [requireFinite3D(value, field), value];
|
|
20
|
+
if (!Array.isArray(value) ||
|
|
21
|
+
value.length !== 2 ||
|
|
22
|
+
!(requireFinite3D(value[1], field) >= requireFinite3D(value[0], field)))
|
|
23
|
+
throw new World3DError('WORLD3D_INPUT_INVALID', field);
|
|
24
|
+
return [value[0], value[1]];
|
|
25
|
+
};
|
|
26
|
+
/**
|
|
27
|
+
* An instanced, camera-facing quad per particle. The instance matrix slots
|
|
28
|
+
* do not hold matrices: they carry each particle's start and birth time,
|
|
29
|
+
* velocity and lifetime, and sizes and angles. Particles move with the
|
|
30
|
+
* emitter's node. Call `update(deltaSeconds)` each frame, or set `time`.
|
|
31
|
+
*/
|
|
32
|
+
export class GpuParticles3D extends InstancedMesh3D {
|
|
33
|
+
loop;
|
|
34
|
+
/** Seconds until the last particle of a burst has died; Infinity for a stream. */
|
|
35
|
+
duration;
|
|
36
|
+
#uniforms;
|
|
37
|
+
space;
|
|
38
|
+
#sorted = false;
|
|
39
|
+
#previousBeforeRender;
|
|
40
|
+
#sortBeforeRender = (camera) => {
|
|
41
|
+
this.#previousBeforeRender?.(camera);
|
|
42
|
+
if (this.#sorted)
|
|
43
|
+
this.arrange(camera);
|
|
44
|
+
};
|
|
45
|
+
/** Sort far to near before drawing. Disabling restores the logical instance order. */
|
|
46
|
+
get sorted() {
|
|
47
|
+
return this.#sorted;
|
|
48
|
+
}
|
|
49
|
+
set sorted(value) {
|
|
50
|
+
if (value === this.#sorted)
|
|
51
|
+
return;
|
|
52
|
+
this.#sorted = value;
|
|
53
|
+
if (value) {
|
|
54
|
+
this.#previousBeforeRender = this.beforeRender;
|
|
55
|
+
this.beforeRender = this.#sortBeforeRender;
|
|
56
|
+
}
|
|
57
|
+
else {
|
|
58
|
+
if (this.beforeRender === this.#sortBeforeRender) {
|
|
59
|
+
if (this.#previousBeforeRender)
|
|
60
|
+
this.beforeRender = this.#previousBeforeRender;
|
|
61
|
+
else
|
|
62
|
+
delete this.beforeRender;
|
|
63
|
+
}
|
|
64
|
+
this.#previousBeforeRender = undefined;
|
|
65
|
+
this.restoreOrder();
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
// What was generated, in the emitter's space; the drawn arrays are filled from it.
|
|
69
|
+
#source;
|
|
70
|
+
// World mode: which life each particle is in, to notice when it is reborn.
|
|
71
|
+
#cycle;
|
|
72
|
+
#order;
|
|
73
|
+
#depth;
|
|
74
|
+
#sphere = new Float32Array(4);
|
|
75
|
+
#worldSphere = new Float32Array(4);
|
|
76
|
+
constructor(options = {}) {
|
|
77
|
+
const count = requireCount3D(options.count ?? 10000, 'count', MESH3D_LIMITS.maxInstances);
|
|
78
|
+
const material = createSpriteMaterial3D({
|
|
79
|
+
...(options.map ? { map: options.map } : {}),
|
|
80
|
+
blending: options.blending ?? 'additive',
|
|
81
|
+
depthWrite: false
|
|
82
|
+
});
|
|
83
|
+
super(createQuadGeometry3D(), material, count, 4);
|
|
84
|
+
this.name = 'gpu-particles';
|
|
85
|
+
this.pickable = false;
|
|
86
|
+
this.castShadow = false;
|
|
87
|
+
this.receiveShadow = false;
|
|
88
|
+
const life = pair(options.lifetime, 2, 'lifetime'), speed = pair(options.speed, 1, 'speed'), size = pair(options.startSize, 0.2, 'startSize');
|
|
89
|
+
const rotation = pair(options.rotation, 0, 'rotation'), spin = pair(options.spin, 0, 'spin');
|
|
90
|
+
if (life[0] <= 0)
|
|
91
|
+
throw new World3DError('WORLD3D_INPUT_INVALID', 'lifetime');
|
|
92
|
+
const endScale = requireFinite3D(options.endScale ?? 1, 'endScale'), spread = requireFinite3D(options.spread ?? Math.PI / 8, 'spread'), drag = requireFinite3D(options.drag ?? 0, 'drag');
|
|
93
|
+
const gravity = options.gravity ?? [0, 0, 0], direction = options.direction ?? [0, 1, 0], shape = options.shape ?? 'point';
|
|
94
|
+
const hasFloor = options.floor !== undefined, floor = requireFinite3D(options.floor ?? 0, 'floor'), bounce = requireFinite3D(options.bounce ?? 0.4, 'bounce');
|
|
95
|
+
const maxBounceSpeed = Math.max(1, Math.abs(Math.fround(bounce)));
|
|
96
|
+
const pullX = Math.abs(Math.fround(gravity[0])), pullY = Math.abs(Math.fround(gravity[1])), pullZ = Math.abs(Math.fround(gravity[2]));
|
|
97
|
+
const radius = requireFinite3D(options.radius ?? 0.5, 'radius'), extents = options.extents ?? [0.5, 0.5, 0.5];
|
|
98
|
+
const dl = Math.hypot(direction[0], direction[1], direction[2]);
|
|
99
|
+
if (dl < 1e-9 || drag < 0)
|
|
100
|
+
throw new World3DError('WORLD3D_INPUT_INVALID', 'direction and drag');
|
|
101
|
+
const dx = direction[0] / dl, dy = direction[1] / dl, dz = direction[2] / dl;
|
|
102
|
+
// Two axes perpendicular to the launch direction, for the cone.
|
|
103
|
+
const ax = Math.abs(dy) < 0.99 ? [dz, 0, -dx] : [1, 0, 0], al = Math.hypot(ax[0], ax[1], ax[2]), ux = ax[0] / al, uy = ax[1] / al, uz = ax[2] / al;
|
|
104
|
+
const vx = dy * uz - dz * uy, vy = dz * ux - dx * uz, vz = dx * uy - dy * ux;
|
|
105
|
+
this.loop = options.loop ?? true;
|
|
106
|
+
const emitOver = this.loop ? life[1] : requireFinite3D(options.duration ?? 0, 'duration');
|
|
107
|
+
this.duration = this.loop ? Infinity : emitOver + life[1];
|
|
108
|
+
const start = new Float32Array([1, 1, 1]), end = new Float32Array(3);
|
|
109
|
+
if (options.startColor !== undefined)
|
|
110
|
+
setColor3D(start, options.startColor);
|
|
111
|
+
end.set(start);
|
|
112
|
+
if (options.endColor !== undefined)
|
|
113
|
+
setColor3D(end, options.endColor);
|
|
114
|
+
const startOpacity = requireFinite3D(options.startOpacity ?? 1, 'startOpacity'), endOpacity = requireFinite3D(options.endOpacity ?? 1, 'endOpacity');
|
|
115
|
+
let seed = (options.seed ?? 0x9e3779b9) >>> 0;
|
|
116
|
+
const random = () => {
|
|
117
|
+
seed = (Math.imul(seed, 1664525) + 1013904223) >>> 0;
|
|
118
|
+
return seed / 4294967296;
|
|
119
|
+
};
|
|
120
|
+
const data = this.instanceMatrices, colors = (this.instanceColors = new Float32Array(count * 4));
|
|
121
|
+
let minX = Infinity, minY = Infinity, minZ = Infinity, maxX = -Infinity, maxY = -Infinity, maxZ = -Infinity, largest = 0;
|
|
122
|
+
const grow = (x, y, z) => {
|
|
123
|
+
minX = Math.min(minX, x);
|
|
124
|
+
minY = Math.min(minY, y);
|
|
125
|
+
minZ = Math.min(minZ, z);
|
|
126
|
+
maxX = Math.max(maxX, x);
|
|
127
|
+
maxY = Math.max(maxY, y);
|
|
128
|
+
maxZ = Math.max(maxZ, z);
|
|
129
|
+
};
|
|
130
|
+
for (let i = 0; i < count; i++) {
|
|
131
|
+
const o = i * 16;
|
|
132
|
+
let px = 0, py = 0, pz = 0;
|
|
133
|
+
if (shape === 'sphere') {
|
|
134
|
+
const z = random() * 2 - 1, turn = random() * Math.PI * 2, flat = Math.sqrt(1 - z * z), r = radius * Math.cbrt(random());
|
|
135
|
+
px = Math.cos(turn) * flat * r;
|
|
136
|
+
py = z * r;
|
|
137
|
+
pz = Math.sin(turn) * flat * r;
|
|
138
|
+
}
|
|
139
|
+
else if (shape === 'box') {
|
|
140
|
+
px = (random() * 2 - 1) * extents[0];
|
|
141
|
+
py = (random() * 2 - 1) * extents[1];
|
|
142
|
+
pz = (random() * 2 - 1) * extents[2];
|
|
143
|
+
}
|
|
144
|
+
else if (shape !== 'point')
|
|
145
|
+
throw new World3DError('WORLD3D_INPUT_INVALID', 'shape');
|
|
146
|
+
// A direction spread evenly over the cap of the cone.
|
|
147
|
+
const cosine = 1 - random() * (1 - Math.cos(Math.min(Math.max(spread, 0), Math.PI))), sine = Math.sqrt(Math.max(0, 1 - cosine * cosine)), turn = random() * Math.PI * 2;
|
|
148
|
+
const sideU = Math.cos(turn) * sine, sideV = Math.sin(turn) * sine, launch = speed[0] + (speed[1] - speed[0]) * random();
|
|
149
|
+
const lifetime = life[0] + (life[1] - life[0]) * random(), startSize = size[0] + (size[1] - size[0]) * random();
|
|
150
|
+
const wx = (dx * cosine + ux * sideU + vx * sideV) * launch, wy = (dy * cosine + uy * sideU + vy * sideV) * launch, wz = (dz * cosine + uz * sideU + vz * sideV) * launch;
|
|
151
|
+
data[o] = px;
|
|
152
|
+
data[o + 1] = py;
|
|
153
|
+
data[o + 2] = pz;
|
|
154
|
+
data[o + 3] = emitOver > 0 ? ((i + random()) / count) * emitOver : 0;
|
|
155
|
+
data[o + 4] = wx;
|
|
156
|
+
data[o + 5] = wy;
|
|
157
|
+
data[o + 6] = wz;
|
|
158
|
+
data[o + 7] = lifetime;
|
|
159
|
+
data[o + 8] = startSize;
|
|
160
|
+
data[o + 9] = startSize * endScale;
|
|
161
|
+
data[o + 10] = rotation[0] + (rotation[1] - rotation[0]) * random();
|
|
162
|
+
data[o + 11] = spin[0] + (spin[1] - spin[0]) * random();
|
|
163
|
+
data[o + 12] = 0;
|
|
164
|
+
data[o + 13] = 0;
|
|
165
|
+
data[o + 14] = 0;
|
|
166
|
+
data[o + 15] = 1;
|
|
167
|
+
colors[i * 4] = start[0];
|
|
168
|
+
colors[i * 4 + 1] = start[1];
|
|
169
|
+
colors[i * 4 + 2] = start[2];
|
|
170
|
+
colors[i * 4 + 3] = startOpacity;
|
|
171
|
+
if (hasFloor) {
|
|
172
|
+
// Bound both ballistic legs over the whole lifetime. At most one bounce
|
|
173
|
+
// scales the velocity, and the floor clamp stays within this extent.
|
|
174
|
+
const t = Math.max(data[o + 7], 1e-4), halfTimeSquared = 0.5 * t * t;
|
|
175
|
+
const reachX = maxBounceSpeed * (Math.abs(data[o + 4]) * t + pullX * halfTimeSquared);
|
|
176
|
+
const reachY = maxBounceSpeed * (Math.abs(data[o + 5]) * t + pullY * halfTimeSquared);
|
|
177
|
+
const reachZ = maxBounceSpeed * (Math.abs(data[o + 6]) * t + pullZ * halfTimeSquared);
|
|
178
|
+
grow(data[o] - reachX, data[o + 1] - reachY, data[o + 2] - reachZ);
|
|
179
|
+
grow(data[o] + reachX, data[o + 1] + reachY, data[o + 2] + reachZ);
|
|
180
|
+
}
|
|
181
|
+
else {
|
|
182
|
+
// Sample the ordinary drag path as before.
|
|
183
|
+
for (let step = 0; step <= 4; step++) {
|
|
184
|
+
const t = (lifetime * step) / 4, travel = drag > 1e-4 ? (1 - Math.exp(-drag * t)) / drag : t;
|
|
185
|
+
grow(px + wx * travel + gravity[0] * 0.5 * t * t, py + wy * travel + gravity[1] * 0.5 * t * t, pz + wz * travel + gravity[2] * 0.5 * t * t);
|
|
186
|
+
}
|
|
187
|
+
}
|
|
188
|
+
largest = Math.max(largest, startSize, startSize * endScale);
|
|
189
|
+
}
|
|
190
|
+
if (count > 0) {
|
|
191
|
+
this.#sphere[0] = (minX + maxX) / 2;
|
|
192
|
+
this.#sphere[1] = (minY + maxY) / 2;
|
|
193
|
+
this.#sphere[2] = (minZ + maxZ) / 2;
|
|
194
|
+
this.#sphere[3] = Math.hypot(maxX - minX, maxY - minY, maxZ - minZ) / 2 + largest;
|
|
195
|
+
}
|
|
196
|
+
else
|
|
197
|
+
this.#sphere[3] = -1;
|
|
198
|
+
this.instanceVersion++;
|
|
199
|
+
this.space = options.space ?? 'local';
|
|
200
|
+
if (this.space !== 'local' && this.space !== 'world')
|
|
201
|
+
throw new World3DError('WORLD3D_INPUT_INVALID', 'space');
|
|
202
|
+
this.sorted = options.sorted ?? false;
|
|
203
|
+
this.#source = data.slice();
|
|
204
|
+
this.#cycle = this.space === 'world' ? new Float64Array(count).fill(NaN) : undefined;
|
|
205
|
+
this.#order = new Uint32Array(count);
|
|
206
|
+
this.#depth = new Float32Array(count);
|
|
207
|
+
// Particles left in the world can be anywhere the emitter has been.
|
|
208
|
+
if (this.space === 'world')
|
|
209
|
+
this.frustumCulled = false;
|
|
210
|
+
const fadeIn = requireFinite3D(options.fadeIn ?? 0.1, 'fadeIn'), fadeOut = requireFinite3D(options.fadeOut ?? 0.3, 'fadeOut');
|
|
211
|
+
// time, loop flag, fade in, fade out | gravity, drag | end color and opacity.
|
|
212
|
+
this.#uniforms = new Float32Array([
|
|
213
|
+
0,
|
|
214
|
+
this.loop ? 1 : 0,
|
|
215
|
+
fadeIn,
|
|
216
|
+
fadeOut,
|
|
217
|
+
gravity[0],
|
|
218
|
+
gravity[1],
|
|
219
|
+
gravity[2],
|
|
220
|
+
drag,
|
|
221
|
+
end[0],
|
|
222
|
+
end[1],
|
|
223
|
+
end[2],
|
|
224
|
+
endOpacity,
|
|
225
|
+
this.space === 'world' ? 1 : 0,
|
|
226
|
+
hasFloor ? 1 : 0,
|
|
227
|
+
floor,
|
|
228
|
+
bounce
|
|
229
|
+
]);
|
|
230
|
+
const shader = Object.freeze({ key: 'world3d-gpu-particles', uniforms: this.#uniforms });
|
|
231
|
+
material.shader = shader;
|
|
232
|
+
material.softness = requireFinite3D(options.softness ?? 0, 'softness');
|
|
233
|
+
}
|
|
234
|
+
/** Seconds since the emitter started. */
|
|
235
|
+
get time() {
|
|
236
|
+
return this.#uniforms[0];
|
|
237
|
+
}
|
|
238
|
+
set time(value) {
|
|
239
|
+
this.#uniforms[0] = requireFinite3D(value, 'time');
|
|
240
|
+
}
|
|
241
|
+
/** True once every particle of a burst has died. */
|
|
242
|
+
get isFinished() {
|
|
243
|
+
return this.#uniforms[0] > this.duration;
|
|
244
|
+
}
|
|
245
|
+
update(deltaSeconds) {
|
|
246
|
+
this.#uniforms[0] = this.#uniforms[0] + requireFinite3D(deltaSeconds, 'deltaSeconds');
|
|
247
|
+
if (this.#cycle)
|
|
248
|
+
this.respawn();
|
|
249
|
+
}
|
|
250
|
+
/** Where a particle is now, in the emitter's space, or in the world for world-space particles; false while it is not alive. */
|
|
251
|
+
positionAt(index, out) {
|
|
252
|
+
if (!Number.isSafeInteger(index) || index < 0 || index >= this.capacity)
|
|
253
|
+
throw new World3DError('WORLD3D_INPUT_INVALID', 'particle index');
|
|
254
|
+
return this.positionInSlot(this.slotOf(index), out);
|
|
255
|
+
}
|
|
256
|
+
positionInSlot(slot, out) {
|
|
257
|
+
const d = this.instanceMatrices, o = slot * 16, u = this.#uniforms, life = Math.max(d[o + 7], 1e-4);
|
|
258
|
+
let t = u[0] - d[o + 3], alive = true;
|
|
259
|
+
if (this.loop) {
|
|
260
|
+
t %= life;
|
|
261
|
+
if (t < 0)
|
|
262
|
+
t += life;
|
|
263
|
+
}
|
|
264
|
+
else
|
|
265
|
+
alive = t >= 0 && t <= life;
|
|
266
|
+
const drag = u[7], travel = drag > 1e-4 && u[13] < 0.5 ? (1 - Math.exp(-drag * t)) / drag : t;
|
|
267
|
+
out[0] = d[o] + d[o + 4] * travel + u[4] * 0.5 * t * t;
|
|
268
|
+
out[1] = d[o + 1] + d[o + 5] * travel + u[5] * 0.5 * t * t;
|
|
269
|
+
out[2] = d[o + 2] + d[o + 6] * travel + u[6] * 0.5 * t * t;
|
|
270
|
+
if (u[13] > 0.5) {
|
|
271
|
+
// The same single bounce the vertex stage computes.
|
|
272
|
+
const a = 0.5 * u[5], b = d[o + 5], c = d[o + 1] - u[14];
|
|
273
|
+
let hit = -1;
|
|
274
|
+
if (c === 0 && (b < 0 || (b === 0 && a < 0)))
|
|
275
|
+
hit = 0;
|
|
276
|
+
else if (Math.abs(a) > 1e-6) {
|
|
277
|
+
const discriminant = b * b - 4 * a * c;
|
|
278
|
+
if (discriminant > 0) {
|
|
279
|
+
// Use the downward crossing, with the equivalent form that avoids cancellation.
|
|
280
|
+
const root = Math.sqrt(discriminant);
|
|
281
|
+
hit = b < 0 ? (2 * c) / (root - b) : (-b - root) / (2 * a);
|
|
282
|
+
}
|
|
283
|
+
}
|
|
284
|
+
else if (b < 0)
|
|
285
|
+
hit = -c / b;
|
|
286
|
+
if (c >= 0 && hit >= 0 && t >= hit) {
|
|
287
|
+
const k = u[15], since = t - hit;
|
|
288
|
+
for (let axis = 0; axis < 3; axis++) {
|
|
289
|
+
const landed = d[o + axis] + d[o + 4 + axis] * hit + u[4 + axis] * 0.5 * hit * hit, away = (d[o + 4 + axis] + u[4 + axis] * hit) * (axis === 1 ? -k : k);
|
|
290
|
+
out[axis] = landed + away * since + u[4 + axis] * 0.5 * since * since;
|
|
291
|
+
}
|
|
292
|
+
out[1] = Math.max(out[1], u[14]);
|
|
293
|
+
}
|
|
294
|
+
}
|
|
295
|
+
return alive;
|
|
296
|
+
}
|
|
297
|
+
/** Start a burst again from its first particle. */
|
|
298
|
+
restart() {
|
|
299
|
+
this.#uniforms[0] = 0;
|
|
300
|
+
this.#cycle?.fill(NaN);
|
|
301
|
+
}
|
|
302
|
+
slotOf(index) {
|
|
303
|
+
return this.#slots ? this.#slots[index] : index;
|
|
304
|
+
}
|
|
305
|
+
// Once sorted: the slot each particle currently sits in.
|
|
306
|
+
#slots;
|
|
307
|
+
/** World mode: a particle starting a new life takes the emitter's place and heading of this moment. */
|
|
308
|
+
respawn() {
|
|
309
|
+
const cycle = this.#cycle, source = this.#source, out = this.instanceMatrices, time = this.#uniforms[0], m = this.matrixWorld;
|
|
310
|
+
this.updateWorldMatrix();
|
|
311
|
+
let changed = false;
|
|
312
|
+
for (let i = 0; i < this.capacity; i++) {
|
|
313
|
+
const o = i * 16, since = time - source[o + 3], life = Math.max(source[o + 7], 1e-4), now = this.loop ? Math.floor(since / life) : since >= 0 ? 0 : -1;
|
|
314
|
+
if (now === cycle[i])
|
|
315
|
+
continue;
|
|
316
|
+
cycle[i] = now;
|
|
317
|
+
const x = source[o], y = source[o + 1], z = source[o + 2], vx = source[o + 4], vy = source[o + 5], vz = source[o + 6], to = this.slotOf(i) * 16;
|
|
318
|
+
out[to] = m[0] * x + m[4] * y + m[8] * z + m[12];
|
|
319
|
+
out[to + 1] = m[1] * x + m[5] * y + m[9] * z + m[13];
|
|
320
|
+
out[to + 2] = m[2] * x + m[6] * y + m[10] * z + m[14];
|
|
321
|
+
out[to + 4] = m[0] * vx + m[4] * vy + m[8] * vz;
|
|
322
|
+
out[to + 5] = m[1] * vx + m[5] * vy + m[9] * vz;
|
|
323
|
+
out[to + 6] = m[2] * vx + m[6] * vy + m[10] * vz;
|
|
324
|
+
changed = true;
|
|
325
|
+
}
|
|
326
|
+
if (changed)
|
|
327
|
+
this.instanceVersion++;
|
|
328
|
+
}
|
|
329
|
+
/** Before a draw: reorder the drawn arrays so the farthest particle comes first. */
|
|
330
|
+
arrange(camera) {
|
|
331
|
+
const n = this.capacity, order = this.#order, depth = this.#depth, view = camera.viewMatrix, world = this.matrixWorld, point = [0, 0, 0];
|
|
332
|
+
if (this.#sorting === undefined) {
|
|
333
|
+
for (let i = 0; i < n; i++)
|
|
334
|
+
order[i] = i;
|
|
335
|
+
this.#sorting = { data: new Float32Array(n * 16), colors: new Float32Array(n * 4), next: new Uint32Array(n) };
|
|
336
|
+
}
|
|
337
|
+
const scratch = this.#sorting, local = this.space === 'local';
|
|
338
|
+
// Depth of every slot as it stands, then the slots in far-to-near order.
|
|
339
|
+
for (let slot = 0; slot < n; slot++) {
|
|
340
|
+
this.positionInSlot(slot, point);
|
|
341
|
+
let x = point[0], y = point[1], z = point[2];
|
|
342
|
+
if (local) {
|
|
343
|
+
const lx = x, ly = y, lz = z;
|
|
344
|
+
x = world[0] * lx + world[4] * ly + world[8] * lz + world[12];
|
|
345
|
+
y = world[1] * lx + world[5] * ly + world[9] * lz + world[13];
|
|
346
|
+
z = world[2] * lx + world[6] * ly + world[10] * lz + world[14];
|
|
347
|
+
}
|
|
348
|
+
depth[slot] = view[2] * x + view[6] * y + view[10] * z + view[14];
|
|
349
|
+
}
|
|
350
|
+
const slots = scratch.next;
|
|
351
|
+
for (let i = 0; i < n; i++)
|
|
352
|
+
slots[i] = i;
|
|
353
|
+
slots.sort((a, b) => depth[a] - depth[b]);
|
|
354
|
+
this.reorderSlots(slots);
|
|
355
|
+
// Convert the source slots to logical indices for the next frame.
|
|
356
|
+
for (let to = 0; to < n; to++)
|
|
357
|
+
slots[to] = order[slots[to]];
|
|
358
|
+
order.set(scratch.next);
|
|
359
|
+
const where = (this.#slots ??= new Uint32Array(n));
|
|
360
|
+
for (let slot = 0; slot < n; slot++)
|
|
361
|
+
where[order[slot]] = slot;
|
|
362
|
+
this.instanceVersion++;
|
|
363
|
+
}
|
|
364
|
+
reorderSlots(slots) {
|
|
365
|
+
const scratch = this.#sorting, data = this.instanceMatrices, colors = this.instanceColors;
|
|
366
|
+
scratch.data.set(data);
|
|
367
|
+
if (colors)
|
|
368
|
+
scratch.colors.set(colors);
|
|
369
|
+
for (let to = 0; to < slots.length; to++) {
|
|
370
|
+
const from = slots[to];
|
|
371
|
+
data.set(scratch.data.subarray(from * 16, from * 16 + 16), to * 16);
|
|
372
|
+
if (colors)
|
|
373
|
+
colors.set(scratch.colors.subarray(from * 4, from * 4 + 4), to * 4);
|
|
374
|
+
}
|
|
375
|
+
}
|
|
376
|
+
restoreOrder() {
|
|
377
|
+
if (!this.#slots)
|
|
378
|
+
return;
|
|
379
|
+
this.reorderSlots(this.#slots);
|
|
380
|
+
for (let i = 0; i < this.capacity; i++)
|
|
381
|
+
this.#order[i] = i;
|
|
382
|
+
this.#slots = undefined;
|
|
383
|
+
this.instanceVersion++;
|
|
384
|
+
}
|
|
385
|
+
#sorting;
|
|
386
|
+
/** Everywhere a particle can be during its life, in world space. */
|
|
387
|
+
get worldBoundingSphere() {
|
|
388
|
+
return sphereTransform(this.#worldSphere, this.#sphere, this.matrixWorld);
|
|
389
|
+
}
|
|
390
|
+
/** Release the geometry and the material. */
|
|
391
|
+
dispose() {
|
|
392
|
+
this.geometry.dispose();
|
|
393
|
+
if (!Array.isArray(this.material))
|
|
394
|
+
this.material.dispose();
|
|
395
|
+
}
|
|
396
|
+
}
|
|
397
|
+
/** Makes particles simulated on the GPU. */
|
|
398
|
+
export function createGpuParticles3D(options = {}) {
|
|
399
|
+
return new GpuParticles3D(options);
|
|
400
|
+
}
|
|
401
|
+
//# sourceMappingURL=GpuParticles3D.js.map
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import { CubeTexture3D } from './Texture3D.js';
|
|
2
|
+
import type { TexturePixels3D } from './Texture3D.js';
|
|
3
|
+
/** The largest HDR image read. */
|
|
4
|
+
export declare const HDR3D_LIMITS: Readonly<{
|
|
5
|
+
readonly maxEdge: 16384;
|
|
6
|
+
readonly maxPixels: 67108864;
|
|
7
|
+
}>;
|
|
8
|
+
/** Linear RGB floats, three per pixel, top row first. */
|
|
9
|
+
export interface HdrImage3D {
|
|
10
|
+
readonly width: number;
|
|
11
|
+
readonly height: number;
|
|
12
|
+
readonly data: Float32Array;
|
|
13
|
+
}
|
|
14
|
+
/** Decode a Radiance .hdr file (flat or run-length encoded, -Y +X orientation). */
|
|
15
|
+
export declare function parseRgbe3D(bytes: Uint8Array): HdrImage3D;
|
|
16
|
+
/** How an equirectangular image is turned into a cube: its size, exposure and brightest value. */
|
|
17
|
+
export interface EquirectOptions3D {
|
|
18
|
+
/** Edge of each cube face in texels. */
|
|
19
|
+
readonly size?: number;
|
|
20
|
+
/** Multiplier applied to linear values before they are stored. */
|
|
21
|
+
readonly exposure?: number;
|
|
22
|
+
/**
|
|
23
|
+
* Largest linear value kept. Brighter texels are compressed toward it, so
|
|
24
|
+
* a very bright sun does not clip to a hard white disc.
|
|
25
|
+
*/
|
|
26
|
+
readonly maxValue?: number;
|
|
27
|
+
}
|
|
28
|
+
/**
|
|
29
|
+
* Build a cube texture from an equirectangular panorama. The source is either
|
|
30
|
+
* linear floats (three per pixel, as parseRgbe3D returns) or sRGB bytes (four
|
|
31
|
+
* per pixel). Faces are stored as 8-bit sRGB after exposure and soft
|
|
32
|
+
* compression of highlights.
|
|
33
|
+
*/
|
|
34
|
+
export declare function createCubeTextureFromEquirect3D(image: HdrImage3D | TexturePixels3D, options?: EquirectOptions3D): CubeTexture3D;
|
|
35
|
+
//# sourceMappingURL=Hdr3D.d.ts.map
|