@minicode-dev/chat 0.1.15 → 0.1.16
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +10 -0
- package/dist/chunks/{BattleshipGameCard-8H-sBCsv.js → BattleshipGameCard-DwNzgH5G.js} +199 -199
- package/dist/chunks/{BattleshipGameCard-8H-sBCsv.js.map → BattleshipGameCard-DwNzgH5G.js.map} +1 -1
- package/dist/chunks/{BattleshipPrototype-CmQd5AUO.js → BattleshipPrototype-CSQxQJt5.js} +52 -52
- package/dist/chunks/{BattleshipPrototype-CmQd5AUO.js.map → BattleshipPrototype-CSQxQJt5.js.map} +1 -1
- package/dist/chunks/{ChatContext-CVW58bzC.js → ChatContext-D5rqvt5D.js} +2 -2
- package/dist/chunks/{ChatContext-CVW58bzC.js.map → ChatContext-D5rqvt5D.js.map} +1 -1
- package/dist/chunks/RacingLiveGameCard-_wvhDRlG.js +1873 -0
- package/dist/chunks/RacingLiveGameCard-_wvhDRlG.js.map +1 -0
- package/dist/chunks/{TanksGameCard-DnCufSH6.js → TanksGameCard-B-gtDYYg.js} +137 -137
- package/dist/chunks/{TanksGameCard-DnCufSH6.js.map → TanksGameCard-B-gtDYYg.js.map} +1 -1
- package/dist/chunks/{TanksLiveGameCard-D_27Jomp.js → TanksLiveGameCard-DXgd1J2Y.js} +392 -392
- package/dist/chunks/{TanksLiveGameCard-D_27Jomp.js.map → TanksLiveGameCard-DXgd1J2Y.js.map} +1 -1
- package/dist/chunks/{avalancheScene3d-CIE2WKQn.js → avalancheScene3d-CNbQyGUd.js} +2 -2
- package/dist/chunks/{avalancheScene3d-CIE2WKQn.js.map → avalancheScene3d-CNbQyGUd.js.map} +1 -1
- package/dist/chunks/{connect4Sounds-BqEHULjv.js → connect4Sounds-3a6h7gUC.js} +8 -8
- package/dist/chunks/{connect4Sounds-BqEHULjv.js.map → connect4Sounds-3a6h7gUC.js.map} +1 -1
- package/dist/chunks/createLiveScene-jrzyQogh.js +756 -0
- package/dist/chunks/{createLiveScene-MTGRv8rx.js.map → createLiveScene-jrzyQogh.js.map} +1 -1
- package/dist/chunks/createRaceScene-C-aw0dlX.js +291 -0
- package/dist/chunks/createRaceScene-C-aw0dlX.js.map +1 -0
- package/dist/chunks/{createTankScene-yhX6la27.js → createTankScene-6asWHKFf.js} +123 -125
- package/dist/chunks/{createTankScene-yhX6la27.js.map → createTankScene-6asWHKFf.js.map} +1 -1
- package/dist/chunks/fx-BNJvJYOu.js +871 -0
- package/dist/chunks/fx-BNJvJYOu.js.map +1 -0
- package/dist/chunks/{games-Bl_8raG6.js → games-D_9SiSBT.js} +708 -697
- package/dist/chunks/games-D_9SiSBT.js.map +1 -0
- package/dist/chunks/tank-DIn6Jyt8.js +605 -0
- package/dist/chunks/tank-DIn6Jyt8.js.map +1 -0
- package/dist/chunks/{tanks-live-BcKmrhnV.js → tanks-live-BRhYW4MG.js} +36 -36
- package/dist/chunks/{tanks-live-BcKmrhnV.js.map → tanks-live-BRhYW4MG.js.map} +1 -1
- package/dist/chunks/{tanksSounds-DTnidbiq.js → tanksSounds-tYPzje61.js} +4 -4
- package/dist/chunks/{tanksSounds-DTnidbiq.js.map → tanksSounds-tYPzje61.js.map} +1 -1
- package/dist/chunks/track-C1TWWT19.js +557 -0
- package/dist/chunks/track-C1TWWT19.js.map +1 -0
- package/dist/index.js +4234 -4018
- package/dist/index.js.map +1 -1
- package/dist/styles.css +1 -1
- package/index.d.ts +2 -0
- package/package.json +1 -1
- package/dist/chunks/RacingLiveGameCard-8j9QLnxW.js +0 -1654
- package/dist/chunks/RacingLiveGameCard-8j9QLnxW.js.map +0 -1
- package/dist/chunks/createLiveScene-MTGRv8rx.js +0 -758
- package/dist/chunks/createRaceScene-BiEtQsVs.js +0 -306
- package/dist/chunks/createRaceScene-BiEtQsVs.js.map +0 -1
- package/dist/chunks/decor-CyyCnmct.js +0 -418
- package/dist/chunks/decor-CyyCnmct.js.map +0 -1
- package/dist/chunks/fx-1ZwzmPWj.js +0 -458
- package/dist/chunks/fx-1ZwzmPWj.js.map +0 -1
- package/dist/chunks/games-Bl_8raG6.js.map +0 -1
- package/dist/chunks/rolldown-runtime-CGnMp29N.js +0 -10
- package/dist/chunks/tank-DjEQ4FXF.js +0 -553
- package/dist/chunks/tank-DjEQ4FXF.js.map +0 -1
- package/dist/chunks/track-BcnnpnAm.js +0 -259
- package/dist/chunks/track-BcnnpnAm.js.map +0 -1
- package/dist/chunks/util-DwI9bfS7.js +0 -57
- package/dist/chunks/util-DwI9bfS7.js.map +0 -1
|
@@ -1,758 +0,0 @@
|
|
|
1
|
-
import { t as e } from "./cars-D1PM7mVD.js";
|
|
2
|
-
import { a as t, c as n, n as r, r as i, s as a, t as o, u as s } from "./util-DwI9bfS7.js";
|
|
3
|
-
import { a as c, i as l, o as u, s as d } from "./tank-DjEQ4FXF.js";
|
|
4
|
-
import { a as f, i as p, n as m, r as h, t as g } from "./decor-CyyCnmct.js";
|
|
5
|
-
import { a as _, c as v, d as ee, f as y, i as te, l as ne, n as re, o as ie, p as ae, r as b, s as oe, u as x } from "./TanksLiveGameCard-D_27Jomp.js";
|
|
6
|
-
import { t as S } from "./fx-1ZwzmPWj.js";
|
|
7
|
-
import { ACESFilmicToneMapping as C, AdditiveBlending as se, BoxGeometry as w, Color as ce, ConeGeometry as le, CylinderGeometry as T, DirectionalLight as ue, DodecahedronGeometry as E, DynamicDrawUsage as de, Fog as fe, Group as pe, HemisphereLight as me, IcosahedronGeometry as he, InstancedMesh as ge, Matrix4 as _e, Mesh as ve, MeshBasicMaterial as ye, MeshLambertMaterial as be, MeshStandardMaterial as xe, Object3D as D, PCFSoftShadowMap as Se, PerspectiveCamera as Ce, Plane as we, PlaneGeometry as O, Raycaster as Te, Scene as Ee, Vector2 as De, Vector3 as k, WebGLRenderer as Oe, sRGBEncoding as ke } from "three";
|
|
8
|
-
// src/games/tanks-live/scene/liveMapScene.js
|
|
9
|
-
var A = {
|
|
10
|
-
meadow: null,
|
|
11
|
-
forest: {
|
|
12
|
-
ground: "#55803a",
|
|
13
|
-
mix: .45,
|
|
14
|
-
gain: 4.2,
|
|
15
|
-
sky: {
|
|
16
|
-
top: "#3d5a7a",
|
|
17
|
-
mid: "#9fb3a0",
|
|
18
|
-
horizon: "#d9d2a8",
|
|
19
|
-
bottom: "#a9b49a",
|
|
20
|
-
sun: "#ffe2a8"
|
|
21
|
-
},
|
|
22
|
-
fog: "#9fae94",
|
|
23
|
-
fogNear: 50,
|
|
24
|
-
fogFar: 250,
|
|
25
|
-
hemiSky: "#d6e6c0",
|
|
26
|
-
hemiGround: "#2c3a26",
|
|
27
|
-
sun: "#ffd9a0",
|
|
28
|
-
hills: "#9fb898",
|
|
29
|
-
treeTint: "#e0f0d8",
|
|
30
|
-
border: "tree"
|
|
31
|
-
},
|
|
32
|
-
desert: {
|
|
33
|
-
ground: "#d9b77a",
|
|
34
|
-
mix: .9,
|
|
35
|
-
gain: 4.4,
|
|
36
|
-
sky: {
|
|
37
|
-
top: "#3f7cc4",
|
|
38
|
-
mid: "#9fc4e0",
|
|
39
|
-
horizon: "#f4dcb0",
|
|
40
|
-
bottom: "#e6c79a",
|
|
41
|
-
sun: "#fff1c8"
|
|
42
|
-
},
|
|
43
|
-
fog: "#e8cfa2",
|
|
44
|
-
fogNear: 80,
|
|
45
|
-
fogFar: 340,
|
|
46
|
-
hemiSky: "#fff0d0",
|
|
47
|
-
hemiGround: "#6b5534",
|
|
48
|
-
sun: "#fff0cc",
|
|
49
|
-
hills: "#ffd9a8",
|
|
50
|
-
treeTint: "#c8b878",
|
|
51
|
-
border: "rock"
|
|
52
|
-
},
|
|
53
|
-
ruins: {
|
|
54
|
-
ground: "#8d8475",
|
|
55
|
-
mix: .8,
|
|
56
|
-
gain: 4.2,
|
|
57
|
-
sky: {
|
|
58
|
-
top: "#3b4250",
|
|
59
|
-
mid: "#8a8c93",
|
|
60
|
-
horizon: "#c9b9a0",
|
|
61
|
-
bottom: "#9b9086",
|
|
62
|
-
sun: "#f0d8b0"
|
|
63
|
-
},
|
|
64
|
-
fog: "#a69c91",
|
|
65
|
-
fogNear: 50,
|
|
66
|
-
fogFar: 260,
|
|
67
|
-
hemiSky: "#d8d4cc",
|
|
68
|
-
hemiGround: "#3a342e",
|
|
69
|
-
sun: "#f2d2a8",
|
|
70
|
-
hills: "#a8a4a4",
|
|
71
|
-
treeTint: "#9c9a80",
|
|
72
|
-
border: "rock"
|
|
73
|
-
},
|
|
74
|
-
arctic: {
|
|
75
|
-
ground: "#eef5fb",
|
|
76
|
-
mix: .93,
|
|
77
|
-
gain: 5,
|
|
78
|
-
sky: {
|
|
79
|
-
top: "#5f86c4",
|
|
80
|
-
mid: "#b8cde6",
|
|
81
|
-
horizon: "#eaf2fa",
|
|
82
|
-
bottom: "#d6e2ee",
|
|
83
|
-
sun: "#ffffff"
|
|
84
|
-
},
|
|
85
|
-
fog: "#dbe7f2",
|
|
86
|
-
fogNear: 60,
|
|
87
|
-
fogFar: 300,
|
|
88
|
-
hemiSky: "#eaf4ff",
|
|
89
|
-
hemiGround: "#6f8094",
|
|
90
|
-
sun: "#f4f8ff",
|
|
91
|
-
hills: "#d8e6f6",
|
|
92
|
-
treeTint: "#dceaf2",
|
|
93
|
-
border: "tree"
|
|
94
|
-
}
|
|
95
|
-
}, Ae = (e) => e && A[e.id] || null;
|
|
96
|
-
function je(e, { renderer: t, scene: r, sky: i, hills: a, hemi: o, sun: s, terrain: c }) {
|
|
97
|
-
if (!e) return;
|
|
98
|
-
let l = i.mesh.material.uniforms;
|
|
99
|
-
l.uTop.value = n(e.sky.top), l.uMid.value = n(e.sky.mid), l.uHorizon.value = n(e.sky.horizon), l.uBottom.value = n(e.sky.bottom), l.uSunColor.value = n(e.sky.sun), r.fog.color = n(e.fog), r.fog.near = e.fogNear, r.fog.far = e.fogFar, t.setClearColor(n(e.sky.horizon), 1), o.color = n(e.hemiSky), o.groundColor = n(e.hemiGround), s.color = n(e.sun), a.mesh.material.color && (a.mesh.material.color = n(e.hills));
|
|
100
|
-
let u = n(e.ground), d = c.material || c.mesh.material;
|
|
101
|
-
d.onBeforeCompile = (t) => {
|
|
102
|
-
t.uniforms.uMapTint = { value: u }, t.uniforms.uMapMix = { value: e.mix }, t.uniforms.uMapGain = { value: e.gain }, t.fragmentShader = t.fragmentShader.replace("#include <common>", "#include <common>\nuniform vec3 uMapTint;\nuniform float uMapMix;\nuniform float uMapGain;").replace("#include <color_fragment>", "#include <color_fragment>\n{ float l = dot(diffuseColor.rgb, vec3(0.2126, 0.7152, 0.0722));\n diffuseColor.rgb = mix(diffuseColor.rgb, min(uMapTint * l * uMapGain, vec3(1.0)), uMapMix); }");
|
|
103
|
-
}, d.customProgramCacheKey = () => `tl-map-${e.ground}`, d.needsUpdate = !0;
|
|
104
|
-
}
|
|
105
|
-
function Me(e, t, r) {
|
|
106
|
-
if (!r) return;
|
|
107
|
-
let i = n(r);
|
|
108
|
-
for (let n of e.children) !t.has(n) && n.isInstancedMesh && n.material?.color && (n.material.color = i);
|
|
109
|
-
}
|
|
110
|
-
var j = [
|
|
111
|
-
"#9a8f84",
|
|
112
|
-
"#a69a8a",
|
|
113
|
-
"#8b7f74",
|
|
114
|
-
"#b0a493"
|
|
115
|
-
], M = [
|
|
116
|
-
"#b9a58a",
|
|
117
|
-
"#a8927a",
|
|
118
|
-
"#c2b097",
|
|
119
|
-
"#9d8b78"
|
|
120
|
-
], N = [
|
|
121
|
-
"#6b4a35",
|
|
122
|
-
"#7a5a3e",
|
|
123
|
-
"#5a4a40",
|
|
124
|
-
"#8a6a4a",
|
|
125
|
-
"#6a6058"
|
|
126
|
-
], P = {
|
|
127
|
-
grass: {
|
|
128
|
-
geo: "cone",
|
|
129
|
-
color: "#5f8f3c",
|
|
130
|
-
h: .7,
|
|
131
|
-
r: .25
|
|
132
|
-
},
|
|
133
|
-
weed: {
|
|
134
|
-
geo: "cone",
|
|
135
|
-
color: "#6b7a3a",
|
|
136
|
-
h: .6,
|
|
137
|
-
r: .25
|
|
138
|
-
},
|
|
139
|
-
dry_grass: {
|
|
140
|
-
geo: "cone",
|
|
141
|
-
color: "#b8a060",
|
|
142
|
-
h: .6,
|
|
143
|
-
r: .25
|
|
144
|
-
},
|
|
145
|
-
flower: {
|
|
146
|
-
geo: "blob",
|
|
147
|
-
color: "#e8d24a",
|
|
148
|
-
alt: [
|
|
149
|
-
"#e86a8a",
|
|
150
|
-
"#f2f2f2",
|
|
151
|
-
"#9a7ae8"
|
|
152
|
-
],
|
|
153
|
-
h: .3,
|
|
154
|
-
r: .22
|
|
155
|
-
},
|
|
156
|
-
bush: {
|
|
157
|
-
geo: "blob",
|
|
158
|
-
color: "#3f6f32",
|
|
159
|
-
h: .9,
|
|
160
|
-
r: .9
|
|
161
|
-
},
|
|
162
|
-
pebble: {
|
|
163
|
-
geo: "rock",
|
|
164
|
-
color: "#8d877e",
|
|
165
|
-
h: .25,
|
|
166
|
-
r: .35
|
|
167
|
-
},
|
|
168
|
-
rubble: {
|
|
169
|
-
geo: "rock",
|
|
170
|
-
color: "#8a8278",
|
|
171
|
-
alt: ["#7a5a48", "#a09a90"],
|
|
172
|
-
h: .35,
|
|
173
|
-
r: .55
|
|
174
|
-
},
|
|
175
|
-
bones: {
|
|
176
|
-
geo: "rock",
|
|
177
|
-
color: "#ece2cc",
|
|
178
|
-
h: .15,
|
|
179
|
-
r: .4
|
|
180
|
-
},
|
|
181
|
-
snow: {
|
|
182
|
-
geo: "blob",
|
|
183
|
-
color: "#f4f8fc",
|
|
184
|
-
h: .25,
|
|
185
|
-
r: .9
|
|
186
|
-
},
|
|
187
|
-
ice_shard: {
|
|
188
|
-
geo: "cone",
|
|
189
|
-
color: "#bfe4f4",
|
|
190
|
-
h: 1.1,
|
|
191
|
-
r: .3
|
|
192
|
-
},
|
|
193
|
-
cactus: {
|
|
194
|
-
geo: "cactus",
|
|
195
|
-
color: "#4f8a46",
|
|
196
|
-
h: 1.8,
|
|
197
|
-
r: .35
|
|
198
|
-
}
|
|
199
|
-
};
|
|
200
|
-
function Ne(t, r, i, { ox: o, oz: s, lowPower: c = !1, shadows: l = !1 } = {}) {
|
|
201
|
-
let u = new pe();
|
|
202
|
-
t.add(u);
|
|
203
|
-
let d = [], f = (e) => (d.push(e), e), p = new D(), m = new ce(), h = (e, t, n = 0, r = 0, a = 0) => {
|
|
204
|
-
let o = i.heightAt(e, t), s = Math.cos(a), c = Math.sin(a);
|
|
205
|
-
for (let [a, l] of [
|
|
206
|
-
[-.5, -.5],
|
|
207
|
-
[.5, -.5],
|
|
208
|
-
[.5, .5],
|
|
209
|
-
[-.5, .5]
|
|
210
|
-
]) {
|
|
211
|
-
let u = a * n, d = l * r;
|
|
212
|
-
o = Math.min(o, i.heightAt(e + u * s - d * c, t + u * c + d * s));
|
|
213
|
-
}
|
|
214
|
-
return o;
|
|
215
|
-
}, g = (e) => f(c ? new be(e) : new xe({
|
|
216
|
-
roughness: .85,
|
|
217
|
-
metalness: .05,
|
|
218
|
-
...e
|
|
219
|
-
})), _ = f(new w(1, 1, 1).translate(0, .5, 0)), ee = f(new T(.5, .5, 1, 3, 1).rotateX(-Math.PI / 2).translate(0, .25, 0).rotateY(Math.PI / 2)), y = f(new T(1, 1, 1, c ? 8 : 14).translate(0, .5, 0)), te = f(new E(1, 0)), re = f(new he(1, 0)), ie = f(new T(1, 1, 1, c ? 6 : 10).rotateZ(Math.PI / 2)), ae = f(new le(1, 1, c ? 4 : 6).translate(0, .5, 0));
|
|
220
|
-
function b(e, t, n, r) {
|
|
221
|
-
if (!n.length) return null;
|
|
222
|
-
let i = new ge(e, t, n.length);
|
|
223
|
-
return i.castShadow = l, i.receiveShadow = l, n.forEach((e, t) => {
|
|
224
|
-
let n = r(e, t);
|
|
225
|
-
p.updateMatrix(), i.setMatrixAt(t, p.matrix), n && i.setColorAt(t, m.set(n).convertSRGBToLinear());
|
|
226
|
-
}), i.instanceMatrix.needsUpdate = !0, i.instanceColor && (i.instanceColor.needsUpdate = !0), u.add(i), d.push({ dispose: () => i.dispose() }), i;
|
|
227
|
-
}
|
|
228
|
-
let oe = ne(r).map((e) => ({
|
|
229
|
-
...e,
|
|
230
|
-
x: e.x + o,
|
|
231
|
-
z: e.z + s
|
|
232
|
-
})), x = (e, t) => oe.filter((n) => n.shape === e && t.includes(n.kind)), S = (e, t, n = 1, r = .3) => {
|
|
233
|
-
p.position.set(e.x, h(e.x, e.z, e.w, e.d, e.rot) - r, e.z), p.rotation.set(0, -e.rot, 0), p.scale.set(e.w * n, t + r, e.d * n);
|
|
234
|
-
}, C = { color: 16777215 };
|
|
235
|
-
b(_, g(C), x("rect", ["wall"]), (e) => (S(e, 2.6 + a(e.x, e.z) * .8), j[Math.floor(a(e.z, e.x) * j.length) % j.length]));
|
|
236
|
-
let se = x("rect", ["house"]);
|
|
237
|
-
b(_, g(C), se, (e) => (S(e, 3.4), M[Math.floor(a(e.x, e.z) * 4) % 4])), b(ee, g(C), se, (e) => {
|
|
238
|
-
let t = e.w >= e.d;
|
|
239
|
-
p.position.set(e.x, h(e.x, e.z, e.w, e.d, e.rot) + 3.35, e.z), p.rotation.set(0, -e.rot + (t ? 0 : Math.PI / 2), 0);
|
|
240
|
-
let n = t ? e.w : e.d, r = t ? e.d : e.w;
|
|
241
|
-
return p.scale.set(n * 1.04, 2.2, r * 1.1), a(e.z, e.x) < .5 ? "#8a3a2a" : "#5a4038";
|
|
242
|
-
}), b(_, g({ color: n("#a89468") }), x("rect", ["low"]), (e) => (S(e, 1.1, 1, .15), null));
|
|
243
|
-
let ue = f(new xe({
|
|
244
|
-
color: n("#cfeefa"),
|
|
245
|
-
roughness: .15,
|
|
246
|
-
metalness: .05,
|
|
247
|
-
transparent: !0,
|
|
248
|
-
opacity: .88
|
|
249
|
-
}));
|
|
250
|
-
b(_, ue, x("rect", ["ice_block"]), (e) => (S(e, 2.4 + a(e.x, e.z) * 1.2), null)), b(te, ue, x("circle", ["ice"]), (e) => (p.position.set(e.x, i.heightAt(e.x, e.z) + e.r * .25, e.z), p.rotation.set(0, a(e.x, e.z) * 6.28, 0), p.scale.set(e.r, e.r * .9, e.r), null)), b(ie, g({ color: n("#6b4a2e") }), x("circle", ["log"]), (e) => (p.position.set(e.x, i.heightAt(e.x, e.z) + .6, e.z), p.rotation.set(0, a(e.x, e.z) * 6.28, 0), p.scale.set(e.r * 2, .7, .7), null));
|
|
251
|
-
let de = x("rect", ["car"]);
|
|
252
|
-
if (de.length) {
|
|
253
|
-
let t = e({ lowPower: c }), n = /* @__PURE__ */ new Set();
|
|
254
|
-
t.forEach((e, r) => {
|
|
255
|
-
let i = de.filter((e) => Math.floor(a(e.x * 1.7, e.z) * t.length) % t.length === r);
|
|
256
|
-
for (let t of e.parts) t.geometry.computeBoundingBox(), n.add(t.material), d.push(t.geometry);
|
|
257
|
-
if (!i.length) return;
|
|
258
|
-
let o = 0, s = 0, c = Infinity;
|
|
259
|
-
for (let t of e.parts) {
|
|
260
|
-
let e = t.geometry.boundingBox;
|
|
261
|
-
o = Math.max(o, e.max.x - e.min.x), s = Math.max(s, e.max.y), c = Math.min(c, e.min.y);
|
|
262
|
-
}
|
|
263
|
-
for (let t of e.parts) b(t.geometry, t.material, i, (e) => {
|
|
264
|
-
let n = e.w / Math.max(.01, o);
|
|
265
|
-
return p.position.set(e.x, h(e.x, e.z, e.w, e.d, e.rot) - c * n - .1, e.z), p.rotation.set((a(e.x, e.z) - .5) * .12, -e.rot, (a(e.z, e.x) - .5) * .1), p.scale.setScalar(n), t.tinted ? N[Math.floor(a(e.x, e.z) * N.length) % N.length] : null;
|
|
266
|
-
});
|
|
267
|
-
}), n.forEach((e) => d.push(e));
|
|
268
|
-
}
|
|
269
|
-
let fe = (r.decor || []).filter((e, t) => P[e?.kind] && Number.isFinite(e.x) && Number.isFinite(e.z) && (!c || t % 2 == 0)), me = g(C), _e = {
|
|
270
|
-
cone: ae,
|
|
271
|
-
blob: re,
|
|
272
|
-
rock: te,
|
|
273
|
-
cactus: y
|
|
274
|
-
};
|
|
275
|
-
for (let e of Object.keys(_e)) {
|
|
276
|
-
let t = fe.filter((t) => P[t.kind].geo === e);
|
|
277
|
-
b(_e[e], me, t, (t) => {
|
|
278
|
-
let n = P[t.kind], r = Number.isFinite(t.s) ? t.s : 1, c = t.x + o, l = t.z + s, u = i.heightAt(c, l);
|
|
279
|
-
return p.position.set(c, e === "cone" || e === "cactus" ? u - .05 : u + n.h * r * .3, l), p.rotation.set(0, Number.isFinite(t.rot) ? t.rot : 0, 0), p.scale.set(n.r * r, n.h * r, n.r * r), (n.alt && a(t.x, t.z) < .6 ? n.alt[Math.floor(a(t.z, t.x) * n.alt.length) % n.alt.length] : null) || n.color;
|
|
280
|
-
});
|
|
281
|
-
}
|
|
282
|
-
let ye = f(new w(1, 1, 1).translate(0, .5, 0)), Se = g({ color: n("#a7773f") }), Ce = g({ color: n("#c62d24") }), we = g({ color: n("#3a2a24") }), O = /* @__PURE__ */ new Map();
|
|
283
|
-
for (let e of v(r)) {
|
|
284
|
-
let t = e.x + o, n = e.z + s, r = i.heightAt(t, n) - .05, c;
|
|
285
|
-
if (e.kind === "barrel") {
|
|
286
|
-
c = new pe();
|
|
287
|
-
let t = new ve(y, Ce);
|
|
288
|
-
t.scale.set(e.r * .85, e.r * 2.2, e.r * .85);
|
|
289
|
-
let n = new ve(y, we);
|
|
290
|
-
n.scale.set(e.r * .88, e.r * .18, e.r * .88), n.position.y = e.r * 1.4, c.add(t, n);
|
|
291
|
-
} else {
|
|
292
|
-
c = new ve(ye, Se);
|
|
293
|
-
let t = e.r * 1.55;
|
|
294
|
-
c.scale.set(t, t, t), c.rotation.y = a(e.x, e.z) * 1.5;
|
|
295
|
-
}
|
|
296
|
-
c.position.set(t, r, n), c.traverse((e) => {
|
|
297
|
-
e.castShadow = l, e.receiveShadow = l;
|
|
298
|
-
}), u.add(c), O.set(e.id, {
|
|
299
|
-
...e,
|
|
300
|
-
x: t,
|
|
301
|
-
z: n,
|
|
302
|
-
y: r,
|
|
303
|
-
mesh: c,
|
|
304
|
-
broken: !1
|
|
305
|
-
});
|
|
306
|
-
}
|
|
307
|
-
function Te(e) {
|
|
308
|
-
let t = O.get(String(e));
|
|
309
|
-
return !t || t.broken ? null : (t.broken = !0, t.mesh.visible = !1, t);
|
|
310
|
-
}
|
|
311
|
-
return {
|
|
312
|
-
destructibles: O,
|
|
313
|
-
breakDestructible: Te,
|
|
314
|
-
sync(e) {
|
|
315
|
-
for (let t of e?.destructibles || []) {
|
|
316
|
-
let e = t && t.id != null ? O.get(String(t.id)) : null;
|
|
317
|
-
e && (t.alive === !1 || Number.isFinite(t.hp) && t.hp <= 0 ? Te(e.id) : e.broken && (e.broken = !1, e.mesh.visible = !0));
|
|
318
|
-
}
|
|
319
|
-
},
|
|
320
|
-
nearest(e, t, n = 3) {
|
|
321
|
-
let r = null, i = n;
|
|
322
|
-
for (let n of O.values()) {
|
|
323
|
-
if (n.broken) continue;
|
|
324
|
-
let a = Math.hypot(n.x - e, n.z - t);
|
|
325
|
-
a < i && (i = a, r = n);
|
|
326
|
-
}
|
|
327
|
-
return r;
|
|
328
|
-
},
|
|
329
|
-
dispose() {
|
|
330
|
-
u.removeFromParent();
|
|
331
|
-
for (let e of d) e.dispose?.();
|
|
332
|
-
}
|
|
333
|
-
};
|
|
334
|
-
}
|
|
335
|
-
// src/games/tanks-live/scene/createLiveScene.js
|
|
336
|
-
var Pe = 4, Fe = 8, Ie = 14, Le = 2, Re = 1 / 15, ze = new k(.62, .42, .66).normalize(), Be = {
|
|
337
|
-
green: "green",
|
|
338
|
-
red: "red"
|
|
339
|
-
}, Ve = n("#7fdcff"), He = {
|
|
340
|
-
green: n("#22c55e"),
|
|
341
|
-
red: n("#ef4444"),
|
|
342
|
-
gold: n("#fbbf24")
|
|
343
|
-
};
|
|
344
|
-
function Ue(e, t, n) {
|
|
345
|
-
let r = s(n), i = [
|
|
346
|
-
r() * 6.28,
|
|
347
|
-
r() * 6.28,
|
|
348
|
-
r() * 6.28,
|
|
349
|
-
r() * 6.28
|
|
350
|
-
], a = new Float32Array(e * e), o = t / (e - 1);
|
|
351
|
-
for (let t = 0; t < e; t++) for (let n = 0; n < e; n++) {
|
|
352
|
-
let r = n * o, s = t * o;
|
|
353
|
-
a[t * e + n] = 2 + .45 * Math.sin(r * .07 + i[0]) * Math.cos(s * .06 + i[1]) + .3 * Math.sin(r * .16 + s * .11 + i[2]) + .18 * Math.cos(r * .23 - s * .19 + i[3]);
|
|
354
|
-
}
|
|
355
|
-
return a;
|
|
356
|
-
}
|
|
357
|
-
function F(e, { arena: a, lowPower: v = !1, reducedMotion: w = !1, onEvent: ce } = {}) {
|
|
358
|
-
if (!e) throw Error("createLiveScene: container element required");
|
|
359
|
-
let le = (e) => {
|
|
360
|
-
try {
|
|
361
|
-
ce?.(e);
|
|
362
|
-
} catch {}
|
|
363
|
-
}, T = v ? "low" : "high", E = b(a), D = Math.ceil((Math.max(E.width, E.depth) + 28) / Le) * Le, A = Ie - E.minX, j = Ie - E.minZ, M = !1, N = typeof window < "u" && window.devicePixelRatio || 1, P = new Oe({
|
|
364
|
-
antialias: !v || N < 2,
|
|
365
|
-
alpha: !1,
|
|
366
|
-
stencil: !1,
|
|
367
|
-
powerPreference: "high-performance"
|
|
368
|
-
});
|
|
369
|
-
P.outputEncoding = ke, P.toneMapping = C, P.toneMappingExposure = 1.05, P.shadowMap.enabled = !v, P.shadowMap.type = Se, P.setPixelRatio(Math.min(N, v ? 1.25 : 1.75)), P.setClearColor(m.horizon, 1);
|
|
370
|
-
let F = P.domElement;
|
|
371
|
-
F.style.display = "block", F.style.width = "100%", F.style.height = "100%", F.style.outline = "none", e.appendChild(F);
|
|
372
|
-
let We = Math.max(1, e.clientWidth), Ge = Math.max(1, e.clientHeight);
|
|
373
|
-
P.setSize(We, Ge, !1);
|
|
374
|
-
let Ke = !1, qe = (e) => {
|
|
375
|
-
e?.preventDefault?.(), Ke = !0, le({ type: "context_lost" });
|
|
376
|
-
};
|
|
377
|
-
F.addEventListener("webglcontextlost", qe);
|
|
378
|
-
let I = new Ee();
|
|
379
|
-
I.fog = new fe(m.fog.clone(), 70, 320);
|
|
380
|
-
let L = new Ce(55, We / Ge, .5, 1400), R = new pe();
|
|
381
|
-
I.add(R);
|
|
382
|
-
let Je = new me(n("#ffd2b0"), n("#33402f"), v ? .8 : .6), z = new ue(n("#ffbe7a"), 1.9);
|
|
383
|
-
if (!v) {
|
|
384
|
-
z.castShadow = !0, z.shadow.mapSize.set(1024, 1024), z.shadow.bias = -6e-4, z.shadow.normalBias = .04;
|
|
385
|
-
let e = z.shadow.camera;
|
|
386
|
-
e.left = -42, e.right = 42, e.top = 42, e.bottom = -42, e.near = 20, e.far = 320, e.updateProjectionMatrix();
|
|
387
|
-
}
|
|
388
|
-
I.add(Je, z, z.target);
|
|
389
|
-
let B = new k(D / 2, 0, D / 2), Ye = p(ze);
|
|
390
|
-
I.add(Ye.mesh);
|
|
391
|
-
let Xe = h(B, ze);
|
|
392
|
-
I.add(Xe.mesh);
|
|
393
|
-
let V = f(), Ze = D / Le + 1;
|
|
394
|
-
V.setHeights({
|
|
395
|
-
heights: Ue(Ze, D, Number(a?.seed) || 7),
|
|
396
|
-
grid: Ze,
|
|
397
|
-
size: D
|
|
398
|
-
}), R.add(V.mesh);
|
|
399
|
-
let Qe = oe(a) ? a : null, $e = Ae(Qe);
|
|
400
|
-
je($e, {
|
|
401
|
-
renderer: P,
|
|
402
|
-
scene: I,
|
|
403
|
-
sky: Ye,
|
|
404
|
-
hills: Xe,
|
|
405
|
-
hemi: Je,
|
|
406
|
-
sun: z,
|
|
407
|
-
terrain: V
|
|
408
|
-
});
|
|
409
|
-
let H = g();
|
|
410
|
-
H.setQuality(T), H.setShadows(!v);
|
|
411
|
-
let et = Qe ? ne(a).filter((e) => e.shape === "circle" && (e.kind === "tree" || e.kind === "rock")) : te(a), tt = [], nt = [];
|
|
412
|
-
for (let e of et) {
|
|
413
|
-
let t = e.x + A, n = e.z + j;
|
|
414
|
-
e.kind === "tree" ? tt.push({
|
|
415
|
-
kind: "tree",
|
|
416
|
-
x: t,
|
|
417
|
-
z: n,
|
|
418
|
-
scale: i(e.r / 1.3, .7, 2.2)
|
|
419
|
-
}) : nt.push({
|
|
420
|
-
kind: "rock",
|
|
421
|
-
x: t,
|
|
422
|
-
z: n,
|
|
423
|
-
w: e.r * 2,
|
|
424
|
-
d: e.r * 2,
|
|
425
|
-
h: e.r * 1.2
|
|
426
|
-
});
|
|
427
|
-
}
|
|
428
|
-
{
|
|
429
|
-
let e = s(31), t = v ? 40 : 90;
|
|
430
|
-
for (let n = 0; n < t; n++) {
|
|
431
|
-
let t = n % 4, r = e() * D, i = 2 + e() * 9, a = t === 0 ? i : t === 1 ? D - i : r, o = t === 2 ? i : t === 3 ? D - i : r;
|
|
432
|
-
$e?.border === "rock" ? n % 2 == 0 && tt.push({
|
|
433
|
-
kind: "rock",
|
|
434
|
-
x: a,
|
|
435
|
-
z: o,
|
|
436
|
-
scale: .8 + e() * 1.4
|
|
437
|
-
}) : tt.push({
|
|
438
|
-
kind: "tree",
|
|
439
|
-
x: a,
|
|
440
|
-
z: o,
|
|
441
|
-
scale: .8 + e() * .7
|
|
442
|
-
});
|
|
443
|
-
}
|
|
444
|
-
}
|
|
445
|
-
let rt = new Set(R.children);
|
|
446
|
-
H.build(R, {
|
|
447
|
-
decor: tt,
|
|
448
|
-
obstacles: nt
|
|
449
|
-
}, V), Me(R, rt, $e?.treeTint);
|
|
450
|
-
let U = Qe ? Ne(R, Qe, V, {
|
|
451
|
-
ox: A,
|
|
452
|
-
oz: j,
|
|
453
|
-
lowPower: v,
|
|
454
|
-
shadows: !v
|
|
455
|
-
}) : null, it = [];
|
|
456
|
-
{
|
|
457
|
-
let e = s(53), t = v ? 7 : 4.5, n = (n, r, i, a) => {
|
|
458
|
-
let o = Math.hypot(i - n, a - r), s = Math.max(1, Math.round(o / t));
|
|
459
|
-
for (let t = 0; t <= s; t++) {
|
|
460
|
-
let o = t / s;
|
|
461
|
-
it.push({
|
|
462
|
-
kind: "rock",
|
|
463
|
-
x: n + (i - n) * o,
|
|
464
|
-
z: r + (a - r) * o,
|
|
465
|
-
scale: .45 + e() * .35
|
|
466
|
-
});
|
|
467
|
-
}
|
|
468
|
-
}, r = Ie + E.width + 1, i = Ie + E.depth + 1;
|
|
469
|
-
n(13, 13, r, 13), n(r, 13, r, i), n(r, i, 13, i), n(13, i, 13, 13);
|
|
470
|
-
}
|
|
471
|
-
let at = g();
|
|
472
|
-
at.setQuality(T), at.build(R, {
|
|
473
|
-
decor: it,
|
|
474
|
-
obstacles: []
|
|
475
|
-
}, V);
|
|
476
|
-
let W = S(I, {
|
|
477
|
-
quality: T,
|
|
478
|
-
reducedMotion: w,
|
|
479
|
-
heightAt: V.heightAt
|
|
480
|
-
}), ot = u(), G = d();
|
|
481
|
-
G.wheelMat = v ? new be({ vertexColors: !0 }) : new xe({
|
|
482
|
-
vertexColors: !0,
|
|
483
|
-
roughness: .7,
|
|
484
|
-
metalness: .25
|
|
485
|
-
});
|
|
486
|
-
let K = new ge(ot.wheel, G.wheelMat, Pe * l.length);
|
|
487
|
-
K.instanceMatrix.setUsage(de), K.frustumCulled = !1, K.count = 0, R.add(K);
|
|
488
|
-
let st = r(64), ct = new O(1, 1);
|
|
489
|
-
ct.rotateX(-Math.PI / 2);
|
|
490
|
-
let lt = new ye({
|
|
491
|
-
map: st,
|
|
492
|
-
transparent: !0,
|
|
493
|
-
depthWrite: !1,
|
|
494
|
-
polygonOffset: !0,
|
|
495
|
-
polygonOffsetFactor: -2,
|
|
496
|
-
polygonOffsetUnits: -2
|
|
497
|
-
}), q = new ge(ct, lt, Pe);
|
|
498
|
-
q.frustumCulled = !1, q.count = 0, q.renderOrder = 2, R.add(q);
|
|
499
|
-
let J = /* @__PURE__ */ new Map(), ut = new he(1, v ? 1 : 2), dt = new ye({
|
|
500
|
-
color: Ve,
|
|
501
|
-
transparent: !0,
|
|
502
|
-
opacity: .3,
|
|
503
|
-
depthWrite: !1,
|
|
504
|
-
blending: se
|
|
505
|
-
}), ft = 0, Y = new k(), X = new k(), pt = new _e(), mt = new k();
|
|
506
|
-
function ht(e, t) {
|
|
507
|
-
let n = String(e.id), r = J.get(n);
|
|
508
|
-
if (r && r.alive === !1 && e.alive !== !1 && (gt(n), r = null), r) return r;
|
|
509
|
-
let i = Be[e.color] || (t === 0 ? "green" : "red"), a = c(ot, G, {
|
|
510
|
-
id: n,
|
|
511
|
-
color: i,
|
|
512
|
-
quality: T
|
|
513
|
-
});
|
|
514
|
-
return a.setShadows(!v), R.add(a.root), a.state.pitch = 4, r = {
|
|
515
|
-
t: a,
|
|
516
|
-
color: i,
|
|
517
|
-
alive: !0,
|
|
518
|
-
last: null,
|
|
519
|
-
dustAcc: 0,
|
|
520
|
-
exhaustAcc: 0,
|
|
521
|
-
seen: !0
|
|
522
|
-
}, J.set(n, r), r;
|
|
523
|
-
}
|
|
524
|
-
function gt(e) {
|
|
525
|
-
let t = J.get(e);
|
|
526
|
-
t && (t.t.state.blown && t.t.turret.removeFromParent(), t.bubble?.removeFromParent(), t.t.dispose(), J.delete(e));
|
|
527
|
-
}
|
|
528
|
-
function _t(e, t) {
|
|
529
|
-
let n = e.state;
|
|
530
|
-
if (n.blown) return;
|
|
531
|
-
if (R.attach(e.turret), !t) {
|
|
532
|
-
let t = (n.hullYaw + 120) * o, r = n.x + Math.cos(t) * 4.5, i = n.z + Math.sin(t) * 4.5;
|
|
533
|
-
e.turret.position.set(r, V.heightAt(r, i) + .2, i), e.turret.rotation.set(.5, t, 2.6), n.blown = {
|
|
534
|
-
p: e.turret.position.clone(),
|
|
535
|
-
v: new k(),
|
|
536
|
-
w: new k(),
|
|
537
|
-
landed: !0
|
|
538
|
-
};
|
|
539
|
-
return;
|
|
540
|
-
}
|
|
541
|
-
let r = Math.random() * Math.PI * 2;
|
|
542
|
-
n.blown = {
|
|
543
|
-
p: e.turret.position.clone(),
|
|
544
|
-
v: new k(Math.cos(r) * 3.5, 15, Math.sin(r) * 3.5),
|
|
545
|
-
w: new k((Math.random() - .5) * 6, (Math.random() - .5) * 5, (Math.random() - .5) * 6),
|
|
546
|
-
landed: !1
|
|
547
|
-
};
|
|
548
|
-
}
|
|
549
|
-
function vt(e, t) {
|
|
550
|
-
let n = e.state.blown;
|
|
551
|
-
if (!n || n.landed) return;
|
|
552
|
-
n.v.y -= 20 * t, n.p.addScaledVector(n.v, t), e.turret.rotation.x += n.w.x * t, e.turret.rotation.y += n.w.y * t, e.turret.rotation.z += n.w.z * t;
|
|
553
|
-
let r = V.heightAt(n.p.x, n.p.z) + .25;
|
|
554
|
-
n.p.y < r && n.v.y < 0 && (n.p.y = r, n.v.y < -5 ? (n.v.y *= -.25, n.v.x *= .5, n.v.z *= .5, n.w.multiplyScalar(.4), W.dust(n.p.x, r, n.p.z, 2)) : n.landed = !0), e.turret.position.copy(n.p);
|
|
555
|
-
}
|
|
556
|
-
let yt = /* @__PURE__ */ new Map(), bt = Array.from({ length: Fe }, (e, t) => t);
|
|
557
|
-
function xt(e) {
|
|
558
|
-
let t = /* @__PURE__ */ new Set();
|
|
559
|
-
for (let n of e || []) {
|
|
560
|
-
let e = String(n.id);
|
|
561
|
-
t.add(e);
|
|
562
|
-
let r = n.x + A, i = n.z + j, a = Number.isFinite(n.y) ? n.y + St : V.heightAt(r, i) + 1.8, o = yt.get(e);
|
|
563
|
-
if (o == null) {
|
|
564
|
-
if (!bt.length) continue;
|
|
565
|
-
o = bt.pop(), yt.set(e, o), W.projShow(o, r, a, i, !1);
|
|
566
|
-
} else W.projMove(o, r, a, i);
|
|
567
|
-
}
|
|
568
|
-
for (let [e, n] of yt) t.has(e) || (W.projHide(n), yt.delete(e), bt.push(n));
|
|
569
|
-
}
|
|
570
|
-
let St = 2, Z = {
|
|
571
|
-
pos: new k(),
|
|
572
|
-
target: new k(),
|
|
573
|
-
yaw: 0,
|
|
574
|
-
snap: !0,
|
|
575
|
-
shake: 0,
|
|
576
|
-
orbit: 0
|
|
577
|
-
}, Ct = !1;
|
|
578
|
-
function wt() {
|
|
579
|
-
let e = We / Ge;
|
|
580
|
-
Ct = e < .85, L.fov = Ct ? 68 : e < 1.25 ? 60 : 52, L.aspect = e, L.updateProjectionMatrix();
|
|
581
|
-
}
|
|
582
|
-
wt();
|
|
583
|
-
function Tt(e) {
|
|
584
|
-
w || (Z.shake = Math.max(Z.shake, e));
|
|
585
|
-
}
|
|
586
|
-
function Et(e, n) {
|
|
587
|
-
if (!n) Z.pos.set(B.x, 70, B.z + D * .55), Z.target.set(B.x, 2, B.z);
|
|
588
|
-
else {
|
|
589
|
-
let r = n.t.state, i = Ct ? 19 : 15, a = Ct ? 15 : 10.5, s = Ct ? 14 : 12;
|
|
590
|
-
if (n.alive) {
|
|
591
|
-
let n = ae(r.hullYaw * o - Z.yaw);
|
|
592
|
-
Z.yaw += n * (Z.snap ? 1 : t(2.6, e));
|
|
593
|
-
let c = Math.cos(Z.yaw), l = Math.sin(Z.yaw);
|
|
594
|
-
Y.set(r.x - c * i, r.y + a, r.z - l * i), X.set(r.x + c * s, r.y + 1, r.z + l * s);
|
|
595
|
-
} else Z.orbit += e * (w ? 0 : .3), Y.set(r.x + Math.cos(Z.orbit) * 20, r.y + 9, r.z + Math.sin(Z.orbit) * 20), X.set(r.x, r.y + 2, r.z);
|
|
596
|
-
let c = V.heightAt(Y.x, Y.z) + 2.5;
|
|
597
|
-
Y.y < c && (Y.y = c), Z.snap ? (Z.pos.copy(Y), Z.target.copy(X), Z.orbit = Math.atan2(Z.pos.z - r.z, Z.pos.x - r.x)) : (Z.pos.lerp(Y, t(6, e)), Z.target.lerp(X, t(8, e))), Z.snap = !1;
|
|
598
|
-
}
|
|
599
|
-
if (L.position.copy(Z.pos), Z.shake > .002) {
|
|
600
|
-
let t = Z.shake;
|
|
601
|
-
L.position.x += (Math.random() - .5) * t, L.position.y += (Math.random() - .5) * t, L.position.z += (Math.random() - .5) * t, Z.shake *= Math.exp(-7 * e);
|
|
602
|
-
} else Z.shake = 0;
|
|
603
|
-
L.lookAt(Z.target), v || (z.target.position.copy(Z.target), z.position.copy(Z.target).addScaledVector(ze, 200));
|
|
604
|
-
}
|
|
605
|
-
let Q = null;
|
|
606
|
-
function Dt(e, t) {
|
|
607
|
-
let n = ie(e);
|
|
608
|
-
if (n === "fire") {
|
|
609
|
-
let n = ee(e, t), r = n ? J.get(String(n.id)) : null;
|
|
610
|
-
if (!r) return;
|
|
611
|
-
r.t.state.recoil = 1, r.t.muzzleWorld(Y), r.t.gunDirWorld(X), W.muzzle(Y, X), n.self && Tt(.18);
|
|
612
|
-
} else if (n === "impact") {
|
|
613
|
-
if (!Number.isFinite(e.x) || !Number.isFinite(e.z)) return;
|
|
614
|
-
let t = e.x + A, n = e.z + j, r = V.heightAt(t, n);
|
|
615
|
-
if (e.kind === "shield") {
|
|
616
|
-
W.flash(t, r + 1.6, n, 6, Ve, .25), W.hitSparks(t, r + 1.4, n);
|
|
617
|
-
return;
|
|
618
|
-
}
|
|
619
|
-
W.explosion(t, r, n, 3, e.kind === "obstacle" ? "obstacle" : "terrain"), V.crater(t, n, 2.2, 0), H.blast(V, t, n, 2.5);
|
|
620
|
-
} else if (n === "hit") {
|
|
621
|
-
let n = y(t, e.target), r = n ? J.get(String(n.id)) : null, i = Number.isFinite(e.x) ? e.x + A : r?.t.state.x, a = Number.isFinite(e.z) ? e.z + j : r?.t.state.z;
|
|
622
|
-
if (i == null) return;
|
|
623
|
-
let o = (r ? r.t.state.y : V.heightAt(i, a)) + 1.6;
|
|
624
|
-
W.hitSparks(i, o, a), W.explosion(i, o, a, 2.6, "tank"), r && (r.t.state.hitFlash = 1), Tt(n?.self ? .9 : .25);
|
|
625
|
-
} else if (n === "destroyed") {
|
|
626
|
-
let n = y(t, e.target), r = n ? J.get(String(n.id)) : null;
|
|
627
|
-
if (!r) return;
|
|
628
|
-
let i = r.t.state;
|
|
629
|
-
W.bigExplosion(i.x, i.y, i.z), H.blast(V, i.x, i.z, 6), V.crater(i.x, i.z, 4, 0), r.t.setCharred(!0), _t(r.t, !w), r.alive = !1, Tt(n.self ? 1.4 : .6);
|
|
630
|
-
} else if (U && (n === "crate_break" || n === "barrel_explode")) {
|
|
631
|
-
let r = Number.isFinite(e.x) ? e.x + A : null, i = Number.isFinite(e.z) ? e.z + j : null, a = U.breakDestructible(e.id ?? e.target) || (r == null ? null : U.nearest(r, i));
|
|
632
|
-
a && !a.broken && U.breakDestructible(a.id);
|
|
633
|
-
let o = r ?? a?.x, s = i ?? a?.z;
|
|
634
|
-
if (o == null) return;
|
|
635
|
-
let c = V.heightAt(o, s);
|
|
636
|
-
if (n === "crate_break") W.explosion(o, c + .4, s, 1.6, "obstacle"), W.dust(o, c, s, 1.5);
|
|
637
|
-
else {
|
|
638
|
-
W.explosion(o, c + .6, s, 6, "tank"), V.crater(o, s, 3, 0), H.blast(V, o, s, 6);
|
|
639
|
-
let n = (t || []).find((e) => e.self);
|
|
640
|
-
Tt(n && Math.hypot(n.x + A - o, n.z + j - s) < 14 ? .8 : .3);
|
|
641
|
-
let r = e.chained && typeof e.chained == "object" ? U.breakDestructible(e.chained.id) : null;
|
|
642
|
-
r && (W.explosion(r.x, r.y + .6, r.z, 6, "tank"), V.crater(r.x, r.z, 3, 0), H.blast(V, r.x, r.z, 6));
|
|
643
|
-
}
|
|
644
|
-
} else if (U && n === "destructible_hit") {
|
|
645
|
-
let t = U.destructibles.get(String(e.target ?? e.id));
|
|
646
|
-
t && !t.broken && (W.dust(t.x, t.y + .5, t.z, 1), t.mesh.rotation.y += .25);
|
|
647
|
-
} else if (n === "wall_hit") {
|
|
648
|
-
if (!Number.isFinite(e.x) || !Number.isFinite(e.z)) return;
|
|
649
|
-
let t = e.x + A, n = e.z + j;
|
|
650
|
-
W.dust(t, V.heightAt(t, n) + 1, n, 1.2);
|
|
651
|
-
} else if (n === "respawn") {
|
|
652
|
-
let n = y(t, e.target ?? e.tank), r = Number.isFinite(e.x) ? e.x + A : n ? n.x + A : null, i = Number.isFinite(e.z) ? e.z + j : n ? n.z + j : null;
|
|
653
|
-
if (r == null) return;
|
|
654
|
-
let a = V.heightAt(r, i);
|
|
655
|
-
W.ring(r, a + .2, i, 7, .8, Ve), W.flash(r, a + 1.6, i, 7, Ve, .35), w || W.dust(r, a, i, 2), n?.self && (Z.snap = !0);
|
|
656
|
-
} else n === "over" && (Q = {
|
|
657
|
-
id: e.winner == null ? null : String(e.winner),
|
|
658
|
-
t: 0,
|
|
659
|
-
next: .2
|
|
660
|
-
});
|
|
661
|
-
}
|
|
662
|
-
let Ot = {
|
|
663
|
-
tanks: 0,
|
|
664
|
-
shells: 0,
|
|
665
|
-
particles: 0,
|
|
666
|
-
calls: 0,
|
|
667
|
-
triangles: 0
|
|
668
|
-
}, $ = null;
|
|
669
|
-
function kt(e, t = 16) {
|
|
670
|
-
if (M || Ke) return;
|
|
671
|
-
let n = i((Number(t) || 16) / 1e3, .001, Re), r = e && e.tanks || [];
|
|
672
|
-
ft += n, w || (dt.opacity = .24 + Math.sin(ft * 5) * .06);
|
|
673
|
-
for (let e of J.values()) e.seen = !1;
|
|
674
|
-
let a = 0, s = 0;
|
|
675
|
-
$ = null, r.forEach((t, r) => {
|
|
676
|
-
if (!Number.isFinite(t.x) || !Number.isFinite(t.z)) return;
|
|
677
|
-
let i = ht(t, r);
|
|
678
|
-
i.seen = !0;
|
|
679
|
-
let c = i.t, u = c.state, d = t.x + A, f = t.z + j, p = (t.yaw ?? 0) * re;
|
|
680
|
-
if (i.last) {
|
|
681
|
-
let e = d - i.last.x, t = f - i.last.z, r = e * Math.cos(p * o) + t * Math.sin(p * o), a = ae((p - i.last.yaw) * o) * 1.4;
|
|
682
|
-
(Math.abs(r) > 1e-4 || Math.abs(a) > 1e-4) && c.scrollTracks(Math.abs(r) > 1e-4 ? r : a);
|
|
683
|
-
let s = Math.hypot(e, t) / n;
|
|
684
|
-
if (s > 1 && i.alive) for (i.dustAcc += n * s * (v ? .5 : 1); i.dustAcc > 1.4;) i.dustAcc -= 1.4, c.localToWorld(Y, -2.6, 0, (Math.random() - .5) * 2.6), W.dust(Y.x, V.heightAt(Y.x, Y.z), Y.z, .9);
|
|
685
|
-
}
|
|
686
|
-
if (i.last = {
|
|
687
|
-
x: d,
|
|
688
|
-
z: f,
|
|
689
|
-
yaw: p
|
|
690
|
-
}, i.alive && t.alive !== !1) for (i.exhaustAcc += n * (v ? 3 : 6); i.exhaustAcc > 1;) --i.exhaustAcc, c.localToWorld(Y, -2.9, 1.3, .8), W.exhaust(Y.x, Y.y, Y.z);
|
|
691
|
-
u.x = d, u.z = f, u.y = V.heightAt(d, f), u.hullYaw = p, u.yaw = (t.turretYaw ?? t.yaw ?? 0) * re, u.hp = t.hp ?? u.hp, t.alive === !1 && i.alive && (i.alive = !1, c.setCharred(!0), _t(c, !1)), u.recoil > 0 && (u.recoil = Math.max(0, u.recoil - n * 4)), u.hitFlash > 0 && (u.hitFlash = Math.max(0, u.hitFlash - n * 3), c.setFlash(u.hitFlash)), c.place(V, n), vt(c, n);
|
|
692
|
-
let m = i.alive && t.alive !== !1 ? x(e, t) : 0;
|
|
693
|
-
if (m > 0 && !i.bubble && (i.bubble = new ve(ut, dt), i.bubble.renderOrder = 3, R.add(i.bubble)), i.bubble && (i.bubble.visible = m > 0 && (m > 500 || Math.floor(ft * 8) % 2 == 0), i.bubble.visible)) {
|
|
694
|
-
let e = 3.6 + (w ? 0 : Math.sin(ft * 6) * .12);
|
|
695
|
-
i.bubble.position.set(u.x, u.y + 1.3, u.z), i.bubble.scale.set(e * 1.1, e * .75, e * 1.1);
|
|
696
|
-
}
|
|
697
|
-
let h = _(t.hp ?? 100, i.alive);
|
|
698
|
-
h > 0 && (c.localToWorld(Y, -.6, 2.2, 0), W.emitDamage(Y.x, Y.y, Y.z, n, h, u)), a + l.length <= Pe * l.length && (c.writeWheels(K, a), a += l.length), v && s < Pe && (mt.set(8, 1, 6), pt.makeRotationY(-p * o).scale(mt).setPosition(d, u.y + .05, f), q.setMatrixAt(s++, pt)), t.self && ($ = i);
|
|
699
|
-
});
|
|
700
|
-
for (let [e, t] of J) t.seen || gt(e);
|
|
701
|
-
K.count = a, K.instanceMatrix.needsUpdate = !0, q.count = s, s && (q.instanceMatrix.needsUpdate = !0), !$ && r.length && ($ = J.get(String(r[0].id)) || null);
|
|
702
|
-
for (let t of e && e.events || []) Dt(t, r);
|
|
703
|
-
if (U && U.sync(e), xt(e && e.shells), Q) {
|
|
704
|
-
Q.t += n;
|
|
705
|
-
let e = Q.id == null ? null : J.get(Q.id);
|
|
706
|
-
if (e && Q.t < 4 && Q.t >= Q.next && !w) {
|
|
707
|
-
Q.next += .45;
|
|
708
|
-
let t = e.t.state;
|
|
709
|
-
W.firework(t.x + (Math.random() - .5) * 8, t.y + 9 + Math.random() * 4, t.z + (Math.random() - .5) * 8, Math.random() < .5 && He[e.color] || He.gold);
|
|
710
|
-
}
|
|
711
|
-
Q.t > 4 && (Q = null);
|
|
712
|
-
}
|
|
713
|
-
Et(n, $), W.update(n, L, P, !1), P.render(I, L);
|
|
714
|
-
let c = P.info.render;
|
|
715
|
-
Ot = {
|
|
716
|
-
tanks: J.size,
|
|
717
|
-
shells: yt.size,
|
|
718
|
-
particles: W.particleCount,
|
|
719
|
-
calls: c.calls,
|
|
720
|
-
triangles: c.triangles
|
|
721
|
-
};
|
|
722
|
-
}
|
|
723
|
-
let At = new Te(), jt = new De(), Mt = new we(new k(0, 1, 0), 0), Nt = new k();
|
|
724
|
-
function Pt(e, t) {
|
|
725
|
-
if (M) return null;
|
|
726
|
-
jt.set(e, t), At.setFromCamera(jt, L);
|
|
727
|
-
let n = $ ? $.t.state.y + 1 : 2;
|
|
728
|
-
return Mt.constant = -n, At.ray.intersectPlane(Mt, Nt) ? {
|
|
729
|
-
x: Nt.x - A,
|
|
730
|
-
z: Nt.z - j
|
|
731
|
-
} : null;
|
|
732
|
-
}
|
|
733
|
-
function Ft() {
|
|
734
|
-
if (M) return;
|
|
735
|
-
let t = e.clientWidth, n = e.clientHeight;
|
|
736
|
-
t && n && (We = t, Ge = n, P.setSize(t, n, !1), wt());
|
|
737
|
-
}
|
|
738
|
-
let It = typeof ResizeObserver < "u" ? new ResizeObserver(Ft) : null;
|
|
739
|
-
return It ? It.observe(e) : typeof window < "u" && window.addEventListener("resize", Ft), {
|
|
740
|
-
kind: "3d",
|
|
741
|
-
render: kt,
|
|
742
|
-
screenToGround: Pt,
|
|
743
|
-
resize: Ft,
|
|
744
|
-
getStats() {
|
|
745
|
-
return { ...Ot };
|
|
746
|
-
},
|
|
747
|
-
dispose() {
|
|
748
|
-
if (!M) {
|
|
749
|
-
M = !0, It ? It.disconnect() : typeof window < "u" && window.removeEventListener("resize", Ft), F.removeEventListener("webglcontextlost", qe);
|
|
750
|
-
for (let e of Array.from(J.keys())) gt(e);
|
|
751
|
-
K.dispose(), G.wheelMat.dispose(), G.dispose(), ot.dispose(), q.dispose(), ct.dispose(), lt.dispose(), st.dispose(), W.dispose(), H.dispose(), at.dispose(), U?.dispose(), ut.dispose(), dt.dispose(), V.dispose(), Ye.dispose(), Xe.dispose(), z.shadow && z.shadow.map && z.shadow.map.dispose(), I.clear(), P.dispose(), P.forceContextLoss(), F.parentNode && F.parentNode.removeChild(F);
|
|
752
|
-
}
|
|
753
|
-
}
|
|
754
|
-
};
|
|
755
|
-
}
|
|
756
|
-
export { F as createLiveScene, F as default };
|
|
757
|
-
|
|
758
|
-
//# sourceMappingURL=createLiveScene-MTGRv8rx.js.map
|