@zylem/game-lib 0.8.2 → 0.8.4
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 +5 -5
- package/dist/api/game-lib.api.json +2079 -1214
- package/dist/api/game-lib.api.md +150 -97
- package/dist/api/game-lib.d.ts +321 -95
- package/dist/api/game-lib.typedoc.json +141279 -214520
- package/dist/bridge.d.ts +111 -0
- package/dist/bridge.js +1 -0
- package/dist/{chunk-KVSJE4XD.js → chunk-3I537JFL.js} +1 -1
- package/dist/chunk-4CHZUWLF.js +1 -0
- package/dist/chunk-6B5JP7T5.js +24 -0
- package/dist/chunk-AIQ6IVT5.js +1 -0
- package/dist/chunk-C5NEGC3S.js +1 -0
- package/dist/chunk-D3JO4HW2.js +1 -0
- package/dist/chunk-HNCTOJP7.js +1 -0
- package/dist/chunk-LKFF6XJC.js +1 -0
- package/dist/{chunk-CD7ZOZ35.js → chunk-OAWK2UUY.js} +1 -1
- package/dist/chunk-PNLNC3FA.js +1 -0
- package/dist/chunk-TV3AZKT4.js +9 -0
- package/dist/chunk-VIPINV7V.js +19 -0
- package/dist/chunk-W5SXED5T.js +1 -0
- package/dist/{chunk-YAOXFYOD.js → chunk-WBQ5TNRZ.js} +1 -1
- package/dist/{collision-builder-B_tm8OVy.d.ts → collision-builder-4TVDzXsp.d.ts} +1 -1
- package/dist/core.d.ts +11 -11
- package/dist/core.js +1 -1
- package/dist/debug-state-s0s-qndj.d.ts +49 -0
- package/dist/debug.d.ts +32 -7
- package/dist/debug.js +1 -1
- package/dist/{entity-BGEq1yfC.d.ts → entity-BI7cSlK8.d.ts} +3 -3
- package/dist/{entity-B9yZeBm4.d.ts → entity-DDks47JB.d.ts} +1 -1
- package/dist/{entity-type-map-CW6RHQkx.d.ts → entity-type-map-COHu4fkW.d.ts} +41 -7
- package/dist/entity.d.ts +7 -7
- package/dist/entity.js +1 -1
- package/dist/events.d.ts +1 -64
- package/dist/events.js +1 -1
- package/dist/{game-DbqBQiFC.d.ts → game-4fsy55uN.d.ts} +55 -27
- package/dist/game-default-4PPYYGAR.js +1 -0
- package/dist/graphics.d.ts +5 -5
- package/dist/{material-DbSuZBbP.d.ts → material-BKPYeBC6.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 → vector-DPbwlzgG.d.ts} +10 -2
- package/dist/web-components.d.ts +9 -9
- package/dist/web-components.js +1 -1
- package/dist/{zylem-camera-Du2UPW9O.d.ts → zylem-camera-B73ZNcgs.d.ts} +1 -1
- package/package.json +20 -14
- package/LICENSE +0 -21
- package/dist/chunk-3PRBSSTS.js +0 -24
- package/dist/chunk-CFVRRRZZ.js +0 -1
- package/dist/chunk-COM6HJ2L.js +0 -1
- package/dist/chunk-JQKS42G4.js +0 -1
- package/dist/chunk-MZZCDXFB.js +0 -1
- package/dist/chunk-TAUWDQZF.js +0 -9
- package/dist/chunk-VS2D4B3W.js +0 -1
- package/dist/chunk-YHEWKN7N.js +0 -1
- package/dist/debug-state-DRoeasG2.d.ts +0 -17
- package/dist/game-default-6AZZCNST.js +0 -1
package/dist/chunk-COM6HJ2L.js
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{a as u}from"./chunk-VS2D4B3W.js";import{DirectionalLight as b,PerspectiveCamera as f,RenderTarget as T,Scene as E,Color as v,LinearFilter as g}from"three";var w=128,h=class{cache=new Map;inFlight=new Map;renderer=null;size;constructor(e=w){this.size=e}setRenderer(e){this.renderer=e}get(e){return this.cache.get(e)??null}invalidate(e){this.cache.delete(e),this.inFlight.delete(e)}clear(){this.cache.clear(),this.inFlight.clear()}async ensure(e,i){let t=this.cache.get(e);if(t)return t;let r=this.inFlight.get(e);if(r)return r;if(!i||!this.renderer)return null;let s=this.render(e,i).then(n=>(this.inFlight.delete(e),n?(this.cache.set(e,n),n):null)).catch(n=>(this.inFlight.delete(e),console.warn("EntityThumbnailCache: failed to render thumbnail",e,n),null));return this.inFlight.set(e,s),s}async render(e,i){let t=this.renderer;if(!t)return null;let r=new E;r.background=new v(3815994);let s=new b(16777215,2);s.position.set(5,10,7),r.add(s);let n=i.clone(!0);n.position.set(0,0,0),n.rotation.set(0,0,0),n.updateMatrixWorld(!0),r.add(n);let a=new f(50,1,.1,100),l=u(n,a),o=new T(this.size,this.size,{minFilter:g,magFilter:g}),m=t.getRenderTarget(),p=t.getScissorTest();try{t.setScissorTest(!1),t.setRenderTarget(o),t.render(r,a)}finally{t.setRenderTarget(m),t.setScissorTest(p)}let y=await t.readRenderTargetPixelsAsync(o,0,0,this.size,this.size);o.dispose(),r.remove(n);let d=R(y,this.size,this.size);return d?{uuid:e,dataUrl:d,bounds:{width:l.width,height:l.height,depth:l.depth}}:null}},D=new h;function R(c,e,i){if(typeof document>"u")return null;let t=document.createElement("canvas");t.width=e,t.height=i;let r=t.getContext("2d");if(!r)return null;let s=c instanceof Uint8Array?c:new Uint8Array(c.buffer,c.byteOffset,c.byteLength),n=r.createImageData(e,i);for(let a=0;a<i;a+=1){let l=(i-1-a)*e*4,o=a*e*4;n.data.set(s.subarray(l,l+e*4),o)}return r.putImageData(n,0,0),t.toDataURL("image/png")}export{h as a,D as b};
|
package/dist/chunk-JQKS42G4.js
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{proxy as n}from"valtio/vanilla";var e=n({enabled:!1,paused:!1,tool:"none",selectedEntity:null,hoveredEntity:null,flags:new Set});function l(){return e.paused}function i(t){e.paused=t}function a(){return e.tool}function r(t){e.tool=t}function u(t){e.selectedEntity=t}function s(){return e.hoveredEntity}function d(t){e.hoveredEntity=t}function y(){e.hoveredEntity=null}export{e as a,l as b,i as c,a as d,r as e,u as f,s as g,d as h,y as i};
|
package/dist/chunk-MZZCDXFB.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-KVSJE4XD.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};
|
package/dist/chunk-TAUWDQZF.js
DELETED
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
import{a as n,c as o,e as a}from"./chunk-JQKS42G4.js";var s=class r extends HTMLElement{_game=null;_state={};container;resizeObserver=null;_viewportProfile="auto";static HOST_CONFIG_MARKER=Symbol("zylem:host-config");constructor(){super(),this.attachShadow({mode:"open"});let e=document.createElement("style");e.textContent=`
|
|
2
|
-
:host {
|
|
3
|
-
display: block;
|
|
4
|
-
width: 100%;
|
|
5
|
-
height: 100%;
|
|
6
|
-
min-width: 0;
|
|
7
|
-
min-height: 0;
|
|
8
|
-
}
|
|
9
|
-
`,this.container=document.createElement("div"),this.container.style.width="100%",this.container.style.height="100%",this.container.style.position="relative",this.container.style.outline="none",this.container.tabIndex=0,this.shadowRoot.append(e,this.container)}focus(){this.container.focus()}connectedCallback(){typeof ResizeObserver<"u"&&!this.resizeObserver&&(this.resizeObserver=new ResizeObserver(()=>{this.syncDisplayRuntime()}),this.resizeObserver.observe(this)),this.syncDisplayRuntime()}set game(e){this._game&&this._game.dispose(),this._game=e,this.attachHostContainer(e),this.syncDisplayRuntime(),e.start()}get game(){return this._game}set state(e){this._state=e,this.syncDebugState(),this.syncToolbarState()}get state(){return this._state}set viewportProfile(e){let t=e==="mobile"||e==="desktop"?e:"auto";this._viewportProfile!==t&&(this._viewportProfile=t,this.syncDisplayRuntime())}get viewportProfile(){return this._viewportProfile}static get observedAttributes(){return["viewport-profile"]}attributeChangedCallback(e,t,i){e==="viewport-profile"&&(this.viewportProfile=i??"auto")}syncDebugState(){let e=this._state.gameState?.debugFlag;e!==void 0&&(n.enabled=e)}syncToolbarState(){let{tool:e,paused:t}=this._state.toolbarState??{};e!==void 0&&a(e),t!==void 0&&o(t)}disconnectedCallback(){this.resizeObserver?.disconnect(),this.resizeObserver=null,this._game&&(this._game.dispose(),this._game=null)}attachHostContainer(e){let t=r.HOST_CONFIG_MARKER,i=e.options.find(l=>!!l?.[t]);if(i){i.container=this.container;return}e.options.push({container:this.container,[t]:!0})}syncDisplayRuntime(){if(!this._game)return;let e=this.getBoundingClientRect(),t=Math.round(e.width||this.clientWidth||0),i=Math.round(e.height||this.clientHeight||0);this._game.setDisplayRuntime({deviceProfile:this._viewportProfile,viewportSize:t>0&&i>0?{width:t,height:i}:void 0})}};customElements.define("zylem-game",s);export{s as a};
|
package/dist/chunk-VS2D4B3W.js
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{a as f,f as b}from"./chunk-JQKS42G4.js";var i=null;function g(n){return i=n,()=>{i===n&&(i=null)}}function O(n){if(!i)return console.warn("focusEntity: no active stage focus context"),!1;let t=i.resolveEntity(n);if(!t)return console.warn(`focusEntity: entity ${n} not found`),!1;let r=t.group??t.mesh??null;return r?(f.enabled||(f.enabled=!0),i.ensureDebugReady?.(),b(t),i.frameObject(r),!0):(console.warn(`focusEntity: entity ${n} has no group/mesh`),!1)}import{Box3 as d,PerspectiveCamera as p,Vector3 as u}from"three";var m=new d,a=new u,x=new u,h=new u;function l(n){m.setFromObject(n),m.getSize(a),m.getCenter(x);let t=Math.max(a.x,1e-4),r=Math.max(a.y,1e-4),o=Math.max(a.z,1e-4),e=Math.max(t,r,o);return{width:t,height:r,depth:o,center:x.clone(),maxDim:e}}function y(n,t,r=1.35){let o=t.fov*(Math.PI/180),e=n/(2*Math.tan(o/2))*r;return Math.max(e,.5)}function M(n,t,r=1.35){let o=l(n),e=y(o.maxDim,t,r);return t.position.copy(o.center).add(new u(e,e,e)),t.lookAt(o.center),t.near=Math.max(e/100,.01),t.far=Math.max(e*20,100),t.updateProjectionMatrix(),o}function v(n,t,r,o=1.5){let e=l(n),c=h.copy(r);c.lengthSq()<1e-8&&c.set(1,1,1),c.normalize();let s=e.maxDim*o;return t instanceof p&&(s=y(e.maxDim,t,o),t.near=Math.max(s/100,.01),t.far=Math.max(s*20,100),t.updateProjectionMatrix()),t.position.copy(e.center).addScaledVector(c,s),t.lookAt(e.center),e}export{M as a,v as b,g as c,O as d};
|
package/dist/chunk-YHEWKN7N.js
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{a as n}from"./chunk-QXVH6POE.js";var i=class{emitter;unsubscribes=[];constructor(){this.emitter=n()}dispatch(e,t){this.emitter.emit(e,t)}listen(e,t){this.emitter.on(e,t);let s=()=>this.emitter.off(e,t);return this.unsubscribes.push(s),s}listenAll(e){this.emitter.on("*",e);let t=()=>this.emitter.off("*",e);return this.unsubscribes.push(t),t}dispose(){this.unsubscribes.forEach(e=>e()),this.unsubscribes=[],this.emitter.all.clear()}};var a=n();export{i as a,a as b};
|
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
import { G as GameEntity } from './entity-BGEq1yfC.js';
|
|
2
|
-
|
|
3
|
-
type DebugTools = 'select' | 'translate' | 'rotate' | 'scale' | 'delete' | 'none';
|
|
4
|
-
interface DebugState {
|
|
5
|
-
enabled: boolean;
|
|
6
|
-
paused: boolean;
|
|
7
|
-
tool: DebugTools;
|
|
8
|
-
selectedEntity: GameEntity<any> | null;
|
|
9
|
-
hoveredEntity: GameEntity<any> | null;
|
|
10
|
-
flags: Set<string>;
|
|
11
|
-
}
|
|
12
|
-
declare const debugState: DebugState;
|
|
13
|
-
declare function setPaused(paused: boolean): void;
|
|
14
|
-
declare function setDebugTool(tool: DebugTools): void;
|
|
15
|
-
declare function setSelectedEntity(entity: GameEntity<any> | null): void;
|
|
16
|
-
|
|
17
|
-
export { type DebugTools as D, setPaused as a, setSelectedEntity as b, debugState as d, setDebugTool as s };
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{v as e}from"./chunk-CFVRRRZZ.js";import"./chunk-VS2D4B3W.js";import"./chunk-JQKS42G4.js";import"./chunk-YAOXFYOD.js";import"./chunk-KVSJE4XD.js";import"./chunk-CM5YRNBJ.js";import"./chunk-YHEWKN7N.js";import"./chunk-QXVH6POE.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{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};
|