@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,112 @@
|
|
|
1
|
+
import { createAssetType } from '@egret/runtime';
|
|
2
|
+
import { World3DError } from '../../rendering/world3d/core3D.js';
|
|
3
|
+
import { Object3D } from '../../rendering/world3d/Object3D.js';
|
|
4
|
+
import { deserializeScene3D } from '../../rendering/world3d/Serialize3D.js';
|
|
5
|
+
import { CubeTexture3D, Texture3D } from '../../rendering/world3d/Texture3D.js';
|
|
6
|
+
import { loadCubeTexture3D, loadGltfFromUrl3D, loadTexture3D } from './loaders3D.js';
|
|
7
|
+
function isRecord(value) {
|
|
8
|
+
return typeof value === 'object' && value !== null;
|
|
9
|
+
}
|
|
10
|
+
/** A loaded glTF file. The reference id is the file URL. */
|
|
11
|
+
export const GLTF_ASSET_3D = createAssetType('world3d.gltf', (value) => isRecord(value) &&
|
|
12
|
+
value['scene'] instanceof Object3D &&
|
|
13
|
+
Array.isArray(value['animations']) &&
|
|
14
|
+
typeof value['dispose'] === 'function');
|
|
15
|
+
/** A 2D texture loaded from an image or KTX2 file. The reference id is the file URL. */
|
|
16
|
+
export const TEXTURE_ASSET_3D = createAssetType('world3d.texture', (value) => value instanceof Texture3D);
|
|
17
|
+
/**
|
|
18
|
+
* A cube texture. The reference id is a URL containing `{face}`, replaced by
|
|
19
|
+
* px, nx, py, ny, pz and nz in turn.
|
|
20
|
+
*/
|
|
21
|
+
export const CUBE_TEXTURE_ASSET_3D = createAssetType('world3d.cubeTexture', (value) => value instanceof CubeTexture3D);
|
|
22
|
+
/** A scene document written by serializeScene3D. The reference id is the JSON file URL. */
|
|
23
|
+
export const SCENE_ASSET_3D = createAssetType('world3d.scene', (value) => isRecord(value) &&
|
|
24
|
+
value['root'] instanceof Object3D &&
|
|
25
|
+
Array.isArray(value['geometries']) &&
|
|
26
|
+
typeof value['dispose'] === 'function');
|
|
27
|
+
const CUBE_FACES = ['px', 'nx', 'py', 'ny', 'pz', 'nz'];
|
|
28
|
+
/** Mirror an Engine cancellation signal onto a browser AbortSignal for fetch. */
|
|
29
|
+
function abortSignal(signal) {
|
|
30
|
+
const controller = new AbortController();
|
|
31
|
+
const abort = () => controller.abort(signal.reason);
|
|
32
|
+
if (signal.aborted)
|
|
33
|
+
abort();
|
|
34
|
+
else
|
|
35
|
+
signal.addEventListener('abort', abort, { once: true });
|
|
36
|
+
return { signal: controller.signal, detach: () => signal.removeEventListener('abort', abort) };
|
|
37
|
+
}
|
|
38
|
+
async function guarded(context, load) {
|
|
39
|
+
const bridge = abortSignal(context.signal);
|
|
40
|
+
try {
|
|
41
|
+
const value = await load(bridge.signal);
|
|
42
|
+
// A load that finished after cancellation must not leak its resources.
|
|
43
|
+
if (context.signal.aborted) {
|
|
44
|
+
value.dispose();
|
|
45
|
+
throw new World3DError('WORLD3D_RESOURCE_FAILED', 'load cancelled', context.signal.reason);
|
|
46
|
+
}
|
|
47
|
+
return value;
|
|
48
|
+
}
|
|
49
|
+
finally {
|
|
50
|
+
bridge.detach();
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
/**
|
|
54
|
+
* Register the World3D asset providers on an AssetManager. Call once per
|
|
55
|
+
* Engine, then acquire with `assets.acquire(createAssetRef(GLTF_ASSET_3D, url))`.
|
|
56
|
+
*/
|
|
57
|
+
export function registerWorld3DAssets(assets, options = {}) {
|
|
58
|
+
const url = (ref) => (options.resolveUrl ? options.resolveUrl(ref.id) : ref.id);
|
|
59
|
+
const limits = options.maxBytes === undefined ? {} : { maxBytes: options.maxBytes };
|
|
60
|
+
const ktx2 = options.transcodeKtx2 ? { transcodeKtx2: options.transcodeKtx2 } : {};
|
|
61
|
+
const dispose = (value) => value.dispose();
|
|
62
|
+
assets.register(GLTF_ASSET_3D, {
|
|
63
|
+
load: (ref, context) => guarded(context, signal => loadGltfFromUrl3D(url(ref), {
|
|
64
|
+
signal,
|
|
65
|
+
...limits,
|
|
66
|
+
...ktx2,
|
|
67
|
+
...(options.decodeMeshopt ? { decodeMeshopt: options.decodeMeshopt } : {}),
|
|
68
|
+
...(options.decodeDraco ? { decodeDraco: options.decodeDraco } : {})
|
|
69
|
+
})),
|
|
70
|
+
dispose
|
|
71
|
+
});
|
|
72
|
+
assets.register(TEXTURE_ASSET_3D, {
|
|
73
|
+
load: (ref, context) => guarded(context, signal => loadTexture3D(url(ref), { ...options.texture, signal, ...limits, ...ktx2 })),
|
|
74
|
+
dispose
|
|
75
|
+
});
|
|
76
|
+
assets.register(CUBE_TEXTURE_ASSET_3D, {
|
|
77
|
+
load: (ref, context) => {
|
|
78
|
+
const template = url(ref);
|
|
79
|
+
if (!template.includes('{face}'))
|
|
80
|
+
return Promise.reject(new World3DError('WORLD3D_INPUT_INVALID', 'cube texture id needs {face}: ' + ref.id));
|
|
81
|
+
return guarded(context, signal => loadCubeTexture3D(CUBE_FACES.map(face => template.replace('{face}', face)), { ...options.cubeTexture, signal, ...limits }));
|
|
82
|
+
},
|
|
83
|
+
dispose
|
|
84
|
+
});
|
|
85
|
+
assets.register(SCENE_ASSET_3D, {
|
|
86
|
+
load: (ref, context) => guarded(context, async (signal) => {
|
|
87
|
+
const target = url(ref);
|
|
88
|
+
let response;
|
|
89
|
+
try {
|
|
90
|
+
response = await fetch(target, { signal });
|
|
91
|
+
}
|
|
92
|
+
catch (cause) {
|
|
93
|
+
throw new World3DError('WORLD3D_RESOURCE_FAILED', target, cause);
|
|
94
|
+
}
|
|
95
|
+
if (!response.ok)
|
|
96
|
+
throw new World3DError('WORLD3D_RESOURCE_FAILED', target + ' (HTTP ' + response.status + ')');
|
|
97
|
+
const text = await response.text();
|
|
98
|
+
if (options.maxBytes !== undefined && text.length > options.maxBytes)
|
|
99
|
+
throw new World3DError('WORLD3D_BUDGET', target);
|
|
100
|
+
let saved;
|
|
101
|
+
try {
|
|
102
|
+
saved = JSON.parse(text);
|
|
103
|
+
}
|
|
104
|
+
catch (cause) {
|
|
105
|
+
throw new World3DError('WORLD3D_INPUT_INVALID', 'scene document: ' + target, cause);
|
|
106
|
+
}
|
|
107
|
+
return deserializeScene3D(saved, options.resolveTexture ? { resolveTexture: options.resolveTexture } : {});
|
|
108
|
+
}),
|
|
109
|
+
dispose
|
|
110
|
+
});
|
|
111
|
+
}
|
|
112
|
+
//# sourceMappingURL=assets3D.js.map
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
import type { Camera3D } from '../../rendering/world3d/Camera3D.js';
|
|
2
|
+
import { type CustomPost3D } from './post3D.js';
|
|
3
|
+
/** An atmosphere to make: its fog's color, density and height, and its light shafts. */
|
|
4
|
+
export interface AtmosphereOptions3D {
|
|
5
|
+
/** Fog color, 0xRRGGBB. Default a pale blue-grey. */
|
|
6
|
+
readonly fogColor?: number;
|
|
7
|
+
/** Fog thickness per world unit at `fogHeight`; 0 turns fog off. Default 0.01. */
|
|
8
|
+
readonly fogDensity?: number;
|
|
9
|
+
/** World height at which the fog has its stated density. Default 0. */
|
|
10
|
+
readonly fogHeight?: number;
|
|
11
|
+
/** How quickly the fog thins with height, per world unit; 0 gives uniform fog. Default 0.08. */
|
|
12
|
+
readonly fogFalloff?: number;
|
|
13
|
+
/**
|
|
14
|
+
* How much of the fog lies over the sky itself, from 0 (a clear sky, fog only on what stands before it) to 1 (the
|
|
15
|
+
* sky fogged as if it were the far plane, which greys the horizon). Default 1, as before. Fixed when made.
|
|
16
|
+
*/
|
|
17
|
+
readonly skyFog?: number;
|
|
18
|
+
/** Brightness of the light shafts; 0 turns them off. Default 0.6. */
|
|
19
|
+
readonly shaftIntensity?: number;
|
|
20
|
+
/** How far the shafts reach across the screen, 0 to 1. Default 0.6. */
|
|
21
|
+
readonly shaftLength?: number;
|
|
22
|
+
}
|
|
23
|
+
/**
|
|
24
|
+
* Height fog and light shafts for `renderer.postProcess.custom`. Call
|
|
25
|
+
* `update(camera, sunDirection)` every frame before rendering: the hook needs
|
|
26
|
+
* to know where the camera and the sun are.
|
|
27
|
+
*/
|
|
28
|
+
export declare class Atmosphere3D {
|
|
29
|
+
#private;
|
|
30
|
+
readonly post: CustomPost3D;
|
|
31
|
+
/** How much of the fog lies over the sky, as given when it was made. */
|
|
32
|
+
readonly skyFog: number;
|
|
33
|
+
constructor(options?: AtmosphereOptions3D);
|
|
34
|
+
get fogDensity(): number;
|
|
35
|
+
set fogDensity(value: number);
|
|
36
|
+
get fogFalloff(): number;
|
|
37
|
+
set fogFalloff(value: number);
|
|
38
|
+
get fogHeight(): number;
|
|
39
|
+
set fogHeight(value: number);
|
|
40
|
+
get shaftIntensity(): number;
|
|
41
|
+
set shaftIntensity(value: number);
|
|
42
|
+
get shaftLength(): number;
|
|
43
|
+
set shaftLength(value: number);
|
|
44
|
+
/** Linear RGB fog color. */
|
|
45
|
+
setFogColor(r: number, g: number, b: number): void;
|
|
46
|
+
/**
|
|
47
|
+
* Refresh the camera and sun data. `sunDirection` is the direction the
|
|
48
|
+
* sunlight travels in, as a directional light's world direction; pass
|
|
49
|
+
* undefined when there is no sun, which leaves only the fog.
|
|
50
|
+
*/
|
|
51
|
+
update(camera: Camera3D, sunDirection?: ArrayLike<number>): void;
|
|
52
|
+
private amount;
|
|
53
|
+
}
|
|
54
|
+
/** Makes height fog and light shafts for a scene. */
|
|
55
|
+
export declare function createAtmosphere3D(options?: AtmosphereOptions3D): Atmosphere3D;
|
|
56
|
+
//# sourceMappingURL=atmosphere3D.d.ts.map
|
|
@@ -0,0 +1,193 @@
|
|
|
1
|
+
import { World3DError, requireFinite3D } from '../../rendering/world3d/core3D.js';
|
|
2
|
+
import { colorFromHex } from '../../rendering/world3d/math3D.js';
|
|
3
|
+
import { createCustomPost3D } from './post3D.js';
|
|
4
|
+
// uniforms: [0] fog rgb, density; [1] falloff, base height, sky distance, shaft intensity;
|
|
5
|
+
// [2] sun uv, sun visibility, shaft length; [3] the camera's world Y axis in view space, camera height.
|
|
6
|
+
const GLSL = (skyFog) => /* glsl */ `
|
|
7
|
+
vec3 customPost(vec3 color, vec2 uv) {
|
|
8
|
+
vec4 fog = uPostCustom[0], shape = uPostCustom[1], sun = uPostCustom[2], up = uPostCustom[3];
|
|
9
|
+
vec3 view = unprojectDepth(uv, rawDepth(uv));
|
|
10
|
+
float reach = length(view);
|
|
11
|
+
if (fog.a > 0.0) {
|
|
12
|
+
// Density falls off exponentially with height; its integral along the ray has a closed form.
|
|
13
|
+
float rise = dot(up.xyz, view), slope = shape.x * rise;
|
|
14
|
+
float thin = abs(slope) > 0.0001 ? (1.0 - exp(-slope)) / slope : 1.0;
|
|
15
|
+
float depth = fog.a * exp(-shape.x * (up.w - shape.y)) * reach * thin;
|
|
16
|
+
// The sky lies on the far plane: it takes its own share of the fog.
|
|
17
|
+
depth *= mix(1.0, ${skyFog}, step(shape.z, reach));
|
|
18
|
+
color = mix(fog.rgb, color, exp(-max(depth, 0.0)));
|
|
19
|
+
}
|
|
20
|
+
if (shape.w > 0.0 && sun.z > 0.0) {
|
|
21
|
+
// March from the pixel toward the sun, gathering how much open sky lies on the way.
|
|
22
|
+
vec2 stride = (sun.xy - uv) * (sun.w / 24.0);
|
|
23
|
+
// Counted from the top row, as the other backend does, so both dither alike.
|
|
24
|
+
vec2 pixel = vec2(uv.x, 1.0 - uv.y) * vec2(textureSize(uDepth, 0));
|
|
25
|
+
float jitter = fract(52.9829189 * fract(dot(pixel, vec2(0.06711056, 0.00583715))));
|
|
26
|
+
vec2 at = uv + stride * jitter;
|
|
27
|
+
float light = 0.0, weight = 1.0;
|
|
28
|
+
for (int i = 0; i < 24; i++) {
|
|
29
|
+
at += stride;
|
|
30
|
+
float open = step(shape.z, sceneDepth(clamp(at, vec2(0.001), vec2(0.999))));
|
|
31
|
+
float nearSun = 1.0 - smoothstep(0.0, 0.7, distance(at, sun.xy));
|
|
32
|
+
light += open * nearSun * weight;
|
|
33
|
+
weight *= 0.95;
|
|
34
|
+
}
|
|
35
|
+
color += vec3(1.0, 0.93, 0.78) * (light / 24.0 * shape.w * sun.z);
|
|
36
|
+
}
|
|
37
|
+
return color;
|
|
38
|
+
}
|
|
39
|
+
`;
|
|
40
|
+
const WGSL = (skyFog) => /* wgsl */ `
|
|
41
|
+
fn customPost(color: vec3f, uv: vec2f) -> vec3f {
|
|
42
|
+
let fog = params.custom[0];
|
|
43
|
+
let shape = params.custom[1];
|
|
44
|
+
// Texture rows run top-down here, so the sun's height on screen is flipped.
|
|
45
|
+
let sun = vec4f(params.custom[2].x, 1.0 - params.custom[2].y, params.custom[2].zw);
|
|
46
|
+
let up = params.custom[3];
|
|
47
|
+
var result = color;
|
|
48
|
+
let view = unprojectDepth(uv, rawDepth(uv));
|
|
49
|
+
let reach = length(view);
|
|
50
|
+
if (fog.a > 0.0) {
|
|
51
|
+
// Density falls off exponentially with height; its integral along the ray has a closed form.
|
|
52
|
+
let rise = dot(up.xyz, view);
|
|
53
|
+
let slope = shape.x * rise;
|
|
54
|
+
var thin = 1.0;
|
|
55
|
+
if (abs(slope) > 0.0001) { thin = (1.0 - exp(-slope)) / slope; }
|
|
56
|
+
let depth = fog.a * exp(-shape.x * (up.w - shape.y)) * reach * thin * mix(1.0, ${skyFog}, step(shape.z, reach));
|
|
57
|
+
result = mix(fog.rgb, result, exp(-max(depth, 0.0)));
|
|
58
|
+
}
|
|
59
|
+
if (shape.w > 0.0 && sun.z > 0.0) {
|
|
60
|
+
// March from the pixel toward the sun, gathering how much open sky lies on the way.
|
|
61
|
+
let size = vec2f(textureDimensions(depthTexture));
|
|
62
|
+
let stride = (sun.xy - uv) * (sun.w / 24.0);
|
|
63
|
+
let jitter = fract(52.9829189 * fract(dot(uv * size, vec2f(0.06711056, 0.00583715))));
|
|
64
|
+
var at = uv + stride * jitter;
|
|
65
|
+
var light = 0.0;
|
|
66
|
+
var weight = 1.0;
|
|
67
|
+
for (var i = 0; i < 24; i++) {
|
|
68
|
+
at += stride;
|
|
69
|
+
let open = step(shape.z, sceneDepth(clamp(at, vec2f(0.001), vec2f(0.999))));
|
|
70
|
+
let nearSun = 1.0 - smoothstep(0.0, 0.7, distance(at, sun.xy));
|
|
71
|
+
light += open * nearSun * weight;
|
|
72
|
+
weight *= 0.95;
|
|
73
|
+
}
|
|
74
|
+
result += vec3f(1.0, 0.93, 0.78) * (light / 24.0 * shape.w * sun.z);
|
|
75
|
+
}
|
|
76
|
+
return result;
|
|
77
|
+
}
|
|
78
|
+
`;
|
|
79
|
+
/**
|
|
80
|
+
* Height fog and light shafts for `renderer.postProcess.custom`. Call
|
|
81
|
+
* `update(camera, sunDirection)` every frame before rendering: the hook needs
|
|
82
|
+
* to know where the camera and the sun are.
|
|
83
|
+
*/
|
|
84
|
+
export class Atmosphere3D {
|
|
85
|
+
post;
|
|
86
|
+
/** How much of the fog lies over the sky, as given when it was made. */
|
|
87
|
+
skyFog;
|
|
88
|
+
#scratch = [0, 0, 0];
|
|
89
|
+
constructor(options = {}) {
|
|
90
|
+
const sky = options.skyFog ?? 1;
|
|
91
|
+
if (typeof sky !== 'number' || !(sky >= 0 && sky <= 1))
|
|
92
|
+
throw new World3DError('WORLD3D_INPUT_INVALID', 'skyFog');
|
|
93
|
+
// A clear sky is a constant of the program: the sixteen numbers of the hook are all in use.
|
|
94
|
+
const constant = sky.toFixed(4);
|
|
95
|
+
this.skyFog = Number(constant);
|
|
96
|
+
this.post = createCustomPost3D({
|
|
97
|
+
key: sky === 1 ? 'world3d-atmosphere' : 'world3d-atmosphere-sky' + constant,
|
|
98
|
+
glsl: GLSL(constant),
|
|
99
|
+
wgsl: WGSL(constant)
|
|
100
|
+
});
|
|
101
|
+
colorFromHex(this.post.uniforms, options.fogColor ?? 0xb4c4d4);
|
|
102
|
+
this.fogDensity = options.fogDensity ?? 0.01;
|
|
103
|
+
this.fogHeight = options.fogHeight ?? 0;
|
|
104
|
+
this.fogFalloff = options.fogFalloff ?? 0.08;
|
|
105
|
+
this.shaftIntensity = options.shaftIntensity ?? 0.6;
|
|
106
|
+
this.shaftLength = options.shaftLength ?? 0.6;
|
|
107
|
+
}
|
|
108
|
+
get fogDensity() {
|
|
109
|
+
return this.post.uniforms[3];
|
|
110
|
+
}
|
|
111
|
+
set fogDensity(value) {
|
|
112
|
+
this.post.uniforms[3] = this.amount(value, 'fogDensity');
|
|
113
|
+
}
|
|
114
|
+
get fogFalloff() {
|
|
115
|
+
return this.post.uniforms[4];
|
|
116
|
+
}
|
|
117
|
+
set fogFalloff(value) {
|
|
118
|
+
this.post.uniforms[4] = this.amount(value, 'fogFalloff');
|
|
119
|
+
}
|
|
120
|
+
get fogHeight() {
|
|
121
|
+
return this.post.uniforms[5];
|
|
122
|
+
}
|
|
123
|
+
set fogHeight(value) {
|
|
124
|
+
this.post.uniforms[5] = requireFinite3D(value, 'fogHeight');
|
|
125
|
+
}
|
|
126
|
+
get shaftIntensity() {
|
|
127
|
+
return this.post.uniforms[7];
|
|
128
|
+
}
|
|
129
|
+
set shaftIntensity(value) {
|
|
130
|
+
this.post.uniforms[7] = this.amount(value, 'shaftIntensity');
|
|
131
|
+
}
|
|
132
|
+
get shaftLength() {
|
|
133
|
+
return this.post.uniforms[11];
|
|
134
|
+
}
|
|
135
|
+
set shaftLength(value) {
|
|
136
|
+
const length = this.amount(value, 'shaftLength');
|
|
137
|
+
if (length > 1)
|
|
138
|
+
throw new World3DError('WORLD3D_INPUT_INVALID', 'shaftLength');
|
|
139
|
+
this.post.uniforms[11] = length;
|
|
140
|
+
}
|
|
141
|
+
/** Linear RGB fog color. */
|
|
142
|
+
setFogColor(r, g, b) {
|
|
143
|
+
this.post.uniforms[0] = requireFinite3D(r, 'color');
|
|
144
|
+
this.post.uniforms[1] = requireFinite3D(g, 'color');
|
|
145
|
+
this.post.uniforms[2] = requireFinite3D(b, 'color');
|
|
146
|
+
}
|
|
147
|
+
/**
|
|
148
|
+
* Refresh the camera and sun data. `sunDirection` is the direction the
|
|
149
|
+
* sunlight travels in, as a directional light's world direction; pass
|
|
150
|
+
* undefined when there is no sun, which leaves only the fog.
|
|
151
|
+
*/
|
|
152
|
+
update(camera, sunDirection) {
|
|
153
|
+
camera.updateViewMatrices();
|
|
154
|
+
const u = this.post.uniforms, world = camera.matrixWorld;
|
|
155
|
+
// World up expressed in view space is the second row of the camera's rotation.
|
|
156
|
+
const sx = Math.hypot(world[0], world[1], world[2]) || 1, sy = Math.hypot(world[4], world[5], world[6]) || 1, sz = Math.hypot(world[8], world[9], world[10]) || 1;
|
|
157
|
+
u[12] = world[1] / sx;
|
|
158
|
+
u[13] = world[5] / sy;
|
|
159
|
+
u[14] = world[9] / sz;
|
|
160
|
+
u[15] = world[13];
|
|
161
|
+
u[6] = camera.far * 0.98;
|
|
162
|
+
u[10] = 0;
|
|
163
|
+
if (!sunDirection)
|
|
164
|
+
return;
|
|
165
|
+
const dx = requireFinite3D(sunDirection[0], 'sunDirection'), dy = requireFinite3D(sunDirection[1], 'sunDirection'), dz = requireFinite3D(sunDirection[2], 'sunDirection'), length = Math.hypot(dx, dy, dz);
|
|
166
|
+
if (length < 1e-9)
|
|
167
|
+
return;
|
|
168
|
+
// The sun sits far away against the light's travel; project that point to the screen.
|
|
169
|
+
const far = camera.far * 0.5, at = this.#scratch;
|
|
170
|
+
at[0] = world[12] - (dx / length) * far;
|
|
171
|
+
at[1] = world[13] - (dy / length) * far;
|
|
172
|
+
at[2] = world[14] - (dz / length) * far;
|
|
173
|
+
const forward = -(world[8] * -dx + world[9] * -dy + world[10] * -dz) / (length * sz);
|
|
174
|
+
if (forward <= 0.05)
|
|
175
|
+
return;
|
|
176
|
+
camera.worldToScreenPoint(at, at);
|
|
177
|
+
u[8] = at[0] * 0.5 + 0.5;
|
|
178
|
+
u[9] = at[1] * 0.5 + 0.5;
|
|
179
|
+
// Fade the shafts out as the sun leaves the view.
|
|
180
|
+
const off = Math.max(Math.abs(at[0]), Math.abs(at[1]));
|
|
181
|
+
u[10] = Math.min(1, forward * 2) * Math.max(0, Math.min(1, (1.8 - off) / 0.8));
|
|
182
|
+
}
|
|
183
|
+
amount(value, field) {
|
|
184
|
+
if (requireFinite3D(value, field) < 0)
|
|
185
|
+
throw new World3DError('WORLD3D_INPUT_INVALID', field);
|
|
186
|
+
return value;
|
|
187
|
+
}
|
|
188
|
+
}
|
|
189
|
+
/** Makes height fog and light shafts for a scene. */
|
|
190
|
+
export function createAtmosphere3D(options = {}) {
|
|
191
|
+
return new Atmosphere3D(options);
|
|
192
|
+
}
|
|
193
|
+
//# sourceMappingURL=atmosphere3D.js.map
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { Font3D } from '../../rendering/world3d/Text3D.js';
|
|
2
|
+
/** A canvas font to make: the page's font family, weight and style, how finely it is traced, and how much it is smoothed. */
|
|
3
|
+
export interface CanvasFontOptions3D {
|
|
4
|
+
/** A CSS font family the page has loaded. Defaults to `sans-serif`. */
|
|
5
|
+
readonly family?: string;
|
|
6
|
+
/** A CSS font weight, such as `bold` or `700`. Defaults to `normal`. */
|
|
7
|
+
readonly weight?: string | number;
|
|
8
|
+
readonly style?: 'normal' | 'italic';
|
|
9
|
+
/** Canvas pixels to one em when a character is traced, 16 to 512. Defaults to 128; more is finer and slower. */
|
|
10
|
+
readonly resolution?: number;
|
|
11
|
+
/** How far, in traced pixels, a smoothed outline may stray from the pixel edge. Defaults to 0.75. */
|
|
12
|
+
readonly tolerance?: number;
|
|
13
|
+
}
|
|
14
|
+
/**
|
|
15
|
+
* A `Font3D` whose glyphs are traced from the page's own fonts, for 3D text in any script the page can draw, such as
|
|
16
|
+
* the Chinese of a road sign, without a font file. Each character is drawn and traced once, when first used. The
|
|
17
|
+
* outlines are straight segments following the drawn edge, so curves are as smooth as `resolution` allows. Where the
|
|
18
|
+
* page has neither `OffscreenCanvas` nor a document, it throws `WORLD3D_CONTEXT_UNAVAILABLE`.
|
|
19
|
+
*/
|
|
20
|
+
export declare function createCanvasFont3D(options?: CanvasFontOptions3D): Font3D;
|
|
21
|
+
//# sourceMappingURL=canvasFont3D.d.ts.map
|
|
@@ -0,0 +1,165 @@
|
|
|
1
|
+
// SPDX-License-Identifier: Apache-2.0
|
|
2
|
+
// A font for 3D text read from the page's own fonts: each character is drawn
|
|
3
|
+
// once onto a small canvas, its edge traced into outlines and smoothed, and
|
|
4
|
+
// handed to Font3D as straight segments. For a few dozen signs in any script,
|
|
5
|
+
// Chinese included, without shipping a font file.
|
|
6
|
+
import { Font3D } from '../../rendering/world3d/Text3D.js';
|
|
7
|
+
import { World3DError } from '../../rendering/world3d/core3D.js';
|
|
8
|
+
function canvasOf(size) {
|
|
9
|
+
const Offscreen = globalThis.OffscreenCanvas;
|
|
10
|
+
if (typeof Offscreen === 'function')
|
|
11
|
+
return new Offscreen(size, size).getContext('2d', { willReadFrequently: true }) ?? undefined;
|
|
12
|
+
const doc = globalThis.document;
|
|
13
|
+
if (doc === undefined)
|
|
14
|
+
return undefined;
|
|
15
|
+
const canvas = doc.createElement('canvas');
|
|
16
|
+
canvas.width = canvas.height = size;
|
|
17
|
+
return canvas.getContext('2d', { willReadFrequently: true }) ?? undefined;
|
|
18
|
+
}
|
|
19
|
+
/** The loops of pixel edges around the filled pixels of a mask, each a list of corner points. */
|
|
20
|
+
function traceEdges(filled, width, height) {
|
|
21
|
+
const at = (x, y) => x >= 0 && y >= 0 && x < width && y < height && filled[y * width + x] === 1;
|
|
22
|
+
// Directed edges with the filled pixel on their left, keyed by their start corner.
|
|
23
|
+
const next = new Map();
|
|
24
|
+
const key = (x, y) => y * (width + 1) + x;
|
|
25
|
+
const edge = (x0, y0, x1, y1) => {
|
|
26
|
+
const from = key(x0, y0), list = next.get(from);
|
|
27
|
+
if (list)
|
|
28
|
+
list.push(key(x1, y1));
|
|
29
|
+
else
|
|
30
|
+
next.set(from, [key(x1, y1)]);
|
|
31
|
+
};
|
|
32
|
+
for (let y = 0; y < height; y++)
|
|
33
|
+
for (let x = 0; x < width; x++) {
|
|
34
|
+
if (!at(x, y))
|
|
35
|
+
continue;
|
|
36
|
+
// Rows run down: going round a pixel with it on the left is anticlockwise on screen.
|
|
37
|
+
if (!at(x, y - 1))
|
|
38
|
+
edge(x + 1, y, x, y);
|
|
39
|
+
if (!at(x - 1, y))
|
|
40
|
+
edge(x, y, x, y + 1);
|
|
41
|
+
if (!at(x, y + 1))
|
|
42
|
+
edge(x, y + 1, x + 1, y + 1);
|
|
43
|
+
if (!at(x + 1, y))
|
|
44
|
+
edge(x + 1, y + 1, x + 1, y);
|
|
45
|
+
}
|
|
46
|
+
const loops = [];
|
|
47
|
+
for (const [start, ends] of next) {
|
|
48
|
+
while (ends.length > 0) {
|
|
49
|
+
const loop = [];
|
|
50
|
+
let from = start, to = ends.pop();
|
|
51
|
+
loop.push(from % (width + 1), Math.floor(from / (width + 1)));
|
|
52
|
+
while (to !== start) {
|
|
53
|
+
loop.push(to % (width + 1), Math.floor(to / (width + 1)));
|
|
54
|
+
const onward = next.get(to);
|
|
55
|
+
if (!onward || onward.length === 0)
|
|
56
|
+
break;
|
|
57
|
+
from = to;
|
|
58
|
+
to = onward.pop();
|
|
59
|
+
}
|
|
60
|
+
if (loop.length >= 6)
|
|
61
|
+
loops.push(loop);
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
return loops;
|
|
65
|
+
}
|
|
66
|
+
/** Fewer points along a closed loop, each removed one within `tolerance` of the line that replaces it. */
|
|
67
|
+
function simplify(loop, tolerance) {
|
|
68
|
+
const count = loop.length / 2;
|
|
69
|
+
if (count <= 4)
|
|
70
|
+
return loop;
|
|
71
|
+
const keep = new Uint8Array(count);
|
|
72
|
+
// Split the loop at its first point and the point farthest from it, and simplify each half.
|
|
73
|
+
let far = 0, best = -1;
|
|
74
|
+
for (let i = 1; i < count; i++) {
|
|
75
|
+
const d = (loop[i * 2] - loop[0]) ** 2 + (loop[i * 2 + 1] - loop[1]) ** 2;
|
|
76
|
+
if (d > best) {
|
|
77
|
+
best = d;
|
|
78
|
+
far = i;
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
keep[0] = keep[far] = 1;
|
|
82
|
+
const stack = [
|
|
83
|
+
[0, far],
|
|
84
|
+
[far, count]
|
|
85
|
+
];
|
|
86
|
+
while (stack.length > 0) {
|
|
87
|
+
const [a, b] = stack.pop();
|
|
88
|
+
const ax = loop[a * 2], ay = loop[a * 2 + 1], bx = loop[(b % count) * 2], by = loop[(b % count) * 2 + 1], length = Math.hypot(bx - ax, by - ay) || 1;
|
|
89
|
+
let worst = -1, distance = tolerance;
|
|
90
|
+
for (let i = a + 1; i < b; i++) {
|
|
91
|
+
const d = Math.abs((bx - ax) * (ay - loop[i * 2 + 1]) - (ax - loop[i * 2]) * (by - ay)) / length;
|
|
92
|
+
if (d > distance) {
|
|
93
|
+
distance = d;
|
|
94
|
+
worst = i;
|
|
95
|
+
}
|
|
96
|
+
}
|
|
97
|
+
if (worst >= 0) {
|
|
98
|
+
keep[worst] = 1;
|
|
99
|
+
stack.push([a, worst], [worst, b]);
|
|
100
|
+
}
|
|
101
|
+
}
|
|
102
|
+
const out = [];
|
|
103
|
+
for (let i = 0; i < count; i++)
|
|
104
|
+
if (keep[i])
|
|
105
|
+
out.push(loop[i * 2], loop[i * 2 + 1]);
|
|
106
|
+
return out.length >= 6 ? out : loop;
|
|
107
|
+
}
|
|
108
|
+
/**
|
|
109
|
+
* A `Font3D` whose glyphs are traced from the page's own fonts, for 3D text in any script the page can draw, such as
|
|
110
|
+
* the Chinese of a road sign, without a font file. Each character is drawn and traced once, when first used. The
|
|
111
|
+
* outlines are straight segments following the drawn edge, so curves are as smooth as `resolution` allows. Where the
|
|
112
|
+
* page has neither `OffscreenCanvas` nor a document, it throws `WORLD3D_CONTEXT_UNAVAILABLE`.
|
|
113
|
+
*/
|
|
114
|
+
export function createCanvasFont3D(options = {}) {
|
|
115
|
+
if (options === null || typeof options !== 'object')
|
|
116
|
+
throw new World3DError('WORLD3D_INPUT_INVALID', 'canvas font');
|
|
117
|
+
const family = options.family ?? 'sans-serif', weight = options.weight ?? 'normal', style = options.style ?? 'normal', em = options.resolution ?? 128, tolerance = options.tolerance ?? 0.75;
|
|
118
|
+
if (typeof family !== 'string' ||
|
|
119
|
+
family.length === 0 ||
|
|
120
|
+
/[;{}]/.test(family) ||
|
|
121
|
+
(typeof weight !== 'string' && typeof weight !== 'number') ||
|
|
122
|
+
(style !== 'normal' && style !== 'italic') ||
|
|
123
|
+
!Number.isInteger(em) ||
|
|
124
|
+
em < 16 ||
|
|
125
|
+
em > 512 ||
|
|
126
|
+
!(tolerance >= 0 && tolerance <= 8))
|
|
127
|
+
throw new World3DError('WORLD3D_INPUT_INVALID', 'canvas font');
|
|
128
|
+
// Room for strokes that reach past the em box on every side.
|
|
129
|
+
const size = em * 2, left = Math.round(em / 2), baseline = Math.round(em * 1.4);
|
|
130
|
+
const context = canvasOf(size);
|
|
131
|
+
if (context === undefined)
|
|
132
|
+
throw new World3DError('WORLD3D_CONTEXT_UNAVAILABLE', 'canvas font');
|
|
133
|
+
context.font = `${style} ${weight} ${em}px ${family}`;
|
|
134
|
+
context.textBaseline = 'alphabetic';
|
|
135
|
+
context.fillStyle = '#fff';
|
|
136
|
+
const metrics = context.measureText('Hg中');
|
|
137
|
+
const ascender = metrics.fontBoundingBoxAscent > 0 ? metrics.fontBoundingBoxAscent : em * 0.88, descender = metrics.fontBoundingBoxDescent > 0 ? -metrics.fontBoundingBoxDescent : -em * 0.12;
|
|
138
|
+
const filled = new Uint8Array(size * size);
|
|
139
|
+
return new Font3D({
|
|
140
|
+
unitsPerEm: em,
|
|
141
|
+
ascender,
|
|
142
|
+
descender,
|
|
143
|
+
lineHeight: Math.max(em * 1.2, ascender - descender),
|
|
144
|
+
familyName: family,
|
|
145
|
+
glyph(codePoint) {
|
|
146
|
+
if (!Number.isInteger(codePoint) || codePoint < 0 || codePoint > 0x10ffff)
|
|
147
|
+
return undefined;
|
|
148
|
+
const text = String.fromCodePoint(codePoint), advance = context.measureText(text).width;
|
|
149
|
+
context.clearRect(0, 0, size, size);
|
|
150
|
+
context.fillText(text, left, baseline);
|
|
151
|
+
const pixels = context.getImageData(0, 0, size, size).data;
|
|
152
|
+
for (let i = 0; i < filled.length; i++)
|
|
153
|
+
filled[i] = pixels[i * 4 + 3] >= 128 ? 1 : 0;
|
|
154
|
+
const commands = [];
|
|
155
|
+
for (const loop of traceEdges(filled, size, size)) {
|
|
156
|
+
const points = simplify(loop, tolerance);
|
|
157
|
+
// Font units run up from the baseline; canvas rows run down.
|
|
158
|
+
for (let i = 0; i < points.length; i += 2)
|
|
159
|
+
commands.push(i === 0 ? 0 : 1, points[i] - left, baseline - points[i + 1]);
|
|
160
|
+
}
|
|
161
|
+
return { advance, commands };
|
|
162
|
+
}
|
|
163
|
+
});
|
|
164
|
+
}
|
|
165
|
+
//# sourceMappingURL=canvasFont3D.js.map
|