@zylem/game-lib 0.9.6 → 0.9.8
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 +3 -3
- package/dist/api/game-lib.api.json +99183 -42019
- package/dist/api/game-lib.api.md +3822 -706
- package/dist/api/game-lib.d.ts +8703 -784
- package/dist/api/game-lib.typedoc.json +336362 -193038
- package/dist/audio.js +1 -1
- package/dist/behavior/action/fighting.d.ts +1 -0
- package/dist/behavior/action/fighting.js +1 -0
- package/dist/behavior/action/pinball.d.ts +1 -0
- package/dist/behavior/action/pinball.js +1 -0
- package/dist/behavior/action/platform.d.ts +1 -0
- package/dist/behavior/action/platform.js +1 -0
- package/dist/behavior/action/rhythm.d.ts +1 -0
- package/dist/behavior/action/rhythm.js +1 -0
- package/dist/behavior/action/shooter/first-person.d.ts +1 -0
- package/dist/behavior/action/shooter/first-person.js +1 -0
- package/dist/behavior/action/shooter/shoot-em-up.d.ts +1 -0
- package/dist/behavior/action/shooter/shoot-em-up.js +1 -0
- package/dist/behavior/action/shooter.d.ts +1 -0
- package/dist/behavior/action/shooter.js +1 -0
- package/dist/behavior/action/stealth.d.ts +1 -0
- package/dist/behavior/action/stealth.js +1 -0
- package/dist/behavior/action/survival.d.ts +1 -0
- package/dist/behavior/action/survival.js +1 -0
- package/dist/behavior/action-adventure.d.ts +1 -0
- package/dist/behavior/action-adventure.js +1 -0
- package/dist/behavior/action.d.ts +1 -0
- package/dist/behavior/action.js +1 -0
- package/dist/behavior/genre-map.d.ts +1 -0
- package/dist/behavior/genre-map.js +1 -0
- package/dist/behavior/mechanics.d.ts +1 -0
- package/dist/behavior/mechanics.js +1 -0
- package/dist/behavior/puzzle/physics.d.ts +1 -0
- package/dist/behavior/puzzle/physics.js +1 -0
- package/dist/behavior/puzzle/tile-matching.d.ts +1 -0
- package/dist/behavior/puzzle/tile-matching.js +1 -0
- package/dist/behavior/puzzle.d.ts +1 -0
- package/dist/behavior/puzzle.js +1 -0
- package/dist/behavior/role-playing/action-rpg.d.ts +1 -0
- package/dist/behavior/role-playing/action-rpg.js +1 -0
- package/dist/behavior/role-playing/monster-taming.d.ts +1 -0
- package/dist/behavior/role-playing/monster-taming.js +1 -0
- package/dist/behavior/role-playing/tactical-rpg.d.ts +1 -0
- package/dist/behavior/role-playing/tactical-rpg.js +1 -0
- package/dist/behavior/role-playing/turn-based.d.ts +1 -0
- package/dist/behavior/role-playing/turn-based.js +1 -0
- package/dist/behavior/role-playing.d.ts +1 -0
- package/dist/behavior/role-playing.js +1 -0
- package/dist/behavior/simulation/life.d.ts +1 -0
- package/dist/behavior/simulation/life.js +1 -0
- package/dist/behavior/simulation/vehicle/racing.d.ts +1 -0
- package/dist/behavior/simulation/vehicle/racing.js +1 -0
- package/dist/behavior/simulation/vehicle.d.ts +1 -0
- package/dist/behavior/simulation/vehicle.js +1 -0
- package/dist/behavior/simulation.d.ts +1 -0
- package/dist/behavior/simulation.js +1 -0
- package/dist/behavior/sports/golf.d.ts +1 -0
- package/dist/behavior/sports/golf.js +1 -0
- package/dist/behavior/sports/racing.d.ts +1 -0
- package/dist/behavior/sports/racing.js +1 -0
- package/dist/behavior/sports/racket.d.ts +1 -0
- package/dist/behavior/sports/racket.js +1 -0
- package/dist/behavior/sports/skate.d.ts +1 -0
- package/dist/behavior/sports/skate.js +1 -0
- package/dist/behavior/sports.d.ts +1 -0
- package/dist/behavior/sports.js +1 -0
- package/dist/behavior/strategy/real-time-tactics.d.ts +1 -0
- package/dist/behavior/strategy/real-time-tactics.js +1 -0
- package/dist/behavior/strategy/tower-defense.d.ts +1 -0
- package/dist/behavior/strategy/tower-defense.js +1 -0
- package/dist/behavior/strategy/turn-based-tactics.d.ts +1 -0
- package/dist/behavior/strategy/turn-based-tactics.js +1 -0
- package/dist/behavior/strategy.d.ts +1 -0
- package/dist/behavior/strategy.js +1 -0
- package/dist/behavior.d.ts +34 -0
- package/dist/bridge.d.ts +16 -4
- package/dist/bridge.js +1 -1
- package/dist/catalog.d.ts +1 -1
- package/dist/catalog.js +1 -1
- package/dist/chunk-26EJFYDX.js +1 -0
- package/dist/chunk-2NO4YCLR.js +1 -0
- package/dist/chunk-3LXDHDJB.js +1 -0
- package/dist/chunk-4DAITCJS.js +1 -0
- package/dist/{chunk-Y23IJJPD.js → chunk-5NQGXW75.js} +1 -1
- package/dist/chunk-5WRFDAZN.js +1 -0
- package/dist/{chunk-OCQ7A5IK.js → chunk-B6GDESCB.js} +1 -1
- package/dist/chunk-BIZOIGCZ.js +1 -0
- package/dist/chunk-BJYXY2FB.js +1 -0
- package/dist/chunk-CI7A5N6G.js +1 -0
- package/dist/chunk-GQXYD2JG.js +1 -0
- package/dist/{chunk-KIFB427K.js → chunk-ICJ2E2OV.js} +1 -1
- package/dist/chunk-NPA6GUGE.js +24 -0
- package/dist/chunk-SIRFF4DY.js +1 -0
- package/dist/chunk-T6O2SGH5.js +1 -0
- package/dist/chunk-UNCP6V7I.js +1 -0
- package/dist/chunk-Y5IU6IA5.js +1 -0
- package/dist/chunk-YFXNZ2RS.js +1 -0
- package/dist/chunk-YW2GTHCV.js +19 -0
- package/dist/chunk-YWH5HQDT.js +1 -0
- package/dist/cinematics.d.ts +7 -6
- package/dist/core.d.ts +20 -17
- package/dist/core.js +1 -1
- package/dist/{debug-state-DhVkY2aM.d.ts → debug-state-JRneI6c2.d.ts} +2 -2
- package/dist/debug.d.ts +28 -126
- package/dist/debug.js +1 -1
- package/dist/{entity-DC0P747T.d.ts → entity-CY75JJSw.d.ts} +78 -4
- package/dist/{entity-type-map-B0S5cfv7.d.ts → entity-type-map-BMaPY8cd.d.ts} +2 -2
- package/dist/entity.d.ts +5 -5
- package/dist/entity.js +1 -1
- package/dist/fbx-loader-SDI6QYTS.js +1 -0
- package/dist/game-default-AF5QFXSD.js +1 -0
- package/dist/{game-mu6OSCrq.d.ts → game-uQd7k6-m.d.ts} +3 -3
- package/dist/gaussian-splat-loader-ACFJKCCL.js +1 -0
- package/dist/geometry-mesh-loader-XDJV77TU.js +1 -0
- package/dist/graphics.d.ts +3 -3
- package/dist/graphics.js +1 -1
- package/dist/{material-CxxAyJYp.d.ts → material-D1IVeQc5.d.ts} +48 -2
- package/dist/obj-loader-SI5RVY24.js +1 -0
- package/dist/placement-session-BNQoL7Jb.d.ts +82 -0
- package/dist/placement.d.ts +52 -0
- package/dist/placement.js +1 -0
- package/dist/public.d.ts +12 -10
- package/dist/public.js +1 -1
- package/dist/sog-loader-BZFMQ3ZB.js +1 -0
- package/dist/{stage-B_KdSEK6.d.ts → stage-Dez16Gxm.d.ts} +186 -16
- package/dist/transform-gizmo-DappLQ9w.d.ts +123 -0
- package/dist/usd-loader-PCBATNPM.js +1 -0
- package/dist/web-components.d.ts +9 -8
- package/dist/{zylem-camera-CWhIGXlW.d.ts → zylem-camera-BA3VPFlS.d.ts} +9 -0
- package/package.json +150 -7
- package/dist/chunk-47HAZZWF.js +0 -1
- package/dist/chunk-5V52N34T.js +0 -1
- package/dist/chunk-6FGXC4T6.js +0 -19
- package/dist/chunk-FUZDTRCU.js +0 -1
- package/dist/chunk-P6IOYQHU.js +0 -1
- package/dist/chunk-QB3NL7VQ.js +0 -1
- package/dist/chunk-RPMV7GDX.js +0 -24
- package/dist/chunk-VKWJHFUR.js +0 -1
- package/dist/chunk-VXE3CV3K.js +0 -1
- package/dist/chunk-YRHRMVHS.js +0 -1
- package/dist/game-default-VUMUMTXA.js +0 -1
- package/dist/level-types-D10LiOcn.d.ts +0 -91
package/dist/chunk-VXE3CV3K.js
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{d as K,j as B}from"./chunk-6FGXC4T6.js";import{a as N,b as U}from"./chunk-AIQ6IVT5.js";import{e as q}from"./chunk-UUOPT2N4.js";import{a as A,b as $,c as Q}from"./chunk-EVYHPR3J.js";import{d as P}from"./chunk-4QLJUQSJ.js";import{c as m,d as T,e as H,f as X,g as j,h as c,i as Y,j as R}from"./chunk-7WRQ2UAN.js";import{p as W}from"./chunk-XRP4JJXL.js";import{StageBodyKind as te}from"@zylem/behaviors/core";import{Color as Pe,Vector2 as J,Vector3 as ee}from"three";function g(i){if(!i||typeof i!="object")return!1;let e=Object.getPrototypeOf(i);return e===Object.prototype||e===null}function l(i){if(i==null||typeof i=="function"||typeof i!="object")return i;if(i instanceof Pe||i instanceof J||i instanceof ee)return i.clone();if(i instanceof Float32Array)return new Float32Array(i);if(Array.isArray(i))return i.map(e=>l(e));if(g(i)){let e={};for(let[t,o]of Object.entries(i))t!=="_builders"&&(e[t]=l(o));return e}return i}function u(i,e){let t=l(i);if(!e)return t;if(!g(t)||!g(e))return l(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]=l(s);continue}if(r instanceof J&&H(s)){o[n]=Y(s,r);continue}if(r instanceof ee&&X(s)){o[n]=R(s,r);continue}if(g(r)&&g(s)){o[n]=u(r,s);continue}o[n]=l(s)}return o}function ie(i){return i&&i.__kind==="collision"}function z(i){return i.cloneComponent()}function Re(i,e){let t={kind:i?te.Static:te.Dynamic,position:[0,0,0],gravityScale:e.gravityScale??1,canSleep:e.canSleep??!1,ccdEnabled:e.ccdEnabled??!0},o=A(e.lockRotations);o&&(t.lockRotation=o);let n=A(e.lockTranslations);return n&&(t.lockTranslation=n),t}function Be(i,e){if(e.offset){let t=c(e.offset,m);i.offset=[t.x,t.y,t.z]}e.sensor&&(i.sensor=!0),e.collisionType&&(i.collisionGroups=$(e.collisionType,e.collisionFilter))}function h(i,e,t){return Be(i,e),{__kind:"collision",bodyDesc:Re(e.static??!1,e),colliderDesc:i,cloneComponent:t}}function we(i={}){let e=c(i.size,T),t={shape:{type:"box",halfExtents:[e.x/2,e.y/2,e.z/2]}},o=l(i);return h(t,i,()=>we(o))}function Se(i={}){let e={shape:{type:"sphere",radius:i.radius??1}},t=l(i);return h(e,i,()=>Se(t))}function Me(i={}){let e=i.radius??1,o={shape:{type:"cone",halfHeight:(i.height??2)/2,radius:e}},n=l(i);return h(o,i,()=>Me(n))}function De(i={}){let e=i.radius??1,o={shape:{type:"cone",halfHeight:(i.height??2)/2,radius:e}},n=l(i);return h(o,i,()=>De(n))}function _e(i={}){let e=Math.max(i.radiusTop??1,i.radiusBottom??1),o={shape:{type:"cylinder",halfHeight:(i.height??2)/2,radius:e}},n=l(i);return h(o,i,()=>_e(n))}function ke(i={}){let e=i.radius??.5,o={shape:{type:"capsule",halfHeight:(i.length??1)/2,radius:e}},n=l(i);return h(o,i,()=>ke(n))}function Te(i={}){let e=j(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=l(r);return h(s,r,()=>Te(a))}function I(i={}){let e=c(i.size,T),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=l(o);return h(t,o,()=>I(n))}import{Mesh as me,ShaderMaterial as Ue,Group as He}from"three";var oe=import.meta.env.VITE_DEBUG_FLAG==="true";import{nanoid as Ae}from"nanoid";var p=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=Ae()}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(ze(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 ze(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 Xe}from"@zylem/behaviors/core";import{makeMoveable as Ie}from"@zylem/behaviors/core";function ne(i){let e=Ie(i);return W(e)}import{clearVelocityIntent as fe}from"@zylem/behaviors/core";import{Color as Ze,Vector3 as Ne}from"three";import{Quaternion as Ge}from"three";var se=Symbol("explicitSpawnPosition"),w=new Ge;function re(i){return i.filter(e=>!(e instanceof p)).some(e=>e!=null&&typeof e=="object"&&"position"in e)}function ae(i){i[se]=!0}function Ve(i){return i._spawnPositionExplicit?!0:i.options[se]===!0}function Fe(i){return i.options.hideUntilPositioned!==!1}function le(i){return i._spawnPlacementPending===!0}function Le(i){return i._spawnPositionExplicit===!0||i._spawnPlacementReady===!0}function S(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=c(i.options.position,m);e.position.set(t.x,t.y,t.z)}}}function ce(i){let e=i.group??i.mesh;if(!(!e||i.controlledRotation)){if(i.physicsAttached&&i.body)try{let t=i.body.rotation();w.set(t.x,t.y,t.z,t.w),e.setRotationFromQuaternion(w);return}catch{}if(i.wasmStageRef&&(i.runtimeHandle??-1)>=0){let t=i.wasmStageRef.getPose(i.runtimeHandle);t&&(w.set(t.rotation[0],t.rotation[1],t.rotation[2],t.rotation[3]),e.setRotationFromQuaternion(w))}}}function x(i,e){i.group&&(i.group.visible=e),i.mesh&&(i.mesh.visible=e)}function Pt(i){if(i._spawnInProgress=!0,i._spawnPlacementReady=!1,!Fe(i)){i._spawnPlacementPending=!1;return}i._spawnPositionExplicit=Ve(i),i._spawnPlacementPending=!0,x(i,!1)}function Rt(i){i._spawnInProgress=!1}function pe(i){i._spawnPlacementReady=!0}function G(i){if(i._spawnPlacementPending){if(S(i),i._spawnPlacementPending=!1,i.options.visible===!1){x(i,!1);return}x(i,!0)}}function Bt(i){!le(i)||i.options.hideUntilPositioned===!0&&!Le(i)||G(i)}function ue(i){S(i),i._spawnPlacementPending=!1,x(i,!0)}function wt(i){le(i)&&x(i,!1)}var M={position:new Ne(0,0,0),material:{color:new Ze("#ffffff"),shader:K},collision:{static:!1}};function de(i,e){let t=i.filter(n=>!(n instanceof p)),o=u(e);for(let n of t)o=u(o,n);return re(i)&&ae(o),o}function je(i){return i!=null&&typeof i=="object"}function he(i){return{phase:i?.phase??"stay",cooldownMs:i?.cooldownMs}}function Ye(){return typeof performance<"u"&&typeof performance.now=="function"?performance.now():Date.now()}var v=class extends p{group;mesh;materials;bodyDesc=null;body=null;physicsAttached=!1;physicsWorldRef=null;colliderDesc;custom={};colliderBaseline=null;colliderScaleDirty=!1;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 N;behaviorRefs=[];cloneFactory=null;trackAddedComponents=!1;trackedComponents=[];transformStore;_scale={x:1,y:1,z:1};_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=Xe(),ne(this),this.wrapSpawnPlacementMutators()}wrapSpawnPlacementMutators(){let e=()=>{pe(this),!this._spawnInProgress&&(S(this),G(this))},t=r=>(a,f,y)=>{!this.body&&!(this.wasmStageRef&&this.runtimeHandle>=0)||(r(a,f,y),e())},o=r=>a=>{!this.body&&!(this.wasmStageRef&&this.runtimeHandle>=0)||(r(a),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._spawnInProgress||ce(this)},s=this.setPose.bind(this);this.setPose=r=>{let a=s(r);return a&&(r.position!=null&&e(),r.rotation!=null&&n(),a)}}reveal(){this.options.visible=!0,ue(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=c(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&&this.body?.markPoseDiscontinuity(),o}let t=this.body;if(!t)return!1;if(e.position){let o=c(e.position);t.setTranslation({x:o.x,y:o.y,z:o.z},!0)}return e.rotation&&t.setRotation(e.rotation,!0),!0}getScale(){return{...this._scale}}setScale(e,t,o){this._scale={x:e,y:t,z:o},(this.group??this.mesh)?.scale.set(e,t,o),this.colliderScaleDirty=!0}add(...e){for(let t of e)t instanceof me?(this.addMeshComponent(t),this.trackComponent(t)):ie(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 He,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=c(this.options?.position,m);this.bodyDesc.position=[t.x,t.y,t.z]}}trackComponent(e){if(this.trackAddedComponents){if(e instanceof me){this.trackedComponents.push({kind:"mesh",component:ye(e)});return}this.trackedComponents.push({kind:"collision",component:z(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,fe(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,fe(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(u(this.options,e)),o=this.copyBehaviorRefsTo(t),n=r=>We(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(ye(r.component));continue}t.add(z(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||je(e[1]))){let n=e[0];if(!n)return this;let s=e[1];return t.push({id:o,callback:n,options:he(s)}),o+=1,this.collisionDelegate.collision=t,this.collisionDelegate.nextId=o,this}for(let n of e)t.push({id:o,callback:n,options:he()}),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}getBehaviorRef(e){return this.behaviorRefs.find(t=>t.descriptor.key===e.key)??null}hasBehavior(e){return this.getBehaviorRef(e)!==null}removeBehavior(e){let t="descriptor"in e?this.behaviorRefs.indexOf(e):this.behaviorRefs.findIndex(n=>n.descriptor.key===e.key);if(t===-1)return null;let[o]=this.behaviorRefs.splice(t,1);return o??null}restoreBehaviorRef(e){this.behaviorRefs.includes(e)||this.behaviorRefs.push(e)}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,l(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:Ye()}){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}`,f=n.get(a);if(f!=null&&o.nowMs-f<r)continue;n.set(a,o.nowMs)}s.callback({entity:this,other:e,globals:t})}}hasMaterial(){return this.mesh!==void 0||this.compoundMeshes.length>0}getMaterials(){return this.materials?[...this.materials]:[]}setMaterial(e,t={}){if(!this.hasMaterial())return null;let o=new B,n=this.constructor.type??Symbol.for("zylem:entity");return o.build(e,n),this.replaceMaterials(o.materials,t)}replaceMaterials(e,t={}){if(!this.hasMaterial()||e.length===0)return null;let{disposePrevious:o=!0}=t,n=this.materials?[...this.materials]:[],s=r=>{Array.isArray(r.material)?r.material=r.material.map((a,f)=>e[f%e.length]):r.material=e[0]};this.mesh&&s(this.mesh);for(let r of this.compoundMeshes)s(r);if(this.materials=[...e],o)for(let r of n)e.includes(r)||r.dispose();return n}updateMaterials(e){if(this.materials?.length)for(let t of this.materials)t instanceof Ue&&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),U.emit(e,t)}listen(e,t){return this.eventDelegate.listen(e,t)}disposeEvents(){this.eventDelegate.dispose()}};function Ke(i){let e=new v;return e.options={...M,...i},E(e,t=>Ke(t??{}))}function ye(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 We(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 E(i,e){return i.finalizeCloneSupport(e),i}function be(i){return typeof i?.load=="function"&&typeof i?.data=="function"}var D=class{entityReference;constructor(e){this.entityReference=e}load(){this.entityReference.load&&this.entityReference.load()}data(){return this.entityReference.data?this.entityReference.data():null}};function ai(i){let{args:e,defaultConfig:t,EntityClass:o,BuilderClass:n,entityType:s,MeshBuilderClass:r,CollisionBuilderClass:a,cloneFactory:f}=i,y=null,b,L=e.findIndex(d=>!(d instanceof p));L!==-1&&(b=e.splice(L,1).find(C=>!(C instanceof p)));let Oe=b?u(t,b):u(t);e.push(Oe);for(let d of e){if(d instanceof p)continue;let C=null,k=new o(d);try{if(be(k)){let O=new D(k);O.load(),C=O.data()}}catch(O){console.error("Error creating entity with loader:",O)}y=new n(d,k,r?new r(C):null,a?new a(C):null),d.material&&y.withMaterial(d.material,s)}if(!y)throw new Error(`missing options for ${String(s)}, builder is not initialized.`);let Z=y.build();return b!=null&&typeof b=="object"&&"position"in b&&(Z._spawnPositionExplicit=!0),E(Z,d=>f(d))}import{Vector3 as V}from"three";var Ce={...M,size:new V(1,1,1),collision:{static:!0}},$e=Symbol("Zone"),F=class extends v{static type=$e;_enteredZone=new Map;_exitedZone=new Map;_zoneEntities=new Map;constructor(e){super(),this.options=u(Ce,e)}getSelectionBounds(e){let t=R(this.options.size,new V(1,1,1)),o=this.getPose()?.position??c(this.options.position,m);return e.setFromCenterAndSize(new V(o.x,o.y,o.z),t),q(e)}handlePostCollision({delta:e}){return this._enteredZone.forEach((t,o)=>{this.exited(e,o)}),this._enteredZone.size>0}handleIntersectionEvent({other:e,delta:t}){this._enteredZone.get(e.uuid)?this.held(t,e):(this.entered(e),this._zoneEntities.set(e.uuid,e))}onEnter(e){return this.options.onEnter=e,this}onHeld(e){return this.options.onHeld=e,this}onExit(e){return this.options.onExit=e,this}entered(e){this._enteredZone.set(e.uuid,1),this.options.onEnter&&this.options.onEnter({self:this,visitor:e,globals:P.globals})}exited(e,t){let o=this._exitedZone.get(t);if(o&&o>1+e){this._exitedZone.delete(t),this._enteredZone.delete(t);let n=this._zoneEntities.get(t);this.options.onExit&&this.options.onExit({self:this,visitor:n,globals:P.globals});return}this._exitedZone.set(t,1+e)}held(e,t){let o=this._enteredZone.get(t.uuid)??0;this._enteredZone.set(t.uuid,o+e),this._exitedZone.set(t.uuid,1),this.options.onHeld&&this.options.onHeld({delta:e,self:this,visitor:t,globals:P.globals,heldTime:o})}};function Qe(...i){let e=de(i,Ce),t=new F(e);return t.add(I({size:e.size,static:e.collision?.static??!0,collisionType:e.collisionType,collisionFilter:e.collisionFilter})),E(t,o=>Qe(o??{}))}import{BufferGeometry as Je,Mesh as ge,Color as et}from"three";import{Mesh as qe}from"three";var _=class{_build(e,t,o){let n=new qe(t,o.at(-1));return n.position.set(0,0,0),n.castShadow=!0,n.receiveShadow=!0,n}_postBuild(){}};var xe=class extends Q{},ve=class extends _{build(e){return new Je}postBuild(){}},Ee=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 B;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 ge&&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}=c(this.options.position,m);e.bodyDesc.position=[n,s,r]}if(this.options.collisionType&&(e.collisionType=this.options.collisionType),this.options.color instanceof et){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 ge&&o.material){let n=o.material;Array.isArray(n)?n.forEach(t):t(n)}})}return e}};export{p as a,u as b,we as c,Se as d,Me as e,De as f,_e as g,ke as h,Te as i,I as j,le as k,S as l,Pt as m,Rt as n,Bt as o,ue as p,wt as q,M as r,de as s,v as t,Ke as u,E as v,xe as w,ve as x,Ee as y,ai as z,$e as A,F as B,Qe as C};
|
package/dist/chunk-YRHRMVHS.js
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{F as U,G as B,H as X,I as N,a as f}from"./chunk-5V52N34T.js";import{b as u,r as C,s as k,t as d,v as G,w as D,y as v,z as b}from"./chunk-VXE3CV3K.js";import{e as V}from"./chunk-6FGXC4T6.js";import{c as h,d as y,h as m,i as T,j as x}from"./chunk-7WRQ2UAN.js";import{Color as W,Group as ot,Sprite as at,SpriteMaterial as pt,CanvasTexture as H,LinearFilter as w,Vector2 as lt,ClampToEdgeWrapping as Y}from"three";var g={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 lt(24,24),zDistance:1},E=class extends v{createEntity(t){return new _(t)}},ct=Symbol("Text"),_=class i extends d{static type=ct;_sprite=null;_texture=null;_canvas=null;_ctx=null;_cameraRef=null;_lastCanvasW=0;_lastCanvasH=0;constructor(t){super(),this.options=u(g,t),this.options.screenPosition=T(this.options.screenPosition,g.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 ot,this.createSprite(),super.create()}createSprite(){this._canvas=document.createElement("canvas"),this._ctx=this._canvas.getContext("2d"),this._texture=new H(this._canvas),this._texture.minFilter=w,this._texture.magFilter=w;let t=new pt({map:this._texture,transparent:!0,depthTest:!1,depthWrite:!1,alphaTest:.5});this._sprite=new at(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),st=p!==this._lastCanvasW||l!==this._lastCanvasH;return this._canvas.width=p,this._canvas.height=l,this._lastCanvasW=p,this._lastCanvasH=l,{sizeChanged:st}}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 H(this._canvas),this._texture.minFilter=w,this._texture.magFilter=w,this._texture.wrapS=Y,this._texture.wrapT=Y),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??g.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 W?t:new W(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()}screenPoint(t){let e=T(this.options.screenPosition,g.screenPosition);if(this.options.screenAnchor)return B(this.options.screenAnchor,e,t);let n=e.x>=0&&e.x<=1,r=e.y>=0&&e.y<=1;return{x:n?e.x*t.width:e.x,y:r?e.y*t.height:e.y}}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||!this._canvas)return;let t=X(this._cameraRef),e=N({camera:this._cameraRef.camera,viewport:t,point:this.screenPoint(t),pivot:this.options.screenAnchor?U(this.options.screenAnchor):{x:.5,y:.5},size:{width:this._canvas.width,height:this._canvas.height},zDistance:this.options.zDistance??1});this._sprite.scale.set(e.scale.x,e.scale.y,1),this.group?.position.set(e.position.x,e.position.y,e.position.z)}updateText(t){this.options.text=t,this.redrawText(t),this.options.stickToViewport&&this._cameraRef&&this.updateStickyTransform()}buildInfo(){return{...new f(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 O(...i){return b({args:i,defaultConfig:{...g},EntityClass:_,BuilderClass:E,entityType:_.type,cloneFactory:t=>O(t??{})})}import{Euler as ht,Group as $,Quaternion as mt,Vector3 as ut}from"three";import{TextureLoader as j,SpriteMaterial as Q,Sprite as q,SRGBColorSpace as J}from"three";import{ClampToEdgeWrapping as K,LinearFilter as dt,NearestFilter as ft}from"three";var tt={...C,size:new ut(1,1,1),images:[],animations:[]},F=class extends D{collider(t){let e=x(t.collisionSize,t.size??y);return{shape:{type:"box",halfExtents:[e.x/2,e.y/2,e.z/2]}}}},z=class extends v{createEntity(t){return new S(t)}},yt=Symbol("Sprite"),S=class i extends d{static type=yt;sprites=[];spriteMap=new Map;currentSpriteIndex=0;animations=new Map;currentAnimation=null;currentAnimationFrame="";currentAnimationIndex=0;currentAnimationTime=0;sheetTexture=null;flippedX=!1;constructor(t){super(),this.options=u(tt,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.sheetTexture=null,this.group=void 0,this.options?.sheet?this.createSpriteFromSheet(this.options.sheet):this.createSpritesFromImages(this.options?.images||[]),this.createAnimations(this.options?.animations||[]),super.create()}createSpritesFromImages(t){let e=new j,n=x(this.options.size,y);t.forEach((r,s)=>{let o=e.load(r.file);o.colorSpace=J,o.anisotropy=V;let a=new Q({map:o,transparent:!0}),p=new q(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 $,this.group.add(...this.sprites)}createSpriteFromSheet(t){let e=x(this.options.size,y),n=new j().load(t.file);n.colorSpace=J,n.wrapS=K,n.wrapT=K;let r=t.filter==="linear"?dt:ft;n.magFilter=r,n.minFilter=r,n.generateMipmaps=!1,n.repeat.set(1/t.columns,1/t.rows);let s=new Q({map:n,transparent:!0}),o=new q(s);o.position.normalize(),o.scale.set(e.x,e.y,e.z),this.sheetTexture=n,this.sprites.push(o),t.frames.forEach((p,l)=>{p&&this.spriteMap.set(p,l)}),this.group=new $,this.group.add(o);let a=t.frames.find(p=>!!p);a&&this.setSprite(a)}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,duration:typeof o=="number"?o:o[l]})),loop:s};this.animations.set(n,a)})}setSprite(t){let n=this.spriteMap.get(t)??0;if(this.currentSpriteIndex=n,this.sheetTexture){this.applySheetFrame(n);return}this.sprites.forEach((r,s)=>{r.visible=this.currentSpriteIndex===s})}setFlipX(t){if(this.flippedX!==t){if(this.flippedX=t,this.sheetTexture){this.applySheetFrame(this.currentSpriteIndex);return}this.sprites.forEach(e=>{e.material.map?.repeat.setX(t?-1:1),e.material.map?.offset.setX(t?1:0)})}}isFlippedX(){return this.flippedX}applySheetFrame(t){let e=this.options.sheet,n=this.sheetTexture;if(!e||!n)return;let r=t%e.columns,s=Math.floor(t/e.columns),o=1/e.columns,a=1/e.rows;n.repeat.x=this.flippedX?-o:o,n.offset.x=this.flippedX?(r+1)*o:r*o,n.offset.y=1-(s+1)*a}setAnimation(t,e){let n=this.animations.get(t);if(!n)return;let{loop:r,frames:s}=n;if(s.length!==0){for(t!==this.currentAnimation?(this.currentAnimation=t,this.currentAnimationIndex=0,this.currentAnimationTime=0):this.currentAnimationTime+=e;;){let o=s[this.currentAnimationIndex].duration;if(!(o>0)||this.currentAnimationTime<o)break;if(this.currentAnimationTime-=o,this.currentAnimationIndex+1<s.length)this.currentAnimationIndex++;else if(r)this.currentAnimationIndex=0;else{this.currentAnimationTime=0;break}}this.currentAnimationFrame=s[this.currentAnimationIndex].key,this.setSprite(this.currentAnimationFrame)}}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 mt(t.x,t.y,t.z,t.w),s=new ht().setFromQuaternion(r,"XYZ");e.material.rotation=s.z}let n=x(this.options.size,y);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(),this.sheetTexture?.dispose(),this.sheetTexture=null}buildInfo(){return{...new f(this).buildDebugInfo(),type:String(i.type)}}};function L(...i){return b({args:i,defaultConfig:tt,EntityClass:S,BuilderClass:z,CollisionBuilderClass:F,entityType:S.type,cloneFactory:t=>L(t??{})})}import{Color as nt,Group as gt}from"three";import{Line2NodeMaterial as _t}from"three/webgpu";import{Line2 as St}from"three/addons/lines/webgpu/Line2.js";import{Color as et}from"three";import{LineGeometry as xt}from"three/addons/lines/LineGeometry.js";function I(i){let t=[];for(let e of i){let{x:n,y:r,z:s}=m(e,h);t.push(n,r,s)}return t}function A(i,t,e){if(!i||i.length===0)return;let n=[],r=new et(e);for(let s=0;s<t;s++){let o=i[s]??i[i.length-1]??e,a=new et(o??r);n.push(a.r,a.g,a.b)}return n}function it(i){let t=new xt,e=I(i.points);t.setPositions(e);let n=A(i.colors,i.points.length,"#ffffff");return n&&t.setColors(n),t}var c={...C,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},Ct=Symbol("Line");function R(i,t){if(!i||i.length<2)throw new Error(`${t}: at least two points are required`);return i}function rt(i){return i instanceof nt?i.clone():new nt(i??"#ffffff")}function vt(i){let t=!!i.colors?.length,e=new _t({color:rt(i.color).getHex(),linewidth:i.linewidth??c.linewidth,worldUnits:i.worldUnits??c.worldUnits,vertexColors:t,dashed:i.dashed??!1,dashSize:i.dashSize??c.dashSize,gapSize:i.gapSize??c.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 wt(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 P=class i extends d{static type=Ct;_line=null;_geometry=null;_material=null;constructor(t){super();let e=u(c,t);e.points=R(e.points,"ZylemLine").map(n=>m(n,h)),this.options=e}create(){return this.disposeLineResources(),this.group=new gt,this.rebuildLine(),this.applyGroupPosition(),super.create()}setPoints(t,e){if(R(t,"setPoints"),this.options.points=t.map(r=>m(r,h)),e&&(this.options.colors=e),!this._line||!this._geometry||!this._material)return this;this._geometry.setPositions(I(this.options.points));let n=A(this.options.colors,this.options.points.length,rt(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 wt(t,this,e)}buildInfo(){return{...new f(this).buildDebugInfo(),type:String(i.type),points:this.options.points.length,linewidth:this.options.linewidth??c.linewidth,worldUnits:this.options.worldUnits??c.worldUnits}}rebuildLine(){this._geometry=it({points:this.options.points,colors:this.options.colors}),this._material=vt(this.options),this._line=new St(this._geometry,this._material),this.options.dashed&&this._line.computeLineDistances(),this.group?.add(this._line)}applyGroupPosition(){if(!this.group)return;let t=m(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 Z(...i){let t=k(i,c);R(t.points,"createLine");let e=new P(t);return G(e,n=>Z(n??{}))}var M={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)}};M.register("text",i=>O(i));M.register("sprite",i=>L(i));M.register("line",i=>Z(i));function Se(i){return{template:i,generate(t){let e=[];for(let n=0;n<t;n++)e.push(i.clone());return e}}}export{ct as a,_ as b,O as c,yt as d,S as e,L as f,Ct as g,wt as h,P as i,Z as j,M as k,Se as l};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{z as e}from"./chunk-P6IOYQHU.js";import"./chunk-47HAZZWF.js";import"./chunk-2HSR5XDQ.js";import"./chunk-VKWJHFUR.js";import"./chunk-273CUPEO.js";import"./chunk-UM5VNQPY.js";import"./chunk-WBQ5TNRZ.js";import"./chunk-FUZDTRCU.js";import"./chunk-VXE3CV3K.js";import"./chunk-6FGXC4T6.js";import"./chunk-AIQ6IVT5.js";import"./chunk-QXVH6POE.js";import"./chunk-UUOPT2N4.js";import"./chunk-EVYHPR3J.js";import"./chunk-D2PATZCC.js";import"./chunk-4QLJUQSJ.js";import"./chunk-7WRQ2UAN.js";import"./chunk-BH53MBAZ.js";import"./chunk-XRP4JJXL.js";import"./chunk-UG22Z42P.js";import"./chunk-WOT6VMZA.js";import{proxy as t}from"valtio/vanilla";var s=()=>({id:"zylem",globals:{},stages:[e()],debug:!1,time:0,input:void 0}),a=t({...s()});function o(){return{id:a.id??"zylem",globals:a.globals??{},stages:a.stages??[e()],debug:a.debug,time:a.time,input:a.input}}export{o as getGameDefaultConfig};
|
|
@@ -1,91 +0,0 @@
|
|
|
1
|
-
import { BridgePose, BridgeVec3 } from '@zylem/bridge';
|
|
2
|
-
|
|
3
|
-
/**
|
|
4
|
-
* Convex brush kernel.
|
|
5
|
-
*
|
|
6
|
-
* A brush is the intersection of half-spaces: a point is inside when
|
|
7
|
-
* `normal · point <= distance` for every plane. The normal points outward.
|
|
8
|
-
* Planes are world-space, so moving a brush shifts every distance by
|
|
9
|
-
* `normal · delta`. No Three.js and no physics types.
|
|
10
|
-
*
|
|
11
|
-
* Copy of `packages/bridge/src/level/brush.ts`, kept inside this package so
|
|
12
|
-
* the declaration build does not reach outside `src`.
|
|
13
|
-
*/
|
|
14
|
-
interface BrushVec3 {
|
|
15
|
-
x: number;
|
|
16
|
-
y: number;
|
|
17
|
-
z: number;
|
|
18
|
-
}
|
|
19
|
-
interface BrushPlane {
|
|
20
|
-
normal: BrushVec3;
|
|
21
|
-
/** The solid is `normal · point <= distance`. */
|
|
22
|
-
distance: number;
|
|
23
|
-
}
|
|
24
|
-
|
|
25
|
-
/**
|
|
26
|
-
* Level document shapes shared with the editor over the bridge.
|
|
27
|
-
*
|
|
28
|
-
* Defined here, matching `packages/bridge/src/protocol.ts`, because the
|
|
29
|
-
* installed `@zylem/bridge` build does not export them yet and the
|
|
30
|
-
* declaration build cannot import files outside this package.
|
|
31
|
-
*/
|
|
32
|
-
|
|
33
|
-
/** Which list in a level document an edit or a visibility toggle addresses. */
|
|
34
|
-
type LevelLayerId = 'solid' | 'doodad' | 'entity';
|
|
35
|
-
/** One convex solid. Planes are world-space half-spaces. */
|
|
36
|
-
interface BrushSolid {
|
|
37
|
-
id: string;
|
|
38
|
-
planes: BrushPlane[];
|
|
39
|
-
}
|
|
40
|
-
/** A visual placement. Spawned with no collider. */
|
|
41
|
-
interface DoodadPlacement {
|
|
42
|
-
id: string;
|
|
43
|
-
typeId: string;
|
|
44
|
-
pose: BridgePose;
|
|
45
|
-
props: Record<string, unknown>;
|
|
46
|
-
}
|
|
47
|
-
/**
|
|
48
|
-
* A gameplay marker.
|
|
49
|
-
*
|
|
50
|
-
* `typeId` is `spawn` or `zone`. Spawn props carry `spawnKind`
|
|
51
|
-
* (`player` | `enemy` | `item`) and `archetype`. Trigger props carry `size`.
|
|
52
|
-
*/
|
|
53
|
-
interface EntityPlacement {
|
|
54
|
-
id: string;
|
|
55
|
-
typeId: string;
|
|
56
|
-
name: string;
|
|
57
|
-
pose: BridgePose;
|
|
58
|
-
props: Record<string, unknown>;
|
|
59
|
-
}
|
|
60
|
-
/**
|
|
61
|
-
* The level file. The editor owns it; the stage only previews and plays it.
|
|
62
|
-
*
|
|
63
|
-
* `version` is 2 so a v1 catalog buffer is recognisable and left alone.
|
|
64
|
-
*/
|
|
65
|
-
interface LevelDocument {
|
|
66
|
-
version: 2;
|
|
67
|
-
solids: BrushSolid[];
|
|
68
|
-
doodads: DoodadPlacement[];
|
|
69
|
-
entities: EntityPlacement[];
|
|
70
|
-
}
|
|
71
|
-
/** What the Add tool will write into the document on the next click. */
|
|
72
|
-
type LevelPlacementArm = {
|
|
73
|
-
kind: 'doodad';
|
|
74
|
-
typeId: string;
|
|
75
|
-
props?: Record<string, unknown>;
|
|
76
|
-
} | {
|
|
77
|
-
kind: 'spawn';
|
|
78
|
-
} | {
|
|
79
|
-
kind: 'trigger';
|
|
80
|
-
size: BridgeVec3;
|
|
81
|
-
};
|
|
82
|
-
/** Edit-time preview. Hidden layers are omitted; play ignores this and streams everything. */
|
|
83
|
-
interface LevelSyncPayload {
|
|
84
|
-
document: LevelDocument;
|
|
85
|
-
hiddenLayers: LevelLayerId[];
|
|
86
|
-
selectedIds: string[];
|
|
87
|
-
activeLayer: LevelLayerId;
|
|
88
|
-
placement: LevelPlacementArm | null;
|
|
89
|
-
}
|
|
90
|
-
|
|
91
|
-
export type { LevelDocument as L, LevelSyncPayload as a };
|