@zephyr3d/scene 0.9.3 → 0.9.5
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/dist/animation/animationmask.js +224 -0
- package/dist/animation/animationmask.js.map +1 -0
- package/dist/animation/animationset.js +268 -67
- package/dist/animation/animationset.js.map +1 -1
- package/dist/animation/animationtrack.js.map +1 -1
- package/dist/animation/eulerrotationtrack.js +3 -0
- package/dist/animation/eulerrotationtrack.js.map +1 -1
- package/dist/animation/fixed_geometry_cache_track.js +7 -0
- package/dist/animation/fixed_geometry_cache_track.js.map +1 -1
- package/dist/animation/ik_modifier.js.map +1 -1
- package/dist/animation/joint_dynamics/collision.js +6 -4
- package/dist/animation/joint_dynamics/collision.js.map +1 -1
- package/dist/animation/joint_dynamics/controller.js +390 -43
- package/dist/animation/joint_dynamics/controller.js.map +1 -1
- package/dist/animation/joint_dynamics/joint_dynamics_system.js +62 -3
- package/dist/animation/joint_dynamics/joint_dynamics_system.js.map +1 -1
- package/dist/animation/joint_dynamics/solver.js +4 -3
- package/dist/animation/joint_dynamics/solver.js.map +1 -1
- package/dist/animation/joint_dynamics/types.js.map +1 -1
- package/dist/animation/joint_dynamics_modifier.js +2 -0
- package/dist/animation/joint_dynamics_modifier.js.map +1 -1
- package/dist/animation/morphtarget.js +3 -72
- package/dist/animation/morphtarget.js.map +1 -1
- package/dist/animation/morphtrack.js +3 -0
- package/dist/animation/morphtrack.js.map +1 -1
- package/dist/animation/pca_geometry_cache_track.js +3 -0
- package/dist/animation/pca_geometry_cache_track.js.map +1 -1
- package/dist/animation/proptrack.js +3 -0
- package/dist/animation/proptrack.js.map +1 -1
- package/dist/animation/rotationtrack.js +3 -0
- package/dist/animation/rotationtrack.js.map +1 -1
- package/dist/animation/scaletrack.js +3 -0
- package/dist/animation/scaletrack.js.map +1 -1
- package/dist/animation/skeleton.js +254 -79
- package/dist/animation/skeleton.js.map +1 -1
- package/dist/animation/skeleton_modifier.js.map +1 -1
- package/dist/animation/spring/spring_particle.js +4 -4
- package/dist/animation/spring/spring_particle.js.map +1 -1
- package/dist/animation/spring_modifier.js.map +1 -1
- package/dist/animation/translationtrack.js +3 -0
- package/dist/animation/translationtrack.js.map +1 -1
- package/dist/app/engine.js +129 -17
- package/dist/app/engine.js.map +1 -1
- package/dist/app/scriptregistry.js +251 -80
- package/dist/app/scriptregistry.js.map +1 -1
- package/dist/asset/assetmanager.js +133 -102
- package/dist/asset/assetmanager.js.map +1 -1
- package/dist/asset/loaders/gltf/gltf_loader.js +18 -14
- package/dist/asset/loaders/gltf/gltf_loader.js.map +1 -1
- package/dist/asset/loaders/loader.js +1 -6
- package/dist/asset/loaders/loader.js.map +1 -1
- package/dist/asset/loaders/zabc/zabc_loader.js.map +1 -1
- package/dist/asset/model.js +1052 -183
- package/dist/asset/model.js.map +1 -1
- package/dist/avatar/wardrobe.js +474 -0
- package/dist/avatar/wardrobe.js.map +1 -0
- package/dist/index.d.ts +1810 -233
- package/dist/index.js +13 -3
- package/dist/index.js.map +1 -1
- package/dist/material/material.js +1 -1
- package/dist/material/material.js.map +1 -1
- package/dist/material/mixins/lightmodel/pbrmetallicroughness.js +6 -3
- package/dist/material/mixins/lightmodel/pbrmetallicroughness.js.map +1 -1
- package/dist/material/mixins/pbr/common.js +72 -15
- package/dist/material/mixins/pbr/common.js.map +1 -1
- package/dist/material/msdf_text.js +180 -0
- package/dist/material/msdf_text.js.map +1 -0
- package/dist/material/msdf_text_sprite.js +64 -0
- package/dist/material/msdf_text_sprite.js.map +1 -0
- package/dist/material/pbrblueprint.js +21 -6
- package/dist/material/pbrblueprint.js.map +1 -1
- package/dist/material/shader/helper.js +277 -277
- package/dist/material/shader/helper.js.map +1 -1
- package/dist/material/sprite_sdf.js +106 -0
- package/dist/material/sprite_sdf.js.map +1 -0
- package/dist/posteffect/ssr.js +1 -0
- package/dist/posteffect/ssr.js.map +1 -1
- package/dist/render/abuffer_oit.js +1 -0
- package/dist/render/abuffer_oit.js.map +1 -1
- package/dist/render/cluster_light.js.map +1 -1
- package/dist/render/cull_visitor.js +28 -0
- package/dist/render/cull_visitor.js.map +1 -1
- package/dist/render/drawable.js.map +1 -1
- package/dist/render/drawable_mixin.js +1 -0
- package/dist/render/drawable_mixin.js.map +1 -1
- package/dist/render/envlight.js +54 -1
- package/dist/render/envlight.js.map +1 -1
- package/dist/render/fbm_wavegenerator.js +1 -0
- package/dist/render/fbm_wavegenerator.js.map +1 -1
- package/dist/render/gerstner_wavegenerator.js +1 -0
- package/dist/render/gerstner_wavegenerator.js.map +1 -1
- package/dist/render/globalbindgroup_allocator.js +1 -0
- package/dist/render/globalbindgroup_allocator.js.map +1 -1
- package/dist/render/render_queue.js +1 -0
- package/dist/render/render_queue.js.map +1 -1
- package/dist/render/sky.js +9 -0
- package/dist/render/sky.js.map +1 -1
- package/dist/scene/basesprite.js +1 -5
- package/dist/scene/basesprite.js.map +1 -1
- package/dist/scene/batchgroup.js +18 -8
- package/dist/scene/batchgroup.js.map +1 -1
- package/dist/scene/environment.js +16 -2
- package/dist/scene/environment.js.map +1 -1
- package/dist/scene/mesh.js +164 -102
- package/dist/scene/mesh.js.map +1 -1
- package/dist/scene/meshdrawable.js +96 -0
- package/dist/scene/meshdrawable.js.map +1 -0
- package/dist/scene/msdftext.js +341 -0
- package/dist/scene/msdftext.js.map +1 -0
- package/dist/scene/msdftextsprite.js +349 -0
- package/dist/scene/msdftextsprite.js.map +1 -0
- package/dist/scene/particlesys.js +1 -0
- package/dist/scene/particlesys.js.map +1 -1
- package/dist/scene/scene.js +2 -0
- package/dist/scene/scene.js.map +1 -1
- package/dist/scene/scene_node.js +437 -230
- package/dist/scene/scene_node.js.map +1 -1
- package/dist/scene/sdftextsprite.js +322 -0
- package/dist/scene/sdftextsprite.js.map +1 -0
- package/dist/scene/terrain-cm/grass.js +1 -0
- package/dist/scene/terrain-cm/grass.js.map +1 -1
- package/dist/scene/terrain-cm/grassmaterial.js +1 -0
- package/dist/scene/terrain-cm/grassmaterial.js.map +1 -1
- package/dist/scene/terrain-cm/terrain-cm.js +1 -0
- package/dist/scene/terrain-cm/terrain-cm.js.map +1 -1
- package/dist/scene/textsprite.js +120 -0
- package/dist/scene/textsprite.js.map +1 -0
- package/dist/scene/water.js +1 -0
- package/dist/scene/water.js.map +1 -1
- package/dist/shadow/shader.js +1 -0
- package/dist/shadow/shader.js.map +1 -1
- package/dist/text/font/font_asset.js +884 -0
- package/dist/text/font/font_asset.js.map +1 -0
- package/dist/text/font/sfnt_reader.js +43 -0
- package/dist/text/font/sfnt_reader.js.map +1 -0
- package/dist/text/msdf/generator.js +417 -0
- package/dist/text/msdf/generator.js.map +1 -0
- package/dist/text/msdf/shape.js +146 -0
- package/dist/text/msdf/shape.js.map +1 -0
- package/dist/text/runtime/msdf_glyph_atlas.js +146 -0
- package/dist/text/runtime/msdf_glyph_atlas.js.map +1 -0
- package/dist/text/runtime/msdf_text_atlas_manager.js +50 -0
- package/dist/text/runtime/msdf_text_atlas_manager.js.map +1 -0
- package/dist/text/runtime/text_layout.js +96 -0
- package/dist/text/runtime/text_layout.js.map +1 -0
- package/dist/utility/blueprint/material/inputs.js +188 -1
- package/dist/utility/blueprint/material/inputs.js.map +1 -1
- package/dist/utility/blueprint/material/ir.js +16 -1
- package/dist/utility/blueprint/material/ir.js.map +1 -1
- package/dist/utility/blueprint/material/pbr.js +32 -0
- package/dist/utility/blueprint/material/pbr.js.map +1 -1
- package/dist/utility/bounding_volume.js.map +1 -1
- package/dist/utility/pmrem.js +34 -8
- package/dist/utility/pmrem.js.map +1 -1
- package/dist/utility/serialization/manager.js +340 -283
- package/dist/utility/serialization/manager.js.map +1 -1
- package/dist/utility/serialization/scene/animation.js +702 -7
- package/dist/utility/serialization/scene/animation.js.map +1 -1
- package/dist/utility/serialization/scene/batch.js +2 -0
- package/dist/utility/serialization/scene/batch.js.map +1 -1
- package/dist/utility/serialization/scene/camera.js +2 -0
- package/dist/utility/serialization/scene/camera.js.map +1 -1
- package/dist/utility/serialization/scene/light.js +2 -0
- package/dist/utility/serialization/scene/light.js.map +1 -1
- package/dist/utility/serialization/scene/material.js +1 -0
- package/dist/utility/serialization/scene/material.js.map +1 -1
- package/dist/utility/serialization/scene/mesh.js +66 -4
- package/dist/utility/serialization/scene/mesh.js.map +1 -1
- package/dist/utility/serialization/scene/node.js +189 -8
- package/dist/utility/serialization/scene/node.js.map +1 -1
- package/dist/utility/serialization/scene/particle.js +2 -0
- package/dist/utility/serialization/scene/particle.js.map +1 -1
- package/dist/utility/serialization/scene/primitive.js +1 -0
- package/dist/utility/serialization/scene/primitive.js.map +1 -1
- package/dist/utility/serialization/scene/sprite.js +2 -0
- package/dist/utility/serialization/scene/sprite.js.map +1 -1
- package/dist/utility/serialization/scene/terrain.js +2 -0
- package/dist/utility/serialization/scene/terrain.js.map +1 -1
- package/dist/utility/serialization/scene/text.js +516 -0
- package/dist/utility/serialization/scene/text.js.map +1 -0
- package/dist/utility/serialization/scene/water.js +2 -0
- package/dist/utility/serialization/scene/water.js.map +1 -1
- package/dist/utility/serialization/types.js.map +1 -1
- package/dist/utility/textures/sheenlut.js +138 -0
- package/dist/utility/textures/sheenlut.js.map +1 -0
- package/dist/values.js +48 -48
- package/dist/values.js.map +1 -1
- package/package.json +3 -3
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"skeleton_modifier.js","sources":["../../src/animation/skeleton_modifier.ts"],"sourcesContent":["import type {
|
|
1
|
+
{"version":3,"file":"skeleton_modifier.js","sources":["../../src/animation/skeleton_modifier.ts"],"sourcesContent":["import type { SkeletonRig } from './skeleton';\r\n\r\n/**\r\n * Abstract base class for skeleton post-processors.\r\n *\r\n * Post-processors are applied after the base animation/bind pose layer,\r\n * allowing procedural modifications like IK, spring physics, or manual overrides.\r\n *\r\n * @public\r\n */\r\nexport abstract class SkeletonModifier {\r\n /** Whether this processor is enabled */\r\n protected _enabled: boolean;\r\n\r\n constructor() {\r\n this._enabled = true;\r\n }\r\n\r\n /**\r\n * Get the blend weight [0-1]\r\n */\r\n get weight(): number {\r\n return this._getWeight();\r\n }\r\n\r\n set weight(value: number) {\r\n this._setWeight(value);\r\n }\r\n\r\n /**\r\n * Get whether this processor is enabled\r\n */\r\n get enabled(): boolean {\r\n return this._enabled;\r\n }\r\n\r\n set enabled(value: boolean) {\r\n this._enabled = value;\r\n }\r\n\r\n /**\r\n * Apply post-processing to skeleton joints.\r\n *\r\n * This method is called after the base animation/bind pose has been applied.\r\n * Implementations should modify joint transforms and blend with the current state\r\n * using the processor's weight.\r\n *\r\n * @param skeleton - The shared rig to process\r\n * @param deltaTime - Time elapsed since last frame (in seconds)\r\n */\r\n abstract apply(skeleton: SkeletonRig, deltaTime: number): void;\r\n\r\n /**\r\n * Reset the processor to its initial state.\r\n *\r\n * Called when the skeleton or animation state changes significantly.\r\n */\r\n abstract reset(): void;\r\n\r\n /**\r\n * Get the blend weight for this processor.\r\n */\r\n protected abstract _getWeight(): number;\r\n\r\n /**\r\n * Set the blend weight for this processor.\r\n * @param _value - New blend weight (0-1)\r\n */\r\n protected abstract _setWeight(_value: number): void;\r\n}\r\n"],"names":["SkeletonModifier","_enabled","weight","_getWeight","value","_setWeight","enabled"],"mappings":"AAEA;;;;;;;AAOC,IACM,MAAeA,gBAAAA,CAAAA;6CAEpB,QAA4B;IAE5B,WAAc,EAAA;QACZ,IAAI,CAACC,QAAQ,GAAG,IAAA;AAClB;AAEA;;AAEC,MACD,IAAIC,MAAiB,GAAA;QACnB,OAAO,IAAI,CAACC,UAAU,EAAA;AACxB;IAEA,IAAID,MAAAA,CAAOE,KAAa,EAAE;QACxB,IAAI,CAACC,UAAU,CAACD,KAAAA,CAAAA;AAClB;AAEA;;AAEC,MACD,IAAIE,OAAmB,GAAA;QACrB,OAAO,IAAI,CAACL,QAAQ;AACtB;IAEA,IAAIK,OAAAA,CAAQF,KAAc,EAAE;QAC1B,IAAI,CAACH,QAAQ,GAAGG,KAAAA;AAClB;AA+BF;;;;"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"spring_particle.js","sources":["../../../src/animation/spring/spring_particle.ts"],"sourcesContent":["import type { Vector3, Quaternion, Nullable } from '@zephyr3d/base';\nimport type { SceneNode } from '../../scene/scene_node';\n\n/**\n * Represents a particle in the spring system\n *\n * @public\n */\nexport interface SpringParticle {\n /** Current position in world space */\n position: Vector3;\n /** Previous position for Verlet integration */\n prevPosition: Vector3;\n /** Original position for reset */\n originalPosition: Vector3;\n /** Animated (target) position for pose preservation */\n animPosition: Vector3;\n /** Original world rotation (for calculating rotation delta) */\n originalRotation: Quaternion | null;\n /** Mass of the particle (affects inertia) */\n mass: number;\n /** Damping coefficient [0-1] (0 = no damping, 1 = full damping) */\n damping: number;\n /** Whether this particle is fixed (anchor point) */\n fixed: boolean;\n /** Associated scene node (optional) */\n node: Nullable<SceneNode>;\n /** Previous frame position (used to calculate velocity for inertial forces) */\n lastFramePosition: Vector3;\n /** Position history for rotation center estimation (for fixed particles) */\n positionHistory?: Vector3[];\n}\n\n/**\n * Creates a new spring particle\n *\n * @public\n */\nexport function createSpringParticle(\n position: Vector3,\n options?: {\n mass?: number;\n damping?: number;\n fixed?: boolean;\n node?: SceneNode;\n originalRotation?: Quaternion;\n }\n): SpringParticle {\n return {\n position: position.clone(),\n prevPosition: position.clone(),\n originalPosition: position.clone(),\n animPosition: position.clone(),\n originalRotation: options?.originalRotation?.clone() ?? null,\n mass: options?.mass ?? 1.0,\n damping: options?.damping ?? 0.95,\n fixed: options?.fixed ?? false,\n node: options?.node ?? null,\n lastFramePosition: position.clone()\n };\n}\n"],"names":["createSpringParticle","position","options","clone","prevPosition","originalPosition","animPosition","originalRotation","mass","damping","fixed","node","lastFramePosition"],"mappings":"AAiCA;;;;AAIC,IACM,SAASA,oBACdC,CAAAA,QAAiB,EACjBC,OAMC,EAAA;IAED,OAAO;AACLD,QAAAA,QAAAA,EAAUA,SAASE,KAAK,EAAA;AACxBC,QAAAA,YAAAA,EAAcH,SAASE,KAAK,EAAA;AAC5BE,QAAAA,gBAAAA,EAAkBJ,SAASE,KAAK,EAAA;AAChCG,QAAAA,YAAAA,EAAcL,SAASE,KAAK,EAAA;QAC5BI,gBAAkBL,EAAAA,OAAAA,EAASK,kBAAkBJ,KAAW,EAAA,IAAA,IAAA;AACxDK,QAAAA,IAAAA,EAAMN,SAASM,IAAQ,IAAA,GAAA;AACvBC,QAAAA,OAAAA,EAASP,SAASO,OAAW,IAAA,IAAA;AAC7BC,QAAAA,KAAAA,EAAOR,SAASQ,KAAS,IAAA,KAAA;AACzBC,QAAAA,IAAAA,EAAMT,SAASS,IAAQ,IAAA,IAAA;AACvBC,QAAAA,iBAAAA,EAAmBX,SAASE,KAAK;AACnC,KAAA;AACF;;;;"}
|
|
1
|
+
{"version":3,"file":"spring_particle.js","sources":["../../../src/animation/spring/spring_particle.ts"],"sourcesContent":["import type { Vector3, Quaternion, Nullable } from '@zephyr3d/base';\r\nimport type { SceneNode } from '../../scene/scene_node';\r\n\r\n/**\r\n * Represents a particle in the spring system\r\n *\r\n * @public\r\n */\r\nexport interface SpringParticle {\r\n /** Current position in world space */\r\n position: Vector3;\r\n /** Previous position for Verlet integration */\r\n prevPosition: Vector3;\r\n /** Original position for reset */\r\n originalPosition: Vector3;\r\n /** Animated (target) position for pose preservation */\r\n animPosition: Vector3;\r\n /** Original world rotation (for calculating rotation delta) */\r\n originalRotation: Quaternion | null;\r\n /** Mass of the particle (affects inertia) */\r\n mass: number;\r\n /** Damping coefficient [0-1] (0 = no damping, 1 = full damping) */\r\n damping: number;\r\n /** Whether this particle is fixed (anchor point) */\r\n fixed: boolean;\r\n /** Associated scene node (optional) */\r\n node: Nullable<SceneNode>;\r\n /** Previous frame position (used to calculate velocity for inertial forces) */\r\n lastFramePosition: Vector3;\r\n /** Position history for rotation center estimation (for fixed particles) */\r\n positionHistory?: Vector3[];\r\n}\r\n\r\n/**\r\n * Creates a new spring particle\r\n *\r\n * @public\r\n */\r\nexport function createSpringParticle(\r\n position: Vector3,\r\n options?: {\r\n mass?: number;\r\n damping?: number;\r\n fixed?: boolean;\r\n node?: SceneNode;\r\n originalRotation?: Quaternion;\r\n }\r\n): SpringParticle {\r\n return {\r\n position: position.clone(),\r\n prevPosition: position.clone(),\r\n originalPosition: position.clone(),\r\n animPosition: position.clone(),\r\n originalRotation: options?.originalRotation?.clone() ?? null,\r\n mass: options?.mass ?? 1.0,\r\n damping: options?.damping ?? 0.95,\r\n fixed: options?.fixed ?? false,\r\n node: options?.node ?? null,\r\n lastFramePosition: position.clone()\r\n };\r\n}\r\n"],"names":["createSpringParticle","position","options","clone","prevPosition","originalPosition","animPosition","originalRotation","mass","damping","fixed","node","lastFramePosition"],"mappings":"AAiCA;;;;AAIC,IACM,SAASA,oBACdC,CAAAA,QAAiB,EACjBC,OAMC,EAAA;IAED,OAAO;AACLD,QAAAA,QAAAA,EAAUA,SAASE,KAAK,EAAA;AACxBC,QAAAA,YAAAA,EAAcH,SAASE,KAAK,EAAA;AAC5BE,QAAAA,gBAAAA,EAAkBJ,SAASE,KAAK,EAAA;AAChCG,QAAAA,YAAAA,EAAcL,SAASE,KAAK,EAAA;QAC5BI,gBAAkBL,EAAAA,OAAAA,EAASK,kBAAkBJ,KAAW,EAAA,IAAA,IAAA;AACxDK,QAAAA,IAAAA,EAAMN,SAASM,IAAQ,IAAA,GAAA;AACvBC,QAAAA,OAAAA,EAASP,SAASO,OAAW,IAAA,IAAA;AAC7BC,QAAAA,KAAAA,EAAOR,SAASQ,KAAS,IAAA,KAAA;AACzBC,QAAAA,IAAAA,EAAMT,SAASS,IAAQ,IAAA,IAAA;AACvBC,QAAAA,iBAAAA,EAAmBX,SAASE,KAAK;AACnC,KAAA;AACF;;;;"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"spring_modifier.js","sources":["../../src/animation/spring_modifier.ts"],"sourcesContent":["import { SkeletonModifier } from './skeleton_modifier';\r\nimport type {
|
|
1
|
+
{"version":3,"file":"spring_modifier.js","sources":["../../src/animation/spring_modifier.ts"],"sourcesContent":["import { SkeletonModifier } from './skeleton_modifier';\r\nimport type { SkeletonRig } from './skeleton';\r\nimport type { SpringSystem } from './spring/spring_system';\r\n\r\n/**\r\n * Post-processor wrapper for spring physics systems.\r\n *\r\n * Integrates spring-based physics simulation into the skeleton post-processing pipeline.\r\n * The spring system is updated each frame and results are blended with the base animation.\r\n *\r\n * @deprecated Use the new {@link JointDynamicsModifier} class instead.\r\n *\r\n * @public\r\n */\r\nexport class SpringModifier extends SkeletonModifier {\r\n private _springSystem: SpringSystem;\r\n private _weight: number;\r\n\r\n /**\r\n * Create a spring post-processor.\r\n *\r\n * @param springSystem - The spring system to integrate\r\n * @param weight - Blend weight [0-1] (default: 1.0)\r\n */\r\n constructor(springSystem: SpringSystem, weight: number = 1.0) {\r\n super();\r\n this._weight = weight;\r\n this._springSystem = springSystem;\r\n }\r\n\r\n /**\r\n * Get the spring system.\r\n */\r\n get springSystem(): SpringSystem {\r\n return this._springSystem;\r\n }\r\n\r\n /**\r\n * Apply spring physics to skeleton joints.\r\n */\r\n apply(_skeleton: SkeletonRig, deltaTime: number): void {\r\n if (!this._enabled || this._weight <= 0) {\r\n return;\r\n }\r\n\r\n // Update spring physics simulation\r\n this._springSystem.update(deltaTime);\r\n\r\n // Apply results to scene nodes with blending\r\n this._springSystem.applyToNodes(this._weight);\r\n }\r\n\r\n /**\r\n * Reset the spring system to initial state.\r\n */\r\n reset(): void {\r\n this._springSystem.reset();\r\n }\r\n\r\n /**\r\n * Get the blend weight for this processor.\r\n * @returns The current blend weight (0-1)\r\n */\r\n protected _getWeight(): number {\r\n return this._weight;\r\n }\r\n\r\n /**\r\n * Set the blend weight for this processor.\r\n * @param value - New blend weight (0-1)\r\n */\r\n protected _setWeight(value: number): void {\r\n this._weight = Math.max(0, Math.min(1, value));\r\n }\r\n}\r\n"],"names":["SpringModifier","SkeletonModifier","_springSystem","_weight","springSystem","weight","apply","_skeleton","deltaTime","_enabled","update","applyToNodes","reset","_setWeight","value","Math","max","min"],"mappings":";;AAIA;;;;;;;;;IAUO,MAAMA,cAAuBC,SAAAA,gBAAAA,CAAAA;IAC1BC,aAA4B;IAC5BC,OAAgB;AAExB;;;;;AAKC,MACD,WAAYC,CAAAA,YAA0B,EAAEC,MAAAA,GAAiB,GAAG,CAAE;QAC5D,KAAK,EAAA;QACL,IAAI,CAACF,OAAO,GAAGE,MAAAA;QACf,IAAI,CAACH,aAAa,GAAGE,YAAAA;AACvB;AAEA;;AAEC,MACD,IAAIA,YAA6B,GAAA;QAC/B,OAAO,IAAI,CAACF,aAAa;AAC3B;AAEA;;AAEC,MACDI,KAAMC,CAAAA,SAAsB,EAAEC,SAAiB,EAAQ;QACrD,IAAI,CAAC,IAAI,CAACC,QAAQ,IAAI,IAAI,CAACN,OAAO,IAAI,CAAG,EAAA;AACvC,YAAA;AACF;;AAGA,QAAA,IAAI,CAACD,aAAa,CAACQ,MAAM,CAACF,SAAAA,CAAAA;;AAG1B,QAAA,IAAI,CAACN,aAAa,CAACS,YAAY,CAAC,IAAI,CAACR,OAAO,CAAA;AAC9C;AAEA;;AAEC,MACDS,KAAc,GAAA;QACZ,IAAI,CAACV,aAAa,CAACU,KAAK,EAAA;AAC1B;AAEA;;;AAGC,MACD,UAA+B,GAAA;QAC7B,OAAO,IAAI,CAACT,OAAO;AACrB;AAEA;;;MAIUU,UAAWC,CAAAA,KAAa,EAAQ;QACxC,IAAI,CAACX,OAAO,GAAGY,IAAKC,CAAAA,GAAG,CAAC,CAAGD,EAAAA,IAAAA,CAAKE,GAAG,CAAC,CAAGH,EAAAA,KAAAA,CAAAA,CAAAA;AACzC;AACF;;;;"}
|
|
@@ -40,6 +40,9 @@ import { AnimationTrack } from './animationtrack.js';
|
|
|
40
40
|
}
|
|
41
41
|
this._interpolator = interp ?? null;
|
|
42
42
|
}
|
|
43
|
+
/** {@inheritDoc AnimationTrack.clone} */ clone() {
|
|
44
|
+
return new NodeTranslationTrack(this._interpolator?.clone(), false);
|
|
45
|
+
}
|
|
43
46
|
/** {@inheritDoc AnimationTrack.calculateState} */ calculateState(target, currentTime) {
|
|
44
47
|
this._interpolator.interpolate(currentTime, this._state);
|
|
45
48
|
return this._state;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"translationtrack.js","sources":["../../src/animation/translationtrack.ts"],"sourcesContent":["import type { InterpolationMode } from '@zephyr3d/base';\r\nimport { Interpolator, Vector3 } from '@zephyr3d/base';\r\nimport { AnimationTrack } from './animationtrack';\r\nimport type { SceneNode } from '../scene';\r\n\r\n/**\r\n * Translate animation track\r\n * @public\r\n */\r\nexport class NodeTranslationTrack extends AnimationTrack<Vector3> {\r\n private readonly _state: Vector3;\r\n private _interpolator!: Interpolator;\r\n /**\r\n * Create an instance of TranslationTrack\r\n */\r\n constructor();\r\n /**\r\n * Create an instance of TranslationTrack from keyframe values\r\n * @param interpolator - Interpolator object that contains the keyframe values\r\n * @param embedded - Whether this track be an embedded track\r\n */\r\n constructor(interpolator: Interpolator, embedded?: boolean);\r\n /**\r\n * Create an instance of TranslationTrack from keyframe values\r\n * @param mode - The interpolation mode of keyframes\r\n * @param keyFrames - Keyframe values\r\n * @param embedded - Whether this track be an embedded track\r\n */\r\n constructor(mode: InterpolationMode, keyFrames: { time: number; value: Vector3 }[], embedded?: boolean);\r\n constructor(\r\n modeOrInterpolator?: Interpolator | InterpolationMode,\r\n keyFramesOrEmbedded?: { time: number; value: Vector3 }[] | boolean,\r\n embedded?: boolean\r\n ) {\r\n if (modeOrInterpolator === undefined) {\r\n super(false);\r\n } else if (modeOrInterpolator instanceof Interpolator) {\r\n if (modeOrInterpolator.target !== 'vec3') {\r\n throw new Error(`TranslationTrack(): interpolator target must be 'vec3'`);\r\n }\r\n super((keyFramesOrEmbedded as boolean) ?? false);\r\n this._interpolator = modeOrInterpolator;\r\n } else {\r\n const keyFrames = keyFramesOrEmbedded as { time: number; value: Vector3 }[];\r\n const inputs = new Float32Array(keyFrames.map((val) => val.time));\r\n const outputs = new Float32Array(keyFrames.length * 3);\r\n for (let i = 0; i < keyFrames.length; i++) {\r\n outputs[i * 3 + 0] = keyFrames[i].value.x;\r\n outputs[i * 3 + 1] = keyFrames[i].value.y;\r\n outputs[i * 3 + 2] = keyFrames[i].value.z;\r\n }\r\n super(embedded ?? false);\r\n this._interpolator = new Interpolator(modeOrInterpolator, 'vec3', inputs, outputs);\r\n }\r\n this._state = new Vector3();\r\n this._jointIndex = -1;\r\n }\r\n get interpolator() {\r\n return this._interpolator;\r\n }\r\n set interpolator(interp: Interpolator) {\r\n if (interp && interp.target !== 'vec3') {\r\n throw new Error(`TranslationTrack(): interpolator target must be 'vec3'`);\r\n }\r\n this._interpolator = interp ?? null;\r\n }\r\n /** {@inheritDoc AnimationTrack.calculateState} */\r\n calculateState(target: object, currentTime: number) {\r\n this._interpolator.interpolate(currentTime, this._state);\r\n return this._state;\r\n }\r\n /** {@inheritDoc AnimationTrack.applyState} */\r\n applyState(node: SceneNode, state: Vector3) {\r\n node.position.set(state);\r\n }\r\n /** {@inheritDoc AnimationTrack.mixState} */\r\n mixState(a: Vector3, b: Vector3, t: number) {\r\n return new Vector3(a.x + t * (b.x - a.x), a.y + t * (b.y - a.y), a.z + t * (b.z - a.z));\r\n }\r\n /** {@inheritDoc AnimationTrack.getBlendId} */\r\n getBlendId() {\r\n return 'node-translation';\r\n }\r\n /** {@inheritDoc AnimationTrack.getDuration} */\r\n getDuration() {\r\n return this._interpolator.maxTime;\r\n }\r\n}\r\n"],"names":["NodeTranslationTrack","AnimationTrack","_state","_interpolator","modeOrInterpolator","keyFramesOrEmbedded","embedded","undefined","Interpolator","target","Error","keyFrames","inputs","Float32Array","map","val","time","outputs","length","i","value","x","y","z","Vector3","_jointIndex","interpolator","interp","calculateState","currentTime","interpolate","applyState","node","state","position","set","mixState","a","b","t","getBlendId","getDuration","maxTime"],"mappings":";;;AAKA;;;IAIO,MAAMA,oBAA6BC,SAAAA,cAAAA,CAAAA;IACvBC,MAAgB;IACzBC,aAA6B;AAk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AAAA,EAAoB,QAAQQ,MAAQK,EAAAA,OAAAA,CAAAA;AAC5E;QACA,IAAI,CAACf,MAAM,GAAG,IAAIsB,OAAAA,EAAAA;QAClB,IAAI,CAACC,WAAW,GAAG,EAAC;AACtB;AACA,IAAA,IAAIC,YAAe,GAAA;QACjB,OAAO,IAAI,CAACvB,aAAa;AAC3B;IACA,IAAIuB,YAAAA,CAAaC,MAAoB,EAAE;AACrC,QAAA,IAAIA,MAAUA,IAAAA,MAAAA,CAAOlB,MAAM,KAAK,MAAQ,EAAA;AACtC,YAAA,MAAM,IAAIC,KAAAA,CAAM,CAAC,sDAAsD,CAAC,CAAA;AAC1E;QACA,IAAI,CAACP,aAAa,GAAGwB,MAAU,IAAA,IAAA;AACjC;AACA,uDACAC,cAAAA,
|
|
1
|
+
{"version":3,"file":"translationtrack.js","sources":["../../src/animation/translationtrack.ts"],"sourcesContent":["import type { InterpolationMode } from '@zephyr3d/base';\r\nimport { Interpolator, Vector3 } from '@zephyr3d/base';\r\nimport { AnimationTrack } from './animationtrack';\r\nimport type { SceneNode } from '../scene';\r\n\r\n/**\r\n * Translate animation track\r\n * @public\r\n */\r\nexport class NodeTranslationTrack extends AnimationTrack<Vector3> {\r\n private readonly _state: Vector3;\r\n private _interpolator!: Interpolator;\r\n /**\r\n * Create an instance of TranslationTrack\r\n */\r\n constructor();\r\n /**\r\n * Create an instance of TranslationTrack from keyframe values\r\n * @param interpolator - Interpolator object that contains the keyframe values\r\n * @param embedded - Whether this track be an embedded track\r\n */\r\n constructor(interpolator: Interpolator, embedded?: boolean);\r\n /**\r\n * Create an instance of TranslationTrack from keyframe values\r\n * @param mode - The interpolation mode of keyframes\r\n * @param keyFrames - Keyframe values\r\n * @param embedded - Whether this track be an embedded track\r\n */\r\n constructor(mode: InterpolationMode, keyFrames: { time: number; value: Vector3 }[], embedded?: boolean);\r\n constructor(\r\n modeOrInterpolator?: Interpolator | InterpolationMode,\r\n keyFramesOrEmbedded?: { time: number; value: Vector3 }[] | boolean,\r\n embedded?: boolean\r\n ) {\r\n if (modeOrInterpolator === undefined) {\r\n super(false);\r\n } else if (modeOrInterpolator instanceof Interpolator) {\r\n if (modeOrInterpolator.target !== 'vec3') {\r\n throw new Error(`TranslationTrack(): interpolator target must be 'vec3'`);\r\n }\r\n super((keyFramesOrEmbedded as boolean) ?? false);\r\n this._interpolator = modeOrInterpolator;\r\n } else {\r\n const keyFrames = keyFramesOrEmbedded as { time: number; value: Vector3 }[];\r\n const inputs = new Float32Array(keyFrames.map((val) => val.time));\r\n const outputs = new Float32Array(keyFrames.length * 3);\r\n for (let i = 0; i < keyFrames.length; i++) {\r\n outputs[i * 3 + 0] = keyFrames[i].value.x;\r\n outputs[i * 3 + 1] = keyFrames[i].value.y;\r\n outputs[i * 3 + 2] = keyFrames[i].value.z;\r\n }\r\n super(embedded ?? false);\r\n this._interpolator = new Interpolator(modeOrInterpolator, 'vec3', inputs, outputs);\r\n }\r\n this._state = new Vector3();\r\n this._jointIndex = -1;\r\n }\r\n get interpolator() {\r\n return this._interpolator;\r\n }\r\n set interpolator(interp: Interpolator) {\r\n if (interp && interp.target !== 'vec3') {\r\n throw new Error(`TranslationTrack(): interpolator target must be 'vec3'`);\r\n }\r\n this._interpolator = interp ?? null;\r\n }\r\n /** {@inheritDoc AnimationTrack.clone} */\r\n clone(): this {\r\n return new NodeTranslationTrack(this._interpolator?.clone(), false) as this;\r\n }\r\n /** {@inheritDoc AnimationTrack.calculateState} */\r\n calculateState(target: object, currentTime: number) {\r\n this._interpolator.interpolate(currentTime, this._state);\r\n return this._state;\r\n }\r\n /** {@inheritDoc AnimationTrack.applyState} */\r\n applyState(node: SceneNode, state: Vector3) {\r\n node.position.set(state);\r\n }\r\n /** {@inheritDoc AnimationTrack.mixState} */\r\n mixState(a: Vector3, b: Vector3, t: number) {\r\n return new Vector3(a.x + t * (b.x - a.x), a.y + t * (b.y - a.y), a.z + t * (b.z - a.z));\r\n }\r\n /** {@inheritDoc AnimationTrack.getBlendId} */\r\n getBlendId() {\r\n return 'node-translation';\r\n }\r\n /** {@inheritDoc AnimationTrack.getDuration} */\r\n getDuration() {\r\n return this._interpolator.maxTime;\r\n }\r\n}\r\n"],"names":["NodeTranslationTrack","AnimationTrack","_state","_interpolator","modeOrInterpolator","keyFramesOrEmbedded","embedded","undefined","Interpolator","target","Error","keyFrames","inputs","Float32Array","map","val","time","outputs","length","i","value","x","y","z","Vector3","_jointIndex","interpolator","interp","clone","calculateState","currentTime","interpolate","applyState","node","state","position","set","mixState","a","b","t","getBlendId","getDuration","maxTime"],"mappings":";;;AAKA;;;IAIO,MAAMA,oBAA6BC,SAAAA,cAAAA,CAAAA;IACvBC,MAAgB;IACzBC,aAA6B;AAkBrC,IAAA,WAAA,CACEC,kBAAqD,EACrDC,mBAAkE,EAClEC,QAAkB,CAClB;AACA,QAAA,IAAIF,uBAAuBG,SAAW,EAAA;AACpC,YAAA,KAAK,CAAC,KAAA,CAAA;SACD,MAAA,IAAIH,8BAA8BI,YAAc,EAAA;YACrD,IAAIJ,kBAAAA,CAAmBK,MAAM,KAAK,MAAQ,EAAA;AACxC,gBAAA,MAAM,IAAIC,KAAAA,CAAM,CAAC,sDAAsD,CAAC,CAAA;AAC1E;YACA,KAAK,CAAC,mBAAoC,IAAA,KAAA,CAAA;YAC1C,IAAI,CAACP,aAAa,GAAGC,kBAAAA;SAChB,MAAA;AACL,YAAA,MAAMO,SAAYN,GAAAA,mBAAAA;YAClB,MAAMO,MAAAA,GAAS,IAAIC,YAAaF,CAAAA,SAAAA,CAAUG,GAAG,CAAC,CAACC,GAAQA,GAAAA,GAAAA,CAAIC,IAAI,CAAA,CAAA;AAC/D,YAAA,MAAMC,OAAU,GAAA,IAAIJ,YAAaF,CAAAA,SAAAA,CAAUO,MAAM,GAAG,CAAA,CAAA;AACpD,YAAA,IAAK,IAAIC,CAAI,GAAA,CAAA,EAAGA,IAAIR,SAAUO,CAAAA,MAAM,EAAEC,CAAK,EAAA,CAAA;gBACzCF,OAAO,CA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WC,IAAe,EAAEC,KAAc,EAAE;QAC1CD,IAAKE,CAAAA,QAAQ,CAACC,GAAG,CAACF,KAAAA,CAAAA;AACpB;AACA,iDACAG,QAASC,CAAAA,CAAU,EAAEC,CAAU,EAAEC,CAAS,EAAE;AAC1C,QAAA,OAAO,IAAIhB,OAAQc,CAAAA,CAAAA,CAAEjB,CAAC,GAAGmB,KAAKD,CAAAA,CAAElB,CAAC,GAAGiB,EAAEjB,CAAAA,CAAIiB,EAAAA,CAAAA,CAAEhB,CAAC,GAAGkB,CAAAA,IAAKD,CAAAA,CAAEjB,CAAC,GAAGgB,CAAAA,CAAEhB,CAAAA,GAAIgB,CAAEf,CAAAA,CAAC,GAAGiB,CAAAA,IAAKD,CAAEhB,CAAAA,CAAC,GAAGe,CAAAA,CAAEf,CAAC,CAADA,CAAAA;AACtF;AACA,mDACAkB,UAAa,GAAA;QACX,OAAO,kBAAA;AACT;AACA,oDACAC,WAAc,GAAA;AACZ,QAAA,OAAO,IAAI,CAACvC,aAAa,CAACwC,OAAO;AACnC;AACF;;;;"}
|
package/dist/app/engine.js
CHANGED
|
@@ -24,8 +24,10 @@ import { PBRSpecularGlossinessMaterial } from '../material/pbrsg.js';
|
|
|
24
24
|
import '../material/pbrblueprint.js';
|
|
25
25
|
import '../material/sprite.js';
|
|
26
26
|
import { StandardSpriteMaterial } from '../material/sprite_std.js';
|
|
27
|
+
import '../material/msdf_text.js';
|
|
27
28
|
import '../utility/blueprint/material/texture.js';
|
|
28
29
|
import { ScreenAdapter } from './screen.js';
|
|
30
|
+
import { MSDFTextAtlasManager } from '../text/runtime/msdf_text_atlas_manager.js';
|
|
29
31
|
|
|
30
32
|
/**
|
|
31
33
|
* Core engine class managing scripting, serialization, and rendering.
|
|
@@ -47,6 +49,7 @@ import { ScreenAdapter } from './screen.js';
|
|
|
47
49
|
_builtinsVFS;
|
|
48
50
|
_scriptingSystem;
|
|
49
51
|
_resourceManager;
|
|
52
|
+
_msdfTextAtlasManager;
|
|
50
53
|
_enabled;
|
|
51
54
|
_screen;
|
|
52
55
|
_activeRenderables;
|
|
@@ -65,6 +68,7 @@ import { ScreenAdapter } from './screen.js';
|
|
|
65
68
|
scriptsRoot
|
|
66
69
|
});
|
|
67
70
|
this._resourceManager = new ResourceManager(VFS);
|
|
71
|
+
this._msdfTextAtlasManager = new MSDFTextAtlasManager();
|
|
68
72
|
this._enabled = enabled ?? true;
|
|
69
73
|
this._activeRenderables = [];
|
|
70
74
|
this._loadingScenes = {};
|
|
@@ -80,7 +84,14 @@ import { ScreenAdapter } from './screen.js';
|
|
|
80
84
|
*/ get VFS() {
|
|
81
85
|
return this._scriptingSystem.registry.VFS;
|
|
82
86
|
}
|
|
83
|
-
|
|
87
|
+
/**
|
|
88
|
+
* Replaces the virtual file system used by the engine.
|
|
89
|
+
*
|
|
90
|
+
* The previous resource manager VFS is closed, the scripting registry is updated,
|
|
91
|
+
* and built-in assets are remounted on the new VFS.
|
|
92
|
+
*
|
|
93
|
+
* @param vfs - New virtual file system.
|
|
94
|
+
*/ set VFS(vfs) {
|
|
84
95
|
if (vfs !== this._resourceManager.VFS) {
|
|
85
96
|
this._resourceManager.VFS?.close();
|
|
86
97
|
this._resourceManager.VFS = vfs;
|
|
@@ -94,6 +105,52 @@ import { ScreenAdapter } from './screen.js';
|
|
|
94
105
|
return this._resourceManager;
|
|
95
106
|
}
|
|
96
107
|
/**
|
|
108
|
+
* Exposes the shared runtime MSDF text atlas manager.
|
|
109
|
+
*/ get msdfTextAtlasManager() {
|
|
110
|
+
return this._msdfTextAtlasManager;
|
|
111
|
+
}
|
|
112
|
+
/**
|
|
113
|
+
* Releases a loaded font asset from the resource cache and disposes its shared MSDF atlas textures.
|
|
114
|
+
*
|
|
115
|
+
* Existing scene nodes that still reference this font asset are not updated automatically.
|
|
116
|
+
* Call this only after you have stopped using the font, or when you intentionally want it to rebuild later.
|
|
117
|
+
*
|
|
118
|
+
* @param font - The loaded font asset path to release.
|
|
119
|
+
* @returns `true` if either the atlas cache or the font cache had an entry to remove.
|
|
120
|
+
*/ releaseFontAsset(font) {
|
|
121
|
+
const fontAsset = this._resourceManager.getFontAsset(font);
|
|
122
|
+
if (!fontAsset) {
|
|
123
|
+
return false;
|
|
124
|
+
}
|
|
125
|
+
const atlasReleased = this._msdfTextAtlasManager.releaseAtlas(fontAsset);
|
|
126
|
+
const fontReleased = this._resourceManager.releaseFontAsset(fontAsset);
|
|
127
|
+
return atlasReleased || fontReleased;
|
|
128
|
+
}
|
|
129
|
+
/**
|
|
130
|
+
* Configures the MSDF atlas for a given font asset, creating or replacing the atlas as needed.
|
|
131
|
+
*
|
|
132
|
+
* This is useful to customize the glyph size, atlas page size, distance range, and padding for MSDF text rendering.
|
|
133
|
+
* Existing scene nodes that reference this font asset will use the updated atlas automatically.
|
|
134
|
+
*
|
|
135
|
+
* @param font - The font asset path to configure the MSDF atlas for.
|
|
136
|
+
* @param pageSize - The size of each atlas page in pixels (e.g., 512, 1024).
|
|
137
|
+
* @param glyphSize - The size of each glyph in pixels (e.g., 32, 64).
|
|
138
|
+
* @param distanceRange - The distance range for MSDF generation. Defaults to 4.
|
|
139
|
+
* @param padding - The padding between glyphs in the atlas in pixels. Defaults to 2.
|
|
140
|
+
* @returns `true` if the atlas was successfully configured, or `false` if the font asset was not found.
|
|
141
|
+
*
|
|
142
|
+
* @remarks
|
|
143
|
+
* The font asset must be loaded and available in the resource manager for the atlas to be configured.
|
|
144
|
+
*/ configureMSDFAtlas(font, pageSize, glyphSize, distanceRange, padding) {
|
|
145
|
+
const fontAsset = this._resourceManager.getFontAsset(font);
|
|
146
|
+
if (!fontAsset) {
|
|
147
|
+
console.warn(`Font asset '${font}' not found for MSDF atlas configuration.`);
|
|
148
|
+
return false;
|
|
149
|
+
}
|
|
150
|
+
this._msdfTextAtlasManager.configureAtlas(fontAsset, pageSize, glyphSize, distanceRange, padding);
|
|
151
|
+
return true;
|
|
152
|
+
}
|
|
153
|
+
/**
|
|
97
154
|
* Exposes the active {@link ScreenAdapter}.
|
|
98
155
|
*/ get screen() {
|
|
99
156
|
return this._screen;
|
|
@@ -125,6 +182,7 @@ import { ScreenAdapter } from './screen.js';
|
|
|
125
182
|
* @typeParam T - Host type.
|
|
126
183
|
* @param host - Host object to attach the script to.
|
|
127
184
|
* @param module - Module identifier to resolve and load.
|
|
185
|
+
* @param config - Optional configuration passed to the script instance.
|
|
128
186
|
* @returns The `RuntimeScript<T>` instance, or `null` if disabled or on failure.
|
|
129
187
|
*/ async attachScript(host, module, config) {
|
|
130
188
|
return this._enabled ? await this._scriptingSystem.attachScript(host, module, config) : null;
|
|
@@ -156,8 +214,6 @@ import { ScreenAdapter } from './screen.js';
|
|
|
156
214
|
/**
|
|
157
215
|
* Ticks all attached scripts by calling their `onUpdate` hooks, if enabled.
|
|
158
216
|
*
|
|
159
|
-
* Delegates to {@link ScriptingSystem.update}. No-op when disabled.
|
|
160
|
-
*
|
|
161
217
|
* @param deltaTime - Time since last update in Seconds.
|
|
162
218
|
* @param elapsedTime - Total elapsed time in Seconds.
|
|
163
219
|
*/ update(deltaTime, elapsedTime) {
|
|
@@ -165,24 +221,60 @@ import { ScreenAdapter } from './screen.js';
|
|
|
165
221
|
this._scriptingSystem.update(deltaTime, elapsedTime);
|
|
166
222
|
}
|
|
167
223
|
}
|
|
168
|
-
|
|
224
|
+
/**
|
|
225
|
+
* Loads a scene from a file path.
|
|
226
|
+
*
|
|
227
|
+
* Concurrent requests for the same normalized path share the same loading promise.
|
|
228
|
+
* Scripts declared on the scene and its nodes are attached after the scene is loaded.
|
|
229
|
+
*
|
|
230
|
+
* @param path - Scene file path in the current VFS.
|
|
231
|
+
* @returns The loaded scene, or `null` when loading fails.
|
|
232
|
+
*/ async loadSceneFromFile(path) {
|
|
169
233
|
path = this.VFS.normalizePath(path);
|
|
170
234
|
if (!this._loadingScenes[path]) {
|
|
171
235
|
this._loadingScenes[path] = this._loadScene(path);
|
|
172
236
|
}
|
|
173
237
|
return this._loadingScenes[path];
|
|
174
238
|
}
|
|
175
|
-
|
|
176
|
-
|
|
239
|
+
/**
|
|
240
|
+
* Sets or clears the renderable for a render layer.
|
|
241
|
+
*
|
|
242
|
+
* Passing `null` clears the layer. Object renderables are held through a strong reference wrapper,
|
|
243
|
+
* while render functions are stored directly.
|
|
244
|
+
*
|
|
245
|
+
* @param renderable - Renderable object or render function to assign, or `null` to clear.
|
|
246
|
+
* @param layer - Render layer index. Defaults to `0`.
|
|
247
|
+
* @param hook - Optional render hook invoked before and after this layer renders.
|
|
248
|
+
*/ setRenderable(renderable, layer = 0, hook) {
|
|
249
|
+
const entry = this._activeRenderables[layer];
|
|
250
|
+
if (!entry) {
|
|
177
251
|
this._activeRenderables[layer] = {
|
|
178
|
-
renderable: new DRef(null
|
|
179
|
-
hook: null
|
|
252
|
+
renderable: renderable ? typeof renderable === 'function' ? renderable : new DRef(renderable) : null,
|
|
253
|
+
hook: hook ?? null
|
|
180
254
|
};
|
|
255
|
+
} else {
|
|
256
|
+
if (entry.renderable) {
|
|
257
|
+
if (entry.renderable instanceof DRef) {
|
|
258
|
+
entry.renderable.dispose();
|
|
259
|
+
}
|
|
260
|
+
entry.renderable = null;
|
|
261
|
+
}
|
|
262
|
+
if (typeof renderable === 'function') {
|
|
263
|
+
entry.renderable = renderable;
|
|
264
|
+
} else if (renderable) {
|
|
265
|
+
entry.renderable = new DRef(renderable);
|
|
266
|
+
}
|
|
267
|
+
entry.hook = hook ?? null;
|
|
181
268
|
}
|
|
182
|
-
this._activeRenderables[layer].hook = hook ?? null;
|
|
183
|
-
this._activeRenderables[layer].renderable.set(renderable);
|
|
184
269
|
}
|
|
185
|
-
|
|
270
|
+
/**
|
|
271
|
+
* Reads a file from the current VFS.
|
|
272
|
+
*
|
|
273
|
+
* @typeParam T - Requested read encoding.
|
|
274
|
+
* @param path - File path to read.
|
|
275
|
+
* @param encoding - Optional read encoding. Defaults to `binary`.
|
|
276
|
+
* @returns The file content, or `null` when the read fails.
|
|
277
|
+
*/ async readFile(path, encoding) {
|
|
186
278
|
try {
|
|
187
279
|
const content = await this.VFS.readFile(path, {
|
|
188
280
|
encoding: encoding ?? 'binary'
|
|
@@ -193,7 +285,15 @@ import { ScreenAdapter } from './screen.js';
|
|
|
193
285
|
return null;
|
|
194
286
|
}
|
|
195
287
|
}
|
|
196
|
-
|
|
288
|
+
/**
|
|
289
|
+
* Starts the runtime by optionally showing a splash screen, running a startup script,
|
|
290
|
+
* and loading the startup scene.
|
|
291
|
+
*
|
|
292
|
+
* @param startupScene - Optional scene path rendered on layer `0` after startup completes.
|
|
293
|
+
* @param splashScreen - Optional scene path rendered on a temporary splash layer during startup.
|
|
294
|
+
* @param startupScript - Optional startup script module path. A trailing `.ts` or `.js`
|
|
295
|
+
* extension is removed before loading.
|
|
296
|
+
*/ async startup(startupScene, splashScreen, startupScript) {
|
|
197
297
|
const splashScreenLayer = 9999;
|
|
198
298
|
if (splashScreen) {
|
|
199
299
|
const splashScreenScene = await this.loadSceneFromFile(splashScreen);
|
|
@@ -211,14 +311,26 @@ import { ScreenAdapter } from './screen.js';
|
|
|
211
311
|
}
|
|
212
312
|
this.setRenderable(null, splashScreenLayer);
|
|
213
313
|
}
|
|
214
|
-
|
|
314
|
+
/**
|
|
315
|
+
* Renders all active render layers.
|
|
316
|
+
*
|
|
317
|
+
* Each layer's `beforeRender` hook can return `false` to skip rendering that layer.
|
|
318
|
+
* The `afterRender` hook is invoked after the render attempt.
|
|
319
|
+
*/ render() {
|
|
215
320
|
this._activeRenderables.forEach((info)=>{
|
|
216
|
-
|
|
321
|
+
if (!info.renderable) {
|
|
322
|
+
return;
|
|
323
|
+
}
|
|
324
|
+
const render = info.hook?.beforeRender ? info.hook.beforeRender(typeof info.renderable === 'function' ? info.renderable : info.renderable.get()) ?? true : true;
|
|
217
325
|
if (render) {
|
|
218
|
-
info.renderable
|
|
326
|
+
if (typeof info.renderable === 'function') {
|
|
327
|
+
info.renderable();
|
|
328
|
+
} else {
|
|
329
|
+
info.renderable.get()?.render();
|
|
330
|
+
}
|
|
219
331
|
}
|
|
220
332
|
if (info.hook?.afterRender) {
|
|
221
|
-
info.hook.afterRender(info.renderable.get()
|
|
333
|
+
info.hook.afterRender(typeof info.renderable === 'function' ? info.renderable : info.renderable.get());
|
|
222
334
|
}
|
|
223
335
|
});
|
|
224
336
|
}
|
|
@@ -323,5 +435,5 @@ import { ScreenAdapter } from './screen.js';
|
|
|
323
435
|
}
|
|
324
436
|
}
|
|
325
437
|
|
|
326
|
-
export { Engine };
|
|
438
|
+
export { Engine, MSDFTextAtlasManager };
|
|
327
439
|
//# sourceMappingURL=engine.js.map
|
package/dist/app/engine.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"engine.js","sources":["../../src/app/engine.ts"],"sourcesContent":["import type { GenericConstructor, IDisposable, Nullable, ReadOptions } from '@zephyr3d/base';\r\nimport { MemoryFS, objectEntries } from '@zephyr3d/base';\r\nimport { DRef } from '@zephyr3d/base';\r\nimport { HttpFS, type VFS } from '@zephyr3d/base';\r\nimport { ScriptingSystem } from './scriptingsystem';\r\nimport type { Host } from './scriptingsystem';\r\nimport type { RuntimeScript, RuntimeScriptConfig } from './runtimescript';\r\nimport { ResourceManager } from '../utility/serialization/manager';\r\nimport type { Scene } from '../scene';\r\nimport {\r\n BoxShape,\r\n CapsuleShape,\r\n CylinderShape,\r\n PlaneShape,\r\n SphereShape,\r\n TetrahedronShape,\r\n TorusShape\r\n} from '../shapes';\r\nimport {\r\n BlinnMaterial,\r\n LambertMaterial,\r\n PBRMetallicRoughnessMaterial,\r\n PBRSpecularGlossinessMaterial,\r\n UnlitMaterial\r\n} from '../material';\r\nimport { StandardSpriteMaterial } from '../material/sprite_std';\r\nimport { ScreenAdapter } from './screen';\r\n\r\n/**\r\n * Interface for objects that can be rendered.\r\n *\r\n * @public\r\n */\r\nexport interface IRenderable extends IDisposable {\r\n render(): void;\r\n}\r\n\r\n/**\r\n * Interface for render hooks to customize rendering behavior.\r\n *\r\n * @public\r\n */\r\nexport interface IRenderHook {\r\n // If presents, called before rendering the renderable. Return `false` to skip rendering.\r\n beforeRender?: (renderable: any) => boolean | void;\r\n // If presents, called after rendering the renderable.\r\n afterRender?: (renderable: any) => void;\r\n}\r\n\r\n/**\r\n * Core engine class managing scripting, serialization, and rendering.\r\n *\r\n * Responsibilities:\r\n * - Manages a {@link ScriptingSystem} for dynamic script attachment and lifecycle.\r\n * - Manages a {@link ResourceManager} for loading scenes and assets.\r\n * - Maintains a list of active renderable objects to be rendered each frame.\r\n * - Provides methods to attach/detach scripts, update scripts, load scenes, and read files.\r\n * - Supports enabling/disabling of runtime operations.\r\n *\r\n * @remarks\r\n * The engine can be configured with a virtual file system (VFS) and script root path.\r\n * It exposes methods to manage scripts on host objects, update scripts each frame,\r\n * load scenes from files, and render active objects.\r\n *\r\n * @public\r\n */\r\nexport class Engine {\r\n private _builtinsVFS: Nullable<MemoryFS>;\r\n private _scriptingSystem: ScriptingSystem;\r\n private _resourceManager: ResourceManager;\r\n private _enabled: boolean;\r\n private _screen: ScreenAdapter;\r\n protected _activeRenderables: {\r\n renderable: DRef<IRenderable>;\r\n hook: Nullable<IRenderHook>;\r\n }[];\r\n private _loadingScenes: Partial<Record<string, Promise<Nullable<Scene>>>>;\r\n /**\r\n * Creates a new runtime manager.\r\n *\r\n * @param VFS - Optional virtual file system passed to the internal {@link ScriptingSystem}.\r\n * @param scriptsRoot - Optional scripts root path within the VFS. Defaults as in `ScriptingSystem`.\r\n * @param enabled - Whether runtime operations are active. Defaults to `true`.\r\n */\r\n constructor(VFS?: VFS, scriptsRoot?: string, enabled?: boolean) {\r\n VFS = VFS ?? new HttpFS('./');\r\n this._builtinsVFS = null;\r\n this._scriptingSystem = new ScriptingSystem({ VFS, scriptsRoot });\r\n this._resourceManager = new ResourceManager(VFS);\r\n this._enabled = enabled ?? true;\r\n this._activeRenderables = [];\r\n this._loadingScenes = {};\r\n this._screen = new ScreenAdapter();\r\n }\r\n /**\r\n * Exposes the instance of {@link ScriptingSystem}.\r\n */\r\n get scriptingSystem() {\r\n return this._scriptingSystem;\r\n }\r\n /**\r\n * Exposes the virtual file system used by the underlying {@link ScriptingSystem}'s registry.\r\n */\r\n get VFS() {\r\n return this._scriptingSystem.registry.VFS;\r\n }\r\n set VFS(vfs: VFS) {\r\n if (vfs !== this._resourceManager.VFS) {\r\n this._resourceManager.VFS?.close();\r\n this._resourceManager.VFS = vfs;\r\n this._scriptingSystem.registry.VFS = vfs;\r\n this.ensureBuiltinVFS();\r\n }\r\n }\r\n /**\r\n * Exposes the instance of {@link ResourceManager}.\r\n */\r\n get resourceManager() {\r\n return this._resourceManager;\r\n }\r\n /**\r\n * Exposes the active {@link ScreenAdapter}.\r\n */\r\n get screen() {\r\n return this._screen;\r\n }\r\n /** @internal */\r\n async init() {\r\n await this.ensureBuiltinVFS();\r\n }\r\n /**\r\n * Detaches all scripts from all hosts, if enabled.\r\n *\r\n * No-op when `enabled === false`.\r\n */\r\n detachAllScripts() {\r\n if (this._enabled) {\r\n this._scriptingSystem.detachAllScripts();\r\n }\r\n }\r\n /**\r\n * Loads a runtime script class from file\r\n * @param module - file path\r\n * @returns The runtime script class or null\r\n */\r\n async loadRuntimeScriptClass<T extends Host = Host>(\r\n module: string\r\n ): Promise<Nullable<{ url: string; cls: GenericConstructor<RuntimeScript<T>> }>> {\r\n return await this._scriptingSystem.loadRuntimeScriptClass(module);\r\n }\r\n /**\r\n * Attaches a script module to the given host, if enabled.\r\n *\r\n * When disabled, this method resolves to `null` without side effects.\r\n *\r\n * @typeParam T - Host type.\r\n * @param host - Host object to attach the script to.\r\n * @param module - Module identifier to resolve and load.\r\n * @returns The `RuntimeScript<T>` instance, or `null` if disabled or on failure.\r\n */\r\n async attachScript<T extends Host>(\r\n host: Nullable<T>,\r\n module: string,\r\n config?: Nullable<RuntimeScriptConfig>\r\n ) {\r\n return this._enabled ? await this._scriptingSystem.attachScript(host, module, config) : null;\r\n }\r\n /**\r\n * Detaches a script from a host, by module ID or instance, if enabled.\r\n *\r\n * No-op when disabled.\r\n *\r\n * @typeParam T - Host type.\r\n * @param host - Host to detach from.\r\n * @param idOrInstance - Target script by module ID or instance reference.\r\n */\r\n detachScript<T extends Host>(host: T, idOrInstance: string | RuntimeScript<T>) {\r\n if (this._enabled) {\r\n this._scriptingSystem.detachScript(host, idOrInstance);\r\n }\r\n }\r\n /**\r\n * Gets all scripts attached to a host.\r\n *\r\n * Delegates to {@link ScriptingSystem.getScriptObjects}.\r\n *\r\n * @typeParam T - Expected script type.\r\n * @param host - Host object to query.\r\n * @returns Script instances attached to the host, or an empty array.\r\n */\r\n getScriptObjects<T extends RuntimeScript<any>>(host: unknown) {\r\n return this._scriptingSystem.getScriptObjects(host) as T[];\r\n }\r\n /**\r\n * Ticks all attached scripts by calling their `onUpdate` hooks, if enabled.\r\n *\r\n * Delegates to {@link ScriptingSystem.update}. No-op when disabled.\r\n *\r\n * @param deltaTime - Time since last update in Seconds.\r\n * @param elapsedTime - Total elapsed time in Seconds.\r\n */\r\n update(deltaTime: number, elapsedTime: number) {\r\n if (this._enabled) {\r\n this._scriptingSystem.update(deltaTime, elapsedTime);\r\n }\r\n }\r\n async loadSceneFromFile(path: string) {\r\n path = this.VFS.normalizePath(path);\r\n if (!this._loadingScenes[path]) {\r\n this._loadingScenes[path] = this._loadScene(path);\r\n }\r\n return this._loadingScenes[path]!;\r\n }\r\n setRenderable(renderable: Nullable<IRenderable>, layer = 0, hook?: IRenderHook) {\r\n if (!this._activeRenderables[layer]) {\r\n this._activeRenderables[layer] = {\r\n renderable: new DRef<IRenderable>(null),\r\n hook: null\r\n };\r\n }\r\n this._activeRenderables[layer].hook = hook ?? null;\r\n this._activeRenderables[layer].renderable.set(renderable);\r\n }\r\n async readFile<T extends ReadOptions['encoding'] = 'binary'>(path: string, encoding?: T) {\r\n try {\r\n const content = await this.VFS.readFile(path, { encoding: encoding ?? 'binary' });\r\n return content as T extends 'binary' ? ArrayBuffer : string;\r\n } catch (err) {\r\n console.error(`Read file '${path}' failed: ${err}`);\r\n return null;\r\n }\r\n }\r\n async startup(\r\n startupScene?: Nullable<string>,\r\n splashScreen?: Nullable<string>,\r\n startupScript?: Nullable<string>\r\n ) {\r\n const splashScreenLayer = 9999;\r\n if (splashScreen) {\r\n const splashScreenScene = await this.loadSceneFromFile(splashScreen);\r\n if (splashScreenScene) {\r\n this.setRenderable(splashScreenScene, splashScreenLayer);\r\n }\r\n }\r\n if (startupScript) {\r\n const path =\r\n startupScript.toLowerCase().endsWith('.ts') || startupScript.toLowerCase().endsWith('.js')\r\n ? startupScript.slice(0, -3)\r\n : startupScript;\r\n await this.attachScript(null, path);\r\n }\r\n if (startupScene) {\r\n const scene = await this.loadSceneFromFile(startupScene);\r\n this.setRenderable(scene, 0);\r\n }\r\n this.setRenderable(null, splashScreenLayer);\r\n }\r\n render() {\r\n this._activeRenderables.forEach((info) => {\r\n const render = info.hook?.beforeRender\r\n ? (info.hook.beforeRender(info.renderable.get() ?? null) ?? true)\r\n : true;\r\n if (render) {\r\n info.renderable.get()?.render();\r\n }\r\n if (info.hook?.afterRender) {\r\n info.hook.afterRender(info.renderable.get() ?? null);\r\n }\r\n });\r\n }\r\n private async ensureBuiltinVFS() {\r\n if (!this._builtinsVFS) {\r\n this._builtinsVFS = await this.createBuiltinVFS();\r\n }\r\n this.VFS.unmount('/assets/@builtins');\r\n this.VFS.mount('/assets/@builtins', this._builtinsVFS);\r\n }\r\n private async createBuiltinVFS() {\r\n const fs = new MemoryFS();\r\n const shapeClsMap = {\r\n '/primitives/box.zmsh': BoxShape,\r\n '/primitives/sphere.zmsh': SphereShape,\r\n '/primitives/cylinder.zmsh': CylinderShape,\r\n '/primitives/plane.zmsh': PlaneShape,\r\n '/primitives/torus.zmsh': TorusShape,\r\n '/primitives/tetrahedron.zmsh': TetrahedronShape,\r\n '/primitives/capsule.zmsh': CapsuleShape,\r\n '/materials/unlit.zmtl': UnlitMaterial,\r\n '/materials/lambert.zmtl': LambertMaterial,\r\n '/materials/blinnphong.zmtl': BlinnMaterial,\r\n '/materials/pbr_metallic_roughness.zmtl': PBRMetallicRoughnessMaterial,\r\n '/materials/pbr_specular_glossiness.zmtl': PBRSpecularGlossinessMaterial,\r\n '/materials/sprite_std.zmtl': StandardSpriteMaterial\r\n } as const;\r\n for (const [key] of objectEntries(shapeClsMap)) {\r\n const obj = new shapeClsMap[key]();\r\n await this.writeSerializableObject(fs, 'Default', obj, key);\r\n obj.dispose();\r\n }\r\n fs.readOnly = true;\r\n return fs;\r\n }\r\n private async writeSerializableObject(VFS: VFS, type: string, obj: any, path: string) {\r\n try {\r\n const data = await this.resourceManager.serializeObject(obj);\r\n const content = JSON.stringify({ type, data }, null, 2);\r\n await VFS.writeFile(path, content, { encoding: 'utf8', create: true });\r\n } catch (err) {\r\n console.error(`Write file '${path}' failed: ${err}`);\r\n }\r\n }\r\n private async _loadScene(path: string) {\r\n try {\r\n const scene = await this._resourceManager.loadScene(path);\r\n if (scene) {\r\n const sceneScripts =\r\n scene.scripts.length > 0\r\n ? scene.scripts\r\n : scene.script\r\n ? [{ script: scene.script, config: scene.scriptConfig }]\r\n : [];\r\n for (const attachment of sceneScripts) {\r\n if (!attachment.script) {\r\n continue;\r\n }\r\n try {\r\n await this.attachScript(\r\n scene,\r\n attachment.script,\r\n (attachment.config ?? null) as RuntimeScriptConfig | null\r\n );\r\n } catch (err) {\r\n console.error(`Attach script failed: ${err}`);\r\n }\r\n }\r\n const nodes: (typeof scene.rootNode)[] = [];\r\n scene.rootNode.iterate((node) => {\r\n nodes.push(node);\r\n });\r\n const attachTasks = nodes.map(async (node) => {\r\n const attachments =\r\n node.scripts.length > 0\r\n ? node.scripts\r\n : node.script\r\n ? [{ script: node.script, config: node.scriptConfig }]\r\n : [];\r\n for (const attachment of attachments) {\r\n if (!attachment.script) {\r\n continue;\r\n }\r\n try {\r\n await this.attachScript(\r\n node,\r\n attachment.script,\r\n (attachment.config ?? null) as RuntimeScriptConfig | null\r\n );\r\n } catch (err) {\r\n console.error(`Attach script failed: ${err}`);\r\n }\r\n }\r\n });\r\n if (attachTasks.length > 0) {\r\n await Promise.allSettled(attachTasks);\r\n }\r\n }\r\n return scene;\r\n } catch (err) {\r\n console.error(`Load scene from '${path}' failed: ${err}`);\r\n return null;\r\n }\r\n }\r\n}\r\n"],"names":["Engine","_builtinsVFS","_scriptingSystem","_resourceManager","_enabled","_screen","_activeRenderables","_loadingScenes","VFS","scriptsRoot","enabled","HttpFS","ScriptingSystem","ResourceManager","ScreenAdapter","scriptingSystem","registry","vfs","close","ensureBuiltinVFS","resourceManager","screen","init","detachAllScripts","loadRuntimeScriptClass","module","attachScript","host","config","detachScript","idOrInstance","getScriptObjects","update","deltaTime","elapsedTime","loadSceneFromFile","path","normalizePath","_loadScene","setRenderable","renderable","layer","hook","DRef","set","readFile","encoding","content","err","console","error","startup","startupScene","splashScreen","startupScript","splashScreenLayer","splashScreenScene","toLowerCase","endsWith","slice","scene","render","forEach","info","beforeRender","get","afterRender","createBuiltinVFS","unmount","mount","fs","MemoryFS","shapeClsMap","BoxShape","SphereShape","CylinderShape","PlaneShape","TorusShape","TetrahedronShape","CapsuleShape","UnlitMaterial","LambertMaterial","BlinnMaterial","PBRMetallicRoughnessMaterial","PBRSpecularGlossinessMaterial","StandardSpriteMaterial","key","objectEntries","obj","writeSerializableObject","dispose","readOnly","type","data","serializeObject","JSON","stringify","writeFile","create","loadScene","sceneScripts","scripts","length","script","scriptConfig","attachment","nodes","rootNode","iterate","node","push","attachTasks","map","attachments","Promise","allSettled"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAiDA;;;;;;;;;;;;;;;;AAgBC,IACM,MAAMA,MAAAA,CAAAA;IACHC,YAAiC;IACjCC,gBAAkC;IAClCC,gBAAkC;IAClCC,QAAkB;IAClBC,OAAuB;IACrBC,kBAGN;IACIC,cAAkE;AAC1E;;;;;;AAMC,MACD,YAAYC,GAAS,EAAEC,WAAoB,EAAEC,OAAiB,CAAE;QAC9DF,GAAMA,GAAAA,GAAAA,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AAAA;AAC3B;AACF;YACA,OAAOnD,KAAAA;AACT,SAAA,CAAE,OAAOZ,GAAK,EAAA;YACZC,OAAQC,CAAAA,KAAK,CAAC,CAAC,iBAAiB,EAAEd,IAAK,CAAA,UAAU,EAAEY,GAAK,CAAA,CAAA,CAAA;YACxD,OAAO,IAAA;AACT;AACF;AACF;;;;"}
|
|
1
|
+
{"version":3,"file":"engine.js","sources":["../../src/app/engine.ts"],"sourcesContent":["import type { GenericConstructor, IDisposable, Nullable, ReadOptions } from '@zephyr3d/base';\r\nimport { MemoryFS, objectEntries } from '@zephyr3d/base';\r\nimport { DRef } from '@zephyr3d/base';\r\nimport { HttpFS, type VFS } from '@zephyr3d/base';\r\nimport { ScriptingSystem } from './scriptingsystem';\r\nimport type { Host } from './scriptingsystem';\r\nimport type { RuntimeScript, RuntimeScriptConfig } from './runtimescript';\r\nimport { ResourceManager } from '../utility/serialization/manager';\r\nimport type { Scene } from '../scene';\r\nimport {\r\n BoxShape,\r\n CapsuleShape,\r\n CylinderShape,\r\n PlaneShape,\r\n SphereShape,\r\n TetrahedronShape,\r\n TorusShape\r\n} from '../shapes';\r\nimport {\r\n BlinnMaterial,\r\n LambertMaterial,\r\n PBRMetallicRoughnessMaterial,\r\n PBRSpecularGlossinessMaterial,\r\n UnlitMaterial\r\n} from '../material';\r\nimport { StandardSpriteMaterial } from '../material/sprite_std';\r\nimport { ScreenAdapter } from './screen';\r\nimport { MSDFTextAtlasManager } from '../text/runtime';\r\n\r\n/**\r\n * Interface for objects that can be rendered.\r\n *\r\n * @public\r\n */\r\nexport interface IRenderable extends IDisposable {\r\n render(): void;\r\n}\r\n\r\nexport type RenderFunc = () => void;\r\n\r\n/**\r\n * Interface for render hooks to customize rendering behavior.\r\n *\r\n * @public\r\n */\r\nexport interface IRenderHook {\r\n // If presents, called before rendering the renderable. Return `false` to skip rendering.\r\n beforeRender?: (renderable: any) => boolean | void;\r\n // If presents, called after rendering the renderable.\r\n afterRender?: (renderable: any) => void;\r\n}\r\n\r\n/**\r\n * Core engine class managing scripting, serialization, and rendering.\r\n *\r\n * Responsibilities:\r\n * - Manages a {@link ScriptingSystem} for dynamic script attachment and lifecycle.\r\n * - Manages a {@link ResourceManager} for loading scenes and assets.\r\n * - Maintains a list of active renderable objects to be rendered each frame.\r\n * - Provides methods to attach/detach scripts, update scripts, load scenes, and read files.\r\n * - Supports enabling/disabling of runtime operations.\r\n *\r\n * @remarks\r\n * The engine can be configured with a virtual file system (VFS) and script root path.\r\n * It exposes methods to manage scripts on host objects, update scripts each frame,\r\n * load scenes from files, and render active objects.\r\n *\r\n * @public\r\n */\r\nexport class Engine {\r\n private _builtinsVFS: Nullable<MemoryFS>;\r\n private _scriptingSystem: ScriptingSystem;\r\n private _resourceManager: ResourceManager;\r\n private _msdfTextAtlasManager: MSDFTextAtlasManager;\r\n private _enabled: boolean;\r\n private _screen: ScreenAdapter;\r\n protected _activeRenderables: {\r\n renderable: Nullable<RenderFunc> | DRef<IRenderable>;\r\n hook: Nullable<IRenderHook>;\r\n }[];\r\n private _loadingScenes: Partial<Record<string, Promise<Nullable<Scene>>>>;\r\n /**\r\n * Creates a new runtime manager.\r\n *\r\n * @param VFS - Optional virtual file system passed to the internal {@link ScriptingSystem}.\r\n * @param scriptsRoot - Optional scripts root path within the VFS. Defaults as in `ScriptingSystem`.\r\n * @param enabled - Whether runtime operations are active. Defaults to `true`.\r\n */\r\n constructor(VFS?: VFS, scriptsRoot?: string, enabled?: boolean) {\r\n VFS = VFS ?? new HttpFS('./');\r\n this._builtinsVFS = null;\r\n this._scriptingSystem = new ScriptingSystem({ VFS, scriptsRoot });\r\n this._resourceManager = new ResourceManager(VFS);\r\n this._msdfTextAtlasManager = new MSDFTextAtlasManager();\r\n this._enabled = enabled ?? true;\r\n this._activeRenderables = [];\r\n this._loadingScenes = {};\r\n this._screen = new ScreenAdapter();\r\n }\r\n /**\r\n * Exposes the instance of {@link ScriptingSystem}.\r\n */\r\n get scriptingSystem() {\r\n return this._scriptingSystem;\r\n }\r\n /**\r\n * Exposes the virtual file system used by the underlying {@link ScriptingSystem}'s registry.\r\n */\r\n get VFS() {\r\n return this._scriptingSystem.registry.VFS;\r\n }\r\n /**\r\n * Replaces the virtual file system used by the engine.\r\n *\r\n * The previous resource manager VFS is closed, the scripting registry is updated,\r\n * and built-in assets are remounted on the new VFS.\r\n *\r\n * @param vfs - New virtual file system.\r\n */\r\n set VFS(vfs: VFS) {\r\n if (vfs !== this._resourceManager.VFS) {\r\n this._resourceManager.VFS?.close();\r\n this._resourceManager.VFS = vfs;\r\n this._scriptingSystem.registry.VFS = vfs;\r\n this.ensureBuiltinVFS();\r\n }\r\n }\r\n /**\r\n * Exposes the instance of {@link ResourceManager}.\r\n */\r\n get resourceManager() {\r\n return this._resourceManager;\r\n }\r\n /**\r\n * Exposes the shared runtime MSDF text atlas manager.\r\n */\r\n get msdfTextAtlasManager() {\r\n return this._msdfTextAtlasManager;\r\n }\r\n /**\r\n * Releases a loaded font asset from the resource cache and disposes its shared MSDF atlas textures.\r\n *\r\n * Existing scene nodes that still reference this font asset are not updated automatically.\r\n * Call this only after you have stopped using the font, or when you intentionally want it to rebuild later.\r\n *\r\n * @param font - The loaded font asset path to release.\r\n * @returns `true` if either the atlas cache or the font cache had an entry to remove.\r\n */\r\n releaseFontAsset(font: string) {\r\n const fontAsset = this._resourceManager.getFontAsset(font);\r\n if (!fontAsset) {\r\n return false;\r\n }\r\n const atlasReleased = this._msdfTextAtlasManager.releaseAtlas(fontAsset);\r\n const fontReleased = this._resourceManager.releaseFontAsset(fontAsset);\r\n return atlasReleased || fontReleased;\r\n }\r\n /**\r\n * Configures the MSDF atlas for a given font asset, creating or replacing the atlas as needed.\r\n *\r\n * This is useful to customize the glyph size, atlas page size, distance range, and padding for MSDF text rendering.\r\n * Existing scene nodes that reference this font asset will use the updated atlas automatically.\r\n *\r\n * @param font - The font asset path to configure the MSDF atlas for.\r\n * @param pageSize - The size of each atlas page in pixels (e.g., 512, 1024).\r\n * @param glyphSize - The size of each glyph in pixels (e.g., 32, 64).\r\n * @param distanceRange - The distance range for MSDF generation. Defaults to 4.\r\n * @param padding - The padding between glyphs in the atlas in pixels. Defaults to 2.\r\n * @returns `true` if the atlas was successfully configured, or `false` if the font asset was not found.\r\n *\r\n * @remarks\r\n * The font asset must be loaded and available in the resource manager for the atlas to be configured.\r\n */\r\n configureMSDFAtlas(\r\n font: string,\r\n pageSize: number,\r\n glyphSize: number,\r\n distanceRange?: number,\r\n padding?: number\r\n ) {\r\n const fontAsset = this._resourceManager.getFontAsset(font);\r\n if (!fontAsset) {\r\n console.warn(`Font asset '${font}' not found for MSDF atlas configuration.`);\r\n return false;\r\n }\r\n this._msdfTextAtlasManager.configureAtlas(fontAsset, pageSize, glyphSize, distanceRange, padding);\r\n return true;\r\n }\r\n /**\r\n * Exposes the active {@link ScreenAdapter}.\r\n */\r\n get screen() {\r\n return this._screen;\r\n }\r\n /** @internal */\r\n async init() {\r\n await this.ensureBuiltinVFS();\r\n }\r\n /**\r\n * Detaches all scripts from all hosts, if enabled.\r\n *\r\n * No-op when `enabled === false`.\r\n */\r\n detachAllScripts() {\r\n if (this._enabled) {\r\n this._scriptingSystem.detachAllScripts();\r\n }\r\n }\r\n /**\r\n * Loads a runtime script class from file\r\n * @param module - file path\r\n * @returns The runtime script class or null\r\n */\r\n async loadRuntimeScriptClass<T extends Host = Host>(\r\n module: string\r\n ): Promise<Nullable<{ url: string; cls: GenericConstructor<RuntimeScript<T>> }>> {\r\n return await this._scriptingSystem.loadRuntimeScriptClass(module);\r\n }\r\n /**\r\n * Attaches a script module to the given host, if enabled.\r\n *\r\n * When disabled, this method resolves to `null` without side effects.\r\n *\r\n * @typeParam T - Host type.\r\n * @param host - Host object to attach the script to.\r\n * @param module - Module identifier to resolve and load.\r\n * @param config - Optional configuration passed to the script instance.\r\n * @returns The `RuntimeScript<T>` instance, or `null` if disabled or on failure.\r\n */\r\n async attachScript<T extends Host>(\r\n host: Nullable<T>,\r\n module: string,\r\n config?: Nullable<RuntimeScriptConfig>\r\n ) {\r\n return this._enabled ? await this._scriptingSystem.attachScript(host, module, config) : null;\r\n }\r\n /**\r\n * Detaches a script from a host, by module ID or instance, if enabled.\r\n *\r\n * No-op when disabled.\r\n *\r\n * @typeParam T - Host type.\r\n * @param host - Host to detach from.\r\n * @param idOrInstance - Target script by module ID or instance reference.\r\n */\r\n detachScript<T extends Host>(host: T, idOrInstance: string | RuntimeScript<T>) {\r\n if (this._enabled) {\r\n this._scriptingSystem.detachScript(host, idOrInstance);\r\n }\r\n }\r\n /**\r\n * Gets all scripts attached to a host.\r\n *\r\n * Delegates to {@link ScriptingSystem.getScriptObjects}.\r\n *\r\n * @typeParam T - Expected script type.\r\n * @param host - Host object to query.\r\n * @returns Script instances attached to the host, or an empty array.\r\n */\r\n getScriptObjects<T extends RuntimeScript<any>>(host: unknown) {\r\n return this._scriptingSystem.getScriptObjects(host) as T[];\r\n }\r\n /**\r\n * Ticks all attached scripts by calling their `onUpdate` hooks, if enabled.\r\n *\r\n * @param deltaTime - Time since last update in Seconds.\r\n * @param elapsedTime - Total elapsed time in Seconds.\r\n */\r\n update(deltaTime: number, elapsedTime: number) {\r\n if (this._enabled) {\r\n this._scriptingSystem.update(deltaTime, elapsedTime);\r\n }\r\n }\r\n /**\r\n * Loads a scene from a file path.\r\n *\r\n * Concurrent requests for the same normalized path share the same loading promise.\r\n * Scripts declared on the scene and its nodes are attached after the scene is loaded.\r\n *\r\n * @param path - Scene file path in the current VFS.\r\n * @returns The loaded scene, or `null` when loading fails.\r\n */\r\n async loadSceneFromFile(path: string) {\r\n path = this.VFS.normalizePath(path);\r\n if (!this._loadingScenes[path]) {\r\n this._loadingScenes[path] = this._loadScene(path);\r\n }\r\n return this._loadingScenes[path]!;\r\n }\r\n /**\r\n * Sets or clears the renderable for a render layer.\r\n *\r\n * Passing `null` clears the layer. Object renderables are held through a strong reference wrapper,\r\n * while render functions are stored directly.\r\n *\r\n * @param renderable - Renderable object or render function to assign, or `null` to clear.\r\n * @param layer - Render layer index. Defaults to `0`.\r\n * @param hook - Optional render hook invoked before and after this layer renders.\r\n */\r\n setRenderable(renderable: Nullable<IRenderable | RenderFunc>, layer = 0, hook?: IRenderHook) {\r\n const entry = this._activeRenderables[layer];\r\n if (!entry) {\r\n this._activeRenderables[layer] = {\r\n renderable: renderable\r\n ? typeof renderable === 'function'\r\n ? renderable\r\n : new DRef<IRenderable>(renderable)\r\n : null,\r\n hook: hook ?? null\r\n };\r\n } else {\r\n if (entry.renderable) {\r\n if (entry.renderable instanceof DRef) {\r\n entry.renderable.dispose();\r\n }\r\n entry.renderable = null;\r\n }\r\n if (typeof renderable === 'function') {\r\n entry.renderable = renderable;\r\n } else if (renderable) {\r\n entry.renderable = new DRef<IRenderable>(renderable);\r\n }\r\n entry.hook = hook ?? null;\r\n }\r\n }\r\n /**\r\n * Reads a file from the current VFS.\r\n *\r\n * @typeParam T - Requested read encoding.\r\n * @param path - File path to read.\r\n * @param encoding - Optional read encoding. Defaults to `binary`.\r\n * @returns The file content, or `null` when the read fails.\r\n */\r\n async readFile<T extends ReadOptions['encoding'] = 'binary'>(path: string, encoding?: T) {\r\n try {\r\n const content = await this.VFS.readFile(path, { encoding: encoding ?? 'binary' });\r\n return content as T extends 'binary' ? ArrayBuffer : string;\r\n } catch (err) {\r\n console.error(`Read file '${path}' failed: ${err}`);\r\n return null;\r\n }\r\n }\r\n /**\r\n * Starts the runtime by optionally showing a splash screen, running a startup script,\r\n * and loading the startup scene.\r\n *\r\n * @param startupScene - Optional scene path rendered on layer `0` after startup completes.\r\n * @param splashScreen - Optional scene path rendered on a temporary splash layer during startup.\r\n * @param startupScript - Optional startup script module path. A trailing `.ts` or `.js`\r\n * extension is removed before loading.\r\n */\r\n async startup(\r\n startupScene?: Nullable<string>,\r\n splashScreen?: Nullable<string>,\r\n startupScript?: Nullable<string>\r\n ) {\r\n const splashScreenLayer = 9999;\r\n if (splashScreen) {\r\n const splashScreenScene = await this.loadSceneFromFile(splashScreen);\r\n if (splashScreenScene) {\r\n this.setRenderable(splashScreenScene, splashScreenLayer);\r\n }\r\n }\r\n if (startupScript) {\r\n const path =\r\n startupScript.toLowerCase().endsWith('.ts') || startupScript.toLowerCase().endsWith('.js')\r\n ? startupScript.slice(0, -3)\r\n : startupScript;\r\n await this.attachScript(null, path);\r\n }\r\n if (startupScene) {\r\n const scene = await this.loadSceneFromFile(startupScene);\r\n this.setRenderable(scene, 0);\r\n }\r\n this.setRenderable(null, splashScreenLayer);\r\n }\r\n /**\r\n * Renders all active render layers.\r\n *\r\n * Each layer's `beforeRender` hook can return `false` to skip rendering that layer.\r\n * The `afterRender` hook is invoked after the render attempt.\r\n */\r\n render() {\r\n this._activeRenderables.forEach((info) => {\r\n if (!info.renderable) {\r\n return;\r\n }\r\n const render = info.hook?.beforeRender\r\n ? (info.hook.beforeRender(\r\n typeof info.renderable === 'function' ? info.renderable : info.renderable.get()\r\n ) ?? true)\r\n : true;\r\n if (render) {\r\n if (typeof info.renderable === 'function') {\r\n info.renderable();\r\n } else {\r\n info.renderable.get()?.render();\r\n }\r\n }\r\n if (info.hook?.afterRender) {\r\n info.hook.afterRender(\r\n typeof info.renderable === 'function' ? info.renderable : info.renderable.get()\r\n );\r\n }\r\n });\r\n }\r\n private async ensureBuiltinVFS() {\r\n if (!this._builtinsVFS) {\r\n this._builtinsVFS = await this.createBuiltinVFS();\r\n }\r\n this.VFS.unmount('/assets/@builtins');\r\n this.VFS.mount('/assets/@builtins', this._builtinsVFS);\r\n }\r\n private async createBuiltinVFS() {\r\n const fs = new MemoryFS();\r\n const shapeClsMap = {\r\n '/primitives/box.zmsh': BoxShape,\r\n '/primitives/sphere.zmsh': SphereShape,\r\n '/primitives/cylinder.zmsh': CylinderShape,\r\n '/primitives/plane.zmsh': PlaneShape,\r\n '/primitives/torus.zmsh': TorusShape,\r\n '/primitives/tetrahedron.zmsh': TetrahedronShape,\r\n '/primitives/capsule.zmsh': CapsuleShape,\r\n '/materials/unlit.zmtl': UnlitMaterial,\r\n '/materials/lambert.zmtl': LambertMaterial,\r\n '/materials/blinnphong.zmtl': BlinnMaterial,\r\n '/materials/pbr_metallic_roughness.zmtl': PBRMetallicRoughnessMaterial,\r\n '/materials/pbr_specular_glossiness.zmtl': PBRSpecularGlossinessMaterial,\r\n '/materials/sprite_std.zmtl': StandardSpriteMaterial\r\n } as const;\r\n for (const [key] of objectEntries(shapeClsMap)) {\r\n const obj = new shapeClsMap[key]();\r\n await this.writeSerializableObject(fs, 'Default', obj, key);\r\n obj.dispose();\r\n }\r\n fs.readOnly = true;\r\n return fs;\r\n }\r\n private async writeSerializableObject(VFS: VFS, type: string, obj: any, path: string) {\r\n try {\r\n const data = await this.resourceManager.serializeObject(obj);\r\n const content = JSON.stringify({ type, data }, null, 2);\r\n await VFS.writeFile(path, content, { encoding: 'utf8', create: true });\r\n } catch (err) {\r\n console.error(`Write file '${path}' failed: ${err}`);\r\n }\r\n }\r\n private async _loadScene(path: string) {\r\n try {\r\n const scene = await this._resourceManager.loadScene(path);\r\n if (scene) {\r\n const sceneScripts =\r\n scene.scripts.length > 0\r\n ? scene.scripts\r\n : scene.script\r\n ? [{ script: scene.script, config: scene.scriptConfig }]\r\n : [];\r\n for (const attachment of sceneScripts) {\r\n if (!attachment.script) {\r\n continue;\r\n }\r\n try {\r\n await this.attachScript(\r\n scene,\r\n attachment.script,\r\n (attachment.config ?? null) as RuntimeScriptConfig | null\r\n );\r\n } catch (err) {\r\n console.error(`Attach script failed: ${err}`);\r\n }\r\n }\r\n const nodes: (typeof scene.rootNode)[] = [];\r\n scene.rootNode.iterate((node) => {\r\n nodes.push(node);\r\n });\r\n const attachTasks = nodes.map(async (node) => {\r\n const attachments =\r\n node.scripts.length > 0\r\n ? node.scripts\r\n : node.script\r\n ? [{ script: node.script, config: node.scriptConfig }]\r\n : [];\r\n for (const attachment of attachments) {\r\n if (!attachment.script) {\r\n continue;\r\n }\r\n try {\r\n await this.attachScript(\r\n node,\r\n attachment.script,\r\n (attachment.config ?? null) as RuntimeScriptConfig | null\r\n );\r\n } catch (err) {\r\n console.error(`Attach script failed: ${err}`);\r\n }\r\n }\r\n });\r\n if (attachTasks.length > 0) {\r\n await Promise.allSettled(attachTasks);\r\n }\r\n }\r\n return scene;\r\n } catch (err) {\r\n console.error(`Load scene from '${path}' failed: ${err}`);\r\n return null;\r\n }\r\n }\r\n}\r\n\r\nexport { MSDFTextAtlasManager };\r\n"],"names":["Engine","_builtinsVFS","_scriptingSystem","_resourceManager","_msdfTextAtlasManager","_enabled","_screen","_activeRenderables","_loadingScenes","VFS","scriptsRoot","enabled","HttpFS","ScriptingSystem","ResourceManager","MSDFTextAtlasManager","ScreenAdapter","scriptingSystem","registry","vfs","close","ensureBuiltinVFS","resourceManager","msdfTextAtlasManager","releaseFontAsset","font","fontAsset","getFontAsset","atlasReleased","releaseAtlas","fontReleased","configureMSDFAtlas","pageSize","glyphSize","distanceRange","padding","console","warn","configureAtlas","screen","init","detachAllScripts","loadRuntimeScriptClass","module","attachScript","host","config","detachScript","idOrInstance","getScriptObjects","update","deltaTime","elapsedTime","loadSceneFromFile","path","normalizePath","_loadScene","setRenderable","renderable","layer","hook","entry","DRef","dispose","readFile","encoding","content","err","error","startup","startupScene","splashScreen","startupScript","splashScreenLayer","splashScreenScene","toLowerCase","endsWith","slice","scene","render","forEach","info","beforeRender","get","afterRender","createBuiltinVFS","unmount","mount","fs","MemoryFS","shapeClsMap","BoxShape","SphereShape","CylinderShape","PlaneShape","TorusShape","TetrahedronShape","CapsuleShape","UnlitMaterial","LambertMaterial","BlinnMaterial","PBRMetallicRoughnessMaterial","PBRSpecularGlossinessMaterial","StandardSpriteMaterial","key","objectEntries","obj","writeSerializableObject","readOnly","type","data","serializeObject","JSON","stringify","writeFile","create","loadScene","sceneScripts","scripts","length","script","scriptConfig","attachment","nodes","rootNode","iterate","node","push","attachTasks","map","attachments","Promise","allSettled"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAoDA;;;;;;;;;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