@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,237 @@
|
|
|
1
|
+
// SPDX-License-Identifier: Apache-2.0
|
|
2
|
+
// WebGL2 side of the world3d post-processing chain. The renderer draws the
|
|
3
|
+
// scene into `scene`, then run() blooms, grades and anti-aliases it into the
|
|
4
|
+
// canvas or the caller's target.
|
|
5
|
+
import { World3DError } from '../../rendering/world3d/core3D.js';
|
|
6
|
+
import { Material3D } from '../../rendering/world3d/Material3D.js';
|
|
7
|
+
import { RenderTarget3D } from '../../rendering/world3d/Texture3D.js';
|
|
8
|
+
import { POST_DOF_GLSL_3D, POST_DOWN_GLSL_3D, POST_FXAA_GLSL_3D, POST_SSAO_GLSL_3D, POST_UP_GLSL_3D, POST_VERTEX_GLSL_3D, bloomLevelCount3D, postCompositeGlsl3D, writeCompositeParams3D } from './post3D.js';
|
|
9
|
+
export class PostChainWebGL23D {
|
|
10
|
+
/** Half-float scene target the renderer draws into before run(). */
|
|
11
|
+
scene = new RenderTarget3D(1, 1, { format: 'rgba16f', depthTexture: true, name: 'world3d.post.scene' });
|
|
12
|
+
/** Target and flat white material for the outline mask. */
|
|
13
|
+
mask = new RenderTarget3D(1, 1, { name: 'world3d.post.mask' });
|
|
14
|
+
maskMaterial = (() => {
|
|
15
|
+
const material = new Material3D('unlit', { side: 'double' });
|
|
16
|
+
material.fog = false;
|
|
17
|
+
material.toneMapped = false;
|
|
18
|
+
return material;
|
|
19
|
+
})();
|
|
20
|
+
#gl;
|
|
21
|
+
#resources;
|
|
22
|
+
#float;
|
|
23
|
+
#levels = [];
|
|
24
|
+
#ldr;
|
|
25
|
+
#ao;
|
|
26
|
+
#dof;
|
|
27
|
+
#black = null;
|
|
28
|
+
#params = new Float32Array(8);
|
|
29
|
+
#view;
|
|
30
|
+
#aoOn = false;
|
|
31
|
+
#custom;
|
|
32
|
+
#outline;
|
|
33
|
+
constructor(gl, resources) {
|
|
34
|
+
this.#gl = gl;
|
|
35
|
+
this.#resources = resources;
|
|
36
|
+
this.#float = resources.floatTargets;
|
|
37
|
+
}
|
|
38
|
+
surface(existing, width, height, float) {
|
|
39
|
+
const gl = this.#gl;
|
|
40
|
+
if (existing && existing.width === width && existing.height === height)
|
|
41
|
+
return existing;
|
|
42
|
+
const texture = existing?.texture ?? gl.createTexture(), framebuffer = existing?.framebuffer ?? gl.createFramebuffer();
|
|
43
|
+
if (!texture || !framebuffer)
|
|
44
|
+
throw new World3DError('WORLD3D_CONTEXT_LOST', 'post surface');
|
|
45
|
+
gl.bindTexture(gl.TEXTURE_2D, texture);
|
|
46
|
+
if (float)
|
|
47
|
+
gl.texImage2D(gl.TEXTURE_2D, 0, gl.RGBA16F, width, height, 0, gl.RGBA, gl.HALF_FLOAT, null);
|
|
48
|
+
else
|
|
49
|
+
gl.texImage2D(gl.TEXTURE_2D, 0, gl.RGBA8, width, height, 0, gl.RGBA, gl.UNSIGNED_BYTE, null);
|
|
50
|
+
gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MIN_FILTER, gl.LINEAR);
|
|
51
|
+
gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MAG_FILTER, gl.LINEAR);
|
|
52
|
+
gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_WRAP_S, gl.CLAMP_TO_EDGE);
|
|
53
|
+
gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_WRAP_T, gl.CLAMP_TO_EDGE);
|
|
54
|
+
gl.bindFramebuffer(gl.FRAMEBUFFER, framebuffer);
|
|
55
|
+
gl.framebufferTexture2D(gl.FRAMEBUFFER, gl.COLOR_ATTACHMENT0, gl.TEXTURE_2D, texture, 0);
|
|
56
|
+
return { texture, framebuffer, width, height };
|
|
57
|
+
}
|
|
58
|
+
pass(program, source, framebuffer, width, height, a, b) {
|
|
59
|
+
const gl = this.#gl, u = program.uniforms;
|
|
60
|
+
gl.useProgram(program.program);
|
|
61
|
+
gl.bindFramebuffer(gl.FRAMEBUFFER, framebuffer);
|
|
62
|
+
gl.viewport(0, 0, width, height);
|
|
63
|
+
gl.activeTexture(gl.TEXTURE0);
|
|
64
|
+
gl.bindTexture(gl.TEXTURE_2D, source);
|
|
65
|
+
if (u['uSource'])
|
|
66
|
+
gl.uniform1i(u['uSource'], 0);
|
|
67
|
+
if (u['uBloom'])
|
|
68
|
+
gl.uniform1i(u['uBloom'], 1);
|
|
69
|
+
if (u['uA'])
|
|
70
|
+
gl.uniform4f(u['uA'], a[0], a[1], a[2], a[3]);
|
|
71
|
+
if (u['uB'])
|
|
72
|
+
gl.uniform4f(u['uB'], b[0], b[1], b[2], b[3]);
|
|
73
|
+
// Depth-reading passes: units 2 and 3 are bound by run().
|
|
74
|
+
if (u['uDepth'])
|
|
75
|
+
gl.uniform1i(u['uDepth'], 2);
|
|
76
|
+
if (u['uAo'])
|
|
77
|
+
gl.uniform1i(u['uAo'], 3);
|
|
78
|
+
if (u['uMask'])
|
|
79
|
+
gl.uniform1i(u['uMask'], 4);
|
|
80
|
+
const outline = this.#outline;
|
|
81
|
+
if (u['uOutline'])
|
|
82
|
+
gl.uniform4f(u['uOutline'], outline ? outline.outlineColor[0] : 0, outline ? outline.outlineColor[1] : 0, outline ? outline.outlineColor[2] : 0, outline ? outline.outlineThickness : 0);
|
|
83
|
+
const view = this.#view;
|
|
84
|
+
if (u['uInverseProjection'] && view)
|
|
85
|
+
gl.uniformMatrix4fv(u['uInverseProjection'], false, view.inverseProjection);
|
|
86
|
+
if (u['uFlags'])
|
|
87
|
+
gl.uniform4f(u['uFlags'], 0, this.#aoOn ? 1 : 0, 1 / width, 1 / height);
|
|
88
|
+
const customLocation = u['uPostCustom[0]'] ?? u['uPostCustom'];
|
|
89
|
+
if (customLocation && this.#custom)
|
|
90
|
+
gl.uniform4fv(customLocation, this.#custom);
|
|
91
|
+
gl.drawArrays(gl.TRIANGLES, 0, 3);
|
|
92
|
+
}
|
|
93
|
+
/**
|
|
94
|
+
* Process `sceneTexture` into `output` (null for the canvas).
|
|
95
|
+
* `outputEncodes` is true when the output converts linear values to sRGB on write.
|
|
96
|
+
*/
|
|
97
|
+
run(sceneTexture, depthTexture, maskTexture, view, width, height, output, outputEncodes, settings, toneMapping, vao) {
|
|
98
|
+
const gl = this.#gl, resources = this.#resources;
|
|
99
|
+
gl.bindVertexArray(vao);
|
|
100
|
+
gl.disable(gl.DEPTH_TEST);
|
|
101
|
+
gl.disable(gl.CULL_FACE);
|
|
102
|
+
gl.disable(gl.BLEND);
|
|
103
|
+
gl.disable(gl.SCISSOR_TEST);
|
|
104
|
+
gl.depthMask(false);
|
|
105
|
+
gl.colorMask(true, true, true, true);
|
|
106
|
+
let draws = 0;
|
|
107
|
+
this.#view = view;
|
|
108
|
+
this.#aoOn = false;
|
|
109
|
+
this.#custom = undefined;
|
|
110
|
+
this.#outline = maskTexture ? settings : undefined;
|
|
111
|
+
const useAo = settings.ssao && depthTexture !== undefined && settings.ssaoIntensity > 0;
|
|
112
|
+
// Allocate before binding the shared units: allocation binds on the active unit.
|
|
113
|
+
const ao = useAo ? (this.#ao = this.surface(this.#ao, width, height, false)) : undefined;
|
|
114
|
+
gl.activeTexture(gl.TEXTURE2);
|
|
115
|
+
gl.bindTexture(gl.TEXTURE_2D, depthTexture ?? null);
|
|
116
|
+
gl.activeTexture(gl.TEXTURE0);
|
|
117
|
+
if (ao) {
|
|
118
|
+
const program = resources.program('post/ssao', () => ({
|
|
119
|
+
vertex: POST_VERTEX_GLSL_3D,
|
|
120
|
+
fragment: POST_SSAO_GLSL_3D
|
|
121
|
+
}));
|
|
122
|
+
this.pass(program, sceneTexture, ao.framebuffer, width, height, [Math.max(settings.ssaoRadius, 0.001), settings.ssaoIntensity, settings.ssaoBias, 0], [0, 0, 0, 0]);
|
|
123
|
+
draws++;
|
|
124
|
+
}
|
|
125
|
+
if (settings.dof && depthTexture !== undefined && settings.dofRadius > 0) {
|
|
126
|
+
// Everything after this reads the blurred image as the scene.
|
|
127
|
+
const dof = (this.#dof = this.surface(this.#dof, width, height, this.#float));
|
|
128
|
+
const program = resources.program('post/dof', () => ({
|
|
129
|
+
vertex: POST_VERTEX_GLSL_3D,
|
|
130
|
+
fragment: POST_DOF_GLSL_3D
|
|
131
|
+
}));
|
|
132
|
+
this.pass(program, sceneTexture, dof.framebuffer, width, height, [settings.dofFocus, Math.max(settings.dofRange, 0.001), settings.dofRadius, 0], [0, 0, 0, 0]);
|
|
133
|
+
sceneTexture = dof.texture;
|
|
134
|
+
draws++;
|
|
135
|
+
}
|
|
136
|
+
const levels = bloomLevelCount3D(settings, width, height);
|
|
137
|
+
if (levels > 0) {
|
|
138
|
+
const down = resources.program('post/down', () => ({ vertex: POST_VERTEX_GLSL_3D, fragment: POST_DOWN_GLSL_3D }));
|
|
139
|
+
const up = resources.program('post/up', () => ({ vertex: POST_VERTEX_GLSL_3D, fragment: POST_UP_GLSL_3D }));
|
|
140
|
+
let w = width, h = height, source = sceneTexture;
|
|
141
|
+
for (let i = 0; i < levels; i++) {
|
|
142
|
+
const sourceWidth = w, sourceHeight = h;
|
|
143
|
+
w = Math.max(w >> 1, 1);
|
|
144
|
+
h = Math.max(h >> 1, 1);
|
|
145
|
+
const level = (this.#levels[i] = this.surface(this.#levels[i], w, h, this.#float));
|
|
146
|
+
this.pass(down, source, level.framebuffer, w, h, [1 / sourceWidth, 1 / sourceHeight, settings.bloomThreshold, Math.min(Math.max(settings.bloomKnee, 0), 1)], [i === 0 ? 1 : 0, 0, 0, 0]);
|
|
147
|
+
source = level.texture;
|
|
148
|
+
draws++;
|
|
149
|
+
}
|
|
150
|
+
// Walk back up, adding each blurred level onto the next larger one.
|
|
151
|
+
gl.enable(gl.BLEND);
|
|
152
|
+
gl.blendFunc(gl.ONE, gl.ONE);
|
|
153
|
+
for (let i = levels - 1; i > 0; i--) {
|
|
154
|
+
const from = this.#levels[i], to = this.#levels[i - 1];
|
|
155
|
+
this.pass(up, from.texture, to.framebuffer, to.width, to.height, [1 / from.width, 1 / from.height, 0, 0], [0, 0, 0, 0]);
|
|
156
|
+
draws++;
|
|
157
|
+
}
|
|
158
|
+
gl.disable(gl.BLEND);
|
|
159
|
+
}
|
|
160
|
+
if (!this.#black) {
|
|
161
|
+
this.#black = gl.createTexture();
|
|
162
|
+
gl.activeTexture(gl.TEXTURE0);
|
|
163
|
+
gl.bindTexture(gl.TEXTURE_2D, this.#black);
|
|
164
|
+
gl.texImage2D(gl.TEXTURE_2D, 0, gl.RGBA8, 1, 1, 0, gl.RGBA, gl.UNSIGNED_BYTE, new Uint8Array(4));
|
|
165
|
+
}
|
|
166
|
+
// Allocate the intermediate before binding unit 1: allocation binds on the active unit.
|
|
167
|
+
const ldr = settings.fxaa ? (this.#ldr = this.surface(this.#ldr, width, height, false)) : undefined;
|
|
168
|
+
gl.activeTexture(gl.TEXTURE1);
|
|
169
|
+
gl.bindTexture(gl.TEXTURE_2D, levels > 0 ? this.#levels[0].texture : this.#black);
|
|
170
|
+
gl.activeTexture(gl.TEXTURE4);
|
|
171
|
+
gl.bindTexture(gl.TEXTURE_2D, maskTexture ?? this.#black);
|
|
172
|
+
gl.activeTexture(gl.TEXTURE3);
|
|
173
|
+
gl.bindTexture(gl.TEXTURE_2D, ao ? ao.texture : this.#black);
|
|
174
|
+
this.#aoOn = ao !== undefined;
|
|
175
|
+
// The hook needs depth; without a depth texture it is left out rather than reading garbage.
|
|
176
|
+
const custom = depthTexture !== undefined && settings.custom?.glsl !== undefined ? settings.custom : undefined;
|
|
177
|
+
this.#custom = custom?.uniforms;
|
|
178
|
+
const composite = resources.program('post/composite' + (custom ? '|' + custom.key : ''), () => ({
|
|
179
|
+
vertex: POST_VERTEX_GLSL_3D,
|
|
180
|
+
fragment: postCompositeGlsl3D(custom?.glsl)
|
|
181
|
+
}));
|
|
182
|
+
const p = this.#params;
|
|
183
|
+
if (ldr) {
|
|
184
|
+
// FXAA works on display-encoded color, so the composite always encodes into the intermediate.
|
|
185
|
+
writeCompositeParams3D(p, settings, levels, toneMapping, true);
|
|
186
|
+
this.pass(composite, sceneTexture, ldr.framebuffer, width, height, [p[0], p[1], p[2], p[3]], [p[4], p[5], p[6], p[7]]);
|
|
187
|
+
const fxaa = resources.program('post/fxaa', () => ({ vertex: POST_VERTEX_GLSL_3D, fragment: POST_FXAA_GLSL_3D }));
|
|
188
|
+
this.pass(fxaa, ldr.texture, output, width, height, [1 / width, 1 / height, outputEncodes ? 1 : 0, 0], [0, 0, 0, 0]);
|
|
189
|
+
draws += 2;
|
|
190
|
+
}
|
|
191
|
+
else {
|
|
192
|
+
writeCompositeParams3D(p, settings, levels, toneMapping, !outputEncodes);
|
|
193
|
+
this.pass(composite, sceneTexture, output, width, height, [p[0], p[1], p[2], p[3]], [p[4], p[5], p[6], p[7]]);
|
|
194
|
+
draws++;
|
|
195
|
+
}
|
|
196
|
+
gl.activeTexture(gl.TEXTURE4);
|
|
197
|
+
gl.bindTexture(gl.TEXTURE_2D, null);
|
|
198
|
+
gl.activeTexture(gl.TEXTURE3);
|
|
199
|
+
gl.bindTexture(gl.TEXTURE_2D, null);
|
|
200
|
+
gl.activeTexture(gl.TEXTURE2);
|
|
201
|
+
gl.bindTexture(gl.TEXTURE_2D, null);
|
|
202
|
+
gl.activeTexture(gl.TEXTURE1);
|
|
203
|
+
gl.bindTexture(gl.TEXTURE_2D, null);
|
|
204
|
+
gl.activeTexture(gl.TEXTURE0);
|
|
205
|
+
gl.bindTexture(gl.TEXTURE_2D, null);
|
|
206
|
+
gl.bindFramebuffer(gl.FRAMEBUFFER, null);
|
|
207
|
+
gl.bindVertexArray(null);
|
|
208
|
+
gl.depthMask(true);
|
|
209
|
+
return draws;
|
|
210
|
+
}
|
|
211
|
+
/** Release GPU objects. Pass `lost` after a context loss, when they are already gone. */
|
|
212
|
+
dispose(lost = false) {
|
|
213
|
+
const gl = this.#gl;
|
|
214
|
+
if (!lost) {
|
|
215
|
+
for (const surface of [
|
|
216
|
+
...this.#levels,
|
|
217
|
+
...(this.#ldr ? [this.#ldr] : []),
|
|
218
|
+
...(this.#ao ? [this.#ao] : []),
|
|
219
|
+
...(this.#dof ? [this.#dof] : [])
|
|
220
|
+
]) {
|
|
221
|
+
gl.deleteTexture(surface.texture);
|
|
222
|
+
gl.deleteFramebuffer(surface.framebuffer);
|
|
223
|
+
}
|
|
224
|
+
if (this.#black)
|
|
225
|
+
gl.deleteTexture(this.#black);
|
|
226
|
+
}
|
|
227
|
+
this.#levels.length = 0;
|
|
228
|
+
this.#ldr = undefined;
|
|
229
|
+
this.#ao = undefined;
|
|
230
|
+
this.#dof = undefined;
|
|
231
|
+
this.#black = null;
|
|
232
|
+
this.scene.dispose();
|
|
233
|
+
this.mask.dispose();
|
|
234
|
+
this.maskMaterial.dispose();
|
|
235
|
+
}
|
|
236
|
+
}
|
|
237
|
+
//# sourceMappingURL=postWebGL23D.js.map
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { Material3D } from '../../rendering/world3d/Material3D.js';
|
|
2
|
+
import { RenderTarget3D } from '../../rendering/world3d/Texture3D.js';
|
|
3
|
+
import type { ToneMapping3D } from './frame3D.js';
|
|
4
|
+
import type { PostProcessSettings3D, PostView3D } from './post3D.js';
|
|
5
|
+
export declare class PostChainWebGPU3D {
|
|
6
|
+
#private;
|
|
7
|
+
/** Half-float scene target the renderer draws into before run(). */
|
|
8
|
+
readonly scene: RenderTarget3D;
|
|
9
|
+
/** Target and flat white material for the outline mask. */
|
|
10
|
+
readonly mask: RenderTarget3D;
|
|
11
|
+
readonly maskMaterial: Material3D;
|
|
12
|
+
constructor(device: GPUDevice);
|
|
13
|
+
private surface;
|
|
14
|
+
private pipeline;
|
|
15
|
+
private pass;
|
|
16
|
+
/**
|
|
17
|
+
* Process `sceneView` into `output`. `outputEncodes` is true when the
|
|
18
|
+
* output format converts linear values to sRGB on write.
|
|
19
|
+
*/
|
|
20
|
+
run(encoder: GPUCommandEncoder, sceneView: GPUTextureView, depthView: GPUTextureView | undefined, maskView: GPUTextureView | undefined, view: PostView3D, width: number, height: number, output: GPUTextureView, outputFormat: GPUTextureFormat, outputEncodes: boolean, settings: PostProcessSettings3D, toneMapping: ToneMapping3D): number;
|
|
21
|
+
dispose(): void;
|
|
22
|
+
}
|
|
23
|
+
//# sourceMappingURL=postWebGPU3D.d.ts.map
|
|
@@ -0,0 +1,255 @@
|
|
|
1
|
+
// SPDX-License-Identifier: Apache-2.0
|
|
2
|
+
// WebGPU side of the world3d post-processing chain; mirrors postWebGL23D.
|
|
3
|
+
import { Material3D } from '../../rendering/world3d/Material3D.js';
|
|
4
|
+
import { RenderTarget3D } from '../../rendering/world3d/Texture3D.js';
|
|
5
|
+
import { POST_DOF_WGSL_3D, POST_DOWN_WGSL_3D, POST_FXAA_WGSL_3D, POST_PARAMS_FLOATS_3D, POST_SSAO_WGSL_3D, POST_UP_WGSL_3D, bloomLevelCount3D, postCompositeWgsl3D, writeCompositeParams3D, writePostParams3D } from './post3D.js';
|
|
6
|
+
// Numeric WebGPU flags, so this module does not depend on the browser globals at load time.
|
|
7
|
+
const UNIFORM = 0x40, COPY_DST = 0x08, TEXTURE_COPY_DST = 0x02, RENDER_ATTACHMENT = 0x10, TEXTURE_BINDING = 0x04, FRAGMENT = 0x2;
|
|
8
|
+
const HDR = 'rgba16float', LDR = 'rgba8unorm';
|
|
9
|
+
const SHADERS = {
|
|
10
|
+
down: POST_DOWN_WGSL_3D,
|
|
11
|
+
up: POST_UP_WGSL_3D,
|
|
12
|
+
fxaa: POST_FXAA_WGSL_3D,
|
|
13
|
+
ssao: POST_SSAO_WGSL_3D,
|
|
14
|
+
dof: POST_DOF_WGSL_3D
|
|
15
|
+
};
|
|
16
|
+
export class PostChainWebGPU3D {
|
|
17
|
+
/** Half-float scene target the renderer draws into before run(). */
|
|
18
|
+
scene = new RenderTarget3D(1, 1, { format: 'rgba16f', depthTexture: true, name: 'world3d.post.scene' });
|
|
19
|
+
/** Target and flat white material for the outline mask. */
|
|
20
|
+
mask = new RenderTarget3D(1, 1, { name: 'world3d.post.mask' });
|
|
21
|
+
maskMaterial = (() => {
|
|
22
|
+
const material = new Material3D('unlit', { side: 'double' });
|
|
23
|
+
material.fog = false;
|
|
24
|
+
material.toneMapped = false;
|
|
25
|
+
return material;
|
|
26
|
+
})();
|
|
27
|
+
#device;
|
|
28
|
+
#layout;
|
|
29
|
+
#pipelineLayout;
|
|
30
|
+
#sampler;
|
|
31
|
+
#black;
|
|
32
|
+
#blackView;
|
|
33
|
+
#modules = new Map();
|
|
34
|
+
#pipelines = new Map();
|
|
35
|
+
#levels = [];
|
|
36
|
+
#slots = [];
|
|
37
|
+
#ldr;
|
|
38
|
+
#ao;
|
|
39
|
+
#dof;
|
|
40
|
+
#slot = 0;
|
|
41
|
+
#params = new Float32Array(POST_PARAMS_FLOATS_3D);
|
|
42
|
+
#maskView;
|
|
43
|
+
#outline;
|
|
44
|
+
#noDepth;
|
|
45
|
+
#noDepthView;
|
|
46
|
+
// State shared by the passes of one run().
|
|
47
|
+
#view = { inverseProjection: new Float32Array(16) };
|
|
48
|
+
#depthView;
|
|
49
|
+
#aoView;
|
|
50
|
+
#custom;
|
|
51
|
+
#width = 1;
|
|
52
|
+
#height = 1;
|
|
53
|
+
constructor(device) {
|
|
54
|
+
this.#device = device;
|
|
55
|
+
this.#layout = device.createBindGroupLayout({
|
|
56
|
+
entries: [
|
|
57
|
+
{ binding: 0, visibility: FRAGMENT, buffer: {} },
|
|
58
|
+
{ binding: 1, visibility: FRAGMENT, texture: {} },
|
|
59
|
+
{ binding: 2, visibility: FRAGMENT, sampler: {} },
|
|
60
|
+
{ binding: 3, visibility: FRAGMENT, texture: {} },
|
|
61
|
+
{ binding: 4, visibility: FRAGMENT, texture: { sampleType: 'depth' } },
|
|
62
|
+
{ binding: 5, visibility: FRAGMENT, texture: {} },
|
|
63
|
+
{ binding: 6, visibility: FRAGMENT, texture: {} }
|
|
64
|
+
]
|
|
65
|
+
});
|
|
66
|
+
this.#pipelineLayout = device.createPipelineLayout({ bindGroupLayouts: [this.#layout] });
|
|
67
|
+
this.#sampler = device.createSampler({
|
|
68
|
+
magFilter: 'linear',
|
|
69
|
+
minFilter: 'linear',
|
|
70
|
+
addressModeU: 'clamp-to-edge',
|
|
71
|
+
addressModeV: 'clamp-to-edge'
|
|
72
|
+
});
|
|
73
|
+
this.#black = device.createTexture({ size: [1, 1], format: LDR, usage: TEXTURE_BINDING | TEXTURE_COPY_DST });
|
|
74
|
+
device.queue.writeTexture({ texture: this.#black }, new Uint8Array(4), {}, [1, 1]);
|
|
75
|
+
this.#blackView = this.#black.createView();
|
|
76
|
+
// Stands in when the scene target has no readable depth; it reads as the near plane and is never used for effects.
|
|
77
|
+
this.#noDepth = device.createTexture({
|
|
78
|
+
size: [1, 1],
|
|
79
|
+
format: 'depth24plus',
|
|
80
|
+
usage: TEXTURE_BINDING | RENDER_ATTACHMENT
|
|
81
|
+
});
|
|
82
|
+
this.#noDepthView = this.#noDepth.createView();
|
|
83
|
+
}
|
|
84
|
+
surface(existing, width, height, format) {
|
|
85
|
+
if (existing && existing.width === width && existing.height === height)
|
|
86
|
+
return existing;
|
|
87
|
+
existing?.texture.destroy();
|
|
88
|
+
const texture = this.#device.createTexture({
|
|
89
|
+
size: [width, height],
|
|
90
|
+
format,
|
|
91
|
+
usage: RENDER_ATTACHMENT | TEXTURE_BINDING
|
|
92
|
+
});
|
|
93
|
+
return { texture, view: texture.createView(), width, height };
|
|
94
|
+
}
|
|
95
|
+
pipeline(name, format, additive) {
|
|
96
|
+
// The composite source depends on the application's hook, so its module is keyed by the hook.
|
|
97
|
+
const custom = name === 'composite' ? this.#custom : undefined, moduleKey = custom ? 'composite|' + custom.key : name;
|
|
98
|
+
const key = moduleKey + '/' + format + (additive ? '/add' : '');
|
|
99
|
+
let pipeline = this.#pipelines.get(key);
|
|
100
|
+
if (pipeline)
|
|
101
|
+
return pipeline;
|
|
102
|
+
let module = this.#modules.get(moduleKey);
|
|
103
|
+
if (!module)
|
|
104
|
+
this.#modules.set(moduleKey, (module = this.#device.createShaderModule({
|
|
105
|
+
code: name === 'composite' ? postCompositeWgsl3D(custom?.wgsl) : SHADERS[name],
|
|
106
|
+
label: 'post/' + moduleKey
|
|
107
|
+
})));
|
|
108
|
+
const blend = {
|
|
109
|
+
color: { srcFactor: 'one', dstFactor: 'one' },
|
|
110
|
+
alpha: { srcFactor: 'one', dstFactor: 'one' }
|
|
111
|
+
};
|
|
112
|
+
pipeline = this.#device.createRenderPipeline({
|
|
113
|
+
label: 'post/' + key,
|
|
114
|
+
layout: this.#pipelineLayout,
|
|
115
|
+
vertex: { module, entryPoint: 'vertexMain' },
|
|
116
|
+
fragment: { module, entryPoint: 'fragmentMain', targets: [{ format, ...(additive ? { blend } : {}) }] },
|
|
117
|
+
primitive: { topology: 'triangle-list' }
|
|
118
|
+
});
|
|
119
|
+
this.#pipelines.set(key, pipeline);
|
|
120
|
+
return pipeline;
|
|
121
|
+
}
|
|
122
|
+
pass(encoder, pipeline, source, bloom, output, load, a, b) {
|
|
123
|
+
const device = this.#device;
|
|
124
|
+
// Each pass in a frame owns one small uniform buffer, since all writes land before the encoder runs.
|
|
125
|
+
let slot = this.#slots[this.#slot];
|
|
126
|
+
if (!slot)
|
|
127
|
+
slot = this.#slots[this.#slot] = {
|
|
128
|
+
buffer: device.createBuffer({ size: this.#params.byteLength, usage: UNIFORM | COPY_DST }),
|
|
129
|
+
group: undefined,
|
|
130
|
+
source: undefined,
|
|
131
|
+
bloom: undefined,
|
|
132
|
+
depth: undefined,
|
|
133
|
+
ao: undefined,
|
|
134
|
+
mask: undefined
|
|
135
|
+
};
|
|
136
|
+
this.#slot++;
|
|
137
|
+
const p = this.#params, depth = this.#depthView ?? this.#noDepthView, ao = this.#aoView ?? this.#blackView;
|
|
138
|
+
const mask = this.#maskView ?? this.#blackView;
|
|
139
|
+
writePostParams3D(p, a, b, this.#view, this.#aoView !== undefined, this.#width, this.#height, this.#custom, this.#outline);
|
|
140
|
+
device.queue.writeBuffer(slot.buffer, 0, p);
|
|
141
|
+
// A surface cannot be sampled by the pass that renders into it.
|
|
142
|
+
const aoInput = ao === output ? this.#blackView : ao;
|
|
143
|
+
if (!slot.group ||
|
|
144
|
+
slot.source !== source ||
|
|
145
|
+
slot.bloom !== bloom ||
|
|
146
|
+
slot.depth !== depth ||
|
|
147
|
+
slot.ao !== aoInput ||
|
|
148
|
+
slot.mask !== mask) {
|
|
149
|
+
slot.group = device.createBindGroup({
|
|
150
|
+
layout: this.#layout,
|
|
151
|
+
entries: [
|
|
152
|
+
{ binding: 0, resource: { buffer: slot.buffer } },
|
|
153
|
+
{ binding: 1, resource: source },
|
|
154
|
+
{ binding: 2, resource: this.#sampler },
|
|
155
|
+
{ binding: 3, resource: bloom },
|
|
156
|
+
{ binding: 4, resource: depth },
|
|
157
|
+
{ binding: 5, resource: aoInput },
|
|
158
|
+
{ binding: 6, resource: mask }
|
|
159
|
+
]
|
|
160
|
+
});
|
|
161
|
+
slot.source = source;
|
|
162
|
+
slot.bloom = bloom;
|
|
163
|
+
slot.depth = depth;
|
|
164
|
+
slot.ao = aoInput;
|
|
165
|
+
slot.mask = mask;
|
|
166
|
+
}
|
|
167
|
+
const pass = encoder.beginRenderPass({
|
|
168
|
+
colorAttachments: [{ view: output, loadOp: load ? 'load' : 'clear', storeOp: 'store', clearValue: [0, 0, 0, 0] }]
|
|
169
|
+
});
|
|
170
|
+
pass.setPipeline(pipeline);
|
|
171
|
+
pass.setBindGroup(0, slot.group);
|
|
172
|
+
pass.draw(3);
|
|
173
|
+
pass.end();
|
|
174
|
+
}
|
|
175
|
+
/**
|
|
176
|
+
* Process `sceneView` into `output`. `outputEncodes` is true when the
|
|
177
|
+
* output format converts linear values to sRGB on write.
|
|
178
|
+
*/
|
|
179
|
+
run(encoder, sceneView, depthView, maskView, view, width, height, output, outputFormat, outputEncodes, settings, toneMapping) {
|
|
180
|
+
this.#slot = 0;
|
|
181
|
+
this.#view = view;
|
|
182
|
+
this.#depthView = depthView;
|
|
183
|
+
this.#aoView = undefined;
|
|
184
|
+
this.#custom = undefined;
|
|
185
|
+
this.#width = width;
|
|
186
|
+
this.#height = height;
|
|
187
|
+
this.#maskView = maskView;
|
|
188
|
+
this.#outline = maskView ? settings : undefined;
|
|
189
|
+
const black = this.#blackView;
|
|
190
|
+
if (settings.ssao && depthView && settings.ssaoIntensity > 0) {
|
|
191
|
+
const ao = (this.#ao = this.surface(this.#ao, width, height, LDR));
|
|
192
|
+
this.pass(encoder, this.pipeline('ssao', LDR, false), sceneView, black, ao.view, false, [Math.max(settings.ssaoRadius, 0.001), settings.ssaoIntensity, settings.ssaoBias, 0], [0, 0, 0, 0]);
|
|
193
|
+
this.#aoView = ao.view;
|
|
194
|
+
}
|
|
195
|
+
if (settings.dof && depthView && settings.dofRadius > 0) {
|
|
196
|
+
// Everything after this reads the blurred image as the scene.
|
|
197
|
+
const dof = (this.#dof = this.surface(this.#dof, width, height, HDR));
|
|
198
|
+
this.pass(encoder, this.pipeline('dof', HDR, false), sceneView, black, dof.view, false, [settings.dofFocus, Math.max(settings.dofRange, 0.001), settings.dofRadius, 0], [0, 0, 0, 0]);
|
|
199
|
+
sceneView = dof.view;
|
|
200
|
+
}
|
|
201
|
+
const levels = bloomLevelCount3D(settings, width, height);
|
|
202
|
+
if (levels > 0) {
|
|
203
|
+
const down = this.pipeline('down', HDR, false), up = this.pipeline('up', HDR, true);
|
|
204
|
+
let w = width, h = height, source = sceneView;
|
|
205
|
+
for (let i = 0; i < levels; i++) {
|
|
206
|
+
const sourceWidth = w, sourceHeight = h;
|
|
207
|
+
w = Math.max(w >> 1, 1);
|
|
208
|
+
h = Math.max(h >> 1, 1);
|
|
209
|
+
const level = (this.#levels[i] = this.surface(this.#levels[i], w, h, HDR));
|
|
210
|
+
this.pass(encoder, down, source, black, level.view, false, [1 / sourceWidth, 1 / sourceHeight, settings.bloomThreshold, Math.min(Math.max(settings.bloomKnee, 0), 1)], [i === 0 ? 1 : 0, 0, 0, 0]);
|
|
211
|
+
source = level.view;
|
|
212
|
+
}
|
|
213
|
+
for (let i = levels - 1; i > 0; i--) {
|
|
214
|
+
const from = this.#levels[i], to = this.#levels[i - 1];
|
|
215
|
+
this.pass(encoder, up, from.view, black, to.view, true, [1 / from.width, 1 / from.height, 0, 0], [0, 0, 0, 0]);
|
|
216
|
+
}
|
|
217
|
+
}
|
|
218
|
+
// The hook needs depth; without a depth texture it is left out rather than reading garbage.
|
|
219
|
+
this.#custom = depthView && settings.custom?.wgsl !== undefined ? settings.custom : undefined;
|
|
220
|
+
const bloom = levels > 0 ? this.#levels[0].view : black, p = new Float32Array(8);
|
|
221
|
+
if (settings.fxaa) {
|
|
222
|
+
const ldr = (this.#ldr = this.surface(this.#ldr, width, height, LDR));
|
|
223
|
+
writeCompositeParams3D(p, settings, levels, toneMapping, true);
|
|
224
|
+
this.pass(encoder, this.pipeline('composite', LDR, false), sceneView, bloom, ldr.view, false, [...p.subarray(0, 4)], [...p.subarray(4, 8)]);
|
|
225
|
+
this.pass(encoder, this.pipeline('fxaa', outputFormat, false), ldr.view, black, output, false, [1 / width, 1 / height, outputEncodes ? 1 : 0, 0], [0, 0, 0, 0]);
|
|
226
|
+
}
|
|
227
|
+
else {
|
|
228
|
+
writeCompositeParams3D(p, settings, levels, toneMapping, !outputEncodes);
|
|
229
|
+
this.pass(encoder, this.pipeline('composite', outputFormat, false), sceneView, bloom, output, false, [...p.subarray(0, 4)], [...p.subarray(4, 8)]);
|
|
230
|
+
}
|
|
231
|
+
return this.#slot;
|
|
232
|
+
}
|
|
233
|
+
dispose() {
|
|
234
|
+
for (const surface of this.#levels)
|
|
235
|
+
surface.texture.destroy();
|
|
236
|
+
this.#ldr?.texture.destroy();
|
|
237
|
+
this.#ao?.texture.destroy();
|
|
238
|
+
this.#dof?.texture.destroy();
|
|
239
|
+
this.#noDepth.destroy();
|
|
240
|
+
for (const slot of this.#slots)
|
|
241
|
+
slot.buffer.destroy();
|
|
242
|
+
this.#black.destroy();
|
|
243
|
+
this.#levels.length = 0;
|
|
244
|
+
this.#slots.length = 0;
|
|
245
|
+
this.#ldr = undefined;
|
|
246
|
+
this.#ao = undefined;
|
|
247
|
+
this.#dof = undefined;
|
|
248
|
+
this.#pipelines.clear();
|
|
249
|
+
this.#modules.clear();
|
|
250
|
+
this.scene.dispose();
|
|
251
|
+
this.mask.dispose();
|
|
252
|
+
this.maskMaterial.dispose();
|
|
253
|
+
}
|
|
254
|
+
}
|
|
255
|
+
//# sourceMappingURL=postWebGPU3D.js.map
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import type { Scene3D } from '../../rendering/world3d/Object3D.js';
|
|
2
|
+
import { CubeTexture3D } from '../../rendering/world3d/Texture3D.js';
|
|
3
|
+
import type { Renderer3D } from './frame3D.js';
|
|
4
|
+
/** How a cube is captured around a point: its size, near and far planes, and layers. */
|
|
5
|
+
export interface CubeCaptureOptions3D {
|
|
6
|
+
/** Edge of each face in texels. */
|
|
7
|
+
readonly size?: number;
|
|
8
|
+
readonly near?: number;
|
|
9
|
+
readonly far?: number;
|
|
10
|
+
/** Camera layer mask, to leave the reflecting object itself out. */
|
|
11
|
+
readonly layerMask?: number;
|
|
12
|
+
}
|
|
13
|
+
/** Render six 90-degree views from `position` and return them as a cube texture with mipmaps. */
|
|
14
|
+
export declare function captureCubeTexture3D(renderer: Renderer3D, scene: Scene3D, position: ArrayLike<number>, options?: CubeCaptureOptions3D): Promise<CubeTexture3D>;
|
|
15
|
+
//# sourceMappingURL=probe3D.d.ts.map
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
// SPDX-License-Identifier: Apache-2.0
|
|
2
|
+
// Reflection probes: capture the scene around a point into a cube texture
|
|
3
|
+
// that can be used as `scene.environment` or a background. The capture reads
|
|
4
|
+
// pixels back from the GPU, so it is meant for baking when a level loads or
|
|
5
|
+
// changes, not for every frame.
|
|
6
|
+
import { Camera3D } from '../../rendering/world3d/Camera3D.js';
|
|
7
|
+
import { World3DError, requireCount3D } from '../../rendering/world3d/core3D.js';
|
|
8
|
+
import { CubeTexture3D, RenderTarget3D } from '../../rendering/world3d/Texture3D.js';
|
|
9
|
+
// Face axes in +X, -X, +Y, -Y, +Z, -Z order with the up vector that puts each image's top row where a cube map expects it.
|
|
10
|
+
const FACES = [
|
|
11
|
+
[1, 0, 0, 0, 1, 0],
|
|
12
|
+
[-1, 0, 0, 0, 1, 0],
|
|
13
|
+
[0, 1, 0, 0, 0, -1],
|
|
14
|
+
[0, -1, 0, 0, 0, 1],
|
|
15
|
+
[0, 0, 1, 0, 1, 0],
|
|
16
|
+
[0, 0, -1, 0, 1, 0]
|
|
17
|
+
];
|
|
18
|
+
/** Render six 90-degree views from `position` and return them as a cube texture with mipmaps. */
|
|
19
|
+
export async function captureCubeTexture3D(renderer, scene, position, options = {}) {
|
|
20
|
+
if (!renderer || !scene || !position || position.length < 3)
|
|
21
|
+
throw new World3DError('WORLD3D_INPUT_INVALID', 'cube capture');
|
|
22
|
+
const size = requireCount3D(options.size ?? 128, 'cube size', 2048);
|
|
23
|
+
if (size < 2)
|
|
24
|
+
throw new World3DError('WORLD3D_INPUT_INVALID', 'cube size');
|
|
25
|
+
const camera = new Camera3D('perspective'), target = new RenderTarget3D(size, size, { name: 'world3d.probe' });
|
|
26
|
+
camera.fov = 90;
|
|
27
|
+
camera.aspect = 1;
|
|
28
|
+
camera.near = options.near ?? 0.1;
|
|
29
|
+
camera.far = options.far ?? 1000;
|
|
30
|
+
if (options.layerMask !== undefined)
|
|
31
|
+
camera.layerMask = options.layerMask;
|
|
32
|
+
// The probe draws plain views: post-processing, viewports and partial clears belong to the main view.
|
|
33
|
+
const post = renderer.postProcess.enabled, viewport = renderer.viewport, autoClear = renderer.autoClear;
|
|
34
|
+
renderer.postProcess.enabled = false;
|
|
35
|
+
renderer.viewport = undefined;
|
|
36
|
+
renderer.autoClear = true;
|
|
37
|
+
const faces = [], px = position[0], py = position[1], pz = position[2];
|
|
38
|
+
try {
|
|
39
|
+
for (const [dx, dy, dz, ux, uy, uz] of FACES) {
|
|
40
|
+
camera.setPosition(px, py, pz).lookAt(px + dx, py + dy, pz + dz, [ux, uy, uz]);
|
|
41
|
+
camera.updateWorldMatrices();
|
|
42
|
+
if (!renderer.render(scene, camera, target))
|
|
43
|
+
throw new World3DError('WORLD3D_CONTEXT_LOST', 'cube capture');
|
|
44
|
+
const data = await renderer.readRenderTargetPixels(target);
|
|
45
|
+
// Cube faces are stored as seen from outside the cube: mirror each row.
|
|
46
|
+
for (let y = 0; y < size; y++)
|
|
47
|
+
for (let x = 0; x < size >> 1; x++) {
|
|
48
|
+
const a = (y * size + x) * 4, b = (y * size + size - 1 - x) * 4;
|
|
49
|
+
for (let c = 0; c < 4; c++) {
|
|
50
|
+
const swap = data[a + c];
|
|
51
|
+
data[a + c] = data[b + c];
|
|
52
|
+
data[b + c] = swap;
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
faces.push({ width: size, height: size, data });
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
finally {
|
|
59
|
+
renderer.postProcess.enabled = post;
|
|
60
|
+
renderer.viewport = viewport;
|
|
61
|
+
renderer.autoClear = autoClear;
|
|
62
|
+
target.dispose();
|
|
63
|
+
}
|
|
64
|
+
return new CubeTexture3D(faces, { colorSpace: 'srgb', mipmaps: true, name: 'probe' });
|
|
65
|
+
}
|
|
66
|
+
//# sourceMappingURL=probe3D.js.map
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
/** Fixed vertex attribute locations shared by every program and vertex array. */
|
|
2
|
+
export declare const ATTRIBUTE_LOCATIONS_3D: Readonly<{
|
|
3
|
+
readonly position: 0;
|
|
4
|
+
readonly normal: 1;
|
|
5
|
+
readonly uv: 2;
|
|
6
|
+
readonly tangent: 3;
|
|
7
|
+
readonly color: 4;
|
|
8
|
+
readonly joints: 5;
|
|
9
|
+
readonly weights: 6;
|
|
10
|
+
readonly uv1: 7;
|
|
11
|
+
readonly instanceMatrix: 8;
|
|
12
|
+
readonly instanceColor: 12;
|
|
13
|
+
readonly instanceAnimation: 13;
|
|
14
|
+
readonly instanceAnimation2: 14;
|
|
15
|
+
readonly instanceLook: 15;
|
|
16
|
+
}>;
|
|
17
|
+
/** Fixed texture units; samplers are assigned once when a program is linked. */
|
|
18
|
+
export declare const TEXTURE_UNITS_3D: Readonly<{
|
|
19
|
+
readonly map: 0;
|
|
20
|
+
readonly normalMap: 1;
|
|
21
|
+
readonly metallicRoughnessMap: 2;
|
|
22
|
+
readonly occlusionMap: 3;
|
|
23
|
+
readonly emissiveMap: 4;
|
|
24
|
+
readonly environment: 5;
|
|
25
|
+
readonly shadow: 6;
|
|
26
|
+
readonly bones: 7;
|
|
27
|
+
readonly morph: 8;
|
|
28
|
+
readonly lightMap: 9;
|
|
29
|
+
readonly sceneColor: 10;
|
|
30
|
+
readonly reflectionMap: 11;
|
|
31
|
+
readonly sceneDepth: 12;
|
|
32
|
+
readonly tiledLights: 13;
|
|
33
|
+
}>;
|
|
34
|
+
export declare const MAX_MORPH_INFLUENCES_3D = 8;
|
|
35
|
+
export interface ShaderSources3D {
|
|
36
|
+
readonly vertex: string;
|
|
37
|
+
readonly fragment: string;
|
|
38
|
+
}
|
|
39
|
+
/** Specialize the material shader pair with a list of preprocessor symbols. */
|
|
40
|
+
export declare function buildMaterialShader3D(defines: readonly string[], customFragment?: string, customVertex?: string, customNormal?: string): ShaderSources3D;
|
|
41
|
+
/** Full-screen triangle that samples a cube map along the view ray; drawn at the far plane. */
|
|
42
|
+
export declare const SKYBOX_SHADER_3D: ShaderSources3D;
|
|
43
|
+
//# sourceMappingURL=shaders3D.d.ts.map
|