@zylem/game-lib 0.8.3 → 0.8.6
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/actions.d.ts +7 -5
- package/dist/api/game-lib.api.json +3564 -395
- package/dist/api/game-lib.api.md +196 -12
- package/dist/api/game-lib.d.ts +547 -14
- package/dist/api/game-lib.typedoc.json +213478 -129350
- package/dist/base-node-idopiSw5.d.ts +96 -0
- package/dist/bridge.d.ts +41 -5
- package/dist/bridge.js +1 -1
- package/dist/catalog.d.ts +77 -0
- package/dist/catalog.js +1 -0
- package/dist/{chunk-CM5YRNBJ.js → chunk-7NYP4YAG.js} +1 -1
- package/dist/chunk-AE3CTVHY.js +1 -0
- package/dist/chunk-BCFFS3FP.js +1 -0
- package/dist/chunk-BMRFDDMR.js +1 -0
- package/dist/chunk-DECK4UEC.js +1 -0
- package/dist/chunk-DQQA3VJH.js +1 -0
- package/dist/chunk-FYQNZCIP.js +1 -0
- package/dist/chunk-GHJQ2HKI.js +1 -0
- package/dist/chunk-LD4KDRYL.js +24 -0
- package/dist/chunk-MXO4VGDB.js +1 -0
- package/dist/chunk-Q2YDBMVY.js +19 -0
- package/dist/chunk-QDQ4QMAI.js +1 -0
- package/dist/{chunk-TV3AZKT4.js → chunk-QVIUZEYA.js} +1 -1
- package/dist/chunk-SAQA4SXW.js +1 -0
- package/dist/chunk-VJZMSBKP.js +1 -0
- package/dist/{chunk-YAOXFYOD.js → chunk-WBQ5TNRZ.js} +1 -1
- package/dist/chunk-YOVE25NW.js +1 -0
- package/dist/{collision-builder-B_tm8OVy.d.ts → collision-builder-BckxkdmA.d.ts} +1 -1
- package/dist/core.d.ts +14 -11
- package/dist/core.js +1 -1
- package/dist/debug-state-B5awuDHl.d.ts +89 -0
- package/dist/debug.d.ts +200 -7
- package/dist/debug.js +1 -1
- package/dist/{entity-B9yZeBm4.d.ts → entity-BIf_a4dl.d.ts} +1 -1
- package/dist/{entity-BGEq1yfC.d.ts → entity-XZNGBeca.d.ts} +32 -98
- package/dist/{entity-type-map-CW6RHQkx.d.ts → entity-type-map-CkkFMSrL.d.ts} +42 -7
- package/dist/entity.d.ts +9 -7
- package/dist/entity.js +1 -1
- package/dist/{game-NHkubIfI.d.ts → game-Cy8f6gJm.d.ts} +181 -17
- package/dist/game-default-F3KPYZ7X.js +1 -0
- package/dist/graphics.d.ts +6 -5
- package/dist/graphics.js +1 -1
- package/dist/{material-DbSuZBbP.d.ts → material-CxxAyJYp.d.ts} +1 -1
- package/dist/public.d.ts +12 -10
- package/dist/public.js +1 -1
- package/dist/runtime.d.ts +3 -3
- package/dist/runtime.js +1 -1
- package/dist/{vector-DN6zlPoE.d.ts → simulation-body-zQw-emOr.d.ts} +11 -42
- package/dist/vector-D3eDzvcA.d.ts +41 -0
- package/dist/web-components.d.ts +12 -9
- package/dist/web-components.js +1 -1
- package/dist/{zylem-camera-Du2UPW9O.d.ts → zylem-camera-DZTpPOiD.d.ts} +12 -1
- package/package.json +21 -16
- package/LICENSE +0 -21
- package/dist/chunk-2VSVOPQN.js +0 -19
- package/dist/chunk-3I537JFL.js +0 -1
- package/dist/chunk-C5NEGC3S.js +0 -1
- package/dist/chunk-CV75NSES.js +0 -1
- package/dist/chunk-GKHAJ3MW.js +0 -1
- package/dist/chunk-LGS5N5M4.js +0 -1
- package/dist/chunk-LKFF6XJC.js +0 -1
- package/dist/chunk-Q27ULMXY.js +0 -24
- package/dist/chunk-W5SXED5T.js +0 -1
- package/dist/chunk-WVSYUWTT.js +0 -1
- package/dist/debug-state-Dp9CQQZ4.d.ts +0 -49
- package/dist/game-default-5TB3T5N7.js +0 -1
- /package/dist/{chunk-DFLI7ICU.js → chunk-MSCVL5OK.js} +0 -0
package/dist/public.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{a as s,b as n,c as l,d as S,e as h,f as y,g as L,h as v,i as Z,j as b,k as g,l as u,m as T,n as j,o as F,p as W,q as k,r as w,s as z,t as B,u as D,v as E,w as G}from"./chunk-QB3NL7VQ.js";import"./chunk-BIGH6D34.js";import"./chunk-DFLI7ICU.js";import{a as _a,b as $a,c as op}from"./chunk-HNCTOJP7.js";import{a as rp}from"./chunk-TV3AZKT4.js";import{a as ep,b as tp,c as mp,d as ap,e as pp,f as fp,g as xp,h as ip,i as dp,j as cp,k as sp,l as np,m as lp,n as Sp,o as hp,p as yp}from"./chunk-47DG7I7M.js";import{A as Ip,B as Jp,C as Kp,a as Lp,b as vp,c as Zp,d as bp,e as gp,f as up,g as Tp,h as jp,i as Fp,j as Wp,k as kp,l as wp,m as zp,n as Bp,o as Dp,p as Ep,q as Gp,r as Mp,s as Np,t as Op,u as Pp,v as Vp,w as qp,x as Ap,y as Cp,z as Hp}from"./chunk-JNFFTNMH.js";import{a as ho,b as yo,c as Lo,d as vo,e as Wo,f as Jr,g as Kr,h as me,i as ae,j as pe,k as fe,l as xe,m as ie,n as de,o as ce}from"./chunk-Q27ULMXY.js";import{a as So,c as Go,d as Mo,e as No,f as Tr,g as jr,h as Br,i as Dr,k as Er,l as Gr,m as Mr,n as Nr,o as Or,p as Pr,q as Vr,r as qr,s as Ar,t as Hr,v as Ir}from"./chunk-WVSYUWTT.js";import{a as Eo}from"./chunk-7GYFZKK7.js";import{a as oo,b as ro}from"./chunk-2VSVOPQN.js";import"./chunk-C5NEGC3S.js";import{c as Do}from"./chunk-GKHAJ3MW.js";import{a as zo,b as Bo}from"./chunk-LKFF6XJC.js";import{a as C,b as H,c as I,e as J,g as K,h as Q,i as R,j as U,k as X,m as Y,n as _,o as $}from"./chunk-W5SXED5T.js";import{b as Zr}from"./chunk-YAOXFYOD.js";import{A as Pe,B as Ve,C as qe,D as Ae,E as Ce,F as He,G as Ie,H as Je,I as Ke,J as Qe,K as Re,L as Ue,M as Xe,N as Ye,O as _e,P as $e,Q as ot,R as rt,a as se,b as ne,c as le,d as Se,e as he,f as ye,g as Le,h as ve,i as Ze,j as be,k as ge,l as ue,m as Te,n as je,o as Fe,p as We,q as ke,r as we,s as ze,t as Be,u as De,v as Ee,w as Ge,x as Me,y as Ne,z as Oe}from"./chunk-CV75NSES.js";import{b as Qr,c as Rr,d as Ur,e as Xr,f as Yr,g as _r,h as $r,i as oe,j as re,k as ee,m as te}from"./chunk-LGS5N5M4.js";import{A as vr,B as br,C as gr,D as ur,c as fr,d as xr,e as ir,f as dr,g as cr,h as sr,i as nr,j as lr,s as Sr,u as hr,y as yr,z as Lr}from"./chunk-3I537JFL.js";import{a as o,b as r,h as e,i as t,k as m,l as a,m as p,n as f,o as x,p as i,q as d,r as c}from"./chunk-CM5YRNBJ.js";import{a as ko,b as wo}from"./chunk-AIQ6IVT5.js";import"./chunk-QXVH6POE.js";import{b as pr}from"./chunk-EVYHPR3J.js";import{$ as rm,$a as ra,A as kt,Aa as km,B as wt,Ba as wm,C as zt,Ca as zm,D as Bt,Da as Bm,E as Dt,Ea as Dm,F as Et,Fa as Em,G as Gt,Ga as Gm,H as Mt,Ha as Mm,I as Nt,Ia as Nm,J as Ot,Ja as Om,K as Pt,Ka as Pm,L as Vt,La as Vm,M as qt,Ma as qm,N as At,Na as Am,O as Ct,Oa as Cm,P as Ht,Pa as Hm,Q as It,Qa as Im,R as Jt,Ra as Jm,S as Kt,Sa as Km,T as Qt,Ta as Qm,U as Rt,Ua as Rm,V as Ut,Va as Um,W as Xt,Wa as Xm,X as Yt,Xa as Ym,Y as _t,Ya as _m,Z as $t,Za as $m,_ as om,_a as oa,a as et,aa as em,ab as ea,b as tt,ba as tm,bb as ta,c as mt,ca as mm,cb as ma,d as at,da as am,db as aa,e as pt,ea as pm,eb as pa,f as ft,fa as fm,fb as fa,g as xt,ga as xm,gb as xa,h as it,ha as im,hb as ia,i as dt,ia as dm,ib as da,j as ct,ja as cm,k as st,ka as sm,l as nt,la as nm,m as lt,ma as lm,n as St,na as Sm,o as ht,oa as hm,p as yt,pa as ym,q as Lt,qa as Lm,r as vt,ra as vm,s as Zt,sa as Zm,t as bt,ta as bm,u as gt,ua as gm,v as ut,va as um,w as Tt,wa as Tm,x as jt,xa as jm,y as Ft,ya as Fm,z as Wt,za as Wm}from"./chunk-XK63E4SX.js";import{a as ca,b as sa,c as na}from"./chunk-ZRT3ZQVH.js";import{a as la,b as Sa,c as ha,d as ya}from"./chunk-WQ3WMMZD.js";import{h as Fr,i as Wr,j as kr,k as wr,l as zr}from"./chunk-D2PATZCC.js";import{e as M,f as N,g as O,h as P,i as V,j as q,m as A}from"./chunk-4QLJUQSJ.js";import{a as Oo,b as Po,c as Vo,d as qo,g as Ao,h as Co,i as Ho,j as Io}from"./chunk-7WRQ2UAN.js";import{A as Ia,B as Ja,C as Ka,D as Qa,E as Ra,a as La,b as va,c as Za,d as ba,e as ga,f as ua,g as Ta,h as ja,i as Fa,j as Wa,k as ka,l as wa,m as za,n as Ba,o as Da,p as Ea,q as Ga,r as Ma,s as Na,t as Oa,u as Pa,v as Va,w as qa,x as Aa,y as Ca,z as Ha}from"./chunk-IPWUDOV5.js";import{a as Cr}from"./chunk-BH53MBAZ.js";import{a as Jo,b as Ko,c as Qo,d as Ro,e as Uo,f as Xo,g as Yo,h as _o,i as $o,j as or,k as rr,l as er,m as tr,n as mr,o as ar}from"./chunk-XRP4JJXL.js";import{a as Ua,b as Xa,c as Ya}from"./chunk-7QF6YTEZ.js";import"./chunk-ORIDWL3T.js";import{a as Zo,b as bo,c as go,d as uo,e as To,f as jo,g as Fo}from"./chunk-PCFF4LLO.js";import{a as eo,b as to,c as mo,d as ao,e as po,f as fo,g as xo,h as io,i as co,j as so,k as no,l as lo}from"./chunk-UG22Z42P.js";export{yr as ACTOR_TYPE,ho as AspectRatio,Le as BOX_TYPE,op as BRIDGE_READY_EVENT,et as BoundaryRicochet3DCoordinator,tt as BoundaryRicochetCoordinator,Ne as CONE_TYPE,Ce as CYLINDER_TYPE,Pr as CameraManager,Er as CameraPipeline,Vr as CameraWrapper,Vp as ColorJsonSchema,mt as CooldownBehavior,Ee as DISK_TYPE,at as Destructible3DBehavior,pt as DestructibleMesh,jp as EntityJsonSchema,vp as EntitySchema,oo as EntityThumbnailCache,ko as EventEmitterDelegate,br as FOG_TYPE,ft as FirstPersonBehavior,xt as FirstPersonEvent,it as FirstPersonFSM,Nr as FirstPersonPerspective,st as FirstPersonPresentation,dt as FirstPersonShooterCoordinator,ct as FirstPersonState,Mr as Fixed2DPerspective,c as Fn,nt as FractureOptions,me as Game,Do as GameBridge,Kp as GameConfigJsonSchema,Jp as GameDeviceConfigJsonSchema,Pp as GameInputConfigSchema,Op as GameInputPlayerConfigSchema,na as Howl,lt as Jumper2DBehavior,St as Jumper2DEvent,ht as Jumper2DFSM,yt as Jumper2DState,Lt as Jumper3DBehavior,vt as Jumper3DEvent,Zt as Jumper3DFSM,bt as Jumper3DState,Wp as KeyboardMappingSchema,Ye as LIGHT_TYPE,$r as LINE_TYPE,up as LineEntityDataSchema,Np as MouseConfigSchema,kp as MouseMappingSchema,gt as MultidirectionalSpaceShooterCoordinator,Re as PARTICLE_SYSTEM_TYPE,Je as PILL_TYPE,Te as PLANE_TYPE,Ve as PYRAMID_TYPE,ut as ParticleEmitterBehavior,Dr as Perspectives,Tt as Platformer2DBehavior,jt as Platformer2DEvent,Ft as Platformer2DFSM,Wt as Platformer2DState,kt as Platformer3DBehavior,wt as Platformer3DEvent,zt as Platformer3DFSM,Bt as Platformer3DState,ze as RECT_TYPE,ra as RUNTIME_BOUNDARY_2D_BEHAVIOR_KEY,ea as RUNTIME_DYNAMIC_CIRCLE_BODY_2D_BEHAVIOR_KEY,ta as RUNTIME_GOAL_ZONE_2D_BEHAVIOR_KEY,ma as RUNTIME_PLAYER_INPUT_2D_BEHAVIOR_KEY,aa as RUNTIME_RICOCHET_2D_BEHAVIOR_KEY,pa as RUNTIME_TRIGGER_REGION_2D_BEHAVIOR_KEY,Tr as RenderBundleManager,jr as RenderStrategyManager,Ip as ResolutionInputSchema,Dt as Ricochet2DBehavior,Et as Ricochet2DEvent,Gt as Ricochet2DFSM,Mt as Ricochet2DState,Nt as Ricochet3DBehavior,Ot as Ricochet3DEvent,Pt as Ricochet3DFSM,Vt as Ricochet3DState,Um as RuntimeBoundary2DBehavior,Xm as RuntimeDynamicCircleBody2DBehavior,Ym as RuntimeGoalZone2DBehavior,_m as RuntimePlayerInput2DBehavior,$m as RuntimeRicochet2DBehavior,oa as RuntimeTriggerRegion2DBehavior,be as SPHERE_TYPE,Xr as SPRITE_TYPE,fe as STAGE_STATE_CHANGE,qt as ScreenVisibilityBehavior,At as ScreenVisibilityFSM,Ct as ScreenWrapBehavior,Ht as ScreenWrapEvent,It as ScreenWrapFSM,Jt as ScreenWrapState,Kt as Shooter2DBehavior,Zr as SimulationBody,Tp as SpriteEntityDataSchema,Cp as StageAssetLoaderConfigSchema,cp as StageBodyKind,sp as StageBoundaryDim,Hp as StageConfigJsonSchema,np as StageEventType,Ap as StageGLTFAssetLoaderConfigSchema,Fp as StageJsonSchema,Kr as StageManager,lp as StageRicochetDim,Sp as StageRicochetReflection,Zp as StageSchema,hp as StageTopDownPlane,Qr as TEXT_TYPE,bp as TextEntityDataSchema,Gr as ThirdPersonPerspective,Qt as ThrusterBehavior,Rt as ThrusterEvent,Ut as ThrusterFSM,Xt as ThrusterState,Yt as TopDownMovementBehavior,_t as TopDownShooterCoordinator,Po as VEC2_ONE,Oo as VEC2_ZERO,qo as VEC3_ONE,Vo as VEC3_ZERO,qp as Vec3ComponentsSchema,Lp as Vector2Schema,gp as Vector3TupleSchema,Bp as VirtualTouchButtonConfigSchema,Ep as VirtualTouchButtonsConfigSchema,Mp as VirtualTouchConfigSchema,Dp as VirtualTouchJoystickConfigSchema,Gp as VirtualTouchJoysticksConfigSchema,zp as VirtualTouchPositionSchema,wp as VirtualTouchStyleSchema,$t as WorldBoundary2DBehavior,om as WorldBoundary2DEvent,rm as WorldBoundary2DFSM,em as WorldBoundary2DState,tm as WorldBoundary3DBehavior,mm as WorldBoundary3DEvent,am as WorldBoundary3DFSM,pm as WorldBoundary3DState,We as ZONE_TYPE,Lr as ZylemActor,ve as ZylemBox,Oe as ZylemCone,He as ZylemCylinder,Ge as ZylemDisk,gr as ZylemFog,rp as ZylemGameElement,_e as ZylemLight,re as ZylemLine,Ue as ZylemParticleSystem,Ke as ZylemPill,je as ZylemPlane,qe as ZylemPyramid,Be as ZylemRect,ge as ZylemSphere,Yr as ZylemSprite,Rr as ZylemText,ke as ZylemZone,u as abs,$a as announceBridgeReady,Cr as applyTransformChanges,g as asin,b as atan,fa as bindRuntimeDynamicCircleBody2DHandle,fr as boxCollision,se as boxMesh,tp as buildBoxCollider,ap as buildCapsuleCollider,fp as buildConvexHullCollider,pp as buildCylinderCollider,ip as buildHeightfieldCollider,ep as buildRuntimeBody,mp as buildSphereCollider,xp as buildTrimeshCollider,dp as bundleRuntimeCollision,ua as callFunc,L as clamp,A as clearGlobalSubscriptions,fm as computeWorldBoundary2DHits,xm as computeWorldBoundary3DHits,ir as coneCollision,le as coneMesh,Z as cos,Sr as create,vr as createActor,s as createBackgroundShader,Ze as createBox,qr as createCamera,Pe as createCone,ot as createCooldownIcon,Ie as createCylinder,Me as createDisk,hr as createEntity,te as createEntityFactory,im as createFirstPersonInputComponent,dm as createFirstPersonMovementComponent,cm as createFirstPersonStateComponent,ur as createFog,de as createFollowTarget,ae as createGame,N as createGlobal,sm as createJumpConfig2D,nm as createJumpConfig3D,lm as createJumpInput2D,Sm as createJumpInput3D,hm as createJumpState2D,ym as createJumpState3D,$e as createLight,ee as createLine,m as createNodeMaterialFromTSL,Xe as createParticleSystem,Or as createPerspective,Lm as createPhysicsBodyComponent,Qe as createPill,Fe as createPlane,vm as createPlatformer2DInputComponent,Zm as createPlatformer2DMovementComponent,bm as createPlatformer2DStateComponent,gm as createPlatformer3DInputComponent,um as createPlatformer3DMovementComponent,Tm as createPlatformer3DStateComponent,Ae as createPyramid,De as createRect,jm as createShooter2DStateComponent,yp as createSimulation,ue as createSphere,_r as createSprite,Ir as createStage,Ur as createText,Fm as createThrusterInputComponent,Wm as createThrusterMovementComponent,km as createThrusterStateComponent,wm as createTopDownMovementComponent,zm as createTopDownMovementInputComponent,Bm as createTopDownMovementStateComponent,Dm as createTransformComponent,Da as createTransformStore,Wr as createVariable,we as createZone,Eo as crossfadeTransitionShader,cr as cylinderCollision,he as cylinderMesh,C as debugState,Fo as defaultTouchControls,Em as defineBehavior,ga as delay,rt as destroy,ie as dispatchStageState,B as dot,xa as emitRuntimeGoal,ia as emitRuntimeRicochet,da as emitRuntimeTriggerRegionEnter,pe as entitySpawner,ro as entityThumbnailCache,T as exp,Ta as fadeOpacity,Gm as fireCooldown,Mm as fireShooter2DIfRequested,d as float,w as floor,Bo as focusEntity,z as fract,Wo as gameConfig,Nm as getCooldown,Om as getCooldownStore,yo as getDisplayAspect,Pm as getEntityFacingAngle2D,O as getGlobal,q as getGlobals,_ as getHoveredEntity,U as getHoveredEntityId,Aa as getPosition,Lo as getPresetResolution,ar as getRotation,Y as getSelectedEntity,Q as getSelectedEntityId,kr as getVariable,Ca as getVelocity,_a as getZylemBridge,la as globalChange,Sa as globalChanges,Vm as hasAnyWorldBoundary2DHit,qm as hasAnyWorldBoundary3DHit,xe as initStageStateDispatcher,t as isGLSLShader,No as isManagedRenderEntity,e as isTSLShader,So as isWebGPUSupported,uo as joystickBaseSvg,To as joystickThumbSvg,D as length,W as max,lo as mergeInputConfigs,k as min,h as mix,G as mod,Ea as move,va as moveBy,qa as moveForwardXY,Za as moveTo,Ga as moveX,Oa as moveXY,Pa as moveXZ,Ma as moveY,Na as moveZ,S as normalize,Ao as normalizeVec2,Co as normalizeVec3,o as objectVertexShader,P as onGlobalChange,V as onGlobalChanges,Fa as onPress,Wa as onRelease,wr as onVariableChange,zr as onVariableChanges,pr as packCollisionGroups,wa as parallel,vo as parseResolution,Am as particleEffect,Cm as particlePresets,oe as pickZylemLine,sr as pillCollision,ye as pillMesh,sa as pingPongBeep,nr as planeCollision,l as positionWorld,n as positionWorldDirection,j as pow,dr as pyramidCollision,Se as pyramidMesh,Hm as registerCooldown,H as registerDebugEntityResolver,zo as registerEntityFocusContext,za as repeat,Ba as repeatForever,Im as resetCooldown,La as resetEntityOpacity,Va as resetVelocity,Jm as resolveAim2D,go as resolveButtonAccent,I as resolveDebugEntity,Go as resolveRenderCategory,bo as resolveTouchTheme,ca as ricochetSound,ba as rotateBy,Qo as rotateEuler,Jo as rotateInDirection,Uo as rotateX,Ro as rotateY,Ko as rotateYEuler,Xo as rotateZ,Ya as screenCenterLookDeltas,Xa as screenCenterLookTargets,ka as sequence,ce as setCameraFeed,K as setDebugTool,M as setGlobal,X as setHoveredEntityId,J as setPaused,Ha as setPosition,Ia as setPositionX,Ja as setPositionY,Ka as setPositionZ,tr as setRotation,mr as setRotationDegrees,or as setRotationDegreesX,_o as setRotationDegreesY,er as setRotationDegreesZ,$o as setRotationX,Yo as setRotationY,rr as setRotationZ,$ as setSelectedEntity,R as setSelectedEntityId,Br as setStageFrameProfilerEnabled,Fr as setVariable,Ua as shortestAngleDelta,v as sin,y as smoothstep,xr as sphereCollision,ne as sphereMesh,Ar as stageConfig,Jr as stageState,r as standardShader,F as step,ja as throttle,Km as tickCooldowns,f as time,Ho as toThreeVector2,Io as toThreeVector3,jo as touchButtonSvg,Zo as touchThemes,a as uniform,Qm as updateBoundaryRicochet,eo as useArrowsForAxes,mo as useArrowsForDirections,to as useArrowsForSecondaryAxes,Rm as useBehavior,fo as useIJKLForAxes,xo as useIJKLForDirections,so as useMouse,io as useMouseLook,co as useScreenCenterLook,no as useVirtualControls,po as useWASDForAxes,ao as useWASDForDirections,Mo as usesManagedRenderPath,p as uv,ha as variableChange,ya as variableChanges,E as vec2,x as vec3,i as vec4,Hr as vessel,Ra as wrapAround3D,Qa as wrapAroundXY,lr as zoneCollision,wo as zylemEventBus};
|
|
1
|
+
import{a as s,b as n,c as l,d as S,e as h,f as y,g as L,h as v,i as Z,j as b,k as g,l as u,m as T,n as j,o as F,p as W,q as k,r as w,s as z,t as B,u as D,v as E,w as G}from"./chunk-QB3NL7VQ.js";import"./chunk-BIGH6D34.js";import"./chunk-MSCVL5OK.js";import{a as Lp,b as vp,c as Zp}from"./chunk-HNCTOJP7.js";import{a as bp}from"./chunk-QVIUZEYA.js";import{a as gp,b as up,c as Tp,d as jp,e as Fp,f as Wp,g as kp,h as wp,i as zp,j as Bp,k as Dp,l as Ep,m as Gp,n as Mp,o as Np,p as Op}from"./chunk-47DG7I7M.js";import{A as cf,B as sf,C as nf,a as Pp,b as Vp,c as qp,d as Ap,e as Cp,f as Hp,g as Ip,h as Jp,i as Kp,j as Qp,k as Rp,l as Up,m as Xp,n as Yp,o as _p,p as $p,q as of,r as rf,s as ef,t as tf,u as mf,v as af,w as pf,x as ff,y as xf,z as df}from"./chunk-JNFFTNMH.js";import{a as jo,b as Fo,c as Wo,d as ko,e as No,f as Xe,g as Ye,h as it,i as dt,j as ct,k as st,l as nt,m as lt,n as St,o as ht}from"./chunk-LD4KDRYL.js";import{a as To,c as Se,d as he,e as ye,f as je,g as Fe,h as Ne,i as Oe,k as Pe,l as Ve,m as qe,n as Ae,o as Ce,p as He,q as Ie,r as Je,s as Ke,t as Re,v as Ue}from"./chunk-FYQNZCIP.js";import{a as le}from"./chunk-7GYFZKK7.js";import{a as io,b as co}from"./chunk-Q2YDBMVY.js";import{c as De,d as Ee,e as Ge,f as Me}from"./chunk-BCFFS3FP.js";import"./chunk-QDQ4QMAI.js";import"./chunk-AE3CTVHY.js";import{f as Ro}from"./chunk-DQQA3VJH.js";import{a as Vo,b as qo,c as Ao,d as Co,e as Ho,f as Io,g as Jo,h as Ko,i as Qo}from"./chunk-VJZMSBKP.js";import{a as C,b as H,c as I,d as J,e as K,f as Q,h as R,j as U,l as X,m as Y,n as _,o as $,p as oo,q as ro,r as eo,s as to,t as mo,u as ao,w as po,x as fo,y as xo}from"./chunk-DECK4UEC.js";import{b as be}from"./chunk-WBQ5TNRZ.js";import{a as yt,b as Lt,c as vt,d as Zt,e as bt}from"./chunk-GHJQ2HKI.js";import{a as _e,b as $e,c as ot,d as rt,e as et,f as tt,g as mt,h as at,i as pt,j as ft,l as xt}from"./chunk-YOVE25NW.js";import{a as Le,b as ve,c as Ze,d as ge,e as ue,f as Te}from"./chunk-MXO4VGDB.js";import{A as oe,B as re,C as ee,D as te,E as me,F as ae,G as pe,H as fe,I as xe,J as ie,K as de,L as ce,M as se,N as ne,b as kr,c as wr,d as zr,e as Br,f as Dr,g as Er,h as Gr,i as Mr,j as Nr,k as Or,l as Pr,m as Vr,n as qr,o as Ar,p as Cr,q as Hr,r as Ir,s as Jr,t as Kr,u as Qr,v as Rr,w as Ur,x as Xr,y as Yr,z as $r}from"./chunk-BMRFDDMR.js";import{c as vr,d as Zr,e as br,f as gr,g as ur,h as Tr,i as jr,j as Fr,u as Wr,z as _r}from"./chunk-SAQA4SXW.js";import{a as o,b as r,h as e,i as t,k as m,l as a,m as p,n as f,o as x,p as i,q as d,r as c}from"./chunk-7NYP4YAG.js";import{a as Oo,b as Po}from"./chunk-AIQ6IVT5.js";import"./chunk-QXVH6POE.js";import{b as Lr}from"./chunk-EVYHPR3J.js";import{$ as bm,$a as ba,A as Rt,Aa as Rm,B as Ut,Ba as Um,C as Xt,Ca as Xm,D as Yt,Da as Ym,E as _t,Ea as _m,F as $t,Fa as $m,G as om,Ga as oa,H as rm,Ha as ra,I as em,Ia as ea,J as tm,Ja as ta,K as mm,Ka as ma,L as am,La as aa,M as pm,Ma as pa,N as fm,Na as fa,O as xm,Oa as xa,P as im,Pa as ia,Q as dm,Qa as da,R as cm,Ra as ca,S as sm,Sa as sa,T as nm,Ta as na,U as lm,Ua as la,V as Sm,Va as Sa,W as hm,Wa as ha,X as ym,Xa as ya,Y as Lm,Ya as La,Z as vm,Za as va,_ as Zm,_a as Za,a as gt,aa as gm,ab as ga,b as ut,ba as um,bb as ua,c as Tt,ca as Tm,cb as Ta,d as jt,da as jm,db as ja,e as Ft,ea as Fm,eb as Fa,f as Wt,fa as Wm,fb as Wa,g as kt,ga as km,gb as ka,h as wt,ha as wm,hb as wa,i as zt,ia as zm,ib as za,j as Bt,ja as Bm,k as Dt,ka as Dm,l as Et,la as Em,m as Gt,ma as Gm,n as Mt,na as Mm,o as Nt,oa as Nm,p as Ot,pa as Om,q as Pt,qa as Pm,r as Vt,ra as Vm,s as qt,sa as qm,t as At,ta as Am,u as Ct,ua as Cm,v as Ht,va as Hm,w as It,wa as Im,x as Jt,xa as Jm,y as Kt,ya as Km,z as Qt,za as Qm}from"./chunk-XK63E4SX.js";import{a as Ba,b as Da,c as Ea}from"./chunk-ZRT3ZQVH.js";import{a as Ga,b as Ma,c as Na,d as Oa}from"./chunk-WQ3WMMZD.js";import{h as We,i as ke,j as we,k as ze,l as Be}from"./chunk-D2PATZCC.js";import{e as M,f as N,g as O,h as P,i as V,j as q,m as A}from"./chunk-4QLJUQSJ.js";import{a as Uo,b as Xo,c as Yo,d as _o,g as $o,h as or,i as rr,j as er}from"./chunk-7WRQ2UAN.js";import{A as dp,B as cp,C as sp,D as np,E as lp,a as Pa,b as Va,c as qa,d as Aa,e as Ca,f as Ha,g as Ia,h as Ja,i as Ka,j as Qa,k as Ra,l as Ua,m as Xa,n as Ya,o as _a,p as $a,q as op,r as rp,s as ep,t as tp,u as mp,v as ap,w as pp,x as fp,y as xp,z as ip}from"./chunk-IPWUDOV5.js";import{a as Qe}from"./chunk-BH53MBAZ.js";import{a as tr,b as mr,c as ar,d as pr,e as fr,f as xr,g as ir,h as dr,i as cr,j as sr,k as nr,l as lr,m as Sr,n as hr,o as yr}from"./chunk-XRP4JJXL.js";import{a as Sp,b as hp,c as yp}from"./chunk-7QF6YTEZ.js";import"./chunk-ORIDWL3T.js";import{a as wo,b as zo,c as Bo,d as Do,e as Eo,f as Go,g as Mo}from"./chunk-PCFF4LLO.js";import{a as so,b as no,c as lo,d as So,e as ho,f as yo,g as Lo,h as vo,i as Zo,j as bo,k as go,l as uo}from"./chunk-UG22Z42P.js";export{Le as ACTOR_TYPE,jo as AspectRatio,Gr as BOX_TYPE,Zp as BRIDGE_READY_EVENT,gt as BoundaryRicochet3DCoordinator,ut as BoundaryRicochetCoordinator,qr as CONE_TYPE,Kr as CYLINDER_TYPE,He as CameraManager,Pe as CameraPipeline,Ie as CameraWrapper,af as ColorJsonSchema,De as ConstructionGrid,Tt as CooldownBehavior,I as DEFAULT_SNAP_SETTINGS,$r as DISK_TYPE,jt as Destructible3DBehavior,Ft as DestructibleMesh,Jp as EntityJsonSchema,Vp as EntitySchema,io as EntityThumbnailCache,Oo as EventEmitterDelegate,ge as FOG_TYPE,Wt as FirstPersonBehavior,kt as FirstPersonEvent,wt as FirstPersonFSM,Ae as FirstPersonPerspective,Dt as FirstPersonPresentation,zt as FirstPersonShooterCoordinator,Bt as FirstPersonState,qe as Fixed2DPerspective,c as Fn,Et as FractureOptions,it as Game,Ro as GameBridge,nf as GameConfigJsonSchema,sf as GameDeviceConfigJsonSchema,mf as GameInputConfigSchema,tf as GameInputPlayerConfigSchema,Ea as Howl,Gt as Jumper2DBehavior,Mt as Jumper2DEvent,Nt as Jumper2DFSM,Ot as Jumper2DState,Pt as Jumper3DBehavior,Vt as Jumper3DEvent,qt as Jumper3DFSM,At as Jumper3DState,Qp as KeyboardMappingSchema,ce as LIGHT_TYPE,mt as LINE_TYPE,Hp as LineEntityDataSchema,ef as MouseConfigSchema,Rp as MouseMappingSchema,Ct as MultidirectionalSpaceShooterCoordinator,yt as PARTICLE_SYSTEM_TYPE,Ur as PILL_TYPE,ee as PLANE_TYPE,Hr as PYRAMID_TYPE,Ht as ParticleEmitterBehavior,Oe as Perspectives,It as Platformer2DBehavior,Jt as Platformer2DEvent,Kt as Platformer2DFSM,Qt as Platformer2DState,Rt as Platformer3DBehavior,Ut as Platformer3DEvent,Xt as Platformer3DFSM,Yt as Platformer3DState,xe as RECT_TYPE,ba as RUNTIME_BOUNDARY_2D_BEHAVIOR_KEY,ga as RUNTIME_DYNAMIC_CIRCLE_BODY_2D_BEHAVIOR_KEY,ua as RUNTIME_GOAL_ZONE_2D_BEHAVIOR_KEY,Ta as RUNTIME_PLAYER_INPUT_2D_BEHAVIOR_KEY,ja as RUNTIME_RICOCHET_2D_BEHAVIOR_KEY,Fa as RUNTIME_TRIGGER_REGION_2D_BEHAVIOR_KEY,je as RenderBundleManager,Fe as RenderStrategyManager,cf as ResolutionInputSchema,_t as Ricochet2DBehavior,$t as Ricochet2DEvent,om as Ricochet2DFSM,rm as Ricochet2DState,em as Ricochet3DBehavior,tm as Ricochet3DEvent,mm as Ricochet3DFSM,am as Ricochet3DState,Sa as RuntimeBoundary2DBehavior,ha as RuntimeDynamicCircleBody2DBehavior,ya as RuntimeGoalZone2DBehavior,La as RuntimePlayerInput2DBehavior,va as RuntimeRicochet2DBehavior,Za as RuntimeTriggerRegion2DBehavior,Or as SPHERE_TYPE,rt as SPRITE_TYPE,st as STAGE_STATE_CHANGE,pm as ScreenVisibilityBehavior,fm as ScreenVisibilityFSM,xm as ScreenWrapBehavior,im as ScreenWrapEvent,dm as ScreenWrapFSM,cm as ScreenWrapState,sm as Shooter2DBehavior,be as SimulationBody,Ip as SpriteEntityDataSchema,xf as StageAssetLoaderConfigSchema,Bp as StageBodyKind,Dp as StageBoundaryDim,df as StageConfigJsonSchema,Ep as StageEventType,ff as StageGLTFAssetLoaderConfigSchema,Kp as StageJsonSchema,Ye as StageManager,Gp as StageRicochetDim,Mp as StageRicochetReflection,qp as StageSchema,Np as StageTopDownPlane,_e as TEXT_TYPE,C as TRANSFORM_TOOLS,Ap as TextEntityDataSchema,Ve as ThirdPersonPerspective,nm as ThrusterBehavior,lm as ThrusterEvent,Sm as ThrusterFSM,hm as ThrusterState,ym as TopDownMovementBehavior,Lm as TopDownShooterCoordinator,Me as TransformGizmo,Xo as VEC2_ONE,Uo as VEC2_ZERO,_o as VEC3_ONE,Yo as VEC3_ZERO,pf as Vec3ComponentsSchema,Pp as Vector2Schema,Cp as Vector3TupleSchema,Yp as VirtualTouchButtonConfigSchema,$p as VirtualTouchButtonsConfigSchema,rf as VirtualTouchConfigSchema,_p as VirtualTouchJoystickConfigSchema,of as VirtualTouchJoysticksConfigSchema,Xp as VirtualTouchPositionSchema,Up as VirtualTouchStyleSchema,vm as WorldBoundary2DBehavior,Zm as WorldBoundary2DEvent,bm as WorldBoundary2DFSM,gm as WorldBoundary2DState,um as WorldBoundary3DBehavior,Tm as WorldBoundary3DEvent,jm as WorldBoundary3DFSM,Fm as WorldBoundary3DState,ae as ZONE_TYPE,ve as ZylemActor,Mr as ZylemBox,Ar as ZylemCone,Qr as ZylemCylinder,oe as ZylemDisk,ue as ZylemFog,bp as ZylemGameElement,se as ZylemLight,pt as ZylemLine,Lt as ZylemParticleSystem,Xr as ZylemPill,te as ZylemPlane,Ir as ZylemPyramid,ie as ZylemRect,Pr as ZylemSphere,et as ZylemSprite,$e as ZylemText,pe as ZylemZone,u as abs,vp as announceBridgeReady,Qe as applyTransformChanges,g as asin,b as atan,Wa as bindRuntimeDynamicCircleBody2DHandle,vr as boxCollision,kr as boxMesh,up as buildBoxCollider,jp as buildCapsuleCollider,Wp as buildConvexHullCollider,Fp as buildCylinderCollider,wp as buildHeightfieldCollider,gp as buildRuntimeBody,Tp as buildSphereCollider,kp as buildTrimeshCollider,zp as bundleRuntimeCollision,Ha as callFunc,L as clamp,A as clearGlobalSubscriptions,Ee as closestAxisValue,Wm as computeWorldBoundary2DHits,km as computeWorldBoundary3DHits,br as coneCollision,zr as coneMesh,Z as cos,Wr as create,Ze as createActor,s as createBackgroundShader,Nr as createBox,Je as createCamera,Cr as createCone,Zt as createCooldownIcon,Rr as createCylinder,re as createDisk,_r as createEntity,xt as createEntityFactory,wm as createFirstPersonInputComponent,zm as createFirstPersonMovementComponent,Bm as createFirstPersonStateComponent,Te as createFog,St as createFollowTarget,dt as createGame,N as createGlobal,Dm as createJumpConfig2D,Em as createJumpConfig3D,Gm as createJumpInput2D,Mm as createJumpInput3D,Nm as createJumpState2D,Om as createJumpState3D,ne as createLight,ft as createLine,m as createNodeMaterialFromTSL,vt as createParticleSystem,Ce as createPerspective,Pm as createPhysicsBodyComponent,Yr as createPill,me as createPlane,Vm as createPlatformer2DInputComponent,qm as createPlatformer2DMovementComponent,Am as createPlatformer2DStateComponent,Cm as createPlatformer3DInputComponent,Hm as createPlatformer3DMovementComponent,Im as createPlatformer3DStateComponent,Jr as createPyramid,de as createRect,Jm as createShooter2DStateComponent,Op as createSimulation,Vr as createSphere,tt as createSprite,Ue as createStage,ot as createText,Km as createThrusterInputComponent,Qm as createThrusterMovementComponent,Rm as createThrusterStateComponent,Um as createTopDownMovementComponent,Xm as createTopDownMovementInputComponent,Ym as createTopDownMovementStateComponent,_m as createTransformComponent,_a as createTransformStore,ke as createVariable,fe as createZone,le as crossfadeTransitionShader,ur as cylinderCollision,Dr as cylinderMesh,J as debugState,Mo as defaultTouchControls,$m as defineBehavior,Ko as degreesToRadians,Ca as delay,bt as destroy,lt as dispatchStageState,B as dot,ka as emitRuntimeGoal,wa as emitRuntimeRicochet,za as emitRuntimeTriggerRegionEnter,ct as entitySpawner,co as entityThumbnailCache,Ao as eulerToQuaternion,T as exp,Ia as fadeOpacity,oa as fireCooldown,ra as fireShooter2DIfRequested,d as float,w as floor,qo as focusEntity,z as fract,No as gameConfig,ea as getCooldown,ta as getCooldownStore,Fo as getDisplayAspect,ma as getEntityFacingAngle2D,O as getGlobal,q as getGlobals,fo as getHoveredEntity,mo as getHoveredEntityId,fp as getPosition,Wo as getPresetResolution,yr as getRotation,po as getSelectedEntity,X as getSelectedEntityId,_ as getSelectedEntityIds,oo as getSnapSettings,we as getVariable,xp as getVelocity,Lp as getZylemBridge,Ga as globalChange,Ma as globalChanges,aa as hasAnyWorldBoundary2DHit,pa as hasAnyWorldBoundary3DHit,nt as initStageStateDispatcher,Ge as intersectPlane,t as isGLSLShader,ye as isManagedRenderEntity,e as isTSLShader,H as isTransformTool,To as isWebGPUSupported,Do as joystickBaseSvg,Eo as joystickThumbSvg,D as length,W as max,uo as mergeInputConfigs,k as min,h as mix,G as mod,$a as move,Va as moveBy,pp as moveForwardXY,qa as moveTo,op as moveX,tp as moveXY,mp as moveXZ,rp as moveY,ep as moveZ,S as normalize,$o as normalizeVec2,or as normalizeVec3,o as objectVertexShader,P as onGlobalChange,V as onGlobalChanges,Ka as onPress,Qa as onRelease,ze as onVariableChange,Be as onVariableChanges,Lr as packCollisionGroups,Ua as parallel,ko as parseResolution,fa as particleEffect,xa as particlePresets,at as pickZylemLine,Tr as pillCollision,Er as pillMesh,Da as pingPongBeep,jr as planeCollision,l as positionWorld,n as positionWorldDirection,j as pow,gr as pyramidCollision,Br as pyramidMesh,Co as quaternionToEuler,Qo as radiansToDegrees,ia as registerCooldown,K as registerDebugEntityResolver,Vo as registerEntityFocusContext,Xa as repeat,Ya as repeatForever,da as resetCooldown,Pa as resetEntityOpacity,ap as resetVelocity,ca as resolveAim2D,Bo as resolveButtonAccent,Q as resolveDebugEntity,Se as resolveRenderCategory,zo as resolveTouchTheme,Ba as ricochetSound,Aa as rotateBy,ar as rotateEuler,tr as rotateInDirection,fr as rotateX,pr as rotateY,mr as rotateYEuler,xr as rotateZ,yp as screenCenterLookDeltas,hp as screenCenterLookTargets,Ra as sequence,to as setAddType,ht as setCameraFeed,U as setDebugTool,M as setGlobal,eo as setGridVisible,ao as setHoveredEntityId,R as setPaused,ip as setPosition,dp as setPositionX,cp as setPositionY,sp as setPositionZ,Sr as setRotation,hr as setRotationDegrees,sr as setRotationDegreesX,dr as setRotationDegreesY,lr as setRotationDegreesZ,cr as setRotationX,ir as setRotationY,nr as setRotationZ,xo as setSelectedEntity,Y as setSelectedEntityId,$ as setSelectedEntityIds,ro as setSnapSettings,Ne as setStageFrameProfilerEnabled,We as setVariable,Sp as shortestAngleDelta,v as sin,y as smoothstep,Jo as snapScale,Ho as snapToIncrement,Io as snapVec3,Zr as sphereCollision,wr as sphereMesh,Ke as stageConfig,Xe as stageState,r as standardShader,F as step,Ja as throttle,sa as tickCooldowns,f as time,rr as toThreeVector2,er as toThreeVector3,Go as touchButtonSvg,wo as touchThemes,a as uniform,na as updateBoundaryRicochet,so as useArrowsForAxes,lo as useArrowsForDirections,no as useArrowsForSecondaryAxes,la as useBehavior,yo as useIJKLForAxes,Lo as useIJKLForDirections,bo as useMouse,vo as useMouseLook,Zo as useScreenCenterLook,go as useVirtualControls,ho as useWASDForAxes,So as useWASDForDirections,he as usesManagedRenderPath,p as uv,Na as variableChange,Oa as variableChanges,E as vec2,x as vec3,i as vec4,Re as vessel,lp as wrapAround3D,np as wrapAroundXY,Fr as zoneCollision,Po as zylemEventBus};
|
package/dist/runtime.d.ts
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { StageBodyKindValue, StageBodyConfig, StageColliderConfig } from '@zylem/behaviors/core';
|
|
2
2
|
export { BehaviorRuntime, EntityDefinition, EntityHandle, Simulation, SimulationBodyDefinition, SimulationColliderDefinition, SimulationEvent, SimulationFrame, SimulationOptions, StageBodyConfig, StageBodyInfo, StageBodyKind, StageBodyKindValue, StageBoundaryDim, StageColliderConfig, StageColliderShape, StageDebugRender, StageEvent, StageEventType, StagePose, StageRaycastHit, StageRenderSlot, StageRicochetDim, StageRicochetReflection, StageTopDownPlane, createSimulation } from '@zylem/behaviors/core';
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
export { p as packCollisionGroups } from './collision-builder-
|
|
3
|
+
export { a as SimulationBody, S as SimulationStepClock } from './simulation-body-zQw-emOr.js';
|
|
4
|
+
import { e as Vec3Input } from './vector-D3eDzvcA.js';
|
|
5
|
+
export { p as packCollisionGroups } from './collision-builder-BckxkdmA.js';
|
|
6
6
|
import 'three';
|
|
7
7
|
|
|
8
8
|
/**
|
package/dist/runtime.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{a as c,b as d,c as e,d as f,e as g,f as h,g as i,h as j,i as k,j as l,k as m,l as n,m as o,n as p,o as q,p as r}from"./chunk-47DG7I7M.js";import{b}from"./chunk-
|
|
1
|
+
import{a as c,b as d,c as e,d as f,e as g,f as h,g as i,h as j,i as k,j as l,k as m,l as n,m as o,n as p,o as q,p as r}from"./chunk-47DG7I7M.js";import{b}from"./chunk-WBQ5TNRZ.js";import{b as a}from"./chunk-EVYHPR3J.js";import"./chunk-7WRQ2UAN.js";export{b as SimulationBody,l as StageBodyKind,m as StageBoundaryDim,n as StageEventType,o as StageRicochetDim,p as StageRicochetReflection,q as StageTopDownPlane,d as buildBoxCollider,f as buildCapsuleCollider,h as buildConvexHullCollider,g as buildCylinderCollider,j as buildHeightfieldCollider,c as buildRuntimeBody,e as buildSphereCollider,i as buildTrimeshCollider,k as bundleRuntimeCollision,r as createSimulation,a as packCollisionGroups};
|
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import { EntityHandle, Simulation } from '@zylem/behaviors/core';
|
|
2
|
-
import { Vector3, Vector2 } from 'three';
|
|
3
2
|
|
|
4
3
|
interface PhysicsVector3 {
|
|
5
4
|
x: number;
|
|
@@ -46,8 +45,16 @@ declare class SimulationBody implements PhysicsRenderPoseProvider {
|
|
|
46
45
|
*/
|
|
47
46
|
private interpolationValidAfterStep;
|
|
48
47
|
constructor(simulation: Simulation, handle: EntityHandle, clock: SimulationStepClock);
|
|
49
|
-
/**
|
|
50
|
-
|
|
48
|
+
/**
|
|
49
|
+
* Suppress interpolation until the render buffers catch up.
|
|
50
|
+
*
|
|
51
|
+
* Called automatically by the pose setters below. Wasm-side behaviors that
|
|
52
|
+
* teleport a body during a step (e.g. `screen_wrap`) bypass those setters,
|
|
53
|
+
* so their host systems must call this after the step and before render
|
|
54
|
+
* poses are synced — otherwise the render buffers straddle the teleport and
|
|
55
|
+
* the body is drawn sweeping between the two poses.
|
|
56
|
+
*/
|
|
57
|
+
markPoseDiscontinuity(): void;
|
|
51
58
|
private isInterpolationStale;
|
|
52
59
|
translation(): PhysicsVector3;
|
|
53
60
|
rotation(): PhysicsQuaternion;
|
|
@@ -120,42 +127,4 @@ declare class SimulationBody implements PhysicsRenderPoseProvider {
|
|
|
120
127
|
private writeLivePose;
|
|
121
128
|
}
|
|
122
129
|
|
|
123
|
-
type
|
|
124
|
-
type Vec3 = Vector3 | Vec3Components;
|
|
125
|
-
type Vec2Components = {
|
|
126
|
-
x: number;
|
|
127
|
-
y: number;
|
|
128
|
-
};
|
|
129
|
-
type Vec3Components = {
|
|
130
|
-
x: number;
|
|
131
|
-
y: number;
|
|
132
|
-
z: number;
|
|
133
|
-
};
|
|
134
|
-
type Vec2Tuple = readonly [number?, number?] & {
|
|
135
|
-
x?: number;
|
|
136
|
-
y?: number;
|
|
137
|
-
};
|
|
138
|
-
type Vec3Tuple = readonly [number?, number?, number?] & {
|
|
139
|
-
x?: number;
|
|
140
|
-
y?: number;
|
|
141
|
-
z?: number;
|
|
142
|
-
};
|
|
143
|
-
type Vec2Input = Vec2 | {
|
|
144
|
-
x?: number;
|
|
145
|
-
y?: number;
|
|
146
|
-
} | Vec2Tuple;
|
|
147
|
-
type Vec3Input = Vec3 | {
|
|
148
|
-
x?: number;
|
|
149
|
-
y?: number;
|
|
150
|
-
z?: number;
|
|
151
|
-
} | Vec3Tuple;
|
|
152
|
-
declare const VEC2_ZERO: Readonly<Vec2Components>;
|
|
153
|
-
declare const VEC2_ONE: Readonly<Vec2Components>;
|
|
154
|
-
declare const VEC3_ZERO: Readonly<Vec3Components>;
|
|
155
|
-
declare const VEC3_ONE: Readonly<Vec3Components>;
|
|
156
|
-
declare function normalizeVec2(input?: Vec2Input | null, defaults?: Vec2Input | Partial<Vec2Components>): Vec2Components;
|
|
157
|
-
declare function normalizeVec3(input?: Vec3Input | null, defaults?: Vec3Input | Partial<Vec3Components>): Vec3Components;
|
|
158
|
-
declare function toThreeVector2(input?: Vec2Input | null, defaults?: Vec2Input | Partial<Vec2Components>): Vector2;
|
|
159
|
-
declare function toThreeVector3(input?: Vec3Input | null, defaults?: Vec3Input | Partial<Vec3Components>): Vector3;
|
|
160
|
-
|
|
161
|
-
export { type SimulationStepClock as S, type Vec2 as V, type Vec2Components as a, type Vec2Input as b, type Vec3 as c, type Vec3Components as d, type Vec3Input as e, VEC2_ONE as f, VEC2_ZERO as g, VEC3_ONE as h, VEC3_ZERO as i, normalizeVec3 as j, toThreeVector3 as k, SimulationBody as l, normalizeVec2 as n, toThreeVector2 as t };
|
|
130
|
+
export { type SimulationStepClock as S, SimulationBody as a };
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
import { Vector3, Vector2 } from 'three';
|
|
2
|
+
|
|
3
|
+
type Vec2 = Vector2;
|
|
4
|
+
type Vec3 = Vector3 | Vec3Components;
|
|
5
|
+
type Vec2Components = {
|
|
6
|
+
x: number;
|
|
7
|
+
y: number;
|
|
8
|
+
};
|
|
9
|
+
type Vec3Components = {
|
|
10
|
+
x: number;
|
|
11
|
+
y: number;
|
|
12
|
+
z: number;
|
|
13
|
+
};
|
|
14
|
+
type Vec2Tuple = readonly [number?, number?] & {
|
|
15
|
+
x?: number;
|
|
16
|
+
y?: number;
|
|
17
|
+
};
|
|
18
|
+
type Vec3Tuple = readonly [number?, number?, number?] & {
|
|
19
|
+
x?: number;
|
|
20
|
+
y?: number;
|
|
21
|
+
z?: number;
|
|
22
|
+
};
|
|
23
|
+
type Vec2Input = Vec2 | {
|
|
24
|
+
x?: number;
|
|
25
|
+
y?: number;
|
|
26
|
+
} | Vec2Tuple;
|
|
27
|
+
type Vec3Input = Vec3 | {
|
|
28
|
+
x?: number;
|
|
29
|
+
y?: number;
|
|
30
|
+
z?: number;
|
|
31
|
+
} | Vec3Tuple;
|
|
32
|
+
declare const VEC2_ZERO: Readonly<Vec2Components>;
|
|
33
|
+
declare const VEC2_ONE: Readonly<Vec2Components>;
|
|
34
|
+
declare const VEC3_ZERO: Readonly<Vec3Components>;
|
|
35
|
+
declare const VEC3_ONE: Readonly<Vec3Components>;
|
|
36
|
+
declare function normalizeVec2(input?: Vec2Input | null, defaults?: Vec2Input | Partial<Vec2Components>): Vec2Components;
|
|
37
|
+
declare function normalizeVec3(input?: Vec3Input | null, defaults?: Vec3Input | Partial<Vec3Components>): Vec3Components;
|
|
38
|
+
declare function toThreeVector2(input?: Vec2Input | null, defaults?: Vec2Input | Partial<Vec2Components>): Vector2;
|
|
39
|
+
declare function toThreeVector3(input?: Vec3Input | null, defaults?: Vec3Input | Partial<Vec3Components>): Vector3;
|
|
40
|
+
|
|
41
|
+
export { type Vec2 as V, type Vec2Components as a, type Vec2Input as b, type Vec3 as c, type Vec3Components as d, type Vec3Input as e, VEC2_ONE as f, VEC2_ZERO as g, VEC3_ONE as h, VEC3_ZERO as i, normalizeVec3 as j, toThreeVector3 as k, normalizeVec2 as n, toThreeVector2 as t };
|
package/dist/web-components.d.ts
CHANGED
|
@@ -1,22 +1,25 @@
|
|
|
1
|
-
import { G as Game, D as DeviceProfile } from './game-
|
|
2
|
-
import {
|
|
1
|
+
import { G as Game, D as DeviceProfile } from './game-Cy8f6gJm.js';
|
|
2
|
+
import { t as DebugTools } from './debug-state-B5awuDHl.js';
|
|
3
3
|
import './base-node-life-cycle-BK9xebT9.js';
|
|
4
4
|
import 'three';
|
|
5
5
|
import './stage-transition-CmGpV4tc.js';
|
|
6
6
|
import './game-interfaces-vF5sRi1n.js';
|
|
7
|
-
import './
|
|
7
|
+
import './base-node-idopiSw5.js';
|
|
8
|
+
import './entity-type-map-CkkFMSrL.js';
|
|
9
|
+
import './entity-XZNGBeca.js';
|
|
8
10
|
import '@zylem/behaviors/core';
|
|
9
|
-
import './
|
|
10
|
-
import './
|
|
11
|
+
import './simulation-body-zQw-emOr.js';
|
|
12
|
+
import './vector-D3eDzvcA.js';
|
|
13
|
+
import './material-CxxAyJYp.js';
|
|
11
14
|
import 'three/webgpu';
|
|
12
|
-
import './collision-builder-
|
|
15
|
+
import './collision-builder-BckxkdmA.js';
|
|
13
16
|
import './events.js';
|
|
14
17
|
import 'mitt';
|
|
15
|
-
import './entity-
|
|
16
|
-
import './entity-B9yZeBm4.js';
|
|
18
|
+
import './entity-BIf_a4dl.js';
|
|
17
19
|
import '@zylem/behaviors/particle-emitter';
|
|
18
20
|
import 'three/addons/lines/webgpu/Line2.js';
|
|
19
|
-
import './zylem-camera-
|
|
21
|
+
import './zylem-camera-DZTpPOiD.js';
|
|
22
|
+
import '@zylem/bridge';
|
|
20
23
|
import './default-controls-CAKJ5zlo.js';
|
|
21
24
|
|
|
22
25
|
/**
|
package/dist/web-components.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{a}from"./chunk-
|
|
1
|
+
import{a}from"./chunk-QVIUZEYA.js";import"./chunk-DECK4UEC.js";export{a as ZylemGameElement};
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { Object3D, Vector2, Scene, Camera, Vector3, Quaternion, RenderTarget, Texture } from 'three';
|
|
2
|
-
import { S as StageEntity } from './entity-
|
|
2
|
+
import { S as StageEntity } from './entity-BIf_a4dl.js';
|
|
3
3
|
import { WebGPURenderer, RenderPipeline } from 'three/webgpu';
|
|
4
4
|
import { R as ResolvedStageTransition } from './stage-transition-CmGpV4tc.js';
|
|
5
5
|
|
|
@@ -542,6 +542,17 @@ declare class ZylemCamera {
|
|
|
542
542
|
* Frame the debug orbit camera on an Object3D (AABB fit).
|
|
543
543
|
*/
|
|
544
544
|
frameObject(object: Object3D): void;
|
|
545
|
+
/**
|
|
546
|
+
* Suspend or resume orbit input. Used by the debug transform tools so a
|
|
547
|
+
* gizmo drag does not also swing the camera.
|
|
548
|
+
*/
|
|
549
|
+
setOrbitInteractionEnabled(enabled: boolean): void;
|
|
550
|
+
/**
|
|
551
|
+
* Stop or resume tracking the debug selection with the orbit target. Used by
|
|
552
|
+
* the transform tools, which cannot be dragged accurately while the camera
|
|
553
|
+
* re-aims at the entity being moved.
|
|
554
|
+
*/
|
|
555
|
+
setOrbitFollowEnabled(enabled: boolean): void;
|
|
545
556
|
/**
|
|
546
557
|
* Directly set the camera position.
|
|
547
558
|
*/
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@zylem/game-lib",
|
|
3
|
-
"version": "0.8.
|
|
3
|
+
"version": "0.8.6",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"description": "A powerful and easy-to-use framework for creating simple 3D digital interactive applications using TypeScript.",
|
|
6
6
|
"license": "MIT",
|
|
@@ -61,6 +61,10 @@
|
|
|
61
61
|
"types": "./dist/debug.d.ts",
|
|
62
62
|
"import": "./dist/debug.js"
|
|
63
63
|
},
|
|
64
|
+
"./catalog": {
|
|
65
|
+
"types": "./dist/catalog.d.ts",
|
|
66
|
+
"import": "./dist/catalog.js"
|
|
67
|
+
},
|
|
64
68
|
"./bridge": {
|
|
65
69
|
"types": "./dist/bridge.d.ts",
|
|
66
70
|
"import": "./dist/bridge.js"
|
|
@@ -101,11 +105,24 @@
|
|
|
101
105
|
"files": [
|
|
102
106
|
"dist"
|
|
103
107
|
],
|
|
108
|
+
"scripts": {
|
|
109
|
+
"build": "tsup && pnpm api:extract && pnpm api:typedoc && pnpm schema:emit",
|
|
110
|
+
"dev": "tsup --watch",
|
|
111
|
+
"api:extract": "mkdir -p dist/api temp && api-extractor run --local --verbose",
|
|
112
|
+
"api:typedoc": "mkdir -p dist/api && typedoc --options typedoc.json",
|
|
113
|
+
"schema:emit": "node --experimental-strip-types ./scripts/emit-json-schemas.ts",
|
|
114
|
+
"prepublishOnly": "NODE_ENV=production pnpm build",
|
|
115
|
+
"lint": "biome check .",
|
|
116
|
+
"typecheck": "tsgo --noEmit",
|
|
117
|
+
"test": "vitest --reporter=verbose",
|
|
118
|
+
"coverage": "vitest run --coverage"
|
|
119
|
+
},
|
|
104
120
|
"dependencies": {
|
|
105
121
|
"@dgreenheck/three-pinata": "^2.0.1",
|
|
106
122
|
"@sinclair/typebox": "^0.34.41",
|
|
107
123
|
"@types/howler": "^2.2.12",
|
|
108
|
-
"@zylem/behaviors": "^0.5.
|
|
124
|
+
"@zylem/behaviors": "^0.5.11",
|
|
125
|
+
"@zylem/bridge": "workspace:*",
|
|
109
126
|
"comlink": "^4.4.2",
|
|
110
127
|
"howler": "^2.2.4",
|
|
111
128
|
"idb-keyval": "^6.2.2",
|
|
@@ -114,8 +131,7 @@
|
|
|
114
131
|
"stats.js": "^0.17.0",
|
|
115
132
|
"three": "^0.185.0",
|
|
116
133
|
"typescript-fsm": "^1.6.0",
|
|
117
|
-
"valtio": "^2.1.7"
|
|
118
|
-
"@zylem/bridge": "0.1.1"
|
|
134
|
+
"valtio": "^2.1.7"
|
|
119
135
|
},
|
|
120
136
|
"peerDependencies": {
|
|
121
137
|
"howler": "^2.2.4",
|
|
@@ -137,16 +153,5 @@
|
|
|
137
153
|
"typescript": "6.0.3",
|
|
138
154
|
"vite-plugin-solid": "^2.11.8",
|
|
139
155
|
"vitest": "^4.0.9"
|
|
140
|
-
},
|
|
141
|
-
"scripts": {
|
|
142
|
-
"build": "tsup && pnpm api:extract && pnpm api:typedoc && pnpm schema:emit",
|
|
143
|
-
"dev": "tsup --watch",
|
|
144
|
-
"api:extract": "mkdir -p dist/api temp && api-extractor run --local --verbose",
|
|
145
|
-
"api:typedoc": "mkdir -p dist/api && typedoc --options typedoc.json",
|
|
146
|
-
"schema:emit": "node --experimental-strip-types ./scripts/emit-json-schemas.ts",
|
|
147
|
-
"lint": "biome check .",
|
|
148
|
-
"typecheck": "tsgo --noEmit",
|
|
149
|
-
"test": "vitest --reporter=verbose",
|
|
150
|
-
"coverage": "vitest run --coverage"
|
|
151
156
|
}
|
|
152
|
-
}
|
|
157
|
+
}
|
package/LICENSE
DELETED
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
MIT License
|
|
2
|
-
|
|
3
|
-
Copyright (c) 2023 Timothy Cool
|
|
4
|
-
|
|
5
|
-
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
-
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
-
in the Software without restriction, including without limitation the rights
|
|
8
|
-
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
-
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
-
furnished to do so, subject to the following conditions:
|
|
11
|
-
|
|
12
|
-
The above copyright notice and this permission notice shall be included in all
|
|
13
|
-
copies or substantial portions of the Software.
|
|
14
|
-
|
|
15
|
-
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
-
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
-
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
-
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
-
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
-
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
-
SOFTWARE.
|
package/dist/chunk-2VSVOPQN.js
DELETED
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
import{a as y}from"./chunk-C5NEGC3S.js";import{AmbientLight as R,Object3D as U,PerspectiveCamera as T,RenderTarget as O,Scene as C,Color as P,LinearFilter as w,SpotLight as W,Vector3 as E}from"three";function d(a,e,t,n={}){let s=e*4,i=new Uint8ClampedArray(t*s),r=null;if(n.srgb){r=new Uint8Array(256);for(let o=0;o<256;o+=1){let c=o/255,u=c<=.0031308?c*12.92:1.055*Math.pow(c,1/2.4)-.055;r[o]=Math.round(Math.max(0,Math.min(1,u))*255)}}for(let o=0;o<t;o+=1){let c=(n.flipY?t-1-o:o)*s,u=o*s;if(r===null){i.set(a.subarray(c,c+s),u);continue}for(let l=0;l<s;l+=4)i[u+l]=r[a[c+l]],i[u+l+1]=r[a[c+l+1]],i[u+l+2]=r[a[c+l+2]],i[u+l+3]=a[c+l+3]}return i}var x=`
|
|
2
|
-
const encodeReadbackPixels = ${d.toString()};
|
|
3
|
-
|
|
4
|
-
self.onmessage = async (event) => {
|
|
5
|
-
const { id, buffer, width, height, options } = event.data;
|
|
6
|
-
try {
|
|
7
|
-
const src = new Uint8ClampedArray(buffer);
|
|
8
|
-
const pixels = encodeReadbackPixels(src, width, height, options);
|
|
9
|
-
const canvas = new OffscreenCanvas(width, height);
|
|
10
|
-
const ctx = canvas.getContext('2d');
|
|
11
|
-
if (!ctx) throw new Error('OffscreenCanvas 2d context unavailable');
|
|
12
|
-
ctx.putImageData(new ImageData(pixels, width, height), 0, 0);
|
|
13
|
-
const blob = await canvas.convertToBlob({ type: 'image/png' });
|
|
14
|
-
self.postMessage({ id, blob });
|
|
15
|
-
} catch (error) {
|
|
16
|
-
self.postMessage({ id, error: String(error) });
|
|
17
|
-
}
|
|
18
|
-
};
|
|
19
|
-
`,h=class{worker=null;workerFailed=!1;nextId=1;pending=new Map;isSupported(){return!this.workerFailed&&typeof Worker<"u"&&typeof OffscreenCanvas<"u"&&typeof URL<"u"&&typeof Blob<"u"}async encodeThumbnail(e,t,n,s={}){if(!this.isSupported())return null;let i=this.ensureWorker();if(!i)return null;let r=new Uint8Array(e.byteLength);r.set(e instanceof Uint8Array?e:new Uint8Array(e.buffer,e.byteOffset,e.byteLength));let o=this.nextId++;try{let c=await new Promise((u,l)=>{this.pending.set(o,{resolve:u,reject:l}),i.postMessage({id:o,buffer:r.buffer,width:t,height:n,options:s},[r.buffer])});return URL.createObjectURL(c)}catch{return null}}dispose(){this.worker&&(this.worker.terminate(),this.worker=null);for(let{reject:e}of this.pending.values())e(new Error("EntityPayloadWorker disposed"));this.pending.clear()}ensureWorker(){if(this.worker)return this.worker;try{let e=new Blob([x],{type:"text/javascript"}),t=URL.createObjectURL(e),n=new Worker(t,{type:"module"});return URL.revokeObjectURL(t),n.onmessage=s=>{let{id:i}=s.data,r=this.pending.get(i);r&&(this.pending.delete(i),"blob"in s.data?r.resolve(s.data.blob):r.reject(new Error(s.data.error)))},n.onerror=()=>{this.workerFailed=!0,this.dispose()},this.worker=n,n}catch{return this.workerFailed=!0,null}}},v=new h;var S=128,L=256,M=1,k=32,p=class{cache=new Map;inFlight=new Map;renderer=null;size;maxEntries;queue=[];activeRenders=0;constructor(e=S,t=L){this.size=e,this.maxEntries=t}setRenderer(e){this.renderer=e}get(e){let t=this.cache.get(e);return t?(this.touch(e,t),t):null}invalidate(e){let t=this.cache.get(e);t&&f(t.dataUrl),this.cache.delete(e),this.inFlight.delete(e),this.queue=this.queue.filter(n=>n.uuid!==e?!0:(n.resolve(null),!1))}clear(){this.cache.forEach(e=>f(e.dataUrl)),this.cache.clear(),this.inFlight.clear();for(let e of this.queue)e.resolve(null);this.queue=[]}get cacheSize(){return this.cache.size}get pendingCount(){return this.queue.length}async ensure(e,t){let n=this.cache.get(e);if(n)return this.touch(e,n),n;let s=this.inFlight.get(e);if(s)return s;if(!t||!this.renderer)return null;let i=new Promise(r=>{if(this.queue.push({uuid:e,object:t,resolve:r}),this.queue.length>k){let o=this.queue.splice(0,this.queue.length-k);for(let c of o)this.inFlight.delete(c.uuid),c.resolve(null)}this.drainQueue()});return this.inFlight.set(e,i),i}drainQueue(){for(;this.activeRenders<M&&this.queue.length>0;){let e=this.queue.shift();if(!e)return;this.activeRenders+=1,this.render(e.uuid,e.object).then(t=>{t&&(this.cache.set(e.uuid,t),this.evictOverflow()),e.resolve(t)}).catch(t=>{console.warn("EntityThumbnailCache: failed to render thumbnail",e.uuid,t),e.resolve(null)}).finally(()=>{this.activeRenders-=1,this.inFlight.delete(e.uuid),this.drainQueue()})}}touch(e,t){this.cache.delete(e),this.cache.set(e,t)}evictOverflow(){for(;this.cache.size>this.maxEntries;){let e=this.cache.keys().next();if(e.done)return;let t=this.cache.get(e.value);t&&f(t.dataUrl),this.cache.delete(e.value)}}async render(e,t){let n=this.renderer;if(!n)return null;let s=new C;s.background=new P(3815994);let i=t.clone(!0);i.position.set(0,0,0),i.rotation.set(0,0,0),i.updateMatrixWorld(!0),s.add(i);let r=new T(50,1,.1,100),o=y(i,r);F(s,r,o);let c=new O(this.size,this.size,{minFilter:w,magFilter:w}),u=n.getRenderTarget(),l=n.getScissorTest();try{n.setScissorTest(!1),n.setRenderTarget(c),n.render(s,r)}finally{n.setRenderTarget(u),n.setScissorTest(l)}let b=await n.readRenderTargetPixelsAsync(c,0,0,this.size,this.size);c.dispose(),s.remove(i);let m={flipY:A(n),srgb:!0},g=await v.encodeThumbnail(b,this.size,this.size,m)??D(b,this.size,this.size,m);return g?{uuid:e,dataUrl:g,bounds:{width:o.width,height:o.height,depth:o.depth}}:null}},N=new p;function f(a){a.startsWith("blob:")&&typeof URL<"u"&&URL.revokeObjectURL(a)}function A(a){return a?.backend?.isWebGLBackend===!0}function F(a,e,t){a.add(new R(16777215,.7)),e.updateMatrixWorld(!0);let n=new E().setFromMatrixColumn(e.matrixWorld,0),s=new E().setFromMatrixColumn(e.matrixWorld,1),i=e.position.distanceTo(t.center)||1,r=new W(16777215,5);r.position.copy(e.position).addScaledVector(n,i*.35).addScaledVector(s,i*.45),r.decay=0,r.distance=0,r.penumbra=.5,r.angle=j(Math.atan(t.maxDim/i)+.25,.4,Math.PI/3),r.castShadow=!1;let o=new U;o.position.copy(t.center),a.add(o),r.target=o,a.add(r)}function j(a,e,t){return Math.min(t,Math.max(e,a))}function D(a,e,t,n={}){if(typeof document>"u")return null;let s=document.createElement("canvas");s.width=e,s.height=t;let i=s.getContext("2d");if(!i)return null;let r=a instanceof Uint8Array?a:new Uint8Array(a.buffer,a.byteOffset,a.byteLength),o=i.createImageData(e,t);return o.data.set(d(r,e,t,n)),i.putImageData(o,0,0),s.toDataURL("image/png")}export{p as a,N as b};
|
package/dist/chunk-3I537JFL.js
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{b as V,d as ve,e as G,j as Se}from"./chunk-CM5YRNBJ.js";import{a as de,b as he}from"./chunk-AIQ6IVT5.js";import{a as Q,b as Ce,c as xe}from"./chunk-EVYHPR3J.js";import{c as v,d as D,e as me,f as fe,g as ye,h as f,i as be,j as L}from"./chunk-7WRQ2UAN.js";import{p as ge}from"./chunk-XRP4JJXL.js";import{StageBodyKind as _e}from"@zylem/behaviors/core";import{Color as st,Vector2 as Oe,Vector3 as Ee}from"three";function F(i){if(!i||typeof i!="object")return!1;let e=Object.getPrototypeOf(i);return e===Object.prototype||e===null}function y(i){if(i==null||typeof i=="function"||typeof i!="object")return i;if(i instanceof st||i instanceof Oe||i instanceof Ee)return i.clone();if(i instanceof Float32Array)return new Float32Array(i);if(Array.isArray(i))return i.map(e=>y(e));if(F(i)){let e={};for(let[t,o]of Object.entries(i))t!=="_builders"&&(e[t]=y(o));return e}return i}function S(i,e){let t=y(i);if(!e)return t;if(!F(t)||!F(e))return y(e);let o=t;for(let[n,s]of Object.entries(e)){if(n==="_builders"||s===void 0)continue;let r=o[n];if(n==="shader"){o[n]=y(s);continue}if(r instanceof Oe&&me(s)){o[n]=be(s,r);continue}if(r instanceof Ee&&fe(s)){o[n]=L(s,r);continue}if(F(r)&&F(s)){o[n]=S(r,s);continue}o[n]=y(s)}return o}function Me(i){return i&&i.__kind==="collision"}function ee(i){return i.cloneComponent()}function rt(i,e){let t={kind:i?_e.Static:_e.Dynamic,position:[0,0,0],gravityScale:e.gravityScale??1,canSleep:e.canSleep??!1,ccdEnabled:e.ccdEnabled??!0},o=Q(e.lockRotations);o&&(t.lockRotation=o);let n=Q(e.lockTranslations);return n&&(t.lockTranslation=n),t}function at(i,e){if(e.offset){let t=f(e.offset,v);i.offset=[t.x,t.y,t.z]}e.sensor&&(i.sensor=!0),e.collisionType&&(i.collisionGroups=Ce(e.collisionType,e.collisionFilter))}function _(i,e,t){return at(i,e),{__kind:"collision",bodyDesc:rt(e.static??!1,e),colliderDesc:i,cloneComponent:t}}function lt(i={}){let e=f(i.size,D),t={shape:{type:"box",halfExtents:[e.x/2,e.y/2,e.z/2]}},o=y(i);return _(t,i,()=>lt(o))}function ct(i={}){let e={shape:{type:"sphere",radius:i.radius??1}},t=y(i);return _(e,i,()=>ct(t))}function ut(i={}){let e=i.radius??1,o={shape:{type:"cone",halfHeight:(i.height??2)/2,radius:e}},n=y(i);return _(o,i,()=>ut(n))}function pt(i={}){let e=i.radius??1,o={shape:{type:"cone",halfHeight:(i.height??2)/2,radius:e}},n=y(i);return _(o,i,()=>pt(n))}function dt(i={}){let e=Math.max(i.radiusTop??1,i.radiusBottom??1),o={shape:{type:"cylinder",halfHeight:(i.height??2)/2,radius:e}},n=y(i);return _(o,i,()=>dt(n))}function ht(i={}){let e=i.radius??.5,o={shape:{type:"capsule",halfHeight:(i.length??1)/2,radius:e}},n=y(i);return _(o,i,()=>ht(n))}function mt(i={}){let e=ye(i.tile,{x:10,y:10}),t=i.subdivisions??10,o=(t+1)*(t+1),n=i.heightData??new Float32Array(o),s={shape:{type:"heightfield",rows:t,cols:t,heights:n,scale:[e.x,1,e.y]}},r={...i,static:i.static??!0},a=y(r);return _(s,r,()=>mt(a))}function ft(i={}){let e=f(i.size,D),t={shape:{type:"box",halfExtents:[e.x/2,e.y/2,e.z/2]},sensor:!0},o={...i,static:i.static??!0,sensor:!0},n=y(o);return _(t,o,()=>ft(n))}import{Mesh as ze,ShaderMaterial as Et,Group as _t}from"three";var Ae=import.meta.env.VITE_DEBUG_FLAG==="true";import{nanoid as yt}from"nanoid";var C=class i{parent=null;children=[];options;uuid="";name="";markedForRemoval=!1;lifecycleCallbacks={setup:[],loaded:[],update:[],destroy:[],cleanup:[]};trackLifecycleRegistrations=!1;userLifecycleRegistrations=[];constructor(e=[]){let t=e.filter(o=>!(o instanceof i)).reduce((o,n)=>({...o,...n}),{});this.options=t,this.uuid=yt()}onSetup(...e){return this.lifecycleCallbacks.setup.push(...e),this.recordLifecycleRegistration("onSetup",e),this}onLoaded(...e){return this.lifecycleCallbacks.loaded.push(...e),this.recordLifecycleRegistration("onLoaded",e),this}onUpdate(...e){return this.lifecycleCallbacks.update.push(...e),this.recordLifecycleRegistration("onUpdate",e),this}onDestroy(...e){return this.lifecycleCallbacks.destroy.push(...e),this.recordLifecycleRegistration("onDestroy",e),this}onCleanup(...e){return this.lifecycleCallbacks.cleanup.push(...e),this.recordLifecycleRegistration("onCleanup",e),this}prependSetup(...e){return this.lifecycleCallbacks.setup.unshift(...e),this.recordLifecycleRegistration("prependSetup",e),this}prependUpdate(...e){return this.lifecycleCallbacks.update.unshift(...e),this.recordLifecycleRegistration("prependUpdate",e),this}setParent(e){this.parent=e}getParent(){return this.parent}add(e){this.children.push(e),e.setParent(this)}remove(e){let t=this.children.indexOf(e);t!==-1&&(this.children.splice(t,1),e.setParent(null))}getChildren(){return this.children}isComposite(){return this.children.length>0}enableUserLifecycleTracking(){this.trackLifecycleRegistrations=!0}replayUserLifecycleRegistrationsTo(e,t){for(let o of this.userLifecycleRegistrations){let n=t?o.callbacks.map(s=>t(s)):[...o.callbacks];switch(o.method){case"onSetup":e.onSetup(...n);break;case"onLoaded":e.onLoaded(...n);break;case"onUpdate":e.onUpdate(...n);break;case"onDestroy":e.onDestroy(...n);break;case"onCleanup":e.onCleanup(...n);break;case"prependSetup":e.prependSetup(...n);break;case"prependUpdate":e.prependUpdate(...n);break}}}cloneChildrenInto(e){for(let t of this.children)e.add(bt(t))}nodeSetup(e){this.markedForRemoval=!1,typeof this._setup=="function"&&this._setup(e);for(let t of this.lifecycleCallbacks.setup)t(e);this.children.forEach(t=>t.nodeSetup(e))}nodeUpdate(e){if(!this.markedForRemoval){typeof this._update=="function"&&this._update(e),typeof this._tickActions=="function"&&this._tickActions(e.delta);for(let t of this.lifecycleCallbacks.update)t(e);this.children.forEach(t=>t.nodeUpdate(e))}}nodeDestroy(e){if(!this.markedForRemoval){this.children.forEach(t=>t.nodeDestroy(e));for(let t of this.lifecycleCallbacks.destroy)t(e);typeof this._destroy=="function"&&this._destroy(e),this.markedForRemoval=!0;for(let t of this.lifecycleCallbacks.cleanup)t(e);typeof this._cleanup=="function"&&this._cleanup(e)}}async nodeLoaded(e){typeof this._loaded=="function"&&await this._loaded(e);for(let t of this.lifecycleCallbacks.loaded)t(e)}nodeCleanup(e){this.children.forEach(t=>t.nodeCleanup?.(e));for(let t of this.lifecycleCallbacks.cleanup)t(e);typeof this._cleanup=="function"&&this._cleanup(e)}getOptions(){return this.options}setOptions(e){this.options={...this.options,...e}}recordLifecycleRegistration(e,t){!this.trackLifecycleRegistrations||t.length===0||this.userLifecycleRegistrations.push({method:e,callbacks:[...t]})}};function bt(i){let e=i?.clone;if(typeof e!="function")throw new Error(`Cannot clone child node "${i.name||i.uuid||"unknown"}": missing clone() support.`);return e.call(i)}import{createTransformStore as Mt}from"@zylem/behaviors/core";import{makeMoveable as gt}from"@zylem/behaviors/core";function Pe(i){let e=gt(i);return ge(e)}import{clearVelocityIntent as je}from"@zylem/behaviors/core";import{Color as St,Vector3 as Ot}from"three";var we=Symbol("explicitSpawnPosition");function De(i){return i.filter(e=>!(e instanceof C)).some(e=>e!=null&&typeof e=="object"&&"position"in e)}function Be(i){i[we]=!0}function Ct(i){return i._spawnPositionExplicit?!0:i.options[we]===!0}function xt(i){return i.options.hideUntilPositioned!==!1}function Re(i){return i._spawnPlacementPending===!0}function vt(i){return i._spawnPositionExplicit===!0||i._spawnPlacementReady===!0}function U(i){let e=i.group??i.mesh;if(e){if(i.physicsAttached&&i.body)try{let t=i.body.translation();e.position.set(t.x,t.y,t.z);return}catch{}if(i.wasmStageRef&&(i.runtimeHandle??-1)>=0){let t=i.wasmStageRef.getPose(i.runtimeHandle);if(t){e.position.set(t.position[0],t.position[1],t.position[2]);return}}if(i.options.position){let t=f(i.options.position,v);e.position.set(t.x,t.y,t.z)}}}function T(i,e){i.group&&(i.group.visible=e),i.mesh&&(i.mesh.visible=e)}function Hi(i){if(i._spawnInProgress=!0,i._spawnPlacementReady=!1,!xt(i)){i._spawnPlacementPending=!1;return}i._spawnPositionExplicit=Ct(i),i._spawnPlacementPending=!0,T(i,!1)}function Yi(i){i._spawnInProgress=!1}function Fe(i){i._spawnPlacementReady=!0}function te(i){if(i._spawnPlacementPending){if(U(i),i._spawnPlacementPending=!1,i.options.visible===!1){T(i,!1);return}T(i,!0)}}function Wi(i){!Re(i)||i.options.hideUntilPositioned===!0&&!vt(i)||te(i)}function Te(i){U(i),i._spawnPlacementPending=!1,T(i,!0)}function ke(i){Re(i)&&T(i,!1)}var N={position:new Ot(0,0,0),material:{color:new St("#ffffff"),shader:V},collision:{static:!1}};function eo(i,e){let t=i.filter(n=>!(n instanceof C)),o=S(e);for(let n of t)o=S(o,n);return De(i)&&Be(o),o}function At(i){return i!=null&&typeof i=="object"}function Ie(i){return{phase:i?.phase??"stay",cooldownMs:i?.cooldownMs}}function Pt(){return typeof performance<"u"&&typeof performance.now=="function"?performance.now():Date.now()}var P=class extends C{group;mesh;materials;bodyDesc=null;body=null;physicsAttached=!1;physicsWorldRef=null;colliderDesc;custom={};colliderDescs=[];compoundMeshes=[];debugInfo={};debugMaterial;collisionDelegate={collision:[],cooldowns:new Map,nextId:0};collisionType;packKey=null;bundleKey=null;instanceId=-1;isInstanced=!1;isBundled=!1;runtimeHandle=-1;runtimeAttached=!1;wasmStageRef=null;eventDelegate=new de;behaviorRefs=[];cloneFactory=null;trackAddedComponents=!1;trackedComponents=[];transformStore;_spawnPlacementPending=!1;_spawnPositionExplicit=!1;_spawnPlacementReady=!1;_spawnInProgress=!1;moveX;moveY;moveZ;moveXY;moveXZ;move;resetVelocity;moveForwardXY;getPosition;getVelocity;setPosition;setPositionX;setPositionY;setPositionZ;wrapAroundXY;wrapAround3D;rotateInDirection;rotateYEuler;rotateEuler;rotateX;rotateY;rotateZ;setRotationY;setRotationX;setRotationZ;setRotationDegrees;setRotationDegreesY;setRotationDegreesX;setRotationDegreesZ;setRotation;getRotation;constructor(){super(),this.transformStore=Mt(),Pe(this),this.wrapSpawnPlacementMutators()}wrapSpawnPlacementMutators(){let e=()=>{Fe(this),!this._spawnInProgress&&(U(this),te(this))},t=s=>(r,a,l)=>{!this.body&&!(this.wasmStageRef&&this.runtimeHandle>=0)||(s(r,a,l),e())},o=s=>r=>{!this.body&&!(this.wasmStageRef&&this.runtimeHandle>=0)||(s(r),e())};this.setPosition=t(this.setPosition.bind(this)),this.setPositionX=o(this.setPositionX.bind(this)),this.setPositionY=o(this.setPositionY.bind(this)),this.setPositionZ=o(this.setPositionZ.bind(this));let n=this.setPose.bind(this);this.setPose=s=>{let r=n(s);return r&&s.position!=null&&e(),r}}reveal(){this.options.visible=!0,Te(this)}getPose(){if(this.wasmStageRef&&this.runtimeHandle>=0){let n=this.wasmStageRef.getPose(this.runtimeHandle);if(n)return{position:{x:n.position[0],y:n.position[1],z:n.position[2]},rotation:{x:n.rotation[0],y:n.rotation[1],z:n.rotation[2],w:n.rotation[3]}}}let e=this.body;if(!e)return null;let t=e.translation(),o=e.rotation();return{position:{x:t.x,y:t.y,z:t.z},rotation:{x:o.x,y:o.y,z:o.z,w:o.w}}}setPose(e){if(this.wasmStageRef&&this.runtimeHandle>=0){let o=!0;if(e.position){let n=f(e.position);o=this.wasmStageRef.setPosition(this.runtimeHandle,n.x,n.y,n.z)&&o}if(e.rotation){let{x:n,y:s,z:r,w:a}=e.rotation;o=this.wasmStageRef.setRotation(this.runtimeHandle,n,s,r,a)&&o}return o}let t=this.body;if(!t)return!1;if(e.position){let o=f(e.position);t.setTranslation({x:o.x,y:o.y,z:o.z},!0)}return e.rotation&&t.setRotation(e.rotation,!0),!0}add(...e){for(let t of e)t instanceof ze?(this.addMeshComponent(t),this.trackComponent(t)):Me(t)?(this.addCollisionComponent(t),this.trackComponent(t)):super.add(t);return this}addMeshComponent(e){if(this.mesh)this.compoundMeshes.push(e),this.group||(this.group=new _t,this.group.add(this.mesh)),this.group.add(e);else if(this.mesh=e,this.materials||(this.materials=[]),e.material){let t=e.material;Array.isArray(t)?this.materials.push(...t):this.materials.push(t)}}addCollisionComponent(e){if(this.bodyDesc)this.colliderDescs.push(e.colliderDesc);else{this.bodyDesc=e.bodyDesc,this.colliderDesc=e.colliderDesc,this.colliderDescs.push(e.colliderDesc);let t=f(this.options?.position,v);this.bodyDesc.position=[t.x,t.y,t.z]}}trackComponent(e){if(this.trackAddedComponents){if(e instanceof ze){this.trackedComponents.push({kind:"mesh",component:Le(e)});return}this.trackedComponents.push({kind:"collision",component:ee(e)})}}_actions=[];runAction(e){return this._actions.push(e),e}action(e){return e.persistent=!0,this._actions.push(e),e}clearActions(){this._actions.length=0}_tickActions(e){if(this._actions.length===0)return;let t=this.transformStore;t.velocity.x=0,t.velocity.y=0,t.velocity.z=0,je(t,"actions"),t.angularVelocity.x=0,t.angularVelocity.y=0,t.angularVelocity.z=0,t.dirty.angularVelocity=!1;for(let o=this._actions.length-1;o>=0;o--){let n=this._actions[o];n.tick(this,e),n.done&&!n.persistent&&this._actions.splice(o,1)}this._actions.length===0&&(t.velocity.x=0,t.velocity.y=0,t.velocity.z=0,je(t,"actions"),t.angularVelocity.x=0,t.angularVelocity.y=0,t.angularVelocity.z=0,t.dirty.angularVelocity=!1)}create(){return this.name=this.options.name||"",this}clone(e){if(!this.cloneFactory)throw new Error(`Cannot clone ${this.constructor.name}: clone() is only supported for entities created by official factory helpers.`);let t=this.cloneFactory(S(this.options,e)),o=this.copyBehaviorRefsTo(t),n=r=>Dt(r,o);this.replayUserLifecycleRegistrationsTo(t,n);let s=this.getCollisionRegistrations();if(s.length>0)for(let r of s)t.onCollision(n(r.callback),r.options);for(let r of this.trackedComponents){if(r.kind==="mesh"){t.add(Le(r.component));continue}t.add(ee(r.component))}return this.cloneChildrenInto(t),t}finalizeCloneSupport(e){return this.cloneFactory=e,this.enableUserLifecycleTracking(),this.trackAddedComponents=!0,this}onCollision(...e){let t=[...this.collisionDelegate.collision??[]],o=this.collisionDelegate.nextId??0;if(e.length===1||e.length===2&&(e[1]==null||At(e[1]))){let n=e[0];if(!n)return this;let s=e[1];return t.push({id:o,callback:n,options:Ie(s)}),o+=1,this.collisionDelegate.collision=t,this.collisionDelegate.nextId=o,this}for(let n of e)t.push({id:o,callback:n,options:Ie()}),o+=1;return this.collisionDelegate.collision=t,this.collisionDelegate.nextId=o,this}use(e,t){let o={descriptor:e,options:{...e.defaultOptions,...t}};this.behaviorRefs.push(o);let n={getFSM:()=>o.fsm??null,getOptions:()=>o.options,ref:o},s=e.createHandle?.(o)??{};return{...n,...s}}getBehaviorRefs(){return this.behaviorRefs}getCollisionCallbacks(){return this.getCollisionRegistrations().map(e=>e.callback)}getCollisionRegistrations(){return(this.collisionDelegate.collision??[]).map(e=>({id:e.id,callback:e.callback,options:{...e.options}}))}copyBehaviorRefsTo(e){let t=new Map;for(let o of this.behaviorRefs){e.use(o.descriptor,y(o.options));let n=e.getBehaviorRefs().at(-1);n&&t.set(o,n)}return t}_setup(e){for(let t=this._actions.length-1;t>=0;t--){let o=this._actions[t];o.done&&!o.persistent?this._actions.splice(t,1):o.reset()}}async _loaded(e){}_update(e){this.updateMaterials(e)}_destroy(e){}_cleanup(e){this.disposeEvents();for(let t of this.compoundMeshes)t.geometry?.dispose(),Array.isArray(t.material)?t.material.forEach(o=>o.dispose()):t.material?.dispose();this.compoundMeshes.length=0,this.debugMaterial?.dispose(),this.debugMaterial=void 0,this.group?.removeFromParent()}_collision(e,t,o={phase:"stay",nowMs:Pt()}){if(!this.collisionDelegate.collision?.length)return;let n=this.collisionDelegate.cooldowns??new Map;this.collisionDelegate.cooldowns=n;for(let s of this.collisionDelegate.collision){if(s.options.phase!==o.phase)continue;let r=s.options.cooldownMs;if(r!=null){let a=`${s.id}:${e.uuid}`,l=n.get(a);if(l!=null&&o.nowMs-l<r)continue;n.set(a,o.nowMs)}s.callback({entity:this,other:e,globals:t})}}updateMaterials(e){if(this.materials?.length)for(let t of this.materials)t instanceof Et&&t.uniforms&&t.uniforms.iTime&&(t.uniforms.iTime.value+=e.delta)}buildInfo(){let e={};return e.name=this.name,e.uuid=this.uuid,e}dispatch(e,t){this.eventDelegate.dispatch(e,t),he.emit(e,t)}listen(e,t){return this.eventDelegate.listen(e,t)}disposeEvents(){this.eventDelegate.dispose()}};function wt(i){let e=new P;return e.options={...N,...i},ie(e,t=>wt(t??{}))}function Le(i){let e=i.clone(!0),t=[],o=[];i.traverse(n=>t.push(n)),e.traverse(n=>o.push(n));for(let n=0;n<t.length;n++){let s=t[n],r=o[n];s?.geometry?.clone&&(r.geometry=s.geometry.clone()),s?.material&&(r.material=Array.isArray(s.material)?s.material.map(a=>a.clone()):s.material.clone())}return e}function Dt(i,e){return e.size===0?i:((...t)=>{let o=Array.from(e.entries()).map(([n,s])=>({sourceRef:n,options:n.options,fsm:n.fsm,hasFSM:Object.prototype.hasOwnProperty.call(n,"fsm"),targetRef:s}));for(let n of o)n.sourceRef.options=n.targetRef.options,n.targetRef.fsm===void 0?delete n.sourceRef.fsm:n.sourceRef.fsm=n.targetRef.fsm;try{return i(...t)}finally{for(let n=o.length-1;n>=0;n--){let s=o[n];s.sourceRef.options=s.options,s.hasFSM?s.sourceRef.fsm=s.fsm:delete s.sourceRef.fsm}}})}function ie(i,e){return i.finalizeCloneSupport(e),i}function Ve(i){return typeof i?.load=="function"&&typeof i?.data=="function"}var Z=class{entityReference;constructor(e){this.entityReference=e}load(){this.entityReference.load&&this.entityReference.load()}data(){return this.entityReference.data?this.entityReference.data():null}};function Ge(i){let{args:e,defaultConfig:t,EntityClass:o,BuilderClass:n,entityType:s,MeshBuilderClass:r,CollisionBuilderClass:a,cloneFactory:l}=i,p=null,d,c=e.findIndex(b=>!(b instanceof C));c!==-1&&(d=e.splice(c,1).find(h=>!(h instanceof C)));let u=d?S(t,d):S(t);e.push(u);for(let b of e){if(b instanceof C)continue;let h=null,R=new o(b);try{if(Ve(R)){let I=new Z(R);I.load(),h=I.data()}}catch(I){console.error("Error creating entity with loader:",I)}p=new n(b,R,r?new r(h):null,a?new a(h):null),b.material&&p.withMaterial(b.material,s)}if(!p)throw new Error(`missing options for ${String(s)}, builder is not initialized.`);let m=p.build();return d!=null&&typeof d=="object"&&"position"in d&&(m._spawnPositionExplicit=!0),ie(m,b=>l(b))}import{Box3 as le,BufferAttribute as Vt,SkinnedMesh as Gt,MeshStandardMaterial as Ut,Group as Nt,Vector3 as M,Matrix4 as Ke}from"three";var B=class{async loadFile(e,t){switch(ve(e)){case"fbx":{let n=await G.loadFBX(e,t);return{object:n.object,animation:n.animations?.[0]}}case"gltf":case"glb":{let n=await G.loadGLTF(e,t);return{object:n.object,gltf:n.gltf}}case"obj":return{object:(await G.loadOBJ(e,t)).object};default:throw new Error(`Unsupported file type: ${e}`)}}};import{AnimationMixer as Bt,Bone as Ue,LoopOnce as Rt,LoopRepeat as Ft}from"three";function Tt(i){let e=i.lastIndexOf(".");return e>=0?i.slice(0,e):i}function Ne(i,e){if(!i?.name?.endsWith(".position"))return!1;let t=Tt(i.name),o=e.get(t);return o instanceof Ue?!(o.parent instanceof Ue):/hips\.position$/i.test(i.name)||/root\.position$/i.test(i.name)}function kt(i,e,t,o){for(let n of i.tracks){if(!Ne(n,e)||!n.values||n.values.length<3)continue;let s=n.values[0],r=o??n.values[1],a=n.values[2];for(let l=0;l<n.values.length;l+=3)n.values[l]=s,t&&(n.values[l+1]=r),n.values[l+2]=a}return i}function zt(i,e){for(let t of i.tracks)if(Ne(t,e)&&!(!t.values||t.values.length<3))return t.values[1];return null}var H=class{constructor(e){this.target=e}_mixer=null;_actions={};_animations=[];_currentAction=null;_pauseAtPercentage=0;_isPaused=!1;_queuedKey=null;_fadeDuration=.5;_currentKey="";_assetLoader=new B;async loadAnimations(e,t={}){if(!e.length)return;let o=t.stripRootMotionY??!1,n=t.referenceRootY,s=t.referenceAnimationPath,r=await Promise.all(e.map(c=>this._assetLoader.loadFile(c.path))),a=new Map;this.target.traverse(c=>{c.name&&a.set(c.name,c)});let l=[];if(r.forEach((c,u)=>{c.animation&&l.push({key:e[u].key||u.toString(),clip:c.animation,path:e[u].path})}),!l.length)return;let p=n;if(o&&p===void 0){let c=s?l.findIndex(m=>m.path===s):0,u=c>=0?[c,...l.map((m,g)=>g).filter(m=>m!==c)]:l.map((m,g)=>g);for(let m of u){let g=zt(l[m].clip,a);if(g!==null){p=g;break}}}let d=l.map(({key:c,clip:u})=>({key:c,clip:kt(u,a,o,p)}));this._animations=d.map(c=>c.clip),this._mixer=new Bt(this.target),d.forEach(({key:c,clip:u})=>{this._actions[c]=this._mixer.clipAction(u)}),this.playAnimation({key:d[0].key})}update(e){if(!this._mixer||!this._currentAction)return;this._mixer.update(e);let t=this._currentAction.getClip().duration*(this._pauseAtPercentage/100);if(!this._isPaused&&this._pauseAtPercentage>0&&this._currentAction.time>=t&&(this._currentAction.time=t,this._currentAction.paused=!0,this._isPaused=!0,this._queuedKey!==null)){let o=this._actions[this._queuedKey];o.reset().play(),this._currentAction.crossFadeTo(o,this._fadeDuration,!1),this._currentAction=o,this._currentKey=this._queuedKey,this._queuedKey=null}}playAnimation(e){if(!this._mixer)return;let{key:t,pauseAtPercentage:o=0,pauseAtEnd:n=!1,fadeToKey:s,fadeDuration:r=.5}=e;if(t===this._currentKey)return;let a=this._actions[t];if(!a)return;if(a===this._currentAction){this._currentKey=t;return}this._queuedKey=s||null,this._fadeDuration=r,this._pauseAtPercentage=n?100:o,this._isPaused=!1;let l=this._currentAction;this._pauseAtPercentage>0?(a.setLoop(Rt,1/0),a.clampWhenFinished=!0):(a.setLoop(Ft,1/0),a.clampWhenFinished=!1),a.reset().play(),l&&l.crossFadeTo(a,r,!1),this._currentAction=a,this._currentKey=t}dispose(){Object.values(this._actions).forEach(e=>{e.stop()}),this._mixer&&(this._mixer.stopAllAction(),this._mixer.uncacheRoot(this.target),this._mixer=null),this._actions={},this._animations=[],this._currentAction=null,this._currentKey=""}get currentAnimationKey(){return this._currentKey}get animations(){return this._animations}};import{BufferGeometry as It,Mesh as Ze,Color as Lt}from"three";import{Mesh as jt}from"three";var Y=class{_build(e,t,o){let n=new jt(t,o.at(-1));return n.position.set(0,0,0),n.castShadow=!0,n.receiveShadow=!0,n}_postBuild(){}};var W=class extends xe{},He=class extends Y{build(e){return new It}postBuild(){}},K=class{meshBuilder;collisionBuilder;materialBuilder;options;entity;constructor(e,t,o,n){this.options=e,this.entity=t,this.meshBuilder=o,this.collisionBuilder=n,this.materialBuilder=new Se;let s={meshBuilder:this.meshBuilder,collisionBuilder:this.collisionBuilder,materialBuilder:this.materialBuilder};this.options._builders=s,t&&t.options&&(t.options._builders=s)}withPosition(e){return this.options.position=e,this}withMaterial(e,t){return this.materialBuilder&&this.materialBuilder.build(e,t),this}applyMaterialToGroup(e,t){e.traverse(o=>{o instanceof Ze&&o.type==="SkinnedMesh"&&t[0]&&!o.material.map&&(o.material=t[0]),o.castShadow=!0,o.receiveShadow=!0})}build(){let e=this.entity;if(this.materialBuilder&&(e.materials=this.materialBuilder.materials),this.meshBuilder&&e.materials){let t=this.meshBuilder.build(this.options);e.mesh=this.meshBuilder._build(this.options,t,e.materials),this.meshBuilder.postBuild()}if(e.group&&e.materials&&this.applyMaterialToGroup(e.group,e.materials),this.collisionBuilder){this.collisionBuilder.withCollision(this.options?.collision||{});let[t,o]=this.collisionBuilder.build(this.options);e.bodyDesc=t,e.colliderDesc=o,e.colliderDescs.push(o);let{x:n,y:s,z:r}=f(this.options.position,v);e.bodyDesc.position=[n,s,r]}if(this.options.collisionType&&(e.collisionType=this.options.collisionType),this.options.color instanceof Lt){let t=o=>{let n=o;n&&n.color&&n.color.set&&n.color.set(this.options.color)};if(e.materials?.length)for(let o of e.materials)t(o);if(e.mesh&&e.mesh.material){let o=e.mesh.material;Array.isArray(o)?o.forEach(t):t(o)}e.group&&e.group.traverse(o=>{if(o instanceof Ze&&o.material){let n=o.material;Array.isArray(n)?n.forEach(t):t(n)}})}return e}};var Xe={...N,material:{shader:V},animations:[],models:[],collisionShape:"capsule"};function k(i){return L(i.scale,D)}var Zt=1e-4,Ht=/foot$/i,oe=new M,q=new M,Ye=new M,X=new M,We=new Ke;function Yt(i){let e=1/0,t=!1;return i.traverse(o=>{if(!o.isSkinnedMesh)return;let n=o,s=n.geometry,r=s.attributes.position,a=s.attributes.skinIndex,l=s.attributes.skinWeight,p=n.skeleton;if(!r||!a||!l||!p)return;t=!0,p.update(),n.updateMatrixWorld(!0);let d=p.boneMatrices;if(d)for(let c=0;c<r.count;c++){Ye.fromBufferAttribute(r,c).applyMatrix4(n.bindMatrix),X.set(0,0,0);for(let u=0;u<4;u++){let m=l.getComponent(c,u);if(m===0)continue;let g=a.getComponent(c,u);We.fromArray(d,g*16),X.addScaledVector(q.copy(Ye).applyMatrix4(We),m)}X.applyMatrix4(n.bindMatrixInverse).applyMatrix4(n.matrixWorld),e=Math.min(e,X.y)}}),!t||!Number.isFinite(e)?null:e}function Wt(i,e){e.updateMatrixWorld(!0);let t=e.getWorldPosition(oe).y,o=Yt(i)??1/0;if(i.traverse(n=>{!n.isBone||!Ht.test(n.name)||(n.getWorldPosition(oe),o=Math.min(o,oe.y))}),Number.isFinite(o)||i.traverse(n=>{if(!n.isSkinnedMesh)return;let s=n;if(s.computeBoundingBox(),!s.boundingBox)return;let{min:r,max:a}=s.boundingBox;for(let l of[[r.x,r.y,r.z],[r.x,r.y,a.z],[r.x,a.y,r.z],[r.x,a.y,a.z],[a.x,r.y,r.z],[a.x,r.y,a.z],[a.x,a.y,r.z],[a.x,a.y,a.z]])q.set(l[0],l[1],l[2]),q.applyMatrix4(s.matrixWorld),o=Math.min(o,q.y)}),!Number.isFinite(o)){let n=new le().setFromObject(i);if(n.isEmpty())return null;o=n.min.y}return o-t}function Kt(i,e,t){return i.stripRootMotionY!==void 0?i.stripRootMotionY:!!(e&&t.some(o=>o===e))}function j(i){let e=i.collision?.position;return e?f(e,v):null}function ne(i){return!!i.collision?.size}function Xt(i){i.hasWarnedDynamicTrimesh||(i.hasWarnedDynamicTrimesh=!0,console.warn(`Actor "${i.name||i.uuid}" requested collisionShape="trimesh" on a dynamic body; falling back to bounds.`))}function $e(i,e,t){let o=i==="model"?"bounds":i??"capsule";return o==="trimesh"&&!e?(t?.(),"bounds"):o}function qe(i,e){let t=i.x||.5,o=i.y||1,n=i.z||.5,s=Math.max(t,n)/2,r=o/2;return{shape:{type:"capsule",halfHeight:Math.max(0,r-s),radius:s},offset:[e.x,e.y,e.z],sensor:!1}}function w(i){let e=f(i.collision?.size??i.size,{x:.5,y:1,z:.5}),t=e.y||1,o=j(i);return qe({x:e.x||.5,y:t,z:e.z||.5},o??{x:0,y:t/2,z:0})}function Je(i){let e=i.collision?.size;if(!e)return null;let t=f(e,v),o=t.x/2,n=t.y/2,s=t.z/2,r=j(i);return{shape:{type:"box",halfExtents:[o,n,s]},offset:[r?.x??0,r?.y??n,r?.z??0],sensor:!1}}function Qe(i,e,t){let n=e.matrixWorld.clone().invert().multiply(i.matrixWorld);return new Ke().makeScale(t.x,t.y,t.z).multiply(n)}function se(i,e,t){i.updateMatrixWorld(!0);let o=!1,n=new le;if(i.traverse(a=>{if(!a.isMesh)return;let l=a,p=l.geometry;if(!p)return;let d=null;if(l instanceof Gt?(l.computeBoundingBox(),d=l.boundingBox?.clone()??null):(p.computeBoundingBox(),d=p.boundingBox?.clone()??null),!d)return;let c=d.applyMatrix4(Qe(l,e,t));if(!o){n.copy(c),o=!0;return}n.union(c)}),!o||n.isEmpty())return null;let s=new M,r=new M;return n.getSize(s),n.getCenter(r),{size:s,center:r}}function $t(i,e,t){i.updateMatrixWorld(!0);let o=[],n=[],s=new le,r=new M,a=!1;if(i.traverse(p=>{if(!p.isMesh)return;let d=p,c=d.geometry;if(!c)return;let u=c.getAttribute("position");if(!(u instanceof Vt))return;let m=Qe(d,e,t),g=o.length/3;for(let h=0;h<u.count;h++)r.set(u.getX(h),u.getY(h),u.getZ(h)),r.applyMatrix4(m),o.push(r.x,r.y,r.z),s.expandByPoint(r);let b=c.getIndex();if(b)for(let h=0;h<b.count;h++)n.push(g+b.getX(h));else for(let h=0;h<u.count;h++)n.push(g+h);a=!0}),!a||o.length===0||n.length===0)return null;let l=new M;return s.getCenter(l),{vertices:new Float32Array(o),indices:new Uint32Array(n),center:l}}function et(i,e,t){let o=Je(t);if(o)return o;if(!i||!e)return w(t);let n=se(i,e,k(t));if(!n)return w(t);let s=j(t);return{shape:{type:"box",halfExtents:[n.size.x/2,n.size.y/2,n.size.z/2]},offset:[s?.x??n.center.x,s?.y??n.center.y,s?.z??n.center.z],sensor:!1}}function tt(i,e,t,o,n){if(ne(n)||!i||!e)return w(n);let s=se(i,e,k(n));if(!s)return w(n);let a=j(n);if(!a){let l=t&&o?se(t,o,k(n)):null;a=l?{x:l.center.x,y:l.center.y,z:l.center.z}:{x:s.center.x,y:s.center.y,z:s.center.z}}return qe({x:s.size.x,y:s.size.y,z:s.size.z},a)}function it(i,e,t){let o=Je(t);if(o)return o;if(!i||!e)return w(t);let n=$t(i,e,k(t));if(!n)return w(t);let s=j(t);return{shape:{type:"trimesh",vertices:n.vertices,indices:n.indices},offset:s?[s.x-n.center.x,s.y-n.center.y,s.z-n.center.z]:[0,0,0],sensor:!1}}function $(i){i&&i.traverse(e=>{if(!e.isMesh)return;let t=e;t.geometry?.dispose(),Array.isArray(t.material)?t.material.forEach(o=>o.dispose()):t.material?.dispose()})}var re=class extends W{objectModel=null;collisionSource=null;collisionShape="capsule";constructor(e){super(),this.objectModel=e.objectModel,this.collisionSource=e.collisionSource??e.objectModel??null,this.collisionShape=e.collisionShape??"capsule"}collider(e){let t=$e(this.collisionShape,!!e.collision?.static);return t==="bounds"?et(this.objectModel,this.objectModel,e):t==="trimesh"?it(this.objectModel,this.objectModel,e):tt(this.collisionSource,this.collisionSource,this.objectModel,this.objectModel,e)}},ae=class extends K{createEntity(e){return new z(e)}},qt=Symbol("Actor"),z=class extends P{static type=qt;_object=null;_collisionSource=null;_animationDelegate=null;_modelFileNames=[];_assetLoader=new B;_loadGeneration=0;_loadStatus="idle";controlledRotation=!1;hasWarnedDynamicTrimesh=!1;constructor(e){super(),this.options=S(Xe,e),this.prependUpdate(this.actorUpdate.bind(this)),this.controlledRotation=!0}create(){return this._loadStatus==="idle"&&(this.options.models?.length??0)>0&&this.load(),super.create()}load(){this._loadStatus==="loading"||this._loadStatus==="loaded"||(this._modelFileNames=[...this.options.models||[]],this._modelFileNames.length!==0&&(this.disposeRuntimeState(!0),this._loadStatus="loading",this.loadModelsDeferred(++this._loadGeneration)))}data(){return{animations:this._animationDelegate?.animations,objectModel:this._object,collisionSource:this._collisionSource??this._object,collisionShape:this.options.collisionShape}}needsDeferredModelCollision(){return this.requiresLoadedCollisionSource()?!this.getRuntimeCollisionSource():!1}synchronizeRuntimeCollider(){let e=this.getResolvedCollisionShape(),t;if(e==="bounds")t=et(this._object,this.group??this._object,this.options);else if(e==="trimesh")t=it(this._object,this.group??this._object,this.options);else{let o=this.getRuntimeCollisionSource();t=tt(o,o,this._object,this._object,this.options)}this.colliderDesc=t,this.colliderDescs.length>0?this.colliderDescs[0]=t:this.colliderDescs.push(t)}actorUpdate(e){this._animationDelegate?.update(e.delta)}actorDestroy(){this._loadGeneration+=1,this._loadStatus="idle",this.disposeRuntimeState(!0),this._modelFileNames=[]}_cleanup(e){super._cleanup(e),this.actorDestroy()}playAnimation(e){this._animationDelegate?.playAnimation(e)}get object(){return this._object}get collisionSource(){return this._collisionSource??this._object}getDebugInfo(){let e={type:"Actor",models:this._modelFileNames.length>0?this._modelFileNames:"none",modelLoaded:!!this._object,scale:(()=>{let t=f(this.options.scale,D);return`${t.x}, ${t.y}, ${t.z}`})(),collisionShape:this.getResolvedCollisionShape()};if(this._animationDelegate&&(e.currentAnimation=this._animationDelegate.currentAnimationKey||"none",e.animationsCount=this.options.animations?.length||0),this._object){let t=0,o=0;this._object.traverse(n=>{if(!n.isMesh)return;t++;let s=n.geometry;s?.attributes.position&&(o+=s.attributes.position.count)}),e.meshCount=t,e.vertexCount=o}return e}getResolvedCollisionShape(){return $e(this.options.collisionShape,!!this.options.collision?.static,()=>Xt(this))}requiresLoadedCollisionSource(){let e=this.getResolvedCollisionShape();return e==="bounds"||e==="trimesh"?!ne(this.options):e==="capsule"?!ne(this.options)&&this.getCollisionSourceSelection().file!==null:!1}getRuntimeCollisionSource(){let e=this.getResolvedCollisionShape();return e==="bounds"||e==="trimesh"?this._object:this._collisionSource??this._object}getCollisionSourceSelection(){let e=this.options.models?.[0]??null,t=this.options.animations?.[0]?.path??null;return t?{file:t,reuseVisibleModel:t===e}:{file:e,reuseVisibleModel:!0}}disposeRuntimeState(e){this._animationDelegate&&(this._animationDelegate.dispose(),this._animationDelegate=null);let t=this._collisionSource;$(this._object),t&&t!==this._object&&$(t),this._object=null,this._collisionSource=null,e&&this.group&&(this.group.clear(),this.group=void 0)}loadModelsDeferred(e){this.dispatch("entity:model:loading",{entityId:this.uuid,files:this._modelFileNames});let t=this.getCollisionSourceSelection(),o=this._modelFileNames.map(s=>this._assetLoader.loadFile(s,{clone:!0})),n=t.file&&!t.reuseVisibleModel?this._assetLoader.loadFile(t.file,{clone:!0}):Promise.resolve(null);Promise.all([Promise.all(o),n]).then(([s,r])=>{if(e!==this._loadGeneration){s.forEach(l=>$(l.object??null)),r?.object&&$(r.object);return}this._object=s[0]?.object??null,this._collisionSource=t.reuseVisibleModel?this._object:r?.object??this._object,this._loadStatus=this._object?"loaded":"idle";let a=0;if(this._object){this._object.traverse(u=>{u.isMesh&&a++}),this.group=new Nt,this.group.add(this._object),this.group.scale.copy(k(this.options)),ke(this),this.applyMaterialOverrides(),this._animationDelegate=new H(this._object);let l=this.options.animations||[],p=this.options.models?.[0],d=l.map(u=>u.path),c=Kt(this.options,p,d);l.length>0?this._animationDelegate.loadAnimations(l,{stripRootMotionY:c,referenceAnimationPath:p}).then(()=>{e===this._loadGeneration&&(this.alignVisualModelToGround(),this.dispatch("entity:animation:loaded",{entityId:this.uuid,animationCount:l.length}))}):this.alignVisualModelToGround()}this.dispatch("entity:model:loaded",{entityId:this.uuid,success:!!this._object,meshCount:a})}).catch(s=>{e===this._loadGeneration&&(this._loadStatus="idle",console.error("Failed to load actor model",s),this.dispatch("entity:model:loaded",{entityId:this.uuid,success:!1,meshCount:0,errorMessage:s instanceof Error?s.message:String(s)}))})}alignVisualModelToGround(){if(!this._object||!this.group)return;this._animationDelegate?.update(0),this._object.updateMatrixWorld(!0);let e=Wt(this._object,this.group);if(e===null||Math.abs(e)<Zt)return;let t=this.group.scale.y||1;this._object.position.y-=e/t}applyMaterialOverrides(){let e=this.options.material;!e||!e.color&&!e.path&&e.opacity===void 0||this._object&&this._object.traverse(t=>{if(!t.isMesh)return;let o=t;o.material=Array.isArray(o.material)?o.material.map(n=>this.tintMaterial(n,e)):this.tintMaterial(o.material,e),e.color&&(o.castShadow=!0,o.receiveShadow=!0)})}tintMaterial(e,t){let o="color"in e,n=!!t.color,s=t.opacity!==void 0;if(!n&&!s)return e;if(n&&!o)return new Ut({color:t.color,emissiveIntensity:.5,lightMapIntensity:.5,fog:!0,opacity:t.opacity??1,transparent:s&&t.opacity<1});let r=e.clone();if(n&&"color"in r&&r.color.copy(t.color),s&&"opacity"in r&&"transparent"in r){let a=r;a.opacity=t.opacity,a.transparent=t.opacity<1}return r.needsUpdate=!0,r}};function Jt(...i){return Ge({args:i,defaultConfig:Xe,EntityClass:z,BuilderClass:ae,CollisionBuilderClass:re,entityType:z.type,cloneFactory:e=>Jt(e??{})})}import{Color as li,Fog as ci,FogExp2 as ui,Group as pi}from"three";import{Color as Qt}from"three";import{Fn as nt,fog as ei,positionWorld as ot,positionView as ti,uniform as x,float as ii,vec3 as O,clamp as ce,mix as E,max as oi,smoothstep as ni,floor as si,fract as ue,dot as ri}from"three/tsl";var J=class{values;u={time:x(0),heightEnabled:x(0),heightLevel:x(0),heightFalloff:x(0),noiseEnabled:x(0),noiseScale:x(0),noiseStrength:x(0),noiseSpeed:x(0)};attachedScene=null;constructor(e){this.values={...e},this.syncUniforms()}setValues(e){Object.assign(this.values,e),this.syncUniforms()}tick(e){this.values.time+=e,this.u.time.value=this.values.time}scan(e){if(this.attachedScene===e)return;let t=e.fog;t&&(e.fogNode=this.buildFogNode(t),this.attachedScene=e)}unpatchAll(){this.attachedScene&&(this.attachedScene.fogNode=null,this.attachedScene=null)}syncUniforms(){this.u.time.value=this.values.time,this.u.heightEnabled.value=this.values.heightEnabled,this.u.heightLevel.value=this.values.heightLevel,this.u.heightFalloff.value=this.values.heightFalloff,this.u.noiseEnabled.value=this.values.noiseEnabled,this.u.noiseScale.value=this.values.noiseScale,this.u.noiseStrength.value=this.values.noiseStrength,this.u.noiseSpeed.value=this.values.noiseSpeed}buildFogNode(e){let t=e.isFogExp2===!0,o=x(new Qt(e.color)),n=ti.z.negate(),s=t?this.exp2Factor(x(e.density),n):ni(x(e.near),x(e.far),n),r=this.u.heightLevel.sub(ot.y),a=ce(r.mul(oi(this.u.heightFalloff,0)),0,1),l=E(s,s.mul(a),this.u.heightEnabled),p=ot.mul(this.u.noiseScale).add(O(this.u.time.mul(this.u.noiseSpeed),0,this.u.time.mul(this.u.noiseSpeed).mul(.5))),c=ai(p).sub(.5).mul(2).mul(ce(this.u.noiseStrength,0,1)),u=ce(l.add(l.mul(c)),0,1),m=E(l,u,this.u.noiseEnabled);return ei(o,m)}exp2Factor(e,t){return e.mul(e).mul(t).mul(t).negate().exp().oneMinus()}},A=nt(([i])=>{let e=ue(i.mul(O(443.8975,397.2973,491.1871))),t=e.add(ri(e,e.yzx.add(19.27)));return ue(t.x.add(t.y).mul(t.z))}),ai=nt(([i])=>{let e=si(i),t=ue(i),o=t.mul(t).mul(ii(3).sub(t.mul(2))),n=A(e.add(O(0,0,0))),s=A(e.add(O(1,0,0))),r=A(e.add(O(0,1,0))),a=A(e.add(O(1,1,0))),l=A(e.add(O(0,0,1))),p=A(e.add(O(1,0,1))),d=A(e.add(O(0,1,1))),c=A(e.add(O(1,1,1))),u=E(n,s,o.x),m=E(r,a,o.x),g=E(l,p,o.x),b=E(d,c,o.x),h=E(u,m,o.y),R=E(g,b,o.y);return E(h,R,o.z)});var di=Symbol("Fog"),hi="#9aa3ad",mi=.015,fi=10,yi=250,bi=5,gi=.2,Ci=.05,xi=.15,vi=.1,pe=class extends P{static type=di;threeFog=null;attachedScene=null;patcher;patcherEnabled;constructor(e={}){super(),this.options={...e};let t=this.resolveUniformValues(this.options);this.patcher=new J(t),this.patcherEnabled=Oi(this.options)}create(){return super.create(),this.threeFog=Si(this.options),this.group=new pi,this.group.name=this.name?`Fog:${this.name}`:"Fog",this}attachToScene(e){this.threeFog&&(this.attachedScene=e,e.fog=this.threeFog,this.patcherEnabled&&this.patcher.scan(e))}_update(e){super._update(e),!(!this.attachedScene||!this.patcherEnabled)&&(this.patcher.tick(e.delta),this.patcher.scan(this.attachedScene))}_cleanup(e){this.patcher.unpatchAll(),this.attachedScene&&this.attachedScene.fog===this.threeFog&&(this.attachedScene.fog=null),this.attachedScene=null,this.threeFog=null,super._cleanup(e)}resolveUniformValues(e){let t=e.height,o=e.noise;return{time:0,heightEnabled:t?.enabled?1:0,heightLevel:t?.level??bi,heightFalloff:t?.falloff??gi,noiseEnabled:o?1:0,noiseScale:o?.scale??Ci,noiseStrength:o?.strength??xi,noiseSpeed:o?.speed??vi}}};function Si(i){let e=new li(i.color??hi);return(i.type??"linear")==="exp2"?new ui(e,i.density??mi):new ci(e,i.start??fi,i.end??yi)}function Oi(i){let e=!!i.height?.enabled,t=!!i.noise;return e||t}function _n(i={}){return new pe(i)}export{C as a,S as b,lt as c,ct as d,ut as e,pt as f,dt as g,ht as h,mt as i,ft as j,Re as k,Hi as l,Yi as m,Wi as n,ke as o,N as p,eo as q,P as r,wt as s,ie as t,Ge as u,W as v,He as w,K as x,qt as y,z,Jt as A,di as B,pe as C,_n as D};
|
package/dist/chunk-C5NEGC3S.js
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{Box3 as d,PerspectiveCamera as h,Vector3 as a}from"three";var m=new d,s=new a,x=new a,p=new a;function u(c){m.setFromObject(c),m.getSize(s),m.getCenter(x);let t=Math.max(s.x,1e-4),o=Math.max(s.y,1e-4),n=Math.max(s.z,1e-4),e=Math.max(t,o,n);return{width:t,height:o,depth:n,center:x.clone(),maxDim:e}}function b(c,t,o=1.35){let n=t.fov*(Math.PI/180),e=c/(2*Math.tan(n/2))*o;return Math.max(e,.5)}function j(c,t,o=1.35){let n=u(c),e=b(n.maxDim,t,o);return t.position.copy(n.center).add(new a(e,e,e)),t.lookAt(n.center),t.near=Math.max(e/100,.01),t.far=Math.max(e*20,100),t.updateProjectionMatrix(),n}function M(c,t,o,n=1.5){let e=u(c),r=p.copy(o);r.lengthSq()<1e-8&&r.set(1,1,1),r.normalize();let i=e.maxDim*n;return t instanceof h&&(i=b(e.maxDim,t,n),t.near=Math.max(i/100,.01),t.far=Math.max(i*20,100),t.updateProjectionMatrix()),t.position.copy(e.center).addScaledVector(r,i),t.lookAt(e.center),e}export{j as a,M as b};
|
package/dist/chunk-CV75NSES.js
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{a as P}from"./chunk-LGS5N5M4.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,p as m,q as w,r as c,t as x,u as R,v as $,w as K,x as D}from"./chunk-3I537JFL.js";import{j as kt}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 Fe}from"three";import{BoxGeometry as ze,CapsuleGeometry as Le,ConeGeometry as Ft,CylinderGeometry as Be,Mesh as I,MeshStandardMaterial as He,SphereGeometry as ke}from"three";function z(i,t=Symbol("mesh")){if(i.material||i.color){let e=new kt;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 ke(i.radius??1),e=z(i);return L(new I(t,e.at(-1)),i)}function tt(i={}){let t=new Ft(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 Ft(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 Gt={...m,size:new Fe(1,1,1)},At=Symbol("Box"),nt=class i extends c{static type=At;constructor(t){super(),this.options={...Gt,...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=w(i,Gt),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,gravityScale:t.collision?.gravityScale,lockRotations:t.collision?.lockRotations,lockTranslations:t.collision?.lockTranslations,collisionType:t.collisionType,collisionFilter:t.collisionFilter})),x(e,o=>Vt(o??{}))}var Yt={...m,radius:1},Nt=Symbol("Sphere"),st=class i extends c{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=w(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,gravityScale:t.collision?.gravityScale,lockRotations:t.collision?.lockRotations,lockTranslations:t.collision?.lockTranslations,collisionType:t.collisionType,collisionFilter:t.collisionFilter})),x(e,o=>Wt(o??{}))}import{PlaneGeometry as Ae,Vector2 as Xt,Vector3 as Ut}from"three";import{BufferGeometry as Ge,Float32BufferAttribute as bt}from"three";var rt=class i extends Ge{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),p=r+1,O=l+1,u=t/r,d=e/l,b=[],f=[],y=[],_=[];for(let g=0;g<O;g++){let h=g*d-a;for(let C=0;C<p;C++){let T=C*u-s;f.push(T,0,h),y.push(0,1,0),_.push(C/r),_.push(1-g/l)}}for(let g=0;g<l;g++)for(let h=0;h<r;h++){let C=h+p*g,T=h+p*(g+1),S=h+1+p*(g+1),v=h+1+p*g;b.push(C,T,v),b.push(T,S,v)}this.setIndex(b),this.setAttribute("position",new bt(f,3)),this.setAttribute("normal",new bt(y,3)),this.setAttribute("uv",new bt(_,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 Ae(s.x,s.z,o,n),p=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,_=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],T=d[h+1],S=g(Math.round((C+s.x/2)/p),o),v=g(Math.round((s.z/2-T)/O),n),M=0;if(f){let Mt=f[v];Mt&&(M=Mt[S]??0)}else y&&y.length>0?M=y[S]??0:_&&(M=Math.random()*4);let G=M*a;d[h+2]=G,u[h+1]=G,b.get(v)||b.set(v,new Map),b.get(v).set(S,G)}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)}},St=class extends D{createEntity(t){return new B(t)}},$t=Symbol("Plane"),B=class extends c{static type=$t;constructor(t){super(),this.options=Z(jt,t)}};function Kt(...i){return R({args:i,defaultConfig:jt,EntityClass:B,BuilderClass:St,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 c{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=w(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 ct,Vector2 as pt,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 pt(24,24),zDistance:1,anchor:new pt(0,0)},wt=class extends D{createEntity(t){return new k(t)}},re=Symbol("Rect"),k=class i extends c{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=ct,this._texture.magFilter=ct;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),p=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(p&&(this._texture.dispose(),this._texture=new ie(this._canvas),this._texture.minFilter=ct,this._texture.magFilter=ct,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)),p=r!==(this.options.width??0)||l!==(this.options.height??0);this.options.screenPosition=new pt(Math.floor(o),Math.floor(n)),this.options.width=r,this.options.height=l,this.options.anchor=new pt(0,0),p&&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,p=1;if(t.isPerspectiveCamera){let S=t,v=Math.tan(S.fov*Math.PI/180/2)*r;l=v*S.aspect,p=v}else if(t.isOrthographicCamera){let S=t;l=(S.right-S.left)/2,p=(S.top-S.bottom)/2}let O=s/e*2-1,u=1-a/o*2,d=O*l,b=u*p,f=1,y=1;if(this._canvas){let v=p*2/o,M=this._canvas.height;y=Math.max(1e-4,M*v);let G=this._canvas.width/this._canvas.height;f=y*G,this._sprite.scale.set(f,y,1),this._mesh&&this._mesh.scale.set(f,y,1)}let _=E(this.options.anchor,H.anchor),g=Math.min(100,Math.max(0,_.x))/100,h=Math.min(100,Math.max(0,_.y))/100,C=(.5-g)*f,T=(h-.5)*y;this.group?.position.set(d+C,b+T,-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)),p=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:p,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:k,BuilderClass:wt,entityType:k.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}}}},vt=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}},_t=class extends D{createEntity(t){return new F(t)}build(){let t=super.build();return t.mesh&&!t.group&&(t.group=new je,t.group.add(t.mesh)),t}},ce=Symbol("Disk"),F=class i extends c{static type=ce;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 pe(...i){return R({args:i,defaultConfig:le,EntityClass:F,BuilderClass:_t,MeshBuilderClass:vt,CollisionBuilderClass:Ct,entityType:F.type,cloneFactory:t=>pe(t??{})})}var he={...m,radius:1,height:2,radialSegments:32},me=Symbol("Cone"),ht=class i extends c{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=w(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,gravityScale:t.collision?.gravityScale,lockRotations:t.collision?.lockRotations,lockTranslations:t.collision?.lockTranslations,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 c{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=w(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,gravityScale:t.collision?.gravityScale,lockRotations:t.collision?.lockRotations,lockTranslations:t.collision?.lockTranslations,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 c{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=w(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,gravityScale:t.collision?.gravityScale,lockRotations:t.collision?.lockRotations,lockTranslations:t.collision?.lockTranslations,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 c{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 Se(...i){let t=w(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,gravityScale:t.collision?.gravityScale,lockRotations:t.collision?.lockRotations,lockTranslations:t.collision?.lockTranslations,collisionType:t.collisionType,collisionFilter:t.collisionFilter})),x(e,o=>Se(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},we=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 c{static type=we;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 ve=Symbol("Light"),ci={x:0,y:0,z:0},A=16777215,pi={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 c{static type=ve;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??A,i.intensity??1);return i.name&&(t.name=i.name),t}function di(i){let t=i.skyColor??i.color??A,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??A,i.intensity??1);i.name&&(t.name=i.name),xi(t,i.castShadow??!1,i.shadow);let e=_e(i.position,i.target);return e&&(t.target=e),{light:t,target:e}}function fi(i){let t=new ai(i.color??A,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??A,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=_e(i.position,i.target);return e&&(t.target=e),{light:t,target:e}}function _e(i,t){if(!t)return null;let e=i??ci,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={...pi,...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 Si,CanvasTexture as wi,LinearFilter as Ze,Color as Te,ClampToEdgeWrapping as Me}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,vi={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)"},_i=Symbol("CooldownIcon"),Tt=class extends c{static type=_i;_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 wi(this._canvas),this._texture.minFilter=Ze,this._texture.magFilter=Ze,this._texture.wrapS=Me,this._texture.wrapT=Me;let e=new Si({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,p=-Math.PI/2,O=p+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,p,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 Te?t:new Te(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],p=r*t,O=l*e,u=e/De;return{px:p+s*u,py:O+a*u}}resolveIconSize(t){let e=this.options.iconSize??"md",o,n;typeof e=="string"?o=n=vi[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),p=n/e*2-1,O=1-s/o*2,u=p*r,d=O*l;{let f=l*2/o,{widthPx:y,heightPx:_}=this.resolveIconSize(o),g=Math.max(1e-4,y*f),h=Math.max(1e-4,_*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 Tt(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,At 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,k as t,ae as u,ce as v,F as w,pe 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,Se as J,we as K,yt as L,ei as M,ve as N,ft as O,bi as P,Ie as Q,Zi as R};
|
package/dist/chunk-GKHAJ3MW.js
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{b as c}from"./chunk-LKFF6XJC.js";import{a as n,e as l,g as r,i as h}from"./chunk-W5SXED5T.js";import{subscribe as p}from"valtio/vanilla";import{announceBridgeReady as m,getZylemBridge as b}from"@zylem/bridge";function g(i){return(i?.group??i?.mesh)?.scale}function w(i){let e=i?.scale??g(i)??{};return{x:e.x??1,y:e.y??1,z:e.z??1}}function v(i,e){if(typeof i?.setScale=="function"){i.setScale(e.x,e.y,e.z);return}g(i)?.set?.(e.x,e.y,e.z)}function G(i,e){b().channel.send("game:notice",{level:i,message:e})}var y=class{channel;unsubscribes=[];host=null;editorKnown={};constructor(){this.channel=b().channel}connect(e,a){this.disconnect(),this.host=e,this.unsubscribes.push(this.channel.on("debug:set",({enabled:t})=>{this.editorKnown.debug=t,n.enabled=t}),this.channel.on("tool:set",({tool:t})=>{r(t)}),this.channel.on("playback:set",({paused:t})=>{this.editorKnown.paused=t,l(t)}),this.channel.on("entity:select",({uuid:t})=>{this.editorKnown.selectedUuid=t,h(t)}),this.channel.on("entity:focus",({uuid:t})=>{c(t)}),this.channel.on("entity:transform",({uuid:t,position:o,rotation:d,scale:u})=>{let s=this.host?.resolveEntity(t);s&&(o&&typeof s.setPosition=="function"&&s.setPosition(o.x,o.y,o.z),d&&(s.setRotationX?.(d.x),s.setRotationY?.(d.y),s.setRotationZ?.(d.z)),u&&v(s,u))}),this.channel.on("stage:variable:set",({key:t,value:o})=>{this.host?.setStageVariable?.(t,o)}),p(n,()=>this.publishDebugStateChanges())),this.publishDebugStateChanges(),m(a)}disconnect(){for(let e of this.unsubscribes)e();this.unsubscribes=[],this.host=null,this.editorKnown={}}publishDebugStateChanges(){let e={};n.paused!==this.editorKnown.paused&&(this.editorKnown.paused=n.paused,e.paused=n.paused),n.enabled!==this.editorKnown.debug&&(this.editorKnown.debug=n.enabled,e.debug=n.enabled),(e.paused!==void 0||e.debug!==void 0)&&this.publishStatus(e),(n.selectedEntityId!==this.editorKnown.selectedUuid||n.hoveredEntityId!==this.editorKnown.hoveredUuid)&&(this.editorKnown.selectedUuid=n.selectedEntityId,this.editorKnown.hoveredUuid=n.hoveredEntityId,this.channel.queue("entity:selection",{selectedUuid:n.selectedEntityId,hoveredUuid:n.hoveredEntityId}))}wantsEntityUpdates(){return this.channel.hasSubscribers("entity:upsert")||this.channel.hasSubscribers("stage:snapshot")}wantsThumbnails(){return this.channel.hasSubscribers("entity:thumbnail")}onEditorAttached(e){return this.channel.onSubscriberAdded(a=>{(a==="entity:upsert"||a==="entity:thumbnail")&&e()})}publishConfig(e){this.channel.send("game:config",e)}publishLoading(e){this.channel.send("game:loading",e)}publishStatus(e){this.channel.queue("game:status",e)}publishVariable(e){this.channel.queue("game:variable",e)}publishNotice(e,a){this.channel.send("game:notice",{level:e,message:a})}publishStageSnapshot(e){this.channel.send("stage:snapshot",e)}queueEntityUpsert(e){e.length&&this.channel.queue("entity:upsert",e)}queueEntityRemoved(e){e.length&&this.channel.queue("entity:removed",{uuids:e})}queueThumbnails(e){e.length&&this.channel.queue("entity:thumbnail",e)}};export{w as a,G as b,y as c};
|
package/dist/chunk-LGS5N5M4.js
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{b as d,p as v,q as V,r as y,t as D,u as S,v as B,x as b}from"./chunk-3I537JFL.js";import{c as k}from"./chunk-CM5YRNBJ.js";import{c as h,d as _,h as u,i as T,j as C}from"./chunk-7WRQ2UAN.js";import{Color as $,Group as nt,Sprite as st,SpriteMaterial as rt,CanvasTexture as U,LinearFilter as E,Vector2 as ot,ClampToEdgeWrapping as H}from"three";import{MeshStandardMaterial as K,MeshBasicMaterial as tt,MeshPhongMaterial as et}from"three";function it(i){return i&&typeof i.getDebugInfo=="function"}var c=class{entity;constructor(t){this.entity=t}getPositionString(){if(this.entity.mesh){let{x:r,y:s,z:o}=this.entity.mesh.position;return`${r.toFixed(2)}, ${s.toFixed(2)}, ${o.toFixed(2)}`}let{x:t,y:e,z:n}=this.entity.options.position||{x:0,y:0,z:0};return`${t.toFixed(2)}, ${e.toFixed(2)}, ${n.toFixed(2)}`}getRotationString(){if(this.entity.mesh){let{x:s,y:o,z:a}=this.entity.mesh.rotation,p=l=>(l*180/Math.PI).toFixed(1);return`${p(s)}\xB0, ${p(o)}\xB0, ${p(a)}\xB0`}let{x:t,y:e,z:n}=this.entity.options.rotation||{x:0,y:0,z:0},r=s=>(s*180/Math.PI).toFixed(1);return`${r(t)}\xB0, ${r(e)}\xB0, ${r(n)}\xB0`}getMaterialInfo(){if(!this.entity.mesh||!this.entity.mesh.material)return{type:"none"};let t=Array.isArray(this.entity.mesh.material)?this.entity.mesh.material[0]:this.entity.mesh.material,e={type:t.type};return(t instanceof K||t instanceof tt||t instanceof et)&&(e.color=`#${t.color.getHexString()}`,e.opacity=t.opacity,e.transparent=t.transparent),"roughness"in t&&(e.roughness=t.roughness),"metalness"in t&&(e.metalness=t.metalness),e}getPhysicsInfo(){if(!this.entity.body)return null;let t={type:this.entity.body.bodyType(),mass:this.entity.body.mass(),isEnabled:this.entity.body.isEnabled(),isSleeping:this.entity.body.isSleeping()},e=this.entity.body.linvel();return t.velocity=`${e.x.toFixed(2)}, ${e.y.toFixed(2)}, ${e.z.toFixed(2)}`,t}buildDebugInfo(){let t={name:this.entity.name||this.entity.uuid,uuid:this.entity.uuid,position:this.getPositionString(),rotation:this.getRotationString(),material:this.getMaterialInfo()},e=this.getPhysicsInfo();if(e&&(t.physics=e),it(this.entity)){let n=this.entity.getDebugInfo();return{...t,...n}}return t}};var f={position:void 0,text:"",fontFamily:'Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace',fontSize:18,fontColor:"#FFFFFF",backgroundColor:null,padding:4,stickToViewport:!0,screenPosition:new ot(24,24),zDistance:1},O=class extends b{createEntity(t){return new g(t)}},at=Symbol("Text"),g=class i extends y{static type=at;_sprite=null;_texture=null;_canvas=null;_ctx=null;_cameraRef=null;_lastCanvasW=0;_lastCanvasH=0;constructor(t){super(),this.options=d(f,t),this.options.screenPosition=T(this.options.screenPosition,f.screenPosition),this.prependSetup(this.textSetup.bind(this)),this.prependUpdate(this.textUpdate.bind(this)),this.onCleanup(this.textDestroy.bind(this))}create(){return this._sprite=null,this._texture=null,this._canvas=null,this._ctx=null,this._lastCanvasW=0,this._lastCanvasH=0,this.group=new nt,this.createSprite(),super.create()}createSprite(){this._canvas=document.createElement("canvas"),this._ctx=this._canvas.getContext("2d"),this._texture=new U(this._canvas),this._texture.minFilter=E,this._texture.magFilter=E;let t=new rt({map:this._texture,transparent:!0,depthTest:!1,depthWrite:!1,alphaTest:.5});this._sprite=new st(t),this.group?.add(this._sprite),this.redrawText(this.options.text??"")}measureAndResizeCanvas(t,e,n,r){if(!this._canvas||!this._ctx)return{sizeChanged:!1};this._ctx.font=`${e}px ${n}`;let s=this._ctx.measureText(t),o=Math.ceil(s.width),a=Math.ceil(e*1.4),p=Math.max(2,o+r*2),l=Math.max(2,a+r*2),w=p!==this._lastCanvasW||l!==this._lastCanvasH;return this._canvas.width=p,this._canvas.height=l,this._lastCanvasW=p,this._lastCanvasH=l,{sizeChanged:w}}drawCenteredText(t,e,n){!this._canvas||!this._ctx||(this._ctx.font=`${e}px ${n}`,this._ctx.textAlign="center",this._ctx.textBaseline="middle",this._ctx.clearRect(0,0,this._canvas.width,this._canvas.height),this.options.backgroundColor&&(this._ctx.fillStyle=this.toCssColor(this.options.backgroundColor),this._ctx.fillRect(0,0,this._canvas.width,this._canvas.height)),this._ctx.fillStyle=this.toCssColor(this.options.fontColor??"#FFFFFF"),this._ctx.fillText(t,this._canvas.width/2,this._canvas.height/2))}updateTexture(t){!this._texture||!this._canvas||(t&&(this._texture.dispose(),this._texture=new U(this._canvas),this._texture.minFilter=E,this._texture.magFilter=E,this._texture.wrapS=H,this._texture.wrapT=H),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))}redrawText(t){if(!this._canvas||!this._ctx)return;let e=this.options.fontSize??18,n=this.options.fontFamily??f.fontFamily,r=this.options.padding??4,{sizeChanged:s}=this.measureAndResizeCanvas(t,e,n,r);this.drawCenteredText(t,e,n),this.updateTexture(!!s),this.options.stickToViewport&&this._cameraRef?this.updateStickyTransform():this.updateWorldSpriteScale()}toCssColor(t){return typeof t=="string"?t:`#${(t instanceof $?t:new $(t)).getHexString()}`}textSetup(t){this._cameraRef=t.camera,this.options.stickToViewport&&this._cameraRef&&(this._cameraRef.camera.add(this.group),this.updateStickyTransform())}textUpdate(t){this._sprite&&this.options.stickToViewport&&this._cameraRef&&this.updateStickyTransform()}getResolution(){return{width:this._cameraRef?.screenResolution.x??1,height:this._cameraRef?.screenResolution.y??1}}getScreenPixels(t,e,n){let r=t.x>=0&&t.x<=1,s=t.y>=0&&t.y<=1;return{px:r?t.x*e:t.x,py:s?t.y*n:t.y}}computeWorldExtents(t,e){let n=1,r=1;if(t.isPerspectiveCamera){let s=t,o=Math.tan(s.fov*Math.PI/180/2)*e;n=o*s.aspect,r=o}else if(t.isOrthographicCamera){let s=t;n=(s.right-s.left)/2,r=(s.top-s.bottom)/2}return{worldHalfW:n,worldHalfH:r}}updateSpriteScale(t,e){if(!this._canvas||!this._sprite)return;let r=t*2/e,s=this._canvas.height,o=Math.max(1e-4,s*r),a=this._canvas.width/this._canvas.height,p=o*a;this._sprite.scale.set(p,o,1)}updateWorldSpriteScale(){if(!this._canvas||!this._sprite)return;let t=this._canvas.width/Math.max(1,this._canvas.height),e=Math.max(1,this.options.fontSize??18),n=Math.max(.25,e/32),r=n*t;this._sprite.scale.set(r,n,1)}updateStickyTransform(){if(!this._sprite||!this._cameraRef)return;let t=this._cameraRef.camera,{width:e,height:n}=this.getResolution(),r=T(this.options.screenPosition,f.screenPosition),{px:s,py:o}=this.getScreenPixels(r,e,n),a=Math.max(.001,this.options.zDistance??1),{worldHalfW:p,worldHalfH:l}=this.computeWorldExtents(t,a),w=s/e*2-1,Q=1-o/n*2,q=w*p,J=Q*l;this.group?.position.set(q,J,-a),this.updateSpriteScale(l,n)}updateText(t){this.options.text=t,this.redrawText(t),this.options.stickToViewport&&this._cameraRef&&this.updateStickyTransform()}buildInfo(){return{...new c(this).buildDebugInfo(),type:String(i.type),text:this.options.text??"",sticky:this.options.stickToViewport}}textDestroy(){this._texture?.dispose(),this._sprite?.material&&this._sprite.material.dispose(),this._sprite&&this._sprite.removeFromParent(),this.group?.removeFromParent(),this._sprite=null,this._texture=null,this._canvas=null,this._ctx=null,this._cameraRef=null}};function I(...i){return S({args:i,defaultConfig:{...f},EntityClass:g,BuilderClass:O,entityType:g.type,cloneFactory:t=>I(t??{})})}import{Euler as pt,Group as lt,Quaternion as ct,Vector3 as mt}from"three";import{TextureLoader as ht,SpriteMaterial as ut,Sprite as dt,SRGBColorSpace as yt}from"three";var W={...v,size:new mt(1,1,1),images:[],animations:[]},R=class extends B{collider(t){let e=C(t.collisionSize,t.size??_);return{shape:{type:"box",halfExtents:[e.x/2,e.y/2,e.z/2]}}}},F=class extends b{createEntity(t){return new x(t)}},ft=Symbol("Sprite"),x=class i extends y{static type=ft;sprites=[];spriteMap=new Map;currentSpriteIndex=0;animations=new Map;currentAnimation=null;currentAnimationFrame="";currentAnimationIndex=0;currentAnimationTime=0;constructor(t){super(),this.options=d(W,t),this.prependSetup(this.spriteSetup.bind(this)),this.prependUpdate(this.spriteUpdate.bind(this)),this.onCleanup(this.spriteDestroy.bind(this))}create(){return this.sprites=[],this.spriteMap.clear(),this.animations.clear(),this.currentAnimation=null,this.currentAnimationFrame="",this.currentAnimationIndex=0,this.currentAnimationTime=0,this.group=void 0,this.createSpritesFromImages(this.options?.images||[]),this.createAnimations(this.options?.animations||[]),super.create()}createSpritesFromImages(t){let e=new ht,n=C(this.options.size,_);t.forEach((r,s)=>{let o=e.load(r.file);o.colorSpace=yt,o.anisotropy=k;let a=new ut({map:o,transparent:!0}),p=new dt(a);p.position.normalize(),p.scale.set(n.x,n.y,n.z),p.visible=s===0,this.sprites.push(p),this.spriteMap.set(r.name,s)}),this.group=new lt,this.group.add(...this.sprites)}createAnimations(t){t.forEach(e=>{let{name:n,frames:r,loop:s=!1,speed:o=1}=e,a={frames:r.map((p,l)=>({key:p,index:l,time:(typeof o=="number"?o:o[l])*(l+1),duration:typeof o=="number"?o:o[l]})),loop:s};this.animations.set(n,a)})}setSprite(t){let n=this.spriteMap.get(t)??0;this.currentSpriteIndex=n,this.sprites.forEach((r,s)=>{r.visible=this.currentSpriteIndex===s})}setAnimation(t,e){let n=this.animations.get(t);if(!n)return;let{loop:r,frames:s}=n,o=s[this.currentAnimationIndex];t===this.currentAnimation?(this.currentAnimationFrame=o.key,this.currentAnimationTime+=e,this.setSprite(this.currentAnimationFrame)):this.currentAnimation=t,this.currentAnimationTime>o.time&&this.currentAnimationIndex++,this.currentAnimationIndex>=s.length&&(r?(this.currentAnimationIndex=0,this.currentAnimationTime=0):this.currentAnimationTime=s[this.currentAnimationIndex].time)}getCurrentRotationQuaternion(){return this.transformStore?.dirty.rotation?this.transformStore.rotation:this.body?.rotation?.()??null}syncSpriteMaterials(){let t=this.getCurrentRotationQuaternion();this.sprites.forEach(e=>{if(e.material&&t){let r=new ct(t.x,t.y,t.z,t.w),s=new pt().setFromQuaternion(r,"XYZ");e.material.rotation=s.z}let n=C(this.options.size,_);e.scale.set(n.x,n.y,n.z)})}spriteSetup(t){this.syncSpriteMaterials()}spriteUpdate(t){this.syncSpriteMaterials()}spriteDestroy(t){this.sprites.forEach(e=>{e.removeFromParent()}),this.group?.remove(...this.sprites),this.group?.removeFromParent()}buildInfo(){return{...new c(this).buildDebugInfo(),type:String(i.type)}}};function P(...i){return S({args:i,defaultConfig:W,EntityClass:x,BuilderClass:F,CollisionBuilderClass:R,entityType:x.type,cloneFactory:t=>P(t??{})})}import{Color as X,Group as xt}from"three";import{Line2NodeMaterial as _t}from"three/webgpu";import{Line2 as Ct}from"three/addons/lines/webgpu/Line2.js";import{Color as N}from"three";import{LineGeometry as gt}from"three/addons/lines/LineGeometry.js";function z(i){let t=[];for(let e of i){let{x:n,y:r,z:s}=u(e,h);t.push(n,r,s)}return t}function L(i,t,e){if(!i||i.length===0)return;let n=[],r=new N(e);for(let s=0;s<t;s++){let o=i[s]??i[i.length-1]??e,a=new N(o??r);n.push(a.r,a.g,a.b)}return n}function Y(i){let t=new gt,e=z(i.points);t.setPositions(e);let n=L(i.colors,i.points.length,"#ffffff");return n&&t.setColors(n),t}var m={...v,points:[{x:0,y:0,z:0},{x:1,y:0,z:0}],linewidth:1,worldUnits:!0,alphaToCoverage:!1,opacity:1,transparent:!1,dashed:!1,dashSize:1,gapSize:1,pickThreshold:0},vt=Symbol("Line");function M(i,t){if(!i||i.length<2)throw new Error(`${t}: at least two points are required`);return i}function j(i){return i instanceof X?i.clone():new X(i??"#ffffff")}function St(i){let t=!!i.colors?.length,e=new _t({color:j(i.color).getHex(),linewidth:i.linewidth??m.linewidth,worldUnits:i.worldUnits??m.worldUnits,vertexColors:t,dashed:i.dashed??!1,dashSize:i.dashSize??m.dashSize,gapSize:i.gapSize??m.gapSize,transparent:i.transparent??!1,opacity:i.opacity??1});return e.alphaToCoverage=i.alphaToCoverage??!1,e}function bt(i){return!i.point||!i.pointOnLine||i.faceIndex==null?null:{point:i.point.clone(),pointOnLine:i.pointOnLine.clone(),faceIndex:i.faceIndex,distance:i.distance}}function Et(i,t,e={}){let n=t.getLineObject();if(!n)return null;let r=e.threshold??t.options.pickThreshold??0,s=i.params.Line2??{threshold:0};s.threshold=r,i.params.Line2=s;let a=i.intersectObject(n,!1)[0];return a?bt(a):null}var Z=class i extends y{static type=vt;_line=null;_geometry=null;_material=null;constructor(t){super();let e=d(m,t);e.points=M(e.points,"ZylemLine").map(n=>u(n,h)),this.options=e}create(){return this.disposeLineResources(),this.group=new xt,this.rebuildLine(),this.applyGroupPosition(),super.create()}setPoints(t,e){if(M(t,"setPoints"),this.options.points=t.map(r=>u(r,h)),e&&(this.options.colors=e),!this._line||!this._geometry||!this._material)return this;this._geometry.setPositions(z(this.options.points));let n=L(this.options.colors,this.options.points.length,j(this.options.color));return n&&this._geometry.setColors(n),this._material.vertexColors=!!this.options.colors?.length,this.options.dashed&&this._line.computeLineDistances(),this._geometry.computeBoundingBox(),this._geometry.computeBoundingSphere(),this}getLineObject(){return this._line}pickFromRaycaster(t,e={}){return Et(t,this,e)}buildInfo(){return{...new c(this).buildDebugInfo(),type:String(i.type),points:this.options.points.length,linewidth:this.options.linewidth??m.linewidth,worldUnits:this.options.worldUnits??m.worldUnits}}rebuildLine(){this._geometry=Y({points:this.options.points,colors:this.options.colors}),this._material=St(this.options),this._line=new Ct(this._geometry,this._material),this.options.dashed&&this._line.computeLineDistances(),this.group?.add(this._line)}applyGroupPosition(){if(!this.group)return;let t=u(this.options.position,h);this.group.position.set(t.x,t.y,t.z)}_cleanup(t){this.disposeLineResources(),super._cleanup(t)}disposeLineResources(){this._line?.removeFromParent(),this._geometry?.dispose(),this._material?.dispose(),this._line=null,this._geometry=null,this._material=null}};function G(...i){let t=V(i,m);M(t.points,"createLine");let e=new Z(t);return D(e,n=>G(n??{}))}var A={registry:new Map,register(i,t){this.registry.set(i,t)},createFromBlueprint(i){let t=this.registry.get(i.type);if(!t)throw new Error(`Unknown entity type: ${i.type}`);let e={...i.data,position:i.position?{x:i.position[0],y:i.position[1],z:0}:void 0,name:i.id};return t(e)}};A.register("text",i=>I(i));A.register("sprite",i=>P(i));A.register("line",i=>G(i));function Ce(i){return{template:i,generate(t){let e=[];for(let n=0;n<t;n++)e.push(i.clone());return e}}}export{c as a,at as b,g as c,I as d,ft as e,x as f,P as g,vt as h,Et as i,Z as j,G as k,A as l,Ce as m};
|