@zylem/game-lib 0.5.1 → 0.6.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/dist/behaviors.d.ts +834 -88
- package/dist/behaviors.js +1166 -355
- package/dist/behaviors.js.map +1 -1
- package/dist/blueprints-Cq3Ko6_G.d.ts +26 -0
- package/dist/{camera-Dk-fOVZE.d.ts → camera-CeJPAgGg.d.ts} +20 -46
- package/dist/camera.d.ts +2 -2
- package/dist/camera.js +340 -129
- package/dist/camera.js.map +1 -1
- package/dist/{core-C2mjetAd.d.ts → core-bO8TzV7u.d.ts} +113 -44
- package/dist/core.d.ts +8 -5
- package/dist/core.js +6180 -3678
- package/dist/core.js.map +1 -1
- package/dist/entities-DvByhMGU.d.ts +306 -0
- package/dist/entities.d.ts +5 -267
- package/dist/entities.js +3239 -1893
- package/dist/entities.js.map +1 -1
- package/dist/entity-Bq_eNEDI.d.ts +28 -0
- package/dist/entity-types-DAu8sGJH.d.ts +26 -0
- package/dist/main.d.ts +147 -31
- package/dist/main.js +9364 -5479
- package/dist/main.js.map +1 -1
- package/dist/{stage-CrmY7V0i.d.ts → stage-types-Bd-KtcYT.d.ts} +149 -61
- package/dist/stage.d.ts +42 -20
- package/dist/stage.js +4103 -2027
- package/dist/stage.js.map +1 -1
- package/dist/world-C8tQ7Plj.d.ts +774 -0
- package/package.json +2 -1
- package/dist/entity-bQElAdpo.d.ts +0 -347
- package/dist/entity-spawner-DNnLYnZq.d.ts +0 -11
package/dist/entities.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/lib/entities/box.ts","../src/lib/entities/entity.ts","../src/lib/systems/transformable.system.ts","../src/lib/core/flags.ts","../src/lib/core/base-node.ts","../src/lib/entities/builder.ts","../src/lib/collision/collision-builder.ts","../src/lib/graphics/mesh.ts","../src/lib/graphics/material.ts","../src/lib/core/utility/strings.ts","../src/lib/graphics/shaders/fragment/stars.glsl","../src/lib/graphics/shaders/fragment/fire.glsl","../src/lib/graphics/shaders/fragment/standard.glsl","../src/lib/graphics/shaders/fragment/debug.glsl","../src/lib/graphics/shaders/vertex/object-shader.glsl","../src/lib/graphics/shaders/vertex/debug.glsl","../src/lib/core/preset-shader.ts","../src/lib/entities/delegates/debug.ts","../src/lib/entities/delegates/loader.ts","../src/lib/entities/create.ts","../src/lib/entities/sphere.ts","../src/lib/entities/sprite.ts","../src/lib/entities/plane.ts","../src/lib/graphics/geometries/XZPlaneGeometry.ts","../src/lib/entities/zone.ts","../src/lib/game/game-state.ts","../src/lib/entities/actor.ts","../src/lib/core/entity-asset-loader.ts","../src/lib/entities/delegates/animation.ts","../src/lib/entities/text.ts","../src/lib/entities/rect.ts"],"sourcesContent":["import { ColliderDesc } from '@dimforge/rapier3d-compat';\nimport { BoxGeometry, Color } from 'three';\nimport { Vector3 } from 'three';\nimport { BaseNode } from '../core/base-node';\nimport { GameEntityOptions, GameEntity } from './entity';\nimport { EntityBuilder } from './builder';\nimport { EntityCollisionBuilder } from './builder';\nimport { EntityMeshBuilder } from './builder';\nimport { DebugDelegate } from './delegates/debug';\nimport { createEntity } from './create';\n\ntype ZylemBoxOptions = GameEntityOptions;\n\nconst boxDefaults: ZylemBoxOptions = {\n\tsize: new Vector3(1, 1, 1),\n\tposition: new Vector3(0, 0, 0),\n\tcollision: {\n\t\tstatic: false,\n\t},\n\tmaterial: {\n\t\tcolor: new Color('#ffffff'),\n\t\tshader: 'standard'\n\t},\n};\n\nexport class BoxCollisionBuilder extends EntityCollisionBuilder {\n\tcollider(options: GameEntityOptions): ColliderDesc {\n\t\tconst size = options.size || new Vector3(1, 1, 1);\n\t\tconst half = { x: size.x / 2, y: size.y / 2, z: size.z / 2 };\n\t\tlet colliderDesc = ColliderDesc.cuboid(half.x, half.y, half.z);\n\t\treturn colliderDesc;\n\t}\n}\n\nexport class BoxMeshBuilder extends EntityMeshBuilder {\n\tbuild(options: GameEntityOptions): BoxGeometry {\n\t\tconst size = options.size ?? new Vector3(1, 1, 1);\n\t\treturn new BoxGeometry(size.x, size.y, size.z);\n\t}\n}\n\nexport class BoxBuilder extends EntityBuilder<ZylemBox, ZylemBoxOptions> {\n\tprotected createEntity(options: Partial<ZylemBoxOptions>): ZylemBox {\n\t\treturn new ZylemBox(options);\n\t}\n}\n\nexport const BOX_TYPE = Symbol('Box');\n\nexport class ZylemBox extends GameEntity<ZylemBoxOptions> {\n\tstatic type = BOX_TYPE;\n\n\tconstructor(options?: ZylemBoxOptions) {\n\t\tsuper();\n\t\tthis.options = { ...boxDefaults, ...options };\n\t}\n\n\tbuildInfo(): Record<string, any> {\n\t\tconst delegate = new DebugDelegate(this as any);\n\t\tconst baseInfo = delegate.buildDebugInfo();\n\n\t\tconst { x: sizeX, y: sizeY, z: sizeZ } = this.options.size ?? { x: 1, y: 1, z: 1 };\n\t\treturn {\n\t\t\t...baseInfo,\n\t\t\ttype: String(ZylemBox.type),\n\t\t\tsize: `${sizeX}, ${sizeY}, ${sizeZ}`,\n\t\t};\n\t}\n}\n\ntype BoxOptions = BaseNode | ZylemBoxOptions;\n\nexport async function box(...args: Array<BoxOptions>): Promise<ZylemBox> {\n\treturn createEntity<ZylemBox, ZylemBoxOptions>({\n\t\targs,\n\t\tdefaultConfig: boxDefaults,\n\t\tEntityClass: ZylemBox,\n\t\tBuilderClass: BoxBuilder,\n\t\tMeshBuilderClass: BoxMeshBuilder,\n\t\tCollisionBuilderClass: BoxCollisionBuilder,\n\t\tentityType: ZylemBox.type\n\t});\n}","import { Mesh, Material, ShaderMaterial, Group, Color } from \"three\";\nimport { Collider, ColliderDesc, RigidBody, RigidBodyDesc } from \"@dimforge/rapier3d-compat\";\nimport { position, rotation, scale } from \"../systems/transformable.system\";\nimport { Vec3 } from \"../core/vector\";\nimport { MaterialBuilder, MaterialOptions } from \"../graphics/material\";\nimport { CollisionOptions } from \"../collision/collision\";\nimport { BaseNode } from \"../core/base-node\";\nimport { DestroyContext, SetupContext, UpdateContext, LoadedContext, CleanupContext } from \"../core/base-node-life-cycle\";\nimport type { EntityMeshBuilder, EntityCollisionBuilder } from \"./builder\";\nimport { Behavior } from \"../actions/behaviors/behavior\";\n\nexport interface LifeCycleDelegate<U> {\n\tsetup?: ((params: SetupContext<U>) => void)[];\n\tupdate?: ((params: UpdateContext<U>) => void)[];\n\tdestroy?: ((params: DestroyContext<U>) => void)[];\n}\n\nexport interface CollisionContext<T, O extends GameEntityOptions, TGlobals extends Record<string, unknown> = any> {\n\tentity: T;\n\tother: GameEntity<O>;\n\tglobals: TGlobals;\n}\n\nexport type BehaviorContext<T, O extends GameEntityOptions> =\n\tSetupContext<T, O> |\n\tUpdateContext<T, O> |\n\tCollisionContext<T, O> |\n\tDestroyContext<T, O>;\n\nexport type BehaviorCallback<T, O extends GameEntityOptions> = (params: BehaviorContext<T, O>) => void;\n\nexport interface CollisionDelegate<T, O extends GameEntityOptions> {\n\tcollision?: ((params: CollisionContext<T, O>) => void)[];\n}\n\nexport type IBuilder<BuilderOptions = any> = {\n\tpreBuild: (options: BuilderOptions) => BuilderOptions;\n\tbuild: (options: BuilderOptions) => BuilderOptions;\n\tpostBuild: (options: BuilderOptions) => BuilderOptions;\n}\n\nexport type GameEntityOptions = {\n\tname?: string;\n\tcolor?: Color;\n\tsize?: Vec3;\n\tposition?: Vec3;\n\tbatched?: boolean;\n\tcollision?: Partial<CollisionOptions>;\n\tmaterial?: Partial<MaterialOptions>;\n\tcustom?: { [key: string]: any };\n\tcollisionType?: string;\n\tcollisionGroup?: string;\n\tcollisionFilter?: string[];\n\t_builders?: {\n\t\tmeshBuilder?: IBuilder | EntityMeshBuilder | null;\n\t\tcollisionBuilder?: IBuilder | EntityCollisionBuilder | null;\n\t\tmaterialBuilder?: MaterialBuilder | null;\n\t};\n}\n\nexport abstract class GameEntityLifeCycle {\n\tabstract _setup(params: SetupContext<this>): void;\n\tabstract _update(params: UpdateContext<this>): void;\n\tabstract _destroy(params: DestroyContext<this>): void;\n}\n\nexport interface EntityDebugInfo {\n\tbuildInfo: () => Record<string, string>;\n}\n\nexport type BehaviorCallbackType = 'setup' | 'update' | 'destroy' | 'collision';\n\nexport class GameEntity<O extends GameEntityOptions> extends BaseNode<O> implements\n\tGameEntityLifeCycle,\n\tEntityDebugInfo {\n\tpublic behaviors: Behavior[] = [];\n\tpublic group: Group | undefined;\n\tpublic mesh: Mesh | undefined;\n\tpublic materials: Material[] | undefined;\n\tpublic bodyDesc: RigidBodyDesc | null = null;\n\tpublic body: RigidBody | null = null;\n\tpublic colliderDesc: ColliderDesc | undefined;\n\tpublic collider: Collider | undefined;\n\tpublic custom: Record<string, any> = {};\n\n\tpublic debugInfo: Record<string, any> = {};\n\tpublic debugMaterial: ShaderMaterial | undefined;\n\n\tpublic lifeCycleDelegate: LifeCycleDelegate<O> = {\n\t\tsetup: [],\n\t\tupdate: [],\n\t\tdestroy: [],\n\t};\n\tpublic collisionDelegate: CollisionDelegate<this, O> = {\n\t\tcollision: [],\n\t};\n\tpublic collisionType?: string;\n\n\tpublic behaviorCallbackMap: Record<BehaviorCallbackType, BehaviorCallback<this, O>[]> = {\n\t\tsetup: [],\n\t\tupdate: [],\n\t\tdestroy: [],\n\t\tcollision: [],\n\t};\n\n\tconstructor() {\n\t\tsuper();\n\t}\n\n\tpublic create(): this {\n\t\tconst { position: setupPosition } = this.options;\n\t\tconst { x, y, z } = setupPosition || { x: 0, y: 0, z: 0 };\n\t\tthis.behaviors = [\n\t\t\t{ component: position, values: { x, y, z } },\n\t\t\t{ component: scale, values: { x: 0, y: 0, z: 0 } },\n\t\t\t{ component: rotation, values: { x: 0, y: 0, z: 0, w: 0 } },\n\t\t];\n\t\tthis.name = this.options.name || '';\n\t\treturn this;\n\t}\n\n\tpublic onSetup(...callbacks: ((params: SetupContext<this>) => void)[]): this {\n\t\tconst combineCallbacks = [...(this.lifeCycleDelegate.setup ?? []), ...callbacks];\n\t\tthis.lifeCycleDelegate = {\n\t\t\t...this.lifeCycleDelegate,\n\t\t\tsetup: combineCallbacks as unknown as ((params: SetupContext<O>) => void)[]\n\t\t};\n\t\treturn this;\n\t}\n\n\tpublic onUpdate(...callbacks: ((params: UpdateContext<this>) => void)[]): this {\n\t\tconst combineCallbacks = [...(this.lifeCycleDelegate.update ?? []), ...callbacks];\n\t\tthis.lifeCycleDelegate = {\n\t\t\t...this.lifeCycleDelegate,\n\t\t\tupdate: combineCallbacks as unknown as ((params: UpdateContext<O>) => void)[]\n\t\t};\n\t\treturn this;\n\t}\n\n\tpublic onDestroy(...callbacks: ((params: DestroyContext<this>) => void)[]): this {\n\t\tthis.lifeCycleDelegate = {\n\t\t\t...this.lifeCycleDelegate,\n\t\t\tdestroy: callbacks.length > 0 ? callbacks as unknown as ((params: DestroyContext<O>) => void)[] : undefined\n\t\t};\n\t\treturn this;\n\t}\n\n\tpublic onCollision(...callbacks: ((params: CollisionContext<this, O>) => void)[]): this {\n\t\tthis.collisionDelegate = {\n\t\t\tcollision: callbacks.length > 0 ? callbacks : undefined\n\t\t};\n\t\treturn this;\n\t}\n\n\tpublic _setup(params: SetupContext<this>): void {\n\t\tthis.behaviorCallbackMap.setup.forEach(callback => {\n\t\t\tcallback({ ...params, me: this });\n\t\t});\n\t\tif (this.lifeCycleDelegate.setup?.length) {\n\t\t\tconst callbacks = this.lifeCycleDelegate.setup;\n\t\t\tcallbacks.forEach(callback => {\n\t\t\t\tcallback({ ...params, me: this as unknown as O });\n\t\t\t});\n\t\t}\n\t}\n\n\tprotected async _loaded(_params: LoadedContext<this>): Promise<void> { }\n\n\tpublic _update(params: UpdateContext<this>): void {\n\t\tthis.updateMaterials(params);\n\t\tif (this.lifeCycleDelegate.update?.length) {\n\t\t\tconst callbacks = this.lifeCycleDelegate.update;\n\t\t\tcallbacks.forEach(callback => {\n\t\t\t\tcallback({ ...params, me: this as unknown as O });\n\t\t\t});\n\t\t}\n\t\tthis.behaviorCallbackMap.update.forEach(callback => {\n\t\t\tcallback({ ...params, me: this });\n\t\t});\n\t}\n\n\tpublic _destroy(params: DestroyContext<this>): void {\n\t\tif (this.lifeCycleDelegate.destroy?.length) {\n\t\t\tconst callbacks = this.lifeCycleDelegate.destroy;\n\t\t\tcallbacks.forEach(callback => {\n\t\t\t\tcallback({ ...params, me: this as unknown as O });\n\t\t\t});\n\t\t}\n\t\tthis.behaviorCallbackMap.destroy.forEach(callback => {\n\t\t\tcallback({ ...params, me: this });\n\t\t});\n\t}\n\n\tprotected async _cleanup(_params: CleanupContext<this>): Promise<void> { }\n\n\tpublic _collision(other: GameEntity<O>, globals?: any): void {\n\t\tif (this.collisionDelegate.collision?.length) {\n\t\t\tconst callbacks = this.collisionDelegate.collision;\n\t\t\tcallbacks.forEach(callback => {\n\t\t\t\tcallback({ entity: this, other, globals });\n\t\t\t});\n\t\t}\n\t\tthis.behaviorCallbackMap.collision.forEach(callback => {\n\t\t\tcallback({ entity: this, other, globals });\n\t\t});\n\t}\n\n\tpublic addBehavior(\n\t\tbehaviorCallback: ({ type: BehaviorCallbackType, handler: any })\n\t): this {\n\t\tconst handler = behaviorCallback.handler as unknown as BehaviorCallback<this, O>;\n\t\tif (handler) {\n\t\t\tthis.behaviorCallbackMap[behaviorCallback.type].push(handler);\n\t\t}\n\t\treturn this;\n\t}\n\n\tpublic addBehaviors(\n\t\tbehaviorCallbacks: ({ type: BehaviorCallbackType, handler: any })[]\n\t): this {\n\t\tbehaviorCallbacks.forEach(callback => {\n\t\t\tconst handler = callback.handler as unknown as BehaviorCallback<this, O>;\n\t\t\tif (handler) {\n\t\t\t\tthis.behaviorCallbackMap[callback.type].push(handler);\n\t\t\t}\n\t\t});\n\t\treturn this;\n\t}\n\n\tprotected updateMaterials(params: any) {\n\t\tif (!this.materials?.length) {\n\t\t\treturn;\n\t\t}\n\t\tfor (const material of this.materials) {\n\t\t\tif (material instanceof ShaderMaterial) {\n\t\t\t\tif (material.uniforms) {\n\t\t\t\t\tmaterial.uniforms.iTime && (material.uniforms.iTime.value += params.delta);\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\n\tpublic buildInfo(): Record<string, string> {\n\t\tconst info: Record<string, string> = {};\n\t\tinfo.name = this.name;\n\t\tinfo.uuid = this.uuid;\n\t\tinfo.eid = this.eid.toString();\n\t\treturn info;\n\t}\n}\n","import {\n\tdefineSystem,\n\tdefineQuery,\n\tdefineComponent,\n\tTypes,\n} from 'bitecs';\nimport { Quaternion } from 'three';\nimport { StageEntity } from '../interfaces/entity';\nimport RAPIER from '@dimforge/rapier3d-compat';\n\nexport type StageSystem = {\n\t_childrenMap: Map<number, StageEntity & { body: RAPIER.RigidBody }>;\n}\n\nexport const position = defineComponent({\n\tx: Types.f32,\n\ty: Types.f32,\n\tz: Types.f32\n});\n\nexport const rotation = defineComponent({\n\tx: Types.f32,\n\ty: Types.f32,\n\tz: Types.f32,\n\tw: Types.f32\n});\n\nexport const scale = defineComponent({\n\tx: Types.f32,\n\ty: Types.f32,\n\tz: Types.f32\n});\n\nexport default function createTransformSystem(stage: StageSystem) {\n\tconst transformQuery = defineQuery([position, rotation]);\n\tconst stageEntities = stage._childrenMap;\n\treturn defineSystem((world) => {\n\t\tconst entities = transformQuery(world);\n\t\tif (stageEntities === undefined) {\n\t\t\treturn world;\n\t\t};\n\t\tfor (const [key, value] of stageEntities) {\n\t\t\tconst id = entities[key];\n\t\t\tconst stageEntity = value;\n\t\t\tif (stageEntity === undefined || !stageEntity?.body || stageEntity.markedForRemoval) {\n\t\t\t\tcontinue;\n\t\t\t}\n\t\t\tconst { x, y, z } = stageEntity.body.translation();\n\t\t\tposition.x[id] = x;\n\t\t\tposition.y[id] = y;\n\t\t\tposition.z[id] = z;\n\t\t\tif (stageEntity.group) {\n\t\t\t\tstageEntity.group.position.set(position.x[id], position.y[id], position.z[id]);\n\t\t\t} else if (stageEntity.mesh) {\n\t\t\t\tstageEntity.mesh.position.set(position.x[id], position.y[id], position.z[id]);\n\t\t\t}\n\t\t\tif (stageEntity.controlledRotation) {\n\t\t\t\tcontinue;\n\t\t\t}\n\t\t\tconst { x: rx, y: ry, z: rz, w: rw } = stageEntity.body.rotation();\n\t\t\trotation.x[id] = rx;\n\t\t\trotation.y[id] = ry;\n\t\t\trotation.z[id] = rz;\n\t\t\trotation.w[id] = rw;\n\t\t\tconst newRotation = new Quaternion(\n\t\t\t\trotation.x[id],\n\t\t\t\trotation.y[id],\n\t\t\t\trotation.z[id],\n\t\t\t\trotation.w[id]\n\t\t\t);\n\t\t\tif (stageEntity.group) {\n\t\t\t\tstageEntity.group.setRotationFromQuaternion(newRotation);\n\t\t\t} else if (stageEntity.mesh) {\n\t\t\t\tstageEntity.mesh.setRotationFromQuaternion(newRotation);\n\t\t\t}\n\t\t}\n\n\t\treturn world;\n\t});\n}","/** Vite build flags */\nexport const DEBUG_FLAG = import.meta.env.VITE_DEBUG_FLAG === 'true';","import {\n\tCleanupContext,\n\tCleanupFunction,\n\tDestroyContext,\n\tDestroyFunction,\n\tLoadedContext,\n\tLoadedFunction,\n\tSetupContext,\n\tSetupFunction,\n\tUpdateContext,\n\tUpdateFunction,\n} from \"./base-node-life-cycle\";\nimport { DEBUG_FLAG } from \"./flags\";\nimport { nanoid } from \"nanoid\";\nimport { NodeInterface } from \"./node-interface\";\n\nexport type BaseNodeOptions<T = any> = BaseNode | Partial<T>;\n\nexport abstract class BaseNode<Options = any, T = any> implements NodeInterface {\n\tprotected parent: NodeInterface | null = null;\n\tprotected children: NodeInterface[] = [];\n\tpublic options: Options;\n\tpublic eid: number = 0;\n\tpublic uuid: string = '';\n\tpublic name: string = '';\n\tpublic markedForRemoval: boolean = false;\n\n\tsetup: SetupFunction<this> = () => { };\n\tloaded: LoadedFunction<this> = () => { };\n\tupdate: UpdateFunction<this> = () => { };\n\tdestroy: DestroyFunction<this> = () => { };\n\tcleanup: CleanupFunction<this> = () => { };\n\n\tconstructor(args: BaseNodeOptions[] = []) {\n\t\tconst options = args\n\t\t\t.filter(arg => !(arg instanceof BaseNode))\n\t\t\t.reduce((acc, opt) => ({ ...acc, ...opt }), {});\n\t\tthis.options = options as Options;\n\t\tthis.uuid = nanoid();\n\t}\n\n\tpublic setParent(parent: NodeInterface | null): void {\n\t\tthis.parent = parent;\n\t}\n\n\tpublic getParent(): NodeInterface | null {\n\t\treturn this.parent;\n\t}\n\n\tpublic add(baseNode: NodeInterface): void {\n\t\tthis.children.push(baseNode);\n\t\tbaseNode.setParent(this);\n\t}\n\n\tpublic remove(baseNode: NodeInterface): void {\n\t\tconst index = this.children.indexOf(baseNode);\n\t\tif (index !== -1) {\n\t\t\tthis.children.splice(index, 1);\n\t\t\tbaseNode.setParent(null);\n\t\t}\n\t}\n\n\tpublic getChildren(): NodeInterface[] {\n\t\treturn this.children;\n\t}\n\n\tpublic isComposite(): boolean {\n\t\treturn this.children.length > 0;\n\t}\n\n\tpublic abstract create(): T;\n\n\tprotected abstract _setup(params: SetupContext<this>): void;\n\n\tprotected abstract _loaded(params: LoadedContext<this>): Promise<void>;\n\n\tprotected abstract _update(params: UpdateContext<this>): void;\n\n\tprotected abstract _destroy(params: DestroyContext<this>): void;\n\n\tprotected abstract _cleanup(params: CleanupContext<this>): Promise<void>;\n\n\tpublic nodeSetup(params: SetupContext<this>) {\n\t\tif (DEBUG_FLAG) { /** */ }\n\t\tthis.markedForRemoval = false;\n\t\tif (typeof this._setup === 'function') {\n\t\t\tthis._setup(params);\n\t\t}\n\t\tif (this.setup) {\n\t\t\tthis.setup(params);\n\t\t}\n\t\tthis.children.forEach(child => child.nodeSetup(params));\n\t}\n\n\tpublic nodeUpdate(params: UpdateContext<this>): void {\n\t\tif (this.markedForRemoval) {\n\t\t\treturn;\n\t\t}\n\t\tif (typeof this._update === 'function') {\n\t\t\tthis._update(params);\n\t\t}\n\t\tif (this.update) {\n\t\t\tthis.update(params);\n\t\t}\n\t\tthis.children.forEach(child => child.nodeUpdate(params));\n\t}\n\n\tpublic nodeDestroy(params: DestroyContext<this>): void {\n\t\tthis.children.forEach(child => child.nodeDestroy(params));\n\t\tif (this.destroy) {\n\t\t\tthis.destroy(params);\n\t\t}\n\t\tif (typeof this._destroy === 'function') {\n\t\t\tthis._destroy(params);\n\t\t}\n\t\tthis.markedForRemoval = true;\n\t}\n\n\tpublic getOptions(): Options {\n\t\treturn this.options;\n\t}\n\n\tpublic setOptions(options: Partial<Options>): void {\n\t\tthis.options = { ...this.options, ...options };\n\t}\n}","import { ColliderDesc } from \"@dimforge/rapier3d-compat\";\nimport { GameEntity, GameEntityOptions } from \"./entity\";\nimport { BufferGeometry, Group, Material, Mesh, Color } from \"three\";\nimport { CollisionBuilder } from \"../collision/collision-builder\";\nimport { MeshBuilder } from \"../graphics/mesh\";\nimport { MaterialBuilder, MaterialOptions } from \"../graphics/material\";\nimport { Vec3 } from \"../core/vector\";\n\nexport abstract class EntityCollisionBuilder extends CollisionBuilder {\n\tabstract collider(options: GameEntityOptions): ColliderDesc;\n}\n\nexport abstract class EntityMeshBuilder extends MeshBuilder {\n\tbuild(options: GameEntityOptions): BufferGeometry {\n\t\treturn new BufferGeometry();\n\t}\n\n\tpostBuild(): void {\n\t\treturn;\n\t}\n}\n\nexport abstract class EntityBuilder<T extends GameEntity<U> & P, U extends GameEntityOptions, P = any> {\n\tprotected meshBuilder: EntityMeshBuilder | null;\n\tprotected collisionBuilder: EntityCollisionBuilder | null;\n\tprotected materialBuilder: MaterialBuilder | null;\n\tprotected options: Partial<U>;\n\tprotected entity: T;\n\n\tconstructor(\n\t\toptions: Partial<U>,\n\t\tentity: T,\n\t\tmeshBuilder: EntityMeshBuilder | null,\n\t\tcollisionBuilder: EntityCollisionBuilder | null,\n\t) {\n\t\tthis.options = options;\n\t\tthis.entity = entity;\n\t\tthis.meshBuilder = meshBuilder;\n\t\tthis.collisionBuilder = collisionBuilder;\n\t\tthis.materialBuilder = new MaterialBuilder();\n\t\tconst builders: NonNullable<GameEntityOptions[\"_builders\"]> = {\n\t\t\tmeshBuilder: this.meshBuilder,\n\t\t\tcollisionBuilder: this.collisionBuilder,\n\t\t\tmaterialBuilder: this.materialBuilder,\n\t\t};\n\t\t(this.options as Partial<GameEntityOptions>)._builders = builders;\n\t}\n\n\twithPosition(setupPosition: Vec3): this {\n\t\tthis.options.position = setupPosition;\n\t\treturn this;\n\t}\n\n\tasync withMaterial(options: Partial<MaterialOptions>, entityType: symbol): Promise<this> {\n\t\tif (this.materialBuilder) {\n\t\t\tawait this.materialBuilder.build(options, entityType);\n\t\t}\n\t\treturn this;\n\t}\n\n\tapplyMaterialToGroup(group: Group, materials: Material[]): void {\n\t\tgroup.traverse((child) => {\n\t\t\tif (child instanceof Mesh) {\n\t\t\t\tif (child.type === 'SkinnedMesh' && materials[0] && !child.material.map) {\n\t\t\t\t\tchild.material = materials[0];\n\t\t\t\t}\n\t\t\t}\n\t\t\tchild.castShadow = true;\n\t\t\tchild.receiveShadow = true;\n\t\t});\n\t}\n\n\tasync build(): Promise<T> {\n\t\tconst entity = this.entity;\n\t\tif (this.materialBuilder) {\n\t\t\tentity.materials = this.materialBuilder.materials;\n\t\t}\n\t\tif (this.meshBuilder && entity.materials) {\n\t\t\tconst geometry = this.meshBuilder.build(this.options);\n\t\t\tentity.mesh = this.meshBuilder._build(this.options, geometry, entity.materials);\n\t\t\tthis.meshBuilder.postBuild();\n\t\t}\n\n\t\tif (entity.group && entity.materials) {\n\t\t\tthis.applyMaterialToGroup(entity.group, entity.materials);\n\t\t}\n\n\t\tif (this.collisionBuilder) {\n\t\t\tthis.collisionBuilder.withCollision(this.options?.collision || {});\n\t\t\tconst [bodyDesc, colliderDesc] = this.collisionBuilder.build(this.options as any);\n\t\t\tentity.bodyDesc = bodyDesc;\n\t\t\tentity.colliderDesc = colliderDesc;\n\n\t\t\tconst { x, y, z } = this.options.position || { x: 0, y: 0, z: 0 };\n\t\t\tentity.bodyDesc.setTranslation(x, y, z);\n\t\t}\n\t\tif (this.options.collisionType) {\n\t\t\tentity.collisionType = this.options.collisionType;\n\t\t}\n\n\t\tif (this.options.color instanceof Color) {\n\t\t\tconst applyColor = (material: Material) => {\n\t\t\t\tconst anyMat = material as any;\n\t\t\t\tif (anyMat && anyMat.color && anyMat.color.set) {\n\t\t\t\t\tanyMat.color.set(this.options.color as Color);\n\t\t\t\t}\n\t\t\t};\n\t\t\tif (entity.materials?.length) {\n\t\t\t\tfor (const mat of entity.materials) applyColor(mat);\n\t\t\t}\n\t\t\tif (entity.mesh && entity.mesh.material) {\n\t\t\t\tconst mat = entity.mesh.material as any;\n\t\t\t\tif (Array.isArray(mat)) mat.forEach(applyColor); else applyColor(mat);\n\t\t\t}\n\t\t\tif (entity.group) {\n\t\t\t\tentity.group.traverse((child) => {\n\t\t\t\t\tif (child instanceof Mesh && child.material) {\n\t\t\t\t\t\tconst mat = child.material as any;\n\t\t\t\t\t\tif (Array.isArray(mat)) mat.forEach(applyColor); else applyColor(mat);\n\t\t\t\t\t}\n\t\t\t\t});\n\t\t\t}\n\t\t}\n\n\t\treturn entity;\n\t}\n\n\tprotected abstract createEntity(options: Partial<U>): T;\n}","import { ActiveCollisionTypes, ColliderDesc, RigidBodyDesc, RigidBodyType, Vector3 } from \"@dimforge/rapier3d-compat\";\nimport { Vec3 } from \"../core/vector\";\nimport { CollisionOptions } from \"./collision\";\n\nconst typeToGroup = new Map<string, number>();\nlet nextGroupId = 0;\n\nexport function getOrCreateCollisionGroupId(type: string): number {\n\tlet groupId = typeToGroup.get(type);\n\tif (groupId === undefined) {\n\t\tgroupId = nextGroupId++ % 16;\n\t\ttypeToGroup.set(type, groupId);\n\t}\n\treturn groupId;\n}\n\nexport function createCollisionFilter(allowedTypes: string[]): number {\n\tlet filter = 0;\n\tallowedTypes.forEach(type => {\n\t\tconst groupId = getOrCreateCollisionGroupId(type);\n\t\tfilter |= (1 << groupId);\n\t});\n\treturn filter;\n}\n\nexport class CollisionBuilder {\n\tstatic: boolean = false;\n\tsensor: boolean = false;\n\tgravity: Vec3 = new Vector3(0, 0, 0);\n\n\tbuild(options: Partial<CollisionOptions>): [RigidBodyDesc, ColliderDesc] {\n\t\tconst bodyDesc = this.bodyDesc({\n\t\t\tisDynamicBody: !this.static\n\t\t});\n\t\tconst collider = this.collider(options);\n\t\tconst type = options.collisionType;\n\t\tif (type) {\n\t\t\tlet groupId = getOrCreateCollisionGroupId(type);\n\t\t\tlet filter = 0b1111111111111111;\n\t\t\tif (options.collisionFilter) {\n\t\t\t\tfilter = createCollisionFilter(options.collisionFilter);\n\t\t\t}\n\t\t\tcollider.setCollisionGroups((groupId << 16) | filter);\n\t\t}\n\t\tconst { KINEMATIC_FIXED, DEFAULT } = ActiveCollisionTypes;\n\t\tcollider.activeCollisionTypes = (this.sensor) ? KINEMATIC_FIXED : DEFAULT;\n\t\treturn [bodyDesc, collider];\n\t}\n\n\twithCollision(collisionOptions: Partial<CollisionOptions>): this {\n\t\tthis.sensor = collisionOptions?.sensor ?? this.sensor;\n\t\tthis.static = collisionOptions?.static ?? this.static;\n\t\treturn this;\n\t}\n\n\tcollider(options: CollisionOptions): ColliderDesc {\n\t\tconst size = options.size ?? new Vector3(1, 1, 1);\n\t\tconst half = { x: size.x / 2, y: size.y / 2, z: size.z / 2 };\n\t\tlet colliderDesc = ColliderDesc.cuboid(half.x, half.y, half.z);\n\t\treturn colliderDesc;\n\t}\n\n\tbodyDesc({ isDynamicBody = true }): RigidBodyDesc {\n\t\tconst type = isDynamicBody ? RigidBodyType.Dynamic : RigidBodyType.Fixed;\n\t\tconst bodyDesc = new RigidBodyDesc(type)\n\t\t\t.setTranslation(0, 0, 0)\n\t\t\t.setGravityScale(1.0)\n\t\t\t.setCanSleep(false)\n\t\t\t.setCcdEnabled(true);\n\t\treturn bodyDesc;\n\t}\n}","import { BufferGeometry, Material, Mesh } from 'three';\nimport { GameEntityOptions } from '../entities/entity';\n\n/**\n * TODO: allow for multiple materials requires geometry groups\n * TODO: allow for instanced uniforms\n * TODO: allow for geometry groups\n * TODO: allow for batched meshes\n * import { InstancedUniformsMesh } from 'three-instanced-uniforms-mesh';\n * may not need geometry groups for shaders though\n * setGeometry<T extends BufferGeometry>(geometry: T) {\n * MeshBuilder.bachedMesh = new BatchedMesh(10, 5000, 10000, material);\n * }\n */\n\nexport type MeshBuilderOptions = Partial<Pick<GameEntityOptions, 'batched' | 'material'>>;\n\nexport class MeshBuilder {\n\n\t_build(meshOptions: MeshBuilderOptions, geometry: BufferGeometry, materials: Material[]): Mesh {\n\t\tconst { batched, material } = meshOptions;\n\t\tif (batched) {\n\t\t\tconsole.warn('warning: mesh batching is not implemented');\n\t\t}\n\t\tconst mesh = new Mesh(geometry, materials.at(-1));\n\t\tmesh.position.set(0, 0, 0);\n\t\tmesh.castShadow = true;\n\t\tmesh.receiveShadow = true;\n\t\treturn mesh;\n\t}\n\n\t_postBuild(): void {\n\t\treturn;\n\t}\n}","import {\n\tColor,\n\tMaterial,\n\tMeshPhongMaterial,\n\tMeshStandardMaterial,\n\tRepeatWrapping,\n\tShaderMaterial,\n\tTextureLoader,\n\tVector2,\n\tVector3\n} from 'three';\nimport { shortHash, sortedStringify } from '../core/utility/strings';\nimport shaderMap, { ZylemShaderObject, ZylemShaderType } from '../core/preset-shader';\n\nexport interface MaterialOptions {\n\tpath?: string;\n\trepeat?: Vector2;\n\tshader?: ZylemShaderType;\n\tcolor?: Color;\n}\n\ntype BatchGeometryMap = Map<symbol, number>;\n\ninterface BatchMaterialMapObject {\n\tgeometryMap: BatchGeometryMap;\n\tmaterial: Material;\n};\n\ntype BatchKey = ReturnType<typeof shortHash>;\n\nexport type TexturePath = string | null;\n\nexport class MaterialBuilder {\n\tstatic batchMaterialMap: Map<BatchKey, BatchMaterialMapObject> = new Map();\n\n\tmaterials: Material[] = [];\n\n\tbatchMaterial(options: Partial<MaterialOptions>, entityType: symbol) {\n\t\tconst batchKey = shortHash(sortedStringify(options));\n\t\tconst mappedObject = MaterialBuilder.batchMaterialMap.get(batchKey);\n\t\tif (mappedObject) {\n\t\t\tconst count = mappedObject.geometryMap.get(entityType);\n\t\t\tif (count) {\n\t\t\t\tmappedObject.geometryMap.set(entityType, count + 1);\n\t\t\t} else {\n\t\t\t\tmappedObject.geometryMap.set(entityType, 1);\n\t\t\t}\n\t\t} else {\n\t\t\tMaterialBuilder.batchMaterialMap.set(\n\t\t\t\tbatchKey, {\n\t\t\t\tgeometryMap: new Map([[entityType, 1]]),\n\t\t\t\tmaterial: this.materials[0]\n\t\t\t});\n\t\t}\n\t}\n\n\tasync build(options: Partial<MaterialOptions>, entityType: symbol) {\n\t\tconst { path, repeat, color, shader } = options;\n\t\tif (shader) this.withShader(shader);\n\t\tif (color) this.withColor(color);\n\t\tawait this.setTexture(path ?? null, repeat);\n\t\tif (this.materials.length === 0) {\n\t\t\tthis.setColor(new Color('#ffffff'));\n\t\t}\n\t\tthis.batchMaterial(options, entityType);\n\t}\n\n\twithColor(color: Color): this {\n\t\tthis.setColor(color);\n\t\treturn this;\n\t}\n\n\twithShader(shaderType: ZylemShaderType): this {\n\t\tthis.setShader(shaderType);\n\t\treturn this;\n\t}\n\n\tasync setTexture(texturePath: TexturePath = null, repeat: Vector2 = new Vector2(1, 1)) {\n\t\tif (!texturePath) {\n\t\t\treturn;\n\t\t}\n\t\tconst loader = new TextureLoader();\n\t\tconst texture = await loader.loadAsync(texturePath as string);\n\t\ttexture.repeat = repeat;\n\t\ttexture.wrapS = RepeatWrapping;\n\t\ttexture.wrapT = RepeatWrapping;\n\t\tconst material = new MeshPhongMaterial({\n\t\t\tmap: texture,\n\t\t});\n\t\tthis.materials.push(material);\n\t}\n\n\tsetColor(color: Color) {\n\t\tconst material = new MeshStandardMaterial({\n\t\t\tcolor: color,\n\t\t\temissiveIntensity: 0.5,\n\t\t\tlightMapIntensity: 0.5,\n\t\t\tfog: true,\n\t\t});\n\n\t\tthis.materials.push(material);\n\t}\n\n\tsetShader(customShader: ZylemShaderType) {\n\t\tconst { fragment, vertex } = shaderMap.get(customShader) ?? shaderMap.get('standard') as ZylemShaderObject;\n\n\t\tconst shader = new ShaderMaterial({\n\t\t\tuniforms: {\n\t\t\t\tiResolution: { value: new Vector3(1, 1, 1) },\n\t\t\t\tiTime: { value: 0 },\n\t\t\t\ttDiffuse: { value: null },\n\t\t\t\ttDepth: { value: null },\n\t\t\t\ttNormal: { value: null }\n\t\t\t},\n\t\t\tvertexShader: vertex,\n\t\t\tfragmentShader: fragment,\n\t\t});\n\t\tthis.materials.push(shader);\n\t}\n}\n","export function sortedStringify(obj: Record<string, any>) {\n\tconst sortedObj = Object.keys(obj)\n\t\t.sort()\n\t\t.reduce((acc: Record<string, any>, key: string) => {\n\t\t\tacc[key] = obj[key];\n\t\t\treturn acc;\n\t\t}, {} as Record<string, any>);\n\n\treturn JSON.stringify(sortedObj);\n}\n\nexport function shortHash(objString: string) {\n\tlet hash = 0;\n\tfor (let i = 0; i < objString.length; i++) {\n\t\thash = Math.imul(31, hash) + objString.charCodeAt(i) | 0;\n\t}\n\treturn hash.toString(36);\n}","export default \"#include <common>\\n\\nuniform vec3 iResolution;\\nuniform float iTime;\\nvarying vec2 vUv;\\n\\n// Credit goes to:\\n// https://www.shadertoy.com/view/mtyGWy\\n\\nvec3 palette( float t ) {\\n vec3 a = vec3(0.5, 0.5, 0.5);\\n vec3 b = vec3(0.5, 0.5, 0.5);\\n vec3 c = vec3(1.0, 1.0, 1.0);\\n vec3 d = vec3(0.263,0.416,0.557);\\n\\n return a + b*cos( 6.28318*(c*t+d) );\\n}\\n\\nvoid mainImage( out vec4 fragColor, in vec2 fragCoord ) {\\n vec2 uv = (fragCoord * 2.0 - iResolution.xy) / iResolution.y;\\n vec2 uv0 = uv;\\n vec3 finalColor = vec3(0.0);\\n \\n for (float i = 0.0; i < 4.0; i++) {\\n uv = fract(uv * 1.5) - 0.5;\\n\\n float d = length(uv) * exp(-length(uv0));\\n\\n vec3 col = palette(length(uv0) + i*.4 + iTime*.4);\\n\\n d = sin(d*5. + iTime)/5.;\\n d = abs(d);\\n\\n d = pow(0.01 / d, 1.2);\\n\\n finalColor += col * d;\\n }\\n \\n fragColor = vec4(finalColor, 1.0);\\n}\\n \\nvoid main() {\\n mainImage(gl_FragColor, vUv);\\n}\"","export default \"#include <common>\\n \\nuniform vec3 iResolution;\\nuniform float iTime;\\nuniform vec2 iOffset;\\nvarying vec2 vUv;\\n\\nfloat snoise(vec3 uv, float res)\\n{\\n\\tconst vec3 s = vec3(1e0, 1e2, 1e3);\\n\\t\\n\\tuv *= res;\\n\\t\\n\\tvec3 uv0 = floor(mod(uv, res))*s;\\n\\tvec3 uv1 = floor(mod(uv+vec3(1.), res))*s;\\n\\t\\n\\tvec3 f = fract(uv); f = f*f*(3.0-2.0*f);\\n\\n\\tvec4 v = vec4(uv0.x+uv0.y+uv0.z, uv1.x+uv0.y+uv0.z,\\n\\t\\t \\t uv0.x+uv1.y+uv0.z, uv1.x+uv1.y+uv0.z);\\n\\n\\tvec4 r = fract(sin(v*1e-1)*1e3);\\n\\tfloat r0 = mix(mix(r.x, r.y, f.x), mix(r.z, r.w, f.x), f.y);\\n\\t\\n\\tr = fract(sin((v + uv1.z - uv0.z)*1e-1)*1e3);\\n\\tfloat r1 = mix(mix(r.x, r.y, f.x), mix(r.z, r.w, f.x), f.y);\\n\\t\\n\\treturn mix(r0, r1, f.z)*2.-1.;\\n}\\n\\nvoid mainImage( out vec4 fragColor, in vec2 fragCoord ) {\\n\\tvec2 p = -.5 + fragCoord.xy / iResolution.xy;\\n\\tp.x *= iResolution.x/iResolution.y;\\n\\t\\n\\tfloat color = 3.0 - (3.*length(2.*p));\\n\\t\\n\\tvec3 coord = vec3(atan(p.x,p.y)/6.2832+.5, length(p)*.4, .5);\\n\\t\\n\\tfor(int i = 1; i <= 7; i++)\\n\\t{\\n\\t\\tfloat power = pow(2.0, float(i));\\n\\t\\tcolor += (1.5 / power) * snoise(coord + vec3(0.,-iTime*.05, iTime*.01), power*16.);\\n\\t}\\n\\tfragColor = vec4( color, pow(max(color,0.),2.)*0.4, pow(max(color,0.),3.)*0.15 , 1.0);\\n}\\n\\nvoid main() {\\n mainImage(gl_FragColor, vUv);\\n}\"","export default \"uniform sampler2D tDiffuse;\\nvarying vec2 vUv;\\n\\nvoid main() {\\n\\tvec4 texel = texture2D( tDiffuse, vUv );\\n\\n\\tgl_FragColor = texel;\\n}\"","export default \"varying vec3 vBarycentric;\\nuniform vec3 baseColor;\\nuniform vec3 wireframeColor;\\nuniform float wireframeThickness;\\n\\nfloat edgeFactor() {\\n vec3 d = fwidth(vBarycentric);\\n vec3 a3 = smoothstep(vec3(0.0), d * wireframeThickness, vBarycentric);\\n return min(min(a3.x, a3.y), a3.z);\\n}\\n\\nvoid main() {\\n float edge = edgeFactor();\\n\\n vec3 wireColor = wireframeColor;\\n\\n vec3 finalColor = mix(wireColor, baseColor, edge);\\n \\n gl_FragColor = vec4(finalColor, 1.0);\\n}\\n\"","export default \"uniform vec2 uvScale;\\nvarying vec2 vUv;\\n\\nvoid main() {\\n\\tvUv = uv;\\n\\tvec4 mvPosition = modelViewMatrix * vec4( position, 1.0 );\\n\\tgl_Position = projectionMatrix * mvPosition;\\n}\"","export default \"varying vec3 vBarycentric;\\n\\nvoid main() {\\n vec3 barycentric = vec3(0.0);\\n int index = gl_VertexID % 3;\\n if (index == 0) barycentric = vec3(1.0, 0.0, 0.0);\\n else if (index == 1) barycentric = vec3(0.0, 1.0, 0.0);\\n else barycentric = vec3(0.0, 0.0, 1.0);\\n vBarycentric = barycentric;\\n \\n gl_Position = projectionMatrix * modelViewMatrix * vec4(position, 1.0);\\n}\\n\"","/* Fragment Shaders **/\nimport starsTest from '../graphics/shaders/fragment/stars.glsl';\nimport fireFragment from '../graphics/shaders/fragment/fire.glsl';\nimport fragmentShader from '../graphics/shaders/fragment/standard.glsl';\nimport debugFragment from '../graphics/shaders/fragment/debug.glsl';\n\n/* Vertex Shaders **/\nimport vertexShader from '../graphics/shaders/vertex/object-shader.glsl';\nimport debugVertexShader from '../graphics/shaders/vertex/debug.glsl';\n\nexport type ZylemShaderObject = { fragment: string, vertex: string };\n\nconst starShader: ZylemShaderObject = {\n\tfragment: starsTest,\n\tvertex: vertexShader\n};\n\nconst fireShader: ZylemShaderObject = {\n\tfragment: fireFragment,\n\tvertex: vertexShader\n};\n\nconst standardShader: ZylemShaderObject = {\n\tfragment: fragmentShader,\n\tvertex: vertexShader\n};\n\nconst debugShader: ZylemShaderObject = {\n\tfragment: debugFragment,\n\tvertex: debugVertexShader\n};\n\nexport type ZylemShaderType = 'standard' | 'fire' | 'star' | 'debug';\n\nconst shaderMap: Map<ZylemShaderType, ZylemShaderObject> = new Map();\nshaderMap.set('standard', standardShader);\nshaderMap.set('fire', fireShader);\nshaderMap.set('star', starShader);\nshaderMap.set('debug', debugShader);\n\nexport default shaderMap;","import { GameEntity, GameEntityOptions } from '../entity';\nimport { MeshStandardMaterial, MeshBasicMaterial, MeshPhongMaterial } from 'three';\n\n/**\n * Interface for entities that provide custom debug information\n */\nexport interface DebugInfoProvider {\n\tgetDebugInfo(): Record<string, any>;\n}\n\n/**\n * Helper to check if an object implements DebugInfoProvider\n */\nfunction hasDebugInfo(obj: any): obj is DebugInfoProvider {\n\treturn obj && typeof obj.getDebugInfo === 'function';\n}\n\n/**\n * Debug delegate that provides debug information for entities\n */\nexport class DebugDelegate {\n\tprivate entity: GameEntity<any>;\n\n\tconstructor(entity: GameEntity<any>) {\n\t\tthis.entity = entity;\n\t}\n\n\t/**\n\t * Get formatted position string\n\t */\n\tprivate getPositionString(): string {\n\t\tif (this.entity.mesh) {\n\t\t\tconst { x, y, z } = this.entity.mesh.position;\n\t\t\treturn `${x.toFixed(2)}, ${y.toFixed(2)}, ${z.toFixed(2)}`;\n\t\t}\n\t\tconst { x, y, z } = this.entity.options.position || { x: 0, y: 0, z: 0 };\n\t\treturn `${x.toFixed(2)}, ${y.toFixed(2)}, ${z.toFixed(2)}`;\n\t}\n\n\t/**\n\t * Get formatted rotation string (in degrees)\n\t */\n\tprivate getRotationString(): string {\n\t\tif (this.entity.mesh) {\n\t\t\tconst { x, y, z } = this.entity.mesh.rotation;\n\t\t\tconst toDeg = (rad: number) => (rad * 180 / Math.PI).toFixed(1);\n\t\t\treturn `${toDeg(x)}°, ${toDeg(y)}°, ${toDeg(z)}°`;\n\t\t}\n\t\tconst { x, y, z } = this.entity.options.rotation || { x: 0, y: 0, z: 0 };\n\t\tconst toDeg = (rad: number) => (rad * 180 / Math.PI).toFixed(1);\n\t\treturn `${toDeg(x)}°, ${toDeg(y)}°, ${toDeg(z)}°`;\n\t}\n\n\t/**\n\t * Get material information\n\t */\n\tprivate getMaterialInfo(): Record<string, any> {\n\t\tif (!this.entity.mesh || !this.entity.mesh.material) {\n\t\t\treturn { type: 'none' };\n\t\t}\n\n\t\tconst material = Array.isArray(this.entity.mesh.material)\n\t\t\t? this.entity.mesh.material[0]\n\t\t\t: this.entity.mesh.material;\n\n\t\tconst info: Record<string, any> = {\n\t\t\ttype: material.type\n\t\t};\n\n\t\tif (material instanceof MeshStandardMaterial ||\n\t\t\tmaterial instanceof MeshBasicMaterial ||\n\t\t\tmaterial instanceof MeshPhongMaterial) {\n\t\t\tinfo.color = `#${material.color.getHexString()}`;\n\t\t\tinfo.opacity = material.opacity;\n\t\t\tinfo.transparent = material.transparent;\n\t\t}\n\n\t\tif ('roughness' in material) {\n\t\t\tinfo.roughness = material.roughness;\n\t\t}\n\n\t\tif ('metalness' in material) {\n\t\t\tinfo.metalness = material.metalness;\n\t\t}\n\n\t\treturn info;\n\t}\n\n\tprivate getPhysicsInfo(): Record<string, any> | null {\n\t\tif (!this.entity.body) {\n\t\t\treturn null;\n\t\t}\n\n\t\tconst info: Record<string, any> = {\n\t\t\ttype: this.entity.body.bodyType(),\n\t\t\tmass: this.entity.body.mass(),\n\t\t\tisEnabled: this.entity.body.isEnabled(),\n\t\t\tisSleeping: this.entity.body.isSleeping()\n\t\t};\n\n\t\tconst velocity = this.entity.body.linvel();\n\t\tinfo.velocity = `${velocity.x.toFixed(2)}, ${velocity.y.toFixed(2)}, ${velocity.z.toFixed(2)}`;\n\n\t\treturn info;\n\t}\n\n\tpublic buildDebugInfo(): Record<string, any> {\n\t\tconst defaultInfo: Record<string, any> = {\n\t\t\tname: this.entity.name || this.entity.uuid,\n\t\t\tuuid: this.entity.uuid,\n\t\t\tposition: this.getPositionString(),\n\t\t\trotation: this.getRotationString(),\n\t\t\tmaterial: this.getMaterialInfo()\n\t\t};\n\n\t\tconst physicsInfo = this.getPhysicsInfo();\n\t\tif (physicsInfo) {\n\t\t\tdefaultInfo.physics = physicsInfo;\n\t\t}\n\n\t\tif (this.entity.behaviors.length > 0) {\n\t\t\tdefaultInfo.behaviors = this.entity.behaviors.map(b => b.constructor.name);\n\t\t}\n\n\t\tif (hasDebugInfo(this.entity)) {\n\t\t\tconst customInfo = this.entity.getDebugInfo();\n\t\t\treturn { ...defaultInfo, ...customInfo };\n\t\t}\n\n\t\treturn defaultInfo;\n\t}\n}\n\nclass EnhancedDebugInfoBuilder {\n\tprivate customBuilder?: (options: GameEntityOptions) => Record<string, any>;\n\n\tconstructor(customBuilder?: (options: GameEntityOptions) => Record<string, any>) {\n\t\tthis.customBuilder = customBuilder;\n\t}\n\n\tbuildInfo(options: GameEntityOptions, entity?: GameEntity<any>): Record<string, any> {\n\t\tif (this.customBuilder) {\n\t\t\treturn this.customBuilder(options);\n\t\t}\n\n\t\tif (entity) {\n\t\t\tconst delegate = new DebugDelegate(entity);\n\t\t\treturn delegate.buildDebugInfo();\n\t\t}\n\n\t\tconst { x, y, z } = options.position || { x: 0, y: 0, z: 0 };\n\t\treturn {\n\t\t\tname: (options as any).name || 'unnamed',\n\t\t\tposition: `${x.toFixed(2)}, ${y.toFixed(2)}, ${z.toFixed(2)}`\n\t\t};\n\t}\n}\n","// this class is not for asset loading, it is for loading entity specific data\n// this is to keep the entity class focused purely on entity logic\n\nexport function isLoadable(obj: any): obj is EntityLoaderDelegate {\n\treturn typeof obj?.load === \"function\" && typeof obj?.data === \"function\";\n}\n\nexport interface EntityLoaderDelegate {\n\tload(): Promise<void>;\n\tdata(): any;\n}\n\nexport class EntityLoader {\n\tentityReference: EntityLoaderDelegate;\n\n\tconstructor(entity: EntityLoaderDelegate) {\n\t\tthis.entityReference = entity;\n\t}\n\n\tasync load() {\n\t\tif (this.entityReference.load) {\n\t\t\tawait this.entityReference.load();\n\t\t}\n\t}\n\n\tasync data() {\n\t\tif (this.entityReference.data) {\n\t\t\treturn this.entityReference.data();\n\t\t}\n\t\treturn null;\n\t}\n}","import { GameEntityOptions, GameEntity } from \"./entity\";\nimport { BaseNode } from \"../core/base-node\";\nimport { EntityBuilder } from \"./builder\";\nimport { EntityCollisionBuilder } from \"./builder\";\nimport { EntityMeshBuilder } from \"./builder\";\nimport { EntityLoader, isLoadable } from \"./delegates/loader\";\n\nexport interface CreateGameEntityOptions<T extends GameEntity<any>, CreateOptions extends GameEntityOptions> {\n\targs: Array<any>;\n\tdefaultConfig: GameEntityOptions;\n\tEntityClass: new (options: any) => T;\n\tBuilderClass: new (options: any, entity: T, meshBuilder: any, collisionBuilder: any) => EntityBuilder<T, CreateOptions>;\n\tMeshBuilderClass?: new (data: any) => EntityMeshBuilder;\n\tCollisionBuilderClass?: new (data: any) => EntityCollisionBuilder;\n\tentityType: symbol;\n};\n\nexport async function createEntity<T extends GameEntity<any>, CreateOptions extends GameEntityOptions>(params: CreateGameEntityOptions<T, CreateOptions>): Promise<T> {\n\tconst {\n\t\targs,\n\t\tdefaultConfig,\n\t\tEntityClass,\n\t\tBuilderClass,\n\t\tentityType,\n\t\tMeshBuilderClass,\n\t\tCollisionBuilderClass,\n\t} = params;\n\n\tlet builder: EntityBuilder<T, CreateOptions> | null = null;\n\tlet configuration;\n\n\tconst configurationIndex = args.findIndex(node => !(node instanceof BaseNode));\n\tif (configurationIndex !== -1) {\n\t\tconst subArgs = args.splice(configurationIndex, 1);\n\t\tconfiguration = subArgs.find(node => !(node instanceof BaseNode));\n\t}\n\n\tconst mergedConfiguration = configuration ? { ...defaultConfig, ...configuration } : defaultConfig;\n\targs.push(mergedConfiguration);\n\n\tfor (const arg of args) {\n\t\tif (arg instanceof BaseNode) {\n\t\t\tcontinue;\n\t\t}\n\t\tlet entityData = null;\n\t\tconst entity = new EntityClass(arg);\n\t\ttry {\n\t\t\tif (isLoadable(entity)) {\n\t\t\t\tconst loader = new EntityLoader(entity);\n\t\t\t\tawait loader.load();\n\t\t\t\tentityData = await loader.data();\n\t\t\t}\n\t\t} catch (error) {\n\t\t\tconsole.error(\"Error creating entity with loader:\", error);\n\t\t}\n\t\tbuilder = new BuilderClass(\n\t\t\targ,\n\t\t\tentity,\n\t\t\tMeshBuilderClass ? new MeshBuilderClass(entityData) : null,\n\t\t\tCollisionBuilderClass ? new CollisionBuilderClass(entityData) : null,\n\t\t);\n\t\tif (arg.material) {\n\t\t\tawait builder.withMaterial(arg.material, entityType);\n\t\t}\n\t}\n\n\tif (!builder) {\n\t\tthrow new Error(`missing options for ${String(entityType)}, builder is not initialized.`);\n\t}\n\n\treturn await builder.build();\n}\n\n","import { ColliderDesc } from '@dimforge/rapier3d-compat';\nimport { Color, SphereGeometry } from 'three';\nimport { Vector3 } from 'three';\nimport { BaseNode } from '../core/base-node';\nimport { GameEntityOptions, GameEntity } from './entity';\nimport { EntityBuilder } from './builder';\nimport { EntityCollisionBuilder } from './builder';\nimport { EntityMeshBuilder } from './builder';\nimport { DebugDelegate } from './delegates/debug';\nimport { createEntity } from './create';\n\ntype ZylemSphereOptions = GameEntityOptions & {\n\tradius?: number;\n};\n\nconst sphereDefaults: ZylemSphereOptions = {\n\tradius: 1,\n\tposition: new Vector3(0, 0, 0),\n\tcollision: {\n\t\tstatic: false,\n\t},\n\tmaterial: {\n\t\tcolor: new Color('#ffffff'),\n\t\tshader: 'standard'\n\t},\n};\n\nexport class SphereCollisionBuilder extends EntityCollisionBuilder {\n\tcollider(options: ZylemSphereOptions): ColliderDesc {\n\t\tconst radius = options.radius ?? 1;\n\t\tlet colliderDesc = ColliderDesc.ball(radius);\n\t\treturn colliderDesc;\n\t}\n}\n\nexport class SphereMeshBuilder extends EntityMeshBuilder {\n\tbuild(options: ZylemSphereOptions): SphereGeometry {\n\t\tconst radius = options.radius ?? 1;\n\t\treturn new SphereGeometry(radius);\n\t}\n}\n\nexport class SphereBuilder extends EntityBuilder<ZylemSphere, ZylemSphereOptions> {\n\tprotected createEntity(options: Partial<ZylemSphereOptions>): ZylemSphere {\n\t\treturn new ZylemSphere(options);\n\t}\n}\n\nexport const SPHERE_TYPE = Symbol('Sphere');\n\nexport class ZylemSphere extends GameEntity<ZylemSphereOptions> {\n\tstatic type = SPHERE_TYPE;\n\n\tconstructor(options?: ZylemSphereOptions) {\n\t\tsuper();\n\t\tthis.options = { ...sphereDefaults, ...options };\n\t}\n\n\tbuildInfo(): Record<string, any> {\n\t\tconst delegate = new DebugDelegate(this as any);\n\t\tconst baseInfo = delegate.buildDebugInfo();\n\t\tconst radius = this.options.radius ?? 1;\n\t\treturn {\n\t\t\t...baseInfo,\n\t\t\ttype: String(ZylemSphere.type),\n\t\t\tradius: radius.toFixed(2),\n\t\t};\n\t}\n}\n\ntype SphereOptions = BaseNode | Partial<ZylemSphereOptions>;\n\nexport async function sphere(...args: Array<SphereOptions>): Promise<ZylemSphere> {\n\treturn createEntity<ZylemSphere, ZylemSphereOptions>({\n\t\targs,\n\t\tdefaultConfig: sphereDefaults,\n\t\tEntityClass: ZylemSphere,\n\t\tBuilderClass: SphereBuilder,\n\t\tMeshBuilderClass: SphereMeshBuilder,\n\t\tCollisionBuilderClass: SphereCollisionBuilder,\n\t\tentityType: ZylemSphere.type\n\t});\n}","import { ColliderDesc } from '@dimforge/rapier3d-compat';\nimport { Color, Euler, Group, Quaternion, Vector3 } from 'three';\nimport {\n\tTextureLoader,\n\tSpriteMaterial,\n\tSprite as ThreeSprite,\n} from 'three';\nimport { BaseNode } from '../core/base-node';\nimport { GameEntityOptions, GameEntity } from './entity';\nimport { EntityBuilder } from './builder';\nimport { EntityCollisionBuilder } from './builder';\nimport { createEntity } from './create';\nimport { DestroyContext, DestroyFunction, UpdateContext, UpdateFunction } from '../core/base-node-life-cycle';\nimport { DebugDelegate } from './delegates/debug';\n\nexport type SpriteImage = { name: string; file: string };\nexport type SpriteAnimation = {\n\tname: string;\n\tframes: string[];\n\tspeed: number | number[];\n\tloop: boolean;\n};\n\ntype ZylemSpriteOptions = GameEntityOptions & {\n\timages?: SpriteImage[];\n\tanimations?: SpriteAnimation[];\n\tsize?: Vector3;\n\tcollisionSize?: Vector3;\n};\n\nconst spriteDefaults: ZylemSpriteOptions = {\n\tsize: new Vector3(1, 1, 1),\n\tposition: new Vector3(0, 0, 0),\n\tcollision: {\n\t\tstatic: false,\n\t},\n\tmaterial: {\n\t\tcolor: new Color('#ffffff'),\n\t\tshader: 'standard'\n\t},\n\timages: [],\n\tanimations: [],\n};\n\nexport class SpriteCollisionBuilder extends EntityCollisionBuilder {\n\tcollider(options: ZylemSpriteOptions): ColliderDesc {\n\t\tconst size = options.collisionSize || options.size || new Vector3(1, 1, 1);\n\t\tconst half = { x: size.x / 2, y: size.y / 2, z: size.z / 2 };\n\t\tlet colliderDesc = ColliderDesc.cuboid(half.x, half.y, half.z);\n\t\treturn colliderDesc;\n\t}\n}\n\nexport class SpriteBuilder extends EntityBuilder<ZylemSprite, ZylemSpriteOptions> {\n\tprotected createEntity(options: Partial<ZylemSpriteOptions>): ZylemSprite {\n\t\treturn new ZylemSprite(options);\n\t}\n}\n\nexport const SPRITE_TYPE = Symbol('Sprite');\n\nexport class ZylemSprite extends GameEntity<ZylemSpriteOptions> {\n\tstatic type = SPRITE_TYPE;\n\n\tprotected sprites: ThreeSprite[] = [];\n\tprotected spriteMap: Map<string, number> = new Map();\n\tprotected currentSpriteIndex: number = 0;\n\tprotected animations: Map<string, any> = new Map();\n\tprotected currentAnimation: any = null;\n\tprotected currentAnimationFrame: string = '';\n\tprotected currentAnimationIndex: number = 0;\n\tprotected currentAnimationTime: number = 0;\n\n\tconstructor(options?: ZylemSpriteOptions) {\n\t\tsuper();\n\t\tthis.options = { ...spriteDefaults, ...options };\n\t\tthis.createSpritesFromImages(options?.images || []);\n\t\tthis.createAnimations(options?.animations || []);\n\t\tthis.lifeCycleDelegate = {\n\t\t\tupdate: [this.spriteUpdate.bind(this) as UpdateFunction<ZylemSpriteOptions>],\n\t\t\tdestroy: [this.spriteDestroy.bind(this) as DestroyFunction<ZylemSpriteOptions>],\n\t\t};\n\t}\n\n\tprotected createSpritesFromImages(images: SpriteImage[]) {\n\t\tconst textureLoader = new TextureLoader();\n\t\timages.forEach((image, index) => {\n\t\t\tconst spriteMap = textureLoader.load(image.file);\n\t\t\tconst material = new SpriteMaterial({\n\t\t\t\tmap: spriteMap,\n\t\t\t\ttransparent: true,\n\t\t\t});\n\t\t\tconst _sprite = new ThreeSprite(material);\n\t\t\t_sprite.position.normalize();\n\t\t\tthis.sprites.push(_sprite);\n\t\t\tthis.spriteMap.set(image.name, index);\n\t\t});\n\t\tthis.group = new Group();\n\t\tthis.group.add(...this.sprites);\n\t}\n\n\tprotected createAnimations(animations: SpriteAnimation[]) {\n\t\tanimations.forEach(animation => {\n\t\t\tconst { name, frames, loop = false, speed = 1 } = animation;\n\t\t\tconst internalAnimation = {\n\t\t\t\tframes: frames.map((frame, index) => ({\n\t\t\t\t\tkey: frame,\n\t\t\t\t\tindex,\n\t\t\t\t\ttime: (typeof speed === 'number' ? speed : speed[index]) * (index + 1),\n\t\t\t\t\tduration: typeof speed === 'number' ? speed : speed[index]\n\t\t\t\t})),\n\t\t\t\tloop,\n\t\t\t};\n\t\t\tthis.animations.set(name, internalAnimation);\n\t\t});\n\t}\n\n\tsetSprite(key: string) {\n\t\tconst spriteIndex = this.spriteMap.get(key);\n\t\tconst useIndex = spriteIndex ?? 0;\n\t\tthis.currentSpriteIndex = useIndex;\n\t\tthis.sprites.forEach((_sprite, i) => {\n\t\t\t_sprite.visible = this.currentSpriteIndex === i;\n\t\t});\n\t}\n\n\tsetAnimation(name: string, delta: number) {\n\t\tconst animation = this.animations.get(name);\n\t\tif (!animation) return;\n\n\t\tconst { loop, frames } = animation;\n\t\tconst frame = frames[this.currentAnimationIndex];\n\n\t\tif (name === this.currentAnimation) {\n\t\t\tthis.currentAnimationFrame = frame.key;\n\t\t\tthis.currentAnimationTime += delta;\n\t\t\tthis.setSprite(this.currentAnimationFrame);\n\t\t} else {\n\t\t\tthis.currentAnimation = name;\n\t\t}\n\n\t\tif (this.currentAnimationTime > frame.time) {\n\t\t\tthis.currentAnimationIndex++;\n\t\t}\n\n\t\tif (this.currentAnimationIndex >= frames.length) {\n\t\t\tif (loop) {\n\t\t\t\tthis.currentAnimationIndex = 0;\n\t\t\t\tthis.currentAnimationTime = 0;\n\t\t\t} else {\n\t\t\t\tthis.currentAnimationTime = frames[this.currentAnimationIndex].time;\n\t\t\t}\n\t\t}\n\t}\n\n\tasync spriteUpdate(params: UpdateContext<ZylemSpriteOptions>): Promise<void> {\n\t\tthis.sprites.forEach(_sprite => {\n\t\t\tif (_sprite.material) {\n\t\t\t\tconst q = this.body?.rotation();\n\t\t\t\tif (q) {\n\t\t\t\t\tconst quat = new Quaternion(q.x, q.y, q.z, q.w);\n\t\t\t\t\tconst euler = new Euler().setFromQuaternion(quat, 'XYZ');\n\t\t\t\t\t_sprite.material.rotation = euler.z;\n\t\t\t\t}\n\t\t\t\t_sprite.scale.set(this.options.size?.x ?? 1, this.options.size?.y ?? 1, this.options.size?.z ?? 1);\n\t\t\t}\n\t\t});\n\t}\n\n\tasync spriteDestroy(params: DestroyContext<ZylemSpriteOptions>): Promise<void> {\n\t\tthis.sprites.forEach(_sprite => {\n\t\t\t_sprite.removeFromParent();\n\t\t});\n\t\tthis.group?.remove(...this.sprites);\n\t\tthis.group?.removeFromParent();\n\t}\n\n\tbuildInfo(): Record<string, any> {\n\t\tconst delegate = new DebugDelegate(this as any);\n\t\tconst baseInfo = delegate.buildDebugInfo();\n\t\treturn {\n\t\t\t...baseInfo,\n\t\t\ttype: String(ZylemSprite.type),\n\t\t};\n\t}\n}\n\ntype SpriteOptions = BaseNode | Partial<ZylemSpriteOptions>;\n\nexport async function sprite(...args: Array<SpriteOptions>): Promise<ZylemSprite> {\n\treturn createEntity<ZylemSprite, ZylemSpriteOptions>({\n\t\targs,\n\t\tdefaultConfig: spriteDefaults,\n\t\tEntityClass: ZylemSprite,\n\t\tBuilderClass: SpriteBuilder,\n\t\tCollisionBuilderClass: SpriteCollisionBuilder,\n\t\tentityType: ZylemSprite.type\n\t});\n}","import { ColliderDesc } from '@dimforge/rapier3d-compat';\nimport { Color, PlaneGeometry, Vector2, Vector3 } from 'three';\nimport { TexturePath } from '../graphics/material';\nimport { BaseNode } from '../core/base-node';\nimport { GameEntityOptions, GameEntity } from './entity';\nimport { EntityBuilder } from './builder';\nimport { EntityCollisionBuilder } from './builder';\nimport { EntityMeshBuilder } from './builder';\nimport { XZPlaneGeometry } from '../graphics/geometries/XZPlaneGeometry';\nimport { createEntity } from './create';\n\ntype ZylemPlaneOptions = GameEntityOptions & {\n\ttile?: Vector2;\n\trepeat?: Vector2;\n\ttexture?: TexturePath;\n\tsubdivisions?: number;\n};\n\nconst DEFAULT_SUBDIVISIONS = 4;\n\nconst planeDefaults: ZylemPlaneOptions = {\n\ttile: new Vector2(10, 10),\n\trepeat: new Vector2(1, 1),\n\tposition: new Vector3(0, 0, 0),\n\tcollision: {\n\t\tstatic: true,\n\t},\n\tmaterial: {\n\t\tcolor: new Color('#ffffff'),\n\t\tshader: 'standard'\n\t},\n\tsubdivisions: DEFAULT_SUBDIVISIONS\n};\n\nexport class PlaneCollisionBuilder extends EntityCollisionBuilder {\n\tcollider(options: ZylemPlaneOptions): ColliderDesc {\n\t\tconst tile = options.tile ?? new Vector2(1, 1);\n\t\tconst subdivisions = options.subdivisions ?? DEFAULT_SUBDIVISIONS;\n\t\tconst size = new Vector3(tile.x, 1, tile.y);\n\n\t\tconst heightData = (options._builders?.meshBuilder as unknown as PlaneMeshBuilder)?.heightData;\n\t\tconst scale = new Vector3(size.x, 1, size.z);\n\t\tlet colliderDesc = ColliderDesc.heightfield(\n\t\t\tsubdivisions,\n\t\t\tsubdivisions,\n\t\t\theightData,\n\t\t\tscale\n\t\t);\n\n\t\treturn colliderDesc;\n\t}\n}\n\nexport class PlaneMeshBuilder extends EntityMeshBuilder {\n\theightData: Float32Array = new Float32Array();\n\tcolumnsRows = new Map();\n\n\tbuild(options: ZylemPlaneOptions): XZPlaneGeometry {\n\t\tconst tile = options.tile ?? new Vector2(1, 1);\n\t\tconst subdivisions = options.subdivisions ?? DEFAULT_SUBDIVISIONS;\n\t\tconst size = new Vector3(tile.x, 1, tile.y);\n\n\t\tconst geometry = new XZPlaneGeometry(size.x, size.z, subdivisions, subdivisions);\n\t\tconst vertexGeometry = new PlaneGeometry(size.x, size.z, subdivisions, subdivisions);\n\t\tconst dx = size.x / subdivisions;\n\t\tconst dy = size.z / subdivisions;\n\t\tconst originalVertices = geometry.attributes.position.array;\n\t\tconst vertices = vertexGeometry.attributes.position.array;\n\t\tconst columsRows = new Map();\n\t\tfor (let i = 0; i < vertices.length; i += 3) {\n\t\t\tlet row = Math.floor(Math.abs((vertices as any)[i] + (size.x / 2)) / dx);\n\t\t\tlet column = Math.floor(Math.abs((vertices as any)[i + 1] - (size.z / 2)) / dy);\n\t\t\tconst randomHeight = Math.random() * 4;\n\t\t\t(vertices as any)[i + 2] = randomHeight;\n\t\t\toriginalVertices[i + 1] = randomHeight;\n\t\t\tif (!columsRows.get(column)) {\n\t\t\t\tcolumsRows.set(column, new Map());\n\t\t\t}\n\t\t\tcolumsRows.get(column).set(row, randomHeight);\n\t\t}\n\t\tthis.columnsRows = columsRows;\n\t\treturn geometry;\n\t}\n\n\tpostBuild(): void {\n\t\tconst heights = [];\n\t\tfor (let i = 0; i <= DEFAULT_SUBDIVISIONS; ++i) {\n\t\t\tfor (let j = 0; j <= DEFAULT_SUBDIVISIONS; ++j) {\n\t\t\t\tconst row = this.columnsRows.get(j);\n\t\t\t\tif (!row) {\n\t\t\t\t\tcontinue;\n\t\t\t\t}\n\t\t\t\tconst data = row.get(i);\n\t\t\t\theights.push(data);\n\t\t\t}\n\t\t}\n\t\tthis.heightData = new Float32Array(heights as unknown as number[]);\n\t}\n}\n\nexport class PlaneBuilder extends EntityBuilder<ZylemPlane, ZylemPlaneOptions> {\n\tprotected createEntity(options: Partial<ZylemPlaneOptions>): ZylemPlane {\n\t\treturn new ZylemPlane(options);\n\t}\n}\n\nexport const PLANE_TYPE = Symbol('Plane');\n\nexport class ZylemPlane extends GameEntity<ZylemPlaneOptions> {\n\tstatic type = PLANE_TYPE;\n\n\tconstructor(options?: ZylemPlaneOptions) {\n\t\tsuper();\n\t\tthis.options = { ...planeDefaults, ...options };\n\t}\n}\n\ntype PlaneOptions = BaseNode | Partial<ZylemPlaneOptions>;\n\nexport async function plane(...args: Array<PlaneOptions>): Promise<ZylemPlane> {\n\treturn createEntity<ZylemPlane, ZylemPlaneOptions>({\n\t\targs,\n\t\tdefaultConfig: planeDefaults,\n\t\tEntityClass: ZylemPlane,\n\t\tBuilderClass: PlaneBuilder,\n\t\tMeshBuilderClass: PlaneMeshBuilder,\n\t\tCollisionBuilderClass: PlaneCollisionBuilder,\n\t\tentityType: ZylemPlane.type\n\t});\n}\n","// @ts-nocheck\nimport { BufferGeometry, Float32BufferAttribute } from 'three';\n\nclass XZPlaneGeometry extends BufferGeometry {\n\n\tconstructor(width = 1, height = 1, widthSegments = 1, heightSegments = 1) {\n\n\t\tsuper();\n\n\t\tthis.type = 'XZPlaneGeometry';\n\n\t\tthis.parameters = {\n\t\t\twidth: width,\n\t\t\theight: height,\n\t\t\twidthSegments: widthSegments,\n\t\t\theightSegments: heightSegments\n\t\t};\n\n\t\tconst width_half = width / 2;\n\t\tconst height_half = height / 2;\n\n\t\tconst gridX = Math.floor(widthSegments);\n\t\tconst gridY = Math.floor(heightSegments);\n\n\t\tconst gridX1 = gridX + 1;\n\t\tconst gridY1 = gridY + 1;\n\n\t\tconst segment_width = width / gridX;\n\t\tconst segment_height = height / gridY;\n\n\t\tconst indices = [];\n\t\tconst vertices = [];\n\t\tconst normals = [];\n\t\tconst uvs = [];\n\n\t\tfor (let iy = 0; iy < gridY1; iy++) {\n\n\t\t\tconst z = iy * segment_height - height_half;\n\n\t\t\tfor (let ix = 0; ix < gridX1; ix++) {\n\n\t\t\t\tconst x = ix * segment_width - width_half;\n\n\t\t\t\tvertices.push(x, 0, z);\n\n\t\t\t\tnormals.push(0, 1, 0);\n\n\t\t\t\tuvs.push(ix / gridX);\n\t\t\t\tuvs.push(1 - (iy / gridY));\n\n\t\t\t}\n\n\t\t}\n\n\t\tfor (let iy = 0; iy < gridY; iy++) {\n\n\t\t\tfor (let ix = 0; ix < gridX; ix++) {\n\n\t\t\t\tconst a = ix + gridX1 * iy;\n\t\t\t\tconst b = ix + gridX1 * (iy + 1);\n\t\t\t\tconst c = (ix + 1) + gridX1 * (iy + 1);\n\t\t\t\tconst d = (ix + 1) + gridX1 * iy;\n\n\t\t\t\tindices.push(a, b, d);\n\t\t\t\tindices.push(b, c, d);\n\n\t\t\t}\n\n\t\t}\n\n\t\tthis.setIndex(indices);\n\t\tthis.setAttribute('position', new Float32BufferAttribute(vertices, 3));\n\t\tthis.setAttribute('normal', new Float32BufferAttribute(normals, 3));\n\t\tthis.setAttribute('uv', new Float32BufferAttribute(uvs, 2));\n\n\t}\n\n\tcopy(source) {\n\n\t\tsuper.copy(source);\n\n\t\tthis.parameters = Object.assign({}, source.parameters);\n\n\t\treturn this;\n\t}\n\n\tstatic fromJSON(data) {\n\t\treturn new XZPlaneGeometry(data.width, data.height, data.widthSegments, data.heightSegments);\n\t}\n\n}\n\nexport { XZPlaneGeometry };","import { ActiveCollisionTypes, ColliderDesc } from '@dimforge/rapier3d-compat';\nimport { Vector3 } from 'three';\nimport { BaseNode } from '../core/base-node';\nimport { GameEntityOptions, GameEntity } from './entity';\nimport { EntityBuilder } from './builder';\nimport { EntityCollisionBuilder } from './builder';\nimport { createEntity } from './create';\nimport { CollisionHandlerDelegate } from '../collision/collision-delegate';\nimport { state } from '../game/game-state';\n\nexport type OnHeldParams = {\n\tdelta: number;\n\tself: ZylemZone;\n\tvisitor: GameEntity<any>;\n\theldTime: number;\n\tglobals: any;\n}\n\nexport type OnEnterParams = Pick<OnHeldParams, 'self' | 'visitor' | 'globals'>;\nexport type OnExitParams = Pick<OnHeldParams, 'self' | 'visitor' | 'globals'>;\n\ntype ZylemZoneOptions = GameEntityOptions & {\n\tsize?: Vector3;\n\tstatic?: boolean;\n\tonEnter?: (params: OnEnterParams) => void;\n\tonHeld?: (params: OnHeldParams) => void;\n\tonExit?: (params: OnExitParams) => void;\n};\n\nconst zoneDefaults: ZylemZoneOptions = {\n\tsize: new Vector3(1, 1, 1),\n\tposition: new Vector3(0, 0, 0),\n\tcollision: {\n\t\tstatic: true,\n\t},\n\tmaterial: {\n\t\tshader: 'standard'\n\t},\n};\n\nexport class ZoneCollisionBuilder extends EntityCollisionBuilder {\n\tcollider(options: ZylemZoneOptions): ColliderDesc {\n\t\tconst size = options.size || new Vector3(1, 1, 1);\n\t\tconst half = { x: size.x / 2, y: size.y / 2, z: size.z / 2 };\n\t\tlet colliderDesc = ColliderDesc.cuboid(half.x, half.y, half.z);\n\t\tcolliderDesc.setSensor(true);\n\t\tcolliderDesc.activeCollisionTypes = ActiveCollisionTypes.KINEMATIC_FIXED;\n\t\treturn colliderDesc;\n\t}\n}\n\nexport class ZoneBuilder extends EntityBuilder<ZylemZone, ZylemZoneOptions> {\n\tprotected createEntity(options: Partial<ZylemZoneOptions>): ZylemZone {\n\t\treturn new ZylemZone(options);\n\t}\n}\n\nexport const ZONE_TYPE = Symbol('Zone');\n\nexport class ZylemZone extends GameEntity<ZylemZoneOptions> implements CollisionHandlerDelegate {\n\tstatic type = ZONE_TYPE;\n\n\tprivate _enteredZone: Map<string, number> = new Map();\n\tprivate _exitedZone: Map<string, number> = new Map();\n\tprivate _zoneEntities: Map<string, any> = new Map();\n\n\tconstructor(options?: ZylemZoneOptions) {\n\t\tsuper();\n\t\tthis.options = { ...zoneDefaults, ...options };\n\t}\n\n\tpublic handlePostCollision({ delta }: { delta: number }): boolean {\n\t\tthis._enteredZone.forEach((val, key) => {\n\t\t\tthis.exited(delta, key);\n\t\t});\n\t\treturn this._enteredZone.size > 0;\n\t}\n\n\tpublic handleIntersectionEvent({ other, delta }: { other: any, delta: number }) {\n\t\tconst hasEntered = this._enteredZone.get(other.uuid);\n\t\tif (!hasEntered) {\n\t\t\tthis.entered(other);\n\t\t\tthis._zoneEntities.set(other.uuid, other);\n\t\t} else {\n\t\t\tthis.held(delta, other);\n\t\t}\n\t}\n\n\tonEnter(callback: (params: OnEnterParams) => void) {\n\t\tthis.options.onEnter = callback;\n\t\treturn this;\n\t}\n\n\tonHeld(callback: (params: OnHeldParams) => void) {\n\t\tthis.options.onHeld = callback;\n\t\treturn this;\n\t}\n\n\tonExit(callback: (params: OnExitParams) => void) {\n\t\tthis.options.onExit = callback;\n\t\treturn this;\n\t}\n\n\tentered(other: any) {\n\t\tthis._enteredZone.set(other.uuid, 1);\n\t\tif (this.options.onEnter) {\n\t\t\tthis.options.onEnter({\n\t\t\t\tself: this,\n\t\t\t\tvisitor: other,\n\t\t\t\tglobals: state.globals\n\t\t\t});\n\t\t}\n\t}\n\n\texited(delta: number, key: string) {\n\t\tconst hasExited = this._exitedZone.get(key);\n\t\tif (hasExited && hasExited > 1 + delta) {\n\t\t\tthis._exitedZone.delete(key);\n\t\t\tthis._enteredZone.delete(key);\n\t\t\tconst other = this._zoneEntities.get(key);\n\t\t\tif (this.options.onExit) {\n\t\t\t\tthis.options.onExit({\n\t\t\t\t\tself: this,\n\t\t\t\t\tvisitor: other,\n\t\t\t\t\tglobals: state.globals\n\t\t\t\t});\n\t\t\t}\n\t\t\treturn;\n\t\t}\n\t\tthis._exitedZone.set(key, 1 + delta);\n\t}\n\n\theld(delta: number, other: any) {\n\t\tconst heldTime = this._enteredZone.get(other.uuid) ?? 0;\n\t\tthis._enteredZone.set(other.uuid, heldTime + delta);\n\t\tthis._exitedZone.set(other.uuid, 1);\n\t\tif (this.options.onHeld) {\n\t\t\tthis.options.onHeld({\n\t\t\t\tdelta,\n\t\t\t\tself: this,\n\t\t\t\tvisitor: other,\n\t\t\t\tglobals: state.globals,\n\t\t\t\theldTime\n\t\t\t});\n\t\t}\n\t}\n}\n\ntype ZoneOptions = BaseNode | Partial<ZylemZoneOptions>;\n\nexport async function zone(...args: Array<ZoneOptions>): Promise<ZylemZone> {\n\treturn createEntity<ZylemZone, ZylemZoneOptions>({\n\t\targs,\n\t\tdefaultConfig: zoneDefaults,\n\t\tEntityClass: ZylemZone,\n\t\tBuilderClass: ZoneBuilder,\n\t\tCollisionBuilderClass: ZoneCollisionBuilder,\n\t\tentityType: ZylemZone.type\n\t});\n}","import { proxy, subscribe } from 'valtio/vanilla';\nimport { getByPath, setByPath } from '../core/utility/path-utils';\n\n/**\n * Internal game state store using valtio proxy for reactivity.\n */\nconst state = proxy({\n\tid: '',\n\tglobals: {} as Record<string, unknown>,\n\ttime: 0,\n});\n\n/**\n * Set a global value by path.\n * @example setGlobal('score', 100)\n * @example setGlobal('player.health', 50)\n */\nexport function setGlobal(path: string, value: unknown): void {\n\tsetByPath(state.globals, path, value);\n}\n\n/**\n * Create/initialize a global with a default value.\n * Only sets the value if it doesn't already exist.\n * Use this to ensure globals have initial values before game starts.\n * @example createGlobal('score', 0)\n * @example createGlobal('player.health', 100)\n */\nexport function createGlobal<T>(path: string, defaultValue: T): T {\n\tconst existing = getByPath<T>(state.globals, path);\n\tif (existing === undefined) {\n\t\tsetByPath(state.globals, path, defaultValue);\n\t\treturn defaultValue;\n\t}\n\treturn existing;\n}\n\n/**\n * Get a global value by path.\n * @example getGlobal('score') // 100\n * @example getGlobal<number>('player.health') // 50\n */\nexport function getGlobal<T = unknown>(path: string): T | undefined {\n\treturn getByPath<T>(state.globals, path);\n}\n\n/**\n * Subscribe to changes on a global value at a specific path.\n * Returns an unsubscribe function.\n * @example const unsub = onGlobalChange('score', (val) => console.log(val));\n */\nexport function onGlobalChange<T = unknown>(\n\tpath: string,\n\tcallback: (value: T) => void\n): () => void {\n\tlet previous = getByPath<T>(state.globals, path);\n\treturn subscribe(state.globals, () => {\n\t\tconst current = getByPath<T>(state.globals, path);\n\t\tif (current !== previous) {\n\t\t\tprevious = current;\n\t\t\tcallback(current as T);\n\t\t}\n\t});\n}\n\n/**\n * Subscribe to changes on multiple global paths.\n * Callback fires when any of the paths change, receiving all current values.\n * Returns an unsubscribe function.\n * @example const unsub = onGlobalChanges(['score', 'lives'], ([score, lives]) => console.log(score, lives));\n */\nexport function onGlobalChanges<T extends unknown[] = unknown[]>(\n\tpaths: string[],\n\tcallback: (values: T) => void\n): () => void {\n\tlet previousValues = paths.map(p => getByPath(state.globals, p));\n\treturn subscribe(state.globals, () => {\n\t\tconst currentValues = paths.map(p => getByPath(state.globals, p));\n\t\tconst hasChange = currentValues.some((val, i) => val !== previousValues[i]);\n\t\tif (hasChange) {\n\t\t\tpreviousValues = currentValues;\n\t\t\tcallback(currentValues as T);\n\t\t}\n\t});\n}\n\n/**\n * Get the entire globals object (read-only snapshot).\n */\nexport function getGlobals<T = Record<string, unknown>>(): T {\n\treturn state.globals as T;\n}\n\n/**\n * Initialize globals from an object. Used internally during game setup.\n */\nexport function initGlobals(globals: Record<string, unknown>): void {\n\tfor (const [key, value] of Object.entries(globals)) {\n\t\tsetByPath(state.globals, key, value);\n\t}\n}\n\n/**\n * Reset all globals. Used internally on game dispose.\n */\nexport function resetGlobals(): void {\n\tstate.globals = {};\n}\n\nexport { state };","import { ActiveCollisionTypes, ColliderDesc } from '@dimforge/rapier3d-compat';\nimport { BufferGeometry, Object3D, SkinnedMesh, Group, Vector3 } from 'three';\nimport { BaseNode } from '../core/base-node';\nimport { GameEntityOptions, GameEntity } from './entity';\nimport { createEntity } from './create';\nimport { UpdateContext, UpdateFunction } from '../core/base-node-life-cycle';\nimport { EntityAssetLoader } from '../core/entity-asset-loader';\nimport { EntityLoaderDelegate } from './delegates/loader';\nimport { Vec3 } from '../core/vector';\nimport { AnimationDelegate, AnimationOptions } from './delegates/animation';\nimport { MaterialOptions } from '../graphics/material';\nimport { DebugInfoProvider } from './delegates/debug';\nimport { EntityBuilder } from './builder';\nimport { EntityCollisionBuilder } from './builder';\n\ntype AnimationObject = {\n\tkey?: string;\n\tpath: string;\n};\n\ntype ZylemActorOptions = GameEntityOptions & {\n\tstatic?: boolean;\n\tanimations?: AnimationObject[];\n\tmodels?: string[];\n\tscale?: Vec3;\n\tmaterial?: MaterialOptions;\n};\n\nconst actorDefaults: ZylemActorOptions = {\n\tposition: { x: 0, y: 0, z: 0 },\n\tcollision: {\n\t\tstatic: false,\n\t\tsize: new Vector3(0.5, 0.5, 0.5),\n\t\tposition: new Vector3(0, 0, 0),\n\t},\n\tmaterial: {\n\t\tshader: 'standard',\n\t},\n\tanimations: [],\n\tmodels: []\n};\n\nclass ActorCollisionBuilder extends EntityCollisionBuilder {\n\tprivate height: number = 1;\n\tprivate objectModel: Group | null = null;\n\n\tconstructor(data: any) {\n\t\tsuper();\n\t\tthis.objectModel = data.objectModel;\n\t}\n\n\tcreateColliderFromObjectModel(objectModel: Group | null): ColliderDesc {\n\t\tif (!objectModel) return ColliderDesc.capsule(1, 1);\n\n\t\tconst skinnedMesh = objectModel.children.find(child => child instanceof SkinnedMesh) as SkinnedMesh;\n\t\tconst geometry = skinnedMesh.geometry as BufferGeometry;\n\n\t\tif (geometry) {\n\t\t\tgeometry.computeBoundingBox();\n\t\t\tif (geometry.boundingBox) {\n\t\t\t\tconst maxY = geometry.boundingBox.max.y;\n\t\t\t\tconst minY = geometry.boundingBox.min.y;\n\t\t\t\tthis.height = maxY - minY;\n\t\t\t}\n\t\t}\n\t\tthis.height = 1;\n\t\tlet colliderDesc = ColliderDesc.capsule(this.height / 2, 1);\n\t\tcolliderDesc.setSensor(false);\n\t\tcolliderDesc.setTranslation(0, this.height + 0.5, 0);\n\t\tcolliderDesc.activeCollisionTypes = ActiveCollisionTypes.DEFAULT;\n\n\t\treturn colliderDesc;\n\t}\n\n\tcollider(options: ZylemActorOptions): ColliderDesc {\n\t\tlet colliderDesc = this.createColliderFromObjectModel(this.objectModel);\n\n\t\treturn colliderDesc;\n\t}\n}\n\nclass ActorBuilder extends EntityBuilder<ZylemActor, ZylemActorOptions> {\n\tprotected createEntity(options: Partial<ZylemActorOptions>): ZylemActor {\n\t\treturn new ZylemActor(options);\n\t}\n}\n\nconst ACTOR_TYPE = Symbol('Actor');\n\nexport class ZylemActor extends GameEntity<ZylemActorOptions> implements EntityLoaderDelegate, DebugInfoProvider {\n\tstatic type = ACTOR_TYPE;\n\n\tprivate _object: Object3D | null = null;\n\tprivate _animationDelegate: AnimationDelegate | null = null;\n\tprivate _modelFileNames: string[] = [];\n\tprivate _assetLoader: EntityAssetLoader = new EntityAssetLoader();\n\n\tcontrolledRotation: boolean = false;\n\n\tconstructor(options?: ZylemActorOptions) {\n\t\tsuper();\n\t\tthis.options = { ...actorDefaults, ...options };\n\t\tthis.lifeCycleDelegate = {\n\t\t\tupdate: [this.actorUpdate.bind(this) as UpdateFunction<ZylemActorOptions>],\n\t\t};\n\t\tthis.controlledRotation = true;\n\t}\n\n\tasync load(): Promise<void> {\n\t\tthis._modelFileNames = this.options.models || [];\n\t\tawait this.loadModels();\n\t\tif (this._object) {\n\t\t\tthis._animationDelegate = new AnimationDelegate(this._object);\n\t\t\tawait this._animationDelegate.loadAnimations(this.options.animations || []);\n\t\t}\n\t}\n\n\tasync data(): Promise<any> {\n\t\treturn {\n\t\t\tanimations: this._animationDelegate?.animations,\n\t\t\tobjectModel: this._object,\n\t\t};\n\t}\n\n\tasync actorUpdate(params: UpdateContext<ZylemActorOptions>): Promise<void> {\n\t\tthis._animationDelegate?.update(params.delta);\n\t}\n\n\tprivate async loadModels(): Promise<void> {\n\t\tif (this._modelFileNames.length === 0) return;\n\t\tconst promises = this._modelFileNames.map(file => this._assetLoader.loadFile(file));\n\t\tconst results = await Promise.all(promises);\n\t\tif (results[0]?.object) {\n\t\t\tthis._object = results[0].object;\n\t\t}\n\t\tif (this._object) {\n\t\t\tthis.group = new Group();\n\t\t\tthis.group.attach(this._object);\n\t\t\tthis.group.scale.set(\n\t\t\t\tthis.options.scale?.x || 1,\n\t\t\t\tthis.options.scale?.y || 1,\n\t\t\t\tthis.options.scale?.z || 1\n\t\t\t);\n\t\t}\n\t}\n\n\tplayAnimation(animationOptions: AnimationOptions) {\n\t\tthis._animationDelegate?.playAnimation(animationOptions);\n\t}\n\n\tget object(): Object3D | null {\n\t\treturn this._object;\n\t}\n\n\t/**\n\t * Provide custom debug information for the actor\n\t * This will be merged with the default debug information\n\t */\n\tgetDebugInfo(): Record<string, any> {\n\t\tconst debugInfo: Record<string, any> = {\n\t\t\ttype: 'Actor',\n\t\t\tmodels: this._modelFileNames.length > 0 ? this._modelFileNames : 'none',\n\t\t\tmodelLoaded: !!this._object,\n\t\t\tscale: this.options.scale ?\n\t\t\t\t`${this.options.scale.x}, ${this.options.scale.y}, ${this.options.scale.z}` :\n\t\t\t\t'1, 1, 1',\n\t\t};\n\n\t\t// Add animation info if available\n\t\tif (this._animationDelegate) {\n\t\t\tdebugInfo.currentAnimation = this._animationDelegate.currentAnimationKey || 'none';\n\t\t\tdebugInfo.animationsCount = this.options.animations?.length || 0;\n\t\t}\n\n\t\t// Add mesh info if model is loaded\n\t\tif (this._object) {\n\t\t\tlet meshCount = 0;\n\t\t\tlet vertexCount = 0;\n\t\t\tthis._object.traverse((child) => {\n\t\t\t\tif ((child as any).isMesh) {\n\t\t\t\t\tmeshCount++;\n\t\t\t\t\tconst geometry = (child as SkinnedMesh).geometry;\n\t\t\t\t\tif (geometry && geometry.attributes.position) {\n\t\t\t\t\t\tvertexCount += geometry.attributes.position.count;\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t});\n\t\t\tdebugInfo.meshCount = meshCount;\n\t\t\tdebugInfo.vertexCount = vertexCount;\n\t\t}\n\n\t\treturn debugInfo;\n\t}\n}\n\ntype ActorOptions = BaseNode | ZylemActorOptions;\n\nexport async function actor(...args: Array<ActorOptions>): Promise<ZylemActor> {\n\treturn await createEntity<ZylemActor, ZylemActorOptions>({\n\t\targs,\n\t\tdefaultConfig: actorDefaults,\n\t\tEntityClass: ZylemActor,\n\t\tBuilderClass: ActorBuilder,\n\t\tCollisionBuilderClass: ActorCollisionBuilder,\n\t\tentityType: ZylemActor.type\n\t});\n}","import { AnimationClip, Object3D } from 'three';\nimport { FBXLoader } from 'three/addons/loaders/FBXLoader.js';\nimport { GLTF, GLTFLoader } from 'three/addons/loaders/GLTFLoader.js';\n\nenum FileExtensionTypes {\n\tFBX = 'fbx',\n\tGLTF = 'gltf'\n}\n\nexport interface AssetLoaderResult {\n\tobject?: Object3D;\n\tanimation?: AnimationClip;\n\tgltf?: GLTF;\n}\n\nexport interface IAssetLoader {\n\tload(file: string): Promise<AssetLoaderResult>;\n\tisSupported(file: string): boolean;\n}\n\nclass FBXAssetLoader implements IAssetLoader {\n\tprivate loader: FBXLoader = new FBXLoader();\n\n\tisSupported(file: string): boolean {\n\t\treturn file.toLowerCase().endsWith(FileExtensionTypes.FBX);\n\t}\n\n\tasync load(file: string): Promise<AssetLoaderResult> {\n\t\treturn new Promise((resolve, reject) => {\n\t\t\tthis.loader.load(\n\t\t\t\tfile,\n\t\t\t\t(object: Object3D) => {\n\t\t\t\t\tconst animation = object.animations[0];\n\t\t\t\t\tresolve({\n\t\t\t\t\t\tobject,\n\t\t\t\t\t\tanimation\n\t\t\t\t\t});\n\t\t\t\t},\n\t\t\t\tundefined,\n\t\t\t\treject\n\t\t\t);\n\t\t});\n\t}\n}\n\nclass GLTFAssetLoader implements IAssetLoader {\n\tprivate loader: GLTFLoader = new GLTFLoader();\n\n\tisSupported(file: string): boolean {\n\t\treturn file.toLowerCase().endsWith(FileExtensionTypes.GLTF);\n\t}\n\n\tasync load(file: string): Promise<AssetLoaderResult> {\n\t\treturn new Promise((resolve, reject) => {\n\t\t\tthis.loader.load(\n\t\t\t\tfile,\n\t\t\t\t(gltf: GLTF) => {\n\t\t\t\t\tresolve({\n\t\t\t\t\t\tobject: gltf.scene,\n\t\t\t\t\t\tgltf\n\t\t\t\t\t});\n\t\t\t\t},\n\t\t\t\tundefined,\n\t\t\t\treject\n\t\t\t);\n\t\t});\n\t}\n}\n\nexport class EntityAssetLoader {\n\tprivate loaders: IAssetLoader[] = [\n\t\tnew FBXAssetLoader(),\n\t\tnew GLTFAssetLoader()\n\t];\n\n\tasync loadFile(file: string): Promise<AssetLoaderResult> {\n\t\tconst loader = this.loaders.find(l => l.isSupported(file));\n\n\t\tif (!loader) {\n\t\t\tthrow new Error(`Unsupported file type: ${file}`);\n\t\t}\n\n\t\treturn loader.load(file);\n\t}\n}\n","import {\n\tAnimationAction,\n\tAnimationClip,\n\tAnimationMixer,\n\tLoopOnce,\n\tLoopRepeat,\n\tObject3D,\n} from 'three';\nimport { EntityAssetLoader, AssetLoaderResult } from '../../core/entity-asset-loader';\n\nexport type AnimationOptions = {\n\tkey: string;\n\tpauseAtEnd?: boolean;\n\tpauseAtPercentage?: number;\n\tfadeToKey?: string;\n\tfadeDuration?: number;\n};\n\ntype AnimationObject = {\n\tkey?: string;\n\tpath: string;\n};\n\nexport class AnimationDelegate {\n\tprivate _mixer: AnimationMixer | null = null;\n\tprivate _actions: Record<string, AnimationAction> = {};\n\tprivate _animations: AnimationClip[] = [];\n\tprivate _currentAction: AnimationAction | null = null;\n\n\tprivate _pauseAtPercentage = 0;\n\tprivate _isPaused = false;\n\tprivate _queuedKey: string | null = null;\n\tprivate _fadeDuration = 0.5;\n\n\tprivate _currentKey: string = '';\n\tprivate _assetLoader = new EntityAssetLoader();\n\n\tconstructor(private target: Object3D) { }\n\n\tasync loadAnimations(animations: AnimationObject[]): Promise<void> {\n\t\tif (!animations.length) return;\n\n\t\tconst results = await Promise.all(animations.map(a => this._assetLoader.loadFile(a.path)));\n\t\tthis._animations = results\n\t\t\t.filter((r): r is AssetLoaderResult => !!r.animation)\n\t\t\t.map(r => r.animation!);\n\n\t\tif (!this._animations.length) return;\n\n\t\tthis._mixer = new AnimationMixer(this.target);\n\t\tthis._animations.forEach((clip, i) => {\n\t\t\tconst key = animations[i].key || i.toString();\n\t\t\tthis._actions[key] = this._mixer!.clipAction(clip);\n\t\t});\n\n\t\tthis.playAnimation({ key: Object.keys(this._actions)[0] });\n\t}\n\n\tupdate(delta: number): void {\n\t\tif (!this._mixer || !this._currentAction) return;\n\n\t\tthis._mixer.update(delta);\n\n\t\tconst pauseAtTime = this._currentAction.getClip().duration * (this._pauseAtPercentage / 100);\n\t\tif (\n\t\t\t!this._isPaused &&\n\t\t\tthis._pauseAtPercentage > 0 &&\n\t\t\tthis._currentAction.time >= pauseAtTime\n\t\t) {\n\t\t\tthis._currentAction.time = pauseAtTime;\n\t\t\tthis._currentAction.paused = true;\n\t\t\tthis._isPaused = true;\n\n\t\t\tif (this._queuedKey !== null) {\n\t\t\t\tconst next = this._actions[this._queuedKey];\n\t\t\t\tnext.reset().play();\n\t\t\t\tthis._currentAction.crossFadeTo(next, this._fadeDuration, false);\n\t\t\t\tthis._currentAction = next;\n\t\t\t\tthis._currentKey = this._queuedKey;\n\t\t\t\tthis._queuedKey = null;\n\t\t\t}\n\t\t}\n\t}\n\n\tplayAnimation(opts: AnimationOptions): void {\n\t\tif (!this._mixer) return;\n\t\tconst { key, pauseAtPercentage = 0, pauseAtEnd = false, fadeToKey, fadeDuration = 0.5 } = opts;\n\t\tif (key === this._currentKey) return;\n\n\t\tthis._queuedKey = fadeToKey || null;\n\t\tthis._fadeDuration = fadeDuration;\n\n\t\tthis._pauseAtPercentage = pauseAtEnd ? 100 : pauseAtPercentage;\n\t\tthis._isPaused = false;\n\n\t\tconst prev = this._currentAction;\n\t\tif (prev) prev.stop();\n\n\t\tconst action = this._actions[key];\n\t\tif (!action) return;\n\n\t\tif (this._pauseAtPercentage > 0) {\n\t\t\taction.setLoop(LoopOnce, Infinity);\n\t\t\taction.clampWhenFinished = true;\n\t\t} else {\n\t\t\taction.setLoop(LoopRepeat, Infinity);\n\t\t\taction.clampWhenFinished = false;\n\t\t}\n\n\t\tif (prev) {\n\t\t\tprev.crossFadeTo(action, fadeDuration, false);\n\t\t}\n\t\taction.reset().play();\n\n\t\tthis._currentAction = action;\n\t\tthis._currentKey = key;\n\t}\n\n\tget currentAnimationKey() { return this._currentKey; }\n\tget animations() { return this._animations; }\n}\n","import { Color, Group, Sprite as ThreeSprite, SpriteMaterial, CanvasTexture, LinearFilter, Vector2, PerspectiveCamera, OrthographicCamera, ClampToEdgeWrapping } from 'three';\nimport { BaseNode } from '../core/base-node';\nimport { GameEntityOptions, GameEntity } from './entity';\nimport { EntityBuilder } from './builder';\nimport { createEntity } from './create';\nimport { UpdateContext, SetupContext } from '../core/base-node-life-cycle';\nimport { ZylemCamera } from '../camera/zylem-camera';\nimport { DebugDelegate } from './delegates/debug';\n\ntype ZylemTextOptions = GameEntityOptions & {\n\ttext?: string;\n\tfontFamily?: string;\n\tfontSize?: number;\n\tfontColor?: Color | string;\n\tbackgroundColor?: Color | string | null;\n\tpadding?: number;\n\tstickToViewport?: boolean;\n\tscreenPosition?: Vector2;\n\tzDistance?: number;\n};\n\nconst textDefaults: ZylemTextOptions = {\n\tposition: undefined,\n\ttext: '',\n\tfontFamily: 'Menlo, Monaco, Consolas, \"Liberation Mono\", \"Courier New\", monospace',\n\tfontSize: 18,\n\tfontColor: '#FFFFFF',\n\tbackgroundColor: null,\n\tpadding: 4,\n\tstickToViewport: true,\n\tscreenPosition: new Vector2(24, 24),\n\tzDistance: 1,\n};\n\nexport class TextBuilder extends EntityBuilder<ZylemText, ZylemTextOptions> {\n\tprotected createEntity(options: Partial<ZylemTextOptions>): ZylemText {\n\t\treturn new ZylemText(options);\n\t}\n}\n\nexport const TEXT_TYPE = Symbol('Text');\n\nexport class ZylemText extends GameEntity<ZylemTextOptions> {\n\tstatic type = TEXT_TYPE;\n\n\tprivate _sprite: ThreeSprite | null = null;\n\tprivate _texture: CanvasTexture | null = null;\n\tprivate _canvas: HTMLCanvasElement | null = null;\n\tprivate _ctx: CanvasRenderingContext2D | null = null;\n\tprivate _cameraRef: ZylemCamera | null = null;\n\tprivate _lastCanvasW: number = 0;\n\tprivate _lastCanvasH: number = 0;\n\n\tconstructor(options?: ZylemTextOptions) {\n\t\tsuper();\n\t\tthis.options = { ...textDefaults, ...options } as ZylemTextOptions;\n\t\tthis.group = new Group();\n\t\tthis.createSprite();\n\t\tthis.lifeCycleDelegate = {\n\t\t\tsetup: [this.textSetup.bind(this) as any],\n\t\t\tupdate: [this.textUpdate.bind(this) as any],\n\t\t};\n\t}\n\n\tprivate createSprite() {\n\t\tthis._canvas = document.createElement('canvas');\n\t\tthis._ctx = this._canvas.getContext('2d');\n\t\tthis._texture = new CanvasTexture(this._canvas);\n\t\tthis._texture.minFilter = LinearFilter;\n\t\tthis._texture.magFilter = LinearFilter;\n\t\tconst material = new SpriteMaterial({\n\t\t\tmap: this._texture,\n\t\t\ttransparent: true,\n\t\t\tdepthTest: false,\n\t\t\tdepthWrite: false,\n\t\t\talphaTest: 0.5,\n\t\t});\n\t\tthis._sprite = new ThreeSprite(material);\n\t\tthis.group?.add(this._sprite);\n\t\tthis.redrawText(this.options.text ?? '');\n\t}\n\n\tprivate measureAndResizeCanvas(text: string, fontSize: number, fontFamily: string, padding: number) {\n\t\tif (!this._canvas || !this._ctx) return { sizeChanged: false };\n\t\tthis._ctx.font = `${fontSize}px ${fontFamily}`;\n\t\tconst metrics = this._ctx.measureText(text);\n\t\tconst textWidth = Math.ceil(metrics.width);\n\t\tconst textHeight = Math.ceil(fontSize * 1.4);\n\t\tconst nextW = Math.max(2, textWidth + padding * 2);\n\t\tconst nextH = Math.max(2, textHeight + padding * 2);\n\t\tconst sizeChanged = nextW !== this._lastCanvasW || nextH !== this._lastCanvasH;\n\t\tthis._canvas.width = nextW;\n\t\tthis._canvas.height = nextH;\n\t\tthis._lastCanvasW = nextW;\n\t\tthis._lastCanvasH = nextH;\n\t\treturn { sizeChanged };\n\t}\n\n\tprivate drawCenteredText(text: string, fontSize: number, fontFamily: string) {\n\t\tif (!this._canvas || !this._ctx) return;\n\t\tthis._ctx.font = `${fontSize}px ${fontFamily}`;\n\t\tthis._ctx.textAlign = 'center';\n\t\tthis._ctx.textBaseline = 'middle';\n\t\tthis._ctx.clearRect(0, 0, this._canvas.width, this._canvas.height);\n\t\tif (this.options.backgroundColor) {\n\t\t\tthis._ctx.fillStyle = this.toCssColor(this.options.backgroundColor);\n\t\t\tthis._ctx.fillRect(0, 0, this._canvas.width, this._canvas.height);\n\t\t}\n\t\tthis._ctx.fillStyle = this.toCssColor(this.options.fontColor ?? '#FFFFFF');\n\t\tthis._ctx.fillText(text, this._canvas.width / 2, this._canvas.height / 2);\n\t}\n\n\tprivate updateTexture(sizeChanged: boolean) {\n\t\tif (!this._texture || !this._canvas) return;\n\t\tif (sizeChanged) {\n\t\t\tthis._texture.dispose();\n\t\t\tthis._texture = new CanvasTexture(this._canvas);\n\t\t\tthis._texture.minFilter = LinearFilter;\n\t\t\tthis._texture.magFilter = LinearFilter;\n\t\t\tthis._texture.wrapS = ClampToEdgeWrapping;\n\t\t\tthis._texture.wrapT = ClampToEdgeWrapping;\n\t\t}\n\t\tthis._texture.image = this._canvas;\n\t\tthis._texture.needsUpdate = true;\n\t\tif (this._sprite && this._sprite.material) {\n\t\t\t(this._sprite.material as any).map = this._texture;\n\t\t\tthis._sprite.material.needsUpdate = true;\n\t\t}\n\t}\n\n\tprivate redrawText(_text: string) {\n\t\tif (!this._canvas || !this._ctx) return;\n\t\tconst fontSize = this.options.fontSize ?? 18;\n\t\tconst fontFamily = this.options.fontFamily ?? (textDefaults.fontFamily as string);\n\t\tconst padding = this.options.padding ?? 4;\n\n\t\tconst { sizeChanged } = this.measureAndResizeCanvas(_text, fontSize, fontFamily, padding);\n\t\tthis.drawCenteredText(_text, fontSize, fontFamily);\n\t\tthis.updateTexture(Boolean(sizeChanged));\n\n\t\tif (this.options.stickToViewport && this._cameraRef) {\n\t\t\tthis.updateStickyTransform();\n\t\t}\n\t}\n\n\tprivate toCssColor(color: Color | string): string {\n\t\tif (typeof color === 'string') return color;\n\t\tconst c = color instanceof Color ? color : new Color(color as any);\n\t\treturn `#${c.getHexString()}`;\n\t}\n\n\tprivate textSetup(params: SetupContext<ZylemTextOptions>) {\n\t\tthis._cameraRef = (params.camera as unknown) as ZylemCamera | null;\n\t\tif (this.options.stickToViewport && this._cameraRef) {\n\t\t\t(this._cameraRef.camera as any).add(this.group);\n\t\t\tthis.updateStickyTransform();\n\t\t}\n\t}\n\n\tprivate textUpdate(params: UpdateContext<ZylemTextOptions>) {\n\t\tif (!this._sprite) return;\n\t\tif (this.options.stickToViewport && this._cameraRef) {\n\t\t\tthis.updateStickyTransform();\n\t\t}\n\t}\n\n\tprivate getResolution() {\n\t\treturn {\n\t\t\twidth: this._cameraRef?.screenResolution.x ?? 1,\n\t\t\theight: this._cameraRef?.screenResolution.y ?? 1,\n\t\t};\n\t}\n\n\tprivate getScreenPixels(sp: Vector2, width: number, height: number) {\n\t\tconst isPercentX = sp.x >= 0 && sp.x <= 1;\n\t\tconst isPercentY = sp.y >= 0 && sp.y <= 1;\n\t\treturn {\n\t\t\tpx: isPercentX ? sp.x * width : sp.x,\n\t\t\tpy: isPercentY ? sp.y * height : sp.y,\n\t\t};\n\t}\n\n\tprivate computeWorldExtents(camera: PerspectiveCamera | OrthographicCamera, zDist: number) {\n\t\tlet worldHalfW = 1;\n\t\tlet worldHalfH = 1;\n\t\tif ((camera as PerspectiveCamera).isPerspectiveCamera) {\n\t\t\tconst pc = camera as PerspectiveCamera;\n\t\t\tconst halfH = Math.tan((pc.fov * Math.PI) / 180 / 2) * zDist;\n\t\t\tconst halfW = halfH * pc.aspect;\n\t\t\tworldHalfW = halfW;\n\t\t\tworldHalfH = halfH;\n\t\t} else if ((camera as OrthographicCamera).isOrthographicCamera) {\n\t\t\tconst oc = camera as OrthographicCamera;\n\t\t\tworldHalfW = (oc.right - oc.left) / 2;\n\t\t\tworldHalfH = (oc.top - oc.bottom) / 2;\n\t\t}\n\t\treturn { worldHalfW, worldHalfH };\n\t}\n\n\tprivate updateSpriteScale(worldHalfH: number, viewportHeight: number) {\n\t\tif (!this._canvas || !this._sprite) return;\n\t\tconst planeH = worldHalfH * 2;\n\t\tconst unitsPerPixel = planeH / viewportHeight;\n\t\tconst pixelH = this._canvas.height;\n\t\tconst scaleY = Math.max(0.0001, pixelH * unitsPerPixel);\n\t\tconst aspect = this._canvas.width / this._canvas.height;\n\t\tconst scaleX = scaleY * aspect;\n\t\tthis._sprite.scale.set(scaleX, scaleY, 1);\n\t}\n\n\tprivate updateStickyTransform() {\n\t\tif (!this._sprite || !this._cameraRef) return;\n\t\tconst camera = this._cameraRef.camera as PerspectiveCamera | OrthographicCamera;\n\t\tconst { width, height } = this.getResolution();\n\t\tconst sp = this.options.screenPosition ?? new Vector2(24, 24);\n\t\tconst { px, py } = this.getScreenPixels(sp, width, height);\n\t\tconst zDist = Math.max(0.001, this.options.zDistance ?? 1);\n\t\tconst { worldHalfW, worldHalfH } = this.computeWorldExtents(camera, zDist);\n\n\t\tconst ndcX = (px / width) * 2 - 1;\n\t\tconst ndcY = 1 - (py / height) * 2;\n\t\tconst localX = ndcX * worldHalfW;\n\t\tconst localY = ndcY * worldHalfH;\n\t\tthis.group?.position.set(localX, localY, -zDist);\n\t\tthis.updateSpriteScale(worldHalfH, height);\n\t}\n\n\tupdateText(_text: string) {\n\t\tthis.options.text = _text;\n\t\tthis.redrawText(_text);\n\t\tif (this.options.stickToViewport && this._cameraRef) {\n\t\t\tthis.updateStickyTransform();\n\t\t}\n\t}\n\n\tbuildInfo(): Record<string, any> {\n\t\tconst delegate = new DebugDelegate(this as any);\n\t\tconst baseInfo = delegate.buildDebugInfo();\n\n\t\treturn {\n\t\t\t...baseInfo,\n\t\t\ttype: String(ZylemText.type),\n\t\t\ttext: this.options.text ?? '',\n\t\t\tsticky: this.options.stickToViewport,\n\t\t};\n\t}\n}\n\ntype TextOptions = BaseNode | Partial<ZylemTextOptions>;\n\nexport async function text(...args: Array<TextOptions>): Promise<ZylemText> {\n\treturn createEntity<ZylemText, ZylemTextOptions>({\n\t\targs,\n\t\tdefaultConfig: { ...textDefaults },\n\t\tEntityClass: ZylemText,\n\t\tBuilderClass: TextBuilder,\n\t\tentityType: ZylemText.type,\n\t});\n}\n\n\n","import { Color, Group, Sprite as ThreeSprite, SpriteMaterial, CanvasTexture, LinearFilter, Vector2, PerspectiveCamera, OrthographicCamera, ClampToEdgeWrapping, ShaderMaterial, Mesh, PlaneGeometry, Vector3 } from 'three';\nimport { BaseNode } from '../core/base-node';\nimport { GameEntityOptions, GameEntity } from './entity';\nimport { EntityBuilder } from './builder';\nimport { createEntity } from './create';\nimport { UpdateContext, SetupContext } from '../core/base-node-life-cycle';\nimport { ZylemCamera } from '../camera/zylem-camera';\nimport { DebugDelegate } from './delegates/debug';\n\ntype ZylemRectOptions = GameEntityOptions & {\n\twidth?: number;\n\theight?: number;\n\tfillColor?: Color | string | null;\n\tstrokeColor?: Color | string | null;\n\tstrokeWidth?: number;\n\tradius?: number;\n\tpadding?: number;\n\tstickToViewport?: boolean;\n\tscreenPosition?: Vector2;\n\tzDistance?: number;\n\tanchor?: Vector2; // 0-100 per axis, default top-left (0,0)\n\tbounds?: {\n\t\tscreen?: { x: number; y: number; width: number; height: number };\n\t\tworld?: { left: number; right: number; top: number; bottom: number; z?: number };\n\t};\n};\n\nconst rectDefaults: ZylemRectOptions = {\n\tposition: undefined,\n\twidth: 120,\n\theight: 48,\n\tfillColor: '#FFFFFF',\n\tstrokeColor: null,\n\tstrokeWidth: 0,\n\tradius: 0,\n\tpadding: 0,\n\tstickToViewport: true,\n\tscreenPosition: new Vector2(24, 24),\n\tzDistance: 1,\n\tanchor: new Vector2(0, 0),\n};\n\nexport class RectBuilder extends EntityBuilder<ZylemRect, ZylemRectOptions> {\n\tprotected createEntity(options: Partial<ZylemRectOptions>): ZylemRect {\n\t\treturn new ZylemRect(options);\n\t}\n}\n\nexport const RECT_TYPE = Symbol('Rect');\n\nexport class ZylemRect extends GameEntity<ZylemRectOptions> {\n\tstatic type = RECT_TYPE;\n\n\tprivate _sprite: ThreeSprite | null = null;\n\tprivate _mesh: Mesh | null = null;\n\tprivate _texture: CanvasTexture | null = null;\n\tprivate _canvas: HTMLCanvasElement | null = null;\n\tprivate _ctx: CanvasRenderingContext2D | null = null;\n\tprivate _cameraRef: ZylemCamera | null = null;\n\tprivate _lastCanvasW: number = 0;\n\tprivate _lastCanvasH: number = 0;\n\n\tconstructor(options?: ZylemRectOptions) {\n\t\tsuper();\n\t\tthis.options = { ...rectDefaults, ...options } as ZylemRectOptions;\n\t\tthis.group = new Group();\n\t\tthis.createSprite();\n\t\tthis.lifeCycleDelegate = {\n\t\t\tsetup: [this.rectSetup.bind(this) as any],\n\t\t\tupdate: [this.rectUpdate.bind(this) as any],\n\t\t};\n\t}\n\n\tprivate createSprite() {\n\t\tthis._canvas = document.createElement('canvas');\n\t\tthis._ctx = this._canvas.getContext('2d');\n\t\tthis._texture = new CanvasTexture(this._canvas);\n\t\tthis._texture.minFilter = LinearFilter;\n\t\tthis._texture.magFilter = LinearFilter;\n\t\tconst material = new SpriteMaterial({\n\t\t\tmap: this._texture,\n\t\t\ttransparent: true,\n\t\t\tdepthTest: false,\n\t\t\tdepthWrite: false,\n\t\t\talphaTest: 0.5,\n\t\t});\n\t\tthis._sprite = new ThreeSprite(material);\n\t\tthis.group?.add(this._sprite);\n\t\tthis.redrawRect();\n\t}\n\n\tprivate redrawRect() {\n\t\tif (!this._canvas || !this._ctx) return;\n\t\tconst width = Math.max(2, Math.floor((this.options.width ?? 120)));\n\t\tconst height = Math.max(2, Math.floor((this.options.height ?? 48)));\n\t\tconst padding = this.options.padding ?? 0;\n\t\tconst strokeWidth = this.options.strokeWidth ?? 0;\n\t\tconst totalW = width + padding * 2 + strokeWidth;\n\t\tconst totalH = height + padding * 2 + strokeWidth;\n\t\tconst nextW = Math.max(2, totalW);\n\t\tconst nextH = Math.max(2, totalH);\n\t\tconst sizeChanged = nextW !== this._lastCanvasW || nextH !== this._lastCanvasH;\n\t\tthis._canvas.width = nextW;\n\t\tthis._canvas.height = nextH;\n\t\tthis._lastCanvasW = nextW;\n\t\tthis._lastCanvasH = nextH;\n\n\t\tthis._ctx.clearRect(0, 0, this._canvas.width, this._canvas.height);\n\n\t\tconst radius = Math.max(0, this.options.radius ?? 0);\n\t\tconst rectX = Math.floor(padding + strokeWidth / 2);\n\t\tconst rectY = Math.floor(padding + strokeWidth / 2);\n\t\tconst rectW = Math.floor(width);\n\t\tconst rectH = Math.floor(height);\n\n\t\tthis._ctx.beginPath();\n\t\tif (radius > 0) {\n\t\t\tthis.roundedRectPath(this._ctx, rectX, rectY, rectW, rectH, radius);\n\t\t} else {\n\t\t\tthis._ctx.rect(rectX, rectY, rectW, rectH);\n\t\t}\n\n\t\tif (this.options.fillColor) {\n\t\t\tthis._ctx.fillStyle = this.toCssColor(this.options.fillColor);\n\t\t\tthis._ctx.fill();\n\t\t}\n\n\t\tif ((this.options.strokeColor && (strokeWidth > 0))) {\n\t\t\tthis._ctx.lineWidth = strokeWidth;\n\t\t\tthis._ctx.strokeStyle = this.toCssColor(this.options.strokeColor);\n\t\t\tthis._ctx.stroke();\n\t\t}\n\n\t\tif (this._texture) {\n\t\t\tif (sizeChanged) {\n\t\t\t\tthis._texture.dispose();\n\t\t\t\tthis._texture = new CanvasTexture(this._canvas);\n\t\t\t\tthis._texture.minFilter = LinearFilter;\n\t\t\t\tthis._texture.magFilter = LinearFilter;\n\t\t\t\tthis._texture.wrapS = ClampToEdgeWrapping;\n\t\t\t\tthis._texture.wrapT = ClampToEdgeWrapping;\n\t\t\t\tif (this._sprite && this._sprite.material instanceof ShaderMaterial) {\n\t\t\t\t\tconst shader = this._sprite.material as ShaderMaterial;\n\t\t\t\t\tif (shader.uniforms?.tDiffuse) shader.uniforms.tDiffuse.value = this._texture;\n\t\t\t\t\tif (shader.uniforms?.iResolution) shader.uniforms.iResolution.value.set(this._canvas.width, this._canvas.height, 1);\n\t\t\t\t}\n\t\t\t}\n\t\t\tthis._texture.image = this._canvas;\n\t\t\tthis._texture.needsUpdate = true;\n\t\t\tif (this._sprite && this._sprite.material) {\n\t\t\t\t(this._sprite.material as any).map = this._texture;\n\t\t\t\tthis._sprite.material.needsUpdate = true;\n\t\t\t}\n\t\t}\n\t}\n\n\tprivate roundedRectPath(ctx: CanvasRenderingContext2D, x: number, y: number, w: number, h: number, r: number) {\n\t\tconst radius = Math.min(r, Math.floor(Math.min(w, h) / 2));\n\t\tctx.moveTo(x + radius, y);\n\t\tctx.lineTo(x + w - radius, y);\n\t\tctx.quadraticCurveTo(x + w, y, x + w, y + radius);\n\t\tctx.lineTo(x + w, y + h - radius);\n\t\tctx.quadraticCurveTo(x + w, y + h, x + w - radius, y + h);\n\t\tctx.lineTo(x + radius, y + h);\n\t\tctx.quadraticCurveTo(x, y + h, x, y + h - radius);\n\t\tctx.lineTo(x, y + radius);\n\t\tctx.quadraticCurveTo(x, y, x + radius, y);\n\t}\n\n\tprivate toCssColor(color: Color | string): string {\n\t\tif (typeof color === 'string') return color;\n\t\tconst c = color instanceof Color ? color : new Color(color as any);\n\t\treturn `#${c.getHexString()}`;\n\t}\n\n\tprivate rectSetup(params: SetupContext<ZylemRectOptions>) {\n\t\tthis._cameraRef = (params.camera as unknown) as ZylemCamera | null;\n\t\tif (this.options.stickToViewport && this._cameraRef) {\n\t\t\t(this._cameraRef.camera as any).add(this.group);\n\t\t}\n\n\t\tif (this.materials?.length && this._sprite) {\n\t\t\tconst mat = this.materials[0];\n\t\t\tif (mat instanceof ShaderMaterial) {\n\t\t\t\tmat.transparent = true;\n\t\t\t\tmat.depthTest = false;\n\t\t\t\tmat.depthWrite = false;\n\t\t\t\tif (this._texture) {\n\t\t\t\t\tif (mat.uniforms?.tDiffuse) mat.uniforms.tDiffuse.value = this._texture;\n\t\t\t\t\tif (mat.uniforms?.iResolution && this._canvas) mat.uniforms.iResolution.value.set(this._canvas.width, this._canvas.height, 1);\n\t\t\t\t}\n\t\t\t\tthis._mesh = new Mesh(new PlaneGeometry(1, 1), mat);\n\t\t\t\tthis.group?.add(this._mesh);\n\t\t\t\tthis._sprite.visible = false;\n\t\t\t}\n\t\t}\n\t}\n\n\tprivate rectUpdate(params: UpdateContext<ZylemRectOptions>) {\n\t\tif (!this._sprite) return;\n\n\t\t// If bounds provided, compute screen-space rect from it and update size/position\n\t\tif (this._cameraRef && this.options.bounds) {\n\t\t\tconst dom = this._cameraRef.renderer.domElement;\n\t\t\tconst screen = this.computeScreenBoundsFromOptions(this.options.bounds);\n\t\t\tif (screen) {\n\t\t\t\tconst { x, y, width, height } = screen;\n\t\t\t\tconst desiredW = Math.max(2, Math.floor(width));\n\t\t\t\tconst desiredH = Math.max(2, Math.floor(height));\n\t\t\t\tconst changed = desiredW !== (this.options.width ?? 0) || desiredH !== (this.options.height ?? 0);\n\t\t\t\tthis.options.screenPosition = new Vector2(Math.floor(x), Math.floor(y));\n\t\t\t\tthis.options.width = desiredW;\n\t\t\t\tthis.options.height = desiredH;\n\t\t\t\tthis.options.anchor = new Vector2(0, 0);\n\t\t\t\tif (changed) {\n\t\t\t\t\tthis.redrawRect();\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\tif (this.options.stickToViewport && this._cameraRef) {\n\t\t\tthis.updateStickyTransform();\n\t\t}\n\t}\n\n\tprivate updateStickyTransform() {\n\t\tif (!this._sprite || !this._cameraRef) return;\n\t\tconst camera = this._cameraRef.camera;\n\t\tconst dom = this._cameraRef.renderer.domElement;\n\t\tconst width = dom.clientWidth;\n\t\tconst height = dom.clientHeight;\n\t\tconst px = (this.options.screenPosition ?? new Vector2(24, 24)).x;\n\t\tconst py = (this.options.screenPosition ?? new Vector2(24, 24)).y;\n\t\tconst zDist = Math.max(0.001, this.options.zDistance ?? 1);\n\n\t\tlet worldHalfW = 1;\n\t\tlet worldHalfH = 1;\n\t\tif ((camera as PerspectiveCamera).isPerspectiveCamera) {\n\t\t\tconst pc = camera as PerspectiveCamera;\n\t\t\tconst halfH = Math.tan((pc.fov * Math.PI) / 180 / 2) * zDist;\n\t\t\tconst halfW = halfH * pc.aspect;\n\t\t\tworldHalfW = halfW;\n\t\t\tworldHalfH = halfH;\n\t\t} else if ((camera as OrthographicCamera).isOrthographicCamera) {\n\t\t\tconst oc = camera as OrthographicCamera;\n\t\t\tworldHalfW = (oc.right - oc.left) / 2;\n\t\t\tworldHalfH = (oc.top - oc.bottom) / 2;\n\t\t}\n\n\t\tconst ndcX = (px / width) * 2 - 1;\n\t\tconst ndcY = 1 - (py / height) * 2;\n\t\tconst localX = ndcX * worldHalfW;\n\t\tconst localY = ndcY * worldHalfH;\n\n\t\tlet scaleX = 1;\n\t\tlet scaleY = 1;\n\t\tif (this._canvas) {\n\t\t\tconst planeH = worldHalfH * 2;\n\t\t\tconst unitsPerPixel = planeH / height;\n\t\t\tconst pixelH = this._canvas.height;\n\t\t\tscaleY = Math.max(0.0001, pixelH * unitsPerPixel);\n\t\t\tconst aspect = this._canvas.width / this._canvas.height;\n\t\t\tscaleX = scaleY * aspect;\n\t\t\tthis._sprite.scale.set(scaleX, scaleY, 1);\n\t\t\tif (this._mesh) this._mesh.scale.set(scaleX, scaleY, 1);\n\t\t}\n\n\t\tconst anchor = this.options.anchor ?? new Vector2(0, 0);\n\t\tconst ax = Math.min(100, Math.max(0, anchor.x)) / 100; // 0..1\n\t\tconst ay = Math.min(100, Math.max(0, anchor.y)) / 100; // 0..1\n\t\tconst offsetX = (0.5 - ax) * scaleX;\n\t\tconst offsetY = (ay - 0.5) * scaleY;\n\t\tthis.group?.position.set(localX + offsetX, localY + offsetY, -zDist);\n\t}\n\n\tprivate worldToScreen(point: Vector3) {\n\t\tif (!this._cameraRef) return { x: 0, y: 0 };\n\t\tconst camera = this._cameraRef.camera;\n\t\tconst dom = this._cameraRef.renderer.domElement;\n\t\tconst v = point.clone().project(camera);\n\t\tconst x = (v.x + 1) / 2 * dom.clientWidth;\n\t\tconst y = (1 - v.y) / 2 * dom.clientHeight;\n\t\treturn { x, y };\n\t}\n\n\tprivate computeScreenBoundsFromOptions(bounds: NonNullable<ZylemRectOptions['bounds']>): { x: number; y: number; width: number; height: number } | null {\n\t\tif (!this._cameraRef) return null;\n\t\tconst dom = this._cameraRef.renderer.domElement;\n\t\tif (bounds.screen) {\n\t\t\treturn { ...bounds.screen };\n\t\t}\n\t\tif (bounds.world) {\n\t\t\tconst { left, right, top, bottom, z = 0 } = bounds.world;\n\t\t\tconst tl = this.worldToScreen(new Vector3(left, top, z));\n\t\t\tconst br = this.worldToScreen(new Vector3(right, bottom, z));\n\t\t\tconst x = Math.min(tl.x, br.x);\n\t\t\tconst y = Math.min(tl.y, br.y);\n\t\t\tconst width = Math.abs(br.x - tl.x);\n\t\t\tconst height = Math.abs(br.y - tl.y);\n\t\t\treturn { x, y, width, height };\n\t\t}\n\t\treturn null;\n\t}\n\n\tupdateRect(options?: Partial<Pick<ZylemRectOptions, 'width' | 'height' | 'fillColor' | 'strokeColor' | 'strokeWidth' | 'radius'>>) {\n\t\tthis.options = { ...this.options, ...options } as ZylemRectOptions;\n\t\tthis.redrawRect();\n\t\tif (this.options.stickToViewport && this._cameraRef) {\n\t\t\tthis.updateStickyTransform();\n\t\t}\n\t}\n\n\tbuildInfo(): Record<string, any> {\n\t\tconst delegate = new DebugDelegate(this as any);\n\t\tconst baseInfo = delegate.buildDebugInfo();\n\n\t\treturn {\n\t\t\t...baseInfo,\n\t\t\ttype: String(ZylemRect.type),\n\t\t\twidth: this.options.width ?? 0,\n\t\t\theight: this.options.height ?? 0,\n\t\t\tsticky: this.options.stickToViewport,\n\t\t};\n\t}\n}\n\ntype RectOptions = BaseNode | Partial<ZylemRectOptions>;\n\nexport async function rect(...args: Array<RectOptions>): Promise<ZylemRect> {\n\treturn createEntity<ZylemRect, ZylemRectOptions>({\n\t\targs,\n\t\tdefaultConfig: { ...rectDefaults },\n\t\tEntityClass: ZylemRect,\n\t\tBuilderClass: RectBuilder,\n\t\tentityType: ZylemRect.type,\n\t});\n}\n\n\n"],"mappings":";AAAA,SA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C9B;AACA,WAAO;AAAA,EACR;AAAA,EAEA,WAAW,SAAwH;AAClI,SAAK,UAAU,EAAE,GAAG,KAAK,SAAS,GAAG,QAAQ;AAC7C,SAAK,WAAW;AAChB,QAAI,KAAK,QAAQ,mBAAmB,KAAK,YAAY;AACpD,WAAK,sBAAsB;AAAA,IAC5B;AAAA,EACD;AAAA,EAEA,YAAiC;AAChC,UAAM,WAAW,IAAI,cAAc,IAAW;AAC9C,UAAM,WAAW,SAAS,eAAe;AAEzC,WAAO;AAAA,MACN,GAAG;AAAA,MACH,MAAM,OAAO,WAAU,IAAI;AAAA,MAC3B,OAAO,KAAK,QAAQ,SAAS;AAAA,MAC7B,QAAQ,KAAK,QAAQ,UAAU;AAAA,MAC/B,QAAQ,KAAK,QAAQ;AAAA,IACtB;AAAA,EACD;AACD;AAIA,eAAsB,QAAQ,MAA8C;AAC3E,SAAO,aAA0C;AAAA,IAChD;AAAA,IACA,eAAe,EAAE,GAAG,aAAa;AAAA,IACjC,aAAa;AAAA,IACb,cAAc;AAAA,IACd,YAAY,UAAU;AAAA,EACvB,CAAC;AACF;","names":["ColliderDesc","Color","Vector3","BufferGeometry","Mesh","Color","Mesh","Color","ShaderMaterial","Vector3","debug_default","debug_default","Color","ShaderMaterial","Vector3","BufferGeometry","Mesh","Color","MeshStandardMaterial","MeshPhongMaterial","x","y","z","toDeg","Vector3","Color","ColliderDesc","ColliderDesc","Color","Vector3","Vector3","Color","ColliderDesc","ColliderDesc","Color","Group","Quaternion","Vector3","TextureLoader","Vector3","Color","ColliderDesc","TextureLoader","Group","Quaternion","ColliderDesc","Color","Vector2","Vector3","BufferGeometry","Vector2","Vector3","Color","scale","ColliderDesc","ActiveCollisionTypes","ColliderDesc","Vector3","Vector3","ColliderDesc","ActiveCollisionTypes","ActiveCollisionTypes","ColliderDesc","Group","Vector3","Vector3","ColliderDesc","ActiveCollisionTypes","Group","Color","Group","ThreeSprite","SpriteMaterial","Vector2","Vector2","Group","SpriteMaterial","ThreeSprite","text","Color","Color","Group","ThreeSprite","SpriteMaterial","CanvasTexture","LinearFilter","Vector2","ClampToEdgeWrapping","ShaderMaterial","Mesh","PlaneGeometry","Vector3","Vector2","Group","CanvasTexture","LinearFilter","SpriteMaterial","ThreeSprite","ClampToEdgeWrapping","ShaderMaterial","Color","Mesh","PlaneGeometry","Vector3"]}
|
|
1
|
+
{"version":3,"sources":["../src/lib/systems/transformable.system.ts","../src/lib/core/flags.ts","../src/lib/core/base-node.ts","../../../node_modules/.pnpm/mitt@3.0.1/node_modules/mitt/src/index.ts","../src/lib/events/event-emitter-delegate.ts","../src/lib/events/zylem-events.ts","../src/lib/events/index.ts","../src/lib/entities/entity.ts","../src/lib/collision/collision-builder.ts","../src/lib/graphics/mesh.ts","../src/lib/core/utility/strings.ts","../src/lib/graphics/shaders/vertex/object.shader.ts","../src/lib/graphics/shaders/standard.shader.ts","../src/lib/core/loaders/texture-loader.ts","../src/lib/core/loaders/gltf-loader.ts","../src/lib/core/loaders/fbx-loader.ts","../src/lib/core/loaders/obj-loader.ts","../src/lib/core/loaders/audio-loader.ts","../src/lib/core/loaders/file-loader.ts","../src/lib/core/loaders/index.ts","../src/lib/core/asset-manager.ts","../src/lib/graphics/material.ts","../src/lib/entities/builder.ts","../src/lib/entities/delegates/debug.ts","../src/lib/entities/delegates/loader.ts","../src/lib/entities/create.ts","../src/lib/entities/common.ts","../src/lib/entities/box.ts","../src/lib/entities/sphere.ts","../src/lib/entities/sprite.ts","../src/lib/graphics/geometries/XZPlaneGeometry.ts","../src/lib/entities/plane.ts","../src/lib/game/game-state.ts","../src/lib/entities/zone.ts","../src/lib/core/entity-asset-loader.ts","../src/lib/entities/delegates/animation.ts","../src/lib/entities/text.ts","../src/lib/entities/rect.ts","../src/lib/behaviors/thruster/index.ts","../src/lib/behaviors/screen-wrap/index.ts","../src/lib/behaviors/world-boundary-2d/index.ts","../src/lib/behaviors/ricochet-2d/index.ts","../src/lib/behaviors/movement-sequence-2d/index.ts","../src/lib/coordinators/boundary-ricochet.coordinator.ts","../src/lib/behaviors/index.ts","../src/api/main.ts","../src/lib/entities/actor.ts","../src/api/entities.ts"],"sourcesContent":["import {\n\tdefineSystem,\n\tdefineQuery,\n\tdefineComponent,\n\tTypes,\n\tremoveQuery,\n\ttype IWorld,\n} from 'bitecs';\nimport { Quaternion } from 'three';\nimport { StageEntity } from '../interfaces/entity';\nimport RAPIER from '@dimforge/rapier3d-compat';\n\nexport type StageSystem = {\n\t_childrenMap: Map<number, StageEntity & { body: RAPIER.RigidBody }>;\n}\n\nexport const position = defineComponent({\n\tx: Types.f32,\n\ty: Types.f32,\n\tz: Types.f32\n});\n\nexport const rotation = defineComponent({\n\tx: Types.f32,\n\ty: Types.f32,\n\tz: Types.f32,\n\tw: Types.f32\n});\n\nexport const scale = defineComponent({\n\tx: Types.f32,\n\ty: Types.f32,\n\tz: Types.f32\n});\n\n// Reusable quaternion to avoid allocations per frame\nconst _tempQuaternion = new Quaternion();\n\nexport type TransformSystemResult = {\n\tsystem: ReturnType<typeof defineSystem>;\n\tdestroy: (world: IWorld) => void;\n};\n\nexport default function createTransformSystem(stage: StageSystem): TransformSystemResult {\n\tconst queryTerms = [position, rotation];\n\tconst transformQuery = defineQuery(queryTerms);\n\tconst stageEntities = stage._childrenMap;\n\n\tconst system = defineSystem((world) => {\n\t\tconst entities = transformQuery(world);\n\t\tif (stageEntities === undefined) {\n\t\t\treturn world;\n\t\t}\n\n\t\tfor (const [key, stageEntity] of stageEntities) {\n\t\t\t// Early bailout - combine conditions\n\t\t\tif (!stageEntity?.body || stageEntity.markedForRemoval) {\n\t\t\t\tcontinue;\n\t\t\t}\n\n\t\t\tconst id = entities[key];\n\t\t\tconst body = stageEntity.body;\n\t\t\tconst target = stageEntity.group ?? stageEntity.mesh;\n\n\t\t\t// Position sync\n\t\t\tconst translation = body.translation();\n\t\t\tposition.x[id] = translation.x;\n\t\t\tposition.y[id] = translation.y;\n\t\t\tposition.z[id] = translation.z;\n\n\t\t\tif (target) {\n\t\t\t\ttarget.position.set(translation.x, translation.y, translation.z);\n\t\t\t}\n\n\t\t\t// Skip rotation if controlled externally\n\t\t\tif (stageEntity.controlledRotation) {\n\t\t\t\tcontinue;\n\t\t\t}\n\n\t\t\t// Rotation sync - reuse quaternion\n\t\t\tconst rot = body.rotation();\n\t\t\trotation.x[id] = rot.x;\n\t\t\trotation.y[id] = rot.y;\n\t\t\trotation.z[id] = rot.z;\n\t\t\trotation.w[id] = rot.w;\n\n\t\t\tif (target) {\n\t\t\t\t_tempQuaternion.set(rot.x, rot.y, rot.z, rot.w);\n\t\t\t\ttarget.setRotationFromQuaternion(_tempQuaternion);\n\t\t\t}\n\t\t}\n\n\t\treturn world;\n\t});\n\n\tconst destroy = (world: IWorld) => {\n\t\t// Remove the query from bitecs world tracking\n\t\tremoveQuery(world, transformQuery);\n\t};\n\n\treturn { system, destroy };\n}","/** Vite build flags */\nexport const DEBUG_FLAG = import.meta.env.VITE_DEBUG_FLAG === 'true';","import {\n\tCleanupContext,\n\tCleanupFunction,\n\tDestroyContext,\n\tDestroyFunction,\n\tLoadedContext,\n\tLoadedFunction,\n\tSetupContext,\n\tSetupFunction,\n\tUpdateContext,\n\tUpdateFunction,\n} from \"./base-node-life-cycle\";\nimport { DEBUG_FLAG } from \"./flags\";\nimport { nanoid } from \"nanoid\";\nimport { NodeInterface } from \"./node-interface\";\n\nexport type BaseNodeOptions<T = any> = BaseNode | Partial<T>;\n\n/**\n * Lifecycle callback arrays - each lifecycle event can have multiple callbacks\n * that execute in order.\n */\nexport interface LifecycleCallbacks<T> {\n\tsetup: Array<SetupFunction<T>>;\n\tloaded: Array<LoadedFunction<T>>;\n\tupdate: Array<UpdateFunction<T>>;\n\tdestroy: Array<DestroyFunction<T>>;\n\tcleanup: Array<CleanupFunction<T>>;\n}\n\nexport abstract class BaseNode<Options = any, T = any> implements NodeInterface {\n\tprotected parent: NodeInterface | null = null;\n\tprotected children: NodeInterface[] = [];\n\tpublic options: Options;\n\tpublic eid: number = 0;\n\tpublic uuid: string = '';\n\tpublic name: string = '';\n\tpublic markedForRemoval: boolean = false;\n\n\t/**\n\t * Lifecycle callback arrays - use onSetup(), onUpdate(), etc. to add callbacks\n\t */\n\tprotected lifecycleCallbacks: LifecycleCallbacks<this> = {\n\t\tsetup: [],\n\t\tloaded: [],\n\t\tupdate: [],\n\t\tdestroy: [],\n\t\tcleanup: [],\n\t};\n\n\tconstructor(args: BaseNodeOptions[] = []) {\n\t\tconst options = args\n\t\t\t.filter(arg => !(arg instanceof BaseNode))\n\t\t\t.reduce((acc, opt) => ({ ...acc, ...opt }), {});\n\t\tthis.options = options as Options;\n\t\tthis.uuid = nanoid();\n\t}\n\n\t// ─────────────────────────────────────────────────────────────────────────────\n\t// Fluent API for adding lifecycle callbacks\n\t// ─────────────────────────────────────────────────────────────────────────────\n\n\t/**\n\t * Add setup callbacks to be executed in order during nodeSetup\n\t */\n\tpublic onSetup(...callbacks: Array<SetupFunction<this>>): this {\n\t\tthis.lifecycleCallbacks.setup.push(...callbacks);\n\t\treturn this;\n\t}\n\n\t/**\n\t * Add loaded callbacks to be executed in order during nodeLoaded\n\t */\n\tpublic onLoaded(...callbacks: Array<LoadedFunction<this>>): this {\n\t\tthis.lifecycleCallbacks.loaded.push(...callbacks);\n\t\treturn this;\n\t}\n\n\t/**\n\t * Add update callbacks to be executed in order during nodeUpdate\n\t */\n\tpublic onUpdate(...callbacks: Array<UpdateFunction<this>>): this {\n\t\tthis.lifecycleCallbacks.update.push(...callbacks);\n\t\treturn this;\n\t}\n\n\t/**\n\t * Add destroy callbacks to be executed in order during nodeDestroy\n\t */\n\tpublic onDestroy(...callbacks: Array<DestroyFunction<this>>): this {\n\t\tthis.lifecycleCallbacks.destroy.push(...callbacks);\n\t\treturn this;\n\t}\n\n\t/**\n\t * Add cleanup callbacks to be executed in order during nodeCleanup\n\t */\n\tpublic onCleanup(...callbacks: Array<CleanupFunction<this>>): this {\n\t\tthis.lifecycleCallbacks.cleanup.push(...callbacks);\n\t\treturn this;\n\t}\n\n\t/**\n\t * Prepend setup callbacks (run before existing ones)\n\t */\n\tpublic prependSetup(...callbacks: Array<SetupFunction<this>>): this {\n\t\tthis.lifecycleCallbacks.setup.unshift(...callbacks);\n\t\treturn this;\n\t}\n\n\t/**\n\t * Prepend update callbacks (run before existing ones)\n\t */\n\tpublic prependUpdate(...callbacks: Array<UpdateFunction<this>>): this {\n\t\tthis.lifecycleCallbacks.update.unshift(...callbacks);\n\t\treturn this;\n\t}\n\n\t// ─────────────────────────────────────────────────────────────────────────────\n\t// Tree structure\n\t// ─────────────────────────────────────────────────────────────────────────────\n\n\tpublic setParent(parent: NodeInterface | null): void {\n\t\tthis.parent = parent;\n\t}\n\n\tpublic getParent(): NodeInterface | null {\n\t\treturn this.parent;\n\t}\n\n\tpublic add(baseNode: NodeInterface): void {\n\t\tthis.children.push(baseNode);\n\t\tbaseNode.setParent(this);\n\t}\n\n\tpublic remove(baseNode: NodeInterface): void {\n\t\tconst index = this.children.indexOf(baseNode);\n\t\tif (index !== -1) {\n\t\t\tthis.children.splice(index, 1);\n\t\t\tbaseNode.setParent(null);\n\t\t}\n\t}\n\n\tpublic getChildren(): NodeInterface[] {\n\t\treturn this.children;\n\t}\n\n\tpublic isComposite(): boolean {\n\t\treturn this.children.length > 0;\n\t}\n\n\t// ─────────────────────────────────────────────────────────────────────────────\n\t// Abstract methods for subclass implementation\n\t// ─────────────────────────────────────────────────────────────────────────────\n\n\tpublic abstract create(): T;\n\n\tprotected abstract _setup(params: SetupContext<this>): void;\n\n\tprotected abstract _loaded(params: LoadedContext<this>): Promise<void>;\n\n\tprotected abstract _update(params: UpdateContext<this>): void;\n\n\tprotected abstract _destroy(params: DestroyContext<this>): void;\n\n\tprotected abstract _cleanup(params: CleanupContext<this>): Promise<void>;\n\n\t// ─────────────────────────────────────────────────────────────────────────────\n\t// Node lifecycle execution - runs internal + callback arrays\n\t// ─────────────────────────────────────────────────────────────────────────────\n\n\tpublic nodeSetup(params: SetupContext<this>) {\n\t\tif (DEBUG_FLAG) { /** */ }\n\t\tthis.markedForRemoval = false;\n\n\t\t// 1. Internal setup\n\t\tif (typeof this._setup === 'function') {\n\t\t\tthis._setup(params);\n\t\t}\n\n\t\t// 2. Run all setup callbacks in order\n\t\tfor (const callback of this.lifecycleCallbacks.setup) {\n\t\t\tcallback(params);\n\t\t}\n\n\t\t// 3. Setup children\n\t\tthis.children.forEach(child => child.nodeSetup(params));\n\t}\n\n\tpublic nodeUpdate(params: UpdateContext<this>): void {\n\t\tif (this.markedForRemoval) {\n\t\t\treturn;\n\t\t}\n\n\t\t// 1. Internal update\n\t\tif (typeof this._update === 'function') {\n\t\t\tthis._update(params);\n\t\t}\n\n\t\t// 2. Run all update callbacks in order\n\t\tfor (const callback of this.lifecycleCallbacks.update) {\n\t\t\tcallback(params);\n\t\t}\n\n\t\t// 3. Update children\n\t\tthis.children.forEach(child => child.nodeUpdate(params));\n\t}\n\n\tpublic nodeDestroy(params: DestroyContext<this>): void {\n\t\t// 1. Destroy children first\n\t\tthis.children.forEach(child => child.nodeDestroy(params));\n\n\t\t// 2. Run all destroy callbacks in order\n\t\tfor (const callback of this.lifecycleCallbacks.destroy) {\n\t\t\tcallback(params);\n\t\t}\n\n\t\t// 3. Internal destroy\n\t\tif (typeof this._destroy === 'function') {\n\t\t\tthis._destroy(params);\n\t\t}\n\n\t\tthis.markedForRemoval = true;\n\t}\n\n\tpublic async nodeLoaded(params: LoadedContext<this>): Promise<void> {\n\t\t// 1. Internal loaded\n\t\tif (typeof this._loaded === 'function') {\n\t\t\tawait this._loaded(params);\n\t\t}\n\n\t\t// 2. Run all loaded callbacks in order\n\t\tfor (const callback of this.lifecycleCallbacks.loaded) {\n\t\t\tcallback(params);\n\t\t}\n\t}\n\n\tpublic async nodeCleanup(params: CleanupContext<this>): Promise<void> {\n\t\t// 1. Run all cleanup callbacks in order\n\t\tfor (const callback of this.lifecycleCallbacks.cleanup) {\n\t\t\tcallback(params);\n\t\t}\n\n\t\t// 2. Internal cleanup\n\t\tif (typeof this._cleanup === 'function') {\n\t\t\tawait this._cleanup(params);\n\t\t}\n\t}\n\n\t// ─────────────────────────────────────────────────────────────────────────────\n\t// Options\n\t// ─────────────────────────────────────────────────────────────────────────────\n\n\tpublic getOptions(): Options {\n\t\treturn this.options;\n\t}\n\n\tpublic setOptions(options: Partial<Options>): void {\n\t\tthis.options = { ...this.options, ...options };\n\t}\n}","export type EventType = string | symbol;\n\n// An event handler can take an optional event argument\n// and should not return a value\nexport type Handler<T = unknown> = (event: T) => void;\nexport type WildcardHandler<T = Record<string, unknown>> = (\n\ttype: keyof T,\n\tevent: T[keyof T]\n) => void;\n\n// An array of all currently registered event handlers for a type\nexport type EventHandlerList<T = unknown> = Array<Handler<T>>;\nexport type WildCardEventHandlerList<T = Record<string, unknown>> = Array<\n\tWildcardHandler<T>\n>;\n\n// A map of event types and their corresponding event handlers.\nexport type EventHandlerMap<Events extends Record<EventType, unknown>> = Map<\n\tkeyof Events | '*',\n\tEventHandlerList<Events[keyof Events]> | WildCardEventHandlerList<Events>\n>;\n\nexport interface Emitter<Events extends Record<EventType, unknown>> {\n\tall: EventHandlerMap<Events>;\n\n\ton<Key extends keyof Events>(type: Key, handler: Handler<Events[Key]>): void;\n\ton(type: '*', handler: WildcardHandler<Events>): void;\n\n\toff<Key extends keyof Events>(\n\t\ttype: Key,\n\t\thandler?: Handler<Events[Key]>\n\t): void;\n\toff(type: '*', handler: WildcardHandler<Events>): void;\n\n\temit<Key extends keyof Events>(type: Key, event: Events[Key]): void;\n\temit<Key extends keyof Events>(\n\t\ttype: undefined extends Events[Key] ? Key : never\n\t): void;\n}\n\n/**\n * Mitt: Tiny (~200b) functional event emitter / pubsub.\n * @name mitt\n * @returns {Mitt}\n */\nexport default function mitt<Events extends Record<EventType, unknown>>(\n\tall?: EventHandlerMap<Events>\n): Emitter<Events> {\n\ttype GenericEventHandler =\n\t\t| Handler<Events[keyof Events]>\n\t\t| WildcardHandler<Events>;\n\tall = all || new Map();\n\n\treturn {\n\t\t/**\n\t\t * A Map of event names to registered handler functions.\n\t\t */\n\t\tall,\n\n\t\t/**\n\t\t * Register an event handler for the given type.\n\t\t * @param {string|symbol} type Type of event to listen for, or `'*'` for all events\n\t\t * @param {Function} handler Function to call in response to given event\n\t\t * @memberOf mitt\n\t\t */\n\t\ton<Key extends keyof Events>(type: Key, handler: GenericEventHandler) {\n\t\t\tconst handlers: Array<GenericEventHandler> | undefined = all!.get(type);\n\t\t\tif (handlers) {\n\t\t\t\thandlers.push(handler);\n\t\t\t} else {\n\t\t\t\tall!.set(type, [handler] as EventHandlerList<Events[keyof Events]>);\n\t\t\t}\n\t\t},\n\n\t\t/**\n\t\t * Remove an event handler for the given type.\n\t\t * If `handler` is omitted, all handlers of the given type are removed.\n\t\t * @param {string|symbol} type Type of event to unregister `handler` from (`'*'` to remove a wildcard handler)\n\t\t * @param {Function} [handler] Handler function to remove\n\t\t * @memberOf mitt\n\t\t */\n\t\toff<Key extends keyof Events>(type: Key, handler?: GenericEventHandler) {\n\t\t\tconst handlers: Array<GenericEventHandler> | undefined = all!.get(type);\n\t\t\tif (handlers) {\n\t\t\t\tif (handler) {\n\t\t\t\t\thandlers.splice(handlers.indexOf(handler) >>> 0, 1);\n\t\t\t\t} else {\n\t\t\t\t\tall!.set(type, []);\n\t\t\t\t}\n\t\t\t}\n\t\t},\n\n\t\t/**\n\t\t * Invoke all handlers for the given type.\n\t\t * If present, `'*'` handlers are invoked after type-matched handlers.\n\t\t *\n\t\t * Note: Manually firing '*' handlers is not supported.\n\t\t *\n\t\t * @param {string|symbol} type The event type to invoke\n\t\t * @param {Any} [evt] Any value (object is recommended and powerful), passed to each handler\n\t\t * @memberOf mitt\n\t\t */\n\t\temit<Key extends keyof Events>(type: Key, evt?: Events[Key]) {\n\t\t\tlet handlers = all!.get(type);\n\t\t\tif (handlers) {\n\t\t\t\t(handlers as EventHandlerList<Events[keyof Events]>)\n\t\t\t\t\t.slice()\n\t\t\t\t\t.map((handler) => {\n\t\t\t\t\t\thandler(evt!);\n\t\t\t\t\t});\n\t\t\t}\n\n\t\t\thandlers = all!.get('*');\n\t\t\tif (handlers) {\n\t\t\t\t(handlers as WildCardEventHandlerList<Events>)\n\t\t\t\t\t.slice()\n\t\t\t\t\t.map((handler) => {\n\t\t\t\t\t\thandler(type, evt!);\n\t\t\t\t\t});\n\t\t\t}\n\t\t}\n\t};\n}\n","import mitt, { Emitter } from 'mitt';\n\n/**\n * Event scope identifier for routing events.\n */\nexport type EventScope = 'game' | 'stage' | 'entity';\n\n/**\n * Reusable delegate for event emission and subscription.\n * Use via composition in Game, Stage, and Entity classes.\n * \n * @example\n * class Game {\n * private eventDelegate = new EventEmitterDelegate<GameEvents>();\n * \n * dispatch<K extends keyof GameEvents>(event: K, payload: GameEvents[K]) {\n * this.eventDelegate.dispatch(event, payload);\n * }\n * }\n */\nexport class EventEmitterDelegate<TEvents extends Record<string, unknown>> {\n\tprivate emitter: Emitter<TEvents>;\n\tprivate unsubscribes: (() => void)[] = [];\n\n\tconstructor() {\n\t\tthis.emitter = mitt<TEvents>();\n\t}\n\n\t/**\n\t * Dispatch an event to all listeners.\n\t */\n\tdispatch<K extends keyof TEvents>(event: K, payload: TEvents[K]): void {\n\t\tthis.emitter.emit(event, payload);\n\t}\n\n\t/**\n\t * Subscribe to an event. Returns an unsubscribe function.\n\t */\n\tlisten<K extends keyof TEvents>(\n\t\tevent: K,\n\t\thandler: (payload: TEvents[K]) => void\n\t): () => void {\n\t\tthis.emitter.on(event, handler);\n\t\tconst unsub = () => this.emitter.off(event, handler);\n\t\tthis.unsubscribes.push(unsub);\n\t\treturn unsub;\n\t}\n\n\t/**\n\t * Subscribe to all events.\n\t */\n\tlistenAll(handler: (type: keyof TEvents, payload: TEvents[keyof TEvents]) => void): () => void {\n\t\tthis.emitter.on('*', handler as any);\n\t\tconst unsub = () => this.emitter.off('*', handler as any);\n\t\tthis.unsubscribes.push(unsub);\n\t\treturn unsub;\n\t}\n\n\t/**\n\t * Clean up all subscriptions.\n\t */\n\tdispose(): void {\n\t\tthis.unsubscribes.forEach(fn => fn());\n\t\tthis.unsubscribes = [];\n\t\tthis.emitter.all.clear();\n\t}\n}\n","import mitt from 'mitt';\nimport type { LoadingEvent } from '../core/interfaces';\n\n/**\n * Payload for game loading events with stage context.\n */\nexport interface GameLoadingPayload extends LoadingEvent {\n\tstageName?: string;\n\tstageIndex?: number;\n}\n\n// ─────────────────────────────────────────────────────────────────────────────\n// Game Events\n// ─────────────────────────────────────────────────────────────────────────────\n\n/** Payload for stage configuration sent to editor. */\nexport interface StageConfigPayload {\n\tid: string;\n\tbackgroundColor: string;\n\tbackgroundImage: string | null;\n\tgravity: { x: number; y: number; z: number };\n\tinputs: Record<string, string[]>;\n\tvariables: Record<string, unknown>;\n}\n\n/** Payload for entity configuration sent to editor. */\nexport interface EntityConfigPayload {\n\tuuid: string;\n\tname: string;\n\ttype: string;\n\tposition: { x: number; y: number; z: number };\n\trotation: { x: number; y: number; z: number };\n\tscale: { x: number; y: number; z: number };\n}\n\n/** Payload for state dispatch events from game to editor. */\nexport interface StateDispatchPayload {\n\tscope: 'game' | 'stage' | 'entity';\n\tpath: string;\n\tvalue: unknown;\n\tpreviousValue?: unknown;\n\tconfig?: {\n\t\tid: string;\n\t\taspectRatio: number;\n\t\tfullscreen: boolean;\n\t\tbodyBackground: string | undefined;\n\t\tinternalResolution: { width: number; height: number } | undefined;\n\t\tdebug: boolean;\n\t} | null;\n\tstageConfig?: StageConfigPayload | null;\n\tentities?: EntityConfigPayload[] | null;\n}\n\nexport type GameEvents = {\n\t'loading:start': GameLoadingPayload;\n\t'loading:progress': GameLoadingPayload;\n\t'loading:complete': GameLoadingPayload;\n\t'paused': { paused: boolean };\n\t'debug': { enabled: boolean };\n\t'state:dispatch': StateDispatchPayload;\n};\n\n// ─────────────────────────────────────────────────────────────────────────────\n// Stage Events\n// ─────────────────────────────────────────────────────────────────────────────\n\nexport type StageEvents = {\n\t'stage:loaded': { stageId: string };\n\t'stage:unloaded': { stageId: string };\n\t'stage:variable:changed': { key: string; value: unknown };\n};\n\n// ─────────────────────────────────────────────────────────────────────────────\n// Entity Events\n// ─────────────────────────────────────────────────────────────────────────────\n\nexport type EntityEvents = {\n\t'entity:spawned': { entityId: string; name: string };\n\t'entity:destroyed': { entityId: string };\n\t'entity:collision': { entityId: string; otherId: string };\n\t'entity:model:loading': { entityId: string; files: string[] };\n\t'entity:model:loaded': { entityId: string; success: boolean; meshCount?: number };\n\t'entity:animation:loaded': { entityId: string; animationCount: number };\n};\n\n// ─────────────────────────────────────────────────────────────────────────────\n// Combined Event Map\n// ─────────────────────────────────────────────────────────────────────────────\n\nexport type ZylemEvents = GameEvents & StageEvents & EntityEvents;\n\n/**\n * Global event bus for cross-package communication.\n * \n * Usage:\n * ```ts\n * import { zylemEventBus } from '@zylem/game-lib';\n * \n * // Subscribe\n * const unsub = zylemEventBus.on('loading:progress', (e) => console.log(e));\n * \n * // Emit\n * zylemEventBus.emit('loading:progress', { type: 'progress', progress: 0.5 });\n * \n * // Cleanup\n * unsub();\n * ```\n */\nexport const zylemEventBus = mitt<ZylemEvents>();\n","export { EventEmitterDelegate, type EventScope } from './event-emitter-delegate';\nexport {\n\tzylemEventBus,\n\ttype ZylemEvents,\n\ttype GameEvents,\n\ttype StageEvents,\n\ttype EntityEvents,\n\ttype GameLoadingPayload,\n\ttype StateDispatchPayload,\n\ttype StageConfigPayload,\n\ttype EntityConfigPayload,\n} from './zylem-events';\n","import { Mesh, Material, ShaderMaterial, Group, Color } from 'three';\nimport {\n Collider,\n ColliderDesc,\n RigidBody,\n RigidBodyDesc,\n} from '@dimforge/rapier3d-compat';\nimport { position, rotation, scale } from '../systems/transformable.system';\nimport { Vec3 } from '../core/vector';\nimport { MaterialBuilder, MaterialOptions } from '../graphics/material';\nimport { CollisionOptions } from '../collision/collision-builder';\nimport { BaseNode } from '../core/base-node';\nimport {\n DestroyContext,\n SetupContext,\n UpdateContext,\n LoadedContext,\n CleanupContext,\n} from '../core/base-node-life-cycle';\nimport type { EntityMeshBuilder, EntityCollisionBuilder } from './builder';\nimport { Behavior } from '../actions/behaviors/behavior';\nimport {\n EventEmitterDelegate,\n zylemEventBus,\n type EntityEvents,\n} from '../events';\nimport type {\n BehaviorDescriptor,\n BehaviorRef,\n BehaviorHandle,\n} from '../behaviors/behavior-descriptor';\n\nexport interface CollisionContext<\n T,\n O extends GameEntityOptions,\n TGlobals extends Record<string, unknown> = any,\n> {\n entity: T;\n // Use 'any' for other's options type to break recursive type variance issues\n other: GameEntity<O | any>;\n globals: TGlobals;\n}\n\nexport type BehaviorContext<T, O extends GameEntityOptions> =\n | SetupContext<T, O>\n | UpdateContext<T, O>\n | CollisionContext<T, O>\n | DestroyContext<T, O>;\n\nexport type BehaviorCallback<T, O extends GameEntityOptions> = (\n params: BehaviorContext<T, O>,\n) => void;\n\nexport interface CollisionDelegate<T, O extends GameEntityOptions> {\n // Use 'any' for entity and options types to avoid contravariance issues\n // with function parameters. Type safety is still enforced at the call site via onCollision()\n collision?: ((params: CollisionContext<any, any>) => void)[];\n}\n\nexport type IBuilder<BuilderOptions = any> = {\n preBuild: (options: BuilderOptions) => BuilderOptions;\n build: (options: BuilderOptions) => BuilderOptions;\n postBuild: (options: BuilderOptions) => BuilderOptions;\n};\n\nexport type GameEntityOptions = {\n name?: string;\n color?: Color;\n size?: Vec3;\n position?: Vec3;\n batched?: boolean;\n collision?: Partial<CollisionOptions>;\n material?: Partial<MaterialOptions>;\n custom?: { [key: string]: any };\n collisionType?: string;\n collisionGroup?: string;\n collisionFilter?: string[];\n _builders?: {\n meshBuilder?: IBuilder | EntityMeshBuilder | null;\n collisionBuilder?: IBuilder | EntityCollisionBuilder | null;\n materialBuilder?: MaterialBuilder | null;\n };\n};\n\nexport abstract class GameEntityLifeCycle {\n abstract _setup(params: SetupContext<this>): void;\n abstract _update(params: UpdateContext<this>): void;\n abstract _destroy(params: DestroyContext<this>): void;\n}\n\nexport interface EntityDebugInfo {\n buildInfo: () => Record<string, string>;\n}\n\nexport type BehaviorCallbackType = 'setup' | 'update' | 'destroy' | 'collision';\n\nexport class GameEntity<O extends GameEntityOptions>\n extends BaseNode<O>\n implements GameEntityLifeCycle, EntityDebugInfo\n{\n public behaviors: Behavior[] = [];\n public group: Group | undefined;\n public mesh: Mesh | undefined;\n public materials: Material[] | undefined;\n public bodyDesc: RigidBodyDesc | null = null;\n public body: RigidBody | null = null;\n public colliderDesc: ColliderDesc | undefined;\n public collider: Collider | undefined;\n public custom: Record<string, any> = {};\n\n public debugInfo: Record<string, any> = {};\n public debugMaterial: ShaderMaterial | undefined;\n\n public collisionDelegate: CollisionDelegate<this, O> = {\n collision: [],\n };\n public collisionType?: string;\n\n /**\n * @deprecated Use the new ECS-based behavior system instead.\n * Use 'any' for callback types to avoid contravariance issues\n * with function parameters. Type safety is enforced where callbacks are registered.\n */\n public behaviorCallbackMap: Record<\n BehaviorCallbackType,\n BehaviorCallback<any, any>[]\n > = {\n setup: [],\n update: [],\n destroy: [],\n collision: [],\n };\n\n // Event delegate for dispatch/listen API\n protected eventDelegate = new EventEmitterDelegate<EntityEvents>();\n\n // Behavior references (new ECS pattern)\n private behaviorRefs: BehaviorRef[] = [];\n\n constructor() {\n super();\n }\n\n public create(): this {\n const { position: setupPosition } = this.options;\n const { x, y, z } = setupPosition || { x: 0, y: 0, z: 0 };\n this.behaviors = [\n { component: position, values: { x, y, z } },\n { component: scale, values: { x: 0, y: 0, z: 0 } },\n { component: rotation, values: { x: 0, y: 0, z: 0, w: 0 } },\n ];\n this.name = this.options.name || '';\n return this;\n }\n\n /**\n * Add collision callbacks\n */\n public onCollision(\n ...callbacks: ((params: CollisionContext<this, O>) => void)[]\n ): this {\n const existing = this.collisionDelegate.collision ?? [];\n this.collisionDelegate.collision = [...existing, ...callbacks];\n return this;\n }\n\n /**\n * Use a behavior on this entity via typed descriptor.\n * Behaviors will be auto-registered as systems when the entity is spawned.\n * @param descriptor The behavior descriptor (import from behaviors module)\n * @param options Optional overrides for the behavior's default options\n * @returns BehaviorHandle with behavior-specific methods for lazy FSM access\n */\n public use<\n O extends Record<string, any>,\n H extends Record<string, any> = Record<string, never>,\n >(\n descriptor: BehaviorDescriptor<O, H>,\n options?: Partial<O>,\n ): BehaviorHandle<O, H> {\n const behaviorRef: BehaviorRef<O> = {\n descriptor: descriptor as BehaviorDescriptor<O, any>,\n options: { ...descriptor.defaultOptions, ...options } as O,\n };\n this.behaviorRefs.push(behaviorRef as BehaviorRef<any>);\n\n // Create base handle\n const baseHandle = {\n getFSM: () => behaviorRef.fsm ?? null,\n getOptions: () => behaviorRef.options,\n ref: behaviorRef,\n };\n\n // Merge behavior-specific methods if createHandle is provided\n const customMethods = descriptor.createHandle?.(behaviorRef) ?? ({} as H);\n\n return {\n ...baseHandle,\n ...customMethods,\n } as BehaviorHandle<O, H>;\n }\n\n /**\n * Get all behavior references attached to this entity.\n * Used by the stage to auto-register required systems.\n */\n public getBehaviorRefs(): BehaviorRef[] {\n return this.behaviorRefs;\n }\n\n /**\n * Entity-specific setup - runs behavior callbacks\n * (User callbacks are handled by BaseNode's lifecycleCallbacks.setup)\n */\n public _setup(params: SetupContext<this>): void {\n this.behaviorCallbackMap.setup.forEach((callback) => {\n callback({ ...params, me: this });\n });\n }\n\n protected async _loaded(_params: LoadedContext<this>): Promise<void> {}\n\n /**\n * Entity-specific update - updates materials and runs behavior callbacks\n * (User callbacks are handled by BaseNode's lifecycleCallbacks.update)\n */\n public _update(params: UpdateContext<this>): void {\n this.updateMaterials(params);\n this.behaviorCallbackMap.update.forEach((callback) => {\n callback({ ...params, me: this });\n });\n }\n\n /**\n * Entity-specific destroy - runs behavior callbacks\n * (User callbacks are handled by BaseNode's lifecycleCallbacks.destroy)\n */\n public _destroy(params: DestroyContext<this>): void {\n this.behaviorCallbackMap.destroy.forEach((callback) => {\n callback({ ...params, me: this });\n });\n }\n\n protected async _cleanup(_params: CleanupContext<this>): Promise<void> {}\n\n public _collision(other: GameEntity<O>, globals?: any): void {\n if (this.collisionDelegate.collision?.length) {\n const callbacks = this.collisionDelegate.collision;\n callbacks.forEach((callback) => {\n callback({ entity: this, other, globals });\n });\n }\n this.behaviorCallbackMap.collision.forEach((callback) => {\n callback({ entity: this, other, globals });\n });\n }\n\n /**\n * @deprecated Use the new ECS-based behavior system instead.\n * See `lib/behaviors/thruster/thruster-movement.behavior.ts` for an example.\n */\n public addBehavior(behaviorCallback: {\n type: BehaviorCallbackType;\n handler: any;\n }): this {\n const handler = behaviorCallback.handler as unknown as BehaviorCallback<\n this,\n O\n >;\n if (handler) {\n this.behaviorCallbackMap[behaviorCallback.type].push(handler);\n }\n return this;\n }\n\n /**\n * @deprecated Use the new ECS-based behavior system instead.\n * See `lib/behaviors/thruster/thruster-movement.behavior.ts` for an example.\n */\n public addBehaviors(\n behaviorCallbacks: { type: BehaviorCallbackType; handler: any }[],\n ): this {\n behaviorCallbacks.forEach((callback) => {\n const handler = callback.handler as unknown as BehaviorCallback<this, O>;\n if (handler) {\n this.behaviorCallbackMap[callback.type].push(handler);\n }\n });\n return this;\n }\n\n protected updateMaterials(params: any) {\n if (!this.materials?.length) {\n return;\n }\n for (const material of this.materials) {\n if (material instanceof ShaderMaterial) {\n if (material.uniforms) {\n material.uniforms.iTime &&\n (material.uniforms.iTime.value += params.delta);\n }\n }\n }\n }\n\n public buildInfo(): Record<string, string> {\n const info: Record<string, string> = {};\n info.name = this.name;\n info.uuid = this.uuid;\n info.eid = this.eid.toString();\n return info;\n }\n\n // ─────────────────────────────────────────────────────────────────────────────\n // Events API\n // ─────────────────────────────────────────────────────────────────────────────\n\n /**\n * Dispatch an event from this entity.\n * Events are emitted both locally and to the global event bus.\n */\n dispatch<K extends keyof EntityEvents>(\n event: K,\n payload: EntityEvents[K],\n ): void {\n this.eventDelegate.dispatch(event, payload);\n (zylemEventBus as any).emit(event, payload);\n }\n\n /**\n * Listen for events on this entity instance.\n * @returns Unsubscribe function\n */\n listen<K extends keyof EntityEvents>(\n event: K,\n handler: (payload: EntityEvents[K]) => void,\n ): () => void {\n return this.eventDelegate.listen(event, handler);\n }\n\n /**\n * Clean up entity event subscriptions.\n */\n disposeEvents(): void {\n this.eventDelegate.dispose();\n }\n}\n","import { ActiveCollisionTypes, ColliderDesc, RigidBodyDesc, RigidBodyType, Vector3 } from \"@dimforge/rapier3d-compat\";\nimport { Vec3 } from \"../core/vector\";\n\n/**\n * Options for configuring entity collision behavior.\n */\nexport interface CollisionOptions {\n\tstatic?: boolean;\n\tsensor?: boolean;\n\tsize?: Vector3;\n\tposition?: Vector3;\n\tcollisionType?: string;\n\tcollisionFilter?: string[];\n}\n\nconst typeToGroup = new Map<string, number>();\nlet nextGroupId = 0;\n\nexport function getOrCreateCollisionGroupId(type: string): number {\n\tlet groupId = typeToGroup.get(type);\n\tif (groupId === undefined) {\n\t\tgroupId = nextGroupId++ % 16;\n\t\ttypeToGroup.set(type, groupId);\n\t}\n\treturn groupId;\n}\n\nexport function createCollisionFilter(allowedTypes: string[]): number {\n\tlet filter = 0;\n\tallowedTypes.forEach(type => {\n\t\tconst groupId = getOrCreateCollisionGroupId(type);\n\t\tfilter |= (1 << groupId);\n\t});\n\treturn filter;\n}\n\nexport class CollisionBuilder {\n\tstatic: boolean = false;\n\tsensor: boolean = false;\n\tgravity: Vec3 = new Vector3(0, 0, 0);\n\n\tbuild(options: Partial<CollisionOptions>): [RigidBodyDesc, ColliderDesc] {\n\t\tconst bodyDesc = this.bodyDesc({\n\t\t\tisDynamicBody: !this.static\n\t\t});\n\t\tconst collider = this.collider(options);\n\t\tconst type = options.collisionType;\n\t\tif (type) {\n\t\t\tlet groupId = getOrCreateCollisionGroupId(type);\n\t\t\tlet filter = 0b1111111111111111;\n\t\t\tif (options.collisionFilter) {\n\t\t\t\tfilter = createCollisionFilter(options.collisionFilter);\n\t\t\t}\n\t\t\tcollider.setCollisionGroups((groupId << 16) | filter);\n\t\t}\n\t\tconst { KINEMATIC_FIXED, DEFAULT } = ActiveCollisionTypes;\n\t\tcollider.activeCollisionTypes = (this.sensor) ? KINEMATIC_FIXED : DEFAULT;\n\t\treturn [bodyDesc, collider];\n\t}\n\n\twithCollision(collisionOptions: Partial<CollisionOptions>): this {\n\t\tthis.sensor = collisionOptions?.sensor ?? this.sensor;\n\t\tthis.static = collisionOptions?.static ?? this.static;\n\t\treturn this;\n\t}\n\n\tcollider(options: CollisionOptions): ColliderDesc {\n\t\tconst size = options.size ?? new Vector3(1, 1, 1);\n\t\tconst half = { x: size.x / 2, y: size.y / 2, z: size.z / 2 };\n\t\tlet colliderDesc = ColliderDesc.cuboid(half.x, half.y, half.z);\n\t\treturn colliderDesc;\n\t}\n\n\tbodyDesc({ isDynamicBody = true }): RigidBodyDesc {\n\t\tconst type = isDynamicBody ? RigidBodyType.Dynamic : RigidBodyType.Fixed;\n\t\tconst bodyDesc = new RigidBodyDesc(type)\n\t\t\t.setTranslation(0, 0, 0)\n\t\t\t.setGravityScale(1.0)\n\t\t\t.setCanSleep(false)\n\t\t\t.setCcdEnabled(true);\n\t\treturn bodyDesc;\n\t}\n}","import { BufferGeometry, Material, Mesh } from 'three';\nimport { GameEntityOptions } from '../entities/entity';\n\n/**\n * TODO: allow for multiple materials requires geometry groups\n * TODO: allow for instanced uniforms\n * TODO: allow for geometry groups\n * TODO: allow for batched meshes\n * import { InstancedUniformsMesh } from 'three-instanced-uniforms-mesh';\n * may not need geometry groups for shaders though\n * setGeometry<T extends BufferGeometry>(geometry: T) {\n * MeshBuilder.bachedMesh = new BatchedMesh(10, 5000, 10000, material);\n * }\n */\n\nexport type MeshBuilderOptions = Partial<Pick<GameEntityOptions, 'batched' | 'material'>>;\n\nexport class MeshBuilder {\n\n\t_build(meshOptions: MeshBuilderOptions, geometry: BufferGeometry, materials: Material[]): Mesh {\n\t\tconst { batched, material } = meshOptions;\n\t\tif (batched) {\n\t\t\tconsole.warn('warning: mesh batching is not implemented');\n\t\t}\n\t\tconst mesh = new Mesh(geometry, materials.at(-1));\n\t\tmesh.position.set(0, 0, 0);\n\t\tmesh.castShadow = true;\n\t\tmesh.receiveShadow = true;\n\t\treturn mesh;\n\t}\n\n\t_postBuild(): void {\n\t\treturn;\n\t}\n}","export function sortedStringify(obj: Record<string, any>) {\n\tconst sortedObj = Object.keys(obj)\n\t\t.sort()\n\t\t.reduce((acc: Record<string, any>, key: string) => {\n\t\t\tacc[key] = obj[key];\n\t\t\treturn acc;\n\t\t}, {} as Record<string, any>);\n\n\treturn JSON.stringify(sortedObj);\n}\n\nexport function shortHash(objString: string) {\n\tlet hash = 0;\n\tfor (let i = 0; i < objString.length; i++) {\n\t\thash = Math.imul(31, hash) + objString.charCodeAt(i) | 0;\n\t}\n\treturn hash.toString(36);\n}","export const objectVertexShader = `\nuniform vec2 uvScale;\nvarying vec2 vUv;\n\nvoid main() {\n\tvUv = uv;\n\tvec4 mvPosition = modelViewMatrix * vec4( position, 1.0 );\n\tgl_Position = projectionMatrix * mvPosition;\n}\n`;\n","import { objectVertexShader } from './vertex/object.shader';\n\nconst fragment = `\nuniform sampler2D tDiffuse;\nvarying vec2 vUv;\n\nvoid main() {\n\tvec4 texel = texture2D( tDiffuse, vUv );\n\n\tgl_FragColor = texel;\n}\n`;\n\nexport const standardShader = {\n vertex: objectVertexShader,\n fragment\n};\n","/**\n * Texture loader adapter for the Asset Manager\n */\n\nimport { TextureLoader, Texture, RepeatWrapping, Vector2, Wrapping } from 'three';\nimport { LoaderAdapter, AssetLoadOptions } from '../asset-types';\n\nexport interface TextureOptions extends AssetLoadOptions {\n\trepeat?: Vector2;\n\twrapS?: Wrapping;\n\twrapT?: Wrapping;\n}\n\nexport class TextureLoaderAdapter implements LoaderAdapter<Texture> {\n\tprivate loader: TextureLoader;\n\n\tconstructor() {\n\t\tthis.loader = new TextureLoader();\n\t}\n\n\tisSupported(url: string): boolean {\n\t\tconst ext = url.split('.').pop()?.toLowerCase();\n\t\treturn ['png', 'jpg', 'jpeg', 'gif', 'webp', 'bmp', 'tga'].includes(ext || '');\n\t}\n\n\tasync load(url: string, options?: TextureOptions): Promise<Texture> {\n\t\tconst texture = await this.loader.loadAsync(url, (event) => {\n\t\t\tif (options?.onProgress && event.lengthComputable) {\n\t\t\t\toptions.onProgress(event.loaded / event.total);\n\t\t\t}\n\t\t});\n\n\t\t// Apply texture options\n\t\tif (options?.repeat) {\n\t\t\ttexture.repeat.copy(options.repeat);\n\t\t}\n\t\ttexture.wrapS = options?.wrapS ?? RepeatWrapping;\n\t\ttexture.wrapT = options?.wrapT ?? RepeatWrapping;\n\n\t\treturn texture;\n\t}\n\n\t/**\n\t * Clone a texture for independent usage\n\t */\n\tclone(texture: Texture): Texture {\n\t\tconst cloned = texture.clone();\n\t\tcloned.needsUpdate = true;\n\t\treturn cloned;\n\t}\n}\n","/**\n * GLTF loader adapter for the Asset Manager\n * Uses native fetch (already async/non-blocking in browsers) + parseAsync\n */\n\nimport { GLTF, GLTFLoader } from 'three/addons/loaders/GLTFLoader.js';\nimport { LoaderAdapter, AssetLoadOptions, ModelLoadResult } from '../asset-types';\n\nexport interface GLTFLoadOptions extends AssetLoadOptions {\n\t/** \n\t * Use async fetch + parseAsync pattern instead of loader.load()\n\t * Note: fetch() is already non-blocking in browsers, so this mainly\n\t * provides a cleaner async/await pattern rather than performance gains\n\t */\n\tuseAsyncFetch?: boolean;\n}\n\nexport class GLTFLoaderAdapter implements LoaderAdapter<ModelLoadResult> {\n\tprivate loader: GLTFLoader;\n\n\tconstructor() {\n\t\tthis.loader = new GLTFLoader();\n\t}\n\n\tisSupported(url: string): boolean {\n\t\tconst ext = url.split('.').pop()?.toLowerCase();\n\t\treturn ['gltf', 'glb'].includes(ext || '');\n\t}\n\n\tasync load(url: string, options?: GLTFLoadOptions): Promise<ModelLoadResult> {\n\t\tif (options?.useAsyncFetch) {\n\t\t\treturn this.loadWithAsyncFetch(url, options);\n\t\t}\n\t\treturn this.loadMainThread(url, options);\n\t}\n\n\t/**\n\t * Load using native fetch + parseAsync\n\t * Both fetch and parsing are async, keeping the main thread responsive\n\t */\n\tprivate async loadWithAsyncFetch(url: string, options?: GLTFLoadOptions): Promise<ModelLoadResult> {\n\t\ttry {\n\t\t\tconst response = await fetch(url);\n\t\t\tif (!response.ok) {\n\t\t\t\tthrow new Error(`Failed to fetch ${url}: ${response.status} ${response.statusText}`);\n\t\t\t}\n\t\t\tconst buffer = await response.arrayBuffer();\n\n\t\t\t// Parse on main thread using GLTFLoader.parseAsync\n\t\t\t// The url is passed as the path for resolving relative resources\n\t\t\tconst gltf = await this.loader.parseAsync(buffer, url);\n\n\t\t\treturn {\n\t\t\t\tobject: gltf.scene,\n\t\t\t\tanimations: gltf.animations,\n\t\t\t\tgltf\n\t\t\t};\n\t\t} catch (error) {\n\t\t\tconsole.error(`Async fetch GLTF load failed for ${url}, falling back to loader.load():`, error);\n\t\t\treturn this.loadMainThread(url, options);\n\t\t}\n\t}\n\n\tprivate async loadMainThread(url: string, options?: GLTFLoadOptions): Promise<ModelLoadResult> {\n\t\treturn new Promise((resolve, reject) => {\n\t\t\tthis.loader.load(\n\t\t\t\turl,\n\t\t\t\t(gltf: GLTF) => {\n\t\t\t\t\tresolve({\n\t\t\t\t\t\tobject: gltf.scene,\n\t\t\t\t\t\tanimations: gltf.animations,\n\t\t\t\t\t\tgltf\n\t\t\t\t\t});\n\t\t\t\t},\n\t\t\t\t(event) => {\n\t\t\t\t\tif (options?.onProgress && event.lengthComputable) {\n\t\t\t\t\t\toptions.onProgress(event.loaded / event.total);\n\t\t\t\t\t}\n\t\t\t\t},\n\t\t\t\t(error) => reject(error)\n\t\t\t);\n\t\t});\n\t}\n\n\t/**\n\t * Clone a loaded GLTF scene for reuse\n\t */\n\tclone(result: ModelLoadResult): ModelLoadResult {\n\t\treturn {\n\t\t\tobject: result.object.clone(),\n\t\t\tanimations: result.animations?.map(anim => anim.clone()),\n\t\t\tgltf: result.gltf\n\t\t};\n\t}\n}\n","/**\n * FBX loader adapter for the Asset Manager\n * Uses native fetch (already async/non-blocking in browsers) + parse\n */\n\nimport { Object3D } from 'three';\nimport { FBXLoader } from 'three/addons/loaders/FBXLoader.js';\nimport { LoaderAdapter, AssetLoadOptions, ModelLoadResult } from '../asset-types';\n\nexport interface FBXLoadOptions extends AssetLoadOptions {\n\t/** \n\t * Use async fetch + parse pattern instead of loader.load()\n\t * Note: fetch() is already non-blocking in browsers\n\t */\n\tuseAsyncFetch?: boolean;\n}\n\nexport class FBXLoaderAdapter implements LoaderAdapter<ModelLoadResult> {\n\tprivate loader: FBXLoader;\n\n\tconstructor() {\n\t\tthis.loader = new FBXLoader();\n\t}\n\n\tisSupported(url: string): boolean {\n\t\tconst ext = url.split('.').pop()?.toLowerCase();\n\t\treturn ext === 'fbx';\n\t}\n\n\tasync load(url: string, options?: FBXLoadOptions): Promise<ModelLoadResult> {\n\t\tif (options?.useAsyncFetch) {\n\t\t\treturn this.loadWithAsyncFetch(url, options);\n\t\t}\n\t\treturn this.loadMainThread(url, options);\n\t}\n\n\t/**\n\t * Load using native fetch + parse\n\t */\n\tprivate async loadWithAsyncFetch(url: string, _options?: FBXLoadOptions): Promise<ModelLoadResult> {\n\t\ttry {\n\t\t\tconst response = await fetch(url);\n\t\t\tif (!response.ok) {\n\t\t\t\tthrow new Error(`Failed to fetch ${url}: ${response.status} ${response.statusText}`);\n\t\t\t}\n\t\t\tconst buffer = await response.arrayBuffer();\n\n\t\t\t// Parse on main thread using FBXLoader.parse\n\t\t\tconst object = this.loader.parse(buffer, url);\n\n\t\t\treturn {\n\t\t\t\tobject,\n\t\t\t\tanimations: (object as any).animations || []\n\t\t\t};\n\t\t} catch (error) {\n\t\t\tconsole.error(`Async fetch FBX load failed for ${url}, falling back to loader.load():`, error);\n\t\t\treturn this.loadMainThread(url, _options);\n\t\t}\n\t}\n\n\tprivate async loadMainThread(url: string, options?: FBXLoadOptions): Promise<ModelLoadResult> {\n\t\treturn new Promise((resolve, reject) => {\n\t\t\tthis.loader.load(\n\t\t\t\turl,\n\t\t\t\t(object: Object3D) => {\n\t\t\t\t\tresolve({\n\t\t\t\t\t\tobject,\n\t\t\t\t\t\tanimations: (object as any).animations || []\n\t\t\t\t\t});\n\t\t\t\t},\n\t\t\t\t(event) => {\n\t\t\t\t\tif (options?.onProgress && event.lengthComputable) {\n\t\t\t\t\t\toptions.onProgress(event.loaded / event.total);\n\t\t\t\t\t}\n\t\t\t\t},\n\t\t\t\t(error) => reject(error)\n\t\t\t);\n\t\t});\n\t}\n\n\t/**\n\t * Clone a loaded FBX object for reuse\n\t */\n\tclone(result: ModelLoadResult): ModelLoadResult {\n\t\treturn {\n\t\t\tobject: result.object.clone(),\n\t\t\tanimations: result.animations?.map(anim => anim.clone())\n\t\t};\n\t}\n}\n","/**\n * OBJ loader adapter for the Asset Manager\n * Supports optional MTL (material) file loading\n */\n\nimport { Object3D, Group } from 'three';\nimport { OBJLoader } from 'three/addons/loaders/OBJLoader.js';\nimport { MTLLoader } from 'three/addons/loaders/MTLLoader.js';\nimport { LoaderAdapter, AssetLoadOptions, ModelLoadResult } from '../asset-types';\n\nexport interface OBJLoadOptions extends AssetLoadOptions {\n\t/** Path to MTL material file */\n\tmtlPath?: string;\n}\n\nexport class OBJLoaderAdapter implements LoaderAdapter<ModelLoadResult> {\n\tprivate loader: OBJLoader;\n\tprivate mtlLoader: MTLLoader;\n\n\tconstructor() {\n\t\tthis.loader = new OBJLoader();\n\t\tthis.mtlLoader = new MTLLoader();\n\t}\n\n\tisSupported(url: string): boolean {\n\t\tconst ext = url.split('.').pop()?.toLowerCase();\n\t\treturn ext === 'obj';\n\t}\n\n\tasync load(url: string, options?: OBJLoadOptions): Promise<ModelLoadResult> {\n\t\t// Load MTL first if provided\n\t\tif (options?.mtlPath) {\n\t\t\tawait this.loadMTL(options.mtlPath);\n\t\t}\n\n\t\treturn new Promise((resolve, reject) => {\n\t\t\tthis.loader.load(\n\t\t\t\turl,\n\t\t\t\t(object: Group) => {\n\t\t\t\t\tresolve({\n\t\t\t\t\t\tobject,\n\t\t\t\t\t\tanimations: []\n\t\t\t\t\t});\n\t\t\t\t},\n\t\t\t\t(event) => {\n\t\t\t\t\tif (options?.onProgress && event.lengthComputable) {\n\t\t\t\t\t\toptions.onProgress(event.loaded / event.total);\n\t\t\t\t\t}\n\t\t\t\t},\n\t\t\t\t(error) => reject(error)\n\t\t\t);\n\t\t});\n\t}\n\n\tprivate async loadMTL(url: string): Promise<void> {\n\t\treturn new Promise((resolve, reject) => {\n\t\t\tthis.mtlLoader.load(\n\t\t\t\turl,\n\t\t\t\t(materials) => {\n\t\t\t\t\tmaterials.preload();\n\t\t\t\t\tthis.loader.setMaterials(materials);\n\t\t\t\t\tresolve();\n\t\t\t\t},\n\t\t\t\tundefined,\n\t\t\t\t(error) => reject(error)\n\t\t\t);\n\t\t});\n\t}\n\n\t/**\n\t * Clone a loaded OBJ object for reuse\n\t */\n\tclone(result: ModelLoadResult): ModelLoadResult {\n\t\treturn {\n\t\t\tobject: result.object.clone(),\n\t\t\tanimations: []\n\t\t};\n\t}\n}\n","/**\n * Audio loader adapter for the Asset Manager\n */\n\nimport { AudioLoader } from 'three';\nimport { LoaderAdapter, AssetLoadOptions } from '../asset-types';\n\nexport class AudioLoaderAdapter implements LoaderAdapter<AudioBuffer> {\n\tprivate loader: AudioLoader;\n\n\tconstructor() {\n\t\tthis.loader = new AudioLoader();\n\t}\n\n\tisSupported(url: string): boolean {\n\t\tconst ext = url.split('.').pop()?.toLowerCase();\n\t\treturn ['mp3', 'ogg', 'wav', 'flac', 'aac', 'm4a'].includes(ext || '');\n\t}\n\n\tasync load(url: string, options?: AssetLoadOptions): Promise<AudioBuffer> {\n\t\treturn new Promise((resolve, reject) => {\n\t\t\tthis.loader.load(\n\t\t\t\turl,\n\t\t\t\t(buffer) => resolve(buffer),\n\t\t\t\t(event) => {\n\t\t\t\t\tif (options?.onProgress && event.lengthComputable) {\n\t\t\t\t\t\toptions.onProgress(event.loaded / event.total);\n\t\t\t\t\t}\n\t\t\t\t},\n\t\t\t\t(error) => reject(error)\n\t\t\t);\n\t\t});\n\t}\n}\n","/**\n * File loader adapter for the Asset Manager\n */\n\nimport { FileLoader } from 'three';\nimport { LoaderAdapter, AssetLoadOptions } from '../asset-types';\n\nexport interface FileLoadOptions extends AssetLoadOptions {\n\tresponseType?: 'text' | 'arraybuffer' | 'blob' | 'json';\n}\n\nexport class FileLoaderAdapter implements LoaderAdapter<string | ArrayBuffer> {\n\tprivate loader: FileLoader;\n\n\tconstructor() {\n\t\tthis.loader = new FileLoader();\n\t}\n\n\tisSupported(_url: string): boolean {\n\t\t// FileLoader can handle any file type\n\t\treturn true;\n\t}\n\n\tasync load(url: string, options?: FileLoadOptions): Promise<string | ArrayBuffer> {\n\t\tconst responseType = options?.responseType ?? 'text';\n\t\tthis.loader.setResponseType(responseType as any);\n\n\t\treturn new Promise((resolve, reject) => {\n\t\t\tthis.loader.load(\n\t\t\t\turl,\n\t\t\t\t(data) => resolve(data as string | ArrayBuffer),\n\t\t\t\t(event) => {\n\t\t\t\t\tif (options?.onProgress && event.lengthComputable) {\n\t\t\t\t\t\toptions.onProgress(event.loaded / event.total);\n\t\t\t\t\t}\n\t\t\t\t},\n\t\t\t\t(error) => reject(error)\n\t\t\t);\n\t\t});\n\t}\n}\n\n/**\n * JSON loader using FileLoader\n */\nexport class JsonLoaderAdapter implements LoaderAdapter<unknown> {\n\tprivate fileLoader: FileLoaderAdapter;\n\n\tconstructor() {\n\t\tthis.fileLoader = new FileLoaderAdapter();\n\t}\n\n\tisSupported(url: string): boolean {\n\t\tconst ext = url.split('.').pop()?.toLowerCase();\n\t\treturn ext === 'json';\n\t}\n\n\tasync load<T = unknown>(url: string, options?: AssetLoadOptions): Promise<T> {\n\t\tconst data = await this.fileLoader.load(url, { ...options, responseType: 'json' });\n\t\treturn data as T;\n\t}\n}\n","/**\n * Loader adapters barrel export\n */\n\nexport { TextureLoaderAdapter, type TextureOptions } from './texture-loader';\nexport { GLTFLoaderAdapter, type GLTFLoadOptions } from './gltf-loader';\nexport { FBXLoaderAdapter, type FBXLoadOptions } from './fbx-loader';\nexport { OBJLoaderAdapter, type OBJLoadOptions } from './obj-loader';\nexport { AudioLoaderAdapter } from './audio-loader';\nexport { FileLoaderAdapter, JsonLoaderAdapter, type FileLoadOptions } from './file-loader';\n","/**\n * Centralized Asset Manager for Zylem\n * \n * Provides caching, parallel loading, and unified access to all asset types.\n * All asset loading should funnel through this manager.\n */\n\nimport { Texture, Object3D, LoadingManager, Cache } from 'three';\nimport { GLTF } from 'three/addons/loaders/GLTFLoader.js';\nimport mitt, { Emitter } from 'mitt';\n\nimport {\n\tAssetType,\n\tAssetLoadOptions,\n\tAssetManagerEvents,\n\tBatchLoadItem,\n\tModelLoadResult\n} from './asset-types';\n\nimport {\n\tTextureLoaderAdapter,\n\tGLTFLoaderAdapter,\n\tFBXLoaderAdapter,\n\tOBJLoaderAdapter,\n\tAudioLoaderAdapter,\n\tFileLoaderAdapter,\n\tJsonLoaderAdapter,\n\tTextureOptions,\n\tGLTFLoadOptions,\n\tFBXLoadOptions,\n\tOBJLoadOptions,\n\tFileLoadOptions\n} from './loaders';\n\n/**\n * Asset cache entry\n */\ninterface CacheEntry<T> {\n\tpromise: Promise<T>;\n\tresult?: T;\n\tloadedAt: number;\n}\n\n/**\n * AssetManager - Singleton for all asset loading\n * \n * Features:\n * - URL-based caching with deduplication\n * - Typed load methods for each asset type\n * - Batch loading with Promise.all() for parallelism\n * - Progress events via LoadingManager\n * - Clone support for shared assets (textures, models)\n */\nexport class AssetManager {\n\tprivate static instance: AssetManager | null = null;\n\n\t// Caches for different asset types\n\tprivate textureCache: Map<string, CacheEntry<Texture>> = new Map();\n\tprivate modelCache: Map<string, CacheEntry<ModelLoadResult>> = new Map();\n\tprivate audioCache: Map<string, CacheEntry<AudioBuffer>> = new Map();\n\tprivate fileCache: Map<string, CacheEntry<string | ArrayBuffer>> = new Map();\n\tprivate jsonCache: Map<string, CacheEntry<unknown>> = new Map();\n\n\t// Loaders\n\tprivate textureLoader: TextureLoaderAdapter;\n\tprivate gltfLoader: GLTFLoaderAdapter;\n\tprivate fbxLoader: FBXLoaderAdapter;\n\tprivate objLoader: OBJLoaderAdapter;\n\tprivate audioLoader: AudioLoaderAdapter;\n\tprivate fileLoader: FileLoaderAdapter;\n\tprivate jsonLoader: JsonLoaderAdapter;\n\n\t// Loading manager for progress tracking\n\tprivate loadingManager: LoadingManager;\n\n\t// Event emitter\n\tprivate events: Emitter<AssetManagerEvents>;\n\n\t// Stats\n\tprivate stats = {\n\t\ttexturesLoaded: 0,\n\t\tmodelsLoaded: 0,\n\t\taudioLoaded: 0,\n\t\tfilesLoaded: 0,\n\t\tcacheHits: 0,\n\t\tcacheMisses: 0\n\t};\n\n\tprivate constructor() {\n\t\t// Initialize loaders\n\t\tthis.textureLoader = new TextureLoaderAdapter();\n\t\tthis.gltfLoader = new GLTFLoaderAdapter();\n\t\tthis.fbxLoader = new FBXLoaderAdapter();\n\t\tthis.objLoader = new OBJLoaderAdapter();\n\t\tthis.audioLoader = new AudioLoaderAdapter();\n\t\tthis.fileLoader = new FileLoaderAdapter();\n\t\tthis.jsonLoader = new JsonLoaderAdapter();\n\n\t\t// Initialize loading manager\n\t\tthis.loadingManager = new LoadingManager();\n\t\tthis.loadingManager.onProgress = (url, loaded, total) => {\n\t\t\tthis.events.emit('batch:progress', { loaded, total });\n\t\t};\n\n\t\t// Initialize event emitter\n\t\tthis.events = mitt<AssetManagerEvents>();\n\n\t\t// Enable Three.js built-in cache\n\t\tCache.enabled = true;\n\t}\n\n\t/**\n\t * Get the singleton instance\n\t */\n\tstatic getInstance(): AssetManager {\n\t\tif (!AssetManager.instance) {\n\t\t\tAssetManager.instance = new AssetManager();\n\t\t}\n\t\treturn AssetManager.instance;\n\t}\n\n\t/**\n\t * Reset the singleton (useful for testing)\n\t */\n\tstatic resetInstance(): void {\n\t\tif (AssetManager.instance) {\n\t\t\tAssetManager.instance.clearCache();\n\t\t\tAssetManager.instance = null;\n\t\t}\n\t}\n\n\t// ==================== TEXTURE LOADING ====================\n\n\t/**\n\t * Load a texture with caching\n\t */\n\tasync loadTexture(url: string, options?: TextureOptions): Promise<Texture> {\n\t\treturn this.loadWithCache(\n\t\t\turl,\n\t\t\tAssetType.TEXTURE,\n\t\t\tthis.textureCache,\n\t\t\t() => this.textureLoader.load(url, options),\n\t\t\toptions,\n\t\t\t(texture) => options?.clone ? this.textureLoader.clone(texture) : texture\n\t\t);\n\t}\n\n\t// ==================== MODEL LOADING ====================\n\n\t/**\n\t * Load a GLTF/GLB model with caching\n\t */\n\tasync loadGLTF(url: string, options?: GLTFLoadOptions): Promise<ModelLoadResult> {\n\t\treturn this.loadWithCache(\n\t\t\turl,\n\t\t\tAssetType.GLTF,\n\t\t\tthis.modelCache,\n\t\t\t() => this.gltfLoader.load(url, options),\n\t\t\toptions,\n\t\t\t(result) => options?.clone ? this.gltfLoader.clone(result) : result\n\t\t);\n\t}\n\n\t/**\n\t * Load an FBX model with caching\n\t */\n\tasync loadFBX(url: string, options?: FBXLoadOptions): Promise<ModelLoadResult> {\n\t\treturn this.loadWithCache(\n\t\t\turl,\n\t\t\tAssetType.FBX,\n\t\t\tthis.modelCache,\n\t\t\t() => this.fbxLoader.load(url, options),\n\t\t\toptions,\n\t\t\t(result) => options?.clone ? this.fbxLoader.clone(result) : result\n\t\t);\n\t}\n\n\t/**\n\t * Load an OBJ model with caching\n\t */\n\tasync loadOBJ(url: string, options?: OBJLoadOptions): Promise<ModelLoadResult> {\n\t\t// Include mtlPath in cache key for OBJ files\n\t\tconst cacheKey = options?.mtlPath ? `${url}:${options.mtlPath}` : url;\n\t\treturn this.loadWithCache(\n\t\t\tcacheKey,\n\t\t\tAssetType.OBJ,\n\t\t\tthis.modelCache,\n\t\t\t() => this.objLoader.load(url, options),\n\t\t\toptions,\n\t\t\t(result) => options?.clone ? this.objLoader.clone(result) : result\n\t\t);\n\t}\n\n\t/**\n\t * Auto-detect model type and load\n\t */\n\tasync loadModel(url: string, options?: AssetLoadOptions): Promise<ModelLoadResult> {\n\t\tconst ext = url.split('.').pop()?.toLowerCase();\n\t\t\n\t\tswitch (ext) {\n\t\t\tcase 'gltf':\n\t\t\tcase 'glb':\n\t\t\t\treturn this.loadGLTF(url, options);\n\t\t\tcase 'fbx':\n\t\t\t\treturn this.loadFBX(url, options);\n\t\t\tcase 'obj':\n\t\t\t\treturn this.loadOBJ(url, options);\n\t\t\tdefault:\n\t\t\t\tthrow new Error(`Unsupported model format: ${ext}`);\n\t\t}\n\t}\n\n\t// ==================== AUDIO LOADING ====================\n\n\t/**\n\t * Load an audio buffer with caching\n\t */\n\tasync loadAudio(url: string, options?: AssetLoadOptions): Promise<AudioBuffer> {\n\t\treturn this.loadWithCache(\n\t\t\turl,\n\t\t\tAssetType.AUDIO,\n\t\t\tthis.audioCache,\n\t\t\t() => this.audioLoader.load(url, options),\n\t\t\toptions\n\t\t);\n\t}\n\n\t// ==================== FILE LOADING ====================\n\n\t/**\n\t * Load a raw file with caching\n\t */\n\tasync loadFile(url: string, options?: FileLoadOptions): Promise<string | ArrayBuffer> {\n\t\tconst cacheKey = options?.responseType ? `${url}:${options.responseType}` : url;\n\t\treturn this.loadWithCache(\n\t\t\tcacheKey,\n\t\t\tAssetType.FILE,\n\t\t\tthis.fileCache,\n\t\t\t() => this.fileLoader.load(url, options),\n\t\t\toptions\n\t\t);\n\t}\n\n\t/**\n\t * Load a JSON file with caching\n\t */\n\tasync loadJSON<T = unknown>(url: string, options?: AssetLoadOptions): Promise<T> {\n\t\treturn this.loadWithCache(\n\t\t\turl,\n\t\t\tAssetType.JSON,\n\t\t\tthis.jsonCache,\n\t\t\t() => this.jsonLoader.load<T>(url, options),\n\t\t\toptions\n\t\t) as Promise<T>;\n\t}\n\n\t// ==================== BATCH LOADING ====================\n\n\t/**\n\t * Load multiple assets in parallel\n\t */\n\tasync loadBatch(items: BatchLoadItem[]): Promise<Map<string, any>> {\n\t\tconst results = new Map<string, any>();\n\t\t\n\t\tconst promises = items.map(async (item) => {\n\t\t\ttry {\n\t\t\t\tlet result: any;\n\t\t\t\t\n\t\t\t\tswitch (item.type) {\n\t\t\t\t\tcase AssetType.TEXTURE:\n\t\t\t\t\t\tresult = await this.loadTexture(item.url, item.options);\n\t\t\t\t\t\tbreak;\n\t\t\t\t\tcase AssetType.GLTF:\n\t\t\t\t\t\tresult = await this.loadGLTF(item.url, item.options);\n\t\t\t\t\t\tbreak;\n\t\t\t\t\tcase AssetType.FBX:\n\t\t\t\t\t\tresult = await this.loadFBX(item.url, item.options);\n\t\t\t\t\t\tbreak;\n\t\t\t\t\tcase AssetType.OBJ:\n\t\t\t\t\t\tresult = await this.loadOBJ(item.url, item.options);\n\t\t\t\t\t\tbreak;\n\t\t\t\t\tcase AssetType.AUDIO:\n\t\t\t\t\t\tresult = await this.loadAudio(item.url, item.options);\n\t\t\t\t\t\tbreak;\n\t\t\t\t\tcase AssetType.FILE:\n\t\t\t\t\t\tresult = await this.loadFile(item.url, item.options);\n\t\t\t\t\t\tbreak;\n\t\t\t\t\tcase AssetType.JSON:\n\t\t\t\t\t\tresult = await this.loadJSON(item.url, item.options);\n\t\t\t\t\t\tbreak;\n\t\t\t\t\tdefault:\n\t\t\t\t\t\tthrow new Error(`Unknown asset type: ${item.type}`);\n\t\t\t\t}\n\t\t\t\t\n\t\t\t\tresults.set(item.url, result);\n\t\t\t} catch (error) {\n\t\t\t\tthis.events.emit('asset:error', {\n\t\t\t\t\turl: item.url,\n\t\t\t\t\ttype: item.type,\n\t\t\t\t\terror: error as Error\n\t\t\t\t});\n\t\t\t\tthrow error;\n\t\t\t}\n\t\t});\n\n\t\tawait Promise.all(promises);\n\t\t\n\t\tthis.events.emit('batch:complete', { urls: items.map(i => i.url) });\n\t\t\n\t\treturn results;\n\t}\n\n\t/**\n\t * Preload assets without returning results\n\t */\n\tasync preload(items: BatchLoadItem[]): Promise<void> {\n\t\tawait this.loadBatch(items);\n\t}\n\n\t// ==================== CACHE MANAGEMENT ====================\n\n\t/**\n\t * Check if an asset is cached\n\t */\n\tisCached(url: string): boolean {\n\t\treturn this.textureCache.has(url) ||\n\t\t\tthis.modelCache.has(url) ||\n\t\t\tthis.audioCache.has(url) ||\n\t\t\tthis.fileCache.has(url) ||\n\t\t\tthis.jsonCache.has(url);\n\t}\n\n\t/**\n\t * Clear all caches or a specific URL\n\t */\n\tclearCache(url?: string): void {\n\t\tif (url) {\n\t\t\tthis.textureCache.delete(url);\n\t\t\tthis.modelCache.delete(url);\n\t\t\tthis.audioCache.delete(url);\n\t\t\tthis.fileCache.delete(url);\n\t\t\tthis.jsonCache.delete(url);\n\t\t} else {\n\t\t\tthis.textureCache.clear();\n\t\t\tthis.modelCache.clear();\n\t\t\tthis.audioCache.clear();\n\t\t\tthis.fileCache.clear();\n\t\t\tthis.jsonCache.clear();\n\t\t\tCache.clear();\n\t\t}\n\t}\n\n\t/**\n\t * Get cache statistics\n\t */\n\tgetStats(): typeof this.stats {\n\t\treturn { ...this.stats };\n\t}\n\n\t// ==================== EVENTS ====================\n\n\t/**\n\t * Subscribe to asset manager events\n\t */\n\ton<K extends keyof AssetManagerEvents>(\n\t\tevent: K,\n\t\thandler: (payload: AssetManagerEvents[K]) => void\n\t): void {\n\t\tthis.events.on(event, handler);\n\t}\n\n\t/**\n\t * Unsubscribe from asset manager events\n\t */\n\toff<K extends keyof AssetManagerEvents>(\n\t\tevent: K,\n\t\thandler: (payload: AssetManagerEvents[K]) => void\n\t): void {\n\t\tthis.events.off(event, handler);\n\t}\n\n\t// ==================== PRIVATE HELPERS ====================\n\n\t/**\n\t * Generic cache wrapper for loading assets\n\t */\n\tprivate async loadWithCache<T>(\n\t\turl: string,\n\t\ttype: AssetType,\n\t\tcache: Map<string, CacheEntry<T>>,\n\t\tloader: () => Promise<T>,\n\t\toptions?: AssetLoadOptions,\n\t\tcloner?: (result: T) => T\n\t): Promise<T> {\n\t\t// Check for force reload\n\t\tif (options?.forceReload) {\n\t\t\tcache.delete(url);\n\t\t}\n\n\t\t// Check cache\n\t\tconst cached = cache.get(url);\n\t\tif (cached) {\n\t\t\tthis.stats.cacheHits++;\n\t\t\tthis.events.emit('asset:loaded', { url, type, fromCache: true });\n\t\t\t\n\t\t\tconst result = await cached.promise;\n\t\t\treturn cloner ? cloner(result) : result;\n\t\t}\n\n\t\t// Cache miss - start loading\n\t\tthis.stats.cacheMisses++;\n\t\tthis.events.emit('asset:loading', { url, type });\n\n\t\tconst promise = loader();\n\t\tconst entry: CacheEntry<T> = {\n\t\t\tpromise,\n\t\t\tloadedAt: Date.now()\n\t\t};\n\t\tcache.set(url, entry);\n\n\t\ttry {\n\t\t\tconst result = await promise;\n\t\t\tentry.result = result;\n\t\t\t\n\t\t\t// Update stats\n\t\t\tthis.updateStats(type);\n\t\t\t\n\t\t\tthis.events.emit('asset:loaded', { url, type, fromCache: false });\n\t\t\t\n\t\t\treturn cloner ? cloner(result) : result;\n\t\t} catch (error) {\n\t\t\t// Remove failed entry from cache\n\t\t\tcache.delete(url);\n\t\t\tthis.events.emit('asset:error', { url, type, error: error as Error });\n\t\t\tthrow error;\n\t\t}\n\t}\n\n\tprivate updateStats(type: AssetType): void {\n\t\tswitch (type) {\n\t\t\tcase AssetType.TEXTURE:\n\t\t\t\tthis.stats.texturesLoaded++;\n\t\t\t\tbreak;\n\t\t\tcase AssetType.GLTF:\n\t\t\tcase AssetType.FBX:\n\t\t\tcase AssetType.OBJ:\n\t\t\t\tthis.stats.modelsLoaded++;\n\t\t\t\tbreak;\n\t\t\tcase AssetType.AUDIO:\n\t\t\t\tthis.stats.audioLoaded++;\n\t\t\t\tbreak;\n\t\t\tcase AssetType.FILE:\n\t\t\tcase AssetType.JSON:\n\t\t\t\tthis.stats.filesLoaded++;\n\t\t\t\tbreak;\n\t\t}\n\t}\n}\n\n/**\n * Singleton instance export for convenience\n */\nexport const assetManager = AssetManager.getInstance();","import {\n\tColor,\n\tMaterial,\n\tMeshPhongMaterial,\n\tMeshStandardMaterial,\n\tNormalBlending,\n\tRepeatWrapping,\n\tShaderMaterial,\n\tVector2,\n\tVector3\n} from 'three';\nimport { shortHash, sortedStringify } from '../core/utility/strings';\nimport { standardShader } from './shaders/standard.shader';\nimport { assetManager } from '../core/asset-manager';\n\nexport type ZylemShaderObject = { fragment: string, vertex: string };\n\nexport interface MaterialOptions {\n\tpath?: string;\n\trepeat?: Vector2;\n\tshader?: ZylemShaderObject;\n\tcolor?: Color;\n}\n\ntype BatchGeometryMap = Map<symbol, number>;\n\ninterface BatchMaterialMapObject {\n\tgeometryMap: BatchGeometryMap;\n\tmaterial: Material;\n};\n\ntype BatchKey = ReturnType<typeof shortHash>;\n\nexport type TexturePath = string | null;\n\nexport class MaterialBuilder {\n\tstatic batchMaterialMap: Map<BatchKey, BatchMaterialMapObject> = new Map();\n\n\tmaterials: Material[] = [];\n\n\tbatchMaterial(options: Partial<MaterialOptions>, entityType: symbol) {\n\t\tconst batchKey = shortHash(sortedStringify(options));\n\t\tconst mappedObject = MaterialBuilder.batchMaterialMap.get(batchKey);\n\t\tif (mappedObject) {\n\t\t\tconst count = mappedObject.geometryMap.get(entityType);\n\t\t\tif (count) {\n\t\t\t\tmappedObject.geometryMap.set(entityType, count + 1);\n\t\t\t} else {\n\t\t\t\tmappedObject.geometryMap.set(entityType, 1);\n\t\t\t}\n\t\t} else {\n\t\t\tMaterialBuilder.batchMaterialMap.set(\n\t\t\t\tbatchKey, {\n\t\t\t\tgeometryMap: new Map([[entityType, 1]]),\n\t\t\t\tmaterial: this.materials[0]\n\t\t\t});\n\t\t}\n\t}\n\n\tbuild(options: Partial<MaterialOptions>, entityType: symbol): void {\n\t\tconst { path, repeat, color, shader } = options;\n\t\t// If shader is provided, use it; otherwise execute standard logic\n\t\tif (shader) {\n\t\t\tthis.withShader(shader);\n\t\t} else if (path) {\n\t\t\t// If path provided but no shader, standard texture logic applies\n\t\t\tthis.setTexture(path, repeat);\n\t\t}\n\t\t\n\t\tif (color) {\n\t\t\t// standard color material if no custom shader\n\t\t\tthis.withColor(color);\n\t\t}\n\n\t\tif (this.materials.length === 0) {\n\t\t\tthis.setColor(new Color('#ffffff'));\n\t\t}\n\t\tthis.batchMaterial(options, entityType);\n\t}\n\n\twithColor(color: Color): this {\n\t\tthis.setColor(color);\n\t\treturn this;\n\t}\n\n\twithShader(shader: ZylemShaderObject): this {\n\t\tthis.setShader(shader);\n\t\treturn this;\n\t}\n\n\t/**\n\t * Set texture - loads in background (deferred).\n\t * Material is created immediately with null map, texture applies when loaded.\n\t */\n\tsetTexture(texturePath: TexturePath = null, repeat: Vector2 = new Vector2(1, 1)): void {\n\t\tif (!texturePath) {\n\t\t\treturn;\n\t\t}\n\t\t// Create material immediately with null map\n\t\tconst material = new MeshPhongMaterial({\n\t\t\tmap: null,\n\t\t});\n\t\tthis.materials.push(material);\n\n\t\t// Load texture in background and apply when ready\n\t\tassetManager.loadTexture(texturePath as string, { \n\t\t\tclone: true,\n\t\t\trepeat \n\t\t}).then(texture => {\n\t\t\ttexture.wrapS = RepeatWrapping;\n\t\t\ttexture.wrapT = RepeatWrapping;\n\t\t\tmaterial.map = texture;\n\t\t\tmaterial.needsUpdate = true;\n\t\t});\n\t}\n\n\tsetColor(color: Color) {\n\t\tconst material = new MeshStandardMaterial({\n\t\t\tcolor: color,\n\t\t\temissiveIntensity: 0.5,\n\t\t\tlightMapIntensity: 0.5,\n\t\t\tfog: true,\n\t\t});\n\n\t\tthis.materials.push(material);\n\t}\n\n\tsetShader(customShader: ZylemShaderObject) {\n\t\tconst { fragment, vertex } = customShader ?? standardShader;\n\n\t\tconst shader = new ShaderMaterial({\n\t\t\tuniforms: {\n\t\t\t\tiResolution: { value: new Vector3(1, 1, 1) },\n\t\t\t\tiTime: { value: 0 },\n\t\t\t\ttDiffuse: { value: null },\n\t\t\t\ttDepth: { value: null },\n\t\t\t\ttNormal: { value: null }\n\t\t\t},\n\t\t\tvertexShader: vertex,\n\t\t\tfragmentShader: fragment,\n\t\t\ttransparent: true,\n\t\t\t// blending: NormalBlending\n\t\t});\n\t\tthis.materials.push(shader);\n\t}\n}\n","import { ColliderDesc } from \"@dimforge/rapier3d-compat\";\nimport { GameEntity, GameEntityOptions } from \"./entity\";\nimport { BufferGeometry, Group, Material, Mesh, Color } from \"three\";\nimport { CollisionBuilder } from \"../collision/collision-builder\";\nimport { MeshBuilder } from \"../graphics/mesh\";\nimport { MaterialBuilder, MaterialOptions } from \"../graphics/material\";\nimport { Vec3 } from \"../core/vector\";\n\nexport abstract class EntityCollisionBuilder extends CollisionBuilder {\n\tabstract collider(options: GameEntityOptions): ColliderDesc;\n}\n\nexport abstract class EntityMeshBuilder extends MeshBuilder {\n\tbuild(options: GameEntityOptions): BufferGeometry {\n\t\treturn new BufferGeometry();\n\t}\n\n\tpostBuild(): void {\n\t\treturn;\n\t}\n}\n\nexport abstract class EntityBuilder<T extends GameEntity<U> & P, U extends GameEntityOptions, P = any> {\n\tprotected meshBuilder: EntityMeshBuilder | null;\n\tprotected collisionBuilder: EntityCollisionBuilder | null;\n\tprotected materialBuilder: MaterialBuilder | null;\n\tprotected options: Partial<U>;\n\tprotected entity: T;\n\n\tconstructor(\n\t\toptions: Partial<U>,\n\t\tentity: T,\n\t\tmeshBuilder: EntityMeshBuilder | null,\n\t\tcollisionBuilder: EntityCollisionBuilder | null,\n\t) {\n\t\tthis.options = options;\n\t\tthis.entity = entity;\n\t\tthis.meshBuilder = meshBuilder;\n\t\tthis.collisionBuilder = collisionBuilder;\n\t\tthis.materialBuilder = new MaterialBuilder();\n\t\tconst builders: NonNullable<GameEntityOptions[\"_builders\"]> = {\n\t\t\tmeshBuilder: this.meshBuilder,\n\t\t\tcollisionBuilder: this.collisionBuilder,\n\t\t\tmaterialBuilder: this.materialBuilder,\n\t\t};\n\t\t(this.options as Partial<GameEntityOptions>)._builders = builders;\n\t}\n\n\twithPosition(setupPosition: Vec3): this {\n\t\tthis.options.position = setupPosition;\n\t\treturn this;\n\t}\n\n\twithMaterial(options: Partial<MaterialOptions>, entityType: symbol): this {\n\t\tif (this.materialBuilder) {\n\t\t\tthis.materialBuilder.build(options, entityType);\n\t\t}\n\t\treturn this;\n\t}\n\n\tapplyMaterialToGroup(group: Group, materials: Material[]): void {\n\t\tgroup.traverse((child) => {\n\t\t\tif (child instanceof Mesh) {\n\t\t\t\tif (child.type === 'SkinnedMesh' && materials[0] && !child.material.map) {\n\t\t\t\t\tchild.material = materials[0];\n\t\t\t\t}\n\t\t\t}\n\t\t\tchild.castShadow = true;\n\t\t\tchild.receiveShadow = true;\n\t\t});\n\t}\n\n\tbuild(): T {\n\t\tconst entity = this.entity;\n\t\tif (this.materialBuilder) {\n\t\t\tentity.materials = this.materialBuilder.materials;\n\t\t}\n\t\tif (this.meshBuilder && entity.materials) {\n\t\t\tconst geometry = this.meshBuilder.build(this.options);\n\t\t\tentity.mesh = this.meshBuilder._build(this.options, geometry, entity.materials);\n\t\t\tthis.meshBuilder.postBuild();\n\t\t}\n\n\t\tif (entity.group && entity.materials) {\n\t\t\tthis.applyMaterialToGroup(entity.group, entity.materials);\n\t\t}\n\n\t\tif (this.collisionBuilder) {\n\t\t\tthis.collisionBuilder.withCollision(this.options?.collision || {});\n\t\t\tconst [bodyDesc, colliderDesc] = this.collisionBuilder.build(this.options as any);\n\t\t\tentity.bodyDesc = bodyDesc;\n\t\t\tentity.colliderDesc = colliderDesc;\n\n\t\t\tconst { x, y, z } = this.options.position || { x: 0, y: 0, z: 0 };\n\t\t\tentity.bodyDesc.setTranslation(x, y, z);\n\t\t}\n\t\tif (this.options.collisionType) {\n\t\t\tentity.collisionType = this.options.collisionType;\n\t\t}\n\n\t\tif (this.options.color instanceof Color) {\n\t\t\tconst applyColor = (material: Material) => {\n\t\t\t\tconst anyMat = material as any;\n\t\t\t\tif (anyMat && anyMat.color && anyMat.color.set) {\n\t\t\t\t\tanyMat.color.set(this.options.color as Color);\n\t\t\t\t}\n\t\t\t};\n\t\t\tif (entity.materials?.length) {\n\t\t\t\tfor (const mat of entity.materials) applyColor(mat);\n\t\t\t}\n\t\t\tif (entity.mesh && entity.mesh.material) {\n\t\t\t\tconst mat = entity.mesh.material as any;\n\t\t\t\tif (Array.isArray(mat)) mat.forEach(applyColor); else applyColor(mat);\n\t\t\t}\n\t\t\tif (entity.group) {\n\t\t\t\tentity.group.traverse((child) => {\n\t\t\t\t\tif (child instanceof Mesh && child.material) {\n\t\t\t\t\t\tconst mat = child.material as any;\n\t\t\t\t\t\tif (Array.isArray(mat)) mat.forEach(applyColor); else applyColor(mat);\n\t\t\t\t\t}\n\t\t\t\t});\n\t\t\t}\n\t\t}\n\n\t\treturn entity;\n\t}\n\n\tprotected abstract createEntity(options: Partial<U>): T;\n}","import { GameEntity, GameEntityOptions } from '../entity';\nimport { MeshStandardMaterial, MeshBasicMaterial, MeshPhongMaterial } from 'three';\n\n/**\n * Interface for entities that provide custom debug information\n */\nexport interface DebugInfoProvider {\n\tgetDebugInfo(): Record<string, any>;\n}\n\n/**\n * Helper to check if an object implements DebugInfoProvider\n */\nfunction hasDebugInfo(obj: any): obj is DebugInfoProvider {\n\treturn obj && typeof obj.getDebugInfo === 'function';\n}\n\n/**\n * Debug delegate that provides debug information for entities\n */\nexport class DebugDelegate {\n\tprivate entity: GameEntity<any>;\n\n\tconstructor(entity: GameEntity<any>) {\n\t\tthis.entity = entity;\n\t}\n\n\t/**\n\t * Get formatted position string\n\t */\n\tprivate getPositionString(): string {\n\t\tif (this.entity.mesh) {\n\t\t\tconst { x, y, z } = this.entity.mesh.position;\n\t\t\treturn `${x.toFixed(2)}, ${y.toFixed(2)}, ${z.toFixed(2)}`;\n\t\t}\n\t\tconst { x, y, z } = this.entity.options.position || { x: 0, y: 0, z: 0 };\n\t\treturn `${x.toFixed(2)}, ${y.toFixed(2)}, ${z.toFixed(2)}`;\n\t}\n\n\t/**\n\t * Get formatted rotation string (in degrees)\n\t */\n\tprivate getRotationString(): string {\n\t\tif (this.entity.mesh) {\n\t\t\tconst { x, y, z } = this.entity.mesh.rotation;\n\t\t\tconst toDeg = (rad: number) => (rad * 180 / Math.PI).toFixed(1);\n\t\t\treturn `${toDeg(x)}°, ${toDeg(y)}°, ${toDeg(z)}°`;\n\t\t}\n\t\tconst { x, y, z } = this.entity.options.rotation || { x: 0, y: 0, z: 0 };\n\t\tconst toDeg = (rad: number) => (rad * 180 / Math.PI).toFixed(1);\n\t\treturn `${toDeg(x)}°, ${toDeg(y)}°, ${toDeg(z)}°`;\n\t}\n\n\t/**\n\t * Get material information\n\t */\n\tprivate getMaterialInfo(): Record<string, any> {\n\t\tif (!this.entity.mesh || !this.entity.mesh.material) {\n\t\t\treturn { type: 'none' };\n\t\t}\n\n\t\tconst material = Array.isArray(this.entity.mesh.material)\n\t\t\t? this.entity.mesh.material[0]\n\t\t\t: this.entity.mesh.material;\n\n\t\tconst info: Record<string, any> = {\n\t\t\ttype: material.type\n\t\t};\n\n\t\tif (material instanceof MeshStandardMaterial ||\n\t\t\tmaterial instanceof MeshBasicMaterial ||\n\t\t\tmaterial instanceof MeshPhongMaterial) {\n\t\t\tinfo.color = `#${material.color.getHexString()}`;\n\t\t\tinfo.opacity = material.opacity;\n\t\t\tinfo.transparent = material.transparent;\n\t\t}\n\n\t\tif ('roughness' in material) {\n\t\t\tinfo.roughness = material.roughness;\n\t\t}\n\n\t\tif ('metalness' in material) {\n\t\t\tinfo.metalness = material.metalness;\n\t\t}\n\n\t\treturn info;\n\t}\n\n\tprivate getPhysicsInfo(): Record<string, any> | null {\n\t\tif (!this.entity.body) {\n\t\t\treturn null;\n\t\t}\n\n\t\tconst info: Record<string, any> = {\n\t\t\ttype: this.entity.body.bodyType(),\n\t\t\tmass: this.entity.body.mass(),\n\t\t\tisEnabled: this.entity.body.isEnabled(),\n\t\t\tisSleeping: this.entity.body.isSleeping()\n\t\t};\n\n\t\tconst velocity = this.entity.body.linvel();\n\t\tinfo.velocity = `${velocity.x.toFixed(2)}, ${velocity.y.toFixed(2)}, ${velocity.z.toFixed(2)}`;\n\n\t\treturn info;\n\t}\n\n\tpublic buildDebugInfo(): Record<string, any> {\n\t\tconst defaultInfo: Record<string, any> = {\n\t\t\tname: this.entity.name || this.entity.uuid,\n\t\t\tuuid: this.entity.uuid,\n\t\t\tposition: this.getPositionString(),\n\t\t\trotation: this.getRotationString(),\n\t\t\tmaterial: this.getMaterialInfo()\n\t\t};\n\n\t\tconst physicsInfo = this.getPhysicsInfo();\n\t\tif (physicsInfo) {\n\t\t\tdefaultInfo.physics = physicsInfo;\n\t\t}\n\n\t\tif (this.entity.behaviors.length > 0) {\n\t\t\tdefaultInfo.behaviors = this.entity.behaviors.map(b => b.constructor.name);\n\t\t}\n\n\t\tif (hasDebugInfo(this.entity)) {\n\t\t\tconst customInfo = this.entity.getDebugInfo();\n\t\t\treturn { ...defaultInfo, ...customInfo };\n\t\t}\n\n\t\treturn defaultInfo;\n\t}\n}\n\nclass EnhancedDebugInfoBuilder {\n\tprivate customBuilder?: (options: GameEntityOptions) => Record<string, any>;\n\n\tconstructor(customBuilder?: (options: GameEntityOptions) => Record<string, any>) {\n\t\tthis.customBuilder = customBuilder;\n\t}\n\n\tbuildInfo(options: GameEntityOptions, entity?: GameEntity<any>): Record<string, any> {\n\t\tif (this.customBuilder) {\n\t\t\treturn this.customBuilder(options);\n\t\t}\n\n\t\tif (entity) {\n\t\t\tconst delegate = new DebugDelegate(entity);\n\t\t\treturn delegate.buildDebugInfo();\n\t\t}\n\n\t\tconst { x, y, z } = options.position || { x: 0, y: 0, z: 0 };\n\t\treturn {\n\t\t\tname: (options as any).name || 'unnamed',\n\t\t\tposition: `${x.toFixed(2)}, ${y.toFixed(2)}, ${z.toFixed(2)}`\n\t\t};\n\t}\n}\n","// this class is not for asset loading, it is for loading entity specific data\n// this is to keep the entity class focused purely on entity logic\n\nexport function isLoadable(obj: any): obj is EntityLoaderDelegate {\n\treturn typeof obj?.load === \"function\" && typeof obj?.data === \"function\";\n}\n\nexport interface EntityLoaderDelegate {\n\t/** Initiates loading (may be async internally, but call returns immediately) */\n\tload(): void;\n\t/** Returns data synchronously (may be null if still loading) */\n\tdata(): any;\n}\n\nexport class EntityLoader {\n\tentityReference: EntityLoaderDelegate;\n\n\tconstructor(entity: EntityLoaderDelegate) {\n\t\tthis.entityReference = entity;\n\t}\n\n\tload(): void {\n\t\tif (this.entityReference.load) {\n\t\t\tthis.entityReference.load();\n\t\t}\n\t}\n\n\tdata(): any {\n\t\tif (this.entityReference.data) {\n\t\t\treturn this.entityReference.data();\n\t\t}\n\t\treturn null;\n\t}\n}","import { GameEntityOptions, GameEntity } from \"./entity\";\nimport { BaseNode } from \"../core/base-node\";\nimport { EntityBuilder } from \"./builder\";\nimport { EntityCollisionBuilder } from \"./builder\";\nimport { EntityMeshBuilder } from \"./builder\";\nimport { EntityLoader, isLoadable } from \"./delegates/loader\";\n\nexport interface CreateGameEntityOptions<T extends GameEntity<any>, CreateOptions extends GameEntityOptions> {\n\targs: Array<any>;\n\tdefaultConfig: GameEntityOptions;\n\tEntityClass: new (options: any) => T;\n\tBuilderClass: new (options: any, entity: T, meshBuilder: any, collisionBuilder: any) => EntityBuilder<T, CreateOptions>;\n\tMeshBuilderClass?: new (data: any) => EntityMeshBuilder;\n\tCollisionBuilderClass?: new (data: any) => EntityCollisionBuilder;\n\tentityType: symbol;\n};\n\nexport function createEntity<T extends GameEntity<any>, CreateOptions extends GameEntityOptions>(params: CreateGameEntityOptions<T, CreateOptions>): T {\n\tconst {\n\t\targs,\n\t\tdefaultConfig,\n\t\tEntityClass,\n\t\tBuilderClass,\n\t\tentityType,\n\t\tMeshBuilderClass,\n\t\tCollisionBuilderClass,\n\t} = params;\n\n\tlet builder: EntityBuilder<T, CreateOptions> | null = null;\n\tlet configuration;\n\n\tconst configurationIndex = args.findIndex(node => !(node instanceof BaseNode));\n\tif (configurationIndex !== -1) {\n\t\tconst subArgs = args.splice(configurationIndex, 1);\n\t\tconfiguration = subArgs.find(node => !(node instanceof BaseNode));\n\t}\n\n\tconst mergedConfiguration = configuration ? { ...defaultConfig, ...configuration } : defaultConfig;\n\targs.push(mergedConfiguration);\n\n\tfor (const arg of args) {\n\t\tif (arg instanceof BaseNode) {\n\t\t\tcontinue;\n\t\t}\n\t\tlet entityData = null;\n\t\tconst entity = new EntityClass(arg);\n\t\ttry {\n\t\t\tif (isLoadable(entity)) {\n\t\t\t\tconst loader = new EntityLoader(entity);\n\t\t\t\tloader.load();\n\t\t\t\tentityData = loader.data();\n\t\t\t}\n\t\t} catch (error) {\n\t\t\tconsole.error(\"Error creating entity with loader:\", error);\n\t\t}\n\t\tbuilder = new BuilderClass(\n\t\t\targ,\n\t\t\tentity,\n\t\t\tMeshBuilderClass ? new MeshBuilderClass(entityData) : null,\n\t\t\tCollisionBuilderClass ? new CollisionBuilderClass(entityData) : null,\n\t\t);\n\t\tif (arg.material) {\n\t\t\tbuilder.withMaterial(arg.material, entityType);\n\t\t}\n\t}\n\n\tif (!builder) {\n\t\tthrow new Error(`missing options for ${String(entityType)}, builder is not initialized.`);\n\t}\n\n\treturn builder.build();\n}\n\n","import { Color, Vector3 } from 'three';\nimport { standardShader } from '../graphics/shaders/standard.shader';\nimport { GameEntityOptions } from './entity';\n\nexport const commonDefaults: Partial<GameEntityOptions> = {\n position: new Vector3(0, 0, 0),\n material: {\n color: new Color('#ffffff'),\n shader: standardShader\n },\n collision: {\n static: false,\n },\n};\n","import { ColliderDesc } from '@dimforge/rapier3d-compat';\nimport { BoxGeometry, Color } from 'three';\nimport { Vector3 } from 'three';\nimport { BaseNode } from '../core/base-node';\nimport { GameEntityOptions, GameEntity } from './entity';\nimport { EntityBuilder } from './builder';\nimport { EntityCollisionBuilder } from './builder';\nimport { EntityMeshBuilder } from './builder';\nimport { DebugDelegate } from './delegates/debug';\nimport { createEntity } from './create';\n\ntype ZylemBoxOptions = GameEntityOptions;\n\nimport { commonDefaults } from './common';\n\nconst boxDefaults: ZylemBoxOptions = {\n\t...commonDefaults,\n\tsize: new Vector3(1, 1, 1),\n};\n\nexport class BoxCollisionBuilder extends EntityCollisionBuilder {\n\tcollider(options: GameEntityOptions): ColliderDesc {\n\t\tconst size = options.size || new Vector3(1, 1, 1);\n\t\tconst half = { x: size.x / 2, y: size.y / 2, z: size.z / 2 };\n\t\tlet colliderDesc = ColliderDesc.cuboid(half.x, half.y, half.z);\n\t\treturn colliderDesc;\n\t}\n}\n\nexport class BoxMeshBuilder extends EntityMeshBuilder {\n\tbuild(options: GameEntityOptions): BoxGeometry {\n\t\tconst size = options.size ?? new Vector3(1, 1, 1);\n\t\treturn new BoxGeometry(size.x, size.y, size.z);\n\t}\n}\n\nexport class BoxBuilder extends EntityBuilder<ZylemBox, ZylemBoxOptions> {\n\tprotected createEntity(options: Partial<ZylemBoxOptions>): ZylemBox {\n\t\treturn new ZylemBox(options);\n\t}\n}\n\nexport const BOX_TYPE = Symbol('Box');\n\nexport class ZylemBox extends GameEntity<ZylemBoxOptions> {\n\tstatic type = BOX_TYPE;\n\n\tconstructor(options?: ZylemBoxOptions) {\n\t\tsuper();\n\t\tthis.options = { ...boxDefaults, ...options };\n\t}\n\n\tbuildInfo(): Record<string, any> {\n\t\tconst delegate = new DebugDelegate(this as any);\n\t\tconst baseInfo = delegate.buildDebugInfo();\n\n\t\tconst { x: sizeX, y: sizeY, z: sizeZ } = this.options.size ?? { x: 1, y: 1, z: 1 };\n\t\treturn {\n\t\t\t...baseInfo,\n\t\t\ttype: String(ZylemBox.type),\n\t\t\tsize: `${sizeX}, ${sizeY}, ${sizeZ}`,\n\t\t};\n\t}\n}\n\ntype BoxOptions = BaseNode | ZylemBoxOptions;\n\nexport function createBox(...args: Array<BoxOptions>): ZylemBox {\n\treturn createEntity<ZylemBox, ZylemBoxOptions>({\n\t\targs,\n\t\tdefaultConfig: boxDefaults,\n\t\tEntityClass: ZylemBox,\n\t\tBuilderClass: BoxBuilder,\n\t\tMeshBuilderClass: BoxMeshBuilder,\n\t\tCollisionBuilderClass: BoxCollisionBuilder,\n\t\tentityType: ZylemBox.type\n\t});\n}","import { ColliderDesc } from '@dimforge/rapier3d-compat';\nimport { Color, SphereGeometry } from 'three';\nimport { Vector3 } from 'three';\nimport { BaseNode } from '../core/base-node';\nimport { GameEntityOptions, GameEntity } from './entity';\nimport { EntityBuilder } from './builder';\nimport { EntityCollisionBuilder } from './builder';\nimport { EntityMeshBuilder } from './builder';\nimport { DebugDelegate } from './delegates/debug';\nimport { standardShader } from '../graphics/shaders/standard.shader';\nimport { createEntity } from './create';\n\ntype ZylemSphereOptions = GameEntityOptions & {\n\tradius?: number;\n};\n\nimport { commonDefaults } from './common';\n\nconst sphereDefaults: ZylemSphereOptions = {\n\t...commonDefaults,\n\tradius: 1,\n};\n\nexport class SphereCollisionBuilder extends EntityCollisionBuilder {\n\tcollider(options: ZylemSphereOptions): ColliderDesc {\n\t\tconst radius = options.radius ?? 1;\n\t\tlet colliderDesc = ColliderDesc.ball(radius);\n\t\treturn colliderDesc;\n\t}\n}\n\nexport class SphereMeshBuilder extends EntityMeshBuilder {\n\tbuild(options: ZylemSphereOptions): SphereGeometry {\n\t\tconst radius = options.radius ?? 1;\n\t\treturn new SphereGeometry(radius);\n\t}\n}\n\nexport class SphereBuilder extends EntityBuilder<ZylemSphere, ZylemSphereOptions> {\n\tprotected createEntity(options: Partial<ZylemSphereOptions>): ZylemSphere {\n\t\treturn new ZylemSphere(options);\n\t}\n}\n\nexport const SPHERE_TYPE = Symbol('Sphere');\n\nexport class ZylemSphere extends GameEntity<ZylemSphereOptions> {\n\tstatic type = SPHERE_TYPE;\n\n\tconstructor(options?: ZylemSphereOptions) {\n\t\tsuper();\n\t\tthis.options = { ...sphereDefaults, ...options };\n\t}\n\n\tbuildInfo(): Record<string, any> {\n\t\tconst delegate = new DebugDelegate(this as any);\n\t\tconst baseInfo = delegate.buildDebugInfo();\n\t\tconst radius = this.options.radius ?? 1;\n\t\treturn {\n\t\t\t...baseInfo,\n\t\t\ttype: String(ZylemSphere.type),\n\t\t\tradius: radius.toFixed(2),\n\t\t};\n\t}\n}\n\ntype SphereOptions = BaseNode | Partial<ZylemSphereOptions>;\n\nexport function createSphere(...args: Array<SphereOptions>): ZylemSphere {\n\treturn createEntity<ZylemSphere, ZylemSphereOptions>({\n\t\targs,\n\t\tdefaultConfig: sphereDefaults,\n\t\tEntityClass: ZylemSphere,\n\t\tBuilderClass: SphereBuilder,\n\t\tMeshBuilderClass: SphereMeshBuilder,\n\t\tCollisionBuilderClass: SphereCollisionBuilder,\n\t\tentityType: ZylemSphere.type\n\t});\n}","import { ColliderDesc } from '@dimforge/rapier3d-compat';\nimport { Color, Euler, Group, Quaternion, Vector3 } from 'three';\nimport {\n\tTextureLoader,\n\tSpriteMaterial,\n\tSprite as ThreeSprite,\n} from 'three';\nimport { BaseNode } from '../core/base-node';\nimport { GameEntityOptions, GameEntity } from './entity';\nimport { EntityBuilder } from './builder';\nimport { EntityCollisionBuilder } from './builder';\nimport { createEntity } from './create';\nimport { DestroyContext, DestroyFunction, UpdateContext, UpdateFunction } from '../core/base-node-life-cycle';\nimport { DebugDelegate } from './delegates/debug';\nimport { standardShader } from '../graphics/shaders/standard.shader';\n\nexport type SpriteImage = { name: string; file: string };\nexport type SpriteAnimation = {\n\tname: string;\n\tframes: string[];\n\tspeed: number | number[];\n\tloop: boolean;\n};\n\ntype ZylemSpriteOptions = GameEntityOptions & {\n\timages?: SpriteImage[];\n\tanimations?: SpriteAnimation[];\n\tsize?: Vector3;\n\tcollisionSize?: Vector3;\n};\n\nimport { commonDefaults } from './common';\n\nconst spriteDefaults: ZylemSpriteOptions = {\n\t...commonDefaults,\n\tsize: new Vector3(1, 1, 1),\n\timages: [],\n\tanimations: [],\n};\n\nexport class SpriteCollisionBuilder extends EntityCollisionBuilder {\n\tcollider(options: ZylemSpriteOptions): ColliderDesc {\n\t\tconst size = options.collisionSize || options.size || new Vector3(1, 1, 1);\n\t\tconst half = { x: size.x / 2, y: size.y / 2, z: size.z / 2 };\n\t\tlet colliderDesc = ColliderDesc.cuboid(half.x, half.y, half.z);\n\t\treturn colliderDesc;\n\t}\n}\n\nexport class SpriteBuilder extends EntityBuilder<ZylemSprite, ZylemSpriteOptions> {\n\tprotected createEntity(options: Partial<ZylemSpriteOptions>): ZylemSprite {\n\t\treturn new ZylemSprite(options);\n\t}\n}\n\nexport const SPRITE_TYPE = Symbol('Sprite');\n\nexport class ZylemSprite extends GameEntity<ZylemSpriteOptions> {\n\tstatic type = SPRITE_TYPE;\n\n\tprotected sprites: ThreeSprite[] = [];\n\tprotected spriteMap: Map<string, number> = new Map();\n\tprotected currentSpriteIndex: number = 0;\n\tprotected animations: Map<string, any> = new Map();\n\tprotected currentAnimation: any = null;\n\tprotected currentAnimationFrame: string = '';\n\tprotected currentAnimationIndex: number = 0;\n\tprotected currentAnimationTime: number = 0;\n\n\tconstructor(options?: ZylemSpriteOptions) {\n\t\tsuper();\n\t\tthis.options = { ...spriteDefaults, ...options };\n\t\t// Add sprite-specific lifecycle callbacks (only registered once)\n\t\tthis.prependUpdate(this.spriteUpdate.bind(this) as any);\n\t\tthis.onDestroy(this.spriteDestroy.bind(this) as any);\n\t}\n\n\tpublic create(): this {\n\t\t// Clear previous state to prevent accumulation on reload\n\t\tthis.sprites = [];\n\t\tthis.spriteMap.clear();\n\t\tthis.animations.clear();\n\t\tthis.currentAnimation = null;\n\t\tthis.currentAnimationFrame = '';\n\t\tthis.currentAnimationIndex = 0;\n\t\tthis.currentAnimationTime = 0;\n\t\tthis.group = undefined;\n\t\t\n\t\t// Recreate sprites and animations\n\t\tthis.createSpritesFromImages(this.options?.images || []);\n\t\tthis.createAnimations(this.options?.animations || []);\n\t\t\n\t\t// Call parent create\n\t\treturn super.create();\n\t}\n\n\tprotected createSpritesFromImages(images: SpriteImage[]) {\n\t\t// Use synchronous load() which returns a texture that updates when ready\n\t\t// This maintains compatibility with the synchronous create() method\n\t\tconst textureLoader = new TextureLoader();\n\t\timages.forEach((image, index) => {\n\t\t\tconst spriteMap = textureLoader.load(image.file);\n\t\t\tconst material = new SpriteMaterial({\n\t\t\t\tmap: spriteMap,\n\t\t\t\ttransparent: true,\n\t\t\t});\n\t\t\tconst _sprite = new ThreeSprite(material);\n\t\t\t_sprite.position.normalize();\n\t\t\tthis.sprites.push(_sprite);\n\t\t\tthis.spriteMap.set(image.name, index);\n\t\t});\n\t\tthis.group = new Group();\n\t\tthis.group.add(...this.sprites);\n\t}\n\n\tprotected createAnimations(animations: SpriteAnimation[]) {\n\t\tanimations.forEach(animation => {\n\t\t\tconst { name, frames, loop = false, speed = 1 } = animation;\n\t\t\tconst internalAnimation = {\n\t\t\t\tframes: frames.map((frame, index) => ({\n\t\t\t\t\tkey: frame,\n\t\t\t\t\tindex,\n\t\t\t\t\ttime: (typeof speed === 'number' ? speed : speed[index]) * (index + 1),\n\t\t\t\t\tduration: typeof speed === 'number' ? speed : speed[index]\n\t\t\t\t})),\n\t\t\t\tloop,\n\t\t\t};\n\t\t\tthis.animations.set(name, internalAnimation);\n\t\t});\n\t}\n\n\tsetSprite(key: string) {\n\t\tconst spriteIndex = this.spriteMap.get(key);\n\t\tconst useIndex = spriteIndex ?? 0;\n\t\tthis.currentSpriteIndex = useIndex;\n\t\tthis.sprites.forEach((_sprite, i) => {\n\t\t\t_sprite.visible = this.currentSpriteIndex === i;\n\t\t});\n\t}\n\n\tsetAnimation(name: string, delta: number) {\n\t\tconst animation = this.animations.get(name);\n\t\tif (!animation) return;\n\n\t\tconst { loop, frames } = animation;\n\t\tconst frame = frames[this.currentAnimationIndex];\n\n\t\tif (name === this.currentAnimation) {\n\t\t\tthis.currentAnimationFrame = frame.key;\n\t\t\tthis.currentAnimationTime += delta;\n\t\t\tthis.setSprite(this.currentAnimationFrame);\n\t\t} else {\n\t\t\tthis.currentAnimation = name;\n\t\t}\n\n\t\tif (this.currentAnimationTime > frame.time) {\n\t\t\tthis.currentAnimationIndex++;\n\t\t}\n\n\t\tif (this.currentAnimationIndex >= frames.length) {\n\t\t\tif (loop) {\n\t\t\t\tthis.currentAnimationIndex = 0;\n\t\t\t\tthis.currentAnimationTime = 0;\n\t\t\t} else {\n\t\t\t\tthis.currentAnimationTime = frames[this.currentAnimationIndex].time;\n\t\t\t}\n\t\t}\n\t}\n\n\tspriteUpdate(params: UpdateContext<ZylemSpriteOptions>): void {\n\t\tthis.sprites.forEach(_sprite => {\n\t\t\tif (_sprite.material) {\n\t\t\t\tconst q = this.body?.rotation();\n\t\t\t\tif (q) {\n\t\t\t\t\tconst quat = new Quaternion(q.x, q.y, q.z, q.w);\n\t\t\t\t\tconst euler = new Euler().setFromQuaternion(quat, 'XYZ');\n\t\t\t\t\t_sprite.material.rotation = euler.z;\n\t\t\t\t}\n\t\t\t\t_sprite.scale.set(this.options.size?.x ?? 1, this.options.size?.y ?? 1, this.options.size?.z ?? 1);\n\t\t\t}\n\t\t});\n\t}\n\n\tspriteDestroy(params: DestroyContext<ZylemSpriteOptions>): void {\n\t\tthis.sprites.forEach(_sprite => {\n\t\t\t_sprite.removeFromParent();\n\t\t});\n\t\tthis.group?.remove(...this.sprites);\n\t\tthis.group?.removeFromParent();\n\t}\n\n\tbuildInfo(): Record<string, any> {\n\t\tconst delegate = new DebugDelegate(this as any);\n\t\tconst baseInfo = delegate.buildDebugInfo();\n\t\treturn {\n\t\t\t...baseInfo,\n\t\t\ttype: String(ZylemSprite.type),\n\t\t};\n\t}\n}\n\ntype SpriteOptions = BaseNode | Partial<ZylemSpriteOptions>;\n\nexport function createSprite(...args: Array<SpriteOptions>): ZylemSprite {\n\treturn createEntity<ZylemSprite, ZylemSpriteOptions>({\n\t\targs,\n\t\tdefaultConfig: spriteDefaults,\n\t\tEntityClass: ZylemSprite,\n\t\tBuilderClass: SpriteBuilder,\n\t\tCollisionBuilderClass: SpriteCollisionBuilder,\n\t\tentityType: ZylemSprite.type\n\t});\n}","// @ts-nocheck\nimport { BufferGeometry, Float32BufferAttribute } from 'three';\n\nclass XZPlaneGeometry extends BufferGeometry {\n\n\tconstructor(width = 1, height = 1, widthSegments = 1, heightSegments = 1) {\n\n\t\tsuper();\n\n\t\tthis.type = 'XZPlaneGeometry';\n\n\t\tthis.parameters = {\n\t\t\twidth: width,\n\t\t\theight: height,\n\t\t\twidthSegments: widthSegments,\n\t\t\theightSegments: heightSegments\n\t\t};\n\n\t\tconst width_half = width / 2;\n\t\tconst height_half = height / 2;\n\n\t\tconst gridX = Math.floor(widthSegments);\n\t\tconst gridY = Math.floor(heightSegments);\n\n\t\tconst gridX1 = gridX + 1;\n\t\tconst gridY1 = gridY + 1;\n\n\t\tconst segment_width = width / gridX;\n\t\tconst segment_height = height / gridY;\n\n\t\tconst indices = [];\n\t\tconst vertices = [];\n\t\tconst normals = [];\n\t\tconst uvs = [];\n\n\t\tfor (let iy = 0; iy < gridY1; iy++) {\n\n\t\t\tconst z = iy * segment_height - height_half;\n\n\t\t\tfor (let ix = 0; ix < gridX1; ix++) {\n\n\t\t\t\tconst x = ix * segment_width - width_half;\n\n\t\t\t\tvertices.push(x, 0, z);\n\n\t\t\t\tnormals.push(0, 1, 0);\n\n\t\t\t\tuvs.push(ix / gridX);\n\t\t\t\tuvs.push(1 - (iy / gridY));\n\n\t\t\t}\n\n\t\t}\n\n\t\tfor (let iy = 0; iy < gridY; iy++) {\n\n\t\t\tfor (let ix = 0; ix < gridX; ix++) {\n\n\t\t\t\tconst a = ix + gridX1 * iy;\n\t\t\t\tconst b = ix + gridX1 * (iy + 1);\n\t\t\t\tconst c = (ix + 1) + gridX1 * (iy + 1);\n\t\t\t\tconst d = (ix + 1) + gridX1 * iy;\n\n\t\t\t\tindices.push(a, b, d);\n\t\t\t\tindices.push(b, c, d);\n\n\t\t\t}\n\n\t\t}\n\n\t\tthis.setIndex(indices);\n\t\tthis.setAttribute('position', new Float32BufferAttribute(vertices, 3));\n\t\tthis.setAttribute('normal', new Float32BufferAttribute(normals, 3));\n\t\tthis.setAttribute('uv', new Float32BufferAttribute(uvs, 2));\n\n\t}\n\n\tcopy(source) {\n\n\t\tsuper.copy(source);\n\n\t\tthis.parameters = Object.assign({}, source.parameters);\n\n\t\treturn this;\n\t}\n\n\tstatic fromJSON(data) {\n\t\treturn new XZPlaneGeometry(data.width, data.height, data.widthSegments, data.heightSegments);\n\t}\n\n}\n\nexport { XZPlaneGeometry };","import { ColliderDesc } from '@dimforge/rapier3d-compat';\nimport { PlaneGeometry, Vector2, Vector3 } from 'three';\nimport { TexturePath } from '../graphics/material';\nimport { BaseNode } from '../core/base-node';\nimport { GameEntityOptions, GameEntity } from './entity';\nimport { EntityBuilder } from './builder';\nimport { EntityCollisionBuilder } from './builder';\nimport { EntityMeshBuilder } from './builder';\nimport { XZPlaneGeometry } from '../graphics/geometries/XZPlaneGeometry';\nimport { createEntity } from './create';\n\ntype ZylemPlaneOptions = GameEntityOptions & {\n\ttile?: Vector2;\n\trepeat?: Vector2;\n\ttexture?: TexturePath;\n\tsubdivisions?: number;\n\trandomizeHeight?: boolean;\n\theightMap?: number[];\n\theightScale?: number;\n};\n\nconst DEFAULT_SUBDIVISIONS = 4;\n\nimport { commonDefaults } from './common';\n\nconst planeDefaults: ZylemPlaneOptions = {\n\t...commonDefaults,\n\ttile: new Vector2(10, 10),\n\trepeat: new Vector2(1, 1),\n\tcollision: {\n\t\tstatic: true,\n\t},\n\tsubdivisions: DEFAULT_SUBDIVISIONS,\n\trandomizeHeight: false,\n\theightScale: 1,\n};\n\nexport class PlaneCollisionBuilder extends EntityCollisionBuilder {\n\tcollider(options: ZylemPlaneOptions): ColliderDesc {\n\t\tconst tile = options.tile ?? new Vector2(1, 1);\n\t\tconst subdivisions = options.subdivisions ?? DEFAULT_SUBDIVISIONS;\n\t\tconst size = new Vector3(tile.x, 1, tile.y);\n\n\t\tconst heightData = (options._builders?.meshBuilder as unknown as PlaneMeshBuilder)?.heightData;\n\t\tconst scale = new Vector3(size.x, 1, size.z);\n\t\tlet colliderDesc = ColliderDesc.heightfield(\n\t\t\tsubdivisions,\n\t\t\tsubdivisions,\n\t\t\theightData,\n\t\t\tscale\n\t\t);\n\n\t\treturn colliderDesc;\n\t}\n}\n\nexport class PlaneMeshBuilder extends EntityMeshBuilder {\n\theightData: Float32Array = new Float32Array();\n\tcolumnsRows = new Map();\n\tprivate subdivisions: number = DEFAULT_SUBDIVISIONS;\n\n\tbuild(options: ZylemPlaneOptions): XZPlaneGeometry {\n\t\tconst tile = options.tile ?? new Vector2(1, 1);\n\t\tconst subdivisions = options.subdivisions ?? DEFAULT_SUBDIVISIONS;\n\t\tthis.subdivisions = subdivisions;\n\t\tconst size = new Vector3(tile.x, 1, tile.y);\n\t\tconst heightScale = options.heightScale ?? 1;\n\n\t\tconst geometry = new XZPlaneGeometry(size.x, size.z, subdivisions, subdivisions);\n\t\tconst vertexGeometry = new PlaneGeometry(size.x, size.z, subdivisions, subdivisions);\n\t\tconst dx = size.x / subdivisions;\n\t\tconst dy = size.z / subdivisions;\n\t\tconst originalVertices = geometry.attributes.position.array;\n\t\tconst vertices = vertexGeometry.attributes.position.array;\n\t\tconst columsRows = new Map();\n\n\t\t// Get height data source\n\t\tconst heightMapData = options.heightMap;\n\t\tconst useRandomHeight = options.randomizeHeight ?? false;\n\n\t\tfor (let i = 0; i < vertices.length; i += 3) {\n\t\t\tconst vertexIndex = i / 3;\n\t\t\tlet row = Math.floor(Math.abs((vertices as any)[i] + (size.x / 2)) / dx);\n\t\t\tlet column = Math.floor(Math.abs((vertices as any)[i + 1] - (size.z / 2)) / dy);\n\n\t\t\tlet height = 0;\n\t\t\tif (heightMapData && heightMapData.length > 0) {\n\t\t\t\t// Loop the height map data if it doesn't cover all vertices\n\t\t\t\tconst heightIndex = vertexIndex % heightMapData.length;\n\t\t\t\theight = heightMapData[heightIndex] * heightScale;\n\t\t\t} else if (useRandomHeight) {\n\t\t\t\theight = Math.random() * 4 * heightScale;\n\t\t\t}\n\n\t\t\t(vertices as any)[i + 2] = height;\n\t\t\toriginalVertices[i + 1] = height;\n\t\t\tif (!columsRows.get(column)) {\n\t\t\t\tcolumsRows.set(column, new Map());\n\t\t\t}\n\t\t\tcolumsRows.get(column).set(row, height);\n\t\t}\n\t\tthis.columnsRows = columsRows;\n\t\treturn geometry;\n\t}\n\n\tpostBuild(): void {\n\t\tconst heights = [];\n\t\tfor (let i = 0; i <= this.subdivisions; ++i) {\n\t\t\tfor (let j = 0; j <= this.subdivisions; ++j) {\n\t\t\t\tconst row = this.columnsRows.get(j);\n\t\t\t\tif (!row) {\n\t\t\t\t\theights.push(0);\n\t\t\t\t\tcontinue;\n\t\t\t\t}\n\t\t\t\tconst data = row.get(i);\n\t\t\t\theights.push(data ?? 0);\n\t\t\t}\n\t\t}\n\t\tthis.heightData = new Float32Array(heights as unknown as number[]);\n\t}\n}\n\nexport class PlaneBuilder extends EntityBuilder<ZylemPlane, ZylemPlaneOptions> {\n\tprotected createEntity(options: Partial<ZylemPlaneOptions>): ZylemPlane {\n\t\treturn new ZylemPlane(options);\n\t}\n}\n\nexport const PLANE_TYPE = Symbol('Plane');\n\nexport class ZylemPlane extends GameEntity<ZylemPlaneOptions> {\n\tstatic type = PLANE_TYPE;\n\n\tconstructor(options?: ZylemPlaneOptions) {\n\t\tsuper();\n\t\tthis.options = { ...planeDefaults, ...options };\n\t}\n}\n\ntype PlaneOptions = BaseNode | Partial<ZylemPlaneOptions>;\n\nexport function createPlane(...args: Array<PlaneOptions>): ZylemPlane {\n\treturn createEntity<ZylemPlane, ZylemPlaneOptions>({\n\t\targs,\n\t\tdefaultConfig: planeDefaults,\n\t\tEntityClass: ZylemPlane,\n\t\tBuilderClass: PlaneBuilder,\n\t\tMeshBuilderClass: PlaneMeshBuilder,\n\t\tCollisionBuilderClass: PlaneCollisionBuilder,\n\t\tentityType: ZylemPlane.type\n\t});\n}\n","import { proxy, subscribe } from 'valtio/vanilla';\nimport { getByPath, setByPath } from '../core/utility/path-utils';\nimport { gameEventBus } from './game-event-bus';\n\n/**\n * Internal game state store using valtio proxy for reactivity.\n */\nconst state = proxy({\n\tid: '',\n\tglobals: {} as Record<string, unknown>,\n\ttime: 0,\n});\n\n/**\n * Track active subscriptions for cleanup on game dispose.\n */\nconst activeSubscriptions: Set<() => void> = new Set();\n\n/**\n * Set a global value by path.\n * Emits a 'game:state:updated' event when the value changes.\n * @example setGlobal('score', 100)\n * @example setGlobal('player.health', 50)\n */\nexport function setGlobal(path: string, value: unknown): void {\n\tconst previousValue = getByPath(state.globals, path);\n\tsetByPath(state.globals, path, value);\n\n\tgameEventBus.emit('game:state:updated', {\n\t\tpath,\n\t\tvalue,\n\t\tpreviousValue,\n\t});\n}\n\n/**\n * Create/initialize a global with a default value.\n * Only sets the value if it doesn't already exist.\n * Use this to ensure globals have initial values before game starts.\n * @example createGlobal('score', 0)\n * @example createGlobal('player.health', 100)\n */\nexport function createGlobal<T>(path: string, defaultValue: T): T {\n\tconst existing = getByPath<T>(state.globals, path);\n\tif (existing === undefined) {\n\t\tsetByPath(state.globals, path, defaultValue);\n\t\treturn defaultValue;\n\t}\n\treturn existing;\n}\n\n/**\n * Get a global value by path.\n * @example getGlobal('score') // 100\n * @example getGlobal<number>('player.health') // 50\n */\nexport function getGlobal<T = unknown>(path: string): T | undefined {\n\treturn getByPath<T>(state.globals, path);\n}\n\n/**\n * Subscribe to changes on a global value at a specific path.\n * Returns an unsubscribe function. Subscriptions are automatically\n * cleaned up when the game is disposed.\n * @example const unsub = onGlobalChange('score', (val) => console.log(val));\n */\nexport function onGlobalChange<T = unknown>(\n\tpath: string,\n\tcallback: (value: T) => void\n): () => void {\n\tlet previous = getByPath<T>(state.globals, path);\n\tconst unsub = subscribe(state.globals, () => {\n\t\tconst current = getByPath<T>(state.globals, path);\n\t\tif (current !== previous) {\n\t\t\tprevious = current;\n\t\t\tcallback(current as T);\n\t\t}\n\t});\n\tactiveSubscriptions.add(unsub);\n\treturn () => {\n\t\tunsub();\n\t\tactiveSubscriptions.delete(unsub);\n\t};\n}\n\n/**\n * Subscribe to changes on multiple global paths.\n * Callback fires when any of the paths change, receiving all current values.\n * Subscriptions are automatically cleaned up when the game is disposed.\n * @example const unsub = onGlobalChanges(['score', 'lives'], ([score, lives]) => console.log(score, lives));\n */\nexport function onGlobalChanges<T extends unknown[] = unknown[]>(\n\tpaths: string[],\n\tcallback: (values: T) => void\n): () => void {\n\tlet previousValues = paths.map(p => getByPath(state.globals, p));\n\tconst unsub = subscribe(state.globals, () => {\n\t\tconst currentValues = paths.map(p => getByPath(state.globals, p));\n\t\tconst hasChange = currentValues.some((val, i) => val !== previousValues[i]);\n\t\tif (hasChange) {\n\t\t\tpreviousValues = currentValues;\n\t\t\tcallback(currentValues as T);\n\t\t}\n\t});\n\tactiveSubscriptions.add(unsub);\n\treturn () => {\n\t\tunsub();\n\t\tactiveSubscriptions.delete(unsub);\n\t};\n}\n\n/**\n * Get the entire globals object (read-only snapshot).\n */\nexport function getGlobals<T = Record<string, unknown>>(): T {\n\treturn state.globals as T;\n}\n\n/**\n * Initialize globals from an object. Used internally during game setup.\n */\nexport function initGlobals(globals: Record<string, unknown>): void {\n\tfor (const [key, value] of Object.entries(globals)) {\n\t\tsetByPath(state.globals, key, value);\n\t}\n}\n\n/**\n * Reset all globals. Used internally on game dispose.\n */\nexport function resetGlobals(): void {\n\tstate.globals = {};\n}\n\n/**\n * Unsubscribe all active global subscriptions.\n * Used internally on game dispose to prevent old callbacks from firing.\n */\nexport function clearGlobalSubscriptions(): void {\n\tfor (const unsub of activeSubscriptions) {\n\t\tunsub();\n\t}\n\tactiveSubscriptions.clear();\n}\n\nexport { state };","import { ActiveCollisionTypes, ColliderDesc } from '@dimforge/rapier3d-compat';\nimport { Vector3 } from 'three';\nimport { BaseNode } from '../core/base-node';\nimport { GameEntityOptions, GameEntity } from './entity';\nimport { EntityBuilder } from './builder';\nimport { EntityCollisionBuilder } from './builder';\nimport { createEntity } from './create';\nimport { CollisionHandlerDelegate } from '../collision/world';\nimport { state } from '../game/game-state';\nimport { commonDefaults } from './common';\n\nexport type OnHeldParams = {\n\tdelta: number;\n\tself: ZylemZone;\n\tvisitor: GameEntity<any>;\n\theldTime: number;\n\tglobals: any;\n}\n\nexport type OnEnterParams = Pick<OnHeldParams, 'self' | 'visitor' | 'globals'>;\nexport type OnExitParams = Pick<OnHeldParams, 'self' | 'visitor' | 'globals'>;\n\ntype ZylemZoneOptions = GameEntityOptions & {\n\tsize?: Vector3;\n\tstatic?: boolean;\n\tonEnter?: (params: OnEnterParams) => void;\n\tonHeld?: (params: OnHeldParams) => void;\n\tonExit?: (params: OnExitParams) => void;\n};\n\nconst zoneDefaults: ZylemZoneOptions = {\n\t...commonDefaults,\n\tsize: new Vector3(1, 1, 1),\n\tcollision: {\n\t\tstatic: true,\n\t},\n};\n\nexport class ZoneCollisionBuilder extends EntityCollisionBuilder {\n\tcollider(options: ZylemZoneOptions): ColliderDesc {\n\t\tconst size = options.size || new Vector3(1, 1, 1);\n\t\tconst half = { x: size.x / 2, y: size.y / 2, z: size.z / 2 };\n\t\tlet colliderDesc = ColliderDesc.cuboid(half.x, half.y, half.z);\n\t\tcolliderDesc.setSensor(true);\n\t\tcolliderDesc.activeCollisionTypes = ActiveCollisionTypes.KINEMATIC_FIXED;\n\t\treturn colliderDesc;\n\t}\n}\n\nexport class ZoneBuilder extends EntityBuilder<ZylemZone, ZylemZoneOptions> {\n\tprotected createEntity(options: Partial<ZylemZoneOptions>): ZylemZone {\n\t\treturn new ZylemZone(options);\n\t}\n}\n\nexport const ZONE_TYPE = Symbol('Zone');\n\nexport class ZylemZone extends GameEntity<ZylemZoneOptions> implements CollisionHandlerDelegate {\n\tstatic type = ZONE_TYPE;\n\n\tprivate _enteredZone: Map<string, number> = new Map();\n\tprivate _exitedZone: Map<string, number> = new Map();\n\tprivate _zoneEntities: Map<string, any> = new Map();\n\n\tconstructor(options?: ZylemZoneOptions) {\n\t\tsuper();\n\t\tthis.options = { ...zoneDefaults, ...options };\n\t}\n\n\tpublic handlePostCollision({ delta }: { delta: number }): boolean {\n\t\tthis._enteredZone.forEach((val, key) => {\n\t\t\tthis.exited(delta, key);\n\t\t});\n\t\treturn this._enteredZone.size > 0;\n\t}\n\n\tpublic handleIntersectionEvent({ other, delta }: { other: any, delta: number }) {\n\t\tconst hasEntered = this._enteredZone.get(other.uuid);\n\t\tif (!hasEntered) {\n\t\t\tthis.entered(other);\n\t\t\tthis._zoneEntities.set(other.uuid, other);\n\t\t} else {\n\t\t\tthis.held(delta, other);\n\t\t}\n\t}\n\n\tonEnter(callback: (params: OnEnterParams) => void) {\n\t\tthis.options.onEnter = callback;\n\t\treturn this;\n\t}\n\n\tonHeld(callback: (params: OnHeldParams) => void) {\n\t\tthis.options.onHeld = callback;\n\t\treturn this;\n\t}\n\n\tonExit(callback: (params: OnExitParams) => void) {\n\t\tthis.options.onExit = callback;\n\t\treturn this;\n\t}\n\n\tentered(other: any) {\n\t\tthis._enteredZone.set(other.uuid, 1);\n\t\tif (this.options.onEnter) {\n\t\t\tthis.options.onEnter({\n\t\t\t\tself: this,\n\t\t\t\tvisitor: other,\n\t\t\t\tglobals: state.globals\n\t\t\t});\n\t\t}\n\t}\n\n\texited(delta: number, key: string) {\n\t\tconst hasExited = this._exitedZone.get(key);\n\t\tif (hasExited && hasExited > 1 + delta) {\n\t\t\tthis._exitedZone.delete(key);\n\t\t\tthis._enteredZone.delete(key);\n\t\t\tconst other = this._zoneEntities.get(key);\n\t\t\tif (this.options.onExit) {\n\t\t\t\tthis.options.onExit({\n\t\t\t\t\tself: this,\n\t\t\t\t\tvisitor: other,\n\t\t\t\t\tglobals: state.globals\n\t\t\t\t});\n\t\t\t}\n\t\t\treturn;\n\t\t}\n\t\tthis._exitedZone.set(key, 1 + delta);\n\t}\n\n\theld(delta: number, other: any) {\n\t\tconst heldTime = this._enteredZone.get(other.uuid) ?? 0;\n\t\tthis._enteredZone.set(other.uuid, heldTime + delta);\n\t\tthis._exitedZone.set(other.uuid, 1);\n\t\tif (this.options.onHeld) {\n\t\t\tthis.options.onHeld({\n\t\t\t\tdelta,\n\t\t\t\tself: this,\n\t\t\t\tvisitor: other,\n\t\t\t\tglobals: state.globals,\n\t\t\t\theldTime\n\t\t\t});\n\t\t}\n\t}\n}\n\ntype ZoneOptions = BaseNode | Partial<ZylemZoneOptions>;\n\nexport function createZone(...args: Array<ZoneOptions>): ZylemZone {\n\treturn createEntity<ZylemZone, ZylemZoneOptions>({\n\t\targs,\n\t\tdefaultConfig: zoneDefaults,\n\t\tEntityClass: ZylemZone,\n\t\tBuilderClass: ZoneBuilder,\n\t\tCollisionBuilderClass: ZoneCollisionBuilder,\n\t\tentityType: ZylemZone.type\n\t});\n}","/**\n * Entity Asset Loader - Refactored to use AssetManager\n * \n * This module provides a compatibility layer for existing code that uses EntityAssetLoader.\n * All loading now goes through the centralized AssetManager for caching.\n */\n\nimport { AnimationClip, Object3D } from 'three';\nimport { GLTF } from 'three/addons/loaders/GLTFLoader.js';\nimport { assetManager } from './asset-manager';\n\nexport interface AssetLoaderResult {\n\tobject?: Object3D;\n\tanimation?: AnimationClip;\n\tgltf?: GLTF;\n}\n\n/**\n * EntityAssetLoader - Uses AssetManager for all model loading\n * \n * This class is now a thin wrapper around AssetManager, providing backward\n * compatibility for existing code while benefiting from centralized caching.\n */\nexport class EntityAssetLoader {\n\t/**\n\t * Load a model file (FBX, GLTF, GLB, OBJ) using the asset manager\n\t */\n\tasync loadFile(file: string): Promise<AssetLoaderResult> {\n\t\tconst ext = file.split('.').pop()?.toLowerCase();\n\n\t\tswitch (ext) {\n\t\t\tcase 'fbx': {\n\t\t\t\tconst result = await assetManager.loadFBX(file);\n\t\t\t\treturn {\n\t\t\t\t\tobject: result.object,\n\t\t\t\t\tanimation: result.animations?.[0]\n\t\t\t\t};\n\t\t\t}\n\t\t\tcase 'gltf':\n\t\t\tcase 'glb': {\n\t\t\t\tconst result = await assetManager.loadGLTF(file);\n\t\t\t\treturn {\n\t\t\t\t\tobject: result.object,\n\t\t\t\t\tgltf: result.gltf\n\t\t\t\t};\n\t\t\t}\n\t\t\tcase 'obj': {\n\t\t\t\tconst result = await assetManager.loadOBJ(file);\n\t\t\t\treturn {\n\t\t\t\t\tobject: result.object\n\t\t\t\t};\n\t\t\t}\n\t\t\tdefault:\n\t\t\t\tthrow new Error(`Unsupported file type: ${file}`);\n\t\t}\n\t}\n}\n","import {\n\tAnimationAction,\n\tAnimationClip,\n\tAnimationMixer,\n\tLoopOnce,\n\tLoopRepeat,\n\tObject3D,\n} from 'three';\nimport { EntityAssetLoader, AssetLoaderResult } from '../../core/entity-asset-loader';\n\nexport type AnimationOptions = {\n\tkey: string;\n\tpauseAtEnd?: boolean;\n\tpauseAtPercentage?: number;\n\tfadeToKey?: string;\n\tfadeDuration?: number;\n};\n\ntype AnimationObject = {\n\tkey?: string;\n\tpath: string;\n};\n\nexport class AnimationDelegate {\n\tprivate _mixer: AnimationMixer | null = null;\n\tprivate _actions: Record<string, AnimationAction> = {};\n\tprivate _animations: AnimationClip[] = [];\n\tprivate _currentAction: AnimationAction | null = null;\n\n\tprivate _pauseAtPercentage = 0;\n\tprivate _isPaused = false;\n\tprivate _queuedKey: string | null = null;\n\tprivate _fadeDuration = 0.5;\n\n\tprivate _currentKey: string = '';\n\tprivate _assetLoader = new EntityAssetLoader();\n\n\tconstructor(private target: Object3D) { }\n\n\tasync loadAnimations(animations: AnimationObject[]): Promise<void> {\n\t\tif (!animations.length) return;\n\n\t\tconst results = await Promise.all(animations.map(a => this._assetLoader.loadFile(a.path)));\n\t\tthis._animations = results\n\t\t\t.filter((r): r is AssetLoaderResult => !!r.animation)\n\t\t\t.map(r => r.animation!);\n\n\t\tif (!this._animations.length) return;\n\n\t\tthis._mixer = new AnimationMixer(this.target);\n\t\tthis._animations.forEach((clip, i) => {\n\t\t\tconst key = animations[i].key || i.toString();\n\t\t\tthis._actions[key] = this._mixer!.clipAction(clip);\n\t\t});\n\n\t\tthis.playAnimation({ key: Object.keys(this._actions)[0] });\n\t}\n\n\tupdate(delta: number): void {\n\t\tif (!this._mixer || !this._currentAction) return;\n\n\t\tthis._mixer.update(delta);\n\n\t\tconst pauseAtTime = this._currentAction.getClip().duration * (this._pauseAtPercentage / 100);\n\t\tif (\n\t\t\t!this._isPaused &&\n\t\t\tthis._pauseAtPercentage > 0 &&\n\t\t\tthis._currentAction.time >= pauseAtTime\n\t\t) {\n\t\t\tthis._currentAction.time = pauseAtTime;\n\t\t\tthis._currentAction.paused = true;\n\t\t\tthis._isPaused = true;\n\n\t\t\tif (this._queuedKey !== null) {\n\t\t\t\tconst next = this._actions[this._queuedKey];\n\t\t\t\tnext.reset().play();\n\t\t\t\tthis._currentAction.crossFadeTo(next, this._fadeDuration, false);\n\t\t\t\tthis._currentAction = next;\n\t\t\t\tthis._currentKey = this._queuedKey;\n\t\t\t\tthis._queuedKey = null;\n\t\t\t}\n\t\t}\n\t}\n\n\tplayAnimation(opts: AnimationOptions): void {\n\t\tif (!this._mixer) return;\n\t\tconst { key, pauseAtPercentage = 0, pauseAtEnd = false, fadeToKey, fadeDuration = 0.5 } = opts;\n\t\tif (key === this._currentKey) return;\n\n\t\tthis._queuedKey = fadeToKey || null;\n\t\tthis._fadeDuration = fadeDuration;\n\n\t\tthis._pauseAtPercentage = pauseAtEnd ? 100 : pauseAtPercentage;\n\t\tthis._isPaused = false;\n\n\t\tconst prev = this._currentAction;\n\t\tif (prev) prev.stop();\n\n\t\tconst action = this._actions[key];\n\t\tif (!action) return;\n\n\t\tif (this._pauseAtPercentage > 0) {\n\t\t\taction.setLoop(LoopOnce, Infinity);\n\t\t\taction.clampWhenFinished = true;\n\t\t} else {\n\t\t\taction.setLoop(LoopRepeat, Infinity);\n\t\t\taction.clampWhenFinished = false;\n\t\t}\n\n\t\tif (prev) {\n\t\t\tprev.crossFadeTo(action, fadeDuration, false);\n\t\t}\n\t\taction.reset().play();\n\n\t\tthis._currentAction = action;\n\t\tthis._currentKey = key;\n\t}\n\n\t/**\n\t * Dispose of all animation resources\n\t */\n\tdispose(): void {\n\t\t// Stop all actions\n\t\tObject.values(this._actions).forEach(action => {\n\t\t\taction.stop();\n\t\t});\n\n\t\t// Stop and uncache mixer\n\t\tif (this._mixer) {\n\t\t\tthis._mixer.stopAllAction();\n\t\t\tthis._mixer.uncacheRoot(this.target);\n\t\t\tthis._mixer = null;\n\t\t}\n\n\t\t// Clear references\n\t\tthis._actions = {};\n\t\tthis._animations = [];\n\t\tthis._currentAction = null;\n\t\tthis._currentKey = '';\n\t}\n\n\tget currentAnimationKey() { return this._currentKey; }\n\tget animations() { return this._animations; }\n}\n","import { Color, Group, Sprite as ThreeSprite, SpriteMaterial, CanvasTexture, LinearFilter, Vector2, PerspectiveCamera, OrthographicCamera, ClampToEdgeWrapping } from 'three';\nimport { BaseNode } from '../core/base-node';\nimport { GameEntityOptions, GameEntity } from './entity';\nimport { EntityBuilder } from './builder';\nimport { createEntity } from './create';\nimport { UpdateContext, SetupContext } from '../core/base-node-life-cycle';\nimport { ZylemCamera } from '../camera/zylem-camera';\nimport { DebugDelegate } from './delegates/debug';\n\ntype ZylemTextOptions = GameEntityOptions & {\n\ttext?: string;\n\tfontFamily?: string;\n\tfontSize?: number;\n\tfontColor?: Color | string;\n\tbackgroundColor?: Color | string | null;\n\tpadding?: number;\n\tstickToViewport?: boolean;\n\tscreenPosition?: Vector2;\n\tzDistance?: number;\n};\n\nconst textDefaults: ZylemTextOptions = {\n\tposition: undefined,\n\ttext: '',\n\tfontFamily: 'Menlo, Monaco, Consolas, \"Liberation Mono\", \"Courier New\", monospace',\n\tfontSize: 18,\n\tfontColor: '#FFFFFF',\n\tbackgroundColor: null,\n\tpadding: 4,\n\tstickToViewport: true,\n\tscreenPosition: new Vector2(24, 24),\n\tzDistance: 1,\n};\n\nexport class TextBuilder extends EntityBuilder<ZylemText, ZylemTextOptions> {\n\tprotected createEntity(options: Partial<ZylemTextOptions>): ZylemText {\n\t\treturn new ZylemText(options);\n\t}\n}\n\nexport const TEXT_TYPE = Symbol('Text');\n\nexport class ZylemText extends GameEntity<ZylemTextOptions> {\n\tstatic type = TEXT_TYPE;\n\n\tprivate _sprite: ThreeSprite | null = null;\n\tprivate _texture: CanvasTexture | null = null;\n\tprivate _canvas: HTMLCanvasElement | null = null;\n\tprivate _ctx: CanvasRenderingContext2D | null = null;\n\tprivate _cameraRef: ZylemCamera | null = null;\n\tprivate _lastCanvasW: number = 0;\n\tprivate _lastCanvasH: number = 0;\n\n\tconstructor(options?: ZylemTextOptions) {\n\t\tsuper();\n\t\tthis.options = { ...textDefaults, ...options } as ZylemTextOptions;\n\t\t// Add text-specific lifecycle callbacks (only registered once)\n\t\tthis.prependSetup(this.textSetup.bind(this) as any);\n\t\tthis.prependUpdate(this.textUpdate.bind(this) as any);\n\t\tthis.onDestroy(this.textDestroy.bind(this) as any);\n\t}\n\n\tpublic create(): this {\n\t\t// Clear previous state to prevent issues on reload\n\t\tthis._sprite = null;\n\t\tthis._texture = null;\n\t\tthis._canvas = null;\n\t\tthis._ctx = null;\n\t\tthis._lastCanvasW = 0;\n\t\tthis._lastCanvasH = 0;\n\t\tthis.group = new Group();\n\t\t\n\t\t// Recreate the sprite\n\t\tthis.createSprite();\n\t\t\n\t\t// Call parent create\n\t\treturn super.create();\n\t}\n\n\tprivate createSprite() {\n\t\tthis._canvas = document.createElement('canvas');\n\t\tthis._ctx = this._canvas.getContext('2d');\n\t\tthis._texture = new CanvasTexture(this._canvas);\n\t\tthis._texture.minFilter = LinearFilter;\n\t\tthis._texture.magFilter = LinearFilter;\n\t\tconst material = new SpriteMaterial({\n\t\t\tmap: this._texture,\n\t\t\ttransparent: true,\n\t\t\tdepthTest: false,\n\t\t\tdepthWrite: false,\n\t\t\talphaTest: 0.5,\n\t\t});\n\t\tthis._sprite = new ThreeSprite(material);\n\t\tthis.group?.add(this._sprite);\n\t\tthis.redrawText(this.options.text ?? '');\n\t}\n\n\tprivate measureAndResizeCanvas(text: string, fontSize: number, fontFamily: string, padding: number) {\n\t\tif (!this._canvas || !this._ctx) return { sizeChanged: false };\n\t\tthis._ctx.font = `${fontSize}px ${fontFamily}`;\n\t\tconst metrics = this._ctx.measureText(text);\n\t\tconst textWidth = Math.ceil(metrics.width);\n\t\tconst textHeight = Math.ceil(fontSize * 1.4);\n\t\tconst nextW = Math.max(2, textWidth + padding * 2);\n\t\tconst nextH = Math.max(2, textHeight + padding * 2);\n\t\tconst sizeChanged = nextW !== this._lastCanvasW || nextH !== this._lastCanvasH;\n\t\tthis._canvas.width = nextW;\n\t\tthis._canvas.height = nextH;\n\t\tthis._lastCanvasW = nextW;\n\t\tthis._lastCanvasH = nextH;\n\t\treturn { sizeChanged };\n\t}\n\n\tprivate drawCenteredText(text: string, fontSize: number, fontFamily: string) {\n\t\tif (!this._canvas || !this._ctx) return;\n\t\tthis._ctx.font = `${fontSize}px ${fontFamily}`;\n\t\tthis._ctx.textAlign = 'center';\n\t\tthis._ctx.textBaseline = 'middle';\n\t\tthis._ctx.clearRect(0, 0, this._canvas.width, this._canvas.height);\n\t\tif (this.options.backgroundColor) {\n\t\t\tthis._ctx.fillStyle = this.toCssColor(this.options.backgroundColor);\n\t\t\tthis._ctx.fillRect(0, 0, this._canvas.width, this._canvas.height);\n\t\t}\n\t\tthis._ctx.fillStyle = this.toCssColor(this.options.fontColor ?? '#FFFFFF');\n\t\tthis._ctx.fillText(text, this._canvas.width / 2, this._canvas.height / 2);\n\t}\n\n\tprivate updateTexture(sizeChanged: boolean) {\n\t\tif (!this._texture || !this._canvas) return;\n\t\tif (sizeChanged) {\n\t\t\tthis._texture.dispose();\n\t\t\tthis._texture = new CanvasTexture(this._canvas);\n\t\t\tthis._texture.minFilter = LinearFilter;\n\t\t\tthis._texture.magFilter = LinearFilter;\n\t\t\tthis._texture.wrapS = ClampToEdgeWrapping;\n\t\t\tthis._texture.wrapT = ClampToEdgeWrapping;\n\t\t}\n\t\tthis._texture.image = this._canvas;\n\t\tthis._texture.needsUpdate = true;\n\t\tif (this._sprite && this._sprite.material) {\n\t\t\t(this._sprite.material as any).map = this._texture;\n\t\t\tthis._sprite.material.needsUpdate = true;\n\t\t}\n\t}\n\n\tprivate redrawText(_text: string) {\n\t\tif (!this._canvas || !this._ctx) return;\n\t\tconst fontSize = this.options.fontSize ?? 18;\n\t\tconst fontFamily = this.options.fontFamily ?? (textDefaults.fontFamily as string);\n\t\tconst padding = this.options.padding ?? 4;\n\n\t\tconst { sizeChanged } = this.measureAndResizeCanvas(_text, fontSize, fontFamily, padding);\n\t\tthis.drawCenteredText(_text, fontSize, fontFamily);\n\t\tthis.updateTexture(Boolean(sizeChanged));\n\n\t\tif (this.options.stickToViewport && this._cameraRef) {\n\t\t\tthis.updateStickyTransform();\n\t\t}\n\t}\n\n\tprivate toCssColor(color: Color | string): string {\n\t\tif (typeof color === 'string') return color;\n\t\tconst c = color instanceof Color ? color : new Color(color as any);\n\t\treturn `#${c.getHexString()}`;\n\t}\n\n\tprivate textSetup(params: SetupContext<ZylemTextOptions>) {\n\t\tthis._cameraRef = (params.camera as unknown) as ZylemCamera | null;\n\t\tif (this.options.stickToViewport && this._cameraRef) {\n\t\t\t(this._cameraRef.camera as any).add(this.group);\n\t\t\tthis.updateStickyTransform();\n\t\t}\n\t}\n\n\tprivate textUpdate(params: UpdateContext<ZylemTextOptions>) {\n\t\tif (!this._sprite) return;\n\t\tif (this.options.stickToViewport && this._cameraRef) {\n\t\t\tthis.updateStickyTransform();\n\t\t}\n\t}\n\n\tprivate getResolution() {\n\t\treturn {\n\t\t\twidth: this._cameraRef?.screenResolution.x ?? 1,\n\t\t\theight: this._cameraRef?.screenResolution.y ?? 1,\n\t\t};\n\t}\n\n\tprivate getScreenPixels(sp: Vector2, width: number, height: number) {\n\t\tconst isPercentX = sp.x >= 0 && sp.x <= 1;\n\t\tconst isPercentY = sp.y >= 0 && sp.y <= 1;\n\t\treturn {\n\t\t\tpx: isPercentX ? sp.x * width : sp.x,\n\t\t\tpy: isPercentY ? sp.y * height : sp.y,\n\t\t};\n\t}\n\n\tprivate computeWorldExtents(camera: PerspectiveCamera | OrthographicCamera, zDist: number) {\n\t\tlet worldHalfW = 1;\n\t\tlet worldHalfH = 1;\n\t\tif ((camera as PerspectiveCamera).isPerspectiveCamera) {\n\t\t\tconst pc = camera as PerspectiveCamera;\n\t\t\tconst halfH = Math.tan((pc.fov * Math.PI) / 180 / 2) * zDist;\n\t\t\tconst halfW = halfH * pc.aspect;\n\t\t\tworldHalfW = halfW;\n\t\t\tworldHalfH = halfH;\n\t\t} else if ((camera as OrthographicCamera).isOrthographicCamera) {\n\t\t\tconst oc = camera as OrthographicCamera;\n\t\t\tworldHalfW = (oc.right - oc.left) / 2;\n\t\t\tworldHalfH = (oc.top - oc.bottom) / 2;\n\t\t}\n\t\treturn { worldHalfW, worldHalfH };\n\t}\n\n\tprivate updateSpriteScale(worldHalfH: number, viewportHeight: number) {\n\t\tif (!this._canvas || !this._sprite) return;\n\t\tconst planeH = worldHalfH * 2;\n\t\tconst unitsPerPixel = planeH / viewportHeight;\n\t\tconst pixelH = this._canvas.height;\n\t\tconst scaleY = Math.max(0.0001, pixelH * unitsPerPixel);\n\t\tconst aspect = this._canvas.width / this._canvas.height;\n\t\tconst scaleX = scaleY * aspect;\n\t\tthis._sprite.scale.set(scaleX, scaleY, 1);\n\t}\n\n\tprivate updateStickyTransform() {\n\t\tif (!this._sprite || !this._cameraRef) return;\n\t\tconst camera = this._cameraRef.camera as PerspectiveCamera | OrthographicCamera;\n\t\tconst { width, height } = this.getResolution();\n\t\tconst sp = this.options.screenPosition ?? new Vector2(24, 24);\n\t\tconst { px, py } = this.getScreenPixels(sp, width, height);\n\t\tconst zDist = Math.max(0.001, this.options.zDistance ?? 1);\n\t\tconst { worldHalfW, worldHalfH } = this.computeWorldExtents(camera, zDist);\n\n\t\tconst ndcX = (px / width) * 2 - 1;\n\t\tconst ndcY = 1 - (py / height) * 2;\n\t\tconst localX = ndcX * worldHalfW;\n\t\tconst localY = ndcY * worldHalfH;\n\t\tthis.group?.position.set(localX, localY, -zDist);\n\t\tthis.updateSpriteScale(worldHalfH, height);\n\t}\n\n\tupdateText(_text: string) {\n\t\tthis.options.text = _text;\n\t\tthis.redrawText(_text);\n\t\tif (this.options.stickToViewport && this._cameraRef) {\n\t\t\tthis.updateStickyTransform();\n\t\t}\n\t}\n\n\tbuildInfo(): Record<string, any> {\n\t\tconst delegate = new DebugDelegate(this as any);\n\t\tconst baseInfo = delegate.buildDebugInfo();\n\n\t\treturn {\n\t\t\t...baseInfo,\n\t\t\ttype: String(ZylemText.type),\n\t\t\ttext: this.options.text ?? '',\n\t\t\tsticky: this.options.stickToViewport,\n\t\t};\n\t}\n\n\t/**\n\t * Dispose of Three.js resources when the entity is destroyed.\n\t */\n\tprivate textDestroy(): void {\n\t\t// Dispose texture\n\t\tthis._texture?.dispose();\n\t\t\n\t\t// Dispose sprite material\n\t\tif (this._sprite?.material) {\n\t\t\t(this._sprite.material as SpriteMaterial).dispose();\n\t\t}\n\t\t\n\t\t// Remove sprite from group\n\t\tif (this._sprite) {\n\t\t\tthis._sprite.removeFromParent();\n\t\t}\n\t\t\n\t\t// Remove group from parent (camera or scene)\n\t\tthis.group?.removeFromParent();\n\t\t\n\t\t// Clear references\n\t\tthis._sprite = null;\n\t\tthis._texture = null;\n\t\tthis._canvas = null;\n\t\tthis._ctx = null;\n\t\tthis._cameraRef = null;\n\t}\n}\n\ntype TextOptions = BaseNode | Partial<ZylemTextOptions>;\n\nexport function createText(...args: Array<TextOptions>): ZylemText {\n\treturn createEntity<ZylemText, ZylemTextOptions>({\n\t\targs,\n\t\tdefaultConfig: { ...textDefaults },\n\t\tEntityClass: ZylemText,\n\t\tBuilderClass: TextBuilder,\n\t\tentityType: ZylemText.type,\n\t});\n}\n\n\n","import { Color, Group, Sprite as ThreeSprite, SpriteMaterial, CanvasTexture, LinearFilter, Vector2, PerspectiveCamera, OrthographicCamera, ClampToEdgeWrapping, ShaderMaterial, Mesh, PlaneGeometry, Vector3 } from 'three';\nimport { BaseNode } from '../core/base-node';\nimport { GameEntityOptions, GameEntity } from './entity';\nimport { EntityBuilder } from './builder';\nimport { createEntity } from './create';\nimport { UpdateContext, SetupContext } from '../core/base-node-life-cycle';\nimport { ZylemCamera } from '../camera/zylem-camera';\nimport { DebugDelegate } from './delegates/debug';\n\ntype ZylemRectOptions = GameEntityOptions & {\n\twidth?: number;\n\theight?: number;\n\tfillColor?: Color | string | null;\n\tstrokeColor?: Color | string | null;\n\tstrokeWidth?: number;\n\tradius?: number;\n\tpadding?: number;\n\tstickToViewport?: boolean;\n\tscreenPosition?: Vector2;\n\tzDistance?: number;\n\tanchor?: Vector2; // 0-100 per axis, default top-left (0,0)\n\tbounds?: {\n\t\tscreen?: { x: number; y: number; width: number; height: number };\n\t\tworld?: { left: number; right: number; top: number; bottom: number; z?: number };\n\t};\n};\n\nconst rectDefaults: ZylemRectOptions = {\n\tposition: undefined,\n\twidth: 120,\n\theight: 48,\n\tfillColor: '#FFFFFF',\n\tstrokeColor: null,\n\tstrokeWidth: 0,\n\tradius: 0,\n\tpadding: 0,\n\tstickToViewport: true,\n\tscreenPosition: new Vector2(24, 24),\n\tzDistance: 1,\n\tanchor: new Vector2(0, 0),\n};\n\nexport class RectBuilder extends EntityBuilder<ZylemRect, ZylemRectOptions> {\n\tprotected createEntity(options: Partial<ZylemRectOptions>): ZylemRect {\n\t\treturn new ZylemRect(options);\n\t}\n}\n\nexport const RECT_TYPE = Symbol('Rect');\n\nexport class ZylemRect extends GameEntity<ZylemRectOptions> {\n\tstatic type = RECT_TYPE;\n\n\tprivate _sprite: ThreeSprite | null = null;\n\tprivate _mesh: Mesh | null = null;\n\tprivate _texture: CanvasTexture | null = null;\n\tprivate _canvas: HTMLCanvasElement | null = null;\n\tprivate _ctx: CanvasRenderingContext2D | null = null;\n\tprivate _cameraRef: ZylemCamera | null = null;\n\tprivate _lastCanvasW: number = 0;\n\tprivate _lastCanvasH: number = 0;\n\n\tconstructor(options?: ZylemRectOptions) {\n\t\tsuper();\n\t\tthis.options = { ...rectDefaults, ...options } as ZylemRectOptions;\n\t\tthis.group = new Group();\n\t\tthis.createSprite();\n\t\t// Add rect-specific lifecycle callbacks\n\t\tthis.prependSetup(this.rectSetup.bind(this) as any);\n\t\tthis.prependUpdate(this.rectUpdate.bind(this) as any);\n\t}\n\n\tprivate createSprite() {\n\t\tthis._canvas = document.createElement('canvas');\n\t\tthis._ctx = this._canvas.getContext('2d');\n\t\tthis._texture = new CanvasTexture(this._canvas);\n\t\tthis._texture.minFilter = LinearFilter;\n\t\tthis._texture.magFilter = LinearFilter;\n\t\tconst material = new SpriteMaterial({\n\t\t\tmap: this._texture,\n\t\t\ttransparent: true,\n\t\t\tdepthTest: false,\n\t\t\tdepthWrite: false,\n\t\t\talphaTest: 0.5,\n\t\t});\n\t\tthis._sprite = new ThreeSprite(material);\n\t\tthis.group?.add(this._sprite);\n\t\tthis.redrawRect();\n\t}\n\n\tprivate redrawRect() {\n\t\tif (!this._canvas || !this._ctx) return;\n\t\tconst width = Math.max(2, Math.floor((this.options.width ?? 120)));\n\t\tconst height = Math.max(2, Math.floor((this.options.height ?? 48)));\n\t\tconst padding = this.options.padding ?? 0;\n\t\tconst strokeWidth = this.options.strokeWidth ?? 0;\n\t\tconst totalW = width + padding * 2 + strokeWidth;\n\t\tconst totalH = height + padding * 2 + strokeWidth;\n\t\tconst nextW = Math.max(2, totalW);\n\t\tconst nextH = Math.max(2, totalH);\n\t\tconst sizeChanged = nextW !== this._lastCanvasW || nextH !== this._lastCanvasH;\n\t\tthis._canvas.width = nextW;\n\t\tthis._canvas.height = nextH;\n\t\tthis._lastCanvasW = nextW;\n\t\tthis._lastCanvasH = nextH;\n\n\t\tthis._ctx.clearRect(0, 0, this._canvas.width, this._canvas.height);\n\n\t\tconst radius = Math.max(0, this.options.radius ?? 0);\n\t\tconst rectX = Math.floor(padding + strokeWidth / 2);\n\t\tconst rectY = Math.floor(padding + strokeWidth / 2);\n\t\tconst rectW = Math.floor(width);\n\t\tconst rectH = Math.floor(height);\n\n\t\tthis._ctx.beginPath();\n\t\tif (radius > 0) {\n\t\t\tthis.roundedRectPath(this._ctx, rectX, rectY, rectW, rectH, radius);\n\t\t} else {\n\t\t\tthis._ctx.rect(rectX, rectY, rectW, rectH);\n\t\t}\n\n\t\tif (this.options.fillColor) {\n\t\t\tthis._ctx.fillStyle = this.toCssColor(this.options.fillColor);\n\t\t\tthis._ctx.fill();\n\t\t}\n\n\t\tif ((this.options.strokeColor && (strokeWidth > 0))) {\n\t\t\tthis._ctx.lineWidth = strokeWidth;\n\t\t\tthis._ctx.strokeStyle = this.toCssColor(this.options.strokeColor);\n\t\t\tthis._ctx.stroke();\n\t\t}\n\n\t\tif (this._texture) {\n\t\t\tif (sizeChanged) {\n\t\t\t\tthis._texture.dispose();\n\t\t\t\tthis._texture = new CanvasTexture(this._canvas);\n\t\t\t\tthis._texture.minFilter = LinearFilter;\n\t\t\t\tthis._texture.magFilter = LinearFilter;\n\t\t\t\tthis._texture.wrapS = ClampToEdgeWrapping;\n\t\t\t\tthis._texture.wrapT = ClampToEdgeWrapping;\n\t\t\t\tif (this._sprite && this._sprite.material instanceof ShaderMaterial) {\n\t\t\t\t\tconst shader = this._sprite.material as ShaderMaterial;\n\t\t\t\t\tif (shader.uniforms?.tDiffuse) shader.uniforms.tDiffuse.value = this._texture;\n\t\t\t\t\tif (shader.uniforms?.iResolution) shader.uniforms.iResolution.value.set(this._canvas.width, this._canvas.height, 1);\n\t\t\t\t}\n\t\t\t}\n\t\t\tthis._texture.image = this._canvas;\n\t\t\tthis._texture.needsUpdate = true;\n\t\t\tif (this._sprite && this._sprite.material) {\n\t\t\t\t(this._sprite.material as any).map = this._texture;\n\t\t\t\tthis._sprite.material.needsUpdate = true;\n\t\t\t}\n\t\t}\n\t}\n\n\tgetWidth() {\n\t\treturn this.options.width ?? 0;\n\t}\n\n\tgetHeight() {\n\t\treturn this.options.height ?? 0;\n\t}\n\n\tprivate roundedRectPath(ctx: CanvasRenderingContext2D, x: number, y: number, w: number, h: number, r: number) {\n\t\tconst radius = Math.min(r, Math.floor(Math.min(w, h) / 2));\n\t\tctx.moveTo(x + radius, y);\n\t\tctx.lineTo(x + w - radius, y);\n\t\tctx.quadraticCurveTo(x + w, y, x + w, y + radius);\n\t\tctx.lineTo(x + w, y + h - radius);\n\t\tctx.quadraticCurveTo(x + w, y + h, x + w - radius, y + h);\n\t\tctx.lineTo(x + radius, y + h);\n\t\tctx.quadraticCurveTo(x, y + h, x, y + h - radius);\n\t\tctx.lineTo(x, y + radius);\n\t\tctx.quadraticCurveTo(x, y, x + radius, y);\n\t}\n\n\tprivate toCssColor(color: Color | string): string {\n\t\tif (typeof color === 'string') return color;\n\t\tconst c = color instanceof Color ? color : new Color(color as any);\n\t\treturn `#${c.getHexString()}`;\n\t}\n\n\tprivate rectSetup(params: SetupContext<ZylemRectOptions>) {\n\t\tthis._cameraRef = (params.camera as unknown) as ZylemCamera | null;\n\t\tif (this.options.stickToViewport && this._cameraRef) {\n\t\t\t(this._cameraRef.camera as any).add(this.group);\n\t\t}\n\n\t\tif (this.materials?.length && this._sprite) {\n\t\t\tconst mat = this.materials[0];\n\t\t\tif (mat instanceof ShaderMaterial) {\n\t\t\t\tmat.transparent = true;\n\t\t\t\tmat.depthTest = false;\n\t\t\t\tmat.depthWrite = false;\n\t\t\t\tif (this._texture) {\n\t\t\t\t\tif (mat.uniforms?.tDiffuse) mat.uniforms.tDiffuse.value = this._texture;\n\t\t\t\t\tif (mat.uniforms?.iResolution && this._canvas) mat.uniforms.iResolution.value.set(this._canvas.width, this._canvas.height, 1);\n\t\t\t\t}\n\t\t\t\tthis._mesh = new Mesh(new PlaneGeometry(1, 1), mat);\n\t\t\t\tthis.group?.add(this._mesh);\n\t\t\t\tthis._sprite.visible = false;\n\t\t\t}\n\t\t}\n\t}\n\n\tprivate rectUpdate(params: UpdateContext<ZylemRectOptions>) {\n\t\tif (!this._sprite) return;\n\n\t\t// If bounds provided, compute screen-space rect from it and update size/position\n\t\tif (this._cameraRef && this.options.bounds) {\n\t\t\tconst dom = this._cameraRef.renderer.domElement;\n\t\t\tconst screen = this.computeScreenBoundsFromOptions(this.options.bounds);\n\t\t\tif (screen) {\n\t\t\t\tconst { x, y, width, height } = screen;\n\t\t\t\tconst desiredW = Math.max(2, Math.floor(width));\n\t\t\t\tconst desiredH = Math.max(2, Math.floor(height));\n\t\t\t\tconst changed = desiredW !== (this.options.width ?? 0) || desiredH !== (this.options.height ?? 0);\n\t\t\t\tthis.options.screenPosition = new Vector2(Math.floor(x), Math.floor(y));\n\t\t\t\tthis.options.width = desiredW;\n\t\t\t\tthis.options.height = desiredH;\n\t\t\t\tthis.options.anchor = new Vector2(0, 0);\n\t\t\t\tif (changed) {\n\t\t\t\t\tthis.redrawRect();\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\tif (this.options.stickToViewport && this._cameraRef) {\n\t\t\tthis.updateStickyTransform();\n\t\t}\n\t}\n\n\tprivate updateStickyTransform() {\n\t\tif (!this._sprite || !this._cameraRef) return;\n\t\tconst camera = this._cameraRef.camera;\n\t\tconst dom = this._cameraRef.renderer.domElement;\n\t\tconst width = dom.clientWidth;\n\t\tconst height = dom.clientHeight;\n\t\tconst px = (this.options.screenPosition ?? new Vector2(24, 24)).x;\n\t\tconst py = (this.options.screenPosition ?? new Vector2(24, 24)).y;\n\t\tconst zDist = Math.max(0.001, this.options.zDistance ?? 1);\n\n\t\tlet worldHalfW = 1;\n\t\tlet worldHalfH = 1;\n\t\tif ((camera as PerspectiveCamera).isPerspectiveCamera) {\n\t\t\tconst pc = camera as PerspectiveCamera;\n\t\t\tconst halfH = Math.tan((pc.fov * Math.PI) / 180 / 2) * zDist;\n\t\t\tconst halfW = halfH * pc.aspect;\n\t\t\tworldHalfW = halfW;\n\t\t\tworldHalfH = halfH;\n\t\t} else if ((camera as OrthographicCamera).isOrthographicCamera) {\n\t\t\tconst oc = camera as OrthographicCamera;\n\t\t\tworldHalfW = (oc.right - oc.left) / 2;\n\t\t\tworldHalfH = (oc.top - oc.bottom) / 2;\n\t\t}\n\n\t\tconst ndcX = (px / width) * 2 - 1;\n\t\tconst ndcY = 1 - (py / height) * 2;\n\t\tconst localX = ndcX * worldHalfW;\n\t\tconst localY = ndcY * worldHalfH;\n\n\t\tlet scaleX = 1;\n\t\tlet scaleY = 1;\n\t\tif (this._canvas) {\n\t\t\tconst planeH = worldHalfH * 2;\n\t\t\tconst unitsPerPixel = planeH / height;\n\t\t\tconst pixelH = this._canvas.height;\n\t\t\tscaleY = Math.max(0.0001, pixelH * unitsPerPixel);\n\t\t\tconst aspect = this._canvas.width / this._canvas.height;\n\t\t\tscaleX = scaleY * aspect;\n\t\t\tthis._sprite.scale.set(scaleX, scaleY, 1);\n\t\t\tif (this._mesh) this._mesh.scale.set(scaleX, scaleY, 1);\n\t\t}\n\n\t\tconst anchor = this.options.anchor ?? new Vector2(0, 0);\n\t\tconst ax = Math.min(100, Math.max(0, anchor.x)) / 100; // 0..1\n\t\tconst ay = Math.min(100, Math.max(0, anchor.y)) / 100; // 0..1\n\t\tconst offsetX = (0.5 - ax) * scaleX;\n\t\tconst offsetY = (ay - 0.5) * scaleY;\n\t\tthis.group?.position.set(localX + offsetX, localY + offsetY, -zDist);\n\t}\n\n\tprivate worldToScreen(point: Vector3) {\n\t\tif (!this._cameraRef) return { x: 0, y: 0 };\n\t\tconst camera = this._cameraRef.camera;\n\t\tconst dom = this._cameraRef.renderer.domElement;\n\t\tconst v = point.clone().project(camera);\n\t\tconst x = (v.x + 1) / 2 * dom.clientWidth;\n\t\tconst y = (1 - v.y) / 2 * dom.clientHeight;\n\t\treturn { x, y };\n\t}\n\n\tprivate computeScreenBoundsFromOptions(bounds: NonNullable<ZylemRectOptions['bounds']>): { x: number; y: number; width: number; height: number } | null {\n\t\tif (!this._cameraRef) return null;\n\t\tconst dom = this._cameraRef.renderer.domElement;\n\t\tif (bounds.screen) {\n\t\t\treturn { ...bounds.screen };\n\t\t}\n\t\tif (bounds.world) {\n\t\t\tconst { left, right, top, bottom, z = 0 } = bounds.world;\n\t\t\tconst tl = this.worldToScreen(new Vector3(left, top, z));\n\t\t\tconst br = this.worldToScreen(new Vector3(right, bottom, z));\n\t\t\tconst x = Math.min(tl.x, br.x);\n\t\t\tconst y = Math.min(tl.y, br.y);\n\t\t\tconst width = Math.abs(br.x - tl.x);\n\t\t\tconst height = Math.abs(br.y - tl.y);\n\t\t\treturn { x, y, width, height };\n\t\t}\n\t\treturn null;\n\t}\n\n\tupdateRect(options?: Partial<Pick<ZylemRectOptions, 'width' | 'height' | 'fillColor' | 'strokeColor' | 'strokeWidth' | 'radius'>>) {\n\t\tthis.options = { ...this.options, ...options } as ZylemRectOptions;\n\t\tthis.redrawRect();\n\t\tif (this.options.stickToViewport && this._cameraRef) {\n\t\t\tthis.updateStickyTransform();\n\t\t}\n\t}\n\n\tbuildInfo(): Record<string, any> {\n\t\tconst delegate = new DebugDelegate(this as any);\n\t\tconst baseInfo = delegate.buildDebugInfo();\n\n\t\treturn {\n\t\t\t...baseInfo,\n\t\t\ttype: String(ZylemRect.type),\n\t\t\twidth: this.options.width ?? 0,\n\t\t\theight: this.options.height ?? 0,\n\t\t\tsticky: this.options.stickToViewport,\n\t\t};\n\t}\n}\n\ntype RectOptions = BaseNode | Partial<ZylemRectOptions>;\n\nexport function createRect(...args: Array<RectOptions>): ZylemRect {\n\treturn createEntity<ZylemRect, ZylemRectOptions>({\n\t\targs,\n\t\tdefaultConfig: { ...rectDefaults },\n\t\tEntityClass: ZylemRect,\n\t\tBuilderClass: RectBuilder,\n\t\tentityType: ZylemRect.type,\n\t});\n}\n\n\n","/**\n * Thruster Behavior Module Index\n * \n * Re-exports all thruster-related components and behaviors.\n */\n\n// Components\nexport {\n\ttype ThrusterMovementComponent,\n\ttype ThrusterInputComponent,\n\ttype ThrusterStateComponent,\n\tcreateThrusterMovementComponent,\n\tcreateThrusterInputComponent,\n\tcreateThrusterStateComponent,\n} from './components';\n\n// FSM\nexport {\n\tThrusterState,\n\tThrusterEvent,\n\tThrusterFSM,\n\ttype ThrusterFSMContext,\n\ttype PlayerInput,\n} from './thruster-fsm';\n\n// Behaviors\nexport {\n\tThrusterMovementBehavior,\n\ttype Behavior,\n\ttype ThrusterEntity,\n} from './thruster-movement.behavior';\n\n// Typed Descriptor (new entity.use() API)\nexport { ThrusterBehavior, type ThrusterBehaviorOptions } from './thruster.descriptor';\n","/**\n * Screen Wrap Behavior Module\n */\n\nexport { ScreenWrapBehavior, type ScreenWrapOptions } from './screen-wrap.descriptor';\nexport { ScreenWrapFSM, ScreenWrapState, ScreenWrapEvent } from './screen-wrap-fsm';\n","/**\n * World Boundary 2D Module\n *\n * Barrel exports for the `world-boundary-2d` behavior and its FSM helpers.\n */\nexport { WorldBoundary2DBehavior } from './world-boundary-2d.descriptor';\n\nexport {\n\tWorldBoundary2DFSM,\n\tcomputeWorldBoundary2DHits,\n\thasAnyWorldBoundary2DHit,\n\ttype WorldBoundary2DHit,\n\ttype WorldBoundary2DHits,\n\ttype WorldBoundary2DPosition,\n\ttype WorldBoundary2DBounds,\n\tWorldBoundary2DState,\n\tWorldBoundary2DEvent,\n} from './world-boundary-2d-fsm';\n\nexport type {\n\tWorldBoundary2DOptions,\n\tWorldBoundary2DHandle,\n} from './world-boundary-2d.descriptor';\n","/**\n * Ricochet 2D Behavior Module\n *\n * Exports FSM, types, and behavior descriptor for 2D ricochet/reflection.\n */\n\n// FSM and types\nexport {\n\tRicochet2DFSM,\n\tRicochet2DState,\n\tRicochet2DEvent,\n\ttype Ricochet2DResult,\n\ttype Ricochet2DCollisionContext,\n} from './ricochet-2d-fsm';\n\n// Behavior descriptor, options, and handle\nexport {\n\tRicochet2DBehavior,\n\ttype Ricochet2DOptions,\n\ttype Ricochet2DHandle,\n} from './ricochet-2d.descriptor';\n\n","/**\n * Movement Sequence 2D Behavior Module\n *\n * Exports FSM, types, and behavior descriptor for 2D movement sequencing.\n */\n\n// FSM and types\nexport {\n\tMovementSequence2DFSM,\n\tMovementSequence2DState,\n\tMovementSequence2DEvent,\n\ttype MovementSequence2DStep,\n\ttype MovementSequence2DMovement,\n\ttype MovementSequence2DProgress,\n\ttype MovementSequence2DCurrentStep,\n} from './movement-sequence-2d-fsm';\n\n// Behavior descriptor, options, and handle\nexport {\n\tMovementSequence2DBehavior,\n\ttype MovementSequence2DOptions,\n\ttype MovementSequence2DHandle,\n} from './movement-sequence-2d.descriptor';\n","import { GameEntity } from '../entities/entity';\nimport { Ricochet2DHandle, Ricochet2DResult } from '../behaviors/ricochet-2d/ricochet-2d.descriptor';\nimport { WorldBoundary2DHandle } from '../behaviors/world-boundary-2d/world-boundary-2d.descriptor';\nimport { MoveableEntity } from '../actions/capabilities/moveable';\n\n/**\n * Coordinator that bridges WorldBoundary2DBehavior and Ricochet2DBehavior.\n * \n * Automatically handles:\n * 1. Checking boundary hits\n * 2. Computing collision normals\n * 3. Requesting ricochet result\n * 4. Applying movement\n */\nexport class BoundaryRicochetCoordinator {\n constructor(\n private entity: GameEntity<any> & MoveableEntity,\n private boundary: WorldBoundary2DHandle,\n private ricochet: Ricochet2DHandle\n ) {}\n\n /**\n * Update loop - call this every frame\n */\n public update(): Ricochet2DResult | null {\n const hits = this.boundary.getLastHits();\n if (!hits) return null;\n\n const anyHit = hits.left || hits.right || hits.top || hits.bottom;\n if (!anyHit) return null;\n\n // Compute collision normal from boundary hits\n let normalX = 0;\n let normalY = 0;\n if (hits.left) normalX = 1;\n if (hits.right) normalX = -1;\n if (hits.bottom) normalY = 1;\n if (hits.top) normalY = -1;\n\n // Compute ricochet result\n return this.ricochet.getRicochet({\n entity: this.entity,\n contact: { normal: { x: normalX, y: normalY } },\n });\n }\n}\n","/**\n * Behaviors Module Index\n *\n * Re-exports all ECS components and behaviors.\n */\n\n// Core Behavior System Interface\nexport type { BehaviorSystem, BehaviorSystemFactory } from './behavior-system';\n\n// Behavior Descriptor Pattern\nexport { defineBehavior } from './behavior-descriptor';\nexport type {\n BehaviorDescriptor,\n BehaviorRef,\n BehaviorHandle,\n DefineBehaviorConfig,\n} from './behavior-descriptor';\n\nexport { useBehavior } from './use-behavior';\n\n// Core ECS Components\nexport {\n type TransformComponent,\n type PhysicsBodyComponent,\n createTransformComponent,\n createPhysicsBodyComponent,\n} from './components';\n\n// Physics Behaviors\nexport { PhysicsStepBehavior } from './physics-step.behavior';\nexport { PhysicsSyncBehavior } from './physics-sync.behavior';\n\n// Thruster Module (components, FSM, and behaviors)\nexport * from './thruster';\n\n// Screen Wrap Module\nexport * from './screen-wrap';\n\n// World Boundary 2D Module\nexport * from './world-boundary-2d';\n\n// Ricochet 2D Module\nexport * from './ricochet-2d';\n\n// Movement Sequence 2D Module\nexport * from './movement-sequence-2d';\n\n// Coordinators\nexport * from '../coordinators/boundary-ricochet.coordinator';\n","// Core game functionality\nexport { createGame, Game } from '../lib/game/game';\nexport type { ZylemGameConfig } from '../lib/game/game-interfaces';\nexport { gameConfig } from '../lib/game/game-config';\n\nexport { createStage } from '../lib/stage/stage';\nexport { entitySpawner } from '../lib/stage/entity-spawner';\nexport type { StageOptions, LoadingEvent } from '../lib/stage/zylem-stage';\nexport type { StageBlueprint } from '../lib/core/blueprints';\nexport { StageManager, stageState } from '../lib/stage/stage-manager';\n\nexport { vessel } from '../lib/core/vessel';\n\n// Camera\nexport { createCamera } from '../lib/camera/camera';\nexport type { PerspectiveType } from '../lib/camera/perspective';\nexport { Perspectives } from '../lib/camera/perspective';\n\n// Utility types\nexport type { Vect3 } from '../lib/core/utility/vector';\n\n// Entities\nexport { createBox } from '../lib/entities/box';\nexport { createSphere } from '../lib/entities/sphere';\nexport { createSprite } from '../lib/entities/sprite';\nexport { createPlane } from '../lib/entities/plane';\nexport { createZone } from '../lib/entities/zone';\nexport { createActor } from '../lib/entities/actor';\nexport { createText } from '../lib/entities/text';\nexport { createRect } from '../lib/entities/rect';\nexport { createDisk } from '../lib/entities/disk';\nexport { createEntityFactory, type TemplateFactory } from '../lib/entities/entity-factory';\nexport { ZylemBox } from '../lib/entities/box';\n\n// ECS Components & Behaviors (new thruster system)\nexport * from '../lib/behaviors';\n\n// Capabilities\nexport { makeMoveable } from '../lib/actions/capabilities/moveable';\nexport { makeRotatable } from '../lib/actions/capabilities/rotatable';\nexport { makeTransformable } from '../lib/actions/capabilities/transformable';\nexport { rotatable } from '../lib/actions/capabilities/rotatable';\nexport { moveable } from '../lib/actions/capabilities/moveable';\nexport { rotateInDirection } from '../lib/actions/capabilities/rotatable';\nexport { move } from '../lib/actions/capabilities/moveable';\nexport { resetVelocity } from '../lib/actions/capabilities/moveable';\n\n\n// Destruction utilities\n// Destruction utilities\nexport { destroy } from '../lib/entities/destroy';\n\n// Sounds\nexport { ricochetSound, pingPongBeep } from '../lib/sounds';\n\n// External dependencies - these will be in separate vendor chunks\nexport { Howl } from 'howler';\nexport * as THREE from 'three';\nexport * as RAPIER from '@dimforge/rapier3d-compat';\n\n// Update helpers\nexport { globalChange, globalChanges, variableChange, variableChanges } from '../lib/actions/global-change';\n\n// State management - standalone functions\nexport { setGlobal, getGlobal, createGlobal, onGlobalChange, onGlobalChanges, getGlobals, clearGlobalSubscriptions } from '../lib/game/game-state';\nexport { setVariable, getVariable, createVariable, onVariableChange, onVariableChanges } from '../lib/stage/stage-state';\n\n// Debug state - exposed for direct mutation by editor integration\nexport { debugState, setDebugTool, setPaused, type DebugTools } from '../lib/debug/debug-state';\n\n// Web Components\nexport { ZylemGameElement, type ZylemGameState } from '../web-components/zylem-game';\n\n// Lifecycle types\nexport type { SetupContext, UpdateContext } from '../lib/core/base-node-life-cycle';\n\n// Interfaces\nexport type { StageEntity } from '../lib/interfaces/entity';\n\n// Entity type symbols for getEntityByName type inference\nexport { \n\tTEXT_TYPE, SPRITE_TYPE, BOX_TYPE, SPHERE_TYPE, \n\tRECT_TYPE, PLANE_TYPE, ZONE_TYPE, ACTOR_TYPE \n} from '../lib/types/entity-type-map';\n\n// Events\nexport {\n\tEventEmitterDelegate,\n\tzylemEventBus,\n\ttype ZylemEvents,\n\ttype GameEvents,\n\ttype StageEvents,\n\ttype EntityEvents,\n\ttype GameLoadingPayload,\n\ttype StateDispatchPayload,\n\ttype StageConfigPayload,\n\ttype EntityConfigPayload,\n} from '../lib/events';\n\n// Shaders\nexport { fireShader } from '../lib/graphics/shaders/fire.shader';\nexport { starShader } from '../lib/graphics/shaders/star.shader';\nexport { standardShader } from '../lib/graphics/shaders/standard.shader';\nexport { debugShader } from '../lib/graphics/shaders/debug.shader';\nexport { objectVertexShader } from '../lib/graphics/shaders/vertex/object.shader';\nexport type { ZylemShaderObject } from '../lib/graphics/material';\n","import { ActiveCollisionTypes, ColliderDesc } from '@dimforge/rapier3d-compat';\nimport { BufferGeometry, Object3D, SkinnedMesh, Mesh, MeshStandardMaterial, Group, Vector3 } from 'three';\nimport { BaseNode } from '../core/base-node';\nimport { GameEntityOptions, GameEntity } from './entity';\nimport { createEntity } from './create';\nimport { UpdateContext, UpdateFunction } from '../core/base-node-life-cycle';\nimport { EntityAssetLoader } from '../core/entity-asset-loader';\nimport { EntityLoaderDelegate } from './delegates/loader';\nimport { Vec3 } from '../core/vector';\nimport { AnimationDelegate, AnimationOptions } from './delegates/animation';\nimport { MaterialOptions } from '../graphics/material';\nimport { DebugInfoProvider } from './delegates/debug';\nimport { EntityBuilder } from './builder';\nimport { EntityCollisionBuilder } from './builder';\nimport { commonDefaults } from './common';\nimport { standardShader } from '~/api/main';\n\ntype AnimationObject = {\n\tkey?: string;\n\tpath: string;\n};\n\nexport type CollisionShapeType = 'capsule' | 'model';\n\ntype ZylemActorOptions = GameEntityOptions & {\n\tstatic?: boolean;\n\tanimations?: AnimationObject[];\n\tmodels?: string[];\n\tscale?: Vec3;\n\tmaterial?: MaterialOptions;\n\tcollisionShape?: CollisionShapeType;\n};\n\nconst actorDefaults: ZylemActorOptions = {\n\t...commonDefaults,\n\tcollision: {\n\t\tstatic: false,\n\t\tsize: new Vector3(0.5, 0.5, 0.5),\n\t\tposition: new Vector3(0, 0, 0),\n\t},\n\tmaterial: {\n\t\tshader: standardShader\n\t},\n\tanimations: [],\n\tmodels: [],\n\tcollisionShape: 'capsule',\n};\n\nclass ActorCollisionBuilder extends EntityCollisionBuilder {\n\tprivate objectModel: Group | null = null;\n\tprivate collisionShape: CollisionShapeType = 'capsule';\n\n\tconstructor(data: any) {\n\t\tsuper();\n\t\tthis.objectModel = data.objectModel;\n\t\tthis.collisionShape = data.collisionShape ?? 'capsule';\n\t}\n\n\tcollider(options: ZylemActorOptions): ColliderDesc {\n\t\tif (this.collisionShape === 'model') {\n\t\t\treturn this.createColliderFromModel(this.objectModel, options);\n\t\t}\n\t\treturn this.createCapsuleCollider(options);\n\t}\n\n\t/**\n\t * Create a capsule collider based on size options (character controller style).\n\t */\n\tprivate createCapsuleCollider(options: ZylemActorOptions): ColliderDesc {\n\t\tconst size = options.collision?.size ?? options.size ?? { x: 0.5, y: 1, z: 0.5 };\n\t\tconst halfHeight = ((size as any).y || 1);\n\t\tconst radius = Math.max((size as any).x || 0.5, (size as any).z || 0.5);\n\t\tlet colliderDesc = ColliderDesc.capsule(halfHeight, radius);\n\t\tcolliderDesc.setSensor(false);\n\t\tcolliderDesc.setTranslation(0, halfHeight + radius, 0);\n\t\tcolliderDesc.activeCollisionTypes = ActiveCollisionTypes.DEFAULT;\n\t\treturn colliderDesc;\n\t}\n\n\t/**\n\t * Create a collider based on model geometry (works with Mesh and SkinnedMesh).\n\t * If collision.size and collision.position are provided, use those instead of computing from geometry.\n\t */\n\tprivate createColliderFromModel(objectModel: Group | null, options: ZylemActorOptions): ColliderDesc {\n\t\tconst collisionSize = options.collision?.size;\n\t\tconst collisionPosition = options.collision?.position;\n\n\t\t// If user provided explicit size, use that instead of computing from model\n\t\tif (collisionSize) {\n\t\t\tconst halfWidth = (collisionSize as any).x / 2;\n\t\t\tconst halfHeight = (collisionSize as any).y / 2;\n\t\t\tconst halfDepth = (collisionSize as any).z / 2;\n\n\t\t\tlet colliderDesc = ColliderDesc.cuboid(halfWidth, halfHeight, halfDepth);\n\t\t\tcolliderDesc.setSensor(false);\n\n\t\t\t// Use user-provided position or default to center\n\t\t\tconst posX = collisionPosition ? (collisionPosition as any).x : 0;\n\t\t\tconst posY = collisionPosition ? (collisionPosition as any).y : halfHeight;\n\t\t\tconst posZ = collisionPosition ? (collisionPosition as any).z : 0;\n\t\t\tcolliderDesc.setTranslation(posX, posY, posZ);\n\t\t\tcolliderDesc.activeCollisionTypes = ActiveCollisionTypes.DEFAULT;\n\t\t\treturn colliderDesc;\n\t\t}\n\n\t\t// Fall back to computing from model geometry\n\t\tif (!objectModel) return this.createCapsuleCollider(options);\n\n\t\t// Find first Mesh (SkinnedMesh or regular Mesh)\n\t\tlet foundGeometry: BufferGeometry | null = null;\n\t\tobjectModel.traverse((child) => {\n\t\t\tif (!foundGeometry && (child as any).isMesh) {\n\t\t\t\tfoundGeometry = (child as Mesh).geometry as BufferGeometry;\n\t\t\t}\n\t\t});\n\n\t\tif (!foundGeometry) return this.createCapsuleCollider(options);\n\n\t\tconst geometry: BufferGeometry = foundGeometry;\n\t\tgeometry.computeBoundingBox();\n\t\tconst box = geometry.boundingBox;\n\t\tif (!box) return this.createCapsuleCollider(options);\n\n\t\tconst height = box.max.y - box.min.y;\n\t\tconst width = box.max.x - box.min.x;\n\t\tconst depth = box.max.z - box.min.z;\n\n\t\t// Create box collider based on mesh bounds\n\t\tlet colliderDesc = ColliderDesc.cuboid(width / 2, height / 2, depth / 2);\n\t\tcolliderDesc.setSensor(false);\n\t\t// Position collider at center of model\n\t\tconst centerY = (box.max.y + box.min.y) / 2;\n\t\tcolliderDesc.setTranslation(0, centerY, 0);\n\t\tcolliderDesc.activeCollisionTypes = ActiveCollisionTypes.DEFAULT;\n\t\treturn colliderDesc;\n\t}\n}\n\nclass ActorBuilder extends EntityBuilder<ZylemActor, ZylemActorOptions> {\n\tprotected createEntity(options: Partial<ZylemActorOptions>): ZylemActor {\n\t\treturn new ZylemActor(options);\n\t}\n}\n\nexport const ACTOR_TYPE = Symbol('Actor');\n\nexport class ZylemActor extends GameEntity<ZylemActorOptions> implements EntityLoaderDelegate, DebugInfoProvider {\n\tstatic type = ACTOR_TYPE;\n\n\tprivate _object: Object3D | null = null;\n\tprivate _animationDelegate: AnimationDelegate | null = null;\n\tprivate _modelFileNames: string[] = [];\n\tprivate _assetLoader: EntityAssetLoader = new EntityAssetLoader();\n\n\tcontrolledRotation: boolean = false;\n\n\tconstructor(options?: ZylemActorOptions) {\n\t\tsuper();\n\t\tthis.options = { ...actorDefaults, ...options };\n\t\t// Add actor-specific update to the lifecycle callbacks\n\t\tthis.prependUpdate(this.actorUpdate.bind(this) as UpdateFunction<this>);\n\t\tthis.controlledRotation = true;\n\t}\n\n\t/**\n\t * Initiates model and animation loading in background (deferred).\n\t * Call returns immediately; assets will be ready on subsequent updates.\n\t */\n\tload(): void {\n\t\tthis._modelFileNames = this.options.models || [];\n\t\t// Start async loading in background\n\t\tthis.loadModelsDeferred();\n\t}\n\n\t/**\n\t * Returns current data synchronously.\n\t * May return null values if loading is still in progress.\n\t */\n\tdata(): any {\n\t\treturn {\n\t\t\tanimations: this._animationDelegate?.animations,\n\t\t\tobjectModel: this._object,\n\t\t\tcollisionShape: this.options.collisionShape,\n\t\t};\n\t}\n\n\tactorUpdate(params: UpdateContext<ZylemActorOptions>): void {\n\t\tthis._animationDelegate?.update(params.delta);\n\t}\n\n\t/**\n\t * Clean up actor resources including animations, models, and groups\n\t */\n\tactorDestroy(): void {\n\t\t// Stop and dispose animation delegate\n\t\tif (this._animationDelegate) {\n\t\t\tthis._animationDelegate.dispose();\n\t\t\tthis._animationDelegate = null;\n\t\t}\n\n\t\t// Dispose geometries and materials from loaded object\n\t\tif (this._object) {\n\t\t\tthis._object.traverse((child) => {\n\t\t\t\tif ((child as any).isMesh) {\n\t\t\t\t\tconst mesh = child as SkinnedMesh;\n\t\t\t\t\tmesh.geometry?.dispose();\n\t\t\t\t\tif (Array.isArray(mesh.material)) {\n\t\t\t\t\t\tmesh.material.forEach(m => m.dispose());\n\t\t\t\t\t} else if (mesh.material) {\n\t\t\t\t\t\tmesh.material.dispose();\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t});\n\t\t\tthis._object = null;\n\t\t}\n\n\t\t// Clear group reference\n\t\tif (this.group) {\n\t\t\tthis.group.clear();\n\t\t\tthis.group = null as any;\n\t\t}\n\n\t\t// Clear file name references\n\t\tthis._modelFileNames = [];\n\t}\n\n\t/**\n\t * Deferred loading - starts async load and updates entity when complete.\n\t * Called by synchronous load() method.\n\t */\n\tprivate loadModelsDeferred(): void {\n\t\tif (this._modelFileNames.length === 0) return;\n\n\t\t// Emit loading started event\n\t\tthis.dispatch('entity:model:loading', {\n\t\t\tentityId: this.uuid,\n\t\t\tfiles: this._modelFileNames\n\t\t});\n\n\t\tconst promises = this._modelFileNames.map(file => this._assetLoader.loadFile(file));\n\t\tPromise.all(promises).then(results => {\n\t\t\tif (results[0]?.object) {\n\t\t\t\tthis._object = results[0].object;\n\t\t\t}\n\t\t\t// Count meshes for the loaded event\n\t\t\tlet meshCount = 0;\n\t\t\tif (this._object) {\n\t\t\t\tthis._object.traverse((child) => {\n\t\t\t\t\tif ((child as any).isMesh) meshCount++;\n\t\t\t\t});\n\t\t\t\tthis.group = new Group();\n\t\t\t\tthis.group.attach(this._object);\n\t\t\t\tthis.group.scale.set(\n\t\t\t\t\tthis.options.scale?.x || 1,\n\t\t\t\t\tthis.options.scale?.y || 1,\n\t\t\t\t\tthis.options.scale?.z || 1\n\t\t\t\t);\n\n\t\t\t\t// Apply material overrides if specified\n\t\t\t\tthis.applyMaterialOverrides();\n\n\t\t\t\t// Load animations after model is ready\n\t\t\t\tthis._animationDelegate = new AnimationDelegate(this._object);\n\t\t\t\tthis._animationDelegate.loadAnimations(this.options.animations || []).then(() => {\n\t\t\t\t\tthis.dispatch('entity:animation:loaded', {\n\t\t\t\t\t\tentityId: this.uuid,\n\t\t\t\t\t\tanimationCount: this.options.animations?.length || 0\n\t\t\t\t\t});\n\t\t\t\t});\n\t\t\t}\n\n\t\t\t// Emit model loaded event\n\t\t\tthis.dispatch('entity:model:loaded', {\n\t\t\t\tentityId: this.uuid,\n\t\t\t\tsuccess: !!this._object,\n\t\t\t\tmeshCount\n\t\t\t});\n\t\t});\n\t}\n\n\tplayAnimation(animationOptions: AnimationOptions) {\n\t\tthis._animationDelegate?.playAnimation(animationOptions);\n\t}\n\n\t/**\n\t * Apply material overrides from options to all meshes in the loaded model.\n\t * Only applies if material options are explicitly specified (not just defaults).\n\t */\n\tprivate applyMaterialOverrides(): void {\n\t\tconst materialOptions = this.options.material;\n\t\t// Only apply if user specified material options beyond defaults\n\t\tif (!materialOptions || (!materialOptions.color && !materialOptions.path)) {\n\t\t\treturn;\n\t\t}\n\n\t\tif (!this._object) return;\n\n\t\tthis._object.traverse((child) => {\n\t\t\tif ((child as any).isMesh) {\n\t\t\t\tconst mesh = child as Mesh;\n\t\t\t\tif (materialOptions.color) {\n\t\t\t\t\t// Create new material with the specified color\n\t\t\t\t\tconst newMaterial = new MeshStandardMaterial({\n\t\t\t\t\t\tcolor: materialOptions.color,\n\t\t\t\t\t\temissiveIntensity: 0.5,\n\t\t\t\t\t\tlightMapIntensity: 0.5,\n\t\t\t\t\t\tfog: true,\n\t\t\t\t\t});\n\t\t\t\t\tmesh.castShadow = true;\n\t\t\t\t\tmesh.receiveShadow = true;\n\t\t\t\t\tmesh.material = newMaterial;\n\t\t\t\t}\n\t\t\t}\n\t\t});\n\t}\n\n\tget object(): Object3D | null {\n\t\treturn this._object;\n\t}\n\n\t/**\n\t * Provide custom debug information for the actor\n\t * This will be merged with the default debug information\n\t */\n\tgetDebugInfo(): Record<string, any> {\n\t\tconst debugInfo: Record<string, any> = {\n\t\t\ttype: 'Actor',\n\t\t\tmodels: this._modelFileNames.length > 0 ? this._modelFileNames : 'none',\n\t\t\tmodelLoaded: !!this._object,\n\t\t\tscale: this.options.scale ?\n\t\t\t\t`${this.options.scale.x}, ${this.options.scale.y}, ${this.options.scale.z}` :\n\t\t\t\t'1, 1, 1',\n\t\t};\n\n\t\t// Add animation info if available\n\t\tif (this._animationDelegate) {\n\t\t\tdebugInfo.currentAnimation = this._animationDelegate.currentAnimationKey || 'none';\n\t\t\tdebugInfo.animationsCount = this.options.animations?.length || 0;\n\t\t}\n\n\t\t// Add mesh info if model is loaded\n\t\tif (this._object) {\n\t\t\tlet meshCount = 0;\n\t\t\tlet vertexCount = 0;\n\t\t\tthis._object.traverse((child) => {\n\t\t\t\tif ((child as any).isMesh) {\n\t\t\t\t\tmeshCount++;\n\t\t\t\t\tconst geometry = (child as SkinnedMesh).geometry;\n\t\t\t\t\tif (geometry && geometry.attributes.position) {\n\t\t\t\t\t\tvertexCount += geometry.attributes.position.count;\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t});\n\t\t\tdebugInfo.meshCount = meshCount;\n\t\t\tdebugInfo.vertexCount = vertexCount;\n\t\t}\n\n\t\treturn debugInfo;\n\t}\n}\n\ntype ActorOptions = BaseNode | ZylemActorOptions;\n\nexport function createActor(...args: Array<ActorOptions>): ZylemActor {\n\treturn createEntity<ZylemActor, ZylemActorOptions>({\n\t\targs,\n\t\tdefaultConfig: actorDefaults,\n\t\tEntityClass: ZylemActor,\n\t\tBuilderClass: ActorBuilder,\n\t\tCollisionBuilderClass: ActorCollisionBuilder,\n\t\tentityType: ZylemActor.type\n\t});\n}","export { createBox, ZylemBox } from '../lib/entities/box';\nexport { createSphere } from '../lib/entities/sphere';\nexport { createSprite } from '../lib/entities/sprite';\nexport { createPlane } from '../lib/entities/plane';\nexport { createZone } from '../lib/entities/zone';\nexport { createActor } from '../lib/entities/actor';\nexport { createText } from '../lib/entities/text';\nexport { createRect } from '../lib/entities/rect';\n"],"mappings":";;;;;;AAAA;AAAA,EACC;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,OAEM;AACP,SAAS,kBAAkB;AAR3B,IAgBa,UAMA,UAOA,OAOP;AApCN;AAAA;AAAA;AAgBO,IAAM,WAAW,gBAAgB;AAAA,MACvC,GAAG,MAAM;AAAA,MACT,GAAG,MAAM;AAAA,MACT,GAAG,MAAM;AAAA,IACV,CAAC;AAEM,IAAM,WAAW,gBAAgB;AAAA,MACvC,GAAG,MAAM;AAAA,MACT,GAAG,MAAM;AAAA,MACT,GAAG,MAAM;AAAA,MACT,GAAG,MAAM;AAAA,IACV,CAAC;AAEM,IAAM,QAAQ,gBAAgB;AAAA,MACpC,GAAG,MAAM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MA,eAAoC;AACnC,cAAM,YAAiC;AAAA,UACtC,MAAM;AAAA,UACN,QAAQ,KAAK,gBAAgB,SAAS,IAAI,KAAK,kBAAkB;AAAA,UACjE,aAAa,CAAC,CAAC,KAAK;AAAA,UACpB,OAAO,KAAK,QAAQ,QACnB,GAAG,KAAK,QAAQ,MAAM,CAAC,KAAK,KAAK,QAAQ,MAAM,CAAC,KAAK,KAAK,QAAQ,MAAM,CAAC,KACzE;AAAA,QACF;AAGA,YAAI,KAAK,oBAAoB;AAC5B,oBAAU,mBAAmB,KAAK,mBAAmB,uBAAuB;AAC5E,oBAAU,kBAAkB,KAAK,QAAQ,YAAY,UAAU;AAAA,QAChE;AAGA,YAAI,KAAK,SAAS;AACjB,cAAI,YAAY;AAChB,cAAI,cAAc;AAClB,eAAK,QAAQ,SAAS,CAAC,UAAU;AAChC,gBAAK,MAAc,QAAQ;AAC1B;AACA,oBAAM,WAAY,MAAsB;AACxC,kBAAI,YAAY,SAAS,WAAW,UAAU;AAC7C,+BAAe,SAAS,WAAW,SAAS;AAAA,cAC7C;AAAA,YACD;AAAA,UACD,CAAC;AACD,oBAAU,YAAY;AACtB,oBAAU,cAAc;AAAA,QACzB;AAEA,eAAO;AAAA,MACR;AAAA,IACD;AAAA;AAAA;;;ACvWA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;","names":["all","Map","on","type","handler","handlers","get","push","set","off","splice","indexOf","emit","evt","slice","map","Mesh","Color","RepeatWrapping","ShaderMaterial","Vector2","Vector3","fragment","BufferGeometry","Mesh","Color","MeshStandardMaterial","MeshPhongMaterial","x","y","z","toDeg","Color","Vector3","ColliderDesc","Vector3","ColliderDesc","ColliderDesc","Group","Quaternion","Vector3","TextureLoader","BufferGeometry","ColliderDesc","Vector2","Vector3","scale","ActiveCollisionTypes","ColliderDesc","Vector3","Color","Group","ThreeSprite","SpriteMaterial","Vector2","Color","Group","ThreeSprite","SpriteMaterial","CanvasTexture","LinearFilter","Vector2","ClampToEdgeWrapping","ShaderMaterial","Mesh","PlaneGeometry","Vector3","ActiveCollisionTypes","ColliderDesc","MeshStandardMaterial","Group","Vector3","colliderDesc"]}
|