@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,426 @@
|
|
|
1
|
+
// SPDX-License-Identifier: Apache-2.0
|
|
2
|
+
// Fewer triangles for the same shape: a model made in code, a scanned or generated asset, a far version for a level
|
|
3
|
+
// of detail. Edges are collapsed one by one, cheapest first, where the cost of a collapse is how far the kept vertex
|
|
4
|
+
// lies from the planes of the triangles around both ends (the quadric error metric of Garland and Heckbert, 1997).
|
|
5
|
+
// A collapse that would turn a triangle over, pinch the surface or move an open edge is refused. With vertex colours
|
|
6
|
+
// the quadrics take in colour as well (Garland and Heckbert, 1998), so painted edges stay. Each kept vertex keeps its own normal, colour and texture
|
|
7
|
+
// coordinates, so seams and painted parts stay where they were.
|
|
8
|
+
import { World3DError } from './core3D.js';
|
|
9
|
+
import { Attribute3D, Geometry3D } from './Geometry3D.js';
|
|
10
|
+
function invalid(what) {
|
|
11
|
+
return new World3DError('WORLD3D_INPUT_INVALID', what);
|
|
12
|
+
}
|
|
13
|
+
class Heap {
|
|
14
|
+
cost = [];
|
|
15
|
+
a = [];
|
|
16
|
+
b = [];
|
|
17
|
+
stamp = [];
|
|
18
|
+
get size() {
|
|
19
|
+
return this.cost.length;
|
|
20
|
+
}
|
|
21
|
+
push(cost, a, b, stamp) {
|
|
22
|
+
let i = this.cost.length;
|
|
23
|
+
this.cost.push(cost);
|
|
24
|
+
this.a.push(a);
|
|
25
|
+
this.b.push(b);
|
|
26
|
+
this.stamp.push(stamp);
|
|
27
|
+
while (i > 0) {
|
|
28
|
+
const p = (i - 1) >> 1;
|
|
29
|
+
if (this.cost[p] <= cost)
|
|
30
|
+
break;
|
|
31
|
+
this.#swap(i, p);
|
|
32
|
+
i = p;
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
pop() {
|
|
36
|
+
const top = [this.cost[0], this.a[0], this.b[0], this.stamp[0]];
|
|
37
|
+
const last = this.cost.length - 1;
|
|
38
|
+
this.#swap(0, last);
|
|
39
|
+
this.cost.pop();
|
|
40
|
+
this.a.pop();
|
|
41
|
+
this.b.pop();
|
|
42
|
+
this.stamp.pop();
|
|
43
|
+
let i = 0;
|
|
44
|
+
for (;;) {
|
|
45
|
+
const l = i * 2 + 1, r = l + 1;
|
|
46
|
+
let m = i;
|
|
47
|
+
if (l < this.cost.length && this.cost[l] < this.cost[m])
|
|
48
|
+
m = l;
|
|
49
|
+
if (r < this.cost.length && this.cost[r] < this.cost[m])
|
|
50
|
+
m = r;
|
|
51
|
+
if (m === i)
|
|
52
|
+
break;
|
|
53
|
+
this.#swap(i, m);
|
|
54
|
+
i = m;
|
|
55
|
+
}
|
|
56
|
+
return top;
|
|
57
|
+
}
|
|
58
|
+
#swap(i, j) {
|
|
59
|
+
for (const list of [this.cost, this.a, this.b, this.stamp]) {
|
|
60
|
+
const t = list[i];
|
|
61
|
+
list[i] = list[j];
|
|
62
|
+
list[j] = t;
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
/**
|
|
67
|
+
* A copy of an indexed triangle geometry with fewer triangles; the geometry given is not changed. Groups (one material per range) are kept;
|
|
68
|
+
* geometries with morph targets are refused. Vertices that sit
|
|
69
|
+
* on an open edge (a hole, or a texture seam where vertices are split) are kept in place.
|
|
70
|
+
*/
|
|
71
|
+
export function simplifyGeometry3D(geometry, options = {}) {
|
|
72
|
+
if (!(geometry instanceof Geometry3D))
|
|
73
|
+
throw invalid('simplify geometry');
|
|
74
|
+
if (geometry.topology !== 'triangles')
|
|
75
|
+
throw invalid('simplify topology');
|
|
76
|
+
// Morph targets move vertices a collapse would join.
|
|
77
|
+
if (geometry.morphTargets.length > 0)
|
|
78
|
+
throw invalid('simplify morph targets');
|
|
79
|
+
if (options === null || typeof options !== 'object')
|
|
80
|
+
throw invalid('simplify options');
|
|
81
|
+
const position = geometry.getAttribute('position');
|
|
82
|
+
if (!position || position.itemSize !== 3)
|
|
83
|
+
throw invalid('simplify positions');
|
|
84
|
+
const P = position.data;
|
|
85
|
+
const n = P.length / 3;
|
|
86
|
+
const source = geometry.index ? Array.from(geometry.index.data) : Array.from({ length: n }, (_, i) => i);
|
|
87
|
+
if (source.length % 3 !== 0)
|
|
88
|
+
throw invalid('simplify indices');
|
|
89
|
+
const faces = source.length / 3;
|
|
90
|
+
let target;
|
|
91
|
+
if (options.triangles !== undefined) {
|
|
92
|
+
if (!Number.isInteger(options.triangles) || options.triangles < 0)
|
|
93
|
+
throw invalid('simplify triangles');
|
|
94
|
+
target = options.triangles;
|
|
95
|
+
}
|
|
96
|
+
else if (options.ratio !== undefined) {
|
|
97
|
+
if (typeof options.ratio !== 'number' || !(options.ratio >= 0 && options.ratio <= 1))
|
|
98
|
+
throw invalid('simplify ratio');
|
|
99
|
+
target = Math.floor(faces * options.ratio);
|
|
100
|
+
}
|
|
101
|
+
else
|
|
102
|
+
target = Math.floor(faces / 2);
|
|
103
|
+
let maxError = Infinity;
|
|
104
|
+
if (options.maxError !== undefined) {
|
|
105
|
+
if (typeof options.maxError !== 'number' || !(options.maxError >= 0))
|
|
106
|
+
throw invalid('simplify maxError');
|
|
107
|
+
maxError = options.maxError;
|
|
108
|
+
}
|
|
109
|
+
const F = Int32Array.from(source);
|
|
110
|
+
// The material of each triangle, from the groups: a collapse never changes it.
|
|
111
|
+
const groupOf = new Int32Array(faces).fill(-1);
|
|
112
|
+
for (const group of geometry.groups)
|
|
113
|
+
for (let i = Math.floor(group.start / 3); i < Math.min(faces, Math.floor((group.start + group.count) / 3)); i++)
|
|
114
|
+
groupOf[i] = group.materialIndex;
|
|
115
|
+
const alive = new Uint8Array(faces).fill(1);
|
|
116
|
+
const vertexFaces = Array.from({ length: n }, () => []);
|
|
117
|
+
for (let f = 0; f < faces; f++)
|
|
118
|
+
for (let c = 0; c < 3; c++)
|
|
119
|
+
vertexFaces[F[f * 3 + c]].push(f);
|
|
120
|
+
// Open edges: an edge used by one triangle only. Their vertices stay.
|
|
121
|
+
const edgeUse = new Map();
|
|
122
|
+
const key = (a, b) => (a < b ? a * n + b : b * n + a);
|
|
123
|
+
for (let f = 0; f < faces; f++)
|
|
124
|
+
for (let c = 0; c < 3; c++) {
|
|
125
|
+
const k = key(F[f * 3 + c], F[f * 3 + ((c + 1) % 3)]);
|
|
126
|
+
edgeUse.set(k, (edgeUse.get(k) ?? 0) + 1);
|
|
127
|
+
}
|
|
128
|
+
const locked = new Uint8Array(n);
|
|
129
|
+
for (let f = 0; f < faces; f++)
|
|
130
|
+
for (let c = 0; c < 3; c++) {
|
|
131
|
+
const a = F[f * 3 + c], b = F[f * 3 + ((c + 1) % 3)];
|
|
132
|
+
if (edgeUse.get(key(a, b)) !== 1)
|
|
133
|
+
continue;
|
|
134
|
+
locked[a] = 1;
|
|
135
|
+
locked[b] = 1;
|
|
136
|
+
}
|
|
137
|
+
// One quadric per vertex: the sum of the squared distances to the planes of its triangles, area-weighted.
|
|
138
|
+
const Q = new Float64Array(n * 10);
|
|
139
|
+
const addPlane = (v, a, b, c, d, w) => {
|
|
140
|
+
const q = v * 10;
|
|
141
|
+
Q[q] = Q[q] + w * a * a;
|
|
142
|
+
Q[q + 1] = Q[q + 1] + w * a * b;
|
|
143
|
+
Q[q + 2] = Q[q + 2] + w * a * c;
|
|
144
|
+
Q[q + 3] = Q[q + 3] + w * a * d;
|
|
145
|
+
Q[q + 4] = Q[q + 4] + w * b * b;
|
|
146
|
+
Q[q + 5] = Q[q + 5] + w * b * c;
|
|
147
|
+
Q[q + 6] = Q[q + 6] + w * b * d;
|
|
148
|
+
Q[q + 7] = Q[q + 7] + w * c * c;
|
|
149
|
+
Q[q + 8] = Q[q + 8] + w * c * d;
|
|
150
|
+
Q[q + 9] = Q[q + 9] + w * d * d;
|
|
151
|
+
};
|
|
152
|
+
const faceNormal = (i0, i1, i2) => {
|
|
153
|
+
const ux = P[i1 * 3] - P[i0 * 3], uy = P[i1 * 3 + 1] - P[i0 * 3 + 1], uz = P[i1 * 3 + 2] - P[i0 * 3 + 2];
|
|
154
|
+
const vx = P[i2 * 3] - P[i0 * 3], vy = P[i2 * 3 + 1] - P[i0 * 3 + 1], vz = P[i2 * 3 + 2] - P[i0 * 3 + 2];
|
|
155
|
+
const x = uy * vz - uz * vy, y = uz * vx - ux * vz, z = ux * vy - uy * vx;
|
|
156
|
+
const l = Math.hypot(x, y, z);
|
|
157
|
+
return l > 0 ? [x / l, y / l, z / l, l / 2] : [0, 0, 0, 0];
|
|
158
|
+
};
|
|
159
|
+
for (let f = 0; f < faces; f++) {
|
|
160
|
+
const i0 = F[f * 3], i1 = F[f * 3 + 1], i2 = F[f * 3 + 2];
|
|
161
|
+
const [a, b, c, area] = faceNormal(i0, i1, i2);
|
|
162
|
+
if (area === 0)
|
|
163
|
+
continue;
|
|
164
|
+
const d = -(a * P[i0 * 3] + b * P[i0 * 3 + 1] + c * P[i0 * 3 + 2]);
|
|
165
|
+
for (const v of [i0, i1, i2])
|
|
166
|
+
addPlane(v, a, b, c, d, area);
|
|
167
|
+
}
|
|
168
|
+
const errorAt = (q, r, v) => {
|
|
169
|
+
// The quadric of q plus that of r, at the position of v.
|
|
170
|
+
const x = P[v * 3], y = P[v * 3 + 1], z = P[v * 3 + 2];
|
|
171
|
+
const s = (i) => Q[q * 10 + i] + Q[r * 10 + i];
|
|
172
|
+
return Math.max(0, s(0) * x * x +
|
|
173
|
+
2 * s(1) * x * y +
|
|
174
|
+
2 * s(2) * x * z +
|
|
175
|
+
2 * s(3) * x +
|
|
176
|
+
s(4) * y * y +
|
|
177
|
+
2 * s(5) * y * z +
|
|
178
|
+
2 * s(6) * y +
|
|
179
|
+
s(7) * z * z +
|
|
180
|
+
2 * s(8) * z +
|
|
181
|
+
s(9));
|
|
182
|
+
};
|
|
183
|
+
const areaOf = new Float64Array(n);
|
|
184
|
+
for (let f = 0; f < faces; f++) {
|
|
185
|
+
const area = faceNormal(F[f * 3], F[f * 3 + 1], F[f * 3 + 2])[3];
|
|
186
|
+
for (let c = 0; c < 3; c++) {
|
|
187
|
+
const v = F[f * 3 + c];
|
|
188
|
+
areaOf[v] = areaOf[v] + area;
|
|
189
|
+
}
|
|
190
|
+
}
|
|
191
|
+
// The quadric error is an area-weighted squared distance; this turns it back into a distance.
|
|
192
|
+
const distanceOf = (cost, u, v) => Math.sqrt(cost / Math.max(areaOf[u] + areaOf[v], 1e-30));
|
|
193
|
+
const stamp = new Int32Array(n);
|
|
194
|
+
const heap = new Heap();
|
|
195
|
+
let colorCostOf;
|
|
196
|
+
// The cost of moving u onto v, Infinity when u may not move.
|
|
197
|
+
// Vertex colours count too, through a quadric over position and colour together (Garland and Heckbert, 1998): each
|
|
198
|
+
// triangle is a plane in six dimensions, and a collapse that drags a vertex of one colour across a stripe of
|
|
199
|
+
// another costs as much as moving the surface by a tenth of the model's size for a full change of colour. Painted
|
|
200
|
+
// edges then keep their line, and the triangles around them do not stretch across.
|
|
201
|
+
const colors = geometry.getAttribute('color');
|
|
202
|
+
const C = colors !== undefined && colors.itemSize >= 3 ? colors.data : undefined, cs = colors?.itemSize ?? 0;
|
|
203
|
+
const D = 6, W6 = D * D + D + 1;
|
|
204
|
+
const Q6 = C === undefined ? undefined : new Float64Array(n * W6);
|
|
205
|
+
if (C !== undefined && Q6 !== undefined) {
|
|
206
|
+
let x0 = Infinity, x1 = -Infinity, y0 = Infinity, y1 = -Infinity, z0 = Infinity, z1 = -Infinity;
|
|
207
|
+
for (let i = 0; i < n; i++) {
|
|
208
|
+
x0 = Math.min(x0, P[i * 3]);
|
|
209
|
+
x1 = Math.max(x1, P[i * 3]);
|
|
210
|
+
y0 = Math.min(y0, P[i * 3 + 1]);
|
|
211
|
+
y1 = Math.max(y1, P[i * 3 + 1]);
|
|
212
|
+
z0 = Math.min(z0, P[i * 3 + 2]);
|
|
213
|
+
z1 = Math.max(z1, P[i * 3 + 2]);
|
|
214
|
+
}
|
|
215
|
+
const scale = Math.hypot(x1 - x0, y1 - y0, z1 - z0) / 10;
|
|
216
|
+
const point = (v, out) => {
|
|
217
|
+
out[0] = P[v * 3];
|
|
218
|
+
out[1] = P[v * 3 + 1];
|
|
219
|
+
out[2] = P[v * 3 + 2];
|
|
220
|
+
for (let c = 0; c < 3; c++)
|
|
221
|
+
out[3 + c] = C[v * cs + c] * scale;
|
|
222
|
+
};
|
|
223
|
+
const p = new Float64Array(D), q = new Float64Array(D), r = new Float64Array(D), e1 = new Float64Array(D), e2 = new Float64Array(D);
|
|
224
|
+
const dot = (a, b) => {
|
|
225
|
+
let sum = 0;
|
|
226
|
+
for (let i = 0; i < D; i++)
|
|
227
|
+
sum += a[i] * b[i];
|
|
228
|
+
return sum;
|
|
229
|
+
};
|
|
230
|
+
for (let f = 0; f < faces; f++) {
|
|
231
|
+
const i0 = F[f * 3], i1 = F[f * 3 + 1], i2 = F[f * 3 + 2];
|
|
232
|
+
const area = faceNormal(i0, i1, i2)[3];
|
|
233
|
+
if (area === 0)
|
|
234
|
+
continue;
|
|
235
|
+
point(i0, p);
|
|
236
|
+
point(i1, q);
|
|
237
|
+
point(i2, r);
|
|
238
|
+
for (let i = 0; i < D; i++)
|
|
239
|
+
e1[i] = q[i] - p[i];
|
|
240
|
+
const l1 = Math.sqrt(dot(e1, e1));
|
|
241
|
+
if (l1 === 0)
|
|
242
|
+
continue;
|
|
243
|
+
for (let i = 0; i < D; i++)
|
|
244
|
+
e1[i] = e1[i] / l1;
|
|
245
|
+
for (let i = 0; i < D; i++)
|
|
246
|
+
e2[i] = r[i] - p[i];
|
|
247
|
+
const along = dot(e1, e2);
|
|
248
|
+
for (let i = 0; i < D; i++)
|
|
249
|
+
e2[i] = e2[i] - along * e1[i];
|
|
250
|
+
const l2 = Math.sqrt(dot(e2, e2));
|
|
251
|
+
if (l2 === 0)
|
|
252
|
+
continue;
|
|
253
|
+
for (let i = 0; i < D; i++)
|
|
254
|
+
e2[i] = e2[i] / l2;
|
|
255
|
+
const p1 = dot(p, e1), p2 = dot(p, e2);
|
|
256
|
+
for (const v of [i0, i1, i2]) {
|
|
257
|
+
const o = v * W6;
|
|
258
|
+
for (let i = 0; i < D; i++)
|
|
259
|
+
for (let j = 0; j < D; j++)
|
|
260
|
+
Q6[o + i * D + j] = Q6[o + i * D + j] + area * ((i === j ? 1 : 0) - e1[i] * e1[j] - e2[i] * e2[j]);
|
|
261
|
+
for (let i = 0; i < D; i++)
|
|
262
|
+
Q6[o + D * D + i] = Q6[o + D * D + i] + area * (p1 * e1[i] + p2 * e2[i] - p[i]);
|
|
263
|
+
Q6[o + D * D + D] = Q6[o + D * D + D] + area * (dot(p, p) - p1 * p1 - p2 * p2);
|
|
264
|
+
}
|
|
265
|
+
}
|
|
266
|
+
// The point of a vertex is fixed now: keep it to price a collapse onto it.
|
|
267
|
+
const points6 = new Float64Array(n * D);
|
|
268
|
+
for (let v = 0; v < n; v++) {
|
|
269
|
+
point(v, p);
|
|
270
|
+
points6.set(p, v * D);
|
|
271
|
+
}
|
|
272
|
+
colorCostOf = (u, v) => {
|
|
273
|
+
let sum = 0;
|
|
274
|
+
const a = u * W6, b = v * W6, x = v * D;
|
|
275
|
+
for (let i = 0; i < D; i++) {
|
|
276
|
+
const xi = points6[x + i];
|
|
277
|
+
let row = 0;
|
|
278
|
+
for (let j = 0; j < D; j++)
|
|
279
|
+
row += (Q6[a + i * D + j] + Q6[b + i * D + j]) * points6[x + j];
|
|
280
|
+
sum += xi * row + 2 * (Q6[a + D * D + i] + Q6[b + D * D + i]) * xi;
|
|
281
|
+
}
|
|
282
|
+
return Math.max(0, sum + Q6[a + D * D + D] + Q6[b + D * D + D]);
|
|
283
|
+
};
|
|
284
|
+
}
|
|
285
|
+
const costOf = (u, v) => locked[u] ? Infinity : colorCostOf === undefined ? errorAt(u, v, v) : colorCostOf(u, v);
|
|
286
|
+
const offer = (a, b) => {
|
|
287
|
+
const ab = costOf(a, b), ba = costOf(b, a);
|
|
288
|
+
if (ab === Infinity && ba === Infinity)
|
|
289
|
+
return;
|
|
290
|
+
if (ab <= ba)
|
|
291
|
+
heap.push(ab, a, b, stamp[a] + stamp[b] * 65536);
|
|
292
|
+
else
|
|
293
|
+
heap.push(ba, b, a, stamp[a] + stamp[b] * 65536);
|
|
294
|
+
};
|
|
295
|
+
for (let f = 0; f < faces; f++)
|
|
296
|
+
for (let c = 0; c < 3; c++) {
|
|
297
|
+
const a = F[f * 3 + c], b = F[f * 3 + ((c + 1) % 3)];
|
|
298
|
+
if (a < b)
|
|
299
|
+
offer(a, b);
|
|
300
|
+
else if (edgeUse.get(key(a, b)) === 1)
|
|
301
|
+
offer(b, a);
|
|
302
|
+
}
|
|
303
|
+
const neighbours = (v) => {
|
|
304
|
+
const out = new Set();
|
|
305
|
+
for (const f of vertexFaces[v])
|
|
306
|
+
if (alive[f])
|
|
307
|
+
for (let c = 0; c < 3; c++)
|
|
308
|
+
out.add(F[f * 3 + c]);
|
|
309
|
+
out.delete(v);
|
|
310
|
+
return out;
|
|
311
|
+
};
|
|
312
|
+
let live = faces, worst = 0;
|
|
313
|
+
while (live > target && heap.size > 0) {
|
|
314
|
+
const [cost, u, v, s] = heap.pop();
|
|
315
|
+
const a = Math.min(u, v), b = Math.max(u, v);
|
|
316
|
+
if (s !== stamp[a] + stamp[b] * 65536)
|
|
317
|
+
continue;
|
|
318
|
+
if (cost === Infinity)
|
|
319
|
+
break;
|
|
320
|
+
// The heap orders by shape and colour together; the distance the surface moves is the shape's part alone.
|
|
321
|
+
const moved = distanceOf(errorAt(u, v, v), u, v);
|
|
322
|
+
if (moved > maxError)
|
|
323
|
+
break;
|
|
324
|
+
// The edge must still be there, and the two ends must share exactly the two vertices across the edge.
|
|
325
|
+
const nu = neighbours(u);
|
|
326
|
+
if (!nu.has(v))
|
|
327
|
+
continue;
|
|
328
|
+
const nv = neighbours(v);
|
|
329
|
+
let shared = 0;
|
|
330
|
+
for (const w of nu)
|
|
331
|
+
if (nv.has(w))
|
|
332
|
+
shared++;
|
|
333
|
+
if (shared !== 2)
|
|
334
|
+
continue;
|
|
335
|
+
// No triangle of u that stays may turn over or become a sliver.
|
|
336
|
+
let flips = false;
|
|
337
|
+
for (const f of vertexFaces[u]) {
|
|
338
|
+
if (!alive[f])
|
|
339
|
+
continue;
|
|
340
|
+
const i0 = F[f * 3], i1 = F[f * 3 + 1], i2 = F[f * 3 + 2];
|
|
341
|
+
if (i0 === v || i1 === v || i2 === v)
|
|
342
|
+
continue;
|
|
343
|
+
const before = faceNormal(i0, i1, i2);
|
|
344
|
+
const after = faceNormal(i0 === u ? v : i0, i1 === u ? v : i1, i2 === u ? v : i2);
|
|
345
|
+
if (after[3] === 0 || before[0] * after[0] + before[1] * after[1] + before[2] * after[2] < 0.3) {
|
|
346
|
+
flips = true;
|
|
347
|
+
break;
|
|
348
|
+
}
|
|
349
|
+
}
|
|
350
|
+
if (flips)
|
|
351
|
+
continue;
|
|
352
|
+
for (const f of vertexFaces[u]) {
|
|
353
|
+
if (!alive[f])
|
|
354
|
+
continue;
|
|
355
|
+
let hasV = false;
|
|
356
|
+
for (let c = 0; c < 3; c++)
|
|
357
|
+
if (F[f * 3 + c] === v)
|
|
358
|
+
hasV = true;
|
|
359
|
+
if (hasV) {
|
|
360
|
+
alive[f] = 0;
|
|
361
|
+
live--;
|
|
362
|
+
continue;
|
|
363
|
+
}
|
|
364
|
+
for (let c = 0; c < 3; c++)
|
|
365
|
+
if (F[f * 3 + c] === u)
|
|
366
|
+
F[f * 3 + c] = v;
|
|
367
|
+
vertexFaces[v].push(f);
|
|
368
|
+
}
|
|
369
|
+
vertexFaces[u] = [];
|
|
370
|
+
for (let i = 0; i < 10; i++)
|
|
371
|
+
Q[v * 10 + i] = Q[v * 10 + i] + Q[u * 10 + i];
|
|
372
|
+
if (Q6 !== undefined)
|
|
373
|
+
for (let i = 0; i < W6; i++)
|
|
374
|
+
Q6[v * W6 + i] = Q6[v * W6 + i] + Q6[u * W6 + i];
|
|
375
|
+
areaOf[v] = areaOf[v] + areaOf[u];
|
|
376
|
+
if (moved > worst)
|
|
377
|
+
worst = moved;
|
|
378
|
+
stamp[v] = stamp[v] + 1;
|
|
379
|
+
stamp[u] = stamp[u] + 1;
|
|
380
|
+
vertexFaces[v] = vertexFaces[v].filter(f => alive[f]);
|
|
381
|
+
for (const w of neighbours(v))
|
|
382
|
+
offer(v, w);
|
|
383
|
+
}
|
|
384
|
+
// Keep the vertices still used, in their first order, with every attribute they had.
|
|
385
|
+
const remap = new Int32Array(n).fill(-1);
|
|
386
|
+
const order = [];
|
|
387
|
+
const indices = [];
|
|
388
|
+
const order3 = Array.from({ length: faces }, (_, f) => f).filter(f => alive[f] === 1);
|
|
389
|
+
if (geometry.groups.length > 0)
|
|
390
|
+
order3.sort((a, b) => groupOf[a] - groupOf[b] || a - b);
|
|
391
|
+
for (const f of order3) {
|
|
392
|
+
for (let c = 0; c < 3; c++) {
|
|
393
|
+
const v = F[f * 3 + c];
|
|
394
|
+
if (remap[v] === -1) {
|
|
395
|
+
remap[v] = order.length;
|
|
396
|
+
order.push(v);
|
|
397
|
+
}
|
|
398
|
+
indices.push(remap[v]);
|
|
399
|
+
}
|
|
400
|
+
}
|
|
401
|
+
const out = new Geometry3D();
|
|
402
|
+
out.topology = 'triangles';
|
|
403
|
+
for (const [name, attribute] of geometry.attributes) {
|
|
404
|
+
const size = attribute.itemSize, data = attribute.data;
|
|
405
|
+
const copy = new data.constructor(order.length * size);
|
|
406
|
+
for (let i = 0; i < order.length; i++)
|
|
407
|
+
for (let c = 0; c < size; c++)
|
|
408
|
+
copy[i * size + c] = data[order[i] * size + c];
|
|
409
|
+
out.setAttribute(name, new Attribute3D(copy, size, attribute.normalized));
|
|
410
|
+
}
|
|
411
|
+
out.setIndex(order.length > 65535 ? Uint32Array.from(indices) : Uint16Array.from(indices));
|
|
412
|
+
if (geometry.groups.length > 0) {
|
|
413
|
+
let start = 0;
|
|
414
|
+
while (start < order3.length) {
|
|
415
|
+
let end = start;
|
|
416
|
+
while (end < order3.length && groupOf[order3[end]] === groupOf[order3[start]])
|
|
417
|
+
end++;
|
|
418
|
+
const material = groupOf[order3[start]];
|
|
419
|
+
if (material >= 0)
|
|
420
|
+
out.addGroup(start * 3, (end - start) * 3, material);
|
|
421
|
+
start = end;
|
|
422
|
+
}
|
|
423
|
+
}
|
|
424
|
+
return { geometry: out, before: faces, after: live, error: worst };
|
|
425
|
+
}
|
|
426
|
+
//# sourceMappingURL=Simplify3D.js.map
|
|
@@ -0,0 +1,87 @@
|
|
|
1
|
+
import { AnimationMixer3D } from './Animation3D.js';
|
|
2
|
+
import type { AnimationClip3D } from './Animation3D.js';
|
|
3
|
+
/** The most states and transitions a state machine has, and how many transitions it takes in one update. */
|
|
4
|
+
export declare const STATE_MACHINE3D_LIMITS: Readonly<{
|
|
5
|
+
readonly maxStates: 256;
|
|
6
|
+
readonly maxTransitions: 2048;
|
|
7
|
+
readonly maxTransitionsPerUpdate: 8;
|
|
8
|
+
}>;
|
|
9
|
+
/** The value of a state machine parameter. */
|
|
10
|
+
export type StateParameter3D = number | boolean;
|
|
11
|
+
/** How a condition compares a parameter with its value. */
|
|
12
|
+
export type StateConditionOperator3D = '>' | '>=' | '<' | '<=' | '==' | '!=';
|
|
13
|
+
/** A condition of a transition: a parameter compared with a value. */
|
|
14
|
+
export interface StateCondition3D {
|
|
15
|
+
readonly parameter: string;
|
|
16
|
+
/** Comparison against `value`. Omit both to test a boolean or a trigger for true. */
|
|
17
|
+
readonly op?: StateConditionOperator3D;
|
|
18
|
+
readonly value?: StateParameter3D;
|
|
19
|
+
}
|
|
20
|
+
/** One clip of a blend state and the parameter value it shows at. */
|
|
21
|
+
export interface StateBlendEntry3D {
|
|
22
|
+
readonly clip: AnimationClip3D;
|
|
23
|
+
/** Parameter value at which this clip plays alone. */
|
|
24
|
+
readonly threshold: number;
|
|
25
|
+
}
|
|
26
|
+
/** A state to add: its clip or blend, whether it loops, its speed, and what it calls on entering and leaving. */
|
|
27
|
+
export interface StateOptions3D {
|
|
28
|
+
/** A single clip, or omit it and give `blend`. */
|
|
29
|
+
readonly clip?: AnimationClip3D;
|
|
30
|
+
/** Blend neighbouring clips by a numeric parameter, with their phases kept in step. */
|
|
31
|
+
readonly blend?: {
|
|
32
|
+
readonly parameter: string;
|
|
33
|
+
readonly clips: readonly StateBlendEntry3D[];
|
|
34
|
+
};
|
|
35
|
+
/** Repeat (default) or play once and hold the last frame. */
|
|
36
|
+
readonly loop?: boolean;
|
|
37
|
+
readonly speed?: number;
|
|
38
|
+
readonly onEnter?: () => void;
|
|
39
|
+
readonly onExit?: () => void;
|
|
40
|
+
}
|
|
41
|
+
/** A transition to add: from and to which state, how long it fades, its conditions, its exit time and whether it can be interrupted. */
|
|
42
|
+
export interface TransitionOptions3D {
|
|
43
|
+
/** Source state, or '*' for any state. */
|
|
44
|
+
readonly from: string;
|
|
45
|
+
readonly to: string;
|
|
46
|
+
/** Cross-fade length in seconds. */
|
|
47
|
+
readonly duration?: number;
|
|
48
|
+
/** Every condition must hold. With none, the transition needs an exit time. */
|
|
49
|
+
readonly conditions?: readonly StateCondition3D[];
|
|
50
|
+
/** Normalized play time of the source state (1 = one full pass) that must be reached first. */
|
|
51
|
+
readonly exitTime?: number;
|
|
52
|
+
/** Allow this transition to start while another fade is still running. Defaults to true. */
|
|
53
|
+
readonly canInterrupt?: boolean;
|
|
54
|
+
}
|
|
55
|
+
/** Plays clips by state, moving between states when their conditions are met. */
|
|
56
|
+
export declare class AnimationStateMachine3D {
|
|
57
|
+
#private;
|
|
58
|
+
readonly mixer: AnimationMixer3D;
|
|
59
|
+
/** Called after every state change, including forced ones. */
|
|
60
|
+
onStateChange: ((from: string | undefined, to: string) => void) | undefined;
|
|
61
|
+
constructor(mixer: AnimationMixer3D);
|
|
62
|
+
/** Name of the active state; during a fade this is the state being faded in. */
|
|
63
|
+
get current(): string | undefined;
|
|
64
|
+
get isTransitioning(): boolean;
|
|
65
|
+
/** Play time of the active state in passes of its duration. */
|
|
66
|
+
get normalizedTime(): number;
|
|
67
|
+
addState(name: string, options: StateOptions3D): this;
|
|
68
|
+
addTransition(options: TransitionOptions3D): this;
|
|
69
|
+
/** Run `callback` each time `state` passes `normalizedTime` (0 to 1 within one pass). */
|
|
70
|
+
addEvent(state: string, normalizedTime: number, callback: () => void): this;
|
|
71
|
+
set(parameter: string, value: StateParameter3D): this;
|
|
72
|
+
get(parameter: string): StateParameter3D | undefined;
|
|
73
|
+
/** Raise a one-shot flag; the first transition that tests it consumes it. */
|
|
74
|
+
trigger(parameter: string): this;
|
|
75
|
+
resetTrigger(parameter: string): this;
|
|
76
|
+
/** Switch to `state` now, cross-fading over `duration` seconds. */
|
|
77
|
+
play(state: string, duration?: number): this;
|
|
78
|
+
private enter;
|
|
79
|
+
private holds;
|
|
80
|
+
private evaluate;
|
|
81
|
+
private applyState;
|
|
82
|
+
/** Evaluate transitions, advance fades and drive the mixer by `deltaSeconds`. */
|
|
83
|
+
update(deltaSeconds: number): void;
|
|
84
|
+
}
|
|
85
|
+
/** Makes an animation state machine that drives a mixer. */
|
|
86
|
+
export declare function createAnimationStateMachine3D(mixer: AnimationMixer3D): AnimationStateMachine3D;
|
|
87
|
+
//# sourceMappingURL=StateMachine3D.d.ts.map
|