gaesup-world 1.0.15 → 1.0.16
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 +1 -1
- package/dist/{index-DBLoviZI.js → index-D-y80TPB.js} +33 -33
- package/dist/{index-9qQ_uAUZ.cjs → index-vksPEPuX.cjs} +1 -1
- package/dist/index.cjs +1 -1
- package/dist/index.js +2 -2
- package/dist/network.cjs +1 -1
- package/dist/network.js +1 -1
- package/package.json +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-9qQ_uAUZ.cjs"),V=require("./index-B0ymJw1j.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-vksPEPuX.cjs"),V=require("./index-B0ymJw1j.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;
|
|
@@ -6,7 +6,7 @@ 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-
|
|
9
|
+
import { u as ne, C as ae, a as se, G as oe } from "./index-D-y80TPB.js";
|
|
10
10
|
import { C as le } from "./index-CsKqKct1.js";
|
|
11
11
|
const w = (t) => t?.type === "character";
|
|
12
12
|
function ce({ blueprint: t }) {
|
|
@@ -30,14 +30,14 @@ function X(e = {}) {
|
|
|
30
30
|
y.current = void 0, v.current = j.getOrCreate("motion");
|
|
31
31
|
const u = v.current;
|
|
32
32
|
if (!u) return;
|
|
33
|
-
const n = u.subscribe((
|
|
33
|
+
const n = u.subscribe((i, t) => {
|
|
34
34
|
const a = s(u);
|
|
35
35
|
if (!a || t !== a) return;
|
|
36
36
|
const c = performance.now();
|
|
37
37
|
if (w.current = c, d > 0 && c - r.current < d) return;
|
|
38
38
|
r.current = c;
|
|
39
|
-
const
|
|
40
|
-
|
|
39
|
+
const o = l.current;
|
|
40
|
+
o.position.copy(i.position), o.velocity.copy(i.velocity), o.rotation.copy(i.rotation), o.isMoving = i.isMoving, o.isGrounded = i.isGrounded, o.speed = i.speed, o.height = 2, g((b) => b + 1);
|
|
41
41
|
});
|
|
42
42
|
return () => {
|
|
43
43
|
n();
|
|
@@ -45,16 +45,16 @@ function X(e = {}) {
|
|
|
45
45
|
}, [f, d]), Z(() => {
|
|
46
46
|
const u = performance.now();
|
|
47
47
|
if (d > 0 && u - r.current < d) return;
|
|
48
|
-
const n = l.current,
|
|
49
|
-
const c = m.current,
|
|
50
|
-
return
|
|
48
|
+
const n = l.current, i = v.current, t = (a) => {
|
|
49
|
+
const c = m.current, o = a.x - c.x, b = a.y - c.y, M = a.z - c.z;
|
|
50
|
+
return o * o + b * b + M * M > 1e-6 ? (c.x = a.x, c.y = a.y, c.z = a.z, !0) : !1;
|
|
51
51
|
};
|
|
52
|
-
if (
|
|
53
|
-
const a = s(
|
|
52
|
+
if (i) {
|
|
53
|
+
const a = s(i);
|
|
54
54
|
if (!(u - w.current < 16) && a) {
|
|
55
|
-
const
|
|
56
|
-
if (
|
|
57
|
-
n.position.copy(
|
|
55
|
+
const o = i.snapshot(a);
|
|
56
|
+
if (o) {
|
|
57
|
+
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, r.current = u, t(n.position) && g((b) => b + 1);
|
|
58
58
|
return;
|
|
59
59
|
}
|
|
60
60
|
}
|
|
@@ -110,11 +110,11 @@ const $ = {
|
|
|
110
110
|
a && t.preventDefault(), p();
|
|
111
111
|
return;
|
|
112
112
|
}
|
|
113
|
-
const
|
|
114
|
-
a && !
|
|
115
|
-
}, u = (t) => s(t, !0), n = (t) => s(t, !1),
|
|
116
|
-
return window.addEventListener("keydown", u), window.addEventListener("keyup", n), document.addEventListener("visibilitychange",
|
|
117
|
-
window.removeEventListener("keydown", u), window.removeEventListener("keyup", n), document.removeEventListener("visibilitychange",
|
|
113
|
+
const o = y.current.has(t.code);
|
|
114
|
+
a && !o ? (y.current.add(t.code), t.code === "Space" && t.preventDefault(), d && l && (c === "forward" || c === "backward" || c === "leftward" || c === "rightward") && (g(), m.updateMouse({ isActive: !1, shouldRun: !1 })), m.updateKeyboard({ [c]: !0 })) : !a && o && (y.current.delete(t.code), m.updateKeyboard({ [c]: !1 }));
|
|
115
|
+
}, u = (t) => s(t, !0), n = (t) => s(t, !1), i = () => document.hidden && p();
|
|
116
|
+
return window.addEventListener("keydown", u), window.addEventListener("keyup", n), document.addEventListener("visibilitychange", i), () => {
|
|
117
|
+
window.removeEventListener("keydown", u), window.removeEventListener("keyup", n), document.removeEventListener("visibilitychange", i);
|
|
118
118
|
};
|
|
119
119
|
}, [
|
|
120
120
|
v,
|
|
@@ -174,19 +174,19 @@ function Q() {
|
|
|
174
174
|
G(() => V(() => {
|
|
175
175
|
g([...I()]);
|
|
176
176
|
}), []);
|
|
177
|
-
const r = f?.target || new S.Vector3(), w = f?.isActive || !1, m = e?.queue || { actions: [], currentIndex: 0 }, y = m.actions || [], v = m.currentIndex || 0, p = d.distanceTo(r) < 1, s = w && !p, u = y.map((t) => t.type === "move" && t.target ? new S.Vector3(t.target.x, t.target.y, t.target.z) : null).filter((t) => t !== null), n = l.length > 0 ? l : [r],
|
|
177
|
+
const r = f?.target || new S.Vector3(), w = f?.isActive || !1, m = e?.queue || { actions: [], currentIndex: 0 }, y = m.actions || [], v = m.currentIndex || 0, p = d.distanceTo(r) < 1, s = w && !p, u = y.map((t) => t.type === "move" && t.target ? new S.Vector3(t.target.x, t.target.y, t.target.z) : null).filter((t) => t !== null), n = l.length > 0 ? l : [r], i = s ? [d, ...n, ...u] : u.length > 0 ? [d, ...u] : [];
|
|
178
178
|
return /* @__PURE__ */ E("group", { children: [
|
|
179
179
|
s && /* @__PURE__ */ h("group", { position: r, children: /* @__PURE__ */ h(O, {}) }),
|
|
180
|
-
|
|
180
|
+
i.length > 1 && /* @__PURE__ */ h(
|
|
181
181
|
D,
|
|
182
182
|
{
|
|
183
|
-
points:
|
|
183
|
+
points: i,
|
|
184
184
|
color: v >= 0 ? "#00ff88" : "#ffaa00"
|
|
185
185
|
}
|
|
186
186
|
),
|
|
187
187
|
y.map((t, a) => {
|
|
188
188
|
if (t.type === "move" && t.target) {
|
|
189
|
-
const c = a === v,
|
|
189
|
+
const c = a === v, o = a < v;
|
|
190
190
|
return /* @__PURE__ */ h(
|
|
191
191
|
"group",
|
|
192
192
|
{
|
|
@@ -196,9 +196,9 @@ function Q() {
|
|
|
196
196
|
/* @__PURE__ */ h(
|
|
197
197
|
"meshStandardMaterial",
|
|
198
198
|
{
|
|
199
|
-
color:
|
|
199
|
+
color: o ? "#888" : c ? "#ff4444" : "#ffaa00",
|
|
200
200
|
transparent: !0,
|
|
201
|
-
opacity:
|
|
201
|
+
opacity: o ? 0.3 : 0.8
|
|
202
202
|
}
|
|
203
203
|
)
|
|
204
204
|
] })
|
|
@@ -236,19 +236,19 @@ function ee({ clickerOptions: e }) {
|
|
|
236
236
|
);
|
|
237
237
|
}
|
|
238
238
|
function te({ props: e, children: d }) {
|
|
239
|
-
const f = k((
|
|
239
|
+
const f = k((i) => i.mode), { gameStates: l } = T(), g = k((i) => i.rideable), r = k((i) => i.urls), w = z((i) => i.isInEditMode()), m = _();
|
|
240
240
|
if (J(), w || !f || !l || !g || !r || f.type === "character" && !r.characterUrl || f.type === "vehicle" && !r.vehicleUrl || f.type === "airplane" && !r.airplaneUrl) return null;
|
|
241
241
|
const { canRide: y, isRiding: v, currentRideable: R } = l, p = R?.id, s = x(
|
|
242
242
|
() => (p ? g[p]?.offset : void 0) ?? Y(),
|
|
243
243
|
[p, g]
|
|
244
244
|
), n = (() => {
|
|
245
|
-
const
|
|
245
|
+
const i = e.rigidBodyRef ?? m.rigidBodyRef, t = e.outerGroupRef ?? m.outerGroupRef, a = e.innerGroupRef ?? m.innerGroupRef, c = e.colliderRef ?? m.colliderRef, o = {
|
|
246
246
|
isActive: !0,
|
|
247
247
|
componentType: f.type,
|
|
248
248
|
enableRiding: y,
|
|
249
249
|
isRiderOn: v,
|
|
250
250
|
offset: s,
|
|
251
|
-
ref:
|
|
251
|
+
ref: i,
|
|
252
252
|
outerGroupRef: t,
|
|
253
253
|
innerGroupRef: a,
|
|
254
254
|
colliderRef: c,
|
|
@@ -272,25 +272,25 @@ function te({ props: e, children: d }) {
|
|
|
272
272
|
switch (f.type) {
|
|
273
273
|
case "character":
|
|
274
274
|
return {
|
|
275
|
-
...
|
|
275
|
+
...o,
|
|
276
276
|
url: r.characterUrl || ""
|
|
277
277
|
};
|
|
278
278
|
case "vehicle":
|
|
279
279
|
return {
|
|
280
|
-
...
|
|
280
|
+
...o,
|
|
281
281
|
...M,
|
|
282
282
|
url: r.vehicleUrl || "",
|
|
283
283
|
wheelUrl: r.wheelUrl
|
|
284
284
|
};
|
|
285
285
|
case "airplane":
|
|
286
286
|
return {
|
|
287
|
-
...
|
|
287
|
+
...o,
|
|
288
288
|
...M,
|
|
289
289
|
url: r.airplaneUrl || ""
|
|
290
290
|
};
|
|
291
291
|
default:
|
|
292
292
|
return {
|
|
293
|
-
...
|
|
293
|
+
...o,
|
|
294
294
|
url: r.characterUrl || ""
|
|
295
295
|
};
|
|
296
296
|
}
|
|
@@ -302,13 +302,13 @@ function ue(e) {
|
|
|
302
302
|
...l ?? {},
|
|
303
303
|
...l?.agentRadius === void 0 && g.colliderSize?.radius !== void 0 ? { agentRadius: g.colliderSize.radius } : {}
|
|
304
304
|
};
|
|
305
|
-
return /* @__PURE__ */
|
|
305
|
+
return /* @__PURE__ */ E(K, { children: [
|
|
306
|
+
/* @__PURE__ */ h(te, { props: g, children: f }),
|
|
306
307
|
d && /* @__PURE__ */ E(K, { children: [
|
|
307
308
|
/* @__PURE__ */ h(ee, { clickerOptions: r }),
|
|
308
309
|
/* @__PURE__ */ h(Q, {})
|
|
309
|
-
] })
|
|
310
|
-
|
|
311
|
-
] }) });
|
|
310
|
+
] })
|
|
311
|
+
] });
|
|
312
312
|
}
|
|
313
313
|
export {
|
|
314
314
|
ue as C,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";const o=require("react/jsx-runtime"),h=require("react"),I=require("three"),O=require("@react-three/drei"),S=require("./index-KD0DiwVP.cjs"),T=require("@react-three/fiber"),E=require("./gaesupStore-2zKBYTYo.cjs"),D=require("@react-three/rapier"),z=require("./index-B0ymJw1j.cjs");function U(e){const c=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(e){for(const a in e)if(a!=="default"){const u=Object.getOwnPropertyDescriptor(e,a);Object.defineProperty(c,a,u.get?u:{enumerable:!0,get:()=>e[a]})}}return c.default=e,Object.freeze(c)}const k=U(I),q=()=>({position:new k.Vector3(0,0,0),velocity:new k.Vector3(0,0,0),rotation:new k.Euler(0,0,0),isMoving:!1,isGrounded:!1,speed:0,height:2});function G(e={}){const{updateInterval:c=0,entityId:a}=e,u=h.useRef(null);u.current||(u.current=q());const[,m]=h.useState(0),r=h.useRef(0),x=h.useRef(0),p=h.useRef({x:0,y:0,z:0}),g=h.useRef(void 0),R=h.useRef(null),{activeState:b,gameStates:v}=S.useStateSystem(),l=y=>{if(a)return a;if(g.current)return g.current;const n=y.getActiveEntities();return g.current=n[0],g.current};return h.useEffect(()=>{g.current=void 0,R.current=E.BridgeFactory.getOrCreate("motion");const y=R.current;if(!y)return;const n=y.subscribe((s,t)=>{const d=l(y);if(!d||t!==d)return;const f=performance.now();if(x.current=f,c>0&&f-r.current<c)return;r.current=f;const i=u.current;i.position.copy(s.position),i.velocity.copy(s.velocity),i.rotation.copy(s.rotation),i.isMoving=s.isMoving,i.isGrounded=s.isGrounded,i.speed=s.speed,i.height=2,m(w=>w+1)});return()=>{n()}},[a,c]),T.useFrame(()=>{const y=performance.now();if(c>0&&y-r.current<c)return;const n=u.current,s=R.current,t=d=>{const f=p.current,i=d.x-f.x,w=d.y-f.y,P=d.z-f.z;return i*i+w*w+P*P>1e-6?(f.x=d.x,f.y=d.y,f.z=d.z,!0):!1};if(s){const d=l(s);if(!(y-x.current<16)&&d){const i=s.snapshot(d);if(i){n.position.copy(i.position),n.velocity.copy(i.velocity),n.rotation.copy(i.rotation),n.isMoving=i.isMoving,n.isGrounded=i.isGrounded,n.speed=i.speed,n.height=2,r.current=y,t(n.position)&&m(w=>w+1);return}}}b?.position&&(n.position.copy(b.position),b.velocity?n.velocity.copy(b.velocity):n.velocity.set(0,0,0),b.euler?n.rotation.copy(b.euler):n.rotation.set(0,0,0),n.isMoving=v?.isMoving||!1,n.isGrounded=v?.isOnTheGround||!1,n.speed=b.velocity?b.velocity.length():0,n.height=2,r.current=y,t(n.position)&&m(d=>d+1))}),u.current}const N={KeyW:"forward",KeyA:"leftward",KeyS:"backward",KeyD:"rightward",ShiftLeft:"shift",Space:"space",KeyZ:"keyZ",KeyR:"keyR",KeyF:"keyF",KeyE:"keyE",Escape:"escape"},M=(e=!0,c=!0,a)=>{const u=E.useGaesupStore(l=>l.automation?.queue.isRunning),m=E.useGaesupStore(l=>l.stopAutomation),r=E.useGaesupStore(l=>l.interaction?.isActive??!0),x=S.useBuildingStore(l=>l.isInEditMode()),p=S.useInputBackend(),g=h.useRef(new Set),R=h.useMemo(()=>({...N}),[]),b=h.useCallback((l,y)=>{if(!r)return!1;try{return p.updateKeyboard({[l]:y}),y?g.current.add(l):g.current.delete(l),!0}catch(n){return console.error("Error updating keyboard state:",n),!1}},[p,r]),v=h.useCallback(()=>{g.current.clear(),p.updateKeyboard({forward:!1,backward:!1,leftward:!1,rightward:!1,shift:!1,space:!1,keyZ:!1,keyR:!1,keyF:!1,keyE:!1,escape:!1})},[p]);return h.useEffect(()=>{(!r||x)&&v()},[v,r,x]),h.useEffect(()=>{const l=(t,d)=>{const f=R[t.code];if(!f)return;if(!r||x){d&&t.preventDefault(),v();return}const i=g.current.has(t.code);d&&!i?(g.current.add(t.code),t.code==="Space"&&t.preventDefault(),c&&u&&(f==="forward"||f==="backward"||f==="leftward"||f==="rightward")&&(m(),p.updateMouse({isActive:!1,shouldRun:!1})),p.updateKeyboard({[f]:!0})):!d&&i&&(g.current.delete(t.code),p.updateKeyboard({[f]:!1}))},y=t=>l(t,!0),n=t=>l(t,!1),s=()=>document.hidden&&v();return window.addEventListener("keydown",y),window.addEventListener("keyup",n),document.addEventListener("visibilitychange",s),()=>{window.removeEventListener("keydown",y),window.removeEventListener("keyup",n),document.removeEventListener("visibilitychange",s)}},[R,c,m,u,v,r,x,p]),{pressedKeys:Array.from(g.current),pushKey:b,isKeyPressed:l=>g.current.has(l),clearAllKeys:v}},C=h.memo(({points:e,color:c})=>e.length<2?null:o.jsx(O.Line,{points:e,color:c,lineWidth:2,dashed:!1}));C.displayName="PathLine";const K=h.memo(()=>o.jsxs("group",{children:[o.jsxs("mesh",{children:[o.jsx("sphereGeometry",{args:[.2,16,16]}),o.jsx("meshStandardMaterial",{color:"#00ff88",emissive:"#00ff88",emissiveIntensity:.5,transparent:!0,opacity:.9})]}),o.jsxs("mesh",{rotation:[Math.PI/2,0,0],children:[o.jsx("ringGeometry",{args:[.3,.5,8]}),o.jsx("meshStandardMaterial",{color:"#00ff88",transparent:!0,opacity:.6,side:k.DoubleSide})]})]}));K.displayName="TargetMarker";function A(){const e=E.useGaesupStore(t=>t.automation),{position:c}=G(),{mouse:a}=S.useInteractionSystem(),[u,m]=h.useState(()=>[...S.getClickNavigationRoute()]);h.useEffect(()=>S.subscribeClickNavigationRoute(()=>{m([...S.getClickNavigationRoute()])}),[]);const r=a?.target||new k.Vector3,x=a?.isActive||!1,p=e?.queue||{actions:[],currentIndex:0},g=p.actions||[],R=p.currentIndex||0,v=c.distanceTo(r)<1,l=x&&!v,y=g.map(t=>t.type==="move"&&t.target?new k.Vector3(t.target.x,t.target.y,t.target.z):null).filter(t=>t!==null),n=u.length>0?u:[r],s=l?[c,...n,...y]:y.length>0?[c,...y]:[];return o.jsxs("group",{children:[l&&o.jsx("group",{position:r,children:o.jsx(K,{})}),s.length>1&&o.jsx(C,{points:s,color:R>=0?"#00ff88":"#ffaa00"}),g.map((t,d)=>{if(t.type==="move"&&t.target){const f=d===R,i=d<R;return o.jsx("group",{position:[t.target.x,t.target.y,t.target.z],children:o.jsxs("mesh",{children:[o.jsx("sphereGeometry",{args:[.1,8,8]}),o.jsx("meshStandardMaterial",{color:i?"#888":f?"#ff4444":"#ffaa00",transparent:!0,opacity:i?.3:.8})]})},`action-${d}`)}return null})]})}function B({clickerOptions:e}){const{onClick:c}=S.useClicker(e),a=u=>{u.stopPropagation();const{cameraOption:m,setCameraOption:r}=E.useGaesupStore.getState();if(m?.focus){r({focus:!1});return}c(u)};return o.jsxs("mesh",{position:[0,0,0],rotation:[-Math.PI/2,0,0],onPointerDown:a,visible:!0,userData:{intangible:!0},children:[o.jsx("planeGeometry",{args:[1e3,1e3]}),o.jsx("meshBasicMaterial",{transparent:!0,opacity:0})]})}function F({props:e,children:c}){const a=E.useGaesupStore(s=>s.mode),{gameStates:u}=S.useStateSystem(),m=E.useGaesupStore(s=>s.rideable),r=E.useGaesupStore(s=>s.urls),x=S.useBuildingStore(s=>s.isInEditMode()),p=z.useGenericRefs();if(M(),x||!a||!u||!m||!r||a.type==="character"&&!r.characterUrl||a.type==="vehicle"&&!r.vehicleUrl||a.type==="airplane"&&!r.airplaneUrl)return null;const{canRide:g,isRiding:R,currentRideable:b}=u,v=b?.id,l=h.useMemo(()=>(v?m[v]?.offset:void 0)??D.vec3(),[v,m]),n=(()=>{const s=e.rigidBodyRef??p.rigidBodyRef,t=e.outerGroupRef??p.outerGroupRef,d=e.innerGroupRef??p.innerGroupRef,f=e.colliderRef??p.colliderRef,i={isActive:!0,componentType:a.type,enableRiding:g,isRiderOn:R,offset:l,ref:s,outerGroupRef:t,innerGroupRef:d,colliderRef:f,parts:(e.parts||[]).filter(j=>!!j.url).map(j=>({...j,url:j.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}:{},...e.currentAnimation?{currentAnimation:e.currentAnimation}:{}},w=R&&a.type!=="character"?r.ridingUrl:void 0,P=typeof w=="string"&&w.length>0?{ridingUrl:w}:{};switch(a.type){case"character":return{...i,url:r.characterUrl||""};case"vehicle":return{...i,...P,url:r.vehicleUrl||"",wheelUrl:r.wheelUrl};case"airplane":return{...i,...P,url:r.airplaneUrl||""};default:return{...i,url:r.characterUrl||""}}})();return a.type==="character"&&u.isRiding?null:o.jsx(S.PhysicsEntity,{...n,children:c})}function L(e){const{clickToMove:c,children:a,clickerOptions:u,...m}=e,r={...u??{},...u?.agentRadius===void 0&&m.colliderSize?.radius!==void 0?{agentRadius:m.colliderSize.radius}:{}};return o.jsx(F,{props:m,children:
|
|
1
|
+
"use strict";const o=require("react/jsx-runtime"),h=require("react"),I=require("three"),O=require("@react-three/drei"),S=require("./index-KD0DiwVP.cjs"),T=require("@react-three/fiber"),E=require("./gaesupStore-2zKBYTYo.cjs"),D=require("@react-three/rapier"),z=require("./index-B0ymJw1j.cjs");function U(e){const c=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(e){for(const a in e)if(a!=="default"){const u=Object.getOwnPropertyDescriptor(e,a);Object.defineProperty(c,a,u.get?u:{enumerable:!0,get:()=>e[a]})}}return c.default=e,Object.freeze(c)}const k=U(I),q=()=>({position:new k.Vector3(0,0,0),velocity:new k.Vector3(0,0,0),rotation:new k.Euler(0,0,0),isMoving:!1,isGrounded:!1,speed:0,height:2});function G(e={}){const{updateInterval:c=0,entityId:a}=e,u=h.useRef(null);u.current||(u.current=q());const[,m]=h.useState(0),r=h.useRef(0),x=h.useRef(0),p=h.useRef({x:0,y:0,z:0}),g=h.useRef(void 0),R=h.useRef(null),{activeState:b,gameStates:v}=S.useStateSystem(),l=y=>{if(a)return a;if(g.current)return g.current;const n=y.getActiveEntities();return g.current=n[0],g.current};return h.useEffect(()=>{g.current=void 0,R.current=E.BridgeFactory.getOrCreate("motion");const y=R.current;if(!y)return;const n=y.subscribe((s,t)=>{const d=l(y);if(!d||t!==d)return;const f=performance.now();if(x.current=f,c>0&&f-r.current<c)return;r.current=f;const i=u.current;i.position.copy(s.position),i.velocity.copy(s.velocity),i.rotation.copy(s.rotation),i.isMoving=s.isMoving,i.isGrounded=s.isGrounded,i.speed=s.speed,i.height=2,m(w=>w+1)});return()=>{n()}},[a,c]),T.useFrame(()=>{const y=performance.now();if(c>0&&y-r.current<c)return;const n=u.current,s=R.current,t=d=>{const f=p.current,i=d.x-f.x,w=d.y-f.y,P=d.z-f.z;return i*i+w*w+P*P>1e-6?(f.x=d.x,f.y=d.y,f.z=d.z,!0):!1};if(s){const d=l(s);if(!(y-x.current<16)&&d){const i=s.snapshot(d);if(i){n.position.copy(i.position),n.velocity.copy(i.velocity),n.rotation.copy(i.rotation),n.isMoving=i.isMoving,n.isGrounded=i.isGrounded,n.speed=i.speed,n.height=2,r.current=y,t(n.position)&&m(w=>w+1);return}}}b?.position&&(n.position.copy(b.position),b.velocity?n.velocity.copy(b.velocity):n.velocity.set(0,0,0),b.euler?n.rotation.copy(b.euler):n.rotation.set(0,0,0),n.isMoving=v?.isMoving||!1,n.isGrounded=v?.isOnTheGround||!1,n.speed=b.velocity?b.velocity.length():0,n.height=2,r.current=y,t(n.position)&&m(d=>d+1))}),u.current}const N={KeyW:"forward",KeyA:"leftward",KeyS:"backward",KeyD:"rightward",ShiftLeft:"shift",Space:"space",KeyZ:"keyZ",KeyR:"keyR",KeyF:"keyF",KeyE:"keyE",Escape:"escape"},M=(e=!0,c=!0,a)=>{const u=E.useGaesupStore(l=>l.automation?.queue.isRunning),m=E.useGaesupStore(l=>l.stopAutomation),r=E.useGaesupStore(l=>l.interaction?.isActive??!0),x=S.useBuildingStore(l=>l.isInEditMode()),p=S.useInputBackend(),g=h.useRef(new Set),R=h.useMemo(()=>({...N}),[]),b=h.useCallback((l,y)=>{if(!r)return!1;try{return p.updateKeyboard({[l]:y}),y?g.current.add(l):g.current.delete(l),!0}catch(n){return console.error("Error updating keyboard state:",n),!1}},[p,r]),v=h.useCallback(()=>{g.current.clear(),p.updateKeyboard({forward:!1,backward:!1,leftward:!1,rightward:!1,shift:!1,space:!1,keyZ:!1,keyR:!1,keyF:!1,keyE:!1,escape:!1})},[p]);return h.useEffect(()=>{(!r||x)&&v()},[v,r,x]),h.useEffect(()=>{const l=(t,d)=>{const f=R[t.code];if(!f)return;if(!r||x){d&&t.preventDefault(),v();return}const i=g.current.has(t.code);d&&!i?(g.current.add(t.code),t.code==="Space"&&t.preventDefault(),c&&u&&(f==="forward"||f==="backward"||f==="leftward"||f==="rightward")&&(m(),p.updateMouse({isActive:!1,shouldRun:!1})),p.updateKeyboard({[f]:!0})):!d&&i&&(g.current.delete(t.code),p.updateKeyboard({[f]:!1}))},y=t=>l(t,!0),n=t=>l(t,!1),s=()=>document.hidden&&v();return window.addEventListener("keydown",y),window.addEventListener("keyup",n),document.addEventListener("visibilitychange",s),()=>{window.removeEventListener("keydown",y),window.removeEventListener("keyup",n),document.removeEventListener("visibilitychange",s)}},[R,c,m,u,v,r,x,p]),{pressedKeys:Array.from(g.current),pushKey:b,isKeyPressed:l=>g.current.has(l),clearAllKeys:v}},C=h.memo(({points:e,color:c})=>e.length<2?null:o.jsx(O.Line,{points:e,color:c,lineWidth:2,dashed:!1}));C.displayName="PathLine";const K=h.memo(()=>o.jsxs("group",{children:[o.jsxs("mesh",{children:[o.jsx("sphereGeometry",{args:[.2,16,16]}),o.jsx("meshStandardMaterial",{color:"#00ff88",emissive:"#00ff88",emissiveIntensity:.5,transparent:!0,opacity:.9})]}),o.jsxs("mesh",{rotation:[Math.PI/2,0,0],children:[o.jsx("ringGeometry",{args:[.3,.5,8]}),o.jsx("meshStandardMaterial",{color:"#00ff88",transparent:!0,opacity:.6,side:k.DoubleSide})]})]}));K.displayName="TargetMarker";function A(){const e=E.useGaesupStore(t=>t.automation),{position:c}=G(),{mouse:a}=S.useInteractionSystem(),[u,m]=h.useState(()=>[...S.getClickNavigationRoute()]);h.useEffect(()=>S.subscribeClickNavigationRoute(()=>{m([...S.getClickNavigationRoute()])}),[]);const r=a?.target||new k.Vector3,x=a?.isActive||!1,p=e?.queue||{actions:[],currentIndex:0},g=p.actions||[],R=p.currentIndex||0,v=c.distanceTo(r)<1,l=x&&!v,y=g.map(t=>t.type==="move"&&t.target?new k.Vector3(t.target.x,t.target.y,t.target.z):null).filter(t=>t!==null),n=u.length>0?u:[r],s=l?[c,...n,...y]:y.length>0?[c,...y]:[];return o.jsxs("group",{children:[l&&o.jsx("group",{position:r,children:o.jsx(K,{})}),s.length>1&&o.jsx(C,{points:s,color:R>=0?"#00ff88":"#ffaa00"}),g.map((t,d)=>{if(t.type==="move"&&t.target){const f=d===R,i=d<R;return o.jsx("group",{position:[t.target.x,t.target.y,t.target.z],children:o.jsxs("mesh",{children:[o.jsx("sphereGeometry",{args:[.1,8,8]}),o.jsx("meshStandardMaterial",{color:i?"#888":f?"#ff4444":"#ffaa00",transparent:!0,opacity:i?.3:.8})]})},`action-${d}`)}return null})]})}function B({clickerOptions:e}){const{onClick:c}=S.useClicker(e),a=u=>{u.stopPropagation();const{cameraOption:m,setCameraOption:r}=E.useGaesupStore.getState();if(m?.focus){r({focus:!1});return}c(u)};return o.jsxs("mesh",{position:[0,0,0],rotation:[-Math.PI/2,0,0],onPointerDown:a,visible:!0,userData:{intangible:!0},children:[o.jsx("planeGeometry",{args:[1e3,1e3]}),o.jsx("meshBasicMaterial",{transparent:!0,opacity:0})]})}function F({props:e,children:c}){const a=E.useGaesupStore(s=>s.mode),{gameStates:u}=S.useStateSystem(),m=E.useGaesupStore(s=>s.rideable),r=E.useGaesupStore(s=>s.urls),x=S.useBuildingStore(s=>s.isInEditMode()),p=z.useGenericRefs();if(M(),x||!a||!u||!m||!r||a.type==="character"&&!r.characterUrl||a.type==="vehicle"&&!r.vehicleUrl||a.type==="airplane"&&!r.airplaneUrl)return null;const{canRide:g,isRiding:R,currentRideable:b}=u,v=b?.id,l=h.useMemo(()=>(v?m[v]?.offset:void 0)??D.vec3(),[v,m]),n=(()=>{const s=e.rigidBodyRef??p.rigidBodyRef,t=e.outerGroupRef??p.outerGroupRef,d=e.innerGroupRef??p.innerGroupRef,f=e.colliderRef??p.colliderRef,i={isActive:!0,componentType:a.type,enableRiding:g,isRiderOn:R,offset:l,ref:s,outerGroupRef:t,innerGroupRef:d,colliderRef:f,parts:(e.parts||[]).filter(j=>!!j.url).map(j=>({...j,url:j.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}:{},...e.currentAnimation?{currentAnimation:e.currentAnimation}:{}},w=R&&a.type!=="character"?r.ridingUrl:void 0,P=typeof w=="string"&&w.length>0?{ridingUrl:w}:{};switch(a.type){case"character":return{...i,url:r.characterUrl||""};case"vehicle":return{...i,...P,url:r.vehicleUrl||"",wheelUrl:r.wheelUrl};case"airplane":return{...i,...P,url:r.airplaneUrl||""};default:return{...i,url:r.characterUrl||""}}})();return a.type==="character"&&u.isRiding?null:o.jsx(S.PhysicsEntity,{...n,children:c})}function L(e){const{clickToMove:c,children:a,clickerOptions:u,...m}=e,r={...u??{},...u?.agentRadius===void 0&&m.colliderSize?.radius!==void 0?{agentRadius:m.colliderSize.radius}:{}};return o.jsxs(o.Fragment,{children:[o.jsx(F,{props:m,children:a}),c&&o.jsxs(o.Fragment,{children:[o.jsx(B,{clickerOptions:r}),o.jsx(A,{})]})]})}exports.Clicker=A;exports.ControllerWrapper=L;exports.GroundClicker=B;exports.useKeyboard=M;exports.usePlayerPosition=G;
|