gaesup-world 1.0.20 → 1.0.22
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/blueprints-editor.cjs +1 -1
- package/dist/blueprints-editor.js +3 -3
- package/dist/blueprints.js +3 -3
- package/dist/editor.js +3 -3
- package/dist/{index-B2hAamTj.js → index-3WAK67Ha.js} +2 -2
- package/dist/{index-B_IfvQvL.js → index-B0oz8u47.js} +1 -1
- package/dist/index-Cpso39Zs.cjs +1 -0
- package/dist/{index-FQgcO1SU.js → index-DGifA0e6.js} +1 -1
- package/dist/{index-B0hl0p1Z.js → index-DRLvJF_k.js} +1 -1
- package/dist/index-DXZjZF_s.js +320 -0
- package/dist/index.cjs +1 -1
- package/dist/index.js +13 -13
- package/dist/network.cjs +1 -1
- package/dist/network.js +4 -4
- package/dist/{plugin--mlpG6-U.js → plugin-BFzSydfr.js} +2 -2
- package/dist/runtime.js +7 -7
- package/dist/{useSpawnFromBlueprint-TYxXKoM5.js → useSpawnFromBlueprint-BxRHlpvL.js} +4 -5
- package/package.json +1 -1
- package/dist/index-BKqky34r.js +0 -319
- package/dist/index-C-4Q2Amk.cjs +0 -1
- package/dist/{index-C-wwuvo7.js → index-C5agFfBe.js} +1 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("react/jsx-runtime"),d=require("react"),E=require("./useSpawnFromBlueprint-aIQsqI3Q.cjs"),U=require("@react-three/drei"),W=require("@react-three/fiber"),z=require("@react-three/rapier"),H=require("three"),L=require("./gaesupStore-2zKBYTYo.cjs"),R=require("./index-C-4Q2Amk.cjs"),V=require("./index-D1hpjfAw.cjs");function Y(t){const o=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(t){for(const u in t)if(u!=="default"){const s=Object.getOwnPropertyDescriptor(t,u);Object.defineProperty(o,u,s.get?s:{enumerable:!0,get:()=>t[u]})}}return o.default=t,Object.freeze(o)}const X=Y(H),g=t=>t?.type==="character";function Z({blueprint:t}){const o=L.useGaesupStore(r=>r.setUrls),u=L.useGaesupStore(r=>r.setCameraOption),s=L.useGaesupStore(r=>r.setMode),_=L.useGaesupStore(r=>r.mode),[l,h]=d.useState(20),c=g(t)?t.controls?.clickToMove??!0:!1,v=g(t)?t.controls?.enableKeyboard??!0:!1,A=g(t)?t.controls?.enableMouse??!0:!1;R.useKeyboard(v,v),d.useEffect(()=>{s({type:"character",control:g(t)&&t.camera?.mode||"thirdPerson"});const r=g(t)?t.camera||{}:{};u({xDistance:r.distance?.x||l,yDistance:r.distance?.y||l*.5,zDistance:r.distance?.z||l,offset:new X.Vector3(0,0,0),enableCollision:r.enableCollision??!1,smoothing:r.smoothing||{position:.25,rotation:.3,fov:.2},fov:r.fov||50,zoom:1,enableZoom:r.enableZoom??!0,zoomSpeed:r.zoomSpeed||.001,minZoom:r.minZoom||.5,maxZoom:r.maxZoom||3,enableFocus:!1,maxDistance:50,distance:10,bounds:{minY:2,maxY:50}})},[s,u,l,t]),d.useEffect(()=>{if(g(t)){if(t.visuals?.model)o({characterUrl:t.visuals.model});else if(t.visuals?.parts&&t.visuals.parts.length>0){const r=t.visuals.parts.find(b=>b.type==="body");r&&o({characterUrl:r.url})}}},[t,o]),d.useEffect(()=>{const r=b=>{if(g(t)&&t.camera?.enableZoom===!1)return;b.preventDefault();const N=b.deltaY*.01;h(P=>Math.max(10,Math.min(40,P+N)))};return window.addEventListener("wheel",r,{passive:!1}),()=>window.removeEventListener("wheel",r)},[t]);const C=()=>!g(t)||!t.visuals?.parts?[]:t.visuals.parts.filter(r=>r.type!=="body").map(r=>r.color?{url:r.url,color:r.color}:{url:r.url});return e.jsxs("div",{className:"blueprint-preview",children:[e.jsxs(W.Canvas,{shadows:!0,camera:{position:[0,10,20],fov:50},style:{width:"100%",height:"100%"},children:[e.jsx(V.Camera,{}),e.jsx(U.Environment,{preset:"sunset"}),e.jsx("ambientLight",{intensity:.5}),e.jsx("directionalLight",{castShadow:!0,position:[20,30,10],intensity:.5,"shadow-mapSize":[1024,1024],"shadow-camera-near":1,"shadow-camera-far":120,"shadow-camera-top":90,"shadow-camera-right":90,"shadow-camera-bottom":-90,"shadow-camera-left":-90}),e.jsxs(z.Physics,{debug:!1,gravity:[0,-9.81,0],children:[t&&_?.type==="character"&&e.jsx(R.ControllerWrapper,{controllerOptions:{lerp:{cameraTurn:.1,cameraPosition:.08}},rigidBodyProps:{lockRotations:!0},parts:C(),position:[0,1,0],rotation:z.euler({x:0,y:Math.PI,z:0})},`preview-${t.id}`),c&&e.jsxs(e.Fragment,{children:[e.jsx(R.Clicker,{}),e.jsx(R.GroundClicker,{})]}),e.jsx(z.RigidBody,{type:"fixed",children:e.jsxs("mesh",{receiveShadow:!0,position:[0,-.5,0],children:[e.jsx("boxGeometry",{args:[100,1,100]}),e.jsx("meshStandardMaterial",{color:"#303030"})]})}),e.jsx(U.Grid,{renderOrder:-1,position:[0,.01,0],infiniteGrid:!0,cellSize:1,cellThickness:.5,cellColor:"#404040",sectionSize:5,sectionThickness:1,sectionColor:"#606060",fadeDistance:50,fadeStrength:1,followCamera:!1,userData:{intangible:!0}})]})]}),t&&e.jsxs("div",{className:"blueprint-preview__info",children:[e.jsx("h4",{className:"blueprint-preview__name",children:t.name}),e.jsx("p",{className:"blueprint-preview__type",children:t.type}),g(t)&&t.physics&&e.jsxs("div",{className:"blueprint-preview__stats",children:[e.jsxs("div",{children:["Move Speed: ",t.physics.moveSpeed]}),e.jsxs("div",{children:["Jump Force: ",t.physics.jumpForce]})]}),e.jsxs("div",{className:"blueprint-preview__controls",children:[e.jsxs("div",{children:["Camera: ",g(t)?t.camera?.mode||"thirdPerson":"N/A"]}),e.jsxs("div",{children:["Keyboard: ",v?"Enabled":"Disabled"]}),e.jsxs("div",{children:["Mouse: ",A?"Enabled":"Disabled"]}),e.jsxs("div",{children:["Click to Move: ",c?"Enabled":"Disabled"]})]})]})]})}const ee=t=>{switch(t.type){case"animation-sequence":return"animation";case"behavior-tree":return"behavior";default:return t.type}},K=t=>({id:t.id,name:t.name,type:ee(t),version:t.version,tags:t.tags||[],description:t.description??"",lastModified:new Date().toISOString().split("T")[0]??""}),G=t=>typeof t=="object"&&t!==null&&!Array.isArray(t),te=(t,o,u)=>{if(o.length===0)return!1;let s=t;for(let l=0;l<o.length-1;l++){const h=o[l];if(!h)return!1;if(Array.isArray(s)){const c=Number(h);if(!Number.isInteger(c)||c<0||c>=s.length)return!1;s=s[c];continue}if(!G(s))return!1;s=s[h]}const _=o[o.length-1];if(!_)return!1;if(Array.isArray(s)){const l=Number(_);return!Number.isInteger(l)||l<0||l>=s.length?!1:(s[l]=u,!0)}return G(s)?(s[_]=u,!0):!1},se=[{id:"characters",name:"Characters",type:"character",count:0},{id:"vehicles",name:"Vehicles",type:"vehicle",count:0},{id:"airplanes",name:"Airplanes",type:"airplane",count:0},{id:"animations",name:"Animations",type:"animation",count:0},{id:"behaviors",name:"Behaviors",type:"behavior",count:0},{id:"items",name:"Items",type:"item",count:0}],re=({onClose:t})=>{const[o,u]=d.useState("character"),[s,_]=d.useState(null),[l,h]=d.useState(""),[c,v]=d.useState(null),[A,C]=d.useState(!0),{spawnAtCursor:r,isSpawning:b}=E.useSpawnFromBlueprint(),N=d.useMemo(()=>E.blueprintRegistry.getAll().map(K),[]),P=d.useMemo(()=>{const i={character:0,vehicle:0,airplane:0,animation:0,behavior:0,item:0};return N.forEach(a=>{a.type in i&&i[a.type]++}),se.map(a=>({...a,count:i[a.type]})).filter(a=>a.count>0)},[N]),w=d.useMemo(()=>N.filter(i=>{const a=i.type===o,m=l===""||i.name.toLowerCase().includes(l.toLowerCase())||i.tags.some(x=>x.toLowerCase().includes(l.toLowerCase()));return a&&m}),[o,l,N]),M=d.useCallback((i,a)=>{v(m=>{if(!m)return null;const x=JSON.parse(JSON.stringify(m));return te(x,i,a)?x:m})},[]),S=d.useCallback(i=>{if(_(i),i){const a=E.blueprintRegistry.get(i);a&&v(JSON.parse(JSON.stringify(a)))}else v(null)},[]);d.useEffect(()=>{const i=w.some(a=>a.id===s);w[0]?.id&&w.length>0&&!i?S(w[0].id):w.length===0&&S(null)},[w,s,S]);const I=async()=>{if(!s)return;await r(s)&&t()},D=(i,a,m)=>Array.isArray(a)?e.jsxs("div",{className:"blueprint-editor__inspector-group",children:[e.jsx("div",{className:"blueprint-editor__inspector-title",children:i}),e.jsx("div",{className:"blueprint-editor__inspector-list",children:a.length===0?"비어 있음":`${a.length}개 항목`})]},m.join(".")):G(a)?e.jsxs("div",{className:"blueprint-editor__inspector-group",children:[e.jsx("div",{className:"blueprint-editor__inspector-title",children:i}),Object.entries(a).map(([x,T])=>D(x,T,[...m,x]))]},m.join(".")):typeof a=="boolean"?e.jsxs("label",{className:"blueprint-editor__inspector-field",children:[e.jsx("span",{children:i}),e.jsx("button",{className:`blueprint-editor__toggle ${a?"blueprint-editor__toggle--on":""}`,onClick:()=>M(m,!a),children:a?"ON":"OFF"})]},m.join(".")):typeof a=="number"?e.jsxs("label",{className:"blueprint-editor__inspector-field",children:[e.jsx("span",{children:i}),e.jsx("input",{type:"number",value:a,onChange:x=>M(m,Number(x.target.value)),className:"blueprint-editor__inspector-input"})]},m.join(".")):e.jsxs("label",{className:"blueprint-editor__inspector-field",children:[e.jsx("span",{children:i}),e.jsx("input",{type:"text",value:typeof a=="string"?a:"",onChange:x=>M(m,x.target.value),className:"blueprint-editor__inspector-input"})]},m.join("."));return e.jsxs("div",{className:"blueprint-editor",children:[e.jsxs("div",{className:"blueprint-editor__sidebar",children:[e.jsx("div",{className:"blueprint-editor__search",children:e.jsx("input",{type:"text",placeholder:"Search blueprints...",value:l,onChange:i=>h(i.target.value),className:"blueprint-editor__search-input"})}),e.jsx("div",{className:"blueprint-editor__categories",children:P.map(i=>e.jsxs("button",{onClick:()=>u(i.type),className:`blueprint-editor__category ${o===i.type?"active":""}`,children:[e.jsx("span",{className:"blueprint-editor__category-name",children:i.name}),e.jsx("span",{className:"blueprint-editor__category-count",children:i.count})]},i.id))}),e.jsx("div",{className:"blueprint-editor__list",children:w.map(i=>e.jsxs("div",{onClick:()=>S(i.id),className:`blueprint-editor__item ${s===i.id?"active":""}`,children:[e.jsx("div",{className:"blueprint-editor__item-name",children:i.name}),e.jsx("div",{className:"blueprint-editor__item-tags",children:i.tags.map(a=>e.jsx("span",{className:"blueprint-editor__tag",children:a},a))})]},i.id))}),e.jsx("div",{className:"blueprint-editor__actions",children:e.jsx("button",{onClick:I,disabled:!s||b,className:"blueprint-editor__spawn-button",children:b?"Spawning...":"Spawn Entity"})})]}),e.jsxs("div",{className:"blueprint-editor__main",children:[e.jsxs("div",{className:"blueprint-editor__preview-section",children:[e.jsxs("div",{className:"blueprint-editor__preview-header",children:[e.jsx("h3",{className:"blueprint-editor__preview-title",children:"Preview"}),e.jsx("button",{onClick:()=>C(!A),className:"blueprint-editor__preview-toggle",children:A?"Hide":"Show"})]}),A&&e.jsx("div",{className:"blueprint-editor__preview-container",children:e.jsx(Z,{blueprint:c},c?c.id:"no-blueprint")})]}),e.jsxs("div",{className:"blueprint-editor__inspector-section",children:[e.jsx("div",{className:"blueprint-editor__preview-header",children:e.jsx("h3",{className:"blueprint-editor__preview-title",children:"Inspector"})}),e.jsx("div",{className:"blueprint-editor__inspector",children:c?Object.entries(c).map(([i,a])=>D(i,a,[i])):e.jsx("div",{className:"blueprint-editor__empty",children:"블루프린트를 선택하세요."})})]})]})]})},F=t=>typeof t=="object"&&t!==null&&!Array.isArray(t),ie=(t,o,u)=>{if(o.length===0)return!1;let s=t;for(let l=0;l<o.length-1;l++){const h=o[l];if(!h)return!1;if(Array.isArray(s)){const c=Number(h);if(!Number.isInteger(c)||c<0||c>=s.length)return!1;s=s[c];continue}if(!F(s))return!1;s=s[h]}const _=o[o.length-1];if(!_)return!1;if(Array.isArray(s)){const l=Number(_);return!Number.isInteger(l)||l<0||l>=s.length?!1:(s[l]=u,!0)}return F(s)?(s[_]=u,!0):!1},ne=[{id:"characters",name:"Characters",type:"character",count:0},{id:"vehicles",name:"Vehicles",type:"vehicle",count:0},{id:"airplanes",name:"Airplanes",type:"airplane",count:0},{id:"animations",name:"Animations",type:"animation",count:0},{id:"behaviors",name:"Behaviors",type:"behavior",count:0},{id:"items",name:"Items",type:"item",count:0}],ae=({className:t="",style:o,children:u})=>{const[s,_]=d.useState("character"),[l,h]=d.useState(null),[c,v]=d.useState(""),[A,C]=d.useState(!1),[r,b]=d.useState(null),[N,P]=d.useState(!1),{spawnAtCursor:w,isSpawning:M}=E.useSpawnFromBlueprint(),S=d.useMemo(()=>E.blueprintRegistry.getAll().map(K),[]),I=d.useMemo(()=>{const n={character:0,vehicle:0,airplane:0,animation:0,behavior:0,item:0};return S.forEach(p=>{p.type in n&&n[p.type]++}),ne.map(p=>({...p,count:n[p.type]}))},[S]),D=d.useMemo(()=>S.filter(n=>{const p=n.type===s,j=c===""||n.name.toLowerCase().includes(c.toLowerCase())||n.tags.some(f=>f.toLowerCase().includes(c.toLowerCase()));return p&&j}),[s,c,S]),i=n=>{h(n);const p=E.blueprintRegistry.get(n);p&&b(JSON.parse(JSON.stringify(p)))},a=()=>{C(!0)},m=()=>{r&&(E.blueprintRegistry.register(r),C(!1),P(!1),i(r.id))},x=()=>{if(C(!1),l){const n=E.blueprintRegistry.get(l);n&&b(JSON.parse(JSON.stringify(n)))}},T=()=>{let n;const p={id:`custom_${s}_${Date.now()}`,name:`New ${s.charAt(0).toUpperCase()+s.slice(1)}`,version:"1.0.0",tags:["custom"],description:"Custom blueprint"};switch(s){case"vehicle":n={...p,type:"vehicle",physics:{mass:1e3,maxSpeed:30,acceleration:10,braking:15,turning:2},seats:[{position:[0,1,0],isDriver:!0}],animations:{idle:""}};break;case"airplane":n={...p,type:"airplane",physics:{mass:2e3,maxSpeed:100,acceleration:20,turning:1,lift:50,drag:10},seats:[{position:[0,1,2],isDriver:!0}],animations:{idle:""}};break;default:n={...p,type:"character",physics:{mass:70,height:1.8,radius:.3,jumpForce:300,moveSpeed:5,runSpeed:10,airControl:.2},animations:{idle:"",walk:"",run:"",jump:{start:"",loop:"",land:""}},stats:{health:100,stamina:50,strength:10,defense:10,speed:10}}}b(n),h(n.id),P(!0),C(!0)},q=(n,p)=>{if(!r)return;const j=JSON.parse(JSON.stringify(r));ie(j,n,p)&&b(j)},J=(n,p=[])=>{const j=[];return Object.entries(n).forEach(([f,y])=>{const k=[...p,f],O=k.join(".");f==="id"||f==="type"?j.push(e.jsxs("div",{className:"property-editor__field",children:[e.jsxs("label",{className:"property-editor__label editor-text-small",children:[f,":"]}),e.jsx("input",{type:"text",value:y,disabled:!0,className:"property-editor__input property-editor__input--disabled"})]},O)):F(y)?j.push(e.jsxs("div",{className:"property-editor__group",children:[e.jsxs("div",{className:"property-editor__group-title editor-text",children:[f.charAt(0).toUpperCase()+f.slice(1),":"]}),e.jsx("div",{className:"property-editor__group-content",children:J(y,k)})]},O)):Array.isArray(y)?y.length>0&&y.every(F)?j.push(e.jsxs("div",{className:"property-editor__group",children:[e.jsxs("div",{className:"property-editor__group-title editor-text",children:[f.charAt(0).toUpperCase()+f.slice(1),":"]}),e.jsx("div",{className:"property-editor__group-content",children:y.map((B,$)=>e.jsxs("div",{className:"property-editor__array-item",children:[e.jsxs("div",{className:"property-editor__array-item-title editor-text-small",children:["Item ",$+1]}),J(B,[...k,$.toString()])]},`${O}.${$}`))})]},O)):j.push(e.jsxs("div",{className:"property-editor__field",children:[e.jsxs("label",{className:"property-editor__label editor-text-small",children:[f,":"]}),e.jsx("input",{type:"text",value:y.join(", "),onChange:B=>q(k,B.target.value.split(",").map($=>$.trim())),className:"property-editor__input"})]},O)):typeof y=="boolean"?j.push(e.jsx("div",{className:"property-editor__field",children:e.jsxs("label",{className:"property-editor__checkbox-label editor-text-small",children:[e.jsx("input",{type:"checkbox",checked:y,onChange:B=>q(k,B.target.checked),className:"property-editor__checkbox"}),f]})},O)):j.push(e.jsxs("div",{className:"property-editor__field",children:[e.jsxs("label",{className:"property-editor__label editor-text-small",children:[f,":"]}),e.jsx("input",{type:typeof y=="number"?"number":"text",value:y,onChange:B=>q(k,typeof y=="number"?Number(B.target.value):B.target.value),className:"property-editor__input"})]},O))}),j},Q=async()=>{!l||await w(l)};return e.jsxs("div",{className:`blueprint-panel ${t}`,style:o,children:[e.jsx("h3",{className:"editor-title",children:"Blueprint Library"}),e.jsx("div",{className:"blueprint-panel__toolbar",children:e.jsxs("div",{className:"blueprint-panel__search-container",children:[e.jsx("input",{type:"text",placeholder:"Search blueprints...",value:c,onChange:n=>v(n.target.value),className:"blueprint-panel__search-input"}),e.jsx("button",{onClick:T,className:"blueprint-panel__button blueprint-panel__button--primary",children:"+ New Blueprint"})]})}),e.jsx("div",{className:"blueprint-panel__categories",children:I.map(n=>e.jsxs("button",{onClick:()=>_(n.type),className:`blueprint-panel__category-button ${s===n.type?"blueprint-panel__category-button--active":""}`,children:[e.jsx("span",{children:n.name}),e.jsxs("span",{children:["(",n.count,")"]})]},n.id))}),A?e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"blueprint-panel__property-editor-container editor-scrollbar",children:r&&e.jsxs("div",{children:[e.jsx("h4",{className:"blueprint-panel__property-editor-title editor-text",children:N?"Create New Blueprint":`Edit: ${r.name}`}),J(r)]})}),e.jsx("div",{className:"blueprint-panel__footer",children:e.jsxs("div",{className:"blueprint-panel__footer-buttons",children:[e.jsx("button",{onClick:m,className:"blueprint-panel__button blueprint-panel__button--primary",children:N?"Create":"Save"}),e.jsx("button",{onClick:x,className:"blueprint-panel__button blueprint-panel__button--danger",children:"Cancel"})]})})]}):e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"blueprint-panel__list editor-scrollbar",children:D.length===0?e.jsx("div",{className:"blueprint-panel__empty-message editor-text-small",children:"No blueprints found"}):D.map(n=>e.jsx("div",{onClick:()=>i(n.id),className:`blueprint-panel__list-item ${l===n.id?"blueprint-panel__list-item--selected":""}`,children:e.jsxs("div",{className:"list-item__content",children:[e.jsxs("div",{className:"list-item__text-content",children:[e.jsx("div",{className:"list-item__name editor-text",children:n.name}),e.jsx("div",{className:"list-item__description editor-text-small",children:n.description}),e.jsx("div",{className:"list-item__tags",children:n.tags.map(p=>e.jsx("span",{className:"list-item__tag editor-text-small",children:p},p))})]}),e.jsxs("div",{className:"list-item__meta editor-text-small",children:[e.jsxs("div",{children:["v",n.version]}),e.jsx("div",{children:n.lastModified})]})]})},n.id))}),l&&e.jsx("div",{className:"blueprint-panel__footer",children:e.jsxs("div",{className:"blueprint-panel__footer-buttons",children:[e.jsx("button",{onClick:a,className:"blueprint-panel__button blueprint-panel__button--secondary",children:"Edit Blueprint"}),e.jsx("button",{onClick:Q,disabled:M,className:"blueprint-panel__button blueprint-panel__button--primary",children:M?"Spawning...":"Spawn Entity"})]})})]}),u]})};exports.BlueprintEditor=re;exports.BlueprintPanel=ae;exports.BlueprintPreview=Z;
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("react/jsx-runtime"),d=require("react"),E=require("./useSpawnFromBlueprint-aIQsqI3Q.cjs"),U=require("@react-three/drei"),W=require("@react-three/fiber"),z=require("@react-three/rapier"),H=require("three"),L=require("./gaesupStore-2zKBYTYo.cjs"),R=require("./index-Cpso39Zs.cjs"),V=require("./index-D1hpjfAw.cjs");function Y(t){const o=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(t){for(const u in t)if(u!=="default"){const s=Object.getOwnPropertyDescriptor(t,u);Object.defineProperty(o,u,s.get?s:{enumerable:!0,get:()=>t[u]})}}return o.default=t,Object.freeze(o)}const X=Y(H),g=t=>t?.type==="character";function Z({blueprint:t}){const o=L.useGaesupStore(r=>r.setUrls),u=L.useGaesupStore(r=>r.setCameraOption),s=L.useGaesupStore(r=>r.setMode),_=L.useGaesupStore(r=>r.mode),[l,h]=d.useState(20),c=g(t)?t.controls?.clickToMove??!0:!1,v=g(t)?t.controls?.enableKeyboard??!0:!1,A=g(t)?t.controls?.enableMouse??!0:!1;R.useKeyboard(v,v),d.useEffect(()=>{s({type:"character",control:g(t)&&t.camera?.mode||"thirdPerson"});const r=g(t)?t.camera||{}:{};u({xDistance:r.distance?.x||l,yDistance:r.distance?.y||l*.5,zDistance:r.distance?.z||l,offset:new X.Vector3(0,0,0),enableCollision:r.enableCollision??!1,smoothing:r.smoothing||{position:.25,rotation:.3,fov:.2},fov:r.fov||50,zoom:1,enableZoom:r.enableZoom??!0,zoomSpeed:r.zoomSpeed||.001,minZoom:r.minZoom||.5,maxZoom:r.maxZoom||3,enableFocus:!1,maxDistance:50,distance:10,bounds:{minY:2,maxY:50}})},[s,u,l,t]),d.useEffect(()=>{if(g(t)){if(t.visuals?.model)o({characterUrl:t.visuals.model});else if(t.visuals?.parts&&t.visuals.parts.length>0){const r=t.visuals.parts.find(b=>b.type==="body");r&&o({characterUrl:r.url})}}},[t,o]),d.useEffect(()=>{const r=b=>{if(g(t)&&t.camera?.enableZoom===!1)return;b.preventDefault();const N=b.deltaY*.01;h(P=>Math.max(10,Math.min(40,P+N)))};return window.addEventListener("wheel",r,{passive:!1}),()=>window.removeEventListener("wheel",r)},[t]);const C=()=>!g(t)||!t.visuals?.parts?[]:t.visuals.parts.filter(r=>r.type!=="body").map(r=>r.color?{url:r.url,color:r.color}:{url:r.url});return e.jsxs("div",{className:"blueprint-preview",children:[e.jsxs(W.Canvas,{shadows:!0,camera:{position:[0,10,20],fov:50},style:{width:"100%",height:"100%"},children:[e.jsx(V.Camera,{}),e.jsx(U.Environment,{preset:"sunset"}),e.jsx("ambientLight",{intensity:.5}),e.jsx("directionalLight",{castShadow:!0,position:[20,30,10],intensity:.5,"shadow-mapSize":[1024,1024],"shadow-camera-near":1,"shadow-camera-far":120,"shadow-camera-top":90,"shadow-camera-right":90,"shadow-camera-bottom":-90,"shadow-camera-left":-90}),e.jsxs(z.Physics,{debug:!1,gravity:[0,-9.81,0],children:[t&&_?.type==="character"&&e.jsx(R.ControllerWrapper,{controllerOptions:{lerp:{cameraTurn:.1,cameraPosition:.08}},rigidBodyProps:{lockRotations:!0},parts:C(),position:[0,1,0],rotation:z.euler({x:0,y:Math.PI,z:0})},`preview-${t.id}`),c&&e.jsxs(e.Fragment,{children:[e.jsx(R.Clicker,{}),e.jsx(R.GroundClicker,{})]}),e.jsx(z.RigidBody,{type:"fixed",children:e.jsxs("mesh",{receiveShadow:!0,position:[0,-.5,0],children:[e.jsx("boxGeometry",{args:[100,1,100]}),e.jsx("meshStandardMaterial",{color:"#303030"})]})}),e.jsx(U.Grid,{renderOrder:-1,position:[0,.01,0],infiniteGrid:!0,cellSize:1,cellThickness:.5,cellColor:"#404040",sectionSize:5,sectionThickness:1,sectionColor:"#606060",fadeDistance:50,fadeStrength:1,followCamera:!1,userData:{intangible:!0}})]})]}),t&&e.jsxs("div",{className:"blueprint-preview__info",children:[e.jsx("h4",{className:"blueprint-preview__name",children:t.name}),e.jsx("p",{className:"blueprint-preview__type",children:t.type}),g(t)&&t.physics&&e.jsxs("div",{className:"blueprint-preview__stats",children:[e.jsxs("div",{children:["Move Speed: ",t.physics.moveSpeed]}),e.jsxs("div",{children:["Jump Force: ",t.physics.jumpForce]})]}),e.jsxs("div",{className:"blueprint-preview__controls",children:[e.jsxs("div",{children:["Camera: ",g(t)?t.camera?.mode||"thirdPerson":"N/A"]}),e.jsxs("div",{children:["Keyboard: ",v?"Enabled":"Disabled"]}),e.jsxs("div",{children:["Mouse: ",A?"Enabled":"Disabled"]}),e.jsxs("div",{children:["Click to Move: ",c?"Enabled":"Disabled"]})]})]})]})}const ee=t=>{switch(t.type){case"animation-sequence":return"animation";case"behavior-tree":return"behavior";default:return t.type}},K=t=>({id:t.id,name:t.name,type:ee(t),version:t.version,tags:t.tags||[],description:t.description??"",lastModified:new Date().toISOString().split("T")[0]??""}),G=t=>typeof t=="object"&&t!==null&&!Array.isArray(t),te=(t,o,u)=>{if(o.length===0)return!1;let s=t;for(let l=0;l<o.length-1;l++){const h=o[l];if(!h)return!1;if(Array.isArray(s)){const c=Number(h);if(!Number.isInteger(c)||c<0||c>=s.length)return!1;s=s[c];continue}if(!G(s))return!1;s=s[h]}const _=o[o.length-1];if(!_)return!1;if(Array.isArray(s)){const l=Number(_);return!Number.isInteger(l)||l<0||l>=s.length?!1:(s[l]=u,!0)}return G(s)?(s[_]=u,!0):!1},se=[{id:"characters",name:"Characters",type:"character",count:0},{id:"vehicles",name:"Vehicles",type:"vehicle",count:0},{id:"airplanes",name:"Airplanes",type:"airplane",count:0},{id:"animations",name:"Animations",type:"animation",count:0},{id:"behaviors",name:"Behaviors",type:"behavior",count:0},{id:"items",name:"Items",type:"item",count:0}],re=({onClose:t})=>{const[o,u]=d.useState("character"),[s,_]=d.useState(null),[l,h]=d.useState(""),[c,v]=d.useState(null),[A,C]=d.useState(!0),{spawnAtCursor:r,isSpawning:b}=E.useSpawnFromBlueprint(),N=d.useMemo(()=>E.blueprintRegistry.getAll().map(K),[]),P=d.useMemo(()=>{const i={character:0,vehicle:0,airplane:0,animation:0,behavior:0,item:0};return N.forEach(a=>{a.type in i&&i[a.type]++}),se.map(a=>({...a,count:i[a.type]})).filter(a=>a.count>0)},[N]),w=d.useMemo(()=>N.filter(i=>{const a=i.type===o,m=l===""||i.name.toLowerCase().includes(l.toLowerCase())||i.tags.some(x=>x.toLowerCase().includes(l.toLowerCase()));return a&&m}),[o,l,N]),M=d.useCallback((i,a)=>{v(m=>{if(!m)return null;const x=JSON.parse(JSON.stringify(m));return te(x,i,a)?x:m})},[]),S=d.useCallback(i=>{if(_(i),i){const a=E.blueprintRegistry.get(i);a&&v(JSON.parse(JSON.stringify(a)))}else v(null)},[]);d.useEffect(()=>{const i=w.some(a=>a.id===s);w[0]?.id&&w.length>0&&!i?S(w[0].id):w.length===0&&S(null)},[w,s,S]);const I=async()=>{if(!s)return;await r(s)&&t()},D=(i,a,m)=>Array.isArray(a)?e.jsxs("div",{className:"blueprint-editor__inspector-group",children:[e.jsx("div",{className:"blueprint-editor__inspector-title",children:i}),e.jsx("div",{className:"blueprint-editor__inspector-list",children:a.length===0?"비어 있음":`${a.length}개 항목`})]},m.join(".")):G(a)?e.jsxs("div",{className:"blueprint-editor__inspector-group",children:[e.jsx("div",{className:"blueprint-editor__inspector-title",children:i}),Object.entries(a).map(([x,T])=>D(x,T,[...m,x]))]},m.join(".")):typeof a=="boolean"?e.jsxs("label",{className:"blueprint-editor__inspector-field",children:[e.jsx("span",{children:i}),e.jsx("button",{className:`blueprint-editor__toggle ${a?"blueprint-editor__toggle--on":""}`,onClick:()=>M(m,!a),children:a?"ON":"OFF"})]},m.join(".")):typeof a=="number"?e.jsxs("label",{className:"blueprint-editor__inspector-field",children:[e.jsx("span",{children:i}),e.jsx("input",{type:"number",value:a,onChange:x=>M(m,Number(x.target.value)),className:"blueprint-editor__inspector-input"})]},m.join(".")):e.jsxs("label",{className:"blueprint-editor__inspector-field",children:[e.jsx("span",{children:i}),e.jsx("input",{type:"text",value:typeof a=="string"?a:"",onChange:x=>M(m,x.target.value),className:"blueprint-editor__inspector-input"})]},m.join("."));return e.jsxs("div",{className:"blueprint-editor",children:[e.jsxs("div",{className:"blueprint-editor__sidebar",children:[e.jsx("div",{className:"blueprint-editor__search",children:e.jsx("input",{type:"text",placeholder:"Search blueprints...",value:l,onChange:i=>h(i.target.value),className:"blueprint-editor__search-input"})}),e.jsx("div",{className:"blueprint-editor__categories",children:P.map(i=>e.jsxs("button",{onClick:()=>u(i.type),className:`blueprint-editor__category ${o===i.type?"active":""}`,children:[e.jsx("span",{className:"blueprint-editor__category-name",children:i.name}),e.jsx("span",{className:"blueprint-editor__category-count",children:i.count})]},i.id))}),e.jsx("div",{className:"blueprint-editor__list",children:w.map(i=>e.jsxs("div",{onClick:()=>S(i.id),className:`blueprint-editor__item ${s===i.id?"active":""}`,children:[e.jsx("div",{className:"blueprint-editor__item-name",children:i.name}),e.jsx("div",{className:"blueprint-editor__item-tags",children:i.tags.map(a=>e.jsx("span",{className:"blueprint-editor__tag",children:a},a))})]},i.id))}),e.jsx("div",{className:"blueprint-editor__actions",children:e.jsx("button",{onClick:I,disabled:!s||b,className:"blueprint-editor__spawn-button",children:b?"Spawning...":"Spawn Entity"})})]}),e.jsxs("div",{className:"blueprint-editor__main",children:[e.jsxs("div",{className:"blueprint-editor__preview-section",children:[e.jsxs("div",{className:"blueprint-editor__preview-header",children:[e.jsx("h3",{className:"blueprint-editor__preview-title",children:"Preview"}),e.jsx("button",{onClick:()=>C(!A),className:"blueprint-editor__preview-toggle",children:A?"Hide":"Show"})]}),A&&e.jsx("div",{className:"blueprint-editor__preview-container",children:e.jsx(Z,{blueprint:c},c?c.id:"no-blueprint")})]}),e.jsxs("div",{className:"blueprint-editor__inspector-section",children:[e.jsx("div",{className:"blueprint-editor__preview-header",children:e.jsx("h3",{className:"blueprint-editor__preview-title",children:"Inspector"})}),e.jsx("div",{className:"blueprint-editor__inspector",children:c?Object.entries(c).map(([i,a])=>D(i,a,[i])):e.jsx("div",{className:"blueprint-editor__empty",children:"블루프린트를 선택하세요."})})]})]})]})},F=t=>typeof t=="object"&&t!==null&&!Array.isArray(t),ie=(t,o,u)=>{if(o.length===0)return!1;let s=t;for(let l=0;l<o.length-1;l++){const h=o[l];if(!h)return!1;if(Array.isArray(s)){const c=Number(h);if(!Number.isInteger(c)||c<0||c>=s.length)return!1;s=s[c];continue}if(!F(s))return!1;s=s[h]}const _=o[o.length-1];if(!_)return!1;if(Array.isArray(s)){const l=Number(_);return!Number.isInteger(l)||l<0||l>=s.length?!1:(s[l]=u,!0)}return F(s)?(s[_]=u,!0):!1},ne=[{id:"characters",name:"Characters",type:"character",count:0},{id:"vehicles",name:"Vehicles",type:"vehicle",count:0},{id:"airplanes",name:"Airplanes",type:"airplane",count:0},{id:"animations",name:"Animations",type:"animation",count:0},{id:"behaviors",name:"Behaviors",type:"behavior",count:0},{id:"items",name:"Items",type:"item",count:0}],ae=({className:t="",style:o,children:u})=>{const[s,_]=d.useState("character"),[l,h]=d.useState(null),[c,v]=d.useState(""),[A,C]=d.useState(!1),[r,b]=d.useState(null),[N,P]=d.useState(!1),{spawnAtCursor:w,isSpawning:M}=E.useSpawnFromBlueprint(),S=d.useMemo(()=>E.blueprintRegistry.getAll().map(K),[]),I=d.useMemo(()=>{const n={character:0,vehicle:0,airplane:0,animation:0,behavior:0,item:0};return S.forEach(p=>{p.type in n&&n[p.type]++}),ne.map(p=>({...p,count:n[p.type]}))},[S]),D=d.useMemo(()=>S.filter(n=>{const p=n.type===s,j=c===""||n.name.toLowerCase().includes(c.toLowerCase())||n.tags.some(f=>f.toLowerCase().includes(c.toLowerCase()));return p&&j}),[s,c,S]),i=n=>{h(n);const p=E.blueprintRegistry.get(n);p&&b(JSON.parse(JSON.stringify(p)))},a=()=>{C(!0)},m=()=>{r&&(E.blueprintRegistry.register(r),C(!1),P(!1),i(r.id))},x=()=>{if(C(!1),l){const n=E.blueprintRegistry.get(l);n&&b(JSON.parse(JSON.stringify(n)))}},T=()=>{let n;const p={id:`custom_${s}_${Date.now()}`,name:`New ${s.charAt(0).toUpperCase()+s.slice(1)}`,version:"1.0.0",tags:["custom"],description:"Custom blueprint"};switch(s){case"vehicle":n={...p,type:"vehicle",physics:{mass:1e3,maxSpeed:30,acceleration:10,braking:15,turning:2},seats:[{position:[0,1,0],isDriver:!0}],animations:{idle:""}};break;case"airplane":n={...p,type:"airplane",physics:{mass:2e3,maxSpeed:100,acceleration:20,turning:1,lift:50,drag:10},seats:[{position:[0,1,2],isDriver:!0}],animations:{idle:""}};break;default:n={...p,type:"character",physics:{mass:70,height:1.8,radius:.3,jumpForce:300,moveSpeed:5,runSpeed:10,airControl:.2},animations:{idle:"",walk:"",run:"",jump:{start:"",loop:"",land:""}},stats:{health:100,stamina:50,strength:10,defense:10,speed:10}}}b(n),h(n.id),P(!0),C(!0)},q=(n,p)=>{if(!r)return;const j=JSON.parse(JSON.stringify(r));ie(j,n,p)&&b(j)},J=(n,p=[])=>{const j=[];return Object.entries(n).forEach(([f,y])=>{const k=[...p,f],O=k.join(".");f==="id"||f==="type"?j.push(e.jsxs("div",{className:"property-editor__field",children:[e.jsxs("label",{className:"property-editor__label editor-text-small",children:[f,":"]}),e.jsx("input",{type:"text",value:y,disabled:!0,className:"property-editor__input property-editor__input--disabled"})]},O)):F(y)?j.push(e.jsxs("div",{className:"property-editor__group",children:[e.jsxs("div",{className:"property-editor__group-title editor-text",children:[f.charAt(0).toUpperCase()+f.slice(1),":"]}),e.jsx("div",{className:"property-editor__group-content",children:J(y,k)})]},O)):Array.isArray(y)?y.length>0&&y.every(F)?j.push(e.jsxs("div",{className:"property-editor__group",children:[e.jsxs("div",{className:"property-editor__group-title editor-text",children:[f.charAt(0).toUpperCase()+f.slice(1),":"]}),e.jsx("div",{className:"property-editor__group-content",children:y.map((B,$)=>e.jsxs("div",{className:"property-editor__array-item",children:[e.jsxs("div",{className:"property-editor__array-item-title editor-text-small",children:["Item ",$+1]}),J(B,[...k,$.toString()])]},`${O}.${$}`))})]},O)):j.push(e.jsxs("div",{className:"property-editor__field",children:[e.jsxs("label",{className:"property-editor__label editor-text-small",children:[f,":"]}),e.jsx("input",{type:"text",value:y.join(", "),onChange:B=>q(k,B.target.value.split(",").map($=>$.trim())),className:"property-editor__input"})]},O)):typeof y=="boolean"?j.push(e.jsx("div",{className:"property-editor__field",children:e.jsxs("label",{className:"property-editor__checkbox-label editor-text-small",children:[e.jsx("input",{type:"checkbox",checked:y,onChange:B=>q(k,B.target.checked),className:"property-editor__checkbox"}),f]})},O)):j.push(e.jsxs("div",{className:"property-editor__field",children:[e.jsxs("label",{className:"property-editor__label editor-text-small",children:[f,":"]}),e.jsx("input",{type:typeof y=="number"?"number":"text",value:y,onChange:B=>q(k,typeof y=="number"?Number(B.target.value):B.target.value),className:"property-editor__input"})]},O))}),j},Q=async()=>{!l||await w(l)};return e.jsxs("div",{className:`blueprint-panel ${t}`,style:o,children:[e.jsx("h3",{className:"editor-title",children:"Blueprint Library"}),e.jsx("div",{className:"blueprint-panel__toolbar",children:e.jsxs("div",{className:"blueprint-panel__search-container",children:[e.jsx("input",{type:"text",placeholder:"Search blueprints...",value:c,onChange:n=>v(n.target.value),className:"blueprint-panel__search-input"}),e.jsx("button",{onClick:T,className:"blueprint-panel__button blueprint-panel__button--primary",children:"+ New Blueprint"})]})}),e.jsx("div",{className:"blueprint-panel__categories",children:I.map(n=>e.jsxs("button",{onClick:()=>_(n.type),className:`blueprint-panel__category-button ${s===n.type?"blueprint-panel__category-button--active":""}`,children:[e.jsx("span",{children:n.name}),e.jsxs("span",{children:["(",n.count,")"]})]},n.id))}),A?e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"blueprint-panel__property-editor-container editor-scrollbar",children:r&&e.jsxs("div",{children:[e.jsx("h4",{className:"blueprint-panel__property-editor-title editor-text",children:N?"Create New Blueprint":`Edit: ${r.name}`}),J(r)]})}),e.jsx("div",{className:"blueprint-panel__footer",children:e.jsxs("div",{className:"blueprint-panel__footer-buttons",children:[e.jsx("button",{onClick:m,className:"blueprint-panel__button blueprint-panel__button--primary",children:N?"Create":"Save"}),e.jsx("button",{onClick:x,className:"blueprint-panel__button blueprint-panel__button--danger",children:"Cancel"})]})})]}):e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"blueprint-panel__list editor-scrollbar",children:D.length===0?e.jsx("div",{className:"blueprint-panel__empty-message editor-text-small",children:"No blueprints found"}):D.map(n=>e.jsx("div",{onClick:()=>i(n.id),className:`blueprint-panel__list-item ${l===n.id?"blueprint-panel__list-item--selected":""}`,children:e.jsxs("div",{className:"list-item__content",children:[e.jsxs("div",{className:"list-item__text-content",children:[e.jsx("div",{className:"list-item__name editor-text",children:n.name}),e.jsx("div",{className:"list-item__description editor-text-small",children:n.description}),e.jsx("div",{className:"list-item__tags",children:n.tags.map(p=>e.jsx("span",{className:"list-item__tag editor-text-small",children:p},p))})]}),e.jsxs("div",{className:"list-item__meta editor-text-small",children:[e.jsxs("div",{children:["v",n.version]}),e.jsx("div",{children:n.lastModified})]})]})},n.id))}),l&&e.jsx("div",{className:"blueprint-panel__footer",children:e.jsxs("div",{className:"blueprint-panel__footer-buttons",children:[e.jsx("button",{onClick:a,className:"blueprint-panel__button blueprint-panel__button--secondary",children:"Edit Blueprint"}),e.jsx("button",{onClick:Q,disabled:M,className:"blueprint-panel__button blueprint-panel__button--primary",children:M?"Spawning...":"Spawn Entity"})]})})]}),u]})};exports.BlueprintEditor=re;exports.BlueprintPanel=ae;exports.BlueprintPreview=Z;
|
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
import { jsxs as i, jsx as e, Fragment as K } from "react/jsx-runtime";
|
|
2
2
|
import { useState as g, useEffect as F, useMemo as M, useCallback as Q } from "react";
|
|
3
|
-
import { u as W, b as D } from "./useSpawnFromBlueprint-
|
|
3
|
+
import { u as W, b as D } from "./useSpawnFromBlueprint-BxRHlpvL.js";
|
|
4
4
|
import { Environment as H, Grid as q } from "@react-three/drei";
|
|
5
5
|
import { Canvas as X } from "@react-three/fiber";
|
|
6
6
|
import { Physics as ee, euler as te, RigidBody as ie } from "@react-three/rapier";
|
|
7
7
|
import * as re from "three";
|
|
8
8
|
import { u as J } from "./gaesupStore-DTu0tYBp.js";
|
|
9
|
-
import { u as ne, C as ae, a as se, G as oe } from "./index-
|
|
10
|
-
import { C as le } from "./index-
|
|
9
|
+
import { u as ne, C as ae, a as se, G as oe } from "./index-DXZjZF_s.js";
|
|
10
|
+
import { C as le } from "./index-DRLvJF_k.js";
|
|
11
11
|
const w = (t) => t?.type === "character";
|
|
12
12
|
function ce({ blueprint: t }) {
|
|
13
13
|
const d = J((n) => n.setUrls), b = J((n) => n.setCameraOption), r = J((n) => n.setMode), h = J((n) => n.mode), [l, u] = g(20), c = w(t) ? t.controls?.clickToMove ?? !0 : !1, C = w(t) ? t.controls?.enableKeyboard ?? !0 : !1, O = w(t) ? t.controls?.enableMouse ?? !0 : !1;
|
package/dist/blueprints.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { b as x } from "./useSpawnFromBlueprint-
|
|
2
|
-
import { B as ee, F as te, W as ie, u as se } from "./useSpawnFromBlueprint-
|
|
1
|
+
import { b as x } from "./useSpawnFromBlueprint-BxRHlpvL.js";
|
|
2
|
+
import { B as ee, F as te, W as ie, u as se } from "./useSpawnFromBlueprint-BxRHlpvL.js";
|
|
3
3
|
import { jsx as C } from "react/jsx-runtime";
|
|
4
4
|
import { useMemo as z, useRef as m, useEffect as M } from "react";
|
|
5
5
|
import { RigidBody as b } from "@react-three/rapier";
|
|
@@ -674,7 +674,7 @@ class u {
|
|
|
674
674
|
);
|
|
675
675
|
}
|
|
676
676
|
async createFromId(e, t) {
|
|
677
|
-
const { blueprintRegistry: s } = await import("./useSpawnFromBlueprint-
|
|
677
|
+
const { blueprintRegistry: s } = await import("./useSpawnFromBlueprint-BxRHlpvL.js").then((n) => n.r), r = s.get(e);
|
|
678
678
|
return r ? this.createEntity(r, t) : (console.error(`Blueprint not found: ${e}`), null);
|
|
679
679
|
}
|
|
680
680
|
createFromDefinition(e, t) {
|
package/dist/editor.js
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import "reflect-metadata";
|
|
2
|
-
import { g as _ } from "./plugin
|
|
3
|
-
import { A, s as C, y as G, w as U, F as f, z as N, D as O, I as v, H as y, K as W, B as x, x as w, v as F, U as b, J as h, C as M, _ as z, X as H, $ as k, a0 as K, a1 as V, ac as j, ad as J, ae as q, a8 as X, af as $, ag as Q, ah as Y, ai as Z, aj as aa, ak as ea, al as ia, am as ta, an as ra, ao as sa, E as na, a as oa, b as la, t as ua, aq as da, ap as ca, G as _a, q as Ea, N as Ta, a6 as Sa, M as Ia, P as La, R as ma, j as Da, k as pa, l as Ba, m as ga, p as Ra, n as Pa, o as Aa, S as Ca, T as Ga, V as Ua, W as fa, O as Na, a4 as Oa, as as va, aa as ya, a3 as Wa, at as xa, ab as wa, a2 as Fa, Z as ba, Q as ha, c as Ma, d as za, h as Ha, ax as ka, a9 as Ka, ar as Va, aD as ja, az as Ja, e as qa, aE as Xa, Y as $a, au as Qa, a7 as Ya, L as Za, ay as ae, i as ee, av as ie, r as te, aA as re, aB as se, aF as ne, aw as oe, a5 as le, aC as ue, u as de, f as ce } from "./plugin
|
|
2
|
+
import { g as _ } from "./plugin-BFzSydfr.js";
|
|
3
|
+
import { A, s as C, y as G, w as U, F as f, z as N, D as O, I as v, H as y, K as W, B as x, x as w, v as F, U as b, J as h, C as M, _ as z, X as H, $ as k, a0 as K, a1 as V, ac as j, ad as J, ae as q, a8 as X, af as $, ag as Q, ah as Y, ai as Z, aj as aa, ak as ea, al as ia, am as ta, an as ra, ao as sa, E as na, a as oa, b as la, t as ua, aq as da, ap as ca, G as _a, q as Ea, N as Ta, a6 as Sa, M as Ia, P as La, R as ma, j as Da, k as pa, l as Ba, m as ga, p as Ra, n as Pa, o as Aa, S as Ca, T as Ga, V as Ua, W as fa, O as Na, a4 as Oa, as as va, aa as ya, a3 as Wa, at as xa, ab as wa, a2 as Fa, Z as ba, Q as ha, c as Ma, d as za, h as Ha, ax as ka, a9 as Ka, ar as Va, aD as ja, az as Ja, e as qa, aE as Xa, Y as $a, au as Qa, a7 as Ya, L as Za, ay as ae, i as ee, av as ie, r as te, aA as re, aB as se, aF as ne, aw as oe, a5 as le, aC as ue, u as de, f as ce } from "./plugin-BFzSydfr.js";
|
|
4
4
|
import { useMemo as E } from "react";
|
|
5
5
|
import { useFrame as T } from "@react-three/fiber";
|
|
6
6
|
import * as d from "three";
|
|
7
|
-
import { Q as Ee, S as Te, R as Se, O as Ie, L as Le, P as me, N as De, M as pe, I as Be, K as ge, H as Re, J as Pe, a as Ae, b as Ce, e as Ge, d as Ue, f as fe, n as Ne, o as Oe, c as ve, r as ye, g as We, h as xe, i as we, j as Fe, k as be, l as he, m as Me, F as ze, p as He, q as ke, s as Ke, u as Ve, t as je, v as Je, w as qe, x as Xe, y as $e, z as Qe, G as Ye, A as Ze, B as ai, C as ei, D as ii, E as ti } from "./index-
|
|
7
|
+
import { Q as Ee, S as Te, R as Se, O as Ie, L as Le, P as me, N as De, M as pe, I as Be, K as ge, H as Re, J as Pe, a as Ae, b as Ce, e as Ge, d as Ue, f as fe, n as Ne, o as Oe, c as ve, r as ye, g as We, h as xe, i as we, j as Fe, k as be, l as he, m as Me, F as ze, p as He, q as ke, s as Ke, u as Ve, t as je, v as Je, w as qe, x as Xe, y as $e, z as Qe, G as Ye, A as Ze, B as ai, C as ei, D as ii, E as ti } from "./index-C5agFfBe.js";
|
|
8
8
|
import { H as t, P as o } from "./gaesupStore-DTu0tYBp.js";
|
|
9
9
|
import { C as si, H as ni, c as oi, l as li, v as ui, a as di } from "./loader-C3ZwumCe.js";
|
|
10
10
|
var S = Object.defineProperty, I = Object.getOwnPropertyDescriptor, r = (e, a, i, l) => {
|
|
@@ -2,8 +2,8 @@ import { jsx as s, jsxs as u } from "react/jsx-runtime";
|
|
|
2
2
|
import { useRef as d, useMemo as f, useEffect as v, useLayoutEffect as h, Suspense as g } from "react";
|
|
3
3
|
import { useThree as U, useFrame as D } from "@react-three/fiber";
|
|
4
4
|
import { u as l } from "./gaesupStore-DTu0tYBp.js";
|
|
5
|
-
import { T as x } from "./index-
|
|
6
|
-
import { C as y } from "./index-
|
|
5
|
+
import { T as x } from "./index-C5agFfBe.js";
|
|
6
|
+
import { C as y } from "./index-DRLvJF_k.js";
|
|
7
7
|
function C() {
|
|
8
8
|
const r = U((o) => o.gl), t = l((o) => o.setPerformance), n = d(0);
|
|
9
9
|
return D(() => {
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { useEffect as k, useRef as I, useState as P, useCallback as W, useMemo as Y } from "react";
|
|
2
|
-
import { g as $, S as tt } from "./index-
|
|
2
|
+
import { g as $, S as tt } from "./index-DGifA0e6.js";
|
|
3
3
|
import { c as et, a as nt, f as rt } from "./runtimeFilter-CS35UPHd.js";
|
|
4
4
|
import { u as st } from "./assetStore-mAClONjR.js";
|
|
5
5
|
import { c as ot } from "./snapshot-OExk53wq.js";
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";const i=require("react/jsx-runtime"),p=require("react"),O=require("three"),T=require("@react-three/drei"),w=require("./index-CJj-Z7Jr.cjs"),D=require("@react-three/fiber"),k=require("./gaesupStore-2zKBYTYo.cjs"),z=require("@react-three/rapier"),U=require("./index-D1hpjfAw.cjs");function q(e){const d=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(e){for(const a in e)if(a!=="default"){const c=Object.getOwnPropertyDescriptor(e,a);Object.defineProperty(d,a,c.get?c:{enumerable:!0,get:()=>e[a]})}}return d.default=e,Object.freeze(d)}const j=q(O),N=()=>({position:new j.Vector3(0,0,0),velocity:new j.Vector3(0,0,0),rotation:new j.Euler(0,0,0),isMoving:!1,isGrounded:!1,speed:0,height:2});function M(e={}){const{updateInterval:d=0,entityId:a}=e,c=p.useRef(null);c.current||(c.current=N());const[,g]=p.useState(0),r=p.useRef(0),S=p.useRef(0),m=p.useRef({x:0,y:0,z:0}),v=p.useRef(void 0),x=p.useRef(null),{activeState:b,gameStates:R}=w.useStateSystem(),f=h=>{if(a)return a;if(v.current)return v.current;const t=h.getActiveEntities();return v.current=t[0],v.current};return p.useEffect(()=>{v.current=void 0,x.current=k.BridgeFactory.getOrCreate("motion");const h=x.current;if(!h)return;const t=h.subscribe((o,y)=>{const u=f(h);if(!u||y!==u)return;const l=performance.now();if(S.current=l,d>0&&l-r.current<d)return;r.current=l;const n=c.current;n.position.copy(o.position),n.velocity.copy(o.velocity),n.rotation.copy(o.rotation),n.isMoving=o.isMoving,n.isGrounded=o.isGrounded,n.speed=o.speed,n.height=2,g(s=>s+1)});return()=>{t()}},[a,d]),D.useFrame(()=>{const h=performance.now();if(d>0&&h-r.current<d)return;const t=c.current,o=x.current,y=u=>{const l=m.current,n=u.x-l.x,s=u.y-l.y,E=u.z-l.z;return n*n+s*s+E*E>1e-6?(l.x=u.x,l.y=u.y,l.z=u.z,!0):!1};if(o){const u=f(o);if(!(h-S.current<16)&&u){const n=o.snapshot(u);if(n){t.position.copy(n.position),t.velocity.copy(n.velocity),t.rotation.copy(n.rotation),t.isMoving=n.isMoving,t.isGrounded=n.isGrounded,t.speed=n.speed,t.height=2,r.current=h,y(t.position)&&g(s=>s+1);return}}}b?.position&&(t.position.copy(b.position),b.velocity?t.velocity.copy(b.velocity):t.velocity.set(0,0,0),b.euler?t.rotation.copy(b.euler):t.rotation.set(0,0,0),t.isMoving=R?.isMoving||!1,t.isGrounded=R?.isOnTheGround||!1,t.speed=b.velocity?b.velocity.length():0,t.height=2,r.current=h,y(t.position)&&g(u=>u+1))}),c.current}const F={KeyW:"forward",KeyA:"leftward",KeyS:"backward",KeyD:"rightward",ShiftLeft:"shift",Space:"space",KeyZ:"keyZ",KeyR:"keyR",KeyF:"keyF",KeyE:"keyE",Escape:"escape"},C=(e=!0,d=!0,a)=>{const c=k.useGaesupStore(f=>f.automation?.queue.isRunning),g=k.useGaesupStore(f=>f.stopAutomation),r=k.useGaesupStore(f=>f.interaction?.isActive??!0),S=w.useBuildingStore(f=>f.isInEditMode()),m=w.useInputBackend(),v=p.useRef(new Set),x=p.useMemo(()=>({...F}),[]),b=p.useCallback((f,h)=>{if(!r)return!1;try{return m.updateKeyboard({[f]:h}),h?v.current.add(f):v.current.delete(f),!0}catch(t){return console.error("Error updating keyboard state:",t),!1}},[m,r]),R=p.useCallback(()=>{v.current.clear(),m.updateKeyboard({forward:!1,backward:!1,leftward:!1,rightward:!1,shift:!1,space:!1,keyZ:!1,keyR:!1,keyF:!1,keyE:!1,escape:!1})},[m]);return p.useEffect(()=>{(!r||S)&&R()},[R,r,S]),p.useEffect(()=>{const f=(y,u)=>{const l=x[y.code];if(!l)return;if(!r||S){u&&y.preventDefault(),R();return}const n=v.current.has(y.code);u&&!n?(v.current.add(y.code),y.code==="Space"&&y.preventDefault(),d&&c&&(l==="forward"||l==="backward"||l==="leftward"||l==="rightward")&&(g(),m.updateMouse({isActive:!1,shouldRun:!1})),m.updateKeyboard({[l]:!0})):!u&&n&&(v.current.delete(y.code),m.updateKeyboard({[l]:!1}))},h=y=>f(y,!0),t=y=>f(y,!1),o=()=>document.hidden&&R();return window.addEventListener("keydown",h),window.addEventListener("keyup",t),document.addEventListener("visibilitychange",o),()=>{window.removeEventListener("keydown",h),window.removeEventListener("keyup",t),document.removeEventListener("visibilitychange",o)}},[x,d,g,c,R,r,S,m]),{pressedKeys:Array.from(v.current),pushKey:b,isKeyPressed:f=>v.current.has(f),clearAllKeys:R}},K=p.memo(({points:e,color:d})=>e.length<2?null:i.jsx(T.Line,{points:e,color:d,lineWidth:2,dashed:!1}));K.displayName="PathLine";const B=p.memo(()=>i.jsxs("group",{children:[i.jsxs("mesh",{children:[i.jsx("sphereGeometry",{args:[.2,16,16]}),i.jsx("meshStandardMaterial",{color:"#00ff88",emissive:"#00ff88",emissiveIntensity:.5,transparent:!0,opacity:.9})]}),i.jsxs("mesh",{rotation:[Math.PI/2,0,0],children:[i.jsx("ringGeometry",{args:[.3,.5,8]}),i.jsx("meshStandardMaterial",{color:"#00ff88",transparent:!0,opacity:.6,side:j.DoubleSide})]})]}));B.displayName="TargetMarker";function I(){const e=k.useGaesupStore(s=>s.automation),{position:d}=M(),{activeState:a}=w.useStateSystem(),{mouse:c}=w.useInteractionSystem(),[g,r]=p.useState(()=>[...w.getClickNavigationRoute()]);p.useEffect(()=>w.subscribeClickNavigationRoute(()=>{r([...w.getClickNavigationRoute()])}),[]);const S=c?.target||new j.Vector3,m=a?.position??d,v=c?.isActive||!1,x=e?.queue||{actions:[],currentIndex:0},b=x.actions||[],R=x.currentIndex||0,h=m.distanceTo(S)<1,t=v&&!h,o=b.map(s=>s.type==="move"&&s.target?new j.Vector3(s.target.x,s.target.y,s.target.z):null).filter(s=>s!==null),y=m.clone(),u=g.length>0?g:[S],l=u[0]??o[0]??S;y.y=l.y;const n=t?[y,...u,...o]:o.length>0?[y,...o]:[];return i.jsxs("group",{children:[t&&i.jsx("group",{position:S,children:i.jsx(B,{})}),n.length>1&&i.jsx(K,{points:n,color:R>=0?"#00ff88":"#ffaa00"}),b.map((s,E)=>{if(s.type==="move"&&s.target){const P=E===R,G=E<R;return i.jsx("group",{position:[s.target.x,s.target.y,s.target.z],children:i.jsxs("mesh",{children:[i.jsx("sphereGeometry",{args:[.1,8,8]}),i.jsx("meshStandardMaterial",{color:G?"#888":P?"#ff4444":"#ffaa00",transparent:!0,opacity:G?.3:.8})]})},`action-${E}`)}return null})]})}function A({clickerOptions:e}){const{onClick:d}=w.useClicker(e),a=c=>{c.stopPropagation();const{cameraOption:g,setCameraOption:r}=k.useGaesupStore.getState();if(g?.focus){r({focus:!1});return}d(c)};return i.jsxs("mesh",{position:[0,0,0],rotation:[-Math.PI/2,0,0],onPointerDown:a,visible:!0,userData:{intangible:!0},children:[i.jsx("planeGeometry",{args:[1e3,1e3]}),i.jsx("meshBasicMaterial",{transparent:!0,opacity:0})]})}function L({props:e,children:d}){const a=k.useGaesupStore(o=>o.mode),{gameStates:c}=w.useStateSystem(),g=k.useGaesupStore(o=>o.rideable),r=k.useGaesupStore(o=>o.urls),S=w.useBuildingStore(o=>o.isInEditMode()),m=U.useGenericRefs();if(C(),S||!a||!c||!g||!r||a.type==="character"&&!r.characterUrl||a.type==="vehicle"&&!r.vehicleUrl||a.type==="airplane"&&!r.airplaneUrl)return null;const{canRide:v,isRiding:x,currentRideable:b}=c,R=b?.id,f=p.useMemo(()=>(R?g[R]?.offset:void 0)??z.vec3(),[R,g]),t=(()=>{const o=e.rigidBodyRef??m.rigidBodyRef,y=e.outerGroupRef??m.outerGroupRef,u=e.innerGroupRef??m.innerGroupRef,l=e.colliderRef??m.colliderRef,n={isActive:!0,componentType:a.type,enableRiding:v,isRiderOn:x,offset:f,ref:o,outerGroupRef:y,innerGroupRef:u,colliderRef:l,parts:(e.parts||[]).filter(P=>!!P.url).map(P=>({...P,url:P.url})),...e.onAnimate?{onAnimate:e.onAnimate}:{},...e.onFrame?{onFrame:e.onFrame}:{},...e.onReady?{onReady:e.onReady}:{},...e.onDestroy?{onDestroy:e.onDestroy}:{},...e.onDestory?{onDestory:e.onDestory}:{},...typeof e.baseColor=="string"&&e.baseColor.trim().length>0?{baseColor:e.baseColor}:{},...Array.isArray(e.excludeBaseNodes)&&e.excludeBaseNodes.length>0?{excludeBaseNodes:e.excludeBaseNodes}:{},...e.rigidBodyProps?{rigidBodyProps:e.rigidBodyProps}:{},...e.controllerOptions?{controllerOptions:e.controllerOptions}:{},...e.groundRay?{groundRay:e.groundRay}:{},...e.colliderSize?{colliderSize:e.colliderSize}:{},...e.position?{position:e.position}:{},...e.rotation?{rotation:e.rotation}:{},...e.scale?{scale:e.scale}:{}},s=x&&a.type!=="character"?r.ridingUrl:void 0,E=typeof s=="string"&&s.length>0?{ridingUrl:s}:{};switch(a.type){case"character":return{...n,url:r.characterUrl||""};case"vehicle":return{...n,...E,url:r.vehicleUrl||"",wheelUrl:r.wheelUrl};case"airplane":return{...n,...E,url:r.airplaneUrl||""};default:return{...n,url:r.characterUrl||""}}})();return a.type==="character"&&c.isRiding?null:i.jsx(w.PhysicsEntity,{...t,children:d})}function V(e){const{clickToMove:d,children:a,clickerOptions:c,...g}=e,r={...c??{},...c?.agentRadius===void 0&&g.colliderSize?.radius!==void 0?{agentRadius:g.colliderSize.radius}:{}};return i.jsx(L,{props:g,children:i.jsxs(i.Fragment,{children:[d&&i.jsxs(i.Fragment,{children:[i.jsx(A,{clickerOptions:r}),i.jsx(I,{})]}),a]})})}exports.Clicker=I;exports.ControllerWrapper=V;exports.GroundClicker=A;exports.useKeyboard=C;exports.usePlayerPosition=M;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { jsxs as R, jsx as k } from "react/jsx-runtime";
|
|
2
2
|
import { useRef as P, useMemo as T, useEffect as B } from "react";
|
|
3
3
|
import * as S from "three";
|
|
4
|
-
import { U as A } from "./index-
|
|
4
|
+
import { U as A } from "./index-C5agFfBe.js";
|
|
5
5
|
import "reflect-metadata";
|
|
6
6
|
import { A as E, R as I, M as z } from "./gaesupStore-DTu0tYBp.js";
|
|
7
7
|
const O = "gaesup-save", _ = 1, w = "slots";
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { useRef as h, useEffect as b, useCallback as A, useMemo as ut, useLayoutEffect as J } from "react";
|
|
2
2
|
import { useFrame as ct, useThree as mt } from "@react-three/fiber";
|
|
3
3
|
import * as a from "three";
|
|
4
|
-
import { V as dt, G as ht, W as gt } from "./index-
|
|
4
|
+
import { V as dt, G as ht, W as gt } from "./index-C5agFfBe.js";
|
|
5
5
|
import { H, P as G, C as pt, M as vt, u as U } from "./gaesupStore-DTu0tYBp.js";
|
|
6
6
|
import "reflect-metadata";
|
|
7
7
|
import yt from "mitt";
|
|
@@ -0,0 +1,320 @@
|
|
|
1
|
+
import { jsx as v, jsxs as P, Fragment as A } from "react/jsx-runtime";
|
|
2
|
+
import { useRef as S, useState as U, useEffect as K, useMemo as T, useCallback as C, memo as z } from "react";
|
|
3
|
+
import * as G from "three";
|
|
4
|
+
import { Line as N } from "@react-three/drei";
|
|
5
|
+
import { V as B, G as D, W as F, X as V, Y as x, Z as q, U as W, _ as Z } from "./index-C5agFfBe.js";
|
|
6
|
+
import { useFrame as j } from "@react-three/fiber";
|
|
7
|
+
import { B as Y, u as k } from "./gaesupStore-DTu0tYBp.js";
|
|
8
|
+
import { vec3 as _ } from "@react-three/rapier";
|
|
9
|
+
import { u as H } from "./index-DRLvJF_k.js";
|
|
10
|
+
const X = () => ({
|
|
11
|
+
position: new G.Vector3(0, 0, 0),
|
|
12
|
+
velocity: new G.Vector3(0, 0, 0),
|
|
13
|
+
rotation: new G.Euler(0, 0, 0),
|
|
14
|
+
isMoving: !1,
|
|
15
|
+
isGrounded: !1,
|
|
16
|
+
speed: 0,
|
|
17
|
+
height: 2
|
|
18
|
+
// Default character height
|
|
19
|
+
});
|
|
20
|
+
function $(e = {}) {
|
|
21
|
+
const { updateInterval: g = 0, entityId: d } = e, u = S(null);
|
|
22
|
+
u.current || (u.current = X());
|
|
23
|
+
const [, f] = U(0), r = S(0), w = S(0), h = S({ x: 0, y: 0, z: 0 }), m = S(void 0), b = S(null), { activeState: R, gameStates: p } = B(), c = (y) => {
|
|
24
|
+
if (d) return d;
|
|
25
|
+
if (m.current) return m.current;
|
|
26
|
+
const t = y.getActiveEntities();
|
|
27
|
+
return m.current = t[0], m.current;
|
|
28
|
+
};
|
|
29
|
+
return K(() => {
|
|
30
|
+
m.current = void 0, b.current = Y.getOrCreate("motion");
|
|
31
|
+
const y = b.current;
|
|
32
|
+
if (!y) return;
|
|
33
|
+
const t = y.subscribe((o, l) => {
|
|
34
|
+
const s = c(y);
|
|
35
|
+
if (!s || l !== s) return;
|
|
36
|
+
const a = performance.now();
|
|
37
|
+
if (w.current = a, g > 0 && a - r.current < g) return;
|
|
38
|
+
r.current = a;
|
|
39
|
+
const n = u.current;
|
|
40
|
+
n.position.copy(o.position), n.velocity.copy(o.velocity), n.rotation.copy(o.rotation), n.isMoving = o.isMoving, n.isGrounded = o.isGrounded, n.speed = o.speed, n.height = 2, f((i) => i + 1);
|
|
41
|
+
});
|
|
42
|
+
return () => {
|
|
43
|
+
t();
|
|
44
|
+
};
|
|
45
|
+
}, [d, g]), j(() => {
|
|
46
|
+
const y = performance.now();
|
|
47
|
+
if (g > 0 && y - r.current < g) return;
|
|
48
|
+
const t = u.current, o = b.current, l = (s) => {
|
|
49
|
+
const a = h.current, n = s.x - a.x, i = s.y - a.y, E = s.z - a.z;
|
|
50
|
+
return n * n + i * i + E * E > 1e-6 ? (a.x = s.x, a.y = s.y, a.z = s.z, !0) : !1;
|
|
51
|
+
};
|
|
52
|
+
if (o) {
|
|
53
|
+
const s = c(o);
|
|
54
|
+
if (!(y - w.current < 16) && s) {
|
|
55
|
+
const n = o.snapshot(s);
|
|
56
|
+
if (n) {
|
|
57
|
+
t.position.copy(n.position), t.velocity.copy(n.velocity), t.rotation.copy(n.rotation), t.isMoving = n.isMoving, t.isGrounded = n.isGrounded, t.speed = n.speed, t.height = 2, r.current = y, l(t.position) && f((i) => i + 1);
|
|
58
|
+
return;
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
R?.position && (t.position.copy(R.position), R.velocity ? t.velocity.copy(R.velocity) : t.velocity.set(0, 0, 0), R.euler ? t.rotation.copy(R.euler) : t.rotation.set(0, 0, 0), t.isMoving = p?.isMoving || !1, t.isGrounded = p?.isOnTheGround || !1, t.speed = R.velocity ? R.velocity.length() : 0, t.height = 2, r.current = y, l(t.position) && f((s) => s + 1));
|
|
63
|
+
}), u.current;
|
|
64
|
+
}
|
|
65
|
+
const J = {
|
|
66
|
+
KeyW: "forward",
|
|
67
|
+
KeyA: "leftward",
|
|
68
|
+
KeyS: "backward",
|
|
69
|
+
KeyD: "rightward",
|
|
70
|
+
ShiftLeft: "shift",
|
|
71
|
+
Space: "space",
|
|
72
|
+
KeyZ: "keyZ",
|
|
73
|
+
KeyR: "keyR",
|
|
74
|
+
KeyF: "keyF",
|
|
75
|
+
KeyE: "keyE",
|
|
76
|
+
Escape: "escape"
|
|
77
|
+
}, Q = (e = !0, g = !0, d) => {
|
|
78
|
+
const u = k((c) => c.automation?.queue.isRunning), f = k((c) => c.stopAutomation), r = k((c) => c.interaction?.isActive ?? !0), w = D((c) => c.isInEditMode()), h = F(), m = S(/* @__PURE__ */ new Set()), b = T(() => ({ ...J }), []), R = C(
|
|
79
|
+
(c, y) => {
|
|
80
|
+
if (!r) return !1;
|
|
81
|
+
try {
|
|
82
|
+
return h.updateKeyboard({ [c]: y }), y ? m.current.add(c) : m.current.delete(c), !0;
|
|
83
|
+
} catch (t) {
|
|
84
|
+
return console.error("Error updating keyboard state:", t), !1;
|
|
85
|
+
}
|
|
86
|
+
},
|
|
87
|
+
[h, r]
|
|
88
|
+
), p = C(() => {
|
|
89
|
+
m.current.clear(), h.updateKeyboard({
|
|
90
|
+
forward: !1,
|
|
91
|
+
backward: !1,
|
|
92
|
+
leftward: !1,
|
|
93
|
+
rightward: !1,
|
|
94
|
+
shift: !1,
|
|
95
|
+
space: !1,
|
|
96
|
+
keyZ: !1,
|
|
97
|
+
keyR: !1,
|
|
98
|
+
keyF: !1,
|
|
99
|
+
keyE: !1,
|
|
100
|
+
escape: !1
|
|
101
|
+
});
|
|
102
|
+
}, [h]);
|
|
103
|
+
return K(() => {
|
|
104
|
+
(!r || w) && p();
|
|
105
|
+
}, [p, r, w]), K(() => {
|
|
106
|
+
const c = (l, s) => {
|
|
107
|
+
const a = b[l.code];
|
|
108
|
+
if (!a) return;
|
|
109
|
+
if (!r || w) {
|
|
110
|
+
s && l.preventDefault(), p();
|
|
111
|
+
return;
|
|
112
|
+
}
|
|
113
|
+
const n = m.current.has(l.code);
|
|
114
|
+
s && !n ? (m.current.add(l.code), l.code === "Space" && l.preventDefault(), g && u && (a === "forward" || a === "backward" || a === "leftward" || a === "rightward") && (f(), h.updateMouse({ isActive: !1, shouldRun: !1 })), h.updateKeyboard({ [a]: !0 })) : !s && n && (m.current.delete(l.code), h.updateKeyboard({ [a]: !1 }));
|
|
115
|
+
}, y = (l) => c(l, !0), t = (l) => c(l, !1), o = () => document.hidden && p();
|
|
116
|
+
return window.addEventListener("keydown", y), window.addEventListener("keyup", t), document.addEventListener("visibilitychange", o), () => {
|
|
117
|
+
window.removeEventListener("keydown", y), window.removeEventListener("keyup", t), document.removeEventListener("visibilitychange", o);
|
|
118
|
+
};
|
|
119
|
+
}, [
|
|
120
|
+
b,
|
|
121
|
+
g,
|
|
122
|
+
f,
|
|
123
|
+
u,
|
|
124
|
+
p,
|
|
125
|
+
r,
|
|
126
|
+
w,
|
|
127
|
+
h
|
|
128
|
+
]), {
|
|
129
|
+
pressedKeys: Array.from(m.current),
|
|
130
|
+
pushKey: R,
|
|
131
|
+
isKeyPressed: (c) => m.current.has(c),
|
|
132
|
+
clearAllKeys: p
|
|
133
|
+
};
|
|
134
|
+
}, O = z(({ points: e, color: g }) => e.length < 2 ? null : /* @__PURE__ */ v(
|
|
135
|
+
N,
|
|
136
|
+
{
|
|
137
|
+
points: e,
|
|
138
|
+
color: g,
|
|
139
|
+
lineWidth: 2,
|
|
140
|
+
dashed: !1
|
|
141
|
+
}
|
|
142
|
+
));
|
|
143
|
+
O.displayName = "PathLine";
|
|
144
|
+
const L = z(() => /* @__PURE__ */ P("group", { children: [
|
|
145
|
+
/* @__PURE__ */ P("mesh", { children: [
|
|
146
|
+
/* @__PURE__ */ v("sphereGeometry", { args: [0.2, 16, 16] }),
|
|
147
|
+
/* @__PURE__ */ v(
|
|
148
|
+
"meshStandardMaterial",
|
|
149
|
+
{
|
|
150
|
+
color: "#00ff88",
|
|
151
|
+
emissive: "#00ff88",
|
|
152
|
+
emissiveIntensity: 0.5,
|
|
153
|
+
transparent: !0,
|
|
154
|
+
opacity: 0.9
|
|
155
|
+
}
|
|
156
|
+
)
|
|
157
|
+
] }),
|
|
158
|
+
/* @__PURE__ */ P("mesh", { rotation: [Math.PI / 2, 0, 0], children: [
|
|
159
|
+
/* @__PURE__ */ v("ringGeometry", { args: [0.3, 0.5, 8] }),
|
|
160
|
+
/* @__PURE__ */ v(
|
|
161
|
+
"meshStandardMaterial",
|
|
162
|
+
{
|
|
163
|
+
color: "#00ff88",
|
|
164
|
+
transparent: !0,
|
|
165
|
+
opacity: 0.6,
|
|
166
|
+
side: G.DoubleSide
|
|
167
|
+
}
|
|
168
|
+
)
|
|
169
|
+
] })
|
|
170
|
+
] }));
|
|
171
|
+
L.displayName = "TargetMarker";
|
|
172
|
+
function ee() {
|
|
173
|
+
const e = k((i) => i.automation), { position: g } = $(), { activeState: d } = B(), { mouse: u } = V(), [f, r] = U(() => [...x()]);
|
|
174
|
+
K(() => q(() => {
|
|
175
|
+
r([...x()]);
|
|
176
|
+
}), []);
|
|
177
|
+
const w = u?.target || new G.Vector3(), h = d?.position ?? g, m = u?.isActive || !1, b = e?.queue || { actions: [], currentIndex: 0 }, R = b.actions || [], p = b.currentIndex || 0, y = h.distanceTo(w) < 1, t = m && !y, o = R.map((i) => i.type === "move" && i.target ? new G.Vector3(i.target.x, i.target.y, i.target.z) : null).filter((i) => i !== null), l = h.clone(), s = f.length > 0 ? f : [w], a = s[0] ?? o[0] ?? w;
|
|
178
|
+
l.y = a.y;
|
|
179
|
+
const n = t ? [l, ...s, ...o] : o.length > 0 ? [l, ...o] : [];
|
|
180
|
+
return /* @__PURE__ */ P("group", { children: [
|
|
181
|
+
t && /* @__PURE__ */ v("group", { position: w, children: /* @__PURE__ */ v(L, {}) }),
|
|
182
|
+
n.length > 1 && /* @__PURE__ */ v(
|
|
183
|
+
O,
|
|
184
|
+
{
|
|
185
|
+
points: n,
|
|
186
|
+
color: p >= 0 ? "#00ff88" : "#ffaa00"
|
|
187
|
+
}
|
|
188
|
+
),
|
|
189
|
+
R.map((i, E) => {
|
|
190
|
+
if (i.type === "move" && i.target) {
|
|
191
|
+
const M = E === p, I = E < p;
|
|
192
|
+
return /* @__PURE__ */ v(
|
|
193
|
+
"group",
|
|
194
|
+
{
|
|
195
|
+
position: [i.target.x, i.target.y, i.target.z],
|
|
196
|
+
children: /* @__PURE__ */ P("mesh", { children: [
|
|
197
|
+
/* @__PURE__ */ v("sphereGeometry", { args: [0.1, 8, 8] }),
|
|
198
|
+
/* @__PURE__ */ v(
|
|
199
|
+
"meshStandardMaterial",
|
|
200
|
+
{
|
|
201
|
+
color: I ? "#888" : M ? "#ff4444" : "#ffaa00",
|
|
202
|
+
transparent: !0,
|
|
203
|
+
opacity: I ? 0.3 : 0.8
|
|
204
|
+
}
|
|
205
|
+
)
|
|
206
|
+
] })
|
|
207
|
+
},
|
|
208
|
+
`action-${E}`
|
|
209
|
+
);
|
|
210
|
+
}
|
|
211
|
+
return null;
|
|
212
|
+
})
|
|
213
|
+
] });
|
|
214
|
+
}
|
|
215
|
+
function te({ clickerOptions: e }) {
|
|
216
|
+
const { onClick: g } = W(e), d = (u) => {
|
|
217
|
+
u.stopPropagation();
|
|
218
|
+
const { cameraOption: f, setCameraOption: r } = k.getState();
|
|
219
|
+
if (f?.focus) {
|
|
220
|
+
r({ focus: !1 });
|
|
221
|
+
return;
|
|
222
|
+
}
|
|
223
|
+
g(u);
|
|
224
|
+
};
|
|
225
|
+
return /* @__PURE__ */ P(
|
|
226
|
+
"mesh",
|
|
227
|
+
{
|
|
228
|
+
position: [0, 0, 0],
|
|
229
|
+
rotation: [-Math.PI / 2, 0, 0],
|
|
230
|
+
onPointerDown: d,
|
|
231
|
+
visible: !0,
|
|
232
|
+
userData: { intangible: !0 },
|
|
233
|
+
children: [
|
|
234
|
+
/* @__PURE__ */ v("planeGeometry", { args: [1e3, 1e3] }),
|
|
235
|
+
/* @__PURE__ */ v("meshBasicMaterial", { transparent: !0, opacity: 0 })
|
|
236
|
+
]
|
|
237
|
+
}
|
|
238
|
+
);
|
|
239
|
+
}
|
|
240
|
+
function re({ props: e, children: g }) {
|
|
241
|
+
const d = k((o) => o.mode), { gameStates: u } = B(), f = k((o) => o.rideable), r = k((o) => o.urls), w = D((o) => o.isInEditMode()), h = H();
|
|
242
|
+
if (Q(), w || !d || !u || !f || !r || d.type === "character" && !r.characterUrl || d.type === "vehicle" && !r.vehicleUrl || d.type === "airplane" && !r.airplaneUrl) return null;
|
|
243
|
+
const { canRide: m, isRiding: b, currentRideable: R } = u, p = R?.id, c = T(
|
|
244
|
+
() => (p ? f[p]?.offset : void 0) ?? _(),
|
|
245
|
+
[p, f]
|
|
246
|
+
), t = (() => {
|
|
247
|
+
const o = e.rigidBodyRef ?? h.rigidBodyRef, l = e.outerGroupRef ?? h.outerGroupRef, s = e.innerGroupRef ?? h.innerGroupRef, a = e.colliderRef ?? h.colliderRef, n = {
|
|
248
|
+
isActive: !0,
|
|
249
|
+
componentType: d.type,
|
|
250
|
+
enableRiding: m,
|
|
251
|
+
isRiderOn: b,
|
|
252
|
+
offset: c,
|
|
253
|
+
ref: o,
|
|
254
|
+
outerGroupRef: l,
|
|
255
|
+
innerGroupRef: s,
|
|
256
|
+
colliderRef: a,
|
|
257
|
+
parts: (e.parts || []).filter((M) => !!M.url).map((M) => ({ ...M, url: M.url })),
|
|
258
|
+
...e.onAnimate ? { onAnimate: e.onAnimate } : {},
|
|
259
|
+
...e.onFrame ? { onFrame: e.onFrame } : {},
|
|
260
|
+
...e.onReady ? { onReady: e.onReady } : {},
|
|
261
|
+
...e.onDestroy ? { onDestroy: e.onDestroy } : {},
|
|
262
|
+
...e.onDestory ? { onDestory: e.onDestory } : {},
|
|
263
|
+
...typeof e.baseColor == "string" && e.baseColor.trim().length > 0 ? { baseColor: e.baseColor } : {},
|
|
264
|
+
...Array.isArray(e.excludeBaseNodes) && e.excludeBaseNodes.length > 0 ? { excludeBaseNodes: e.excludeBaseNodes } : {},
|
|
265
|
+
...e.rigidBodyProps ? { rigidBodyProps: e.rigidBodyProps } : {},
|
|
266
|
+
...e.controllerOptions ? { controllerOptions: e.controllerOptions } : {},
|
|
267
|
+
...e.groundRay ? { groundRay: e.groundRay } : {},
|
|
268
|
+
...e.colliderSize ? { colliderSize: e.colliderSize } : {},
|
|
269
|
+
...e.position ? { position: e.position } : {},
|
|
270
|
+
...e.rotation ? { rotation: e.rotation } : {},
|
|
271
|
+
...e.scale ? { scale: e.scale } : {}
|
|
272
|
+
}, i = b && d.type !== "character" ? r.ridingUrl : void 0, E = typeof i == "string" && i.length > 0 ? { ridingUrl: i } : {};
|
|
273
|
+
switch (d.type) {
|
|
274
|
+
case "character":
|
|
275
|
+
return {
|
|
276
|
+
...n,
|
|
277
|
+
url: r.characterUrl || ""
|
|
278
|
+
};
|
|
279
|
+
case "vehicle":
|
|
280
|
+
return {
|
|
281
|
+
...n,
|
|
282
|
+
...E,
|
|
283
|
+
url: r.vehicleUrl || "",
|
|
284
|
+
wheelUrl: r.wheelUrl
|
|
285
|
+
};
|
|
286
|
+
case "airplane":
|
|
287
|
+
return {
|
|
288
|
+
...n,
|
|
289
|
+
...E,
|
|
290
|
+
url: r.airplaneUrl || ""
|
|
291
|
+
};
|
|
292
|
+
default:
|
|
293
|
+
return {
|
|
294
|
+
...n,
|
|
295
|
+
url: r.characterUrl || ""
|
|
296
|
+
};
|
|
297
|
+
}
|
|
298
|
+
})();
|
|
299
|
+
return d.type === "character" && u.isRiding ? null : /* @__PURE__ */ v(Z, { ...t, children: g });
|
|
300
|
+
}
|
|
301
|
+
function de(e) {
|
|
302
|
+
const { clickToMove: g, children: d, clickerOptions: u, ...f } = e, r = {
|
|
303
|
+
...u ?? {},
|
|
304
|
+
...u?.agentRadius === void 0 && f.colliderSize?.radius !== void 0 ? { agentRadius: f.colliderSize.radius } : {}
|
|
305
|
+
};
|
|
306
|
+
return /* @__PURE__ */ v(re, { props: f, children: /* @__PURE__ */ P(A, { children: [
|
|
307
|
+
g && /* @__PURE__ */ P(A, { children: [
|
|
308
|
+
/* @__PURE__ */ v(te, { clickerOptions: r }),
|
|
309
|
+
/* @__PURE__ */ v(ee, {})
|
|
310
|
+
] }),
|
|
311
|
+
d
|
|
312
|
+
] }) });
|
|
313
|
+
}
|
|
314
|
+
export {
|
|
315
|
+
de as C,
|
|
316
|
+
te as G,
|
|
317
|
+
ee as a,
|
|
318
|
+
$ as b,
|
|
319
|
+
Q as u
|
|
320
|
+
};
|