@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,95 @@
|
|
|
1
|
+
import { Shape3D } from './Curves3D.js';
|
|
2
|
+
import type { Geometry3D } from './Geometry3D.js';
|
|
3
|
+
/** The most characters, font bytes and glyph points 3D text has. */
|
|
4
|
+
export declare const TEXT3D_LIMITS: Readonly<{
|
|
5
|
+
readonly maxCharacters: 4096;
|
|
6
|
+
readonly maxFontBytes: 67108864;
|
|
7
|
+
readonly maxGlyphPoints: 65536;
|
|
8
|
+
readonly maxCompositeDepth: 8;
|
|
9
|
+
}>;
|
|
10
|
+
/**
|
|
11
|
+
* One glyph in font units. `commands` is a flat list of pen commands:
|
|
12
|
+
* 0 x y (start a contour), 1 x y (line), 2 cx cy x y (quadratic curve) and
|
|
13
|
+
* 3 c1x c1y c2x c2y x y (cubic curve).
|
|
14
|
+
*/
|
|
15
|
+
export interface GlyphOutline3D {
|
|
16
|
+
readonly advance: number;
|
|
17
|
+
readonly commands: readonly number[];
|
|
18
|
+
}
|
|
19
|
+
/** A font for 3D text: its metrics, family, and its glyphs' outlines. */
|
|
20
|
+
export interface FontSource3D {
|
|
21
|
+
readonly unitsPerEm: number;
|
|
22
|
+
readonly ascender: number;
|
|
23
|
+
readonly descender: number;
|
|
24
|
+
/** Distance between baselines in font units. */
|
|
25
|
+
readonly lineHeight: number;
|
|
26
|
+
readonly familyName?: string;
|
|
27
|
+
/** Outline for a Unicode code point, or undefined when the font lacks it. */
|
|
28
|
+
readonly glyph: (codePoint: number) => GlyphOutline3D | undefined;
|
|
29
|
+
}
|
|
30
|
+
/** How 3D text is laid out: its size, curve detail, spacing, line height and alignment. */
|
|
31
|
+
export interface TextLayoutOptions3D {
|
|
32
|
+
/** Height of the em square in world units. Defaults to 1. */
|
|
33
|
+
readonly size?: number;
|
|
34
|
+
/** Segments used for each curved piece of an outline. Defaults to 6. */
|
|
35
|
+
readonly curveSegments?: number;
|
|
36
|
+
/** Extra space after each character, in world units. */
|
|
37
|
+
readonly letterSpacing?: number;
|
|
38
|
+
/** Multiplier on the font's own line spacing. */
|
|
39
|
+
readonly lineHeight?: number;
|
|
40
|
+
/** How lines are placed against x = 0. Defaults to 'left'. */
|
|
41
|
+
readonly align?: 'left' | 'center' | 'right';
|
|
42
|
+
}
|
|
43
|
+
/** 3D text to make: how deep it is extruded, and in how many steps. */
|
|
44
|
+
export interface TextGeometryOptions3D extends TextLayoutOptions3D {
|
|
45
|
+
/** Thickness along +Z. Zero gives flat text. Defaults to a fifth of the size. */
|
|
46
|
+
readonly depth?: number;
|
|
47
|
+
/** Subdivisions along the depth. */
|
|
48
|
+
readonly steps?: number;
|
|
49
|
+
}
|
|
50
|
+
/** A font that gives the outlines of text for 3D text geometry. */
|
|
51
|
+
export declare class Font3D {
|
|
52
|
+
#private;
|
|
53
|
+
readonly unitsPerEm: number;
|
|
54
|
+
readonly ascender: number;
|
|
55
|
+
readonly descender: number;
|
|
56
|
+
readonly lineHeight: number;
|
|
57
|
+
readonly familyName: string;
|
|
58
|
+
constructor(source: FontSource3D);
|
|
59
|
+
/** Outline of a code point; decoded once and kept. */
|
|
60
|
+
glyph(codePoint: number): GlyphOutline3D | undefined;
|
|
61
|
+
hasGlyph(character: string): boolean;
|
|
62
|
+
/** Width of the widest line, in world units. */
|
|
63
|
+
measureText(text: string, options?: TextLayoutOptions3D): number;
|
|
64
|
+
/** Lines of placed glyphs: pen position of each glyph and the line's width, in world units. */
|
|
65
|
+
private layout;
|
|
66
|
+
/**
|
|
67
|
+
* Outlines of a text as shapes in the XY plane: the first baseline lies
|
|
68
|
+
* on y = 0 and further lines go down. Counters such as the inside of an
|
|
69
|
+
* "o" become holes.
|
|
70
|
+
*/
|
|
71
|
+
generateShapes(text: string, options?: TextLayoutOptions3D): Shape3D[];
|
|
72
|
+
private glyphShapes;
|
|
73
|
+
}
|
|
74
|
+
/**
|
|
75
|
+
* Read a font in the typeface JSON format (the `*.typeface.json` files used
|
|
76
|
+
* with web 3D libraries). Accepts the parsed object or its text.
|
|
77
|
+
*/
|
|
78
|
+
export declare function parseTypefaceFont3D(input: string | Record<string, unknown>): Font3D;
|
|
79
|
+
/**
|
|
80
|
+
* Read a TrueType font: a .ttf file, an OpenType file with TrueType (glyf)
|
|
81
|
+
* outlines, or the first font of a .ttc collection. Glyphs are decoded on
|
|
82
|
+
* demand, so large fonts cost only what the text uses. OpenType fonts with
|
|
83
|
+
* PostScript (CFF) outlines are not supported.
|
|
84
|
+
*/
|
|
85
|
+
export declare function parseTrueTypeFont3D(input: ArrayBuffer | ArrayBufferView): Font3D;
|
|
86
|
+
/** Outlines of a text as flat shapes; see Font3D.generateShapes. */
|
|
87
|
+
export declare function createTextShapes3D(text: string, font: Font3D, options?: TextLayoutOptions3D): Shape3D[];
|
|
88
|
+
/**
|
|
89
|
+
* Text as a mesh geometry in the XY plane, facing +Z, with the first
|
|
90
|
+
* baseline on y = 0. With depth it has two material groups like any
|
|
91
|
+
* extrusion: 0 for the faces, 1 for the sides. The text must contain at
|
|
92
|
+
* least one visible character.
|
|
93
|
+
*/
|
|
94
|
+
export declare function createTextGeometry3D(text: string, font: Font3D, options?: TextGeometryOptions3D): Geometry3D;
|
|
95
|
+
//# sourceMappingURL=Text3D.d.ts.map
|
|
@@ -0,0 +1,560 @@
|
|
|
1
|
+
// SPDX-License-Identifier: Apache-2.0
|
|
2
|
+
// Text as geometry: a font supplies glyph outlines, the outlines become flat
|
|
3
|
+
// shapes, and the shapes are filled or given depth. Fonts are read either
|
|
4
|
+
// straight from a TrueType file (.ttf, or .otf/.ttc with TrueType outlines)
|
|
5
|
+
// or from the typeface JSON format used by web 3D tools. Layout is simple
|
|
6
|
+
// left-to-right text with line breaks; there is no shaping, so scripts that
|
|
7
|
+
// need joined or reordered letters are not laid out correctly.
|
|
8
|
+
import { World3DError, requireFinite3D, requirePositive3D } from './core3D.js';
|
|
9
|
+
import { Path2D3D, Shape3D, signedArea2D } from './Curves3D.js';
|
|
10
|
+
import { createExtrudeGeometry3D, createShapeGeometry3D } from './geometries3D.js';
|
|
11
|
+
/** The most characters, font bytes and glyph points 3D text has. */
|
|
12
|
+
export const TEXT3D_LIMITS = Object.freeze({
|
|
13
|
+
maxCharacters: 4096,
|
|
14
|
+
maxFontBytes: 67108864,
|
|
15
|
+
maxGlyphPoints: 65536,
|
|
16
|
+
maxCompositeDepth: 8
|
|
17
|
+
});
|
|
18
|
+
function inside(point, polygon) {
|
|
19
|
+
let hit = false;
|
|
20
|
+
for (let i = 0, j = polygon.length - 1; i < polygon.length; j = i++) {
|
|
21
|
+
const a = polygon[i], b = polygon[j];
|
|
22
|
+
if (a[1] > point[1] !== b[1] > point[1] && point[0] < ((b[0] - a[0]) * (point[1] - a[1])) / (b[1] - a[1]) + a[0])
|
|
23
|
+
hit = !hit;
|
|
24
|
+
}
|
|
25
|
+
return hit;
|
|
26
|
+
}
|
|
27
|
+
/** A font that gives the outlines of text for 3D text geometry. */
|
|
28
|
+
export class Font3D {
|
|
29
|
+
unitsPerEm;
|
|
30
|
+
ascender;
|
|
31
|
+
descender;
|
|
32
|
+
lineHeight;
|
|
33
|
+
familyName;
|
|
34
|
+
#source;
|
|
35
|
+
#cache = new Map();
|
|
36
|
+
constructor(source) {
|
|
37
|
+
if (!source || typeof source.glyph !== 'function')
|
|
38
|
+
throw new World3DError('WORLD3D_INPUT_INVALID', 'font');
|
|
39
|
+
this.unitsPerEm = requirePositive3D(source.unitsPerEm, 'font unitsPerEm');
|
|
40
|
+
this.ascender = requireFinite3D(source.ascender, 'font ascender');
|
|
41
|
+
this.descender = requireFinite3D(source.descender, 'font descender');
|
|
42
|
+
this.lineHeight = requirePositive3D(source.lineHeight, 'font lineHeight');
|
|
43
|
+
this.familyName = source.familyName ?? '';
|
|
44
|
+
this.#source = source;
|
|
45
|
+
}
|
|
46
|
+
/** Outline of a code point; decoded once and kept. */
|
|
47
|
+
glyph(codePoint) {
|
|
48
|
+
if (this.#cache.has(codePoint))
|
|
49
|
+
return this.#cache.get(codePoint);
|
|
50
|
+
const glyph = this.#source.glyph(codePoint);
|
|
51
|
+
this.#cache.set(codePoint, glyph);
|
|
52
|
+
return glyph;
|
|
53
|
+
}
|
|
54
|
+
hasGlyph(character) {
|
|
55
|
+
return this.glyph(character.codePointAt(0) ?? -1) !== undefined;
|
|
56
|
+
}
|
|
57
|
+
/** Width of the widest line, in world units. */
|
|
58
|
+
measureText(text, options = {}) {
|
|
59
|
+
let widest = 0;
|
|
60
|
+
for (const line of this.layout(text, options))
|
|
61
|
+
widest = Math.max(widest, line.width);
|
|
62
|
+
return widest;
|
|
63
|
+
}
|
|
64
|
+
/** Lines of placed glyphs: pen position of each glyph and the line's width, in world units. */
|
|
65
|
+
layout(text, options) {
|
|
66
|
+
if (typeof text !== 'string')
|
|
67
|
+
throw new World3DError('WORLD3D_INPUT_INVALID', 'text');
|
|
68
|
+
if (text.length > TEXT3D_LIMITS.maxCharacters)
|
|
69
|
+
throw new World3DError('WORLD3D_BUDGET', 'text length');
|
|
70
|
+
const scale = requirePositive3D(options.size ?? 1, 'text size') / this.unitsPerEm, spacing = requireFinite3D(options.letterSpacing ?? 0, 'letterSpacing');
|
|
71
|
+
const fallback = this.glyph(63), lines = [];
|
|
72
|
+
for (const line of text.split('\n')) {
|
|
73
|
+
const glyphs = [];
|
|
74
|
+
let x = 0, width = 0;
|
|
75
|
+
for (const character of line) {
|
|
76
|
+
const code = character.codePointAt(0);
|
|
77
|
+
if (code === 13)
|
|
78
|
+
continue;
|
|
79
|
+
// A missing character shows as a question mark, or as a gap when the font lacks that too.
|
|
80
|
+
const glyph = this.glyph(code) ?? fallback;
|
|
81
|
+
if (!glyph) {
|
|
82
|
+
x += this.unitsPerEm * 0.5 * scale + spacing;
|
|
83
|
+
continue;
|
|
84
|
+
}
|
|
85
|
+
glyphs.push({ glyph, x });
|
|
86
|
+
width = x + glyph.advance * scale;
|
|
87
|
+
x = width + spacing;
|
|
88
|
+
}
|
|
89
|
+
lines.push({ glyphs, width });
|
|
90
|
+
}
|
|
91
|
+
return lines;
|
|
92
|
+
}
|
|
93
|
+
/**
|
|
94
|
+
* Outlines of a text as shapes in the XY plane: the first baseline lies
|
|
95
|
+
* on y = 0 and further lines go down. Counters such as the inside of an
|
|
96
|
+
* "o" become holes.
|
|
97
|
+
*/
|
|
98
|
+
generateShapes(text, options = {}) {
|
|
99
|
+
const size = requirePositive3D(options.size ?? 1, 'text size'), scale = size / this.unitsPerEm, segments = Math.min(Math.max(Math.floor(options.curveSegments ?? 6), 1), 64);
|
|
100
|
+
const lineStep = this.lineHeight * scale * requirePositive3D(options.lineHeight ?? 1, 'lineHeight'), align = options.align ?? 'left';
|
|
101
|
+
const shapes = [];
|
|
102
|
+
this.layout(text, options).forEach((line, row) => {
|
|
103
|
+
const shift = align === 'center' ? -line.width / 2 : align === 'right' ? -line.width : 0, y = -row * lineStep;
|
|
104
|
+
for (const placed of line.glyphs)
|
|
105
|
+
this.glyphShapes(placed.glyph, placed.x + shift, y, scale, segments, shapes);
|
|
106
|
+
});
|
|
107
|
+
return shapes;
|
|
108
|
+
}
|
|
109
|
+
glyphShapes(glyph, offsetX, offsetY, scale, segments, out) {
|
|
110
|
+
const c = glyph.commands, contours = [];
|
|
111
|
+
let current, x = 0, y = 0;
|
|
112
|
+
const at = (i) => c[i] * scale;
|
|
113
|
+
for (let i = 0; i < c.length;) {
|
|
114
|
+
const op = c[i++];
|
|
115
|
+
if (op === 0) {
|
|
116
|
+
contours.push((current = []));
|
|
117
|
+
x = at(i) + offsetX;
|
|
118
|
+
y = at(i + 1) + offsetY;
|
|
119
|
+
i += 2;
|
|
120
|
+
current.push([x, y]);
|
|
121
|
+
continue;
|
|
122
|
+
}
|
|
123
|
+
if (!current)
|
|
124
|
+
throw new World3DError('WORLD3D_INPUT_INVALID', 'glyph outline');
|
|
125
|
+
if (op === 1) {
|
|
126
|
+
x = at(i) + offsetX;
|
|
127
|
+
y = at(i + 1) + offsetY;
|
|
128
|
+
i += 2;
|
|
129
|
+
current.push([x, y]);
|
|
130
|
+
}
|
|
131
|
+
else if (op === 2) {
|
|
132
|
+
const cx = at(i) + offsetX, cy = at(i + 1) + offsetY, ex = at(i + 2) + offsetX, ey = at(i + 3) + offsetY;
|
|
133
|
+
i += 4;
|
|
134
|
+
for (let s = 1; s <= segments; s++) {
|
|
135
|
+
const t = s / segments, k = 1 - t;
|
|
136
|
+
current.push([k * k * x + 2 * k * t * cx + t * t * ex, k * k * y + 2 * k * t * cy + t * t * ey]);
|
|
137
|
+
}
|
|
138
|
+
x = ex;
|
|
139
|
+
y = ey;
|
|
140
|
+
}
|
|
141
|
+
else if (op === 3) {
|
|
142
|
+
const ax = at(i) + offsetX, ay = at(i + 1) + offsetY, bx = at(i + 2) + offsetX, by = at(i + 3) + offsetY, ex = at(i + 4) + offsetX, ey = at(i + 5) + offsetY;
|
|
143
|
+
i += 6;
|
|
144
|
+
for (let s = 1; s <= segments; s++) {
|
|
145
|
+
const t = s / segments, k = 1 - t, p = k * k * k, q = 3 * k * k * t, r = 3 * k * t * t, w = t * t * t;
|
|
146
|
+
current.push([p * x + q * ax + r * bx + w * ex, p * y + q * ay + r * by + w * ey]);
|
|
147
|
+
}
|
|
148
|
+
x = ex;
|
|
149
|
+
y = ey;
|
|
150
|
+
}
|
|
151
|
+
else
|
|
152
|
+
throw new World3DError('WORLD3D_INPUT_INVALID', 'glyph outline');
|
|
153
|
+
}
|
|
154
|
+
// Drop repeated points and outlines without area.
|
|
155
|
+
const rings = [];
|
|
156
|
+
for (const contour of contours) {
|
|
157
|
+
const points = [];
|
|
158
|
+
for (const p of contour) {
|
|
159
|
+
const last = points[points.length - 1];
|
|
160
|
+
if (!last || Math.abs(last[0] - p[0]) > 1e-9 || Math.abs(last[1] - p[1]) > 1e-9)
|
|
161
|
+
points.push(p);
|
|
162
|
+
}
|
|
163
|
+
const first = points[0], last = points[points.length - 1];
|
|
164
|
+
if (points.length > 1 &&
|
|
165
|
+
first &&
|
|
166
|
+
last &&
|
|
167
|
+
Math.abs(first[0] - last[0]) < 1e-9 &&
|
|
168
|
+
Math.abs(first[1] - last[1]) < 1e-9)
|
|
169
|
+
points.pop();
|
|
170
|
+
const area = points.length >= 3 ? Math.abs(signedArea2D(points)) : 0;
|
|
171
|
+
if (area > 1e-12)
|
|
172
|
+
rings.push({ points, area });
|
|
173
|
+
}
|
|
174
|
+
// An outline inside an even number of others is solid; inside an odd number, a hole of the smallest one around it.
|
|
175
|
+
const depth = rings.map((ring, i) => rings.reduce((n, other, j) => n + (i !== j && inside(ring.points[0], other.points) ? 1 : 0), 0));
|
|
176
|
+
const solids = new Map();
|
|
177
|
+
rings.forEach((ring, i) => {
|
|
178
|
+
if (depth[i] % 2 === 0) {
|
|
179
|
+
const shape = new Shape3D(ring.points);
|
|
180
|
+
solids.set(i, shape);
|
|
181
|
+
out.push(shape);
|
|
182
|
+
}
|
|
183
|
+
});
|
|
184
|
+
rings.forEach((ring, i) => {
|
|
185
|
+
if (depth[i] % 2 === 0)
|
|
186
|
+
return;
|
|
187
|
+
let owner = -1;
|
|
188
|
+
for (const j of solids.keys())
|
|
189
|
+
if (depth[j] === depth[i] - 1 &&
|
|
190
|
+
inside(ring.points[0], rings[j].points) &&
|
|
191
|
+
(owner < 0 || rings[j].area < rings[owner].area))
|
|
192
|
+
owner = j;
|
|
193
|
+
if (owner < 0)
|
|
194
|
+
return;
|
|
195
|
+
const hole = new Path2D3D();
|
|
196
|
+
for (const p of ring.points)
|
|
197
|
+
hole.moveTo(p[0], p[1]);
|
|
198
|
+
solids.get(owner).holes.push(hole);
|
|
199
|
+
});
|
|
200
|
+
}
|
|
201
|
+
}
|
|
202
|
+
// ---- typeface JSON ------------------------------------------------------------
|
|
203
|
+
/**
|
|
204
|
+
* Read a font in the typeface JSON format (the `*.typeface.json` files used
|
|
205
|
+
* with web 3D libraries). Accepts the parsed object or its text.
|
|
206
|
+
*/
|
|
207
|
+
export function parseTypefaceFont3D(input) {
|
|
208
|
+
let json;
|
|
209
|
+
try {
|
|
210
|
+
json = typeof input === 'string' ? JSON.parse(input) : input;
|
|
211
|
+
}
|
|
212
|
+
catch (cause) {
|
|
213
|
+
throw new World3DError('WORLD3D_INPUT_INVALID', 'typeface JSON', cause);
|
|
214
|
+
}
|
|
215
|
+
const glyphs = json?.['glyphs'];
|
|
216
|
+
if (!glyphs || typeof glyphs !== 'object')
|
|
217
|
+
throw new World3DError('WORLD3D_INPUT_INVALID', 'typeface JSON has no glyphs');
|
|
218
|
+
const unitsPerEm = Number(json['resolution'] ?? 1000), box = json['boundingBox'];
|
|
219
|
+
const ascender = Number(json['ascender'] ?? box?.yMax ?? unitsPerEm * 0.8), descender = Number(json['descender'] ?? box?.yMin ?? -unitsPerEm * 0.2);
|
|
220
|
+
const lineHeight = box && Number.isFinite(box.yMax) && Number.isFinite(box.yMin)
|
|
221
|
+
? box.yMax - box.yMin + Number(json['underlineThickness'] ?? 0)
|
|
222
|
+
: ascender - descender;
|
|
223
|
+
return new Font3D({
|
|
224
|
+
unitsPerEm,
|
|
225
|
+
ascender,
|
|
226
|
+
descender,
|
|
227
|
+
lineHeight: lineHeight > 0 ? lineHeight : unitsPerEm,
|
|
228
|
+
familyName: typeof json['familyName'] === 'string' ? json['familyName'] : '',
|
|
229
|
+
glyph(codePoint) {
|
|
230
|
+
const entry = glyphs[String.fromCodePoint(codePoint)];
|
|
231
|
+
if (!entry)
|
|
232
|
+
return undefined;
|
|
233
|
+
const tokens = (entry.o ?? '').split(' '), commands = [];
|
|
234
|
+
const number = (i) => requireFinite3D(Number(tokens[i]), 'typeface outline');
|
|
235
|
+
for (let i = 0; i < tokens.length;) {
|
|
236
|
+
const op = tokens[i++];
|
|
237
|
+
// Curves list their end point first, then the control points.
|
|
238
|
+
if (op === 'm') {
|
|
239
|
+
commands.push(0, number(i), number(i + 1));
|
|
240
|
+
i += 2;
|
|
241
|
+
}
|
|
242
|
+
else if (op === 'l') {
|
|
243
|
+
commands.push(1, number(i), number(i + 1));
|
|
244
|
+
i += 2;
|
|
245
|
+
}
|
|
246
|
+
else if (op === 'q') {
|
|
247
|
+
commands.push(2, number(i + 2), number(i + 3), number(i), number(i + 1));
|
|
248
|
+
i += 4;
|
|
249
|
+
}
|
|
250
|
+
else if (op === 'b') {
|
|
251
|
+
commands.push(3, number(i + 2), number(i + 3), number(i + 4), number(i + 5), number(i), number(i + 1));
|
|
252
|
+
i += 6;
|
|
253
|
+
}
|
|
254
|
+
else if (op === 'z' || op === '' || op === undefined)
|
|
255
|
+
continue;
|
|
256
|
+
else
|
|
257
|
+
throw new World3DError('WORLD3D_INPUT_INVALID', 'typeface outline command');
|
|
258
|
+
}
|
|
259
|
+
return { advance: Number(entry.ha ?? 0), commands };
|
|
260
|
+
}
|
|
261
|
+
});
|
|
262
|
+
}
|
|
263
|
+
// ---- TrueType -----------------------------------------------------------------
|
|
264
|
+
/**
|
|
265
|
+
* Read a TrueType font: a .ttf file, an OpenType file with TrueType (glyf)
|
|
266
|
+
* outlines, or the first font of a .ttc collection. Glyphs are decoded on
|
|
267
|
+
* demand, so large fonts cost only what the text uses. OpenType fonts with
|
|
268
|
+
* PostScript (CFF) outlines are not supported.
|
|
269
|
+
*/
|
|
270
|
+
export function parseTrueTypeFont3D(input) {
|
|
271
|
+
const bytes = input instanceof ArrayBuffer
|
|
272
|
+
? new Uint8Array(input)
|
|
273
|
+
: ArrayBuffer.isView(input)
|
|
274
|
+
? new Uint8Array(input.buffer, input.byteOffset, input.byteLength)
|
|
275
|
+
: undefined;
|
|
276
|
+
if (!bytes || bytes.length < 12)
|
|
277
|
+
throw new World3DError('WORLD3D_INPUT_INVALID', 'font data');
|
|
278
|
+
if (bytes.length > TEXT3D_LIMITS.maxFontBytes)
|
|
279
|
+
throw new World3DError('WORLD3D_BUDGET', 'font size');
|
|
280
|
+
const view = new DataView(bytes.buffer, bytes.byteOffset, bytes.byteLength);
|
|
281
|
+
try {
|
|
282
|
+
let start = 0, tag = view.getUint32(0);
|
|
283
|
+
if (tag === 0x74746366) {
|
|
284
|
+
start = view.getUint32(12);
|
|
285
|
+
tag = view.getUint32(start);
|
|
286
|
+
} // 'ttcf'
|
|
287
|
+
if (tag === 0x4f54544f)
|
|
288
|
+
throw new World3DError('WORLD3D_INPUT_INVALID', 'fonts with PostScript (CFF) outlines are not supported');
|
|
289
|
+
if (tag !== 0x00010000 && tag !== 0x74727565)
|
|
290
|
+
throw new World3DError('WORLD3D_INPUT_INVALID', 'not a TrueType font');
|
|
291
|
+
const tables = new Map(), count = view.getUint16(start + 4);
|
|
292
|
+
for (let i = 0; i < count; i++) {
|
|
293
|
+
const at = start + 12 + i * 16;
|
|
294
|
+
tables.set(String.fromCharCode(view.getUint8(at), view.getUint8(at + 1), view.getUint8(at + 2), view.getUint8(at + 3)), view.getUint32(at + 8));
|
|
295
|
+
}
|
|
296
|
+
const table = (name) => {
|
|
297
|
+
const offset = tables.get(name);
|
|
298
|
+
if (offset === undefined)
|
|
299
|
+
throw new World3DError('WORLD3D_INPUT_INVALID', name === 'glyf' ? 'the font has no TrueType outlines' : 'font table ' + name);
|
|
300
|
+
return offset;
|
|
301
|
+
};
|
|
302
|
+
const head = table('head'), hhea = table('hhea'), hmtx = table('hmtx'), loca = table('loca'), glyf = table('glyf'), cmap = table('cmap');
|
|
303
|
+
const unitsPerEm = view.getUint16(head + 18), longOffsets = view.getInt16(head + 50) !== 0, glyphCount = view.getUint16(table('maxp') + 4);
|
|
304
|
+
const ascender = view.getInt16(hhea + 4), descender = view.getInt16(hhea + 6), lineGap = view.getInt16(hhea + 8), metrics = view.getUint16(hhea + 34);
|
|
305
|
+
// Pick the richest Unicode character map: full range first, then the basic plane.
|
|
306
|
+
let map = -1, format = 0;
|
|
307
|
+
const subtables = view.getUint16(cmap + 2);
|
|
308
|
+
for (let i = 0; i < subtables; i++) {
|
|
309
|
+
const platform = view.getUint16(cmap + 4 + i * 8), encoding = view.getUint16(cmap + 6 + i * 8), offset = cmap + view.getUint32(cmap + 8 + i * 8), kind = view.getUint16(offset);
|
|
310
|
+
const unicode = platform === 0 || (platform === 3 && (encoding === 1 || encoding === 10));
|
|
311
|
+
if (unicode && (kind === 12 || kind === 4) && kind > format) {
|
|
312
|
+
map = offset;
|
|
313
|
+
format = kind;
|
|
314
|
+
}
|
|
315
|
+
}
|
|
316
|
+
if (map < 0)
|
|
317
|
+
throw new World3DError('WORLD3D_INPUT_INVALID', 'the font has no Unicode character map');
|
|
318
|
+
const glyphIndex = (code) => {
|
|
319
|
+
if (format === 12) {
|
|
320
|
+
let low = 0, high = view.getUint32(map + 12) - 1;
|
|
321
|
+
while (low <= high) {
|
|
322
|
+
const middle = (low + high) >> 1, at = map + 16 + middle * 12, first = view.getUint32(at);
|
|
323
|
+
if (code < first)
|
|
324
|
+
high = middle - 1;
|
|
325
|
+
else if (code > view.getUint32(at + 4))
|
|
326
|
+
low = middle + 1;
|
|
327
|
+
else
|
|
328
|
+
return view.getUint32(at + 8) + code - first;
|
|
329
|
+
}
|
|
330
|
+
return 0;
|
|
331
|
+
}
|
|
332
|
+
if (code > 0xffff)
|
|
333
|
+
return 0;
|
|
334
|
+
const segments = view.getUint16(map + 6) >> 1, ends = map + 14, starts = ends + segments * 2 + 2, deltas = starts + segments * 2, ranges = deltas + segments * 2;
|
|
335
|
+
let low = 0, high = segments - 1;
|
|
336
|
+
while (low <= high) {
|
|
337
|
+
const middle = (low + high) >> 1;
|
|
338
|
+
if (code > view.getUint16(ends + middle * 2))
|
|
339
|
+
low = middle + 1;
|
|
340
|
+
else if (code < view.getUint16(starts + middle * 2))
|
|
341
|
+
high = middle - 1;
|
|
342
|
+
else {
|
|
343
|
+
const range = view.getUint16(ranges + middle * 2), delta = view.getUint16(deltas + middle * 2);
|
|
344
|
+
if (range === 0)
|
|
345
|
+
return (code + delta) & 0xffff;
|
|
346
|
+
const glyph = view.getUint16(ranges + middle * 2 + range + (code - view.getUint16(starts + middle * 2)) * 2);
|
|
347
|
+
return glyph === 0 ? 0 : (glyph + delta) & 0xffff;
|
|
348
|
+
}
|
|
349
|
+
}
|
|
350
|
+
return 0;
|
|
351
|
+
};
|
|
352
|
+
const glyphRange = (index) => longOffsets
|
|
353
|
+
? [view.getUint32(loca + index * 4), view.getUint32(loca + index * 4 + 4)]
|
|
354
|
+
: [view.getUint16(loca + index * 2) * 2, view.getUint16(loca + index * 2 + 2) * 2];
|
|
355
|
+
/** Append a glyph's contours as point lists [x, y, onCurve, ...], one list per contour. */
|
|
356
|
+
const contoursOf = (index, out, level) => {
|
|
357
|
+
if (index >= glyphCount || level > TEXT3D_LIMITS.maxCompositeDepth)
|
|
358
|
+
return;
|
|
359
|
+
const [from, to] = glyphRange(index);
|
|
360
|
+
if (to <= from)
|
|
361
|
+
return; // no outline, as for a space
|
|
362
|
+
let at = glyf + from;
|
|
363
|
+
const contours = view.getInt16(at);
|
|
364
|
+
at += 10;
|
|
365
|
+
if (contours >= 0) {
|
|
366
|
+
const ends = [];
|
|
367
|
+
for (let i = 0; i < contours; i++) {
|
|
368
|
+
ends.push(view.getUint16(at));
|
|
369
|
+
at += 2;
|
|
370
|
+
}
|
|
371
|
+
const points = contours > 0 ? ends[contours - 1] + 1 : 0;
|
|
372
|
+
if (points > TEXT3D_LIMITS.maxGlyphPoints)
|
|
373
|
+
throw new World3DError('WORLD3D_BUDGET', 'glyph points');
|
|
374
|
+
at += 2 + view.getUint16(at); // skip hinting instructions
|
|
375
|
+
const flags = new Uint8Array(points);
|
|
376
|
+
for (let i = 0; i < points;) {
|
|
377
|
+
const flag = view.getUint8(at++);
|
|
378
|
+
flags[i++] = flag;
|
|
379
|
+
if (flag & 8) {
|
|
380
|
+
let repeat = view.getUint8(at++);
|
|
381
|
+
while (repeat-- > 0 && i < points)
|
|
382
|
+
flags[i++] = flag;
|
|
383
|
+
}
|
|
384
|
+
}
|
|
385
|
+
const xs = new Int32Array(points), ys = new Int32Array(points);
|
|
386
|
+
let value = 0;
|
|
387
|
+
for (let i = 0; i < points; i++) {
|
|
388
|
+
const flag = flags[i];
|
|
389
|
+
if (flag & 2) {
|
|
390
|
+
const delta = view.getUint8(at++);
|
|
391
|
+
value += flag & 16 ? delta : -delta;
|
|
392
|
+
}
|
|
393
|
+
else if (!(flag & 16)) {
|
|
394
|
+
value += view.getInt16(at);
|
|
395
|
+
at += 2;
|
|
396
|
+
}
|
|
397
|
+
xs[i] = value;
|
|
398
|
+
}
|
|
399
|
+
value = 0;
|
|
400
|
+
for (let i = 0; i < points; i++) {
|
|
401
|
+
const flag = flags[i];
|
|
402
|
+
if (flag & 4) {
|
|
403
|
+
const delta = view.getUint8(at++);
|
|
404
|
+
value += flag & 32 ? delta : -delta;
|
|
405
|
+
}
|
|
406
|
+
else if (!(flag & 32)) {
|
|
407
|
+
value += view.getInt16(at);
|
|
408
|
+
at += 2;
|
|
409
|
+
}
|
|
410
|
+
ys[i] = value;
|
|
411
|
+
}
|
|
412
|
+
let first = 0;
|
|
413
|
+
for (const end of ends) {
|
|
414
|
+
const contour = [];
|
|
415
|
+
for (let i = first; i <= end; i++)
|
|
416
|
+
contour.push(xs[i], ys[i], flags[i] & 1);
|
|
417
|
+
if (contour.length >= 9)
|
|
418
|
+
out.push(contour);
|
|
419
|
+
first = end + 1;
|
|
420
|
+
}
|
|
421
|
+
return;
|
|
422
|
+
}
|
|
423
|
+
// A composite glyph places other glyphs, each with its own offset and optional scale.
|
|
424
|
+
for (let more = true; more;) {
|
|
425
|
+
const flags = view.getUint16(at), component = view.getUint16(at + 2);
|
|
426
|
+
at += 4;
|
|
427
|
+
let dx = 0, dy = 0;
|
|
428
|
+
if (flags & 1) {
|
|
429
|
+
if (flags & 2) {
|
|
430
|
+
dx = view.getInt16(at);
|
|
431
|
+
dy = view.getInt16(at + 2);
|
|
432
|
+
}
|
|
433
|
+
at += 4;
|
|
434
|
+
}
|
|
435
|
+
else {
|
|
436
|
+
if (flags & 2) {
|
|
437
|
+
dx = view.getInt8(at);
|
|
438
|
+
dy = view.getInt8(at + 1);
|
|
439
|
+
}
|
|
440
|
+
at += 2;
|
|
441
|
+
}
|
|
442
|
+
let a = 1, b = 0, c = 0, d = 1;
|
|
443
|
+
if (flags & 8) {
|
|
444
|
+
a = d = view.getInt16(at) / 16384;
|
|
445
|
+
at += 2;
|
|
446
|
+
}
|
|
447
|
+
else if (flags & 0x40) {
|
|
448
|
+
a = view.getInt16(at) / 16384;
|
|
449
|
+
d = view.getInt16(at + 2) / 16384;
|
|
450
|
+
at += 4;
|
|
451
|
+
}
|
|
452
|
+
else if (flags & 0x80) {
|
|
453
|
+
a = view.getInt16(at) / 16384;
|
|
454
|
+
b = view.getInt16(at + 2) / 16384;
|
|
455
|
+
c = view.getInt16(at + 4) / 16384;
|
|
456
|
+
d = view.getInt16(at + 6) / 16384;
|
|
457
|
+
at += 8;
|
|
458
|
+
}
|
|
459
|
+
const before = out.length;
|
|
460
|
+
contoursOf(component, out, level + 1);
|
|
461
|
+
for (let i = before; i < out.length; i++) {
|
|
462
|
+
const contour = out[i];
|
|
463
|
+
for (let k = 0; k < contour.length; k += 3) {
|
|
464
|
+
const x = contour[k], y = contour[k + 1];
|
|
465
|
+
contour[k] = a * x + c * y + dx;
|
|
466
|
+
contour[k + 1] = b * x + d * y + dy;
|
|
467
|
+
}
|
|
468
|
+
}
|
|
469
|
+
more = (flags & 0x20) !== 0;
|
|
470
|
+
}
|
|
471
|
+
};
|
|
472
|
+
return new Font3D({
|
|
473
|
+
unitsPerEm,
|
|
474
|
+
ascender,
|
|
475
|
+
descender,
|
|
476
|
+
lineHeight: Math.max(ascender - descender + lineGap, 1),
|
|
477
|
+
glyph(codePoint) {
|
|
478
|
+
const index = glyphIndex(codePoint);
|
|
479
|
+
if (index === 0 || index >= glyphCount)
|
|
480
|
+
return undefined;
|
|
481
|
+
try {
|
|
482
|
+
const advance = view.getUint16(hmtx + Math.min(index, metrics - 1) * 4), contours = [], commands = [];
|
|
483
|
+
contoursOf(index, contours, 0);
|
|
484
|
+
for (const contour of contours) {
|
|
485
|
+
// Curves are quadratic; two control points in a row imply an on-curve point halfway between them.
|
|
486
|
+
const n = contour.length / 3, x = (i) => contour[i * 3], y = (i) => contour[i * 3 + 1], on = (i) => contour[i * 3 + 2] === 1;
|
|
487
|
+
let sx, sy, from = 0, to = n;
|
|
488
|
+
if (on(0)) {
|
|
489
|
+
sx = x(0);
|
|
490
|
+
sy = y(0);
|
|
491
|
+
from = 1;
|
|
492
|
+
}
|
|
493
|
+
else if (on(n - 1)) {
|
|
494
|
+
sx = x(n - 1);
|
|
495
|
+
sy = y(n - 1);
|
|
496
|
+
to = n - 1;
|
|
497
|
+
}
|
|
498
|
+
else {
|
|
499
|
+
sx = (x(0) + x(n - 1)) / 2;
|
|
500
|
+
sy = (y(0) + y(n - 1)) / 2;
|
|
501
|
+
}
|
|
502
|
+
commands.push(0, sx, sy);
|
|
503
|
+
let pending = false, cx = 0, cy = 0;
|
|
504
|
+
for (let i = from; i < to; i++) {
|
|
505
|
+
if (on(i)) {
|
|
506
|
+
if (pending)
|
|
507
|
+
commands.push(2, cx, cy, x(i), y(i));
|
|
508
|
+
else
|
|
509
|
+
commands.push(1, x(i), y(i));
|
|
510
|
+
pending = false;
|
|
511
|
+
}
|
|
512
|
+
else {
|
|
513
|
+
if (pending)
|
|
514
|
+
commands.push(2, cx, cy, (cx + x(i)) / 2, (cy + y(i)) / 2);
|
|
515
|
+
cx = x(i);
|
|
516
|
+
cy = y(i);
|
|
517
|
+
pending = true;
|
|
518
|
+
}
|
|
519
|
+
}
|
|
520
|
+
if (pending)
|
|
521
|
+
commands.push(2, cx, cy, sx, sy);
|
|
522
|
+
}
|
|
523
|
+
return { advance, commands };
|
|
524
|
+
}
|
|
525
|
+
catch (cause) {
|
|
526
|
+
if (cause instanceof World3DError)
|
|
527
|
+
throw cause;
|
|
528
|
+
throw new World3DError('WORLD3D_INPUT_INVALID', 'font glyph data', cause);
|
|
529
|
+
}
|
|
530
|
+
}
|
|
531
|
+
});
|
|
532
|
+
}
|
|
533
|
+
catch (cause) {
|
|
534
|
+
if (cause instanceof World3DError)
|
|
535
|
+
throw cause;
|
|
536
|
+
throw new World3DError('WORLD3D_INPUT_INVALID', 'font data', cause);
|
|
537
|
+
}
|
|
538
|
+
}
|
|
539
|
+
/** Outlines of a text as flat shapes; see Font3D.generateShapes. */
|
|
540
|
+
export function createTextShapes3D(text, font, options = {}) {
|
|
541
|
+
if (!(font instanceof Font3D))
|
|
542
|
+
throw new World3DError('WORLD3D_INPUT_INVALID', 'font');
|
|
543
|
+
return font.generateShapes(text, options);
|
|
544
|
+
}
|
|
545
|
+
/**
|
|
546
|
+
* Text as a mesh geometry in the XY plane, facing +Z, with the first
|
|
547
|
+
* baseline on y = 0. With depth it has two material groups like any
|
|
548
|
+
* extrusion: 0 for the faces, 1 for the sides. The text must contain at
|
|
549
|
+
* least one visible character.
|
|
550
|
+
*/
|
|
551
|
+
export function createTextGeometry3D(text, font, options = {}) {
|
|
552
|
+
const shapes = createTextShapes3D(text, font, options);
|
|
553
|
+
if (shapes.length === 0)
|
|
554
|
+
throw new World3DError('WORLD3D_INPUT_INVALID', 'the text has no visible characters');
|
|
555
|
+
const depth = requireFinite3D(options.depth ?? (options.size ?? 1) * 0.2, 'text depth');
|
|
556
|
+
return depth > 0
|
|
557
|
+
? createExtrudeGeometry3D(shapes, { depth, ...(options.steps !== undefined ? { steps: options.steps } : {}) })
|
|
558
|
+
: createShapeGeometry3D(shapes);
|
|
559
|
+
}
|
|
560
|
+
//# sourceMappingURL=Text3D.js.map
|