@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,601 @@
|
|
|
1
|
+
// SPDX-License-Identifier: Apache-2.0
|
|
2
|
+
// Crowds of animated characters in one draw call. Clips are sampled once into
|
|
3
|
+
// a table of bone matrices per frame; each instance then only names the two
|
|
4
|
+
// frames it is between, and the vertex stage looks its bones up in the table.
|
|
5
|
+
// DOM-free: backends upload the table as a float texture or a storage buffer.
|
|
6
|
+
import { Resource3D, World3DError, requireCount3D, requireFinite3D, requirePositive3D } from './core3D.js';
|
|
7
|
+
import { sampleAnimationTrack3D } from './Animation3D.js';
|
|
8
|
+
import { InstancedMesh3D } from './Mesh3D.js';
|
|
9
|
+
import { frustumIntersectsSphere, mat4Identity, mat4Invert, mat4Multiply } from './math3D.js';
|
|
10
|
+
// sqrt(||A||_1 * ||A||_inf) bounds the stretch even when composed matrices shear.
|
|
11
|
+
function affineScaleBound(m, o) {
|
|
12
|
+
const a = Math.abs(m[o]), b = Math.abs(m[o + 4]), c = Math.abs(m[o + 8]);
|
|
13
|
+
const d = Math.abs(m[o + 1]), e = Math.abs(m[o + 5]), f = Math.abs(m[o + 9]);
|
|
14
|
+
const g = Math.abs(m[o + 2]), h = Math.abs(m[o + 6]), i = Math.abs(m[o + 10]);
|
|
15
|
+
const rows = Math.max(a + b + c, d + e + f, g + h + i);
|
|
16
|
+
const columns = Math.max(a + d + g, b + e + h, c + f + i);
|
|
17
|
+
return Math.sqrt(rows) * Math.sqrt(columns);
|
|
18
|
+
}
|
|
19
|
+
export const ANIMATION_TEXTURE3D_LIMITS = Object.freeze({ maxMatrices: 2097152, maxClips: 256, maxFps: 240 });
|
|
20
|
+
/**
|
|
21
|
+
* Bone matrices of one skinned mesh for every frame of a set of clips. The
|
|
22
|
+
* table is a run of frames, each `stride` matrices of 16 floats: one per
|
|
23
|
+
* bone, taking a vertex from the mesh's bind pose to its posed place in the
|
|
24
|
+
* mesh's own space, and a last one whose 16 floats are the frame's morph
|
|
25
|
+
* weights. Frame 0 is not a pose: its matrix for a bone holds, in the fourth
|
|
26
|
+
* column, the point that bone turns about in the bind pose.
|
|
27
|
+
*/
|
|
28
|
+
export class AnimationTexture3D extends Resource3D {
|
|
29
|
+
boneCount;
|
|
30
|
+
/** Matrices per frame: the bones and one for morph weights. */
|
|
31
|
+
stride;
|
|
32
|
+
/** Morph targets whose weights are stored, at most 16. */
|
|
33
|
+
morphCount;
|
|
34
|
+
frameCount;
|
|
35
|
+
fps;
|
|
36
|
+
data;
|
|
37
|
+
clips;
|
|
38
|
+
/** How far a bone travels from the mesh origin in any frame, relative to the geometry's bounding radius; instances widen their bounds by it. */
|
|
39
|
+
reach;
|
|
40
|
+
constructor(boneCount, fps, data, clips, reach = 1, morphCount = 0) {
|
|
41
|
+
super();
|
|
42
|
+
this.boneCount = requireCount3D(boneCount, 'boneCount', 1024);
|
|
43
|
+
this.fps = requirePositive3D(fps, 'fps');
|
|
44
|
+
this.stride = this.boneCount + 1;
|
|
45
|
+
this.morphCount = requireCount3D(morphCount, 'morphCount', 16);
|
|
46
|
+
if (this.boneCount < 1 ||
|
|
47
|
+
!(data instanceof Float32Array) ||
|
|
48
|
+
data.length < this.stride * 32 ||
|
|
49
|
+
data.length % (this.stride * 16) !== 0)
|
|
50
|
+
throw new World3DError('WORLD3D_INPUT_INVALID', 'animation texture data');
|
|
51
|
+
if (data.length / 16 > ANIMATION_TEXTURE3D_LIMITS.maxMatrices)
|
|
52
|
+
throw new World3DError('WORLD3D_BUDGET', 'animation texture matrices');
|
|
53
|
+
this.data = data;
|
|
54
|
+
this.frameCount = data.length / (this.stride * 16);
|
|
55
|
+
requireCount3D(clips.length, 'clips', ANIMATION_TEXTURE3D_LIMITS.maxClips);
|
|
56
|
+
for (const clip of clips) {
|
|
57
|
+
if (!Number.isSafeInteger(clip.start) ||
|
|
58
|
+
!Number.isSafeInteger(clip.frames) ||
|
|
59
|
+
clip.start < 1 ||
|
|
60
|
+
clip.frames < 1 ||
|
|
61
|
+
clip.start + clip.frames > this.frameCount ||
|
|
62
|
+
!(clip.duration >= 0))
|
|
63
|
+
throw new World3DError('WORLD3D_INPUT_INVALID', 'baked clip range');
|
|
64
|
+
}
|
|
65
|
+
this.clips = Object.freeze(clips.map(clip => Object.freeze({ name: clip.name, start: clip.start, frames: clip.frames, duration: clip.duration })));
|
|
66
|
+
this.reach = requirePositive3D(reach, 'reach');
|
|
67
|
+
}
|
|
68
|
+
/** Index of the clip with this name, or -1. */
|
|
69
|
+
clipIndex(name) {
|
|
70
|
+
return this.clips.findIndex(clip => clip.name === name);
|
|
71
|
+
}
|
|
72
|
+
/**
|
|
73
|
+
* The two table frames around a time in a clip and the blend between
|
|
74
|
+
* them, written to `out` as [first, second, blend].
|
|
75
|
+
*/
|
|
76
|
+
framesAt(clip, time, loop, out, offset = 0) {
|
|
77
|
+
const baked = this.clips[clip];
|
|
78
|
+
if (!baked)
|
|
79
|
+
throw new World3DError('WORLD3D_INPUT_INVALID', 'clip index');
|
|
80
|
+
const last = baked.frames - 1;
|
|
81
|
+
let at = 0;
|
|
82
|
+
if (baked.duration > 0 && last > 0) {
|
|
83
|
+
let t = time;
|
|
84
|
+
if (loop) {
|
|
85
|
+
t %= baked.duration;
|
|
86
|
+
if (t < 0)
|
|
87
|
+
t += baked.duration;
|
|
88
|
+
}
|
|
89
|
+
else
|
|
90
|
+
t = t < 0 ? 0 : t > baked.duration ? baked.duration : t;
|
|
91
|
+
at = (t / baked.duration) * last;
|
|
92
|
+
}
|
|
93
|
+
const first = Math.min(Math.floor(at), last);
|
|
94
|
+
out[offset] = baked.start + first;
|
|
95
|
+
out[offset + 1] = baked.start + Math.min(first + 1, last);
|
|
96
|
+
out[offset + 2] = at - first;
|
|
97
|
+
}
|
|
98
|
+
}
|
|
99
|
+
/**
|
|
100
|
+
* Sample clips into an animation texture. `root` is the subtree the clips
|
|
101
|
+
* animate, as for an AnimationMixer3D, and `mesh` the skinned mesh inside it
|
|
102
|
+
* whose skeleton is baked. The subtree is posed while baking and put back as
|
|
103
|
+
* it was. Bone transforms are stored, and the weights of the mesh's first 16
|
|
104
|
+
* morph targets where a clip animates them.
|
|
105
|
+
*/
|
|
106
|
+
export function bakeAnimationTexture3D(root, mesh, clips, options = {}) {
|
|
107
|
+
const skeleton = mesh?.skeleton;
|
|
108
|
+
if (!skeleton || skeleton.bones.length === 0)
|
|
109
|
+
throw new World3DError('WORLD3D_INPUT_INVALID', 'bake needs a skinned mesh');
|
|
110
|
+
if (!clips || clips.length === 0)
|
|
111
|
+
throw new World3DError('WORLD3D_INPUT_INVALID', 'bake needs at least one clip');
|
|
112
|
+
requireCount3D(clips.length, 'clips', ANIMATION_TEXTURE3D_LIMITS.maxClips);
|
|
113
|
+
const fps = requirePositive3D(options.fps ?? 30, 'fps');
|
|
114
|
+
if (fps > ANIMATION_TEXTURE3D_LIMITS.maxFps)
|
|
115
|
+
throw new World3DError('WORLD3D_BUDGET', 'fps');
|
|
116
|
+
const bones = skeleton.bones, boneCount = bones.length;
|
|
117
|
+
const names = new Map();
|
|
118
|
+
root.traverse(object => {
|
|
119
|
+
if (object.name && !names.has(object.name))
|
|
120
|
+
names.set(object.name, object);
|
|
121
|
+
});
|
|
122
|
+
const baked = [];
|
|
123
|
+
// Frame 0 holds the bones' turning points; poses start at 1.
|
|
124
|
+
let frameCount = 1;
|
|
125
|
+
for (const clip of clips) {
|
|
126
|
+
const frames = Math.max(1, Math.ceil(clip.duration * fps - 1e-6)) + 1;
|
|
127
|
+
baked.push({ name: clip.name, start: frameCount, frames, duration: clip.duration });
|
|
128
|
+
frameCount += frames;
|
|
129
|
+
}
|
|
130
|
+
const stride = boneCount + 1, morphCount = Math.min(16, mesh.geometry.morphTargets.length);
|
|
131
|
+
if (frameCount * stride > ANIMATION_TEXTURE3D_LIMITS.maxMatrices)
|
|
132
|
+
throw new World3DError('WORLD3D_BUDGET', 'animation texture matrices');
|
|
133
|
+
const data = new Float32Array(frameCount * stride * 16);
|
|
134
|
+
mesh.syncMorphWeights();
|
|
135
|
+
const restWeights = mesh.morphWeights.slice(0, morphCount);
|
|
136
|
+
// Remember every transform a clip may touch so the subtree can be put back.
|
|
137
|
+
const saved = new Map();
|
|
138
|
+
for (const clip of clips)
|
|
139
|
+
for (const track of clip.tracks) {
|
|
140
|
+
const target = names.get(track.targetName);
|
|
141
|
+
if (target && !saved.has(target))
|
|
142
|
+
saved.set(target, Float32Array.of(...target.position, ...target.quaternion, ...target.scale));
|
|
143
|
+
}
|
|
144
|
+
const restore = () => {
|
|
145
|
+
for (const [target, values] of saved) {
|
|
146
|
+
target.position.set(values.subarray(0, 3));
|
|
147
|
+
target.quaternion.set(values.subarray(3, 7));
|
|
148
|
+
target.scale.set(values.subarray(7, 10));
|
|
149
|
+
target.markTransformDirty();
|
|
150
|
+
}
|
|
151
|
+
};
|
|
152
|
+
const scratch = new Float32Array(Math.max(16, mesh.geometry.morphTargets.length)), toMesh = new Float32Array(16), posed = new Float32Array(16), hint = { index: 0 };
|
|
153
|
+
// Turning points: where each bone sits in the bind pose, in the mesh's bind space.
|
|
154
|
+
const fromSkeleton = new Float32Array(16);
|
|
155
|
+
if (!mat4Invert(fromSkeleton, mesh.bindMatrix))
|
|
156
|
+
mat4Identity(fromSkeleton);
|
|
157
|
+
for (let bone = 0; bone < stride; bone++) {
|
|
158
|
+
const out = mat4Identity(data.subarray(bone * 16, bone * 16 + 16));
|
|
159
|
+
if (bone < boneCount && mat4Invert(posed, skeleton.inverseBindMatrices.subarray(bone * 16, bone * 16 + 16))) {
|
|
160
|
+
mat4Multiply(posed, fromSkeleton, posed);
|
|
161
|
+
out[12] = posed[12];
|
|
162
|
+
out[13] = posed[13];
|
|
163
|
+
out[14] = posed[14];
|
|
164
|
+
}
|
|
165
|
+
}
|
|
166
|
+
const radius = Math.max(mesh.geometry.boundingSphere[3], 1e-6);
|
|
167
|
+
let far = 0;
|
|
168
|
+
try {
|
|
169
|
+
clips.forEach((clip, clipIndex) => {
|
|
170
|
+
const entry = baked[clipIndex];
|
|
171
|
+
for (let frame = 0; frame < entry.frames; frame++) {
|
|
172
|
+
// Every clip starts from the rest pose, so a track missing from one clip does not inherit another's.
|
|
173
|
+
restore();
|
|
174
|
+
const time = entry.frames > 1 ? (frame / (entry.frames - 1)) * clip.duration : 0;
|
|
175
|
+
const weights = data.subarray(((entry.start + frame) * stride + boneCount) * 16, ((entry.start + frame) * stride + boneCount + 1) * 16);
|
|
176
|
+
weights.fill(0);
|
|
177
|
+
weights.set(restWeights);
|
|
178
|
+
for (const track of clip.tracks) {
|
|
179
|
+
const target = names.get(track.targetName);
|
|
180
|
+
if (!target)
|
|
181
|
+
continue;
|
|
182
|
+
if (track.path === 'weights') {
|
|
183
|
+
// Only the baked mesh's own weights are kept.
|
|
184
|
+
if (target !== mesh || track.size > scratch.length)
|
|
185
|
+
continue;
|
|
186
|
+
hint.index = 0;
|
|
187
|
+
sampleAnimationTrack3D(track, time, scratch, hint);
|
|
188
|
+
for (let i = 0; i < Math.min(track.size, morphCount); i++)
|
|
189
|
+
weights[i] = scratch[i];
|
|
190
|
+
continue;
|
|
191
|
+
}
|
|
192
|
+
hint.index = 0;
|
|
193
|
+
sampleAnimationTrack3D(track, time, scratch, hint);
|
|
194
|
+
const to = track.path === 'position'
|
|
195
|
+
? target.position
|
|
196
|
+
: track.path === 'quaternion'
|
|
197
|
+
? target.quaternion
|
|
198
|
+
: target.scale;
|
|
199
|
+
for (let i = 0; i < to.length; i++)
|
|
200
|
+
to[i] = scratch[i];
|
|
201
|
+
target.markTransformDirty();
|
|
202
|
+
}
|
|
203
|
+
root.updateWorldMatrices();
|
|
204
|
+
mesh.updateWorldMatrix();
|
|
205
|
+
if (!mat4Invert(toMesh, mesh.matrixWorld))
|
|
206
|
+
throw new World3DError('WORLD3D_INPUT_INVALID', 'mesh transform is singular');
|
|
207
|
+
for (let bone = 0; bone < boneCount; bone++) {
|
|
208
|
+
const out = data.subarray(((entry.start + frame) * stride + bone) * 16, ((entry.start + frame) * stride + bone + 1) * 16);
|
|
209
|
+
mat4Multiply(posed, bones[bone].matrixWorld, skeleton.inverseBindMatrices.subarray(bone * 16, bone * 16 + 16));
|
|
210
|
+
mat4Multiply(posed, posed, mesh.bindMatrix);
|
|
211
|
+
mat4Multiply(out, toMesh, posed);
|
|
212
|
+
mat4Multiply(posed, toMesh, bones[bone].matrixWorld);
|
|
213
|
+
far = Math.max(far, Math.hypot(posed[12], posed[13], posed[14]));
|
|
214
|
+
}
|
|
215
|
+
}
|
|
216
|
+
});
|
|
217
|
+
}
|
|
218
|
+
finally {
|
|
219
|
+
restore();
|
|
220
|
+
root.updateWorldMatrices();
|
|
221
|
+
}
|
|
222
|
+
return new AnimationTexture3D(boneCount, fps, data, baked, Math.max(1, far / radius + 0.5), morphCount);
|
|
223
|
+
}
|
|
224
|
+
const FLOATS = 12; // per instance: two frames and a blend for each of two clips, and a bone rotation
|
|
225
|
+
const scratchSphere = new Float32Array(4);
|
|
226
|
+
/**
|
|
227
|
+
* Many copies of one skinned mesh in a single draw call, each at its own
|
|
228
|
+
* place in its own clip. The geometry needs `joints` and `weights`; the mesh
|
|
229
|
+
* needs no skeleton, because poses come from the animation texture. Call
|
|
230
|
+
* `update(deltaSeconds)` once per frame.
|
|
231
|
+
*
|
|
232
|
+
* An instance plays one clip, optionally blended with a second at a weight
|
|
233
|
+
* you set (walk into run) or cross-faded from the one before. One bone,
|
|
234
|
+
* `lookBone`, can be given an extra rotation per instance, as for heads that
|
|
235
|
+
* turn toward something. Before each draw the instances outside the camera's
|
|
236
|
+
* view may be left out of the draw arrays. `count` and its alias `total`
|
|
237
|
+
* remain the number of active instances, and `drawCount` reports the visible range.
|
|
238
|
+
*/
|
|
239
|
+
export class SkinnedInstancedMesh3D extends InstancedMesh3D {
|
|
240
|
+
animations;
|
|
241
|
+
#legacyAnimation;
|
|
242
|
+
/** Four floats per logical instance: first frame, second frame, blend and bone count. */
|
|
243
|
+
get instanceAnimation() {
|
|
244
|
+
if (!this.#legacyAnimation) {
|
|
245
|
+
this.#legacyAnimation = new Float32Array(this.capacity * 4);
|
|
246
|
+
for (let i = 0; i < this.capacity; i++)
|
|
247
|
+
this.writeLegacy(i, this.#legacyAnimation);
|
|
248
|
+
}
|
|
249
|
+
return this.#legacyAnimation;
|
|
250
|
+
}
|
|
251
|
+
/** Alias for the active instance count. */
|
|
252
|
+
get total() {
|
|
253
|
+
return this.count;
|
|
254
|
+
}
|
|
255
|
+
set total(value) {
|
|
256
|
+
this.count = value;
|
|
257
|
+
}
|
|
258
|
+
/** Number of entries prepared for the current draw. */
|
|
259
|
+
get drawCount() {
|
|
260
|
+
return this.#drawCount;
|
|
261
|
+
}
|
|
262
|
+
/** Draw matrices in the prepared instance order. */
|
|
263
|
+
get drawMatrices() {
|
|
264
|
+
return this.#compacting ? this.#compactMatrices : this.instanceMatrices;
|
|
265
|
+
}
|
|
266
|
+
/** Draw colors in the prepared instance order. */
|
|
267
|
+
get drawColors() {
|
|
268
|
+
return this.#compacting && this.instanceColors ? this.#compactColors : this.instanceColors;
|
|
269
|
+
}
|
|
270
|
+
/** Packed GPU animation data in the prepared instance order. */
|
|
271
|
+
get drawAnimation() {
|
|
272
|
+
return this.#compacting ? this.#compactAnimation : this.#animation;
|
|
273
|
+
}
|
|
274
|
+
/** Enables view culling when a conservative posed radius is available. */
|
|
275
|
+
cullInstances = true;
|
|
276
|
+
/** Extra radius multiples retained around the view. Default 3. */
|
|
277
|
+
cullPadding = 3;
|
|
278
|
+
#cullRadius;
|
|
279
|
+
/**
|
|
280
|
+
* A sphere about the instance origin covering every used skin, morph and bone pose.
|
|
281
|
+
* Without this authored bound, drawing keeps all instances.
|
|
282
|
+
*/
|
|
283
|
+
get cullRadius() {
|
|
284
|
+
return this.#cullRadius;
|
|
285
|
+
}
|
|
286
|
+
set cullRadius(value) {
|
|
287
|
+
this.#cullRadius = value === undefined ? undefined : requirePositive3D(value, 'posed crowd culling radius');
|
|
288
|
+
}
|
|
289
|
+
#drawCount = 0;
|
|
290
|
+
#compacting = false;
|
|
291
|
+
#compactMatrices;
|
|
292
|
+
#compactColors;
|
|
293
|
+
#compactAnimation;
|
|
294
|
+
#animation;
|
|
295
|
+
#clip;
|
|
296
|
+
#time;
|
|
297
|
+
#speed;
|
|
298
|
+
#loop;
|
|
299
|
+
// The second clip of each instance: -1 for none.
|
|
300
|
+
#clipB;
|
|
301
|
+
#timeB;
|
|
302
|
+
#speedB;
|
|
303
|
+
#flagsB; // bit 0: loop, bit 1: follow the first clip's phase
|
|
304
|
+
#weightB;
|
|
305
|
+
#fadeRate; // weight lost per second while cross-fading, 0 for a blend that stays
|
|
306
|
+
#lookBone = -1;
|
|
307
|
+
constructor(geometry, material, animations, capacity, instanceColorSize = 3) {
|
|
308
|
+
super(geometry, material, capacity, instanceColorSize);
|
|
309
|
+
if (!(animations instanceof AnimationTexture3D))
|
|
310
|
+
throw new World3DError('WORLD3D_INPUT_INVALID', 'animations');
|
|
311
|
+
if (!geometry.getAttribute('joints') || !geometry.getAttribute('weights'))
|
|
312
|
+
throw new World3DError('WORLD3D_INPUT_INVALID', 'geometry needs joints and weights');
|
|
313
|
+
this.animations = animations;
|
|
314
|
+
this.boundsScale = animations.reach;
|
|
315
|
+
this.frustumCulled = false;
|
|
316
|
+
const n = this.capacity;
|
|
317
|
+
this.#animation = new Float32Array(n * FLOATS);
|
|
318
|
+
this.#clip = new Int32Array(n);
|
|
319
|
+
this.#time = new Float32Array(n);
|
|
320
|
+
this.#speed = new Float32Array(n).fill(1);
|
|
321
|
+
this.#loop = new Uint8Array(n).fill(1);
|
|
322
|
+
this.#clipB = new Int32Array(n).fill(-1);
|
|
323
|
+
this.#timeB = new Float32Array(n);
|
|
324
|
+
this.#speedB = new Float32Array(n).fill(1);
|
|
325
|
+
this.#flagsB = new Uint8Array(n);
|
|
326
|
+
this.#weightB = new Float32Array(n);
|
|
327
|
+
this.#fadeRate = new Float32Array(n);
|
|
328
|
+
for (let i = 0; i < n; i++) {
|
|
329
|
+
this.#animation[i * FLOATS + 11] = 1;
|
|
330
|
+
this.write(i);
|
|
331
|
+
}
|
|
332
|
+
this.compact(undefined);
|
|
333
|
+
this.beforeRender = (camera) => this.compact(this.cullInstances ? camera : undefined);
|
|
334
|
+
}
|
|
335
|
+
/** The bone that per-instance rotations apply to, or -1. Vertices weighted to it turn about its joint; bones below it do not follow. */
|
|
336
|
+
get lookBone() {
|
|
337
|
+
return this.#lookBone;
|
|
338
|
+
}
|
|
339
|
+
set lookBone(bone) {
|
|
340
|
+
if (!Number.isSafeInteger(bone) || bone < -1 || bone >= this.animations.boneCount)
|
|
341
|
+
throw new World3DError('WORLD3D_INPUT_INVALID', 'lookBone');
|
|
342
|
+
this.#lookBone = bone;
|
|
343
|
+
for (let i = 0; i < this.capacity; i++)
|
|
344
|
+
this.write(i);
|
|
345
|
+
this.compact(undefined);
|
|
346
|
+
}
|
|
347
|
+
/** Extra rotation of the look bone for one instance, as a quaternion in the mesh's own axes. */
|
|
348
|
+
setBoneRotationAt(index, x, y, z, w) {
|
|
349
|
+
this.check(index);
|
|
350
|
+
const o = index * FLOATS + 8, length = Math.hypot(x, y, z, w);
|
|
351
|
+
if (!(length > 1e-9))
|
|
352
|
+
throw new World3DError('WORLD3D_INPUT_INVALID', 'rotation');
|
|
353
|
+
this.#animation[o] = x / length;
|
|
354
|
+
this.#animation[o + 1] = y / length;
|
|
355
|
+
this.#animation[o + 2] = z / length;
|
|
356
|
+
this.#animation[o + 3] = w / length;
|
|
357
|
+
}
|
|
358
|
+
/** Play a clip, by index or name, on one instance. */
|
|
359
|
+
setClipAt(index, clip, options = {}) {
|
|
360
|
+
this.check(index);
|
|
361
|
+
const resolved = this.resolve(clip), fade = requireFinite3D(options.fade ?? 0, 'fade');
|
|
362
|
+
if (fade > 0) {
|
|
363
|
+
// The clip playing now becomes the second one and runs on while its weight drops to nothing.
|
|
364
|
+
this.#clipB[index] = this.#clip[index];
|
|
365
|
+
this.#timeB[index] = this.#time[index];
|
|
366
|
+
this.#speedB[index] = this.#speed[index];
|
|
367
|
+
this.#flagsB[index] = this.#loop[index];
|
|
368
|
+
this.#weightB[index] = 1;
|
|
369
|
+
this.#fadeRate[index] = 1 / fade;
|
|
370
|
+
}
|
|
371
|
+
else if (this.#fadeRate[index] > 0) {
|
|
372
|
+
this.#clipB[index] = -1;
|
|
373
|
+
this.#weightB[index] = 0;
|
|
374
|
+
this.#fadeRate[index] = 0;
|
|
375
|
+
}
|
|
376
|
+
this.#clip[index] = resolved;
|
|
377
|
+
this.#time[index] = requireFinite3D(options.time ?? 0, 'time');
|
|
378
|
+
this.#speed[index] = requireFinite3D(options.speed ?? 1, 'speed');
|
|
379
|
+
this.#loop[index] = options.loop === false ? 0 : 1;
|
|
380
|
+
this.write(index);
|
|
381
|
+
}
|
|
382
|
+
/**
|
|
383
|
+
* Blend a second clip into an instance at a weight from 0 to 1, until
|
|
384
|
+
* changed: 0.3 shows 70% of its clip and 30% of this one. A weight of 0
|
|
385
|
+
* removes the second clip.
|
|
386
|
+
*/
|
|
387
|
+
setBlendAt(index, clip, weight, options = {}) {
|
|
388
|
+
this.check(index);
|
|
389
|
+
const amount = requireFinite3D(weight, 'weight');
|
|
390
|
+
if (amount < 0 || amount > 1)
|
|
391
|
+
throw new World3DError('WORLD3D_INPUT_INVALID', 'weight');
|
|
392
|
+
if (amount === 0) {
|
|
393
|
+
this.#clipB[index] = -1;
|
|
394
|
+
this.#weightB[index] = 0;
|
|
395
|
+
this.#fadeRate[index] = 0;
|
|
396
|
+
this.write(index);
|
|
397
|
+
return;
|
|
398
|
+
}
|
|
399
|
+
const resolved = this.resolve(clip);
|
|
400
|
+
if (this.#clipB[index] !== resolved || this.#fadeRate[index] > 0) {
|
|
401
|
+
this.#clipB[index] = resolved;
|
|
402
|
+
this.#timeB[index] = requireFinite3D(options.time ?? 0, 'time');
|
|
403
|
+
}
|
|
404
|
+
this.#speedB[index] = requireFinite3D(options.speed ?? 1, 'speed');
|
|
405
|
+
this.#flagsB[index] = (options.loop === false ? 0 : 1) | (options.sync === false ? 0 : 2);
|
|
406
|
+
this.#weightB[index] = amount;
|
|
407
|
+
this.#fadeRate[index] = 0;
|
|
408
|
+
this.write(index);
|
|
409
|
+
}
|
|
410
|
+
clipAt(index) {
|
|
411
|
+
this.check(index);
|
|
412
|
+
return this.#clip[index];
|
|
413
|
+
}
|
|
414
|
+
timeAt(index) {
|
|
415
|
+
this.check(index);
|
|
416
|
+
return this.#time[index];
|
|
417
|
+
}
|
|
418
|
+
/** Weight of the instance's second clip, 0 when it has none. */
|
|
419
|
+
blendAt(index) {
|
|
420
|
+
this.check(index);
|
|
421
|
+
return this.#clipB[index] < 0 ? 0 : this.#weightB[index];
|
|
422
|
+
}
|
|
423
|
+
setTimeAt(index, seconds) {
|
|
424
|
+
this.check(index);
|
|
425
|
+
this.#time[index] = requireFinite3D(seconds, 'time');
|
|
426
|
+
this.write(index);
|
|
427
|
+
}
|
|
428
|
+
setSpeedAt(index, speed) {
|
|
429
|
+
this.check(index);
|
|
430
|
+
this.#speed[index] = requireFinite3D(speed, 'speed');
|
|
431
|
+
}
|
|
432
|
+
/** True once a clip that does not loop has reached its end. */
|
|
433
|
+
isFinishedAt(index) {
|
|
434
|
+
this.check(index);
|
|
435
|
+
return (this.#loop[index] === 0 &&
|
|
436
|
+
(this.#speed[index] >= 0
|
|
437
|
+
? this.#time[index] >= this.animations.clips[this.#clip[index]].duration
|
|
438
|
+
: this.#time[index] <= 0));
|
|
439
|
+
}
|
|
440
|
+
/** Advance every instance by a time step in seconds. */
|
|
441
|
+
update(deltaSeconds) {
|
|
442
|
+
const dt = requireFinite3D(deltaSeconds, 'deltaSeconds'), clips = this.animations.clips;
|
|
443
|
+
const step = (time, by, duration, loop) => {
|
|
444
|
+
let t = time + by;
|
|
445
|
+
if (loop) {
|
|
446
|
+
if (duration > 0) {
|
|
447
|
+
t %= duration;
|
|
448
|
+
if (t < 0)
|
|
449
|
+
t += duration;
|
|
450
|
+
}
|
|
451
|
+
else
|
|
452
|
+
t = 0;
|
|
453
|
+
}
|
|
454
|
+
else
|
|
455
|
+
t = t < 0 ? 0 : t > duration ? duration : t;
|
|
456
|
+
return t;
|
|
457
|
+
};
|
|
458
|
+
for (let i = 0; i < Math.min(this.total, this.capacity); i++) {
|
|
459
|
+
const duration = clips[this.#clip[i]].duration;
|
|
460
|
+
this.#time[i] = step(this.#time[i], dt * this.#speed[i], duration, this.#loop[i] === 1);
|
|
461
|
+
const second = this.#clipB[i];
|
|
462
|
+
if (second >= 0) {
|
|
463
|
+
const other = clips[second].duration, flags = this.#flagsB[i];
|
|
464
|
+
// A synced clip sits at the same share of its length as the first.
|
|
465
|
+
if (flags & 2)
|
|
466
|
+
this.#timeB[i] = duration > 0 ? (this.#time[i] / duration) * other : 0;
|
|
467
|
+
else
|
|
468
|
+
this.#timeB[i] = step(this.#timeB[i], dt * this.#speedB[i], other, (flags & 1) === 1);
|
|
469
|
+
if (this.#fadeRate[i] > 0) {
|
|
470
|
+
this.#weightB[i] = this.#weightB[i] - this.#fadeRate[i] * Math.abs(dt);
|
|
471
|
+
if (this.#weightB[i] <= 0) {
|
|
472
|
+
this.#clipB[i] = -1;
|
|
473
|
+
this.#weightB[i] = 0;
|
|
474
|
+
this.#fadeRate[i] = 0;
|
|
475
|
+
}
|
|
476
|
+
}
|
|
477
|
+
}
|
|
478
|
+
this.write(i);
|
|
479
|
+
}
|
|
480
|
+
this.compact(undefined);
|
|
481
|
+
}
|
|
482
|
+
/**
|
|
483
|
+
* Fill the drawn arrays from the instances a camera can see, or from all
|
|
484
|
+
* of them without one. Rendering does this by itself.
|
|
485
|
+
*/
|
|
486
|
+
compact(camera) {
|
|
487
|
+
const total = Math.min(this.count, this.capacity), size = this.instanceColorSize, colors = this.instanceColors, m = this.instanceMatrices;
|
|
488
|
+
let drawn = 0;
|
|
489
|
+
// Camera compaction is shared by the shadow draw. Keep all casters
|
|
490
|
+
// until shadow and camera lists can consume separate instance ranges.
|
|
491
|
+
if (camera && this.#cullRadius !== undefined && !this.castShadow && Number.isFinite(this.cullPadding)) {
|
|
492
|
+
this.#compacting = true;
|
|
493
|
+
this.#compactMatrices ??= new Float32Array(this.capacity * 16);
|
|
494
|
+
this.#compactAnimation ??= new Float32Array(this.capacity * FLOATS);
|
|
495
|
+
if (colors)
|
|
496
|
+
this.#compactColors ??= new Float32Array(this.capacity * size);
|
|
497
|
+
this.updateWorldMatrix();
|
|
498
|
+
camera.updateViewMatrices();
|
|
499
|
+
const world = this.matrixWorld, sphere = scratchSphere;
|
|
500
|
+
const worldRadius = this.#cullRadius * (1 + Math.max(0, this.cullPadding)) * affineScaleBound(world, 0);
|
|
501
|
+
for (let i = 0; i < total; i++) {
|
|
502
|
+
const o = i * 16;
|
|
503
|
+
const x = m[o + 12], y = m[o + 13], z = m[o + 14];
|
|
504
|
+
sphere[0] = world[0] * x + world[4] * y + world[8] * z + world[12];
|
|
505
|
+
sphere[1] = world[1] * x + world[5] * y + world[9] * z + world[13];
|
|
506
|
+
sphere[2] = world[2] * x + world[6] * y + world[10] * z + world[14];
|
|
507
|
+
sphere[3] = worldRadius * affineScaleBound(m, o);
|
|
508
|
+
if (!Number.isFinite(sphere[3]) || frustumIntersectsSphere(camera.frustum, sphere))
|
|
509
|
+
this.place(drawn++, i, size, colors);
|
|
510
|
+
}
|
|
511
|
+
}
|
|
512
|
+
else {
|
|
513
|
+
this.#compacting = false;
|
|
514
|
+
drawn = total;
|
|
515
|
+
}
|
|
516
|
+
this.#drawCount = drawn;
|
|
517
|
+
this.instanceVersion++;
|
|
518
|
+
}
|
|
519
|
+
clone() {
|
|
520
|
+
const copy = new SkinnedInstancedMesh3D(this.geometry, this.material, this.animations, this.capacity, this.instanceColorSize);
|
|
521
|
+
copy.copyFrom(this);
|
|
522
|
+
copy.total = this.total;
|
|
523
|
+
copy.cullInstances = this.cullInstances;
|
|
524
|
+
copy.cullPadding = this.cullPadding;
|
|
525
|
+
copy.#cullRadius = this.#cullRadius;
|
|
526
|
+
copy.instanceMatrices.set(this.instanceMatrices);
|
|
527
|
+
copy.#animation.set(this.#animation);
|
|
528
|
+
if (this.instanceColors)
|
|
529
|
+
copy.instanceColors = this.instanceColors.slice();
|
|
530
|
+
copy.#clip.set(this.#clip);
|
|
531
|
+
copy.#time.set(this.#time);
|
|
532
|
+
copy.#speed.set(this.#speed);
|
|
533
|
+
copy.#loop.set(this.#loop);
|
|
534
|
+
copy.#clipB.set(this.#clipB);
|
|
535
|
+
copy.#timeB.set(this.#timeB);
|
|
536
|
+
copy.#speedB.set(this.#speedB);
|
|
537
|
+
copy.#flagsB.set(this.#flagsB);
|
|
538
|
+
copy.#weightB.set(this.#weightB);
|
|
539
|
+
copy.#fadeRate.set(this.#fadeRate);
|
|
540
|
+
copy.#lookBone = this.#lookBone;
|
|
541
|
+
copy.compact(undefined);
|
|
542
|
+
return copy;
|
|
543
|
+
}
|
|
544
|
+
place(slot, index, size, colors) {
|
|
545
|
+
this.#compactMatrices.set(this.instanceMatrices.subarray(index * 16, index * 16 + 16), slot * 16);
|
|
546
|
+
this.#compactAnimation.set(this.#animation.subarray(index * FLOATS, index * FLOATS + FLOATS), slot * FLOATS);
|
|
547
|
+
if (colors)
|
|
548
|
+
this.#compactColors.set(colors.subarray(index * size, index * size + size), slot * size);
|
|
549
|
+
}
|
|
550
|
+
resolve(clip) {
|
|
551
|
+
const resolved = typeof clip === 'string' ? this.animations.clipIndex(clip) : clip;
|
|
552
|
+
if (!Number.isSafeInteger(resolved) || resolved < 0 || resolved >= this.animations.clips.length)
|
|
553
|
+
throw new World3DError('WORLD3D_INPUT_INVALID', 'clip');
|
|
554
|
+
return resolved;
|
|
555
|
+
}
|
|
556
|
+
check(index) {
|
|
557
|
+
if (!Number.isSafeInteger(index) || index < 0 || index >= this.capacity)
|
|
558
|
+
throw new World3DError('WORLD3D_INPUT_INVALID', 'instance index');
|
|
559
|
+
}
|
|
560
|
+
write(index) {
|
|
561
|
+
const a = this.#animation, o = index * FLOATS, second = this.#clipB[index];
|
|
562
|
+
this.animations.framesAt(this.#clip[index], this.#time[index], this.#loop[index] === 1, a, o);
|
|
563
|
+
// The fourth float carries two numbers every instance shares: matrices per frame and the look bone.
|
|
564
|
+
a[o + 3] = this.animations.stride + 2048 * (this.#lookBone + 1);
|
|
565
|
+
if (second >= 0) {
|
|
566
|
+
this.animations.framesAt(second, this.#timeB[index], (this.#flagsB[index] & 1) === 1, a, o + 4);
|
|
567
|
+
a[o + 7] = this.#weightB[index];
|
|
568
|
+
}
|
|
569
|
+
else {
|
|
570
|
+
a[o + 4] = a[o];
|
|
571
|
+
a[o + 5] = a[o + 1];
|
|
572
|
+
a[o + 6] = 0;
|
|
573
|
+
a[o + 7] = 0;
|
|
574
|
+
}
|
|
575
|
+
if (this.#legacyAnimation)
|
|
576
|
+
this.writeLegacy(index, this.#legacyAnimation);
|
|
577
|
+
}
|
|
578
|
+
writeLegacy(index, target) {
|
|
579
|
+
const o = index * FLOATS, to = index * 4, data = this.#animation;
|
|
580
|
+
if (this.#fadeRate[index] > 0) {
|
|
581
|
+
// The legacy four-float view can report only the nearest frame of each fading clip.
|
|
582
|
+
target[to] = data[o + (data[o + 6] < 0.5 ? 4 : 5)];
|
|
583
|
+
target[to + 1] = data[o + (data[o + 2] < 0.5 ? 0 : 1)];
|
|
584
|
+
target[to + 2] = 1 - data[o + 7];
|
|
585
|
+
}
|
|
586
|
+
else {
|
|
587
|
+
target[to] = data[o];
|
|
588
|
+
target[to + 1] = data[o + 1];
|
|
589
|
+
target[to + 2] = data[o + 2];
|
|
590
|
+
}
|
|
591
|
+
target[to + 3] = this.animations.boneCount;
|
|
592
|
+
}
|
|
593
|
+
}
|
|
594
|
+
/** A baked skin can extend beyond the available sphere, including when a bone scales in place. */
|
|
595
|
+
export function worldRenderSphere3D(mesh) {
|
|
596
|
+
return mesh instanceof SkinnedInstancedMesh3D ? undefined : mesh.worldBoundingSphere;
|
|
597
|
+
}
|
|
598
|
+
export function createSkinnedInstancedMesh3D(geometry, material, animations, capacity, instanceColorSize = 3) {
|
|
599
|
+
return new SkinnedInstancedMesh3D(geometry, material, animations, capacity, instanceColorSize);
|
|
600
|
+
}
|
|
601
|
+
//# sourceMappingURL=AnimationTexture3D.js.map
|
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
import type { Camera3D } from './Camera3D.js';
|
|
2
|
+
import { Geometry3D } from './Geometry3D.js';
|
|
3
|
+
import { Material3D } from './Material3D.js';
|
|
4
|
+
import type { ColorInput3D } from './Material3D.js';
|
|
5
|
+
import { Mesh3D } from './Mesh3D.js';
|
|
6
|
+
export declare const BATCH3D_LIMITS: Readonly<{
|
|
7
|
+
readonly maxItems: 65536;
|
|
8
|
+
readonly maxVertices: 4194304;
|
|
9
|
+
readonly maxLinePoints: 65536;
|
|
10
|
+
}>;
|
|
11
|
+
/**
|
|
12
|
+
* Many geometries drawn as one mesh with one material and one draw call.
|
|
13
|
+
* Each added geometry keeps its own transform, visibility and tint, which
|
|
14
|
+
* can change afterwards; the combined buffers are rebuilt only when something
|
|
15
|
+
* did. Best for props that move rarely, since a change rewrites the batch.
|
|
16
|
+
*/
|
|
17
|
+
export declare class BatchedMesh3D extends Mesh3D {
|
|
18
|
+
#private;
|
|
19
|
+
constructor(material: Material3D);
|
|
20
|
+
/** Number of geometries added and not deleted. */
|
|
21
|
+
get itemCount(): number;
|
|
22
|
+
/** Add a triangle geometry and return its id within this batch. The geometry itself is copied. */
|
|
23
|
+
addGeometry(geometry: Geometry3D, matrix?: ArrayLike<number>): number;
|
|
24
|
+
private checkedMatrix;
|
|
25
|
+
private item;
|
|
26
|
+
setMatrixAt(id: number, matrix: ArrayLike<number>): this;
|
|
27
|
+
getMatrixAt(id: number, out?: Float32Array): Float32Array;
|
|
28
|
+
setVisibleAt(id: number, visible: boolean): this;
|
|
29
|
+
getVisibleAt(id: number): boolean;
|
|
30
|
+
/** Tint one item through vertex colors; the material needs `vertexColors` enabled. */
|
|
31
|
+
setColorAt(id: number, r: number, g: number, b: number): this;
|
|
32
|
+
/** Remove an item. Its id is not reused. */
|
|
33
|
+
deleteGeometry(id: number): this;
|
|
34
|
+
/** Rebuild the combined buffers now instead of at the next frame. */
|
|
35
|
+
flush(): void;
|
|
36
|
+
beforeRender(): void;
|
|
37
|
+
/** Release the combined geometry. The material stays with its owner. */
|
|
38
|
+
dispose(): void;
|
|
39
|
+
}
|
|
40
|
+
export interface FatLineOptions3D {
|
|
41
|
+
/** Width in world units, or in pixels when `screenSpace` is set. */
|
|
42
|
+
readonly width?: number;
|
|
43
|
+
/** Keep a constant width on screen; set `resolutionHeight` to the output height in pixels. */
|
|
44
|
+
readonly screenSpace?: boolean;
|
|
45
|
+
readonly color?: ColorInput3D;
|
|
46
|
+
/** Join the last point back to the first. */
|
|
47
|
+
readonly closed?: boolean;
|
|
48
|
+
}
|
|
49
|
+
/**
|
|
50
|
+
* A polyline drawn as a ribbon of triangles that turns to face the camera,
|
|
51
|
+
* so it can be wider than the one pixel that plain lines allow. Give points
|
|
52
|
+
* in the line's local space; call setPoints() to change them.
|
|
53
|
+
*/
|
|
54
|
+
export declare class FatLine3D extends Mesh3D {
|
|
55
|
+
#private;
|
|
56
|
+
width: number;
|
|
57
|
+
screenSpace: boolean;
|
|
58
|
+
/** Output height in pixels, used to convert a pixel width to world units. */
|
|
59
|
+
resolutionHeight: number;
|
|
60
|
+
closed: boolean;
|
|
61
|
+
constructor(points: ArrayLike<number> | readonly ArrayLike<number>[], options?: FatLineOptions3D);
|
|
62
|
+
/** Replace the points: a flat [x, y, z, ...] array or a list of [x, y, z]. */
|
|
63
|
+
setPoints(points: ArrayLike<number> | readonly ArrayLike<number>[]): this;
|
|
64
|
+
/** Rebuild the ribbon so it faces `camera`. The render list calls this each frame. */
|
|
65
|
+
beforeRender(camera: Camera3D): void;
|
|
66
|
+
/** Release the line's own geometry and material. */
|
|
67
|
+
dispose(): void;
|
|
68
|
+
}
|
|
69
|
+
export declare function createBatchedMesh3D(material: Material3D): BatchedMesh3D;
|
|
70
|
+
export declare function createFatLine3D(points: ArrayLike<number> | readonly ArrayLike<number>[], options?: FatLineOptions3D): FatLine3D;
|
|
71
|
+
//# sourceMappingURL=Batch3D.d.ts.map
|