@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,242 @@
|
|
|
1
|
+
// SPDX-License-Identifier: Apache-2.0
|
|
2
|
+
// Decals: a texture laid onto existing geometry, such as a bullet hole, a
|
|
3
|
+
// scorch mark or a painted sign. The triangles of the target that fall inside
|
|
4
|
+
// a box are cut out and returned as a new geometry that hugs the surface, so
|
|
5
|
+
// the decal is lit and shadowed like any other mesh on both backends.
|
|
6
|
+
import { World3DError, requireFinite3D, requirePositive3D } from './core3D.js';
|
|
7
|
+
import { Attribute3D, Geometry3D } from './Geometry3D.js';
|
|
8
|
+
import { Mesh3D } from './Mesh3D.js';
|
|
9
|
+
import { mat4Invert, mat4Multiply } from './math3D.js';
|
|
10
|
+
/** The most triangles a decal has. */
|
|
11
|
+
export const DECAL3D_LIMITS = Object.freeze({ maxTriangles: 262144 });
|
|
12
|
+
/**
|
|
13
|
+
* Cut the part of a mesh's surface that lies inside the decal box. The
|
|
14
|
+
* result is in the mesh's local space, with coordinates running 0 to 1 across
|
|
15
|
+
* the box, or undefined when nothing is inside. A skinned mesh is cut in its
|
|
16
|
+
* bind pose, where `position` and `normal` must lie too, and the result keeps
|
|
17
|
+
* joints and weights so it can follow the same skeleton. Interpolated weights
|
|
18
|
+
* approximate the posed surface where the source vertices have different weights.
|
|
19
|
+
*/
|
|
20
|
+
export function createDecalGeometry3D(mesh, options) {
|
|
21
|
+
if (!(mesh instanceof Mesh3D) || !options)
|
|
22
|
+
throw new World3DError('WORLD3D_INPUT_INVALID', 'decal target');
|
|
23
|
+
const geometry = mesh.geometry, source = geometry.getAttribute('position');
|
|
24
|
+
if (!source || geometry.topology !== 'triangles')
|
|
25
|
+
throw new World3DError('WORLD3D_INPUT_INVALID', 'decal target needs triangles');
|
|
26
|
+
const width = requirePositive3D(options.width ?? 1, 'width'), height = requirePositive3D(options.height ?? 1, 'height'), depth = requirePositive3D(options.depth ?? Math.max(width, height) / 2, 'depth');
|
|
27
|
+
const limit = Math.cos(requireFinite3D(options.maxAngle ?? 1.4, 'maxAngle')), lift = requireFinite3D(options.offset ?? 0.002, 'offset');
|
|
28
|
+
// The decal's frame in world space: Z faces away from the surface.
|
|
29
|
+
let zx = requireFinite3D(options.normal[0], 'normal'), zy = requireFinite3D(options.normal[1], 'normal'), zz = requireFinite3D(options.normal[2], 'normal');
|
|
30
|
+
const zl = Math.hypot(zx, zy, zz);
|
|
31
|
+
if (zl < 1e-9)
|
|
32
|
+
throw new World3DError('WORLD3D_INPUT_INVALID', 'normal');
|
|
33
|
+
zx /= zl;
|
|
34
|
+
zy /= zl;
|
|
35
|
+
zz /= zl;
|
|
36
|
+
const hint = options.up ?? (Math.abs(zy) > 0.99 ? [0, 0, -1] : [0, 1, 0]);
|
|
37
|
+
let xx = hint[1] * zz - hint[2] * zy, xy = hint[2] * zx - hint[0] * zz, xz = hint[0] * zy - hint[1] * zx;
|
|
38
|
+
const xl = Math.hypot(xx, xy, xz);
|
|
39
|
+
if (xl < 1e-9)
|
|
40
|
+
throw new World3DError('WORLD3D_INPUT_INVALID', 'up must not be parallel to the normal');
|
|
41
|
+
xx /= xl;
|
|
42
|
+
xy /= xl;
|
|
43
|
+
xz /= xl;
|
|
44
|
+
let yx = zy * xz - zz * xy, yy = zz * xx - zx * xz, yz = zx * xy - zy * xx;
|
|
45
|
+
const turn = requireFinite3D(options.rotation ?? 0, 'rotation'), c = Math.cos(turn), s = Math.sin(turn);
|
|
46
|
+
[xx, xy, xz, yx, yy, yz] = [
|
|
47
|
+
xx * c + yx * s,
|
|
48
|
+
xy * c + yy * s,
|
|
49
|
+
xz * c + yz * s,
|
|
50
|
+
yx * c - xx * s,
|
|
51
|
+
yy * c - xy * s,
|
|
52
|
+
yz * c - xz * s
|
|
53
|
+
];
|
|
54
|
+
const frame = new Float32Array([
|
|
55
|
+
xx,
|
|
56
|
+
xy,
|
|
57
|
+
xz,
|
|
58
|
+
0,
|
|
59
|
+
yx,
|
|
60
|
+
yy,
|
|
61
|
+
yz,
|
|
62
|
+
0,
|
|
63
|
+
zx,
|
|
64
|
+
zy,
|
|
65
|
+
zz,
|
|
66
|
+
0,
|
|
67
|
+
requireFinite3D(options.position[0], 'position'),
|
|
68
|
+
requireFinite3D(options.position[1], 'position'),
|
|
69
|
+
requireFinite3D(options.position[2], 'position'),
|
|
70
|
+
1
|
|
71
|
+
]);
|
|
72
|
+
mesh.updateWorldMatrix();
|
|
73
|
+
// Mesh space to decal space and back.
|
|
74
|
+
const toDecal = new Float32Array(16), toMesh = new Float32Array(16);
|
|
75
|
+
if (!mat4Invert(toDecal, frame))
|
|
76
|
+
throw new World3DError('WORLD3D_INPUT_INVALID', 'decal frame');
|
|
77
|
+
mat4Multiply(toDecal, toDecal, mesh.matrixWorld);
|
|
78
|
+
if (!mat4Invert(toMesh, toDecal))
|
|
79
|
+
throw new World3DError('WORLD3D_INPUT_INVALID', 'mesh transform is singular');
|
|
80
|
+
const p = source.data, normals = geometry.getAttribute('normal')?.data, index = geometry.index?.data, count = index ? index.length : source.count;
|
|
81
|
+
if (count / 3 > DECAL3D_LIMITS.maxTriangles)
|
|
82
|
+
throw new World3DError('WORLD3D_BUDGET', 'decal target triangles');
|
|
83
|
+
const hx = width / 2, hy = height / 2, hz = depth / 2, m = toDecal;
|
|
84
|
+
// Reflected transforms reverse winding, but the renderers keep the same visible face.
|
|
85
|
+
const determinant = m[0] * (m[5] * m[10] - m[6] * m[9]) -
|
|
86
|
+
m[4] * (m[1] * m[10] - m[2] * m[9]) +
|
|
87
|
+
m[8] * (m[1] * m[6] - m[2] * m[5]);
|
|
88
|
+
const facing = determinant < 0 ? -1 : 1;
|
|
89
|
+
const joints = geometry.getAttribute('joints')?.data, weights = geometry.getAttribute('weights')?.data, skinned = joints !== undefined && weights !== undefined;
|
|
90
|
+
const read = (i) => {
|
|
91
|
+
const x = p[i * 3], y = p[i * 3 + 1], z = p[i * 3 + 2];
|
|
92
|
+
const out = [
|
|
93
|
+
m[0] * x + m[4] * y + m[8] * z + m[12],
|
|
94
|
+
m[1] * x + m[5] * y + m[9] * z + m[13],
|
|
95
|
+
m[2] * x + m[6] * y + m[10] * z + m[14],
|
|
96
|
+
0,
|
|
97
|
+
0,
|
|
98
|
+
0
|
|
99
|
+
];
|
|
100
|
+
if (normals) {
|
|
101
|
+
const nx = normals[i * 3], ny = normals[i * 3 + 1], nz = normals[i * 3 + 2];
|
|
102
|
+
// Normals use the inverse transpose, so lifting the decal follows the surface under nonuniform scale.
|
|
103
|
+
const inverse = toMesh;
|
|
104
|
+
out[3] = inverse[0] * nx + inverse[1] * ny + inverse[2] * nz;
|
|
105
|
+
out[4] = inverse[4] * nx + inverse[5] * ny + inverse[6] * nz;
|
|
106
|
+
out[5] = inverse[8] * nx + inverse[9] * ny + inverse[10] * nz;
|
|
107
|
+
}
|
|
108
|
+
if (skinned) {
|
|
109
|
+
out.bones = [];
|
|
110
|
+
for (let k = 0; k < 4; k++)
|
|
111
|
+
if (weights[i * 4 + k] > 0)
|
|
112
|
+
out.bones.push(joints[i * 4 + k], weights[i * 4 + k]);
|
|
113
|
+
}
|
|
114
|
+
return out;
|
|
115
|
+
};
|
|
116
|
+
// Sutherland-Hodgman: keep the part of a polygon on the inner side of one face of the box.
|
|
117
|
+
const clip = (polygon, axis, sign, half) => {
|
|
118
|
+
const out = [];
|
|
119
|
+
for (let i = 0; i < polygon.length; i++) {
|
|
120
|
+
const a = polygon[i], b = polygon[(i + 1) % polygon.length], da = half - a[axis] * sign, db = half - b[axis] * sign;
|
|
121
|
+
if (da >= 0)
|
|
122
|
+
out.push(a);
|
|
123
|
+
if (da >= 0 !== db >= 0) {
|
|
124
|
+
const t = da / (da - db);
|
|
125
|
+
const cut = [
|
|
126
|
+
a[0] + (b[0] - a[0]) * t,
|
|
127
|
+
a[1] + (b[1] - a[1]) * t,
|
|
128
|
+
a[2] + (b[2] - a[2]) * t,
|
|
129
|
+
a[3] + (b[3] - a[3]) * t,
|
|
130
|
+
a[4] + (b[4] - a[4]) * t,
|
|
131
|
+
a[5] + (b[5] - a[5]) * t
|
|
132
|
+
];
|
|
133
|
+
if (a.bones && b.bones) {
|
|
134
|
+
// Blend endpoint influences to approximate attachment along the clipped edge.
|
|
135
|
+
cut.bones = [];
|
|
136
|
+
for (let k = 0; k < a.bones.length; k += 2)
|
|
137
|
+
cut.bones.push(a.bones[k], a.bones[k + 1] * (1 - t));
|
|
138
|
+
for (let k = 0; k < b.bones.length; k += 2) {
|
|
139
|
+
const known = cut.bones.findIndex((value, at) => at % 2 === 0 && value === b.bones[k]);
|
|
140
|
+
if (known >= 0)
|
|
141
|
+
cut.bones[known + 1] = cut.bones[known + 1] + b.bones[k + 1] * t;
|
|
142
|
+
else
|
|
143
|
+
cut.bones.push(b.bones[k], b.bones[k + 1] * t);
|
|
144
|
+
}
|
|
145
|
+
}
|
|
146
|
+
out.push(cut);
|
|
147
|
+
}
|
|
148
|
+
}
|
|
149
|
+
return out;
|
|
150
|
+
};
|
|
151
|
+
const outPositions = [], outNormals = [], outUvs = [], outJoints = [], outWeights = [];
|
|
152
|
+
for (let t = 0; t < count; t += 3) {
|
|
153
|
+
const a = read(index ? index[t] : t), b = read(index ? index[t + 1] : t + 1), d = read(index ? index[t + 2] : t + 2);
|
|
154
|
+
// Quick rejects: wholly outside one face of the box, or turned away from the decal.
|
|
155
|
+
if (Math.min(a[0], b[0], d[0]) > hx ||
|
|
156
|
+
Math.max(a[0], b[0], d[0]) < -hx ||
|
|
157
|
+
Math.min(a[1], b[1], d[1]) > hy ||
|
|
158
|
+
Math.max(a[1], b[1], d[1]) < -hy ||
|
|
159
|
+
Math.min(a[2], b[2], d[2]) > hz ||
|
|
160
|
+
Math.max(a[2], b[2], d[2]) < -hz)
|
|
161
|
+
continue;
|
|
162
|
+
const ux = b[0] - a[0], uy = b[1] - a[1], uz = b[2] - a[2], vx = d[0] - a[0], vy = d[1] - a[1], vz = d[2] - a[2];
|
|
163
|
+
let fx = uy * vz - uz * vy, fy = uz * vx - ux * vz, fz = ux * vy - uy * vx;
|
|
164
|
+
const fl = Math.hypot(fx, fy, fz);
|
|
165
|
+
if (fl < 1e-12 || (facing * fz) / fl < limit)
|
|
166
|
+
continue;
|
|
167
|
+
const normalScale = facing / fl;
|
|
168
|
+
fx *= normalScale;
|
|
169
|
+
fy *= normalScale;
|
|
170
|
+
fz *= normalScale;
|
|
171
|
+
if (!normals)
|
|
172
|
+
for (const vertex of [a, b, d]) {
|
|
173
|
+
vertex[3] = fx;
|
|
174
|
+
vertex[4] = fy;
|
|
175
|
+
vertex[5] = fz;
|
|
176
|
+
}
|
|
177
|
+
let polygon = [a, b, d];
|
|
178
|
+
polygon = clip(polygon, 0, 1, hx);
|
|
179
|
+
polygon = clip(polygon, 0, -1, hx);
|
|
180
|
+
polygon = clip(polygon, 1, 1, hy);
|
|
181
|
+
polygon = clip(polygon, 1, -1, hy);
|
|
182
|
+
polygon = clip(polygon, 2, 1, hz);
|
|
183
|
+
polygon = clip(polygon, 2, -1, hz);
|
|
184
|
+
for (let i = 1; i + 1 < polygon.length; i++) {
|
|
185
|
+
for (const vertex of [polygon[0], polygon[i], polygon[i + 1]]) {
|
|
186
|
+
const nl = Math.hypot(vertex[3], vertex[4], vertex[5]) || 1, nx = vertex[3] / nl, ny = vertex[4] / nl, nz = vertex[5] / nl;
|
|
187
|
+
const x = vertex[0] + nx * lift, y = vertex[1] + ny * lift, z = vertex[2] + nz * lift, w = toMesh;
|
|
188
|
+
outPositions.push(w[0] * x + w[4] * y + w[8] * z + w[12], w[1] * x + w[5] * y + w[9] * z + w[13], w[2] * x + w[6] * y + w[10] * z + w[14]);
|
|
189
|
+
const mx = m[0] * nx + m[1] * ny + m[2] * nz, my = m[4] * nx + m[5] * ny + m[6] * nz, mz = m[8] * nx + m[9] * ny + m[10] * nz;
|
|
190
|
+
const ml = Math.hypot(mx, my, mz) || 1;
|
|
191
|
+
outNormals.push(mx / ml, my / ml, mz / ml);
|
|
192
|
+
outUvs.push(vertex[0] / width + 0.5, vertex[1] / height + 0.5);
|
|
193
|
+
if (skinned) {
|
|
194
|
+
// Keep the four strongest bones and make their weights sum to one.
|
|
195
|
+
const pairs = [];
|
|
196
|
+
for (let k = 0; k < (vertex.bones?.length ?? 0); k += 2)
|
|
197
|
+
pairs.push([vertex.bones[k], vertex.bones[k + 1]]);
|
|
198
|
+
pairs.sort((first, second) => second[1] - first[1]);
|
|
199
|
+
const kept = pairs.slice(0, 4), total = kept.reduce((sum, pair) => sum + pair[1], 0) || 1;
|
|
200
|
+
for (let k = 0; k < 4; k++) {
|
|
201
|
+
outJoints.push(kept[k]?.[0] ?? 0);
|
|
202
|
+
outWeights.push((kept[k]?.[1] ?? 0) / total);
|
|
203
|
+
}
|
|
204
|
+
}
|
|
205
|
+
}
|
|
206
|
+
}
|
|
207
|
+
}
|
|
208
|
+
if (outPositions.length === 0)
|
|
209
|
+
return undefined;
|
|
210
|
+
const out = new Geometry3D();
|
|
211
|
+
out.setAttribute('position', new Attribute3D(new Float32Array(outPositions), 3));
|
|
212
|
+
out.setAttribute('normal', new Attribute3D(new Float32Array(outNormals), 3));
|
|
213
|
+
out.setAttribute('uv', new Attribute3D(new Float32Array(outUvs), 2));
|
|
214
|
+
if (skinned) {
|
|
215
|
+
out.setAttribute('joints', new Attribute3D(new Uint16Array(outJoints), 4));
|
|
216
|
+
out.setAttribute('weights', new Attribute3D(new Float32Array(outWeights), 4));
|
|
217
|
+
}
|
|
218
|
+
return out;
|
|
219
|
+
}
|
|
220
|
+
/**
|
|
221
|
+
* A decal mesh on a target mesh, added as its child so it moves with it.
|
|
222
|
+
* The material is used as given except that it stops writing depth and gains a
|
|
223
|
+
* depth offset when it has none. On a skinned mesh the decal follows the
|
|
224
|
+
* skeleton. Returns undefined when the box misses the surface.
|
|
225
|
+
*/
|
|
226
|
+
export function createDecal3D(mesh, material, options) {
|
|
227
|
+
const geometry = createDecalGeometry3D(mesh, options);
|
|
228
|
+
if (!geometry)
|
|
229
|
+
return undefined;
|
|
230
|
+
material.depthWrite = false;
|
|
231
|
+
material.polygonOffset ??= [-2, -4];
|
|
232
|
+
const decal = new Mesh3D(geometry, material);
|
|
233
|
+
decal.name = 'decal';
|
|
234
|
+
decal.castShadow = false;
|
|
235
|
+
decal.receiveShadow = mesh.receiveShadow;
|
|
236
|
+
mesh.addChild(decal);
|
|
237
|
+
// On a skinned target the decal is moved by the same bones.
|
|
238
|
+
if (mesh.skeleton && geometry.getAttribute('joints'))
|
|
239
|
+
decal.bind(mesh.skeleton, mesh.bindMatrix);
|
|
240
|
+
return decal;
|
|
241
|
+
}
|
|
242
|
+
//# sourceMappingURL=Decal3D.js.map
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { Geometry3D } from './Geometry3D.js';
|
|
2
|
+
import { Object3D } from './Object3D.js';
|
|
3
|
+
/** How a model is written. */
|
|
4
|
+
export interface GlbExportOptions3D {
|
|
5
|
+
/** The name of the root node; that of the object, or 'model', unless given. */
|
|
6
|
+
readonly name?: string;
|
|
7
|
+
}
|
|
8
|
+
/**
|
|
9
|
+
* The model as the bytes of a .glb file: a geometry alone (with a plain material that shows its vertex colours), or an
|
|
10
|
+
* object and everything under it. Meshes that draw lines or points are left out.
|
|
11
|
+
*/
|
|
12
|
+
export declare function exportGlb3D(source: Geometry3D | Object3D, options?: GlbExportOptions3D): Uint8Array;
|
|
13
|
+
//# sourceMappingURL=Export3D.d.ts.map
|
|
@@ -0,0 +1,263 @@
|
|
|
1
|
+
// SPDX-License-Identifier: Apache-2.0
|
|
2
|
+
// Writes a model as a binary glTF (.glb): a mesh made in code saved once and loaded fast after, opened in Blender to be
|
|
3
|
+
// touched up, or handed to another tool. Geometry (positions, normals, vertex colours, texture coordinates, indices,
|
|
4
|
+
// material groups), the node tree with each node's position, rotation and scale, and each material's colour,
|
|
5
|
+
// opacity, metalness and roughness are written. Textures, skins, morph targets and animations are not.
|
|
6
|
+
import { World3DError } from './core3D.js';
|
|
7
|
+
import { Geometry3D } from './Geometry3D.js';
|
|
8
|
+
import { Mesh3D } from './Mesh3D.js';
|
|
9
|
+
import { Object3D } from './Object3D.js';
|
|
10
|
+
const FLOAT = 5126, UNSIGNED_SHORT = 5123, UNSIGNED_INT = 5125;
|
|
11
|
+
const ARRAY_BUFFER = 34962, ELEMENT_ARRAY_BUFFER = 34963;
|
|
12
|
+
const TYPES = { 1: 'SCALAR', 2: 'VEC2', 3: 'VEC3', 4: 'VEC4' };
|
|
13
|
+
const NAMES = { position: 'POSITION', normal: 'NORMAL', color: 'COLOR_0', uv: 'TEXCOORD_0' };
|
|
14
|
+
function invalid(what) {
|
|
15
|
+
return new World3DError('WORLD3D_INPUT_INVALID', what);
|
|
16
|
+
}
|
|
17
|
+
/** UTF-8 bytes of a string; this module runs where no TextEncoder is promised. */
|
|
18
|
+
function utf8(text) {
|
|
19
|
+
const out = [];
|
|
20
|
+
for (const ch of text) {
|
|
21
|
+
const c = ch.codePointAt(0);
|
|
22
|
+
if (c < 0x80)
|
|
23
|
+
out.push(c);
|
|
24
|
+
else if (c < 0x800)
|
|
25
|
+
out.push(0xc0 | (c >> 6), 0x80 | (c & 63));
|
|
26
|
+
else if (c < 0x10000)
|
|
27
|
+
out.push(0xe0 | (c >> 12), 0x80 | ((c >> 6) & 63), 0x80 | (c & 63));
|
|
28
|
+
else
|
|
29
|
+
out.push(0xf0 | (c >> 18), 0x80 | ((c >> 12) & 63), 0x80 | ((c >> 6) & 63), 0x80 | (c & 63));
|
|
30
|
+
}
|
|
31
|
+
return Uint8Array.from(out);
|
|
32
|
+
}
|
|
33
|
+
/** The attribute's values as floats, normalized integers turned into 0 to 1 (or -1 to 1). */
|
|
34
|
+
function floats(attribute) {
|
|
35
|
+
const data = attribute.data;
|
|
36
|
+
if (data instanceof Float32Array)
|
|
37
|
+
return data;
|
|
38
|
+
const out = new Float32Array(data.length);
|
|
39
|
+
let scale = 1;
|
|
40
|
+
if (attribute.normalized) {
|
|
41
|
+
if (data instanceof Uint8Array)
|
|
42
|
+
scale = 1 / 255;
|
|
43
|
+
else if (data instanceof Uint16Array)
|
|
44
|
+
scale = 1 / 65535;
|
|
45
|
+
else if (data instanceof Int8Array)
|
|
46
|
+
scale = 1 / 127;
|
|
47
|
+
else if (data instanceof Int16Array)
|
|
48
|
+
scale = 1 / 32767;
|
|
49
|
+
}
|
|
50
|
+
for (let i = 0; i < data.length; i++)
|
|
51
|
+
out[i] = data[i] * scale;
|
|
52
|
+
return out;
|
|
53
|
+
}
|
|
54
|
+
/**
|
|
55
|
+
* The model as the bytes of a .glb file: a geometry alone (with a plain material that shows its vertex colours), or an
|
|
56
|
+
* object and everything under it. Meshes that draw lines or points are left out.
|
|
57
|
+
*/
|
|
58
|
+
export function exportGlb3D(source, options = {}) {
|
|
59
|
+
if (!(source instanceof Geometry3D) && !(source instanceof Object3D))
|
|
60
|
+
throw invalid('export source');
|
|
61
|
+
if (options === null || typeof options !== 'object')
|
|
62
|
+
throw invalid('export options');
|
|
63
|
+
if (options.name !== undefined && typeof options.name !== 'string')
|
|
64
|
+
throw invalid('export name');
|
|
65
|
+
const json = {
|
|
66
|
+
asset: { version: '2.0', generator: 'Egret Engine World3D' },
|
|
67
|
+
scene: 0,
|
|
68
|
+
scenes: [{ nodes: [0] }],
|
|
69
|
+
nodes: [],
|
|
70
|
+
meshes: [],
|
|
71
|
+
materials: [],
|
|
72
|
+
accessors: [],
|
|
73
|
+
bufferViews: [],
|
|
74
|
+
buffers: []
|
|
75
|
+
};
|
|
76
|
+
const chunks = [];
|
|
77
|
+
let byteLength = 0;
|
|
78
|
+
const view = (bytes, target) => {
|
|
79
|
+
const pad = (4 - (byteLength % 4)) % 4;
|
|
80
|
+
if (pad > 0) {
|
|
81
|
+
chunks.push(new Uint8Array(pad));
|
|
82
|
+
byteLength += pad;
|
|
83
|
+
}
|
|
84
|
+
json.bufferViews.push({ buffer: 0, byteOffset: byteLength, byteLength: bytes.byteLength, target });
|
|
85
|
+
chunks.push(bytes);
|
|
86
|
+
byteLength += bytes.byteLength;
|
|
87
|
+
return json.bufferViews.length - 1;
|
|
88
|
+
};
|
|
89
|
+
const accessor = (values, size, extra) => {
|
|
90
|
+
const bytes = new Uint8Array(values.buffer.slice(values.byteOffset, values.byteOffset + values.byteLength));
|
|
91
|
+
const isIndex = !(values instanceof Float32Array);
|
|
92
|
+
json.accessors.push({
|
|
93
|
+
bufferView: view(bytes, isIndex ? ELEMENT_ARRAY_BUFFER : ARRAY_BUFFER),
|
|
94
|
+
componentType: values instanceof Float32Array ? FLOAT : values instanceof Uint16Array ? UNSIGNED_SHORT : UNSIGNED_INT,
|
|
95
|
+
count: values.length / size,
|
|
96
|
+
type: TYPES[size],
|
|
97
|
+
...extra
|
|
98
|
+
});
|
|
99
|
+
return json.accessors.length - 1;
|
|
100
|
+
};
|
|
101
|
+
const materialIndex = new Map();
|
|
102
|
+
const material = (m) => {
|
|
103
|
+
const known = materialIndex.get(m);
|
|
104
|
+
if (known !== undefined)
|
|
105
|
+
return known;
|
|
106
|
+
const entry = m === null
|
|
107
|
+
? {
|
|
108
|
+
name: 'vertex colours',
|
|
109
|
+
pbrMetallicRoughness: { baseColorFactor: [1, 1, 1, 1], metallicFactor: 0, roughnessFactor: 0.8 }
|
|
110
|
+
}
|
|
111
|
+
: {
|
|
112
|
+
name: m.name || undefined,
|
|
113
|
+
pbrMetallicRoughness: {
|
|
114
|
+
baseColorFactor: [m.color[0], m.color[1], m.color[2], m.opacity],
|
|
115
|
+
metallicFactor: m.metallic,
|
|
116
|
+
roughnessFactor: m.roughness
|
|
117
|
+
},
|
|
118
|
+
...(m.opacity < 1 ? { alphaMode: 'BLEND' } : {}),
|
|
119
|
+
...(m.side === 'double' ? { doubleSided: true } : {})
|
|
120
|
+
};
|
|
121
|
+
json.materials.push(entry);
|
|
122
|
+
materialIndex.set(m, json.materials.length - 1);
|
|
123
|
+
return json.materials.length - 1;
|
|
124
|
+
};
|
|
125
|
+
const meshIndex = new Map();
|
|
126
|
+
const ids = new WeakMap();
|
|
127
|
+
let nextId = 1;
|
|
128
|
+
const idOf = (o) => {
|
|
129
|
+
let id = ids.get(o);
|
|
130
|
+
if (id === undefined)
|
|
131
|
+
ids.set(o, (id = nextId++));
|
|
132
|
+
return id;
|
|
133
|
+
};
|
|
134
|
+
const attributesOf = new Map();
|
|
135
|
+
const mesh = (geometry, materials) => {
|
|
136
|
+
if (geometry.topology !== 'triangles')
|
|
137
|
+
return undefined;
|
|
138
|
+
const position = geometry.getAttribute('position');
|
|
139
|
+
if (!position || position.itemSize !== 3 || position.count === 0)
|
|
140
|
+
return undefined;
|
|
141
|
+
const key = idOf(geometry) + ':' + materials.map(m => (m === null ? 0 : idOf(m))).join(',');
|
|
142
|
+
const known = meshIndex.get(key);
|
|
143
|
+
if (known !== undefined)
|
|
144
|
+
return known;
|
|
145
|
+
let attributes = attributesOf.get(geometry);
|
|
146
|
+
if (attributes === undefined) {
|
|
147
|
+
attributes = {};
|
|
148
|
+
for (const [name, gltfName] of Object.entries(NAMES)) {
|
|
149
|
+
const attribute = geometry.getAttribute(name);
|
|
150
|
+
if (!attribute)
|
|
151
|
+
continue;
|
|
152
|
+
if (name === 'position') {
|
|
153
|
+
const p = floats(attribute), min = [Infinity, Infinity, Infinity], max = [-Infinity, -Infinity, -Infinity];
|
|
154
|
+
for (let i = 0; i < p.length; i += 3)
|
|
155
|
+
for (let a = 0; a < 3; a++) {
|
|
156
|
+
min[a] = Math.min(min[a], p[i + a]);
|
|
157
|
+
max[a] = Math.max(max[a], p[i + a]);
|
|
158
|
+
}
|
|
159
|
+
attributes[gltfName] = accessor(p, 3, { min, max });
|
|
160
|
+
}
|
|
161
|
+
else if ((name === 'color' && (attribute.itemSize === 3 || attribute.itemSize === 4)) || name !== 'color')
|
|
162
|
+
attributes[gltfName] = accessor(floats(attribute), attribute.itemSize, {});
|
|
163
|
+
}
|
|
164
|
+
attributesOf.set(geometry, attributes);
|
|
165
|
+
}
|
|
166
|
+
const count = position.count;
|
|
167
|
+
const index = geometry.index ? Array.from(geometry.index.data) : Array.from({ length: count }, (_, i) => i);
|
|
168
|
+
const ranges = geometry.groups.length > 0
|
|
169
|
+
? geometry.groups.map(g => ({ start: g.start, count: g.count, material: g.materialIndex }))
|
|
170
|
+
: [{ start: 0, count: index.length, material: 0 }];
|
|
171
|
+
const primitives = [];
|
|
172
|
+
for (const range of ranges) {
|
|
173
|
+
const part = index.slice(range.start, range.start + range.count);
|
|
174
|
+
if (part.length === 0)
|
|
175
|
+
continue;
|
|
176
|
+
const values = count > 65535 ? Uint32Array.from(part) : Uint16Array.from(part);
|
|
177
|
+
primitives.push({
|
|
178
|
+
attributes,
|
|
179
|
+
indices: accessor(values, 1, {}),
|
|
180
|
+
material: material(materials[Math.min(range.material, materials.length - 1)] ?? null),
|
|
181
|
+
mode: 4
|
|
182
|
+
});
|
|
183
|
+
}
|
|
184
|
+
if (primitives.length === 0)
|
|
185
|
+
return undefined;
|
|
186
|
+
json.meshes.push({ primitives });
|
|
187
|
+
meshIndex.set(key, json.meshes.length - 1);
|
|
188
|
+
return json.meshes.length - 1;
|
|
189
|
+
};
|
|
190
|
+
const node = (object) => {
|
|
191
|
+
const entry = {};
|
|
192
|
+
if (object.name)
|
|
193
|
+
entry.name = object.name;
|
|
194
|
+
const [px, py, pz] = object.position, [qx, qy, qz, qw] = object.quaternion, [sx, sy, sz] = object.scale;
|
|
195
|
+
if (px !== 0 || py !== 0 || pz !== 0)
|
|
196
|
+
entry.translation = [px, py, pz];
|
|
197
|
+
if (qx !== 0 || qy !== 0 || qz !== 0 || qw !== 1)
|
|
198
|
+
entry.rotation = [qx, qy, qz, qw];
|
|
199
|
+
if (sx !== 1 || sy !== 1 || sz !== 1)
|
|
200
|
+
entry.scale = [sx, sy, sz];
|
|
201
|
+
if (object instanceof Mesh3D) {
|
|
202
|
+
const list = Array.isArray(object.material) ? object.material : [object.material];
|
|
203
|
+
const m = mesh(object.geometry, list);
|
|
204
|
+
if (m !== undefined)
|
|
205
|
+
entry.mesh = m;
|
|
206
|
+
}
|
|
207
|
+
json.nodes.push(entry);
|
|
208
|
+
const at = json.nodes.length - 1;
|
|
209
|
+
const children = object.children.map(node);
|
|
210
|
+
if (children.length > 0)
|
|
211
|
+
entry.children = children;
|
|
212
|
+
return at;
|
|
213
|
+
};
|
|
214
|
+
if (source instanceof Geometry3D) {
|
|
215
|
+
const m = mesh(source, [null]);
|
|
216
|
+
if (m === undefined)
|
|
217
|
+
throw invalid('export geometry');
|
|
218
|
+
json.nodes.push({ name: options.name ?? 'model', mesh: m });
|
|
219
|
+
}
|
|
220
|
+
else {
|
|
221
|
+
node(source);
|
|
222
|
+
if (options.name !== undefined)
|
|
223
|
+
json.nodes[0].name = options.name;
|
|
224
|
+
else if (json.nodes[0].name === undefined)
|
|
225
|
+
json.nodes[0].name = 'model';
|
|
226
|
+
}
|
|
227
|
+
if (json.materials.length === 0)
|
|
228
|
+
delete json.materials;
|
|
229
|
+
if (json.meshes.length === 0)
|
|
230
|
+
delete json.meshes;
|
|
231
|
+
if (byteLength === 0) {
|
|
232
|
+
delete json.accessors;
|
|
233
|
+
delete json.bufferViews;
|
|
234
|
+
delete json.buffers;
|
|
235
|
+
}
|
|
236
|
+
else
|
|
237
|
+
json.buffers.push({ byteLength: byteLength + ((4 - (byteLength % 4)) % 4) });
|
|
238
|
+
const text = utf8(JSON.stringify(json));
|
|
239
|
+
const jsonLength = text.byteLength + ((4 - (text.byteLength % 4)) % 4);
|
|
240
|
+
const binLength = byteLength === 0 ? 0 : byteLength + ((4 - (byteLength % 4)) % 4);
|
|
241
|
+
const total = 12 + 8 + jsonLength + (binLength > 0 ? 8 + binLength : 0);
|
|
242
|
+
const out = new Uint8Array(total);
|
|
243
|
+
const dv = new DataView(out.buffer);
|
|
244
|
+
dv.setUint32(0, 0x46546c67, true);
|
|
245
|
+
dv.setUint32(4, 2, true);
|
|
246
|
+
dv.setUint32(8, total, true);
|
|
247
|
+
dv.setUint32(12, jsonLength, true);
|
|
248
|
+
dv.setUint32(16, 0x4e4f534a, true);
|
|
249
|
+
out.set(text, 20);
|
|
250
|
+
out.fill(0x20, 20 + text.byteLength, 20 + jsonLength);
|
|
251
|
+
if (binLength > 0) {
|
|
252
|
+
let at = 20 + jsonLength;
|
|
253
|
+
dv.setUint32(at, binLength, true);
|
|
254
|
+
dv.setUint32(at + 4, 0x004e4942, true);
|
|
255
|
+
at += 8;
|
|
256
|
+
for (const chunk of chunks) {
|
|
257
|
+
out.set(chunk, at);
|
|
258
|
+
at += chunk.byteLength;
|
|
259
|
+
}
|
|
260
|
+
}
|
|
261
|
+
return out;
|
|
262
|
+
}
|
|
263
|
+
//# sourceMappingURL=Export3D.js.map
|
|
@@ -0,0 +1,95 @@
|
|
|
1
|
+
import { Resource3D } from './core3D.js';
|
|
2
|
+
/** An array of vertex data. */
|
|
3
|
+
export type AttributeArray3D = Float32Array | Uint32Array | Uint16Array | Uint8Array | Int16Array | Int8Array;
|
|
4
|
+
/** How a geometry's vertices are joined: as triangles, lines, a strip of lines, or points. */
|
|
5
|
+
export type Topology3D = 'triangles' | 'lines' | 'line-strip' | 'points';
|
|
6
|
+
/** The most vertices, indices, morph targets and groups a geometry has. */
|
|
7
|
+
export declare const GEOMETRY3D_LIMITS: Readonly<{
|
|
8
|
+
readonly maxVertices: 4194304;
|
|
9
|
+
readonly maxIndices: 12582912;
|
|
10
|
+
readonly maxMorphTargets: 256;
|
|
11
|
+
readonly maxGroups: 1024;
|
|
12
|
+
}>;
|
|
13
|
+
/** Well-known attribute names understood by the built-in materials. */
|
|
14
|
+
export declare const ATTRIBUTE_3D: Readonly<{
|
|
15
|
+
readonly position: 'position';
|
|
16
|
+
readonly normal: 'normal';
|
|
17
|
+
readonly tangent: 'tangent';
|
|
18
|
+
readonly uv: 'uv';
|
|
19
|
+
readonly uv1: 'uv1';
|
|
20
|
+
readonly color: 'color';
|
|
21
|
+
readonly joints: 'joints';
|
|
22
|
+
readonly weights: 'weights';
|
|
23
|
+
}>;
|
|
24
|
+
/** One attribute of a geometry, such as positions: its data, how many numbers each vertex has, and whether they are normalized. */
|
|
25
|
+
export declare class Attribute3D {
|
|
26
|
+
#private;
|
|
27
|
+
readonly data: AttributeArray3D;
|
|
28
|
+
readonly itemSize: number;
|
|
29
|
+
/** Integer data is mapped to [0, 1] or [-1, 1] when sampled as float. */
|
|
30
|
+
readonly normalized: boolean;
|
|
31
|
+
/** Hint that data changes often, so the backend picks a streaming buffer. */
|
|
32
|
+
dynamic: boolean;
|
|
33
|
+
constructor(data: AttributeArray3D, itemSize: number, normalized?: boolean);
|
|
34
|
+
get count(): number;
|
|
35
|
+
get version(): number;
|
|
36
|
+
touch(): void;
|
|
37
|
+
}
|
|
38
|
+
/** A range of a geometry's indices drawn with one of its mesh's materials. */
|
|
39
|
+
export interface GeometryGroup3D {
|
|
40
|
+
readonly start: number;
|
|
41
|
+
readonly count: number;
|
|
42
|
+
readonly materialIndex: number;
|
|
43
|
+
}
|
|
44
|
+
/** A morph target: the positions, and normals, it moves a geometry toward. */
|
|
45
|
+
export interface MorphTarget3D {
|
|
46
|
+
readonly name: string;
|
|
47
|
+
/** Per-vertex deltas relative to the base attribute. */
|
|
48
|
+
readonly position?: Float32Array;
|
|
49
|
+
readonly normal?: Float32Array;
|
|
50
|
+
}
|
|
51
|
+
/** The vertices of a mesh: its attributes and indices, its groups and morph targets, and calls that compute normals and tangents. */
|
|
52
|
+
export declare class Geometry3D extends Resource3D {
|
|
53
|
+
#private;
|
|
54
|
+
topology: Topology3D;
|
|
55
|
+
get attributes(): ReadonlyMap<string, Attribute3D>;
|
|
56
|
+
get index(): Attribute3D | undefined;
|
|
57
|
+
get groups(): readonly GeometryGroup3D[];
|
|
58
|
+
get morphTargets(): readonly MorphTarget3D[];
|
|
59
|
+
get layoutVersion(): number;
|
|
60
|
+
get vertexCount(): number;
|
|
61
|
+
/** Number of indices, or vertices when the geometry is not indexed. */
|
|
62
|
+
get drawCount(): number;
|
|
63
|
+
setAttribute(name: string, attribute: Attribute3D): this;
|
|
64
|
+
getAttribute(name: string): Attribute3D | undefined;
|
|
65
|
+
removeAttribute(name: string): this;
|
|
66
|
+
setIndex(index: Uint16Array | Uint32Array | readonly number[] | undefined): this;
|
|
67
|
+
/** Assign a material slot to an index (or vertex) range. */
|
|
68
|
+
addGroup(start: number, count: number, materialIndex?: number): this;
|
|
69
|
+
clearGroups(): this;
|
|
70
|
+
setMorphTargets(targets: readonly MorphTarget3D[]): this;
|
|
71
|
+
/** Local-space [minX, minY, minZ, maxX, maxY, maxZ], cached until positions change. */
|
|
72
|
+
get boundingBox(): Float32Array;
|
|
73
|
+
/** Local-space [x, y, z, radius]; radius is negative for an empty geometry. */
|
|
74
|
+
get boundingSphere(): Float32Array;
|
|
75
|
+
/** Counts `invalidateBounds` calls: what a mesh's world bounds are kept by, beside the structure version. */
|
|
76
|
+
get boundsVersion(): number;
|
|
77
|
+
/** Call after editing position data in place. Meshes of this geometry find their world bounds again. */
|
|
78
|
+
invalidateBounds(): void;
|
|
79
|
+
/** Area-weighted smooth normals for triangle geometry. */
|
|
80
|
+
computeNormals(): this;
|
|
81
|
+
/** Per-vertex tangents (xyz + handedness) from positions, normals and UVs. */
|
|
82
|
+
computeTangents(): this;
|
|
83
|
+
}
|
|
84
|
+
/** A geometry to make: its positions, and its normals, texture coordinates, colors and indices where given. */
|
|
85
|
+
export interface GeometryInput3D {
|
|
86
|
+
readonly positions: ArrayLike<number>;
|
|
87
|
+
readonly normals?: ArrayLike<number>;
|
|
88
|
+
readonly uvs?: ArrayLike<number>;
|
|
89
|
+
readonly colors?: ArrayLike<number>;
|
|
90
|
+
readonly indices?: ArrayLike<number>;
|
|
91
|
+
readonly topology?: Topology3D;
|
|
92
|
+
}
|
|
93
|
+
/** Build a geometry from plain arrays; missing normals are computed for triangles. */
|
|
94
|
+
export declare function createGeometry3D(input: GeometryInput3D): Geometry3D;
|
|
95
|
+
//# sourceMappingURL=Geometry3D.d.ts.map
|