@egret/engine 0.0.0-stage → 7.0.1-rc.3
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 +464 -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 +42 -0
- package/dist/animation/sequenceResetTypes.js +2 -0
- package/dist/animation/types.d.ts +69 -0
- package/dist/animation/types.js +2 -0
- package/dist/assetBundle.d.ts +52 -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 +15 -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 +43 -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 +233 -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 +29 -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 +109 -0
- package/dist/bitmapFontTypes.js +2 -0
- package/dist/bitmapResourceSlot.d.ts +25 -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 +411 -0
- package/dist/cameraTypes.d.ts +114 -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 +33 -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 +42 -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 +34 -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 +31 -0
- package/dist/gameClockTypes.js +2 -0
- package/dist/gameRun.d.ts +50 -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 +134 -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 +119 -0
- package/dist/hoverInputTypes.js +2 -0
- package/dist/index.d.ts +49 -0
- package/dist/index.js +20 -0
- package/dist/input.d.ts +6 -0
- package/dist/input.js +5 -0
- package/dist/inputActions.d.ts +81 -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 +64 -0
- package/dist/internal/uiFactoryState.js +157 -0
- package/dist/internal/uiRootState.d.ts +67 -0
- package/dist/internal/uiRootState.js +103 -0
- package/dist/keyboardInput.d.ts +12 -0
- package/dist/keyboardInput.js +578 -0
- package/dist/keyboardInputTypes.d.ts +81 -0
- package/dist/keyboardInputTypes.js +2 -0
- package/dist/kit.d.ts +14 -0
- package/dist/kit.js +9 -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 +16 -0
- package/dist/manifestResourceState.js +57 -0
- package/dist/manifestResourceTypes.d.ts +25 -0
- package/dist/manifestResourceTypes.js +2 -0
- package/dist/motion.d.ts +33 -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 +37 -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 +292 -0
- package/dist/particleTypes.d.ts +107 -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 +167 -0
- package/dist/physics2dTypes.js +2 -0
- package/dist/physics2dWorld.d.ts +4 -0
- package/dist/physics2dWorld.js +623 -0
- package/dist/pointerInput.d.ts +11 -0
- package/dist/pointerInput.js +299 -0
- package/dist/pointerInputTypes.d.ts +38 -0
- package/dist/pointerInputTypes.js +2 -0
- package/dist/random.d.ts +29 -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 +331 -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 +88 -0
- package/dist/rendering/prepareSharedDraws2D.js +652 -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 +18 -0
- package/dist/rendering/sharedColor2D.js +68 -0
- package/dist/rendering/sharedEffects2D.d.ts +23 -0
- package/dist/rendering/sharedEffects2D.js +118 -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 +95 -0
- package/dist/rendering/world3d/Animation3D.js +380 -0
- package/dist/rendering/world3d/AnimationTexture3D.d.ts +157 -0
- package/dist/rendering/world3d/AnimationTexture3D.js +601 -0
- package/dist/rendering/world3d/Batch3D.d.ts +71 -0
- package/dist/rendering/world3d/Batch3D.js +329 -0
- package/dist/rendering/world3d/Camera3D.d.ts +57 -0
- package/dist/rendering/world3d/Camera3D.js +129 -0
- package/dist/rendering/world3d/Character3D.d.ts +123 -0
- package/dist/rendering/world3d/Character3D.js +303 -0
- package/dist/rendering/world3d/Cloth3D.d.ts +115 -0
- package/dist/rendering/world3d/Cloth3D.js +498 -0
- package/dist/rendering/world3d/Compression3D.d.ts +21 -0
- package/dist/rendering/world3d/Compression3D.js +702 -0
- package/dist/rendering/world3d/Curves3D.d.ts +111 -0
- package/dist/rendering/world3d/Curves3D.js +455 -0
- package/dist/rendering/world3d/Decal3D.d.ts +41 -0
- package/dist/rendering/world3d/Decal3D.js +241 -0
- package/dist/rendering/world3d/Geometry3D.d.ts +85 -0
- package/dist/rendering/world3d/Geometry3D.js +326 -0
- package/dist/rendering/world3d/GeometryBuilder3D.d.ts +51 -0
- package/dist/rendering/world3d/GeometryBuilder3D.js +196 -0
- package/dist/rendering/world3d/Gizmo3D.d.ts +75 -0
- package/dist/rendering/world3d/Gizmo3D.js +512 -0
- package/dist/rendering/world3d/Gltf3D.d.ts +67 -0
- package/dist/rendering/world3d/Gltf3D.js +976 -0
- package/dist/rendering/world3d/GpuParticles3D.d.ts +107 -0
- package/dist/rendering/world3d/GpuParticles3D.js +400 -0
- package/dist/rendering/world3d/Hdr3D.d.ts +33 -0
- package/dist/rendering/world3d/Hdr3D.js +190 -0
- package/dist/rendering/world3d/Jelly3D.d.ts +75 -0
- package/dist/rendering/world3d/Jelly3D.js +266 -0
- package/dist/rendering/world3d/Ktx23D.d.ts +27 -0
- package/dist/rendering/world3d/Ktx23D.js +112 -0
- package/dist/rendering/world3d/Light3D.d.ts +75 -0
- package/dist/rendering/world3d/Light3D.js +93 -0
- package/dist/rendering/world3d/Material3D.d.ts +243 -0
- package/dist/rendering/world3d/Material3D.js +267 -0
- package/dist/rendering/world3d/Mesh3D.d.ts +108 -0
- package/dist/rendering/world3d/Mesh3D.js +323 -0
- package/dist/rendering/world3d/Meshopt3D.d.ts +12 -0
- package/dist/rendering/world3d/Meshopt3D.js +275 -0
- package/dist/rendering/world3d/Navigation3D.d.ts +173 -0
- package/dist/rendering/world3d/Navigation3D.js +971 -0
- package/dist/rendering/world3d/Object3D.d.ts +107 -0
- package/dist/rendering/world3d/Object3D.js +305 -0
- package/dist/rendering/world3d/Particles3D.d.ts +85 -0
- package/dist/rendering/world3d/Particles3D.js +274 -0
- package/dist/rendering/world3d/Physics3D.d.ts +416 -0
- package/dist/rendering/world3d/Physics3D.js +2835 -0
- package/dist/rendering/world3d/PhysicsHull3D.d.ts +35 -0
- package/dist/rendering/world3d/PhysicsHull3D.js +227 -0
- package/dist/rendering/world3d/PhysicsMesh3D.d.ts +39 -0
- package/dist/rendering/world3d/PhysicsMesh3D.js +338 -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 +174 -0
- package/dist/rendering/world3d/PhysicsRemote3D.js +534 -0
- package/dist/rendering/world3d/Ragdoll3D.d.ts +69 -0
- package/dist/rendering/world3d/Ragdoll3D.js +200 -0
- package/dist/rendering/world3d/Raycast3D.d.ts +37 -0
- package/dist/rendering/world3d/Raycast3D.js +246 -0
- package/dist/rendering/world3d/RenderList3D.d.ts +88 -0
- package/dist/rendering/world3d/RenderList3D.js +490 -0
- package/dist/rendering/world3d/Retarget3D.d.ts +20 -0
- package/dist/rendering/world3d/Retarget3D.js +185 -0
- package/dist/rendering/world3d/Serialize3D.d.ts +49 -0
- package/dist/rendering/world3d/Serialize3D.js +607 -0
- package/dist/rendering/world3d/StateMachine3D.d.ts +78 -0
- package/dist/rendering/world3d/StateMachine3D.js +277 -0
- package/dist/rendering/world3d/Terrain3D.d.ts +227 -0
- package/dist/rendering/world3d/Terrain3D.js +803 -0
- package/dist/rendering/world3d/Text3D.d.ts +90 -0
- package/dist/rendering/world3d/Text3D.js +558 -0
- package/dist/rendering/world3d/Texture3D.d.ts +133 -0
- package/dist/rendering/world3d/Texture3D.js +252 -0
- package/dist/rendering/world3d/Trail3D.d.ts +59 -0
- package/dist/rendering/world3d/Trail3D.js +193 -0
- package/dist/rendering/world3d/Vehicle3D.d.ts +97 -0
- package/dist/rendering/world3d/Vehicle3D.js +226 -0
- package/dist/rendering/world3d/VolumetricFog3D.d.ts +55 -0
- package/dist/rendering/world3d/VolumetricFog3D.js +229 -0
- package/dist/rendering/world3d/Water3D.d.ts +163 -0
- package/dist/rendering/world3d/Water3D.js +606 -0
- package/dist/rendering/world3d/core3D.d.ts +34 -0
- package/dist/rendering/world3d/core3D.js +99 -0
- package/dist/rendering/world3d/debug3D.d.ts +64 -0
- package/dist/rendering/world3d/debug3D.js +257 -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 +99 -0
- package/dist/rendering/world3d/geometries3D.js +605 -0
- package/dist/rendering/world3d/helpers3D.d.ts +65 -0
- package/dist/rendering/world3d/helpers3D.js +177 -0
- package/dist/rendering/world3d/index.d.ts +91 -0
- package/dist/rendering/world3d/index.js +56 -0
- package/dist/rendering/world3d/math3D.d.ts +78 -0
- package/dist/rendering/world3d/math3D.js +640 -0
- package/dist/rendering/world3d/primitives3D.d.ts +60 -0
- package/dist/rendering/world3d/primitives3D.js +196 -0
- package/dist/resources.d.ts +8 -0
- package/dist/resources.js +6 -0
- package/dist/saveStore.d.ts +56 -0
- package/dist/saveStore.js +163 -0
- package/dist/semanticList.d.ts +122 -0
- package/dist/semanticList.js +174 -0
- package/dist/semanticTree.d.ts +10 -0
- package/dist/semanticTree.js +532 -0
- package/dist/semanticTypes.d.ts +167 -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 +21 -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 +23 -0
- package/dist/text.js +4 -0
- package/dist/textField.d.ts +6 -0
- package/dist/textField.js +6 -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 +169 -0
- package/dist/tilemapTypes.js +2 -0
- package/dist/tween.d.ts +15 -0
- package/dist/tween.js +329 -0
- package/dist/tweenTypes.d.ts +27 -0
- package/dist/tweenTypes.js +2 -0
- package/dist/ui/controlKeys.d.ts +109 -0
- package/dist/ui/controlKeys.js +249 -0
- package/dist/ui/controls.d.ts +52 -0
- package/dist/ui/controls.js +288 -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 +91 -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 +50 -0
- package/dist/ui/rangeControl.js +167 -0
- package/dist/ui/scrollControl.d.ts +72 -0
- package/dist/ui/scrollControl.js +218 -0
- package/dist/ui/stateControls.d.ts +82 -0
- package/dist/ui/stateControls.js +328 -0
- package/dist/ui/textEditor.d.ts +53 -0
- package/dist/ui/textEditor.js +370 -0
- package/dist/ui/textEditorTypes.d.ts +78 -0
- package/dist/ui/textEditorTypes.js +2 -0
- package/dist/ui/textFieldControl.d.ts +96 -0
- package/dist/ui/textFieldControl.js +259 -0
- package/dist/ui/theme.d.ts +59 -0
- package/dist/ui/theme.js +165 -0
- package/dist/ui/types.d.ts +265 -0
- package/dist/ui/types.js +2 -0
- package/dist/ui/uiRoot.d.ts +4 -0
- package/dist/ui/uiRoot.js +1497 -0
- package/dist/ui/uiRootDisplay.d.ts +46 -0
- package/dist/ui/uiRootDisplay.js +148 -0
- package/dist/ui/uiRootModel.d.ts +112 -0
- package/dist/ui/uiRootModel.js +60 -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 +74 -0
- package/dist/videoTypes.js +2 -0
- package/dist/web/BrowserAssetBundle.d.ts +39 -0
- package/dist/web/BrowserAssetBundle.js +136 -0
- package/dist/web/BrowserAudio.d.ts +41 -0
- package/dist/web/BrowserAudio.js +473 -0
- package/dist/web/BrowserFrameLoop.d.ts +65 -0
- package/dist/web/BrowserFrameLoop.js +125 -0
- package/dist/web/BrowserGame.d.ts +112 -0
- package/dist/web/BrowserGame.js +352 -0
- package/dist/web/BrowserGamepadInput.d.ts +35 -0
- package/dist/web/BrowserGamepadInput.js +134 -0
- package/dist/web/BrowserHoverInput.d.ts +24 -0
- package/dist/web/BrowserHoverInput.js +266 -0
- package/dist/web/BrowserImageTextures.d.ts +66 -0
- package/dist/web/BrowserImageTextures.js +169 -0
- package/dist/web/BrowserInputActions.d.ts +53 -0
- package/dist/web/BrowserInputActions.js +342 -0
- package/dist/web/BrowserKeyboardInput.d.ts +4 -0
- package/dist/web/BrowserKeyboardInput.js +223 -0
- package/dist/web/BrowserPlay.d.ts +289 -0
- package/dist/web/BrowserPlay.js +1301 -0
- package/dist/web/BrowserPointerInput.d.ts +4 -0
- package/dist/web/BrowserPointerInput.js +511 -0
- package/dist/web/BrowserSemantics.d.ts +34 -0
- package/dist/web/BrowserSemantics.js +418 -0
- package/dist/web/BrowserStatsPanel.d.ts +46 -0
- package/dist/web/BrowserStatsPanel.js +137 -0
- package/dist/web/BrowserStorage.d.ts +33 -0
- package/dist/web/BrowserStorage.js +132 -0
- package/dist/web/BrowserTextEditor.d.ts +49 -0
- package/dist/web/BrowserTextEditor.js +839 -0
- package/dist/web/BrowserTextInput.d.ts +83 -0
- package/dist/web/BrowserTextInput.js +524 -0
- package/dist/web/BrowserTextureProvider.d.ts +52 -0
- package/dist/web/BrowserTextureProvider.js +935 -0
- package/dist/web/BrowserVideo.d.ts +28 -0
- package/dist/web/BrowserVideo.js +211 -0
- package/dist/web/CanvasKitFontSetProvider.d.ts +29 -0
- package/dist/web/CanvasKitFontSetProvider.js +215 -0
- package/dist/web/CanvasKitParagraphProvider.d.ts +169 -0
- package/dist/web/CanvasKitParagraphProvider.js +691 -0
- package/dist/web/CanvasTextRasterProvider.d.ts +4 -0
- package/dist/web/CanvasTextRasterProvider.js +312 -0
- package/dist/web/ManifestByteSource.d.ts +147 -0
- package/dist/web/ManifestByteSource.js +974 -0
- package/dist/web/ManifestFontContentLoader.d.ts +12 -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 +2672 -0
- package/dist/web/WebGPUHost.d.ts +87 -0
- package/dist/web/WebGPUHost.js +3349 -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 +50 -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 +14 -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 +10 -0
- package/dist/web/kit.js +7 -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 +5 -0
- package/dist/web/play.js +6 -0
- package/dist/web/playSfx.d.ts +36 -0
- package/dist/web/playSfx.js +112 -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 +57 -0
- package/dist/web/resources.d.ts +27 -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 +9 -0
- package/dist/web/sharedEffectShaders.js +165 -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 +30 -0
- package/dist/web/sharedWebGL2Options.js +96 -0
- package/dist/web/sharedWebGL2Shaders.d.ts +20 -0
- package/dist/web/sharedWebGL2Shaders.js +314 -0
- package/dist/web/sharedWebGPUOptions.d.ts +37 -0
- package/dist/web/sharedWebGPUOptions.js +126 -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 +70 -0
- package/dist/web/webgl2Native.js +568 -0
- package/dist/web/webgl2Types.d.ts +132 -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 +53 -0
- package/dist/web/webgpuImageResidency.js +61 -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 +84 -0
- package/dist/web/webgpuSharedPass.d.ts +7 -0
- package/dist/web/webgpuSharedPass.js +211 -0
- package/dist/web/webgpuSharedResolvePass.d.ts +3 -0
- package/dist/web/webgpuSharedResolvePass.js +29 -0
- package/dist/web/world3d/Audio3D.d.ts +68 -0
- package/dist/web/world3d/Audio3D.js +212 -0
- package/dist/web/world3d/BrowserPlay3D.d.ts +182 -0
- package/dist/web/world3d/BrowserPlay3D.js +851 -0
- package/dist/web/world3d/FlyControls3D.d.ts +55 -0
- package/dist/web/world3d/FlyControls3D.js +160 -0
- package/dist/web/world3d/FollowControls3D.d.ts +28 -0
- package/dist/web/world3d/FollowControls3D.js +117 -0
- package/dist/web/world3d/OrbitControls3D.d.ts +55 -0
- package/dist/web/world3d/OrbitControls3D.js +187 -0
- package/dist/web/world3d/TransformControls3D.d.ts +34 -0
- package/dist/web/world3d/TransformControls3D.js +125 -0
- package/dist/web/world3d/WebGL2Renderer3D.d.ts +133 -0
- package/dist/web/world3d/WebGL2Renderer3D.js +1173 -0
- package/dist/web/world3d/WebGPURenderer3D.d.ts +110 -0
- package/dist/web/world3d/WebGPURenderer3D.js +1915 -0
- package/dist/web/world3d/World3DView.d.ts +51 -0
- package/dist/web/world3d/World3DView.js +77 -0
- package/dist/web/world3d/app3D.d.ts +136 -0
- package/dist/web/world3d/app3D.js +304 -0
- package/dist/web/world3d/assets3D.d.ts +38 -0
- package/dist/web/world3d/assets3D.js +112 -0
- package/dist/web/world3d/atmosphere3D.d.ts +47 -0
- package/dist/web/world3d/atmosphere3D.js +178 -0
- package/dist/web/world3d/frame3D.d.ts +142 -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 +23 -0
- package/dist/web/world3d/host3D.js +61 -0
- package/dist/web/world3d/index.d.ts +38 -0
- package/dist/web/world3d/index.js +23 -0
- package/dist/web/world3d/loaders3D.d.ts +26 -0
- package/dist/web/world3d/loaders3D.js +138 -0
- package/dist/web/world3d/markers3D.d.ts +49 -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 +28 -0
- package/dist/web/world3d/overlay3D.js +170 -0
- package/dist/web/world3d/post3D.d.ts +112 -0
- package/dist/web/world3d/post3D.js +459 -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 +14 -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 +31 -0
- package/dist/web/world3d/stats3D.js +80 -0
- package/dist/web/world3d/webGL2FrameMetrics3D.d.ts +66 -0
- package/dist/web/world3d/webGL2FrameMetrics3D.js +185 -0
- package/dist/web/world3d/webgpu.d.ts +35 -0
- package/dist/web/world3d/webgpu.js +22 -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,51 @@
|
|
|
1
|
+
import type { Disposable } from '@egret/contracts';
|
|
2
|
+
import type { Scope } from '@egret/runtime';
|
|
3
|
+
import type { AnimationMixer3D } from '../../rendering/world3d/Animation3D.js';
|
|
4
|
+
import type { Camera3D } from '../../rendering/world3d/Camera3D.js';
|
|
5
|
+
import type { Scene3D } from '../../rendering/world3d/Object3D.js';
|
|
6
|
+
import type { OrbitControls3D } from './OrbitControls3D.js';
|
|
7
|
+
import type { Renderer3D } from './frame3D.js';
|
|
8
|
+
/** The part of an Engine this view needs: its explicit game clock. */
|
|
9
|
+
export interface World3DClockSource {
|
|
10
|
+
readonly clock: {
|
|
11
|
+
onTick(scope: Scope, handler: (tick: {
|
|
12
|
+
readonly deltaSeconds: number;
|
|
13
|
+
readonly elapsedSeconds: number;
|
|
14
|
+
}) => undefined): Disposable;
|
|
15
|
+
};
|
|
16
|
+
}
|
|
17
|
+
export interface World3DViewOptions {
|
|
18
|
+
readonly renderer: Renderer3D;
|
|
19
|
+
readonly scene: Scene3D;
|
|
20
|
+
readonly camera: Camera3D;
|
|
21
|
+
readonly mixers?: readonly AnimationMixer3D[];
|
|
22
|
+
readonly controls?: OrbitControls3D;
|
|
23
|
+
/** Called every tick before animation and rendering. */
|
|
24
|
+
readonly onUpdate?: (deltaSeconds: number, elapsedSeconds: number) => void;
|
|
25
|
+
/** Keep the drawing buffer and camera aspect matched to the canvas CSS size. Defaults to true. */
|
|
26
|
+
readonly autoResize?: boolean;
|
|
27
|
+
/** Upper bound for the device pixel ratio used by autoResize. Defaults to 2. */
|
|
28
|
+
readonly maxPixelRatio?: number;
|
|
29
|
+
/** Step particle emitters found in the scene. Defaults to true. */
|
|
30
|
+
readonly updateParticles?: boolean;
|
|
31
|
+
/** Receives failures thrown while updating or drawing; the view keeps ticking. */
|
|
32
|
+
readonly onError?: (cause: unknown) => void;
|
|
33
|
+
}
|
|
34
|
+
export declare class World3DView implements Disposable {
|
|
35
|
+
#private;
|
|
36
|
+
readonly renderer: Renderer3D;
|
|
37
|
+
scene: Scene3D;
|
|
38
|
+
camera: Camera3D;
|
|
39
|
+
readonly mixers: AnimationMixer3D[];
|
|
40
|
+
controls: OrbitControls3D | undefined;
|
|
41
|
+
/** Skip animation and drawing while true; the clock subscription stays active. */
|
|
42
|
+
paused: boolean;
|
|
43
|
+
constructor(engine: World3DClockSource, scope: Scope, options: World3DViewOptions);
|
|
44
|
+
get isDisposed(): boolean;
|
|
45
|
+
/** Advance and draw one frame. Normally driven by the Engine clock. */
|
|
46
|
+
tick(deltaSeconds: number, elapsedSeconds: number): void;
|
|
47
|
+
/** Stop ticking. The renderer, scene and controls stay owned by their creator. */
|
|
48
|
+
dispose(): void;
|
|
49
|
+
}
|
|
50
|
+
export declare function createWorld3DView(engine: World3DClockSource, scope: Scope, options: World3DViewOptions): World3DView;
|
|
51
|
+
//# sourceMappingURL=World3DView.d.ts.map
|
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
import { World3DError } from '../../rendering/world3d/core3D.js';
|
|
2
|
+
import { ParticleEmitter3D } from '../../rendering/world3d/Particles3D.js';
|
|
3
|
+
export class World3DView {
|
|
4
|
+
renderer;
|
|
5
|
+
scene;
|
|
6
|
+
camera;
|
|
7
|
+
mixers;
|
|
8
|
+
controls;
|
|
9
|
+
/** Skip animation and drawing while true; the clock subscription stays active. */
|
|
10
|
+
paused = false;
|
|
11
|
+
#subscription;
|
|
12
|
+
#options;
|
|
13
|
+
#disposed = false;
|
|
14
|
+
constructor(engine, scope, options) {
|
|
15
|
+
if (!engine || typeof engine.clock?.onTick !== 'function')
|
|
16
|
+
throw new World3DError('WORLD3D_INPUT_INVALID', 'engine');
|
|
17
|
+
if (!options?.renderer || !options.scene || !options.camera)
|
|
18
|
+
throw new World3DError('WORLD3D_INPUT_INVALID', 'view options');
|
|
19
|
+
this.#options = options;
|
|
20
|
+
this.renderer = options.renderer;
|
|
21
|
+
this.scene = options.scene;
|
|
22
|
+
this.camera = options.camera;
|
|
23
|
+
this.mixers = [...(options.mixers ?? [])];
|
|
24
|
+
this.controls = options.controls;
|
|
25
|
+
// The Scope owns this view: closing the Scope ends ticking before the Engine closes.
|
|
26
|
+
this.#subscription = engine.clock.onTick(scope, tick => {
|
|
27
|
+
this.tick(tick.deltaSeconds, tick.elapsedSeconds);
|
|
28
|
+
return undefined;
|
|
29
|
+
});
|
|
30
|
+
scope.use(this);
|
|
31
|
+
}
|
|
32
|
+
get isDisposed() {
|
|
33
|
+
return this.#disposed;
|
|
34
|
+
}
|
|
35
|
+
/** Advance and draw one frame. Normally driven by the Engine clock. */
|
|
36
|
+
tick(deltaSeconds, elapsedSeconds) {
|
|
37
|
+
if (this.#disposed || this.paused)
|
|
38
|
+
return;
|
|
39
|
+
const options = this.#options;
|
|
40
|
+
try {
|
|
41
|
+
if (options.autoResize ?? true) {
|
|
42
|
+
const ratio = Math.min(typeof devicePixelRatio === 'number' ? devicePixelRatio : 1, options.maxPixelRatio ?? 2);
|
|
43
|
+
this.renderer.resizeToDisplaySize(ratio);
|
|
44
|
+
const canvas = this.renderer.canvas;
|
|
45
|
+
if (canvas.height > 0)
|
|
46
|
+
this.camera.aspect = canvas.width / canvas.height;
|
|
47
|
+
}
|
|
48
|
+
options.onUpdate?.(deltaSeconds, elapsedSeconds);
|
|
49
|
+
for (const mixer of this.mixers)
|
|
50
|
+
mixer.update(deltaSeconds);
|
|
51
|
+
this.controls?.update(deltaSeconds);
|
|
52
|
+
if (options.updateParticles ?? true) {
|
|
53
|
+
this.scene.traverse(object => {
|
|
54
|
+
if (object instanceof ParticleEmitter3D && object.visible)
|
|
55
|
+
object.update(deltaSeconds);
|
|
56
|
+
});
|
|
57
|
+
}
|
|
58
|
+
this.renderer.render(this.scene, this.camera);
|
|
59
|
+
}
|
|
60
|
+
catch (cause) {
|
|
61
|
+
if (!options.onError)
|
|
62
|
+
throw cause;
|
|
63
|
+
options.onError(cause);
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
/** Stop ticking. The renderer, scene and controls stay owned by their creator. */
|
|
67
|
+
dispose() {
|
|
68
|
+
if (this.#disposed)
|
|
69
|
+
return;
|
|
70
|
+
this.#disposed = true;
|
|
71
|
+
this.#subscription.dispose();
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
export function createWorld3DView(engine, scope, options) {
|
|
75
|
+
return new World3DView(engine, scope, options);
|
|
76
|
+
}
|
|
77
|
+
//# sourceMappingURL=World3DView.js.map
|
|
@@ -0,0 +1,136 @@
|
|
|
1
|
+
import type { Engine } from '@egret/engine';
|
|
2
|
+
import type { Scope } from '@egret/runtime';
|
|
3
|
+
import type { Disposable } from '@egret/contracts';
|
|
4
|
+
import type { Camera3D } from '../../rendering/world3d/Camera3D.js';
|
|
5
|
+
import type { Scene3D } from '../../rendering/world3d/Object3D.js';
|
|
6
|
+
import type { AnimationMixer3D } from '../../rendering/world3d/Animation3D.js';
|
|
7
|
+
import type { Renderer3D, ToneMapping3D } from './frame3D.js';
|
|
8
|
+
import { World3DView } from './World3DView.js';
|
|
9
|
+
import type { OrbitControls3D } from './OrbitControls3D.js';
|
|
10
|
+
export type World3DBackend = 'webgl2' | 'webgpu';
|
|
11
|
+
export type World3DQuality = 'low' | 'medium' | 'high';
|
|
12
|
+
/** What one picture quality turns on. */
|
|
13
|
+
export interface World3DQualityPreset {
|
|
14
|
+
/** Largest device pixel ratio drawn at. */
|
|
15
|
+
readonly pixelRatio: number;
|
|
16
|
+
/** Multisampling of the canvas; fixed when the renderer is made. */
|
|
17
|
+
readonly antialias: boolean;
|
|
18
|
+
readonly shadows: boolean;
|
|
19
|
+
/** Edge of the shadow atlas in texels; fixed when the renderer is made. */
|
|
20
|
+
readonly shadowAtlasSize: number;
|
|
21
|
+
/** The post-processing chain, and which of its parts run. */
|
|
22
|
+
readonly post: boolean;
|
|
23
|
+
readonly bloom: boolean;
|
|
24
|
+
readonly ssao: boolean;
|
|
25
|
+
readonly fxaa: boolean;
|
|
26
|
+
}
|
|
27
|
+
/** The three qualities. A phone gets `low`, a desktop `high`; `medium` sits between for weaker computers. */
|
|
28
|
+
export declare const WORLD3D_QUALITY_PRESETS: Readonly<Record<World3DQuality, World3DQualityPreset>>;
|
|
29
|
+
/** What `pickWorld3DQuality` reads about the device. Every field is optional; missing ones are read from the page. */
|
|
30
|
+
export interface World3DDeviceHints {
|
|
31
|
+
/** The page address's query, as `location.search` or its parsed form. `quality=low|medium|high` wins. */
|
|
32
|
+
readonly query?: string | URLSearchParams;
|
|
33
|
+
/** A quality the player chose before, as kept in a save. Wins over the device, not over the address. */
|
|
34
|
+
readonly stored?: string | null;
|
|
35
|
+
/** True when the main pointer is a finger. */
|
|
36
|
+
readonly coarsePointer?: boolean;
|
|
37
|
+
/** The shorter side of the window, in CSS pixels. */
|
|
38
|
+
readonly shortSide?: number;
|
|
39
|
+
/** `navigator.deviceMemory`, in gigabytes, where the browser reports it. */
|
|
40
|
+
readonly deviceMemory?: number;
|
|
41
|
+
/** True when the page is drawn by software, without a graphics card. Not read from the page: see `isSoftwareRendered3D`. */
|
|
42
|
+
readonly softwareRenderer?: boolean;
|
|
43
|
+
}
|
|
44
|
+
/**
|
|
45
|
+
* The picture quality for this device: the address's `quality`, then a stored choice, then `low` for software
|
|
46
|
+
* rendering, a finger or a window shorter than 600 pixels, `medium` for 4 GB of memory or less, and `high` otherwise.
|
|
47
|
+
*/
|
|
48
|
+
export declare function pickWorld3DQuality(hints?: World3DDeviceHints): World3DQuality;
|
|
49
|
+
/**
|
|
50
|
+
* Whether WebGL here is drawn by software (SwiftShader, llvmpipe and the like), as in a headless browser, a virtual
|
|
51
|
+
* machine or a page whose graphics card is blocked. It asks a throwaway context for its renderer's name.
|
|
52
|
+
*/
|
|
53
|
+
export declare function isSoftwareRendered3D(document?: Document): boolean;
|
|
54
|
+
/** The backend asked for by the address (`backend=webgpu`), or `fallback`. */
|
|
55
|
+
export declare function pickWorld3DBackend(query?: string | URLSearchParams, fallback?: World3DBackend): World3DBackend;
|
|
56
|
+
export interface DynamicResolutionOptions3D {
|
|
57
|
+
/** Smallest share of the quality's pixel ratio drawn at. Defaults to 0.6. */
|
|
58
|
+
readonly min?: number;
|
|
59
|
+
/** Largest share. Defaults to 1. */
|
|
60
|
+
readonly max?: number;
|
|
61
|
+
/** How much one change moves the share. Defaults to 0.15. */
|
|
62
|
+
readonly step?: number;
|
|
63
|
+
/** Below this smoothed frame rate the share goes down. Defaults to 45. */
|
|
64
|
+
readonly lowFps?: number;
|
|
65
|
+
/** Above this smoothed frame rate the share goes up. Defaults to 57. */
|
|
66
|
+
readonly highFps?: number;
|
|
67
|
+
/** Seconds the rate must stay low before going down. Defaults to 1.5. */
|
|
68
|
+
readonly downAfter?: number;
|
|
69
|
+
/** Seconds the rate must stay high before going up. Defaults to 6. */
|
|
70
|
+
readonly upAfter?: number;
|
|
71
|
+
}
|
|
72
|
+
/** A drawing resolution that follows the frame rate: down quickly when frames are slow, up slowly when they are not. */
|
|
73
|
+
export interface DynamicResolution3D {
|
|
74
|
+
/** The share of the pixel ratio to draw at now. */
|
|
75
|
+
readonly scale: number;
|
|
76
|
+
/** The smoothed frame rate. */
|
|
77
|
+
readonly fps: number;
|
|
78
|
+
/** Takes one frame's seconds and returns the share to draw at. */
|
|
79
|
+
update(deltaSeconds: number): number;
|
|
80
|
+
/** Back to the largest share, as after a change of scene. */
|
|
81
|
+
reset(): void;
|
|
82
|
+
}
|
|
83
|
+
export declare function createDynamicResolution3D(options?: DynamicResolutionOptions3D): DynamicResolution3D;
|
|
84
|
+
export interface World3DAppOptions {
|
|
85
|
+
/** `webgl2` or `webgpu`. Defaults to what the address asks (`backend=`), else WebGL2. */
|
|
86
|
+
readonly backend?: World3DBackend;
|
|
87
|
+
/** A fixed quality, or `auto` (the default) for `pickWorld3DQuality`. */
|
|
88
|
+
readonly quality?: World3DQuality | 'auto';
|
|
89
|
+
/** A quality the player chose before; used by `auto` after the address. */
|
|
90
|
+
readonly storedQuality?: string | null;
|
|
91
|
+
/** The address's query; `location.search` by default. */
|
|
92
|
+
readonly query?: string | URLSearchParams;
|
|
93
|
+
/** Let the drawing resolution follow the frame rate. On by default; pass options or `false`. */
|
|
94
|
+
readonly dynamicResolution?: boolean | DynamicResolutionOptions3D;
|
|
95
|
+
readonly toneMapping?: ToneMapping3D;
|
|
96
|
+
readonly exposure?: number;
|
|
97
|
+
readonly powerPreference?: 'default' | 'low-power' | 'high-performance';
|
|
98
|
+
/** Told of failures while updating or drawing and of a stopped loop. Without it they are thrown. */
|
|
99
|
+
readonly onError?: (cause: unknown) => void;
|
|
100
|
+
/** Told once when the graphics device is lost. */
|
|
101
|
+
readonly onDeviceLost?: (message: string) => void;
|
|
102
|
+
}
|
|
103
|
+
export interface World3DShowOptions {
|
|
104
|
+
/** Called every frame before animation and drawing. */
|
|
105
|
+
readonly onUpdate?: (deltaSeconds: number, elapsedSeconds: number) => void;
|
|
106
|
+
readonly mixers?: readonly AnimationMixer3D[];
|
|
107
|
+
readonly controls?: OrbitControls3D;
|
|
108
|
+
}
|
|
109
|
+
export interface World3DApp extends Disposable {
|
|
110
|
+
readonly engine: Engine;
|
|
111
|
+
/** The Engine scope the app's view and renderer belong to. */
|
|
112
|
+
readonly scope: Scope;
|
|
113
|
+
readonly renderer: Renderer3D;
|
|
114
|
+
/** The backend in use. A WebGPU request falls back to WebGL2 when the browser has no adapter. */
|
|
115
|
+
readonly backend: World3DBackend;
|
|
116
|
+
/** True when WebGPU was asked for and WebGL2 is drawing instead. */
|
|
117
|
+
readonly fellBack: boolean;
|
|
118
|
+
readonly quality: World3DQuality;
|
|
119
|
+
/** The share of the quality's pixel ratio drawn at, 1 without dynamic resolution. */
|
|
120
|
+
readonly resolutionScale: number;
|
|
121
|
+
/** The view showing now, if any. */
|
|
122
|
+
readonly view: World3DView | undefined;
|
|
123
|
+
/** Applies another quality's shadows, post-processing and pixel ratio. Antialiasing and the atlas size stay. */
|
|
124
|
+
setQuality(quality: World3DQuality): void;
|
|
125
|
+
/** Shows a scene through a camera, replacing what was shown. The loop starts if it is not running. */
|
|
126
|
+
show(scene: Scene3D, camera: Camera3D, options?: World3DShowOptions): World3DView;
|
|
127
|
+
/** Starts or stops the frame loop. */
|
|
128
|
+
start(): void;
|
|
129
|
+
stop(): void;
|
|
130
|
+
}
|
|
131
|
+
/**
|
|
132
|
+
* Starts a World3D game on `canvas`: an Engine, a renderer for the chosen backend and quality, and a frame loop.
|
|
133
|
+
* Call `show(scene, camera)` to draw. `dispose()` ends the loop, the view, the renderer and the Engine.
|
|
134
|
+
*/
|
|
135
|
+
export declare function createWorld3DApp(canvas: HTMLCanvasElement | OffscreenCanvas, options?: World3DAppOptions): Promise<World3DApp>;
|
|
136
|
+
//# sourceMappingURL=app3D.d.ts.map
|
|
@@ -0,0 +1,304 @@
|
|
|
1
|
+
// SPDX-License-Identifier: Apache-2.0
|
|
2
|
+
// A World3D game in a page from one call: the backend chosen from the address or the device, an Engine on a
|
|
3
|
+
// World3D host, a renderer set up for a picture quality, a frame loop, and a drawing resolution that follows the
|
|
4
|
+
// frame rate. Each piece is made the way its own module makes it, and one dispose ends them all.
|
|
5
|
+
import { createEngine } from '@egret/engine';
|
|
6
|
+
import { World3DError } from '../../rendering/world3d/core3D.js';
|
|
7
|
+
import { createWorld3DHost, startWorld3DLoop } from './host3D.js';
|
|
8
|
+
import { World3DView } from './World3DView.js';
|
|
9
|
+
/** The three qualities. A phone gets `low`, a desktop `high`; `medium` sits between for weaker computers. */
|
|
10
|
+
export const WORLD3D_QUALITY_PRESETS = Object.freeze({
|
|
11
|
+
low: Object.freeze({
|
|
12
|
+
pixelRatio: 1,
|
|
13
|
+
antialias: false,
|
|
14
|
+
shadows: false,
|
|
15
|
+
shadowAtlasSize: 1024,
|
|
16
|
+
post: false,
|
|
17
|
+
bloom: false,
|
|
18
|
+
ssao: false,
|
|
19
|
+
fxaa: false
|
|
20
|
+
}),
|
|
21
|
+
medium: Object.freeze({
|
|
22
|
+
pixelRatio: 1.5,
|
|
23
|
+
antialias: true,
|
|
24
|
+
shadows: true,
|
|
25
|
+
shadowAtlasSize: 2048,
|
|
26
|
+
post: true,
|
|
27
|
+
bloom: true,
|
|
28
|
+
ssao: false,
|
|
29
|
+
fxaa: true
|
|
30
|
+
}),
|
|
31
|
+
high: Object.freeze({
|
|
32
|
+
pixelRatio: 2,
|
|
33
|
+
antialias: true,
|
|
34
|
+
shadows: true,
|
|
35
|
+
shadowAtlasSize: 4096,
|
|
36
|
+
post: true,
|
|
37
|
+
bloom: true,
|
|
38
|
+
ssao: true,
|
|
39
|
+
fxaa: true
|
|
40
|
+
})
|
|
41
|
+
});
|
|
42
|
+
const QUALITIES = ['low', 'medium', 'high'];
|
|
43
|
+
const isQuality = (value) => typeof value === 'string' && QUALITIES.includes(value);
|
|
44
|
+
const params = (query) => {
|
|
45
|
+
if (query instanceof URLSearchParams)
|
|
46
|
+
return query;
|
|
47
|
+
if (typeof query === 'string')
|
|
48
|
+
return new URLSearchParams(query);
|
|
49
|
+
const search = globalThis.location?.search;
|
|
50
|
+
return typeof search === 'string' ? new URLSearchParams(search) : undefined;
|
|
51
|
+
};
|
|
52
|
+
/**
|
|
53
|
+
* The picture quality for this device: the address's `quality`, then a stored choice, then `low` for software
|
|
54
|
+
* rendering, a finger or a window shorter than 600 pixels, `medium` for 4 GB of memory or less, and `high` otherwise.
|
|
55
|
+
*/
|
|
56
|
+
export function pickWorld3DQuality(hints = {}) {
|
|
57
|
+
const asked = params(hints.query)?.get('quality');
|
|
58
|
+
if (isQuality(asked))
|
|
59
|
+
return asked;
|
|
60
|
+
if (isQuality(hints.stored))
|
|
61
|
+
return hints.stored;
|
|
62
|
+
const g = globalThis;
|
|
63
|
+
// Drawn by the processor, every effect is paid for many times over.
|
|
64
|
+
if (hints.softwareRenderer === true)
|
|
65
|
+
return 'low';
|
|
66
|
+
const coarse = hints.coarsePointer ?? g.matchMedia?.('(pointer: coarse)').matches ?? false;
|
|
67
|
+
const shortSide = hints.shortSide ?? Math.min(g.innerWidth ?? 1200, g.innerHeight ?? 800);
|
|
68
|
+
if (coarse || shortSide < 600)
|
|
69
|
+
return 'low';
|
|
70
|
+
const memory = hints.deviceMemory ?? g.navigator?.deviceMemory;
|
|
71
|
+
if (typeof memory === 'number' && memory <= 4)
|
|
72
|
+
return 'medium';
|
|
73
|
+
return 'high';
|
|
74
|
+
}
|
|
75
|
+
/**
|
|
76
|
+
* Whether WebGL here is drawn by software (SwiftShader, llvmpipe and the like), as in a headless browser, a virtual
|
|
77
|
+
* machine or a page whose graphics card is blocked. It asks a throwaway context for its renderer's name.
|
|
78
|
+
*/
|
|
79
|
+
export function isSoftwareRendered3D(document = globalThis.document) {
|
|
80
|
+
try {
|
|
81
|
+
const gl = document.createElement('canvas').getContext('webgl2');
|
|
82
|
+
if (!gl)
|
|
83
|
+
return false;
|
|
84
|
+
const info = gl.getExtension('WEBGL_debug_renderer_info');
|
|
85
|
+
const name = String(info ? gl.getParameter(info.UNMASKED_RENDERER_WEBGL) : gl.getParameter(gl.RENDERER));
|
|
86
|
+
gl.getExtension('WEBGL_lose_context')?.loseContext();
|
|
87
|
+
return /swiftshader|llvmpipe|softpipe|software/i.test(name);
|
|
88
|
+
}
|
|
89
|
+
catch {
|
|
90
|
+
return false;
|
|
91
|
+
}
|
|
92
|
+
}
|
|
93
|
+
/** The backend asked for by the address (`backend=webgpu`), or `fallback`. */
|
|
94
|
+
export function pickWorld3DBackend(query, fallback = 'webgl2') {
|
|
95
|
+
const asked = params(query)?.get('backend');
|
|
96
|
+
return asked === 'webgpu' || asked === 'webgl2' ? asked : fallback;
|
|
97
|
+
}
|
|
98
|
+
export function createDynamicResolution3D(options = {}) {
|
|
99
|
+
const min = options.min ?? 0.6, max = options.max ?? 1, step = options.step ?? 0.15, lowFps = options.lowFps ?? 45, highFps = options.highFps ?? 57, downAfter = options.downAfter ?? 1.5, upAfter = options.upAfter ?? 6;
|
|
100
|
+
const numbers = [min, max, step, lowFps, highFps, downAfter, upAfter];
|
|
101
|
+
if (!numbers.every(n => typeof n === 'number' && Number.isFinite(n) && n > 0) || min > max || lowFps >= highFps)
|
|
102
|
+
throw new World3DError('WORLD3D_INPUT_INVALID', 'dynamic resolution');
|
|
103
|
+
let scale = max, fps = 60, slow = 0, fast = 0;
|
|
104
|
+
return {
|
|
105
|
+
get scale() {
|
|
106
|
+
return scale;
|
|
107
|
+
},
|
|
108
|
+
get fps() {
|
|
109
|
+
return fps;
|
|
110
|
+
},
|
|
111
|
+
update(deltaSeconds) {
|
|
112
|
+
// A frame of zero or of a hidden tab says nothing about the device.
|
|
113
|
+
if (!(deltaSeconds > 0) || deltaSeconds > 0.5)
|
|
114
|
+
return scale;
|
|
115
|
+
fps += (1 / deltaSeconds - fps) * 0.05;
|
|
116
|
+
slow = fps < lowFps ? slow + deltaSeconds : 0;
|
|
117
|
+
fast = fps > highFps ? fast + deltaSeconds : 0;
|
|
118
|
+
if (slow >= downAfter && scale > min) {
|
|
119
|
+
scale = Math.max(min, scale - step);
|
|
120
|
+
slow = 0;
|
|
121
|
+
}
|
|
122
|
+
else if (fast >= upAfter && scale < max) {
|
|
123
|
+
scale = Math.min(max, scale + step);
|
|
124
|
+
fast = 0;
|
|
125
|
+
}
|
|
126
|
+
return scale;
|
|
127
|
+
},
|
|
128
|
+
reset() {
|
|
129
|
+
scale = max;
|
|
130
|
+
fps = 60;
|
|
131
|
+
slow = fast = 0;
|
|
132
|
+
}
|
|
133
|
+
};
|
|
134
|
+
}
|
|
135
|
+
async function hasWebGPUAdapter(powerPreference) {
|
|
136
|
+
const gpu = globalThis.navigator
|
|
137
|
+
?.gpu;
|
|
138
|
+
if (!gpu || typeof gpu.requestAdapter !== 'function')
|
|
139
|
+
return false;
|
|
140
|
+
try {
|
|
141
|
+
const options = powerPreference && powerPreference !== 'default' ? { powerPreference } : undefined;
|
|
142
|
+
return (await gpu.requestAdapter(options)) != null;
|
|
143
|
+
}
|
|
144
|
+
catch {
|
|
145
|
+
return false;
|
|
146
|
+
}
|
|
147
|
+
}
|
|
148
|
+
/**
|
|
149
|
+
* Starts a World3D game on `canvas`: an Engine, a renderer for the chosen backend and quality, and a frame loop.
|
|
150
|
+
* Call `show(scene, camera)` to draw. `dispose()` ends the loop, the view, the renderer and the Engine.
|
|
151
|
+
*/
|
|
152
|
+
export async function createWorld3DApp(canvas, options = {}) {
|
|
153
|
+
if (typeof canvas !== 'object' || canvas === null)
|
|
154
|
+
throw new World3DError('WORLD3D_INPUT_INVALID', 'canvas');
|
|
155
|
+
if (typeof options !== 'object' || options === null)
|
|
156
|
+
throw new World3DError('WORLD3D_INPUT_INVALID', 'options');
|
|
157
|
+
const asked = options.backend ?? pickWorld3DBackend(options.query);
|
|
158
|
+
if (asked !== 'webgl2' && asked !== 'webgpu')
|
|
159
|
+
throw new World3DError('WORLD3D_INPUT_INVALID', 'backend');
|
|
160
|
+
const askedQuality = options.quality ?? 'auto';
|
|
161
|
+
if (askedQuality !== 'auto' && !isQuality(askedQuality))
|
|
162
|
+
throw new World3DError('WORLD3D_INPUT_INVALID', 'quality');
|
|
163
|
+
let quality = askedQuality === 'auto'
|
|
164
|
+
? pickWorld3DQuality({
|
|
165
|
+
...(options.query === undefined ? {} : { query: options.query }),
|
|
166
|
+
...(options.storedQuality === undefined ? {} : { stored: options.storedQuality }),
|
|
167
|
+
softwareRenderer: isSoftwareRendered3D('ownerDocument' in canvas ? canvas.ownerDocument : undefined)
|
|
168
|
+
})
|
|
169
|
+
: askedQuality;
|
|
170
|
+
const preset = WORLD3D_QUALITY_PRESETS[quality];
|
|
171
|
+
const resolution = options.dynamicResolution === false
|
|
172
|
+
? undefined
|
|
173
|
+
: createDynamicResolution3D(options.dynamicResolution === true ? {} : options.dynamicResolution);
|
|
174
|
+
const backend = asked === 'webgpu' && (await hasWebGPUAdapter(options.powerPreference)) ? 'webgpu' : 'webgl2';
|
|
175
|
+
const common = {
|
|
176
|
+
canvas,
|
|
177
|
+
antialias: preset.antialias,
|
|
178
|
+
shadows: preset.shadows,
|
|
179
|
+
shadowAtlasSize: preset.shadowAtlasSize,
|
|
180
|
+
...(options.toneMapping === undefined ? {} : { toneMapping: options.toneMapping }),
|
|
181
|
+
...(options.exposure === undefined ? {} : { exposure: options.exposure })
|
|
182
|
+
};
|
|
183
|
+
const engine = await createEngine({ host: createWorld3DHost(canvas) });
|
|
184
|
+
let renderer;
|
|
185
|
+
try {
|
|
186
|
+
if (backend === 'webgpu') {
|
|
187
|
+
const { createWebGPURenderer3D } = await import('./WebGPURenderer3D.js');
|
|
188
|
+
renderer = await createWebGPURenderer3D({
|
|
189
|
+
...common,
|
|
190
|
+
...(options.powerPreference && options.powerPreference !== 'default'
|
|
191
|
+
? { powerPreference: options.powerPreference }
|
|
192
|
+
: {}),
|
|
193
|
+
...(options.onDeviceLost ? { onDeviceLost: options.onDeviceLost } : {})
|
|
194
|
+
});
|
|
195
|
+
}
|
|
196
|
+
else {
|
|
197
|
+
const { createWebGL2Renderer3D } = await import('./WebGL2Renderer3D.js');
|
|
198
|
+
renderer = createWebGL2Renderer3D({
|
|
199
|
+
...common,
|
|
200
|
+
...(options.powerPreference ? { powerPreference: options.powerPreference } : {}),
|
|
201
|
+
...(options.onDeviceLost ? { onContextLost: () => options.onDeviceLost('context lost') } : {})
|
|
202
|
+
});
|
|
203
|
+
}
|
|
204
|
+
}
|
|
205
|
+
catch (cause) {
|
|
206
|
+
await engine.dispose();
|
|
207
|
+
throw cause;
|
|
208
|
+
}
|
|
209
|
+
const scope = engine.createScope();
|
|
210
|
+
scope.use(renderer);
|
|
211
|
+
const apply = (next) => {
|
|
212
|
+
renderer.shadowsEnabled = next.shadows;
|
|
213
|
+
const post = renderer.postProcess;
|
|
214
|
+
post.enabled = next.post;
|
|
215
|
+
post.bloom = next.bloom;
|
|
216
|
+
post.ssao = next.ssao;
|
|
217
|
+
post.fxaa = next.fxaa;
|
|
218
|
+
};
|
|
219
|
+
apply(preset);
|
|
220
|
+
let view, loop, disposed = false;
|
|
221
|
+
const fail = (cause) => {
|
|
222
|
+
if (!options.onError)
|
|
223
|
+
throw cause;
|
|
224
|
+
options.onError(cause);
|
|
225
|
+
};
|
|
226
|
+
const resize = (camera) => {
|
|
227
|
+
const dpr = typeof devicePixelRatio === 'number' ? devicePixelRatio : 1;
|
|
228
|
+
const ratio = Math.min(dpr, WORLD3D_QUALITY_PRESETS[quality].pixelRatio) * (resolution?.scale ?? 1);
|
|
229
|
+
renderer.resizeToDisplaySize(ratio);
|
|
230
|
+
const drawn = renderer.canvas;
|
|
231
|
+
if (drawn.height > 0)
|
|
232
|
+
camera.aspect = drawn.width / drawn.height;
|
|
233
|
+
};
|
|
234
|
+
const app = {
|
|
235
|
+
engine,
|
|
236
|
+
scope,
|
|
237
|
+
renderer,
|
|
238
|
+
backend,
|
|
239
|
+
fellBack: asked === 'webgpu' && backend === 'webgl2',
|
|
240
|
+
get quality() {
|
|
241
|
+
return quality;
|
|
242
|
+
},
|
|
243
|
+
get resolutionScale() {
|
|
244
|
+
return resolution?.scale ?? 1;
|
|
245
|
+
},
|
|
246
|
+
get view() {
|
|
247
|
+
return view;
|
|
248
|
+
},
|
|
249
|
+
setQuality(next) {
|
|
250
|
+
if (!isQuality(next))
|
|
251
|
+
throw new World3DError('WORLD3D_INPUT_INVALID', 'quality');
|
|
252
|
+
quality = next;
|
|
253
|
+
apply(WORLD3D_QUALITY_PRESETS[next]);
|
|
254
|
+
resolution?.reset();
|
|
255
|
+
},
|
|
256
|
+
show(scene, camera, show = {}) {
|
|
257
|
+
if (disposed)
|
|
258
|
+
throw new World3DError('WORLD3D_DISPOSED', 'app');
|
|
259
|
+
view?.dispose();
|
|
260
|
+
resolution?.reset();
|
|
261
|
+
const created = new World3DView(engine, scope, {
|
|
262
|
+
renderer,
|
|
263
|
+
scene,
|
|
264
|
+
camera,
|
|
265
|
+
autoResize: false,
|
|
266
|
+
...(show.mixers ? { mixers: show.mixers } : {}),
|
|
267
|
+
...(show.controls ? { controls: show.controls } : {}),
|
|
268
|
+
...(options.onError ? { onError: options.onError } : {}),
|
|
269
|
+
onUpdate(deltaSeconds, elapsedSeconds) {
|
|
270
|
+
resolution?.update(deltaSeconds);
|
|
271
|
+
resize(created.camera);
|
|
272
|
+
show.onUpdate?.(deltaSeconds, elapsedSeconds);
|
|
273
|
+
}
|
|
274
|
+
});
|
|
275
|
+
view = created;
|
|
276
|
+
app.start();
|
|
277
|
+
return created;
|
|
278
|
+
},
|
|
279
|
+
start() {
|
|
280
|
+
if (disposed)
|
|
281
|
+
throw new World3DError('WORLD3D_DISPOSED', 'app');
|
|
282
|
+
loop ??= startWorld3DLoop(engine, cause => {
|
|
283
|
+
loop = undefined;
|
|
284
|
+
fail(cause);
|
|
285
|
+
});
|
|
286
|
+
},
|
|
287
|
+
stop() {
|
|
288
|
+
loop?.dispose();
|
|
289
|
+
loop = undefined;
|
|
290
|
+
},
|
|
291
|
+
dispose() {
|
|
292
|
+
if (disposed)
|
|
293
|
+
return;
|
|
294
|
+
disposed = true;
|
|
295
|
+
app.stop();
|
|
296
|
+
view?.dispose();
|
|
297
|
+
view = undefined;
|
|
298
|
+
// Closing the Engine closes its scopes, which dispose the renderer.
|
|
299
|
+
void engine.dispose();
|
|
300
|
+
}
|
|
301
|
+
};
|
|
302
|
+
return app;
|
|
303
|
+
}
|
|
304
|
+
//# sourceMappingURL=app3D.js.map
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import type { AssetManager, AssetType } from '@egret/runtime';
|
|
2
|
+
import type { GltfAsset3D } from '../../rendering/world3d/Gltf3D.js';
|
|
3
|
+
import type { DeserializedScene3D, DeserializeOptions3D } from '../../rendering/world3d/Serialize3D.js';
|
|
4
|
+
import { CubeTexture3D, Texture3D } from '../../rendering/world3d/Texture3D.js';
|
|
5
|
+
import type { TextureOptions3D } from '../../rendering/world3d/Texture3D.js';
|
|
6
|
+
import type { GltfUrlLoadOptions3D, TextureLoadOptions3D } from './loaders3D.js';
|
|
7
|
+
/** A loaded glTF file. The reference id is the file URL. */
|
|
8
|
+
export declare const GLTF_ASSET_3D: AssetType<GltfAsset3D>;
|
|
9
|
+
/** A 2D texture loaded from an image or KTX2 file. The reference id is the file URL. */
|
|
10
|
+
export declare const TEXTURE_ASSET_3D: AssetType<Texture3D>;
|
|
11
|
+
/**
|
|
12
|
+
* A cube texture. The reference id is a URL containing `{face}`, replaced by
|
|
13
|
+
* px, nx, py, ny, pz and nz in turn.
|
|
14
|
+
*/
|
|
15
|
+
export declare const CUBE_TEXTURE_ASSET_3D: AssetType<CubeTexture3D>;
|
|
16
|
+
/** A scene document written by serializeScene3D. The reference id is the JSON file URL. */
|
|
17
|
+
export declare const SCENE_ASSET_3D: AssetType<DeserializedScene3D>;
|
|
18
|
+
export interface World3DAssetOptions {
|
|
19
|
+
/** Map a reference id to the URL to download. Defaults to using the id as the URL. */
|
|
20
|
+
readonly resolveUrl?: (id: string) => string;
|
|
21
|
+
/** Upper bound for one downloaded file, in bytes. */
|
|
22
|
+
readonly maxBytes?: number;
|
|
23
|
+
/** Sampling options applied to every texture loaded through TEXTURE_ASSET_3D. */
|
|
24
|
+
readonly texture?: TextureOptions3D;
|
|
25
|
+
/** Sampling options applied to every cube texture. */
|
|
26
|
+
readonly cubeTexture?: TextureOptions3D;
|
|
27
|
+
readonly transcodeKtx2?: TextureLoadOptions3D['transcodeKtx2'];
|
|
28
|
+
readonly decodeMeshopt?: GltfUrlLoadOptions3D['decodeMeshopt'];
|
|
29
|
+
readonly decodeDraco?: GltfUrlLoadOptions3D['decodeDraco'];
|
|
30
|
+
/** Resolve keyed textures referenced by scene documents. */
|
|
31
|
+
readonly resolveTexture?: DeserializeOptions3D['resolveTexture'];
|
|
32
|
+
}
|
|
33
|
+
/**
|
|
34
|
+
* Register the World3D asset providers on an AssetManager. Call once per
|
|
35
|
+
* Engine, then acquire with `assets.acquire(createAssetRef(GLTF_ASSET_3D, url))`.
|
|
36
|
+
*/
|
|
37
|
+
export declare function registerWorld3DAssets(assets: AssetManager, options?: World3DAssetOptions): void;
|
|
38
|
+
//# sourceMappingURL=assets3D.d.ts.map
|