@zylem/game-lib 0.8.4 → 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 +3424 -514
- package/dist/api/game-lib.api.md +178 -10
- package/dist/api/game-lib.d.ts +481 -11
- package/dist/api/game-lib.typedoc.json +220347 -136841
- package/dist/base-node-idopiSw5.d.ts +96 -0
- package/dist/bridge.d.ts +27 -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-VIPINV7V.js → chunk-Q2YDBMVY.js} +1 -1
- 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-YOVE25NW.js +1 -0
- package/dist/{collision-builder-4TVDzXsp.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 +194 -7
- package/dist/debug.js +1 -1
- package/dist/{entity-DDks47JB.d.ts → entity-BIf_a4dl.d.ts} +1 -1
- package/dist/{entity-BI7cSlK8.d.ts → entity-XZNGBeca.d.ts} +32 -98
- package/dist/{entity-type-map-COHu4fkW.d.ts → entity-type-map-CkkFMSrL.d.ts} +5 -4
- package/dist/entity.d.ts +9 -7
- package/dist/entity.js +1 -1
- package/dist/{game-4fsy55uN.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-BKPYeBC6.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/{vector-DPbwlzgG.d.ts → simulation-body-zQw-emOr.d.ts} +1 -40
- 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-B73ZNcgs.d.ts → zylem-camera-DZTpPOiD.d.ts} +12 -1
- package/package.json +6 -2
- package/dist/chunk-3I537JFL.js +0 -1
- package/dist/chunk-4CHZUWLF.js +0 -1
- package/dist/chunk-6B5JP7T5.js +0 -24
- package/dist/chunk-C5NEGC3S.js +0 -1
- package/dist/chunk-D3JO4HW2.js +0 -1
- package/dist/chunk-LKFF6XJC.js +0 -1
- package/dist/chunk-OAWK2UUY.js +0 -1
- package/dist/chunk-PNLNC3FA.js +0 -1
- package/dist/chunk-W5SXED5T.js +0 -1
- package/dist/debug-state-s0s-qndj.d.ts +0 -49
- package/dist/game-default-4PPYYGAR.js +0 -1
- /package/dist/{chunk-DFLI7ICU.js → chunk-MSCVL5OK.js} +0 -0
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{a as f}from"./chunk-BMRFDDMR.js";import{b as u,r as C,s as V,t as d,v as G,w as U,y as v,z as b}from"./chunk-SAQA4SXW.js";import{e as D}from"./chunk-7NYP4YAG.js";import{c as h,d as y,h as m,i as E,j as x}from"./chunk-7WRQ2UAN.js";import{Color as B,Group as st,Sprite as ot,SpriteMaterial as at,CanvasTexture as H,LinearFilter as w,Vector2 as pt,ClampToEdgeWrapping as W}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 pt(24,24),zDistance:1},O=class extends v{createEntity(t){return new _(t)}},lt=Symbol("Text"),_=class i extends d{static type=lt;_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=E(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 st,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 at({map:this._texture,transparent:!0,depthTest:!1,depthWrite:!1,alphaTest:.5});this._sprite=new ot(t),this.group?.add(this._sprite),this.redrawText(this.options.text??"")}measureAndResizeCanvas(t,e,n,s){if(!this._canvas||!this._ctx)return{sizeChanged:!1};this._ctx.font=`${e}px ${n}`;let r=this._ctx.measureText(t),o=Math.ceil(r.width),a=Math.ceil(e*1.4),p=Math.max(2,o+s*2),l=Math.max(2,a+s*2),T=p!==this._lastCanvasW||l!==this._lastCanvasH;return this._canvas.width=p,this._canvas.height=l,this._lastCanvasW=p,this._lastCanvasH=l,{sizeChanged:T}}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=W,this._texture.wrapT=W),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,s=this.options.padding??4,{sizeChanged:r}=this.measureAndResizeCanvas(t,e,n,s);this.drawCenteredText(t,e,n),this.updateTexture(!!r),this.options.stickToViewport&&this._cameraRef?this.updateStickyTransform():this.updateWorldSpriteScale()}toCssColor(t){return typeof t=="string"?t:`#${(t instanceof B?t:new B(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 s=t.x>=0&&t.x<=1,r=t.y>=0&&t.y<=1;return{px:s?t.x*e:t.x,py:r?t.y*n:t.y}}computeWorldExtents(t,e){let n=1,s=1;if(t.isPerspectiveCamera){let r=t,o=Math.tan(r.fov*Math.PI/180/2)*e;n=o*r.aspect,s=o}else if(t.isOrthographicCamera){let r=t;n=(r.right-r.left)/2,s=(r.top-r.bottom)/2}return{worldHalfW:n,worldHalfH:s}}updateSpriteScale(t,e){if(!this._canvas||!this._sprite)return;let s=t*2/e,r=this._canvas.height,o=Math.max(1e-4,r*s),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),s=n*t;this._sprite.scale.set(s,n,1)}updateStickyTransform(){if(!this._sprite||!this._cameraRef)return;let t=this._cameraRef.camera,{width:e,height:n}=this.getResolution(),s=E(this.options.screenPosition,g.screenPosition),{px:r,py:o}=this.getScreenPixels(s,e,n),a=Math.max(.001,this.options.zDistance??1),{worldHalfW:p,worldHalfH:l}=this.computeWorldExtents(t,a),T=r/e*2-1,it=1-o/n*2,nt=T*p,rt=it*l;this.group?.position.set(nt,rt,-a),this.updateSpriteScale(l,n)}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 F(...i){return b({args:i,defaultConfig:{...g},EntityClass:_,BuilderClass:O,entityType:_.type,cloneFactory:t=>F(t??{})})}import{Euler as ct,Group as X,Quaternion as ht,Vector3 as mt}from"three";import{TextureLoader as N,SpriteMaterial as Y,Sprite as $,SRGBColorSpace as j}from"three";import{ClampToEdgeWrapping as Q,LinearFilter as ut,NearestFilter as dt}from"three";var q={...C,size:new mt(1,1,1),images:[],animations:[]},L=class extends U{collider(t){let e=x(t.collisionSize,t.size??y);return{shape:{type:"box",halfExtents:[e.x/2,e.y/2,e.z/2]}}}},I=class extends v{createEntity(t){return new S(t)}},ft=Symbol("Sprite"),S=class i extends d{static type=ft;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(q,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 N,n=x(this.options.size,y);t.forEach((s,r)=>{let o=e.load(s.file);o.colorSpace=j,o.anisotropy=D;let a=new Y({map:o,transparent:!0}),p=new $(a);p.position.normalize(),p.scale.set(n.x,n.y,n.z),p.visible=r===0,this.sprites.push(p),this.spriteMap.set(s.name,r)}),this.group=new X,this.group.add(...this.sprites)}createSpriteFromSheet(t){let e=x(this.options.size,y),n=new N().load(t.file);n.colorSpace=j,n.wrapS=Q,n.wrapT=Q;let s=t.filter==="linear"?ut:dt;n.magFilter=s,n.minFilter=s,n.generateMipmaps=!1,n.repeat.set(1/t.columns,1/t.rows);let r=new Y({map:n,transparent:!0}),o=new $(r);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 X,this.group.add(o);let a=t.frames.find(p=>!!p);a&&this.setSprite(a)}createAnimations(t){t.forEach(e=>{let{name:n,frames:s,loop:r=!1,speed:o=1}=e,a={frames:s.map((p,l)=>({key:p,index:l,duration:typeof o=="number"?o:o[l]})),loop:r};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((s,r)=>{s.visible=this.currentSpriteIndex===r})}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 s=t%e.columns,r=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?(s+1)*o:s*o,n.offset.y=1-(r+1)*a}setAnimation(t,e){let n=this.animations.get(t);if(!n)return;let{loop:s,frames:r}=n;if(r.length!==0){for(t!==this.currentAnimation?(this.currentAnimation=t,this.currentAnimationIndex=0,this.currentAnimationTime=0):this.currentAnimationTime+=e;;){let o=r[this.currentAnimationIndex].duration;if(!(o>0)||this.currentAnimationTime<o)break;if(this.currentAnimationTime-=o,this.currentAnimationIndex+1<r.length)this.currentAnimationIndex++;else if(s)this.currentAnimationIndex=0;else{this.currentAnimationTime=0;break}}this.currentAnimationFrame=r[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 s=new ht(t.x,t.y,t.z,t.w),r=new ct().setFromQuaternion(s,"XYZ");e.material.rotation=r.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 z(...i){return b({args:i,defaultConfig:q,EntityClass:S,BuilderClass:I,CollisionBuilderClass:L,entityType:S.type,cloneFactory:t=>z(t??{})})}import{Color as tt,Group as xt}from"three";import{Line2NodeMaterial as gt}from"three/webgpu";import{Line2 as _t}from"three/addons/lines/webgpu/Line2.js";import{Color as J}from"three";import{LineGeometry as yt}from"three/addons/lines/LineGeometry.js";function R(i){let t=[];for(let e of i){let{x:n,y:s,z:r}=m(e,h);t.push(n,s,r)}return t}function P(i,t,e){if(!i||i.length===0)return;let n=[],s=new J(e);for(let r=0;r<t;r++){let o=i[r]??i[i.length-1]??e,a=new J(o??s);n.push(a.r,a.g,a.b)}return n}function K(i){let t=new yt,e=R(i.points);t.setPositions(e);let n=P(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},St=Symbol("Line");function Z(i,t){if(!i||i.length<2)throw new Error(`${t}: at least two points are required`);return i}function et(i){return i instanceof tt?i.clone():new tt(i??"#ffffff")}function Ct(i){let t=!!i.colors?.length,e=new gt({color:et(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 vt(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 bt(i,t,e={}){let n=t.getLineObject();if(!n)return null;let s=e.threshold??t.options.pickThreshold??0,r=i.params.Line2??{threshold:0};r.threshold=s,i.params.Line2=r;let a=i.intersectObject(n,!1)[0];return a?vt(a):null}var A=class i extends d{static type=St;_line=null;_geometry=null;_material=null;constructor(t){super();let e=u(c,t);e.points=Z(e.points,"ZylemLine").map(n=>m(n,h)),this.options=e}create(){return this.disposeLineResources(),this.group=new xt,this.rebuildLine(),this.applyGroupPosition(),super.create()}setPoints(t,e){if(Z(t,"setPoints"),this.options.points=t.map(s=>m(s,h)),e&&(this.options.colors=e),!this._line||!this._geometry||!this._material)return this;this._geometry.setPositions(R(this.options.points));let n=P(this.options.colors,this.options.points.length,et(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 bt(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=K({points:this.options.points,colors:this.options.colors}),this._material=Ct(this.options),this._line=new _t(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 M(...i){let t=V(i,c);Z(t.points,"createLine");let e=new A(t);return G(e,n=>M(n??{}))}var k={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)}};k.register("text",i=>F(i));k.register("sprite",i=>z(i));k.register("line",i=>M(i));function ge(i){return{template:i,generate(t){let e=[];for(let n=0;n<t;n++)e.push(i.clone());return e}}}export{lt as a,_ as b,F as c,ft as d,S as e,z as f,St as g,bt as h,A as i,M as j,k,ge as l};
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { SimulationBodyDefinition, SimulationColliderDefinition } from '@zylem/behaviors/core';
|
|
2
|
-
import { e as Vec3Input } from './vector-
|
|
2
|
+
import { e as Vec3Input } from './vector-D3eDzvcA.js';
|
|
3
3
|
|
|
4
4
|
/** Per-axis lock input: `true` locks all axes, or pass an [x, y, z] tuple. */
|
|
5
5
|
type LockAxesInput = boolean | readonly [boolean, boolean, boolean];
|
package/dist/core.d.ts
CHANGED
|
@@ -1,27 +1,30 @@
|
|
|
1
|
-
import { B as Stage, E as StageStateInterface, C as CameraWrapper } from './game-
|
|
2
|
-
export { A as AspectRatio, q as AspectRatioValue, k as CameraManager, j as CameraOptions, D as DeviceProfile, p as FirstPersonOptions, l as FirstPersonPerspective, o as Fixed2DOptions, F as Fixed2DPerspective, G as Game, b as GameConfigLike, d as GameDeviceConfig, a as GameLoadingEvent, P as PerspectiveOptions, y as RenderBundleManager, z as RenderStrategyManager, R as ResolutionInput, e as ResolveGameConfigRuntime, v as RetroPreset, w as RetroPresetKey, x as RetroResolution, S as StageConfigLike, h as StageOptions, n as ThirdPersonOptions, T as ThirdPersonPerspective, i as createCamera, c as createGame, m as createPerspective, f as createStage, g as gameConfig, r as getDisplayAspect, t as getPresetResolution, u as parseResolution, s as stageConfig } from './game-
|
|
1
|
+
import { B as Stage, E as StageStateInterface, C as CameraWrapper } from './game-Cy8f6gJm.js';
|
|
2
|
+
export { A as AspectRatio, q as AspectRatioValue, k as CameraManager, j as CameraOptions, D as DeviceProfile, p as FirstPersonOptions, l as FirstPersonPerspective, o as Fixed2DOptions, F as Fixed2DPerspective, G as Game, b as GameConfigLike, d as GameDeviceConfig, a as GameLoadingEvent, P as PerspectiveOptions, y as RenderBundleManager, z as RenderStrategyManager, R as ResolutionInput, e as ResolveGameConfigRuntime, v as RetroPreset, w as RetroPresetKey, x as RetroResolution, S as StageConfigLike, h as StageOptions, n as ThirdPersonOptions, T as ThirdPersonPerspective, i as createCamera, c as createGame, m as createPerspective, f as createStage, g as gameConfig, r as getDisplayAspect, t as getPresetResolution, u as parseResolution, s as stageConfig } from './game-Cy8f6gJm.js';
|
|
3
3
|
export { G as GameInputConfig, a as GameInputPlayerConfig, K as KeyboardMapping, M as MouseConfig, b as MouseMapping, V as VirtualTouchButtonConfig, d as VirtualTouchButtonSlot, c as VirtualTouchButtonsConfig, e as VirtualTouchConfig, f as VirtualTouchJoystickConfig, g as VirtualTouchJoysticksConfig, h as VirtualTouchPosition, i as VirtualTouchStyle, Z as ZylemGameConfig } from './game-interfaces-vF5sRi1n.js';
|
|
4
4
|
import { Vector2 } from 'three';
|
|
5
|
-
import { G as GameEntity,
|
|
5
|
+
import { G as GameEntity, a as GameEntityOptions } from './entity-XZNGBeca.js';
|
|
6
6
|
import { S as StageBlueprint } from './blueprints-TbGY-h53.js';
|
|
7
7
|
import { a as SetupContext, k as LoadedContext, U as UpdateContext, D as DestroyContext, l as CleanupContext } from './base-node-life-cycle-BK9xebT9.js';
|
|
8
8
|
export { L as LoadingEvent, S as StageNavigationOptions } from './base-node-life-cycle-BK9xebT9.js';
|
|
9
9
|
export { S as StageTransitionConfig, a as StageTransitionEasing, Z as ZylemTransitionShader, c as crossfadeTransitionShader } from './stage-transition-CmGpV4tc.js';
|
|
10
|
-
import { f as CameraBehavior } from './zylem-camera-
|
|
11
|
-
export { g as CameraAction, d as CameraContext, e as CameraPerspective, j as CameraPipeline, h as CameraPipelineState, C as CameraPose, P as PerspectiveType, a as Perspectives, c as PoseDelta, T as TransformLike, V as Viewport, b as ZylemRenderer, i as isWebGPUSupported } from './zylem-camera-
|
|
12
|
-
import { e as Vec3Input, c as Vec3 } from './vector-
|
|
13
|
-
export { f as VEC2_ONE, g as VEC2_ZERO, h as VEC3_ONE, i as VEC3_ZERO, V as Vec2, a as Vec2Components, b as Vec2Input, d as Vec3Components, n as normalizeVec2, j as normalizeVec3, t as toThreeVector2, k as toThreeVector3 } from './vector-
|
|
14
|
-
import { S as StageEntity } from './entity-
|
|
15
|
-
import './
|
|
16
|
-
import './
|
|
10
|
+
import { f as CameraBehavior } from './zylem-camera-DZTpPOiD.js';
|
|
11
|
+
export { g as CameraAction, d as CameraContext, e as CameraPerspective, j as CameraPipeline, h as CameraPipelineState, C as CameraPose, P as PerspectiveType, a as Perspectives, c as PoseDelta, T as TransformLike, V as Viewport, b as ZylemRenderer, i as isWebGPUSupported } from './zylem-camera-DZTpPOiD.js';
|
|
12
|
+
import { e as Vec3Input, c as Vec3 } from './vector-D3eDzvcA.js';
|
|
13
|
+
export { f as VEC2_ONE, g as VEC2_ZERO, h as VEC3_ONE, i as VEC3_ZERO, V as Vec2, a as Vec2Components, b as Vec2Input, d as Vec3Components, n as normalizeVec2, j as normalizeVec3, t as toThreeVector2, k as toThreeVector3 } from './vector-D3eDzvcA.js';
|
|
14
|
+
import { S as StageEntity } from './entity-BIf_a4dl.js';
|
|
15
|
+
import { B as BaseNode, N as NodeInterface } from './base-node-idopiSw5.js';
|
|
16
|
+
import './entity-type-map-CkkFMSrL.js';
|
|
17
|
+
import './material-CxxAyJYp.js';
|
|
17
18
|
import 'three/webgpu';
|
|
18
19
|
import '@zylem/behaviors/core';
|
|
19
20
|
import '@zylem/behaviors/particle-emitter';
|
|
20
21
|
import 'three/addons/lines/webgpu/Line2.js';
|
|
22
|
+
import './simulation-body-zQw-emOr.js';
|
|
23
|
+
import '@zylem/bridge';
|
|
21
24
|
import './events.js';
|
|
22
25
|
import 'mitt';
|
|
23
26
|
import './default-controls-CAKJ5zlo.js';
|
|
24
|
-
import './collision-builder-
|
|
27
|
+
import './collision-builder-BckxkdmA.js';
|
|
25
28
|
import '@sinclair/typebox';
|
|
26
29
|
|
|
27
30
|
/**
|
package/dist/core.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{a as b,b as c,c as d,d as e,e as f,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}from"./chunk-
|
|
1
|
+
import{a as b,b as c,c as d,d as e,e as f,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}from"./chunk-LD4KDRYL.js";import{a,c as p,d as q,e as r,f as s,g as t,h as u,i as v,k as w,l as x,m as y,n as z,o as A,p as B,q as C,r as D,s as E,t as F,v as G}from"./chunk-FYQNZCIP.js";import{a as o}from"./chunk-7GYFZKK7.js";import"./chunk-Q2YDBMVY.js";import"./chunk-BCFFS3FP.js";import"./chunk-QDQ4QMAI.js";import"./chunk-AE3CTVHY.js";import"./chunk-DQQA3VJH.js";import"./chunk-VJZMSBKP.js";import"./chunk-DECK4UEC.js";import"./chunk-WBQ5TNRZ.js";import"./chunk-YOVE25NW.js";import"./chunk-MXO4VGDB.js";import"./chunk-BMRFDDMR.js";import"./chunk-SAQA4SXW.js";import"./chunk-7NYP4YAG.js";import"./chunk-AIQ6IVT5.js";import"./chunk-QXVH6POE.js";import"./chunk-EVYHPR3J.js";import"./chunk-D2PATZCC.js";import"./chunk-4QLJUQSJ.js";import{a as g,b as h,c as i,d as j,g as k,h as l,i as m,j as n}from"./chunk-7WRQ2UAN.js";import"./chunk-BH53MBAZ.js";import"./chunk-XRP4JJXL.js";import"./chunk-PCFF4LLO.js";import"./chunk-UG22Z42P.js";export{b as AspectRatio,B as CameraManager,w as CameraPipeline,C as CameraWrapper,z as FirstPersonPerspective,y as Fixed2DPerspective,J as Game,v as Perspectives,s as RenderBundleManager,t as RenderStrategyManager,M as STAGE_STATE_CHANGE,I as StageManager,x as ThirdPersonPerspective,h as VEC2_ONE,g as VEC2_ZERO,j as VEC3_ONE,i as VEC3_ZERO,D as createCamera,P as createFollowTarget,K as createGame,A as createPerspective,G as createStage,o as crossfadeTransitionShader,O as dispatchStageState,L as entitySpawner,f as gameConfig,c as getDisplayAspect,d as getPresetResolution,N as initStageStateDispatcher,r as isManagedRenderEntity,a as isWebGPUSupported,k as normalizeVec2,l as normalizeVec3,e as parseResolution,p as resolveRenderCategory,Q as setCameraFeed,u as setStageFrameProfilerEnabled,E as stageConfig,H as stageState,m as toThreeVector2,n as toThreeVector3,q as usesManagedRenderPath,F as vessel};
|
|
@@ -0,0 +1,89 @@
|
|
|
1
|
+
import { G as GameEntity } from './entity-XZNGBeca.js';
|
|
2
|
+
|
|
3
|
+
type DebugTools = 'select' | 'translate' | 'rotate' | 'scale' | 'delete' | 'add' | 'none';
|
|
4
|
+
/** Tools that manipulate a selected entity's transform via the gizmo. */
|
|
5
|
+
declare const TRANSFORM_TOOLS: readonly ["translate", "rotate", "scale"];
|
|
6
|
+
type TransformTool = (typeof TRANSFORM_TOOLS)[number];
|
|
7
|
+
declare function isTransformTool(tool: DebugTools): tool is TransformTool;
|
|
8
|
+
/** Grid increments applied to gizmo drags, in world units and radians. */
|
|
9
|
+
interface SnapSettings {
|
|
10
|
+
enabled: boolean;
|
|
11
|
+
translate: number;
|
|
12
|
+
/** Radians. Defaults to 15 degrees. */
|
|
13
|
+
rotate: number;
|
|
14
|
+
scale: number;
|
|
15
|
+
}
|
|
16
|
+
declare const DEFAULT_SNAP_SETTINGS: SnapSettings;
|
|
17
|
+
interface DebugState {
|
|
18
|
+
enabled: boolean;
|
|
19
|
+
paused: boolean;
|
|
20
|
+
tool: DebugTools;
|
|
21
|
+
/**
|
|
22
|
+
* UUID of the selected entity, never the entity itself. Valtio deep-proxies
|
|
23
|
+
* any object assigned into a proxy, so storing a live `GameEntity` here
|
|
24
|
+
* would walk `group.parent` into the entire THREE scene graph and
|
|
25
|
+
* `physicsWorldRef` into the Rapier world, freezing the tab and handing
|
|
26
|
+
* Proxy wrappers to engine code that expects real instances.
|
|
27
|
+
*/
|
|
28
|
+
selectedEntityId: string | null;
|
|
29
|
+
/**
|
|
30
|
+
* Full selection, in click order. `selectedEntityId` mirrors the first
|
|
31
|
+
* entry. Only ever holds one uuid today, but the gizmo and scene operations
|
|
32
|
+
* are already written against the list so multi-select needs no rework here.
|
|
33
|
+
*/
|
|
34
|
+
selectedEntityIds: string[];
|
|
35
|
+
/** UUID of the hovered entity. Same constraint as `selectedEntityId`. */
|
|
36
|
+
hoveredEntityId: string | null;
|
|
37
|
+
snap: SnapSettings;
|
|
38
|
+
/** Whether the construction-plane grid is drawn. */
|
|
39
|
+
gridVisible: boolean;
|
|
40
|
+
/** Catalog type the add tool will spawn, or null when disarmed. */
|
|
41
|
+
addTypeId: string | null;
|
|
42
|
+
/** Creation options merged over the armed type's defaults. */
|
|
43
|
+
addTypeProps: Record<string, unknown> | null;
|
|
44
|
+
flags: Set<string>;
|
|
45
|
+
}
|
|
46
|
+
declare const debugState: DebugState;
|
|
47
|
+
/** Resolves a UUID to the live entity owned by the active stage. */
|
|
48
|
+
type DebugEntityResolver = (uuid: string) => GameEntity<any> | null;
|
|
49
|
+
/**
|
|
50
|
+
* Register the active stage's entity resolver so `getSelectedEntity` /
|
|
51
|
+
* `getHoveredEntity` can hand back live entities without the reactive store
|
|
52
|
+
* ever holding one.
|
|
53
|
+
*
|
|
54
|
+
* @returns An unregister function.
|
|
55
|
+
*/
|
|
56
|
+
declare function registerDebugEntityResolver(resolver: DebugEntityResolver): () => void;
|
|
57
|
+
/** Resolve a UUID through the active stage, or null when unavailable. */
|
|
58
|
+
declare function resolveDebugEntity(uuid: string | null): GameEntity<any> | null;
|
|
59
|
+
declare function setPaused(paused: boolean): void;
|
|
60
|
+
declare function setDebugTool(tool: DebugTools): void;
|
|
61
|
+
declare function getSelectedEntityId(): string | null;
|
|
62
|
+
declare function setSelectedEntityId(uuid: string | null): void;
|
|
63
|
+
/** Every selected uuid, in click order. */
|
|
64
|
+
declare function getSelectedEntityIds(): string[];
|
|
65
|
+
/**
|
|
66
|
+
* Replace the selection. `selectedEntityId` follows the first entry so the
|
|
67
|
+
* single-select consumers (debug cursor, orbit focus target, bridge mirror)
|
|
68
|
+
* keep working unchanged.
|
|
69
|
+
*/
|
|
70
|
+
declare function setSelectedEntityIds(uuids: string[]): void;
|
|
71
|
+
/** Current snap increments. */
|
|
72
|
+
declare function getSnapSettings(): SnapSettings;
|
|
73
|
+
declare function setSnapSettings(snap: Partial<SnapSettings>): void;
|
|
74
|
+
declare function setGridVisible(visible: boolean): void;
|
|
75
|
+
/** Arm the add tool with a catalog type, or pass `null` to disarm it. */
|
|
76
|
+
declare function setAddType(typeId: string | null, props?: Record<string, unknown> | null): void;
|
|
77
|
+
declare function getHoveredEntityId(): string | null;
|
|
78
|
+
declare function setHoveredEntityId(uuid: string | null): void;
|
|
79
|
+
/** The live selected entity, resolved on demand through the active stage. */
|
|
80
|
+
declare function getSelectedEntity(): GameEntity<any> | null;
|
|
81
|
+
/** The live hovered entity, resolved on demand through the active stage. */
|
|
82
|
+
declare function getHoveredEntity(): GameEntity<any> | null;
|
|
83
|
+
/**
|
|
84
|
+
* @deprecated Pass a UUID to {@link setSelectedEntityId} instead. Accepts a
|
|
85
|
+
* live entity only to keep the previous public API working.
|
|
86
|
+
*/
|
|
87
|
+
declare function setSelectedEntity(entity: GameEntity<any> | string | null): void;
|
|
88
|
+
|
|
89
|
+
export { DEFAULT_SNAP_SETTINGS as D, type SnapSettings as S, TRANSFORM_TOOLS as T, setPaused as a, setSelectedEntity as b, setSelectedEntityId as c, debugState as d, getSelectedEntity as e, setSelectedEntityIds as f, getSelectedEntityId as g, getSelectedEntityIds as h, setHoveredEntityId as i, getHoveredEntityId as j, getHoveredEntity as k, resolveDebugEntity as l, getSnapSettings as m, setSnapSettings as n, setGridVisible as o, setAddType as p, isTransformTool as q, registerDebugEntityResolver as r, setDebugTool as s, type DebugTools as t, type DebugEntityResolver as u, type TransformTool as v };
|
package/dist/debug.d.ts
CHANGED
|
@@ -1,16 +1,203 @@
|
|
|
1
|
-
export {
|
|
2
|
-
import
|
|
3
|
-
import {
|
|
1
|
+
export { D as DEFAULT_SNAP_SETTINGS, u as DebugEntityResolver, t as DebugTools, S as SnapSettings, T as TRANSFORM_TOOLS, v as TransformTool, d as debugState, k as getHoveredEntity, j as getHoveredEntityId, e as getSelectedEntity, g as getSelectedEntityId, h as getSelectedEntityIds, m as getSnapSettings, q as isTransformTool, r as registerDebugEntityResolver, l as resolveDebugEntity, p as setAddType, s as setDebugTool, o as setGridVisible, i as setHoveredEntityId, a as setPaused, b as setSelectedEntity, c as setSelectedEntityId, f as setSelectedEntityIds, n as setSnapSettings } from './debug-state-B5awuDHl.js';
|
|
2
|
+
import * as three from 'three';
|
|
3
|
+
import { Group, Scene, Vector3, Camera, Object3D } from 'three';
|
|
4
|
+
import { c as Vec3 } from './vector-D3eDzvcA.js';
|
|
5
|
+
import { G as GameEntity } from './entity-XZNGBeca.js';
|
|
4
6
|
import { WebGPURenderer } from 'three/webgpu';
|
|
5
7
|
import '@zylem/behaviors/core';
|
|
6
|
-
import './
|
|
7
|
-
import './material-
|
|
8
|
-
import './collision-builder-
|
|
8
|
+
import './simulation-body-zQw-emOr.js';
|
|
9
|
+
import './material-CxxAyJYp.js';
|
|
10
|
+
import './collision-builder-BckxkdmA.js';
|
|
11
|
+
import './base-node-idopiSw5.js';
|
|
9
12
|
import './base-node-life-cycle-BK9xebT9.js';
|
|
10
13
|
import './stage-transition-CmGpV4tc.js';
|
|
11
14
|
import './events.js';
|
|
12
15
|
import 'mitt';
|
|
13
16
|
|
|
17
|
+
type GizmoMode = 'translate' | 'rotate' | 'scale';
|
|
18
|
+
/** Single-axis, planar, and uniform handle identifiers. */
|
|
19
|
+
type GizmoAxis = 'x' | 'y' | 'z' | 'xy' | 'yz' | 'xz' | 'xyz';
|
|
20
|
+
/** A raw, unsnapped drag result in world space. */
|
|
21
|
+
type GizmoDelta = {
|
|
22
|
+
kind: 'translate';
|
|
23
|
+
offset: Vector3;
|
|
24
|
+
} | {
|
|
25
|
+
kind: 'rotate';
|
|
26
|
+
axis: Vector3;
|
|
27
|
+
angle: number;
|
|
28
|
+
} | {
|
|
29
|
+
kind: 'scale';
|
|
30
|
+
factor: Vector3;
|
|
31
|
+
};
|
|
32
|
+
/** A mouse ray in world space. */
|
|
33
|
+
interface GizmoRay {
|
|
34
|
+
origin: Vector3;
|
|
35
|
+
direction: Vector3;
|
|
36
|
+
}
|
|
37
|
+
/**
|
|
38
|
+
* Closest point along an infinite line to a ray, as a distance along the line.
|
|
39
|
+
*
|
|
40
|
+
* Returns `null` when the ray is close enough to parallel with the line that the
|
|
41
|
+
* closest point becomes unstable; see {@link MAX_DRAG_GAIN}.
|
|
42
|
+
*/
|
|
43
|
+
declare function closestAxisValue(ray: GizmoRay, origin: Vector3, axis: Vector3): number | null;
|
|
44
|
+
/**
|
|
45
|
+
* Intersect a ray with the plane through `origin` with the given normal.
|
|
46
|
+
*
|
|
47
|
+
* Returns `null` for a plane seen too close to edge-on, where the hit point
|
|
48
|
+
* races away across the plane for very little pointer motion.
|
|
49
|
+
*/
|
|
50
|
+
declare function intersectPlane(ray: GizmoRay, origin: Vector3, normal: Vector3, target: Vector3): Vector3 | null;
|
|
51
|
+
declare class TransformGizmo {
|
|
52
|
+
/** Root added to the scene; carries the pivot transform. */
|
|
53
|
+
readonly root: Group<three.Object3DEventMap>;
|
|
54
|
+
private scene;
|
|
55
|
+
private modeGroups;
|
|
56
|
+
private handles;
|
|
57
|
+
private materials;
|
|
58
|
+
private geometries;
|
|
59
|
+
private mode;
|
|
60
|
+
private highlighted;
|
|
61
|
+
private drag;
|
|
62
|
+
private raycaster;
|
|
63
|
+
constructor();
|
|
64
|
+
addTo(scene: Scene): void;
|
|
65
|
+
removeFromScene(): void;
|
|
66
|
+
dispose(): void;
|
|
67
|
+
setMode(mode: GizmoMode): void;
|
|
68
|
+
getMode(): GizmoMode;
|
|
69
|
+
/** Place the gizmo at a pivot and show it. */
|
|
70
|
+
show(pivot: Vector3): void;
|
|
71
|
+
hide(): void;
|
|
72
|
+
get visible(): boolean;
|
|
73
|
+
get pivot(): Vector3;
|
|
74
|
+
/**
|
|
75
|
+
* Keep the gizmo a constant size on screen.
|
|
76
|
+
*
|
|
77
|
+
* A world-sized gizmo is unusable in an orbit view: it fills the screen up
|
|
78
|
+
* close and disappears from a distance.
|
|
79
|
+
*/
|
|
80
|
+
update(camera: Camera): void;
|
|
81
|
+
/**
|
|
82
|
+
* Which handle a ray hits, or `null`.
|
|
83
|
+
*
|
|
84
|
+
* Raycasts the gizmo's own meshes rather than the physics world. Handles are
|
|
85
|
+
* render-only objects with no colliders, so the physics raycast used to pick
|
|
86
|
+
* entities cannot see them at all.
|
|
87
|
+
*/
|
|
88
|
+
pick(ray: GizmoRay): GizmoAxis | null;
|
|
89
|
+
/**
|
|
90
|
+
* Whether a handle can be dragged from the current viewing angle.
|
|
91
|
+
*
|
|
92
|
+
* Each handle type degenerates differently: an arrow aimed at the camera has
|
|
93
|
+
* no screen-space direction left to follow, while a plane quad or rotation
|
|
94
|
+
* ring seen edge-on turns a pixel of motion into a huge sweep across it.
|
|
95
|
+
*/
|
|
96
|
+
private isHandleDraggable;
|
|
97
|
+
/** Tint a handle to show it is hovered or being dragged. */
|
|
98
|
+
setHighlight(axis: GizmoAxis | null): void;
|
|
99
|
+
/**
|
|
100
|
+
* Begin a drag on a handle.
|
|
101
|
+
*
|
|
102
|
+
* @returns `false` when the gesture cannot be tracked (a near-parallel view
|
|
103
|
+
* of the drag axis), so the caller can ignore the press rather than start a
|
|
104
|
+
* drag that would jump.
|
|
105
|
+
*/
|
|
106
|
+
beginDrag(axis: GizmoAxis, ray: GizmoRay, camera: Camera): boolean;
|
|
107
|
+
/** Raw delta for the current pointer position, or `null` when unusable. */
|
|
108
|
+
updateDrag(ray: GizmoRay, camera: Camera): GizmoDelta | null;
|
|
109
|
+
endDrag(): void;
|
|
110
|
+
get isDragging(): boolean;
|
|
111
|
+
get draggingAxis(): GizmoAxis | null;
|
|
112
|
+
private isPlaneAxis;
|
|
113
|
+
/** Signed angle of the ray's hit point around `normal`, in radians. */
|
|
114
|
+
private angleOnPlane;
|
|
115
|
+
/** Distance from pivot to the ray hit on the camera-facing plane. */
|
|
116
|
+
private cameraPlaneRadius;
|
|
117
|
+
private applyModeVisibility;
|
|
118
|
+
private makeMaterial;
|
|
119
|
+
private track;
|
|
120
|
+
/**
|
|
121
|
+
* An invisible, generously sized mesh used only for hit testing.
|
|
122
|
+
*
|
|
123
|
+
* The visible shafts and rings are a couple of pixels wide, which is
|
|
124
|
+
* miserable to click. The raycaster still reaches `visible: false` meshes,
|
|
125
|
+
* so picking accuracy is decoupled from how thin the handle looks.
|
|
126
|
+
*/
|
|
127
|
+
private makePicker;
|
|
128
|
+
private orientAlongAxis;
|
|
129
|
+
private buildTranslate;
|
|
130
|
+
private positionPlaneHandle;
|
|
131
|
+
private buildRotate;
|
|
132
|
+
private orientRing;
|
|
133
|
+
private buildScale;
|
|
134
|
+
}
|
|
135
|
+
|
|
136
|
+
/**
|
|
137
|
+
* The y=0 construction plane, drawn so the snap lattice is legible.
|
|
138
|
+
*
|
|
139
|
+
* Two overlaid grids: fine lines at the translation snap increment, and heavier
|
|
140
|
+
* lines every metre. Without the coarse pass a 0.25 grid over any useful area
|
|
141
|
+
* reads as flat grey noise.
|
|
142
|
+
*/
|
|
143
|
+
|
|
144
|
+
declare class ConstructionGrid {
|
|
145
|
+
private group;
|
|
146
|
+
private scene;
|
|
147
|
+
private fine;
|
|
148
|
+
private coarse;
|
|
149
|
+
private increment;
|
|
150
|
+
constructor();
|
|
151
|
+
addTo(scene: Scene): void;
|
|
152
|
+
/** Rebuild only when the increment actually changed; this allocates. */
|
|
153
|
+
setIncrement(increment: number): void;
|
|
154
|
+
setVisible(visible: boolean): void;
|
|
155
|
+
get visible(): boolean;
|
|
156
|
+
dispose(): void;
|
|
157
|
+
private rebuild;
|
|
158
|
+
private clearHelpers;
|
|
159
|
+
}
|
|
160
|
+
|
|
161
|
+
/**
|
|
162
|
+
* Pure transform math shared by the editor gizmo, the bridge adapter, and
|
|
163
|
+
* their tests. No THREE scene state and no simulation access, so it can be
|
|
164
|
+
* exercised in a plain node environment.
|
|
165
|
+
*/
|
|
166
|
+
|
|
167
|
+
/** Quaternion as carried by the bridge and the wasm runtime. */
|
|
168
|
+
interface Quat {
|
|
169
|
+
x: number;
|
|
170
|
+
y: number;
|
|
171
|
+
z: number;
|
|
172
|
+
w: number;
|
|
173
|
+
}
|
|
174
|
+
/** Convert Euler angles (radians, XYZ order) to a quaternion. */
|
|
175
|
+
declare function eulerToQuaternion(rotation: Vec3): Quat;
|
|
176
|
+
/** Convert a quaternion to Euler angles (radians, XYZ order). */
|
|
177
|
+
declare function quaternionToEuler(rotation: Quat): Vec3;
|
|
178
|
+
/**
|
|
179
|
+
* Snap a value onto an absolute lattice of `increment`-sized steps.
|
|
180
|
+
*
|
|
181
|
+
* Absolute rather than relative to where the drag started: the result is
|
|
182
|
+
* always a multiple of the increment, so independently placed entities line up
|
|
183
|
+
* with each other instead of each keeping its own arbitrary offset.
|
|
184
|
+
*/
|
|
185
|
+
declare function snapToIncrement(value: number, increment: number): number;
|
|
186
|
+
/** {@link snapToIncrement} across all three components. */
|
|
187
|
+
declare function snapVec3(value: Vec3, increment: number): Vec3;
|
|
188
|
+
/**
|
|
189
|
+
* Snap a scale, clamped away from zero.
|
|
190
|
+
*
|
|
191
|
+
* A snapped-to-zero axis would collapse the collider into a degenerate shape
|
|
192
|
+
* that the physics runtime cannot solve, so the smallest representable scale
|
|
193
|
+
* is one increment.
|
|
194
|
+
*/
|
|
195
|
+
declare function snapScale(value: Vec3, increment: number): Vec3;
|
|
196
|
+
/** Degrees to radians. */
|
|
197
|
+
declare function degreesToRadians(degrees: number): number;
|
|
198
|
+
/** Radians to degrees. */
|
|
199
|
+
declare function radiansToDegrees(radians: number): number;
|
|
200
|
+
|
|
14
201
|
/**
|
|
15
202
|
* Context registered by the active stage so the editor can focus entities
|
|
16
203
|
* without importing stage internals.
|
|
@@ -98,4 +285,4 @@ declare class EntityThumbnailCache {
|
|
|
98
285
|
/** Shared cache used by the running game to feed editor entity payloads. */
|
|
99
286
|
declare const entityThumbnailCache: EntityThumbnailCache;
|
|
100
287
|
|
|
101
|
-
export { type EntityFocusContext, EntityThumbnailCache, type EntityThumbnailCacheEntry, type EntityThumbnailResult, entityThumbnailCache, focusEntity, registerEntityFocusContext };
|
|
288
|
+
export { ConstructionGrid, type EntityFocusContext, EntityThumbnailCache, type EntityThumbnailCacheEntry, type EntityThumbnailResult, type GizmoAxis, type GizmoDelta, type GizmoMode, type GizmoRay, type Quat, TransformGizmo, closestAxisValue, degreesToRadians, entityThumbnailCache, eulerToQuaternion, focusEntity, intersectPlane, quaternionToEuler, radiansToDegrees, registerEntityFocusContext, snapScale, snapToIncrement, snapVec3 };
|
package/dist/debug.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import"./chunk-
|
|
1
|
+
import"./chunk-MSCVL5OK.js";import{a as v,b as w}from"./chunk-Q2YDBMVY.js";import{c as G,d as H,e as I,f as J}from"./chunk-BCFFS3FP.js";import{a as x,b as y,c as z,d as A,e as B,f as C,g as D,h as E,i as F}from"./chunk-VJZMSBKP.js";import{a,b,c,d,e,f,h as g,j as h,l as i,m as j,n as k,o as l,p as m,q as n,r as o,s as p,t as q,u as r,w as s,x as t,y as u}from"./chunk-DECK4UEC.js";export{G as ConstructionGrid,c as DEFAULT_SNAP_SETTINGS,v as EntityThumbnailCache,a as TRANSFORM_TOOLS,J as TransformGizmo,H as closestAxisValue,d as debugState,E as degreesToRadians,w as entityThumbnailCache,z as eulerToQuaternion,y as focusEntity,t as getHoveredEntity,q as getHoveredEntityId,s as getSelectedEntity,i as getSelectedEntityId,k as getSelectedEntityIds,m as getSnapSettings,I as intersectPlane,b as isTransformTool,A as quaternionToEuler,F as radiansToDegrees,e as registerDebugEntityResolver,x as registerEntityFocusContext,f as resolveDebugEntity,p as setAddType,h as setDebugTool,o as setGridVisible,r as setHoveredEntityId,g as setPaused,u as setSelectedEntity,j as setSelectedEntityId,l as setSelectedEntityIds,n as setSnapSettings,D as snapScale,B as snapToIncrement,C as snapVec3};
|
|
@@ -1,104 +1,13 @@
|
|
|
1
1
|
import { BufferGeometry, Material, Mesh, Group, Vector3, Color, ShaderMaterial } from 'three';
|
|
2
2
|
import { SimulationColliderDefinition, TransformState, SimulationBodyDefinition, MoveableEntity, BehaviorRuntime, Vector, BehaviorDescriptor, BehaviorHandle, BehaviorRef } from '@zylem/behaviors/core';
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
6
|
-
import {
|
|
3
|
+
import { a as SimulationBody } from './simulation-body-zQw-emOr.js';
|
|
4
|
+
import { c as Vec3, e as Vec3Input, b as Vec2Input } from './vector-D3eDzvcA.js';
|
|
5
|
+
import { M as MaterialBuilder, e as MaterialOptions } from './material-CxxAyJYp.js';
|
|
6
|
+
import { C as CollisionBuilder, L as LockAxesInput, a as CollisionOptions } from './collision-builder-BckxkdmA.js';
|
|
7
|
+
import { B as BaseNode, N as NodeInterface } from './base-node-idopiSw5.js';
|
|
8
|
+
import { a as SetupContext, U as UpdateContext, D as DestroyContext, k as LoadedContext, l as CleanupContext } from './base-node-life-cycle-BK9xebT9.js';
|
|
7
9
|
import { EventEmitterDelegate, EntityEvents } from './events.js';
|
|
8
10
|
|
|
9
|
-
interface NodeInterface {
|
|
10
|
-
uuid: string;
|
|
11
|
-
name: string;
|
|
12
|
-
markedForRemoval: boolean;
|
|
13
|
-
nodeSetup(params: SetupContext<any>): void;
|
|
14
|
-
nodeUpdate(params: UpdateContext<any>): void;
|
|
15
|
-
nodeDestroy(params: DestroyContext<any>): void;
|
|
16
|
-
setParent(parent: NodeInterface | null): void;
|
|
17
|
-
getParent(): NodeInterface | null;
|
|
18
|
-
}
|
|
19
|
-
|
|
20
|
-
type BaseNodeOptions<T = any> = BaseNode | Partial<T>;
|
|
21
|
-
/**
|
|
22
|
-
* Lifecycle callback arrays - each lifecycle event can have multiple callbacks
|
|
23
|
-
* that execute in order.
|
|
24
|
-
*/
|
|
25
|
-
interface LifecycleCallbacks<T> {
|
|
26
|
-
setup: Array<SetupFunction<T>>;
|
|
27
|
-
loaded: Array<LoadedFunction<T>>;
|
|
28
|
-
update: Array<UpdateFunction<T>>;
|
|
29
|
-
destroy: Array<DestroyFunction<T>>;
|
|
30
|
-
cleanup: Array<CleanupFunction<T>>;
|
|
31
|
-
}
|
|
32
|
-
declare abstract class BaseNode<Options = any, T = any> implements NodeInterface {
|
|
33
|
-
protected parent: NodeInterface | null;
|
|
34
|
-
protected children: NodeInterface[];
|
|
35
|
-
options: Options;
|
|
36
|
-
uuid: string;
|
|
37
|
-
name: string;
|
|
38
|
-
markedForRemoval: boolean;
|
|
39
|
-
/**
|
|
40
|
-
* Lifecycle callback arrays - use onSetup(), onUpdate(), etc. to add callbacks
|
|
41
|
-
* Uses `any` for the type parameter to avoid invariance issues when subclasses
|
|
42
|
-
* are assigned to BaseNode references. Type safety is enforced by the public
|
|
43
|
-
* onSetup/onUpdate/etc. methods which are typed with `this`.
|
|
44
|
-
*/
|
|
45
|
-
protected lifecycleCallbacks: LifecycleCallbacks<any>;
|
|
46
|
-
private trackLifecycleRegistrations;
|
|
47
|
-
private userLifecycleRegistrations;
|
|
48
|
-
constructor(args?: BaseNodeOptions[]);
|
|
49
|
-
/**
|
|
50
|
-
* Add setup callbacks to be executed in order during nodeSetup
|
|
51
|
-
*/
|
|
52
|
-
onSetup(...callbacks: Array<SetupFunction<this>>): this;
|
|
53
|
-
/**
|
|
54
|
-
* Add loaded callbacks to be executed in order during nodeLoaded
|
|
55
|
-
*/
|
|
56
|
-
onLoaded(...callbacks: Array<LoadedFunction<this>>): this;
|
|
57
|
-
/**
|
|
58
|
-
* Add update callbacks to be executed in order during nodeUpdate
|
|
59
|
-
*/
|
|
60
|
-
onUpdate(...callbacks: Array<UpdateFunction<this>>): this;
|
|
61
|
-
/**
|
|
62
|
-
* Add destroy callbacks to be executed in order during nodeDestroy
|
|
63
|
-
*/
|
|
64
|
-
onDestroy(...callbacks: Array<DestroyFunction<this>>): this;
|
|
65
|
-
/**
|
|
66
|
-
* Add cleanup callbacks to be executed in order during nodeCleanup
|
|
67
|
-
*/
|
|
68
|
-
onCleanup(...callbacks: Array<CleanupFunction<this>>): this;
|
|
69
|
-
/**
|
|
70
|
-
* Prepend setup callbacks (run before existing ones)
|
|
71
|
-
*/
|
|
72
|
-
prependSetup(...callbacks: Array<SetupFunction<this>>): this;
|
|
73
|
-
/**
|
|
74
|
-
* Prepend update callbacks (run before existing ones)
|
|
75
|
-
*/
|
|
76
|
-
prependUpdate(...callbacks: Array<UpdateFunction<this>>): this;
|
|
77
|
-
setParent(parent: NodeInterface | null): void;
|
|
78
|
-
getParent(): NodeInterface | null;
|
|
79
|
-
add(baseNode: NodeInterface): void;
|
|
80
|
-
remove(baseNode: NodeInterface): void;
|
|
81
|
-
getChildren(): NodeInterface[];
|
|
82
|
-
isComposite(): boolean;
|
|
83
|
-
enableUserLifecycleTracking(): void;
|
|
84
|
-
protected replayUserLifecycleRegistrationsTo(target: BaseNode<any, any>, wrap?: <T extends Function>(callback: T) => T): void;
|
|
85
|
-
protected cloneChildrenInto(target: BaseNode<any, any>): void;
|
|
86
|
-
abstract create(): T;
|
|
87
|
-
protected abstract _setup(params: SetupContext<this>): void;
|
|
88
|
-
protected abstract _loaded(params: LoadedContext<this>): Promise<void>;
|
|
89
|
-
protected abstract _update(params: UpdateContext<this>): void;
|
|
90
|
-
protected abstract _destroy(params: DestroyContext<this>): void;
|
|
91
|
-
protected abstract _cleanup(params: CleanupContext<this>): void;
|
|
92
|
-
nodeSetup(params: SetupContext<this>): void;
|
|
93
|
-
nodeUpdate(params: UpdateContext<this>): void;
|
|
94
|
-
nodeDestroy(params: DestroyContext<this>): void;
|
|
95
|
-
nodeLoaded(params: LoadedContext<this>): Promise<void>;
|
|
96
|
-
nodeCleanup(params: CleanupContext<this>): void;
|
|
97
|
-
getOptions(): Options;
|
|
98
|
-
setOptions(options: Partial<Options>): void;
|
|
99
|
-
private recordLifecycleRegistration;
|
|
100
|
-
}
|
|
101
|
-
|
|
102
11
|
/**
|
|
103
12
|
* TODO: allow for multiple materials requires geometry groups
|
|
104
13
|
* TODO: allow for instanced uniforms
|
|
@@ -460,6 +369,18 @@ declare class GameEntity<O extends GameEntityOptions> extends BaseNode<O> implem
|
|
|
460
369
|
physicsWorldRef: unknown;
|
|
461
370
|
colliderDesc: SimulationColliderDefinition | undefined;
|
|
462
371
|
custom: Record<string, any>;
|
|
372
|
+
/**
|
|
373
|
+
* Pristine collider definitions captured before the first scale change, so
|
|
374
|
+
* scaling stays absolute rather than compounding. See
|
|
375
|
+
* {@link ensureColliderBaseline}.
|
|
376
|
+
*/
|
|
377
|
+
colliderBaseline: SimulationColliderDefinition[] | null;
|
|
378
|
+
/**
|
|
379
|
+
* Set when {@link GameEntity.setScale} has scaled the render object but the
|
|
380
|
+
* colliders have not been rebuilt yet. Cleared by
|
|
381
|
+
* {@link commitColliderScale}.
|
|
382
|
+
*/
|
|
383
|
+
colliderScaleDirty: boolean;
|
|
463
384
|
/** All collider descriptions for this entity (including primary) */
|
|
464
385
|
colliderDescs: SimulationColliderDefinition[];
|
|
465
386
|
/** Additional meshes for compound visual entities (added via add()) */
|
|
@@ -499,6 +420,8 @@ declare class GameEntity<O extends GameEntityOptions> extends BaseNode<O> implem
|
|
|
499
420
|
private trackAddedComponents;
|
|
500
421
|
private trackedComponents;
|
|
501
422
|
transformStore: TransformState;
|
|
423
|
+
/** Absolute scale, authored by the editor. Unit scale until changed. */
|
|
424
|
+
private _scale;
|
|
502
425
|
/** Hide render target until spawn placement is confirmed. */
|
|
503
426
|
_spawnPlacementPending: boolean;
|
|
504
427
|
/** Author passed `position` in create options. */
|
|
@@ -570,6 +493,17 @@ declare class GameEntity<O extends GameEntityOptions> extends BaseNode<O> implem
|
|
|
570
493
|
w: number;
|
|
571
494
|
};
|
|
572
495
|
}): boolean;
|
|
496
|
+
/** Current absolute scale. */
|
|
497
|
+
getScale(): Vec3;
|
|
498
|
+
/**
|
|
499
|
+
* Set absolute scale on the render object.
|
|
500
|
+
*
|
|
501
|
+
* Colliders are *not* resized here — they are baked into the wasm
|
|
502
|
+
* simulation and can only be replaced by respawning the body, which is far
|
|
503
|
+
* too costly to do per drag frame. The entity is flagged instead, and
|
|
504
|
+
* {@link commitColliderScale} rebuilds them once the gesture commits.
|
|
505
|
+
*/
|
|
506
|
+
setScale(x: number, y: number, z: number): void;
|
|
573
507
|
/**
|
|
574
508
|
* Add meshes, collision components, or child entities to this entity.
|
|
575
509
|
* Supports fluent chaining: `entity.add(boxMesh()).add(boxCollision())`.
|
|
@@ -687,4 +621,4 @@ declare class GameEntity<O extends GameEntityOptions> extends BaseNode<O> implem
|
|
|
687
621
|
*/
|
|
688
622
|
declare function create(options?: Partial<GameEntityOptions>): GameEntity<GameEntityOptions>;
|
|
689
623
|
|
|
690
|
-
export { type Action as A,
|
|
624
|
+
export { type Action as A, EntityMeshBuilder as B, type CollisionComponent as C, EntityCollisionBuilder as D, EntityBuilder as E, GameEntity as G, type GameEntityOptions as a, boxCollision as b, create as c, coneCollision as d, cylinderCollision as e, pillCollision as f, planeCollision as g, rotateYEuler as h, rotateEuler as i, rotateX as j, rotateY as k, rotateZ as l, setRotationY as m, setRotationX as n, setRotationZ as o, pyramidCollision as p, setRotationDegrees as q, rotateInDirection as r, sphereCollision as s, setRotationDegreesY as t, setRotationDegreesX as u, setRotationDegreesZ as v, setRotation as w, getRotation as x, GameEntityLifeCycle as y, zoneCollision as z };
|
|
@@ -1,10 +1,11 @@
|
|
|
1
1
|
import { Vector3, Sprite, Texture, Color, Object3D, ColorRepresentation, Light, Fog, FogExp2, Scene, Raycaster } from 'three';
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
2
|
+
import { B as BaseNode } from './base-node-idopiSw5.js';
|
|
3
|
+
import { G as GameEntity, a as GameEntityOptions } from './entity-XZNGBeca.js';
|
|
4
|
+
import { d as Vec3Components, e as Vec3Input, b as Vec2Input } from './vector-D3eDzvcA.js';
|
|
4
5
|
import { U as UpdateContext, a as SetupContext, D as DestroyContext, l as CleanupContext } from './base-node-life-cycle-BK9xebT9.js';
|
|
5
|
-
import { T as TexturePath, e as MaterialOptions } from './material-
|
|
6
|
+
import { T as TexturePath, e as MaterialOptions } from './material-CxxAyJYp.js';
|
|
6
7
|
import { Simulation } from '@zylem/behaviors/core';
|
|
7
|
-
import { E as Entity } from './entity-
|
|
8
|
+
import { E as Entity } from './entity-BIf_a4dl.js';
|
|
8
9
|
import { ParticleEmitterBehaviorOptions, ParticleEffectDefinition, ParticleEmitterHandle } from '@zylem/behaviors/particle-emitter';
|
|
9
10
|
import { Line2 } from 'three/addons/lines/webgpu/Line2.js';
|
|
10
11
|
|
package/dist/entity.d.ts
CHANGED
|
@@ -1,16 +1,18 @@
|
|
|
1
|
-
export { A as ACTOR_TYPE, a0 as AmbientLightOptions, B as BOX_TYPE, E as CONE_TYPE, K as CYLINDER_TYPE, C as CollisionShapeType, D as DISK_TYPE, a2 as DirectionalLightOptions, ak as EntityForType, aj as EntityTypeMap, a8 as FOG_TYPE, a1 as HemisphereLightOptions, _ as LIGHT_TYPE, ab as LINE_TYPE, a5 as LightShadowOptions, ae as LinePickResult, o as OnEnterParams, p as OnExitParams, O as OnHeldParams, V as PARTICLE_SYSTEM_TYPE, N as PILL_TYPE, P as PLANE_TYPE, H as PYRAMID_TYPE, a3 as PointLightOptions, R as RECT_TYPE, S as SPHERE_TYPE, f as SPRITE_TYPE, a4 as SpotLightOptions, h as SpriteAnimation, g as SpriteImage, i as SpriteSheet, T as TEXT_TYPE, n as ZONE_TYPE, r as ZylemActor, Z as ZylemBox, z as ZylemCone, J as ZylemCylinder, x as ZylemDisk, a7 as ZylemFog, ah as ZylemFogHeightOptions, ai as ZylemFogNoiseOptions, af as ZylemFogOptions, ag as ZylemFogType, Y as ZylemLight, $ as ZylemLightOptions, aa as ZylemLine, ad as ZylemLineOptions, U as ZylemParticleSystem, W as ZylemParticleSystemOptions, M as ZylemPill, k as ZylemPlane, G as ZylemPyramid, v as ZylemRect, b as ZylemSphere, e as ZylemSprite, t as ZylemText, m as ZylemZone, q as createActor, c as createBox, y as createCone, I as createCylinder, w as createDisk, a6 as createFog, X as createLight, a9 as createLine, Q as createParticleSystem, L as createPill, j as createPlane, F as createPyramid, u as createRect, a as createSphere, d as createSprite, s as createText, l as createZone, ac as pickZylemLine } from './entity-type-map-
|
|
2
|
-
import { G as GameEntity, a as GameEntityOptions, E as EntityBuilder,
|
|
3
|
-
export { C as CollisionComponent, b as boxCollision, d as coneCollision, c as create, e as cylinderCollision, f as pillCollision, g as planeCollision, p as pyramidCollision, s as sphereCollision, z as zoneCollision } from './entity-
|
|
1
|
+
export { A as ACTOR_TYPE, a0 as AmbientLightOptions, B as BOX_TYPE, E as CONE_TYPE, K as CYLINDER_TYPE, C as CollisionShapeType, D as DISK_TYPE, a2 as DirectionalLightOptions, ak as EntityForType, aj as EntityTypeMap, a8 as FOG_TYPE, a1 as HemisphereLightOptions, _ as LIGHT_TYPE, ab as LINE_TYPE, a5 as LightShadowOptions, ae as LinePickResult, o as OnEnterParams, p as OnExitParams, O as OnHeldParams, V as PARTICLE_SYSTEM_TYPE, N as PILL_TYPE, P as PLANE_TYPE, H as PYRAMID_TYPE, a3 as PointLightOptions, R as RECT_TYPE, S as SPHERE_TYPE, f as SPRITE_TYPE, a4 as SpotLightOptions, h as SpriteAnimation, g as SpriteImage, i as SpriteSheet, T as TEXT_TYPE, n as ZONE_TYPE, r as ZylemActor, Z as ZylemBox, z as ZylemCone, J as ZylemCylinder, x as ZylemDisk, a7 as ZylemFog, ah as ZylemFogHeightOptions, ai as ZylemFogNoiseOptions, af as ZylemFogOptions, ag as ZylemFogType, Y as ZylemLight, $ as ZylemLightOptions, aa as ZylemLine, ad as ZylemLineOptions, U as ZylemParticleSystem, W as ZylemParticleSystemOptions, M as ZylemPill, k as ZylemPlane, G as ZylemPyramid, v as ZylemRect, b as ZylemSphere, e as ZylemSprite, t as ZylemText, m as ZylemZone, q as createActor, c as createBox, y as createCone, I as createCylinder, w as createDisk, a6 as createFog, X as createLight, a9 as createLine, Q as createParticleSystem, L as createPill, j as createPlane, F as createPyramid, u as createRect, a as createSphere, d as createSprite, s as createText, l as createZone, ac as pickZylemLine } from './entity-type-map-CkkFMSrL.js';
|
|
2
|
+
import { G as GameEntity, a as GameEntityOptions, E as EntityBuilder, B as EntityMeshBuilder, D as EntityCollisionBuilder } from './entity-XZNGBeca.js';
|
|
3
|
+
export { C as CollisionComponent, b as boxCollision, d as coneCollision, c as create, e as cylinderCollision, f as pillCollision, g as planeCollision, p as pyramidCollision, s as sphereCollision, z as zoneCollision } from './entity-XZNGBeca.js';
|
|
4
4
|
import { Color, Mesh } from 'three';
|
|
5
|
-
import {
|
|
6
|
-
import { e as
|
|
5
|
+
import { B as BaseNode } from './base-node-idopiSw5.js';
|
|
6
|
+
import { b as Vec2Input, e as Vec3Input } from './vector-D3eDzvcA.js';
|
|
7
|
+
import { e as MaterialOptions } from './material-CxxAyJYp.js';
|
|
7
8
|
import './base-node-life-cycle-BK9xebT9.js';
|
|
8
9
|
import './stage-transition-CmGpV4tc.js';
|
|
9
10
|
import '@zylem/behaviors/core';
|
|
10
|
-
import './entity-
|
|
11
|
+
import './entity-BIf_a4dl.js';
|
|
12
|
+
import './simulation-body-zQw-emOr.js';
|
|
11
13
|
import '@zylem/behaviors/particle-emitter';
|
|
12
14
|
import 'three/addons/lines/webgpu/Line2.js';
|
|
13
|
-
import './collision-builder-
|
|
15
|
+
import './collision-builder-BckxkdmA.js';
|
|
14
16
|
import './events.js';
|
|
15
17
|
import 'mitt';
|
|
16
18
|
import 'three/webgpu';
|