@zylem/game-lib 0.7.0 → 0.8.0
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/README.md +15 -1
- package/dist/actions.d.ts +71 -8
- package/dist/actions.js +1 -1
- package/dist/api/game-lib.api.json +54074 -0
- package/dist/api/game-lib.api.md +4544 -0
- package/dist/api/game-lib.d.ts +8258 -0
- package/dist/api/game-lib.typedoc.json +345421 -0
- package/dist/audio.js +1 -1
- package/dist/{base-node-life-cycle-CnJ-7zX-.d.ts → base-node-life-cycle-D2NuN1VB.d.ts} +12 -4
- package/dist/behavior.d.ts +2 -3
- package/dist/behavior.js +1 -1
- package/dist/blueprints-TbGY-h53.d.ts +162 -0
- package/dist/chunk-7FR5JSQ2.js +1 -0
- package/dist/chunk-7GYFZKK7.js +1 -0
- package/dist/chunk-7WRQ2UAN.js +1 -0
- package/dist/chunk-BH53MBAZ.js +1 -0
- package/dist/chunk-BIGH6D34.js +0 -0
- package/dist/chunk-CM5YRNBJ.js +19 -0
- package/dist/chunk-COM6HJ2L.js +1 -0
- package/dist/chunk-D2PATZCC.js +1 -0
- package/dist/chunk-DFLI7ICU.js +0 -0
- package/dist/chunk-E3UBSUPX.js +1 -0
- package/dist/chunk-FKIKN7RP.js +24 -0
- package/dist/chunk-G4HONLWC.js +1 -0
- package/dist/chunk-IKWE2W6L.js +1 -0
- package/dist/chunk-IPWUDOV5.js +1 -0
- package/dist/chunk-JEHFHUH4.js +0 -0
- package/dist/chunk-JNKPTL77.js +1 -0
- package/dist/chunk-JQKS42G4.js +1 -0
- package/dist/chunk-M3XNO56P.js +1 -0
- package/dist/chunk-ORIDWL3T.js +0 -0
- package/dist/chunk-QB3NL7VQ.js +1 -0
- package/dist/chunk-TAUWDQZF.js +9 -0
- package/dist/chunk-VS2D4B3W.js +1 -0
- package/dist/chunk-WQ3WMMZD.js +1 -0
- package/dist/chunk-XK63E4SX.js +1 -0
- package/dist/chunk-XNDS4YFR.js +1 -0
- package/dist/chunk-XNHVRFAK.js +1 -0
- package/dist/chunk-ZRT3ZQVH.js +1 -0
- package/dist/collision-builder-jF-toPIl.d.ts +38 -0
- package/dist/core.d.ts +45 -30
- package/dist/core.js +1 -24
- package/dist/debug-state-BPT6jEog.d.ts +17 -0
- package/dist/debug.d.ts +71 -19
- package/dist/debug.js +1 -1
- package/dist/{default-controls-BGc61yYl.d.ts → default-controls-0-vCnli7.d.ts} +3 -3
- package/dist/{entity-DNkYKfdp.d.ts → entity-BdSI8CL3.d.ts} +63 -444
- package/dist/entity-DZbFQ1Wg.d.ts +28 -0
- package/dist/{entity-type-map-C94h2TDW.d.ts → entity-type-map-Bd69SpAS.d.ts} +153 -6
- package/dist/entity.d.ts +11 -8
- package/dist/entity.js +1 -1
- package/dist/events.d.ts +10 -1
- package/dist/events.js +1 -1
- package/dist/{game-Cuj5gy7U.d.ts → game-C1FHVqXl.d.ts} +429 -133
- package/dist/game-default-QHROHW2O.js +1 -0
- package/dist/{game-interfaces-tfpM5NBk.d.ts → game-interfaces-mchNYSZE.d.ts} +2 -2
- package/dist/globals.d.ts +12 -1
- package/dist/globals.js +1 -1
- package/dist/graphics.d.ts +16 -46
- package/dist/graphics.js +1 -1
- package/dist/input-ui.d.ts +5 -4
- package/dist/input-ui.js +1 -1
- package/dist/input.d.ts +4 -3
- package/dist/input.js +1 -1
- package/dist/{material-Wz83vTTp.d.ts → material-9vJ6SZaI.d.ts} +25 -50
- package/dist/public.d.ts +38 -0
- package/dist/public.js +1 -0
- package/dist/runtime.d.ts +7 -381
- package/dist/runtime.js +1 -1
- package/dist/schema/entity.schema.json +244 -0
- package/dist/schema/game-config.schema.json +625 -0
- package/dist/schema/input-config.schema.json +499 -0
- package/dist/schema/stage-config.schema.json +93 -0
- package/dist/schema/stage.schema.json +271 -0
- package/dist/schema.d.ts +538 -0
- package/dist/schema.js +1 -0
- package/dist/stage-transition-CmGpV4tc.d.ts +46 -0
- package/dist/vector-CiSHbivc.d.ts +133 -0
- package/dist/web-components.d.ts +15 -12
- package/dist/web-components.js +1 -9
- package/dist/{zylem-stage-runtime-Cs-UDEVU.d.ts → zylem-camera-C3bn6BTI.d.ts} +62 -264
- package/package.json +28 -20
- package/dist/chunk-73VZQZUL.js +0 -1
- package/dist/chunk-A34ZG3L4.js +0 -1
- package/dist/chunk-CDPY4VOQ.js +0 -1
- package/dist/chunk-DR6XXZE7.js +0 -19
- package/dist/chunk-FM5TBEPO.js +0 -1
- package/dist/chunk-G2IIMSUH.js +0 -1
- package/dist/chunk-NIH5CONO.js +0 -1
- package/dist/chunk-ONWXGBWB.js +0 -1
- package/dist/chunk-QEDQDR27.js +0 -1
- package/dist/chunk-WKHW2QO2.js +0 -1
- package/dist/chunk-YHKXQ2ZN.js +0 -1
- package/dist/game-default-PZLLHYL7.js +0 -1
- package/dist/world-C9zdyl5d.d.ts +0 -103
package/dist/audio.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
|
|
1
|
+
import{a,b,c}from"./chunk-ZRT3ZQVH.js";export{c as Howl,b as pingPongBeep,a as ricochetSound};
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { Vector3 } from 'three';
|
|
2
|
+
import { S as StageTransitionConfig } from './stage-transition-CmGpV4tc.js';
|
|
2
3
|
|
|
3
4
|
/** Input
|
|
4
5
|
*
|
|
@@ -67,11 +68,18 @@ type LoadingEvent = {
|
|
|
67
68
|
total?: number;
|
|
68
69
|
current?: number;
|
|
69
70
|
};
|
|
71
|
+
/**
|
|
72
|
+
* Options for stage navigation (`nextStage` / `previousStage` / `reset`).
|
|
73
|
+
*/
|
|
74
|
+
interface StageNavigationOptions {
|
|
75
|
+
/** Visual transition to blend from the outgoing stage to the incoming one. */
|
|
76
|
+
transition?: StageTransitionConfig;
|
|
77
|
+
}
|
|
70
78
|
interface IGame<TGlobals extends Record<string, unknown> = any> {
|
|
71
79
|
start: () => Promise<this>;
|
|
72
|
-
nextStage: () => void;
|
|
73
|
-
previousStage: () => void;
|
|
74
|
-
reset: () => Promise<void>;
|
|
80
|
+
nextStage: (options?: StageNavigationOptions) => void;
|
|
81
|
+
previousStage: (options?: StageNavigationOptions) => void;
|
|
82
|
+
reset: (options?: StageNavigationOptions) => Promise<void>;
|
|
75
83
|
pause: () => Promise<void>;
|
|
76
84
|
resume: () => Promise<void>;
|
|
77
85
|
onLoading: (callback: (event: LoadingEvent) => void) => void;
|
|
@@ -140,4 +148,4 @@ interface CleanupFunction<T, TGlobals extends GlobalRecord = any> {
|
|
|
140
148
|
(context: CleanupContext<T, TGlobals>): void;
|
|
141
149
|
}
|
|
142
150
|
|
|
143
|
-
export type { AnalogState as A, ButtonState as B,
|
|
151
|
+
export type { AnalogState as A, ButtonState as B, CleanupFunction as C, DestroyContext as D, Inputs as I, LoadingEvent as L, StageNavigationOptions as S, UpdateContext as U, SetupContext as a, InputPlayer as b, InputGamepad as c, ButtonName as d, InputPlayerNumber as e, InputProvider as f, UpdateFunction as g, SetupFunction as h, LoadedFunction as i, DestroyFunction as j, LoadedContext as k, CleanupContext as l, IGame as m };
|
package/dist/behavior.d.ts
CHANGED
|
@@ -1,3 +1,2 @@
|
|
|
1
|
-
export {
|
|
2
|
-
export {
|
|
3
|
-
export { RUNTIME_BOUNDARY_2D_BEHAVIOR_KEY, RUNTIME_DYNAMIC_CIRCLE_BODY_2D_BEHAVIOR_KEY, RUNTIME_PLAYER_INPUT_2D_BEHAVIOR_KEY, RuntimeBoundary2DBehavior, RuntimeBoundary2DOptions, RuntimeDynamicCircleBody2DBehavior, RuntimeDynamicCircleBody2DHandle, RuntimeDynamicCircleBody2DOptions, RuntimePlayerInput2DBehavior, RuntimePlayerInput2DOptions, RuntimeRicochet2DBehavior as RuntimeRicochet2DDescriptor, RuntimeTriggerRegion2DBehavior as RuntimeTriggerRegion2DDescriptor, bindRuntimeDynamicCircleBody2DHandle } from '@zylem/behaviors/runtime-2d';
|
|
1
|
+
export { BehaviorDescriptor, BehaviorHandle, BehaviorRef, BehaviorSystem, BehaviorSystemFactory, BoundaryRicochet3DCoordinator, BoundaryRicochet3DEntity, BoundaryRicochetCoordinator, BoundaryRicochetEntity, BoundaryRicochetUpdate, BurstParticlePresetOptions, CooldownBehavior, CooldownConfig, CooldownEntry, CooldownHandle, CooldownOptions, DefineBehaviorConfig, Destructible3DBehavior, Destructible3DBehaviorOptions, Destructible3DColliderOptions, Destructible3DFragmentColliderShape, Destructible3DFragmentPhysicsOptions, Destructible3DHandle, DestructibleMesh, DestructiblePrebakeWorkerAPI, FacingAngle2DEntity, FirstPersonBehavior, FirstPersonBehaviorOptions, FirstPersonContext, FirstPersonEntity, FirstPersonEvent, FirstPersonFSM, FirstPersonInputComponent, FirstPersonMovementComponent, FirstPersonPresentation, FirstPersonShooterCoordinator, FirstPersonShooterEntity, FirstPersonShooterInput, FirstPersonState, FirstPersonStateComponent, FractureOptions, FractureOptionsInput, JumpConfig2D, JumpConfig3D, JumpContext2D, JumpContext3D, JumpInput2D, JumpInput3D, JumpState2D, JumpState3D, Jumper2DBehavior, Jumper2DBehaviorOptions, Jumper2DEntity, Jumper2DEvent, Jumper2DFSM, Jumper2DState, Jumper3DBehavior, Jumper3DBehaviorOptions, Jumper3DEntity, Jumper3DEvent, Jumper3DFSM, Jumper3DState, MultidirectionalSpaceShooterCoordinator, MultidirectionalSpaceShooterEntity, MultidirectionalSpaceShooterInput, ParticleEffectDefinition, ParticleEmitterBehavior, ParticleEmitterBehaviorOptions, ParticleEmitterHandle, ParticleMagicAgency, ParticleMagicAlignment, ParticleMagicModifierInput, ParticleMagicModifierOptions, ParticleMagicOrder, ParticleMagicRealityEffect, ParticleMagicTemperament, ParticlePresetMaterialOptions, PhysicsBodyComponent, PlainBufferGeometryPayload, PlainFractureOptions, Platformer2DBehavior, Platformer2DBehaviorOptions, Platformer2DCollisionContext, Platformer2DContext, Platformer2DEntity, Platformer2DEvent, Platformer2DFSM, Platformer2DInputComponent, Platformer2DMovementComponent, Platformer2DState, Platformer2DStateComponent, Platformer3DBehavior, Platformer3DBehaviorOptions, Platformer3DContext, Platformer3DEntity, Platformer3DEvent, Platformer3DFSM, Platformer3DInputComponent, Platformer3DMovementComponent, Platformer3DState, Platformer3DStateComponent, PlatformerCollisionContext, PlayerInput, PrebakeWorkerRequest, PrebakeWorkerResponse, ResolvedAim2D, Ricochet2DBehavior, Ricochet2DCollisionContext, Ricochet2DEvent, Ricochet2DFSM, Ricochet2DHandle, Ricochet2DOptions, Ricochet2DResult, Ricochet2DState, Ricochet3DBehavior, Ricochet3DCallback, Ricochet3DCollisionContext, Ricochet3DEvent, Ricochet3DFSM, Ricochet3DHandle, Ricochet3DOptions, Ricochet3DResult, Ricochet3DState, RicochetCallback, ScreenVisibilityBehavior, ScreenVisibilityChangeContext, ScreenVisibilityFSM, ScreenVisibilityHandle, ScreenVisibilityOptions, ScreenVisibilitySize, ScreenVisibilitySnapshot, ScreenWrapBehavior, ScreenWrapEvent, ScreenWrapFSM, ScreenWrapOptions, ScreenWrapState, SemanticParticlePresetOptions, Shooter2DAimFireInput, Shooter2DBehavior, Shooter2DBehaviorOptions, Shooter2DFireArgs, Shooter2DHandle, Shooter2DProjectileFactory, Shooter2DSourceEntity, Shooter2DStageLike, Shooter2DStateComponent, Shooter2DTarget, ThrusterBehavior, ThrusterBehaviorOptions, ThrusterEntity, ThrusterEvent, ThrusterFSM, ThrusterFSMContext, ThrusterInputComponent, ThrusterMovementComponent, ThrusterState, ThrusterStateComponent, TopDownMovementBehavior, TopDownMovementBehaviorOptions, TopDownMovementComponent, TopDownMovementEntity, TopDownMovementHandle, TopDownMovementInputComponent, TopDownMovementStateComponent, TopDownShooterCoordinator, TopDownShooterEntity, TopDownShooterInput, TransformComponent, Vec3Like, ViewmodelConfig, VoronoiOptions, WorldBoundary2DBehavior, WorldBoundary2DBounds, WorldBoundary2DEvent, WorldBoundary2DFSM, WorldBoundary2DHandle, WorldBoundary2DHit, WorldBoundary2DHits, WorldBoundary2DOptions, WorldBoundary2DPosition, WorldBoundary2DState, WorldBoundary3DBehavior, WorldBoundary3DBounds, WorldBoundary3DEvent, WorldBoundary3DFSM, WorldBoundary3DHandle, WorldBoundary3DHit, WorldBoundary3DHits, WorldBoundary3DOptions, WorldBoundary3DPosition, WorldBoundary3DState, computeWorldBoundary2DHits, computeWorldBoundary3DHits, createFirstPersonInputComponent, createFirstPersonMovementComponent, createFirstPersonStateComponent, createJumpConfig2D, createJumpConfig3D, createJumpInput2D, createJumpInput3D, createJumpState2D, createJumpState3D, createPhysicsBodyComponent, createPlatformer2DInputComponent, createPlatformer2DMovementComponent, createPlatformer2DStateComponent, createPlatformer3DInputComponent, createPlatformer3DMovementComponent, createPlatformer3DStateComponent, createShooter2DStateComponent, createThrusterInputComponent, createThrusterMovementComponent, createThrusterStateComponent, createTopDownMovementComponent, createTopDownMovementInputComponent, createTopDownMovementStateComponent, createTransformComponent, defineBehavior, fireCooldown, fireShooter2DIfRequested, getCooldown, getCooldownStore, getEntityFacingAngle2D, hasAnyWorldBoundary2DHit, hasAnyWorldBoundary3DHit, particleEffect, particlePresets, registerCooldown, resetCooldown, resolveAim2D, tickCooldowns, updateBoundaryRicochet, useBehavior } from '@zylem/behaviors';
|
|
2
|
+
export { RUNTIME_BOUNDARY_2D_BEHAVIOR_KEY, RUNTIME_DYNAMIC_CIRCLE_BODY_2D_BEHAVIOR_KEY, RUNTIME_GOAL_ZONE_2D_BEHAVIOR_KEY, RUNTIME_PLAYER_INPUT_2D_BEHAVIOR_KEY, RUNTIME_RICOCHET_2D_BEHAVIOR_KEY, RUNTIME_TRIGGER_REGION_2D_BEHAVIOR_KEY, RuntimeBoundary2DBehavior, RuntimeBoundary2DOptions, RuntimeDynamicCircleBody2DBehavior, RuntimeDynamicCircleBody2DHandle, RuntimeDynamicCircleBody2DOptions, RuntimeGoalZone2DBehavior, RuntimeGoalZone2DEvent, RuntimeGoalZone2DHandle, RuntimeGoalZone2DOptions, RuntimePlayerInput2DBehavior, RuntimePlayerInput2DOptions, RuntimeRicochet2DBehavior, RuntimeRicochet2DEvent, RuntimeRicochet2DHandle, RuntimeRicochet2DOptions, RuntimeTriggerRegion2DBehavior, RuntimeTriggerRegion2DEvent, RuntimeTriggerRegion2DHandle, RuntimeTriggerRegion2DOptions, bindRuntimeDynamicCircleBody2DHandle, emitRuntimeGoal, emitRuntimeRicochet, emitRuntimeTriggerRegionEnter } from '@zylem/behaviors/runtime-2d';
|
package/dist/behavior.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{
|
|
1
|
+
import{$,$a,A,Aa,B,Ba,C,Ca,D,Da,E,Ea,F,Fa,G,Ga,H,Ha,I,Ia,J,Ja,K,Ka,L,La,M,Ma,N,Na,O,Oa,P,Pa,Q,Qa,R,Ra,S,Sa,T,Ta,U,Ua,V,Va,W,Wa,X,Xa,Y,Ya,Z,Za,_,_a,a,aa,ab,b,ba,bb,c,ca,cb,d,da,db,e,ea,eb,f,fa,fb,g,ga,gb,h,ha,hb,i,ia,ib,j,ja,k,ka,l,la,m,ma,n,na,o,oa,p,pa,q,qa,r,ra,s,sa,t,ta,u,ua,v,va,w,wa,x,xa,y,ya,z,za}from"./chunk-XK63E4SX.js";export{a as BoundaryRicochet3DCoordinator,b as BoundaryRicochetCoordinator,c as CooldownBehavior,d as Destructible3DBehavior,e as DestructibleMesh,f as FirstPersonBehavior,g as FirstPersonEvent,h as FirstPersonFSM,k as FirstPersonPresentation,i as FirstPersonShooterCoordinator,j as FirstPersonState,l as FractureOptions,m as Jumper2DBehavior,n as Jumper2DEvent,o as Jumper2DFSM,p as Jumper2DState,q as Jumper3DBehavior,r as Jumper3DEvent,s as Jumper3DFSM,t as Jumper3DState,u as MultidirectionalSpaceShooterCoordinator,v as ParticleEmitterBehavior,w as Platformer2DBehavior,x as Platformer2DEvent,y as Platformer2DFSM,z as Platformer2DState,A as Platformer3DBehavior,B as Platformer3DEvent,C as Platformer3DFSM,D as Platformer3DState,$a as RUNTIME_BOUNDARY_2D_BEHAVIOR_KEY,ab as RUNTIME_DYNAMIC_CIRCLE_BODY_2D_BEHAVIOR_KEY,bb as RUNTIME_GOAL_ZONE_2D_BEHAVIOR_KEY,cb as RUNTIME_PLAYER_INPUT_2D_BEHAVIOR_KEY,db as RUNTIME_RICOCHET_2D_BEHAVIOR_KEY,eb as RUNTIME_TRIGGER_REGION_2D_BEHAVIOR_KEY,E as Ricochet2DBehavior,F as Ricochet2DEvent,G as Ricochet2DFSM,H as Ricochet2DState,I as Ricochet3DBehavior,J as Ricochet3DEvent,K as Ricochet3DFSM,L as Ricochet3DState,Va as RuntimeBoundary2DBehavior,Wa as RuntimeDynamicCircleBody2DBehavior,Xa as RuntimeGoalZone2DBehavior,Ya as RuntimePlayerInput2DBehavior,Za as RuntimeRicochet2DBehavior,_a as RuntimeTriggerRegion2DBehavior,M as ScreenVisibilityBehavior,N as ScreenVisibilityFSM,O as ScreenWrapBehavior,P as ScreenWrapEvent,Q as ScreenWrapFSM,R as ScreenWrapState,S as Shooter2DBehavior,T as ThrusterBehavior,U as ThrusterEvent,V as ThrusterFSM,W as ThrusterState,X as TopDownMovementBehavior,Y as TopDownShooterCoordinator,Z as WorldBoundary2DBehavior,_ as WorldBoundary2DEvent,$ as WorldBoundary2DFSM,aa as WorldBoundary2DState,ba as WorldBoundary3DBehavior,ca as WorldBoundary3DEvent,da as WorldBoundary3DFSM,ea as WorldBoundary3DState,fb as bindRuntimeDynamicCircleBody2DHandle,fa as computeWorldBoundary2DHits,ga as computeWorldBoundary3DHits,ha as createFirstPersonInputComponent,ia as createFirstPersonMovementComponent,ja as createFirstPersonStateComponent,ka as createJumpConfig2D,la as createJumpConfig3D,ma as createJumpInput2D,na as createJumpInput3D,oa as createJumpState2D,pa as createJumpState3D,qa as createPhysicsBodyComponent,ra as createPlatformer2DInputComponent,sa as createPlatformer2DMovementComponent,ta as createPlatformer2DStateComponent,ua as createPlatformer3DInputComponent,va as createPlatformer3DMovementComponent,wa as createPlatformer3DStateComponent,xa as createShooter2DStateComponent,ya as createThrusterInputComponent,za as createThrusterMovementComponent,Aa as createThrusterStateComponent,Ba as createTopDownMovementComponent,Ca as createTopDownMovementInputComponent,Da as createTopDownMovementStateComponent,Ea as createTransformComponent,Fa as defineBehavior,gb as emitRuntimeGoal,hb as emitRuntimeRicochet,ib as emitRuntimeTriggerRegionEnter,Ga as fireCooldown,Ha as fireShooter2DIfRequested,Ia as getCooldown,Ja as getCooldownStore,Ka as getEntityFacingAngle2D,La as hasAnyWorldBoundary2DHit,Ma as hasAnyWorldBoundary3DHit,Na as particleEffect,Oa as particlePresets,Pa as registerCooldown,Qa as resetCooldown,Ra as resolveAim2D,Sa as tickCooldowns,Ta as updateBoundaryRicochet,Ua as useBehavior};
|
|
@@ -0,0 +1,162 @@
|
|
|
1
|
+
import * as _sinclair_typebox from '@sinclair/typebox';
|
|
2
|
+
import { Static } from '@sinclair/typebox';
|
|
3
|
+
|
|
4
|
+
/** 2D position tuple `[x, y]` used by blueprint entities. */
|
|
5
|
+
declare const Vector2Schema: _sinclair_typebox.TTuple<[_sinclair_typebox.TNumber, _sinclair_typebox.TNumber]>;
|
|
6
|
+
/**
|
|
7
|
+
* Runtime entity blueprint (open `data` for factory spreading).
|
|
8
|
+
* Prefer {@link EntityJsonSchema} for editor / Monaco JSON Schema.
|
|
9
|
+
*/
|
|
10
|
+
declare const EntitySchema: _sinclair_typebox.TObject<{
|
|
11
|
+
id: _sinclair_typebox.TString;
|
|
12
|
+
type: _sinclair_typebox.TString;
|
|
13
|
+
position: _sinclair_typebox.TOptional<_sinclair_typebox.TTuple<[_sinclair_typebox.TNumber, _sinclair_typebox.TNumber]>>;
|
|
14
|
+
data: _sinclair_typebox.TOptional<_sinclair_typebox.TRecord<_sinclair_typebox.TString, _sinclair_typebox.TAny>>;
|
|
15
|
+
}>;
|
|
16
|
+
/** Stage blueprint: id, optional name, entities, and optional asset URLs. */
|
|
17
|
+
declare const StageSchema: _sinclair_typebox.TObject<{
|
|
18
|
+
id: _sinclair_typebox.TString;
|
|
19
|
+
name: _sinclair_typebox.TOptional<_sinclair_typebox.TString>;
|
|
20
|
+
entities: _sinclair_typebox.TArray<_sinclair_typebox.TObject<{
|
|
21
|
+
id: _sinclair_typebox.TString;
|
|
22
|
+
type: _sinclair_typebox.TString;
|
|
23
|
+
position: _sinclair_typebox.TOptional<_sinclair_typebox.TTuple<[_sinclair_typebox.TNumber, _sinclair_typebox.TNumber]>>;
|
|
24
|
+
data: _sinclair_typebox.TOptional<_sinclair_typebox.TRecord<_sinclair_typebox.TString, _sinclair_typebox.TAny>>;
|
|
25
|
+
}>>;
|
|
26
|
+
assets: _sinclair_typebox.TOptional<_sinclair_typebox.TArray<_sinclair_typebox.TString>>;
|
|
27
|
+
}>;
|
|
28
|
+
/** JSON-serializable data for blueprint entities of type `text`. */
|
|
29
|
+
declare const TextEntityDataSchema: _sinclair_typebox.TObject<{
|
|
30
|
+
value: _sinclair_typebox.TOptional<_sinclair_typebox.TString>;
|
|
31
|
+
color: _sinclair_typebox.TOptional<_sinclair_typebox.TString>;
|
|
32
|
+
fontSize: _sinclair_typebox.TOptional<_sinclair_typebox.TNumber>;
|
|
33
|
+
fontFamily: _sinclair_typebox.TOptional<_sinclair_typebox.TString>;
|
|
34
|
+
}>;
|
|
35
|
+
/** 3D position tuple `[x, y, z]` for line vertices. */
|
|
36
|
+
declare const Vector3TupleSchema: _sinclair_typebox.TTuple<[_sinclair_typebox.TNumber, _sinclair_typebox.TNumber, _sinclair_typebox.TNumber]>;
|
|
37
|
+
/** JSON-serializable data for blueprint entities of type `line`. */
|
|
38
|
+
declare const LineEntityDataSchema: _sinclair_typebox.TObject<{
|
|
39
|
+
points: _sinclair_typebox.TArray<_sinclair_typebox.TTuple<[_sinclair_typebox.TNumber, _sinclair_typebox.TNumber, _sinclair_typebox.TNumber]>>;
|
|
40
|
+
color: _sinclair_typebox.TOptional<_sinclair_typebox.TString>;
|
|
41
|
+
colors: _sinclair_typebox.TOptional<_sinclair_typebox.TArray<_sinclair_typebox.TString>>;
|
|
42
|
+
linewidth: _sinclair_typebox.TOptional<_sinclair_typebox.TNumber>;
|
|
43
|
+
worldUnits: _sinclair_typebox.TOptional<_sinclair_typebox.TBoolean>;
|
|
44
|
+
alphaToCoverage: _sinclair_typebox.TOptional<_sinclair_typebox.TBoolean>;
|
|
45
|
+
opacity: _sinclair_typebox.TOptional<_sinclair_typebox.TNumber>;
|
|
46
|
+
transparent: _sinclair_typebox.TOptional<_sinclair_typebox.TBoolean>;
|
|
47
|
+
dashed: _sinclair_typebox.TOptional<_sinclair_typebox.TBoolean>;
|
|
48
|
+
dashSize: _sinclair_typebox.TOptional<_sinclair_typebox.TNumber>;
|
|
49
|
+
gapSize: _sinclair_typebox.TOptional<_sinclair_typebox.TNumber>;
|
|
50
|
+
pickThreshold: _sinclair_typebox.TOptional<_sinclair_typebox.TNumber>;
|
|
51
|
+
}>;
|
|
52
|
+
/** JSON-serializable data for blueprint entities of type `sprite`. */
|
|
53
|
+
declare const SpriteEntityDataSchema: _sinclair_typebox.TObject<{
|
|
54
|
+
imagePath: _sinclair_typebox.TOptional<_sinclair_typebox.TString>;
|
|
55
|
+
width: _sinclair_typebox.TOptional<_sinclair_typebox.TNumber>;
|
|
56
|
+
height: _sinclair_typebox.TOptional<_sinclair_typebox.TNumber>;
|
|
57
|
+
}>;
|
|
58
|
+
/**
|
|
59
|
+
* Editor-oriented entity blueprint with discriminated `type` / `data`.
|
|
60
|
+
* Used for published JSON Schema; runtime code uses {@link EntitySchema}.
|
|
61
|
+
*/
|
|
62
|
+
declare const EntityJsonSchema: _sinclair_typebox.TUnion<[_sinclair_typebox.TObject<{
|
|
63
|
+
id: _sinclair_typebox.TString;
|
|
64
|
+
type: _sinclair_typebox.TLiteral<"text">;
|
|
65
|
+
position: _sinclair_typebox.TOptional<_sinclair_typebox.TTuple<[_sinclair_typebox.TNumber, _sinclair_typebox.TNumber]>>;
|
|
66
|
+
data: _sinclair_typebox.TOptional<_sinclair_typebox.TObject<{
|
|
67
|
+
value: _sinclair_typebox.TOptional<_sinclair_typebox.TString>;
|
|
68
|
+
color: _sinclair_typebox.TOptional<_sinclair_typebox.TString>;
|
|
69
|
+
fontSize: _sinclair_typebox.TOptional<_sinclair_typebox.TNumber>;
|
|
70
|
+
fontFamily: _sinclair_typebox.TOptional<_sinclair_typebox.TString>;
|
|
71
|
+
}>>;
|
|
72
|
+
}>, _sinclair_typebox.TObject<{
|
|
73
|
+
id: _sinclair_typebox.TString;
|
|
74
|
+
type: _sinclair_typebox.TLiteral<"sprite">;
|
|
75
|
+
position: _sinclair_typebox.TOptional<_sinclair_typebox.TTuple<[_sinclair_typebox.TNumber, _sinclair_typebox.TNumber]>>;
|
|
76
|
+
data: _sinclair_typebox.TOptional<_sinclair_typebox.TObject<{
|
|
77
|
+
imagePath: _sinclair_typebox.TOptional<_sinclair_typebox.TString>;
|
|
78
|
+
width: _sinclair_typebox.TOptional<_sinclair_typebox.TNumber>;
|
|
79
|
+
height: _sinclair_typebox.TOptional<_sinclair_typebox.TNumber>;
|
|
80
|
+
}>>;
|
|
81
|
+
}>, _sinclair_typebox.TObject<{
|
|
82
|
+
id: _sinclair_typebox.TString;
|
|
83
|
+
type: _sinclair_typebox.TLiteral<"line">;
|
|
84
|
+
position: _sinclair_typebox.TOptional<_sinclair_typebox.TTuple<[_sinclair_typebox.TNumber, _sinclair_typebox.TNumber]>>;
|
|
85
|
+
data: _sinclair_typebox.TOptional<_sinclair_typebox.TObject<{
|
|
86
|
+
points: _sinclair_typebox.TArray<_sinclair_typebox.TTuple<[_sinclair_typebox.TNumber, _sinclair_typebox.TNumber, _sinclair_typebox.TNumber]>>;
|
|
87
|
+
color: _sinclair_typebox.TOptional<_sinclair_typebox.TString>;
|
|
88
|
+
colors: _sinclair_typebox.TOptional<_sinclair_typebox.TArray<_sinclair_typebox.TString>>;
|
|
89
|
+
linewidth: _sinclair_typebox.TOptional<_sinclair_typebox.TNumber>;
|
|
90
|
+
worldUnits: _sinclair_typebox.TOptional<_sinclair_typebox.TBoolean>;
|
|
91
|
+
alphaToCoverage: _sinclair_typebox.TOptional<_sinclair_typebox.TBoolean>;
|
|
92
|
+
opacity: _sinclair_typebox.TOptional<_sinclair_typebox.TNumber>;
|
|
93
|
+
transparent: _sinclair_typebox.TOptional<_sinclair_typebox.TBoolean>;
|
|
94
|
+
dashed: _sinclair_typebox.TOptional<_sinclair_typebox.TBoolean>;
|
|
95
|
+
dashSize: _sinclair_typebox.TOptional<_sinclair_typebox.TNumber>;
|
|
96
|
+
gapSize: _sinclair_typebox.TOptional<_sinclair_typebox.TNumber>;
|
|
97
|
+
pickThreshold: _sinclair_typebox.TOptional<_sinclair_typebox.TNumber>;
|
|
98
|
+
}>>;
|
|
99
|
+
}>, _sinclair_typebox.TObject<{
|
|
100
|
+
id: _sinclair_typebox.TString;
|
|
101
|
+
type: _sinclair_typebox.TString;
|
|
102
|
+
position: _sinclair_typebox.TOptional<_sinclair_typebox.TTuple<[_sinclair_typebox.TNumber, _sinclair_typebox.TNumber]>>;
|
|
103
|
+
data: _sinclair_typebox.TOptional<_sinclair_typebox.TRecord<_sinclair_typebox.TString, _sinclair_typebox.TUnknown>>;
|
|
104
|
+
}>]>;
|
|
105
|
+
/** Editor-oriented stage blueprint referencing {@link EntityJsonSchema}. */
|
|
106
|
+
declare const StageJsonSchema: _sinclair_typebox.TObject<{
|
|
107
|
+
id: _sinclair_typebox.TString;
|
|
108
|
+
name: _sinclair_typebox.TOptional<_sinclair_typebox.TString>;
|
|
109
|
+
entities: _sinclair_typebox.TArray<_sinclair_typebox.TUnion<[_sinclair_typebox.TObject<{
|
|
110
|
+
id: _sinclair_typebox.TString;
|
|
111
|
+
type: _sinclair_typebox.TLiteral<"text">;
|
|
112
|
+
position: _sinclair_typebox.TOptional<_sinclair_typebox.TTuple<[_sinclair_typebox.TNumber, _sinclair_typebox.TNumber]>>;
|
|
113
|
+
data: _sinclair_typebox.TOptional<_sinclair_typebox.TObject<{
|
|
114
|
+
value: _sinclair_typebox.TOptional<_sinclair_typebox.TString>;
|
|
115
|
+
color: _sinclair_typebox.TOptional<_sinclair_typebox.TString>;
|
|
116
|
+
fontSize: _sinclair_typebox.TOptional<_sinclair_typebox.TNumber>;
|
|
117
|
+
fontFamily: _sinclair_typebox.TOptional<_sinclair_typebox.TString>;
|
|
118
|
+
}>>;
|
|
119
|
+
}>, _sinclair_typebox.TObject<{
|
|
120
|
+
id: _sinclair_typebox.TString;
|
|
121
|
+
type: _sinclair_typebox.TLiteral<"sprite">;
|
|
122
|
+
position: _sinclair_typebox.TOptional<_sinclair_typebox.TTuple<[_sinclair_typebox.TNumber, _sinclair_typebox.TNumber]>>;
|
|
123
|
+
data: _sinclair_typebox.TOptional<_sinclair_typebox.TObject<{
|
|
124
|
+
imagePath: _sinclair_typebox.TOptional<_sinclair_typebox.TString>;
|
|
125
|
+
width: _sinclair_typebox.TOptional<_sinclair_typebox.TNumber>;
|
|
126
|
+
height: _sinclair_typebox.TOptional<_sinclair_typebox.TNumber>;
|
|
127
|
+
}>>;
|
|
128
|
+
}>, _sinclair_typebox.TObject<{
|
|
129
|
+
id: _sinclair_typebox.TString;
|
|
130
|
+
type: _sinclair_typebox.TLiteral<"line">;
|
|
131
|
+
position: _sinclair_typebox.TOptional<_sinclair_typebox.TTuple<[_sinclair_typebox.TNumber, _sinclair_typebox.TNumber]>>;
|
|
132
|
+
data: _sinclair_typebox.TOptional<_sinclair_typebox.TObject<{
|
|
133
|
+
points: _sinclair_typebox.TArray<_sinclair_typebox.TTuple<[_sinclair_typebox.TNumber, _sinclair_typebox.TNumber, _sinclair_typebox.TNumber]>>;
|
|
134
|
+
color: _sinclair_typebox.TOptional<_sinclair_typebox.TString>;
|
|
135
|
+
colors: _sinclair_typebox.TOptional<_sinclair_typebox.TArray<_sinclair_typebox.TString>>;
|
|
136
|
+
linewidth: _sinclair_typebox.TOptional<_sinclair_typebox.TNumber>;
|
|
137
|
+
worldUnits: _sinclair_typebox.TOptional<_sinclair_typebox.TBoolean>;
|
|
138
|
+
alphaToCoverage: _sinclair_typebox.TOptional<_sinclair_typebox.TBoolean>;
|
|
139
|
+
opacity: _sinclair_typebox.TOptional<_sinclair_typebox.TNumber>;
|
|
140
|
+
transparent: _sinclair_typebox.TOptional<_sinclair_typebox.TBoolean>;
|
|
141
|
+
dashed: _sinclair_typebox.TOptional<_sinclair_typebox.TBoolean>;
|
|
142
|
+
dashSize: _sinclair_typebox.TOptional<_sinclair_typebox.TNumber>;
|
|
143
|
+
gapSize: _sinclair_typebox.TOptional<_sinclair_typebox.TNumber>;
|
|
144
|
+
pickThreshold: _sinclair_typebox.TOptional<_sinclair_typebox.TNumber>;
|
|
145
|
+
}>>;
|
|
146
|
+
}>, _sinclair_typebox.TObject<{
|
|
147
|
+
id: _sinclair_typebox.TString;
|
|
148
|
+
type: _sinclair_typebox.TString;
|
|
149
|
+
position: _sinclair_typebox.TOptional<_sinclair_typebox.TTuple<[_sinclair_typebox.TNumber, _sinclair_typebox.TNumber]>>;
|
|
150
|
+
data: _sinclair_typebox.TOptional<_sinclair_typebox.TRecord<_sinclair_typebox.TString, _sinclair_typebox.TUnknown>>;
|
|
151
|
+
}>]>>;
|
|
152
|
+
assets: _sinclair_typebox.TOptional<_sinclair_typebox.TArray<_sinclair_typebox.TString>>;
|
|
153
|
+
}>;
|
|
154
|
+
type EntityBlueprint = Static<typeof EntitySchema>;
|
|
155
|
+
type StageBlueprint = Static<typeof StageSchema>;
|
|
156
|
+
type TextEntityData = Static<typeof TextEntityDataSchema>;
|
|
157
|
+
type SpriteEntityData = Static<typeof SpriteEntityDataSchema>;
|
|
158
|
+
type LineEntityData = Static<typeof LineEntityDataSchema>;
|
|
159
|
+
type EntityJson = Static<typeof EntityJsonSchema>;
|
|
160
|
+
type StageJson = Static<typeof StageJsonSchema>;
|
|
161
|
+
|
|
162
|
+
export { EntitySchema as E, LineEntityDataSchema as L, type StageBlueprint as S, TextEntityDataSchema as T, Vector2Schema as V, Vector3TupleSchema as a, SpriteEntityDataSchema as b, StageSchema as c, EntityJsonSchema as d, StageJsonSchema as e, type EntityBlueprint as f, type TextEntityData as g, type SpriteEntityData as h, type LineEntityData as i, type EntityJson as j, type StageJson as k };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{a as P}from"./chunk-XNDS4YFR.js";import{a as Dt,b as Z,c as Y,d as N,e as W,f as X,g as U,h as j,j as q,k as m,l as S,m as p,o as x,p as R,q as $,r as K,s as D}from"./chunk-XNHVRFAK.js";import{j as Ft}from"./chunk-CM5YRNBJ.js";import{d as V,j as Rt}from"./chunk-4QLJUQSJ.js";import{a as It,b as gt,c as zt,d as Lt,g as Bt,h as xt,i as E,j as Ht}from"./chunk-7WRQ2UAN.js";import{Vector3 as Ge}from"three";import{BoxGeometry as ze,CapsuleGeometry as Le,ConeGeometry as Gt,CylinderGeometry as Be,Mesh as I,MeshStandardMaterial as He,SphereGeometry as Fe}from"three";function z(i,t=Symbol("mesh")){if(i.material||i.color){let e=new Ft;if(e.build({...i.material,color:i.color??i.material?.color},t),e.materials.length>0)return e.materials}return[new He]}function L(i,t){if(t.position){let e=xt(t.position,zt);i.position.set(e.x,e.y,e.z)}return i.castShadow=!0,i.receiveShadow=!0,i}function Q(i={}){let t=xt(i.size,Lt),e=new ze(t.x,t.y,t.z),o=z(i);return L(new I(e,o.at(-1)),i)}function J(i={}){let t=new Fe(i.radius??1),e=z(i);return L(new I(t,e.at(-1)),i)}function tt(i={}){let t=new Gt(i.radius??1,i.height??2,i.radialSegments??32),e=z(i);return L(new I(t,e.at(-1)),i)}function et(i={}){let t=new Gt(i.radius??1,i.height??2,4),e=z(i);return L(new I(t,e.at(-1)),i)}function it(i={}){let t=new Be(i.radiusTop??1,i.radiusBottom??1,i.height??2,i.radialSegments??32),e=z(i);return L(new I(t,e.at(-1)),i)}function ot(i={}){let t=new Le(i.radius??.5,i.length??1,i.capSegments??10,i.radialSegments??20),e=z(i);return L(new I(t,e.at(-1)),i)}var At={...m,size:new Ge(1,1,1)},kt=Symbol("Box"),nt=class i extends p{static type=kt;constructor(t){super(),this.options={...At,...t}}buildInfo(){let e=new P(this).buildDebugInfo(),{x:o,y:n,z:s}=this.options.size??{x:1,y:1,z:1};return{...e,type:String(i.type),size:`${o}, ${n}, ${s}`}}};function Vt(...i){let t=S(i,At),e=new nt(t);return e.add(Q({size:t.size,material:t.material,color:t.color}),Y({size:t.size,static:t.collision?.static,sensor:t.collision?.sensor,canSleep:t.collision?.canSleep,ccdEnabled:t.collision?.ccdEnabled,collisionType:t.collisionType,collisionFilter:t.collisionFilter})),x(e,o=>Vt(o??{}))}var Yt={...m,radius:1},Nt=Symbol("Sphere"),st=class i extends p{static type=Nt;constructor(t){super(),this.options={...Yt,...t}}buildInfo(){let e=new P(this).buildDebugInfo(),o=this.options.radius??1;return{...e,type:String(i.type),radius:o.toFixed(2)}}};function Wt(...i){let t=S(i,Yt),e=new st(t);return e.add(J({radius:t.radius,material:t.material,color:t.color}),N({radius:t.radius,static:t.collision?.static,sensor:t.collision?.sensor,collisionType:t.collisionType,collisionFilter:t.collisionFilter})),x(e,o=>Wt(o??{}))}import{PlaneGeometry as ke,Vector2 as Xt,Vector3 as Ut}from"three";import{BufferGeometry as Ae,Float32BufferAttribute as bt}from"three";var rt=class i extends Ae{constructor(t=1,e=1,o=1,n=1){super(),this.type="XZPlaneGeometry",this.parameters={width:t,height:e,widthSegments:o,heightSegments:n};let s=t/2,a=e/2,r=Math.floor(o),l=Math.floor(n),c=r+1,O=l+1,u=t/r,d=e/l,b=[],f=[],y=[],v=[];for(let g=0;g<O;g++){let h=g*d-a;for(let C=0;C<c;C++){let M=C*u-s;f.push(M,0,h),y.push(0,1,0),v.push(C/r),v.push(1-g/l)}}for(let g=0;g<l;g++)for(let h=0;h<r;h++){let C=h+c*g,M=h+c*(g+1),w=h+1+c*(g+1),_=h+1+c*g;b.push(C,M,_),b.push(M,w,_)}this.setIndex(b),this.setAttribute("position",new bt(f,3)),this.setAttribute("normal",new bt(y,3)),this.setAttribute("uv",new bt(v,2))}copy(t){return super.copy(t),this.parameters=Object.assign({},t.parameters),this}static fromJSON(t){return new i(t.width,t.height,t.widthSegments,t.heightSegments)}};var at=4,jt={...m,tile:new Xt(10,10),repeat:new Xt(1,1),collision:{static:!0},subdivisions:at,randomizeHeight:!1,heightScale:1};function qt(i){let t=i.subdivisions??at,e=i.heightMap2D,o=i.heightMap,n=i.subdivisionsX??t,s=i.subdivisionsZ??t;return e&&e.length>0&&e[0]?.length>0?(s=e.length-1,n=e[0].length-1):o&&o.length>0&&(n=o.length-1),{subdivisionsX:n,subdivisionsZ:s}}var Ot=class extends ${collider(t){let e=E(t.tile,gt),{subdivisionsX:o,subdivisionsZ:n}=qt(t),s=new Ut(e.x,1,e.y),a=t._builders?.meshBuilder?.heightData??new Float32Array((o+1)*(n+1));return{shape:{type:"heightfield",rows:o,cols:n,heights:a,scale:[s.x,1,s.z]}}}},Pt=class extends K{heightData=new Float32Array;columnsRows=new Map;subdivisionsX=at;subdivisionsZ=at;build(t){let e=E(t.tile,gt),{subdivisionsX:o,subdivisionsZ:n}=qt(t);this.subdivisionsX=o,this.subdivisionsZ=n;let s=new Ut(e.x,1,e.y),a=t.heightScale??1,r=new rt(s.x,s.z,o,n),l=new ke(s.x,s.z,o,n),c=o>0?s.x/o:1,O=n>0?s.z/n:1,u=r.attributes.position.array,d=l.attributes.position.array,b=new Map,f=t.heightMap2D,y=t.heightMap,v=t.randomizeHeight??!1,g=(h,C)=>h<0?0:h>C?C:h;for(let h=0;h<d.length;h+=3){let C=d[h],M=d[h+1],w=g(Math.round((C+s.x/2)/c),o),_=g(Math.round((s.z/2-M)/O),n),T=0;if(f){let Tt=f[_];Tt&&(T=Tt[w]??0)}else y&&y.length>0?T=y[w]??0:v&&(T=Math.random()*4);let A=T*a;d[h+2]=A,u[h+1]=A,b.get(_)||b.set(_,new Map),b.get(_).set(w,A)}return this.columnsRows=b,r}postBuild(){let t=[];for(let e=0;e<=this.subdivisionsX;++e)for(let o=0;o<=this.subdivisionsZ;++o){let n=this.columnsRows.get(o);t.push(n?.get(e)??0)}this.heightData=new Float32Array(t)}},wt=class extends D{createEntity(t){return new B(t)}},$t=Symbol("Plane"),B=class extends p{static type=$t;constructor(t){super(),this.options=Z(jt,t)}};function Kt(...i){return R({args:i,defaultConfig:jt,EntityClass:B,BuilderClass:wt,MeshBuilderClass:Pt,CollisionBuilderClass:Ot,entityType:B.type,cloneFactory:t=>Kt(t??{})})}import{Vector3 as Ve}from"three";var Qt={...m,size:new Ve(1,1,1),collision:{static:!0}},Jt=Symbol("Zone"),lt=class extends p{static type=Jt;_enteredZone=new Map;_exitedZone=new Map;_zoneEntities=new Map;constructor(t){super(),this.options=Z(Qt,t)}handlePostCollision({delta:t}){return this._enteredZone.forEach((e,o)=>{this.exited(t,o)}),this._enteredZone.size>0}handleIntersectionEvent({other:t,delta:e}){this._enteredZone.get(t.uuid)?this.held(e,t):(this.entered(t),this._zoneEntities.set(t.uuid,t))}onEnter(t){return this.options.onEnter=t,this}onHeld(t){return this.options.onHeld=t,this}onExit(t){return this.options.onExit=t,this}entered(t){this._enteredZone.set(t.uuid,1),this.options.onEnter&&this.options.onEnter({self:this,visitor:t,globals:V.globals})}exited(t,e){let o=this._exitedZone.get(e);if(o&&o>1+t){this._exitedZone.delete(e),this._enteredZone.delete(e);let n=this._zoneEntities.get(e);this.options.onExit&&this.options.onExit({self:this,visitor:n,globals:V.globals});return}this._exitedZone.set(e,1+t)}held(t,e){let o=this._enteredZone.get(e.uuid)??0;this._enteredZone.set(e.uuid,o+t),this._exitedZone.set(e.uuid,1),this.options.onHeld&&this.options.onHeld({delta:t,self:this,visitor:e,globals:V.globals,heldTime:o})}};function te(...i){let t=S(i,Qt),e=new lt(t);return e.add(q({size:t.size,static:t.collision?.static??!0,collisionType:t.collisionType,collisionFilter:t.collisionFilter})),x(e,o=>te(o??{}))}import{Color as ee,Group as Ye,Sprite as Ne,SpriteMaterial as We,CanvasTexture as ie,LinearFilter as pt,Vector2 as ct,ClampToEdgeWrapping as oe,ShaderMaterial as ne,Mesh as Xe,PlaneGeometry as Ue,Vector3 as se}from"three";var H={position:void 0,width:120,height:48,fillColor:"#FFFFFF",strokeColor:null,strokeWidth:0,radius:0,padding:0,stickToViewport:!0,screenPosition:new ct(24,24),zDistance:1,anchor:new ct(0,0)},St=class extends D{createEntity(t){return new F(t)}},re=Symbol("Rect"),F=class i extends p{static type=re;_sprite=null;_mesh=null;_texture=null;_canvas=null;_ctx=null;_cameraRef=null;_lastCanvasW=0;_lastCanvasH=0;constructor(t){super(),this.options=Z(H,t),this.options.screenPosition=E(this.options.screenPosition,H.screenPosition),this.options.anchor=E(this.options.anchor,H.anchor),this.group=new Ye,this.createSprite(),this.prependSetup(this.rectSetup.bind(this)),this.prependUpdate(this.rectUpdate.bind(this))}createSprite(){this._canvas=document.createElement("canvas"),this._ctx=this._canvas.getContext("2d"),this._texture=new ie(this._canvas),this._texture.minFilter=pt,this._texture.magFilter=pt;let t=new We({map:this._texture,transparent:!0,depthTest:!1,depthWrite:!1,alphaTest:.5});this._sprite=new Ne(t),this.group?.add(this._sprite),this.redrawRect()}redrawRect(){if(!this._canvas||!this._ctx)return;let t=Math.max(2,Math.floor(this.options.width??120)),e=Math.max(2,Math.floor(this.options.height??48)),o=this.options.padding??0,n=this.options.strokeWidth??0,s=t+o*2+n,a=e+o*2+n,r=Math.max(2,s),l=Math.max(2,a),c=r!==this._lastCanvasW||l!==this._lastCanvasH;this._canvas.width=r,this._canvas.height=l,this._lastCanvasW=r,this._lastCanvasH=l,this._ctx.clearRect(0,0,this._canvas.width,this._canvas.height);let O=Math.max(0,this.options.radius??0),u=Math.floor(o+n/2),d=Math.floor(o+n/2),b=Math.floor(t),f=Math.floor(e);if(this._ctx.beginPath(),O>0?this.roundedRectPath(this._ctx,u,d,b,f,O):this._ctx.rect(u,d,b,f),this.options.fillColor&&(this._ctx.fillStyle=this.toCssColor(this.options.fillColor),this._ctx.fill()),this.options.strokeColor&&n>0&&(this._ctx.lineWidth=n,this._ctx.strokeStyle=this.toCssColor(this.options.strokeColor),this._ctx.stroke()),this._texture){if(c&&(this._texture.dispose(),this._texture=new ie(this._canvas),this._texture.minFilter=pt,this._texture.magFilter=pt,this._texture.wrapS=oe,this._texture.wrapT=oe,this._sprite&&this._sprite.material instanceof ne)){let y=this._sprite.material;y.uniforms?.tDiffuse&&(y.uniforms.tDiffuse.value=this._texture),y.uniforms?.iResolution&&y.uniforms.iResolution.value.set(this._canvas.width,this._canvas.height,1)}this._texture.image=this._canvas,this._texture.needsUpdate=!0,this._sprite&&this._sprite.material&&(this._sprite.material.map=this._texture,this._sprite.material.needsUpdate=!0)}}getWidth(){return this.options.width??0}getHeight(){return this.options.height??0}roundedRectPath(t,e,o,n,s,a){let r=Math.min(a,Math.floor(Math.min(n,s)/2));t.moveTo(e+r,o),t.lineTo(e+n-r,o),t.quadraticCurveTo(e+n,o,e+n,o+r),t.lineTo(e+n,o+s-r),t.quadraticCurveTo(e+n,o+s,e+n-r,o+s),t.lineTo(e+r,o+s),t.quadraticCurveTo(e,o+s,e,o+s-r),t.lineTo(e,o+r),t.quadraticCurveTo(e,o,e+r,o)}toCssColor(t){return typeof t=="string"?t:`#${(t instanceof ee?t:new ee(t)).getHexString()}`}getResolution(){try{let t=this._cameraRef?.renderer?.domElement;if(t)return{width:t.clientWidth||1,height:t.clientHeight||1}}catch{}return{width:this._cameraRef?.screenResolution?.x??1,height:this._cameraRef?.screenResolution?.y??1}}rectSetup(t){if(this._cameraRef=t.camera,this.options.stickToViewport&&this._cameraRef&&this._cameraRef.camera.add(this.group),this.materials?.length&&this._sprite){let e=this.materials[0];e instanceof ne&&(e.transparent=!0,e.depthTest=!1,e.depthWrite=!1,this._texture&&(e.uniforms?.tDiffuse&&(e.uniforms.tDiffuse.value=this._texture),e.uniforms?.iResolution&&this._canvas&&e.uniforms.iResolution.value.set(this._canvas.width,this._canvas.height,1)),this._mesh=new Xe(new Ue(1,1),e),this.group?.add(this._mesh),this._sprite.visible=!1)}}rectUpdate(t){if(this._sprite){if(this._cameraRef&&this.options.bounds){let e=this.computeScreenBoundsFromOptions(this.options.bounds);if(e){let{x:o,y:n,width:s,height:a}=e,r=Math.max(2,Math.floor(s)),l=Math.max(2,Math.floor(a)),c=r!==(this.options.width??0)||l!==(this.options.height??0);this.options.screenPosition=new ct(Math.floor(o),Math.floor(n)),this.options.width=r,this.options.height=l,this.options.anchor=new ct(0,0),c&&this.redrawRect()}}this.options.stickToViewport&&this._cameraRef&&this.updateStickyTransform()}}updateStickyTransform(){if(!this._sprite||!this._cameraRef)return;let t=this._cameraRef.camera,{width:e,height:o}=this.getResolution(),n=E(this.options.screenPosition,H.screenPosition),s=n.x,a=n.y,r=Math.max(.001,this.options.zDistance??1),l=1,c=1;if(t.isPerspectiveCamera){let w=t,_=Math.tan(w.fov*Math.PI/180/2)*r;l=_*w.aspect,c=_}else if(t.isOrthographicCamera){let w=t;l=(w.right-w.left)/2,c=(w.top-w.bottom)/2}let O=s/e*2-1,u=1-a/o*2,d=O*l,b=u*c,f=1,y=1;if(this._canvas){let _=c*2/o,T=this._canvas.height;y=Math.max(1e-4,T*_);let A=this._canvas.width/this._canvas.height;f=y*A,this._sprite.scale.set(f,y,1),this._mesh&&this._mesh.scale.set(f,y,1)}let v=E(this.options.anchor,H.anchor),g=Math.min(100,Math.max(0,v.x))/100,h=Math.min(100,Math.max(0,v.y))/100,C=(.5-g)*f,M=(h-.5)*y;this.group?.position.set(d+C,b+M,-r)}worldToScreen(t){if(!this._cameraRef)return{x:0,y:0};let e=this._cameraRef.camera,{width:o,height:n}=this.getResolution(),s=t.clone().project(e),a=(s.x+1)/2*o,r=(1-s.y)/2*n;return{x:a,y:r}}computeScreenBoundsFromOptions(t){if(!this._cameraRef)return null;if(t.screen)return{...t.screen};if(t.world){let{left:e,right:o,top:n,bottom:s,z:a=0}=t.world,r=this.worldToScreen(new se(e,n,a)),l=this.worldToScreen(new se(o,s,a)),c=Math.min(r.x,l.x),O=Math.min(r.y,l.y),u=Math.abs(l.x-r.x),d=Math.abs(l.y-r.y);return{x:c,y:O,width:u,height:d}}return null}updateRect(t){this.options={...this.options,...t},this.redrawRect(),this.options.stickToViewport&&this._cameraRef&&this.updateStickyTransform()}buildInfo(){return{...new P(this).buildDebugInfo(),type:String(i.type),width:this.options.width??0,height:this.options.height??0,sticky:this.options.stickToViewport}}};function ae(...i){return R({args:i,defaultConfig:{...H},EntityClass:F,BuilderClass:St,entityType:F.type,cloneFactory:t=>ae(t??{})})}import{Group as je,RingGeometry as qe}from"three";var le={...m,innerRadius:0,outerRadius:1,thetaSegments:32},Ct=class extends ${collider(t){let e=t.outerRadius??1;return{shape:{type:"cylinder",halfHeight:.1/2,radius:e}}}},_t=class extends K{build(t){let e=t.innerRadius??0,o=t.outerRadius??1,n=t.thetaSegments??32,s=new qe(e,o,n);return s.rotateX(-Math.PI/2),s}},vt=class extends D{createEntity(t){return new G(t)}build(){let t=super.build();return t.mesh&&!t.group&&(t.group=new je,t.group.add(t.mesh)),t}},pe=Symbol("Disk"),G=class i extends p{static type=pe;constructor(t){super(),this.options={...le,...t}}buildInfo(){let e=new P(this).buildDebugInfo(),o=this.options.innerRadius??0,n=this.options.outerRadius??1;return{...e,type:String(i.type),innerRadius:o.toFixed(2),outerRadius:n.toFixed(2)}}};function ce(...i){return R({args:i,defaultConfig:le,EntityClass:G,BuilderClass:vt,MeshBuilderClass:_t,CollisionBuilderClass:Ct,entityType:G.type,cloneFactory:t=>ce(t??{})})}var he={...m,radius:1,height:2,radialSegments:32},me=Symbol("Cone"),ht=class i extends p{static type=me;constructor(t){super(),this.options={...he,...t}}buildInfo(){let e=new P(this).buildDebugInfo(),o=this.options.radius??1,n=this.options.height??2;return{...e,type:String(i.type),radius:o.toFixed(2),height:n.toFixed(2)}}};function ue(...i){let t=S(i,he),e=new ht(t);return e.add(tt({radius:t.radius,height:t.height,radialSegments:t.radialSegments,material:t.material,color:t.color}),W({radius:t.radius,height:t.height,static:t.collision?.static,sensor:t.collision?.sensor,collisionType:t.collisionType,collisionFilter:t.collisionFilter})),x(e,o=>ue(o??{}))}var de={...m,radius:1,height:2},ye=Symbol("Pyramid"),mt=class i extends p{static type=ye;constructor(t){super(),this.options={...de,...t}}buildInfo(){let e=new P(this).buildDebugInfo(),o=this.options.radius??1,n=this.options.height??2;return{...e,type:String(i.type),radius:o.toFixed(2),height:n.toFixed(2)}}};function fe(...i){let t=S(i,de),e=new mt(t);return e.add(et({radius:t.radius,height:t.height,material:t.material,color:t.color}),X({radius:t.radius,height:t.height,static:t.collision?.static,sensor:t.collision?.sensor,collisionType:t.collisionType,collisionFilter:t.collisionFilter})),x(e,o=>fe(o??{}))}var ge={...m,radiusTop:1,radiusBottom:1,height:2,radialSegments:32},xe=Symbol("Cylinder"),ut=class i extends p{static type=xe;constructor(t){super(),this.options={...ge,...t}}buildInfo(){let e=new P(this).buildDebugInfo(),o=this.options.radiusTop??1,n=this.options.radiusBottom??1,s=this.options.height??2;return{...e,type:String(i.type),radiusTop:o.toFixed(2),radiusBottom:n.toFixed(2),height:s.toFixed(2)}}};function be(...i){let t=S(i,ge),e=new ut(t);return e.add(it({radiusTop:t.radiusTop,radiusBottom:t.radiusBottom,height:t.height,radialSegments:t.radialSegments,material:t.material,color:t.color}),U({radiusTop:t.radiusTop,radiusBottom:t.radiusBottom,height:t.height,static:t.collision?.static,sensor:t.collision?.sensor,collisionType:t.collisionType,collisionFilter:t.collisionFilter})),x(e,o=>be(o??{}))}var Oe={...m,radius:.5,length:1,capSegments:10,radialSegments:20},Pe=Symbol("Pill"),dt=class i extends p{static type=Pe;constructor(t){super(),this.options={...Oe,...t}}buildInfo(){let e=new P(this).buildDebugInfo(),o=this.options.radius??.5,n=this.options.length??1;return{...e,type:String(i.type),radius:o.toFixed(2),length:n.toFixed(2)}}};function we(...i){let t=S(i,Oe),e=new dt(t);return e.add(ot({radius:t.radius,length:t.length,capSegments:t.capSegments,radialSegments:t.radialSegments,material:t.material,color:t.color}),j({radius:t.radius,length:t.length,static:t.collision?.static,sensor:t.collision?.sensor,collisionType:t.collisionType,collisionFilter:t.collisionFilter})),x(e,o=>we(o??{}))}import{Group as $e,Quaternion as Ke,Vector3 as Qe}from"three";import{ParticleEmitterBehavior as Et}from"@zylem/behaviors/particle-emitter";var Je={...m,effect:{create(){throw new Error("createParticleSystem(...) requires an effect or preset definition.")}},preset:void 0,autoplay:!0,localOffset:void 0,followPosition:!0,followRotation:!0,autoDestroy:!1},Se=Symbol("ParticleSystem");function ti(i){return{effect:i.preset??i.effect,autoplay:i.autoplay,localOffset:i.localOffset,followPosition:i.followPosition,followRotation:i.followRotation,autoDestroy:i.autoDestroy}}var yt=class i extends p{static type=Se;particleHandle=null;constructor(t,e=!0){super(),this.options=Z(Je,t),this.group=new $e;let o=this.options.position;o&&this.group.position.copy(Ht(o)),this.__zylemParticleSystemEntity=!0,this.bindStandaloneTransforms(),e&&(this.particleHandle=this.use(Et,ti(this.options)))}bindStandaloneTransforms(){let t=()=>{this.options.position=new Qe(this.group?.position.x??0,this.group?.position.y??0,this.group?.position.z??0)},e=()=>{this.group&&(this._rotation2DAngle=this.group.rotation.z)};this.setPosition=(o,n,s)=>{this.group?.position.set(o,n,s),t()},this.setPositionX=o=>{this.group&&(this.group.position.x=o,t())},this.setPositionY=o=>{this.group&&(this.group.position.y=o,t())},this.setPositionZ=o=>{this.group&&(this.group.position.z=o,t())},this.getPosition=()=>this.group?{x:this.group.position.x,y:this.group.position.y,z:this.group.position.z}:null,this.setRotation=(o,n,s)=>{this.group?.rotation.set(o,n,s),e()},this.setRotationX=o=>{this.group&&(this.group.rotation.x=o,e())},this.setRotationY=o=>{this.group&&(this.group.rotation.y=o,e())},this.setRotationZ=o=>{this.group&&(this.group.rotation.z=o,e())},this.setRotationDegrees=(o,n,s)=>{this.group?.rotation.set(o*Math.PI/180,n*Math.PI/180,s*Math.PI/180),e()},this.setRotationDegreesX=o=>{this.group&&(this.group.rotation.x=o*Math.PI/180,e())},this.setRotationDegreesY=o=>{this.group&&(this.group.rotation.y=o*Math.PI/180,e())},this.setRotationDegreesZ=o=>{this.group&&(this.group.rotation.z=o*Math.PI/180,e())},this.rotateX=o=>{this.group?.rotateX(o),e()},this.rotateY=o=>{this.group?.rotateY(o),e()},this.rotateZ=o=>{this.group?.rotateZ(o),e()},this.getRotation=()=>{if(!this.group)return null;let o=new Ke;return this.group.getWorldQuaternion(o),o}}resolveParticleHandle(){if(this.particleHandle)return this.particleHandle;let t=this.getBehaviorRefs().find(n=>n.descriptor.key===Et.key);if(!t)return null;let e={getFSM:()=>t.fsm??null,getOptions:()=>t.options,ref:t},o=Et.createHandle?.(t)??{};return this.particleHandle={...e,...o},this.particleHandle}play(){this.resolveParticleHandle()?.play()}stop(){this.resolveParticleHandle()?.stop()}pause(){this.resolveParticleHandle()?.pause()}restart(){this.resolveParticleHandle()?.restart()}burst(){this.resolveParticleHandle()?.burst()}isPlaying(){return this.resolveParticleHandle()?.isPlaying()??!1}getSystem(){return this.resolveParticleHandle()?.getSystem()}buildInfo(){return{...super.buildInfo(),type:String(i.type)}}};function Ce(i,t=!0){let e=new yt(i,t);return x(e,o=>Ce(o,!1))}function ei(i){return Ce(i,!0)}import{AmbientLight as ii,DirectionalLight as oi,Group as ni,HemisphereLight as si,Object3D as ri,PointLight as ai,SpotLight as li}from"three";var _e=Symbol("Light"),pi={x:0,y:0,z:0},k=16777215,ci={mapSize:2048,near:.1,far:500,bias:0,radius:1,left:-100,right:100,top:100,bottom:-100},hi={mapSize:1024,near:.1,far:500,bias:0,radius:1},ft=class extends p{static type=_e;light=null;lightTarget=null;constructor(t){super(),this.options={...t}}create(){super.create();let t=new ni,{light:e,target:o}=mi(this.options);return t.add(e),o&&t.add(o),this.group=t,this.light=e,this.lightTarget=o,this}_cleanup(t){this.light?.shadow?.map?.dispose?.(),this.light=null,this.lightTarget=null,super._cleanup(t)}};function mi(i){switch(i.type){case"ambient":return{light:ui(i),target:null};case"hemisphere":return{light:di(i),target:null};case"directional":return yi(i);case"point":return{light:fi(i),target:null};case"spot":return gi(i)}}function ui(i){let t=new ii(i.color??k,i.intensity??1);return i.name&&(t.name=i.name),t}function di(i){let t=i.skyColor??i.color??k,e=i.groundColor??0,o=new si(t,e,i.intensity??1);return i.name&&(o.name=i.name),o}function yi(i){let t=new oi(i.color??k,i.intensity??1);i.name&&(t.name=i.name),xi(t,i.castShadow??!1,i.shadow);let e=ve(i.position,i.target);return e&&(t.target=e),{light:t,target:e}}function fi(i){let t=new ai(i.color??k,i.intensity??1,i.distance,i.decay);return i.name&&(t.name=i.name),Ee(t,i.castShadow??!1,i.shadow),t}function gi(i){let t=new li(i.color??k,i.intensity??1,i.distance,i.angle,i.penumbra,i.decay);i.name&&(t.name=i.name),Ee(t,i.castShadow??!1,i.shadow);let e=ve(i.position,i.target);return e&&(t.target=e),{light:t,target:e}}function ve(i,t){if(!t)return null;let e=i??pi,o=new ri;return o.position.set(t.x-e.x,t.y-e.y,t.z-e.z),o}function xi(i,t,e){if(!t){i.castShadow=!1;return}i.castShadow=!0;let o={...ci,...e??{}};i.shadow.mapSize.set(o.mapSize,o.mapSize),i.shadow.camera.near=o.near,i.shadow.camera.far=o.far,i.shadow.camera.left=o.left,i.shadow.camera.right=o.right,i.shadow.camera.top=o.top,i.shadow.camera.bottom=o.bottom,i.shadow.bias=o.bias,i.shadow.radius=o.radius,i.shadow.camera.updateProjectionMatrix()}function Ee(i,t,e){if(!t){i.castShadow=!1;return}i.castShadow=!0;let o={...hi,...e??{}};i.shadow.mapSize.set(o.mapSize,o.mapSize),i.shadow.camera.near=o.near,i.shadow.camera.far=o.far,i.shadow.bias=o.bias,i.shadow.radius=o.radius,i.shadow.camera.updateProjectionMatrix()}function bi(i){return new ft(i)}import{Group as Oi,Sprite as Pi,SpriteMaterial as wi,CanvasTexture as Si,LinearFilter as Ze,Color as Me,ClampToEdgeWrapping as Te}from"three";import{getCooldown as Re}from"@zylem/behaviors/cooldown";var Ci={"top-left":{fx:0,fy:0},"top-center":{fx:.5,fy:0},"top-right":{fx:1,fy:0},"center-left":{fx:0,fy:.5},center:{fx:.5,fy:.5},"center-right":{fx:1,fy:.5},"bottom-left":{fx:0,fy:1},"bottom-center":{fx:.5,fy:1},"bottom-right":{fx:1,fy:1}},De=192,_i={xs:8,sm:16,md:32,lg:48,xl:64},Zt={position:void 0,cooldown:"",iconSize:"md",fillColor:"#333333",showTimer:!0,stickToViewport:!0,screenAnchor:"top-left",screenPosition:{x:0,y:0},zDistance:1,overlayColor:"rgba(0, 0, 0, 0.65)"},vi=Symbol("CooldownIcon"),Mt=class extends p{static type=vi;_sprite=null;_texture=null;_canvas=null;_ctx=null;_cameraRef=null;_iconTexture=null;_iconImage=null;_lastRenderedProgress=-1;constructor(t){super(),this.options=Z(Zt,t),this.options.screenPosition=E(this.options.screenPosition,Zt.screenPosition),this.group=new Oi,this.createSprite(),this.prependSetup(this.iconSetup.bind(this)),this.prependUpdate(this.iconUpdate.bind(this)),this.onCleanup(this.iconDestroy.bind(this))}createSprite(){this._canvas=document.createElement("canvas"),this._canvas.width=256,this._canvas.height=256,this._ctx=this._canvas.getContext("2d"),this._texture=new Si(this._canvas),this._texture.minFilter=Ze,this._texture.magFilter=Ze,this._texture.wrapS=Te,this._texture.wrapT=Te;let e=new wi({map:this._texture,transparent:!0,depthTest:!1,depthWrite:!1});if(this._sprite=new Pi(e),this.group?.add(this._sprite),this.options.icon){let o=new Image;o.crossOrigin="anonymous",o.onload=()=>{this._iconImage=o,this.redraw(this._lastRenderedProgress>=0?this._lastRenderedProgress:1)},o.src=this.options.icon}this.redraw(1)}redraw(t){if(!this._canvas||!this._ctx)return;let e=this._ctx,o=this._canvas.width,n=this._canvas.height,s=o/2,a=n/2,r=Math.min(s,a);if(e.clearRect(0,0,o,n),this._iconImage?e.drawImage(this._iconImage,0,0,o,n):(e.fillStyle=this.toCssColor(this.options.fillColor??"#333333"),e.fillRect(0,0,o,n)),t<1){let l=(1-t)*Math.PI*2,c=-Math.PI/2,O=c+l;if(e.save(),e.fillStyle=this.options.overlayColor??"rgba(0, 0, 0, 0.65)",e.beginPath(),e.moveTo(s,a),e.arc(s,a,r+1,c,O,!1),e.closePath(),e.fill(),e.restore(),this.options.showTimer){let u=Re(this.options.cooldown);if(u){let d=Math.max(0,u.duration-u.elapsed),b=d>=10?Math.ceil(d).toString():d.toFixed(1),f=Math.floor(o*.3);e.font=`bold ${f}px sans-serif`,e.textAlign="center",e.textBaseline="middle",e.fillStyle="#FFFFFF",e.strokeStyle="#000000",e.lineWidth=2,e.strokeText(b,s,a),e.fillText(b,s,a)}}}this._texture&&(this._texture.needsUpdate=!0),this._lastRenderedProgress=t}toCssColor(t){return typeof t=="string"?t:`#${(t instanceof Me?t:new Me(t)).getHexString()}`}getResolution(){try{let t=this._cameraRef?.renderer?.domElement;if(t)return{width:t.clientWidth||1,height:t.clientHeight||1}}catch{}return{width:this._cameraRef?.screenResolution?.x??1,height:this._cameraRef?.screenResolution?.y??1}}iconSetup(t){this._sprite||this.createSprite(),this._cameraRef=t.camera,this.options.stickToViewport&&this._cameraRef&&(this._cameraRef.camera.add(this.group),this.updateStickyTransform())}iconUpdate(t){let o=Re(this.options.cooldown)?.progress??1;(Math.abs(o-this._lastRenderedProgress)>.02||o===1&&this._lastRenderedProgress!==1)&&this.redraw(o),this.options.stickToViewport&&this._cameraRef&&this.updateStickyTransform()}resolveScreenPosition(t,e){let o=this.options.screenAnchor??"top-left",n=Bt(this.options.screenPosition,It),s=n.x,a=n.y,{fx:r,fy:l}=Ci[o],c=r*t,O=l*e,u=e/De;return{px:c+s*u,py:O+a*u}}resolveIconSize(t){let e=this.options.iconSize??"md",o,n;typeof e=="string"?o=n=_i[e]:typeof e=="number"?o=n=e:(o=e.width,n=e.height);let s=t/De;return{widthPx:o*s,heightPx:n*s}}computeWorldExtents(t,e){let o=1,n=1;if(t.isPerspectiveCamera){let s=t,a=Math.tan(s.fov*Math.PI/180/2)*e;o=a*s.aspect,n=a}else if(t.isOrthographicCamera){let s=t;o=(s.right-s.left)/2,n=(s.top-s.bottom)/2}return{worldHalfW:o,worldHalfH:n}}updateStickyTransform(){if(!this._sprite||!this._cameraRef)return;let t=this._cameraRef.camera,{width:e,height:o}=this.getResolution(),{px:n,py:s}=this.resolveScreenPosition(e,o),a=Math.max(.001,this.options.zDistance??1),{worldHalfW:r,worldHalfH:l}=this.computeWorldExtents(t,a),c=n/e*2-1,O=1-s/o*2,u=c*r,d=O*l;{let f=l*2/o,{widthPx:y,heightPx:v}=this.resolveIconSize(o),g=Math.max(1e-4,y*f),h=Math.max(1e-4,v*f);this._sprite.scale.set(g,h,1)}this.group?.position.set(u,d,-a)}iconDestroy(){this._texture?.dispose(),this._sprite?.material&&this._sprite.material.dispose(),this._sprite&&this._sprite.removeFromParent(),this.group?.removeFromParent(),this._iconTexture?.dispose(),this._sprite=null,this._texture=null,this._canvas=null,this._ctx=null,this._cameraRef=null,this._iconTexture=null,this._iconImage=null}};function Ie(...i){let t=i.filter(o=>!(o instanceof Dt)),e={...Zt};for(let o of t)e={...e,...o};return x(new Mt(e),o=>Ie(o??{}))}function Ei(i,t,e){e({me:i,globals:t})}function Zi(i,t){let e=t??Rt();Ei(i,e,i.nodeDestroy.bind(i))}export{Q as a,J as b,tt as c,et as d,it as e,ot as f,kt as g,nt as h,Vt as i,Nt as j,st as k,Wt as l,$t as m,B as n,Kt as o,Jt as p,lt as q,te as r,re as s,F as t,ae as u,pe as v,G as w,ce as x,me as y,ht as z,ue as A,ye as B,mt as C,fe as D,xe as E,ut as F,be as G,Pe as H,dt as I,we as J,Se as K,yt as L,ei as M,_e as N,ft as O,bi as P,Ie as Q,Zi as R};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{clamp as t,mix as a}from"three/tsl";var o=({fromNode:e,toNode:n,progress:r})=>a(e,n,t(r,0,1));function i(e){return e<.5?2*e*e:1-(-2*e+2)**2/2}function s(e){return typeof e=="function"?e:e==="linear"?n=>n:i}function m(e={}){let n=e.shader,r=typeof n=="function"?n:n?.shader??o;return{duration:Math.max(.01,e.duration??.8),shader:r,easing:s(e.easing),onComplete:e.onComplete}}export{o as a,m as b};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{Vector2 as s,Vector3 as x}from"three";var c=Object.freeze({x:0,y:0}),d=Object.freeze({x:1,y:1}),i=Object.freeze({x:0,y:0,z:0}),w=Object.freeze({x:1,y:1,z:1});function p(n){return typeof n=="number"&&Number.isFinite(n)}function b(n){return n!=null&&typeof n=="object"&&("x"in n||"y"in n)}function f(n){return n!=null&&typeof n=="object"&&("x"in n||"y"in n||"z"in n)}function V(n,t,e){if(!n)return e;let r=n[t];return p(r)?r:e}function y(n,t,e){if(!n)return e;let r=n[t];return p(r)?r:e}function u(n,t,e,r){return n?Array.isArray(n)?V(n,e,r):y(n,t,r):r}function o(n,t,e,r){return n?Array.isArray(n)?V(n,e,r):y(n,t,r):r}function a(n){return{x:u(n,"x",0,0),y:u(n,"y",1,0)}}function z(n){return{x:o(n,"x",0,0),y:o(n,"y",1,0),z:o(n,"z",2,0)}}function k(n){return Array.isArray(n)||b(n)}function A(n){return Array.isArray(n)||f(n)}function C(n,t=c){let e=a(t);return{x:u(n,"x",0,e.x),y:u(n,"y",1,e.y)}}function l(n,t=i){let e=z(t);return{x:o(n,"x",0,e.x),y:o(n,"y",1,e.y),z:o(n,"z",2,e.z)}}function h(n,t=c){let{x:e,y:r}=C(n,t);return new s(e,r)}function T(n,t=i){let{x:e,y:r,z:m}=l(n,t);return new x(e,r,m)}export{c as a,d as b,i as c,w as d,k as e,A as f,C as g,l as h,h as i,T as j};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
function d(e,n){return e.priority!==n.priority?e.priority-n.priority:e.sourceId.localeCompare(n.sourceId)}function m(e,n,t){let r=!1,l=0,u=!1,y=e,a=Number.NEGATIVE_INFINITY;for(let i of n){let o=i[t];if(o!=null){if(r=!0,i.mode==="add"){l+=o;continue}(!u||i.priority>=a)&&(u=!0,a=i.priority,y=o)}}return{touched:r,value:(u?y:0)+l}}function b(e,n){return{x:m(e.x,n,"x"),y:m(e.y,n,"y"),z:m(e.z,n,"z")}}function v(e){for(let n in e.velocityChannels)delete e.velocityChannels[n];e.dirty.velocityChannels=!1}function f(e){let n=[];if(e.dirty.velocityChannels)for(let t in e.velocityChannels){let r=e.velocityChannels[t];n.push({sourceId:t,mode:r.mode??"replace",priority:r.priority??0,x:r.x,y:r.y,z:r.z})}return(e.dirty.velocityX||e.dirty.velocityY||e.dirty.velocityZ)&&n.push({sourceId:"__legacy_per_axis__",mode:"replace",priority:-100,x:e.dirty.velocityX?e.velocity.x:void 0,y:e.dirty.velocityY?e.velocity.y:void 0,z:e.dirty.velocityZ?e.velocity.z:void 0}),n}function p(e){e.dirty.position=!1,e.dirty.rotation=!1,e.dirty.velocityX=!1,e.dirty.velocityY=!1,e.dirty.velocityZ=!1,v(e),e.dirty.angularVelocity=!1}function x(e,n,t){let r=t.dirty.position,l=t.dirty.rotation,u=t.dirty.angularVelocity,y=t.dirty.velocityX||t.dirty.velocityY||t.dirty.velocityZ,a=t.dirty.velocityChannels;if(!r&&!l&&!u&&!y&&!a)return;let i=f(t);if(i.length>0){let o=e.getLinearVelocity(n)??[0,0,0],c={x:o[0],y:o[1],z:o[2]};i.length>1&&i.sort(d);let s=b(c,i);e.setLinearVelocity(n,s.x.touched?s.x.value:c.x,s.y.touched?s.y.value:c.y,s.z.touched?s.z.value:c.z)}if(l){let o=t.rotation;e.setRotation(n,o.x,o.y,o.z,o.w)}if(u){let o=t.angularVelocity;e.setAngularVelocity(n,o.x,o.y,o.z)}if(r){let o=e.getPose(n);o&&e.setPosition(n,o.position[0]+t.position.x,o.position[1]+t.position.y,o.position[2]+t.position.z)}p(t)}function h(e,n){if(!e.body){e.wasmStageRef&&(e.runtimeHandle??-1)>=0&&x(e.wasmStageRef,e.runtimeHandle,n);return}let t=n.dirty.position,r=n.dirty.rotation,l=n.dirty.angularVelocity,u=n.dirty.velocityX||n.dirty.velocityY||n.dirty.velocityZ,y=n.dirty.velocityChannels;if(!t&&!r&&!l&&!u&&!y)return;let a=f(n);if(a.length>0){let i=e.body.linvel();a.length>1&&a.sort(d);let o=b(i,a);e.body.setLinvel({x:o.x.touched?o.x.value:i.x,y:o.y.touched?o.y.value:i.y,z:o.z.touched?o.z.value:i.z},!0)}if(r&&e.body.setRotation(n.rotation,!0),l&&e.body.setAngvel(n.angularVelocity,!0),t){let i=e.body.translation();e.body.setTranslation({x:i.x+n.position.x,y:i.y+n.position.y,z:i.z+n.position.z},!0)}p(n)}export{h as a};
|
|
File without changes
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import{a as R}from"./chunk-QXVH6POE.js";import{b as p,i as h}from"./chunk-7WRQ2UAN.js";var C=`
|
|
2
|
+
uniform vec2 uvScale;
|
|
3
|
+
varying vec2 vUv;
|
|
4
|
+
|
|
5
|
+
void main() {
|
|
6
|
+
vUv = uv;
|
|
7
|
+
vec4 mvPosition = modelViewMatrix * vec4( position, 1.0 );
|
|
8
|
+
gl_Position = projectionMatrix * mvPosition;
|
|
9
|
+
}
|
|
10
|
+
`;var D=`
|
|
11
|
+
uniform sampler2D tDiffuse;
|
|
12
|
+
varying vec2 vUv;
|
|
13
|
+
|
|
14
|
+
void main() {
|
|
15
|
+
vec4 texel = texture2D( tDiffuse, vUv );
|
|
16
|
+
|
|
17
|
+
gl_FragColor = texel;
|
|
18
|
+
}
|
|
19
|
+
`,O={vertex:C,fragment:D};import{Color as F,RepeatWrapping as v,SRGBColorSpace as te}from"three";import{MeshBasicNodeMaterial as re,MeshStandardNodeMaterial as P}from"three/webgpu";function G(s){let e=Object.keys(s).sort().reduce((t,r)=>(t[r]=s[r],t),{});return JSON.stringify(e)}function E(s){let e=0;for(let t=0;t<s.length;t++)e=Math.imul(31,e)+s.charCodeAt(t)|0;return e.toString(36)}import{LoadingManager as ee,Cache as k}from"three";import{TextureLoader as X,RepeatWrapping as B}from"three";var b=16,L=class{loader;constructor(){this.loader=new X}isSupported(e){let t=e.split(".").pop()?.toLowerCase();return["png","jpg","jpeg","gif","webp","bmp","tga"].includes(t||"")}async load(e,t){let r=await this.loader.loadAsync(e,a=>{t?.onProgress&&a.lengthComputable&&t.onProgress(a.loaded/a.total)});return t?.repeat&&r.repeat.copy(h(t.repeat,p)),r.wrapS=t?.wrapS??B,r.wrapT=t?.wrapT??B,t?.colorSpace!==void 0&&(r.colorSpace=t.colorSpace),r.anisotropy=t?.anisotropy??b,r}clone(e){let t=e.clone();return t.anisotropy=e.anisotropy||b,t.needsUpdate=!0,t}};import{GLTFLoader as J}from"three/addons/loaders/GLTFLoader.js";import{DRACOLoader as K}from"three/addons/loaders/DRACOLoader.js";import{KTX2Loader as Z}from"three/addons/loaders/KTX2Loader.js";import{MeshoptDecoder as $}from"three/addons/libs/meshopt_decoder.module.js";import{Mesh as j}from"three";import{clone as W}from"three/addons/utils/SkeletonUtils.js";function u(s){let e=W(s),t=[],r=[];s.traverse(a=>t.push(a)),e.traverse(a=>r.push(a));for(let a=0;a<t.length;a++){let o=t[a],n=r[a];!(o instanceof j)||!(n instanceof j)||(o.geometry?.clone&&(n.geometry=o.geometry.clone()),o.material&&(n.material=Array.isArray(o.material)?o.material.map(i=>i.clone()):o.material.clone()))}return e}function I(s){let e=s.indexOf("?"),t=s.indexOf("#"),r=[e,t].filter(a=>a>=0).reduce((a,o)=>Math.min(a,o),s.length);return s.slice(0,r)}function c(s){let e=I(s),t=e.lastIndexOf("/"),r=t>=0?e.slice(t+1):e,a=r.lastIndexOf(".");return a<0||a===r.length-1?null:r.slice(a+1).toLowerCase()}var V=["map","normalMap","roughnessMap","metalnessMap","emissiveMap","aoMap"],H="https://www.gstatic.com/draco/v1/decoders/",g=class{loader;dracoLoader;ktx2Loader=null;meshoptEnabled=!1;configuredRenderer=null;ktx2TranscoderPath=null;constructor(){this.dracoLoader=new K,this.dracoLoader.setDecoderPath(H),this.loader=new J,this.loader.setDRACOLoader(this.dracoLoader),this.setMeshoptEnabled(!0)}isSupported(e){let t=c(e);return["gltf","glb"].includes(t||"")}async configureRuntime({meshopt:e=!0,ktx2TranscoderPath:t,renderer:r=null}={}){this.setMeshoptEnabled(e!==!1);let a=this.normalizeTranscoderPath(t);if(!a){this.clearKTX2Loader();return}if(!r)throw new Error("GLTFLoaderAdapter.configureRuntime requires a renderer when ktx2TranscoderPath is provided.");(!this.ktx2Loader||this.ktx2TranscoderPath!==a)&&(this.clearKTX2Loader(),this.ktx2Loader=new Z,this.ktx2Loader.setTranscoderPath(a),this.loader.setKTX2Loader(this.ktx2Loader),this.ktx2TranscoderPath=a,this.configuredRenderer=null),!(!this.ktx2Loader||this.configuredRenderer===r)&&(this.ktx2Loader.detectSupport(r),this.configuredRenderer=r)}async load(e,t){return t?.useAsyncFetch?this.loadWithAsyncFetch(e,t):this.loadMainThread(e,t)}async loadWithAsyncFetch(e,t){try{let r=await fetch(e);if(!r.ok)throw new Error(`Failed to fetch ${e}: ${r.status} ${r.statusText}`);let a=await r.arrayBuffer(),o=await this.loader.parseAsync(a,e);return this.applyTextureAnisotropy(o.scene),{object:o.scene,animations:o.animations,gltf:o}}catch(r){return console.error(`Async fetch GLTF load failed for ${e}, falling back to loader.load():`,r),this.loadMainThread(e,t)}}async loadMainThread(e,t){return new Promise((r,a)=>{this.loader.load(e,o=>{this.applyTextureAnisotropy(o.scene),r({object:o.scene,animations:o.animations,gltf:o})},o=>{t?.onProgress&&o.lengthComputable&&t.onProgress(o.loaded/o.total)},o=>a(o))})}clone(e){return{object:u(e.object),animations:e.animations?.map(t=>t.clone()),gltf:e.gltf}}applyTextureAnisotropy(e){e.traverse(t=>{let r=t.material;if(!r)return;let a=Array.isArray(r)?r:[r];for(let o of a)for(let n of V){let i=o[n];if(i&&i.isTexture){let d=i;d.anisotropy=b,d.needsUpdate=!0}}})}setMeshoptEnabled(e){if(e){if(this.meshoptEnabled)return;this.loader.setMeshoptDecoder($),this.meshoptEnabled=!0;return}this.meshoptEnabled&&(this.loader.setMeshoptDecoder(void 0),this.meshoptEnabled=!1)}clearKTX2Loader(){this.ktx2Loader&&(this.ktx2Loader.dispose(),this.ktx2Loader=null),this.loader.setKTX2Loader(void 0),this.configuredRenderer=null,this.ktx2TranscoderPath=null}normalizeTranscoderPath(e){if(!e)return null;let t=String(e);return t.endsWith("/")?t:`${t}/`}};import{FBXLoader as _}from"three/addons/loaders/FBXLoader.js";var T=class{loader;constructor(){this.loader=new _}isSupported(e){return c(e)==="fbx"}async load(e,t){return t?.useAsyncFetch?this.loadWithAsyncFetch(e,t):this.loadMainThread(e,t)}async loadWithAsyncFetch(e,t){try{let r=await fetch(e);if(!r.ok)throw new Error(`Failed to fetch ${e}: ${r.status} ${r.statusText}`);let a=await r.arrayBuffer(),o=this.loader.parse(a,e);return{object:o,animations:o.animations||[]}}catch(r){return console.error(`Async fetch FBX load failed for ${e}, falling back to loader.load():`,r),this.loadMainThread(e,t)}}async loadMainThread(e,t){return new Promise((r,a)=>{this.loader.load(e,o=>{r({object:o,animations:o.animations||[]})},o=>{t?.onProgress&&o.lengthComputable&&t.onProgress(o.loaded/o.total)},o=>a(o))})}clone(e){return{object:u(e.object),animations:e.animations?.map(t=>t.clone())}}};import{OBJLoader as z}from"three/addons/loaders/OBJLoader.js";import{MTLLoader as Y}from"three/addons/loaders/MTLLoader.js";var y=class{loader;mtlLoader;constructor(){this.loader=new z,this.mtlLoader=new Y}isSupported(e){return c(e)==="obj"}async load(e,t){return t?.mtlPath&&await this.loadMTL(t.mtlPath),new Promise((r,a)=>{this.loader.load(e,o=>{r({object:o,animations:[]})},o=>{t?.onProgress&&o.lengthComputable&&t.onProgress(o.loaded/o.total)},o=>a(o))})}async loadMTL(e){return new Promise((t,r)=>{this.mtlLoader.load(e,a=>{a.preload(),this.loader.setMaterials(a),t()},void 0,a=>r(a))})}clone(e){return{object:u(e.object),animations:[]}}};import{AudioLoader as q}from"three";var x=class{loader;constructor(){this.loader=new q}isSupported(e){let t=c(e);return["mp3","ogg","wav","flac","aac","m4a"].includes(t||"")}async load(e,t){return new Promise((r,a)=>{this.loader.load(e,o=>r(o),o=>{t?.onProgress&&o.lengthComputable&&t.onProgress(o.loaded/o.total)},o=>a(o))})}};import{FileLoader as Q}from"three";var m=class{loader;constructor(){this.loader=new Q}isSupported(e){return!0}async load(e,t){let r=t?.responseType??"text";return this.loader.setResponseType(r),new Promise((a,o)=>{this.loader.load(e,n=>a(n),n=>{t?.onProgress&&n.lengthComputable&&t.onProgress(n.loaded/n.total)},n=>o(n))})}},M=class{fileLoader;constructor(){this.fileLoader=new m}isSupported(e){return c(e)==="json"}async load(e,t){return await this.fileLoader.load(e,{...t,responseType:"json"})}};var w=class s{static instance=null;textureCache=new Map;modelCache=new Map;audioCache=new Map;fileCache=new Map;jsonCache=new Map;pendingGLTFRuntimePath=null;pendingGLTFRuntimePromise=null;pendingGLTFRuntimeResolve=null;textureLoader;gltfLoader;fbxLoader;objLoader;audioLoader;fileLoader;jsonLoader;loadingManager;events;stats={texturesLoaded:0,modelsLoaded:0,audioLoaded:0,filesLoaded:0,cacheHits:0,cacheMisses:0};constructor(){this.textureLoader=new L,this.gltfLoader=new g,this.fbxLoader=new T,this.objLoader=new y,this.audioLoader=new x,this.fileLoader=new m,this.jsonLoader=new M,this.loadingManager=new ee,this.loadingManager.onProgress=(e,t,r)=>{this.events.emit("batch:progress",{loaded:t,total:r})},this.events=R(),k.enabled=!0}static getInstance(){return s.instance||(s.instance=new s),s.instance}static resetInstance(){s.instance&&(s.instance.clearCache(),s.instance=null)}async loadTexture(e,t){return this.loadWithCache(e,"texture",this.textureCache,()=>this.textureLoader.load(e,t),t,r=>{if(!t?.clone)return r;let a=this.textureLoader.clone(r);return t.repeat&&a.repeat.copy(h(t.repeat,p)),t.wrapS!==void 0&&(a.wrapS=t.wrapS),t.wrapT!==void 0&&(a.wrapT=t.wrapT),a})}async loadGLTF(e,t){return await this.waitForPreparedGLTFRuntime(),this.loadWithCache(e,"gltf",this.modelCache,()=>this.gltfLoader.load(e,t),t,r=>t?.clone?this.gltfLoader.clone(r):r)}prepareGLTFRuntime(e){let t=this.normalizeTranscoderPath(e?.ktx2TranscoderPath);t&&(this.pendingGLTFRuntimePath===t&&this.pendingGLTFRuntimePromise||(this.pendingGLTFRuntimePath=t,this.pendingGLTFRuntimePromise||(this.pendingGLTFRuntimePromise=new Promise(r=>{this.pendingGLTFRuntimeResolve=r}))))}async configureGLTFRuntime(e){await this.gltfLoader.configureRuntime(e);let t=this.normalizeTranscoderPath(e?.ktx2TranscoderPath);t&&e?.renderer&&this.resolvePreparedGLTFRuntime(t)}async loadFBX(e,t){return this.loadWithCache(e,"fbx",this.modelCache,()=>this.fbxLoader.load(e,t),t,r=>t?.clone?this.fbxLoader.clone(r):r)}async loadOBJ(e,t){let r=t?.mtlPath?`${e}:${t.mtlPath}`:e;return this.loadWithCache(r,"obj",this.modelCache,()=>this.objLoader.load(e,t),t,a=>t?.clone?this.objLoader.clone(a):a)}async loadModel(e,t){let r=c(e);switch(r){case"gltf":case"glb":return this.loadGLTF(e,t);case"fbx":return this.loadFBX(e,t);case"obj":return this.loadOBJ(e,t);default:throw new Error(`Unsupported model format: ${r}`)}}async loadAudio(e,t){return this.loadWithCache(e,"audio",this.audioCache,()=>this.audioLoader.load(e,t),t)}async loadFile(e,t){let r=t?.responseType?`${e}:${t.responseType}`:e;return this.loadWithCache(r,"file",this.fileCache,()=>this.fileLoader.load(e,t),t)}async loadJSON(e,t){return this.loadWithCache(e,"json",this.jsonCache,()=>this.jsonLoader.load(e,t),t)}async loadBatch(e){let t=new Map,r=e.map(async a=>{try{let o;switch(a.type){case"texture":o=await this.loadTexture(a.url,a.options);break;case"gltf":o=await this.loadGLTF(a.url,a.options);break;case"fbx":o=await this.loadFBX(a.url,a.options);break;case"obj":o=await this.loadOBJ(a.url,a.options);break;case"audio":o=await this.loadAudio(a.url,a.options);break;case"file":o=await this.loadFile(a.url,a.options);break;case"json":o=await this.loadJSON(a.url,a.options);break;default:throw new Error(`Unknown asset type: ${a.type}`)}t.set(a.url,o)}catch(o){throw this.events.emit("asset:error",{url:a.url,type:a.type,error:o}),o}});return await Promise.all(r),this.events.emit("batch:complete",{urls:e.map(a=>a.url)}),t}async preload(e){await this.loadBatch(e)}isCached(e){return this.textureCache.has(e)||this.modelCache.has(e)||this.audioCache.has(e)||this.fileCache.has(e)||this.jsonCache.has(e)}clearCache(e){e?(this.textureCache.delete(e),this.modelCache.delete(e),this.audioCache.delete(e),this.fileCache.delete(e),this.jsonCache.delete(e)):(this.textureCache.clear(),this.modelCache.clear(),this.audioCache.clear(),this.fileCache.clear(),this.jsonCache.clear(),k.clear(),this.pendingGLTFRuntimePath=null,this.pendingGLTFRuntimePromise=null,this.pendingGLTFRuntimeResolve=null)}getStats(){return{...this.stats}}on(e,t){this.events.on(e,t)}off(e,t){this.events.off(e,t)}async loadWithCache(e,t,r,a,o,n){o?.forceReload&&r.delete(e);let i=r.get(e);if(i){this.stats.cacheHits++,this.events.emit("asset:loaded",{url:e,type:t,fromCache:!0});let l=await i.promise;return n?n(l):l}this.stats.cacheMisses++,this.events.emit("asset:loading",{url:e,type:t});let d=a(),f={promise:d,loadedAt:Date.now()};r.set(e,f);try{let l=await d;return f.result=l,this.updateStats(t),this.events.emit("asset:loaded",{url:e,type:t,fromCache:!1}),n?n(l):l}catch(l){throw r.delete(e),this.events.emit("asset:error",{url:e,type:t,error:l}),l}}updateStats(e){switch(e){case"texture":this.stats.texturesLoaded++;break;case"gltf":case"fbx":case"obj":this.stats.modelsLoaded++;break;case"audio":this.stats.audioLoaded++;break;case"file":case"json":this.stats.filesLoaded++;break}}async waitForPreparedGLTFRuntime(){this.pendingGLTFRuntimePromise&&await this.pendingGLTFRuntimePromise}resolvePreparedGLTFRuntime(e){this.pendingGLTFRuntimePath&&this.pendingGLTFRuntimePath!==e||(this.pendingGLTFRuntimeResolve?.(),this.pendingGLTFRuntimeResolve=null,this.pendingGLTFRuntimePromise=null,this.pendingGLTFRuntimePath=null)}normalizeTranscoderPath(e){if(!e)return null;let t=String(e);return t.endsWith("/")?t:`${t}/`}},A=w.getInstance();import{uniform as vt,uv as Ot,time as wt,vec3 as At,vec4 as Ft,float as Pt,Fn as St}from"three/tsl";function ae(s){return"colorNode"in s}function N(s){return"fragment"in s&&"vertex"in s}function oe(s){return!!s&&N(s)&&s.vertex===O.vertex&&s.fragment===O.fragment}var U=class s{static sharedMaterialMap=new Map;static clearSharedMaterialCache(){s.sharedMaterialMap.clear()}materials=[];useTSL;constructor(e=!0){this.useTSL=e}trackSharedMaterial(e,t){let r=E(G(e)),a=s.sharedMaterialMap.get(r);if(a){let o=a.geometryMap.get(t);o?a.geometryMap.set(t,o+1):a.geometryMap.set(t,1)}else s.sharedMaterialMap.set(r,{geometryMap:new Map([[t,1]]),material:this.materials[0]})}build(e,t){let{path:r,normalMap:a,repeat:o,color:n,shader:i,opacity:d}=e,f=oe(i),l=!!i&&!f,S=!!r&&(!i||f);S?this.setTexture(r??null,o,!0,d,n):l&&i?ae(i)?this.setTSLShader(i,d):N(i)&&(console.warn("MaterialBuilder: GLSL shaders are not supported on the WebGPU renderer. Author custom shaders as TSL (ZylemTSLShader). Falling back to a default node material."),this.setColor(n??new F("#ffffff"),!0,d)):r&&this.setTexture(r,o,!0,d,n),n&&!S&&!l&&this.withColor(n,!0,d),this.materials.length===0&&this.setColor(new F("#ffffff"),!0,d),a&&this.materials.length>0&&this.setNormalMap(a,o),this.trackSharedMaterial(e,t)}withColor(e,t=!1,r){return this.setColor(e,t,r),this}withShader(e,t){return this.setShader(e,t),this}withTSLShader(e,t){return this.setTSLShader(e,t),this}applyOpacity(e,t,r=!1){t!==void 0&&(e.opacity=t),e.transparent=r||t!==void 0&&t<1,e.needsUpdate=!0}setTexture(e=null,t=p,r=!0,a,o){if(!e)return;let n=new P;o&&(n.color=o),this.applyOpacity(n,a),this.materials.push(n),A.loadTexture(e,{clone:!0,repeat:h(t,p),colorSpace:te}).then(i=>{i.wrapS=v,i.wrapT=v,n.map=i,n.needsUpdate=!0})}setNormalMap(e,t=p){let r=this.materials[this.materials.length-1];r&&A.loadTexture(e,{clone:!0,repeat:h(t,p)}).then(a=>{a.wrapS=v,a.wrapT=v,r instanceof P&&(r.normalMap=a,r.needsUpdate=!0)})}setColor(e,t=!0,r){let a=new P;a.color=e,this.applyOpacity(a,r),this.materials.push(a)}setShader(e,t){console.warn("MaterialBuilder.setShader: GLSL shaders are not supported on the WebGPU renderer. Author custom shaders as TSL (ZylemTSLShader). Falling back to a default node material."),this.setColor(new F("#ffffff"),!0,t)}setTSLShader(e,t){this.materials.push(se(e,t))}};function se(s,e){let t=new re;return t.colorNode=s.colorNode,s.positionNode&&(t.positionNode=s.positionNode),s.normalNode&&(t.normalNode=s.normalNode),s.blending!==void 0&&(t.blending=s.blending),s.side!==void 0&&(t.side=s.side),s.depthTest!==void 0&&(t.depthTest=s.depthTest),e!==void 0&&(t.opacity=e),t.transparent=!!s.transparent||e!==void 0&&e<1,t.needsUpdate=!0,t}export{C as a,O as b,b as c,c as d,A as e,G as f,E as g,ae as h,N as i,U as j,se as k,vt as l,Ot as m,wt as n,At as o,Ft as p,Pt as q,St as r};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{a as u}from"./chunk-VS2D4B3W.js";import{DirectionalLight as b,PerspectiveCamera as f,RenderTarget as T,Scene as E,Color as v,LinearFilter as g}from"three";var w=128,h=class{cache=new Map;inFlight=new Map;renderer=null;size;constructor(e=w){this.size=e}setRenderer(e){this.renderer=e}get(e){return this.cache.get(e)??null}invalidate(e){this.cache.delete(e),this.inFlight.delete(e)}clear(){this.cache.clear(),this.inFlight.clear()}async ensure(e,i){let t=this.cache.get(e);if(t)return t;let r=this.inFlight.get(e);if(r)return r;if(!i||!this.renderer)return null;let s=this.render(e,i).then(n=>(this.inFlight.delete(e),n?(this.cache.set(e,n),n):null)).catch(n=>(this.inFlight.delete(e),console.warn("EntityThumbnailCache: failed to render thumbnail",e,n),null));return this.inFlight.set(e,s),s}async render(e,i){let t=this.renderer;if(!t)return null;let r=new E;r.background=new v(3815994);let s=new b(16777215,2);s.position.set(5,10,7),r.add(s);let n=i.clone(!0);n.position.set(0,0,0),n.rotation.set(0,0,0),n.updateMatrixWorld(!0),r.add(n);let a=new f(50,1,.1,100),l=u(n,a),o=new T(this.size,this.size,{minFilter:g,magFilter:g}),m=t.getRenderTarget(),p=t.getScissorTest();try{t.setScissorTest(!1),t.setRenderTarget(o),t.render(r,a)}finally{t.setRenderTarget(m),t.setScissorTest(p)}let y=await t.readRenderTargetPixelsAsync(o,0,0,this.size,this.size);o.dispose(),r.remove(n);let d=R(y,this.size,this.size);return d?{uuid:e,dataUrl:d,bounds:{width:l.width,height:l.height,depth:l.depth}}:null}},D=new h;function R(c,e,i){if(typeof document>"u")return null;let t=document.createElement("canvas");t.width=e,t.height=i;let r=t.getContext("2d");if(!r)return null;let s=c instanceof Uint8Array?c:new Uint8Array(c.buffer,c.byteOffset,c.byteLength),n=r.createImageData(e,i);for(let a=0;a<i;a+=1){let l=(i-1-a)*e*4,o=a*e*4;n.data.set(s.subarray(l,l+e*4),o)}return r.putImageData(n,0,0),t.toDataURL("image/png")}export{h as a,D as b};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{a as s,b as d}from"./chunk-4QLJUQSJ.js";import{c as i,d as c}from"./chunk-7WRQ2UAN.js";import{Color as f,Vector3 as y}from"three";import{proxy as x,subscribe as k}from"valtio/vanilla";import{Color as V,Vector3 as b}from"three";var m=new V("#0333EC");var S=new b(i.x,i.y,i.z),E=new b(c.x,c.y,c.z);var Z={backgroundColor:m,backgroundImage:null,backgroundShader:null,inputs:{p1:["gamepad-1","keyboard"],p2:["gamepad-2","keyboard"]},gravity:new y(0,0,0),variables:{},physicsRate:60,defaultLighting:!0,entities:[]},l=x({backgroundColor:new f(f.NAMES.cornflowerblue),backgroundImage:null,inputs:{p1:["gamepad-1","keyboard-1"],p2:["gamepad-2","keyboard-2"]},variables:{},gravity:new y(0,0,0),entities:[]}),A=e=>{l.backgroundColor=e},P=e=>{l.backgroundImage=e},G=e=>{l.variables={...e}},O=()=>{l.variables={}},u=new Map;function g(e){let t=u.get(e);return t||(t=x({}),u.set(e,t)),t}function z(e,t,r){let o=g(e);d(o,t,r)}function M(e,t,r){let o=g(e),a=s(o,t);return a===void 0?(d(o,t,r),r):a}function N(e,t){let r=u.get(e);if(r)return s(r,t)}function _(e,t,r){let o=g(e),a=s(o,t);return k(o,()=>{let n=s(o,t);n!==a&&(a=n,r(n))})}function D(e,t,r){let o=g(e),a=t.map(n=>s(o,n));return k(o,()=>{let n=t.map(p=>s(o,p));n.some((p,C)=>p!==a[C])&&(a=n,r(n))})}function L(e){u.delete(e)}export{m as a,Z as b,l as c,A as d,P as e,G as f,O as g,z as h,M as i,N as j,_ as k,D as l,L as m};
|
|
File without changes
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{c as s,d as r,h as n}from"./chunk-7WRQ2UAN.js";import{StageBodyKind as l}from"@zylem/behaviors/core";var f=new Map,u=0;function c(e){let i=f.get(e);return i===void 0&&(i=u++%16,f.set(e,i)),i}function p(e){let i=0;return e.forEach(o=>{let t=c(o);i|=1<<t}),i}function d(e,i){if(!e)return 4294967295;let o=c(e),t=i?p(i):65535;return(1<<o&65535)<<16|t&65535}var a=class{static=!1;sensor=!1;build(i){let o=this.bodyDesc({isDynamicBody:!this.static}),t=this.collider(i);return this.sensor&&(t.sensor=!0),i.collisionType&&(t.collisionGroups=d(i.collisionType,i.collisionFilter)),[o,t]}withCollision(i){return this.sensor=i?.sensor??this.sensor,this.static=i?.static??this.static,this}collider(i){let o=n(i.size,r),t=n(i.position,s);return{shape:{type:"box",halfExtents:[o.x/2,o.y/2,o.z/2]},offset:[t.x,t.y,t.z]}}bodyDesc({isDynamicBody:i=!0}){return{kind:i?l.Dynamic:l.Static,position:[0,0,0],gravityScale:1,canSleep:!1,ccdEnabled:!0}}};export{d as a,a as b};
|