goldsrc-bsp-viewer 1.0.0
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/CHANGELOG.md +23 -0
- package/LICENSE +21 -0
- package/README.md +160 -0
- package/dist/goldsrc-bsp-viewer.js +2071 -0
- package/dist/goldsrc-bsp-viewer.umd.cjs +110 -0
- package/dist/icons.svg +24 -0
- package/dist/index.d.ts +326 -0
- package/package.json +91 -0
|
@@ -0,0 +1,2071 @@
|
|
|
1
|
+
var St = Object.defineProperty;
|
|
2
|
+
var kt = (y, e, t) => e in y ? St(y, e, { enumerable: !0, configurable: !0, writable: !0, value: t }) : y[e] = t;
|
|
3
|
+
var g = (y, e, t) => kt(y, typeof e != "symbol" ? e + "" : e, t);
|
|
4
|
+
import * as l from "three";
|
|
5
|
+
import { Controls as Lt, Vector3 as Ft, Euler as Pt } from "three";
|
|
6
|
+
import Je, { forwardRef as be, useRef as Be, useImperativeHandle as Tt, useEffect as me, createElement as ye, useState as ve } from "react";
|
|
7
|
+
const J = new Pt(0, 0, 0, "YXZ"), Z = new Ft(), At = { type: "change" }, It = { type: "lock" }, Ut = { type: "unlock" }, $e = Math.PI / 2;
|
|
8
|
+
class Ot extends Lt {
|
|
9
|
+
constructor(e, t = null) {
|
|
10
|
+
super(e, t), this.isLocked = !1, this.minPolarAngle = 0, this.maxPolarAngle = Math.PI, this.pointerSpeed = 1, this._onMouseMove = jt.bind(this), this._onPointerlockChange = Vt.bind(this), this._onPointerlockError = Dt.bind(this), this.domElement !== null && this.connect();
|
|
11
|
+
}
|
|
12
|
+
connect() {
|
|
13
|
+
this.domElement.ownerDocument.addEventListener("mousemove", this._onMouseMove), this.domElement.ownerDocument.addEventListener("pointerlockchange", this._onPointerlockChange), this.domElement.ownerDocument.addEventListener("pointerlockerror", this._onPointerlockError);
|
|
14
|
+
}
|
|
15
|
+
disconnect() {
|
|
16
|
+
this.domElement.ownerDocument.removeEventListener("mousemove", this._onMouseMove), this.domElement.ownerDocument.removeEventListener("pointerlockchange", this._onPointerlockChange), this.domElement.ownerDocument.removeEventListener("pointerlockerror", this._onPointerlockError);
|
|
17
|
+
}
|
|
18
|
+
dispose() {
|
|
19
|
+
this.disconnect();
|
|
20
|
+
}
|
|
21
|
+
getObject() {
|
|
22
|
+
return console.warn("THREE.PointerLockControls: getObject() has been deprecated. Use controls.object instead."), this.object;
|
|
23
|
+
}
|
|
24
|
+
getDirection(e) {
|
|
25
|
+
return e.set(0, 0, -1).applyQuaternion(this.object.quaternion);
|
|
26
|
+
}
|
|
27
|
+
moveForward(e) {
|
|
28
|
+
if (this.enabled === !1) return;
|
|
29
|
+
const t = this.object;
|
|
30
|
+
Z.setFromMatrixColumn(t.matrix, 0), Z.crossVectors(t.up, Z), t.position.addScaledVector(Z, e);
|
|
31
|
+
}
|
|
32
|
+
moveRight(e) {
|
|
33
|
+
if (this.enabled === !1) return;
|
|
34
|
+
const t = this.object;
|
|
35
|
+
Z.setFromMatrixColumn(t.matrix, 0), t.position.addScaledVector(Z, e);
|
|
36
|
+
}
|
|
37
|
+
lock() {
|
|
38
|
+
this.domElement.requestPointerLock();
|
|
39
|
+
}
|
|
40
|
+
unlock() {
|
|
41
|
+
this.domElement.ownerDocument.exitPointerLock();
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
function jt(y) {
|
|
45
|
+
if (this.enabled === !1 || this.isLocked === !1) return;
|
|
46
|
+
const e = this.object;
|
|
47
|
+
J.setFromQuaternion(e.quaternion), J.y -= y.movementX * 2e-3 * this.pointerSpeed, J.x -= y.movementY * 2e-3 * this.pointerSpeed, J.x = Math.max($e - this.maxPolarAngle, Math.min($e - this.minPolarAngle, J.x)), e.quaternion.setFromEuler(J), this.dispatchEvent(At);
|
|
48
|
+
}
|
|
49
|
+
function Vt() {
|
|
50
|
+
this.domElement.ownerDocument.pointerLockElement === this.domElement ? (this.dispatchEvent(It), this.isLocked = !0) : (this.dispatchEvent(Ut), this.isLocked = !1);
|
|
51
|
+
}
|
|
52
|
+
function Dt() {
|
|
53
|
+
console.error("THREE.PointerLockControls: Unable to use Pointer Lock API");
|
|
54
|
+
}
|
|
55
|
+
const Nt = 0, Gt = 1, zt = 2, Wt = 3, Bt = 4, $t = 5, Ht = 6, Yt = 7, Kt = 8, qt = 9, Xt = 10, Jt = 11, Zt = 12, Qt = 13, es = 14, ts = 15;
|
|
56
|
+
class ss {
|
|
57
|
+
constructor(e) {
|
|
58
|
+
g(this, "view");
|
|
59
|
+
this.view = new DataView(e);
|
|
60
|
+
}
|
|
61
|
+
parse() {
|
|
62
|
+
const e = this.view.getInt32(0, !0);
|
|
63
|
+
e !== 30 && console.warn(`Unsupported BSP version: ${e}. Expected 30.`);
|
|
64
|
+
const t = [];
|
|
65
|
+
for (let w = 0; w < ts; w++)
|
|
66
|
+
t.push({
|
|
67
|
+
offset: this.view.getInt32(4 + w * 8, !0),
|
|
68
|
+
length: this.view.getInt32(8 + w * 8, !0)
|
|
69
|
+
});
|
|
70
|
+
const n = this.parseEntities(t[Nt]), r = this.parseVertices(t[Wt]), i = this.parseEdges(t[Zt]), a = this.parseSurfEdges(t[Qt]), c = this.parseFaces(t[Yt]), o = this.parseTexInfos(t[Ht]), u = this.parsePlanes(t[Gt]), f = this.parseTextures(t[zt]), d = this.parseLighting(t[Kt]), v = this.parseVisibility(t[Bt]), E = this.parseModels(t[es]), m = this.parseNodes(t[$t]), M = this.parseLeaves(t[Xt]), R = this.parseMarkSurfaces(t[Jt]), x = this.parseClipNodes(t[qt]);
|
|
71
|
+
return {
|
|
72
|
+
version: e,
|
|
73
|
+
entities: n,
|
|
74
|
+
vertices: r,
|
|
75
|
+
edges: i,
|
|
76
|
+
surfEdges: a,
|
|
77
|
+
faces: c,
|
|
78
|
+
texInfos: o,
|
|
79
|
+
planes: u,
|
|
80
|
+
textures: f,
|
|
81
|
+
lighting: d,
|
|
82
|
+
visibility: v,
|
|
83
|
+
models: E,
|
|
84
|
+
nodes: m,
|
|
85
|
+
leaves: M,
|
|
86
|
+
markSurfaces: R,
|
|
87
|
+
clipNodes: x
|
|
88
|
+
};
|
|
89
|
+
}
|
|
90
|
+
parseEntities(e) {
|
|
91
|
+
const t = new TextDecoder().decode(new Uint8Array(this.view.buffer, e.offset, e.length)), n = [];
|
|
92
|
+
let r = null;
|
|
93
|
+
const i = t.split(`
|
|
94
|
+
`);
|
|
95
|
+
for (let a of i)
|
|
96
|
+
if (a = a.trim(), a === "{")
|
|
97
|
+
r = { classname: "" };
|
|
98
|
+
else if (a === "}")
|
|
99
|
+
r && r.classname && n.push(r), r = null;
|
|
100
|
+
else if (r) {
|
|
101
|
+
const c = a.match(/"(.*)"\s+"(.*)"/);
|
|
102
|
+
if (c) {
|
|
103
|
+
const o = c[1], u = c[2];
|
|
104
|
+
o === "classname" ? r.classname = u : r[o] = u;
|
|
105
|
+
}
|
|
106
|
+
}
|
|
107
|
+
return n;
|
|
108
|
+
}
|
|
109
|
+
parseVertices(e) {
|
|
110
|
+
const t = e.length / 12, n = [];
|
|
111
|
+
for (let r = 0; r < t; r++)
|
|
112
|
+
n.push({
|
|
113
|
+
x: this.view.getFloat32(e.offset + r * 12, !0),
|
|
114
|
+
y: this.view.getFloat32(e.offset + r * 12 + 4, !0),
|
|
115
|
+
z: this.view.getFloat32(e.offset + r * 12 + 8, !0)
|
|
116
|
+
});
|
|
117
|
+
return n;
|
|
118
|
+
}
|
|
119
|
+
parseEdges(e) {
|
|
120
|
+
const t = e.length / 4, n = [];
|
|
121
|
+
for (let r = 0; r < t; r++)
|
|
122
|
+
n.push({
|
|
123
|
+
v: [
|
|
124
|
+
this.view.getUint16(e.offset + r * 4, !0),
|
|
125
|
+
this.view.getUint16(e.offset + r * 4 + 2, !0)
|
|
126
|
+
]
|
|
127
|
+
});
|
|
128
|
+
return n;
|
|
129
|
+
}
|
|
130
|
+
parseSurfEdges(e) {
|
|
131
|
+
const t = e.length / 4, n = [];
|
|
132
|
+
for (let r = 0; r < t; r++)
|
|
133
|
+
n.push(this.view.getInt32(e.offset + r * 4, !0));
|
|
134
|
+
return n;
|
|
135
|
+
}
|
|
136
|
+
parseFaces(e) {
|
|
137
|
+
const t = e.length / 20, n = [];
|
|
138
|
+
for (let r = 0; r < t; r++) {
|
|
139
|
+
const i = e.offset + r * 20;
|
|
140
|
+
n.push({
|
|
141
|
+
plane: this.view.getUint16(i, !0),
|
|
142
|
+
planeSide: this.view.getUint16(i + 2, !0),
|
|
143
|
+
firstEdge: this.view.getInt32(i + 4, !0),
|
|
144
|
+
numEdges: this.view.getUint16(i + 8, !0),
|
|
145
|
+
texInfo: this.view.getUint16(i + 10, !0),
|
|
146
|
+
styles: [
|
|
147
|
+
this.view.getUint8(i + 12),
|
|
148
|
+
this.view.getUint8(i + 13),
|
|
149
|
+
this.view.getUint8(i + 14),
|
|
150
|
+
this.view.getUint8(i + 15)
|
|
151
|
+
],
|
|
152
|
+
lightmapOffset: this.view.getInt32(i + 16, !0)
|
|
153
|
+
});
|
|
154
|
+
}
|
|
155
|
+
return n;
|
|
156
|
+
}
|
|
157
|
+
parseTexInfos(e) {
|
|
158
|
+
const t = e.length / 40, n = [];
|
|
159
|
+
for (let r = 0; r < t; r++) {
|
|
160
|
+
const i = e.offset + r * 40;
|
|
161
|
+
n.push({
|
|
162
|
+
s: { x: this.view.getFloat32(i, !0), y: this.view.getFloat32(i + 4, !0), z: this.view.getFloat32(i + 8, !0) },
|
|
163
|
+
shiftS: this.view.getFloat32(i + 12, !0),
|
|
164
|
+
t: { x: this.view.getFloat32(i + 16, !0), y: this.view.getFloat32(i + 20, !0), z: this.view.getFloat32(i + 24, !0) },
|
|
165
|
+
shiftT: this.view.getFloat32(i + 28, !0),
|
|
166
|
+
miptex: this.view.getInt32(i + 32, !0),
|
|
167
|
+
flags: this.view.getInt32(i + 36, !0)
|
|
168
|
+
});
|
|
169
|
+
}
|
|
170
|
+
return n;
|
|
171
|
+
}
|
|
172
|
+
parsePlanes(e) {
|
|
173
|
+
const t = e.length / 20, n = [];
|
|
174
|
+
for (let r = 0; r < t; r++) {
|
|
175
|
+
const i = e.offset + r * 20;
|
|
176
|
+
n.push({
|
|
177
|
+
normal: { x: this.view.getFloat32(i, !0), y: this.view.getFloat32(i + 4, !0), z: this.view.getFloat32(i + 8, !0) },
|
|
178
|
+
dist: this.view.getFloat32(i + 12, !0),
|
|
179
|
+
type: this.view.getInt32(i + 16, !0)
|
|
180
|
+
});
|
|
181
|
+
}
|
|
182
|
+
return n;
|
|
183
|
+
}
|
|
184
|
+
parseTextures(e) {
|
|
185
|
+
if (e.length === 0) return [];
|
|
186
|
+
const t = this.view.getInt32(e.offset, !0), n = [];
|
|
187
|
+
for (let r = 0; r < t; r++) {
|
|
188
|
+
const i = this.view.getInt32(e.offset + 4 + r * 4, !0);
|
|
189
|
+
if (i === -1) continue;
|
|
190
|
+
const a = e.offset + i;
|
|
191
|
+
let c = "";
|
|
192
|
+
for (let v = 0; v < 16; v++) {
|
|
193
|
+
const E = this.view.getUint8(a + v);
|
|
194
|
+
if (E === 0) break;
|
|
195
|
+
c += String.fromCharCode(E);
|
|
196
|
+
}
|
|
197
|
+
const o = this.view.getUint32(a + 16, !0), u = this.view.getUint32(a + 20, !0), f = [
|
|
198
|
+
this.view.getUint32(a + 24, !0),
|
|
199
|
+
this.view.getUint32(a + 28, !0),
|
|
200
|
+
this.view.getUint32(a + 32, !0),
|
|
201
|
+
this.view.getUint32(a + 36, !0)
|
|
202
|
+
], d = { name: c, width: o, height: u, offsets: f };
|
|
203
|
+
if (f[0] !== 0) {
|
|
204
|
+
const v = Math.floor(o * u * 85 / 64) + 2 + 768;
|
|
205
|
+
d.data = new Uint8Array(this.view.buffer, a, v);
|
|
206
|
+
}
|
|
207
|
+
n.push(d);
|
|
208
|
+
}
|
|
209
|
+
return n;
|
|
210
|
+
}
|
|
211
|
+
parseLighting(e) {
|
|
212
|
+
return new Uint8Array(this.view.buffer, e.offset, e.length);
|
|
213
|
+
}
|
|
214
|
+
parseVisibility(e) {
|
|
215
|
+
return new Uint8Array(this.view.buffer, e.offset, e.length);
|
|
216
|
+
}
|
|
217
|
+
parseModels(e) {
|
|
218
|
+
const t = e.length / 64, n = [];
|
|
219
|
+
for (let r = 0; r < t; r++) {
|
|
220
|
+
const i = e.offset + r * 64;
|
|
221
|
+
n.push({
|
|
222
|
+
mins: { x: this.view.getFloat32(i, !0), y: this.view.getFloat32(i + 4, !0), z: this.view.getFloat32(i + 8, !0) },
|
|
223
|
+
maxs: { x: this.view.getFloat32(i + 12, !0), y: this.view.getFloat32(i + 16, !0), z: this.view.getFloat32(i + 20, !0) },
|
|
224
|
+
origin: { x: this.view.getFloat32(i + 24, !0), y: this.view.getFloat32(i + 28, !0), z: this.view.getFloat32(i + 32, !0) },
|
|
225
|
+
headNodes: [
|
|
226
|
+
this.view.getInt32(i + 36, !0),
|
|
227
|
+
this.view.getInt32(i + 40, !0),
|
|
228
|
+
this.view.getInt32(i + 44, !0),
|
|
229
|
+
this.view.getInt32(i + 48, !0)
|
|
230
|
+
],
|
|
231
|
+
visLeafs: this.view.getInt32(i + 52, !0),
|
|
232
|
+
firstFace: this.view.getInt32(i + 56, !0),
|
|
233
|
+
numFaces: this.view.getInt32(i + 60, !0)
|
|
234
|
+
});
|
|
235
|
+
}
|
|
236
|
+
return n;
|
|
237
|
+
}
|
|
238
|
+
parseNodes(e) {
|
|
239
|
+
const t = e.length / 24, n = [];
|
|
240
|
+
for (let r = 0; r < t; r++) {
|
|
241
|
+
const i = e.offset + r * 24;
|
|
242
|
+
n.push({
|
|
243
|
+
plane: this.view.getInt32(i, !0),
|
|
244
|
+
children: [this.view.getInt16(i + 4, !0), this.view.getInt16(i + 6, !0)],
|
|
245
|
+
mins: [this.view.getInt16(i + 8, !0), this.view.getInt16(i + 10, !0), this.view.getInt16(i + 12, !0)],
|
|
246
|
+
maxs: [this.view.getInt16(i + 14, !0), this.view.getInt16(i + 16, !0), this.view.getInt16(i + 18, !0)],
|
|
247
|
+
firstFace: this.view.getUint16(i + 20, !0),
|
|
248
|
+
numFaces: this.view.getUint16(i + 22, !0)
|
|
249
|
+
});
|
|
250
|
+
}
|
|
251
|
+
return n;
|
|
252
|
+
}
|
|
253
|
+
parseLeaves(e) {
|
|
254
|
+
const t = e.length / 24, n = [];
|
|
255
|
+
for (let r = 0; r < t; r++) {
|
|
256
|
+
const i = e.offset + r * 24;
|
|
257
|
+
n.push({
|
|
258
|
+
contents: this.view.getInt32(i, !0),
|
|
259
|
+
visOffset: this.view.getInt32(i + 4, !0),
|
|
260
|
+
mins: [this.view.getInt16(i + 8, !0), this.view.getInt16(i + 10, !0), this.view.getInt16(i + 12, !0)],
|
|
261
|
+
maxs: [this.view.getInt16(i + 14, !0), this.view.getInt16(i + 16, !0), this.view.getInt16(i + 18, !0)],
|
|
262
|
+
firstMarkSurface: this.view.getUint16(i + 20, !0),
|
|
263
|
+
numMarkSurfaces: this.view.getUint16(i + 22, !0),
|
|
264
|
+
ambientLevels: [
|
|
265
|
+
this.view.getUint8(i + 24),
|
|
266
|
+
this.view.getUint8(i + 25),
|
|
267
|
+
this.view.getUint8(i + 26),
|
|
268
|
+
this.view.getUint8(i + 27)
|
|
269
|
+
]
|
|
270
|
+
});
|
|
271
|
+
}
|
|
272
|
+
return n;
|
|
273
|
+
}
|
|
274
|
+
parseMarkSurfaces(e) {
|
|
275
|
+
const t = e.length / 2, n = [];
|
|
276
|
+
for (let r = 0; r < t; r++)
|
|
277
|
+
n.push(this.view.getUint16(e.offset + r * 2, !0));
|
|
278
|
+
return n;
|
|
279
|
+
}
|
|
280
|
+
parseClipNodes(e) {
|
|
281
|
+
const t = e.length / 8, n = [];
|
|
282
|
+
for (let r = 0; r < t; r++) {
|
|
283
|
+
const i = e.offset + r * 8;
|
|
284
|
+
n.push({
|
|
285
|
+
plane: this.view.getInt32(i, !0),
|
|
286
|
+
children: [this.view.getInt16(i + 4, !0), this.view.getInt16(i + 6, !0)]
|
|
287
|
+
});
|
|
288
|
+
}
|
|
289
|
+
return n;
|
|
290
|
+
}
|
|
291
|
+
}
|
|
292
|
+
class is {
|
|
293
|
+
constructor(e) {
|
|
294
|
+
g(this, "view");
|
|
295
|
+
this.view = new DataView(e);
|
|
296
|
+
}
|
|
297
|
+
parse() {
|
|
298
|
+
const e = String.fromCharCode(
|
|
299
|
+
this.view.getUint8(0),
|
|
300
|
+
this.view.getUint8(1),
|
|
301
|
+
this.view.getUint8(2),
|
|
302
|
+
this.view.getUint8(3)
|
|
303
|
+
);
|
|
304
|
+
if (e !== "WAD3")
|
|
305
|
+
throw new Error(`Not a WAD3 file: ${e}`);
|
|
306
|
+
const t = this.view.getInt32(4, !0), n = this.view.getInt32(8, !0);
|
|
307
|
+
console.log(`[WadParser] Parsing WAD with ${t} entries`);
|
|
308
|
+
const r = /* @__PURE__ */ new Map();
|
|
309
|
+
for (let i = 0; i < t; i++) {
|
|
310
|
+
const a = n + i * 32, c = this.view.getInt32(a, !0), o = this.view.getUint8(a + 12);
|
|
311
|
+
let u = "";
|
|
312
|
+
for (let f = 0; f < 16; f++) {
|
|
313
|
+
const d = this.view.getUint8(a + 16 + f);
|
|
314
|
+
if (d === 0) break;
|
|
315
|
+
u += String.fromCharCode(d);
|
|
316
|
+
}
|
|
317
|
+
if (o === 67)
|
|
318
|
+
try {
|
|
319
|
+
const f = this.parseMiptex(c, u);
|
|
320
|
+
r.set(u.toLowerCase(), f);
|
|
321
|
+
} catch (f) {
|
|
322
|
+
console.error(`[WadParser] Failed to parse texture ${u}:`, f);
|
|
323
|
+
}
|
|
324
|
+
}
|
|
325
|
+
return console.log(`[WadParser] Successfully loaded ${r.size} textures`), r;
|
|
326
|
+
}
|
|
327
|
+
parseMiptex(e, t) {
|
|
328
|
+
const n = this.view.getUint32(e + 16, !0), r = this.view.getUint32(e + 20, !0), i = [
|
|
329
|
+
this.view.getUint32(e + 24, !0),
|
|
330
|
+
this.view.getUint32(e + 28, !0),
|
|
331
|
+
this.view.getUint32(e + 32, !0),
|
|
332
|
+
this.view.getUint32(e + 36, !0)
|
|
333
|
+
], a = n / 8 * (r / 8), c = e + i[3] + a, o = new Uint8Array(this.view.buffer, c + 2, 768), u = n * r, f = new Uint8Array(this.view.buffer, e + i[0], u);
|
|
334
|
+
return {
|
|
335
|
+
name: t,
|
|
336
|
+
width: n,
|
|
337
|
+
height: r,
|
|
338
|
+
data: new Uint8Array(f),
|
|
339
|
+
palette: new Uint8Array(o)
|
|
340
|
+
};
|
|
341
|
+
}
|
|
342
|
+
}
|
|
343
|
+
function Q(y) {
|
|
344
|
+
return new l.Vector3(-y.y, y.z, -y.x);
|
|
345
|
+
}
|
|
346
|
+
function He(y, e, t) {
|
|
347
|
+
const n = y.faces[e];
|
|
348
|
+
if (!n) return null;
|
|
349
|
+
const r = y.texInfos[n.texInfo];
|
|
350
|
+
if (!r) return null;
|
|
351
|
+
const i = y.textures[r.miptex];
|
|
352
|
+
if (!i) return null;
|
|
353
|
+
const a = n.firstEdge, c = n.numEdges;
|
|
354
|
+
if (c < 3) return null;
|
|
355
|
+
const o = [];
|
|
356
|
+
for (let R = 0; R < c; R++) {
|
|
357
|
+
const x = y.surfEdges[a + R], w = y.edges[Math.abs(x)], k = x >= 0 ? w.v[0] : w.v[1];
|
|
358
|
+
o.push(Q(y.vertices[k]));
|
|
359
|
+
}
|
|
360
|
+
const f = (c - 2) * 3, d = new Float32Array(f * 3), v = new Float32Array(f * 2), E = new Float32Array(f * 2);
|
|
361
|
+
t && o.forEach((R) => {
|
|
362
|
+
const x = -R.z, w = -R.x, k = R.y;
|
|
363
|
+
x * r.s.x + w * r.s.y + k * r.s.z + r.shiftS, x * r.t.x + w * r.t.y + k * r.t.z + r.shiftT;
|
|
364
|
+
});
|
|
365
|
+
let m = 0, M = 0;
|
|
366
|
+
for (let R = 1; R < o.length - 1; R++) {
|
|
367
|
+
const x = o[0], w = o[R], k = o[R + 1], O = [x, k, w];
|
|
368
|
+
for (const I of O) {
|
|
369
|
+
d[m++] = I.x, d[m++] = I.y, d[m++] = I.z;
|
|
370
|
+
const $ = -I.z, z = -I.x, T = I.y, H = $ * r.s.x + z * r.s.y + T * r.s.z + r.shiftS, D = $ * r.t.x + z * r.t.y + T * r.t.z + r.shiftT;
|
|
371
|
+
if (v[M] = H / (i.width || 1), v[M + 1] = D / (i.height || 1), t) {
|
|
372
|
+
const W = H / t.step - t.minU_step + 0.5, j = D / t.step - t.minV_step + 0.5;
|
|
373
|
+
E[M] = (t.x + 1 + W) / t.atlasWidth, E[M + 1] = (t.y + 1 + j) / t.atlasHeight;
|
|
374
|
+
}
|
|
375
|
+
M += 2;
|
|
376
|
+
}
|
|
377
|
+
}
|
|
378
|
+
return { positions: d, uvs: v, lightUvs: E };
|
|
379
|
+
}
|
|
380
|
+
const Ye = {
|
|
381
|
+
vertexShader: `
|
|
382
|
+
attribute vec2 lightUv;
|
|
383
|
+
varying vec2 vUv;
|
|
384
|
+
varying vec2 vLightUv;
|
|
385
|
+
varying vec3 vNormal;
|
|
386
|
+
varying vec3 vViewPosition;
|
|
387
|
+
|
|
388
|
+
void main() {
|
|
389
|
+
vUv = uv;
|
|
390
|
+
vLightUv = lightUv;
|
|
391
|
+
vNormal = normalize(normalMatrix * normal);
|
|
392
|
+
vec4 mvPosition = modelViewMatrix * vec4(position, 1.0);
|
|
393
|
+
vViewPosition = -mvPosition.xyz;
|
|
394
|
+
gl_Position = projectionMatrix * mvPosition;
|
|
395
|
+
}
|
|
396
|
+
`,
|
|
397
|
+
fragmentShader: `
|
|
398
|
+
uniform sampler2D diffuseMap;
|
|
399
|
+
uniform sampler2D lightmapAtlas;
|
|
400
|
+
uniform bool hasLightmap;
|
|
401
|
+
uniform float opacity;
|
|
402
|
+
varying vec2 vUv;
|
|
403
|
+
varying vec2 vLightUv;
|
|
404
|
+
varying vec3 vNormal;
|
|
405
|
+
varying vec3 vViewPosition;
|
|
406
|
+
|
|
407
|
+
void main() {
|
|
408
|
+
// Sample diffuse
|
|
409
|
+
vec4 diffuseColor = texture2D(diffuseMap, vUv);
|
|
410
|
+
|
|
411
|
+
// Handle transparency from texture ({ textures)
|
|
412
|
+
if (diffuseColor.a < 0.1) discard;
|
|
413
|
+
|
|
414
|
+
vec3 finalColor;
|
|
415
|
+
if (hasLightmap) {
|
|
416
|
+
vec3 lightColor = texture2D(lightmapAtlas, vLightUv).rgb;
|
|
417
|
+
finalColor = diffuseColor.rgb * lightColor;
|
|
418
|
+
float gamma = 1.6;
|
|
419
|
+
finalColor = pow(finalColor, vec3(1.0/gamma));
|
|
420
|
+
} else {
|
|
421
|
+
// Better fallback lighting
|
|
422
|
+
vec3 normal = normalize(vNormal);
|
|
423
|
+
vec3 lightDir = normalize(vec3(0.5, 1.0, 0.5));
|
|
424
|
+
float dotNL = max(dot(normal, lightDir), 0.3);
|
|
425
|
+
finalColor = diffuseColor.rgb * dotNL;
|
|
426
|
+
}
|
|
427
|
+
|
|
428
|
+
gl_FragColor = vec4(finalColor, opacity);
|
|
429
|
+
}
|
|
430
|
+
`
|
|
431
|
+
};
|
|
432
|
+
class rs {
|
|
433
|
+
parse(e) {
|
|
434
|
+
const t = /* @__PURE__ */ new Map(), n = /@(\w+Class).*?=\s*(\w+)/g;
|
|
435
|
+
let r;
|
|
436
|
+
for (; (r = n.exec(e)) !== null; ) {
|
|
437
|
+
const i = r[1], a = r[2], c = r.index, o = e.indexOf("=", c), f = e.substring(c, o).match(/color\((\d+)\s+(\d+)\s+(\d+)\)/), d = f ? [parseInt(f[1]), parseInt(f[2]), parseInt(f[3])] : void 0;
|
|
438
|
+
t.set(a, { name: a, type: i, color: d });
|
|
439
|
+
}
|
|
440
|
+
return t;
|
|
441
|
+
}
|
|
442
|
+
}
|
|
443
|
+
class ns {
|
|
444
|
+
constructor(e) {
|
|
445
|
+
g(this, "scene");
|
|
446
|
+
g(this, "fgd", /* @__PURE__ */ new Map());
|
|
447
|
+
this.scene = e;
|
|
448
|
+
}
|
|
449
|
+
async loadFgd(e) {
|
|
450
|
+
const t = new rs();
|
|
451
|
+
this.fgd = t.parse(e);
|
|
452
|
+
}
|
|
453
|
+
renderEntities(e) {
|
|
454
|
+
const t = new l.Group();
|
|
455
|
+
return t.name = "entities", e.forEach((n) => {
|
|
456
|
+
if (!n.origin) return;
|
|
457
|
+
const r = n.origin.split(" ").map(Number), i = n.classname, a = this.fgd.get(i), c = a != null && a.color ? new l.Color(a.color[0] / 255, a.color[1] / 255, a.color[2] / 255) : new l.Color(8421504), o = new l.Vector3(-r[1], r[2], -r[0]), u = new l.BoxGeometry(8, 8, 8), f = new l.MeshBasicMaterial({
|
|
458
|
+
color: c,
|
|
459
|
+
wireframe: !1,
|
|
460
|
+
transparent: !0,
|
|
461
|
+
opacity: 0.8
|
|
462
|
+
}), d = new l.Mesh(u, f);
|
|
463
|
+
d.position.copy(o), d.userData = { entity: n }, t.add(d);
|
|
464
|
+
const v = new l.EdgesGeometry(u), E = new l.LineBasicMaterial({ color: 16777215, transparent: !0, opacity: 0.5 }), m = new l.LineSegments(v, E);
|
|
465
|
+
m.name = "point_helper_wireframe", d.add(m);
|
|
466
|
+
}), this.scene.add(t), t;
|
|
467
|
+
}
|
|
468
|
+
}
|
|
469
|
+
class as {
|
|
470
|
+
constructor(e) {
|
|
471
|
+
g(this, "bsp");
|
|
472
|
+
this.bsp = e;
|
|
473
|
+
}
|
|
474
|
+
getLeafIndex(e) {
|
|
475
|
+
return this.findLeaf(e);
|
|
476
|
+
}
|
|
477
|
+
getVisibleLeafs(e) {
|
|
478
|
+
if (e <= 0)
|
|
479
|
+
return Array.from({ length: this.bsp.leaves.length }, (n, r) => r);
|
|
480
|
+
const t = this.bsp.leaves[e];
|
|
481
|
+
return !t || t.visOffset === -1 ? Array.from({ length: this.bsp.leaves.length }, (n, r) => r) : this.decompressVis(t.visOffset);
|
|
482
|
+
}
|
|
483
|
+
findLeaf(e) {
|
|
484
|
+
const t = { x: -e.z, y: -e.x, z: e.y };
|
|
485
|
+
let n = 0, r = 0;
|
|
486
|
+
for (; n >= 0 && r < 1e3; ) {
|
|
487
|
+
r++;
|
|
488
|
+
const i = this.bsp.nodes[n];
|
|
489
|
+
if (!i) break;
|
|
490
|
+
const a = this.bsp.planes[i.plane];
|
|
491
|
+
t.x * a.normal.x + t.y * a.normal.y + t.z * a.normal.z - a.dist >= 0 ? n = i.children[0] : n = i.children[1];
|
|
492
|
+
}
|
|
493
|
+
return n < 0 ? ~n : 0;
|
|
494
|
+
}
|
|
495
|
+
decompressVis(e) {
|
|
496
|
+
const t = [], n = this.bsp.leaves.length;
|
|
497
|
+
let r = 1, i = e;
|
|
498
|
+
const a = this.bsp.visibility;
|
|
499
|
+
for (; r < n; )
|
|
500
|
+
if (a[i] === 0) {
|
|
501
|
+
const c = a[i + 1];
|
|
502
|
+
r += c * 8, i += 2;
|
|
503
|
+
} else {
|
|
504
|
+
for (let c = 0; c < 8; c++)
|
|
505
|
+
a[i] & 1 << c && t.push(r), r++;
|
|
506
|
+
i++;
|
|
507
|
+
}
|
|
508
|
+
return t;
|
|
509
|
+
}
|
|
510
|
+
}
|
|
511
|
+
class os {
|
|
512
|
+
constructor(e, t) {
|
|
513
|
+
g(this, "scene");
|
|
514
|
+
g(this, "bsp", null);
|
|
515
|
+
g(this, "textures", /* @__PURE__ */ new Map());
|
|
516
|
+
g(this, "entityRenderer");
|
|
517
|
+
g(this, "entitiesGroup", null);
|
|
518
|
+
g(this, "brushEntitiesGroup", null);
|
|
519
|
+
g(this, "pvsManager", null);
|
|
520
|
+
g(this, "worldGroup", null);
|
|
521
|
+
g(this, "leafToMaterials", /* @__PURE__ */ new Map());
|
|
522
|
+
g(this, "materialMeshes", /* @__PURE__ */ new Map());
|
|
523
|
+
g(this, "lightmapAtlas", null);
|
|
524
|
+
g(this, "materialCache", /* @__PURE__ */ new Map());
|
|
525
|
+
g(this, "atlasWidth", 2048);
|
|
526
|
+
g(this, "atlasHeight", 2048);
|
|
527
|
+
g(this, "faceLightmapInfo", /* @__PURE__ */ new Map());
|
|
528
|
+
g(this, "currentLeafIdx", -1);
|
|
529
|
+
g(this, "pvsEnabled", !1);
|
|
530
|
+
g(this, "highlightGroup", null);
|
|
531
|
+
g(this, "connectionsGroup", null);
|
|
532
|
+
g(this, "brushWireframesVisible", !0);
|
|
533
|
+
g(this, "axesVisible", !0);
|
|
534
|
+
g(this, "aaaTriggerOpacity", 0.5);
|
|
535
|
+
g(this, "entityConnectionsMode", "none");
|
|
536
|
+
g(this, "entityCenters", /* @__PURE__ */ new Map());
|
|
537
|
+
g(this, "selectedEntity", null);
|
|
538
|
+
g(this, "onProgress");
|
|
539
|
+
g(this, "connectionMaterials", {
|
|
540
|
+
yellow: new l.LineBasicMaterial({ color: 16776960, depthTest: !0 }),
|
|
541
|
+
green: new l.LineBasicMaterial({ color: 65280, depthTest: !0 })
|
|
542
|
+
});
|
|
543
|
+
this.scene = e, this.entityRenderer = new ns(e), this.onProgress = t;
|
|
544
|
+
}
|
|
545
|
+
dispose() {
|
|
546
|
+
this.cleanup();
|
|
547
|
+
}
|
|
548
|
+
cleanup() {
|
|
549
|
+
this.clearHighlight(), this.clearConnections(), this.worldGroup && (this.worldGroup.traverse((t) => {
|
|
550
|
+
t instanceof l.Mesh && t.geometry.dispose();
|
|
551
|
+
}), this.scene.remove(this.worldGroup), this.worldGroup = null), this.brushEntitiesGroup && (this.brushEntitiesGroup.traverse((t) => {
|
|
552
|
+
t instanceof l.Mesh && t.geometry.dispose();
|
|
553
|
+
}), this.scene.remove(this.brushEntitiesGroup), this.brushEntitiesGroup = null);
|
|
554
|
+
const e = this.scene.getObjectByName("origin_axes");
|
|
555
|
+
e && (e.traverse((t) => {
|
|
556
|
+
t.geometry && t.geometry.dispose(), t.material && (Array.isArray(t.material) ? t.material.forEach((n) => n.dispose()) : t.material.dispose());
|
|
557
|
+
}), this.scene.remove(e)), this.materialCache.forEach((t) => {
|
|
558
|
+
t.uniforms.diffuseMap.value && t.uniforms.diffuseMap.value.dispose(), t.dispose();
|
|
559
|
+
}), this.materialCache.clear(), this.textures.forEach((t) => t.dispose()), this.textures.clear(), this.lightmapAtlas && (this.lightmapAtlas.dispose(), this.lightmapAtlas = null), this.leafToMaterials.clear(), this.faceLightmapInfo.clear(), this.entityCenters.clear();
|
|
560
|
+
}
|
|
561
|
+
async loadMap(e, t, n) {
|
|
562
|
+
var i, a, c, o, u, f, d, v;
|
|
563
|
+
this.cleanup(), (i = this.onProgress) == null || i.call(this, 10, "Parsing BSP...");
|
|
564
|
+
const r = new ss(e);
|
|
565
|
+
this.bsp = r.parse(), this.pvsManager = new as(this.bsp), n && ((a = this.onProgress) == null || a.call(this, 20, "Parsing FGD..."), await this.entityRenderer.loadFgd(n)), (c = this.onProgress) == null || c.call(this, 30, "Parsing WADs...");
|
|
566
|
+
for (let E = 0; E < t.length; E++) {
|
|
567
|
+
const m = t[E];
|
|
568
|
+
try {
|
|
569
|
+
new is(m).parse().forEach((x, w) => {
|
|
570
|
+
const k = this.createThreeTexture(x);
|
|
571
|
+
this.textures.set(w.toLowerCase(), k);
|
|
572
|
+
});
|
|
573
|
+
} catch (M) {
|
|
574
|
+
console.error("[MapRenderer] Failed to parse WAD", M);
|
|
575
|
+
}
|
|
576
|
+
(o = this.onProgress) == null || o.call(this, 30 + E / t.length * 20, `Loading textures... (${E + 1}/${t.length})`);
|
|
577
|
+
}
|
|
578
|
+
console.log(`[MapRenderer] Total textures registered: ${this.textures.size}`), (u = this.onProgress) == null || u.call(this, 60, "Generating Lightmaps..."), this.generateLightmapAtlas(), (f = this.onProgress) == null || f.call(this, 70, "Building World Geometry..."), this.renderWorld(), (d = this.onProgress) == null || d.call(this, 90, "Rendering Entities..."), this.entitiesGroup = this.entityRenderer.renderEntities(this.bsp.entities), this.calculateEntityCenters(), this.drawOriginAxes(), this.renderConnections(), (v = this.onProgress) == null || v.call(this, 100, "Ready");
|
|
579
|
+
}
|
|
580
|
+
calculateEntityCenters() {
|
|
581
|
+
this.bsp && (this.entityCenters.clear(), this.bsp.entities.forEach((e) => {
|
|
582
|
+
if (e.model && e.model.startsWith("*")) {
|
|
583
|
+
const t = parseInt(e.model.substring(1)), n = this.bsp.models[t];
|
|
584
|
+
if (n) {
|
|
585
|
+
const r = new l.Vector3(1 / 0, 1 / 0, 1 / 0), i = new l.Vector3(-1 / 0, -1 / 0, -1 / 0);
|
|
586
|
+
for (let c = 0; c < n.numFaces; c++) {
|
|
587
|
+
const o = this.bsp.faces[n.firstFace + c];
|
|
588
|
+
for (let u = 0; u < o.numEdges; u++) {
|
|
589
|
+
const f = this.bsp.surfEdges[o.firstEdge + u], d = this.bsp.edges[Math.abs(f)], v = f >= 0 ? d.v[0] : d.v[1], E = this.bsp.vertices[v], m = Q(E);
|
|
590
|
+
r.min(m), i.max(m);
|
|
591
|
+
}
|
|
592
|
+
}
|
|
593
|
+
const a = new l.Vector3().addVectors(r, i).multiplyScalar(0.5);
|
|
594
|
+
if (e.origin) {
|
|
595
|
+
const c = e.origin.split(" ").map(Number);
|
|
596
|
+
c.length === 3 && a.add(Q({ x: c[0], y: c[1], z: c[2] }));
|
|
597
|
+
}
|
|
598
|
+
this.entityCenters.set(e, a);
|
|
599
|
+
}
|
|
600
|
+
} else if (e.origin) {
|
|
601
|
+
const t = e.origin.split(" ").map(Number);
|
|
602
|
+
t.length === 3 && this.entityCenters.set(e, Q({ x: t[0], y: t[1], z: t[2] }));
|
|
603
|
+
}
|
|
604
|
+
}));
|
|
605
|
+
}
|
|
606
|
+
drawOriginAxes() {
|
|
607
|
+
const t = new l.Vector3(0, 0, 0), n = new l.Vector3(0, 0, -1), r = new l.Vector3(-1, 0, 0), i = new l.Vector3(0, 1, 0), a = new l.Group();
|
|
608
|
+
a.name = "origin_axes";
|
|
609
|
+
const c = new l.ArrowHelper(n, t, 128, 16711680), o = new l.ArrowHelper(r, t, 128, 65280), u = new l.ArrowHelper(i, t, 128, 255);
|
|
610
|
+
a.add(c), a.add(o), a.add(u);
|
|
611
|
+
const f = (d, v, E) => {
|
|
612
|
+
const m = document.createElement("canvas");
|
|
613
|
+
m.width = 64, m.height = 64;
|
|
614
|
+
const M = m.getContext("2d");
|
|
615
|
+
M && (M.fillStyle = E, M.font = "Bold 48px Arial", M.textAlign = "center", M.fillText(d, 32, 48));
|
|
616
|
+
const R = new l.CanvasTexture(m), x = new l.SpriteMaterial({ map: R, depthTest: !0 }), w = new l.Sprite(x);
|
|
617
|
+
return w.position.copy(v), w.scale.set(20, 20, 1), w;
|
|
618
|
+
};
|
|
619
|
+
a.add(f("X", n.clone().multiplyScalar(143), "#ff0000")), a.add(f("Y", r.clone().multiplyScalar(143), "#00ff00")), a.add(f("Z", i.clone().multiplyScalar(143), "#0000ff")), a.visible = this.axesVisible, this.scene.add(a);
|
|
620
|
+
}
|
|
621
|
+
calcFaceTextureStep(e) {
|
|
622
|
+
if (!this.bsp) return 16;
|
|
623
|
+
const t = this.bsp.faces[e], n = this.bsp.texInfos[t.texInfo];
|
|
624
|
+
return this.bsp.version === 31 ? 8 : n.flags & 2 ? 1 : n.flags & 8 ? 8 : 16;
|
|
625
|
+
}
|
|
626
|
+
generateLightmapAtlas() {
|
|
627
|
+
if (!this.bsp) return;
|
|
628
|
+
const e = new Uint8Array(this.atlasWidth * this.atlasHeight * 4);
|
|
629
|
+
let t = 0, n = 0, r = 0;
|
|
630
|
+
for (let i = 0; i < this.bsp.faces.length; i++) {
|
|
631
|
+
const a = this.bsp.faces[i];
|
|
632
|
+
if (!a || a.lightmapOffset === -1) continue;
|
|
633
|
+
const c = this.bsp.texInfos[a.texInfo];
|
|
634
|
+
if (!c) continue;
|
|
635
|
+
const o = this.calcFaceTextureStep(i);
|
|
636
|
+
let u = 1 / 0, f = -1 / 0, d = 1 / 0, v = -1 / 0;
|
|
637
|
+
const E = a.firstEdge, m = a.numEdges;
|
|
638
|
+
for (let T = 0; T < m; T++) {
|
|
639
|
+
const H = this.bsp.surfEdges[E + T], D = this.bsp.edges[Math.abs(H)], W = H >= 0 ? D.v[0] : D.v[1], j = this.bsp.vertices[W], N = j.x * c.s.x + j.y * c.s.y + j.z * c.s.z + c.shiftS, U = j.x * c.t.x + j.y * c.t.y + j.z * c.t.z + c.shiftT;
|
|
640
|
+
u = Math.min(u, N), f = Math.max(f, N), d = Math.min(d, U), v = Math.max(v, U);
|
|
641
|
+
}
|
|
642
|
+
const M = Math.floor(u / o), R = Math.floor(d / o), x = Math.ceil(f / o), w = Math.ceil(v / o), k = x - M + 1, O = w - R + 1, I = k + 2, $ = O + 2;
|
|
643
|
+
if (t + I > this.atlasWidth && (t = 0, n += r, r = 0), n + $ > this.atlasHeight) continue;
|
|
644
|
+
const z = k * O * 3;
|
|
645
|
+
if (a.lightmapOffset + z <= this.bsp.lighting.length) {
|
|
646
|
+
const T = this.bsp.lighting.subarray(a.lightmapOffset, a.lightmapOffset + z), H = (D, W) => {
|
|
647
|
+
const j = Math.max(0, Math.min(k - 1, D)), U = (Math.max(0, Math.min(O - 1, W)) * k + j) * 3;
|
|
648
|
+
return [T[U], T[U + 1], T[U + 2]];
|
|
649
|
+
};
|
|
650
|
+
for (let D = 0; D < $; D++)
|
|
651
|
+
for (let W = 0; W < I; W++) {
|
|
652
|
+
const [j, N, U] = H(W - 1, D - 1), Y = ((n + D) * this.atlasWidth + (t + W)) * 4;
|
|
653
|
+
e[Y + 0] = j, e[Y + 1] = N, e[Y + 2] = U, e[Y + 3] = 255;
|
|
654
|
+
}
|
|
655
|
+
}
|
|
656
|
+
this.faceLightmapInfo.set(i, { x: t, y: n, w: k, h: O, minU_step: M, minV_step: R, step: o }), t += I, r = Math.max(r, $);
|
|
657
|
+
}
|
|
658
|
+
this.lightmapAtlas = new l.DataTexture(e, this.atlasWidth, this.atlasHeight, l.RGBAFormat), this.lightmapAtlas.magFilter = l.LinearFilter, this.lightmapAtlas.minFilter = l.LinearFilter, this.lightmapAtlas.generateMipmaps = !1, this.lightmapAtlas.needsUpdate = !0;
|
|
659
|
+
}
|
|
660
|
+
getEntityByModelIndex(e) {
|
|
661
|
+
if (this.bsp)
|
|
662
|
+
return this.bsp.entities.find((t) => t.model === `*${e}`);
|
|
663
|
+
}
|
|
664
|
+
createThreeTexture(e) {
|
|
665
|
+
const { width: t, height: n, data: r, palette: i } = e;
|
|
666
|
+
if (!r || !i)
|
|
667
|
+
return console.warn(`[MapRenderer] Missing data/palette for texture ${e.name}`), new l.DataTexture(new Uint8Array([255, 0, 255, 255]), 1, 1, l.RGBAFormat);
|
|
668
|
+
const a = new Uint8Array(t * n * 4), c = e.name.startsWith("{");
|
|
669
|
+
for (let u = 0; u < t * n; u++) {
|
|
670
|
+
const f = r[u], d = f * 3;
|
|
671
|
+
a[u * 4 + 0] = i[d + 0], a[u * 4 + 1] = i[d + 1], a[u * 4 + 2] = i[d + 2], a[u * 4 + 3] = c && f === 255 ? 0 : 255;
|
|
672
|
+
}
|
|
673
|
+
const o = new l.DataTexture(a, t, n, l.RGBAFormat);
|
|
674
|
+
return o.wrapS = l.RepeatWrapping, o.wrapT = l.RepeatWrapping, o.minFilter = l.LinearFilter, o.magFilter = l.LinearFilter, o.needsUpdate = !0, o;
|
|
675
|
+
}
|
|
676
|
+
getMaterial(e, t, n = 1) {
|
|
677
|
+
const r = e.name.toLowerCase(), i = `${r}-${t}-${n}`;
|
|
678
|
+
if (this.materialCache.has(i)) return this.materialCache.get(i);
|
|
679
|
+
const a = this.textures.get(r);
|
|
680
|
+
a || console.warn(`[MapRenderer] Texture not found in registry: ${r}`);
|
|
681
|
+
const c = new l.ShaderMaterial({
|
|
682
|
+
uniforms: {
|
|
683
|
+
diffuseMap: { value: a || null },
|
|
684
|
+
lightmapAtlas: { value: this.lightmapAtlas },
|
|
685
|
+
hasLightmap: { value: t },
|
|
686
|
+
opacity: { value: n }
|
|
687
|
+
},
|
|
688
|
+
vertexShader: Ye.vertexShader,
|
|
689
|
+
fragmentShader: Ye.fragmentShader,
|
|
690
|
+
transparent: e.name.startsWith("{") || n < 1,
|
|
691
|
+
side: l.FrontSide,
|
|
692
|
+
depthWrite: n >= 1
|
|
693
|
+
});
|
|
694
|
+
return this.materialCache.set(i, c), c;
|
|
695
|
+
}
|
|
696
|
+
renderWorld() {
|
|
697
|
+
if (!this.bsp) return;
|
|
698
|
+
this.worldGroup = new l.Group(), this.worldGroup.name = "world", this.leafToMaterials.clear(), this.materialMeshes.clear();
|
|
699
|
+
const t = this.bsp.models.map((i) => {
|
|
700
|
+
const a = /* @__PURE__ */ new Set();
|
|
701
|
+
for (let c = 0; c < i.numFaces; c++)
|
|
702
|
+
a.add(i.firstFace + c);
|
|
703
|
+
return a;
|
|
704
|
+
})[0], n = /* @__PURE__ */ new Map(), r = [];
|
|
705
|
+
for (let i = 0; i < this.bsp.faces.length; i++) {
|
|
706
|
+
if (!t.has(i)) {
|
|
707
|
+
r[i] = "";
|
|
708
|
+
continue;
|
|
709
|
+
}
|
|
710
|
+
const a = this.bsp.faces[i], c = this.bsp.texInfos[a.texInfo], o = this.bsp.textures[c.miptex];
|
|
711
|
+
if (!o) {
|
|
712
|
+
r[i] = "";
|
|
713
|
+
continue;
|
|
714
|
+
}
|
|
715
|
+
const u = this.faceLightmapInfo.get(i), f = u ? { x: u.x, y: u.y, atlasWidth: this.atlasWidth, atlasHeight: this.atlasHeight, minU_step: u.minU_step, minV_step: u.minV_step, step: u.step } : void 0, d = He(this.bsp, i, f);
|
|
716
|
+
if (!d) {
|
|
717
|
+
r[i] = "";
|
|
718
|
+
continue;
|
|
719
|
+
}
|
|
720
|
+
const v = this.getMaterial(o, !!u), E = `${o.name}-${!!u}-1`;
|
|
721
|
+
r[i] = E, n.has(E) || n.set(E, { pos: [], uv: [], luv: [], mat: v });
|
|
722
|
+
const m = n.get(E);
|
|
723
|
+
m.pos.push(...Array.from(d.positions)), m.uv.push(...Array.from(d.uvs)), m.luv.push(...Array.from(d.lightUvs));
|
|
724
|
+
}
|
|
725
|
+
this.bsp.leaves.forEach((i, a) => {
|
|
726
|
+
this.leafToMaterials.has(a) || this.leafToMaterials.set(a, /* @__PURE__ */ new Set());
|
|
727
|
+
for (let c = 0; c < i.numMarkSurfaces; c++) {
|
|
728
|
+
const o = this.bsp.markSurfaces[i.firstMarkSurface + c], u = r[o];
|
|
729
|
+
u && this.leafToMaterials.get(a).add(u);
|
|
730
|
+
}
|
|
731
|
+
}), n.forEach((i, a) => {
|
|
732
|
+
const c = new l.BufferGeometry();
|
|
733
|
+
c.setAttribute("position", new l.BufferAttribute(new Float32Array(i.pos), 3)), c.setAttribute("uv", new l.BufferAttribute(new Float32Array(i.uv), 2)), c.setAttribute("lightUv", new l.BufferAttribute(new Float32Array(i.luv), 2)), c.computeVertexNormals();
|
|
734
|
+
const o = new l.Mesh(c, i.mat);
|
|
735
|
+
o.name = `material_${a}`, this.worldGroup.add(o), this.materialMeshes.set(a, o);
|
|
736
|
+
}), this.scene.add(this.worldGroup), this.brushEntitiesGroup = new l.Group(), this.brushEntitiesGroup.name = "brush_entities";
|
|
737
|
+
for (let i = 1; i < this.bsp.models.length; i++) {
|
|
738
|
+
const a = this.getEntityByModelIndex(i), c = this.bsp.models[i];
|
|
739
|
+
let o = !1;
|
|
740
|
+
for (let m = 0; m < c.numFaces; m++) {
|
|
741
|
+
const M = c.firstFace + m, R = this.bsp.faces[M], x = this.bsp.texInfos[R.texInfo], w = this.bsp.textures[x.miptex];
|
|
742
|
+
if (w && w.name.toLowerCase() === "aaatrigger") {
|
|
743
|
+
o = !0;
|
|
744
|
+
break;
|
|
745
|
+
}
|
|
746
|
+
}
|
|
747
|
+
let u = 1;
|
|
748
|
+
const f = a ? parseInt(a.rendermode || "0") : 0;
|
|
749
|
+
o ? u = this.aaaTriggerOpacity : a && f !== 0 && a.renderamt !== void 0 && (u = parseInt(a.renderamt) / 255);
|
|
750
|
+
const d = new l.Group();
|
|
751
|
+
if (d.name = `model_${i}`, a) {
|
|
752
|
+
if (d.userData.entity = a, a.origin) {
|
|
753
|
+
const m = a.origin.split(" ").map(Number);
|
|
754
|
+
m.length === 3 && d.position.copy(Q({ x: m[0], y: m[1], z: m[2] }));
|
|
755
|
+
}
|
|
756
|
+
if (a.angles) {
|
|
757
|
+
const m = a.angles.split(" ").map(Number);
|
|
758
|
+
if (m.length === 3) {
|
|
759
|
+
const M = l.MathUtils.degToRad(m[0]), R = l.MathUtils.degToRad(m[1]), x = l.MathUtils.degToRad(m[2]);
|
|
760
|
+
d.rotation.set(M, R, x, "YXZ");
|
|
761
|
+
}
|
|
762
|
+
}
|
|
763
|
+
}
|
|
764
|
+
const v = /* @__PURE__ */ new Map(), E = /* @__PURE__ */ new Set();
|
|
765
|
+
for (let m = 0; m < c.numFaces; m++) {
|
|
766
|
+
const M = c.firstFace + m, R = this.bsp.faces[M], x = this.bsp.texInfos[R.texInfo], w = this.bsp.textures[x.miptex], k = this.faceLightmapInfo.get(M), O = k ? { x: k.x, y: k.y, atlasWidth: this.atlasWidth, atlasHeight: this.atlasHeight, minU_step: k.minU_step, minV_step: k.minV_step, step: k.step } : void 0, I = He(this.bsp, M, O);
|
|
767
|
+
if (!I) continue;
|
|
768
|
+
const $ = this.getMaterial(w, !!k, u), z = `${w.name}-${!!k}-${u}`;
|
|
769
|
+
w.name && E.add(w.name), v.has(z) || v.set(z, { pos: [], uv: [], luv: [], mat: $ });
|
|
770
|
+
const T = v.get(z);
|
|
771
|
+
T.pos.push(...Array.from(I.positions)), T.uv.push(...Array.from(I.uvs)), T.luv.push(...Array.from(I.lightUvs));
|
|
772
|
+
}
|
|
773
|
+
a && (a.info_textures = Array.from(E).join(";")), v.forEach((m) => {
|
|
774
|
+
const M = new l.BufferGeometry();
|
|
775
|
+
M.setAttribute("position", new l.BufferAttribute(new Float32Array(m.pos), 3)), M.setAttribute("uv", new l.BufferAttribute(new Float32Array(m.uv), 2)), M.setAttribute("lightUv", new l.BufferAttribute(new Float32Array(m.luv), 2)), M.computeVertexNormals(), M.computeBoundingBox(), M.computeBoundingSphere();
|
|
776
|
+
const R = new l.Mesh(M, m.mat);
|
|
777
|
+
R.userData.entity = a;
|
|
778
|
+
const x = new l.EdgesGeometry(M), w = new l.LineBasicMaterial({ color: 16777215, transparent: !0, opacity: 0.5 }), k = new l.LineSegments(x, w);
|
|
779
|
+
k.name = "helper_wireframe", k.visible = this.brushWireframesVisible, R.add(k), d.add(R);
|
|
780
|
+
}), this.brushEntitiesGroup.add(d);
|
|
781
|
+
}
|
|
782
|
+
this.scene.add(this.brushEntitiesGroup);
|
|
783
|
+
}
|
|
784
|
+
setEntitiesVisible(e) {
|
|
785
|
+
this.entitiesGroup && (this.entitiesGroup.visible = e);
|
|
786
|
+
}
|
|
787
|
+
setBrushEntitiesVisible(e) {
|
|
788
|
+
this.brushEntitiesGroup && (this.brushEntitiesGroup.visible = e);
|
|
789
|
+
}
|
|
790
|
+
setBrushWireframesVisible(e) {
|
|
791
|
+
this.brushWireframesVisible = e, this.bsp && this.brushEntitiesGroup && (this.brushEntitiesGroup.traverse((t) => {
|
|
792
|
+
t.name === "helper_wireframe" && (t.visible = e);
|
|
793
|
+
}), this.selectedEntity && this.highlightEntity(this.selectedEntity));
|
|
794
|
+
}
|
|
795
|
+
setAxesVisible(e) {
|
|
796
|
+
this.axesVisible = e;
|
|
797
|
+
const t = this.scene.getObjectByName("origin_axes");
|
|
798
|
+
t && (t.visible = e);
|
|
799
|
+
}
|
|
800
|
+
setAaaTriggerOpacity(e) {
|
|
801
|
+
this.aaaTriggerOpacity = e / 100, this.bsp && (this.materialCache.forEach((t, n) => {
|
|
802
|
+
n.toLowerCase().startsWith("aaatrigger-") && (t.uniforms.opacity.value = this.aaaTriggerOpacity, t.transparent = this.aaaTriggerOpacity < 1, t.depthWrite = this.aaaTriggerOpacity >= 1, t.needsUpdate = !0);
|
|
803
|
+
}), this.brushEntitiesGroup && this.brushEntitiesGroup.traverse((t) => {
|
|
804
|
+
var n;
|
|
805
|
+
if (t instanceof l.Mesh) {
|
|
806
|
+
const r = t.userData.entity, i = (n = r == null ? void 0 : r.model) != null && n.startsWith("*") ? parseInt(r.model.substring(1)) : -1;
|
|
807
|
+
if (i !== -1) {
|
|
808
|
+
const a = this.bsp.models[i];
|
|
809
|
+
let c = !1;
|
|
810
|
+
for (let o = 0; o < a.numFaces; o++) {
|
|
811
|
+
const u = a.firstFace + o, f = this.bsp.faces[u], d = this.bsp.texInfos[f.texInfo], v = this.bsp.textures[d.miptex];
|
|
812
|
+
if (v && v.name.toLowerCase() === "aaatrigger") {
|
|
813
|
+
c = !0;
|
|
814
|
+
break;
|
|
815
|
+
}
|
|
816
|
+
}
|
|
817
|
+
c && t.material instanceof l.ShaderMaterial && (t.material.uniforms.opacity.value = this.aaaTriggerOpacity, t.material.transparent = this.aaaTriggerOpacity < 1, t.material.depthWrite = this.aaaTriggerOpacity >= 1);
|
|
818
|
+
}
|
|
819
|
+
}
|
|
820
|
+
}));
|
|
821
|
+
}
|
|
822
|
+
setEntityConnectionsMode(e) {
|
|
823
|
+
this.entityConnectionsMode = e, this.bsp && this.renderConnections();
|
|
824
|
+
}
|
|
825
|
+
setTextureFiltering(e) {
|
|
826
|
+
const t = e ? l.LinearFilter : l.NearestFilter;
|
|
827
|
+
this.textures.forEach((n) => {
|
|
828
|
+
n.magFilter = t, n.minFilter = t, n.needsUpdate = !0;
|
|
829
|
+
});
|
|
830
|
+
}
|
|
831
|
+
setLightmapFiltering(e) {
|
|
832
|
+
if (!this.lightmapAtlas) return;
|
|
833
|
+
const t = e ? l.LinearFilter : l.NearestFilter;
|
|
834
|
+
this.lightmapAtlas.magFilter = t, this.lightmapAtlas.minFilter = t, this.lightmapAtlas.needsUpdate = !0;
|
|
835
|
+
}
|
|
836
|
+
setPvsEnabled(e) {
|
|
837
|
+
this.pvsEnabled !== e && (this.pvsEnabled = e, e || (this.materialMeshes.forEach((t) => {
|
|
838
|
+
t.visible = !0;
|
|
839
|
+
}), this.currentLeafIdx = -1));
|
|
840
|
+
}
|
|
841
|
+
highlightEntity(e) {
|
|
842
|
+
this.clearHighlight(), this.selectedEntity = e, this.highlightGroup = new l.Group(), this.highlightGroup.name = "selection_highlight";
|
|
843
|
+
const t = [];
|
|
844
|
+
if (this.scene.traverse((o) => {
|
|
845
|
+
o instanceof l.Mesh && o.userData.entity === e && t.push(o);
|
|
846
|
+
}), t.length === 0) return;
|
|
847
|
+
const n = new l.LineBasicMaterial({ color: 16711680, transparent: !1, depthTest: !1 }), r = new l.PointsMaterial({ color: 16711680, size: 5, sizeAttenuation: !1, depthTest: !1 });
|
|
848
|
+
t.forEach((o) => {
|
|
849
|
+
const u = new l.EdgesGeometry(o.geometry), f = new l.LineSegments(u, n);
|
|
850
|
+
f.renderOrder = 9999, f.position.copy(o.position), f.quaternion.copy(o.quaternion), f.scale.copy(o.scale), o.parent && o.parent !== this.scene && o.parent !== this.brushEntitiesGroup && (f.position.applyMatrix4(o.parent.matrixWorld), f.quaternion.setFromRotationMatrix(o.parent.matrixWorld)), o.children.forEach((d) => {
|
|
851
|
+
(d.name === "helper_wireframe" || d.name === "point_helper_wireframe") && (d.visible = !1);
|
|
852
|
+
}), this.highlightGroup.add(f);
|
|
853
|
+
});
|
|
854
|
+
let i = new l.Vector3(0, 0, 0);
|
|
855
|
+
if (e.origin) {
|
|
856
|
+
const o = e.origin.split(" ").map(Number);
|
|
857
|
+
o.length === 3 && (i = Q({ x: o[0], y: o[1], z: o[2] }));
|
|
858
|
+
} else if (e.model && e.model.startsWith("*")) {
|
|
859
|
+
const o = this.entityCenters.get(e);
|
|
860
|
+
o && i.copy(o);
|
|
861
|
+
}
|
|
862
|
+
const a = new l.BufferGeometry().setAttribute("position", new l.BufferAttribute(new Float32Array([i.x, i.y, i.z]), 3)), c = new l.Points(a, r);
|
|
863
|
+
c.renderOrder = 1e4, this.highlightGroup.add(c), this.scene.add(this.highlightGroup);
|
|
864
|
+
}
|
|
865
|
+
clearHighlight() {
|
|
866
|
+
this.selectedEntity = null, this.scene.traverse((e) => {
|
|
867
|
+
e.name === "helper_wireframe" ? e.visible = this.brushWireframesVisible : e.name === "point_helper_wireframe" && (e.visible = !0);
|
|
868
|
+
}), this.highlightGroup && (this.highlightGroup.traverse((e) => {
|
|
869
|
+
(e instanceof l.Mesh || e instanceof l.LineSegments || e instanceof l.Points) && e.geometry && e.geometry.dispose();
|
|
870
|
+
}), this.scene.remove(this.highlightGroup), this.highlightGroup = null);
|
|
871
|
+
}
|
|
872
|
+
clearConnections() {
|
|
873
|
+
this.connectionsGroup && (this.connectionsGroup.traverse((e) => {
|
|
874
|
+
e.geometry && e.geometry.dispose(), e.material && e.material.dispose();
|
|
875
|
+
}), this.scene.remove(this.connectionsGroup), this.connectionsGroup = null);
|
|
876
|
+
}
|
|
877
|
+
renderConnections() {
|
|
878
|
+
if (this.clearConnections(), this.entityConnectionsMode === "none" || !this.bsp) return;
|
|
879
|
+
this.connectionsGroup = new l.Group(), this.connectionsGroup.name = "entity_connections";
|
|
880
|
+
const e = this.bsp.entities, t = /* @__PURE__ */ new Map();
|
|
881
|
+
e.forEach((n) => {
|
|
882
|
+
if (n.targetname) {
|
|
883
|
+
const r = n.targetname.toLowerCase();
|
|
884
|
+
t.has(r) || t.set(r, []), t.get(r).push(n);
|
|
885
|
+
}
|
|
886
|
+
}), e.forEach((n) => {
|
|
887
|
+
if (n.target) {
|
|
888
|
+
const r = n.target.toLowerCase(), i = t.get(r);
|
|
889
|
+
i && i.forEach((a) => {
|
|
890
|
+
const c = this.entityCenters.get(n), o = this.entityCenters.get(a);
|
|
891
|
+
if (c && o) {
|
|
892
|
+
let u = !1, f = this.connectionMaterials.yellow;
|
|
893
|
+
if (this.entityConnectionsMode === "all" ? (u = !0, f = this.connectionMaterials.yellow) : this.entityConnectionsMode === "selected" && this.selectedEntity && (n === this.selectedEntity ? (u = !0, f = this.connectionMaterials.yellow) : a === this.selectedEntity && (u = !0, f = this.connectionMaterials.green)), u) {
|
|
894
|
+
const d = new l.BufferGeometry().setFromPoints([c, o]), v = new l.Line(d, f);
|
|
895
|
+
this.connectionsGroup.add(v);
|
|
896
|
+
}
|
|
897
|
+
}
|
|
898
|
+
});
|
|
899
|
+
}
|
|
900
|
+
}), this.scene.add(this.connectionsGroup);
|
|
901
|
+
}
|
|
902
|
+
updateVisibility(e) {
|
|
903
|
+
if (!this.pvsManager || !this.pvsEnabled) return;
|
|
904
|
+
const t = this.pvsManager.getLeafIndex(e);
|
|
905
|
+
if (t === this.currentLeafIdx) return;
|
|
906
|
+
this.currentLeafIdx = t;
|
|
907
|
+
const n = this.pvsManager.getVisibleLeafs(t), r = new Set(n), i = /* @__PURE__ */ new Set();
|
|
908
|
+
r.forEach((a) => {
|
|
909
|
+
const c = this.leafToMaterials.get(a);
|
|
910
|
+
c && c.forEach((o) => i.add(o));
|
|
911
|
+
}), this.materialMeshes.forEach((a, c) => {
|
|
912
|
+
a.visible = i.has(c);
|
|
913
|
+
});
|
|
914
|
+
}
|
|
915
|
+
}
|
|
916
|
+
class cs {
|
|
917
|
+
constructor(e) {
|
|
918
|
+
g(this, "camera");
|
|
919
|
+
g(this, "velocity", new l.Vector3());
|
|
920
|
+
g(this, "moveForward", !1);
|
|
921
|
+
g(this, "moveBackward", !1);
|
|
922
|
+
g(this, "moveLeft", !1);
|
|
923
|
+
g(this, "moveRight", !1);
|
|
924
|
+
g(this, "moveUp", !1);
|
|
925
|
+
g(this, "moveDown", !1);
|
|
926
|
+
g(this, "isSprinting", !1);
|
|
927
|
+
g(this, "enabled", !1);
|
|
928
|
+
g(this, "onKeyDown", (e) => {
|
|
929
|
+
if (this.enabled)
|
|
930
|
+
switch (e.code) {
|
|
931
|
+
case "KeyW":
|
|
932
|
+
this.moveForward = !0;
|
|
933
|
+
break;
|
|
934
|
+
case "KeyS":
|
|
935
|
+
this.moveBackward = !0;
|
|
936
|
+
break;
|
|
937
|
+
case "KeyA":
|
|
938
|
+
this.moveLeft = !0;
|
|
939
|
+
break;
|
|
940
|
+
case "KeyD":
|
|
941
|
+
this.moveRight = !0;
|
|
942
|
+
break;
|
|
943
|
+
case "Space":
|
|
944
|
+
this.moveUp = !0;
|
|
945
|
+
break;
|
|
946
|
+
case "ControlLeft":
|
|
947
|
+
this.moveDown = !0;
|
|
948
|
+
break;
|
|
949
|
+
case "ShiftLeft":
|
|
950
|
+
case "ShiftRight":
|
|
951
|
+
this.isSprinting = !0;
|
|
952
|
+
break;
|
|
953
|
+
}
|
|
954
|
+
});
|
|
955
|
+
g(this, "onKeyUp", (e) => {
|
|
956
|
+
if (this.enabled)
|
|
957
|
+
switch (e.code) {
|
|
958
|
+
case "KeyW":
|
|
959
|
+
this.moveForward = !1;
|
|
960
|
+
break;
|
|
961
|
+
case "KeyS":
|
|
962
|
+
this.moveBackward = !1;
|
|
963
|
+
break;
|
|
964
|
+
case "KeyA":
|
|
965
|
+
this.moveLeft = !1;
|
|
966
|
+
break;
|
|
967
|
+
case "KeyD":
|
|
968
|
+
this.moveRight = !1;
|
|
969
|
+
break;
|
|
970
|
+
case "Space":
|
|
971
|
+
this.moveUp = !1;
|
|
972
|
+
break;
|
|
973
|
+
case "ControlLeft":
|
|
974
|
+
this.moveDown = !1;
|
|
975
|
+
break;
|
|
976
|
+
case "ShiftLeft":
|
|
977
|
+
case "ShiftRight":
|
|
978
|
+
this.isSprinting = !1;
|
|
979
|
+
break;
|
|
980
|
+
}
|
|
981
|
+
});
|
|
982
|
+
this.camera = e, window.addEventListener("keydown", this.onKeyDown), window.addEventListener("keyup", this.onKeyUp);
|
|
983
|
+
}
|
|
984
|
+
update(e) {
|
|
985
|
+
const t = Math.min(e, 0.1), n = 5e3, r = this.isSprinting ? n * 2 : n, i = 15, a = 800, c = this.isSprinting ? a * 2 : a, o = new l.Vector3();
|
|
986
|
+
o.z = Number(this.moveForward) - Number(this.moveBackward), o.x = Number(this.moveRight) - Number(this.moveLeft), o.y = Number(this.moveUp) - Number(this.moveDown), o.normalize(), (this.moveForward || this.moveBackward) && (this.velocity.z += o.z * r * t), (this.moveLeft || this.moveRight) && (this.velocity.x += o.x * r * t), (this.moveUp || this.moveDown) && (this.velocity.y += o.y * r * t), this.velocity.x -= this.velocity.x * i * t, this.velocity.z -= this.velocity.z * i * t, this.velocity.y -= this.velocity.y * i * t;
|
|
987
|
+
const u = this.velocity.length();
|
|
988
|
+
u > c && this.velocity.multiplyScalar(c / u), Math.abs(this.velocity.x) < 1 && (this.velocity.x = 0), Math.abs(this.velocity.y) < 1 && (this.velocity.y = 0), Math.abs(this.velocity.z) < 1 && (this.velocity.z = 0);
|
|
989
|
+
const f = new l.Vector3(0, 0, -1).applyQuaternion(this.camera.quaternion), d = new l.Vector3(1, 0, 0).applyQuaternion(this.camera.quaternion), v = new l.Vector3(0, 1, 0), E = new l.Vector3();
|
|
990
|
+
E.addScaledVector(f, this.velocity.z * t), E.addScaledVector(d, this.velocity.x * t), E.addScaledVector(v, this.velocity.y * t), this.camera.position.add(E);
|
|
991
|
+
}
|
|
992
|
+
dispose() {
|
|
993
|
+
window.removeEventListener("keydown", this.onKeyDown), window.removeEventListener("keyup", this.onKeyUp);
|
|
994
|
+
}
|
|
995
|
+
}
|
|
996
|
+
class ls {
|
|
997
|
+
constructor(e) {
|
|
998
|
+
g(this, "container");
|
|
999
|
+
g(this, "scene");
|
|
1000
|
+
g(this, "camera");
|
|
1001
|
+
g(this, "renderer");
|
|
1002
|
+
g(this, "controls");
|
|
1003
|
+
g(this, "navigator");
|
|
1004
|
+
g(this, "mapRenderer");
|
|
1005
|
+
g(this, "clock");
|
|
1006
|
+
g(this, "requestRef", 0);
|
|
1007
|
+
g(this, "options");
|
|
1008
|
+
g(this, "selectedEntity", null);
|
|
1009
|
+
g(this, "resizeObserver");
|
|
1010
|
+
g(this, "onClickBound");
|
|
1011
|
+
g(this, "eventListeners", /* @__PURE__ */ new Map());
|
|
1012
|
+
this.container = e.container, this.options = {
|
|
1013
|
+
container: e.container,
|
|
1014
|
+
backgroundColor: e.backgroundColor ?? 328965,
|
|
1015
|
+
showAxes: e.showAxes ?? !0,
|
|
1016
|
+
onEntitySelect: e.onEntitySelect ?? (() => {
|
|
1017
|
+
}),
|
|
1018
|
+
onProgress: e.onProgress ?? (() => {
|
|
1019
|
+
}),
|
|
1020
|
+
onLockChange: e.onLockChange ?? (() => {
|
|
1021
|
+
}),
|
|
1022
|
+
pvsEnabled: e.pvsEnabled ?? !1,
|
|
1023
|
+
showPointEntities: e.showPointEntities ?? !0,
|
|
1024
|
+
showBrushEntities: e.showBrushEntities ?? !0,
|
|
1025
|
+
showBrushWireframes: e.showBrushWireframes ?? !0,
|
|
1026
|
+
aaaTriggerOpacity: e.aaaTriggerOpacity ?? 50,
|
|
1027
|
+
entityConnectionsMode: e.entityConnectionsMode ?? "none",
|
|
1028
|
+
textureFiltering: e.textureFiltering ?? !0,
|
|
1029
|
+
lightmapFiltering: e.lightmapFiltering ?? !0,
|
|
1030
|
+
antialias: e.antialias ?? !0
|
|
1031
|
+
}, this.scene = new l.Scene(), this.scene.background = new l.Color(this.options.backgroundColor);
|
|
1032
|
+
const t = this.container.clientWidth / this.container.clientHeight;
|
|
1033
|
+
this.camera = new l.PerspectiveCamera(75, t, 0.1, 1e4), this.camera.position.set(0, 500, 1e3), this.renderer = new l.WebGLRenderer({ antialias: this.options.antialias }), this.renderer.setSize(this.container.clientWidth, this.container.clientHeight), this.renderer.setPixelRatio(window.devicePixelRatio), this.container.appendChild(this.renderer.domElement), this.controls = new Ot(this.camera, this.renderer.domElement), this.navigator = new cs(this.camera);
|
|
1034
|
+
const n = (r, i) => {
|
|
1035
|
+
this.emit("progress", { percent: r, message: i }), this.options.onProgress(r, i);
|
|
1036
|
+
};
|
|
1037
|
+
this.mapRenderer = new os(this.scene, n), this.clock = new l.Clock(), this.onClickBound = this.onClick.bind(this), this.resizeObserver = new ResizeObserver(() => this.onResize()), this.resizeObserver.observe(this.container), this.setupEventListeners(), this.startAnimate(), this.applyOptions(), e.onEntitySelect && this.addEventListener("entitySelect", e.onEntitySelect), e.onLockChange && this.addEventListener("lockChange", e.onLockChange);
|
|
1038
|
+
}
|
|
1039
|
+
setupEventListeners() {
|
|
1040
|
+
this.controls.addEventListener("lock", () => {
|
|
1041
|
+
this.navigator.enabled = !0, this.emit("lockChange", !0);
|
|
1042
|
+
}), this.controls.addEventListener("unlock", () => {
|
|
1043
|
+
this.navigator.enabled = !1, this.emit("lockChange", !1);
|
|
1044
|
+
}), this.container.addEventListener("click", this.onClickBound);
|
|
1045
|
+
}
|
|
1046
|
+
onResize() {
|
|
1047
|
+
const e = this.container.clientWidth, t = this.container.clientHeight;
|
|
1048
|
+
e === 0 || t === 0 || (this.camera.aspect = e / t, this.camera.updateProjectionMatrix(), this.renderer.setSize(e, t));
|
|
1049
|
+
}
|
|
1050
|
+
onClick() {
|
|
1051
|
+
if (this.controls.isLocked)
|
|
1052
|
+
this.handlePicking();
|
|
1053
|
+
else
|
|
1054
|
+
try {
|
|
1055
|
+
this.controls.lock();
|
|
1056
|
+
} catch (e) {
|
|
1057
|
+
console.warn("Pointer lock failed:", e);
|
|
1058
|
+
}
|
|
1059
|
+
}
|
|
1060
|
+
startAnimate() {
|
|
1061
|
+
const e = () => {
|
|
1062
|
+
this.requestRef = requestAnimationFrame(e);
|
|
1063
|
+
const t = this.clock.getDelta();
|
|
1064
|
+
this.navigator.update(t), this.mapRenderer.updateVisibility(this.camera.position), this.renderer.render(this.scene, this.camera);
|
|
1065
|
+
};
|
|
1066
|
+
this.requestRef = requestAnimationFrame(e);
|
|
1067
|
+
}
|
|
1068
|
+
handlePicking() {
|
|
1069
|
+
const e = new l.Raycaster();
|
|
1070
|
+
e.setFromCamera(new l.Vector2(0, 0), this.camera);
|
|
1071
|
+
const t = this.scene.children.filter(
|
|
1072
|
+
(r) => r.name !== "entity_connections" && r.name !== "selection_highlight" && r.name !== "origin_axes"
|
|
1073
|
+
), n = e.intersectObjects(t, !0);
|
|
1074
|
+
if (n.length > 0) {
|
|
1075
|
+
const r = n[0].object;
|
|
1076
|
+
let i = r, a = !0;
|
|
1077
|
+
for (; i; ) {
|
|
1078
|
+
if (!i.visible) {
|
|
1079
|
+
a = !1;
|
|
1080
|
+
break;
|
|
1081
|
+
}
|
|
1082
|
+
i = i.parent;
|
|
1083
|
+
}
|
|
1084
|
+
if (!a) {
|
|
1085
|
+
this.setSelectedEntity(null);
|
|
1086
|
+
return;
|
|
1087
|
+
}
|
|
1088
|
+
let c = null, o = r;
|
|
1089
|
+
for (; o; ) {
|
|
1090
|
+
if (o.userData.entity) {
|
|
1091
|
+
c = o.userData.entity;
|
|
1092
|
+
break;
|
|
1093
|
+
}
|
|
1094
|
+
o = o.parent;
|
|
1095
|
+
}
|
|
1096
|
+
this.setSelectedEntity(c);
|
|
1097
|
+
} else
|
|
1098
|
+
this.setSelectedEntity(null);
|
|
1099
|
+
}
|
|
1100
|
+
async loadMap(e, t, n) {
|
|
1101
|
+
await this.mapRenderer.loadMap(e, t, n), this.applyOptions(), this.setSelectedEntity(this.selectedEntity);
|
|
1102
|
+
}
|
|
1103
|
+
resetView() {
|
|
1104
|
+
this.camera.position.set(0, 500, 1e3), this.camera.lookAt(0, 0, 0);
|
|
1105
|
+
}
|
|
1106
|
+
destroy() {
|
|
1107
|
+
cancelAnimationFrame(this.requestRef), this.resizeObserver.disconnect(), this.container.removeEventListener("click", this.onClickBound), this.controls.dispose(), this.navigator.dispose(), this.mapRenderer.dispose(), this.renderer.dispose(), this.container.contains(this.renderer.domElement) && this.container.removeChild(this.renderer.domElement), this.eventListeners.clear();
|
|
1108
|
+
}
|
|
1109
|
+
// Alias for compatibility if needed, but destroy is the preferred name now
|
|
1110
|
+
dispose() {
|
|
1111
|
+
this.destroy();
|
|
1112
|
+
}
|
|
1113
|
+
// Event Emitter methods
|
|
1114
|
+
addEventListener(e, t) {
|
|
1115
|
+
this.eventListeners.has(e) || this.eventListeners.set(e, /* @__PURE__ */ new Set()), this.eventListeners.get(e).add(t);
|
|
1116
|
+
}
|
|
1117
|
+
removeEventListener(e, t) {
|
|
1118
|
+
var n;
|
|
1119
|
+
(n = this.eventListeners.get(e)) == null || n.delete(t);
|
|
1120
|
+
}
|
|
1121
|
+
emit(e, ...t) {
|
|
1122
|
+
var n;
|
|
1123
|
+
(n = this.eventListeners.get(e)) == null || n.forEach((r) => r(...t));
|
|
1124
|
+
}
|
|
1125
|
+
setOptions(e) {
|
|
1126
|
+
this.options = { ...this.options, ...e }, this.applyOptions(), e.backgroundColor !== void 0 && (this.scene.background = new l.Color(this.options.backgroundColor));
|
|
1127
|
+
}
|
|
1128
|
+
applyOptions() {
|
|
1129
|
+
this.mapRenderer.setPvsEnabled(this.options.pvsEnabled), this.mapRenderer.setEntitiesVisible(this.options.showPointEntities), this.mapRenderer.setBrushEntitiesVisible(this.options.showBrushEntities), this.mapRenderer.setBrushWireframesVisible(this.options.showBrushWireframes), this.mapRenderer.setAxesVisible(this.options.showAxes), this.mapRenderer.setAaaTriggerOpacity(this.options.aaaTriggerOpacity), this.mapRenderer.setEntityConnectionsMode(this.options.entityConnectionsMode), this.mapRenderer.setTextureFiltering(this.options.textureFiltering), this.mapRenderer.setLightmapFiltering(this.options.lightmapFiltering);
|
|
1130
|
+
}
|
|
1131
|
+
// Proxy methods to MapRenderer (kept for backward compatibility and granular control)
|
|
1132
|
+
setPvsEnabled(e) {
|
|
1133
|
+
this.options.pvsEnabled = e, this.mapRenderer.setPvsEnabled(e);
|
|
1134
|
+
}
|
|
1135
|
+
setPointEntitiesVisible(e) {
|
|
1136
|
+
this.options.showPointEntities = e, this.mapRenderer.setEntitiesVisible(e);
|
|
1137
|
+
}
|
|
1138
|
+
setBrushEntitiesVisible(e) {
|
|
1139
|
+
this.options.showBrushEntities = e, this.mapRenderer.setBrushEntitiesVisible(e);
|
|
1140
|
+
}
|
|
1141
|
+
setBrushWireframesVisible(e) {
|
|
1142
|
+
this.options.showBrushWireframes = e, this.mapRenderer.setBrushWireframesVisible(e);
|
|
1143
|
+
}
|
|
1144
|
+
setAxesVisible(e) {
|
|
1145
|
+
this.options.showAxes = e, this.mapRenderer.setAxesVisible(e);
|
|
1146
|
+
}
|
|
1147
|
+
setAaaTriggerOpacity(e) {
|
|
1148
|
+
this.options.aaaTriggerOpacity = e, this.mapRenderer.setAaaTriggerOpacity(e);
|
|
1149
|
+
}
|
|
1150
|
+
setEntityConnectionsMode(e) {
|
|
1151
|
+
this.options.entityConnectionsMode = e, this.mapRenderer.setEntityConnectionsMode(e);
|
|
1152
|
+
}
|
|
1153
|
+
setTextureFiltering(e) {
|
|
1154
|
+
this.options.textureFiltering = e, this.mapRenderer.setTextureFiltering(e);
|
|
1155
|
+
}
|
|
1156
|
+
setLightmapFiltering(e) {
|
|
1157
|
+
this.options.lightmapFiltering = e, this.mapRenderer.setLightmapFiltering(e);
|
|
1158
|
+
}
|
|
1159
|
+
setSelectedEntity(e) {
|
|
1160
|
+
this.selectedEntity = e, e ? this.mapRenderer.highlightEntity(e) : this.mapRenderer.clearHighlight(), this.options.entityConnectionsMode === "selected" && this.mapRenderer.setEntityConnectionsMode("selected"), this.emit("entitySelect", e);
|
|
1161
|
+
}
|
|
1162
|
+
}
|
|
1163
|
+
var oe = { exports: {} }, te = {};
|
|
1164
|
+
/**
|
|
1165
|
+
* @license React
|
|
1166
|
+
* react-jsx-runtime.production.min.js
|
|
1167
|
+
*
|
|
1168
|
+
* Copyright (c) Facebook, Inc. and its affiliates.
|
|
1169
|
+
*
|
|
1170
|
+
* This source code is licensed under the MIT license found in the
|
|
1171
|
+
* LICENSE file in the root directory of this source tree.
|
|
1172
|
+
*/
|
|
1173
|
+
var Ke;
|
|
1174
|
+
function hs() {
|
|
1175
|
+
if (Ke) return te;
|
|
1176
|
+
Ke = 1;
|
|
1177
|
+
var y = Je, e = Symbol.for("react.element"), t = Symbol.for("react.fragment"), n = Object.prototype.hasOwnProperty, r = y.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.ReactCurrentOwner, i = { key: !0, ref: !0, __self: !0, __source: !0 };
|
|
1178
|
+
function a(c, o, u) {
|
|
1179
|
+
var f, d = {}, v = null, E = null;
|
|
1180
|
+
u !== void 0 && (v = "" + u), o.key !== void 0 && (v = "" + o.key), o.ref !== void 0 && (E = o.ref);
|
|
1181
|
+
for (f in o) n.call(o, f) && !i.hasOwnProperty(f) && (d[f] = o[f]);
|
|
1182
|
+
if (c && c.defaultProps) for (f in o = c.defaultProps, o) d[f] === void 0 && (d[f] = o[f]);
|
|
1183
|
+
return { $$typeof: e, type: c, key: v, ref: E, props: d, _owner: r.current };
|
|
1184
|
+
}
|
|
1185
|
+
return te.Fragment = t, te.jsx = a, te.jsxs = a, te;
|
|
1186
|
+
}
|
|
1187
|
+
var se = {};
|
|
1188
|
+
/**
|
|
1189
|
+
* @license React
|
|
1190
|
+
* react-jsx-runtime.development.js
|
|
1191
|
+
*
|
|
1192
|
+
* Copyright (c) Facebook, Inc. and its affiliates.
|
|
1193
|
+
*
|
|
1194
|
+
* This source code is licensed under the MIT license found in the
|
|
1195
|
+
* LICENSE file in the root directory of this source tree.
|
|
1196
|
+
*/
|
|
1197
|
+
var qe;
|
|
1198
|
+
function us() {
|
|
1199
|
+
return qe || (qe = 1, process.env.NODE_ENV !== "production" && (function() {
|
|
1200
|
+
var y = Je, e = Symbol.for("react.element"), t = Symbol.for("react.portal"), n = Symbol.for("react.fragment"), r = Symbol.for("react.strict_mode"), i = Symbol.for("react.profiler"), a = Symbol.for("react.provider"), c = Symbol.for("react.context"), o = Symbol.for("react.forward_ref"), u = Symbol.for("react.suspense"), f = Symbol.for("react.suspense_list"), d = Symbol.for("react.memo"), v = Symbol.for("react.lazy"), E = Symbol.for("react.offscreen"), m = Symbol.iterator, M = "@@iterator";
|
|
1201
|
+
function R(s) {
|
|
1202
|
+
if (s === null || typeof s != "object")
|
|
1203
|
+
return null;
|
|
1204
|
+
var h = m && s[m] || s[M];
|
|
1205
|
+
return typeof h == "function" ? h : null;
|
|
1206
|
+
}
|
|
1207
|
+
var x = y.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED;
|
|
1208
|
+
function w(s) {
|
|
1209
|
+
{
|
|
1210
|
+
for (var h = arguments.length, p = new Array(h > 1 ? h - 1 : 0), b = 1; b < h; b++)
|
|
1211
|
+
p[b - 1] = arguments[b];
|
|
1212
|
+
k("error", s, p);
|
|
1213
|
+
}
|
|
1214
|
+
}
|
|
1215
|
+
function k(s, h, p) {
|
|
1216
|
+
{
|
|
1217
|
+
var b = x.ReactDebugCurrentFrame, L = b.getStackAddendum();
|
|
1218
|
+
L !== "" && (h += "%s", p = p.concat([L]));
|
|
1219
|
+
var F = p.map(function(S) {
|
|
1220
|
+
return String(S);
|
|
1221
|
+
});
|
|
1222
|
+
F.unshift("Warning: " + h), Function.prototype.apply.call(console[s], console, F);
|
|
1223
|
+
}
|
|
1224
|
+
}
|
|
1225
|
+
var O = !1, I = !1, $ = !1, z = !1, T = !1, H;
|
|
1226
|
+
H = Symbol.for("react.module.reference");
|
|
1227
|
+
function D(s) {
|
|
1228
|
+
return !!(typeof s == "string" || typeof s == "function" || s === n || s === i || T || s === r || s === u || s === f || z || s === E || O || I || $ || typeof s == "object" && s !== null && (s.$$typeof === v || s.$$typeof === d || s.$$typeof === a || s.$$typeof === c || s.$$typeof === o || // This needs to include all possible module reference object
|
|
1229
|
+
// types supported by any Flight configuration anywhere since
|
|
1230
|
+
// we don't know which Flight build this will end up being used
|
|
1231
|
+
// with.
|
|
1232
|
+
s.$$typeof === H || s.getModuleId !== void 0));
|
|
1233
|
+
}
|
|
1234
|
+
function W(s, h, p) {
|
|
1235
|
+
var b = s.displayName;
|
|
1236
|
+
if (b)
|
|
1237
|
+
return b;
|
|
1238
|
+
var L = h.displayName || h.name || "";
|
|
1239
|
+
return L !== "" ? p + "(" + L + ")" : p;
|
|
1240
|
+
}
|
|
1241
|
+
function j(s) {
|
|
1242
|
+
return s.displayName || "Context";
|
|
1243
|
+
}
|
|
1244
|
+
function N(s) {
|
|
1245
|
+
if (s == null)
|
|
1246
|
+
return null;
|
|
1247
|
+
if (typeof s.tag == "number" && w("Received an unexpected object in getComponentNameFromType(). This is likely a bug in React. Please file an issue."), typeof s == "function")
|
|
1248
|
+
return s.displayName || s.name || null;
|
|
1249
|
+
if (typeof s == "string")
|
|
1250
|
+
return s;
|
|
1251
|
+
switch (s) {
|
|
1252
|
+
case n:
|
|
1253
|
+
return "Fragment";
|
|
1254
|
+
case t:
|
|
1255
|
+
return "Portal";
|
|
1256
|
+
case i:
|
|
1257
|
+
return "Profiler";
|
|
1258
|
+
case r:
|
|
1259
|
+
return "StrictMode";
|
|
1260
|
+
case u:
|
|
1261
|
+
return "Suspense";
|
|
1262
|
+
case f:
|
|
1263
|
+
return "SuspenseList";
|
|
1264
|
+
}
|
|
1265
|
+
if (typeof s == "object")
|
|
1266
|
+
switch (s.$$typeof) {
|
|
1267
|
+
case c:
|
|
1268
|
+
var h = s;
|
|
1269
|
+
return j(h) + ".Consumer";
|
|
1270
|
+
case a:
|
|
1271
|
+
var p = s;
|
|
1272
|
+
return j(p._context) + ".Provider";
|
|
1273
|
+
case o:
|
|
1274
|
+
return W(s, s.render, "ForwardRef");
|
|
1275
|
+
case d:
|
|
1276
|
+
var b = s.displayName || null;
|
|
1277
|
+
return b !== null ? b : N(s.type) || "Memo";
|
|
1278
|
+
case v: {
|
|
1279
|
+
var L = s, F = L._payload, S = L._init;
|
|
1280
|
+
try {
|
|
1281
|
+
return N(S(F));
|
|
1282
|
+
} catch {
|
|
1283
|
+
return null;
|
|
1284
|
+
}
|
|
1285
|
+
}
|
|
1286
|
+
}
|
|
1287
|
+
return null;
|
|
1288
|
+
}
|
|
1289
|
+
var U = Object.assign, Y = 0, xe, Ee, Me, Re, Ce, _e, Se;
|
|
1290
|
+
function ke() {
|
|
1291
|
+
}
|
|
1292
|
+
ke.__reactDisabledLog = !0;
|
|
1293
|
+
function et() {
|
|
1294
|
+
{
|
|
1295
|
+
if (Y === 0) {
|
|
1296
|
+
xe = console.log, Ee = console.info, Me = console.warn, Re = console.error, Ce = console.group, _e = console.groupCollapsed, Se = console.groupEnd;
|
|
1297
|
+
var s = {
|
|
1298
|
+
configurable: !0,
|
|
1299
|
+
enumerable: !0,
|
|
1300
|
+
value: ke,
|
|
1301
|
+
writable: !0
|
|
1302
|
+
};
|
|
1303
|
+
Object.defineProperties(console, {
|
|
1304
|
+
info: s,
|
|
1305
|
+
log: s,
|
|
1306
|
+
warn: s,
|
|
1307
|
+
error: s,
|
|
1308
|
+
group: s,
|
|
1309
|
+
groupCollapsed: s,
|
|
1310
|
+
groupEnd: s
|
|
1311
|
+
});
|
|
1312
|
+
}
|
|
1313
|
+
Y++;
|
|
1314
|
+
}
|
|
1315
|
+
}
|
|
1316
|
+
function tt() {
|
|
1317
|
+
{
|
|
1318
|
+
if (Y--, Y === 0) {
|
|
1319
|
+
var s = {
|
|
1320
|
+
configurable: !0,
|
|
1321
|
+
enumerable: !0,
|
|
1322
|
+
writable: !0
|
|
1323
|
+
};
|
|
1324
|
+
Object.defineProperties(console, {
|
|
1325
|
+
log: U({}, s, {
|
|
1326
|
+
value: xe
|
|
1327
|
+
}),
|
|
1328
|
+
info: U({}, s, {
|
|
1329
|
+
value: Ee
|
|
1330
|
+
}),
|
|
1331
|
+
warn: U({}, s, {
|
|
1332
|
+
value: Me
|
|
1333
|
+
}),
|
|
1334
|
+
error: U({}, s, {
|
|
1335
|
+
value: Re
|
|
1336
|
+
}),
|
|
1337
|
+
group: U({}, s, {
|
|
1338
|
+
value: Ce
|
|
1339
|
+
}),
|
|
1340
|
+
groupCollapsed: U({}, s, {
|
|
1341
|
+
value: _e
|
|
1342
|
+
}),
|
|
1343
|
+
groupEnd: U({}, s, {
|
|
1344
|
+
value: Se
|
|
1345
|
+
})
|
|
1346
|
+
});
|
|
1347
|
+
}
|
|
1348
|
+
Y < 0 && w("disabledDepth fell below zero. This is a bug in React. Please file an issue.");
|
|
1349
|
+
}
|
|
1350
|
+
}
|
|
1351
|
+
var ce = x.ReactCurrentDispatcher, le;
|
|
1352
|
+
function ie(s, h, p) {
|
|
1353
|
+
{
|
|
1354
|
+
if (le === void 0)
|
|
1355
|
+
try {
|
|
1356
|
+
throw Error();
|
|
1357
|
+
} catch (L) {
|
|
1358
|
+
var b = L.stack.trim().match(/\n( *(at )?)/);
|
|
1359
|
+
le = b && b[1] || "";
|
|
1360
|
+
}
|
|
1361
|
+
return `
|
|
1362
|
+
` + le + s;
|
|
1363
|
+
}
|
|
1364
|
+
}
|
|
1365
|
+
var he = !1, re;
|
|
1366
|
+
{
|
|
1367
|
+
var st = typeof WeakMap == "function" ? WeakMap : Map;
|
|
1368
|
+
re = new st();
|
|
1369
|
+
}
|
|
1370
|
+
function Le(s, h) {
|
|
1371
|
+
if (!s || he)
|
|
1372
|
+
return "";
|
|
1373
|
+
{
|
|
1374
|
+
var p = re.get(s);
|
|
1375
|
+
if (p !== void 0)
|
|
1376
|
+
return p;
|
|
1377
|
+
}
|
|
1378
|
+
var b;
|
|
1379
|
+
he = !0;
|
|
1380
|
+
var L = Error.prepareStackTrace;
|
|
1381
|
+
Error.prepareStackTrace = void 0;
|
|
1382
|
+
var F;
|
|
1383
|
+
F = ce.current, ce.current = null, et();
|
|
1384
|
+
try {
|
|
1385
|
+
if (h) {
|
|
1386
|
+
var S = function() {
|
|
1387
|
+
throw Error();
|
|
1388
|
+
};
|
|
1389
|
+
if (Object.defineProperty(S.prototype, "props", {
|
|
1390
|
+
set: function() {
|
|
1391
|
+
throw Error();
|
|
1392
|
+
}
|
|
1393
|
+
}), typeof Reflect == "object" && Reflect.construct) {
|
|
1394
|
+
try {
|
|
1395
|
+
Reflect.construct(S, []);
|
|
1396
|
+
} catch (G) {
|
|
1397
|
+
b = G;
|
|
1398
|
+
}
|
|
1399
|
+
Reflect.construct(s, [], S);
|
|
1400
|
+
} else {
|
|
1401
|
+
try {
|
|
1402
|
+
S.call();
|
|
1403
|
+
} catch (G) {
|
|
1404
|
+
b = G;
|
|
1405
|
+
}
|
|
1406
|
+
s.call(S.prototype);
|
|
1407
|
+
}
|
|
1408
|
+
} else {
|
|
1409
|
+
try {
|
|
1410
|
+
throw Error();
|
|
1411
|
+
} catch (G) {
|
|
1412
|
+
b = G;
|
|
1413
|
+
}
|
|
1414
|
+
s();
|
|
1415
|
+
}
|
|
1416
|
+
} catch (G) {
|
|
1417
|
+
if (G && b && typeof G.stack == "string") {
|
|
1418
|
+
for (var C = G.stack.split(`
|
|
1419
|
+
`), V = b.stack.split(`
|
|
1420
|
+
`), P = C.length - 1, A = V.length - 1; P >= 1 && A >= 0 && C[P] !== V[A]; )
|
|
1421
|
+
A--;
|
|
1422
|
+
for (; P >= 1 && A >= 0; P--, A--)
|
|
1423
|
+
if (C[P] !== V[A]) {
|
|
1424
|
+
if (P !== 1 || A !== 1)
|
|
1425
|
+
do
|
|
1426
|
+
if (P--, A--, A < 0 || C[P] !== V[A]) {
|
|
1427
|
+
var B = `
|
|
1428
|
+
` + C[P].replace(" at new ", " at ");
|
|
1429
|
+
return s.displayName && B.includes("<anonymous>") && (B = B.replace("<anonymous>", s.displayName)), typeof s == "function" && re.set(s, B), B;
|
|
1430
|
+
}
|
|
1431
|
+
while (P >= 1 && A >= 0);
|
|
1432
|
+
break;
|
|
1433
|
+
}
|
|
1434
|
+
}
|
|
1435
|
+
} finally {
|
|
1436
|
+
he = !1, ce.current = F, tt(), Error.prepareStackTrace = L;
|
|
1437
|
+
}
|
|
1438
|
+
var X = s ? s.displayName || s.name : "", K = X ? ie(X) : "";
|
|
1439
|
+
return typeof s == "function" && re.set(s, K), K;
|
|
1440
|
+
}
|
|
1441
|
+
function it(s, h, p) {
|
|
1442
|
+
return Le(s, !1);
|
|
1443
|
+
}
|
|
1444
|
+
function rt(s) {
|
|
1445
|
+
var h = s.prototype;
|
|
1446
|
+
return !!(h && h.isReactComponent);
|
|
1447
|
+
}
|
|
1448
|
+
function ne(s, h, p) {
|
|
1449
|
+
if (s == null)
|
|
1450
|
+
return "";
|
|
1451
|
+
if (typeof s == "function")
|
|
1452
|
+
return Le(s, rt(s));
|
|
1453
|
+
if (typeof s == "string")
|
|
1454
|
+
return ie(s);
|
|
1455
|
+
switch (s) {
|
|
1456
|
+
case u:
|
|
1457
|
+
return ie("Suspense");
|
|
1458
|
+
case f:
|
|
1459
|
+
return ie("SuspenseList");
|
|
1460
|
+
}
|
|
1461
|
+
if (typeof s == "object")
|
|
1462
|
+
switch (s.$$typeof) {
|
|
1463
|
+
case o:
|
|
1464
|
+
return it(s.render);
|
|
1465
|
+
case d:
|
|
1466
|
+
return ne(s.type, h, p);
|
|
1467
|
+
case v: {
|
|
1468
|
+
var b = s, L = b._payload, F = b._init;
|
|
1469
|
+
try {
|
|
1470
|
+
return ne(F(L), h, p);
|
|
1471
|
+
} catch {
|
|
1472
|
+
}
|
|
1473
|
+
}
|
|
1474
|
+
}
|
|
1475
|
+
return "";
|
|
1476
|
+
}
|
|
1477
|
+
var ee = Object.prototype.hasOwnProperty, Fe = {}, Pe = x.ReactDebugCurrentFrame;
|
|
1478
|
+
function ae(s) {
|
|
1479
|
+
if (s) {
|
|
1480
|
+
var h = s._owner, p = ne(s.type, s._source, h ? h.type : null);
|
|
1481
|
+
Pe.setExtraStackFrame(p);
|
|
1482
|
+
} else
|
|
1483
|
+
Pe.setExtraStackFrame(null);
|
|
1484
|
+
}
|
|
1485
|
+
function nt(s, h, p, b, L) {
|
|
1486
|
+
{
|
|
1487
|
+
var F = Function.call.bind(ee);
|
|
1488
|
+
for (var S in s)
|
|
1489
|
+
if (F(s, S)) {
|
|
1490
|
+
var C = void 0;
|
|
1491
|
+
try {
|
|
1492
|
+
if (typeof s[S] != "function") {
|
|
1493
|
+
var V = Error((b || "React class") + ": " + p + " type `" + S + "` is invalid; it must be a function, usually from the `prop-types` package, but received `" + typeof s[S] + "`.This often happens because of typos such as `PropTypes.function` instead of `PropTypes.func`.");
|
|
1494
|
+
throw V.name = "Invariant Violation", V;
|
|
1495
|
+
}
|
|
1496
|
+
C = s[S](h, S, b, p, null, "SECRET_DO_NOT_PASS_THIS_OR_YOU_WILL_BE_FIRED");
|
|
1497
|
+
} catch (P) {
|
|
1498
|
+
C = P;
|
|
1499
|
+
}
|
|
1500
|
+
C && !(C instanceof Error) && (ae(L), w("%s: type specification of %s `%s` is invalid; the type checker function must return `null` or an `Error` but returned a %s. You may have forgotten to pass an argument to the type checker creator (arrayOf, instanceOf, objectOf, oneOf, oneOfType, and shape all require an argument).", b || "React class", p, S, typeof C), ae(null)), C instanceof Error && !(C.message in Fe) && (Fe[C.message] = !0, ae(L), w("Failed %s type: %s", p, C.message), ae(null));
|
|
1501
|
+
}
|
|
1502
|
+
}
|
|
1503
|
+
}
|
|
1504
|
+
var at = Array.isArray;
|
|
1505
|
+
function ue(s) {
|
|
1506
|
+
return at(s);
|
|
1507
|
+
}
|
|
1508
|
+
function ot(s) {
|
|
1509
|
+
{
|
|
1510
|
+
var h = typeof Symbol == "function" && Symbol.toStringTag, p = h && s[Symbol.toStringTag] || s.constructor.name || "Object";
|
|
1511
|
+
return p;
|
|
1512
|
+
}
|
|
1513
|
+
}
|
|
1514
|
+
function ct(s) {
|
|
1515
|
+
try {
|
|
1516
|
+
return Te(s), !1;
|
|
1517
|
+
} catch {
|
|
1518
|
+
return !0;
|
|
1519
|
+
}
|
|
1520
|
+
}
|
|
1521
|
+
function Te(s) {
|
|
1522
|
+
return "" + s;
|
|
1523
|
+
}
|
|
1524
|
+
function Ae(s) {
|
|
1525
|
+
if (ct(s))
|
|
1526
|
+
return w("The provided key is an unsupported type %s. This value must be coerced to a string before before using it here.", ot(s)), Te(s);
|
|
1527
|
+
}
|
|
1528
|
+
var Ie = x.ReactCurrentOwner, lt = {
|
|
1529
|
+
key: !0,
|
|
1530
|
+
ref: !0,
|
|
1531
|
+
__self: !0,
|
|
1532
|
+
__source: !0
|
|
1533
|
+
}, Ue, Oe;
|
|
1534
|
+
function ht(s) {
|
|
1535
|
+
if (ee.call(s, "ref")) {
|
|
1536
|
+
var h = Object.getOwnPropertyDescriptor(s, "ref").get;
|
|
1537
|
+
if (h && h.isReactWarning)
|
|
1538
|
+
return !1;
|
|
1539
|
+
}
|
|
1540
|
+
return s.ref !== void 0;
|
|
1541
|
+
}
|
|
1542
|
+
function ut(s) {
|
|
1543
|
+
if (ee.call(s, "key")) {
|
|
1544
|
+
var h = Object.getOwnPropertyDescriptor(s, "key").get;
|
|
1545
|
+
if (h && h.isReactWarning)
|
|
1546
|
+
return !1;
|
|
1547
|
+
}
|
|
1548
|
+
return s.key !== void 0;
|
|
1549
|
+
}
|
|
1550
|
+
function ft(s, h) {
|
|
1551
|
+
typeof s.ref == "string" && Ie.current;
|
|
1552
|
+
}
|
|
1553
|
+
function dt(s, h) {
|
|
1554
|
+
{
|
|
1555
|
+
var p = function() {
|
|
1556
|
+
Ue || (Ue = !0, w("%s: `key` is not a prop. Trying to access it will result in `undefined` being returned. If you need to access the same value within the child component, you should pass it as a different prop. (https://reactjs.org/link/special-props)", h));
|
|
1557
|
+
};
|
|
1558
|
+
p.isReactWarning = !0, Object.defineProperty(s, "key", {
|
|
1559
|
+
get: p,
|
|
1560
|
+
configurable: !0
|
|
1561
|
+
});
|
|
1562
|
+
}
|
|
1563
|
+
}
|
|
1564
|
+
function pt(s, h) {
|
|
1565
|
+
{
|
|
1566
|
+
var p = function() {
|
|
1567
|
+
Oe || (Oe = !0, w("%s: `ref` is not a prop. Trying to access it will result in `undefined` being returned. If you need to access the same value within the child component, you should pass it as a different prop. (https://reactjs.org/link/special-props)", h));
|
|
1568
|
+
};
|
|
1569
|
+
p.isReactWarning = !0, Object.defineProperty(s, "ref", {
|
|
1570
|
+
get: p,
|
|
1571
|
+
configurable: !0
|
|
1572
|
+
});
|
|
1573
|
+
}
|
|
1574
|
+
}
|
|
1575
|
+
var gt = function(s, h, p, b, L, F, S) {
|
|
1576
|
+
var C = {
|
|
1577
|
+
// This tag allows us to uniquely identify this as a React Element
|
|
1578
|
+
$$typeof: e,
|
|
1579
|
+
// Built-in properties that belong on the element
|
|
1580
|
+
type: s,
|
|
1581
|
+
key: h,
|
|
1582
|
+
ref: p,
|
|
1583
|
+
props: S,
|
|
1584
|
+
// Record the component responsible for creating this element.
|
|
1585
|
+
_owner: F
|
|
1586
|
+
};
|
|
1587
|
+
return C._store = {}, Object.defineProperty(C._store, "validated", {
|
|
1588
|
+
configurable: !1,
|
|
1589
|
+
enumerable: !1,
|
|
1590
|
+
writable: !0,
|
|
1591
|
+
value: !1
|
|
1592
|
+
}), Object.defineProperty(C, "_self", {
|
|
1593
|
+
configurable: !1,
|
|
1594
|
+
enumerable: !1,
|
|
1595
|
+
writable: !1,
|
|
1596
|
+
value: b
|
|
1597
|
+
}), Object.defineProperty(C, "_source", {
|
|
1598
|
+
configurable: !1,
|
|
1599
|
+
enumerable: !1,
|
|
1600
|
+
writable: !1,
|
|
1601
|
+
value: L
|
|
1602
|
+
}), Object.freeze && (Object.freeze(C.props), Object.freeze(C)), C;
|
|
1603
|
+
};
|
|
1604
|
+
function mt(s, h, p, b, L) {
|
|
1605
|
+
{
|
|
1606
|
+
var F, S = {}, C = null, V = null;
|
|
1607
|
+
p !== void 0 && (Ae(p), C = "" + p), ut(h) && (Ae(h.key), C = "" + h.key), ht(h) && (V = h.ref, ft(h, L));
|
|
1608
|
+
for (F in h)
|
|
1609
|
+
ee.call(h, F) && !lt.hasOwnProperty(F) && (S[F] = h[F]);
|
|
1610
|
+
if (s && s.defaultProps) {
|
|
1611
|
+
var P = s.defaultProps;
|
|
1612
|
+
for (F in P)
|
|
1613
|
+
S[F] === void 0 && (S[F] = P[F]);
|
|
1614
|
+
}
|
|
1615
|
+
if (C || V) {
|
|
1616
|
+
var A = typeof s == "function" ? s.displayName || s.name || "Unknown" : s;
|
|
1617
|
+
C && dt(S, A), V && pt(S, A);
|
|
1618
|
+
}
|
|
1619
|
+
return gt(s, C, V, L, b, Ie.current, S);
|
|
1620
|
+
}
|
|
1621
|
+
}
|
|
1622
|
+
var fe = x.ReactCurrentOwner, je = x.ReactDebugCurrentFrame;
|
|
1623
|
+
function q(s) {
|
|
1624
|
+
if (s) {
|
|
1625
|
+
var h = s._owner, p = ne(s.type, s._source, h ? h.type : null);
|
|
1626
|
+
je.setExtraStackFrame(p);
|
|
1627
|
+
} else
|
|
1628
|
+
je.setExtraStackFrame(null);
|
|
1629
|
+
}
|
|
1630
|
+
var de;
|
|
1631
|
+
de = !1;
|
|
1632
|
+
function pe(s) {
|
|
1633
|
+
return typeof s == "object" && s !== null && s.$$typeof === e;
|
|
1634
|
+
}
|
|
1635
|
+
function Ve() {
|
|
1636
|
+
{
|
|
1637
|
+
if (fe.current) {
|
|
1638
|
+
var s = N(fe.current.type);
|
|
1639
|
+
if (s)
|
|
1640
|
+
return `
|
|
1641
|
+
|
|
1642
|
+
Check the render method of \`` + s + "`.";
|
|
1643
|
+
}
|
|
1644
|
+
return "";
|
|
1645
|
+
}
|
|
1646
|
+
}
|
|
1647
|
+
function vt(s) {
|
|
1648
|
+
return "";
|
|
1649
|
+
}
|
|
1650
|
+
var De = {};
|
|
1651
|
+
function wt(s) {
|
|
1652
|
+
{
|
|
1653
|
+
var h = Ve();
|
|
1654
|
+
if (!h) {
|
|
1655
|
+
var p = typeof s == "string" ? s : s.displayName || s.name;
|
|
1656
|
+
p && (h = `
|
|
1657
|
+
|
|
1658
|
+
Check the top-level render call using <` + p + ">.");
|
|
1659
|
+
}
|
|
1660
|
+
return h;
|
|
1661
|
+
}
|
|
1662
|
+
}
|
|
1663
|
+
function Ne(s, h) {
|
|
1664
|
+
{
|
|
1665
|
+
if (!s._store || s._store.validated || s.key != null)
|
|
1666
|
+
return;
|
|
1667
|
+
s._store.validated = !0;
|
|
1668
|
+
var p = wt(h);
|
|
1669
|
+
if (De[p])
|
|
1670
|
+
return;
|
|
1671
|
+
De[p] = !0;
|
|
1672
|
+
var b = "";
|
|
1673
|
+
s && s._owner && s._owner !== fe.current && (b = " It was passed a child from " + N(s._owner.type) + "."), q(s), w('Each child in a list should have a unique "key" prop.%s%s See https://reactjs.org/link/warning-keys for more information.', p, b), q(null);
|
|
1674
|
+
}
|
|
1675
|
+
}
|
|
1676
|
+
function Ge(s, h) {
|
|
1677
|
+
{
|
|
1678
|
+
if (typeof s != "object")
|
|
1679
|
+
return;
|
|
1680
|
+
if (ue(s))
|
|
1681
|
+
for (var p = 0; p < s.length; p++) {
|
|
1682
|
+
var b = s[p];
|
|
1683
|
+
pe(b) && Ne(b, h);
|
|
1684
|
+
}
|
|
1685
|
+
else if (pe(s))
|
|
1686
|
+
s._store && (s._store.validated = !0);
|
|
1687
|
+
else if (s) {
|
|
1688
|
+
var L = R(s);
|
|
1689
|
+
if (typeof L == "function" && L !== s.entries)
|
|
1690
|
+
for (var F = L.call(s), S; !(S = F.next()).done; )
|
|
1691
|
+
pe(S.value) && Ne(S.value, h);
|
|
1692
|
+
}
|
|
1693
|
+
}
|
|
1694
|
+
}
|
|
1695
|
+
function yt(s) {
|
|
1696
|
+
{
|
|
1697
|
+
var h = s.type;
|
|
1698
|
+
if (h == null || typeof h == "string")
|
|
1699
|
+
return;
|
|
1700
|
+
var p;
|
|
1701
|
+
if (typeof h == "function")
|
|
1702
|
+
p = h.propTypes;
|
|
1703
|
+
else if (typeof h == "object" && (h.$$typeof === o || // Note: Memo only checks outer props here.
|
|
1704
|
+
// Inner props are checked in the reconciler.
|
|
1705
|
+
h.$$typeof === d))
|
|
1706
|
+
p = h.propTypes;
|
|
1707
|
+
else
|
|
1708
|
+
return;
|
|
1709
|
+
if (p) {
|
|
1710
|
+
var b = N(h);
|
|
1711
|
+
nt(p, s.props, "prop", b, s);
|
|
1712
|
+
} else if (h.PropTypes !== void 0 && !de) {
|
|
1713
|
+
de = !0;
|
|
1714
|
+
var L = N(h);
|
|
1715
|
+
w("Component %s declared `PropTypes` instead of `propTypes`. Did you misspell the property assignment?", L || "Unknown");
|
|
1716
|
+
}
|
|
1717
|
+
typeof h.getDefaultProps == "function" && !h.getDefaultProps.isReactClassApproved && w("getDefaultProps is only used on classic React.createClass definitions. Use a static property named `defaultProps` instead.");
|
|
1718
|
+
}
|
|
1719
|
+
}
|
|
1720
|
+
function bt(s) {
|
|
1721
|
+
{
|
|
1722
|
+
for (var h = Object.keys(s.props), p = 0; p < h.length; p++) {
|
|
1723
|
+
var b = h[p];
|
|
1724
|
+
if (b !== "children" && b !== "key") {
|
|
1725
|
+
q(s), w("Invalid prop `%s` supplied to `React.Fragment`. React.Fragment can only have `key` and `children` props.", b), q(null);
|
|
1726
|
+
break;
|
|
1727
|
+
}
|
|
1728
|
+
}
|
|
1729
|
+
s.ref !== null && (q(s), w("Invalid attribute `ref` supplied to `React.Fragment`."), q(null));
|
|
1730
|
+
}
|
|
1731
|
+
}
|
|
1732
|
+
var ze = {};
|
|
1733
|
+
function We(s, h, p, b, L, F) {
|
|
1734
|
+
{
|
|
1735
|
+
var S = D(s);
|
|
1736
|
+
if (!S) {
|
|
1737
|
+
var C = "";
|
|
1738
|
+
(s === void 0 || typeof s == "object" && s !== null && Object.keys(s).length === 0) && (C += " You likely forgot to export your component from the file it's defined in, or you might have mixed up default and named imports.");
|
|
1739
|
+
var V = vt();
|
|
1740
|
+
V ? C += V : C += Ve();
|
|
1741
|
+
var P;
|
|
1742
|
+
s === null ? P = "null" : ue(s) ? P = "array" : s !== void 0 && s.$$typeof === e ? (P = "<" + (N(s.type) || "Unknown") + " />", C = " Did you accidentally export a JSX literal instead of a component?") : P = typeof s, w("React.jsx: type is invalid -- expected a string (for built-in components) or a class/function (for composite components) but got: %s.%s", P, C);
|
|
1743
|
+
}
|
|
1744
|
+
var A = mt(s, h, p, L, F);
|
|
1745
|
+
if (A == null)
|
|
1746
|
+
return A;
|
|
1747
|
+
if (S) {
|
|
1748
|
+
var B = h.children;
|
|
1749
|
+
if (B !== void 0)
|
|
1750
|
+
if (b)
|
|
1751
|
+
if (ue(B)) {
|
|
1752
|
+
for (var X = 0; X < B.length; X++)
|
|
1753
|
+
Ge(B[X], s);
|
|
1754
|
+
Object.freeze && Object.freeze(B);
|
|
1755
|
+
} else
|
|
1756
|
+
w("React.jsx: Static children should always be an array. You are likely explicitly calling React.jsxs or React.jsxDEV. Use the Babel transform instead.");
|
|
1757
|
+
else
|
|
1758
|
+
Ge(B, s);
|
|
1759
|
+
}
|
|
1760
|
+
if (ee.call(h, "key")) {
|
|
1761
|
+
var K = N(s), G = Object.keys(h).filter(function(_t) {
|
|
1762
|
+
return _t !== "key";
|
|
1763
|
+
}), ge = G.length > 0 ? "{key: someKey, " + G.join(": ..., ") + ": ...}" : "{key: someKey}";
|
|
1764
|
+
if (!ze[K + ge]) {
|
|
1765
|
+
var Ct = G.length > 0 ? "{" + G.join(": ..., ") + ": ...}" : "{}";
|
|
1766
|
+
w(`A props object containing a "key" prop is being spread into JSX:
|
|
1767
|
+
let props = %s;
|
|
1768
|
+
<%s {...props} />
|
|
1769
|
+
React keys must be passed directly to JSX without using spread:
|
|
1770
|
+
let props = %s;
|
|
1771
|
+
<%s key={someKey} {...props} />`, ge, K, Ct, K), ze[K + ge] = !0;
|
|
1772
|
+
}
|
|
1773
|
+
}
|
|
1774
|
+
return s === n ? bt(A) : yt(A), A;
|
|
1775
|
+
}
|
|
1776
|
+
}
|
|
1777
|
+
function xt(s, h, p) {
|
|
1778
|
+
return We(s, h, p, !0);
|
|
1779
|
+
}
|
|
1780
|
+
function Et(s, h, p) {
|
|
1781
|
+
return We(s, h, p, !1);
|
|
1782
|
+
}
|
|
1783
|
+
var Mt = Et, Rt = xt;
|
|
1784
|
+
se.Fragment = n, se.jsx = Mt, se.jsxs = Rt;
|
|
1785
|
+
})()), se;
|
|
1786
|
+
}
|
|
1787
|
+
var Xe;
|
|
1788
|
+
function fs() {
|
|
1789
|
+
return Xe || (Xe = 1, process.env.NODE_ENV === "production" ? oe.exports = hs() : oe.exports = us()), oe.exports;
|
|
1790
|
+
}
|
|
1791
|
+
var _ = fs();
|
|
1792
|
+
const Es = be(({
|
|
1793
|
+
onEntitySelect: y,
|
|
1794
|
+
onLockChange: e,
|
|
1795
|
+
pvsEnabled: t,
|
|
1796
|
+
showPointEntities: n,
|
|
1797
|
+
showBrushEntities: r,
|
|
1798
|
+
showBrushWireframes: i,
|
|
1799
|
+
showAxes: a,
|
|
1800
|
+
aaaTriggerOpacity: c,
|
|
1801
|
+
entityConnectionsMode: o,
|
|
1802
|
+
textureFiltering: u,
|
|
1803
|
+
lightmapFiltering: f,
|
|
1804
|
+
antialias: d,
|
|
1805
|
+
selectedEntity: v,
|
|
1806
|
+
onProgress: E
|
|
1807
|
+
}, m) => {
|
|
1808
|
+
const M = Be(null), R = Be(null);
|
|
1809
|
+
return Tt(m, () => ({
|
|
1810
|
+
loadMap: async (x, w, k) => {
|
|
1811
|
+
if (R.current)
|
|
1812
|
+
try {
|
|
1813
|
+
const O = await x.arrayBuffer(), I = await Promise.all(w.map((T) => T.arrayBuffer())), z = (await Promise.all(k.map((T) => T.text()))).join(`
|
|
1814
|
+
`);
|
|
1815
|
+
await R.current.loadMap(O, I, z);
|
|
1816
|
+
} catch (O) {
|
|
1817
|
+
throw console.error("Load failed:", O), O;
|
|
1818
|
+
}
|
|
1819
|
+
},
|
|
1820
|
+
resetView: () => {
|
|
1821
|
+
var x;
|
|
1822
|
+
(x = R.current) == null || x.resetView();
|
|
1823
|
+
},
|
|
1824
|
+
instance: R.current
|
|
1825
|
+
})), me(() => {
|
|
1826
|
+
if (!M.current) return;
|
|
1827
|
+
const x = new ls({
|
|
1828
|
+
container: M.current,
|
|
1829
|
+
onEntitySelect: y,
|
|
1830
|
+
onLockChange: e,
|
|
1831
|
+
onProgress: E,
|
|
1832
|
+
showAxes: a,
|
|
1833
|
+
pvsEnabled: t,
|
|
1834
|
+
showPointEntities: n,
|
|
1835
|
+
showBrushEntities: r,
|
|
1836
|
+
showBrushWireframes: i,
|
|
1837
|
+
aaaTriggerOpacity: c,
|
|
1838
|
+
entityConnectionsMode: o,
|
|
1839
|
+
textureFiltering: u,
|
|
1840
|
+
lightmapFiltering: f,
|
|
1841
|
+
antialias: d
|
|
1842
|
+
});
|
|
1843
|
+
return R.current = x, () => {
|
|
1844
|
+
x.destroy(), R.current = null;
|
|
1845
|
+
};
|
|
1846
|
+
}, [y, e, E]), me(() => {
|
|
1847
|
+
var x;
|
|
1848
|
+
(x = R.current) == null || x.setOptions({
|
|
1849
|
+
pvsEnabled: t,
|
|
1850
|
+
showPointEntities: n,
|
|
1851
|
+
showBrushEntities: r,
|
|
1852
|
+
showBrushWireframes: i,
|
|
1853
|
+
showAxes: a,
|
|
1854
|
+
aaaTriggerOpacity: c,
|
|
1855
|
+
entityConnectionsMode: o,
|
|
1856
|
+
textureFiltering: u,
|
|
1857
|
+
lightmapFiltering: f
|
|
1858
|
+
});
|
|
1859
|
+
}, [
|
|
1860
|
+
t,
|
|
1861
|
+
n,
|
|
1862
|
+
r,
|
|
1863
|
+
i,
|
|
1864
|
+
a,
|
|
1865
|
+
c,
|
|
1866
|
+
o,
|
|
1867
|
+
u,
|
|
1868
|
+
f
|
|
1869
|
+
]), me(() => {
|
|
1870
|
+
var x;
|
|
1871
|
+
(x = R.current) == null || x.setSelectedEntity(v);
|
|
1872
|
+
}, [v]), /* @__PURE__ */ _.jsx("div", { className: "w-full h-full overflow-hidden", ref: M });
|
|
1873
|
+
});
|
|
1874
|
+
/**
|
|
1875
|
+
* @license lucide-react v0.474.0 - ISC
|
|
1876
|
+
*
|
|
1877
|
+
* This source code is licensed under the ISC license.
|
|
1878
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
1879
|
+
*/
|
|
1880
|
+
const ds = (y) => y.replace(/([a-z0-9])([A-Z])/g, "$1-$2").toLowerCase(), Ze = (...y) => y.filter((e, t, n) => !!e && e.trim() !== "" && n.indexOf(e) === t).join(" ").trim();
|
|
1881
|
+
/**
|
|
1882
|
+
* @license lucide-react v0.474.0 - ISC
|
|
1883
|
+
*
|
|
1884
|
+
* This source code is licensed under the ISC license.
|
|
1885
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
1886
|
+
*/
|
|
1887
|
+
var ps = {
|
|
1888
|
+
xmlns: "http://www.w3.org/2000/svg",
|
|
1889
|
+
width: 24,
|
|
1890
|
+
height: 24,
|
|
1891
|
+
viewBox: "0 0 24 24",
|
|
1892
|
+
fill: "none",
|
|
1893
|
+
stroke: "currentColor",
|
|
1894
|
+
strokeWidth: 2,
|
|
1895
|
+
strokeLinecap: "round",
|
|
1896
|
+
strokeLinejoin: "round"
|
|
1897
|
+
};
|
|
1898
|
+
/**
|
|
1899
|
+
* @license lucide-react v0.474.0 - ISC
|
|
1900
|
+
*
|
|
1901
|
+
* This source code is licensed under the ISC license.
|
|
1902
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
1903
|
+
*/
|
|
1904
|
+
const gs = be(
|
|
1905
|
+
({
|
|
1906
|
+
color: y = "currentColor",
|
|
1907
|
+
size: e = 24,
|
|
1908
|
+
strokeWidth: t = 2,
|
|
1909
|
+
absoluteStrokeWidth: n,
|
|
1910
|
+
className: r = "",
|
|
1911
|
+
children: i,
|
|
1912
|
+
iconNode: a,
|
|
1913
|
+
...c
|
|
1914
|
+
}, o) => ye(
|
|
1915
|
+
"svg",
|
|
1916
|
+
{
|
|
1917
|
+
ref: o,
|
|
1918
|
+
...ps,
|
|
1919
|
+
width: e,
|
|
1920
|
+
height: e,
|
|
1921
|
+
stroke: y,
|
|
1922
|
+
strokeWidth: n ? Number(t) * 24 / Number(e) : t,
|
|
1923
|
+
className: Ze("lucide", r),
|
|
1924
|
+
...c
|
|
1925
|
+
},
|
|
1926
|
+
[
|
|
1927
|
+
...a.map(([u, f]) => ye(u, f)),
|
|
1928
|
+
...Array.isArray(i) ? i : [i]
|
|
1929
|
+
]
|
|
1930
|
+
)
|
|
1931
|
+
);
|
|
1932
|
+
/**
|
|
1933
|
+
* @license lucide-react v0.474.0 - ISC
|
|
1934
|
+
*
|
|
1935
|
+
* This source code is licensed under the ISC license.
|
|
1936
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
1937
|
+
*/
|
|
1938
|
+
const Qe = (y, e) => {
|
|
1939
|
+
const t = be(
|
|
1940
|
+
({ className: n, ...r }, i) => ye(gs, {
|
|
1941
|
+
ref: i,
|
|
1942
|
+
iconNode: e,
|
|
1943
|
+
className: Ze(`lucide-${ds(y)}`, n),
|
|
1944
|
+
...r
|
|
1945
|
+
})
|
|
1946
|
+
);
|
|
1947
|
+
return t.displayName = `${y}`, t;
|
|
1948
|
+
};
|
|
1949
|
+
/**
|
|
1950
|
+
* @license lucide-react v0.474.0 - ISC
|
|
1951
|
+
*
|
|
1952
|
+
* This source code is licensed under the ISC license.
|
|
1953
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
1954
|
+
*/
|
|
1955
|
+
const ms = [
|
|
1956
|
+
["circle", { cx: "12", cy: "12", r: "10", key: "1mglay" }],
|
|
1957
|
+
["path", { d: "m9 12 2 2 4-4", key: "dzmm74" }]
|
|
1958
|
+
], vs = Qe("CircleCheck", ms);
|
|
1959
|
+
/**
|
|
1960
|
+
* @license lucide-react v0.474.0 - ISC
|
|
1961
|
+
*
|
|
1962
|
+
* This source code is licensed under the ISC license.
|
|
1963
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
1964
|
+
*/
|
|
1965
|
+
const ws = [
|
|
1966
|
+
["path", { d: "M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4", key: "ih7n3h" }],
|
|
1967
|
+
["polyline", { points: "17 8 12 3 7 8", key: "t8dd8p" }],
|
|
1968
|
+
["line", { x1: "12", x2: "12", y1: "3", y2: "15", key: "widbto" }]
|
|
1969
|
+
], we = Qe("Upload", ws), Ms = ({ onLoad: y, status: e }) => {
|
|
1970
|
+
const [t, n] = ve(null), [r, i] = ve([]), [a, c] = ve([]), o = () => {
|
|
1971
|
+
t && y(t, r, a);
|
|
1972
|
+
};
|
|
1973
|
+
return /* @__PURE__ */ _.jsxs("div", { className: "w-80 bg-zinc-950 border border-white/10 rounded shadow-2xl overflow-hidden flex flex-col font-mono", children: [
|
|
1974
|
+
/* @__PURE__ */ _.jsx("div", { className: "p-3 border-b border-white/10 bg-white/5 flex items-center justify-between", children: /* @__PURE__ */ _.jsx("div", { className: "flex items-center gap-2", children: /* @__PURE__ */ _.jsx("span", { className: "text-[10px] font-bold text-white uppercase tracking-wider", children: "Load Map Resources" }) }) }),
|
|
1975
|
+
/* @__PURE__ */ _.jsxs("div", { className: "p-4 space-y-4", children: [
|
|
1976
|
+
/* @__PURE__ */ _.jsxs("div", { className: "space-y-1.5", children: [
|
|
1977
|
+
/* @__PURE__ */ _.jsxs("label", { className: "text-[9px] font-bold text-zinc-500 uppercase tracking-widest flex items-center gap-1.5", children: [
|
|
1978
|
+
/* @__PURE__ */ _.jsx("div", { className: "w-1 h-1 bg-blue-500 rounded-full" }),
|
|
1979
|
+
"BSP File (Geometry)"
|
|
1980
|
+
] }),
|
|
1981
|
+
/* @__PURE__ */ _.jsxs("div", { className: "relative group", children: [
|
|
1982
|
+
/* @__PURE__ */ _.jsx(
|
|
1983
|
+
"input",
|
|
1984
|
+
{
|
|
1985
|
+
type: "file",
|
|
1986
|
+
accept: ".bsp",
|
|
1987
|
+
onChange: (u) => {
|
|
1988
|
+
var f;
|
|
1989
|
+
return n(((f = u.target.files) == null ? void 0 : f[0]) || null);
|
|
1990
|
+
},
|
|
1991
|
+
className: "absolute inset-0 w-full h-full opacity-0 cursor-pointer z-10"
|
|
1992
|
+
}
|
|
1993
|
+
),
|
|
1994
|
+
/* @__PURE__ */ _.jsxs("div", { className: `py-2 px-3 border border-dashed rounded transition-colors flex items-center justify-between ${t ? "border-blue-500/50 bg-blue-500/5" : "border-white/10 group-hover:border-white/20"}`, children: [
|
|
1995
|
+
/* @__PURE__ */ _.jsx("span", { className: `text-[10px] truncate pr-4 ${t ? "text-blue-300" : "text-zinc-500"}`, children: t ? t.name : "Select .bsp file..." }),
|
|
1996
|
+
t ? /* @__PURE__ */ _.jsx(vs, { className: "w-3 h-3 text-blue-500 shrink-0" }) : /* @__PURE__ */ _.jsx(we, { className: "w-3 h-3 text-zinc-600 shrink-0" })
|
|
1997
|
+
] })
|
|
1998
|
+
] })
|
|
1999
|
+
] }),
|
|
2000
|
+
/* @__PURE__ */ _.jsxs("div", { className: "space-y-1.5", children: [
|
|
2001
|
+
/* @__PURE__ */ _.jsxs("label", { className: "text-[9px] font-bold text-zinc-500 uppercase tracking-widest flex items-center gap-1.5", children: [
|
|
2002
|
+
/* @__PURE__ */ _.jsx("div", { className: "w-1 h-1 bg-zinc-500 rounded-full" }),
|
|
2003
|
+
"WAD Files (Textures)"
|
|
2004
|
+
] }),
|
|
2005
|
+
/* @__PURE__ */ _.jsxs("div", { className: "relative group", children: [
|
|
2006
|
+
/* @__PURE__ */ _.jsx(
|
|
2007
|
+
"input",
|
|
2008
|
+
{
|
|
2009
|
+
type: "file",
|
|
2010
|
+
multiple: !0,
|
|
2011
|
+
accept: ".wad",
|
|
2012
|
+
onChange: (u) => i(Array.from(u.target.files || [])),
|
|
2013
|
+
className: "absolute inset-0 w-full h-full opacity-0 cursor-pointer z-10"
|
|
2014
|
+
}
|
|
2015
|
+
),
|
|
2016
|
+
/* @__PURE__ */ _.jsxs("div", { className: `py-2 px-3 border border-dashed rounded transition-colors flex items-center justify-between ${r.length > 0 ? "border-zinc-500/50 bg-white/5" : "border-white/10 group-hover:border-white/20"}`, children: [
|
|
2017
|
+
/* @__PURE__ */ _.jsx("span", { className: `text-[10px] truncate pr-4 ${r.length > 0 ? "text-zinc-300" : "text-zinc-500"}`, children: r.length > 0 ? `${r.length} files selected` : "Select .wad files..." }),
|
|
2018
|
+
/* @__PURE__ */ _.jsx(we, { className: "w-3 h-3 text-zinc-600 shrink-0" })
|
|
2019
|
+
] })
|
|
2020
|
+
] })
|
|
2021
|
+
] }),
|
|
2022
|
+
/* @__PURE__ */ _.jsxs("div", { className: "space-y-1.5", children: [
|
|
2023
|
+
/* @__PURE__ */ _.jsxs("label", { className: "text-[9px] font-bold text-zinc-500 uppercase tracking-widest flex items-center gap-1.5", children: [
|
|
2024
|
+
/* @__PURE__ */ _.jsx("div", { className: "w-1 h-1 bg-zinc-500 rounded-full" }),
|
|
2025
|
+
"FGD Files (Entities)"
|
|
2026
|
+
] }),
|
|
2027
|
+
/* @__PURE__ */ _.jsxs("div", { className: "relative group", children: [
|
|
2028
|
+
/* @__PURE__ */ _.jsx(
|
|
2029
|
+
"input",
|
|
2030
|
+
{
|
|
2031
|
+
type: "file",
|
|
2032
|
+
multiple: !0,
|
|
2033
|
+
accept: ".fgd",
|
|
2034
|
+
onChange: (u) => c(Array.from(u.target.files || [])),
|
|
2035
|
+
className: "absolute inset-0 w-full h-full opacity-0 cursor-pointer z-10"
|
|
2036
|
+
}
|
|
2037
|
+
),
|
|
2038
|
+
/* @__PURE__ */ _.jsxs("div", { className: `py-2 px-3 border border-dashed rounded transition-colors flex items-center justify-between ${a.length > 0 ? "border-zinc-500/50 bg-white/5" : "border-white/10 group-hover:border-white/20"}`, children: [
|
|
2039
|
+
/* @__PURE__ */ _.jsx("span", { className: `text-[10px] truncate pr-4 ${a.length > 0 ? "text-zinc-300" : "text-zinc-500"}`, children: a.length > 0 ? `${a.length} files selected` : "Select .fgd files..." }),
|
|
2040
|
+
/* @__PURE__ */ _.jsx(we, { className: "w-3 h-3 text-zinc-600 shrink-0" })
|
|
2041
|
+
] })
|
|
2042
|
+
] })
|
|
2043
|
+
] }),
|
|
2044
|
+
/* @__PURE__ */ _.jsxs("div", { className: "pt-2 flex flex-col gap-2", children: [
|
|
2045
|
+
/* @__PURE__ */ _.jsx(
|
|
2046
|
+
"button",
|
|
2047
|
+
{
|
|
2048
|
+
onClick: o,
|
|
2049
|
+
disabled: !t || e === "Loading...",
|
|
2050
|
+
className: `w-full py-2.5 rounded text-[10px] font-bold uppercase tracking-widest transition-all ${t && e !== "Loading..." ? "bg-blue-600 hover:bg-blue-500 text-white shadow-lg shadow-blue-500/20 active:scale-[0.98]" : "bg-zinc-800 text-zinc-500 cursor-not-allowed"}`,
|
|
2051
|
+
children: e === "Loading..." ? "Processing Map..." : "Initialize Engine"
|
|
2052
|
+
}
|
|
2053
|
+
),
|
|
2054
|
+
e !== "Waiting for map..." && /* @__PURE__ */ _.jsxs("div", { className: "flex items-center justify-center gap-2 py-1", children: [
|
|
2055
|
+
/* @__PURE__ */ _.jsx("div", { className: `w-1.5 h-1.5 rounded-full animate-pulse ${e === "Load Error" ? "bg-red-500" : "bg-green-500"}` }),
|
|
2056
|
+
/* @__PURE__ */ _.jsx("span", { className: "text-[9px] font-bold text-zinc-400 uppercase", children: e })
|
|
2057
|
+
] })
|
|
2058
|
+
] })
|
|
2059
|
+
] })
|
|
2060
|
+
] });
|
|
2061
|
+
};
|
|
2062
|
+
export {
|
|
2063
|
+
ss as BspParser,
|
|
2064
|
+
ls as BspViewer,
|
|
2065
|
+
rs as FgdParser,
|
|
2066
|
+
Ms as MapLoader,
|
|
2067
|
+
os as MapRenderer,
|
|
2068
|
+
cs as Navigator,
|
|
2069
|
+
Es as ViewerCanvas,
|
|
2070
|
+
is as WadParser
|
|
2071
|
+
};
|