gaesup-world 1.0.21 → 1.0.23
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 +2 -2
- package/dist/core/interactions/components/Clicker/index.d.ts +1 -4
- package/dist/editor.cjs +1 -1
- package/dist/editor.js +2 -2
- package/dist/{index-Drmv86ws.js → index-3WAK67Ha.js} +1 -1
- package/dist/{index-DShLht0Q.js → index-B0oz8u47.js} +1 -1
- package/dist/index-B3DY2LIR.js +320 -0
- package/dist/{index-syAx2qzT.cjs → index-C7uc7Whg.cjs} +1 -1
- package/dist/index-Ctehfr0N.cjs +1 -0
- package/dist/{index-BUQXtHf3.js → index-DGifA0e6.js} +5 -4
- package/dist/{index-D0Rz5_-J.js → index-DRLvJF_k.js} +5 -4
- package/dist/index-De3ev_jU.cjs +1 -0
- package/dist/{index-DHZJyO9k.cjs → index-RPpT5kHy.cjs} +1 -1
- package/dist/index-TNaPJQpb.cjs +1 -0
- package/dist/index.cjs +1 -1
- package/dist/index.js +11 -11
- package/dist/network.cjs +1 -1
- package/dist/network.js +2 -2
- package/dist/{plugin-CS2nMv9n.cjs → plugin-B4lSjyeZ.cjs} +1 -1
- package/dist/{plugin-BEJHB06f.js → plugin-BFzSydfr.js} +35 -34
- package/dist/runtime.cjs +1 -1
- package/dist/runtime.js +5 -5
- package/package.json +1 -1
- package/dist/index-CHoKlv0U.cjs +0 -1
- package/dist/index-D1hpjfAw.cjs +0 -1
- package/dist/index-HxpKt5rO.js +0 -320
- package/dist/index-co-QAQz9.cjs +0 -1
|
@@ -12,13 +12,14 @@ import { A as gu, c as aa, b as jp } from "./index-C-ViQFGa.js";
|
|
|
12
12
|
import { create as yi } from "zustand";
|
|
13
13
|
import { useShallow as Ns } from "zustand/react/shallow";
|
|
14
14
|
import { r as Vp, o as Zp, G as Yp, S as bu, h as Xp, k as Kp, f as qp, j as Qp, e as Jp, i as eh, m as th, n as nh, c as ih, v as oh } from "./loader-C3ZwumCe.js";
|
|
15
|
-
import { g as Ui, M as rh, W as ah } from "./index-
|
|
15
|
+
import { g as Ui, M as rh, W as ah } from "./index-DGifA0e6.js";
|
|
16
16
|
import { useGLTF as Is, useAnimations as sh, useTexture as Ts, shaderMaterial as Es, OrbitControls as lh } from "@react-three/drei";
|
|
17
17
|
import * as B from "three";
|
|
18
18
|
import { w as Ao } from "./sfe-CRsG1dTW.js";
|
|
19
19
|
import { enableMapSet as ch } from "immer";
|
|
20
20
|
import { immer as uh } from "zustand/middleware/immer";
|
|
21
21
|
import { SkeletonUtils as yu, Water as dh } from "three-stdlib";
|
|
22
|
+
import "reflect-metadata";
|
|
22
23
|
import { u as As } from "./weatherStore-CzG5N441.js";
|
|
23
24
|
import { createNoise2D as ks } from "simplex-noise";
|
|
24
25
|
function Xe({ label: e, min: t, max: n, step: i, value: o, suffix: r, onChange: a }) {
|
|
@@ -9807,7 +9808,7 @@ function _1(e, t) {
|
|
|
9807
9808
|
e.position[2] + Math.sin(i) * o
|
|
9808
9809
|
];
|
|
9809
9810
|
}
|
|
9810
|
-
function
|
|
9811
|
+
function bM(e, t, n) {
|
|
9811
9812
|
const i = ds(e, t);
|
|
9812
9813
|
return kr.set(i, n), () => {
|
|
9813
9814
|
kr.delete(i);
|
|
@@ -12062,13 +12063,13 @@ const Si = {
|
|
|
12062
12063
|
face: "표정",
|
|
12063
12064
|
weapon: "무기",
|
|
12064
12065
|
accessory: "액세서리"
|
|
12065
|
-
},
|
|
12066
|
+
}, yM = {
|
|
12066
12067
|
short: "단발",
|
|
12067
12068
|
long: "긴머리",
|
|
12068
12069
|
cap: "모자머리",
|
|
12069
12070
|
bun: "쪽머리",
|
|
12070
12071
|
spiky: "뻗친머리"
|
|
12071
|
-
},
|
|
12072
|
+
}, vM = {
|
|
12072
12073
|
default: "기본",
|
|
12073
12074
|
smile: "미소",
|
|
12074
12075
|
wink: "윙크",
|
|
@@ -13264,7 +13265,7 @@ const Ax = ({
|
|
|
13264
13265
|
...e.smoothing ? { smoothing: { ...e.smoothing } } : {},
|
|
13265
13266
|
...e.bounds ? { bounds: { ...e.bounds } } : {},
|
|
13266
13267
|
...e.modeSettings ? { modeSettings: { ...e.modeSettings } } : {}
|
|
13267
|
-
}),
|
|
13268
|
+
}), wM = ({
|
|
13268
13269
|
children: e,
|
|
13269
13270
|
className: t = "",
|
|
13270
13271
|
style: n = {},
|
|
@@ -13310,7 +13311,7 @@ const Ax = ({
|
|
|
13310
13311
|
}, Px = () => /* @__PURE__ */ s("svg", { width: "14", height: "14", viewBox: "0 0 24 24", fill: "none", stroke: "currentColor", strokeWidth: "2", strokeLinecap: "round", strokeLinejoin: "round", children: /* @__PURE__ */ s("line", { x1: "5", y1: "12", x2: "19", y2: "12" }) }), Bx = () => /* @__PURE__ */ x("svg", { width: "14", height: "14", viewBox: "0 0 24 24", fill: "none", stroke: "currentColor", strokeWidth: "2", strokeLinecap: "round", strokeLinejoin: "round", children: [
|
|
13311
13312
|
/* @__PURE__ */ s("line", { x1: "18", y1: "6", x2: "6", y2: "18" }),
|
|
13312
13313
|
/* @__PURE__ */ s("line", { x1: "6", y1: "6", x2: "18", y2: "18" })
|
|
13313
|
-
] }),
|
|
13314
|
+
] }), xM = ({
|
|
13314
13315
|
children: e,
|
|
13315
13316
|
title: t,
|
|
13316
13317
|
initialWidth: n = 280,
|
|
@@ -13408,7 +13409,7 @@ const Ax = ({
|
|
|
13408
13409
|
setActiveNodeGraph: (t) => e({ activeNodeGraph: t }),
|
|
13409
13410
|
clipboard: null,
|
|
13410
13411
|
setClipboard: (t) => e({ clipboard: t })
|
|
13411
|
-
}),
|
|
13412
|
+
}), _M = ff, Rx = yi(ff), SM = () => {
|
|
13412
13413
|
const e = Rx();
|
|
13413
13414
|
return {
|
|
13414
13415
|
...e,
|
|
@@ -13417,7 +13418,7 @@ const Ax = ({
|
|
|
13417
13418
|
clearSelection: () => e.setSelectedObjectIds([])
|
|
13418
13419
|
};
|
|
13419
13420
|
};
|
|
13420
|
-
function
|
|
13421
|
+
function MM(e = {}) {
|
|
13421
13422
|
const t = {
|
|
13422
13423
|
panels: e.panels ?? [],
|
|
13423
13424
|
actions: (e.commands ?? []).map((n) => ({
|
|
@@ -13428,7 +13429,7 @@ function SM(e = {}) {
|
|
|
13428
13429
|
};
|
|
13429
13430
|
return e.defaultActivePanels && (t.defaultActivePanels = e.defaultActivePanels), typeof e.defaultPanelOpen == "boolean" && (t.defaultPanelOpen = e.defaultPanelOpen), typeof e.defaultModalOpen == "boolean" && (t.defaultModalOpen = e.defaultModalOpen), e.hiddenBuiltInPanels && (t.hiddenBuiltInPanels = e.hiddenBuiltInPanels), e.panelOrder && (t.panelOrder = e.panelOrder), e.panelDefaults && (t.panelDefaults = e.panelDefaults), e.validate && (t.validate = e.validate), t;
|
|
13430
13431
|
}
|
|
13431
|
-
function
|
|
13432
|
+
function CM() {
|
|
13432
13433
|
const e = [], t = [];
|
|
13433
13434
|
return {
|
|
13434
13435
|
execute: async (n) => {
|
|
@@ -14652,7 +14653,7 @@ const E_ = ge.memo(function({ billboards: t }) {
|
|
|
14652
14653
|
const r = o[0];
|
|
14653
14654
|
return r ? r.imageUrl ? /* @__PURE__ */ s(I_, { entries: o }, i) : /* @__PURE__ */ s(T_, { entries: o }, i) : null;
|
|
14654
14655
|
}) });
|
|
14655
|
-
}),
|
|
14656
|
+
}), NM = ge.memo(N_);
|
|
14656
14657
|
var A_ = `varying vec2 vUv;\r
|
|
14657
14658
|
uniform float time;\r
|
|
14658
14659
|
uniform float intensity;\r
|
|
@@ -14945,7 +14946,7 @@ const R_ = ({ intensity: e = 1.5, width: t = 1, height: n = 1.5, color: i = "#ff
|
|
|
14945
14946
|
})()),
|
|
14946
14947
|
/* @__PURE__ */ s("points", { geometry: f, material: a.ember })
|
|
14947
14948
|
] });
|
|
14948
|
-
},
|
|
14949
|
+
}, IM = ge.memo(R_), D_ = (
|
|
14949
14950
|
/* glsl */
|
|
14950
14951
|
`
|
|
14951
14952
|
attribute float aSeed;
|
|
@@ -15923,7 +15924,7 @@ function c2({ trees: e, toon: t }) {
|
|
|
15923
15924
|
/* @__PURE__ */ s("points", { geometry: _, children: /* @__PURE__ */ s("pointsMaterial", { size: 0.085 * h, sizeAttenuation: !0, vertexColors: !0, transparent: !0, opacity: 0.7, depthWrite: !1 }) })
|
|
15924
15925
|
] });
|
|
15925
15926
|
}
|
|
15926
|
-
function
|
|
15927
|
+
function TM({ size: e = 4, toon: t }) {
|
|
15927
15928
|
const n = ee(null), i = ee(null), o = ee(null), r = ee(null), a = ee(null), l = ee(null), c = X(() => B.MathUtils.clamp(e / 4, 0.95, 1.85), [e]), u = 3.8 * c, d = 1.65 * c + Math.min(e * 0.08, 0.55), f = 2.15 * c + Math.min(e * 0.04, 0.35), p = t ?? We(), h = Of(), w = Hf(p), g = X(() => Gf(c, u, "round"), [c, u]), _ = X(() => Wf(c), [c]), b = X(() => Uf(c, u, d, f, "round"), [c, u, d, f]), S = g.length, m = _.length + g.length, y = b.length, v = Math.max(180, Math.min(420, Math.round(210 + c * 95))), C = Math.max(44, Math.min(120, Math.round(54 + c * 26))), T = Math.max(52, Math.min(132, Math.round(62 + c * 30))), P = X(() => {
|
|
15928
15929
|
const E = new Float32Array(v * 3), G = new Float32Array(v * 3);
|
|
15929
15930
|
return jf(E, G, 0, v, u, d, f, 0, 0, 0), Fr(E, G, !0);
|
|
@@ -16438,7 +16439,7 @@ function x2({ entries: e, toon: t }) {
|
|
|
16438
16439
|
) })
|
|
16439
16440
|
] });
|
|
16440
16441
|
}
|
|
16441
|
-
function
|
|
16442
|
+
function EM({ size: e = 4, toon: t, color: n, accentColor: i }) {
|
|
16442
16443
|
const o = t ?? We(), r = Kf(o), [a, l] = X(() => {
|
|
16443
16444
|
const c = Math.max(20, Math.round(e * 6)), u = new B.PlaneGeometry(e, e, c, c);
|
|
16444
16445
|
u.rotateX(-Math.PI / 2);
|
|
@@ -16563,7 +16564,7 @@ function S2({ entries: e, toon: t }) {
|
|
|
16563
16564
|
) })
|
|
16564
16565
|
] });
|
|
16565
16566
|
}
|
|
16566
|
-
function
|
|
16567
|
+
function AM({ size: e = 4, toon: t, color: n, accentColor: i }) {
|
|
16567
16568
|
const o = t ?? We(), r = qf(o), [a, l] = X(() => {
|
|
16568
16569
|
const c = Math.max(22, Math.round(e * 7)), u = new B.PlaneGeometry(e, e, c, c);
|
|
16569
16570
|
u.rotateX(-Math.PI / 2);
|
|
@@ -19190,7 +19191,7 @@ function $S() {
|
|
|
19190
19191
|
}), null;
|
|
19191
19192
|
}
|
|
19192
19193
|
const OS = 9, HS = 150;
|
|
19193
|
-
function
|
|
19194
|
+
function kM() {
|
|
19194
19195
|
const { gl: e } = Li(), {
|
|
19195
19196
|
updateMousePosition: t,
|
|
19196
19197
|
placeWall: n,
|
|
@@ -19291,7 +19292,7 @@ function AM() {
|
|
|
19291
19292
|
] });
|
|
19292
19293
|
}
|
|
19293
19294
|
const su = rf;
|
|
19294
|
-
function
|
|
19295
|
+
function PM({
|
|
19295
19296
|
onClose: e,
|
|
19296
19297
|
canEdit: t = !0,
|
|
19297
19298
|
npcPanel: n = !1,
|
|
@@ -20792,7 +20793,7 @@ function ZS(e = {}) {
|
|
|
20792
20793
|
}
|
|
20793
20794
|
};
|
|
20794
20795
|
}
|
|
20795
|
-
const
|
|
20796
|
+
const BM = ZS();
|
|
20796
20797
|
export {
|
|
20797
20798
|
US as $,
|
|
20798
20799
|
kh as A,
|
|
@@ -20812,21 +20813,21 @@ export {
|
|
|
20812
20813
|
Qf as O,
|
|
20813
20814
|
Fh as P,
|
|
20814
20815
|
su as Q,
|
|
20815
|
-
|
|
20816
|
+
xM as R,
|
|
20816
20817
|
Nx as S,
|
|
20817
20818
|
sS as T,
|
|
20818
|
-
|
|
20819
|
+
PM as U,
|
|
20819
20820
|
Lh as V,
|
|
20820
20821
|
gS as W,
|
|
20821
20822
|
_o as X,
|
|
20822
20823
|
Ks as Y,
|
|
20823
20824
|
rf as Z,
|
|
20824
20825
|
WS as _,
|
|
20825
|
-
|
|
20826
|
+
wM as a,
|
|
20826
20827
|
jS as a0,
|
|
20827
20828
|
VS as a1,
|
|
20828
20829
|
ZS as a2,
|
|
20829
|
-
|
|
20830
|
+
BM as a3,
|
|
20830
20831
|
hx as a4,
|
|
20831
20832
|
Ue as a5,
|
|
20832
20833
|
Rt as a6,
|
|
@@ -20843,13 +20844,13 @@ export {
|
|
|
20843
20844
|
Bh as aH,
|
|
20844
20845
|
Dh as aI,
|
|
20845
20846
|
_a as aJ,
|
|
20846
|
-
|
|
20847
|
-
|
|
20847
|
+
yM as aK,
|
|
20848
|
+
vM as aL,
|
|
20848
20849
|
Z1 as aM,
|
|
20849
20850
|
uf as aN,
|
|
20850
20851
|
w1 as aO,
|
|
20851
20852
|
S1 as aP,
|
|
20852
|
-
|
|
20853
|
+
bM as aQ,
|
|
20853
20854
|
Jo as aR,
|
|
20854
20855
|
N1 as aS,
|
|
20855
20856
|
wh as aT,
|
|
@@ -20887,27 +20888,27 @@ export {
|
|
|
20887
20888
|
dl as ay,
|
|
20888
20889
|
f_ as az,
|
|
20889
20890
|
Ax as b,
|
|
20890
|
-
|
|
20891
|
-
|
|
20892
|
-
|
|
20891
|
+
CM as c,
|
|
20892
|
+
MM as d,
|
|
20893
|
+
_M as e,
|
|
20893
20894
|
Rx as f,
|
|
20894
20895
|
Zc as g,
|
|
20895
20896
|
ff as h,
|
|
20896
20897
|
Tx as i,
|
|
20897
|
-
|
|
20898
|
+
TM as j,
|
|
20898
20899
|
c2 as k,
|
|
20899
|
-
|
|
20900
|
+
EM as l,
|
|
20900
20901
|
x2 as m,
|
|
20901
|
-
|
|
20902
|
+
AM as n,
|
|
20902
20903
|
S2 as o,
|
|
20903
20904
|
Xf as p,
|
|
20904
20905
|
ip as q,
|
|
20905
20906
|
Ex as r,
|
|
20906
|
-
|
|
20907
|
-
|
|
20908
|
-
|
|
20907
|
+
NM as s,
|
|
20908
|
+
IM as t,
|
|
20909
|
+
SM as u,
|
|
20909
20910
|
xS as v,
|
|
20910
|
-
|
|
20911
|
+
kM as w,
|
|
20911
20912
|
LS as x,
|
|
20912
20913
|
y_ as y,
|
|
20913
20914
|
RS as z
|
package/dist/runtime.cjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});require("reflect-metadata");const m=require("./index-DHZJyO9k.cjs"),le=require("./runtimeFilter-W6iMw1pL.cjs"),b=require("./index-CJj-Z7Jr.cjs"),de=require("three"),p=require("./gaesupStore-2zKBYTYo.cjs"),W=require("./index-syAx2qzT.cjs"),d=require("react/jsx-runtime"),x=require("./index-D1hpjfAw.cjs"),g=require("react"),ue=require("@react-three/fiber"),U=require("@react-three/rapier"),I=require("./index-co-QAQz9.cjs");function fe(s){const e=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(s){for(const t in s)if(t!=="default"){const r=Object.getOwnPropertyDescriptor(s,t);Object.defineProperty(e,t,r.get?r:{enumerable:!0,get:()=>s[t]})}}return e.default=s,Object.freeze(e)}const F=fe(de);class T{cellSize;cells=new Map;objectPositions=new Map;constructor(e={}){this.cellSize=e.cellSize??10}static zigZag(e){return e>=0?e*2:-e*2-1}static pair(e,t){const r=T.zigZag(e),a=T.zigZag(t),n=r+a;return n*(n+1)/2+a}getCellKey(e,t){const r=Math.floor(e/this.cellSize),a=Math.floor(t/this.cellSize);return T.pair(r,a)}add(e,t){this.remove(e);const r=this.getCellKey(t.x,t.z);this.cells.has(r)||this.cells.set(r,new Set),this.cells.get(r).add(e),this.objectPositions.set(e,t.clone())}remove(e){const t=this.objectPositions.get(e);if(t){const r=this.getCellKey(t.x,t.z),a=this.cells.get(r);a&&(a.delete(e),a.size===0&&this.cells.delete(r)),this.objectPositions.delete(e)}}update(e,t){const r=this.objectPositions.get(e);if(!r){this.add(e,t);return}if(r.equals(t))return;const a=this.getCellKey(r.x,r.z),n=this.getCellKey(t.x,t.z);if(a!==n){const i=this.cells.get(a);i&&(i.delete(e),i.size===0&&this.cells.delete(a));const o=this.cells.get(n)??new Set;o.add(e),this.cells.set(n,o)}r.copy(t)}getNearby(e,t,r){const a=r??[];r&&(r.length=0);const n=Math.ceil(t/this.cellSize),i=Math.floor(e.x/this.cellSize),o=Math.floor(e.z/this.cellSize),l=t*t;for(let f=i-n;f<=i+n;f++)for(let u=o-n;u<=o+n;u++){const h=T.pair(f,u),v=this.cells.get(h);if(v)for(const R of v){const S=this.objectPositions.get(R);if(!S)continue;const D=e.x-S.x,C=e.y-S.y,B=e.z-S.z;D*D+C*C+B*B<=l&&a.push(R)}}return a}clear(){this.cells.clear(),this.objectPositions.clear()}get size(){return this.objectPositions.size}}var pe=Object.defineProperty,ye=Object.getOwnPropertyDescriptor,L=(s,e,t,r)=>{for(var a=r>1?void 0:r?ye(e,t):e,n=s.length-1,i;n>=0;n--)(i=s[n])&&(a=(r?i(e,t,a):i(a))||a);return r&&a&&pe(e,t,a),a};exports.WorldSystem=class{objects=new Map;interactionEvents=[];spatial=new T({cellSize:10});raycaster=new F.Raycaster;tempVector=new F.Vector3;nearbyIds=[];nearbyIds2=[];async init(){}update(e){}dispose(){this.cleanup()}addObject(e){this.objects.set(e.id,e),this.spatial.add(e.id,e.position)}removeObject(e){return this.objects.get(e)&&this.spatial.remove(e),this.objects.delete(e)}getObject(e){return this.objects.get(e)}getAllObjects(){return Array.from(this.objects.values())}getObjectsByType(e){return this.getAllObjects().filter(t=>t.type===e)}updateObject(e,t){const r=this.objects.get(e);return r?(Object.assign(r,t),t.position&&this.spatial.update(e,t.position),!0):!1}getObjectsInRadius(e,t){const r=this.spatial.getNearby(e,t,this.nearbyIds),a=[];for(const n of r){const i=this.objects.get(n);i&&a.push(i)}return a}checkCollisions(e){const t=this.objects.get(e);if(!t||!t.boundingBox)return[];const r=t.boundingBox.max.distanceTo(t.boundingBox.min),a=this.spatial.getNearby(t.position,r,this.nearbyIds2),n=[];for(const i of a){if(i===e)continue;const o=this.objects.get(i);!o||!o.boundingBox||t.boundingBox.intersectsBox(o.boundingBox)&&n.push(o)}return n}processInteraction(e){this.interactionEvents.push(e),this.interactionEvents.length>1e3&&(this.interactionEvents=this.interactionEvents.slice(-500))}getRecentEvents(e=1e3){const t=Date.now();return this.interactionEvents.filter(r=>t-r.timestamp<=e)}raycast(e,t,r=100){this.raycaster.set(e,t),this.raycaster.near=0,this.raycaster.far=r;const a=this.spatial.getNearby(e,r,this.nearbyIds);for(const n of a){const i=this.objects.get(n);if(i&&i.boundingBox){const o=this.raycaster.ray.intersectBox(i.boundingBox,this.tempVector);if(o)return{object:i,distance:e.distanceTo(o),point:o.clone()}}}return null}cleanup(){this.objects.clear(),this.interactionEvents.length=0,this.spatial.clear()}};L([p.HandleError()],exports.WorldSystem.prototype,"init",1);L([p.Profile(),p.HandleError()],exports.WorldSystem.prototype,"update",1);L([p.HandleError()],exports.WorldSystem.prototype,"dispose",1);exports.WorldSystem=L([p.RegisterSystem("world")],exports.WorldSystem);var me=Object.defineProperty,ge=Object.getOwnPropertyDescriptor,z=(s,e,t,r)=>{for(var a=r>1?void 0:r?ge(e,t):e,n=s.length-1,i;n>=0;n--)(i=s[n])&&(a=(r?i(e,t,a):i(a))||a);return r&&a&&me(e,t,a),a};exports.WorldBridge=class extends b.CoreBridge{buildEngine(e,t){const r=new exports.WorldSystem,a={...t?.selectedObjectId!==void 0?{selectedObjectId:t.selectedObjectId}:{},interactionMode:t?.interactionMode??"view",showDebugInfo:t?.showDebugInfo??!1};return{system:r,state:a,dispose:()=>r.dispose()}}executeCommand(e,t,r){const{system:a,state:n}=e;switch(t.type){case"addObject":const{id:i,...o}=t.data,l=typeof i=="string"&&i.length>0?i:this.generateId(),f={...o,id:l};a.addObject(f);break;case"removeObject":a.removeObject(t.data.id),n.selectedObjectId===t.data.id&&delete n.selectedObjectId;break;case"updateObject":a.updateObject(t.data.id,t.data.updates);break;case"selectObject":t.data.id!==void 0?n.selectedObjectId=t.data.id:delete n.selectedObjectId;break;case"setInteractionMode":n.interactionMode=t.data.mode;break;case"toggleDebugInfo":n.showDebugInfo=!n.showDebugInfo;break;case"interact":const u=a.getObject(t.data.objectId);if(u&&u.canInteract){const h={type:"custom",object1Id:t.data.objectId,timestamp:Date.now(),data:{action:t.data.action}};a.processInteraction(h)}break;case"cleanup":a.cleanup(),delete n.selectedObjectId,n.interactionMode="view",n.showDebugInfo=!1;break}}createSnapshot(e,t){const{system:r,state:a}=e;return{objects:r.getAllObjects(),...a.selectedObjectId!==void 0?{selectedObjectId:a.selectedObjectId}:{},interactionMode:a.interactionMode,showDebugInfo:a.showDebugInfo,events:r.getRecentEvents(),objectsInRadius:(n,i)=>r.getObjectsInRadius(n,i),objectsByType:n=>r.getObjectsByType(n),raycast:(n,i)=>r.raycast(n,i)?.object||null}}addObject(e,t){const r=t.id,a=typeof r=="string"&&r.length>0?r:this.generateId();return this.execute(e,{type:"addObject",data:{...t,id:a}}),a}removeObject(e,t){this.execute(e,{type:"removeObject",data:{id:t}})}updateObject(e,t,r){this.execute(e,{type:"updateObject",data:{id:t,updates:r}})}selectObject(e,t){this.execute(e,{type:"selectObject",data:t!==void 0?{id:t}:{}})}setInteractionMode(e,t){this.execute(e,{type:"setInteractionMode",data:{mode:t}})}toggleDebugInfo(e){this.execute(e,{type:"toggleDebugInfo"})}interact(e,t,r){this.execute(e,{type:"interact",data:{objectId:t,action:r}})}cleanup(e){this.execute(e,{type:"cleanup"})}getObjectsInRadius(e,t,r){const a=this.getEngine(e);return a?a.system.getObjectsInRadius(t,r):[]}getObjectsByType(e,t){const r=this.getEngine(e);return r?r.system.getObjectsByType(t):[]}raycast(e,t,r){const a=this.getEngine(e);return a&&a.system.raycast(t,r)?.object||null}generateId(){return`world_${Date.now()}_${Math.random().toString(36).substr(2,9)}`}};z([b.ValidateCommand()],exports.WorldBridge.prototype,"executeCommand",1);z([b.LogSnapshot(),b.CacheSnapshot(16)],exports.WorldBridge.prototype,"createSnapshot",1);exports.WorldBridge=z([b.DomainBridge("world"),b.EnableEventLog()],exports.WorldBridge);const he={isRiderOn:!1,position:U.vec3(),rotation:U.euler(),offset:U.vec3(),visible:!0};function ve(){const{gameStates:s,updateGameStates:e,activeState:t}=b.useStateSystem(),r=p.useGaesupStore(c=>c.rideable),a=p.useGaesupStore(c=>c.urls),n=p.useGaesupStore(c=>c.setMode),i=p.useGaesupStore(c=>c.setRideable),o=p.useGaesupStore(c=>c.setUrls),{getSizesByUrls:l}=b.useGaesupGltf(),f=g.useCallback(c=>c==="airplane"?"airplane":"vehicle",[]),u=g.useCallback(c=>{const y={},j=c.ridingUrl??a.characterUrl;if(typeof j=="string"&&j.length>0&&(y.ridingUrl=j),c.objectType==="airplane"){y.airplaneUrl=c.url??"",o(y);return}c.objectType&&(y.vehicleUrl=c.url??"",y.wheelUrl=c.wheelUrl??""),o(y)},[o,a]),h=g.useCallback(c=>{const y=r[c];if(!y?.position)return;const j=y.objectType,{vehicleUrl:ie,airplaneUrl:oe,characterUrl:ce}=l({...a});!(j==="airplane"?oe:ie)||!ce||(e({canRide:!1,isRiding:!1,currentRideable:void 0}),i(c,{...y,visible:!0,position:t.position.clone()}))},[r,l,a,e,i,t.position]),v=g.useCallback(async()=>{if(s.canRide&&s.nearbyRideable&&!s.isRiding){const{objectkey:c,objectType:y}=s.nearbyRideable,j=r[c];if(!j)return;u(j),n({type:f(y)}),e({currentRideable:s.nearbyRideable,isRiding:!0,canRide:!1,nearbyRideable:void 0}),i(c,{...j,visible:!1})}},[s.canRide,s.nearbyRideable,s.isRiding,r,u,n,f,e,i]),R=g.useCallback(async()=>{s.isRiding&&s.currentRideable&&(h(s.currentRideable.objectkey),n({type:"character"}),e({isRiding:!1,currentRideable:void 0}))},[s.isRiding,s.currentRideable,h,n,e]);g.useEffect(()=>{const c=y=>{y.code==="KeyF"&&(s.canRide&&s.nearbyRideable?v():s.isRiding&&R())};return window.addEventListener("keydown",c),()=>window.removeEventListener("keydown",c)},[s.canRide,s.nearbyRideable,s.isRiding,v,R]);const S=g.useCallback(c=>{i(c.objectkey,{...he,...c})},[i]),D=g.useCallback(c=>{i(c.objectkey,c)},[i]),C=c=>r[c],B=g.useCallback(async(c,y)=>{if((c.other.rigidBodyObject&&c.other.rigidBodyObject.name==="character"||c.other.rigidBodyObject&&!c.other.rigidBodyObject.name||c.other.rigidBody)&&!s.isRiding){if(!y.objectType)return;e({nearbyRideable:{id:y.objectkey,objectkey:y.objectkey,objectType:y.objectType,type:"rideable",maxSpeed:0,acceleration:0,deceleration:0,isOccupied:!1,controls:{forward:!1,backward:!1,left:!1,right:!1,brake:!1},name:y.objectType==="vehicle"?"차량":"비행기",...y.rideMessage?{rideMessage:y.rideMessage}:{},...y.exitMessage?{exitMessage:y.exitMessage}:{},...y.displayName?{displayName:y.displayName}:{}},canRide:!0})}},[s.isRiding,e]),M=g.useCallback(async c=>{(c.other.rigidBodyObject&&c.other.rigidBodyObject.name==="character"||c.other.rigidBodyObject&&!c.other.rigidBodyObject.name||c.other.rigidBody)&&e({nearbyRideable:void 0,canRide:!1})},[e]);return{initRideable:S,updateRideable:D,getRideable:C,onRideableNear:B,onRideableLeave:M,enterRideable:v,exitRideable:R,landing:h}}const E="default",be=s=>{const e=p.BridgeFactory.getOrCreate("world");if(e){e.register(E);const t=e;t.__gaesupWorldSliceUnsubscribe?.(),t.__gaesupWorldSliceUnsubscribe=e.subscribe(r=>{s({objects:r.objects,selectedObjectId:r.selectedObjectId,interactionMode:r.interactionMode,showDebugInfo:r.showDebugInfo,events:r.events,loading:!1,error:void 0})})}return{objects:[],selectedObjectId:void 0,interactionMode:"view",showDebugInfo:!1,events:[],loading:!1,error:void 0,addObject:t=>{if(!e)return"";s({loading:!0,error:void 0});try{const r=e.addObject(E,t);return s({loading:!1}),r}catch(r){return s({loading:!1,error:r instanceof Error?r.message:"Unknown error"}),""}},removeObject:t=>{if(!e)return!1;s({loading:!0,error:void 0});try{return e.removeObject(E,t),s({loading:!1}),!0}catch(r){return s({loading:!1,error:r instanceof Error?r.message:"Unknown error"}),!1}},updateObject:(t,r)=>{if(!e)return!1;s({loading:!0,error:void 0});try{return e.updateObject(E,t,r),s({loading:!1}),!0}catch(a){return s({loading:!1,error:a instanceof Error?a.message:"Unknown error"}),!1}},selectObject:t=>{e&&e.selectObject(E,t)},setInteractionMode:t=>{e&&e.setInteractionMode(E,t)},toggleDebugInfo:()=>{e&&e.toggleDebugInfo(E)},setLoading:t=>{s({loading:t})},setError:t=>{s({error:t})},clearEvents:()=>{s({events:[]})},getBridge:()=>e,getObjectsInRadius:(t,r)=>e?e.getObjectsInRadius(E,t,r):[],getObjectsByType:t=>e?e.getObjectsByType(E,t):[],raycast:(t,r)=>e?e.raycast(E,t,r):null,interact:(t,r)=>{e&&e.interact(E,t,r)},cleanup:()=>{e&&e.cleanup(E)}}};var Se=Object.defineProperty,Re=Object.getOwnPropertyDescriptor,O=(s,e,t,r)=>{for(var a=Re(e,t),n=s.length-1,i;n>=0;n--)(i=s[n])&&(a=i(e,t,a)||a);return a&&Se(e,t,a),a};const we="1.0.0",P="gaesup_world_save_",G="base64-json:",Z="gaesup-world:gzip-json:v1";class w{version;storage;fileWriter;now;constructor(e={}){this.version=e.version??we,this.storage=e.storage,this.fileWriter=e.fileWriter,this.now=e.now??Date.now}async save(e,t,r={}){try{const a=this.createSaveData(e,t,r);return r.compress?await this.saveCompressed(a):await this.saveUncompressed(a)}catch(a){return{success:!1,error:a instanceof Error?a.message:"Unknown error occurred"}}}async load(e,t={}){try{const r=`${P}${e}`,a=this.getStorage().getItem(r);if(!a)throw new Error(`Save data not found: ${e}`);const n=await this.parseStoredSaveData(a);if(!this.validateSaveData(n))throw new Error("Invalid save data format");return{success:!0,data:{...n,world:this.filterWorldData(n.world,t)}}}catch(r){return{success:!1,error:r instanceof Error?r.message:"Failed to load save data"}}}async saveToFile(e,t,r,a={}){try{const n=this.createSaveData(e,r,a);return await this.writeFile(t,n),{success:!0,data:n}}catch(n){return{success:!1,error:n instanceof Error?n.message:"Failed to save file"}}}async loadFromFile(e,t={}){try{const r=await e.text(),a=JSON.parse(r);if(!this.validateSaveData(a))throw new Error("Invalid save file format");return{success:!0,data:{...a,world:this.filterWorldData(a.world,t)}}}catch(r){return{success:!1,error:r instanceof Error?r.message:"Failed to load file"}}}listSaves(){const e=[];let t;try{t=this.getStorage()}catch(r){return console.error("Failed to list saves:",r),e}for(let r=0;r<t.length;r++){const a=t.key(r);if(a&&a.startsWith(P))try{const n=a.substring(P.length),i=t.getItem(a);if(i){const o=this.parseStoredSaveDataSync(i);e.push({id:n,timestamp:o.timestamp,...o.metadata?{metadata:o.metadata}:{}})}}catch(n){console.error(`Failed to parse save: ${a}`,n)}}return e.sort((r,a)=>a.timestamp-r.timestamp)}deleteSave(e){try{const t=`${P}${e}`;return this.getStorage().removeItem(t),!0}catch(t){return console.error("Failed to delete save:",t),!1}}filterWorldData(e,t){const r={...e};return t.includeBuildings===!1&&(r.buildings={wallGroups:[],tileGroups:[],blocks:[],meshes:[]}),t.includeNPCs===!1&&(r.npcs=[]),t.includeEnvironment===!1&&(r.environment={lighting:{ambientIntensity:1,directionalIntensity:1,directionalPosition:{x:0,y:10,z:0}}}),t.includeCamera===!1&&delete r.camera,r}createSaveData(e,t,r={}){const a=this.now();return{version:this.version,timestamp:a,world:this.filterWorldData(e,r),...t?{metadata:{...t,createdAt:t.createdAt||a,updatedAt:a}}:{}}}getStorage(){if(this.storage)return this.storage;if(typeof localStorage>"u")throw new Error("Legacy save storage is not available in this environment");return localStorage}async writeFile(e,t){if(this.fileWriter){await this.fileWriter(e,t);return}if(typeof document>"u"||typeof URL>"u"||typeof Blob>"u")throw new Error("File download is not available in this environment");const r=new Blob([JSON.stringify(t,null,2)],{type:"application/json"}),a=URL.createObjectURL(r),n=document.createElement("a");n.href=a,n.download=e.endsWith(".json")?e:`${e}.json`,document.body.appendChild(n),n.click(),document.body.removeChild(n),URL.revokeObjectURL(a)}async saveUncompressed(e){const t=`${e.world.id}_${e.timestamp}`,r=`${P}${t}`;try{return this.getStorage().setItem(r,JSON.stringify(e)),{success:!0,data:e}}catch(a){throw a instanceof Error&&a.name==="QuotaExceededError"?new Error("Storage quota exceeded. Please delete some saves."):a}}async saveCompressed(e){const t=await this.compressData(e),r=`${e.world.id}_${e.timestamp}`,a=`${P}${r}`;try{return this.getStorage().setItem(a,t),{success:!0,data:e}}catch(n){throw n instanceof Error&&n.name==="QuotaExceededError"?new Error("Storage quota exceeded. Please delete some saves."):n}}async compressData(e){const t=JSON.stringify(e);if(!H())return`${G}${$(V(t))}`;const r=await this.gzipBytes(V(t)),a={encoding:Z,version:e.version,timestamp:e.timestamp,worldId:e.world.id,worldName:e.world.name,...e.metadata?{metadata:e.metadata}:{},payload:$(r)};return JSON.stringify(a)}async decompressData(e){const t=X(e),r=await this.gunzipBytes(t),a=Q(r);return JSON.parse(a)}async parseStoredSaveData(e){if(e.startsWith("{")){const t=JSON.parse(e);return q(t)?this.decompressData(t.payload):t}return e.startsWith(G)?_(e.slice(G.length)):_(e)}parseStoredSaveDataSync(e){if(e.startsWith("{")){const t=JSON.parse(e);return q(t)?{version:t.version,timestamp:t.timestamp,world:{id:t.worldId,name:t.worldName,buildings:{wallGroups:[],tileGroups:[],blocks:[],meshes:[]},npcs:[],environment:{lighting:{ambientIntensity:1,directionalIntensity:1,directionalPosition:{x:0,y:10,z:0}}}},...t.metadata?{metadata:t.metadata}:{}}:t}return e.startsWith(G)?_(e.slice(G.length)):_(e)}async gzipBytes(e){if(!H())return e;const t=new Blob([e]).stream().pipeThrough(new CompressionStream("gzip"));return new Uint8Array(await new Response(t).arrayBuffer())}async gunzipBytes(e){if(!Ee())return e;const t=new Blob([e]).stream().pipeThrough(new DecompressionStream("gzip"));return new Uint8Array(await new Response(t).arrayBuffer())}validateSaveData(e){return e!==null&&typeof e=="object"&&"version"in e&&"timestamp"in e&&"world"in e&&typeof e.version=="string"&&typeof e.timestamp=="number"&&e.world&&typeof e.world.id=="string"&&typeof e.world.name=="string"}}O([p.HandleError(),p.Profile(),p.Timeout(5e3)],w.prototype,"save");O([p.HandleError(),p.Profile(),p.Timeout(5e3)],w.prototype,"load");O([p.HandleError(),p.Profile()],w.prototype,"saveToFile");O([p.HandleError(),p.Profile()],w.prototype,"loadFromFile");O([p.MonitorMemory(10)],w.prototype,"listSaves");O([p.HandleError()],w.prototype,"deleteSave");O([p.Profile()],w.prototype,"filterWorldData");O([p.Profile()],w.prototype,"createSaveData");O([p.HandleError()],w.prototype,"saveUncompressed");O([p.HandleError()],w.prototype,"saveCompressed");O([p.Profile()],w.prototype,"compressData");O([p.Profile()],w.prototype,"decompressData");function $(s){let e="";for(let r=0;r<s.length;r+=32768)e+=String.fromCharCode(...s.subarray(r,r+32768));return btoa(e)}function X(s){const e=atob(s),t=new Uint8Array(e.length);for(let r=0;r<e.length;r+=1)t[r]=e.charCodeAt(r);return t}function _(s){return JSON.parse(Q(X(s)))}function V(s){if(typeof TextEncoder<"u")return new TextEncoder().encode(s);const e=unescape(encodeURIComponent(s)),t=new Uint8Array(e.length);for(let r=0;r<e.length;r+=1)t[r]=e.charCodeAt(r);return t}function Q(s){if(typeof TextDecoder<"u")return new TextDecoder().decode(s);let e="";const t=32768;for(let r=0;r<s.length;r+=t)e+=String.fromCharCode(...s.subarray(r,r+t));return decodeURIComponent(escape(e))}function H(){return typeof CompressionStream<"u"&&typeof Blob<"u"&&typeof Response<"u"&&typeof new Blob().stream=="function"}function Ee(){return typeof DecompressionStream<"u"&&typeof Blob<"u"&&typeof Response<"u"&&typeof new Blob().stream=="function"}function q(s){if(!s||typeof s!="object")return!1;const e=s;return e.encoding===Z&&typeof e.version=="string"&&typeof e.timestamp=="number"&&typeof e.worldId=="string"&&typeof e.worldName=="string"&&typeof e.payload=="string"}const Oe=()=>({});function J(s,e,t){const{buildingStore:r,npcStore:a,cameraStore:n}=s;if(!r)throw new Error("Building store not initialized");const i=r.getState(),o=n?.getState(),l=o?{position:o.position,rotation:o.rotation,mode:o.mode,...o.settings?{settings:o.settings}:{}}:void 0;return{id:e,name:t,buildings:{wallGroups:Array.from(i.wallGroups.values()),tileGroups:Array.from(i.tileGroups.values()),blocks:Array.from(i.blocks),meshes:Array.from(i.meshes.values())},npcs:a?Array.from(a.getState().instances.values()):[],environment:m.DEFAULT_WORLD_SAVE_ENVIRONMENT,...l?{camera:l}:{}}}function je(s,e){if(!s||!e)return;const t=s.getState();if(typeof t.hydrate=="function"){t.hydrate(e);return}t.wallGroups.clear(),t.tileGroups.clear(),t.meshes.clear(),t.blocks=[],e.wallGroups.forEach(r=>{t.wallGroups.set(r.id,r)}),e.tileGroups.forEach(r=>{t.tileGroups.set(r.id,r)}),e.meshes.forEach(r=>{t.meshes.set(r.id,r)}),t.blocks=[...e.blocks??[]]}function xe(s,e){if(!s||!e)return;const t=s.getState();t.instances.clear(),e.forEach(r=>{t.instances.set(r.id,r)})}function Ie(s,e){!s||!e||s.setState({position:e.position,rotation:e.rotation,mode:e.mode,settings:e.settings||{}})}function K(s,e){je(s.buildingStore,e.buildings),xe(s.npcStore,e.npcs),Ie(s.cameraStore,e.camera)}function k(s){return typeof s=="object"&&s!==null&&!Array.isArray(s)}function De(s){return s.replace(/\.json$/i,"")}function Y(s){return k(s)&&typeof s.version=="number"&&typeof s.savedAt=="number"&&k(s.domains)}function A(s){return k(s)&&s.kind==="gaesup.save-system"&&typeof s.worldId=="string"&&typeof s.worldName=="string"&&Y(s.blob)}async function N(s){return(await s.list()).map(t=>({id:t,timestamp:m.parseWorldSaveTimestamp(t)})).sort((t,r)=>r.timestamp-t.timestamp)}function Ce(s,e){if(typeof document>"u"||typeof URL>"u"||typeof Blob>"u")throw new Error("File download is not available in this environment");const t=new Blob([JSON.stringify(e,null,2)],{type:"application/json"}),r=URL.createObjectURL(t),a=document.createElement("a");a.href=r,a.download=s.endsWith(".json")?s:`${s}.json`,document.body.appendChild(a),a.click(),document.body.removeChild(a),URL.revokeObjectURL(r)}async function Be(s){const e=JSON.parse(await s.text());if(A(e)||Y(e))return e;throw new Error("Invalid SaveSystem file format")}function ee(s={}){const e=s.getStores??Oe,t=s.saveSystem;return(r,a)=>({saveLoadManager:s.saveLoadManager??new w,currentSaveId:null,saves:[],isSaving:!1,isLoading:!1,lastError:null,saveWorld:async(n,i,o,l)=>{r({isSaving:!0,lastError:null});try{if(t){const h=Date.now(),v=`${n}_${h}`;await t.save(v),r({currentSaveId:v,saves:await N(t)});return}const f=J(e(),n,i),u=await a().saveLoadManager.save(f,o,l);if(u.success){const h=`${n}_${u.data.timestamp}`;r({currentSaveId:h}),a().refreshSaveList()}else throw new Error(u.error)}catch(f){throw r({lastError:f instanceof Error?f.message:"Save failed"}),f}finally{r({isSaving:!1})}},loadWorld:async(n,i)=>{r({isLoading:!0,lastError:null});try{if(t){if(!await t.load(n))throw new Error(`Save data not found: ${n}`);return r({currentSaveId:n}),m.createSaveDataFromSaveSystem(t,n)}const o=await a().saveLoadManager.load(n,i);if(o.success&&o.data)return K(e(),o.data.world),r({currentSaveId:n}),o.data;throw new Error(o.error)}catch(o){return r({lastError:o instanceof Error?o.message:"Load failed"}),null}finally{r({isLoading:!1})}},saveToFile:async(n,i,o,l,f)=>{r({isSaving:!0,lastError:null});try{if(t){const v={kind:"gaesup.save-system",version:1,worldId:n,worldName:i,blob:t.createBlob(o),...l?{metadata:l}:{}};Ce(o,v);return}const u=J(e(),n,i),h=await a().saveLoadManager.saveToFile(u,o,l,f);if(!h.success)throw new Error(h.error)}catch(u){throw r({lastError:u instanceof Error?u.message:"Save to file failed"}),u}finally{r({isSaving:!1})}},loadFromFile:async(n,i)=>{r({isLoading:!0,lastError:null});try{if(t){const l=await Be(n),f=A(l)?l.blob:l;t.hydrateBlob(f,n.name);const u=A(l)?l.worldId:De(n.name),h=A(l)?l.worldName:u,v=f.savedAt,R={version:String(f.version),timestamp:v,world:m.createWorldDataFromSaveDomains(f.domains,u,h)},S=A(l)?m.normalizeSaveMetadata(l.metadata,v):void 0;return S?{...R,metadata:S}:R}const o=await a().saveLoadManager.loadFromFile(n,i);if(o.success&&o.data)return K(e(),o.data.world),o.data;throw new Error(o.error)}catch(o){return r({lastError:o instanceof Error?o.message:"Load from file failed"}),null}finally{r({isLoading:!1})}},refreshSaveList:()=>{if(t){N(t).then(i=>r({saves:i})).catch(i=>{r({lastError:i instanceof Error?i.message:"Failed to list saves"})});return}const n=a().saveLoadManager.listSaves();r({saves:n})},deleteSave:n=>{if(t){(async()=>{try{await t.remove(n);const o=await N(t);r({saves:o,...a().currentSaveId===n?{currentSaveId:null}:{}})}catch(o){r({lastError:o instanceof Error?o.message:"Failed to delete save"})}})();return}a().saveLoadManager.deleteSave(n)&&(a().refreshSaveList(),a().currentSaveId===n&&r({currentSaveId:null}))},clearError:()=>{r({lastError:null})}})}const Pe=ee();function te({object:s,selected:e=!1,onSelect:t,showDebugInfo:r=!1}){const a=x.useGenericRefs(),n=s.metadata?.airplaneUrl??s.metadata?.modelUrl,i=typeof n=="string"?n:void 0;if(typeof i!="string"||i.length===0)return null;const o=s.metadata?.ridingUrl,l=typeof o=="string"?o:void 0,f=s.metadata?.currentAnimation,u=typeof f=="string"?f:"idle";return d.jsx(b.PhysicsEntity,{url:i,isActive:!1,componentType:"airplane",name:`active-airplane-${s.id}`,position:s.position,rotation:s.rotation,scale:s.scale,currentAnimation:u,...l?{ridingUrl:l}:{},ref:a.rigidBodyRef,outerGroupRef:a.outerGroupRef,innerGroupRef:a.innerGroupRef,colliderRef:a.colliderRef,userData:{id:s.id,type:"active",subType:"airplane",health:s.health,maxHealth:s.maxHealth,energy:s.energy,maxEnergy:s.maxEnergy},onCollisionEnter:()=>{t&&t(s.id)},children:e&&r&&d.jsxs("mesh",{position:[0,3,0],children:[d.jsx("boxGeometry",{args:[.5,.5,.5]}),d.jsx("meshStandardMaterial",{color:"#00ffff",transparent:!0,opacity:.6})]})})}function re({object:s,selected:e=!1,onSelect:t,showDebugInfo:r=!1}){const a=x.useGenericRefs();g.useEffect(()=>{a.rigidBodyRef&&a.rigidBodyRef.current&&a.rigidBodyRef.current.setEnabledRotations(!1,!1,!1,!1)},[a.rigidBodyRef]);const n=s.metadata?.characterUrl;if(typeof n!="string"||n.length===0)return null;const i=s.metadata?.currentAnimation,o=typeof i=="string"?i:"idle",l=s.metadata?.nameTag,f=typeof l=="string"?l:void 0;return d.jsx(b.PhysicsEntity,{url:n,isActive:!1,componentType:"character",name:`active-character-${s.id}`,position:s.position,rotation:s.rotation,scale:s.scale,currentAnimation:o,ref:a.rigidBodyRef,outerGroupRef:a.outerGroupRef,innerGroupRef:a.innerGroupRef,colliderRef:a.colliderRef,userData:{id:s.id,type:"active",subType:"character",health:s.health,maxHealth:s.maxHealth,energy:s.energy,maxEnergy:s.maxEnergy,nameTag:f},onCollisionEnter:()=>{t&&t(s.id)},children:e&&r&&d.jsxs("mesh",{position:[0,3,0],children:[d.jsx("boxGeometry",{args:[.5,.5,.5]}),d.jsx("meshStandardMaterial",{color:"#ff0000",transparent:!0,opacity:.6})]})})}function se({object:s,selected:e=!1,onSelect:t,showDebugInfo:r=!1}){const a=x.useGenericRefs(),n=s.metadata?.vehicleUrl??s.metadata?.modelUrl,i=typeof n=="string"?n:void 0;if(typeof i!="string"||i.length===0)return null;const o=s.metadata?.ridingUrl,l=typeof o=="string"?o:void 0,f=s.metadata?.currentAnimation,u=typeof f=="string"?f:"idle";return d.jsx(b.PhysicsEntity,{url:i,isActive:!1,componentType:"vehicle",name:`active-vehicle-${s.id}`,position:s.position,rotation:s.rotation,scale:s.scale,currentAnimation:u,...l?{ridingUrl:l}:{},ref:a.rigidBodyRef,outerGroupRef:a.outerGroupRef,innerGroupRef:a.innerGroupRef,colliderRef:a.colliderRef,userData:{id:s.id,type:"active",subType:"vehicle",health:s.health,maxHealth:s.maxHealth,energy:s.energy,maxEnergy:s.maxEnergy},onCollisionEnter:()=>{t&&t(s.id)},children:e&&r&&d.jsxs("mesh",{position:[0,3,0],children:[d.jsx("boxGeometry",{args:[.5,.5,.5]}),d.jsx("meshStandardMaterial",{color:"#0000ff",transparent:!0,opacity:.6})]})})}function Te({objects:s,selectedId:e,onSelect:t,showDebugInfo:r=!1}){const{gameStates:a}=b.useStateSystem(),n=p.useGaesupStore(i=>i.mode);return d.jsx("group",{name:"active-objects",children:s.map(i=>{const o=i.id===e;if(i.type==="character"&&a?.isRiding&&n?.type!=="character")return null;switch(i.type){case"vehicle":return d.jsx(se,{object:i,selected:o,...t?{onSelect:t}:{},showDebugInfo:r},i.id);case"airplane":return d.jsx(te,{object:i,selected:o,...t?{onSelect:t}:{},showDebugInfo:r},i.id);case"character":return d.jsx(re,{object:i,selected:o,...t?{onSelect:t}:{},showDebugInfo:r},i.id);default:return null}})})}function ae(s){const{children:e,visible:t=!0,...r}=s,a=x.useGenericRefs();return d.jsx("group",{visible:t,children:d.jsx(b.PhysicsEntity,{...r,url:r.url||"",isActive:!1,componentType:"vehicle",name:r.name??"vehicle",ref:a.rigidBodyRef,outerGroupRef:a.outerGroupRef,innerGroupRef:a.innerGroupRef,colliderRef:a.colliderRef,children:e})})}function ne(s){const{children:e,visible:t=!0,...r}=s,a=x.useGenericRefs();return d.jsx("group",{visible:t,children:d.jsx(b.PhysicsEntity,{...r,url:r.url||"",isActive:!1,componentType:"airplane",name:r.name??"airplane",ref:a.rigidBodyRef,outerGroupRef:a.outerGroupRef,innerGroupRef:a.innerGroupRef,colliderRef:a.colliderRef,children:e})})}function Ge(s){const{children:e,visible:t=!0,...r}=s,a=x.useGenericRefs();g.useEffect(()=>{a.rigidBodyRef&&a.rigidBodyRef.current&&a.rigidBodyRef.current.setEnabledRotations(!1,!1,!1,!1)},[a.rigidBodyRef]);const n=r.controllerOptions??{lerp:{cameraTurn:1,cameraPosition:1}};return d.jsx("group",{visible:t,children:d.jsx(b.PhysicsEntity,{...r,url:r.url||"",isActive:!1,componentType:"character",controllerOptions:n,ref:a.rigidBodyRef,outerGroupRef:a.outerGroupRef,innerGroupRef:a.innerGroupRef,colliderRef:a.colliderRef,children:e})})}const Ae=150*150,Ue=g.memo(function({object:e,isSelected:t,onSelect:r,showDebugInfo:a=!1,enableInteraction:n=!0}){const i=x.useGenericRefs(),o=e.metadata?.modelUrl,l=typeof o=="string"?o:void 0,f=g.useCallback(()=>{n&&e.interactable&&r&&r(e.id)},[n,e.interactable,e.id,r]),u=g.useCallback(v=>{n&&e.interactable&&(v.stopPropagation(),document.body.style.cursor="pointer")},[n,e.interactable]),h=g.useCallback(()=>{document.body.style.cursor="default"},[]);return l?d.jsx(b.PhysicsEntity,{url:l,isActive:!1,componentType:e.type,name:`passive-${e.type}-${e.id}`,position:e.position,rotation:e.rotation,scale:e.scale,ref:i.rigidBodyRef,outerGroupRef:i.outerGroupRef,innerGroupRef:i.innerGroupRef,colliderRef:i.colliderRef,userData:{id:e.id,type:"passive",subType:e.type,interactable:e.interactable,onNear:e.metadata?.onNear,onLeave:e.metadata?.onLeave,onInteract:e.metadata?.onInteract},onCollisionEnter:()=>{n&&e.interactable&&r&&r(e.id)},children:t&&a&&d.jsxs("mesh",{position:[0,3,0],children:[d.jsx("boxGeometry",{args:[.5,.5,.5]}),d.jsx("meshStandardMaterial",{color:"#00ff00",transparent:!0,opacity:.6})]})}):d.jsxs(U.RigidBody,{type:"fixed",position:e.position,rotation:e.rotation,colliders:!1,children:[d.jsx(U.CapsuleCollider,{args:[1,.5],position:[0,1,0]}),d.jsx("group",{scale:e.scale,onClick:f,onPointerEnter:u,onPointerLeave:h})]})}),Me=g.memo(function({objects:e,selectedId:t,onSelect:r,showDebugInfo:a=!1,enableInteraction:n=!0}){const[i,o]=g.useState(()=>new Set),l=g.useRef(0);ue.useFrame((u,h)=>{if(l.current+=h,l.current<.5)return;l.current=0;const v=u.camera.position,R=new Set;for(const S of e){const D=S.position.x,C=S.position.y,B=S.position.z,M=D-v.x,c=C-v.y,y=B-v.z;M*M+c*c+y*y<=Ae&&R.add(S.id)}(R.size!==i.size||[...R].some(S=>!i.has(S)))&&o(R)});const f=g.useMemo(()=>e.filter(u=>i.has(u.id)).map(u=>d.jsx(Ue,{object:u,isSelected:u.id===t,...r?{onSelect:r}:{},showDebugInfo:a,enableInteraction:n},u.id)),[e,t,r,a,n,i]);return d.jsx("group",{name:"passive-objects",children:f})});function _e({states:s}){if(!s||!s.canRide&&!s.isRiding)return null;const e=s.nearbyRideable?.rideMessage??`Press F to ride ${s.nearbyRideable?.displayName??s.nearbyRideable?.name??"vehicle"}`,t=s.nearbyRideable?.exitMessage??"Press F to exit";return d.jsx("div",{className:"rideable-ui-container",children:d.jsxs("div",{className:"message-box",children:[s.canRide&&d.jsx("div",{children:e}),s.isRiding&&d.jsx("div",{children:t})]})})}function We(s){const e=p.useGaesupStore(u=>u.rideable),{initRideable:t,onRideableNear:r,onRideableLeave:a,landing:n}=ve();g.useEffect(()=>{t(s)},[s,t]);const{controllerOptions:i,...o}=s,l=i?.lerp?{lerp:{cameraTurn:i.lerp.cameraTurn??1,cameraPosition:i.lerp.cameraPosition??1}}:void 0,f={objectType:s.objectType,objectkey:s.objectkey,rideable:!0,init:t,onNear:r,onLeave:a,landing:n,rideMessage:s.rideMessage,exitMessage:s.exitMessage,displayName:s.displayName};return d.jsxs(d.Fragment,{children:[s.objectType==="vehicle"&&d.jsx(ae,{...o,...l?{controllerOptions:l}:{},userData:f,sensor:!0,visible:!e[s.objectkey]?.isOccupied}),s.objectType==="airplane"&&d.jsx(ne,{...o,...l?{controllerOptions:l}:{},userData:f,sensor:!0,visible:!e[s.objectkey]?.isOccupied})]})}exports.BugSpot=m.BugSpot;exports.DEFAULT_RUNTIME_SAVE_DIAGNOSTICS_SERVICE_ID=m.DEFAULT_RUNTIME_SAVE_DIAGNOSTICS_SERVICE_ID;exports.DEFAULT_WORLD_SAVE_ENVIRONMENT=m.DEFAULT_WORLD_SAVE_ENVIRONMENT;exports.FishSpot=m.FishSpot;exports.RUNTIME_SAVE_DIAGNOSTIC_EVENT=m.RUNTIME_SAVE_DIAGNOSTIC_EVENT;exports.TreeObject=m.TreeObject;exports.createCameraSaveDataFromDomain=m.createCameraSaveDataFromDomain;exports.createGaesupRuntime=m.createGaesupRuntime;exports.createRuntimeSaveDiagnostics=m.createRuntimeSaveDiagnostics;exports.createSaveDataFromSaveSystem=m.createSaveDataFromSaveSystem;exports.createWorldDataFromSaveDomains=m.createWorldDataFromSaveDomains;exports.formatRuntimeSaveDiagnostic=m.formatRuntimeSaveDiagnostic;exports.normalizeSaveMetadata=m.normalizeSaveMetadata;exports.parseWorldSaveId=m.parseWorldSaveId;exports.parseWorldSaveTimestamp=m.parseWorldSaveTimestamp;exports.useAutoSave=m.useAutoSave;exports.useLoadOnMount=m.useLoadOnMount;exports.shouldSetupPluginForRuntime=le.shouldSetupPluginForRuntime;exports.GaesupRuntimeProvider=b.GaesupRuntimeProvider;exports.useGaesupRuntime=b.useGaesupRuntime;exports.useGaesupRuntimeRevision=b.useGaesupRuntimeRevision;exports.GaesupWorldContent=W.GaesupWorldContent;exports.World=W.WorldContainer;exports.WorldConfigProvider=W.WorldConfigProvider;exports.WorldContainer=W.WorldContainer;exports.DuplicateSaveDomainBindingError=I.DuplicateSaveDomainBindingError;exports.IndexedDBAdapter=I.IndexedDBAdapter;exports.LocalStorageAdapter=I.LocalStorageAdapter;exports.SaveSystem=I.SaveSystem;exports.WorldProps=I.WorldProps;exports.createDefaultSaveSystem=I.createDefaultSaveSystem;exports.getSaveSystem=I.getSaveSystem;exports.ActiveObjects=Te;exports.Airplane=te;exports.Character=re;exports.PassiveAirplane=ne;exports.PassiveCharacter=Ge;exports.PassiveObjects=Me;exports.PassiveVehicle=ae;exports.Rideable=We;exports.RideableUI=_e;exports.SaveLoadManager=w;exports.Vehicle=se;exports.createPersistenceSlice=Pe;exports.createPersistenceSliceWithOptions=ee;exports.createWorldSlice=be;
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});require("reflect-metadata");const m=require("./index-RPpT5kHy.cjs"),le=require("./runtimeFilter-W6iMw1pL.cjs"),b=require("./index-CJj-Z7Jr.cjs"),de=require("three"),p=require("./gaesupStore-2zKBYTYo.cjs"),W=require("./index-C7uc7Whg.cjs"),d=require("react/jsx-runtime"),x=require("./index-TNaPJQpb.cjs"),g=require("react"),ue=require("@react-three/fiber"),U=require("@react-three/rapier"),I=require("./index-De3ev_jU.cjs");function fe(s){const e=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(s){for(const t in s)if(t!=="default"){const r=Object.getOwnPropertyDescriptor(s,t);Object.defineProperty(e,t,r.get?r:{enumerable:!0,get:()=>s[t]})}}return e.default=s,Object.freeze(e)}const F=fe(de);class T{cellSize;cells=new Map;objectPositions=new Map;constructor(e={}){this.cellSize=e.cellSize??10}static zigZag(e){return e>=0?e*2:-e*2-1}static pair(e,t){const r=T.zigZag(e),a=T.zigZag(t),n=r+a;return n*(n+1)/2+a}getCellKey(e,t){const r=Math.floor(e/this.cellSize),a=Math.floor(t/this.cellSize);return T.pair(r,a)}add(e,t){this.remove(e);const r=this.getCellKey(t.x,t.z);this.cells.has(r)||this.cells.set(r,new Set),this.cells.get(r).add(e),this.objectPositions.set(e,t.clone())}remove(e){const t=this.objectPositions.get(e);if(t){const r=this.getCellKey(t.x,t.z),a=this.cells.get(r);a&&(a.delete(e),a.size===0&&this.cells.delete(r)),this.objectPositions.delete(e)}}update(e,t){const r=this.objectPositions.get(e);if(!r){this.add(e,t);return}if(r.equals(t))return;const a=this.getCellKey(r.x,r.z),n=this.getCellKey(t.x,t.z);if(a!==n){const i=this.cells.get(a);i&&(i.delete(e),i.size===0&&this.cells.delete(a));const o=this.cells.get(n)??new Set;o.add(e),this.cells.set(n,o)}r.copy(t)}getNearby(e,t,r){const a=r??[];r&&(r.length=0);const n=Math.ceil(t/this.cellSize),i=Math.floor(e.x/this.cellSize),o=Math.floor(e.z/this.cellSize),l=t*t;for(let f=i-n;f<=i+n;f++)for(let u=o-n;u<=o+n;u++){const h=T.pair(f,u),v=this.cells.get(h);if(v)for(const R of v){const S=this.objectPositions.get(R);if(!S)continue;const D=e.x-S.x,C=e.y-S.y,B=e.z-S.z;D*D+C*C+B*B<=l&&a.push(R)}}return a}clear(){this.cells.clear(),this.objectPositions.clear()}get size(){return this.objectPositions.size}}var pe=Object.defineProperty,ye=Object.getOwnPropertyDescriptor,L=(s,e,t,r)=>{for(var a=r>1?void 0:r?ye(e,t):e,n=s.length-1,i;n>=0;n--)(i=s[n])&&(a=(r?i(e,t,a):i(a))||a);return r&&a&&pe(e,t,a),a};exports.WorldSystem=class{objects=new Map;interactionEvents=[];spatial=new T({cellSize:10});raycaster=new F.Raycaster;tempVector=new F.Vector3;nearbyIds=[];nearbyIds2=[];async init(){}update(e){}dispose(){this.cleanup()}addObject(e){this.objects.set(e.id,e),this.spatial.add(e.id,e.position)}removeObject(e){return this.objects.get(e)&&this.spatial.remove(e),this.objects.delete(e)}getObject(e){return this.objects.get(e)}getAllObjects(){return Array.from(this.objects.values())}getObjectsByType(e){return this.getAllObjects().filter(t=>t.type===e)}updateObject(e,t){const r=this.objects.get(e);return r?(Object.assign(r,t),t.position&&this.spatial.update(e,t.position),!0):!1}getObjectsInRadius(e,t){const r=this.spatial.getNearby(e,t,this.nearbyIds),a=[];for(const n of r){const i=this.objects.get(n);i&&a.push(i)}return a}checkCollisions(e){const t=this.objects.get(e);if(!t||!t.boundingBox)return[];const r=t.boundingBox.max.distanceTo(t.boundingBox.min),a=this.spatial.getNearby(t.position,r,this.nearbyIds2),n=[];for(const i of a){if(i===e)continue;const o=this.objects.get(i);!o||!o.boundingBox||t.boundingBox.intersectsBox(o.boundingBox)&&n.push(o)}return n}processInteraction(e){this.interactionEvents.push(e),this.interactionEvents.length>1e3&&(this.interactionEvents=this.interactionEvents.slice(-500))}getRecentEvents(e=1e3){const t=Date.now();return this.interactionEvents.filter(r=>t-r.timestamp<=e)}raycast(e,t,r=100){this.raycaster.set(e,t),this.raycaster.near=0,this.raycaster.far=r;const a=this.spatial.getNearby(e,r,this.nearbyIds);for(const n of a){const i=this.objects.get(n);if(i&&i.boundingBox){const o=this.raycaster.ray.intersectBox(i.boundingBox,this.tempVector);if(o)return{object:i,distance:e.distanceTo(o),point:o.clone()}}}return null}cleanup(){this.objects.clear(),this.interactionEvents.length=0,this.spatial.clear()}};L([p.HandleError()],exports.WorldSystem.prototype,"init",1);L([p.Profile(),p.HandleError()],exports.WorldSystem.prototype,"update",1);L([p.HandleError()],exports.WorldSystem.prototype,"dispose",1);exports.WorldSystem=L([p.RegisterSystem("world")],exports.WorldSystem);var me=Object.defineProperty,ge=Object.getOwnPropertyDescriptor,z=(s,e,t,r)=>{for(var a=r>1?void 0:r?ge(e,t):e,n=s.length-1,i;n>=0;n--)(i=s[n])&&(a=(r?i(e,t,a):i(a))||a);return r&&a&&me(e,t,a),a};exports.WorldBridge=class extends b.CoreBridge{buildEngine(e,t){const r=new exports.WorldSystem,a={...t?.selectedObjectId!==void 0?{selectedObjectId:t.selectedObjectId}:{},interactionMode:t?.interactionMode??"view",showDebugInfo:t?.showDebugInfo??!1};return{system:r,state:a,dispose:()=>r.dispose()}}executeCommand(e,t,r){const{system:a,state:n}=e;switch(t.type){case"addObject":const{id:i,...o}=t.data,l=typeof i=="string"&&i.length>0?i:this.generateId(),f={...o,id:l};a.addObject(f);break;case"removeObject":a.removeObject(t.data.id),n.selectedObjectId===t.data.id&&delete n.selectedObjectId;break;case"updateObject":a.updateObject(t.data.id,t.data.updates);break;case"selectObject":t.data.id!==void 0?n.selectedObjectId=t.data.id:delete n.selectedObjectId;break;case"setInteractionMode":n.interactionMode=t.data.mode;break;case"toggleDebugInfo":n.showDebugInfo=!n.showDebugInfo;break;case"interact":const u=a.getObject(t.data.objectId);if(u&&u.canInteract){const h={type:"custom",object1Id:t.data.objectId,timestamp:Date.now(),data:{action:t.data.action}};a.processInteraction(h)}break;case"cleanup":a.cleanup(),delete n.selectedObjectId,n.interactionMode="view",n.showDebugInfo=!1;break}}createSnapshot(e,t){const{system:r,state:a}=e;return{objects:r.getAllObjects(),...a.selectedObjectId!==void 0?{selectedObjectId:a.selectedObjectId}:{},interactionMode:a.interactionMode,showDebugInfo:a.showDebugInfo,events:r.getRecentEvents(),objectsInRadius:(n,i)=>r.getObjectsInRadius(n,i),objectsByType:n=>r.getObjectsByType(n),raycast:(n,i)=>r.raycast(n,i)?.object||null}}addObject(e,t){const r=t.id,a=typeof r=="string"&&r.length>0?r:this.generateId();return this.execute(e,{type:"addObject",data:{...t,id:a}}),a}removeObject(e,t){this.execute(e,{type:"removeObject",data:{id:t}})}updateObject(e,t,r){this.execute(e,{type:"updateObject",data:{id:t,updates:r}})}selectObject(e,t){this.execute(e,{type:"selectObject",data:t!==void 0?{id:t}:{}})}setInteractionMode(e,t){this.execute(e,{type:"setInteractionMode",data:{mode:t}})}toggleDebugInfo(e){this.execute(e,{type:"toggleDebugInfo"})}interact(e,t,r){this.execute(e,{type:"interact",data:{objectId:t,action:r}})}cleanup(e){this.execute(e,{type:"cleanup"})}getObjectsInRadius(e,t,r){const a=this.getEngine(e);return a?a.system.getObjectsInRadius(t,r):[]}getObjectsByType(e,t){const r=this.getEngine(e);return r?r.system.getObjectsByType(t):[]}raycast(e,t,r){const a=this.getEngine(e);return a&&a.system.raycast(t,r)?.object||null}generateId(){return`world_${Date.now()}_${Math.random().toString(36).substr(2,9)}`}};z([b.ValidateCommand()],exports.WorldBridge.prototype,"executeCommand",1);z([b.LogSnapshot(),b.CacheSnapshot(16)],exports.WorldBridge.prototype,"createSnapshot",1);exports.WorldBridge=z([b.DomainBridge("world"),b.EnableEventLog()],exports.WorldBridge);const he={isRiderOn:!1,position:U.vec3(),rotation:U.euler(),offset:U.vec3(),visible:!0};function ve(){const{gameStates:s,updateGameStates:e,activeState:t}=b.useStateSystem(),r=p.useGaesupStore(c=>c.rideable),a=p.useGaesupStore(c=>c.urls),n=p.useGaesupStore(c=>c.setMode),i=p.useGaesupStore(c=>c.setRideable),o=p.useGaesupStore(c=>c.setUrls),{getSizesByUrls:l}=b.useGaesupGltf(),f=g.useCallback(c=>c==="airplane"?"airplane":"vehicle",[]),u=g.useCallback(c=>{const y={},j=c.ridingUrl??a.characterUrl;if(typeof j=="string"&&j.length>0&&(y.ridingUrl=j),c.objectType==="airplane"){y.airplaneUrl=c.url??"",o(y);return}c.objectType&&(y.vehicleUrl=c.url??"",y.wheelUrl=c.wheelUrl??""),o(y)},[o,a]),h=g.useCallback(c=>{const y=r[c];if(!y?.position)return;const j=y.objectType,{vehicleUrl:ie,airplaneUrl:oe,characterUrl:ce}=l({...a});!(j==="airplane"?oe:ie)||!ce||(e({canRide:!1,isRiding:!1,currentRideable:void 0}),i(c,{...y,visible:!0,position:t.position.clone()}))},[r,l,a,e,i,t.position]),v=g.useCallback(async()=>{if(s.canRide&&s.nearbyRideable&&!s.isRiding){const{objectkey:c,objectType:y}=s.nearbyRideable,j=r[c];if(!j)return;u(j),n({type:f(y)}),e({currentRideable:s.nearbyRideable,isRiding:!0,canRide:!1,nearbyRideable:void 0}),i(c,{...j,visible:!1})}},[s.canRide,s.nearbyRideable,s.isRiding,r,u,n,f,e,i]),R=g.useCallback(async()=>{s.isRiding&&s.currentRideable&&(h(s.currentRideable.objectkey),n({type:"character"}),e({isRiding:!1,currentRideable:void 0}))},[s.isRiding,s.currentRideable,h,n,e]);g.useEffect(()=>{const c=y=>{y.code==="KeyF"&&(s.canRide&&s.nearbyRideable?v():s.isRiding&&R())};return window.addEventListener("keydown",c),()=>window.removeEventListener("keydown",c)},[s.canRide,s.nearbyRideable,s.isRiding,v,R]);const S=g.useCallback(c=>{i(c.objectkey,{...he,...c})},[i]),D=g.useCallback(c=>{i(c.objectkey,c)},[i]),C=c=>r[c],B=g.useCallback(async(c,y)=>{if((c.other.rigidBodyObject&&c.other.rigidBodyObject.name==="character"||c.other.rigidBodyObject&&!c.other.rigidBodyObject.name||c.other.rigidBody)&&!s.isRiding){if(!y.objectType)return;e({nearbyRideable:{id:y.objectkey,objectkey:y.objectkey,objectType:y.objectType,type:"rideable",maxSpeed:0,acceleration:0,deceleration:0,isOccupied:!1,controls:{forward:!1,backward:!1,left:!1,right:!1,brake:!1},name:y.objectType==="vehicle"?"차량":"비행기",...y.rideMessage?{rideMessage:y.rideMessage}:{},...y.exitMessage?{exitMessage:y.exitMessage}:{},...y.displayName?{displayName:y.displayName}:{}},canRide:!0})}},[s.isRiding,e]),M=g.useCallback(async c=>{(c.other.rigidBodyObject&&c.other.rigidBodyObject.name==="character"||c.other.rigidBodyObject&&!c.other.rigidBodyObject.name||c.other.rigidBody)&&e({nearbyRideable:void 0,canRide:!1})},[e]);return{initRideable:S,updateRideable:D,getRideable:C,onRideableNear:B,onRideableLeave:M,enterRideable:v,exitRideable:R,landing:h}}const E="default",be=s=>{const e=p.BridgeFactory.getOrCreate("world");if(e){e.register(E);const t=e;t.__gaesupWorldSliceUnsubscribe?.(),t.__gaesupWorldSliceUnsubscribe=e.subscribe(r=>{s({objects:r.objects,selectedObjectId:r.selectedObjectId,interactionMode:r.interactionMode,showDebugInfo:r.showDebugInfo,events:r.events,loading:!1,error:void 0})})}return{objects:[],selectedObjectId:void 0,interactionMode:"view",showDebugInfo:!1,events:[],loading:!1,error:void 0,addObject:t=>{if(!e)return"";s({loading:!0,error:void 0});try{const r=e.addObject(E,t);return s({loading:!1}),r}catch(r){return s({loading:!1,error:r instanceof Error?r.message:"Unknown error"}),""}},removeObject:t=>{if(!e)return!1;s({loading:!0,error:void 0});try{return e.removeObject(E,t),s({loading:!1}),!0}catch(r){return s({loading:!1,error:r instanceof Error?r.message:"Unknown error"}),!1}},updateObject:(t,r)=>{if(!e)return!1;s({loading:!0,error:void 0});try{return e.updateObject(E,t,r),s({loading:!1}),!0}catch(a){return s({loading:!1,error:a instanceof Error?a.message:"Unknown error"}),!1}},selectObject:t=>{e&&e.selectObject(E,t)},setInteractionMode:t=>{e&&e.setInteractionMode(E,t)},toggleDebugInfo:()=>{e&&e.toggleDebugInfo(E)},setLoading:t=>{s({loading:t})},setError:t=>{s({error:t})},clearEvents:()=>{s({events:[]})},getBridge:()=>e,getObjectsInRadius:(t,r)=>e?e.getObjectsInRadius(E,t,r):[],getObjectsByType:t=>e?e.getObjectsByType(E,t):[],raycast:(t,r)=>e?e.raycast(E,t,r):null,interact:(t,r)=>{e&&e.interact(E,t,r)},cleanup:()=>{e&&e.cleanup(E)}}};var Se=Object.defineProperty,Re=Object.getOwnPropertyDescriptor,O=(s,e,t,r)=>{for(var a=Re(e,t),n=s.length-1,i;n>=0;n--)(i=s[n])&&(a=i(e,t,a)||a);return a&&Se(e,t,a),a};const we="1.0.0",P="gaesup_world_save_",G="base64-json:",Z="gaesup-world:gzip-json:v1";class w{version;storage;fileWriter;now;constructor(e={}){this.version=e.version??we,this.storage=e.storage,this.fileWriter=e.fileWriter,this.now=e.now??Date.now}async save(e,t,r={}){try{const a=this.createSaveData(e,t,r);return r.compress?await this.saveCompressed(a):await this.saveUncompressed(a)}catch(a){return{success:!1,error:a instanceof Error?a.message:"Unknown error occurred"}}}async load(e,t={}){try{const r=`${P}${e}`,a=this.getStorage().getItem(r);if(!a)throw new Error(`Save data not found: ${e}`);const n=await this.parseStoredSaveData(a);if(!this.validateSaveData(n))throw new Error("Invalid save data format");return{success:!0,data:{...n,world:this.filterWorldData(n.world,t)}}}catch(r){return{success:!1,error:r instanceof Error?r.message:"Failed to load save data"}}}async saveToFile(e,t,r,a={}){try{const n=this.createSaveData(e,r,a);return await this.writeFile(t,n),{success:!0,data:n}}catch(n){return{success:!1,error:n instanceof Error?n.message:"Failed to save file"}}}async loadFromFile(e,t={}){try{const r=await e.text(),a=JSON.parse(r);if(!this.validateSaveData(a))throw new Error("Invalid save file format");return{success:!0,data:{...a,world:this.filterWorldData(a.world,t)}}}catch(r){return{success:!1,error:r instanceof Error?r.message:"Failed to load file"}}}listSaves(){const e=[];let t;try{t=this.getStorage()}catch(r){return console.error("Failed to list saves:",r),e}for(let r=0;r<t.length;r++){const a=t.key(r);if(a&&a.startsWith(P))try{const n=a.substring(P.length),i=t.getItem(a);if(i){const o=this.parseStoredSaveDataSync(i);e.push({id:n,timestamp:o.timestamp,...o.metadata?{metadata:o.metadata}:{}})}}catch(n){console.error(`Failed to parse save: ${a}`,n)}}return e.sort((r,a)=>a.timestamp-r.timestamp)}deleteSave(e){try{const t=`${P}${e}`;return this.getStorage().removeItem(t),!0}catch(t){return console.error("Failed to delete save:",t),!1}}filterWorldData(e,t){const r={...e};return t.includeBuildings===!1&&(r.buildings={wallGroups:[],tileGroups:[],blocks:[],meshes:[]}),t.includeNPCs===!1&&(r.npcs=[]),t.includeEnvironment===!1&&(r.environment={lighting:{ambientIntensity:1,directionalIntensity:1,directionalPosition:{x:0,y:10,z:0}}}),t.includeCamera===!1&&delete r.camera,r}createSaveData(e,t,r={}){const a=this.now();return{version:this.version,timestamp:a,world:this.filterWorldData(e,r),...t?{metadata:{...t,createdAt:t.createdAt||a,updatedAt:a}}:{}}}getStorage(){if(this.storage)return this.storage;if(typeof localStorage>"u")throw new Error("Legacy save storage is not available in this environment");return localStorage}async writeFile(e,t){if(this.fileWriter){await this.fileWriter(e,t);return}if(typeof document>"u"||typeof URL>"u"||typeof Blob>"u")throw new Error("File download is not available in this environment");const r=new Blob([JSON.stringify(t,null,2)],{type:"application/json"}),a=URL.createObjectURL(r),n=document.createElement("a");n.href=a,n.download=e.endsWith(".json")?e:`${e}.json`,document.body.appendChild(n),n.click(),document.body.removeChild(n),URL.revokeObjectURL(a)}async saveUncompressed(e){const t=`${e.world.id}_${e.timestamp}`,r=`${P}${t}`;try{return this.getStorage().setItem(r,JSON.stringify(e)),{success:!0,data:e}}catch(a){throw a instanceof Error&&a.name==="QuotaExceededError"?new Error("Storage quota exceeded. Please delete some saves."):a}}async saveCompressed(e){const t=await this.compressData(e),r=`${e.world.id}_${e.timestamp}`,a=`${P}${r}`;try{return this.getStorage().setItem(a,t),{success:!0,data:e}}catch(n){throw n instanceof Error&&n.name==="QuotaExceededError"?new Error("Storage quota exceeded. Please delete some saves."):n}}async compressData(e){const t=JSON.stringify(e);if(!H())return`${G}${$(V(t))}`;const r=await this.gzipBytes(V(t)),a={encoding:Z,version:e.version,timestamp:e.timestamp,worldId:e.world.id,worldName:e.world.name,...e.metadata?{metadata:e.metadata}:{},payload:$(r)};return JSON.stringify(a)}async decompressData(e){const t=X(e),r=await this.gunzipBytes(t),a=Q(r);return JSON.parse(a)}async parseStoredSaveData(e){if(e.startsWith("{")){const t=JSON.parse(e);return q(t)?this.decompressData(t.payload):t}return e.startsWith(G)?_(e.slice(G.length)):_(e)}parseStoredSaveDataSync(e){if(e.startsWith("{")){const t=JSON.parse(e);return q(t)?{version:t.version,timestamp:t.timestamp,world:{id:t.worldId,name:t.worldName,buildings:{wallGroups:[],tileGroups:[],blocks:[],meshes:[]},npcs:[],environment:{lighting:{ambientIntensity:1,directionalIntensity:1,directionalPosition:{x:0,y:10,z:0}}}},...t.metadata?{metadata:t.metadata}:{}}:t}return e.startsWith(G)?_(e.slice(G.length)):_(e)}async gzipBytes(e){if(!H())return e;const t=new Blob([e]).stream().pipeThrough(new CompressionStream("gzip"));return new Uint8Array(await new Response(t).arrayBuffer())}async gunzipBytes(e){if(!Ee())return e;const t=new Blob([e]).stream().pipeThrough(new DecompressionStream("gzip"));return new Uint8Array(await new Response(t).arrayBuffer())}validateSaveData(e){return e!==null&&typeof e=="object"&&"version"in e&&"timestamp"in e&&"world"in e&&typeof e.version=="string"&&typeof e.timestamp=="number"&&e.world&&typeof e.world.id=="string"&&typeof e.world.name=="string"}}O([p.HandleError(),p.Profile(),p.Timeout(5e3)],w.prototype,"save");O([p.HandleError(),p.Profile(),p.Timeout(5e3)],w.prototype,"load");O([p.HandleError(),p.Profile()],w.prototype,"saveToFile");O([p.HandleError(),p.Profile()],w.prototype,"loadFromFile");O([p.MonitorMemory(10)],w.prototype,"listSaves");O([p.HandleError()],w.prototype,"deleteSave");O([p.Profile()],w.prototype,"filterWorldData");O([p.Profile()],w.prototype,"createSaveData");O([p.HandleError()],w.prototype,"saveUncompressed");O([p.HandleError()],w.prototype,"saveCompressed");O([p.Profile()],w.prototype,"compressData");O([p.Profile()],w.prototype,"decompressData");function $(s){let e="";for(let r=0;r<s.length;r+=32768)e+=String.fromCharCode(...s.subarray(r,r+32768));return btoa(e)}function X(s){const e=atob(s),t=new Uint8Array(e.length);for(let r=0;r<e.length;r+=1)t[r]=e.charCodeAt(r);return t}function _(s){return JSON.parse(Q(X(s)))}function V(s){if(typeof TextEncoder<"u")return new TextEncoder().encode(s);const e=unescape(encodeURIComponent(s)),t=new Uint8Array(e.length);for(let r=0;r<e.length;r+=1)t[r]=e.charCodeAt(r);return t}function Q(s){if(typeof TextDecoder<"u")return new TextDecoder().decode(s);let e="";const t=32768;for(let r=0;r<s.length;r+=t)e+=String.fromCharCode(...s.subarray(r,r+t));return decodeURIComponent(escape(e))}function H(){return typeof CompressionStream<"u"&&typeof Blob<"u"&&typeof Response<"u"&&typeof new Blob().stream=="function"}function Ee(){return typeof DecompressionStream<"u"&&typeof Blob<"u"&&typeof Response<"u"&&typeof new Blob().stream=="function"}function q(s){if(!s||typeof s!="object")return!1;const e=s;return e.encoding===Z&&typeof e.version=="string"&&typeof e.timestamp=="number"&&typeof e.worldId=="string"&&typeof e.worldName=="string"&&typeof e.payload=="string"}const Oe=()=>({});function J(s,e,t){const{buildingStore:r,npcStore:a,cameraStore:n}=s;if(!r)throw new Error("Building store not initialized");const i=r.getState(),o=n?.getState(),l=o?{position:o.position,rotation:o.rotation,mode:o.mode,...o.settings?{settings:o.settings}:{}}:void 0;return{id:e,name:t,buildings:{wallGroups:Array.from(i.wallGroups.values()),tileGroups:Array.from(i.tileGroups.values()),blocks:Array.from(i.blocks),meshes:Array.from(i.meshes.values())},npcs:a?Array.from(a.getState().instances.values()):[],environment:m.DEFAULT_WORLD_SAVE_ENVIRONMENT,...l?{camera:l}:{}}}function je(s,e){if(!s||!e)return;const t=s.getState();if(typeof t.hydrate=="function"){t.hydrate(e);return}t.wallGroups.clear(),t.tileGroups.clear(),t.meshes.clear(),t.blocks=[],e.wallGroups.forEach(r=>{t.wallGroups.set(r.id,r)}),e.tileGroups.forEach(r=>{t.tileGroups.set(r.id,r)}),e.meshes.forEach(r=>{t.meshes.set(r.id,r)}),t.blocks=[...e.blocks??[]]}function xe(s,e){if(!s||!e)return;const t=s.getState();t.instances.clear(),e.forEach(r=>{t.instances.set(r.id,r)})}function Ie(s,e){!s||!e||s.setState({position:e.position,rotation:e.rotation,mode:e.mode,settings:e.settings||{}})}function K(s,e){je(s.buildingStore,e.buildings),xe(s.npcStore,e.npcs),Ie(s.cameraStore,e.camera)}function k(s){return typeof s=="object"&&s!==null&&!Array.isArray(s)}function De(s){return s.replace(/\.json$/i,"")}function Y(s){return k(s)&&typeof s.version=="number"&&typeof s.savedAt=="number"&&k(s.domains)}function A(s){return k(s)&&s.kind==="gaesup.save-system"&&typeof s.worldId=="string"&&typeof s.worldName=="string"&&Y(s.blob)}async function N(s){return(await s.list()).map(t=>({id:t,timestamp:m.parseWorldSaveTimestamp(t)})).sort((t,r)=>r.timestamp-t.timestamp)}function Ce(s,e){if(typeof document>"u"||typeof URL>"u"||typeof Blob>"u")throw new Error("File download is not available in this environment");const t=new Blob([JSON.stringify(e,null,2)],{type:"application/json"}),r=URL.createObjectURL(t),a=document.createElement("a");a.href=r,a.download=s.endsWith(".json")?s:`${s}.json`,document.body.appendChild(a),a.click(),document.body.removeChild(a),URL.revokeObjectURL(r)}async function Be(s){const e=JSON.parse(await s.text());if(A(e)||Y(e))return e;throw new Error("Invalid SaveSystem file format")}function ee(s={}){const e=s.getStores??Oe,t=s.saveSystem;return(r,a)=>({saveLoadManager:s.saveLoadManager??new w,currentSaveId:null,saves:[],isSaving:!1,isLoading:!1,lastError:null,saveWorld:async(n,i,o,l)=>{r({isSaving:!0,lastError:null});try{if(t){const h=Date.now(),v=`${n}_${h}`;await t.save(v),r({currentSaveId:v,saves:await N(t)});return}const f=J(e(),n,i),u=await a().saveLoadManager.save(f,o,l);if(u.success){const h=`${n}_${u.data.timestamp}`;r({currentSaveId:h}),a().refreshSaveList()}else throw new Error(u.error)}catch(f){throw r({lastError:f instanceof Error?f.message:"Save failed"}),f}finally{r({isSaving:!1})}},loadWorld:async(n,i)=>{r({isLoading:!0,lastError:null});try{if(t){if(!await t.load(n))throw new Error(`Save data not found: ${n}`);return r({currentSaveId:n}),m.createSaveDataFromSaveSystem(t,n)}const o=await a().saveLoadManager.load(n,i);if(o.success&&o.data)return K(e(),o.data.world),r({currentSaveId:n}),o.data;throw new Error(o.error)}catch(o){return r({lastError:o instanceof Error?o.message:"Load failed"}),null}finally{r({isLoading:!1})}},saveToFile:async(n,i,o,l,f)=>{r({isSaving:!0,lastError:null});try{if(t){const v={kind:"gaesup.save-system",version:1,worldId:n,worldName:i,blob:t.createBlob(o),...l?{metadata:l}:{}};Ce(o,v);return}const u=J(e(),n,i),h=await a().saveLoadManager.saveToFile(u,o,l,f);if(!h.success)throw new Error(h.error)}catch(u){throw r({lastError:u instanceof Error?u.message:"Save to file failed"}),u}finally{r({isSaving:!1})}},loadFromFile:async(n,i)=>{r({isLoading:!0,lastError:null});try{if(t){const l=await Be(n),f=A(l)?l.blob:l;t.hydrateBlob(f,n.name);const u=A(l)?l.worldId:De(n.name),h=A(l)?l.worldName:u,v=f.savedAt,R={version:String(f.version),timestamp:v,world:m.createWorldDataFromSaveDomains(f.domains,u,h)},S=A(l)?m.normalizeSaveMetadata(l.metadata,v):void 0;return S?{...R,metadata:S}:R}const o=await a().saveLoadManager.loadFromFile(n,i);if(o.success&&o.data)return K(e(),o.data.world),o.data;throw new Error(o.error)}catch(o){return r({lastError:o instanceof Error?o.message:"Load from file failed"}),null}finally{r({isLoading:!1})}},refreshSaveList:()=>{if(t){N(t).then(i=>r({saves:i})).catch(i=>{r({lastError:i instanceof Error?i.message:"Failed to list saves"})});return}const n=a().saveLoadManager.listSaves();r({saves:n})},deleteSave:n=>{if(t){(async()=>{try{await t.remove(n);const o=await N(t);r({saves:o,...a().currentSaveId===n?{currentSaveId:null}:{}})}catch(o){r({lastError:o instanceof Error?o.message:"Failed to delete save"})}})();return}a().saveLoadManager.deleteSave(n)&&(a().refreshSaveList(),a().currentSaveId===n&&r({currentSaveId:null}))},clearError:()=>{r({lastError:null})}})}const Pe=ee();function te({object:s,selected:e=!1,onSelect:t,showDebugInfo:r=!1}){const a=x.useGenericRefs(),n=s.metadata?.airplaneUrl??s.metadata?.modelUrl,i=typeof n=="string"?n:void 0;if(typeof i!="string"||i.length===0)return null;const o=s.metadata?.ridingUrl,l=typeof o=="string"?o:void 0,f=s.metadata?.currentAnimation,u=typeof f=="string"?f:"idle";return d.jsx(b.PhysicsEntity,{url:i,isActive:!1,componentType:"airplane",name:`active-airplane-${s.id}`,position:s.position,rotation:s.rotation,scale:s.scale,currentAnimation:u,...l?{ridingUrl:l}:{},ref:a.rigidBodyRef,outerGroupRef:a.outerGroupRef,innerGroupRef:a.innerGroupRef,colliderRef:a.colliderRef,userData:{id:s.id,type:"active",subType:"airplane",health:s.health,maxHealth:s.maxHealth,energy:s.energy,maxEnergy:s.maxEnergy},onCollisionEnter:()=>{t&&t(s.id)},children:e&&r&&d.jsxs("mesh",{position:[0,3,0],children:[d.jsx("boxGeometry",{args:[.5,.5,.5]}),d.jsx("meshStandardMaterial",{color:"#00ffff",transparent:!0,opacity:.6})]})})}function re({object:s,selected:e=!1,onSelect:t,showDebugInfo:r=!1}){const a=x.useGenericRefs();g.useEffect(()=>{a.rigidBodyRef&&a.rigidBodyRef.current&&a.rigidBodyRef.current.setEnabledRotations(!1,!1,!1,!1)},[a.rigidBodyRef]);const n=s.metadata?.characterUrl;if(typeof n!="string"||n.length===0)return null;const i=s.metadata?.currentAnimation,o=typeof i=="string"?i:"idle",l=s.metadata?.nameTag,f=typeof l=="string"?l:void 0;return d.jsx(b.PhysicsEntity,{url:n,isActive:!1,componentType:"character",name:`active-character-${s.id}`,position:s.position,rotation:s.rotation,scale:s.scale,currentAnimation:o,ref:a.rigidBodyRef,outerGroupRef:a.outerGroupRef,innerGroupRef:a.innerGroupRef,colliderRef:a.colliderRef,userData:{id:s.id,type:"active",subType:"character",health:s.health,maxHealth:s.maxHealth,energy:s.energy,maxEnergy:s.maxEnergy,nameTag:f},onCollisionEnter:()=>{t&&t(s.id)},children:e&&r&&d.jsxs("mesh",{position:[0,3,0],children:[d.jsx("boxGeometry",{args:[.5,.5,.5]}),d.jsx("meshStandardMaterial",{color:"#ff0000",transparent:!0,opacity:.6})]})})}function se({object:s,selected:e=!1,onSelect:t,showDebugInfo:r=!1}){const a=x.useGenericRefs(),n=s.metadata?.vehicleUrl??s.metadata?.modelUrl,i=typeof n=="string"?n:void 0;if(typeof i!="string"||i.length===0)return null;const o=s.metadata?.ridingUrl,l=typeof o=="string"?o:void 0,f=s.metadata?.currentAnimation,u=typeof f=="string"?f:"idle";return d.jsx(b.PhysicsEntity,{url:i,isActive:!1,componentType:"vehicle",name:`active-vehicle-${s.id}`,position:s.position,rotation:s.rotation,scale:s.scale,currentAnimation:u,...l?{ridingUrl:l}:{},ref:a.rigidBodyRef,outerGroupRef:a.outerGroupRef,innerGroupRef:a.innerGroupRef,colliderRef:a.colliderRef,userData:{id:s.id,type:"active",subType:"vehicle",health:s.health,maxHealth:s.maxHealth,energy:s.energy,maxEnergy:s.maxEnergy},onCollisionEnter:()=>{t&&t(s.id)},children:e&&r&&d.jsxs("mesh",{position:[0,3,0],children:[d.jsx("boxGeometry",{args:[.5,.5,.5]}),d.jsx("meshStandardMaterial",{color:"#0000ff",transparent:!0,opacity:.6})]})})}function Te({objects:s,selectedId:e,onSelect:t,showDebugInfo:r=!1}){const{gameStates:a}=b.useStateSystem(),n=p.useGaesupStore(i=>i.mode);return d.jsx("group",{name:"active-objects",children:s.map(i=>{const o=i.id===e;if(i.type==="character"&&a?.isRiding&&n?.type!=="character")return null;switch(i.type){case"vehicle":return d.jsx(se,{object:i,selected:o,...t?{onSelect:t}:{},showDebugInfo:r},i.id);case"airplane":return d.jsx(te,{object:i,selected:o,...t?{onSelect:t}:{},showDebugInfo:r},i.id);case"character":return d.jsx(re,{object:i,selected:o,...t?{onSelect:t}:{},showDebugInfo:r},i.id);default:return null}})})}function ae(s){const{children:e,visible:t=!0,...r}=s,a=x.useGenericRefs();return d.jsx("group",{visible:t,children:d.jsx(b.PhysicsEntity,{...r,url:r.url||"",isActive:!1,componentType:"vehicle",name:r.name??"vehicle",ref:a.rigidBodyRef,outerGroupRef:a.outerGroupRef,innerGroupRef:a.innerGroupRef,colliderRef:a.colliderRef,children:e})})}function ne(s){const{children:e,visible:t=!0,...r}=s,a=x.useGenericRefs();return d.jsx("group",{visible:t,children:d.jsx(b.PhysicsEntity,{...r,url:r.url||"",isActive:!1,componentType:"airplane",name:r.name??"airplane",ref:a.rigidBodyRef,outerGroupRef:a.outerGroupRef,innerGroupRef:a.innerGroupRef,colliderRef:a.colliderRef,children:e})})}function Ge(s){const{children:e,visible:t=!0,...r}=s,a=x.useGenericRefs();g.useEffect(()=>{a.rigidBodyRef&&a.rigidBodyRef.current&&a.rigidBodyRef.current.setEnabledRotations(!1,!1,!1,!1)},[a.rigidBodyRef]);const n=r.controllerOptions??{lerp:{cameraTurn:1,cameraPosition:1}};return d.jsx("group",{visible:t,children:d.jsx(b.PhysicsEntity,{...r,url:r.url||"",isActive:!1,componentType:"character",controllerOptions:n,ref:a.rigidBodyRef,outerGroupRef:a.outerGroupRef,innerGroupRef:a.innerGroupRef,colliderRef:a.colliderRef,children:e})})}const Ae=150*150,Ue=g.memo(function({object:e,isSelected:t,onSelect:r,showDebugInfo:a=!1,enableInteraction:n=!0}){const i=x.useGenericRefs(),o=e.metadata?.modelUrl,l=typeof o=="string"?o:void 0,f=g.useCallback(()=>{n&&e.interactable&&r&&r(e.id)},[n,e.interactable,e.id,r]),u=g.useCallback(v=>{n&&e.interactable&&(v.stopPropagation(),document.body.style.cursor="pointer")},[n,e.interactable]),h=g.useCallback(()=>{document.body.style.cursor="default"},[]);return l?d.jsx(b.PhysicsEntity,{url:l,isActive:!1,componentType:e.type,name:`passive-${e.type}-${e.id}`,position:e.position,rotation:e.rotation,scale:e.scale,ref:i.rigidBodyRef,outerGroupRef:i.outerGroupRef,innerGroupRef:i.innerGroupRef,colliderRef:i.colliderRef,userData:{id:e.id,type:"passive",subType:e.type,interactable:e.interactable,onNear:e.metadata?.onNear,onLeave:e.metadata?.onLeave,onInteract:e.metadata?.onInteract},onCollisionEnter:()=>{n&&e.interactable&&r&&r(e.id)},children:t&&a&&d.jsxs("mesh",{position:[0,3,0],children:[d.jsx("boxGeometry",{args:[.5,.5,.5]}),d.jsx("meshStandardMaterial",{color:"#00ff00",transparent:!0,opacity:.6})]})}):d.jsxs(U.RigidBody,{type:"fixed",position:e.position,rotation:e.rotation,colliders:!1,children:[d.jsx(U.CapsuleCollider,{args:[1,.5],position:[0,1,0]}),d.jsx("group",{scale:e.scale,onClick:f,onPointerEnter:u,onPointerLeave:h})]})}),Me=g.memo(function({objects:e,selectedId:t,onSelect:r,showDebugInfo:a=!1,enableInteraction:n=!0}){const[i,o]=g.useState(()=>new Set),l=g.useRef(0);ue.useFrame((u,h)=>{if(l.current+=h,l.current<.5)return;l.current=0;const v=u.camera.position,R=new Set;for(const S of e){const D=S.position.x,C=S.position.y,B=S.position.z,M=D-v.x,c=C-v.y,y=B-v.z;M*M+c*c+y*y<=Ae&&R.add(S.id)}(R.size!==i.size||[...R].some(S=>!i.has(S)))&&o(R)});const f=g.useMemo(()=>e.filter(u=>i.has(u.id)).map(u=>d.jsx(Ue,{object:u,isSelected:u.id===t,...r?{onSelect:r}:{},showDebugInfo:a,enableInteraction:n},u.id)),[e,t,r,a,n,i]);return d.jsx("group",{name:"passive-objects",children:f})});function _e({states:s}){if(!s||!s.canRide&&!s.isRiding)return null;const e=s.nearbyRideable?.rideMessage??`Press F to ride ${s.nearbyRideable?.displayName??s.nearbyRideable?.name??"vehicle"}`,t=s.nearbyRideable?.exitMessage??"Press F to exit";return d.jsx("div",{className:"rideable-ui-container",children:d.jsxs("div",{className:"message-box",children:[s.canRide&&d.jsx("div",{children:e}),s.isRiding&&d.jsx("div",{children:t})]})})}function We(s){const e=p.useGaesupStore(u=>u.rideable),{initRideable:t,onRideableNear:r,onRideableLeave:a,landing:n}=ve();g.useEffect(()=>{t(s)},[s,t]);const{controllerOptions:i,...o}=s,l=i?.lerp?{lerp:{cameraTurn:i.lerp.cameraTurn??1,cameraPosition:i.lerp.cameraPosition??1}}:void 0,f={objectType:s.objectType,objectkey:s.objectkey,rideable:!0,init:t,onNear:r,onLeave:a,landing:n,rideMessage:s.rideMessage,exitMessage:s.exitMessage,displayName:s.displayName};return d.jsxs(d.Fragment,{children:[s.objectType==="vehicle"&&d.jsx(ae,{...o,...l?{controllerOptions:l}:{},userData:f,sensor:!0,visible:!e[s.objectkey]?.isOccupied}),s.objectType==="airplane"&&d.jsx(ne,{...o,...l?{controllerOptions:l}:{},userData:f,sensor:!0,visible:!e[s.objectkey]?.isOccupied})]})}exports.BugSpot=m.BugSpot;exports.DEFAULT_RUNTIME_SAVE_DIAGNOSTICS_SERVICE_ID=m.DEFAULT_RUNTIME_SAVE_DIAGNOSTICS_SERVICE_ID;exports.DEFAULT_WORLD_SAVE_ENVIRONMENT=m.DEFAULT_WORLD_SAVE_ENVIRONMENT;exports.FishSpot=m.FishSpot;exports.RUNTIME_SAVE_DIAGNOSTIC_EVENT=m.RUNTIME_SAVE_DIAGNOSTIC_EVENT;exports.TreeObject=m.TreeObject;exports.createCameraSaveDataFromDomain=m.createCameraSaveDataFromDomain;exports.createGaesupRuntime=m.createGaesupRuntime;exports.createRuntimeSaveDiagnostics=m.createRuntimeSaveDiagnostics;exports.createSaveDataFromSaveSystem=m.createSaveDataFromSaveSystem;exports.createWorldDataFromSaveDomains=m.createWorldDataFromSaveDomains;exports.formatRuntimeSaveDiagnostic=m.formatRuntimeSaveDiagnostic;exports.normalizeSaveMetadata=m.normalizeSaveMetadata;exports.parseWorldSaveId=m.parseWorldSaveId;exports.parseWorldSaveTimestamp=m.parseWorldSaveTimestamp;exports.useAutoSave=m.useAutoSave;exports.useLoadOnMount=m.useLoadOnMount;exports.shouldSetupPluginForRuntime=le.shouldSetupPluginForRuntime;exports.GaesupRuntimeProvider=b.GaesupRuntimeProvider;exports.useGaesupRuntime=b.useGaesupRuntime;exports.useGaesupRuntimeRevision=b.useGaesupRuntimeRevision;exports.GaesupWorldContent=W.GaesupWorldContent;exports.World=W.WorldContainer;exports.WorldConfigProvider=W.WorldConfigProvider;exports.WorldContainer=W.WorldContainer;exports.DuplicateSaveDomainBindingError=I.DuplicateSaveDomainBindingError;exports.IndexedDBAdapter=I.IndexedDBAdapter;exports.LocalStorageAdapter=I.LocalStorageAdapter;exports.SaveSystem=I.SaveSystem;exports.WorldProps=I.WorldProps;exports.createDefaultSaveSystem=I.createDefaultSaveSystem;exports.getSaveSystem=I.getSaveSystem;exports.ActiveObjects=Te;exports.Airplane=te;exports.Character=re;exports.PassiveAirplane=ne;exports.PassiveCharacter=Ge;exports.PassiveObjects=Me;exports.PassiveVehicle=ae;exports.Rideable=We;exports.RideableUI=_e;exports.SaveLoadManager=w;exports.Vehicle=se;exports.createPersistenceSlice=Pe;exports.createPersistenceSliceWithOptions=ee;exports.createWorldSlice=be;
|
package/dist/runtime.js
CHANGED
|
@@ -1,18 +1,18 @@
|
|
|
1
1
|
import "reflect-metadata";
|
|
2
|
-
import { c as le, n as de, a as ue, p as fe, D as pe } from "./index-
|
|
3
|
-
import { B as Et, d as Ot, F as It, R as jt, T as Dt, g as xt, b as Bt, e as Tt, f as Ut, h as Ct, u as Mt, i as At } from "./index-
|
|
2
|
+
import { c as le, n as de, a as ue, p as fe, D as pe } from "./index-B0oz8u47.js";
|
|
3
|
+
import { B as Et, d as Ot, F as It, R as jt, T as Dt, g as xt, b as Bt, e as Tt, f as Ut, h as Ct, u as Mt, i as At } from "./index-B0oz8u47.js";
|
|
4
4
|
import { s as Gt } from "./runtimeFilter-CS35UPHd.js";
|
|
5
5
|
import { $ as ye, a0 as ge, a1 as me, a2 as he, a3 as ve, a4 as be, V as Y, a5 as Se, _ as D } from "./index-C5agFfBe.js";
|
|
6
6
|
import { T as zt, a6 as Lt, a7 as Nt } from "./index-C5agFfBe.js";
|
|
7
7
|
import * as V from "three";
|
|
8
8
|
import { H as E, P as O, R as Re, u as I, B as we, T as ee, a as Ee } from "./gaesupStore-DTu0tYBp.js";
|
|
9
|
-
import { G as kt, W as Wt, a as $t, W as Vt } from "./index-
|
|
9
|
+
import { G as kt, W as Wt, a as $t, W as Vt } from "./index-3WAK67Ha.js";
|
|
10
10
|
import { jsx as f, jsxs as j, Fragment as Oe } from "react/jsx-runtime";
|
|
11
|
-
import { u as x } from "./index-
|
|
11
|
+
import { u as x } from "./index-DRLvJF_k.js";
|
|
12
12
|
import { useCallback as S, useEffect as N, memo as te, useState as Ie, useRef as je, useMemo as De } from "react";
|
|
13
13
|
import { useFrame as xe } from "@react-three/fiber";
|
|
14
14
|
import { vec3 as J, euler as Be, RigidBody as Te, CapsuleCollider as Ue } from "@react-three/rapier";
|
|
15
|
-
import { D as Kt, I as Ht, L as Zt, S as qt, W as Xt, c as Qt, g as Yt } from "./index-
|
|
15
|
+
import { D as Kt, I as Ht, L as Zt, S as qt, W as Xt, c as Qt, g as Yt } from "./index-DGifA0e6.js";
|
|
16
16
|
class M {
|
|
17
17
|
cellSize;
|
|
18
18
|
cells = /* @__PURE__ */ new Map();
|
package/package.json
CHANGED
package/dist/index-CHoKlv0U.cjs
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
"use strict";const s=require("react/jsx-runtime"),p=require("react"),A=require("three"),O=require("@react-three/drei"),w=require("./index-CJj-Z7Jr.cjs"),z=require("@react-three/fiber"),E=require("./gaesupStore-2zKBYTYo.cjs"),T=require("@react-three/rapier"),D=require("./index-D1hpjfAw.cjs");function U(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 P=U(A),q=()=>({position:new P.Vector3(0,0,0),velocity:new P.Vector3(0,0,0),rotation:new P.Euler(0,0,0),isMoving:!1,isGrounded:!1,speed:0,height:2});function G(e={}){const{updateInterval:d=0,entityId:a}=e,c=p.useRef(null);c.current||(c.current=q());const[,f]=p.useState(0),n=p.useRef(0),R=p.useRef(0),m=p.useRef({x:0,y:0,z:0}),h=p.useRef(void 0),S=p.useRef(null),{activeState:v,gameStates:b}=w.useStateSystem(),u=y=>{if(a)return a;if(h.current)return h.current;const r=y.getActiveEntities();return h.current=r[0],h.current};return p.useEffect(()=>{h.current=void 0,S.current=E.BridgeFactory.getOrCreate("motion");const y=S.current;if(!y)return;const r=y.subscribe((o,g)=>{const l=u(y);if(!l||g!==l)return;const t=performance.now();if(R.current=t,d>0&&t-n.current<d)return;n.current=t;const i=c.current;i.position.copy(o.position),i.velocity.copy(o.velocity),i.rotation.copy(o.rotation),i.isMoving=o.isMoving,i.isGrounded=o.isGrounded,i.speed=o.speed,i.height=2,f(x=>x+1)});return()=>{r()}},[a,d]),z.useFrame(()=>{const y=performance.now();if(d>0&&y-n.current<d)return;const r=c.current,o=S.current,g=l=>{const t=m.current,i=l.x-t.x,x=l.y-t.y,k=l.z-t.z;return i*i+x*x+k*k>1e-6?(t.x=l.x,t.y=l.y,t.z=l.z,!0):!1};if(o){const l=u(o);if(!(y-R.current<16)&&l){const i=o.snapshot(l);if(i){r.position.copy(i.position),r.velocity.copy(i.velocity),r.rotation.copy(i.rotation),r.isMoving=i.isMoving,r.isGrounded=i.isGrounded,r.speed=i.speed,r.height=2,n.current=y,g(r.position)&&f(x=>x+1);return}}}v?.position&&(r.position.copy(v.position),v.velocity?r.velocity.copy(v.velocity):r.velocity.set(0,0,0),v.euler?r.rotation.copy(v.euler):r.rotation.set(0,0,0),r.isMoving=b?.isMoving||!1,r.isGrounded=b?.isOnTheGround||!1,r.speed=v.velocity?v.velocity.length():0,r.height=2,n.current=y,g(r.position)&&f(l=>l+1))}),c.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,d=!0,a)=>{const c=E.useGaesupStore(u=>u.automation?.queue.isRunning),f=E.useGaesupStore(u=>u.stopAutomation),n=E.useGaesupStore(u=>u.interaction?.isActive??!0),R=w.useBuildingStore(u=>u.isInEditMode()),m=w.useInputBackend(),h=p.useRef(new Set),S=p.useMemo(()=>({...N}),[]),v=p.useCallback((u,y)=>{if(!n)return!1;try{return m.updateKeyboard({[u]:y}),y?h.current.add(u):h.current.delete(u),!0}catch(r){return console.error("Error updating keyboard state:",r),!1}},[m,n]),b=p.useCallback(()=>{h.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(()=>{(!n||R)&&b()},[b,n,R]),p.useEffect(()=>{const u=(g,l)=>{const t=S[g.code];if(!t)return;if(!n||R){l&&g.preventDefault(),b();return}const i=h.current.has(g.code);l&&!i?(h.current.add(g.code),g.code==="Space"&&g.preventDefault(),d&&c&&(t==="forward"||t==="backward"||t==="leftward"||t==="rightward")&&(f(),m.updateMouse({isActive:!1,shouldRun:!1})),m.updateKeyboard({[t]:!0})):!l&&i&&(h.current.delete(g.code),m.updateKeyboard({[t]:!1}))},y=g=>u(g,!0),r=g=>u(g,!1),o=()=>document.hidden&&b();return window.addEventListener("keydown",y),window.addEventListener("keyup",r),document.addEventListener("visibilitychange",o),()=>{window.removeEventListener("keydown",y),window.removeEventListener("keyup",r),document.removeEventListener("visibilitychange",o)}},[S,d,f,c,b,n,R,m]),{pressedKeys:Array.from(h.current),pushKey:v,isKeyPressed:u=>h.current.has(u),clearAllKeys:b}},C=p.memo(({points:e,color:d})=>e.length<2?null:s.jsx(O.Line,{points:e,color:d,lineWidth:2,dashed:!1}));C.displayName="PathLine";const K=p.memo(()=>s.jsxs("group",{children:[s.jsxs("mesh",{children:[s.jsx("sphereGeometry",{args:[.2,16,16]}),s.jsx("meshStandardMaterial",{color:"#00ff88",emissive:"#00ff88",emissiveIntensity:.5,transparent:!0,opacity:.9})]}),s.jsxs("mesh",{rotation:[Math.PI/2,0,0],children:[s.jsx("ringGeometry",{args:[.3,.5,8]}),s.jsx("meshStandardMaterial",{color:"#00ff88",transparent:!0,opacity:.6,side:P.DoubleSide})]})]}));K.displayName="TargetMarker";function B({lineStartHeight:e}={}){const d=E.useGaesupStore(t=>t.automation),{position:a}=G(),{mouse:c}=w.useInteractionSystem(),[f,n]=p.useState(()=>[...w.getClickNavigationRoute()]);p.useEffect(()=>w.subscribeClickNavigationRoute(()=>{n([...w.getClickNavigationRoute()])}),[]);const R=c?.target||new P.Vector3,m=c?.isActive||!1,h=d?.queue||{actions:[],currentIndex:0},S=h.actions||[],v=h.currentIndex||0,u=a.distanceTo(R)<1,y=m&&!u,r=S.map(t=>t.type==="move"&&t.target?new P.Vector3(t.target.x,t.target.y,t.target.z):null).filter(t=>t!==null),o=a.clone();e!==void 0&&(o.y+=e);const g=f.length>0?f:[R],l=y?[o,...g,...r]:r.length>0?[o,...r]:[];return s.jsxs("group",{children:[y&&s.jsx("group",{position:R,children:s.jsx(K,{})}),l.length>1&&s.jsx(C,{points:l,color:v>=0?"#00ff88":"#ffaa00"}),S.map((t,i)=>{if(t.type==="move"&&t.target){const x=i===v,k=i<v;return s.jsx("group",{position:[t.target.x,t.target.y,t.target.z],children:s.jsxs("mesh",{children:[s.jsx("sphereGeometry",{args:[.1,8,8]}),s.jsx("meshStandardMaterial",{color:k?"#888":x?"#ff4444":"#ffaa00",transparent:!0,opacity:k?.3:.8})]})},`action-${i}`)}return null})]})}function I({clickerOptions:e}){const{onClick:d}=w.useClicker(e),a=c=>{c.stopPropagation();const{cameraOption:f,setCameraOption:n}=E.useGaesupStore.getState();if(f?.focus){n({focus:!1});return}d(c)};return s.jsxs("mesh",{position:[0,0,0],rotation:[-Math.PI/2,0,0],onPointerDown:a,visible:!0,userData:{intangible:!0},children:[s.jsx("planeGeometry",{args:[1e3,1e3]}),s.jsx("meshBasicMaterial",{transparent:!0,opacity:0})]})}function F({props:e,children:d}){const a=E.useGaesupStore(o=>o.mode),{gameStates:c}=w.useStateSystem(),f=E.useGaesupStore(o=>o.rideable),n=E.useGaesupStore(o=>o.urls),R=w.useBuildingStore(o=>o.isInEditMode()),m=D.useGenericRefs();if(M(),R||!a||!c||!f||!n||a.type==="character"&&!n.characterUrl||a.type==="vehicle"&&!n.vehicleUrl||a.type==="airplane"&&!n.airplaneUrl)return null;const{canRide:h,isRiding:S,currentRideable:v}=c,b=v?.id,u=p.useMemo(()=>(b?f[b]?.offset:void 0)??T.vec3(),[b,f]),r=(()=>{const o=e.rigidBodyRef??m.rigidBodyRef,g=e.outerGroupRef??m.outerGroupRef,l=e.innerGroupRef??m.innerGroupRef,t=e.colliderRef??m.colliderRef,i={isActive:!0,componentType:a.type,enableRiding:h,isRiderOn:S,offset:u,ref:o,outerGroupRef:g,innerGroupRef:l,colliderRef:t,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}:{}},x=S&&a.type!=="character"?n.ridingUrl:void 0,k=typeof x=="string"&&x.length>0?{ridingUrl:x}:{};switch(a.type){case"character":return{...i,url:n.characterUrl||""};case"vehicle":return{...i,...k,url:n.vehicleUrl||"",wheelUrl:n.wheelUrl};case"airplane":return{...i,...k,url:n.airplaneUrl||""};default:return{...i,url:n.characterUrl||""}}})();return a.type==="character"&&c.isRiding?null:s.jsx(w.PhysicsEntity,{...r,children:d})}function L(e){const{clickToMove:d,children:a,clickerOptions:c,...f}=e,n=f.colliderSize?.height?f.colliderSize.height*.5:void 0,R={...c??{},...c?.agentRadius===void 0&&f.colliderSize?.radius!==void 0?{agentRadius:f.colliderSize.radius}:{}};return s.jsx(F,{props:f,children:s.jsxs(s.Fragment,{children:[d&&s.jsxs(s.Fragment,{children:[s.jsx(I,{clickerOptions:R}),s.jsx(B,{...n!==void 0?{lineStartHeight:n}:{}})]}),a]})})}exports.Clicker=B;exports.ControllerWrapper=L;exports.GroundClicker=I;exports.useKeyboard=M;exports.usePlayerPosition=G;
|
package/dist/index-D1hpjfAw.cjs
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
"use strict";const u=require("react"),j=require("@react-three/fiber"),rt=require("three"),q=require("./index-CJj-Z7Jr.cjs"),C=require("./gaesupStore-2zKBYTYo.cjs"),at=require("mitt");function ct(o){const e=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(o){for(const t in o)if(t!=="default"){const i=Object.getOwnPropertyDescriptor(o,t);Object.defineProperty(e,t,i.get?i:{enumerable:!0,get:()=>o[t]})}}return e.default=o,Object.freeze(e)}const a=ct(rt);var lt=Object.defineProperty,ut=Object.getOwnPropertyDescriptor,H=(o,e,t,i)=>{for(var n=ut(e,t),r=o.length-1,c;r>=0;r--)(c=o[r])&&(n=c(e,t,n)||n);return n&<(e,t,n),n};function _(o){return{...o,distance:{...o.distance},smoothing:{...o.smoothing},...o.focusTarget?{focusTarget:{...o.focusTarget}}:{},...o.offset?{offset:{...o.offset}}:{},...o.lookAt?{lookAt:{...o.lookAt}}:{}}}class I{emitter;config;metrics={frameCount:0,totalFrameTime:0,lastUpdateTime:0};constructor(e){this.emitter=at(),this.config=_(e)}updateConfig(e){const t={...this.config};this.config=_({...this.config,...e}),Object.keys(e).forEach(i=>{this.emitter.emit("configChange",{key:i,value:e[i]})}),t.mode!==this.config.mode&&this.emitter.emit("modeChange",{from:t.mode,to:this.config.mode})}getConfig(){return _(this.config)}getState(){return{config:this.getConfig(),metrics:this.getMetrics()}}getMetrics(){return{frameCount:this.metrics.frameCount,averageFrameTime:this.metrics.frameCount>0?this.metrics.totalFrameTime/this.metrics.frameCount:0,lastUpdateTime:this.metrics.lastUpdateTime}}trackFrameMetrics(e){this.metrics.frameCount++,this.metrics.totalFrameTime+=e,this.metrics.lastUpdateTime=Date.now()}emitError(e,t){this.emitter.emit("error",{message:e,details:t})}destroy(){this.emitter.all.clear()}}H([C.HandleError()],I.prototype,"updateConfig");H([C.Profile()],I.prototype,"trackFrameMetrics");H([C.HandleError()],I.prototype,"destroy");const D=new a.Vector3,B=new a.Vector3,ft=new a.Quaternion,mt=new a.Matrix4,G=new a.Quaternion,R=new a.Vector3,A=new a.Raycaster,U=[],K=new a.Vector3,$=new a.Vector3,dt=new a.Vector3,ht=new a.Euler,gt=new a.Vector3,pt=new a.Vector3;new a.Vector3;let Z=[],J=null,W=-1;function tt(o){const e=[];return o.traverse(t=>{t instanceof a.Mesh&&!t.userData.intangible&&t.geometry?.boundingSphere&&e.push(t)}),e}function yt(o){const e=o._frameId;return e===void 0?tt(o):(o===J&&e-W<60||(J=o,W=e,Z=tt(o)),Z)}function vt(o,e){if(!e||e.length===0)return!1;let t=o;for(;t;){for(let i=0,n=e.length;i<n;i++)if(t===e[i])return!0;t=t.parent}return!1}const v={tempVectors:{temp1:new a.Vector3,temp2:new a.Vector3,temp3:new a.Vector3},clampValue:(o,e,t)=>Math.max(e,Math.min(t,o)),smoothingToSpeed:(o,e=C.CAMERA_CONSTANTS.FRAME_RATE_LERP_SPEED)=>{if(o===void 0||!Number.isFinite(o))return e;if(o<=0)return 0;if(o>=1)return o;const t=v.clampValue(o,.001,.999);return-Math.log(1-t)*60},frameRateIndependentLerpVector3:(o,e,t,i)=>{const n=1-Math.exp(-t*i);o.lerp(e,n)},smoothLookAt:(o,e,t,i)=>{const n=ft.setFromRotationMatrix(mt.lookAt(o.position,e,o.up)).normalize();G.copy(o.quaternion).normalize(),G.dot(n)<0&&(n.x*=-1,n.y*=-1,n.z*=-1,n.w*=-1);const r=1-Math.exp(-t*i);o.quaternion.slerp(n,r).normalize()},preventCameraJitter:(o,e,t,i,n,r=i*.8)=>{v.frameRateIndependentLerpVector3(o.position,e,i,n),v.smoothLookAt(o,t,r,n)},improvedCollisionCheck:(o,e,t,i=.5,n)=>{R.subVectors(e,o);const r=R.length();if(r<=0)return{safe:!0,position:e,obstacles:[]};R.multiplyScalar(1/r),A.set(o,R),A.near=0,A.far=r;const c=[],l=yt(t);for(let d=0,S=l.length;d<S;d++){const w=l[d];if(!w||vt(w,n))continue;U.length=0,A.intersectObject(w,!1,U);const g=U[0];g&&c.push({object:w,distance:g.distance,point:g.point})}if(c.length===0)return{safe:!0,position:e,obstacles:[]};const m=c.reduce((d,S)=>S.distance<d.distance?S:d);return K.copy(o).addScaledVector(R,Math.max(0,m.distance-i)),$.copy(K),{safe:!1,position:$,obstacles:c}},distanceSquared:(o,e)=>D.subVectors(o,e).lengthSq(),safeNormalize:o=>{const e=o.length();return e>0?o.divideScalar(e):o.set(0,0,0)},smoothDamp:(o,e,t,i,n,r)=>{const c=2/i,l=c*n,m=1/(1+l+.48*l*l+.235*l*l*l);D.subVectors(o,e);const d=r?r*i:1/0;D.clampLength(0,d),B.copy(t).addScaledVector(D,c).multiplyScalar(n),t.copy(t).sub(B).multiplyScalar(m),o.copy(e).add(D.add(B).multiplyScalar(m))},calculateBounds:(o,e,t)=>{if(!t)return o;const i=t.minX!==void 0?Math.max(t.minX,o.x):o.x,n=t.minY!==void 0?Math.max(t.minY,o.y):o.y,r=t.minZ!==void 0?Math.max(t.minZ,o.z):o.z,c=t.maxX!==void 0?Math.min(t.maxX,i):i,l=t.maxY!==void 0?Math.min(t.maxY,n):n,m=t.maxZ!==void 0?Math.min(t.maxZ,r):r;return D.set(c,l,m)},fastAtan2:(o,e)=>e===0?o>0?Math.PI/2:o<0?-Math.PI/2:0:e>0?Math.atan(o/e):Math.atan(o/e)+(o>=0?Math.PI:-Math.PI),updateFOV:(o,e,t,i)=>{if(!t||t<=0){if(Math.abs(e-o.fov)<1e-4)return;o.fov=e,o.updateProjectionMatrix();return}const n=i===void 0?t:1-Math.exp(-v.smoothingToSpeed(t)*i),r=n>=1?e:a.MathUtils.lerp(o.fov,e,n);Math.abs(r-o.fov)<1e-4||(o.fov=r,o.updateProjectionMatrix())},clampPosition:(o,e)=>(e&&(o.y=v.clampValue(o.y,e.minY||-1/0,e.maxY||1/0)),o),isPositionEqual:(o,e,t=.001)=>Math.abs(o.x-e.x)<t&&Math.abs(o.y-e.y)<t&&Math.abs(o.z-e.z)<t,pool:{vectors:[],getVector3:()=>v.pool.vectors.pop()||new a.Vector3,releaseVector3:o=>{o.set(0,0,0),v.pool.vectors.push(o)}},calculateSafeDistance:(o,e,t,i)=>{const n=o.distanceTo(e);return a.MathUtils.clamp(n,t,i)},isPositionValid:(o,e)=>e?o.y>=(e.minY??-1/0)&&o.y<=(e.maxY??1/0):!0},y={getPosition:o=>o?.position?o.position:dt.set(0,0,0),getEuler:o=>o?.euler?o.euler:ht.set(0,0,0),getVelocity:o=>o?.velocity?o.velocity:gt.set(0,0,0),calculateCameraOffset:(o,e,t)=>{const{xDistance:i=15,yDistance:n=8,zDistance:r=15,euler:c,mode:l="thirdPerson"}=e,m=t??pt;switch(l){case"chase":if(c){const d=1/Math.SQRT2;return m.set(-i*Math.sin(c.y)*d,n*d,-r*Math.cos(c.y)*d)}return m.set(-i,n,-r);case"thirdPerson":default:return m.set(-i,n,-r)}},getCameraTarget:(o,e)=>{const t=y.getPosition(o);return e.target||t}};var wt=Object.defineProperty,Ct=Object.getOwnPropertyDescriptor,it=(o,e,t,i)=>{for(var n=Ct(e,t),r=o.length-1,c;r>=0;r--)(c=o[r])&&(n=c(e,t,n)||n);return n&&wt(e,t,n),n};class P{focusTarget=new a.Vector3;focusDirection=new a.Vector3;focusBasePosition=new a.Vector3;focusTargetPosition=new a.Vector3;orbitRight=new a.Vector3;orbitYawQuaternion=new a.Quaternion;orbitPitchQuaternion=new a.Quaternion;xAxis=new a.Vector3(1,0,0);yAxis=new a.Vector3(0,1,0);applyDefaults(e){const t=this.defaultConfig,i=e.config;if(t.enableCollision!==void 0&&i.enableCollision===void 0&&(i.enableCollision=t.enableCollision),t.distance){const n=i.distance;n?(n.x===void 0&&t.distance.x!==void 0&&(n.x=t.distance.x),n.y===void 0&&t.distance.y!==void 0&&(n.y=t.distance.y),n.z===void 0&&t.distance.z!==void 0&&(n.z=t.distance.z)):i.distance={...t.distance}}if(t.smoothing){const n=i.smoothing;n?(n.position===void 0&&t.smoothing.position!==void 0&&(n.position=t.smoothing.position),n.rotation===void 0&&t.smoothing.rotation!==void 0&&(n.rotation=t.smoothing.rotation),n.fov===void 0&&t.smoothing.fov!==void 0&&(n.fov=t.smoothing.fov)):i.smoothing={...t.smoothing}}}calculateLookAt(e,t){return y.getPosition(e.activeState)}applyOrbitOffset(e,t){const i=t.config.orbitYaw??0,n=t.config.orbitPitch??0;return i===0&&n===0||(i!==0&&(this.orbitYawQuaternion.setFromAxisAngle(this.yAxis,i),e.applyQuaternion(this.orbitYawQuaternion)),n!==0&&(this.orbitRight.crossVectors(e,this.yAxis),this.orbitRight.lengthSq()<=1e-6?this.orbitRight.copy(this.xAxis):this.orbitRight.normalize(),this.orbitPitchQuaternion.setFromAxisAngle(this.orbitRight,n),e.applyQuaternion(this.orbitPitchQuaternion))),e}update(e,t){const{camera:i,deltaTime:n,activeState:r}=e;if(!r)return;this.applyDefaults(t);const c=t.config;let l,m;if(c.focus&&c.focusTarget){const g=this.focusTarget;g.set(c.focusTarget.x,c.focusTarget.y,c.focusTarget.z),m=g;const z=c.focusDistance||10,E=this.focusBasePosition.copy(this.calculateTargetPosition(e,t)),p=this.focusDirection;p.copy(E).sub(g),p.lengthSq()===0&&p.copy(i.position).sub(g),p.lengthSq()===0&&p.set(1,1,1),p.normalize(),l=this.focusTargetPosition.copy(g).addScaledVector(p,z)}else l=this.calculateTargetPosition(e,t),m=this.calculateLookAt(e,t);c.enableCollision&&(l=v.improvedCollisionCheck(m,l,e.scene,c.collisionMargin??.5,e.excludeObjects).position);const d=c.focusLerpSpeed||10,S=c.focus?d:v.smoothingToSpeed(c.smoothing?.position),w=c.focus?d*.8:v.smoothingToSpeed(c.smoothing?.rotation,S*.8);v.preventCameraJitter(i,l,m,S,n,w),t.config.fov&&i instanceof a.PerspectiveCamera&&v.updateFOV(i,t.config.fov,t.config.smoothing?.fov,n)}}it([C.Profile()],P.prototype,"calculateLookAt");it([C.HandleError(),C.Profile()],P.prototype,"update");class xt extends P{name="thirdPerson";target=new a.Vector3;offset=new a.Vector3;defaultConfig={distance:{x:15,y:8,z:15},smoothing:{position:.1,rotation:.1,fov:.1},enableCollision:!0};calculateTargetPosition(e,t){const i=y.getPosition(e.activeState),n=t.config.zoom||1;return y.calculateCameraOffset(i,{xDistance:t.config.distance.x*n,yDistance:t.config.distance.y*n,zDistance:t.config.distance.z*n,mode:"thirdPerson"},this.offset),this.applyOrbitOffset(this.offset,t),this.target.copy(i).add(this.offset)}}class bt extends P{name="firstPerson";target=new a.Vector3;lookAt=new a.Vector3;lookDirection=new a.Vector3;eyePosition=new a.Vector3;defaultConfig={distance:{x:0,y:2,z:.45},smoothing:{position:.2,rotation:.15,fov:.1},enableCollision:!1};calculateTargetPosition(e,t){const i=y.getPosition(e.activeState),n=y.getEuler(e.activeState),r=t.config.distance.y||this.defaultConfig.distance?.y||2,c=t.config.distance.z||this.defaultConfig.distance?.z||.45,l=this.lookDirection.set(0,0,-1);return n&&l.applyEuler(n),this.target.set(i.x,i.y+r,i.z).addScaledVector(l,c)}calculateLookAt(e,t){const i=this.eyePosition.copy(this.calculateTargetPosition(e,t)),n=y.getEuler(e.activeState),r=this.lookDirection.set(0,0,-1);return n&&r.applyEuler(n),this.lookAt.copy(i).add(r)}}class St extends P{name="chase";target=new a.Vector3;offset=new a.Vector3;defaultConfig={distance:{x:10,y:5,z:10},smoothing:{position:.15,rotation:.1,fov:.1},enableCollision:!0};calculateTargetPosition(e,t){const i=y.getPosition(e.activeState),n=y.getEuler(e.activeState),r=t.config.zoom||-1;return y.calculateCameraOffset(i,{xDistance:t.config.distance.x*r,yDistance:t.config.distance.y*r,zDistance:t.config.distance.z*r,euler:n,mode:"chase"},this.offset),this.applyOrbitOffset(this.offset,t),this.target.copy(i).add(this.offset)}}class Pt extends P{name="topDown";target=new a.Vector3;offset=new a.Vector3;yawQuaternion=new a.Quaternion;pitchQuaternion=new a.Quaternion;topDownXAxis=new a.Vector3(1,0,0);topDownYAxis=new a.Vector3(0,1,0);defaultConfig={distance:{x:0,y:20,z:0},smoothing:{position:.1,rotation:.1,fov:.1},enableCollision:!1};calculateTargetPosition(e,t){const i=y.getPosition(e.activeState),n=t.config.zoom||1,r=this.offset.set(0,t.config.distance.y*n,0),c=t.config.orbitPitch??0,l=t.config.orbitYaw??0;return c!==0&&(this.pitchQuaternion.setFromAxisAngle(this.topDownXAxis,c),r.applyQuaternion(this.pitchQuaternion)),l!==0&&(this.yawQuaternion.setFromAxisAngle(this.topDownYAxis,l),r.applyQuaternion(this.yawQuaternion)),this.target.copy(i).add(r)}}class Mt extends P{name="isometric";target=new a.Vector3;defaultConfig={distance:{x:15,y:15,z:15},smoothing:{position:.1,rotation:.1,fov:.1},enableCollision:!1};calculateTargetPosition(e,t){const i=y.getPosition(e.activeState),n=Math.PI/4,r=Math.sqrt(t.config.distance.x**2+t.config.distance.z**2);return this.target.set(i.x+Math.cos(n)*r,i.y+t.config.distance.y,i.z+Math.sin(n)*r)}}class Et extends P{name="sideScroll";target=new a.Vector3;defaultConfig={distance:{x:0,y:5,z:18},smoothing:{position:.08,rotation:.1,fov:.1},enableCollision:!1};calculateTargetPosition(e,t){const i=y.getPosition(e.activeState);return this.target.set(i.x+t.config.distance.x,i.y+t.config.distance.y,i.z+t.config.distance.z)}}class zt extends P{name="fixed";defaultPosition=new a.Vector3(0,10,10);defaultLookAt=new a.Vector3(0,0,0);defaultConfig={distance:{x:0,y:0,z:0},smoothing:{position:0,rotation:0,fov:0},enableCollision:!1};calculateTargetPosition(e,t){return t.config.fixedPosition||this.defaultPosition}calculateLookAt(e,t){return t.config.fixedLookAt||this.defaultLookAt}}var Tt=Object.getOwnPropertyDescriptor,Dt=(o,e,t,i)=>{for(var n=i>1?void 0:i?Tt(e,t):e,r=o.length-1,c;r>=0;r--)(c=o[r])&&(n=c(n)||n);return n};exports.CameraSystem=class extends I{controllers=new Map;state;cameraStates=new Map;currentCameraStateName="default";cameraTransitions=[];constructor(e){super(e),this.state=this.createInitialState(e),this.registerControllers(),this.initializeCameraStates()}createInitialState(e){return{config:_(e),lastUpdate:Date.now()}}initializeCameraStates(){const e={name:"default",type:"thirdPerson",position:new a.Vector3(0,5,10),rotation:new a.Euler(0,0,0),fov:75,config:{distance:{x:15,y:8,z:15},height:5,followSpeed:.1,rotationSpeed:.1},priority:0,tags:[]};this.cameraStates.set("default",e)}registerController(e){this.controllers.set(e.name,e)}updateConfig(e){super.updateConfig(e),this.state.config=this.getConfig()}update(e){this.trackFrameMetrics(e)}calculate(e){try{const t=this.controllers.get(this.state.config.mode);if(!t)return;this.state.activeController=t,t.update(e,this.state)}catch(t){this.emitError("Camera calculation failed",t instanceof Error?t.message:void 0)}}getCameraState(e){return this.cameraStates.get(e)}getCurrentCameraState(){return this.cameraStates.get(this.currentCameraStateName)}addCameraState(e,t){this.cameraStates.set(e,t)}setCameraTransitions(e){this.cameraTransitions=e,this.cameraTransitions.length}switchCameraState(e){if(this.cameraStates.has(e)){this.currentCameraStateName=e;const t=this.cameraStates.get(e),i={mode:t.type,fov:t.fov};t.config.distance&&(i.distance=t.config.distance),this.updateConfig(i)}}registerControllers(){this.registerController(new xt),this.registerController(new bt),this.registerController(new St),this.registerController(new Pt),this.registerController(new Mt),this.registerController(new Et),this.registerController(new zt)}};exports.CameraSystem=Dt([C.ManageRuntime({autoStart:!1})],exports.CameraSystem);function Rt(o,e,t){const i=u.useRef(null);i.current||(i.current=new o(e));const n=i.current;j.useFrame((m,d)=>{n?.update(d)}),u.useEffect(()=>{},[t,n]),u.useEffect(()=>()=>{n?.destroy()},[n]);const r=u.useCallback(m=>{n?.updateConfig(m)},[n]),c=u.useCallback(()=>n?.getState(),[n]),l=u.useCallback(()=>n?.getMetrics(),[n]);return{system:n,updateConfig:r,getState:c,getMetrics:l}}const et=.0015,ot=10,nt=1e-4,Vt=-.65,Ot=.85,N=o=>{if(!(o instanceof HTMLElement))return!1;const e=o.tagName.toLowerCase();return e==="input"||e==="textarea"||e==="select"||o.isContentEditable};function kt(){const{gl:o}=j.useThree(),{activeState:e}=q.useStateSystem(),t=C.useGaesupStore(s=>s.cameraOption),i=C.useGaesupStore(s=>s.setCameraOption),n=C.useGaesupStore(s=>s.mode),r=q.useBuildingStore(s=>s.isInEditMode()),c=q.useInputBackend(),l=u.useRef(t);u.useEffect(()=>{l.current=t},[t]);const m=u.useRef(n);u.useEffect(()=>{m.current=n},[n]);const d=u.useRef(r);u.useEffect(()=>{d.current=r},[r]);const S=u.useRef([]),w=u.useRef(null),g=u.useRef(new Set),z=u.useRef(!1),E=u.useRef(0),p=u.useRef(0),X=u.useRef(0),Y=u.useRef(0),st=u.useMemo(()=>({mode:n?.control||"thirdPerson",distance:{x:t?.xDistance??0,y:t?.yDistance??0,z:t?.zDistance??0},smoothing:{position:t?.smoothing?.position??.1,rotation:t?.smoothing?.rotation??.1,fov:t?.smoothing?.fov??.1},fov:t?.fov??75,zoom:t?.zoom??1,enableCollision:t?.enableCollision??!0,...t?.collisionMargin!==void 0?{collisionMargin:t.collisionMargin}:{},orbitYaw:E.current,orbitPitch:p.current,...t?.maxDistance!==void 0?{maxDistance:t.maxDistance}:{},...t?.offset?{offset:{x:t.offset.x,y:t.offset.y,z:t.offset.z}}:{},...t?.target?{lookAt:{x:t.target.x,y:t.target.y,z:t.target.z}}:{}}),[]),{system:Q,updateConfig:V}=Rt(exports.CameraSystem,st),O=u.useCallback(()=>{const s=l.current,h=m.current;V({mode:h?.control||"thirdPerson",distance:{x:s?.xDistance??0,y:s?.yDistance??0,z:s?.zDistance??0},smoothing:{position:s?.smoothing?.position??.1,rotation:s?.smoothing?.rotation??.1,fov:s?.smoothing?.fov??.1},fov:s?.fov??75,zoom:s?.zoom??1,enableCollision:s?.enableCollision??!0,...s?.collisionMargin!==void 0?{collisionMargin:s.collisionMargin}:{},orbitYaw:E.current,orbitPitch:p.current,...s?.maxDistance!==void 0?{maxDistance:s.maxDistance}:{},...s?.offset?{offset:{x:s.offset.x,y:s.offset.y,z:s.offset.z}}:{},...s?.target?{lookAt:{x:s.target.x,y:s.target.y,z:s.target.z}}:{},...s?.focus!==void 0?{focus:s.focus}:{},...s?.focusTarget?{focusTarget:{x:s.focusTarget.x,y:s.focusTarget.y,z:s.focusTarget.z}}:{focusTarget:void 0},...s?.focusDistance!==void 0?{focusDistance:s.focusDistance}:{},...s?.focusLerpSpeed!==void 0?{focusLerpSpeed:s.focusLerpSpeed}:{}})},[V]),F=u.useCallback(s=>{const h=l.current;if(!h?.enableZoom)return;s.preventDefault();const x=h.zoomSpeed||.001,M=h.minZoom||.45,b=h.maxZoom||2.4,k=h.zoom||1,T=s.deltaY*x,L=Math.min(Math.max(k+T,M),b);i({zoom:L})},[i]);return u.useEffect(()=>{const s=o.domElement;if(t?.enableZoom)return s.addEventListener("wheel",F,{passive:!1}),()=>{s.removeEventListener("wheel",F)}},[o,F,t?.enableZoom]),u.useEffect(()=>{const s=o.domElement,h=f=>{N(f.target)||(f.code==="ControlLeft"||f.code==="ControlRight")&&g.current.add(f.code)},x=f=>{f.code!=="ControlLeft"&&f.code!=="ControlRight"||g.current.delete(f.code)},M=f=>{!d.current||N(f.target)||f.button!==1&&f.button!==2||(f.preventDefault(),z.current=!0)},b=f=>{f.button!==1&&f.button!==2||(z.current=!1)},k=f=>{!(g.current.size>0||z.current)||N(f.target)||f.movementX===0&&f.movementY===0||(X.current-=f.movementX*et,Y.current=a.MathUtils.clamp(Y.current+f.movementY*et,Vt,Ot))},T=()=>{g.current.clear(),z.current=!1},L=f=>{d.current&&f.preventDefault()};return window.addEventListener("keydown",h),window.addEventListener("keyup",x),window.addEventListener("mousemove",k),window.addEventListener("mouseup",b),window.addEventListener("blur",T),document.addEventListener("visibilitychange",T),s.addEventListener("mousedown",M),s.addEventListener("contextmenu",L),()=>{window.removeEventListener("keydown",h),window.removeEventListener("keyup",x),window.removeEventListener("mousemove",k),window.removeEventListener("mouseup",b),window.removeEventListener("blur",T),document.removeEventListener("visibilitychange",T),s.removeEventListener("mousedown",M),s.removeEventListener("contextmenu",L)}},[o,V]),u.useEffect(()=>{const s=h=>{const x=l.current;h.key==="Escape"&&x?.focus&&i({focus:!1})};if(t?.enableFocus&&!r)return window.addEventListener("keydown",s),()=>{window.removeEventListener("keydown",s)}},[t?.enableFocus,r,i]),u.useLayoutEffect(()=>{c.updateMouse({isLookAround:!1}),O()},[c,O]),u.useLayoutEffect(()=>{O()},[t,n,O]),j.useFrame((s,h)=>{if(!Q)return;const x=a.MathUtils.damp(E.current,X.current,ot,h),M=a.MathUtils.damp(p.current,Y.current,ot,h);if((Math.abs(x-E.current)>nt||Math.abs(M-p.current)>nt)&&(E.current=x,p.current=M,V({orbitYaw:x,orbitPitch:M})),!w.current)w.current={camera:s.camera,scene:s.scene,deltaTime:h,activeState:e,clock:s.clock,excludeObjects:S.current};else{const b=w.current;b.camera=s.camera,b.scene=s.scene,b.deltaTime=h,b.activeState=e,b.clock=s.clock}Q.calculate(w.current)}),{system:Q}}function Lt(){return kt(),null}function At(){const o=u.useRef(null),e=u.useRef(null),t=u.useRef(null),i=u.useRef(null);return{outerGroupRef:o,innerGroupRef:e,rigidBodyRef:t,colliderRef:i}}exports.Camera=Lt;exports.useGenericRefs=At;
|