phoria2 1.2.0 → 1.3.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/README.md +2 -3
- package/dist/charts.js +476 -459
- package/dist/charts.js.map +1 -1
- package/dist/core.js +1192 -963
- package/dist/core.js.map +1 -1
- package/dist/edit.js +75 -75
- package/dist/edit.js.map +1 -1
- package/dist/explain.js +1 -1
- package/dist/gltf.js +84 -84
- package/dist/gltf.js.map +1 -1
- package/dist/keyboard.js +188 -0
- package/dist/keyboard.js.map +1 -0
- package/dist/motion.js +35 -35
- package/dist/motion.js.map +1 -1
- package/dist/particles.js +191 -118
- package/dist/particles.js.map +1 -1
- package/dist/passes.js +16 -16
- package/dist/passes.js.map +1 -1
- package/dist/phoria2.js +1 -1
- package/dist/picking.js +30 -14
- package/dist/picking.js.map +1 -1
- package/dist/snapshot.js +1 -1
- package/dist/tooltip.js +1 -1
- package/dist/types/View.d.ts +11 -0
- package/dist/types/area.d.ts +18 -0
- package/dist/types/geometry/Geometry.d.ts +16 -0
- package/dist/types/index.d.ts +2 -0
- package/dist/types/material/Material.d.ts +15 -0
- package/dist/types/material/Texture.d.ts +18 -2
- package/dist/types/particles/Emitter.d.ts +39 -2
- package/dist/types/scene/drawables.d.ts +23 -2
- package/dist/types/webgl/resources.d.ts +12 -2
- package/dist/types/webgl/shaders.d.ts +7 -2
- package/llms-full.txt +48 -1
- package/package.json +1 -1
- package/schema/scene.schema.json +48 -0
- package/src/View.js +16 -0
- package/src/area.js +131 -0
- package/src/charts/marks.js +29 -2
- package/src/geometry/Geometry.js +16 -1
- package/src/index.js +1 -0
- package/src/material/Material.js +9 -2
- package/src/material/Texture.js +55 -2
- package/src/particles/Emitter.js +121 -10
- package/src/scene/drawables.js +68 -4
- package/src/watch.js +8 -1
- package/src/webgl/WebGLRenderer.js +36 -5
- package/src/webgl/picking.js +22 -1
- package/src/webgl/resources.js +168 -14
- package/src/webgl/shaders.js +110 -11
package/dist/core.js
CHANGED
|
@@ -869,13 +869,23 @@ var Ne = class e extends Float32Array {
|
|
|
869
869
|
"uvs",
|
|
870
870
|
"uvs2",
|
|
871
871
|
"colors",
|
|
872
|
+
"sizes",
|
|
873
|
+
"opacities",
|
|
874
|
+
"angles",
|
|
872
875
|
"indices"
|
|
876
|
+
], Fe = [
|
|
877
|
+
"sizes",
|
|
878
|
+
"opacities",
|
|
879
|
+
"angles"
|
|
873
880
|
], U = class e {
|
|
874
881
|
static OPTIONS = Pe;
|
|
875
882
|
positions;
|
|
876
883
|
uvs = null;
|
|
877
884
|
uvs2 = null;
|
|
878
885
|
colors = null;
|
|
886
|
+
sizes = null;
|
|
887
|
+
opacities = null;
|
|
888
|
+
angles = null;
|
|
879
889
|
indices = null;
|
|
880
890
|
version = 0;
|
|
881
891
|
drawCount = null;
|
|
@@ -885,9 +895,11 @@ var Ne = class e extends Float32Array {
|
|
|
885
895
|
#n = null;
|
|
886
896
|
#r = /* @__PURE__ */ new Set();
|
|
887
897
|
constructor(e) {
|
|
888
|
-
A("Geometry", e, Pe), e?.positions || E("Geometry", "'positions' is required - an array of x, y, z per vertex"), this.positions =
|
|
898
|
+
A("Geometry", e, Pe), e?.positions || E("Geometry", "'positions' is required - an array of x, y, z per vertex"), this.positions = Ie("positions", e.positions, 3);
|
|
889
899
|
let t = this.vertexCount;
|
|
890
|
-
|
|
900
|
+
e.normals && (this.#e = Ie("normals", e.normals, 3, t)), e.uvs && (this.uvs = Ie("uvs", e.uvs, 2, t)), e.uvs2 && (this.uvs2 = Ie("uvs2", e.uvs2, 2, t)), e.colors && (this.colors = Ie("colors", e.colors, 3, t));
|
|
901
|
+
for (let n of Fe) e[n] && (this[n] = Ie(n, e[n], 1, t));
|
|
902
|
+
if (e.indices) {
|
|
891
903
|
let n = -1;
|
|
892
904
|
for (let t = 0; t < e.indices.length; t++) {
|
|
893
905
|
let r = e.indices[t];
|
|
@@ -950,6 +962,9 @@ var Ne = class e extends Float32Array {
|
|
|
950
962
|
uvs: this.uvs ?? void 0,
|
|
951
963
|
uvs2: this.uvs2 ?? void 0,
|
|
952
964
|
colors: this.colors ?? void 0,
|
|
965
|
+
sizes: this.sizes ?? void 0,
|
|
966
|
+
opacities: this.opacities ?? void 0,
|
|
967
|
+
angles: this.angles ?? void 0,
|
|
953
968
|
indices: this.indices ?? void 0
|
|
954
969
|
});
|
|
955
970
|
return t.source = this.source && { ...this.source }, t.drawCount = this.drawCount, t;
|
|
@@ -963,7 +978,9 @@ var Ne = class e extends Float32Array {
|
|
|
963
978
|
toJSON() {
|
|
964
979
|
if (this.source) return { ...this.source };
|
|
965
980
|
let e = { positions: Array.from(this.positions) };
|
|
966
|
-
|
|
981
|
+
this.#e && (e.normals = Array.from(this.#e)), this.uvs && (e.uvs = Array.from(this.uvs)), this.uvs2 && (e.uvs2 = Array.from(this.uvs2)), this.colors && (e.colors = Array.from(this.colors));
|
|
982
|
+
for (let t of Fe) this[t] && (e[t] = Array.from(this[t]));
|
|
983
|
+
return this.indices && (e.indices = Array.from(this.indices)), e;
|
|
967
984
|
}
|
|
968
985
|
#a(e) {
|
|
969
986
|
return this.indices ? this.indices[e] : e;
|
|
@@ -975,17 +992,19 @@ var Ne = class e extends Float32Array {
|
|
|
975
992
|
for (let i = 0; i < e.length; i++) for (let a = 0; a < n; a++) r[i * n + a] = t[e[i] * n + a];
|
|
976
993
|
return r;
|
|
977
994
|
};
|
|
978
|
-
this.positions = t(this.positions, 3), this.uvs = t(this.uvs, 2), this.uvs2 = t(this.uvs2, 2), this.colors = t(this.colors, 3)
|
|
995
|
+
this.positions = t(this.positions, 3), this.uvs = t(this.uvs, 2), this.uvs2 = t(this.uvs2, 2), this.colors = t(this.colors, 3);
|
|
996
|
+
for (let e of Fe) this[e] = t(this[e], 1);
|
|
997
|
+
this.indices = null, this.source = null;
|
|
979
998
|
}
|
|
980
999
|
};
|
|
981
|
-
function
|
|
1000
|
+
function Ie(e, t, n, r) {
|
|
982
1001
|
t && typeof t == "object" && typeof t.length == "number" || E("Geometry", `'${e}' must be an array of numbers, got ${j(t)}`), t.length % n !== 0 && E("Geometry", `'${e}' has ${t.length} numbers - expected ${n} per vertex`), r !== void 0 && t.length !== r * n && E("Geometry", `'${e}' has ${t.length / n} entries but 'positions' has ${r} vertices`);
|
|
983
1002
|
let i = Float32Array.from(t);
|
|
984
1003
|
for (let t = 0; t < i.length; t++) Number.isNaN(i[t]) && E("Geometry", `'${e}' contains a non-number at index ${t}`);
|
|
985
1004
|
return i;
|
|
986
1005
|
}
|
|
987
1006
|
// src/material/Texture.js
|
|
988
|
-
var
|
|
1007
|
+
var Le = [
|
|
989
1008
|
"image",
|
|
990
1009
|
"url",
|
|
991
1010
|
"colorSpace",
|
|
@@ -999,7 +1018,7 @@ var Ie = [
|
|
|
999
1018
|
"mipmaps",
|
|
1000
1019
|
"anisotropy",
|
|
1001
1020
|
"flipY"
|
|
1002
|
-
],
|
|
1021
|
+
], Re = {
|
|
1003
1022
|
colorSpace: "srgb",
|
|
1004
1023
|
wrap: "repeat",
|
|
1005
1024
|
repeat: [1, 1],
|
|
@@ -1011,7 +1030,7 @@ var Ie = [
|
|
|
1011
1030
|
mipmaps: !0,
|
|
1012
1031
|
anisotropy: 8,
|
|
1013
1032
|
flipY: !1
|
|
1014
|
-
},
|
|
1033
|
+
}, ze = {
|
|
1015
1034
|
src: "use 'url' for the image address",
|
|
1016
1035
|
encoding: "use colorSpace: 'srgb' | 'linear'",
|
|
1017
1036
|
wrapS: "use wrap: 'repeat' | 'clamp' | 'mirror' (applies to both directions)",
|
|
@@ -1019,9 +1038,9 @@ var Ie = [
|
|
|
1019
1038
|
channel: "use 'uvSet' - 0 for the first UV set, 1 for the second",
|
|
1020
1039
|
texCoord: "use 'uvSet' - 0 for the first UV set, 1 for the second",
|
|
1021
1040
|
scale: "use 'repeat' - [u, v] times across"
|
|
1022
|
-
}, W = class {
|
|
1023
|
-
static OPTIONS =
|
|
1024
|
-
static HINTS =
|
|
1041
|
+
}, Be = 256, W = class {
|
|
1042
|
+
static OPTIONS = Le;
|
|
1043
|
+
static HINTS = ze;
|
|
1025
1044
|
#e = null;
|
|
1026
1045
|
url = null;
|
|
1027
1046
|
#t = "srgb";
|
|
@@ -1037,27 +1056,28 @@ var Ie = [
|
|
|
1037
1056
|
anisotropy = 8;
|
|
1038
1057
|
flipY = !1;
|
|
1039
1058
|
version = 0;
|
|
1059
|
+
#r = [];
|
|
1040
1060
|
ready;
|
|
1041
|
-
#
|
|
1061
|
+
#i = /* @__PURE__ */ new Set();
|
|
1042
1062
|
constructor(e = {}) {
|
|
1043
|
-
typeof e == "string" && (e = { url: e }), A("Texture", e,
|
|
1063
|
+
typeof e == "string" && (e = { url: e }), A("Texture", e, Le, ze);
|
|
1044
1064
|
let t = {
|
|
1045
|
-
...
|
|
1065
|
+
...Re,
|
|
1046
1066
|
...e
|
|
1047
1067
|
};
|
|
1048
1068
|
this.#t = P("Texture", "colorSpace", t.colorSpace, ["srgb", "linear"]), this.#n = e.colorSpace !== void 0, this.wrap = P("Texture", "wrap", t.wrap, [
|
|
1049
1069
|
"repeat",
|
|
1050
1070
|
"clamp",
|
|
1051
1071
|
"mirror"
|
|
1052
|
-
]), this.filter = P("Texture", "filter", t.filter, ["linear", "nearest"]), this.repeat =
|
|
1072
|
+
]), this.filter = P("Texture", "filter", t.filter, ["linear", "nearest"]), this.repeat = Ge("repeat", t.repeat), this.offset = Ge("offset", t.offset), this.rotation = M("Texture", "rotation", t.rotation), this.center = Ge("center", t.center), t.uvSet !== 0 && t.uvSet !== 1 && E("Texture", `'uvSet' is 0 (the first UV set) or 1 (the second), got ${j(t.uvSet)}`), this.uvSet = t.uvSet, this.mipmaps = e.mipmaps === void 0 ? !(He(t.image) || !t.image && Ve.test(t.url ?? "")) : !!e.mipmaps, this.anisotropy = M("Texture", "anisotropy", t.anisotropy), this.anisotropy >= 1 || E("Texture", `'anisotropy' is how many samples along a glancing angle - 1 (off) or more, got ${this.anisotropy}`), this.flipY = !!t.flipY, this.url = t.url ?? null, t.image ? (this.image = t.image, this.ready = He(t.image) ? Ue(t.image).then(() => this) : Promise.resolve(this), this.ready.catch(() => {})) : this.url ? (this.ready = this.#o(this.url), this.ready.catch(() => {})) : E("Texture", "needs an 'image' or a 'url'");
|
|
1053
1073
|
}
|
|
1054
1074
|
get image() {
|
|
1055
1075
|
return this.#e;
|
|
1056
1076
|
}
|
|
1057
1077
|
set image(e) {
|
|
1058
|
-
this.#e = e, this.needsUpdate(),
|
|
1078
|
+
this.#e = e, this.needsUpdate(), He(e) && this.#a(e);
|
|
1059
1079
|
}
|
|
1060
|
-
#
|
|
1080
|
+
#a(e) {
|
|
1061
1081
|
if (typeof e.requestVideoFrameCallback == "function") {
|
|
1062
1082
|
let t = () => {
|
|
1063
1083
|
this.#e === e && (this.needsUpdate(), e.requestVideoFrameCallback(t));
|
|
@@ -1083,19 +1103,49 @@ var Ie = [
|
|
|
1083
1103
|
get colorSpaceSet() {
|
|
1084
1104
|
return this.#n;
|
|
1085
1105
|
}
|
|
1086
|
-
needsUpdate() {
|
|
1087
|
-
|
|
1106
|
+
needsUpdate(e) {
|
|
1107
|
+
let t = null;
|
|
1108
|
+
if (e !== void 0) {
|
|
1109
|
+
let { x: n, y: r, width: i, height: a } = e ?? {};
|
|
1110
|
+
(![
|
|
1111
|
+
n,
|
|
1112
|
+
r,
|
|
1113
|
+
i,
|
|
1114
|
+
a
|
|
1115
|
+
].every((e) => typeof e == "number" && Number.isFinite(e)) || i < 0 || a < 0) && E("Texture", `needsUpdate() takes the region changed, { x, y, width, height } in the image's pixels, got ${j(e)}`);
|
|
1116
|
+
let o = Math.floor(n), s = Math.floor(r);
|
|
1117
|
+
t = {
|
|
1118
|
+
x: o,
|
|
1119
|
+
y: s,
|
|
1120
|
+
width: Math.ceil(n + i) - o,
|
|
1121
|
+
height: Math.ceil(r + a) - s
|
|
1122
|
+
};
|
|
1123
|
+
}
|
|
1124
|
+
return this.version++, this.#r.push({
|
|
1125
|
+
version: this.version,
|
|
1126
|
+
region: t
|
|
1127
|
+
}), this.#r.length > Be && this.#r.shift(), this;
|
|
1128
|
+
}
|
|
1129
|
+
changedSince(e) {
|
|
1130
|
+
let t = this.#r[0];
|
|
1131
|
+
if (!t || t.version > e + 1) return null;
|
|
1132
|
+
let n = [];
|
|
1133
|
+
for (let { version: t, region: r } of this.#r) if (!(t <= e)) {
|
|
1134
|
+
if (!r) return null;
|
|
1135
|
+
n.push(r);
|
|
1136
|
+
}
|
|
1137
|
+
return n.length ? n : null;
|
|
1088
1138
|
}
|
|
1089
1139
|
dispose() {
|
|
1090
|
-
for (let e of this.#
|
|
1140
|
+
for (let e of this.#i) e();
|
|
1091
1141
|
}
|
|
1092
1142
|
onDispose(e) {
|
|
1093
|
-
return this.#
|
|
1143
|
+
return this.#i.add(e), () => this.#i.delete(e);
|
|
1094
1144
|
}
|
|
1095
1145
|
toJSON() {
|
|
1096
1146
|
if (!this.url) return null;
|
|
1097
1147
|
let e = { url: this.url };
|
|
1098
|
-
for (let [t, n] of Object.entries(
|
|
1148
|
+
for (let [t, n] of Object.entries(Re)) {
|
|
1099
1149
|
let r = this[t];
|
|
1100
1150
|
JSON.stringify(r) !== JSON.stringify(n) && (e[t] = r);
|
|
1101
1151
|
}
|
|
@@ -1104,8 +1154,8 @@ var Ie = [
|
|
|
1104
1154
|
get isHDR() {
|
|
1105
1155
|
return !!this.image && "data" in this.image && this.image.data instanceof Float32Array;
|
|
1106
1156
|
}
|
|
1107
|
-
async #
|
|
1108
|
-
if (
|
|
1157
|
+
async #o(e) {
|
|
1158
|
+
if (Ve.test(e)) {
|
|
1109
1159
|
if (typeof document > "u") throw Error(`Texture: can't load '${e}' - no video support in this environment`);
|
|
1110
1160
|
let t = document.createElement("video");
|
|
1111
1161
|
Object.assign(t, {
|
|
@@ -1117,7 +1167,7 @@ var Ie = [
|
|
|
1117
1167
|
src: e
|
|
1118
1168
|
});
|
|
1119
1169
|
try {
|
|
1120
|
-
await
|
|
1170
|
+
await Ue(t);
|
|
1121
1171
|
} catch {
|
|
1122
1172
|
throw Error(`Texture: failed to load '${e}'`);
|
|
1123
1173
|
}
|
|
@@ -1138,26 +1188,26 @@ var Ie = [
|
|
|
1138
1188
|
}
|
|
1139
1189
|
return this.image = t, this;
|
|
1140
1190
|
}
|
|
1141
|
-
},
|
|
1142
|
-
function
|
|
1191
|
+
}, Ve = /\.(mp4|webm|ogv|mov|m4v)($|[?#])/i;
|
|
1192
|
+
function He(e) {
|
|
1143
1193
|
return typeof HTMLVideoElement < "u" && e instanceof HTMLVideoElement;
|
|
1144
1194
|
}
|
|
1145
|
-
function
|
|
1195
|
+
function Ue(e) {
|
|
1146
1196
|
return e.readyState >= 2 ? Promise.resolve() : new Promise((t, n) => {
|
|
1147
1197
|
e.addEventListener("loadeddata", () => t(), { once: !0 }), e.addEventListener("error", () => n(/* @__PURE__ */ Error("Texture: the video failed to load")), { once: !0 });
|
|
1148
1198
|
});
|
|
1149
1199
|
}
|
|
1150
|
-
function
|
|
1200
|
+
function We(e, t = {}) {
|
|
1151
1201
|
return new W({
|
|
1152
1202
|
...t,
|
|
1153
1203
|
url: e
|
|
1154
1204
|
}).ready;
|
|
1155
1205
|
}
|
|
1156
|
-
function
|
|
1206
|
+
function Ge(e, t) {
|
|
1157
1207
|
return (!Array.isArray(t) || t.length !== 2 || t.some((e) => typeof e != "number")) && E("Texture", `'${e}' must be [u, v], got ${j(t)}`), [t[0], t[1]];
|
|
1158
1208
|
}
|
|
1159
1209
|
// src/material/Material.js
|
|
1160
|
-
var
|
|
1210
|
+
var Ke = [
|
|
1161
1211
|
"map",
|
|
1162
1212
|
"roughnessMap",
|
|
1163
1213
|
"metalnessMap",
|
|
@@ -1167,13 +1217,13 @@ var We = [
|
|
|
1167
1217
|
"emissiveMap",
|
|
1168
1218
|
"lightMap",
|
|
1169
1219
|
"matcap"
|
|
1170
|
-
],
|
|
1220
|
+
], qe = /* @__PURE__ */ new Set([
|
|
1171
1221
|
"roughnessMap",
|
|
1172
1222
|
"metalnessMap",
|
|
1173
1223
|
"normalMap",
|
|
1174
1224
|
"bumpMap",
|
|
1175
1225
|
"aoMap"
|
|
1176
|
-
]),
|
|
1226
|
+
]), Je = [
|
|
1177
1227
|
"unlit",
|
|
1178
1228
|
"flatShading",
|
|
1179
1229
|
"doubleSided",
|
|
@@ -1183,7 +1233,7 @@ var We = [
|
|
|
1183
1233
|
"sizeAttenuation",
|
|
1184
1234
|
"transparent",
|
|
1185
1235
|
"fog"
|
|
1186
|
-
],
|
|
1236
|
+
], Ye = {
|
|
1187
1237
|
opacity: [0, 1],
|
|
1188
1238
|
roughness: [0, 1],
|
|
1189
1239
|
metalness: [0, 1],
|
|
@@ -1207,14 +1257,17 @@ var We = [
|
|
|
1207
1257
|
translucency: [0, 1],
|
|
1208
1258
|
toon: [0, 16],
|
|
1209
1259
|
lightMapIntensity: [0, Infinity],
|
|
1210
|
-
environmentIntensity: [0, Infinity]
|
|
1211
|
-
|
|
1260
|
+
environmentIntensity: [0, Infinity],
|
|
1261
|
+
dash: [0, Infinity],
|
|
1262
|
+
gap: [0, Infinity],
|
|
1263
|
+
dashOffset: [-Infinity, Infinity]
|
|
1264
|
+
}, Xe = {
|
|
1212
1265
|
color: 16777215,
|
|
1213
1266
|
emissive: 0,
|
|
1214
1267
|
sheenColor: 16777215,
|
|
1215
1268
|
specularColor: 16777215,
|
|
1216
1269
|
translucencyColor: 16777215
|
|
1217
|
-
},
|
|
1270
|
+
}, Ze = {
|
|
1218
1271
|
name: "",
|
|
1219
1272
|
opacity: 1,
|
|
1220
1273
|
alphaTest: 0,
|
|
@@ -1248,15 +1301,18 @@ var We = [
|
|
|
1248
1301
|
fog: !0,
|
|
1249
1302
|
size: 1,
|
|
1250
1303
|
sizeAttenuation: !0,
|
|
1251
|
-
width: 1
|
|
1252
|
-
|
|
1304
|
+
width: 1,
|
|
1305
|
+
dash: 0,
|
|
1306
|
+
gap: 0,
|
|
1307
|
+
dashOffset: 0
|
|
1308
|
+
}, Qe = [
|
|
1253
1309
|
"name",
|
|
1254
|
-
...Object.keys(
|
|
1255
|
-
...We,
|
|
1310
|
+
...Object.keys(Xe),
|
|
1256
1311
|
...Ke,
|
|
1257
|
-
...
|
|
1312
|
+
...Je,
|
|
1313
|
+
...Object.keys(Ye),
|
|
1258
1314
|
"blending"
|
|
1259
|
-
],
|
|
1315
|
+
], $e = {
|
|
1260
1316
|
type: "phoria2 has one material - drop 'type' and set 'unlit: true' for a flat colour",
|
|
1261
1317
|
side: "use 'doubleSided: true'",
|
|
1262
1318
|
wireframe: "use new Lines({ geometry: edges(geometry) }) for a wireframe",
|
|
@@ -1275,9 +1331,9 @@ var We = [
|
|
|
1275
1331
|
colour: "use 'color'",
|
|
1276
1332
|
emissiveColor: "use 'emissive'",
|
|
1277
1333
|
alpha: "use 'opacity'"
|
|
1278
|
-
},
|
|
1279
|
-
static OPTIONS =
|
|
1280
|
-
static HINTS =
|
|
1334
|
+
}, et = class e {
|
|
1335
|
+
static OPTIONS = Qe;
|
|
1336
|
+
static HINTS = $e;
|
|
1281
1337
|
name;
|
|
1282
1338
|
opacity;
|
|
1283
1339
|
alphaTest;
|
|
@@ -1312,13 +1368,16 @@ var We = [
|
|
|
1312
1368
|
size;
|
|
1313
1369
|
sizeAttenuation;
|
|
1314
1370
|
width;
|
|
1315
|
-
|
|
1371
|
+
dash;
|
|
1372
|
+
gap;
|
|
1373
|
+
dashOffset;
|
|
1374
|
+
#e = Object.fromEntries(Object.entries(Xe).map(([e, t]) => [e, new H(t)]));
|
|
1316
1375
|
#t = !1;
|
|
1317
|
-
#n = Object.fromEntries(
|
|
1376
|
+
#n = Object.fromEntries(Ke.map((e) => [e, null]));
|
|
1318
1377
|
#r = /* @__PURE__ */ new Set();
|
|
1319
1378
|
constructor(e = {}) {
|
|
1320
|
-
A("Material", e,
|
|
1321
|
-
for (let [t, n] of Object.entries(e)) n !== void 0 && (t in
|
|
1379
|
+
A("Material", e, Qe, $e), Object.assign(this, Ze);
|
|
1380
|
+
for (let [t, n] of Object.entries(e)) n !== void 0 && (t in Xe ? this.#e[t].set(n, "Material") : Ke.includes(t) ? this.setMap(t, n) : Je.includes(t) ? this[t] = tt(t, n) : t in Ye ? this[t] = nt(t, n, Ye[t]) : t === "blending" ? this.blending = P("Material", "blending", n, [
|
|
1322
1381
|
"normal",
|
|
1323
1382
|
"additive",
|
|
1324
1383
|
"multiply"
|
|
@@ -1417,12 +1476,12 @@ var We = [
|
|
|
1417
1476
|
return;
|
|
1418
1477
|
}
|
|
1419
1478
|
if (t instanceof W) {
|
|
1420
|
-
|
|
1479
|
+
qe.has(e) && t.colorSpace === "srgb" && (t.colorSpaceSet ? F(t, `'${e}' holds data, not colour, so its texture should be colorSpace: 'linear' - this one is 'srgb', and will be decoded as colour`) : (t.colorSpace = "linear", t.needsUpdate())), this.#n[e] = t;
|
|
1421
1480
|
return;
|
|
1422
1481
|
}
|
|
1423
1482
|
let n = typeof t == "string" ? { url: t } : t;
|
|
1424
1483
|
(typeof n != "object" || Array.isArray(n)) && E("Material", `'${e}' must be a Texture, a url or texture options, got ${j(t)}`), this.#n[e] = new W({
|
|
1425
|
-
colorSpace:
|
|
1484
|
+
colorSpace: qe.has(e) ? "linear" : "srgb",
|
|
1426
1485
|
...n
|
|
1427
1486
|
});
|
|
1428
1487
|
}
|
|
@@ -1456,9 +1515,9 @@ var We = [
|
|
|
1456
1515
|
}
|
|
1457
1516
|
toJSON(e = !1) {
|
|
1458
1517
|
let t = {};
|
|
1459
|
-
for (let [e, n] of Object.entries(
|
|
1518
|
+
for (let [e, n] of Object.entries(Ze)) this[e] !== n && (t[e] = this[e]);
|
|
1460
1519
|
this.#t && (t.transparent = !0);
|
|
1461
|
-
for (let [e, n] of Object.entries(this.#e)) n.getHex() !==
|
|
1520
|
+
for (let [e, n] of Object.entries(this.#e)) n.getHex() !== Xe[e] && (t[e] = n.getStyle());
|
|
1462
1521
|
for (let [n, r] of this.textures) {
|
|
1463
1522
|
let i = e ? r : r.toJSON();
|
|
1464
1523
|
i && (t[n] = i);
|
|
@@ -1466,16 +1525,16 @@ var We = [
|
|
|
1466
1525
|
return t;
|
|
1467
1526
|
}
|
|
1468
1527
|
};
|
|
1469
|
-
function
|
|
1528
|
+
function tt(e, t) {
|
|
1470
1529
|
return typeof t != "boolean" && E("Material", `'${e}' must be true or false, got ${j(t)}`), t;
|
|
1471
1530
|
}
|
|
1472
|
-
function
|
|
1531
|
+
function nt(e, t, [n, r]) {
|
|
1473
1532
|
M("Material", e, t);
|
|
1474
1533
|
let i = t;
|
|
1475
1534
|
return (i < n || i > r) && E("Material", `'${e}' must be ${r === Infinity ? `${n} or more` : `${n}-${r}`}, got ${i}`), i;
|
|
1476
1535
|
}
|
|
1477
1536
|
// src/resolve.js
|
|
1478
|
-
function
|
|
1537
|
+
function rt(e, t) {
|
|
1479
1538
|
if (e instanceof U) return e;
|
|
1480
1539
|
if ((!e || typeof e != "object" || Array.isArray(e)) && E(t, `'geometry' must be a Geometry such as box(2), got ${j(e)}`), "type" in e) {
|
|
1481
1540
|
let n = e.type;
|
|
@@ -1483,18 +1542,18 @@ function tt(e, t) {
|
|
|
1483
1542
|
}
|
|
1484
1543
|
return new U(e);
|
|
1485
1544
|
}
|
|
1486
|
-
function
|
|
1487
|
-
return e === void 0 ? new
|
|
1545
|
+
function it(e) {
|
|
1546
|
+
return e === void 0 ? new et() : et.fromInput(e);
|
|
1488
1547
|
}
|
|
1489
1548
|
// src/math/mat3.js
|
|
1490
|
-
function
|
|
1549
|
+
function at(e) {
|
|
1491
1550
|
return e.fill(0), e[0] = e[4] = e[8] = 1, e;
|
|
1492
1551
|
}
|
|
1493
|
-
function
|
|
1552
|
+
function ot(e, t) {
|
|
1494
1553
|
let n = t[0], r = t[1], i = t[2], a = t[3], o = t[4], s = t[5], c = t[6], l = t[7], u = t[8], d = t[9], f = t[10], p = t[11], m = t[12], h = t[13], g = t[14], _ = t[15], v = n * s - r * o, y = n * c - i * o, b = n * l - a * o, x = r * c - i * s, S = r * l - a * s, C = i * l - a * c, w = u * h - d * m, T = u * g - f * m, E = u * _ - p * m, D = d * g - f * h, O = d * _ - p * h, k = f * _ - p * g, A = v * k - y * O + b * D + x * E - S * T + C * w;
|
|
1495
1554
|
return A ? (A = 1 / A, e[0] = (s * k - c * O + l * D) * A, e[1] = (c * E - o * k - l * T) * A, e[2] = (o * O - s * E + l * w) * A, e[3] = (i * O - r * k - a * D) * A, e[4] = (n * k - i * E + a * T) * A, e[5] = (r * E - n * O - a * w) * A, e[6] = (h * C - g * S + _ * x) * A, e[7] = (g * b - m * C - _ * y) * A, e[8] = (m * S - h * b + _ * v) * A, e) : null;
|
|
1496
1555
|
}
|
|
1497
|
-
function
|
|
1556
|
+
function st(e, t) {
|
|
1498
1557
|
return e[0] = t[0], e[1] = t[1], e[2] = t[2], e[3] = t[4], e[4] = t[5], e[5] = t[6], e[6] = t[8], e[7] = t[9], e[8] = t[10], e;
|
|
1499
1558
|
}
|
|
1500
1559
|
// src/scene/Node.js
|
|
@@ -1519,7 +1578,7 @@ var G = [
|
|
|
1519
1578
|
"clip",
|
|
1520
1579
|
"onDrag",
|
|
1521
1580
|
"outline"
|
|
1522
|
-
],
|
|
1581
|
+
], ct = {
|
|
1523
1582
|
rotationX: "use rotation: [x, y, z] (radians)",
|
|
1524
1583
|
scaleX: "use scale: [x, y, z] or a single number",
|
|
1525
1584
|
translate: "use position: [x, y, z]",
|
|
@@ -1530,14 +1589,14 @@ var G = [
|
|
|
1530
1589
|
onDragStart: "use onDrag - drag.phase is 'start', 'move' or 'end'",
|
|
1531
1590
|
onDragEnd: "use onDrag - drag.phase is 'start', 'move' or 'end'",
|
|
1532
1591
|
selected: "outline what's selected: node.outline = '#ffcc00'"
|
|
1533
|
-
},
|
|
1592
|
+
}, lt = [], ut = new Float32Array([
|
|
1534
1593
|
0,
|
|
1535
1594
|
1,
|
|
1536
1595
|
0
|
|
1537
|
-
]),
|
|
1596
|
+
]), dt = /* @__PURE__ */ new Float32Array(16), ft = /* @__PURE__ */ new Float32Array(9), K = class e {
|
|
1538
1597
|
static type = "node";
|
|
1539
1598
|
static OPTIONS = G;
|
|
1540
|
-
static HINTS =
|
|
1599
|
+
static HINTS = ct;
|
|
1541
1600
|
name = "";
|
|
1542
1601
|
#e = new z();
|
|
1543
1602
|
#t = new z(1, 1, 1);
|
|
@@ -1590,7 +1649,7 @@ var G = [
|
|
|
1590
1649
|
constructor(e = {}) {
|
|
1591
1650
|
let t = new.target;
|
|
1592
1651
|
A(t.name, e, t.OPTIONS, {
|
|
1593
|
-
...
|
|
1652
|
+
...ct,
|
|
1594
1653
|
...t.HINTS
|
|
1595
1654
|
}), this.rotation.onChange = () => Me(this.quaternion, this.rotation.x, this.rotation.y, this.rotation.z), this.quaternion.onChange = () => this.rotation.setFromQuat(this.quaternion);
|
|
1596
1655
|
let n = t.name;
|
|
@@ -1655,7 +1714,7 @@ var G = [
|
|
|
1655
1714
|
}
|
|
1656
1715
|
add(e, ...t) {
|
|
1657
1716
|
e === void 0 && E(this.constructor.name, "add() needs a node to add - add(new Mesh({...})), or add(...nodes) for several");
|
|
1658
|
-
let n = [e, ...t].map((e) =>
|
|
1717
|
+
let n = [e, ...t].map((e) => ht(e));
|
|
1659
1718
|
for (let e of n) {
|
|
1660
1719
|
e === this && E(this.constructor.name, "can't add a node to itself");
|
|
1661
1720
|
for (let t = this.#c; t; t = t.#c) t === e && E(this.constructor.name, "can't add an ancestor as a child - that would make a loop");
|
|
@@ -1712,7 +1771,7 @@ var G = [
|
|
|
1712
1771
|
}
|
|
1713
1772
|
handlersFor(e) {
|
|
1714
1773
|
let t = e === "hover" ? this.onHover : this.onClick, n = this.#s?.[e];
|
|
1715
|
-
return n?.size ? t ? [t, ...n] : [...n] : t ? [t] :
|
|
1774
|
+
return n?.size ? t ? [t, ...n] : [...n] : t ? [t] : lt;
|
|
1716
1775
|
}
|
|
1717
1776
|
runHandlers(e, t) {
|
|
1718
1777
|
for (let n of this.#u) n(this, e, t);
|
|
@@ -1759,19 +1818,19 @@ var G = [
|
|
|
1759
1818
|
], e);
|
|
1760
1819
|
}
|
|
1761
1820
|
lookAt(t, n) {
|
|
1762
|
-
let r = t instanceof e ? t.updateWorld().worldPosition : z.fromInput(t, this.constructor.name), i = n === void 0 ?
|
|
1821
|
+
let r = t instanceof e ? t.updateWorld().worldPosition : z.fromInput(t, this.constructor.name), i = n === void 0 ? ut : z.fromInput(n, `${this.constructor.name}.lookAt() up`).normalize();
|
|
1763
1822
|
this.updateWorld();
|
|
1764
1823
|
let a = this.worldPosition;
|
|
1765
1824
|
if (a.equals(r, 1e-9)) return this;
|
|
1766
1825
|
let o = r.clone().sub(a).normalize();
|
|
1767
|
-
f(
|
|
1826
|
+
f(dt, a, r, Math.abs(o.dot(i)) > .9999 ? Math.abs(i[1]) > .9 ? [
|
|
1768
1827
|
0,
|
|
1769
1828
|
0,
|
|
1770
1829
|
-1
|
|
1771
|
-
] :
|
|
1772
|
-
let s = je(/* @__PURE__ */ new Float32Array(4),
|
|
1830
|
+
] : ut : i);
|
|
1831
|
+
let s = je(/* @__PURE__ */ new Float32Array(4), st(ft, dt));
|
|
1773
1832
|
if (this.#c) {
|
|
1774
|
-
let e = Oe(/* @__PURE__ */ new Float32Array(4), je(/* @__PURE__ */ new Float32Array(4),
|
|
1833
|
+
let e = Oe(/* @__PURE__ */ new Float32Array(4), je(/* @__PURE__ */ new Float32Array(4), gt(this.#c.worldMatrix)));
|
|
1775
1834
|
De(s, ke(e, e), s);
|
|
1776
1835
|
}
|
|
1777
1836
|
return this.quaternion.copy(Oe(s, s)), this;
|
|
@@ -1796,7 +1855,7 @@ var G = [
|
|
|
1796
1855
|
return this.worldMatrix.getPosition();
|
|
1797
1856
|
}
|
|
1798
1857
|
get worldQuaternion() {
|
|
1799
|
-
let e = je(/* @__PURE__ */ new Float32Array(4),
|
|
1858
|
+
let e = je(/* @__PURE__ */ new Float32Array(4), gt(this.worldMatrix));
|
|
1800
1859
|
return new Ne(e[0], e[1], e[2], e[3]).normalize();
|
|
1801
1860
|
}
|
|
1802
1861
|
get worldScale() {
|
|
@@ -1875,33 +1934,33 @@ var G = [
|
|
|
1875
1934
|
this.traverse((e) => e !== this && e.dispose());
|
|
1876
1935
|
}
|
|
1877
1936
|
};
|
|
1878
|
-
function
|
|
1937
|
+
function pt(e, t, n) {
|
|
1879
1938
|
return t == null ? null : e ? e.copy(t, n) : z.fromInput(t, n);
|
|
1880
1939
|
}
|
|
1881
|
-
function
|
|
1940
|
+
function mt(e, t) {
|
|
1882
1941
|
let n = t instanceof K ? t.updateWorld().worldPosition : z.fromInput(t, `${e.constructor.name}.lookAt()`), r = e.parent;
|
|
1883
1942
|
return r ? n.applyMatrix4(r.updateWorld().worldMatrix.clone().invert()) : n;
|
|
1884
1943
|
}
|
|
1885
|
-
function
|
|
1944
|
+
function ht(e) {
|
|
1886
1945
|
return e instanceof K ? e : e && typeof e == "object" && "type" in e ? E("Node", `add() takes nodes - build one from a description with add(create({ type: '${e.type}', ... }))`) : E("Node", `add() expects nodes, got ${j(e)}`);
|
|
1887
1946
|
}
|
|
1888
|
-
function
|
|
1889
|
-
let t =
|
|
1947
|
+
function gt(e) {
|
|
1948
|
+
let t = st(/* @__PURE__ */ new Float32Array(9), e);
|
|
1890
1949
|
for (let e = 0; e < 3; e++) {
|
|
1891
1950
|
let n = Math.hypot(t[e * 3], t[e * 3 + 1], t[e * 3 + 2]) || 1;
|
|
1892
1951
|
t[e * 3] /= n, t[e * 3 + 1] /= n, t[e * 3 + 2] /= n;
|
|
1893
1952
|
}
|
|
1894
1953
|
return t;
|
|
1895
1954
|
}
|
|
1896
|
-
var
|
|
1955
|
+
var _t = class extends K {
|
|
1897
1956
|
static type = "group";
|
|
1898
|
-
},
|
|
1957
|
+
}, vt = [
|
|
1899
1958
|
"center",
|
|
1900
1959
|
"above",
|
|
1901
1960
|
"below",
|
|
1902
1961
|
"left",
|
|
1903
1962
|
"right"
|
|
1904
|
-
],
|
|
1963
|
+
], yt = [
|
|
1905
1964
|
"place",
|
|
1906
1965
|
"offset",
|
|
1907
1966
|
"className",
|
|
@@ -1911,7 +1970,7 @@ var ht = class extends K {
|
|
|
1911
1970
|
"leader",
|
|
1912
1971
|
"edge",
|
|
1913
1972
|
"minScale"
|
|
1914
|
-
],
|
|
1973
|
+
], bt = {
|
|
1915
1974
|
line: "use leader: true - a line from the point to the label",
|
|
1916
1975
|
callout: "use leader: true, with edge: 'left' | 'right' to line the labels up down the side",
|
|
1917
1976
|
column: "use edge: 'left' | 'right' - the label sits at that edge of the view, level with its point",
|
|
@@ -1922,14 +1981,14 @@ var ht = class extends K {
|
|
|
1922
1981
|
minZoom: "use 'minScale': CSS pixels to one world unit at the label's point",
|
|
1923
1982
|
lod: "use 'minScale': the label shows when zoomed in at least this far (CSS pixels to one world unit)",
|
|
1924
1983
|
collision: "use overlap: 'hide' | 'dim' | 'show'"
|
|
1925
|
-
},
|
|
1926
|
-
...
|
|
1984
|
+
}, xt = {
|
|
1985
|
+
...bt,
|
|
1927
1986
|
position: "labels per instance sit on their instance - offset moves them in pixels"
|
|
1928
1987
|
};
|
|
1929
|
-
function
|
|
1988
|
+
function St(e, t) {
|
|
1930
1989
|
let n = t.offset ?? [0, 0];
|
|
1931
1990
|
return Array.isArray(n) && n.length === 2 && n.every(Number.isFinite) || E(e, `'offset' must be [x, y] in pixels, got ${j(n)}`), {
|
|
1932
|
-
place: t.place === void 0 ? "center" : P(e, "place", t.place,
|
|
1991
|
+
place: t.place === void 0 ? "center" : P(e, "place", t.place, vt),
|
|
1933
1992
|
offset: [n[0], n[1]],
|
|
1934
1993
|
className: t.className ? String(t.className) : "",
|
|
1935
1994
|
priority: t.priority === void 0 ? 0 : M(e, "priority", t.priority),
|
|
@@ -1941,20 +2000,20 @@ function bt(e, t) {
|
|
|
1941
2000
|
occlude: !!t.occlude,
|
|
1942
2001
|
leader: !!t.leader,
|
|
1943
2002
|
edge: t.edge == null ? null : P(e, "edge", t.edge, ["left", "right"]),
|
|
1944
|
-
minScale: t.minScale === void 0 ? 0 :
|
|
2003
|
+
minScale: t.minScale === void 0 ? 0 : Ct(e, t.minScale)
|
|
1945
2004
|
};
|
|
1946
2005
|
}
|
|
1947
|
-
function
|
|
2006
|
+
function Ct(e, t) {
|
|
1948
2007
|
let n = M(e, "minScale", t);
|
|
1949
2008
|
return n >= 0 || E(e, `'minScale' is CSS pixels to one world unit, 0 or more, got ${n}`), n;
|
|
1950
2009
|
}
|
|
1951
|
-
function
|
|
2010
|
+
function wt(e, t) {
|
|
1952
2011
|
if (t == null) return null;
|
|
1953
|
-
if (Array.isArray(t)) return t.length || E(e, "'labels' as a list needs at least one { text: (datum, index) => string, ... }"), t.map((t) =>
|
|
2012
|
+
if (Array.isArray(t)) return t.length || E(e, "'labels' as a list needs at least one { text: (datum, index) => string, ... }"), t.map((t) => wt(e, t));
|
|
1954
2013
|
(typeof t != "object" || typeof t.text != "function") && E(e, `'labels' must be { text: (datum, index) => string, ... }, got ${j(t)}`);
|
|
1955
2014
|
let n = t;
|
|
1956
|
-
for (let t of Object.keys(n)) t !== "text" && t !== "at" && !
|
|
1957
|
-
let r = n.at === void 0 ? "top" : P(e, "labels.at", n.at, ["top", "center"]), i = typeof n.priority == "function", a =
|
|
2015
|
+
for (let t of Object.keys(n)) t !== "text" && t !== "at" && !yt.includes(t) && E(e, `unknown labels option '${t}'${xt[t] ? ` - ${xt[t]}` : ` - expected text, at, ${yt.join(", ")}`}`);
|
|
2016
|
+
let r = n.at === void 0 ? "top" : P(e, "labels.at", n.at, ["top", "center"]), i = typeof n.priority == "function", a = St(e, i ? {
|
|
1958
2017
|
...n,
|
|
1959
2018
|
priority: 0
|
|
1960
2019
|
} : n);
|
|
@@ -1965,7 +2024,7 @@ function St(e, t) {
|
|
|
1965
2024
|
priority: i ? n.priority : a.priority
|
|
1966
2025
|
};
|
|
1967
2026
|
}
|
|
1968
|
-
var
|
|
2027
|
+
var Tt = [
|
|
1969
2028
|
...G,
|
|
1970
2029
|
"geometry",
|
|
1971
2030
|
"material",
|
|
@@ -1974,13 +2033,13 @@ var Ct = [
|
|
|
1974
2033
|
"renderOrder",
|
|
1975
2034
|
"frustumCulled",
|
|
1976
2035
|
"data"
|
|
1977
|
-
],
|
|
2036
|
+
], Et = {
|
|
1978
2037
|
mesh: "pass 'geometry' and 'material' directly",
|
|
1979
2038
|
materials: "one 'material' per node - use a Group of meshes for several",
|
|
1980
2039
|
rows: "use 'data' - one row per instance or point"
|
|
1981
|
-
},
|
|
1982
|
-
static OPTIONS =
|
|
1983
|
-
static HINTS =
|
|
2040
|
+
}, Dt = class extends K {
|
|
2041
|
+
static OPTIONS = Tt;
|
|
2042
|
+
static HINTS = Et;
|
|
1984
2043
|
#e;
|
|
1985
2044
|
#t;
|
|
1986
2045
|
castShadow = !1;
|
|
@@ -1991,19 +2050,19 @@ var Ct = [
|
|
|
1991
2050
|
constructor(e) {
|
|
1992
2051
|
super(e);
|
|
1993
2052
|
let t = this.constructor.name;
|
|
1994
|
-
e && e.geometry !== void 0 || E(t, `'geometry' is required, e.g. new ${t}({ geometry: box(1), material: { color: 'orange' } })`), this.#e =
|
|
2053
|
+
e && e.geometry !== void 0 || E(t, `'geometry' is required, e.g. new ${t}({ geometry: box(1), material: { color: 'orange' } })`), this.#e = rt(e.geometry, t), this.#t = it(e.material), e.castShadow !== void 0 && (this.castShadow = !!e.castShadow), e.receiveShadow !== void 0 && (this.receiveShadow = !!e.receiveShadow), e.renderOrder !== void 0 && (this.renderOrder = M(t, "renderOrder", e.renderOrder)), e.frustumCulled !== void 0 && (this.frustumCulled = !!e.frustumCulled), e.data !== void 0 && (this.data = e.data), this.checkGeometry();
|
|
1995
2054
|
}
|
|
1996
2055
|
get geometry() {
|
|
1997
2056
|
return this.#e;
|
|
1998
2057
|
}
|
|
1999
2058
|
set geometry(e) {
|
|
2000
|
-
this.#e =
|
|
2059
|
+
this.#e = rt(e, this.constructor.name), this.checkGeometry();
|
|
2001
2060
|
}
|
|
2002
2061
|
get material() {
|
|
2003
2062
|
return this.#t;
|
|
2004
2063
|
}
|
|
2005
2064
|
set material(e) {
|
|
2006
|
-
this.#t =
|
|
2065
|
+
this.#t = it(e);
|
|
2007
2066
|
}
|
|
2008
2067
|
datumAt(e) {
|
|
2009
2068
|
return ("instanceMatrices" in this || this.drawMode !== "triangles") && Array.isArray(this.data) ? e === null ? null : this.data[e] ?? null : this.data ?? null;
|
|
@@ -2042,33 +2101,33 @@ var Ct = [
|
|
|
2042
2101
|
for (let [, e] of this.material.textures) e.dispose();
|
|
2043
2102
|
super.dispose();
|
|
2044
2103
|
}
|
|
2045
|
-
},
|
|
2104
|
+
}, Ot = class extends Dt {
|
|
2046
2105
|
static type = "mesh";
|
|
2047
2106
|
checkGeometry() {
|
|
2048
2107
|
let e = this.geometry.elementCount;
|
|
2049
2108
|
e % 3 != 0 && E("Mesh", `geometry has ${e} ${this.geometry.indices ? "indices" : "vertices"}, not a multiple of 3 - triangles need three each (use Lines for pairs, Points for single vertices)`);
|
|
2050
2109
|
}
|
|
2051
|
-
},
|
|
2110
|
+
}, kt = /* @__PURE__ */ new Set([
|
|
2052
2111
|
"position",
|
|
2053
2112
|
"rotation",
|
|
2054
2113
|
"quaternion",
|
|
2055
2114
|
"scale",
|
|
2056
2115
|
"color"
|
|
2057
|
-
]),
|
|
2116
|
+
]), At = {
|
|
2058
2117
|
position: new z(),
|
|
2059
2118
|
scale: new z(),
|
|
2060
2119
|
quaternion: new Ne(),
|
|
2061
2120
|
rotation: new Te()
|
|
2062
|
-
},
|
|
2063
|
-
function
|
|
2121
|
+
}, jt = new H(), Mt = /* @__PURE__ */ new Float32Array(16);
|
|
2122
|
+
function Nt(e, t) {
|
|
2064
2123
|
let n = t * 16;
|
|
2065
2124
|
return !e[n] && !e[n + 1] && !e[n + 2] && !e[n + 4] && !e[n + 5] && !e[n + 6] && !e[n + 8] && !e[n + 9] && !e[n + 10];
|
|
2066
2125
|
}
|
|
2067
|
-
var
|
|
2126
|
+
var Pt = class extends Ot {
|
|
2068
2127
|
static type = "instanced-mesh";
|
|
2069
2128
|
static get OPTIONS() {
|
|
2070
2129
|
return [
|
|
2071
|
-
...
|
|
2130
|
+
...Tt,
|
|
2072
2131
|
"count",
|
|
2073
2132
|
"instances",
|
|
2074
2133
|
"instanceMatrices",
|
|
@@ -2082,7 +2141,7 @@ var Mt = class extends Et {
|
|
|
2082
2141
|
version = 0;
|
|
2083
2142
|
labels = null;
|
|
2084
2143
|
constructor(e) {
|
|
2085
|
-
super(e), this.labels =
|
|
2144
|
+
super(e), this.labels = wt("InstancedMesh", e.labels);
|
|
2086
2145
|
let t = e.count ?? e.instances?.length ?? (Array.isArray(e.data) ? e.data.length : void 0);
|
|
2087
2146
|
(!Number.isInteger(t) || t < 0) && E("InstancedMesh", `'count' must be a whole number, got ${j(t)}`), this.count = t, this.instanceMatrices = new Float32Array(t * 16);
|
|
2088
2147
|
let n = this.instanceMatrices;
|
|
@@ -2091,11 +2150,11 @@ var Mt = class extends Et {
|
|
|
2091
2150
|
}
|
|
2092
2151
|
setInstance(e, t) {
|
|
2093
2152
|
this.#e(e);
|
|
2094
|
-
for (let e in t)
|
|
2095
|
-
let { position: n, scale: r, quaternion: i } =
|
|
2153
|
+
for (let e in t) kt.has(e) || E("InstancedMesh", `unknown instance option '${e}' - expected position, rotation, quaternion, scale or color`);
|
|
2154
|
+
let { position: n, scale: r, quaternion: i } = At;
|
|
2096
2155
|
if (t.position === void 0 ? n.set(0, 0, 0) : n.copy(t.position, "InstancedMesh"), t.scale === void 0 ? r.set(1, 1, 1) : typeof t.scale == "number" ? r.set(t.scale, t.scale, t.scale) : r.copy(t.scale, "InstancedMesh"), i.set(0, 0, 0, 1), t.quaternion) i.copy(t.quaternion, "InstancedMesh").normalize();
|
|
2097
2156
|
else if (t.rotation) {
|
|
2098
|
-
let e = t.rotation instanceof Te ? t.rotation :
|
|
2157
|
+
let e = t.rotation instanceof Te ? t.rotation : At.rotation.copy(t.rotation, "InstancedMesh");
|
|
2099
2158
|
i.setFromEuler(e.x, e.y, e.z);
|
|
2100
2159
|
}
|
|
2101
2160
|
return u(this.instanceMatrices.subarray(e * 16, e * 16 + 16), i, n, r), t.color !== void 0 && this.#t(e, t.color), this.version++, this;
|
|
@@ -2110,7 +2169,7 @@ var Mt = class extends Et {
|
|
|
2110
2169
|
(!Number.isInteger(e) || e < 0 || e >= this.instanceMatrices.length / 16) && E("InstancedMesh", `instance ${j(e)} is out of range 0-${this.instanceMatrices.length / 16 - 1}`);
|
|
2111
2170
|
}
|
|
2112
2171
|
#t(e, t) {
|
|
2113
|
-
this.instanceColors ||= new Float32Array(this.instanceMatrices.length / 16 * 3).fill(1), this.instanceColors.set(
|
|
2172
|
+
this.instanceColors ||= new Float32Array(this.instanceMatrices.length / 16 * 3).fill(1), this.instanceColors.set(jt.set(t, "InstancedMesh"), e * 3);
|
|
2114
2173
|
}
|
|
2115
2174
|
expandBounds(e) {
|
|
2116
2175
|
return this.eachInstanceBox((t, n, r, i, a, o) => {
|
|
@@ -2119,9 +2178,9 @@ var Mt = class extends Et {
|
|
|
2119
2178
|
}
|
|
2120
2179
|
eachInstanceBox(e) {
|
|
2121
2180
|
if (!this.count || !this.geometry.vertexCount) return;
|
|
2122
|
-
let t = this.geometry.bounds, n = (t.min[0] + t.max[0]) / 2, r = (t.min[1] + t.max[1]) / 2, i = (t.min[2] + t.max[2]) / 2, a = (t.max[0] - t.min[0]) / 2, o = (t.max[1] - t.min[1]) / 2, c = (t.max[2] - t.min[2]) / 2, l = this.worldMatrix, u = this.instanceMatrices, d =
|
|
2181
|
+
let t = this.geometry.bounds, n = (t.min[0] + t.max[0]) / 2, r = (t.min[1] + t.max[1]) / 2, i = (t.min[2] + t.max[2]) / 2, a = (t.max[0] - t.min[0]) / 2, o = (t.max[1] - t.min[1]) / 2, c = (t.max[2] - t.min[2]) / 2, l = this.worldMatrix, u = this.instanceMatrices, d = Mt;
|
|
2123
2182
|
for (let t = 0; t < this.count; t++) {
|
|
2124
|
-
if (
|
|
2183
|
+
if (Nt(u, t)) continue;
|
|
2125
2184
|
s(d, l, u.subarray(t * 16, t * 16 + 16));
|
|
2126
2185
|
let f = d[0] * n + d[4] * r + d[8] * i + d[12], p = d[1] * n + d[5] * r + d[9] * i + d[13], m = d[2] * n + d[6] * r + d[10] * i + d[14], h = Math.abs(d[0]) * a + Math.abs(d[4]) * o + Math.abs(d[8]) * c, g = Math.abs(d[1]) * a + Math.abs(d[5]) * o + Math.abs(d[9]) * c, _ = Math.abs(d[2]) * a + Math.abs(d[6]) * o + Math.abs(d[10]) * c;
|
|
2127
2186
|
e(f - h, p - g, m - _, f + h, p + g, m + _);
|
|
@@ -2146,26 +2205,79 @@ var Mt = class extends Et {
|
|
|
2146
2205
|
...this.instanceColors ? { instanceColors: Array.from(this.instanceColors) } : {}
|
|
2147
2206
|
};
|
|
2148
2207
|
}
|
|
2149
|
-
},
|
|
2208
|
+
}, Ft = class extends Dt {
|
|
2150
2209
|
static type = "points";
|
|
2151
2210
|
static get OPTIONS() {
|
|
2152
|
-
return [
|
|
2211
|
+
return [
|
|
2212
|
+
...Tt,
|
|
2213
|
+
"labels",
|
|
2214
|
+
"sort"
|
|
2215
|
+
];
|
|
2153
2216
|
}
|
|
2154
2217
|
labels = null;
|
|
2218
|
+
sort = !1;
|
|
2155
2219
|
constructor(e) {
|
|
2156
|
-
super(e), this.labels =
|
|
2220
|
+
super(e), this.labels = wt(this.constructor.name, e?.labels), e?.sort !== void 0 && (typeof e.sort != "boolean" && E(this.constructor.name, `'sort' is true or false, got ${j(e.sort)}`), this.sort = e.sort);
|
|
2221
|
+
}
|
|
2222
|
+
get drawsSprites() {
|
|
2223
|
+
let e = this.geometry;
|
|
2224
|
+
return this.sort || !!(e.sizes || e.opacities || e.angles);
|
|
2157
2225
|
}
|
|
2158
2226
|
cloneOptions() {
|
|
2159
2227
|
return {
|
|
2160
2228
|
...super.cloneOptions(),
|
|
2161
|
-
labels: this.labels
|
|
2229
|
+
labels: this.labels,
|
|
2230
|
+
sort: this.sort
|
|
2231
|
+
};
|
|
2232
|
+
}
|
|
2233
|
+
jsonOptions() {
|
|
2234
|
+
return {
|
|
2235
|
+
...super.jsonOptions(),
|
|
2236
|
+
...this.sort ? { sort: !0 } : {}
|
|
2162
2237
|
};
|
|
2163
2238
|
}
|
|
2164
2239
|
get drawMode() {
|
|
2165
2240
|
return "points";
|
|
2166
2241
|
}
|
|
2167
|
-
},
|
|
2242
|
+
}, It = [
|
|
2243
|
+
"none",
|
|
2244
|
+
"start",
|
|
2245
|
+
"end",
|
|
2246
|
+
"both"
|
|
2247
|
+
], Lt = class extends Dt {
|
|
2168
2248
|
static type = "lines";
|
|
2249
|
+
static get OPTIONS() {
|
|
2250
|
+
return [
|
|
2251
|
+
...Tt,
|
|
2252
|
+
"arrows",
|
|
2253
|
+
"arrowSize"
|
|
2254
|
+
];
|
|
2255
|
+
}
|
|
2256
|
+
arrows = "none";
|
|
2257
|
+
arrowSize = 0;
|
|
2258
|
+
constructor(e) {
|
|
2259
|
+
super(e), e?.arrows !== void 0 && (this.arrows = P("Lines", "arrows", e.arrows, It)), e?.arrowSize !== void 0 && (this.arrowSize = Math.max(0, M("Lines", "arrowSize", e.arrowSize)));
|
|
2260
|
+
}
|
|
2261
|
+
get arrowBits() {
|
|
2262
|
+
return It.indexOf(this.arrows);
|
|
2263
|
+
}
|
|
2264
|
+
arrowPixels(e) {
|
|
2265
|
+
return this.arrowSize || 6 + e * 3;
|
|
2266
|
+
}
|
|
2267
|
+
cloneOptions() {
|
|
2268
|
+
return {
|
|
2269
|
+
...super.cloneOptions(),
|
|
2270
|
+
arrows: this.arrows,
|
|
2271
|
+
arrowSize: this.arrowSize
|
|
2272
|
+
};
|
|
2273
|
+
}
|
|
2274
|
+
jsonOptions() {
|
|
2275
|
+
return {
|
|
2276
|
+
...super.jsonOptions(),
|
|
2277
|
+
...this.arrows === "none" ? {} : { arrows: this.arrows },
|
|
2278
|
+
...this.arrowSize ? { arrowSize: this.arrowSize } : {}
|
|
2279
|
+
};
|
|
2280
|
+
}
|
|
2169
2281
|
get drawMode() {
|
|
2170
2282
|
return "lines";
|
|
2171
2283
|
}
|
|
@@ -2173,17 +2285,17 @@ var Mt = class extends Et {
|
|
|
2173
2285
|
let e = this.geometry.elementCount;
|
|
2174
2286
|
e % 2 != 0 && E("Lines", `geometry has ${e} ${this.geometry.indices ? "indices" : "vertices"} - segments need them in pairs`);
|
|
2175
2287
|
}
|
|
2176
|
-
},
|
|
2288
|
+
}, Rt = class extends K {
|
|
2177
2289
|
static type = "label";
|
|
2178
2290
|
static get OPTIONS() {
|
|
2179
2291
|
return [
|
|
2180
2292
|
...G,
|
|
2181
2293
|
"text",
|
|
2182
|
-
...
|
|
2294
|
+
...yt
|
|
2183
2295
|
];
|
|
2184
2296
|
}
|
|
2185
2297
|
static get HINTS() {
|
|
2186
|
-
return
|
|
2298
|
+
return bt;
|
|
2187
2299
|
}
|
|
2188
2300
|
text = "";
|
|
2189
2301
|
className = "";
|
|
@@ -2196,7 +2308,7 @@ var Mt = class extends Et {
|
|
|
2196
2308
|
edge = null;
|
|
2197
2309
|
minScale = 0;
|
|
2198
2310
|
constructor(e) {
|
|
2199
|
-
super(e), typeof e?.text != "string" && typeof e?.text != "number" && E("Label", `'text' is required, got ${j(e?.text)}`), this.text = String(e.text), Object.assign(this,
|
|
2311
|
+
super(e), typeof e?.text != "string" && typeof e?.text != "number" && E("Label", `'text' is required, got ${j(e?.text)}`), this.text = String(e.text), Object.assign(this, St("Label", e));
|
|
2200
2312
|
}
|
|
2201
2313
|
get isLabel() {
|
|
2202
2314
|
return !0;
|
|
@@ -2223,13 +2335,13 @@ var Mt = class extends Et {
|
|
|
2223
2335
|
let e = { text: this.text };
|
|
2224
2336
|
return this.className && (e.className = this.className), this.place !== "center" && (e.place = this.place), (this.offset[0] || this.offset[1]) && (e.offset = [...this.offset]), this.priority && (e.priority = this.priority), this.overlap !== "hide" && (e.overlap = this.overlap), this.occlude && (e.occlude = !0), this.leader && (e.leader = !0), this.edge && (e.edge = this.edge), this.minScale && (e.minScale = this.minScale), e;
|
|
2225
2337
|
}
|
|
2226
|
-
},
|
|
2338
|
+
}, zt = {
|
|
2227
2339
|
punctual: 4,
|
|
2228
2340
|
directional: 2
|
|
2229
2341
|
};
|
|
2230
|
-
function
|
|
2342
|
+
function Bt(e, t) {
|
|
2231
2343
|
t.updateWorld();
|
|
2232
|
-
let n = t.viewMatrix, r = t.projectionMatrix, i = new B().multiplyMatrices(r, n), a =
|
|
2344
|
+
let n = t.viewMatrix, r = t.projectionMatrix, i = new B().multiplyMatrices(r, n), a = Yt(i), o = {
|
|
2233
2345
|
camera: {
|
|
2234
2346
|
view: n,
|
|
2235
2347
|
projection: r,
|
|
@@ -2273,14 +2385,14 @@ function Lt(e, t) {
|
|
|
2273
2385
|
items: []
|
|
2274
2386
|
}, o.outlines.push(c)), e.overlay && o.overlays.push(e.overlay), e.onDrag && (o.interactive = o.draggable = !0), e.tooltip ? o.interactive = o.tooltips = !0 : (e.highlight || e.handlersFor("hover").length || e.handlersFor("click").length) && (o.interactive = !0), e.isDrawable) {
|
|
2275
2387
|
e.castShadow && e.drawMode !== "points" && e.drawMode !== "lines" && l.push([e, s]), e.receiveShadow && u.push(e);
|
|
2276
|
-
let t =
|
|
2388
|
+
let t = Vt(e, n, a, s);
|
|
2277
2389
|
if (t) {
|
|
2278
2390
|
let a = e.material.transparent || e.drawMode === "points" && e.material.map;
|
|
2279
2391
|
if ((a ? o.transparent : o.opaque).push(t), c && e.drawMode === "triangles" && c.items.push(t), t.clip?.cap && !a) {
|
|
2280
2392
|
let e = d.get(t.clip);
|
|
2281
2393
|
e ? e.push(t) : d.set(t.clip, [t]);
|
|
2282
2394
|
}
|
|
2283
|
-
o.stats.drawn++, e.labels &&
|
|
2395
|
+
o.stats.drawn++, e.labels && Gt(e, i, n, r[5], o.labels);
|
|
2284
2396
|
} else o.stats.culled++;
|
|
2285
2397
|
} else if (e.isLabel) {
|
|
2286
2398
|
let t = e.worldPosition;
|
|
@@ -2291,7 +2403,7 @@ function Lt(e, t) {
|
|
|
2291
2403
|
text: e.text,
|
|
2292
2404
|
style: e,
|
|
2293
2405
|
position: t,
|
|
2294
|
-
...
|
|
2406
|
+
...Jt(t, i, n, r[5])
|
|
2295
2407
|
});
|
|
2296
2408
|
} else e.lightKind && p(e);
|
|
2297
2409
|
for (let t of e.children) f(t, s, c);
|
|
@@ -2309,14 +2421,14 @@ function Lt(e, t) {
|
|
|
2309
2421
|
color: t.sky,
|
|
2310
2422
|
ground: t.ground,
|
|
2311
2423
|
intensity: t.intensity
|
|
2312
|
-
}) : n === "directional" ? ++c >
|
|
2424
|
+
}) : n === "directional" ? ++c > zt.directional ? F(e, `more than ${zt.directional} directional lights - the extras are ignored; use scene.environment for more light`) : o.lights.push({
|
|
2313
2425
|
kind: "directional",
|
|
2314
2426
|
node: t,
|
|
2315
2427
|
color: t.color,
|
|
2316
2428
|
intensity: t.intensity,
|
|
2317
2429
|
direction: t.worldDirection,
|
|
2318
2430
|
castShadow: t.castShadow
|
|
2319
|
-
}) : ++s >
|
|
2431
|
+
}) : ++s > zt.punctual ? F(e, `more than ${zt.punctual} point and spot lights - the extras are ignored`) : n === "spot" ? o.lights.push({
|
|
2320
2432
|
kind: "spot",
|
|
2321
2433
|
node: t,
|
|
2322
2434
|
color: t.color,
|
|
@@ -2339,17 +2451,17 @@ function Lt(e, t) {
|
|
|
2339
2451
|
});
|
|
2340
2452
|
};
|
|
2341
2453
|
f(e, null, null), o.outlines = o.outlines.filter((e) => e.items.length);
|
|
2342
|
-
for (let [e, t] of d) o.caps.push(
|
|
2343
|
-
let m = o.lights.findIndex((e) => e.kind === "directional" && e.castShadow), h = o.lights.filter((e) => e.kind === "spot" && e.castShadow), g = o.lights.filter((e) => e.kind === "point" && e.castShadow), _ = m >= 0 || h.length || g.length ? l.map(([e, t]) =>
|
|
2454
|
+
for (let [e, t] of d) o.caps.push(Ht(e, t));
|
|
2455
|
+
let m = o.lights.findIndex((e) => e.kind === "directional" && e.castShadow), h = o.lights.filter((e) => e.kind === "spot" && e.castShadow), g = o.lights.filter((e) => e.kind === "point" && e.castShadow), _ = m >= 0 || h.length || g.length ? l.map(([e, t]) => Vt(e, n, null, t)).filter(Boolean) : [];
|
|
2344
2456
|
if (h.length > 4 && F(e, "more than 4 spot lights cast shadows - the extras don't"), g.length > 1 && F(e, "more than one point light casts shadows - only the first does"), _.length && g.length) {
|
|
2345
2457
|
let e = g[0], t = _.map((e) => e.node.expandBounds(new V())), n = le(e.position, e.range ?? 0, t, u.map((e) => e.expandBounds(new V())));
|
|
2346
2458
|
n && (o.pointShadow = {
|
|
2347
2459
|
light: e,
|
|
2348
2460
|
faces: n.viewProjections.map((e) => {
|
|
2349
|
-
let n =
|
|
2461
|
+
let n = Yt(e);
|
|
2350
2462
|
return {
|
|
2351
2463
|
viewProjection: e,
|
|
2352
|
-
casters: _.filter((e, r) =>
|
|
2464
|
+
casters: _.filter((e, r) => Xt(n, t[r].getCenter(), t[r].getRadius()))
|
|
2353
2465
|
};
|
|
2354
2466
|
}),
|
|
2355
2467
|
near: n.near,
|
|
@@ -2362,10 +2474,10 @@ function Lt(e, t) {
|
|
|
2362
2474
|
for (let n of h.slice(0, 4)) {
|
|
2363
2475
|
let r = n.position, i = e.map((e) => e.containsPoint(r)), a = oe(r, n.direction, n.angle, n.range ?? 0, e.filter((e, t) => !i[t]), t);
|
|
2364
2476
|
if (!a) continue;
|
|
2365
|
-
let s =
|
|
2477
|
+
let s = Yt(a.viewProjection), c = _.filter((t, n) => {
|
|
2366
2478
|
if (i[n]) return !1;
|
|
2367
2479
|
let r = e[n];
|
|
2368
|
-
return
|
|
2480
|
+
return Xt(s, r.getCenter(), r.getRadius());
|
|
2369
2481
|
});
|
|
2370
2482
|
n.shadowTile = o.spotShadows.length, o.spotShadows.push({
|
|
2371
2483
|
light: n,
|
|
@@ -2386,11 +2498,11 @@ function Lt(e, t) {
|
|
|
2386
2498
|
}
|
|
2387
2499
|
return o.opaque.sort((e, t) => e.node.renderOrder - t.node.renderOrder || (e.material.variant < t.material.variant ? -1 : +(e.material.variant > t.material.variant)) || e.depth - t.depth), o.transparent.sort((e, t) => e.node.renderOrder - t.node.renderOrder || t.depth - e.depth), o;
|
|
2388
2500
|
}
|
|
2389
|
-
function
|
|
2501
|
+
function Vt(e, t, n, r) {
|
|
2390
2502
|
let { geometry: i, material: a, worldMatrix: o } = e, s = "instanceMatrices" in e ? e : null;
|
|
2391
2503
|
if (s && s.count === 0 || !i.vertexCount) return null;
|
|
2392
2504
|
let c = i.bounds, l = c.getCenter().applyMatrix4(o), u = Math.max(Math.hypot(o[0], o[1], o[2]), Math.hypot(o[4], o[5], o[6]), Math.hypot(o[8], o[9], o[10]));
|
|
2393
|
-
if (n && e.frustumCulled && !s && !
|
|
2505
|
+
if (n && e.frustumCulled && !s && !Xt(n, l, c.getRadius() * u)) return null;
|
|
2394
2506
|
let d = r && e.drawMode === "triangles" ? r : null;
|
|
2395
2507
|
if (d && !s) {
|
|
2396
2508
|
let e = d.plane;
|
|
@@ -2406,7 +2518,7 @@ function Rt(e, t, n, r) {
|
|
|
2406
2518
|
clip: d
|
|
2407
2519
|
};
|
|
2408
2520
|
}
|
|
2409
|
-
function
|
|
2521
|
+
function Ht(e, t) {
|
|
2410
2522
|
let n = new V();
|
|
2411
2523
|
for (let e of t) e.node.expandBounds(n);
|
|
2412
2524
|
let r = n.getCenter(), i = e.plane, a = i[0] * r[0] + i[1] * r[1] + i[2] * r[2] + i[3], o = new z(r[0] - i[0] * a, r[1] - i[1] * a, r[2] - i[2] * a);
|
|
@@ -2418,13 +2530,13 @@ function zt(e, t) {
|
|
|
2418
2530
|
radius: n.getRadius()
|
|
2419
2531
|
};
|
|
2420
2532
|
}
|
|
2421
|
-
var
|
|
2422
|
-
function
|
|
2423
|
-
Array.isArray(e.labels) ? e.labels.forEach((a, o) =>
|
|
2533
|
+
var Ut = /* @__PURE__ */ new WeakMap(), Wt = 1;
|
|
2534
|
+
function Gt(e, t, n, r, i) {
|
|
2535
|
+
Array.isArray(e.labels) ? e.labels.forEach((a, o) => Kt(e, a, o, t, n, r, i)) : Kt(e, e.labels, 0, t, n, r, i);
|
|
2424
2536
|
}
|
|
2425
|
-
function
|
|
2426
|
-
let { worldMatrix: s } = e, c =
|
|
2427
|
-
c === void 0 &&
|
|
2537
|
+
function Kt(e, t, n, r, i, a, o) {
|
|
2538
|
+
let { worldMatrix: s } = e, c = Ut.get(e);
|
|
2539
|
+
c === void 0 && Ut.set(e, c = Wt++);
|
|
2428
2540
|
let l = "instanceMatrices" in e, u = l ? e.count : e.geometry.drawnVertices, d = 0, f = 0, p = 0;
|
|
2429
2541
|
if (l) {
|
|
2430
2542
|
let n = e.geometry.bounds, r = n.getCenter();
|
|
@@ -2432,7 +2544,7 @@ function Ut(e, t, n, r, i, a, o) {
|
|
|
2432
2544
|
}
|
|
2433
2545
|
let m = Array.isArray(e.data) ? e.data : null, h = typeof t.priority == "function";
|
|
2434
2546
|
for (let g = 0; g < u; g++) {
|
|
2435
|
-
if (l &&
|
|
2547
|
+
if (l && Nt(e.instanceMatrices, g)) continue;
|
|
2436
2548
|
let u = m ? m[g] : null, _ = t.text(u, g);
|
|
2437
2549
|
if (_ == null || _ === "") continue;
|
|
2438
2550
|
let v, y, b;
|
|
@@ -2454,11 +2566,11 @@ function Ut(e, t, n, r, i, a, o) {
|
|
|
2454
2566
|
text: String(_),
|
|
2455
2567
|
style: S,
|
|
2456
2568
|
position: x,
|
|
2457
|
-
...
|
|
2569
|
+
...Jt(x, r, i, a)
|
|
2458
2570
|
});
|
|
2459
2571
|
}
|
|
2460
2572
|
}
|
|
2461
|
-
function
|
|
2573
|
+
function qt(e, t) {
|
|
2462
2574
|
let n = t, r = n[0] * e[0] + n[4] * e[1] + n[8] * e[2] + n[12], i = n[1] * e[0] + n[5] * e[1] + n[9] * e[2] + n[13], a = n[2] * e[0] + n[6] * e[1] + n[10] * e[2] + n[14], o = n[3] * e[0] + n[7] * e[1] + n[11] * e[2] + n[15], s = [
|
|
2463
2575
|
r / o,
|
|
2464
2576
|
i / o,
|
|
@@ -2469,8 +2581,8 @@ function Wt(e, t) {
|
|
|
2469
2581
|
visible: o > 0 && Math.abs(s[0]) <= 1 && Math.abs(s[1]) <= 1 && Math.abs(s[2]) <= 1
|
|
2470
2582
|
};
|
|
2471
2583
|
}
|
|
2472
|
-
function
|
|
2473
|
-
let { ndc: i, visible: a } =
|
|
2584
|
+
function Jt(e, t, n, r) {
|
|
2585
|
+
let { ndc: i, visible: a } = qt(e, t), o = -(n[2] * e[0] + n[6] * e[1] + n[10] * e[2] + n[14]), s = t, c = s[3] * e[0] + s[7] * e[1] + s[11] * e[2] + s[15];
|
|
2474
2586
|
return {
|
|
2475
2587
|
ndc: [i[0], i[1]],
|
|
2476
2588
|
depth: o,
|
|
@@ -2478,7 +2590,7 @@ function Gt(e, t, n, r) {
|
|
|
2478
2590
|
scale: c > 0 ? r / c : 0
|
|
2479
2591
|
};
|
|
2480
2592
|
}
|
|
2481
|
-
function
|
|
2593
|
+
function Yt(e) {
|
|
2482
2594
|
let t = (t) => [
|
|
2483
2595
|
e[t],
|
|
2484
2596
|
e[4 + t],
|
|
@@ -2532,27 +2644,27 @@ function Kt(e) {
|
|
|
2532
2644
|
]);
|
|
2533
2645
|
});
|
|
2534
2646
|
}
|
|
2535
|
-
function
|
|
2647
|
+
function Xt(e, t, n) {
|
|
2536
2648
|
for (let r of e) if (r[0] * t[0] + r[1] * t[1] + r[2] * t[2] + r[3] < -n) return !1;
|
|
2537
2649
|
return !0;
|
|
2538
2650
|
}
|
|
2539
|
-
var
|
|
2651
|
+
var Zt = class {
|
|
2540
2652
|
lastFrame = null;
|
|
2541
2653
|
frameCount = 0;
|
|
2542
2654
|
render(e, t) {
|
|
2543
|
-
return e.updateWorldTree(), this.renderFrame(
|
|
2655
|
+
return e.updateWorldTree(), this.renderFrame(Bt(e, t));
|
|
2544
2656
|
}
|
|
2545
2657
|
renderFrame(e) {
|
|
2546
2658
|
return this.lastFrame = e, this.frameCount++, e;
|
|
2547
2659
|
}
|
|
2548
2660
|
dispose() {}
|
|
2549
|
-
},
|
|
2550
|
-
function
|
|
2551
|
-
if (o) return [o === "left" ?
|
|
2661
|
+
}, Qt = 6, $t = 16, en = 64, tn = .2, nn = .5;
|
|
2662
|
+
function rn(e, t, n, r, i, a, o = null, s = 0) {
|
|
2663
|
+
if (o) return [o === "left" ? $t + a[0] : s - $t - n - a[0], t - r / 2 + a[1]];
|
|
2552
2664
|
let c = e - n / 2, l = t - r / 2;
|
|
2553
|
-
return i === "above" ? l = t - r -
|
|
2665
|
+
return i === "above" ? l = t - r - Qt : i === "below" ? l = t + Qt : i === "left" ? c = e - n - Qt : i === "right" && (c = e + Qt), [c + a[0], l + a[1]];
|
|
2554
2666
|
}
|
|
2555
|
-
function
|
|
2667
|
+
function an(e, t, n = 4) {
|
|
2556
2668
|
for (let r of ["left", "right"]) {
|
|
2557
2669
|
let i = e.filter((e) => e.edge === r).sort((e, t) => e.top - t.top), a = [];
|
|
2558
2670
|
for (let e of i) {
|
|
@@ -2584,23 +2696,23 @@ function tn(e, t, n = 4) {
|
|
|
2584
2696
|
}
|
|
2585
2697
|
}
|
|
2586
2698
|
}
|
|
2587
|
-
function
|
|
2699
|
+
function on(e) {
|
|
2588
2700
|
for (let t of ["left", "right"]) {
|
|
2589
2701
|
let n = e.filter((e) => e.edge === t), r = Math.max(0, ...n.map((e) => e.width));
|
|
2590
2702
|
for (let e of n) t === "right" && (e.left -= r - e.width), e.width = r;
|
|
2591
2703
|
}
|
|
2592
2704
|
}
|
|
2593
|
-
function
|
|
2705
|
+
function sn(e, t, n, r = null, i = 0) {
|
|
2594
2706
|
if (r) return [r === "left" ? n.left + n.width : n.left, n.top + n.height - i / 2];
|
|
2595
2707
|
let a = Math.min(Math.max(e, n.left), n.left + n.width), o = Math.min(Math.max(t, n.top), n.top + n.height);
|
|
2596
2708
|
return Math.hypot(a - e, o - t) < 2 ? null : [a, o];
|
|
2597
2709
|
}
|
|
2598
|
-
function
|
|
2710
|
+
function cn(e) {
|
|
2599
2711
|
let t = e.map((e, t) => t).sort((t, n) => {
|
|
2600
2712
|
let r = e[t], i = e[n];
|
|
2601
2713
|
return +(i.overlap === "show") - (r.overlap === "show") || i.priority - r.priority || +!!i.sticky - !!r.sticky || r.depth - i.depth || t - n;
|
|
2602
2714
|
}), n = Array(e.length).fill("hide"), r = /* @__PURE__ */ new Map(), i = (e, t) => {
|
|
2603
|
-
let n = Math.floor(e.left /
|
|
2715
|
+
let n = Math.floor(e.left / en), r = Math.floor((e.left + e.width) / en), i = Math.floor(e.top / en), a = Math.floor((e.top + e.height) / en);
|
|
2604
2716
|
for (let e = n; e <= r; e++) for (let n = i; n <= a; n++) t(`${e},${n}`);
|
|
2605
2717
|
}, a = (e, t) => {
|
|
2606
2718
|
let n = Math.min(e.left + e.width, t.left + t.width) - Math.max(e.left, t.left), r = Math.min(e.top + e.height, t.top + t.height) - Math.max(e.top, t.top);
|
|
@@ -2609,7 +2721,7 @@ function an(e) {
|
|
|
2609
2721
|
for (let o of t) {
|
|
2610
2722
|
let t = e[o];
|
|
2611
2723
|
if (t.overlap !== "show") {
|
|
2612
|
-
let e = t.sticky ?
|
|
2724
|
+
let e = t.sticky ? nn : tn, s = !!t.covered;
|
|
2613
2725
|
if (i(t, (n) => {
|
|
2614
2726
|
s ||= (r.get(n) ?? []).some((n) => a(t, n) > e);
|
|
2615
2727
|
}), s) {
|
|
@@ -2625,7 +2737,7 @@ function an(e) {
|
|
|
2625
2737
|
return n;
|
|
2626
2738
|
}
|
|
2627
2739
|
// src/labels.js
|
|
2628
|
-
var
|
|
2740
|
+
var ln = "http://www.w3.org/2000/svg", un = "0.4", dn = class {
|
|
2629
2741
|
#e = null;
|
|
2630
2742
|
#t = /* @__PURE__ */ new Map();
|
|
2631
2743
|
shown = [];
|
|
@@ -2664,7 +2776,7 @@ var on = "http://www.w3.org/2000/svg", sn = "0.4", cn = class {
|
|
|
2664
2776
|
for (let { entry: e } of o) e.width < 0 && (e.el.style.display = "");
|
|
2665
2777
|
for (let { entry: e } of o) e.width >= 0 || (e.el.style.minWidth = "", e.width = e.el.offsetWidth, e.height = e.el.offsetHeight);
|
|
2666
2778
|
let s = o.map(({ label: e, entry: t }) => {
|
|
2667
|
-
let n = (e.ndc[0] * .5 + .5) * i.width, r = (.5 - e.ndc[1] * .5) * i.height, [a, o] =
|
|
2779
|
+
let n = (e.ndc[0] * .5 + .5) * i.width, r = (.5 - e.ndc[1] * .5) * i.height, [a, o] = rn(n, r, t.width, t.height, e.style.place, e.style.offset, e.style.edge, i.width);
|
|
2668
2780
|
return {
|
|
2669
2781
|
left: a,
|
|
2670
2782
|
top: o,
|
|
@@ -2680,8 +2792,8 @@ var on = "http://www.w3.org/2000/svg", sn = "0.4", cn = class {
|
|
|
2680
2792
|
edge: e.style.edge
|
|
2681
2793
|
};
|
|
2682
2794
|
});
|
|
2683
|
-
|
|
2684
|
-
let c =
|
|
2795
|
+
on(s), an(s, i.height);
|
|
2796
|
+
let c = cn(s);
|
|
2685
2797
|
for (let e of this.#t.values()) e.showing = !1;
|
|
2686
2798
|
let l = new Set(this.#t.values());
|
|
2687
2799
|
o.forEach(({ label: e, entry: t }, r) => {
|
|
@@ -2694,7 +2806,7 @@ var on = "http://www.w3.org/2000/svg", sn = "0.4", cn = class {
|
|
|
2694
2806
|
let a = !!this.pointer?.interactive(e);
|
|
2695
2807
|
a !== t.interactive && (t.interactive = a, t.el.style.pointerEvents = a ? "auto" : "", a ? t.el.dataset.interactive = "" : (delete t.el.dataset.interactive, this.#l(t))), i === "dim" ? n.dimmed++ : n.shown++, this.shown.push(t.el);
|
|
2696
2808
|
let o = t.el, u = s[r];
|
|
2697
|
-
o.style.display = "", o.style.opacity = i === "dim" ?
|
|
2809
|
+
o.style.display = "", o.style.opacity = i === "dim" ? un : "", u.left = Math.round(u.left), u.top = Math.round(u.top), o.style.transform = `translate(${u.left}px, ${u.top}px)`;
|
|
2698
2810
|
let d = e.style.edge, f = d && t.width !== u.width ? `${u.width}px` : "", p = d === "right" ? "right" : "";
|
|
2699
2811
|
(o.style.minWidth !== f || o.style.textAlign !== p) && Object.assign(o.style, {
|
|
2700
2812
|
minWidth: f,
|
|
@@ -2718,8 +2830,8 @@ var on = "http://www.w3.org/2000/svg", sn = "0.4", cn = class {
|
|
|
2718
2830
|
let t = getComputedStyle(e.el);
|
|
2719
2831
|
e.color = t.color, e.rule = t.borderBottomStyle === "none" ? 0 : parseFloat(t.borderBottomWidth) || 0;
|
|
2720
2832
|
}
|
|
2721
|
-
let a =
|
|
2722
|
-
o || (o = document.createElementNS(
|
|
2833
|
+
let a = sn(r, i, t, t.edge, e.rule), o = e.leader;
|
|
2834
|
+
o || (o = document.createElementNS(ln, "g"), o.append(document.createElementNS(ln, "line"), document.createElementNS(ln, "circle")), this.#c().append(o), e.leader = o);
|
|
2723
2835
|
let s = e.color;
|
|
2724
2836
|
o.setAttribute("class", `phoria-leader${e.className.slice(12)}`), o.setAttribute("stroke", s), o.setAttribute("fill", s), o.style.display = "", o.style.opacity = String(n);
|
|
2725
2837
|
let [c, l] = [...o.children];
|
|
@@ -2732,7 +2844,7 @@ var on = "http://www.w3.org/2000/svg", sn = "0.4", cn = class {
|
|
|
2732
2844
|
}
|
|
2733
2845
|
#c() {
|
|
2734
2846
|
if (this.#n) return this.#n;
|
|
2735
|
-
let e = document.createElementNS(
|
|
2847
|
+
let e = document.createElementNS(ln, "svg");
|
|
2736
2848
|
return e.setAttribute("class", "phoria-leaders"), Object.assign(e.style, {
|
|
2737
2849
|
position: "absolute",
|
|
2738
2850
|
left: "0",
|
|
@@ -2813,7 +2925,7 @@ var on = "http://www.w3.org/2000/svg", sn = "0.4", cn = class {
|
|
|
2813
2925
|
let t = this.canvas;
|
|
2814
2926
|
e.style.position = getComputedStyle(t).position === "fixed" ? "fixed" : "absolute", e.style.left = `${t.offsetLeft + t.clientLeft}px`, e.style.top = `${t.offsetTop + t.clientTop}px`, e.style.width = `${t.clientWidth}px`, e.style.height = `${t.clientHeight}px`;
|
|
2815
2927
|
}
|
|
2816
|
-
},
|
|
2928
|
+
}, fn = [
|
|
2817
2929
|
"enabled",
|
|
2818
2930
|
"mode",
|
|
2819
2931
|
"rotateSpeed",
|
|
@@ -2827,7 +2939,7 @@ var on = "http://www.w3.org/2000/svg", sn = "0.4", cn = class {
|
|
|
2827
2939
|
"maxDistance",
|
|
2828
2940
|
"minPitch",
|
|
2829
2941
|
"maxPitch"
|
|
2830
|
-
],
|
|
2942
|
+
], pn = {
|
|
2831
2943
|
enableDamping: "use 'inertia' (0 to turn it off)",
|
|
2832
2944
|
enableRotate: "use mode: 'map' to make dragging pan instead of turning",
|
|
2833
2945
|
rotate: "use mode: 'map' to make dragging pan instead of turning",
|
|
@@ -2836,14 +2948,14 @@ var on = "http://www.w3.org/2000/svg", sn = "0.4", cn = class {
|
|
|
2836
2948
|
screenSpacePanning: "panning always follows the screen",
|
|
2837
2949
|
dampingFactor: "use 'inertia': the fraction of speed kept each 1/60 s (default 0.85)",
|
|
2838
2950
|
target: "set camera.target - the control orbits around it"
|
|
2839
|
-
},
|
|
2840
|
-
function
|
|
2951
|
+
}, mn = Math.PI / 2 - .001, hn = 4;
|
|
2952
|
+
function gn(e) {
|
|
2841
2953
|
let t = "OrbitControl";
|
|
2842
2954
|
e.mode !== void 0 && P(t, "mode", e.mode, ["orbit", "map"]), e.rotateSpeed !== void 0 && N(t, "rotateSpeed", e.rotateSpeed, 0), e.zoomSpeed !== void 0 && N(t, "zoomSpeed", e.zoomSpeed, 0), e.inertia !== void 0 && N(t, "inertia", e.inertia, 0, .99), e.autoRotate === void 0 || typeof e.autoRotate == "boolean" || typeof e.autoRotate == "number" && Number.isFinite(e.autoRotate) || E(t, `'autoRotate' is true, false or a speed in radians per second, got ${j(e.autoRotate)}`), e.minDistance !== void 0 && N(t, "minDistance", e.minDistance, 0), e.maxDistance !== void 0 && N(t, "maxDistance", e.maxDistance, 0, Infinity, { above: !0 }), e.minPitch !== void 0 && N(t, "minPitch", e.minPitch, -Math.PI / 2, Math.PI / 2), e.maxPitch !== void 0 && N(t, "maxPitch", e.maxPitch, -Math.PI / 2, Math.PI / 2);
|
|
2843
2955
|
}
|
|
2844
|
-
var
|
|
2845
|
-
static OPTIONS =
|
|
2846
|
-
static HINTS =
|
|
2956
|
+
var _n = class {
|
|
2957
|
+
static OPTIONS = fn;
|
|
2958
|
+
static HINTS = pn;
|
|
2847
2959
|
enabled = !0;
|
|
2848
2960
|
mode = "orbit";
|
|
2849
2961
|
rotateSpeed = .005;
|
|
@@ -2855,8 +2967,8 @@ var mn = class {
|
|
|
2855
2967
|
autoRotate = !1;
|
|
2856
2968
|
minDistance = .1;
|
|
2857
2969
|
maxDistance = Infinity;
|
|
2858
|
-
minPitch = -
|
|
2859
|
-
maxPitch =
|
|
2970
|
+
minPitch = -mn;
|
|
2971
|
+
maxPitch = mn;
|
|
2860
2972
|
camera;
|
|
2861
2973
|
element;
|
|
2862
2974
|
#e = /* @__PURE__ */ new Map();
|
|
@@ -2875,7 +2987,7 @@ var mn = class {
|
|
|
2875
2987
|
#s;
|
|
2876
2988
|
#c = null;
|
|
2877
2989
|
constructor(e, t, n = {}) {
|
|
2878
|
-
A("OrbitControl", n,
|
|
2990
|
+
A("OrbitControl", n, fn, pn), e && "target" in e || E("OrbitControl", "expects a camera, e.g. new OrbitControl(view.camera, view.canvas)"), this.camera = e, this.element = t, gn(n), Object.assign(this, n), this.minDistance > this.maxDistance && E("OrbitControl", `'minDistance' (${this.minDistance}) is more than 'maxDistance' (${this.maxDistance})`), this.minPitch > this.maxPitch && E("OrbitControl", `'minPitch' (${this.minPitch}) is more than 'maxPitch' (${this.maxPitch})`), e.target ??= new z(), t.style.touchAction = "none";
|
|
2879
2991
|
let r = (e) => this.#f(e), i = (e) => this.#p(e), a = (e) => this.#m(e), o = (e) => this.#h(e), s = (e) => {
|
|
2880
2992
|
this.enabled && this.pan && e.preventDefault();
|
|
2881
2993
|
}, c = (e) => {
|
|
@@ -3000,7 +3112,7 @@ var mn = class {
|
|
|
3000
3112
|
else {
|
|
3001
3113
|
let e = -n * this.rotateSpeed, t = r * this.rotateSpeed;
|
|
3002
3114
|
this.rotate(e, t);
|
|
3003
|
-
let i = performance.now(), a = Math.max(1 / 60, (i - this.#n) / 1e3), o = (e) => Math.max(-4, Math.min(
|
|
3115
|
+
let i = performance.now(), a = Math.max(1 / 60, (i - this.#n) / 1e3), o = (e) => Math.max(-4, Math.min(hn, e / a));
|
|
3004
3116
|
this.#t = {
|
|
3005
3117
|
yaw: o(e),
|
|
3006
3118
|
pitch: o(t)
|
|
@@ -3026,34 +3138,34 @@ var mn = class {
|
|
|
3026
3138
|
let [e, t] = [...this.#e.values()];
|
|
3027
3139
|
return Math.hypot(e.x - t.x, e.y - t.y);
|
|
3028
3140
|
}
|
|
3029
|
-
},
|
|
3141
|
+
}, vn = new Float32Array([
|
|
3030
3142
|
0,
|
|
3031
3143
|
1,
|
|
3032
3144
|
0
|
|
3033
|
-
]),
|
|
3034
|
-
function
|
|
3145
|
+
]), yn = /* @__PURE__ */ new Float32Array(16), bn = /* @__PURE__ */ new Float32Array(9);
|
|
3146
|
+
function xn(e, t) {
|
|
3035
3147
|
if (e.position.equals(t, 1e-9)) return;
|
|
3036
3148
|
let n = t.clone().sub(e.position).normalize(), r = Math.hypot(n[0], n[2]) < 5e-4 ? [
|
|
3037
3149
|
0,
|
|
3038
3150
|
0,
|
|
3039
3151
|
-1
|
|
3040
|
-
] :
|
|
3041
|
-
f(
|
|
3042
|
-
let i = Oe(/* @__PURE__ */ new Float32Array(4), je(/* @__PURE__ */ new Float32Array(4),
|
|
3152
|
+
] : vn;
|
|
3153
|
+
f(yn, e.position, t, r);
|
|
3154
|
+
let i = Oe(/* @__PURE__ */ new Float32Array(4), je(/* @__PURE__ */ new Float32Array(4), st(bn, yn)));
|
|
3043
3155
|
e.quaternion.copy(i);
|
|
3044
3156
|
}
|
|
3045
|
-
var
|
|
3157
|
+
var Sn = [
|
|
3046
3158
|
...G,
|
|
3047
3159
|
"near",
|
|
3048
3160
|
"far",
|
|
3049
3161
|
"target",
|
|
3050
3162
|
"aspect"
|
|
3051
|
-
],
|
|
3163
|
+
], Cn = {
|
|
3052
3164
|
lookAt: "use target: [x, y, z], or call camera.lookAt(...) after creating it",
|
|
3053
3165
|
zoom: "move the camera, or change 'fov' (perspective) or 'height' (orthographic)"
|
|
3054
|
-
},
|
|
3055
|
-
static OPTIONS =
|
|
3056
|
-
static HINTS =
|
|
3166
|
+
}, wn = class extends K {
|
|
3167
|
+
static OPTIONS = Sn;
|
|
3168
|
+
static HINTS = Cn;
|
|
3057
3169
|
near = .1;
|
|
3058
3170
|
far = 1e3;
|
|
3059
3171
|
aspect = 1;
|
|
@@ -3067,13 +3179,13 @@ var yn = [
|
|
|
3067
3179
|
return this.#e;
|
|
3068
3180
|
}
|
|
3069
3181
|
set target(e) {
|
|
3070
|
-
this.#e =
|
|
3182
|
+
this.#e = pt(this.#e, e, this.constructor.name);
|
|
3071
3183
|
}
|
|
3072
3184
|
updateMatrix() {
|
|
3073
|
-
return this.target &&
|
|
3185
|
+
return this.target && xn(this, this.target), super.updateMatrix();
|
|
3074
3186
|
}
|
|
3075
3187
|
lookAt(e, t) {
|
|
3076
|
-
return this.target ? (this.target.copy(
|
|
3188
|
+
return this.target ? (this.target.copy(mt(this, e)), this) : super.lookAt(e, t);
|
|
3077
3189
|
}
|
|
3078
3190
|
get projectionMatrix() {
|
|
3079
3191
|
return new B();
|
|
@@ -3094,10 +3206,10 @@ var yn = [
|
|
|
3094
3206
|
let e = {};
|
|
3095
3207
|
return this.near !== .1 && (e.near = this.near), this.far !== 1e3 && (e.far = this.far), this.target && (e.target = this.target.toArray()), e;
|
|
3096
3208
|
}
|
|
3097
|
-
},
|
|
3209
|
+
}, Tn = class extends wn {
|
|
3098
3210
|
static type = "perspective-camera";
|
|
3099
3211
|
static get OPTIONS() {
|
|
3100
|
-
return [...
|
|
3212
|
+
return [...Sn, "fov"];
|
|
3101
3213
|
}
|
|
3102
3214
|
fov = 50;
|
|
3103
3215
|
constructor(e = {}) {
|
|
@@ -3118,10 +3230,10 @@ var yn = [
|
|
|
3118
3230
|
...this.fov === 50 ? {} : { fov: this.fov }
|
|
3119
3231
|
};
|
|
3120
3232
|
}
|
|
3121
|
-
},
|
|
3233
|
+
}, En = class extends wn {
|
|
3122
3234
|
static type = "orthographic-camera";
|
|
3123
3235
|
static get OPTIONS() {
|
|
3124
|
-
return [...
|
|
3236
|
+
return [...Sn, "height"];
|
|
3125
3237
|
}
|
|
3126
3238
|
height = 10;
|
|
3127
3239
|
constructor(e = {}) {
|
|
@@ -3143,7 +3255,7 @@ var yn = [
|
|
|
3143
3255
|
...this.height === 10 ? {} : { height: this.height }
|
|
3144
3256
|
};
|
|
3145
3257
|
}
|
|
3146
|
-
},
|
|
3258
|
+
}, Dn = {
|
|
3147
3259
|
perspective: [
|
|
3148
3260
|
.6,
|
|
3149
3261
|
.45,
|
|
@@ -3169,7 +3281,7 @@ var yn = [
|
|
|
3169
3281
|
0,
|
|
3170
3282
|
0
|
|
3171
3283
|
]
|
|
3172
|
-
},
|
|
3284
|
+
}, On = Object.keys(Dn), kn = {
|
|
3173
3285
|
ortho: "isometric",
|
|
3174
3286
|
orthographic: "isometric",
|
|
3175
3287
|
iso: "isometric",
|
|
@@ -3183,13 +3295,13 @@ var yn = [
|
|
|
3183
3295
|
persp: "perspective",
|
|
3184
3296
|
"3d": "perspective"
|
|
3185
3297
|
};
|
|
3186
|
-
function
|
|
3298
|
+
function An(e, { target: t = [
|
|
3187
3299
|
0,
|
|
3188
3300
|
0,
|
|
3189
3301
|
0
|
|
3190
3302
|
], distance: n = 10 } = {}) {
|
|
3191
|
-
let r =
|
|
3192
|
-
return e === "perspective" ? new
|
|
3303
|
+
let r = jn(e), i = new z(t[0], t[1], t[2]).add(r.multiplyScalar(n));
|
|
3304
|
+
return e === "perspective" ? new Tn({
|
|
3193
3305
|
fov: 45,
|
|
3194
3306
|
position: i,
|
|
3195
3307
|
target: [
|
|
@@ -3197,7 +3309,7 @@ function Dn(e, { target: t = [
|
|
|
3197
3309
|
t[1],
|
|
3198
3310
|
t[2]
|
|
3199
3311
|
]
|
|
3200
|
-
}) : new
|
|
3312
|
+
}) : new En({
|
|
3201
3313
|
height: n,
|
|
3202
3314
|
position: i,
|
|
3203
3315
|
target: [
|
|
@@ -3208,15 +3320,15 @@ function Dn(e, { target: t = [
|
|
|
3208
3320
|
far: Math.max(1e3, n * 20)
|
|
3209
3321
|
});
|
|
3210
3322
|
}
|
|
3211
|
-
function
|
|
3212
|
-
if (!(e in
|
|
3213
|
-
let t =
|
|
3214
|
-
E("View", `camera '${e}' is not a preset - ${t ? `use '${t}'` : `expected one of ${
|
|
3323
|
+
function jn(e) {
|
|
3324
|
+
if (!(e in Dn)) {
|
|
3325
|
+
let t = kn[String(e).toLowerCase()];
|
|
3326
|
+
E("View", `camera '${e}' is not a preset - ${t ? `use '${t}'` : `expected one of ${On.map((e) => `'${e}'`).join(", ")}${k(String(e), On)}`}`);
|
|
3215
3327
|
}
|
|
3216
|
-
return new z(...
|
|
3328
|
+
return new z(...Dn[e]).normalize();
|
|
3217
3329
|
}
|
|
3218
|
-
var
|
|
3219
|
-
function
|
|
3330
|
+
var Mn = .12;
|
|
3331
|
+
function Nn(e, t, { aspect: n, fov: r, padding: i = 0 }) {
|
|
3220
3332
|
let a = 1 + i, o = n > 0 ? n : 1, s = new z(-t[0], -t[1], -t[2]), c = s.clone().cross(Math.abs(s[1]) > .9999 ? [
|
|
3221
3333
|
0,
|
|
3222
3334
|
0,
|
|
@@ -3263,7 +3375,7 @@ function An(e, t, { aspect: n, fov: r, padding: i = 0 }) {
|
|
|
3263
3375
|
let a = x + i[2] - m[2], o = (i[0] - m[0]) / a / v, s = (i[1] - m[1]) / a / _;
|
|
3264
3376
|
e = Math.min(e, o), t = Math.max(t, o), n = Math.min(n, s), r = Math.max(r, s);
|
|
3265
3377
|
}
|
|
3266
|
-
let i = (e + t) / 2, a = (n + r) / 2 +
|
|
3378
|
+
let i = (e + t) / 2, a = (n + r) / 2 + Mn;
|
|
3267
3379
|
if (Math.abs(i) < 1e-4 && Math.abs(a) < 1e-4) break;
|
|
3268
3380
|
m[0] += i * v * x, m[1] += a * _ * x, x = b();
|
|
3269
3381
|
}
|
|
@@ -3272,18 +3384,18 @@ function An(e, t, { aspect: n, fov: r, padding: i = 0 }) {
|
|
|
3272
3384
|
size: x
|
|
3273
3385
|
};
|
|
3274
3386
|
}
|
|
3275
|
-
function
|
|
3387
|
+
function Pn(e, t, n) {
|
|
3276
3388
|
if (e === "height" || !(n > 0) || !(t > 0)) return 1;
|
|
3277
3389
|
let r = t / n;
|
|
3278
3390
|
return e === "width" ? r : Math.max(1, r);
|
|
3279
3391
|
}
|
|
3280
3392
|
// src/ease.js
|
|
3281
|
-
var
|
|
3393
|
+
var Fn = {
|
|
3282
3394
|
linear: (e) => e,
|
|
3283
3395
|
in: (e) => e * e * e,
|
|
3284
3396
|
out: (e) => 1 - (1 - e) ** 3,
|
|
3285
3397
|
inOut: (e) => e < .5 ? 4 * e * e * e : 1 - (-2 * e + 2) ** 3 / 2
|
|
3286
|
-
},
|
|
3398
|
+
}, In = new z(), Ln = new z(), Rn = new z(), q = new z(), zn = new z(), Bn = class e {
|
|
3287
3399
|
origin = new z();
|
|
3288
3400
|
direction = new z(0, 0, -1);
|
|
3289
3401
|
constructor(e, t) {
|
|
@@ -3313,17 +3425,17 @@ var Mn = {
|
|
|
3313
3425
|
return r >= 0 ? r : null;
|
|
3314
3426
|
}
|
|
3315
3427
|
intersectTriangle(e, t, n, r) {
|
|
3316
|
-
|
|
3317
|
-
let i =
|
|
3428
|
+
In.set(t[0] - e[0], t[1] - e[1], t[2] - e[2]), Ln.set(n[0] - e[0], n[1] - e[1], n[2] - e[2]), Rn.copy(this.direction).cross(Ln);
|
|
3429
|
+
let i = In.dot(Rn);
|
|
3318
3430
|
if (r ? i < 1e-10 : Math.abs(i) < 1e-10) return null;
|
|
3319
3431
|
let a = 1 / i;
|
|
3320
3432
|
q.set(this.origin[0] - e[0], this.origin[1] - e[1], this.origin[2] - e[2]);
|
|
3321
|
-
let o = q.dot(
|
|
3433
|
+
let o = q.dot(Rn) * a;
|
|
3322
3434
|
if (o < 0 || o > 1) return null;
|
|
3323
|
-
|
|
3324
|
-
let s = this.direction.dot(
|
|
3435
|
+
zn.copy(q).cross(In);
|
|
3436
|
+
let s = this.direction.dot(zn) * a;
|
|
3325
3437
|
if (s < 0 || o + s > 1) return null;
|
|
3326
|
-
let c =
|
|
3438
|
+
let c = Ln.dot(zn) * a;
|
|
3327
3439
|
return c >= 0 ? {
|
|
3328
3440
|
t: c,
|
|
3329
3441
|
u: o,
|
|
@@ -3332,7 +3444,7 @@ var Mn = {
|
|
|
3332
3444
|
}
|
|
3333
3445
|
distanceSqToPoint(e) {
|
|
3334
3446
|
q.set(e[0] - this.origin[0], e[1] - this.origin[1], e[2] - this.origin[2]);
|
|
3335
|
-
let t = Math.max(0, q.dot(this.direction)), n = this.at(t,
|
|
3447
|
+
let t = Math.max(0, q.dot(this.direction)), n = this.at(t, zn);
|
|
3336
3448
|
return {
|
|
3337
3449
|
distanceSq: (e[0] - n[0]) ** 2 + (e[1] - n[1]) ** 2 + (e[2] - n[2]) ** 2,
|
|
3338
3450
|
t
|
|
@@ -3350,18 +3462,18 @@ var Mn = {
|
|
|
3350
3462
|
s: m
|
|
3351
3463
|
};
|
|
3352
3464
|
}
|
|
3353
|
-
},
|
|
3354
|
-
function
|
|
3355
|
-
let n =
|
|
3465
|
+
}, Vn = 8, Hn = /* @__PURE__ */ new WeakMap();
|
|
3466
|
+
function Un(e, t) {
|
|
3467
|
+
let n = Hn.get(e);
|
|
3356
3468
|
if (n && n.version === e.version && n.count === t) return n.bvh;
|
|
3357
|
-
let r =
|
|
3358
|
-
return
|
|
3469
|
+
let r = Wn(e, t);
|
|
3470
|
+
return Hn.set(e, {
|
|
3359
3471
|
version: e.version,
|
|
3360
3472
|
count: t,
|
|
3361
3473
|
bvh: r
|
|
3362
3474
|
}), r;
|
|
3363
3475
|
}
|
|
3364
|
-
function
|
|
3476
|
+
function Wn(e, t) {
|
|
3365
3477
|
let n = e.positions, r = e.indices, i = (e, t) => (r ? r[e * 3 + t] : e * 3 + t) * 3, a = new Float32Array(t * 9);
|
|
3366
3478
|
for (let e = 0; e < t; e++) {
|
|
3367
3479
|
let t = i(e, 0), r = i(e, 1), o = i(e, 2);
|
|
@@ -3372,7 +3484,7 @@ function Vn(e, t) {
|
|
|
3372
3484
|
}
|
|
3373
3485
|
let o = new Uint32Array(t);
|
|
3374
3486
|
for (let e = 0; e < t; e++) o[e] = e;
|
|
3375
|
-
let s = Math.max(1, 2 * Math.ceil(t /
|
|
3487
|
+
let s = Math.max(1, 2 * Math.ceil(t / Vn) * 2), c = new Float32Array(s * 6), l = new Int32Array(s * 2), u = 0, d = () => {
|
|
3376
3488
|
let e = new Float32Array(c.length * 2), t = new Int32Array(l.length * 2);
|
|
3377
3489
|
e.set(c), t.set(l), c = e, l = t;
|
|
3378
3490
|
}, f = () => ((u + 1) * 2 > l.length && d(), u++), p = [[
|
|
@@ -3395,12 +3507,12 @@ function Vn(e, t) {
|
|
|
3395
3507
|
m
|
|
3396
3508
|
], e * 6);
|
|
3397
3509
|
let x = v - h, S = y - g, C = b - _;
|
|
3398
|
-
if (n - t <=
|
|
3510
|
+
if (n - t <= Vn || Math.max(x, S, C) <= 0) {
|
|
3399
3511
|
l[e * 2] = t, l[e * 2 + 1] = n - t;
|
|
3400
3512
|
continue;
|
|
3401
3513
|
}
|
|
3402
3514
|
let w = x >= S && x >= C ? 6 : S >= C ? 7 : 8, T = t + n >> 1;
|
|
3403
|
-
|
|
3515
|
+
Gn(o, a, w, t, n, T);
|
|
3404
3516
|
let E = f();
|
|
3405
3517
|
f(), l[e * 2] = E, l[e * 2 + 1] = 0, p.push([
|
|
3406
3518
|
E,
|
|
@@ -3418,7 +3530,7 @@ function Vn(e, t) {
|
|
|
3418
3530
|
order: o
|
|
3419
3531
|
};
|
|
3420
3532
|
}
|
|
3421
|
-
function
|
|
3533
|
+
function Gn(e, t, n, r, i, a) {
|
|
3422
3534
|
let o = r, s = i - 1;
|
|
3423
3535
|
for (; o < s;) {
|
|
3424
3536
|
let r = t[e[o + s >> 1] * 9 + n], i = o, c = s;
|
|
@@ -3435,7 +3547,7 @@ function Hn(e, t, n, r, i, a) {
|
|
|
3435
3547
|
else break;
|
|
3436
3548
|
}
|
|
3437
3549
|
}
|
|
3438
|
-
function
|
|
3550
|
+
function Kn(e, t, n, r) {
|
|
3439
3551
|
let { boxes: i, nodes: a, order: o } = e, s = 1 / n[0], c = 1 / n[1], l = 1 / n[2], u = (e) => {
|
|
3440
3552
|
let n = e * 6, r = (i[n] - t[0]) * s, a = (i[n + 3] - t[0]) * s, o = Math.min(r, a), u = Math.max(r, a);
|
|
3441
3553
|
return r = (i[n + 1] - t[1]) * c, a = (i[n + 4] - t[1]) * c, o = Math.max(o, Math.min(r, a)), u = Math.min(u, Math.max(r, a)), r = (i[n + 2] - t[2]) * l, a = (i[n + 5] - t[2]) * l, o = Math.max(o, Math.min(r, a)), u = Math.min(u, Math.max(r, a)), u >= Math.max(o, 0) || Number.isNaN(o) || Number.isNaN(u) ? Math.max(o, 0) || 0 : Infinity;
|
|
@@ -3455,11 +3567,11 @@ function Un(e, t, n, r) {
|
|
|
3455
3567
|
}
|
|
3456
3568
|
}
|
|
3457
3569
|
// src/Raycaster.js
|
|
3458
|
-
var
|
|
3570
|
+
var qn = /* @__PURE__ */ new Float32Array(16), Jn = /* @__PURE__ */ new Float32Array(16), J = new z(), Y = new z(), Yn = new z(), Xn = /* @__PURE__ */ new Float32Array(4), Zn = (e) => e?.clip ? {
|
|
3459
3571
|
plane: Ce(e),
|
|
3460
3572
|
cap: !!e.clip.cap
|
|
3461
|
-
} : null,
|
|
3462
|
-
ray = new
|
|
3573
|
+
} : null, Qn = class {
|
|
3574
|
+
ray = new Bn();
|
|
3463
3575
|
near = 0;
|
|
3464
3576
|
far = Infinity;
|
|
3465
3577
|
threshold = .1;
|
|
@@ -3476,7 +3588,7 @@ var Wn = /* @__PURE__ */ new Float32Array(16), Gn = /* @__PURE__ */ new Float32A
|
|
|
3476
3588
|
}
|
|
3477
3589
|
intersect(e) {
|
|
3478
3590
|
let t = [];
|
|
3479
|
-
for (let n of [e].flat()) n.updateWorld(), this.#e(n, t,
|
|
3591
|
+
for (let n of [e].flat()) n.updateWorld(), this.#e(n, t, Zn(we(n.parent)));
|
|
3480
3592
|
return t.filter((e) => e.distance >= this.near && e.distance <= this.far).sort((e, t) => e.distance - t.distance);
|
|
3481
3593
|
}
|
|
3482
3594
|
intersectDrawn(e) {
|
|
@@ -3488,7 +3600,7 @@ var Wn = /* @__PURE__ */ new Float32Array(16), Gn = /* @__PURE__ */ new Float32A
|
|
|
3488
3600
|
plane: n.clip.plane,
|
|
3489
3601
|
cap: !!n.clip.cap
|
|
3490
3602
|
} : null;
|
|
3491
|
-
if (n.instances) for (let i = 0; i < n.instances.count; i++) s(
|
|
3603
|
+
if (n.instances) for (let i = 0; i < n.instances.count; i++) s(Jn, n.worldMatrix, n.instances.instanceMatrices.subarray(i * 16, i * 16 + 16)), this.#t(e, Jn, i, t, r);
|
|
3492
3604
|
else this.#t(e, n.worldMatrix, null, t, r);
|
|
3493
3605
|
}
|
|
3494
3606
|
return t.filter((e) => e.distance >= this.near && e.distance <= this.far).sort((e, t) => e.distance - t.distance);
|
|
@@ -3532,10 +3644,10 @@ var Wn = /* @__PURE__ */ new Float32Array(16), Gn = /* @__PURE__ */ new Float32A
|
|
|
3532
3644
|
}
|
|
3533
3645
|
intersectElement(e, t) {
|
|
3534
3646
|
e.updateWorld();
|
|
3535
|
-
let n = e, r = [], i =
|
|
3647
|
+
let n = e, r = [], i = Zn(we(e));
|
|
3536
3648
|
if (n.drawMode === "triangles" && n.instanceMatrices) {
|
|
3537
3649
|
if (t >= n.count) return null;
|
|
3538
|
-
s(
|
|
3650
|
+
s(Jn, n.worldMatrix, n.instanceMatrices.subarray(t * 16, t * 16 + 16)), this.#t(n, Jn, t, r, i);
|
|
3539
3651
|
} else if (n.drawMode === "triangles") this.#t(n, n.worldMatrix, null, r, i);
|
|
3540
3652
|
else if (n.drawMode === "points") {
|
|
3541
3653
|
let e = n.geometry.positions;
|
|
@@ -3571,9 +3683,9 @@ var Wn = /* @__PURE__ */ new Float32Array(16), Gn = /* @__PURE__ */ new Float32A
|
|
|
3571
3683
|
}
|
|
3572
3684
|
#e(e, t, n) {
|
|
3573
3685
|
if (!(this.camera ? e.shownTo(this.camera) : e.visible) || !e.pickable) return;
|
|
3574
|
-
e.clip && (n =
|
|
3686
|
+
e.clip && (n = Zn(e));
|
|
3575
3687
|
let r = e;
|
|
3576
|
-
if (r.drawMode === "triangles" && r.instanceMatrices) for (let e = 0; e < r.count; e++) s(
|
|
3688
|
+
if (r.drawMode === "triangles" && r.instanceMatrices) for (let e = 0; e < r.count; e++) s(Jn, r.worldMatrix, r.instanceMatrices.subarray(e * 16, e * 16 + 16)), this.#t(r, Jn, e, t, n);
|
|
3577
3689
|
else r.drawMode === "triangles" ? this.#t(r, r.worldMatrix, null, t, n) : r.drawMode === "points" ? this.#n(r, t) : r.drawMode === "lines" && this.#r(r, t);
|
|
3578
3690
|
for (let r of e.children) this.#e(r, t, n);
|
|
3579
3691
|
}
|
|
@@ -3581,26 +3693,26 @@ var Wn = /* @__PURE__ */ new Float32Array(16), Gn = /* @__PURE__ */ new Float32A
|
|
|
3581
3693
|
let o = e.geometry;
|
|
3582
3694
|
if (!o.vertexCount) return;
|
|
3583
3695
|
let s = o.bounds, c = s.getCenter().applyMatrix4(t), l = Math.max(Math.hypot(t[0], t[1], t[2]), Math.hypot(t[4], t[5], t[6]), Math.hypot(t[8], t[9], t[10]));
|
|
3584
|
-
if (this.ray.intersectSphere(c, s.getRadius() * l) === null || !a(
|
|
3585
|
-
let u = this.ray.clone().applyMatrix4(
|
|
3586
|
-
if (i) for (let e = 0; e < 4; e++)
|
|
3696
|
+
if (this.ray.intersectSphere(c, s.getRadius() * l) === null || !a(qn, t)) return;
|
|
3697
|
+
let u = this.ray.clone().applyMatrix4(qn), d = o.positions, f = o.indices, p = !e.material.doubleSided && !i?.cap;
|
|
3698
|
+
if (i) for (let e = 0; e < 4; e++) Xn[e] = i.plane[0] * t[e * 4] + i.plane[1] * t[e * 4 + 1] + i.plane[2] * t[e * 4 + 2] + i.plane[3] * t[e * 4 + 3];
|
|
3587
3699
|
let m = u.origin, h = u.direction, g = null, _ = Infinity, v = -1, y = (e) => {
|
|
3588
3700
|
let t = f ? f[e * 3] : e * 3, n = f ? f[e * 3 + 1] : e * 3 + 1, r = f ? f[e * 3 + 2] : e * 3 + 2;
|
|
3589
|
-
J.set(d[t * 3], d[t * 3 + 1], d[t * 3 + 2]), Y.set(d[n * 3], d[n * 3 + 1], d[n * 3 + 2]),
|
|
3590
|
-
let a = u.intersectTriangle(J, Y,
|
|
3591
|
-
return a && i &&
|
|
3701
|
+
J.set(d[t * 3], d[t * 3 + 1], d[t * 3 + 2]), Y.set(d[n * 3], d[n * 3 + 1], d[n * 3 + 2]), Yn.set(d[r * 3], d[r * 3 + 1], d[r * 3 + 2]);
|
|
3702
|
+
let a = u.intersectTriangle(J, Y, Yn, p);
|
|
3703
|
+
return a && i && Xn[0] * (m[0] + h[0] * a.t) + Xn[1] * (m[1] + h[1] * a.t) + Xn[2] * (m[2] + h[2] * a.t) + Xn[3] > 0 || a && (a.t < _ || a.t === _ && e < v) && (g = {
|
|
3592
3704
|
...a,
|
|
3593
3705
|
i0: t,
|
|
3594
3706
|
i1: n,
|
|
3595
3707
|
i2: r
|
|
3596
3708
|
}, _ = a.t, v = e), _;
|
|
3597
3709
|
}, b = Math.floor(o.drawnCount / 3);
|
|
3598
|
-
if (b >= 128) Un(
|
|
3710
|
+
if (b >= 128) Kn(Un(o, b), m, h, y);
|
|
3599
3711
|
else for (let e = 0; e < b; e++) y(e);
|
|
3600
3712
|
if (!g) return;
|
|
3601
3713
|
let x = u.at(g.t).applyMatrix4(t);
|
|
3602
|
-
J.set(d[g.i0 * 3], d[g.i0 * 3 + 1], d[g.i0 * 3 + 2]), Y.set(d[g.i1 * 3], d[g.i1 * 3 + 1], d[g.i1 * 3 + 2]).sub(J),
|
|
3603
|
-
let S = Y.clone().cross(
|
|
3714
|
+
J.set(d[g.i0 * 3], d[g.i0 * 3 + 1], d[g.i0 * 3 + 2]), Y.set(d[g.i1 * 3], d[g.i1 * 3 + 1], d[g.i1 * 3 + 2]).sub(J), Yn.set(d[g.i2 * 3], d[g.i2 * 3 + 1], d[g.i2 * 3 + 2]).sub(J);
|
|
3715
|
+
let S = Y.clone().cross(Yn), C = ot(/* @__PURE__ */ new Float32Array(9), t), w = C ? new z(C[0] * S[0] + C[3] * S[1] + C[6] * S[2], C[1] * S[0] + C[4] * S[1] + C[7] * S[2], C[2] * S[0] + C[5] * S[1] + C[8] * S[2]).normalize() : null;
|
|
3604
3716
|
if (i?.cap && w && w.dot(this.ray.direction) > 0) {
|
|
3605
3717
|
let e = i.plane, { origin: t, direction: n } = this.ray, r = e[0] * n[0] + e[1] * n[1] + e[2] * n[2];
|
|
3606
3718
|
r < 0 && (x = this.ray.at(-(e[0] * t[0] + e[1] * t[1] + e[2] * t[2] + e[3]) / r)), w = new z(e[0], e[1], e[2]);
|
|
@@ -3665,10 +3777,94 @@ var Wn = /* @__PURE__ */ new Float32Array(16), Gn = /* @__PURE__ */ new Float32A
|
|
|
3665
3777
|
}
|
|
3666
3778
|
s && t.push(s);
|
|
3667
3779
|
}
|
|
3668
|
-
},
|
|
3669
|
-
|
|
3670
|
-
|
|
3671
|
-
},
|
|
3780
|
+
}, $n = /* @__PURE__ */ new Float32Array(16);
|
|
3781
|
+
function er(e) {
|
|
3782
|
+
let t;
|
|
3783
|
+
if (Array.isArray(e)) (e.length < 3 || !e.every((e) => Array.isArray(e) && e.length === 2 && e.every(Number.isFinite))) && E("View", `pickArea() takes a box { x, y, width, height } or a lasso of three or more [x, y] points, got ${j(e)}`), t = e.flat();
|
|
3784
|
+
else {
|
|
3785
|
+
let { x: n, y: r, width: i, height: a } = e ?? {};
|
|
3786
|
+
[
|
|
3787
|
+
n,
|
|
3788
|
+
r,
|
|
3789
|
+
i,
|
|
3790
|
+
a
|
|
3791
|
+
].every(Number.isFinite) || E("View", `pickArea() takes a box { x, y, width, height } or a lasso of three or more [x, y] points, got ${j(e)}`), t = [
|
|
3792
|
+
n,
|
|
3793
|
+
r,
|
|
3794
|
+
n + i,
|
|
3795
|
+
r,
|
|
3796
|
+
n + i,
|
|
3797
|
+
r + a,
|
|
3798
|
+
n,
|
|
3799
|
+
r + a
|
|
3800
|
+
];
|
|
3801
|
+
}
|
|
3802
|
+
let n = Infinity, r = Infinity, i = -Infinity, a = -Infinity;
|
|
3803
|
+
for (let e = 0; e < t.length; e += 2) n = Math.min(n, t[e]), i = Math.max(i, t[e]), r = Math.min(r, t[e + 1]), a = Math.max(a, t[e + 1]);
|
|
3804
|
+
return {
|
|
3805
|
+
points: t,
|
|
3806
|
+
left: n,
|
|
3807
|
+
top: r,
|
|
3808
|
+
right: i,
|
|
3809
|
+
bottom: a
|
|
3810
|
+
};
|
|
3811
|
+
}
|
|
3812
|
+
function tr(e, t, n) {
|
|
3813
|
+
let r = !1;
|
|
3814
|
+
for (let i = 0, a = e.length - 2; i < e.length; a = i, i += 2) {
|
|
3815
|
+
let o = e[i + 1], s = e[a + 1];
|
|
3816
|
+
o > n != s > n && t < e[i] + (e[a] - e[i]) * (n - o) / (s - o) && (r = !r);
|
|
3817
|
+
}
|
|
3818
|
+
return r;
|
|
3819
|
+
}
|
|
3820
|
+
function nr(e, t, n, r, i, a) {
|
|
3821
|
+
let o = er(a), c = t.worldPosition, l = n, u = [], d = (e, t, n) => {
|
|
3822
|
+
let a = l[3] * e + l[7] * t + l[11] * n + l[15];
|
|
3823
|
+
if (a <= 0) return !1;
|
|
3824
|
+
let s = (l[2] * e + l[6] * t + l[10] * n + l[14]) / a;
|
|
3825
|
+
if (s < -1 || s > 1) return !1;
|
|
3826
|
+
let c = ((l[0] * e + l[4] * t + l[8] * n + l[12]) / a * .5 + .5) * r, u = (.5 - (l[1] * e + l[5] * t + l[9] * n + l[13]) / a * .5) * i;
|
|
3827
|
+
return c >= o.left && c <= o.right && u >= o.top && u <= o.bottom && tr(o.points, c, u);
|
|
3828
|
+
}, f = (e, t, n, r, i, a) => {
|
|
3829
|
+
let o = new z(t, n, r);
|
|
3830
|
+
u.push({
|
|
3831
|
+
node: e,
|
|
3832
|
+
point: o,
|
|
3833
|
+
distance: o.distanceTo(c),
|
|
3834
|
+
normal: null,
|
|
3835
|
+
face: i,
|
|
3836
|
+
instance: a,
|
|
3837
|
+
uv: null,
|
|
3838
|
+
datum: e.datumAt(a ?? i)
|
|
3839
|
+
});
|
|
3840
|
+
}, p = new z(), m = (e) => {
|
|
3841
|
+
if (!e.shownTo(t) || !e.pickable) return;
|
|
3842
|
+
let n = e;
|
|
3843
|
+
if (n.isDrawable && n.geometry.vertexCount) {
|
|
3844
|
+
let e = n.geometry, t = n.worldMatrix;
|
|
3845
|
+
if (n.drawMode === "points") {
|
|
3846
|
+
let r = e.positions;
|
|
3847
|
+
for (let i = 0; i < e.drawnVertices; i++) p.set(r[i * 3], r[i * 3 + 1], r[i * 3 + 2]).applyMatrix4(t), d(p[0], p[1], p[2]) && f(n, p[0], p[1], p[2], i, null);
|
|
3848
|
+
} else if (n.drawMode === "lines") {
|
|
3849
|
+
let r = e.positions, i = e.indices;
|
|
3850
|
+
for (let a = 0; a < Math.floor(e.drawnCount / 2); a++) {
|
|
3851
|
+
let e = i ? i[a * 2] : a * 2, o = i ? i[a * 2 + 1] : a * 2 + 1;
|
|
3852
|
+
p.set((r[e * 3] + r[o * 3]) / 2, (r[e * 3 + 1] + r[o * 3 + 1]) / 2, (r[e * 3 + 2] + r[o * 3 + 2]) / 2).applyMatrix4(t), d(p[0], p[1], p[2]) && f(n, p[0], p[1], p[2], a, null);
|
|
3853
|
+
}
|
|
3854
|
+
} else if (n.instanceMatrices) {
|
|
3855
|
+
let r = e.bounds.getCenter();
|
|
3856
|
+
for (let e = 0; e < n.count; e++) Nt(n.instanceMatrices, e) || (s($n, t, n.instanceMatrices.subarray(e * 16, e * 16 + 16)), p.copy(r).applyMatrix4($n), d(p[0], p[1], p[2]) && f(n, p[0], p[1], p[2], null, e));
|
|
3857
|
+
} else p.copy(e.bounds.getCenter()).applyMatrix4(t), d(p[0], p[1], p[2]) && f(n, p[0], p[1], p[2], null, null);
|
|
3858
|
+
}
|
|
3859
|
+
for (let t of e.children) m(t);
|
|
3860
|
+
};
|
|
3861
|
+
return m(e), u.sort((e, t) => e.distance - t.distance);
|
|
3862
|
+
}
|
|
3863
|
+
// src/watch.js
|
|
3864
|
+
var rr = /* @__PURE__ */ new WeakMap(), ir = 1, X = (e) => {
|
|
3865
|
+
let t = rr.get(e);
|
|
3866
|
+
return t === void 0 && rr.set(e, t = ir++), t;
|
|
3867
|
+
}, ar = class {
|
|
3672
3868
|
#e = /* @__PURE__ */ new Float64Array(256);
|
|
3673
3869
|
#t = /* @__PURE__ */ new Float64Array(256);
|
|
3674
3870
|
#n = 0;
|
|
@@ -3721,7 +3917,7 @@ var Wn = /* @__PURE__ */ new Float32Array(16), Gn = /* @__PURE__ */ new Float32A
|
|
|
3721
3917
|
}
|
|
3722
3918
|
#d(e) {
|
|
3723
3919
|
let t = e.geometry, n = e.material;
|
|
3724
|
-
this.#o(X(t)), this.#o(t.version), this.#o(t.drawCount ?? -1), this.#o(e.renderOrder), this.#o(+!!e.castShadow | (e.receiveShadow ? 2 : 0)), this.#o(e.labels ? X(e.labels) : 0), this.#o(e.data && typeof e.data == "object" ? X(e.data) : 0), "instanceMatrices" in e && (this.#o(e.count), this.#o(e.version)), this.#o(X(n)), this.#s(n.color), this.#s(n.emissive), this.#o(n.emissiveIntensity), this.#o(n.opacity), this.#o(n.roughness), this.#o(n.metalness), this.#o(n.size), this.#o(n.width), this.#o(n.alphaTest), this.#o(n.normalScale), this.#o(n.aoMapIntensity), this.#o(n.triplanar), this.#o(n.bumpScale), this.#o(n.transmission), this.#o(n.clearcoat), this.#o(n.clearcoatRoughness), this.#o(n.sheen), this.#s(n.sheenColor), this.#o(n.sheenRoughness), this.#o(n.ior), this.#o(n.specularIntensity), this.#s(n.specularColor), this.#o(n.anisotropy), this.#o(n.anisotropyRotation), this.#o(n.translucency), this.#o(n.toon), this.#o(n.lightMapIntensity), this.#o(n.environmentIntensity), this.#s(n.translucencyColor), this.#o(+!!n.unlit | (n.flatShading ? 2 : 0) | (n.doubleSided ? 4 : 0) | (n.vertexColors ? 8 : 0) | (n.depthWrite ? 16 : 0) | (n.depthTest ? 32 : 0) | (n.sizeAttenuation ? 64 : 0) | (n.blending === "additive" ? 128 : n.blending === "multiply" ? 1024 : 0) | (n.transparent ? 256 : 0) | (n.fog ? 512 : 0));
|
|
3920
|
+
this.#o(X(t)), this.#o(t.version), this.#o(t.drawCount ?? -1), this.#o(e.renderOrder), this.#o(+!!e.castShadow | (e.receiveShadow ? 2 : 0) | (e.sort ? 4 : 0)), "arrowBits" in e && (this.#o(e.arrowBits), this.#o(e.arrowSize)), this.#o(e.labels ? X(e.labels) : 0), this.#o(e.data && typeof e.data == "object" ? X(e.data) : 0), "instanceMatrices" in e && (this.#o(e.count), this.#o(e.version)), this.#o(X(n)), this.#s(n.color), this.#s(n.emissive), this.#o(n.emissiveIntensity), this.#o(n.opacity), this.#o(n.roughness), this.#o(n.metalness), this.#o(n.size), this.#o(n.width), this.#o(n.dash), this.#o(n.gap), this.#o(n.dashOffset), this.#o(n.alphaTest), this.#o(n.normalScale), this.#o(n.aoMapIntensity), this.#o(n.triplanar), this.#o(n.bumpScale), this.#o(n.transmission), this.#o(n.clearcoat), this.#o(n.clearcoatRoughness), this.#o(n.sheen), this.#s(n.sheenColor), this.#o(n.sheenRoughness), this.#o(n.ior), this.#o(n.specularIntensity), this.#s(n.specularColor), this.#o(n.anisotropy), this.#o(n.anisotropyRotation), this.#o(n.translucency), this.#o(n.toon), this.#o(n.lightMapIntensity), this.#o(n.environmentIntensity), this.#s(n.translucencyColor), this.#o(+!!n.unlit | (n.flatShading ? 2 : 0) | (n.doubleSided ? 4 : 0) | (n.vertexColors ? 8 : 0) | (n.depthWrite ? 16 : 0) | (n.depthTest ? 32 : 0) | (n.sizeAttenuation ? 64 : 0) | (n.blending === "additive" ? 128 : n.blending === "multiply" ? 1024 : 0) | (n.transparent ? 256 : 0) | (n.fog ? 512 : 0));
|
|
3725
3921
|
for (let [, e] of n.textures) this.#f(e);
|
|
3726
3922
|
}
|
|
3727
3923
|
#f(e) {
|
|
@@ -3733,24 +3929,24 @@ var Wn = /* @__PURE__ */ new Float32Array(16), Gn = /* @__PURE__ */ new Float32A
|
|
|
3733
3929
|
#m(e) {
|
|
3734
3930
|
this.#s(e.color), this.#o(e.intensity), e.ground && this.#s(e.ground), e.direction && this.#s(e.direction), e.target && this.#s(e.target), e.castShadow && this.#o(1), e.shadowBounds && (this.#s(e.shadowBounds.min), this.#s(e.shadowBounds.max)), "range" in e && this.#o(e.range), "angle" in e && (this.#o(e.angle), this.#o(e.penumbra));
|
|
3735
3931
|
}
|
|
3736
|
-
},
|
|
3932
|
+
}, or = [
|
|
3737
3933
|
"color",
|
|
3738
3934
|
"density",
|
|
3739
3935
|
"near",
|
|
3740
3936
|
"far"
|
|
3741
|
-
],
|
|
3937
|
+
], sr = {
|
|
3742
3938
|
start: "use 'near' for where linear fog starts",
|
|
3743
3939
|
end: "use 'far' for where linear fog is complete",
|
|
3744
3940
|
type: "give 'density' for exponential fog, or 'near' and 'far' for linear",
|
|
3745
3941
|
exp2: "give 'density' for exponential fog",
|
|
3746
3942
|
colour: "use 'color'"
|
|
3747
|
-
},
|
|
3943
|
+
}, cr = class e {
|
|
3748
3944
|
color = new H(8421504);
|
|
3749
3945
|
density = .05;
|
|
3750
3946
|
near = 0;
|
|
3751
3947
|
far = 100;
|
|
3752
3948
|
constructor(e = {}) {
|
|
3753
|
-
A("fog", e,
|
|
3949
|
+
A("fog", e, or, sr), e.color !== void 0 && this.color.set(e.color, "fog");
|
|
3754
3950
|
let t = e.near !== void 0 || e.far !== void 0;
|
|
3755
3951
|
t && e.density !== void 0 && E("fog", "give 'density' for exponential fog, or 'near' and 'far' for linear - not both"), t ? (this.density = 0, e.near !== void 0 && (this.near = M("fog", "near", e.near)), e.far !== void 0 && (this.far = M("fog", "far", e.far)), this.near >= 0 && this.far > this.near || E("fog", `'near' must be 0 or more and 'far' beyond it, got near ${this.near}, far ${this.far}`)) : e.density !== void 0 && (this.density = M("fog", "density", e.density), this.density > 0 || E("fog", `'density' must be more than 0, got ${this.density}`));
|
|
3756
3952
|
}
|
|
@@ -3771,7 +3967,7 @@ var Wn = /* @__PURE__ */ new Float32Array(16), Gn = /* @__PURE__ */ new Float32A
|
|
|
3771
3967
|
density: this.density
|
|
3772
3968
|
};
|
|
3773
3969
|
}
|
|
3774
|
-
},
|
|
3970
|
+
}, lr = class extends K {
|
|
3775
3971
|
static type = "scene";
|
|
3776
3972
|
static get OPTIONS() {
|
|
3777
3973
|
return [
|
|
@@ -3797,13 +3993,13 @@ var Wn = /* @__PURE__ */ new Float32Array(16), Gn = /* @__PURE__ */ new Float32A
|
|
|
3797
3993
|
motionReduced = !1;
|
|
3798
3994
|
#n = null;
|
|
3799
3995
|
constructor(e = {}) {
|
|
3800
|
-
super(e), e.background !== void 0 && this.#r(e.background), e.environment !== void 0 && this.#i(e.environment), e.environmentIntensity !== void 0 && (this.environmentIntensity = M("Scene", "environmentIntensity", e.environmentIntensity)), e.backgroundBlur !== void 0 && (this.backgroundBlur = M("Scene", "backgroundBlur", e.backgroundBlur)), e.fog != null && (this.#n =
|
|
3996
|
+
super(e), e.background !== void 0 && this.#r(e.background), e.environment !== void 0 && this.#i(e.environment), e.environmentIntensity !== void 0 && (this.environmentIntensity = M("Scene", "environmentIntensity", e.environmentIntensity)), e.backgroundBlur !== void 0 && (this.backgroundBlur = M("Scene", "backgroundBlur", e.backgroundBlur)), e.fog != null && (this.#n = cr.fromInput(e.fog, "Scene"));
|
|
3801
3997
|
}
|
|
3802
3998
|
get fog() {
|
|
3803
3999
|
return this.#n;
|
|
3804
4000
|
}
|
|
3805
4001
|
set fog(e) {
|
|
3806
|
-
this.#n = e == null ? null :
|
|
4002
|
+
this.#n = e == null ? null : cr.fromInput(e, "Scene");
|
|
3807
4003
|
}
|
|
3808
4004
|
get background() {
|
|
3809
4005
|
return this.#e;
|
|
@@ -3832,7 +4028,7 @@ var Wn = /* @__PURE__ */ new Float32Array(16), Gn = /* @__PURE__ */ new Float32A
|
|
|
3832
4028
|
}) : E("Scene", `'environment' must be 'studio', 'none', an .hdr url or a texture, got ${j(e)}`);
|
|
3833
4029
|
}
|
|
3834
4030
|
update(e, t) {
|
|
3835
|
-
return
|
|
4031
|
+
return ur(this, e, t, /* @__PURE__ */ new Set()), this.updateWorldTree(), this;
|
|
3836
4032
|
}
|
|
3837
4033
|
get ready() {
|
|
3838
4034
|
let e = [];
|
|
@@ -3861,24 +4057,24 @@ var Wn = /* @__PURE__ */ new Float32Array(16), Gn = /* @__PURE__ */ new Float32A
|
|
|
3861
4057
|
return this.environmentIntensity !== 1 && (e.environmentIntensity = this.environmentIntensity), this.backgroundBlur && (e.backgroundBlur = this.backgroundBlur), this.#n && (e.fog = this.#n.toJSON()), e;
|
|
3862
4058
|
}
|
|
3863
4059
|
};
|
|
3864
|
-
function
|
|
4060
|
+
function ur(e, t, n, r) {
|
|
3865
4061
|
e.hasHandlers && !r.has(e) && (r.add(e), e.runHandlers(t, n));
|
|
3866
4062
|
let i = e.children;
|
|
3867
|
-
if (i.length) for (let e of [...i])
|
|
4063
|
+
if (i.length) for (let e of [...i]) ur(e, t, n, r);
|
|
3868
4064
|
}
|
|
3869
4065
|
// src/scene/lights.js
|
|
3870
|
-
var
|
|
4066
|
+
var dr = [
|
|
3871
4067
|
...G,
|
|
3872
4068
|
"color",
|
|
3873
4069
|
"intensity"
|
|
3874
|
-
],
|
|
4070
|
+
], fr = {
|
|
3875
4071
|
distance: "use 'range' (0 = infinite)",
|
|
3876
4072
|
decay: "falloff is physical (inverse square), as in glTF - limit it with range",
|
|
3877
4073
|
attenuation: "use 'range' - falloff is physical (inverse square)",
|
|
3878
4074
|
shadow: "use 'castShadow: true' (directional, spot and point lights)"
|
|
3879
|
-
},
|
|
3880
|
-
static OPTIONS =
|
|
3881
|
-
static HINTS =
|
|
4075
|
+
}, pr = class extends K {
|
|
4076
|
+
static OPTIONS = dr;
|
|
4077
|
+
static HINTS = fr;
|
|
3882
4078
|
static kind = "ambient";
|
|
3883
4079
|
get lightKind() {
|
|
3884
4080
|
return this.constructor.kind;
|
|
@@ -3907,10 +4103,10 @@ var ir = [
|
|
|
3907
4103
|
let e = {};
|
|
3908
4104
|
return this.#e.getHex() !== 16777215 && (e.color = this.#e.getStyle()), this.intensity !== 1 && (e.intensity = this.intensity), e;
|
|
3909
4105
|
}
|
|
3910
|
-
},
|
|
4106
|
+
}, mr = class extends pr {
|
|
3911
4107
|
static type = "ambient-light";
|
|
3912
4108
|
static kind = "ambient";
|
|
3913
|
-
},
|
|
4109
|
+
}, hr = class extends pr {
|
|
3914
4110
|
static type = "hemisphere-light";
|
|
3915
4111
|
static kind = "hemisphere";
|
|
3916
4112
|
static get OPTIONS() {
|
|
@@ -3958,7 +4154,7 @@ var ir = [
|
|
|
3958
4154
|
...this.#e.getHex() === 4473924 ? {} : { ground: this.#e.getStyle() }
|
|
3959
4155
|
};
|
|
3960
4156
|
}
|
|
3961
|
-
},
|
|
4157
|
+
}, gr = class extends pr {
|
|
3962
4158
|
#e = new z(0, -1, 0);
|
|
3963
4159
|
#t = null;
|
|
3964
4160
|
get direction() {
|
|
@@ -3972,7 +4168,7 @@ var ir = [
|
|
|
3972
4168
|
return this.#t;
|
|
3973
4169
|
}
|
|
3974
4170
|
set target(e) {
|
|
3975
|
-
this.#t =
|
|
4171
|
+
this.#t = pt(this.#t, e, this.constructor.name);
|
|
3976
4172
|
}
|
|
3977
4173
|
constructor(e = {}) {
|
|
3978
4174
|
super(e);
|
|
@@ -3980,7 +4176,7 @@ var ir = [
|
|
|
3980
4176
|
e.direction !== void 0 && e.target !== void 0 && E(t, "give 'direction' or 'target', not both"), e.direction !== void 0 && (this.direction = e.direction), e.target !== void 0 && (this.target = e.target);
|
|
3981
4177
|
}
|
|
3982
4178
|
lookAt(e) {
|
|
3983
|
-
let t =
|
|
4179
|
+
let t = mt(this, e);
|
|
3984
4180
|
return this.target ? this.target.copy(t) : t.equals(this.position, 1e-9) || this.direction.copy(t.sub(this.position).normalize()), this;
|
|
3985
4181
|
}
|
|
3986
4182
|
get worldDirection() {
|
|
@@ -4003,12 +4199,12 @@ var ir = [
|
|
|
4003
4199
|
...this.target ? { target: this.target.toArray() } : { direction: this.direction.toArray() }
|
|
4004
4200
|
};
|
|
4005
4201
|
}
|
|
4006
|
-
},
|
|
4202
|
+
}, _r = class extends gr {
|
|
4007
4203
|
static type = "directional-light";
|
|
4008
4204
|
static kind = "directional";
|
|
4009
4205
|
static get OPTIONS() {
|
|
4010
4206
|
return [
|
|
4011
|
-
...
|
|
4207
|
+
...dr,
|
|
4012
4208
|
"direction",
|
|
4013
4209
|
"target",
|
|
4014
4210
|
"castShadow",
|
|
@@ -4054,12 +4250,12 @@ var ir = [
|
|
|
4054
4250
|
} } : {}
|
|
4055
4251
|
};
|
|
4056
4252
|
}
|
|
4057
|
-
},
|
|
4253
|
+
}, vr = class extends pr {
|
|
4058
4254
|
static type = "point-light";
|
|
4059
4255
|
static kind = "point";
|
|
4060
4256
|
static get OPTIONS() {
|
|
4061
4257
|
return [
|
|
4062
|
-
...
|
|
4258
|
+
...dr,
|
|
4063
4259
|
"range",
|
|
4064
4260
|
"castShadow"
|
|
4065
4261
|
];
|
|
@@ -4067,7 +4263,7 @@ var ir = [
|
|
|
4067
4263
|
range = 0;
|
|
4068
4264
|
castShadow = !1;
|
|
4069
4265
|
constructor(e = {}) {
|
|
4070
|
-
super(e), e.range !== void 0 && (this.range =
|
|
4266
|
+
super(e), e.range !== void 0 && (this.range = br(this.constructor.name, e.range)), e.castShadow !== void 0 && (this.castShadow = !!e.castShadow);
|
|
4071
4267
|
}
|
|
4072
4268
|
cloneOptions() {
|
|
4073
4269
|
return {
|
|
@@ -4083,12 +4279,12 @@ var ir = [
|
|
|
4083
4279
|
...this.castShadow ? { castShadow: !0 } : {}
|
|
4084
4280
|
};
|
|
4085
4281
|
}
|
|
4086
|
-
},
|
|
4282
|
+
}, yr = class extends gr {
|
|
4087
4283
|
static type = "spot-light";
|
|
4088
4284
|
static kind = "spot";
|
|
4089
4285
|
static get OPTIONS() {
|
|
4090
4286
|
return [
|
|
4091
|
-
...
|
|
4287
|
+
...dr,
|
|
4092
4288
|
"direction",
|
|
4093
4289
|
"target",
|
|
4094
4290
|
"range",
|
|
@@ -4102,7 +4298,7 @@ var ir = [
|
|
|
4102
4298
|
angle = Math.PI / 6;
|
|
4103
4299
|
penumbra = .1;
|
|
4104
4300
|
constructor(e = {}) {
|
|
4105
|
-
super(e), e.castShadow !== void 0 && (this.castShadow = !!e.castShadow), e.range !== void 0 && (this.range =
|
|
4301
|
+
super(e), e.castShadow !== void 0 && (this.castShadow = !!e.castShadow), e.range !== void 0 && (this.range = br("SpotLight", e.range)), e.angle !== void 0 && (this.angle = M("SpotLight", "angle", e.angle), (this.angle <= 0 || this.angle > Math.PI / 2) && E("SpotLight", `'angle' is the cone's half-angle in radians, above 0 and up to PI/2, got ${this.angle}`)), e.penumbra !== void 0 && (this.penumbra = M("SpotLight", "penumbra", e.penumbra), (this.penumbra < 0 || this.penumbra > 1) && E("SpotLight", `'penumbra' must be 0-1, got ${this.penumbra}`));
|
|
4106
4302
|
}
|
|
4107
4303
|
cloneOptions() {
|
|
4108
4304
|
return {
|
|
@@ -4118,7 +4314,7 @@ var ir = [
|
|
|
4118
4314
|
return this.range && (e.range = this.range), this.angle !== Math.PI / 6 && (e.angle = this.angle), this.penumbra !== .1 && (e.penumbra = this.penumbra), this.castShadow && (e.castShadow = !0), e;
|
|
4119
4315
|
}
|
|
4120
4316
|
};
|
|
4121
|
-
function
|
|
4317
|
+
function br(e, t) {
|
|
4122
4318
|
let n = M(e, "range", t);
|
|
4123
4319
|
return n < 0 && E(e, `'range' can't be negative (0 means unlimited), got ${n}`), n;
|
|
4124
4320
|
}
|
|
@@ -4132,12 +4328,17 @@ var Z = {
|
|
|
4132
4328
|
instanceColor: 8,
|
|
4133
4329
|
tangent: 9,
|
|
4134
4330
|
uv2: 10,
|
|
4331
|
+
pointSize: 11,
|
|
4332
|
+
pointOpacity: 12,
|
|
4333
|
+
pointAngle: 13,
|
|
4334
|
+
pointIndex: 14,
|
|
4135
4335
|
segmentStart: 0,
|
|
4136
4336
|
segmentEnd: 1,
|
|
4137
4337
|
segmentColorStart: 2,
|
|
4138
4338
|
segmentColorEnd: 3,
|
|
4139
|
-
corner: 4
|
|
4140
|
-
|
|
4339
|
+
corner: 4,
|
|
4340
|
+
segmentInfo: 5
|
|
4341
|
+
}, xr = "#ifdef CLIP\nuniform vec4 uClipPlane;\nvoid clipAway(vec3 p) {\nif (dot(uClipPlane.xyz, p) + uClipPlane.w > 0.0) discard;\n}\n#else\nvoid clipAway(vec3 p) {}\n#endif\n", Sr = "#ifdef FOG\nuniform vec3 uFogColor;\nuniform vec2 uFogRange;\nuniform float uFogDensity;\nin float vFogDepth;\nvec3 fogged(vec3 c) {\n#ifdef FOG_LINEAR\nfloat f = clamp((vFogDepth - uFogRange.x) / max(uFogRange.y - uFogRange.x, 1e-4), 0.0, 1.0);\n#else\nfloat d = uFogDensity * vFogDepth;\nfloat f = 1.0 - exp(-d * d);\n#endif\n#ifdef FOG_ADD\nreturn c * (1.0 - f);\n#elif defined(FOG_MULTIPLY)\nreturn mix(c, vec3(1.0), f);\n#else\nreturn mix(c, uFogColor, f);\n#endif\n}\n#else\nvec3 fogged(vec3 c) { return c; }\n#endif\n", Cr = [
|
|
4141
4342
|
"uMap",
|
|
4142
4343
|
"uRoughnessMap",
|
|
4143
4344
|
"uMetalnessMap",
|
|
@@ -4146,10 +4347,10 @@ var Z = {
|
|
|
4146
4347
|
"uAoMap",
|
|
4147
4348
|
"uEmissiveMap",
|
|
4148
4349
|
"uLightMap"
|
|
4149
|
-
],
|
|
4350
|
+
], wr = `#ifdef UV2
|
|
4150
4351
|
in vec2 vUv2;
|
|
4151
4352
|
#endif
|
|
4152
|
-
${
|
|
4353
|
+
${Cr.map((e) => `uniform mat3 ${e}Uv;
|
|
4153
4354
|
#ifndef ${e}Set
|
|
4154
4355
|
#define ${e}Set vUv
|
|
4155
4356
|
#endif
|
|
@@ -4175,11 +4376,11 @@ vec4 triplanar(sampler2D s, mat3 t) {
|
|
|
4175
4376
|
vec3 p = vObjectPosition * uTriplanar, w = triplanarWeights(normalize(vObjectNormal));
|
|
4176
4377
|
return texture(s, projected(p.zy, t)) * w.x + texture(s, projected(p.xz, t)) * w.y + texture(s, projected(p.xy, t)) * w.z;
|
|
4177
4378
|
}
|
|
4178
|
-
${
|
|
4379
|
+
${Cr.map((e) => `#define ${e}Texel triplanar(${e}, ${e}Uv)`).join("\n")}
|
|
4179
4380
|
#else
|
|
4180
|
-
${
|
|
4381
|
+
${Cr.map((e) => `#define ${e}Texel texture(${e}, ${e}Coord)`).join("\n")}
|
|
4181
4382
|
#endif
|
|
4182
|
-
`,
|
|
4383
|
+
`, Tr = `precision highp float;
|
|
4183
4384
|
in vec3 vWorldPosition;
|
|
4184
4385
|
out vec4 fragColor;
|
|
4185
4386
|
#ifdef ALPHA_TEST
|
|
@@ -4188,10 +4389,10 @@ uniform float uOpacity;
|
|
|
4188
4389
|
uniform float uAlphaTest;
|
|
4189
4390
|
#ifdef MAP
|
|
4190
4391
|
uniform sampler2D uMap;
|
|
4191
|
-
${
|
|
4392
|
+
${wr}
|
|
4192
4393
|
#endif
|
|
4193
4394
|
#endif
|
|
4194
|
-
${
|
|
4395
|
+
${xr}
|
|
4195
4396
|
void main() {
|
|
4196
4397
|
clipAway(vWorldPosition);
|
|
4197
4398
|
#ifdef ALPHA_TEST
|
|
@@ -4203,7 +4404,7 @@ if (alpha < uAlphaTest) discard;
|
|
|
4203
4404
|
#endif
|
|
4204
4405
|
fragColor = vec4(1.0);
|
|
4205
4406
|
}
|
|
4206
|
-
`,
|
|
4407
|
+
`, Er = "vec3 srgbToLinear(vec3 c) {\nreturn mix(c / 12.92, pow((c + 0.055) / 1.055, vec3(2.4)), step(0.04045, c));\n}\nvec3 linearToSrgb(vec3 c) {\nc = clamp(c, 0.0, 1.0);\nreturn mix(c * 12.92, 1.055 * pow(c, vec3(1.0 / 2.4)) - 0.055, step(0.0031308, c));\n}\n", Dr = "vec2 equirectUv(vec3 d) {\nreturn vec2(atan(d.z, d.x) * 0.15915494 + 0.5, acos(clamp(d.y, -1.0, 1.0)) * 0.31830989);\n}\nvec3 equirectDirection(vec2 uv) {\nfloat phi = (uv.x - 0.5) * 6.28318531, theta = uv.y * 3.14159265;\nreturn vec3(cos(phi) * sin(theta), cos(theta), sin(phi) * sin(theta));\n}\n", Or = "out vec2 vUv;\nvoid main() {\nvec2 p = vec2(float((gl_VertexID << 1) & 2), float(gl_VertexID & 2));\nvUv = p;\ngl_Position = vec4(p * 2.0 - 1.0, 0.0, 1.0);\n}\n", kr = "uniform float uExposure;\nuniform int uToneMapping;\nvec3 toneMap(vec3 c) {\nc *= uExposure;\nif (uToneMapping == 1) {\nc = clamp((c * (2.51 * c + 0.03)) / (c * (2.43 * c + 0.59) + 0.14), 0.0, 1.0);\n} else if (uToneMapping == 2) {\nfloat x = min(c.r, min(c.g, c.b));\nfloat offset = x < 0.08 ? x - 6.25 * x * x : 0.04;\nc -= offset;\nfloat peak = max(c.r, max(c.g, c.b));\nif (peak > 0.8) {\nfloat d = 0.2;\nfloat newPeak = 1.0 - d * d / (peak + d - 0.8);\nc *= newPeak / peak;\nfloat g = 1.0 - 1.0 / (0.15 * (peak - newPeak) + 1.0);\nc = mix(c, vec3(newPeak), g);\n}\n}\nreturn c;\n}\n", Ar = `layout(location = 0) in vec3 position;
|
|
4207
4408
|
layout(location = 1) in vec3 normal;
|
|
4208
4409
|
layout(location = 2) in vec2 uv;
|
|
4209
4410
|
layout(location = 3) in vec3 color;
|
|
@@ -4240,7 +4441,7 @@ out mat3 vObjectToWorld;
|
|
|
4240
4441
|
#ifdef PICK
|
|
4241
4442
|
flat out uint vPickElement;
|
|
4242
4443
|
#endif
|
|
4243
|
-
${
|
|
4444
|
+
${Er}
|
|
4244
4445
|
void main() {
|
|
4245
4446
|
vColor = vec3(1.0);
|
|
4246
4447
|
vHighlight = uHighlightIndex == -1 ? 1.0 : 0.0;
|
|
@@ -4289,7 +4490,7 @@ vFogDepth = -(uView * world).z;
|
|
|
4289
4490
|
vPickElement = uint(gl_InstanceID);
|
|
4290
4491
|
#endif
|
|
4291
4492
|
}
|
|
4292
|
-
`,
|
|
4493
|
+
`, jr = `precision highp float;
|
|
4293
4494
|
precision highp sampler2DShadow;
|
|
4294
4495
|
precision highp samplerCubeShadow;
|
|
4295
4496
|
in vec3 vWorldPosition;
|
|
@@ -4310,7 +4511,7 @@ uniform float uAlphaTest;
|
|
|
4310
4511
|
#ifdef EMISSIVE_MAP
|
|
4311
4512
|
uniform sampler2D uEmissiveMap;
|
|
4312
4513
|
#endif
|
|
4313
|
-
${
|
|
4514
|
+
${wr}
|
|
4314
4515
|
#ifdef LIT
|
|
4315
4516
|
uniform vec3 uCameraPosition;
|
|
4316
4517
|
uniform float uRoughness;
|
|
@@ -4408,10 +4609,10 @@ uniform float uPointShadowBias;
|
|
|
4408
4609
|
#endif
|
|
4409
4610
|
#endif
|
|
4410
4611
|
out vec4 fragColor;
|
|
4411
|
-
${
|
|
4412
|
-
${
|
|
4413
|
-
${hr}
|
|
4612
|
+
${Er}
|
|
4613
|
+
${xr}
|
|
4414
4614
|
${Sr}
|
|
4615
|
+
${kr}
|
|
4415
4616
|
#ifdef LIT
|
|
4416
4617
|
const float PI = 3.14159265359;
|
|
4417
4618
|
float D_GGX(float NoH, float a) {
|
|
@@ -4520,7 +4721,7 @@ vec2 ab = vec2(-1.04, 1.04) * a004 + r.zw;
|
|
|
4520
4721
|
return f0 * ab.x + ab.y * f90;
|
|
4521
4722
|
}
|
|
4522
4723
|
#ifdef ENV_MAP
|
|
4523
|
-
${
|
|
4724
|
+
${Dr}
|
|
4524
4725
|
vec3 envIrradiance(vec3 n) {
|
|
4525
4726
|
return uEnvSH[0]
|
|
4526
4727
|
+ uEnvSH[1] * n.y + uEnvSH[2] * n.z + uEnvSH[3] * n.x
|
|
@@ -4846,8 +5047,18 @@ coverage = mix(coverage, base.a, vHighlight * uHighlight.a);
|
|
|
4846
5047
|
color = fogged(color);
|
|
4847
5048
|
fragColor = vec4(linearToSrgb(color) * base.a, coverage);
|
|
4848
5049
|
}
|
|
4849
|
-
`,
|
|
5050
|
+
`, Mr = `layout(location = 0) in vec3 position;
|
|
4850
5051
|
layout(location = 3) in vec3 color;
|
|
5052
|
+
#ifdef SPRITES
|
|
5053
|
+
layout(location = 4) in vec2 corner;
|
|
5054
|
+
layout(location = 11) in float pointSize;
|
|
5055
|
+
layout(location = 12) in float pointOpacity;
|
|
5056
|
+
layout(location = 13) in float pointAngle;
|
|
5057
|
+
layout(location = 14) in float pointIndex;
|
|
5058
|
+
uniform vec2 uResolution;
|
|
5059
|
+
out vec2 vUv;
|
|
5060
|
+
out float vOpacity;
|
|
5061
|
+
#endif
|
|
4851
5062
|
uniform mat4 uModel;
|
|
4852
5063
|
uniform mat4 uView;
|
|
4853
5064
|
uniform mat4 uProjection;
|
|
@@ -4862,14 +5073,33 @@ flat out uint vPickElement;
|
|
|
4862
5073
|
#ifdef FOG
|
|
4863
5074
|
out float vFogDepth;
|
|
4864
5075
|
#endif
|
|
4865
|
-
${
|
|
5076
|
+
${Er}
|
|
4866
5077
|
void main() {
|
|
4867
5078
|
vec4 viewPosition = uView * (uModel * vec4(position, 1.0));
|
|
5079
|
+
#ifdef SPRITES
|
|
5080
|
+
vec2 c = vec2(corner.x * 2.0 - 1.0, corner.y);
|
|
5081
|
+
float s = sin(pointAngle), k = cos(pointAngle);
|
|
5082
|
+
vec2 turned = vec2(c.x * k - c.y * s, c.x * s + c.y * k);
|
|
5083
|
+
float size = uSize * pointSize;
|
|
5084
|
+
#ifdef SIZE_ATTENUATION
|
|
5085
|
+
viewPosition.xy += turned * size * 0.5;
|
|
4868
5086
|
gl_Position = uProjection * viewPosition;
|
|
5087
|
+
#else
|
|
5088
|
+
gl_Position = uProjection * viewPosition;
|
|
5089
|
+
gl_Position.xy += turned * size / uResolution * gl_Position.w;
|
|
5090
|
+
#endif
|
|
5091
|
+
vUv = vec2(c.x * 0.5 + 0.5, 0.5 - c.y * 0.5);
|
|
5092
|
+
vOpacity = pointOpacity;
|
|
5093
|
+
int self = int(pointIndex + 0.5);
|
|
5094
|
+
#else
|
|
5095
|
+
gl_Position = uProjection * viewPosition;
|
|
5096
|
+
int self = gl_VertexID;
|
|
5097
|
+
#endif
|
|
4869
5098
|
#ifdef FOG
|
|
4870
5099
|
vFogDepth = -viewPosition.z;
|
|
4871
5100
|
#endif
|
|
4872
|
-
#ifdef
|
|
5101
|
+
#ifdef SPRITES
|
|
5102
|
+
#elif defined(SIZE_ATTENUATION)
|
|
4873
5103
|
float depth = uProjection[3][3] == 1.0 ? 1.0 : max(-viewPosition.z, 1e-4);
|
|
4874
5104
|
gl_PointSize = uSize * uScale / depth;
|
|
4875
5105
|
#else
|
|
@@ -4879,14 +5109,18 @@ vColor = vec3(1.0);
|
|
|
4879
5109
|
#ifdef VERTEX_COLORS
|
|
4880
5110
|
vColor = srgbToLinear(color);
|
|
4881
5111
|
#endif
|
|
4882
|
-
vHighlight = uHighlightIndex == -1 ||
|
|
5112
|
+
vHighlight = uHighlightIndex == -1 || self == uHighlightIndex ? 1.0 : 0.0;
|
|
4883
5113
|
#ifdef PICK
|
|
4884
|
-
vPickElement = uint(
|
|
5114
|
+
vPickElement = uint(self);
|
|
4885
5115
|
#endif
|
|
4886
5116
|
}
|
|
4887
|
-
`,
|
|
5117
|
+
`, Nr = `precision highp float;
|
|
4888
5118
|
in vec3 vColor;
|
|
4889
5119
|
flat in float vHighlight;
|
|
5120
|
+
#ifdef SPRITES
|
|
5121
|
+
in vec2 vUv;
|
|
5122
|
+
in float vOpacity;
|
|
5123
|
+
#endif
|
|
4890
5124
|
uniform vec4 uHighlight;
|
|
4891
5125
|
uniform vec3 uColor;
|
|
4892
5126
|
uniform float uOpacity;
|
|
@@ -4894,14 +5128,20 @@ uniform float uOpacity;
|
|
|
4894
5128
|
uniform sampler2D uMap;
|
|
4895
5129
|
#endif
|
|
4896
5130
|
out vec4 fragColor;
|
|
4897
|
-
${
|
|
4898
|
-
${
|
|
5131
|
+
${Er}
|
|
5132
|
+
${Sr}
|
|
4899
5133
|
void main() {
|
|
5134
|
+
#ifdef SPRITES
|
|
5135
|
+
vec2 at = vUv;
|
|
5136
|
+
vec4 base = vec4(uColor * vColor, uOpacity * vOpacity);
|
|
5137
|
+
#else
|
|
5138
|
+
vec2 at = gl_PointCoord;
|
|
4900
5139
|
vec4 base = vec4(uColor * vColor, uOpacity);
|
|
5140
|
+
#endif
|
|
4901
5141
|
#ifdef MAP
|
|
4902
|
-
base *= texture(uMap,
|
|
5142
|
+
base *= texture(uMap, at);
|
|
4903
5143
|
#else
|
|
4904
|
-
vec2 p =
|
|
5144
|
+
vec2 p = at * 2.0 - 1.0;
|
|
4905
5145
|
float r = dot(p, p);
|
|
4906
5146
|
float edge = fwidth(r);
|
|
4907
5147
|
base.a *= 1.0 - smoothstep(1.0 - edge, 1.0, r);
|
|
@@ -4910,25 +5150,32 @@ if (base.a <= 0.0) discard;
|
|
|
4910
5150
|
base.rgb = fogged(mix(base.rgb, uHighlight.rgb, vHighlight * uHighlight.a));
|
|
4911
5151
|
fragColor = vec4(linearToSrgb(base.rgb) * base.a, base.a);
|
|
4912
5152
|
}
|
|
4913
|
-
`,
|
|
5153
|
+
`, Pr = `layout(location = 0) in vec3 segmentStart;
|
|
4914
5154
|
layout(location = 1) in vec3 segmentEnd;
|
|
4915
5155
|
layout(location = 2) in vec3 segmentColorStart;
|
|
4916
5156
|
layout(location = 3) in vec3 segmentColorEnd;
|
|
4917
|
-
layout(location =
|
|
5157
|
+
layout(location = 5) in vec3 segmentInfo;
|
|
4918
5158
|
uniform mat4 uModel;
|
|
4919
5159
|
uniform mat4 uView;
|
|
4920
5160
|
uniform mat4 uProjection;
|
|
4921
5161
|
uniform vec2 uResolution;
|
|
4922
5162
|
uniform float uWidth;
|
|
4923
5163
|
uniform float uNear;
|
|
5164
|
+
uniform int uArrows;
|
|
5165
|
+
uniform float uArrowSize;
|
|
5166
|
+
const vec2 QUAD[6] = vec2[6](vec2(0.0, -1.0), vec2(0.0, 1.0), vec2(1.0, -1.0), vec2(1.0, -1.0), vec2(0.0, 1.0), vec2(1.0, 1.0));
|
|
4924
5167
|
out vec3 vColor;
|
|
5168
|
+
#ifdef DASHED
|
|
5169
|
+
out float vDistance;
|
|
5170
|
+
flat out float vArrow;
|
|
5171
|
+
#endif
|
|
4925
5172
|
#ifdef PICK
|
|
4926
5173
|
flat out uint vPickElement;
|
|
4927
5174
|
#endif
|
|
4928
5175
|
#ifdef FOG
|
|
4929
5176
|
out float vFogDepth;
|
|
4930
5177
|
#endif
|
|
4931
|
-
${
|
|
5178
|
+
${Er}
|
|
4932
5179
|
void main() {
|
|
4933
5180
|
vec4 a = uView * (uModel * vec4(segmentStart, 1.0));
|
|
4934
5181
|
vec4 b = uView * (uModel * vec4(segmentEnd, 1.0));
|
|
@@ -4947,43 +5194,78 @@ vec2 dir = sb - sa;
|
|
|
4947
5194
|
float len = length(dir);
|
|
4948
5195
|
dir = len > 0.0 ? dir / len : vec2(1.0, 0.0);
|
|
4949
5196
|
vec2 normal = vec2(-dir.y, dir.x);
|
|
4950
|
-
|
|
5197
|
+
bool arrowStart = (uArrows & 1) != 0 && segmentInfo.y > 0.5;
|
|
5198
|
+
bool arrowEnd = (uArrows & 2) != 0 && segmentInfo.z > 0.5;
|
|
5199
|
+
float along, arrow = 0.0;
|
|
5200
|
+
vec2 offset;
|
|
5201
|
+
if (gl_VertexID < 6) {
|
|
5202
|
+
vec2 c = QUAD[gl_VertexID];
|
|
5203
|
+
along = c.x;
|
|
5204
|
+
float startOut = arrowStart ? -uArrowSize * 0.8 : uWidth * 0.5;
|
|
5205
|
+
float endOut = arrowEnd ? -uArrowSize * 0.8 : uWidth * 0.5;
|
|
5206
|
+
offset = normal * c.y * uWidth * 0.5 + dir * (along > 0.5 ? endOut : -startOut);
|
|
5207
|
+
} else {
|
|
5208
|
+
int which = (gl_VertexID - 6) / 3, k = gl_VertexID - 6 - which * 3;
|
|
5209
|
+
if (which == 0 ? !arrowStart : !arrowEnd) {
|
|
5210
|
+
gl_Position = vec4(2.0, 2.0, 2.0, 1.0);
|
|
5211
|
+
return;
|
|
5212
|
+
}
|
|
5213
|
+
along = float(which);
|
|
5214
|
+
vec2 d = which == 1 ? dir : -dir;
|
|
5215
|
+
float wing = uArrowSize * 0.45;
|
|
5216
|
+
offset = k == 0 ? vec2(0.0) : -d * uArrowSize + normal * (k == 1 ? wing : -wing);
|
|
5217
|
+
arrow = 1.0;
|
|
5218
|
+
}
|
|
5219
|
+
vec4 clip = mix(ca, cb, along);
|
|
4951
5220
|
#ifdef FOG
|
|
4952
|
-
vFogDepth = -mix(a.z, b.z,
|
|
5221
|
+
vFogDepth = -mix(a.z, b.z, along);
|
|
4953
5222
|
#endif
|
|
4954
|
-
vec2 offset = normal * corner.y * uWidth * 0.5 + dir * (corner.x * 2.0 - 1.0) * uWidth * 0.5;
|
|
4955
5223
|
clip.xy += offset / (uResolution * 0.5) * clip.w;
|
|
4956
5224
|
gl_Position = clip;
|
|
5225
|
+
#ifdef DASHED
|
|
5226
|
+
vDistance = segmentInfo.x + length(segmentEnd - segmentStart) * along;
|
|
5227
|
+
vArrow = arrow;
|
|
5228
|
+
#endif
|
|
4957
5229
|
#ifdef PICK
|
|
4958
5230
|
vPickElement = uint(gl_InstanceID);
|
|
4959
5231
|
#endif
|
|
4960
5232
|
vColor = vec3(1.0);
|
|
4961
5233
|
#ifdef VERTEX_COLORS
|
|
4962
|
-
vColor = srgbToLinear(mix(segmentColorStart, segmentColorEnd,
|
|
5234
|
+
vColor = srgbToLinear(mix(segmentColorStart, segmentColorEnd, along));
|
|
4963
5235
|
#endif
|
|
4964
5236
|
}
|
|
4965
|
-
`,
|
|
5237
|
+
`, Fr = `precision highp float;
|
|
4966
5238
|
in vec3 vColor;
|
|
4967
5239
|
uniform vec3 uColor;
|
|
4968
5240
|
uniform float uOpacity;
|
|
5241
|
+
#ifdef DASHED
|
|
5242
|
+
in float vDistance;
|
|
5243
|
+
flat in float vArrow;
|
|
5244
|
+
uniform float uDash;
|
|
5245
|
+
uniform float uGap;
|
|
5246
|
+
uniform float uDashOffset;
|
|
5247
|
+
#endif
|
|
4969
5248
|
out vec4 fragColor;
|
|
4970
|
-
${
|
|
4971
|
-
${
|
|
5249
|
+
${Er}
|
|
5250
|
+
${Sr}
|
|
4972
5251
|
void main() {
|
|
5252
|
+
#ifdef DASHED
|
|
5253
|
+
if (vArrow < 0.5 && mod(vDistance - uDashOffset, uDash + uGap) >= uDash) discard;
|
|
5254
|
+
#endif
|
|
4973
5255
|
vec3 color = fogged(uColor * vColor);
|
|
4974
5256
|
fragColor = vec4(linearToSrgb(color) * uOpacity, uOpacity);
|
|
4975
5257
|
}
|
|
4976
|
-
`,
|
|
4977
|
-
mesh: [
|
|
4978
|
-
points: [
|
|
4979
|
-
lines: [
|
|
5258
|
+
`, Ir = {
|
|
5259
|
+
mesh: [Ar, jr],
|
|
5260
|
+
points: [Mr, Nr],
|
|
5261
|
+
lines: [Pr, Fr]
|
|
4980
5262
|
};
|
|
4981
|
-
function
|
|
4982
|
-
let n = `#version 300 es\n${t.map((e) => `#define ${e}\n`).join("")}`, [r, i] = typeof e == "string" ?
|
|
5263
|
+
function Lr(e, t) {
|
|
5264
|
+
let n = `#version 300 es\n${t.map((e) => `#define ${e}\n`).join("")}`, [r, i] = typeof e == "string" ? Ir[e] : e;
|
|
4983
5265
|
return [n + r, n + i];
|
|
4984
5266
|
}
|
|
4985
5267
|
// src/webgl/programs.js
|
|
4986
|
-
var
|
|
5268
|
+
var Rr = class {
|
|
4987
5269
|
#e = /* @__PURE__ */ new Map();
|
|
4988
5270
|
#t;
|
|
4989
5271
|
#n = null;
|
|
@@ -5000,7 +5282,7 @@ var jr = class {
|
|
|
5000
5282
|
}
|
|
5001
5283
|
get(e, t, n) {
|
|
5002
5284
|
let r = `${e}|${t.join(",")}`, i = this.#e.get(r);
|
|
5003
|
-
return i || (i = this.#r(r,
|
|
5285
|
+
return i || (i = this.#r(r, Lr(n ?? e, t)), this.#e.set(r, i)), i;
|
|
5004
5286
|
}
|
|
5005
5287
|
ready(e, t, n) {
|
|
5006
5288
|
let r = this.get(e, t, n);
|
|
@@ -5040,18 +5322,18 @@ var jr = class {
|
|
|
5040
5322
|
#i(e) {
|
|
5041
5323
|
let t = this.gl, { program: n, key: r, shaders: i, sources: a } = e;
|
|
5042
5324
|
if (!t.getProgramParameter(n, t.LINK_STATUS) && !t.isContextLost()) throw i.forEach((e, n) => {
|
|
5043
|
-
if (!t.getShaderParameter(e, t.COMPILE_STATUS)) throw Error(`phoria2: ${n ? "fragment" : "vertex"} shader '${r}' failed to compile:\n${t.getShaderInfoLog(e)}\n${
|
|
5325
|
+
if (!t.getShaderParameter(e, t.COMPILE_STATUS)) throw Error(`phoria2: ${n ? "fragment" : "vertex"} shader '${r}' failed to compile:\n${t.getShaderInfoLog(e)}\n${Br(a[n])}`);
|
|
5044
5326
|
}), Error(`phoria2: shader program '${r}' failed to link: ${t.getProgramInfoLog(n)}`);
|
|
5045
5327
|
for (let e of i) t.deleteShader(e);
|
|
5046
5328
|
let o = /* @__PURE__ */ new Map(), s = t.getProgramParameter(n, t.ACTIVE_UNIFORMS), c = 0;
|
|
5047
5329
|
for (let e = 0; e < s; e++) {
|
|
5048
5330
|
let r = t.getActiveUniform(n, e), i = r.name.replace(/\[0\]$/, ""), a = t.getUniformLocation(n, r.name), s = r.type === t.SAMPLER_2D || r.type === t.SAMPLER_2D_SHADOW || r.type === t.SAMPLER_CUBE_SHADOW;
|
|
5049
|
-
o.set(i,
|
|
5331
|
+
o.set(i, zr(t, r.type, a, s ? c++ : 0));
|
|
5050
5332
|
}
|
|
5051
5333
|
e.set = (e, t) => o.get(e)?.(t), e.ready = !0;
|
|
5052
5334
|
}
|
|
5053
5335
|
};
|
|
5054
|
-
function
|
|
5336
|
+
function zr(e, t, n, r) {
|
|
5055
5337
|
switch (t) {
|
|
5056
5338
|
case e.FLOAT: return (t) => typeof t == "number" ? e.uniform1f(n, t) : e.uniform1fv(n, t);
|
|
5057
5339
|
case e.FLOAT_VEC2: return (t) => e.uniform2fv(n, t);
|
|
@@ -5072,8 +5354,8 @@ function Mr(e, t, n, r) {
|
|
|
5072
5354
|
default: return () => {};
|
|
5073
5355
|
}
|
|
5074
5356
|
}
|
|
5075
|
-
var
|
|
5076
|
-
function
|
|
5357
|
+
var Br = (e) => e.split("\n").map((e, t) => `${String(t + 1).padStart(4)} ${e}`).join("\n"), Vr = 15, Hr = 16, Ur = 4;
|
|
5358
|
+
function Wr(e, t, n, r) {
|
|
5077
5359
|
return [
|
|
5078
5360
|
e.positions.length,
|
|
5079
5361
|
n,
|
|
@@ -5086,7 +5368,7 @@ function Fr(e, t, n, r) {
|
|
|
5086
5368
|
r
|
|
5087
5369
|
].join();
|
|
5088
5370
|
}
|
|
5089
|
-
function
|
|
5371
|
+
function Gr(e) {
|
|
5090
5372
|
let t = e.positions, n = e.normals, r = e.uvs, i = t.length / 3, a = new Float32Array(i * 4), o = new Float32Array(i * 3), s = new Float32Array(i * 3);
|
|
5091
5373
|
if (r) {
|
|
5092
5374
|
let n = e.indices, a = (n ? n.length : i) / 3;
|
|
@@ -5116,12 +5398,12 @@ function Ir(e) {
|
|
|
5116
5398
|
}
|
|
5117
5399
|
return a;
|
|
5118
5400
|
}
|
|
5119
|
-
var
|
|
5120
|
-
function
|
|
5121
|
-
let t = Math.cos(e.rotation), n = Math.sin(e.rotation), [r, i] = e.repeat, [a, o] = e.center, s =
|
|
5401
|
+
var Kr = /* @__PURE__ */ new Float32Array(9);
|
|
5402
|
+
function qr(e) {
|
|
5403
|
+
let t = Math.cos(e.rotation), n = Math.sin(e.rotation), [r, i] = e.repeat, [a, o] = e.center, s = Kr;
|
|
5122
5404
|
return s[0] = t * r, s[1] = -n * r, s[2] = 0, s[3] = n * i, s[4] = t * i, s[5] = 0, s[6] = a - t * a - n * o + e.offset[0], s[7] = o + n * a - t * o + e.offset[1], s[8] = 1, s;
|
|
5123
5405
|
}
|
|
5124
|
-
var
|
|
5406
|
+
var Jr = new Float32Array([
|
|
5125
5407
|
0,
|
|
5126
5408
|
-1,
|
|
5127
5409
|
0,
|
|
@@ -5130,53 +5412,85 @@ var zr = new Float32Array([
|
|
|
5130
5412
|
-1,
|
|
5131
5413
|
1,
|
|
5132
5414
|
1
|
|
5133
|
-
]),
|
|
5415
|
+
]), Yr = [
|
|
5416
|
+
[
|
|
5417
|
+
Z.position,
|
|
5418
|
+
3,
|
|
5419
|
+
0
|
|
5420
|
+
],
|
|
5421
|
+
[
|
|
5422
|
+
Z.color,
|
|
5423
|
+
3,
|
|
5424
|
+
3
|
|
5425
|
+
],
|
|
5426
|
+
[
|
|
5427
|
+
Z.pointSize,
|
|
5428
|
+
1,
|
|
5429
|
+
6
|
|
5430
|
+
],
|
|
5431
|
+
[
|
|
5432
|
+
Z.pointOpacity,
|
|
5433
|
+
1,
|
|
5434
|
+
7
|
|
5435
|
+
],
|
|
5436
|
+
[
|
|
5437
|
+
Z.pointAngle,
|
|
5438
|
+
1,
|
|
5439
|
+
8
|
|
5440
|
+
],
|
|
5441
|
+
[
|
|
5442
|
+
Z.pointIndex,
|
|
5443
|
+
1,
|
|
5444
|
+
9
|
|
5445
|
+
]
|
|
5446
|
+
], Xr = 10, Zr = class {
|
|
5134
5447
|
gl;
|
|
5135
5448
|
#e = /* @__PURE__ */ new WeakMap();
|
|
5136
5449
|
#t = /* @__PURE__ */ new WeakMap();
|
|
5137
5450
|
#n = /* @__PURE__ */ new WeakMap();
|
|
5138
5451
|
#r = /* @__PURE__ */ new WeakMap();
|
|
5139
|
-
#i =
|
|
5452
|
+
#i = /* @__PURE__ */ new WeakMap();
|
|
5140
5453
|
#a = null;
|
|
5454
|
+
#o = null;
|
|
5141
5455
|
counts = {
|
|
5142
5456
|
geometries: 0,
|
|
5143
5457
|
textures: 0
|
|
5144
5458
|
};
|
|
5145
5459
|
owner = null;
|
|
5146
|
-
#
|
|
5460
|
+
#s = /* @__PURE__ */ new WeakMap();
|
|
5147
5461
|
constructor(e) {
|
|
5148
5462
|
this.gl = e;
|
|
5149
5463
|
}
|
|
5150
|
-
#
|
|
5151
|
-
#
|
|
5152
|
-
if (this.#
|
|
5464
|
+
#c;
|
|
5465
|
+
#l() {
|
|
5466
|
+
if (this.#c !== void 0) return this.#c;
|
|
5153
5467
|
let e = this.gl.getExtension("EXT_texture_filter_anisotropic");
|
|
5154
|
-
return this.#
|
|
5468
|
+
return this.#c = e ? {
|
|
5155
5469
|
ext: e,
|
|
5156
5470
|
max: this.gl.getParameter(e.MAX_TEXTURE_MAX_ANISOTROPY_EXT) || 1
|
|
5157
|
-
} : null, this.#
|
|
5471
|
+
} : null, this.#c;
|
|
5158
5472
|
}
|
|
5159
5473
|
mesh(e, t, n, r = !1) {
|
|
5160
5474
|
let i = t ?? e;
|
|
5161
|
-
this.#
|
|
5475
|
+
this.#d(i);
|
|
5162
5476
|
let a = n ? this.#e : this.#t, o = a.get(i), s = o?.geometry === e;
|
|
5163
5477
|
if (r = n && (r || s && !!o?.attributes?.tangent), o && s && o.version === e.version && (!t || o.instanceVersion === t.version) && r === !!o.attributes?.tangent) return o;
|
|
5164
|
-
let c =
|
|
5478
|
+
let c = Wr(e, t, n, r);
|
|
5165
5479
|
if (o && s && o.layout === c) {
|
|
5166
5480
|
if (o.version !== e.version) {
|
|
5167
5481
|
let t = o.attributes;
|
|
5168
|
-
this.#
|
|
5482
|
+
this.#u(t.position, e.positions), n && this.#u(t.normal, e.normals), e.uvs && this.#u(t.uv, e.uvs), e.uvs2 && this.#u(t.uv2, e.uvs2), e.colors && this.#u(t.color, e.colors), r && this.#u(t.tangent, Gr(e)), e.indices && (this.gl.bindVertexArray(o.vao), this.gl.bufferSubData(this.gl.ELEMENT_ARRAY_BUFFER, 0, e.indices), this.gl.bindVertexArray(null)), o.version = e.version;
|
|
5169
5483
|
}
|
|
5170
|
-
return t && o.instanceVersion !== t.version && (this.#
|
|
5484
|
+
return t && o.instanceVersion !== t.version && (this.#u(o.matrixBuffer, t.instanceMatrices), t.instanceColors && this.#u(o.colorBuffer, t.instanceColors), o.instanceVersion = t.version), o;
|
|
5171
5485
|
}
|
|
5172
|
-
o ? (this.#
|
|
5486
|
+
o ? (this.#m(o), s || (this.counts.geometries--, this.#p(e, i, a))) : this.#p(e, i, a);
|
|
5173
5487
|
let l = this.gl, u = l.createVertexArray();
|
|
5174
5488
|
l.bindVertexArray(u);
|
|
5175
5489
|
let d = [], f = (e, t, n, r = 0) => {
|
|
5176
5490
|
let i = l.createBuffer();
|
|
5177
5491
|
return l.bindBuffer(l.ARRAY_BUFFER, i), l.bufferData(l.ARRAY_BUFFER, t, l.STATIC_DRAW), l.enableVertexAttribArray(e), l.vertexAttribPointer(e, n, l.FLOAT, !1, 0, 0), r && l.vertexAttribDivisor(e, r), d.push(i), i;
|
|
5178
5492
|
}, p = {};
|
|
5179
|
-
p.position = f(Z.position, e.positions, 3), n && (p.normal = f(Z.normal, e.normals, 3)), e.uvs ? p.uv = f(Z.uv, e.uvs, 2) : l.vertexAttrib2f(Z.uv, 0, 0), e.uvs2 && (p.uv2 = f(Z.uv2, e.uvs2, 2)), e.colors ? p.color = f(Z.color, e.colors, 3) : l.vertexAttrib3f(Z.color, 1, 1, 1), r && (p.tangent = f(Z.tangent,
|
|
5493
|
+
p.position = f(Z.position, e.positions, 3), n && (p.normal = f(Z.normal, e.normals, 3)), e.uvs ? p.uv = f(Z.uv, e.uvs, 2) : l.vertexAttrib2f(Z.uv, 0, 0), e.uvs2 && (p.uv2 = f(Z.uv2, e.uvs2, 2)), e.colors ? p.color = f(Z.color, e.colors, 3) : l.vertexAttrib3f(Z.color, 1, 1, 1), r && (p.tangent = f(Z.tangent, Gr(e), 4));
|
|
5180
5494
|
let m = null, h = null;
|
|
5181
5495
|
if (t) {
|
|
5182
5496
|
m = l.createBuffer(), l.bindBuffer(l.ARRAY_BUFFER, m), l.bufferData(l.ARRAY_BUFFER, t.instanceMatrices, l.STATIC_DRAW);
|
|
@@ -5211,31 +5525,35 @@ var zr = new Float32Array([
|
|
|
5211
5525
|
let a = e.drawnCount - e.drawnCount % 3, o = t ? t.count : 1;
|
|
5212
5526
|
return i.indexType ? t ? r.drawElementsInstanced(r.TRIANGLES, a, i.indexType, 0, o) : r.drawElements(r.TRIANGLES, a, i.indexType, 0) : t ? r.drawArraysInstanced(r.TRIANGLES, 0, a, o) : r.drawArrays(r.TRIANGLES, 0, a), a / 3 * o;
|
|
5213
5527
|
}
|
|
5214
|
-
#
|
|
5528
|
+
#u(e, t) {
|
|
5215
5529
|
let n = this.gl;
|
|
5216
5530
|
n.bindBuffer(n.ARRAY_BUFFER, e), n.bufferSubData(n.ARRAY_BUFFER, 0, t);
|
|
5217
5531
|
}
|
|
5218
5532
|
lines(e) {
|
|
5219
|
-
this.#
|
|
5533
|
+
this.#d(e);
|
|
5220
5534
|
let t = this.#n.get(e);
|
|
5221
5535
|
if (t && t.version === e.version) return t;
|
|
5222
|
-
t ? this.#
|
|
5223
|
-
let n = this.gl, r = e.positions, i = e.colors, a = e.indices, o = e.elementCount / 2, s = new Float32Array(o * 6), c = new Float32Array(o * 6).fill(1);
|
|
5536
|
+
t ? this.#m(t) : this.#p(e, e, this.#n);
|
|
5537
|
+
let n = this.gl, r = e.positions, i = e.colors, a = e.indices, o = e.elementCount / 2, s = new Float32Array(o * 6), c = new Float32Array(o * 6).fill(1), l = new Float32Array(o * 3);
|
|
5224
5538
|
for (let e = 0; e < o; e++) {
|
|
5225
5539
|
let t = a ? a[e * 2] : e * 2, n = a ? a[e * 2 + 1] : e * 2 + 1;
|
|
5226
5540
|
for (let a = 0; a < 3; a++) s[e * 6 + a] = r[t * 3 + a], s[e * 6 + 3 + a] = r[n * 3 + a], i && (c[e * 6 + a] = i[t * 3 + a], c[e * 6 + 3 + a] = i[n * 3 + a]);
|
|
5541
|
+
let o = e * 6;
|
|
5542
|
+
e > 0 && s[o - 3] === s[o] && s[o - 2] === s[o + 1] && s[o - 1] === s[o + 2] ? (l[e * 3] = l[e * 3 - 3] + Math.hypot(s[o - 3] - s[o - 6], s[o - 2] - s[o - 5], s[o - 1] - s[o - 4]), l[e * 3 - 1] = 0) : l[e * 3 + 1] = 1, l[e * 3 + 2] = 1;
|
|
5227
5543
|
}
|
|
5228
|
-
let
|
|
5229
|
-
n.bindVertexArray(
|
|
5230
|
-
let
|
|
5544
|
+
let u = n.createVertexArray();
|
|
5545
|
+
n.bindVertexArray(u);
|
|
5546
|
+
let d = [], f = (e, t, r) => {
|
|
5231
5547
|
let i = n.createBuffer();
|
|
5232
5548
|
n.bindBuffer(n.ARRAY_BUFFER, i), n.bufferData(n.ARRAY_BUFFER, e, n.STATIC_DRAW);
|
|
5233
5549
|
for (let [e, i] of [[t, 0], [r, 12]]) n.enableVertexAttribArray(e), n.vertexAttribPointer(e, 3, n.FLOAT, !1, 24, i), n.vertexAttribDivisor(e, 1);
|
|
5234
|
-
|
|
5550
|
+
d.push(i);
|
|
5235
5551
|
};
|
|
5236
|
-
|
|
5237
|
-
|
|
5238
|
-
|
|
5552
|
+
f(s, Z.segmentStart, Z.segmentEnd), f(c, Z.segmentColorStart, Z.segmentColorEnd);
|
|
5553
|
+
let p = n.createBuffer();
|
|
5554
|
+
return n.bindBuffer(n.ARRAY_BUFFER, p), n.bufferData(n.ARRAY_BUFFER, l, n.STATIC_DRAW), n.enableVertexAttribArray(Z.segmentInfo), n.vertexAttribPointer(Z.segmentInfo, 3, n.FLOAT, !1, 0, 0), n.vertexAttribDivisor(Z.segmentInfo, 1), d.push(p), n.bindBuffer(n.ARRAY_BUFFER, this.#g()), n.enableVertexAttribArray(Z.corner), n.vertexAttribPointer(Z.corner, 2, n.FLOAT, !1, 0, 0), n.bindVertexArray(null), t = {
|
|
5555
|
+
vao: u,
|
|
5556
|
+
buffers: d,
|
|
5239
5557
|
count: o,
|
|
5240
5558
|
indexType: 0,
|
|
5241
5559
|
geometry: e,
|
|
@@ -5244,35 +5562,50 @@ var zr = new Float32Array([
|
|
|
5244
5562
|
}, this.#n.set(e, t), t;
|
|
5245
5563
|
}
|
|
5246
5564
|
texture(e) {
|
|
5247
|
-
if (!e.image) return this.#
|
|
5248
|
-
this.#
|
|
5249
|
-
let t = this.gl, n = this.#
|
|
5565
|
+
if (!e.image) return this.#h();
|
|
5566
|
+
this.#d(e);
|
|
5567
|
+
let t = this.gl, n = this.#i.get(e);
|
|
5250
5568
|
if (n && n.version === e.version) return n.texture;
|
|
5251
|
-
if (
|
|
5569
|
+
if (He(e.image) && e.image.readyState < 2) return n?.texture ?? this.#h();
|
|
5252
5570
|
n || (n = {
|
|
5253
5571
|
texture: t.createTexture(),
|
|
5254
|
-
version: -1
|
|
5255
|
-
|
|
5256
|
-
|
|
5257
|
-
|
|
5258
|
-
|
|
5259
|
-
|
|
5260
|
-
|
|
5261
|
-
|
|
5262
|
-
|
|
5572
|
+
version: -1,
|
|
5573
|
+
width: 0,
|
|
5574
|
+
height: 0,
|
|
5575
|
+
internal: 0
|
|
5576
|
+
}, this.#i.set(e, n), this.counts.textures++, e.onDispose(() => this.#f(e))), t.activeTexture(t.TEXTURE0 + Vr), t.bindTexture(t.TEXTURE_2D, n.texture), t.pixelStorei(t.UNPACK_FLIP_Y_WEBGL, e.flipY), t.pixelStorei(t.UNPACK_PREMULTIPLY_ALPHA_WEBGL, !1);
|
|
5577
|
+
let r = e.image, i = "data" in r ? r : null, a = !!i && i.data instanceof Float32Array, o = a ? t.RGBA16F : e.colorSpace === "srgb" ? t.SRGB8_ALPHA8 : t.RGBA8, s = a ? t.FLOAT : t.UNSIGNED_BYTE, [c, l] = Qr(r);
|
|
5578
|
+
if (n.version < 0 || n.width !== c || n.height !== l || n.internal !== o) i ? t.texImage2D(t.TEXTURE_2D, 0, o, c, l, 0, t.RGBA, s, i.data) : t.texImage2D(t.TEXTURE_2D, 0, o, t.RGBA, s, r), Object.assign(n, {
|
|
5579
|
+
width: c,
|
|
5580
|
+
height: l,
|
|
5581
|
+
internal: o
|
|
5582
|
+
});
|
|
5583
|
+
else {
|
|
5584
|
+
let a = e.flipY ? null : e.changedSince(n.version);
|
|
5585
|
+
a && a.length > Hr && (a = $r(a, c, l));
|
|
5586
|
+
for (let e of a ?? [{
|
|
5587
|
+
x: 0,
|
|
5588
|
+
y: 0,
|
|
5589
|
+
width: c,
|
|
5590
|
+
height: l
|
|
5591
|
+
}]) {
|
|
5592
|
+
let n = Math.max(0, e.x), a = Math.max(0, e.y), o = Math.min(c, e.x + e.width) - n, u = Math.min(l, e.y + e.height) - a;
|
|
5593
|
+
o > 0 && u > 0 && (t.pixelStorei(t.UNPACK_SKIP_PIXELS, n), t.pixelStorei(t.UNPACK_SKIP_ROWS, a), i && t.pixelStorei(t.UNPACK_ROW_LENGTH, c), t.texSubImage2D(t.TEXTURE_2D, 0, n, a, o, u, t.RGBA, s, i ? i.data : r));
|
|
5594
|
+
}
|
|
5595
|
+
t.pixelStorei(t.UNPACK_SKIP_PIXELS, 0), t.pixelStorei(t.UNPACK_SKIP_ROWS, 0), t.pixelStorei(t.UNPACK_ROW_LENGTH, 0);
|
|
5263
5596
|
}
|
|
5264
|
-
let
|
|
5597
|
+
let u = {
|
|
5265
5598
|
repeat: t.REPEAT,
|
|
5266
5599
|
clamp: t.CLAMP_TO_EDGE,
|
|
5267
5600
|
mirror: t.MIRRORED_REPEAT
|
|
5268
5601
|
}[e.wrap];
|
|
5269
|
-
t.texParameteri(t.TEXTURE_2D, t.TEXTURE_WRAP_S,
|
|
5270
|
-
let
|
|
5271
|
-
if (t.texParameteri(t.TEXTURE_2D, t.TEXTURE_MAG_FILTER,
|
|
5272
|
-
t.generateMipmap(t.TEXTURE_2D), t.texParameteri(t.TEXTURE_2D, t.TEXTURE_MIN_FILTER,
|
|
5273
|
-
let n = this.#
|
|
5274
|
-
n && !
|
|
5275
|
-
} else t.texParameteri(t.TEXTURE_2D, t.TEXTURE_MIN_FILTER,
|
|
5602
|
+
t.texParameteri(t.TEXTURE_2D, t.TEXTURE_WRAP_S, u), t.texParameteri(t.TEXTURE_2D, t.TEXTURE_WRAP_T, u);
|
|
5603
|
+
let d = e.filter === "nearest";
|
|
5604
|
+
if (t.texParameteri(t.TEXTURE_2D, t.TEXTURE_MAG_FILTER, d ? t.NEAREST : t.LINEAR), e.mipmaps) {
|
|
5605
|
+
t.generateMipmap(t.TEXTURE_2D), t.texParameteri(t.TEXTURE_2D, t.TEXTURE_MIN_FILTER, d ? t.NEAREST_MIPMAP_NEAREST : t.LINEAR_MIPMAP_LINEAR);
|
|
5606
|
+
let n = this.#l();
|
|
5607
|
+
n && !d && t.texParameterf(t.TEXTURE_2D, n.ext.TEXTURE_MAX_ANISOTROPY_EXT, Math.min(e.anisotropy, n.max));
|
|
5608
|
+
} else t.texParameteri(t.TEXTURE_2D, t.TEXTURE_MIN_FILTER, d ? t.NEAREST : t.LINEAR);
|
|
5276
5609
|
return n.version = e.version, n.texture;
|
|
5277
5610
|
}
|
|
5278
5611
|
release(e, t) {
|
|
@@ -5285,63 +5618,128 @@ var zr = new Float32Array([
|
|
|
5285
5618
|
}
|
|
5286
5619
|
});
|
|
5287
5620
|
for (let t of n) {
|
|
5288
|
-
let n = this.#
|
|
5621
|
+
let n = this.#s.get(t);
|
|
5289
5622
|
if (n?.delete(e) && !n.size) {
|
|
5290
|
-
this.#
|
|
5623
|
+
this.#s.delete(t);
|
|
5291
5624
|
for (let e of [
|
|
5292
5625
|
this.#e,
|
|
5293
5626
|
this.#t,
|
|
5294
|
-
this.#n
|
|
5627
|
+
this.#n,
|
|
5628
|
+
this.#r
|
|
5295
5629
|
]) {
|
|
5296
5630
|
let n = e.get(t);
|
|
5297
|
-
n && (this.#
|
|
5631
|
+
n && (this.#m(n), e.delete(t), this.counts.geometries--);
|
|
5298
5632
|
}
|
|
5299
|
-
this.#
|
|
5633
|
+
this.#f(t);
|
|
5300
5634
|
}
|
|
5301
5635
|
}
|
|
5302
5636
|
}
|
|
5303
|
-
#
|
|
5637
|
+
#d(e) {
|
|
5304
5638
|
if (!this.owner) return;
|
|
5305
|
-
let t = this.#
|
|
5306
|
-
t || this.#
|
|
5639
|
+
let t = this.#s.get(e);
|
|
5640
|
+
t || this.#s.set(e, t = /* @__PURE__ */ new Set()), t.add(this.owner);
|
|
5641
|
+
}
|
|
5642
|
+
sprites(e, t) {
|
|
5643
|
+
this.#d(e);
|
|
5644
|
+
let n = this.gl, r = this.#r.get(e), i = !!t;
|
|
5645
|
+
if (r && r.version === e.version && !i && (t === void 0 || !r.sorted)) return r;
|
|
5646
|
+
let a = e.drawnVertices, o = e.vertexCount;
|
|
5647
|
+
if (!r || r.capacity < o) {
|
|
5648
|
+
r ? this.#m(r) : this.#p(e, e, this.#r);
|
|
5649
|
+
let t = n.createVertexArray();
|
|
5650
|
+
n.bindVertexArray(t);
|
|
5651
|
+
let i = n.createBuffer();
|
|
5652
|
+
n.bindBuffer(n.ARRAY_BUFFER, i), n.bufferData(n.ARRAY_BUFFER, o * Xr * 4, n.DYNAMIC_DRAW);
|
|
5653
|
+
for (let [e, t, r] of Yr) n.enableVertexAttribArray(e), n.vertexAttribPointer(e, t, n.FLOAT, !1, 40, r * 4), n.vertexAttribDivisor(e, 1);
|
|
5654
|
+
n.bindBuffer(n.ARRAY_BUFFER, this.#g()), n.enableVertexAttribArray(Z.corner), n.vertexAttribPointer(Z.corner, 2, n.FLOAT, !1, 0, 0), n.bindVertexArray(null), r = {
|
|
5655
|
+
vao: t,
|
|
5656
|
+
buffers: [i],
|
|
5657
|
+
count: 0,
|
|
5658
|
+
indexType: 0,
|
|
5659
|
+
geometry: e,
|
|
5660
|
+
version: -1,
|
|
5661
|
+
instanceVersion: 0,
|
|
5662
|
+
capacity: o,
|
|
5663
|
+
sorted: !1,
|
|
5664
|
+
data: new Float32Array(o * Xr)
|
|
5665
|
+
}, this.#r.set(e, r);
|
|
5666
|
+
}
|
|
5667
|
+
let s = i ? ei(e.positions, a, t) : null, c = e.positions, l = e.colors, u = e.sizes, d = e.opacities, f = e.angles, p = r.data;
|
|
5668
|
+
for (let e = 0; e < a; e++) {
|
|
5669
|
+
let t = s ? s[e] : e, n = e * Xr;
|
|
5670
|
+
p[n] = c[t * 3], p[n + 1] = c[t * 3 + 1], p[n + 2] = c[t * 3 + 2], p[n + 3] = l ? l[t * 3] : 1, p[n + 4] = l ? l[t * 3 + 1] : 1, p[n + 5] = l ? l[t * 3 + 2] : 1, p[n + 6] = u ? u[t] : 1, p[n + 7] = d ? d[t] : 1, p[n + 8] = f ? f[t] : 0, p[n + 9] = t;
|
|
5671
|
+
}
|
|
5672
|
+
return n.bindBuffer(n.ARRAY_BUFFER, r.buffers[0]), n.bufferSubData(n.ARRAY_BUFFER, 0, p, 0, a * Xr), Object.assign(r, {
|
|
5673
|
+
count: a,
|
|
5674
|
+
version: e.version,
|
|
5675
|
+
sorted: i
|
|
5676
|
+
}), r;
|
|
5307
5677
|
}
|
|
5308
|
-
#
|
|
5309
|
-
let t = this.#
|
|
5310
|
-
t && (this.gl.deleteTexture(t.texture), this.#
|
|
5678
|
+
#f(e) {
|
|
5679
|
+
let t = this.#i.get(e);
|
|
5680
|
+
t && (this.gl.deleteTexture(t.texture), this.#i.delete(e), this.counts.textures--);
|
|
5311
5681
|
}
|
|
5312
5682
|
reset() {
|
|
5313
|
-
this.#e = /* @__PURE__ */ new WeakMap(), this.#t = /* @__PURE__ */ new WeakMap(), this.#n = /* @__PURE__ */ new WeakMap(), this.#r = /* @__PURE__ */ new WeakMap(), this.#
|
|
5683
|
+
this.#e = /* @__PURE__ */ new WeakMap(), this.#t = /* @__PURE__ */ new WeakMap(), this.#n = /* @__PURE__ */ new WeakMap(), this.#r = /* @__PURE__ */ new WeakMap(), this.#i = /* @__PURE__ */ new WeakMap(), this.#s = /* @__PURE__ */ new WeakMap(), this.#a = null, this.#o = null, this.#c = void 0, this.counts = {
|
|
5314
5684
|
geometries: 0,
|
|
5315
5685
|
textures: 0
|
|
5316
5686
|
};
|
|
5317
5687
|
}
|
|
5318
|
-
#
|
|
5688
|
+
#p(e, t, n) {
|
|
5319
5689
|
this.counts.geometries++, e.onDispose(() => {
|
|
5320
5690
|
let r = n.get(t);
|
|
5321
|
-
r && r.geometry === e && (this.#
|
|
5691
|
+
r && r.geometry === e && (this.#m(r), n.delete(t), this.counts.geometries--);
|
|
5322
5692
|
});
|
|
5323
5693
|
}
|
|
5324
|
-
#
|
|
5694
|
+
#m(e) {
|
|
5325
5695
|
let t = this.gl;
|
|
5326
5696
|
t.deleteVertexArray(e.vao);
|
|
5327
5697
|
for (let n of e.buffers) t.deleteBuffer(n);
|
|
5328
5698
|
}
|
|
5329
|
-
#
|
|
5330
|
-
if (this.#
|
|
5699
|
+
#h() {
|
|
5700
|
+
if (this.#a) return this.#a;
|
|
5331
5701
|
let e = this.gl;
|
|
5332
|
-
return this.#
|
|
5702
|
+
return this.#a = e.createTexture(), e.activeTexture(e.TEXTURE0 + Vr), e.bindTexture(e.TEXTURE_2D, this.#a), e.texImage2D(e.TEXTURE_2D, 0, e.RGBA8, 1, 1, 0, e.RGBA, e.UNSIGNED_BYTE, new Uint8Array([
|
|
5333
5703
|
255,
|
|
5334
5704
|
255,
|
|
5335
5705
|
255,
|
|
5336
5706
|
255
|
|
5337
|
-
])), this.#
|
|
5707
|
+
])), this.#a;
|
|
5338
5708
|
}
|
|
5339
|
-
#
|
|
5340
|
-
if (this.#
|
|
5709
|
+
#g() {
|
|
5710
|
+
if (this.#o) return this.#o;
|
|
5341
5711
|
let e = this.gl;
|
|
5342
|
-
return this.#
|
|
5712
|
+
return this.#o = e.createBuffer(), e.bindBuffer(e.ARRAY_BUFFER, this.#o), e.bufferData(e.ARRAY_BUFFER, Jr, e.STATIC_DRAW), this.#o;
|
|
5713
|
+
}
|
|
5714
|
+
};
|
|
5715
|
+
function Qr(e) {
|
|
5716
|
+
return He(e) ? [e.videoWidth, e.videoHeight] : "naturalWidth" in e ? [e.naturalWidth, e.naturalHeight] : [e.width, e.height];
|
|
5717
|
+
}
|
|
5718
|
+
function $r(e, t, n) {
|
|
5719
|
+
let r = /* @__PURE__ */ new Map();
|
|
5720
|
+
for (let i of e) {
|
|
5721
|
+
let e = Math.min(3, Math.max(0, Math.floor((i.x + i.width / 2) / t * Ur))), a = Math.min(3, Math.max(0, Math.floor((i.y + i.height / 2) / n * Ur))) * Ur + e, o = r.get(a);
|
|
5722
|
+
o ? (o[0] = Math.min(o[0], i.x), o[1] = Math.min(o[1], i.y), o[2] = Math.max(o[2], i.x + i.width), o[3] = Math.max(o[3], i.y + i.height)) : r.set(a, [
|
|
5723
|
+
i.x,
|
|
5724
|
+
i.y,
|
|
5725
|
+
i.x + i.width,
|
|
5726
|
+
i.y + i.height
|
|
5727
|
+
]);
|
|
5343
5728
|
}
|
|
5344
|
-
|
|
5729
|
+
return [...r.values()].map(([e, t, n, r]) => ({
|
|
5730
|
+
x: e,
|
|
5731
|
+
y: t,
|
|
5732
|
+
width: n - e,
|
|
5733
|
+
height: r - t
|
|
5734
|
+
}));
|
|
5735
|
+
}
|
|
5736
|
+
function ei(e, t, n) {
|
|
5737
|
+
let r = new Float32Array(t), i = new Uint32Array(t);
|
|
5738
|
+
for (let a = 0; a < t; a++) r[a] = n[2] * e[a * 3] + n[6] * e[a * 3 + 1] + n[10] * e[a * 3 + 2] + n[14], i[a] = a;
|
|
5739
|
+
return i.sort((e, t) => r[e] - r[t]);
|
|
5740
|
+
}
|
|
5741
|
+
// src/webgl/context.js
|
|
5742
|
+
var ti = null, ni = class e {
|
|
5345
5743
|
canvas;
|
|
5346
5744
|
gl;
|
|
5347
5745
|
programs;
|
|
@@ -5360,8 +5758,8 @@ var zr = new Float32Array([
|
|
|
5360
5758
|
#i;
|
|
5361
5759
|
constructor(e, { antialias: t = !0, shared: n = !1 } = {}) {
|
|
5362
5760
|
this.canvas = e, this.isShared = n;
|
|
5363
|
-
let r =
|
|
5364
|
-
r && (clearTimeout(r.timer),
|
|
5761
|
+
let r = ri.get(e);
|
|
5762
|
+
r && (clearTimeout(r.timer), ri.delete(e));
|
|
5365
5763
|
let i = e.getContext("webgl2", {
|
|
5366
5764
|
antialias: t,
|
|
5367
5765
|
alpha: !0,
|
|
@@ -5369,7 +5767,7 @@ var zr = new Float32Array([
|
|
|
5369
5767
|
stencil: !0,
|
|
5370
5768
|
powerPreference: "high-performance"
|
|
5371
5769
|
});
|
|
5372
|
-
i || E("WebGLRenderer", "WebGL 2 is not available in this browser or on this device"), this.gl = i, this.programs = new
|
|
5770
|
+
i || E("WebGLRenderer", "WebGL 2 is not available in this browser or on this device"), this.gl = i, this.programs = new Rr(this.gl), this.resources = new Zr(this.gl);
|
|
5373
5771
|
let a = (e) => {
|
|
5374
5772
|
e.preventDefault(), this.lost = !0;
|
|
5375
5773
|
}, o = () => {
|
|
@@ -5381,11 +5779,11 @@ var zr = new Float32Array([
|
|
|
5381
5779
|
}, r && i.isContextLost() && (this.lost = !0, r.lose?.restoreContext());
|
|
5382
5780
|
}
|
|
5383
5781
|
static shared() {
|
|
5384
|
-
if (!
|
|
5782
|
+
if (!ti) {
|
|
5385
5783
|
let t = typeof document < "u" ? document.createElement("canvas") : new OffscreenCanvas(1, 1);
|
|
5386
|
-
|
|
5784
|
+
ti = new e(t, { shared: !0 });
|
|
5387
5785
|
}
|
|
5388
|
-
return
|
|
5786
|
+
return ti;
|
|
5389
5787
|
}
|
|
5390
5788
|
fit(e, t) {
|
|
5391
5789
|
let n = this.canvas;
|
|
@@ -5426,12 +5824,12 @@ var zr = new Float32Array([
|
|
|
5426
5824
|
if (this.users.delete(e), t && this.resources.release(e, t), this.users.size) return;
|
|
5427
5825
|
this.programs.dispose(), this.resources.reset(), this.passes?.reset(), this.bloom?.dispose(), this.#i();
|
|
5428
5826
|
let n = this.gl.getExtension("WEBGL_lose_context");
|
|
5429
|
-
this ===
|
|
5827
|
+
this === ti ? (n?.loseContext(), ti = null) : ri.set(this.canvas, {
|
|
5430
5828
|
lose: n,
|
|
5431
5829
|
timer: setTimeout(() => n?.loseContext())
|
|
5432
5830
|
});
|
|
5433
5831
|
}
|
|
5434
|
-
},
|
|
5832
|
+
}, ri = /* @__PURE__ */ new WeakMap(), ii = [
|
|
5435
5833
|
"canvas",
|
|
5436
5834
|
"shared",
|
|
5437
5835
|
"antialias",
|
|
@@ -5440,40 +5838,40 @@ var zr = new Float32Array([
|
|
|
5440
5838
|
"exposure",
|
|
5441
5839
|
"pixelRatio",
|
|
5442
5840
|
"bloom"
|
|
5443
|
-
],
|
|
5841
|
+
], ai = {
|
|
5444
5842
|
strength: 1,
|
|
5445
5843
|
radius: .6,
|
|
5446
5844
|
threshold: .6
|
|
5447
|
-
},
|
|
5845
|
+
}, oi = Object.keys(ai), si = {
|
|
5448
5846
|
intensity: "use 'strength'",
|
|
5449
5847
|
amount: "use 'strength'",
|
|
5450
5848
|
size: "use 'radius'",
|
|
5451
5849
|
blur: "use 'radius'"
|
|
5452
|
-
},
|
|
5453
|
-
function
|
|
5850
|
+
}, ci = { alpha: "the canvas is always transparent where the scene has no background" };
|
|
5851
|
+
function li(e, t) {
|
|
5454
5852
|
if (t == null || t === !1) return null;
|
|
5455
|
-
if (t === !0) return { ...
|
|
5456
|
-
typeof t != "object" && E(e, `bloom is true, false or { strength, radius, threshold }, got ${j(t)}`), A(`${e} bloom`, t,
|
|
5457
|
-
let n = { ...
|
|
5458
|
-
for (let r of Object.keys(
|
|
5853
|
+
if (t === !0) return { ...ai };
|
|
5854
|
+
typeof t != "object" && E(e, `bloom is true, false or { strength, radius, threshold }, got ${j(t)}`), A(`${e} bloom`, t, oi, si);
|
|
5855
|
+
let n = { ...ai };
|
|
5856
|
+
for (let r of Object.keys(ai)) t[r] !== void 0 && (n[r] = M(`${e} bloom`, r, t[r]));
|
|
5459
5857
|
return n;
|
|
5460
5858
|
}
|
|
5461
|
-
var
|
|
5859
|
+
var ui = {
|
|
5462
5860
|
none: 0,
|
|
5463
5861
|
aces: 1,
|
|
5464
5862
|
neutral: 2
|
|
5465
|
-
},
|
|
5863
|
+
}, di = [], fi = {
|
|
5466
5864
|
roughnessMap: "ROUGHNESS_MAP",
|
|
5467
5865
|
metalnessMap: "METALNESS_MAP",
|
|
5468
5866
|
normalMap: "NORMAL_MAP",
|
|
5469
5867
|
bumpMap: "BUMP_MAP",
|
|
5470
5868
|
aoMap: "AO_MAP",
|
|
5471
5869
|
lightMap: "LIGHT_MAP"
|
|
5472
|
-
},
|
|
5870
|
+
}, pi = [
|
|
5473
5871
|
"map",
|
|
5474
5872
|
"emissiveMap",
|
|
5475
|
-
...Object.keys(
|
|
5476
|
-
],
|
|
5873
|
+
...Object.keys(fi)
|
|
5874
|
+
], mi = {
|
|
5477
5875
|
matcap: "uMatcap",
|
|
5478
5876
|
map: "uMap",
|
|
5479
5877
|
roughnessMap: "uRoughnessMap",
|
|
@@ -5483,7 +5881,7 @@ var Xr = {
|
|
|
5483
5881
|
aoMap: "uAoMap",
|
|
5484
5882
|
emissiveMap: "uEmissiveMap",
|
|
5485
5883
|
lightMap: "uLightMap"
|
|
5486
|
-
},
|
|
5884
|
+
}, hi = [Ar, Tr], gi = new U({
|
|
5487
5885
|
positions: [
|
|
5488
5886
|
-1,
|
|
5489
5887
|
0,
|
|
@@ -5530,14 +5928,14 @@ var Xr = {
|
|
|
5530
5928
|
3,
|
|
5531
5929
|
2
|
|
5532
5930
|
]
|
|
5533
|
-
}),
|
|
5931
|
+
}), _i = {
|
|
5534
5932
|
drawMode: "triangles",
|
|
5535
5933
|
receiveShadow: !0,
|
|
5536
5934
|
castShadow: !1,
|
|
5537
5935
|
renderOrder: 0
|
|
5538
|
-
},
|
|
5539
|
-
static OPTIONS =
|
|
5540
|
-
static HINTS =
|
|
5936
|
+
}, vi = class {
|
|
5937
|
+
static OPTIONS = ii;
|
|
5938
|
+
static HINTS = ci;
|
|
5541
5939
|
canvas;
|
|
5542
5940
|
toneMapping = "neutral";
|
|
5543
5941
|
exposure = 1;
|
|
@@ -5558,28 +5956,29 @@ var Xr = {
|
|
|
5558
5956
|
#r = null;
|
|
5559
5957
|
#i = [];
|
|
5560
5958
|
#a = /* @__PURE__ */ new Float32Array(9);
|
|
5561
|
-
#o =
|
|
5562
|
-
#s =
|
|
5563
|
-
#c =
|
|
5564
|
-
#l =
|
|
5565
|
-
#u =
|
|
5959
|
+
#o = /* @__PURE__ */ new Float32Array(16);
|
|
5960
|
+
#s = {};
|
|
5961
|
+
#c = !1;
|
|
5962
|
+
#l = [];
|
|
5963
|
+
#u = !1;
|
|
5964
|
+
#d = /* @__PURE__ */ new Map();
|
|
5566
5965
|
constructor(e) {
|
|
5567
|
-
if (A("WebGLRenderer", e,
|
|
5966
|
+
if (A("WebGLRenderer", e, ii, ci), e?.canvas || E("WebGLRenderer", "'canvas' is required"), this.canvas = e.canvas, e.toneMapping !== void 0 && (this.toneMapping = P("WebGLRenderer", "toneMapping", e.toneMapping, [
|
|
5568
5967
|
"aces",
|
|
5569
5968
|
"neutral",
|
|
5570
5969
|
"none"
|
|
5571
|
-
])), e.exposure !== void 0 && (this.exposure = N("WebGLRenderer", "exposure", e.exposure, 0)), e.pixelRatio !== void 0 && (this.pixelRatio = N("WebGLRenderer", "pixelRatio", e.pixelRatio, 0, Infinity, { above: !0 })), this.#e =
|
|
5572
|
-
this.#t =
|
|
5970
|
+
])), e.exposure !== void 0 && (this.exposure = N("WebGLRenderer", "exposure", e.exposure, 0)), e.pixelRatio !== void 0 && (this.pixelRatio = N("WebGLRenderer", "pixelRatio", e.pixelRatio, 0, Infinity, { above: !0 })), this.#e = li("WebGLRenderer", e.bloom), this.outlineAntialias = e.outlineAntialias === void 0 ? e.shared || e.antialias !== !1 : !!e.outlineAntialias, e.shared) {
|
|
5971
|
+
this.#t = ni.shared();
|
|
5573
5972
|
let e = this.canvas.getContext("2d");
|
|
5574
5973
|
e || E("WebGLRenderer", "a shared renderer's canvas needs a 2D context - give it a canvas that has no WebGL context yet"), this.#n = e;
|
|
5575
|
-
} else this.#t = new
|
|
5974
|
+
} else this.#t = new ni(this.canvas, { antialias: e.antialias });
|
|
5576
5975
|
this.#t.users.add(this);
|
|
5577
5976
|
}
|
|
5578
5977
|
get bloom() {
|
|
5579
5978
|
return this.#e;
|
|
5580
5979
|
}
|
|
5581
5980
|
set bloom(e) {
|
|
5582
|
-
this.#e =
|
|
5981
|
+
this.#e = li("WebGLRenderer", e);
|
|
5583
5982
|
}
|
|
5584
5983
|
get gl() {
|
|
5585
5984
|
return this.#t.gl;
|
|
@@ -5591,13 +5990,13 @@ var Xr = {
|
|
|
5591
5990
|
this.pixelRatio = n, this.canvas.width = Math.max(1, Math.round(e * n)), this.canvas.height = Math.max(1, Math.round(t * n));
|
|
5592
5991
|
}
|
|
5593
5992
|
render(e, t) {
|
|
5594
|
-
return e.updateWorldTree(), this.renderFrame(
|
|
5993
|
+
return e.updateWorldTree(), this.renderFrame(Bt(e, t));
|
|
5595
5994
|
}
|
|
5596
5995
|
renderFrame(e, { wait: t = !1 } = {}) {
|
|
5597
5996
|
let n = this.#t;
|
|
5598
5997
|
if (n.lost) return e;
|
|
5599
5998
|
let r = n.gl;
|
|
5600
|
-
n.frame++, n.resources.owner = this, this.#
|
|
5999
|
+
n.frame++, n.resources.owner = this, this.#c = t, this.info.drawCalls = 0, this.info.triangles = 0, this.info.compiling = 0;
|
|
5601
6000
|
let i = this.canvas.width, a = this.canvas.height;
|
|
5602
6001
|
n.isShared && n.fit(i, a);
|
|
5603
6002
|
let o = e.environment, s = e.background, c = n.loadPasses(!!e.shadow || e.spotShadows.length > 0 || !!e.pointShadow || e.outlines.length > 0 || typeof o == "object" && !!o.image || !!s && !("getHex" in s) && !!s.image);
|
|
@@ -5613,12 +6012,12 @@ var Xr = {
|
|
|
5613
6012
|
} else r.clearColor(0, 0, 0, 0);
|
|
5614
6013
|
r.depthMask(!0), r.enable(r.SCISSOR_TEST), r.scissor(0, 0, i, a), r.clear(r.COLOR_BUFFER_BIT | r.DEPTH_BUFFER_BIT), r.disable(r.SCISSOR_TEST), c && s && !("getHex" in s) && s.image && c.background(e, s, {
|
|
5615
6014
|
exposure: this.exposure,
|
|
5616
|
-
toneMapping:
|
|
5617
|
-
}), r.enable(r.DEPTH_TEST), r.depthFunc(r.LEQUAL), this.#
|
|
5618
|
-
for (let t of e.opaque) this.#
|
|
5619
|
-
for (let t of e.caps) this.#
|
|
6015
|
+
toneMapping: ui[this.toneMapping]
|
|
6016
|
+
}), r.enable(r.DEPTH_TEST), r.depthFunc(r.LEQUAL), this.#f(e), r.disable(r.BLEND);
|
|
6017
|
+
for (let t of e.opaque) this.#p(t, e, !1);
|
|
6018
|
+
for (let t of e.caps) this.#m(t, e, i, a);
|
|
5620
6019
|
r.enable(r.BLEND);
|
|
5621
|
-
for (let t of e.transparent) this.#
|
|
6020
|
+
for (let t of e.transparent) this.#p(t, e, !0);
|
|
5622
6021
|
if (l && c && c.outlineComposite(l), r.depthMask(!0), r.disable(r.BLEND), r.bindVertexArray(null), u && this.#e && u.end(this.#e), this.info.compiling && n.whenCompiled(), this.#n) {
|
|
5623
6022
|
let e = this.#n, t = n.canvas;
|
|
5624
6023
|
e.globalCompositeOperation = "copy", e.drawImage(t, 0, t.height - a, i, a, 0, 0, i, a);
|
|
@@ -5646,7 +6045,7 @@ var Xr = {
|
|
|
5646
6045
|
dispose(e) {
|
|
5647
6046
|
this.#t.release(this, e);
|
|
5648
6047
|
}
|
|
5649
|
-
#
|
|
6048
|
+
#f(e) {
|
|
5650
6049
|
let t = [
|
|
5651
6050
|
0,
|
|
5652
6051
|
0,
|
|
@@ -5679,7 +6078,7 @@ var Xr = {
|
|
|
5679
6078
|
p[t * 2] = Math.cos(e), p[t * 2 + 1] = Math.cos(e * (1 - (i.penumbra ?? 0)));
|
|
5680
6079
|
} else p[t * 2] = -2, p[t * 2 + 1] = -1;
|
|
5681
6080
|
}
|
|
5682
|
-
this.#
|
|
6081
|
+
this.#l = [`NUM_DIRECTIONAL ${m}`, `NUM_PUNCTUAL ${h}`], this.#u = e.environment === "studio", this.#s = {
|
|
5683
6082
|
uAmbient: t,
|
|
5684
6083
|
uHemisphereSky: n,
|
|
5685
6084
|
uHemisphereGround: r,
|
|
@@ -5694,99 +6093,110 @@ var Xr = {
|
|
|
5694
6093
|
uPointShadowIndex: g
|
|
5695
6094
|
};
|
|
5696
6095
|
}
|
|
5697
|
-
#
|
|
5698
|
-
let r = this.gl, { node: i, geometry: a, material:
|
|
5699
|
-
|
|
5700
|
-
let
|
|
5701
|
-
|
|
5702
|
-
|
|
5703
|
-
|
|
5704
|
-
|
|
6096
|
+
#p(e, t, n) {
|
|
6097
|
+
let r = this.gl, { node: i, geometry: a, material: c, worldMatrix: l, instances: u } = e, d = i.drawMode, f = d === "points" ? "points" : d === "lines" ? "lines" : "mesh", p = f === "mesh" && i.receiveShadow && !c.unlit ? this.#i : di, m = f === "mesh" ? e.clip : null, h = this.#g(f, c, a.colors !== null, !!u, a.uvs2 !== null);
|
|
6098
|
+
f === "points" && i.drawsSprites && h.push("SPRITES");
|
|
6099
|
+
for (let e of p) h.push(e.define);
|
|
6100
|
+
let g = c.fog ? t.fog : null;
|
|
6101
|
+
g && (h.push("FOG"), g.linear && h.push("FOG_LINEAR"), c.blending === "additive" ? h.push("FOG_ADD") : c.blending === "multiply" && h.push("FOG_MULTIPLY")), m && h.push("CLIP");
|
|
6102
|
+
let _ = this.#t.programs, v = _.get(f, h);
|
|
6103
|
+
if (!_.isReady(v)) {
|
|
6104
|
+
if (!this.#c) {
|
|
5705
6105
|
this.info.compiling++;
|
|
5706
6106
|
return;
|
|
5707
6107
|
}
|
|
5708
|
-
|
|
6108
|
+
_.ready(f, h);
|
|
5709
6109
|
}
|
|
5710
|
-
if (r.useProgram(
|
|
5711
|
-
for (let [e, t] of Object.entries(this.#
|
|
6110
|
+
if (r.useProgram(v.program), v.frame !== this.#t.frame && (v.frame = this.#t.frame, v.set("uView", t.camera.view), v.set("uProjection", t.camera.projection), v.set("uViewProjection", t.camera.viewProjection), v.set("uCameraPosition", t.camera.position), v.set("uExposure", this.exposure), v.set("uToneMapping", ui[this.toneMapping]), v.set("uResolution", [this.canvas.width, this.canvas.height]), v.set("uNear", t.camera.near), v.set("uScale", t.camera.projection[5] * this.canvas.height / 2), f === "mesh" && !c.unlit)) {
|
|
6111
|
+
for (let [e, t] of Object.entries(this.#s)) v.set(e, t);
|
|
5712
6112
|
let e = this.#r;
|
|
5713
|
-
e && (
|
|
5714
|
-
for (let e of
|
|
6113
|
+
e && (v.set("uEnvMaxLod", e.maxLod), v.set("uEnvSH", e.sh), v.set("uEnvIntensity", t.environmentIntensity));
|
|
6114
|
+
for (let e of p) for (let [t, n] of Object.entries(e.uniforms)) v.set(t, n);
|
|
5715
6115
|
}
|
|
5716
|
-
if (
|
|
5717
|
-
this.#r &&
|
|
5718
|
-
for (let e of
|
|
6116
|
+
if (f === "mesh" && !c.unlit) {
|
|
6117
|
+
this.#r && v.set("uEnvMap", this.#r.prefiltered);
|
|
6118
|
+
for (let e of p) v.set(e.sampler, e.texture);
|
|
5719
6119
|
}
|
|
5720
|
-
|
|
5721
|
-
let
|
|
5722
|
-
|
|
5723
|
-
|
|
5724
|
-
|
|
5725
|
-
|
|
5726
|
-
|
|
5727
|
-
])) :
|
|
5728
|
-
let
|
|
5729
|
-
|
|
5730
|
-
|
|
5731
|
-
|
|
5732
|
-
|
|
5733
|
-
]),
|
|
5734
|
-
let
|
|
5735
|
-
if (
|
|
5736
|
-
Math.min(
|
|
5737
|
-
Math.min(
|
|
5738
|
-
Math.min(
|
|
5739
|
-
|
|
5740
|
-
]),
|
|
5741
|
-
let e =
|
|
5742
|
-
|
|
6120
|
+
v.set("uModel", l);
|
|
6121
|
+
let y = t.highlight;
|
|
6122
|
+
y && (y.nodes ? y.nodes.has(i) : y.node === i) ? (v.set("uHighlightIndex", y.index ?? -1), v.set("uHighlight", [
|
|
6123
|
+
y.color[0],
|
|
6124
|
+
y.color[1],
|
|
6125
|
+
y.color[2],
|
|
6126
|
+
y.amount
|
|
6127
|
+
])) : v.set("uHighlightIndex", -2), v.set("uColor", c.color), v.set("uOpacity", c.opacity), g && (v.set("uFogColor", g.color), v.set("uFogRange", [g.near, g.far]), v.set("uFogDensity", g.density)), m && v.set("uClipPlane", m.plane);
|
|
6128
|
+
let b = c.emissive, x = c.emissiveIntensity;
|
|
6129
|
+
v.set("uEmissive", [
|
|
6130
|
+
b[0] * x,
|
|
6131
|
+
b[1] * x,
|
|
6132
|
+
b[2] * x
|
|
6133
|
+
]), v.set("uRoughness", c.roughness), v.set("uMetalness", c.metalness), v.set("uNormalScale", c.normalScale), c.bumpMap && v.set("uBumpScale", c.bumpScale), c.triplanar > 0 && v.set("uTriplanar", c.triplanar), v.set("uAoMapIntensity", c.aoMapIntensity), c.transmission > 0 && v.set("uTransmission", c.transmission), c.clearcoat > 0 && (v.set("uClearcoat", c.clearcoat), v.set("uClearcoatRoughness", c.clearcoatRoughness));
|
|
6134
|
+
let S = (c.ior - 1) / (c.ior + 1), C = c.specularColor, w = c.specularIntensity;
|
|
6135
|
+
if (v.set("uSpecular", [
|
|
6136
|
+
Math.min(S * S * C[0], 1) * w,
|
|
6137
|
+
Math.min(S * S * C[1], 1) * w,
|
|
6138
|
+
Math.min(S * S * C[2], 1) * w,
|
|
6139
|
+
w
|
|
6140
|
+
]), c.sheen > 0) {
|
|
6141
|
+
let e = c.sheenColor, t = c.sheen;
|
|
6142
|
+
v.set("uSheenColor", [
|
|
5743
6143
|
e[0] * t,
|
|
5744
6144
|
e[1] * t,
|
|
5745
6145
|
e[2] * t
|
|
5746
|
-
]),
|
|
6146
|
+
]), v.set("uSheenRoughness", c.sheenRoughness);
|
|
5747
6147
|
}
|
|
5748
|
-
if (
|
|
5749
|
-
let e =
|
|
5750
|
-
|
|
6148
|
+
if (c.anisotropy > 0 && (v.set("uAnisotropy", c.anisotropy), v.set("uAnisotropyDirection", [Math.cos(c.anisotropyRotation), Math.sin(c.anisotropyRotation)])), c.translucency > 0) {
|
|
6149
|
+
let e = c.translucencyColor, t = c.translucency;
|
|
6150
|
+
v.set("uTranslucency", [
|
|
5751
6151
|
e[0] * t,
|
|
5752
6152
|
e[1] * t,
|
|
5753
6153
|
e[2] * t,
|
|
5754
6154
|
t
|
|
5755
6155
|
]);
|
|
5756
6156
|
}
|
|
5757
|
-
|
|
5758
|
-
let
|
|
5759
|
-
for (let [e, t] of
|
|
5760
|
-
for (let [e, t] of
|
|
5761
|
-
if (
|
|
5762
|
-
r.disable(r.CULL_FACE),
|
|
5763
|
-
let e =
|
|
5764
|
-
|
|
5765
|
-
|
|
5766
|
-
r.
|
|
5767
|
-
|
|
5768
|
-
r.
|
|
5769
|
-
|
|
5770
|
-
|
|
5771
|
-
|
|
5772
|
-
|
|
6157
|
+
c.toon > 0 && v.set("uToon", Math.max(2, Math.round(c.toon))), v.set("uAlphaTest", c.alphaTest);
|
|
6158
|
+
let T = f === "mesh" ? c.textures : c.map ? [["map", c.map]] : [], E = T.map(([e, t]) => [mi[e], this.#t.resources.texture(t)]);
|
|
6159
|
+
for (let [e, t] of E) v.set(e, t);
|
|
6160
|
+
for (let [e, t] of T) e !== "matcap" && v.set(`${mi[e]}Uv`, qr(t));
|
|
6161
|
+
if (c.lightMap && v.set("uLightMapIntensity", c.lightMapIntensity), v.set("uEnvStrength", c.environmentIntensity), r.depthMask(!n && c.depthWrite), c.depthTest ? r.enable(r.DEPTH_TEST) : r.disable(r.DEPTH_TEST), n && (c.blending === "additive" ? r.blendFunc(r.ONE, r.ONE) : c.blending === "multiply" ? r.blendFunc(r.DST_COLOR, r.ONE_MINUS_SRC_ALPHA) : r.blendFunc(r.ONE, r.ONE_MINUS_SRC_ALPHA)), f === "lines") {
|
|
6162
|
+
r.disable(r.CULL_FACE), v.set("uWidth", c.width * this.pixelRatio);
|
|
6163
|
+
let e = i.arrowBits ?? 0;
|
|
6164
|
+
v.set("uArrows", e), v.set("uArrowSize", i.arrowPixels?.(c.width) * this.pixelRatio || 0), c.dash > 0 && (v.set("uDash", c.dash), v.set("uGap", c.gap || c.dash), v.set("uDashOffset", c.dashOffset));
|
|
6165
|
+
let t = this.#t.resources.lines(a);
|
|
6166
|
+
r.bindVertexArray(t.vao), r.drawArraysInstanced(r.TRIANGLES, 0, e ? 12 : 6, Math.min(t.count, Math.floor(a.drawnCount / 2))), this.info.drawCalls++;
|
|
6167
|
+
} else if (f === "points") {
|
|
6168
|
+
r.disable(r.CULL_FACE), v.set("uSize", c.sizeAttenuation ? c.size : c.size * this.pixelRatio);
|
|
6169
|
+
let e = !n && !c.map;
|
|
6170
|
+
if (e && (r.enable(r.BLEND), r.blendFunc(r.ONE, r.ONE_MINUS_SRC_ALPHA)), i.drawsSprites) {
|
|
6171
|
+
v.set("uResolution", [this.canvas.width, this.canvas.height]);
|
|
6172
|
+
let e = i.sort ? s(this.#o, t.camera.view, l) : null, n = this.#t.resources.sprites(a, e);
|
|
6173
|
+
r.bindVertexArray(n.vao), r.drawArraysInstanced(r.TRIANGLE_STRIP, 0, 4, n.count);
|
|
6174
|
+
} else {
|
|
6175
|
+
let e = this.#t.resources.mesh(a, null, !1);
|
|
6176
|
+
r.bindVertexArray(e.vao), r.drawArrays(r.POINTS, 0, a.drawnVertices);
|
|
6177
|
+
}
|
|
6178
|
+
e && r.disable(r.BLEND), this.info.drawCalls++;
|
|
6179
|
+
} else ot(this.#a, l) || at(this.#a), v.set("uNormalMatrix", this.#a), r.frontFace(o(l) < 0 ? r.CW : r.CCW), c.doubleSided ? r.disable(r.CULL_FACE) : (r.enable(r.CULL_FACE), r.cullFace(r.BACK)), r.enable(r.POLYGON_OFFSET_FILL), r.polygonOffset(1, 2), this.info.triangles += this.#t.resources.drawTriangles(a, u, c.anisotropy > 0 && !c.unlit), r.disable(r.POLYGON_OFFSET_FILL), this.info.drawCalls++;
|
|
6180
|
+
}
|
|
6181
|
+
#m(e, t, n, r) {
|
|
6182
|
+
let i = this.gl, a = this.#t.programs, s = [!1, !0].map((e) => a.get("clip-mask", e ? ["INSTANCED", "CLIP"] : ["CLIP"], hi));
|
|
5773
6183
|
if (!s.every((e) => a.isReady(e))) {
|
|
5774
|
-
if (!this.#
|
|
6184
|
+
if (!this.#c) {
|
|
5775
6185
|
this.info.compiling++;
|
|
5776
6186
|
return;
|
|
5777
6187
|
}
|
|
5778
|
-
for (let e of [!1, !0]) a.ready("clip-mask", e ? ["INSTANCED", "CLIP"] : ["CLIP"],
|
|
6188
|
+
for (let e of [!1, !0]) a.ready("clip-mask", e ? ["INSTANCED", "CLIP"] : ["CLIP"], hi);
|
|
5779
6189
|
}
|
|
5780
6190
|
i.enable(i.STENCIL_TEST), i.enable(i.SCISSOR_TEST), i.scissor(0, 0, n, r), i.clearStencil(0), i.clear(i.STENCIL_BUFFER_BIT), i.disable(i.SCISSOR_TEST), i.colorMask(!1, !1, !1, !1), i.depthMask(!1), i.disable(i.DEPTH_TEST), i.disable(i.CULL_FACE), i.stencilFunc(i.ALWAYS, 0, 255), i.stencilOpSeparate(i.BACK, i.KEEP, i.KEEP, i.INCR_WRAP), i.stencilOpSeparate(i.FRONT, i.KEEP, i.KEEP, i.DECR_WRAP);
|
|
5781
6191
|
for (let n of e.items) {
|
|
5782
6192
|
let r = s[+!!n.instances];
|
|
5783
6193
|
i.useProgram(r.program), r.set("uViewProjection", t.camera.viewProjection), r.set("uModel", n.worldMatrix), r.set("uClipPlane", e.plane), i.frontFace(o(n.worldMatrix) < 0 ? i.CW : i.CCW), this.#t.resources.drawTriangles(n.geometry, n.instances), this.info.drawCalls++;
|
|
5784
6194
|
}
|
|
5785
|
-
i.colorMask(!0, !0, !0, !0), i.stencilFunc(i.NOTEQUAL, 0, 255), i.stencilOp(i.KEEP, i.KEEP, i.KEEP), this.#
|
|
6195
|
+
i.colorMask(!0, !0, !0, !0), i.stencilFunc(i.NOTEQUAL, 0, 255), i.stencilOp(i.KEEP, i.KEEP, i.KEEP), this.#p(this.#h(e), t, !1), i.disable(i.STENCIL_TEST);
|
|
5786
6196
|
}
|
|
5787
|
-
#
|
|
5788
|
-
let t = e.color.getHex(), n = this.#
|
|
5789
|
-
n || this.#
|
|
6197
|
+
#h(e) {
|
|
6198
|
+
let t = e.color.getHex(), n = this.#d.get(t);
|
|
6199
|
+
n || this.#d.set(t, n = new et({
|
|
5790
6200
|
color: e.color.getStyle(),
|
|
5791
6201
|
roughness: .6
|
|
5792
6202
|
}));
|
|
@@ -5819,8 +6229,8 @@ var Xr = {
|
|
|
5819
6229
|
1
|
|
5820
6230
|
]);
|
|
5821
6231
|
return {
|
|
5822
|
-
node:
|
|
5823
|
-
geometry:
|
|
6232
|
+
node: _i,
|
|
6233
|
+
geometry: gi,
|
|
5824
6234
|
material: n,
|
|
5825
6235
|
worldMatrix: g,
|
|
5826
6236
|
instances: null,
|
|
@@ -5828,21 +6238,21 @@ var Xr = {
|
|
|
5828
6238
|
clip: null
|
|
5829
6239
|
};
|
|
5830
6240
|
}
|
|
5831
|
-
#
|
|
6241
|
+
#g(e, t, n, r, i) {
|
|
5832
6242
|
let a = [];
|
|
5833
6243
|
if (t.vertexColors && n && a.push("VERTEX_COLORS"), e === "mesh") {
|
|
5834
6244
|
if (!t.unlit) {
|
|
5835
6245
|
a.push("LIT");
|
|
5836
|
-
for (let [e, n] of Object.entries(
|
|
5837
|
-
a.push(...this.#
|
|
6246
|
+
for (let [e, n] of Object.entries(fi)) t[e] && a.push(n);
|
|
6247
|
+
a.push(...this.#l), this.#r ? a.push("ENV_MAP") : this.#u && a.push("STUDIO"), t.transmission > 0 && a.push("TRANSMISSION"), t.clearcoat > 0 && a.push("CLEARCOAT"), t.sheen > 0 && a.push("SHEEN"), t.anisotropy > 0 && a.push("ANISOTROPY"), t.translucency > 0 && a.push("TRANSLUCENCY"), t.matcap && a.push("MATCAP"), t.toon > 0 && a.push("TOON");
|
|
5838
6248
|
}
|
|
5839
|
-
t.map && a.push("MAP"), t.emissiveMap && a.push("EMISSIVE_MAP"), t.alphaTest > 0 && a.push("ALPHA_TEST"), t.flatShading && a.push("FLAT_SHADING"), t.doubleSided && a.push("DOUBLE_SIDED"), t.triplanar > 0 &&
|
|
6249
|
+
t.map && a.push("MAP"), t.emissiveMap && a.push("EMISSIVE_MAP"), t.alphaTest > 0 && a.push("ALPHA_TEST"), t.flatShading && a.push("FLAT_SHADING"), t.doubleSided && a.push("DOUBLE_SIDED"), t.triplanar > 0 && pi.some((e) => t[e]) && a.push("TRIPLANAR");
|
|
5840
6250
|
let e = i ? t.textures.filter(([e, t]) => t.uvSet === 1 && e !== "matcap") : [];
|
|
5841
|
-
e.length && a.push("UV2", ...e.map(([e]) => `${
|
|
5842
|
-
} else e === "points"
|
|
6251
|
+
e.length && a.push("UV2", ...e.map(([e]) => `${mi[e]}Set vUv2`)), r && a.push("INSTANCED");
|
|
6252
|
+
} else e === "points" ? (t.map && a.push("MAP"), t.sizeAttenuation && a.push("SIZE_ATTENUATION")) : t.dash > 0 && a.push("DASHED");
|
|
5843
6253
|
return a;
|
|
5844
6254
|
}
|
|
5845
|
-
},
|
|
6255
|
+
}, yi = [
|
|
5846
6256
|
"canvas",
|
|
5847
6257
|
"scene",
|
|
5848
6258
|
"camera",
|
|
@@ -5864,7 +6274,7 @@ var Xr = {
|
|
|
5864
6274
|
"reducedMotion",
|
|
5865
6275
|
"keyboard",
|
|
5866
6276
|
"description"
|
|
5867
|
-
],
|
|
6277
|
+
], bi = ["keep", "aspect"], xi = {
|
|
5868
6278
|
renderer: "the View makes its renderer - read it from view.renderer",
|
|
5869
6279
|
controls: "use orbit: true (or orbit options); the control is then view.controls",
|
|
5870
6280
|
container: "use canvas: an element or selector (a full-window canvas is made when omitted)",
|
|
@@ -5874,7 +6284,7 @@ var Xr = {
|
|
|
5874
6284
|
keep: "use framing: { keep: 'width' | 'height' | 'both' }",
|
|
5875
6285
|
fit: "use framing: { keep: 'both' } to keep everything framed in view as the canvas changes shape",
|
|
5876
6286
|
aspect: "the canvas sets the aspect; framing: { aspect } says which shape the camera was set up for"
|
|
5877
|
-
},
|
|
6287
|
+
}, Si = {
|
|
5878
6288
|
mouseover: "hover",
|
|
5879
6289
|
mouseenter: "hover",
|
|
5880
6290
|
mousemove: "hover",
|
|
@@ -5888,10 +6298,10 @@ var Xr = {
|
|
|
5888
6298
|
select: "click",
|
|
5889
6299
|
pointerdown: "click",
|
|
5890
6300
|
mousedown: "click"
|
|
5891
|
-
},
|
|
5892
|
-
static OPTIONS =
|
|
5893
|
-
static HINTS =
|
|
5894
|
-
static FRAMING_OPTIONS =
|
|
6301
|
+
}, Ci = .45, wi = H.fromInput("#ffcc00"), Ti = 4, Ei = 5e3, Di = 0, Oi = class {
|
|
6302
|
+
static OPTIONS = yi;
|
|
6303
|
+
static HINTS = xi;
|
|
6304
|
+
static FRAMING_OPTIONS = bi;
|
|
5895
6305
|
canvas;
|
|
5896
6306
|
scene;
|
|
5897
6307
|
#e;
|
|
@@ -5920,7 +6330,7 @@ var Xr = {
|
|
|
5920
6330
|
#g = "height";
|
|
5921
6331
|
#_ = 0;
|
|
5922
6332
|
#v = 1;
|
|
5923
|
-
#y = new
|
|
6333
|
+
#y = new ar();
|
|
5924
6334
|
#b = [];
|
|
5925
6335
|
#x;
|
|
5926
6336
|
#S = null;
|
|
@@ -5949,12 +6359,12 @@ var Xr = {
|
|
|
5949
6359
|
#H = null;
|
|
5950
6360
|
#U = null;
|
|
5951
6361
|
#W = null;
|
|
5952
|
-
#G = new
|
|
6362
|
+
#G = new hr({
|
|
5953
6363
|
sky: "#ffffff",
|
|
5954
6364
|
ground: "#444444",
|
|
5955
6365
|
intensity: .5
|
|
5956
6366
|
});
|
|
5957
|
-
#K = new
|
|
6367
|
+
#K = new _r({
|
|
5958
6368
|
direction: [
|
|
5959
6369
|
-.5,
|
|
5960
6370
|
-1,
|
|
@@ -5964,7 +6374,7 @@ var Xr = {
|
|
|
5964
6374
|
});
|
|
5965
6375
|
#q = !1;
|
|
5966
6376
|
constructor(e = {}) {
|
|
5967
|
-
A("View", e,
|
|
6377
|
+
A("View", e, yi, xi), this.canvas = Vi(e.canvas), this.#a = e.canvas === void 0, e.scene === void 0 ? this.scene = new lr() : e.scene instanceof lr ? this.scene = e.scene : E("View", `'scene' must be a Scene${e.scene && typeof e.scene == "object" && "type" in e.scene ? " - build one from a description with create({ type: 'scene', ... })" : `, got ${j(e.scene)}`}`), e.background !== void 0 && (this.scene.background = e.background), e.camera instanceof wn ? this.#e = e.camera : typeof e.camera == "string" ? (this.#e = An(e.camera), this.#m = !0) : e.camera === void 0 ? (this.#e = An("perspective"), this.#m = !0) : this.#e = new Tn({
|
|
5968
6378
|
position: [
|
|
5969
6379
|
0,
|
|
5970
6380
|
1.5,
|
|
@@ -5976,15 +6386,15 @@ var Xr = {
|
|
|
5976
6386
|
0
|
|
5977
6387
|
],
|
|
5978
6388
|
...e.camera
|
|
5979
|
-
}), this.#m && (this.#h =
|
|
6389
|
+
}), this.#m && (this.#h = ki(this.#e));
|
|
5980
6390
|
let t = e.context === void 0 ? "auto" : P("View", "context", e.context, [
|
|
5981
6391
|
"auto",
|
|
5982
6392
|
"own",
|
|
5983
6393
|
"shared"
|
|
5984
6394
|
]);
|
|
5985
6395
|
e.exposure !== void 0 && N("View", "exposure", e.exposure, 0);
|
|
5986
|
-
let n = t === "shared" || t === "auto" &&
|
|
5987
|
-
if (this.renderer = new
|
|
6396
|
+
let n = t === "shared" || t === "auto" && Di >= Ti;
|
|
6397
|
+
if (this.renderer = new vi({
|
|
5988
6398
|
canvas: this.canvas,
|
|
5989
6399
|
shared: n,
|
|
5990
6400
|
antialias: e.antialias,
|
|
@@ -5992,7 +6402,7 @@ var Xr = {
|
|
|
5992
6402
|
toneMapping: e.toneMapping,
|
|
5993
6403
|
exposure: e.exposure,
|
|
5994
6404
|
bloom: e.bloom
|
|
5995
|
-
}), n || (this.#i = !0,
|
|
6405
|
+
}), n || (this.#i = !0, Di++), this.renderer.onReady = () => {
|
|
5996
6406
|
this.#I = !0, this.invalidate();
|
|
5997
6407
|
}, e.autoLight !== void 0 && (this.autoLight = !!e.autoLight), e.reducedMotion !== void 0 && this.#Y(e.reducedMotion), e.maxDelta !== void 0 && (this.maxDelta = N("View", "maxDelta", e.maxDelta, 0, Infinity, { above: !0 })), e.renderMode !== void 0 && (this.renderMode = P("View", "renderMode", e.renderMode, [
|
|
5998
6408
|
"auto",
|
|
@@ -6000,17 +6410,17 @@ var Xr = {
|
|
|
6000
6410
|
"manual"
|
|
6001
6411
|
])), e.pixelRatio !== void 0 && (this.#f = N("View", "pixelRatio", e.pixelRatio, 0, Infinity, { above: !0 }), this.#p = !0), e.orbit !== void 0 && e.orbit !== !1 && e.orbit !== !0 && (typeof e.orbit != "object" || Array.isArray(e.orbit) || e.orbit === null) && E("View", `'orbit' must be true, false or orbit options such as { autoRotate: true }, got ${j(e.orbit)}`), e.orbit) {
|
|
6002
6412
|
let t = e.orbit === !0 ? {} : e.orbit, n = t.mode ?? (e.camera === "top" ? "map" : void 0);
|
|
6003
|
-
this.controls = new
|
|
6413
|
+
this.controls = new _n(this.camera, this.canvas, n ? {
|
|
6004
6414
|
...t,
|
|
6005
6415
|
mode: n
|
|
6006
6416
|
} : t), this.#B = this.controls.handOverPointer();
|
|
6007
6417
|
}
|
|
6008
|
-
if (e.highlight !== void 0 && this.#J(e.highlight), e.tooltip !== void 0 && this.tooltip(e.tooltip), e.description !== void 0 && (this.description = e.description), e.keyboard !== void 0 && e.keyboard !== !1 && this.#ae(e.keyboard), this.#x = new
|
|
6009
|
-
interactive: (e) =>
|
|
6418
|
+
if (e.highlight !== void 0 && this.#J(e.highlight), e.tooltip !== void 0 && this.tooltip(e.tooltip), e.description !== void 0 && (this.description = e.description), e.keyboard !== void 0 && e.keyboard !== !1 && this.#ae(e.keyboard), this.#x = new dn(this.canvas, {
|
|
6419
|
+
interactive: (e) => zi(e, "click").length > 0 || zi(e, "hover").length > 0,
|
|
6010
6420
|
on: (e, t, n) => this.#me(e, t, n)
|
|
6011
6421
|
}), e.framing !== void 0) {
|
|
6012
6422
|
let t = typeof e.framing == "string" ? { keep: e.framing } : e.framing;
|
|
6013
|
-
A("View", t,
|
|
6423
|
+
A("View", t, bi, {}, "framing"), t.keep !== void 0 && (this.#g = P("View", "framing.keep", t.keep, [
|
|
6014
6424
|
"height",
|
|
6015
6425
|
"width",
|
|
6016
6426
|
"both"
|
|
@@ -6024,12 +6434,12 @@ var Xr = {
|
|
|
6024
6434
|
set camera(e) {
|
|
6025
6435
|
if (typeof e == "string") {
|
|
6026
6436
|
let t = this.#e, n = t.target ?? new z();
|
|
6027
|
-
e =
|
|
6437
|
+
e = An(e, {
|
|
6028
6438
|
target: n,
|
|
6029
6439
|
distance: Math.max(.001, t.position.distanceTo(n))
|
|
6030
6440
|
}), this.#m = !0;
|
|
6031
6441
|
} else this.#m = !1;
|
|
6032
|
-
e instanceof
|
|
6442
|
+
e instanceof wn || E("View", `'camera' must be a camera or a preset name, got ${j(e)}`), this.#U = null, this.#e = e, this.#d && (e.aspect = this.#u / this.#d), this.#_ = e.aspect, this.#v = 1, this.controls && (e.target ??= this.controls.target.clone(), this.controls.camera = e), this.#m && (this.#h = ki(e)), this.invalidate();
|
|
6033
6443
|
}
|
|
6034
6444
|
get bloom() {
|
|
6035
6445
|
return this.renderer.bloom;
|
|
@@ -6099,8 +6509,8 @@ var Xr = {
|
|
|
6099
6509
|
#X(e) {
|
|
6100
6510
|
if (this.#U) return this.#$(e);
|
|
6101
6511
|
if (!this.controls) return;
|
|
6102
|
-
let t = this.#m &&
|
|
6103
|
-
this.controls.update(e, this.reducedMotion), t && (this.#h =
|
|
6512
|
+
let t = this.#m && Ai(ki(this.camera), this.#h);
|
|
6513
|
+
this.controls.update(e, this.reducedMotion), t && (this.#h = ki(this.camera));
|
|
6104
6514
|
}
|
|
6105
6515
|
render() {
|
|
6106
6516
|
return this.#Z(!1);
|
|
@@ -6109,10 +6519,10 @@ var Xr = {
|
|
|
6109
6519
|
if (this.#m) {
|
|
6110
6520
|
this.resize();
|
|
6111
6521
|
let e = this.scene.bounds;
|
|
6112
|
-
|
|
6522
|
+
Ai(ki(this.camera), this.#h) ? e.isEmpty() || this.frame(this.scene) : this.#m = !1;
|
|
6113
6523
|
}
|
|
6114
6524
|
this.scene.updateWorldTree();
|
|
6115
|
-
let t =
|
|
6525
|
+
let t = Bt(this.scene, this.camera);
|
|
6116
6526
|
return this.autoLight && t.lights.length === 0 && this.#xe(t), t.highlight = this.#ge(this.#H), this.#_e(t), this.renderer.renderFrame(t, { wait: e }), this.#S = this.#x.update(t.labels, t.overlays), t.tooltips && !this.#w && this.#ie(), this.lastFrame = t, this.#c = !1, this.renderMode === "auto" && this.#y.changed(this.scene, this.camera), (this.#F || this.#j) && this.#de() && (this.#I = !0), t;
|
|
6117
6527
|
}
|
|
6118
6528
|
resize() {
|
|
@@ -6124,20 +6534,20 @@ var Xr = {
|
|
|
6124
6534
|
}
|
|
6125
6535
|
let n = e || this.canvas.width || 1, r = t || this.canvas.height || 1;
|
|
6126
6536
|
this.#p || (this.#f = Math.min(globalThis.devicePixelRatio || 1, 2)), this.#u = n, this.#d = r, this.renderer.setSize(n, r, this.#f), this.camera.aspect = n / r;
|
|
6127
|
-
let i = this.#m &&
|
|
6128
|
-
this.#ce(), i && (this.#h =
|
|
6537
|
+
let i = this.#m && Ai(ki(this.camera), this.#h);
|
|
6538
|
+
this.#ce(), i && (this.#h = ki(this.camera)), this.#c = !0;
|
|
6129
6539
|
}
|
|
6130
6540
|
frame(e = this.scene, { padding: t = .2, direction: n, duration: r = 0 } = {}) {
|
|
6131
6541
|
N("View", "frame() duration", r, 0);
|
|
6132
|
-
let i = this.camera, a =
|
|
6542
|
+
let i = this.camera, a = Fi(i);
|
|
6133
6543
|
this.#U = null;
|
|
6134
6544
|
let o = this.#Q("frame", e, t, n);
|
|
6135
|
-
return this.#m = !1, o && (
|
|
6545
|
+
return this.#m = !1, o && (Ii(i, o.place), i.near = o.near ?? i.near, i.far = Math.max(i.far, o.far), this.#_ = i.aspect, this.#v = 1, r > 0 && !this.reducedMotion && (this.#U = {
|
|
6136
6546
|
from: a,
|
|
6137
|
-
to:
|
|
6547
|
+
to: Fi(i),
|
|
6138
6548
|
time: 0,
|
|
6139
6549
|
duration: r
|
|
6140
|
-
},
|
|
6550
|
+
}, Ii(i, a)), this.invalidate()), this;
|
|
6141
6551
|
}
|
|
6142
6552
|
framing(e = this.scene, { padding: t = .2, direction: n } = {}) {
|
|
6143
6553
|
let r = this.#Q("framing", e, t, n);
|
|
@@ -6154,11 +6564,11 @@ var Xr = {
|
|
|
6154
6564
|
}
|
|
6155
6565
|
#Q(e, t, n, r) {
|
|
6156
6566
|
n >= 0 || E("View", `${e}() padding is the margin around, as a fraction of the size (0.2 = 20%), got ${j(n)}`), n >= 1 && F(this, `${e}() padding ${n} leaves a margin of ${Math.round(n * 100)}% - it is a fraction of the size (0.2 = 20%)`);
|
|
6157
|
-
let i = this.camera, a = r === void 0 ? i.position.clone().sub(i.target ?? new z()).normalize() : typeof r == "string" ?
|
|
6567
|
+
let i = this.camera, a = r === void 0 ? i.position.clone().sub(i.target ?? new z()).normalize() : typeof r == "string" ? jn(r) : z.fromInput(r, "View").normalize();
|
|
6158
6568
|
r !== void 0 && !(a.len() > 0) && E("View", `${e}() direction is a preset name or a vector from the target towards the camera, got ${j(r)}`), a.len() === 0 && a.set(0, .3, 1).normalize();
|
|
6159
|
-
let o = t instanceof V ?
|
|
6569
|
+
let o = t instanceof V ? ji(t) : this.#ee(t, a);
|
|
6160
6570
|
if (!o.length) return null;
|
|
6161
|
-
let s = i.constructor.type === "orthographic-camera", { center: c, size: l } =
|
|
6571
|
+
let s = i.constructor.type === "orthographic-camera", { center: c, size: l } = Nn(o, a, {
|
|
6162
6572
|
aspect: i.aspect,
|
|
6163
6573
|
fov: s ? void 0 : i.fov,
|
|
6164
6574
|
padding: n
|
|
@@ -6185,16 +6595,16 @@ var Xr = {
|
|
|
6185
6595
|
#$(e) {
|
|
6186
6596
|
let t = this.#U;
|
|
6187
6597
|
t.time = Math.min(t.duration, t.time + e);
|
|
6188
|
-
let n =
|
|
6189
|
-
|
|
6598
|
+
let n = Fn.inOut(t.time / t.duration), r = this.camera, i = t.from.target.clone().lerp(t.to.target, n), a = t.from.position.clone().sub(t.from.target), o = t.to.position.clone().sub(t.to.target), s = a.len() || 1e-6, c = o.len() || 1e-6, l = Ri(a.multiplyScalar(1 / s), o.multiplyScalar(1 / c), n);
|
|
6599
|
+
Li(r, i), r.position.copy(i).add(l.multiplyScalar(s * (c / s) ** n)), t.to.height !== void 0 && (r.height = t.from.height * (t.to.height / t.from.height) ** n), t.time >= t.duration && (Ii(r, t.to), this.#U = null), this.invalidate();
|
|
6190
6600
|
}
|
|
6191
6601
|
#ee(e, t) {
|
|
6192
6602
|
let n = e.bounds;
|
|
6193
6603
|
if (n.isEmpty()) return [];
|
|
6194
6604
|
let r = this.camera, i = r.position.clone();
|
|
6195
6605
|
r.position.copy(n.getCenter()).add(t.clone().multiplyScalar(Math.max(n.getRadius(), .001) * 3)), r.updateWorld();
|
|
6196
|
-
let a =
|
|
6197
|
-
return r.position.copy(i), r.updateWorld(), a.length ? a :
|
|
6606
|
+
let a = Ni(e, r);
|
|
6607
|
+
return r.position.copy(i), r.updateWorld(), a.length ? a : ji(n);
|
|
6198
6608
|
}
|
|
6199
6609
|
pick(e, t) {
|
|
6200
6610
|
if (typeof e == "object") {
|
|
@@ -6210,7 +6620,7 @@ var Xr = {
|
|
|
6210
6620
|
t = e.clientY - n.top, e = e.clientX - n.left;
|
|
6211
6621
|
}
|
|
6212
6622
|
let n = [e / (this.#u || 1) * 2 - 1, 1 - t / (this.#d || 1) * 2];
|
|
6213
|
-
return new
|
|
6623
|
+
return new Qn().setFromCamera(n, this.camera).ray;
|
|
6214
6624
|
}
|
|
6215
6625
|
#te() {
|
|
6216
6626
|
let e = this.lastFrame;
|
|
@@ -6220,10 +6630,10 @@ var Xr = {
|
|
|
6220
6630
|
let e = n.drawMode;
|
|
6221
6631
|
t += i ? i.count : e === "points" ? r.drawnVertices : e === "lines" ? r.drawnCount / 2 : r.drawnCount / 3;
|
|
6222
6632
|
}
|
|
6223
|
-
return t >
|
|
6633
|
+
return t > Ei ? e : null;
|
|
6224
6634
|
}
|
|
6225
6635
|
#ne(e, t) {
|
|
6226
|
-
let n = e.item.node, r = new
|
|
6636
|
+
let n = e.item.node, r = new Qn().setFromCamera(e.ndc, this.camera), i = r.intersectElement(n, e.element);
|
|
6227
6637
|
if (i) return i;
|
|
6228
6638
|
let a = new B().copy(t.camera.viewProjection).invert(), o = new z(e.ndc[0], e.ndc[1], e.ndc[2]).applyMatrix4(a), s = "instanceMatrices" in n, c = e.element, l = s || n.drawMode !== "triangles";
|
|
6229
6639
|
return {
|
|
@@ -6238,7 +6648,7 @@ var Xr = {
|
|
|
6238
6648
|
};
|
|
6239
6649
|
}
|
|
6240
6650
|
project(e) {
|
|
6241
|
-
let { ndc: [t, n, r], visible: i } =
|
|
6651
|
+
let { ndc: [t, n, r], visible: i } = qt(z.fromInput(e, "View"), this.#re());
|
|
6242
6652
|
return {
|
|
6243
6653
|
x: (t * .5 + .5) * this.#u,
|
|
6244
6654
|
y: (.5 - n * .5) * this.#d,
|
|
@@ -6247,7 +6657,7 @@ var Xr = {
|
|
|
6247
6657
|
};
|
|
6248
6658
|
}
|
|
6249
6659
|
screenBounds(e = this.scene) {
|
|
6250
|
-
let t = e instanceof V ?
|
|
6660
|
+
let t = e instanceof V ? ji(e) : Ni(e, this.camera);
|
|
6251
6661
|
if (!t.length) return null;
|
|
6252
6662
|
let n = Infinity, r = Infinity, i = -Infinity, a = -Infinity;
|
|
6253
6663
|
for (let e of t) {
|
|
@@ -6268,12 +6678,15 @@ var Xr = {
|
|
|
6268
6678
|
let e = this.camera;
|
|
6269
6679
|
return e.updateWorld(), new B().multiplyMatrices(e.projectionMatrix, e.viewMatrix);
|
|
6270
6680
|
}
|
|
6681
|
+
pickArea(e) {
|
|
6682
|
+
return this.scene.updateWorldTree(), nr(this.scene, this.camera, this.#re(), this.#u, this.#d, e);
|
|
6683
|
+
}
|
|
6271
6684
|
pickAll(e, t) {
|
|
6272
6685
|
if (typeof e == "object") {
|
|
6273
6686
|
let n = this.canvas.getBoundingClientRect();
|
|
6274
6687
|
t = e.clientY - n.top, e = e.clientX - n.left;
|
|
6275
6688
|
}
|
|
6276
|
-
let n = [e / this.#u * 2 - 1, 1 - t / this.#d * 2], r = new
|
|
6689
|
+
let n = [e / this.#u * 2 - 1, 1 - t / this.#d * 2], r = new Qn().setFromCamera(n, this.camera), i = this.camera, a = i.position.distanceTo(i.target ?? [
|
|
6277
6690
|
0,
|
|
6278
6691
|
0,
|
|
6279
6692
|
0
|
|
@@ -6282,7 +6695,7 @@ var Xr = {
|
|
|
6282
6695
|
}
|
|
6283
6696
|
on(e, t) {
|
|
6284
6697
|
if (!(e in this.#C)) {
|
|
6285
|
-
let t =
|
|
6698
|
+
let t = Si[e];
|
|
6286
6699
|
t && E("View", `on('${e}') - use '${t}'${t === "hover" ? ", which fires as the thing under the pointer changes (null when it leaves)" : ""}`), P("View", "event", e, ["click", "hover"]);
|
|
6287
6700
|
}
|
|
6288
6701
|
typeof t != "function" && E("View", `on('${e}', fn) needs a function, got ${j(t)}`);
|
|
@@ -6303,13 +6716,13 @@ var Xr = {
|
|
|
6303
6716
|
A("View", t, ["label"], {
|
|
6304
6717
|
describe: "use 'label: (hit) => text'",
|
|
6305
6718
|
text: "use 'label: (hit) => text'"
|
|
6306
|
-
}, "keyboard"), t.label !== void 0 && typeof t.label != "function" && E("View", `keyboard.label is a function (hit) => text, got ${j(t.label)}`),
|
|
6719
|
+
}, "keyboard"), t.label !== void 0 && typeof t.label != "function" && E("View", `keyboard.label is a function (hit) => text, got ${j(t.label)}`), import("./keyboard.js").then(({ Keyboard: e }) => {
|
|
6307
6720
|
this.#r || (this.#A = new e(this, {
|
|
6308
6721
|
focus: (e) => {
|
|
6309
6722
|
this.#j = e, this.#I = !0, this.invalidate();
|
|
6310
6723
|
},
|
|
6311
6724
|
press: (e) => {
|
|
6312
|
-
for (let t of
|
|
6725
|
+
for (let t of Bi(e.node, "click")) t(e);
|
|
6313
6726
|
for (let t of this.#C.click) t(e, null);
|
|
6314
6727
|
},
|
|
6315
6728
|
tooltip: (e) => this.#se(e)?.(e),
|
|
@@ -6374,13 +6787,13 @@ var Xr = {
|
|
|
6374
6787
|
if (!this.#r) {
|
|
6375
6788
|
this.#r = !0, this.#n = !1, cancelAnimationFrame(this.#o);
|
|
6376
6789
|
for (let e of this.#b) e();
|
|
6377
|
-
this.controls?.dispose(), this.#x.dispose(), this.#w?.dispose(), this.#A?.dispose(), this.#M !== null && !this.#A && (this.description = null), this.renderer.dispose(this.scene), this.#i &&
|
|
6790
|
+
this.controls?.dispose(), this.#x.dispose(), this.#w?.dispose(), this.#A?.dispose(), this.#M !== null && !this.#A && (this.description = null), this.renderer.dispose(this.scene), this.#i && Di--, this.#a && this.canvas.remove();
|
|
6378
6791
|
}
|
|
6379
6792
|
}
|
|
6380
6793
|
#ce() {
|
|
6381
6794
|
let e = this.#e;
|
|
6382
6795
|
this.#_ ||= e.aspect;
|
|
6383
|
-
let t =
|
|
6796
|
+
let t = Pn(this.#g, this.#_, e.aspect), n = t / this.#v;
|
|
6384
6797
|
if (this.#v = t, !(Math.abs(n - 1) < 1e-9)) {
|
|
6385
6798
|
if (e.constructor.type === "orthographic-camera") e.height *= n;
|
|
6386
6799
|
else if (e.target) {
|
|
@@ -6425,8 +6838,8 @@ var Xr = {
|
|
|
6425
6838
|
#pe(e, t = this.#F) {
|
|
6426
6839
|
let n = this.#H, r = n === e || n && e && n.node === e.node && n.instance === e.instance && n.datum === e.datum && (e.node.drawMode !== "points" || n.face === e.face);
|
|
6427
6840
|
if (this.#H = e, t && e && this.#w ? this.#w.show(e, t.clientX, t.clientY) : this.#w?.hide(), r) return;
|
|
6428
|
-
(this.#ge(n) || this.#ge(e)) && this.invalidate(), (this.#C.click.size || this.lastFrame?.interactive) && (this.canvas.style.cursor = e &&
|
|
6429
|
-
let i =
|
|
6841
|
+
(this.#ge(n) || this.#ge(e)) && this.invalidate(), (this.#C.click.size || this.lastFrame?.interactive) && (this.canvas.style.cursor = e && Pi(e.node, "onDrag") ? "grab" : e && this.#he(e) ? "pointer" : "");
|
|
6842
|
+
let i = Bi(n?.node, "hover"), a = Bi(e?.node, "hover");
|
|
6430
6843
|
for (let e of i) a.includes(e) || e(null);
|
|
6431
6844
|
for (let t of a) t(e);
|
|
6432
6845
|
for (let n of this.#C.hover) n(e, t?.event ?? null);
|
|
@@ -6443,7 +6856,7 @@ var Xr = {
|
|
|
6443
6856
|
datum: r.datumAt?.(i) ?? null
|
|
6444
6857
|
};
|
|
6445
6858
|
if (e === "click") {
|
|
6446
|
-
for (let e of
|
|
6859
|
+
for (let e of Bi(r, "click")) e(o);
|
|
6447
6860
|
for (let e of this.#C.click) e(o, n);
|
|
6448
6861
|
} else {
|
|
6449
6862
|
if (this.#W = e === "over" ? o : null, n) {
|
|
@@ -6460,13 +6873,13 @@ var Xr = {
|
|
|
6460
6873
|
}
|
|
6461
6874
|
}
|
|
6462
6875
|
#he(e) {
|
|
6463
|
-
return this.#C.click.size > 0 ||
|
|
6876
|
+
return this.#C.click.size > 0 || Bi(e.node, "click").length > 0;
|
|
6464
6877
|
}
|
|
6465
6878
|
#ge(e) {
|
|
6466
6879
|
if (!e) return null;
|
|
6467
6880
|
let t = null, n = null;
|
|
6468
6881
|
for (let r = e.node; r; r = r.parent) t ??= r.highlight, n ??= r.highlightWhole ? r : null;
|
|
6469
|
-
if (t ??= this.#O, !t && e === this.#j && (t =
|
|
6882
|
+
if (t ??= this.#O, !t && e === this.#j && (t = wi), !t) return null;
|
|
6470
6883
|
let r = e.node;
|
|
6471
6884
|
if (n) {
|
|
6472
6885
|
let e = /* @__PURE__ */ new Set();
|
|
@@ -6477,20 +6890,20 @@ var Xr = {
|
|
|
6477
6890
|
index: null,
|
|
6478
6891
|
nodes: e,
|
|
6479
6892
|
color: t,
|
|
6480
|
-
amount:
|
|
6893
|
+
amount: Ci
|
|
6481
6894
|
};
|
|
6482
6895
|
}
|
|
6483
6896
|
return {
|
|
6484
6897
|
node: r,
|
|
6485
6898
|
index: e.instance ?? (r.drawMode === "points" ? e.face : null),
|
|
6486
6899
|
color: t,
|
|
6487
|
-
amount:
|
|
6900
|
+
amount: Ci
|
|
6488
6901
|
};
|
|
6489
6902
|
}
|
|
6490
6903
|
#_e(e) {
|
|
6491
6904
|
let t = e.labels, n = this.height / 2, r = t.filter((e) => e.style.occlude && e.visible && !(e.style.minScale && e.scale * n < e.style.minScale));
|
|
6492
6905
|
if (!r.length) return;
|
|
6493
|
-
let i =
|
|
6906
|
+
let i = Qn.solids([...e.opaque, ...e.transparent]), a = new Qn();
|
|
6494
6907
|
for (let e of r) {
|
|
6495
6908
|
a.setFromCamera(e.ndc, this.camera);
|
|
6496
6909
|
let t = e.position.distanceTo(a.ray.origin);
|
|
@@ -6525,7 +6938,7 @@ var Xr = {
|
|
|
6525
6938
|
y: r.y,
|
|
6526
6939
|
moved: !1
|
|
6527
6940
|
};
|
|
6528
|
-
let i = this.lastFrame?.draggable && (n.pointerType !== "mouse" || n.button === 0) ? this.pick(n) : null, a = i &&
|
|
6941
|
+
let i = this.lastFrame?.draggable && (n.pointerType !== "mouse" || n.button === 0) ? this.pick(n) : null, a = i && Pi(i.node, "onDrag");
|
|
6529
6942
|
if (!i || !a) {
|
|
6530
6943
|
this.#B?.down(n);
|
|
6531
6944
|
return;
|
|
@@ -6562,7 +6975,7 @@ var Xr = {
|
|
|
6562
6975
|
}
|
|
6563
6976
|
if (!this.#C.click.size && !this.lastFrame?.interactive) return;
|
|
6564
6977
|
let t = this.pick(e);
|
|
6565
|
-
if (t) for (let e of
|
|
6978
|
+
if (t) for (let e of Bi(t.node, "click")) e(t);
|
|
6566
6979
|
for (let n of this.#C.click) n(t, e);
|
|
6567
6980
|
};
|
|
6568
6981
|
e.addEventListener("pointerdown", a), e.addEventListener("pointermove", n), e.addEventListener("pointerleave", r), e.addEventListener("pointerup", i), e.addEventListener("pointercancel", i), e.addEventListener("click", o);
|
|
@@ -6640,15 +7053,15 @@ var Xr = {
|
|
|
6640
7053
|
});
|
|
6641
7054
|
}
|
|
6642
7055
|
};
|
|
6643
|
-
function
|
|
7056
|
+
function ki(e) {
|
|
6644
7057
|
return [
|
|
6645
7058
|
...e.position,
|
|
6646
7059
|
...e.target ?? [],
|
|
6647
7060
|
e.fov ?? e.height
|
|
6648
7061
|
];
|
|
6649
7062
|
}
|
|
6650
|
-
var
|
|
6651
|
-
function
|
|
7063
|
+
var Ai = (e, t) => !!t && e.length === t.length && e.every((e, n) => e === t[n]);
|
|
7064
|
+
function ji(e) {
|
|
6652
7065
|
if (e.isEmpty()) return [];
|
|
6653
7066
|
if (e.min.equals(e.max)) return [e.min.toArray()];
|
|
6654
7067
|
let t = [];
|
|
@@ -6659,14 +7072,14 @@ function _i(e) {
|
|
|
6659
7072
|
]);
|
|
6660
7073
|
return t;
|
|
6661
7074
|
}
|
|
6662
|
-
var
|
|
6663
|
-
function
|
|
7075
|
+
var Mi = 4e3;
|
|
7076
|
+
function Ni(e, t) {
|
|
6664
7077
|
e.updateWorld();
|
|
6665
7078
|
let n = [];
|
|
6666
7079
|
return e.eachShownTo(t, (e) => {
|
|
6667
7080
|
let t = e;
|
|
6668
|
-
if ("instanceMatrices" in t && t.count <=
|
|
6669
|
-
n.push(...
|
|
7081
|
+
if ("instanceMatrices" in t && t.count <= Mi) t.eachInstanceBox((e, t, r, i, a, o) => {
|
|
7082
|
+
n.push(...ji(new V([
|
|
6670
7083
|
e,
|
|
6671
7084
|
t,
|
|
6672
7085
|
r
|
|
@@ -6676,7 +7089,7 @@ function yi(e, t) {
|
|
|
6676
7089
|
o
|
|
6677
7090
|
])));
|
|
6678
7091
|
});
|
|
6679
|
-
else if ((t.drawMode === "lines" || t.drawMode === "points") && t.geometry.vertexCount <=
|
|
7092
|
+
else if ((t.drawMode === "lines" || t.drawMode === "points") && t.geometry.vertexCount <= Mi) {
|
|
6680
7093
|
let e = t.geometry, r = e.positions, i = t.worldMatrix, a = e.indices ? e.vertexCount : e.drawnVertices;
|
|
6681
7094
|
for (let e = 0; e < a; e++) {
|
|
6682
7095
|
let t = r[e * 3], a = r[e * 3 + 1], o = r[e * 3 + 2];
|
|
@@ -6686,45 +7099,45 @@ function yi(e, t) {
|
|
|
6686
7099
|
i[2] * t + i[6] * a + i[10] * o + i[14]
|
|
6687
7100
|
]);
|
|
6688
7101
|
}
|
|
6689
|
-
} else n.push(...
|
|
7102
|
+
} else n.push(...ji(e.expandBounds(new V())));
|
|
6690
7103
|
}), n;
|
|
6691
7104
|
}
|
|
6692
|
-
function
|
|
7105
|
+
function Pi(e, t) {
|
|
6693
7106
|
for (let n = e; n; n = n.parent) if (n[t]) return n;
|
|
6694
7107
|
return null;
|
|
6695
7108
|
}
|
|
6696
|
-
function
|
|
7109
|
+
function Fi(e) {
|
|
6697
7110
|
return {
|
|
6698
7111
|
position: e.position.clone(),
|
|
6699
7112
|
target: (e.target ?? new z()).clone(),
|
|
6700
7113
|
height: e.height
|
|
6701
7114
|
};
|
|
6702
7115
|
}
|
|
6703
|
-
function
|
|
6704
|
-
e.position.copy(t.position),
|
|
7116
|
+
function Ii(e, t) {
|
|
7117
|
+
e.position.copy(t.position), Li(e, t.target), t.height !== void 0 && (e.height = t.height);
|
|
6705
7118
|
}
|
|
6706
|
-
function
|
|
7119
|
+
function Li(e, t) {
|
|
6707
7120
|
e.target ? e.target.copy(t) : e.target = t.clone();
|
|
6708
7121
|
}
|
|
6709
|
-
function
|
|
7122
|
+
function Ri(e, t, n) {
|
|
6710
7123
|
let r = Math.max(-1, Math.min(1, e.dot(t)));
|
|
6711
7124
|
if (r > .9999) return e.clone().lerp(t, n).normalize();
|
|
6712
7125
|
if (r < -.9999) {
|
|
6713
7126
|
let r = Math.abs(e[1]) < .9 ? new z(0, 1, 0) : new z(1, 0, 0), i = e.clone().cross(r).normalize();
|
|
6714
|
-
return n < .5 ?
|
|
7127
|
+
return n < .5 ? Ri(e, i, n * 2) : Ri(i, t, n * 2 - 1);
|
|
6715
7128
|
}
|
|
6716
7129
|
let i = Math.acos(r), a = Math.sin(i);
|
|
6717
7130
|
return e.clone().multiplyScalar(Math.sin((1 - n) * i) / a).add(t.clone().multiplyScalar(Math.sin(n * i) / a));
|
|
6718
7131
|
}
|
|
6719
|
-
function
|
|
6720
|
-
return e.index === null && !e.node.handlersFor(t).length ? [] :
|
|
7132
|
+
function zi(e, t) {
|
|
7133
|
+
return e.index === null && !e.node.handlersFor(t).length ? [] : Bi(e.node, t);
|
|
6721
7134
|
}
|
|
6722
|
-
function
|
|
7135
|
+
function Bi(e, t) {
|
|
6723
7136
|
let n = [];
|
|
6724
7137
|
for (let r = e; r; r = r.parent) n.push(...r.handlersFor(t));
|
|
6725
7138
|
return n;
|
|
6726
7139
|
}
|
|
6727
|
-
function
|
|
7140
|
+
function Vi(e) {
|
|
6728
7141
|
if (e === void 0) {
|
|
6729
7142
|
let e = document.createElement("canvas");
|
|
6730
7143
|
return Object.assign(e.style, {
|
|
@@ -6742,25 +7155,25 @@ function Di(e) {
|
|
|
6742
7155
|
return e instanceof HTMLCanvasElement || E("View", `'canvas' must be a <canvas> element or a selector, got ${j(e)}`), e;
|
|
6743
7156
|
}
|
|
6744
7157
|
// src/geometry/triangulate.js
|
|
6745
|
-
function
|
|
7158
|
+
function Hi(e) {
|
|
6746
7159
|
let t = 0;
|
|
6747
7160
|
for (let n = 0, r = e.length - 1; n < e.length; r = n++) t += (e[r][0] - e[n][0]) * (e[r][1] + e[n][1]);
|
|
6748
7161
|
return t;
|
|
6749
7162
|
}
|
|
6750
|
-
function
|
|
7163
|
+
function Ui(e, t = []) {
|
|
6751
7164
|
let n = [...e], r = e.map((e, t) => t);
|
|
6752
|
-
|
|
7165
|
+
Hi(e) < 0 && r.reverse();
|
|
6753
7166
|
let i = t.map((e) => {
|
|
6754
7167
|
let t = n.length;
|
|
6755
7168
|
n.push(...e);
|
|
6756
7169
|
let r = e.map((e, n) => t + n);
|
|
6757
|
-
return
|
|
6758
|
-
}).sort((e, t) =>
|
|
6759
|
-
for (let e of i) r =
|
|
6760
|
-
return
|
|
7170
|
+
return Hi(e) > 0 && r.reverse(), r;
|
|
7171
|
+
}).sort((e, t) => Wi(n, t) - Wi(n, e));
|
|
7172
|
+
for (let e of i) r = Gi(n, r, e, i);
|
|
7173
|
+
return Ji(n, r);
|
|
6761
7174
|
}
|
|
6762
|
-
var
|
|
6763
|
-
function
|
|
7175
|
+
var Wi = (e, t) => Math.max(...t.map((t) => e[t][0]));
|
|
7176
|
+
function Gi(e, t, n, r) {
|
|
6764
7177
|
let i = 0;
|
|
6765
7178
|
n.forEach((t, r) => {
|
|
6766
7179
|
e[t][0] > e[n[i]][0] && (i = r);
|
|
@@ -6770,7 +7183,7 @@ function ji(e, t, n, r) {
|
|
|
6770
7183
|
let s = -1, c = Infinity;
|
|
6771
7184
|
t.forEach((t, n) => {
|
|
6772
7185
|
let r = e[t], i = ((r[0] - a[0]) ** 2 + (r[1] - a[1]) ** 2) * (r[0] >= a[0] ? 1 : 4);
|
|
6773
|
-
i >= c || o.some(([e, t]) =>
|
|
7186
|
+
i >= c || o.some(([e, t]) => Ki(a, r, e, t)) || (s = n, c = i);
|
|
6774
7187
|
}), s < 0 && (s = 0);
|
|
6775
7188
|
let l = [...n.slice(i), ...n.slice(0, i)];
|
|
6776
7189
|
return [
|
|
@@ -6781,52 +7194,52 @@ function ji(e, t, n, r) {
|
|
|
6781
7194
|
...t.slice(s + 1)
|
|
6782
7195
|
];
|
|
6783
7196
|
}
|
|
6784
|
-
function
|
|
6785
|
-
if (
|
|
7197
|
+
function Ki(e, t, n, r) {
|
|
7198
|
+
if (qi(e, n) || qi(e, r) || qi(t, n) || qi(t, r)) return !1;
|
|
6786
7199
|
let i = Q(n, r, e), a = Q(n, r, t), o = Q(e, t, n), s = Q(e, t, r);
|
|
6787
7200
|
return i * a < 0 && o * s < 0;
|
|
6788
7201
|
}
|
|
6789
|
-
var
|
|
6790
|
-
function
|
|
7202
|
+
var qi = (e, t) => e[0] === t[0] && e[1] === t[1], Q = (e, t, n) => (t[0] - e[0]) * (n[1] - e[1]) - (t[1] - e[1]) * (n[0] - e[0]);
|
|
7203
|
+
function Ji(e, t) {
|
|
6791
7204
|
let n = [...t], r = [];
|
|
6792
7205
|
for (; n.length > 3;) {
|
|
6793
7206
|
let t = -1;
|
|
6794
|
-
for (let r = 0; r < n.length && t < 0; r++)
|
|
6795
|
-
if (t < 0) for (let r = 0; r < n.length && t < 0; r++)
|
|
7207
|
+
for (let r = 0; r < n.length && t < 0; r++) Xi(e, n, r) && (t = r);
|
|
7208
|
+
if (t < 0) for (let r = 0; r < n.length && t < 0; r++) Yi(e, n, r) && (t = r);
|
|
6796
7209
|
t < 0 && (t = 0);
|
|
6797
7210
|
let i = n.length;
|
|
6798
7211
|
r.push(n[(t + i - 1) % i], n[t], n[(t + 1) % i]), n.splice(t, 1);
|
|
6799
7212
|
}
|
|
6800
7213
|
return n.length === 3 && r.push(...n), r;
|
|
6801
7214
|
}
|
|
6802
|
-
function
|
|
7215
|
+
function Yi(e, t, n) {
|
|
6803
7216
|
let r = t.length;
|
|
6804
7217
|
return Q(e[t[(n + r - 1) % r]], e[t[n]], e[t[(n + 1) % r]]) > 0;
|
|
6805
7218
|
}
|
|
6806
|
-
function
|
|
6807
|
-
if (!
|
|
7219
|
+
function Xi(e, t, n) {
|
|
7220
|
+
if (!Yi(e, t, n)) return !1;
|
|
6808
7221
|
let r = t.length, i = e[t[(n + r - 1) % r]], a = e[t[n]], o = e[t[(n + 1) % r]];
|
|
6809
7222
|
for (let n of t) {
|
|
6810
7223
|
let t = e[n];
|
|
6811
|
-
if (!(
|
|
7224
|
+
if (!(qi(t, i) || qi(t, a) || qi(t, o)) && Q(i, a, t) >= 0 && Q(a, o, t) >= 0 && Q(o, i, t) >= 0) return !1;
|
|
6812
7225
|
}
|
|
6813
7226
|
return !0;
|
|
6814
7227
|
}
|
|
6815
7228
|
// src/geometry/generators.js
|
|
6816
|
-
var
|
|
7229
|
+
var Zi = /* @__PURE__ */ t({
|
|
6817
7230
|
GENERATOR_OPTIONS: () => $,
|
|
6818
|
-
axes: () =>
|
|
6819
|
-
box: () =>
|
|
6820
|
-
cylinder: () =>
|
|
6821
|
-
edges: () =>
|
|
6822
|
-
extrude: () =>
|
|
6823
|
-
grid: () =>
|
|
6824
|
-
icosphere: () =>
|
|
6825
|
-
lathe: () =>
|
|
6826
|
-
plane: () =>
|
|
6827
|
-
sphere: () =>
|
|
6828
|
-
torus: () =>
|
|
6829
|
-
}),
|
|
7231
|
+
axes: () => ma,
|
|
7232
|
+
box: () => ea,
|
|
7233
|
+
cylinder: () => ia,
|
|
7234
|
+
edges: () => pa,
|
|
7235
|
+
extrude: () => la,
|
|
7236
|
+
grid: () => ha,
|
|
7237
|
+
icosphere: () => sa,
|
|
7238
|
+
lathe: () => ca,
|
|
7239
|
+
plane: () => ra,
|
|
7240
|
+
sphere: () => na,
|
|
7241
|
+
torus: () => oa
|
|
7242
|
+
}), Qi = Math.PI * 2, $ = {
|
|
6830
7243
|
box: [
|
|
6831
7244
|
"size",
|
|
6832
7245
|
"width",
|
|
@@ -6873,18 +7286,18 @@ var Li = /* @__PURE__ */ t({
|
|
|
6873
7286
|
],
|
|
6874
7287
|
axes: ["size"],
|
|
6875
7288
|
grid: ["size", "divisions"]
|
|
6876
|
-
},
|
|
6877
|
-
function
|
|
7289
|
+
}, $i = "has one 'segments' option, used for every face";
|
|
7290
|
+
function ea(e) {
|
|
6878
7291
|
let t = "box()", n = I(t, e, $.box, (e) => ({ size: e }), {
|
|
6879
|
-
widthSegments: `box() ${
|
|
6880
|
-
heightSegments: `box() ${
|
|
6881
|
-
depthSegments: `box() ${
|
|
7292
|
+
widthSegments: `box() ${$i}`,
|
|
7293
|
+
heightSegments: `box() ${$i}`,
|
|
7294
|
+
depthSegments: `box() ${$i}`
|
|
6882
7295
|
}), r = L(t, "size", n.size, 1), i = L(t, "width", n.width, r), a = L(t, "height", n.height, r), o = L(t, "depth", n.depth, r), s = R(t, "segments", n.segments, 1), c = [
|
|
6883
7296
|
i,
|
|
6884
7297
|
a,
|
|
6885
7298
|
o
|
|
6886
|
-
], l = new
|
|
6887
|
-
for (let [e, t, n] of
|
|
7299
|
+
], l = new ga();
|
|
7300
|
+
for (let [e, t, n] of ta) {
|
|
6888
7301
|
let r = l.count;
|
|
6889
7302
|
for (let r = 0; r <= s; r++) {
|
|
6890
7303
|
let i = r / s;
|
|
@@ -6907,7 +7320,7 @@ function Bi(e) {
|
|
|
6907
7320
|
segments: s
|
|
6908
7321
|
});
|
|
6909
7322
|
}
|
|
6910
|
-
var
|
|
7323
|
+
var ta = [
|
|
6911
7324
|
[
|
|
6912
7325
|
[
|
|
6913
7326
|
1,
|
|
@@ -7011,15 +7424,15 @@ var Vi = [
|
|
|
7011
7424
|
]
|
|
7012
7425
|
]
|
|
7013
7426
|
];
|
|
7014
|
-
function
|
|
7427
|
+
function na(e) {
|
|
7015
7428
|
let t = "sphere()", n = I(t, e, $.sphere, (e) => ({ radius: e }), {
|
|
7016
7429
|
widthSegments: "sphere(): use 'segments' for the divisions around the sphere",
|
|
7017
7430
|
heightSegments: "sphere(): use 'rings' for the divisions from pole to pole"
|
|
7018
|
-
}), r = L(t, "radius", n.radius, 1), i = R(t, "segments", n.segments, 32, 3), a = R(t, "rings", n.rings, 16, 2), o = new
|
|
7431
|
+
}), r = L(t, "radius", n.radius, 1), i = R(t, "segments", n.segments, 32, 3), a = R(t, "rings", n.rings, 16, 2), o = new ga();
|
|
7019
7432
|
for (let e = 0; e <= a; e++) {
|
|
7020
7433
|
let t = e / a, n = e === 0 || e === a, s = n ? 0 : Math.sin(t * Math.PI), c = e === 0 ? 1 : e === a ? -1 : Math.cos(t * Math.PI);
|
|
7021
7434
|
for (let e = 0; e <= i; e++) {
|
|
7022
|
-
let a = n && e < i ? (e + .5) / i : e / i, l = e % i / i *
|
|
7435
|
+
let a = n && e < i ? (e + .5) / i : e / i, l = e % i / i * Qi, u = -Math.cos(l) * s, d = c, f = Math.sin(l) * s;
|
|
7023
7436
|
o.vertex(u * r, d * r, f * r, u, d, f, a, t);
|
|
7024
7437
|
}
|
|
7025
7438
|
}
|
|
@@ -7033,12 +7446,12 @@ function Hi(e) {
|
|
|
7033
7446
|
rings: a
|
|
7034
7447
|
});
|
|
7035
7448
|
}
|
|
7036
|
-
function
|
|
7449
|
+
function ra(e) {
|
|
7037
7450
|
let t = "plane()", n = I(t, e, $.plane, (e) => ({ size: e }), {
|
|
7038
7451
|
height: "plane() lies in the x-z plane - use 'depth' rather than 'height'",
|
|
7039
|
-
widthSegments: `plane() ${
|
|
7040
|
-
heightSegments: `plane() ${
|
|
7041
|
-
}), r = L(t, "size", n.size, 1), i = L(t, "width", n.width, r), a = L(t, "depth", n.depth, r), o = R(t, "segments", n.segments, 1), s = new
|
|
7452
|
+
widthSegments: `plane() ${$i}`,
|
|
7453
|
+
heightSegments: `plane() ${$i}`
|
|
7454
|
+
}), r = L(t, "size", n.size, 1), i = L(t, "width", n.width, r), a = L(t, "depth", n.depth, r), o = R(t, "segments", n.segments, 1), s = new ga();
|
|
7042
7455
|
for (let e = 0; e <= o; e++) {
|
|
7043
7456
|
let t = e / o;
|
|
7044
7457
|
for (let e = 0; e <= o; e++) {
|
|
@@ -7053,7 +7466,7 @@ function Ui(e) {
|
|
|
7053
7466
|
segments: o
|
|
7054
7467
|
});
|
|
7055
7468
|
}
|
|
7056
|
-
function
|
|
7469
|
+
function ia(e) {
|
|
7057
7470
|
let t = "cylinder()", n = I(t, e, $.cylinder, null, {
|
|
7058
7471
|
radiusBottom: "cylinder(): use 'radius' for the bottom radius",
|
|
7059
7472
|
radialSegments: "cylinder(): use 'segments' for the divisions around the cylinder",
|
|
@@ -7062,18 +7475,18 @@ function Wi(e) {
|
|
|
7062
7475
|
r === 0 && i === 0 && E(t, "'radius' and 'radiusTop' can't both be 0");
|
|
7063
7476
|
let a = L(t, "height", n.height, 1), o = R(t, "segments", n.segments, 32, 3), s = n.caps ?? !0;
|
|
7064
7477
|
typeof s != "boolean" && E(t, `'caps' must be true or false, got ${j(s)}`);
|
|
7065
|
-
let c =
|
|
7478
|
+
let c = va(t, n.axis, "y"), l = new ga(), u = r - i, d = Math.hypot(a, u), f = a / d, p = u / d;
|
|
7066
7479
|
for (let e = 0; e <= 1; e++) {
|
|
7067
7480
|
let t = e === 0 ? i : r, n = e === 0 ? a / 2 : -a / 2;
|
|
7068
7481
|
for (let r = 0; r <= o; r++) {
|
|
7069
|
-
let i = t === 0 && r < o ? (r + .5) / o : r / o, a = t === 0 ? i *
|
|
7482
|
+
let i = t === 0 && r < o ? (r + .5) / o : r / o, a = t === 0 ? i * Qi : r % o / o * Qi, s = Math.sin(a), c = Math.cos(a);
|
|
7070
7483
|
l.vertex(t * s, n, t * c, f * s, p, f * c, i, e);
|
|
7071
7484
|
}
|
|
7072
7485
|
}
|
|
7073
7486
|
return l.grid(0, o, 1, {
|
|
7074
7487
|
pinchTop: i === 0,
|
|
7075
7488
|
pinchBottom: r === 0
|
|
7076
|
-
}), s && (i > 0 &&
|
|
7489
|
+
}), s && (i > 0 && aa(l, i, a / 2, 1, o), r > 0 && aa(l, r, -a / 2, -1, o)), l.turn("y", c), l.build({
|
|
7077
7490
|
type: "cylinder",
|
|
7078
7491
|
radius: r,
|
|
7079
7492
|
radiusTop: i,
|
|
@@ -7083,10 +7496,10 @@ function Wi(e) {
|
|
|
7083
7496
|
...c !== "y" && { axis: c }
|
|
7084
7497
|
});
|
|
7085
7498
|
}
|
|
7086
|
-
function
|
|
7499
|
+
function aa(e, t, n, r, i) {
|
|
7087
7500
|
let a = e.vertex(0, n, 0, 0, r, 0, .5, .5);
|
|
7088
7501
|
for (let a = 0; a < i; a++) {
|
|
7089
|
-
let o = a / i *
|
|
7502
|
+
let o = a / i * Qi, s = Math.sin(o), c = Math.cos(o);
|
|
7090
7503
|
e.vertex(t * s, n, t * c, 0, r, 0, .5 + s / 2, .5 + r * c / 2);
|
|
7091
7504
|
}
|
|
7092
7505
|
for (let t = 0; t < i; t++) {
|
|
@@ -7094,15 +7507,15 @@ function Gi(e, t, n, r, i) {
|
|
|
7094
7507
|
r > 0 ? e.indices.push(a, n, o) : e.indices.push(a, o, n);
|
|
7095
7508
|
}
|
|
7096
7509
|
}
|
|
7097
|
-
function
|
|
7510
|
+
function oa(e) {
|
|
7098
7511
|
let t = "torus()", n = I(t, e, $.torus, null, {
|
|
7099
7512
|
tubularSegments: "torus(): use 'segments' for the divisions around the ring",
|
|
7100
7513
|
radialSegments: "torus(): use 'tubeSegments' for the divisions around the tube"
|
|
7101
|
-
}), r = L(t, "radius", n.radius, 1), i = L(t, "tube", n.tube, .4), a = R(t, "segments", n.segments, 48, 3), o = R(t, "tubeSegments", n.tubeSegments, 16, 3), s = new
|
|
7514
|
+
}), r = L(t, "radius", n.radius, 1), i = L(t, "tube", n.tube, .4), a = R(t, "segments", n.segments, 48, 3), o = R(t, "tubeSegments", n.tubeSegments, 16, 3), s = new ga();
|
|
7102
7515
|
for (let e = 0; e <= o; e++) {
|
|
7103
|
-
let t = e / o, n = -(e % o / o) *
|
|
7516
|
+
let t = e / o, n = -(e % o / o) * Qi, c = Math.cos(n), l = Math.sin(n);
|
|
7104
7517
|
for (let e = 0; e <= a; e++) {
|
|
7105
|
-
let n = e / a, o = e % a / a *
|
|
7518
|
+
let n = e / a, o = e % a / a * Qi, u = Math.sin(o), d = Math.cos(o), f = c * u, p = l, m = c * d;
|
|
7106
7519
|
s.vertex(r * u + i * f, i * p, r * d + i * m, f, p, m, n, t);
|
|
7107
7520
|
}
|
|
7108
7521
|
}
|
|
@@ -7114,7 +7527,7 @@ function Ki(e) {
|
|
|
7114
7527
|
tubeSegments: o
|
|
7115
7528
|
});
|
|
7116
7529
|
}
|
|
7117
|
-
function
|
|
7530
|
+
function sa(e) {
|
|
7118
7531
|
let t = "icosphere()", n = I(t, e, $.icosphere, (e) => ({ radius: e }), { subdivisions: "icosphere(): use 'detail' (0-6) for the subdivision level" }), r = L(t, "radius", n.radius, 1), i = R(t, "detail", n.detail, 2, 0, 6), a = (1 + Math.sqrt(5)) / 2, o = [], s = (e, t, n) => {
|
|
7119
7532
|
let r = Math.hypot(e, t, n);
|
|
7120
7533
|
return o.push(e / r, t / r, n / r), o.length / 3 - 1;
|
|
@@ -7265,14 +7678,14 @@ function qi(e) {
|
|
|
7265
7678
|
detail: i
|
|
7266
7679
|
}, l;
|
|
7267
7680
|
}
|
|
7268
|
-
function
|
|
7681
|
+
function ca(e) {
|
|
7269
7682
|
let t = "lathe()", n = I(t, e, $.lathe, null, {
|
|
7270
7683
|
divisions: "lathe(): use 'segments' for the divisions around the axis",
|
|
7271
7684
|
phiSegments: "lathe(): use 'segments' for the divisions around the axis",
|
|
7272
7685
|
profile: "lathe(): use 'points' for the profile, as [radius, y] pairs"
|
|
7273
|
-
}), r =
|
|
7686
|
+
}), r = fa(t, "points", n.points, 2).map(([e, t]) => [Math.abs(e) < 1e-9 ? 0 : e, t]);
|
|
7274
7687
|
r.some(([e]) => e < 0) && E(t, "'points' are [radius, y] pairs - a radius can't be below 0");
|
|
7275
|
-
let i = R(t, "segments", n.segments, 32, 3), a =
|
|
7688
|
+
let i = R(t, "segments", n.segments, 32, 3), a = va(t, n.axis, "y"), o = [];
|
|
7276
7689
|
for (let e = 0; e + 1 < r.length; e++) {
|
|
7277
7690
|
let [t, n] = r[e], [i, a] = r[e + 1], s = Math.hypot(i - t, a - n);
|
|
7278
7691
|
s !== 0 && o.push({
|
|
@@ -7283,9 +7696,9 @@ function Ji(e) {
|
|
|
7283
7696
|
});
|
|
7284
7697
|
}
|
|
7285
7698
|
o.length || E(t, "'points' need at least two different points");
|
|
7286
|
-
let s = o.reduce((e, t) => e + t.len, 0), c = new
|
|
7699
|
+
let s = o.reduce((e, t) => e + t.len, 0), c = new ga(), l = 0;
|
|
7287
7700
|
return o.forEach((e, t) => {
|
|
7288
|
-
let n =
|
|
7701
|
+
let n = da(o[t - 1]?.normal, e.normal), r = da(o[t + 1]?.normal, e.normal), a = c.count;
|
|
7289
7702
|
for (let [[t, a], [o, u], d] of [[
|
|
7290
7703
|
e.to,
|
|
7291
7704
|
r,
|
|
@@ -7295,7 +7708,7 @@ function Ji(e) {
|
|
|
7295
7708
|
n,
|
|
7296
7709
|
1 - l / s
|
|
7297
7710
|
]]) for (let e = 0; e <= i; e++) {
|
|
7298
|
-
let n = e % i / i *
|
|
7711
|
+
let n = e % i / i * Qi, r = Math.sin(n), s = Math.cos(n);
|
|
7299
7712
|
c.vertex(t * r, a, t * s, o * r, u, o * s, e / i, d);
|
|
7300
7713
|
}
|
|
7301
7714
|
c.grid(a, i, 1, {
|
|
@@ -7309,17 +7722,17 @@ function Ji(e) {
|
|
|
7309
7722
|
...a !== "y" && { axis: a }
|
|
7310
7723
|
});
|
|
7311
7724
|
}
|
|
7312
|
-
function
|
|
7725
|
+
function la(e) {
|
|
7313
7726
|
let t = "extrude()", n = I(t, e, $.extrude, null, {
|
|
7314
7727
|
amount: "extrude(): use 'depth'",
|
|
7315
7728
|
points: "extrude(): use 'shape' for the outline, as [x, y] pairs",
|
|
7316
7729
|
outline: "extrude(): use 'shape' for the outline, as [x, y] pairs",
|
|
7317
7730
|
bevelEnabled: "extrude() has no bevel - round the shape's corners instead"
|
|
7318
|
-
}), r =
|
|
7731
|
+
}), r = ya(fa(t, "shape", n.shape, 3));
|
|
7319
7732
|
n.holes !== void 0 && !Array.isArray(n.holes) && E(t, `'holes' must be a list of outlines, got ${j(n.holes)}`), typeof n.holes?.[0]?.[0] == "number" && E(t, "'holes' is a list of outlines - for one hole, holes: [outline]");
|
|
7320
|
-
let i = (n.holes ?? []).map((e, n) =>
|
|
7733
|
+
let i = (n.holes ?? []).map((e, n) => ya(fa(t, `holes[${n}]`, e, 3))), a = L(t, "depth", n.depth, 1), o = va(t, n.axis, "z"), s = a / 2, c = Hi(r) < 0 ? [...r].reverse() : r, l = i.map((e) => Hi(e) > 0 ? [...e].reverse() : e), u = [c, ...l].flat(), d = Infinity, f = -Infinity, p = Infinity, m = -Infinity;
|
|
7321
7734
|
for (let [e, t] of u) d = Math.min(d, e), f = Math.max(f, e), p = Math.min(p, t), m = Math.max(m, t);
|
|
7322
|
-
let h = f - d || 1, g = m - p || 1, _ = new
|
|
7735
|
+
let h = f - d || 1, g = m - p || 1, _ = new ga(), v = Ui(c, l);
|
|
7323
7736
|
for (let [e, t] of [[s, 1], [-s, -1]]) {
|
|
7324
7737
|
let n = _.count;
|
|
7325
7738
|
for (let [n, r] of u) _.vertex(n, r, e, 0, 0, t, t > 0 ? (n - d) / h : (f - n) / h, (m - r) / g);
|
|
@@ -7331,7 +7744,7 @@ function Yi(e) {
|
|
|
7331
7744
|
return [(s - i) / c, -(o - r) / c];
|
|
7332
7745
|
}), i = n.reduce((e, t) => e + t, 0) || 1, a = 0;
|
|
7333
7746
|
for (let o = 0; o < t; o++) {
|
|
7334
|
-
let c = r[o], [l, u] = [
|
|
7747
|
+
let c = r[o], [l, u] = [da(r[(o + t - 1) % t], c), da(r[(o + 1) % t], c)], [d, f] = e[o], [p, m] = e[(o + 1) % t], h = a / i, g = (a + n[o]) / i, v = _.vertex(d, f, s, l[0], l[1], 0, h, 0), y = _.vertex(d, f, -s, l[0], l[1], 0, h, 1), b = _.vertex(p, m, -s, u[0], u[1], 0, g, 1), x = _.vertex(p, m, s, u[0], u[1], 0, g, 0);
|
|
7335
7748
|
_.indices.push(v, y, b, v, b, x), a += n[o];
|
|
7336
7749
|
}
|
|
7337
7750
|
}
|
|
@@ -7343,13 +7756,13 @@ function Yi(e) {
|
|
|
7343
7756
|
...o !== "z" && { axis: o }
|
|
7344
7757
|
});
|
|
7345
7758
|
}
|
|
7346
|
-
var
|
|
7347
|
-
function
|
|
7348
|
-
if (!e || e[0] * t[0] + e[1] * t[1] <
|
|
7759
|
+
var ua = Math.cos(Math.PI / 6);
|
|
7760
|
+
function da(e, t) {
|
|
7761
|
+
if (!e || e[0] * t[0] + e[1] * t[1] < ua) return t;
|
|
7349
7762
|
let n = e[0] + t[0], r = e[1] + t[1], i = Math.hypot(n, r) || 1;
|
|
7350
7763
|
return [n / i, r / i];
|
|
7351
7764
|
}
|
|
7352
|
-
function
|
|
7765
|
+
function fa(e, t, n, r) {
|
|
7353
7766
|
Array.isArray(n) || E(e, `'${t}' must be a list of [x, y] pairs, got ${j(n)}`);
|
|
7354
7767
|
let i = n;
|
|
7355
7768
|
return i.length < r && E(e, `'${t}' needs at least ${r} points, got ${i.length}`), i.map((n, r) => {
|
|
@@ -7358,7 +7771,7 @@ function Qi(e, t, n, r) {
|
|
|
7358
7771
|
return typeof i == "number" && typeof a == "number" && Number.isFinite(i) && Number.isFinite(a) || E(e, `'${t}' point ${r} must be two finite numbers, got ${j(n)}`), [i, a];
|
|
7359
7772
|
});
|
|
7360
7773
|
}
|
|
7361
|
-
function
|
|
7774
|
+
function pa(e, t = {}) {
|
|
7362
7775
|
e instanceof U || E("edges()", `expected a Geometry, got ${j(e)}`);
|
|
7363
7776
|
let { angle: n = 1 } = I("edges()", t, ["angle"], null);
|
|
7364
7777
|
n >= 0 && n < 180 || E("edges()", `'angle' is in degrees, 0 to under 180, got ${j(n)}`);
|
|
@@ -7400,7 +7813,7 @@ function $i(e, t = {}) {
|
|
|
7400
7813
|
indices: p
|
|
7401
7814
|
});
|
|
7402
7815
|
}
|
|
7403
|
-
function
|
|
7816
|
+
function ma(e) {
|
|
7404
7817
|
let t = "axes()", n = L(t, "size", I(t, e, $.axes, (e) => ({ size: e })).size, 1), r = new U({
|
|
7405
7818
|
positions: [
|
|
7406
7819
|
0,
|
|
@@ -7448,7 +7861,7 @@ function ea(e) {
|
|
|
7448
7861
|
size: n
|
|
7449
7862
|
}, r;
|
|
7450
7863
|
}
|
|
7451
|
-
function
|
|
7864
|
+
function ha(e) {
|
|
7452
7865
|
let t = "grid()", n = I(t, e, $.grid, (e) => ({ size: e }), { segments: "grid() uses 'divisions' for the number of squares along each side" }), r = L(t, "size", n.size, 10), i = R(t, "divisions", n.divisions, 10), a = r / 2, o = [];
|
|
7453
7866
|
for (let e = 0; e <= i; e++) {
|
|
7454
7867
|
let t = -a + r * e / i;
|
|
@@ -7461,7 +7874,7 @@ function ta(e) {
|
|
|
7461
7874
|
divisions: i
|
|
7462
7875
|
}, s;
|
|
7463
7876
|
}
|
|
7464
|
-
var
|
|
7877
|
+
var ga = class {
|
|
7465
7878
|
positions = [];
|
|
7466
7879
|
normals = [];
|
|
7467
7880
|
uvs = [];
|
|
@@ -7481,7 +7894,7 @@ var na = class {
|
|
|
7481
7894
|
}
|
|
7482
7895
|
turn(e, t) {
|
|
7483
7896
|
if (e === t) return;
|
|
7484
|
-
let n =
|
|
7897
|
+
let n = _a[e][t];
|
|
7485
7898
|
for (let e of [this.positions, this.normals]) for (let t = 0; t < e.length; t += 3) {
|
|
7486
7899
|
let [r, i, a] = n(e[t], e[t + 1], e[t + 2]);
|
|
7487
7900
|
e[t] = r, e[t + 1] = i, e[t + 2] = a;
|
|
@@ -7496,7 +7909,7 @@ var na = class {
|
|
|
7496
7909
|
});
|
|
7497
7910
|
return a.source = e, a;
|
|
7498
7911
|
}
|
|
7499
|
-
},
|
|
7912
|
+
}, _a = {
|
|
7500
7913
|
y: {
|
|
7501
7914
|
x: (e, t, n) => [
|
|
7502
7915
|
t,
|
|
@@ -7522,14 +7935,14 @@ var na = class {
|
|
|
7522
7935
|
]
|
|
7523
7936
|
}
|
|
7524
7937
|
};
|
|
7525
|
-
function
|
|
7938
|
+
function va(e, t, n) {
|
|
7526
7939
|
return t === void 0 ? n : P(e, "axis", t, [
|
|
7527
7940
|
"x",
|
|
7528
7941
|
"y",
|
|
7529
7942
|
"z"
|
|
7530
7943
|
]);
|
|
7531
7944
|
}
|
|
7532
|
-
function
|
|
7945
|
+
function ya(e) {
|
|
7533
7946
|
let t = e.filter((t, n) => {
|
|
7534
7947
|
let r = e[(n + e.length - 1) % e.length];
|
|
7535
7948
|
return t[0] !== r[0] || t[1] !== r[1];
|
|
@@ -7537,7 +7950,7 @@ function aa(e) {
|
|
|
7537
7950
|
return t.length >= 3 ? t : e;
|
|
7538
7951
|
}
|
|
7539
7952
|
// src/geometry/outline.js
|
|
7540
|
-
var
|
|
7953
|
+
var ba = Math.PI * 2, xa = {
|
|
7541
7954
|
circle: [
|
|
7542
7955
|
"radius",
|
|
7543
7956
|
"segments",
|
|
@@ -7570,7 +7983,7 @@ var oa = Math.PI * 2, sa = {
|
|
|
7570
7983
|
"depth",
|
|
7571
7984
|
"center"
|
|
7572
7985
|
]
|
|
7573
|
-
},
|
|
7986
|
+
}, Sa = {
|
|
7574
7987
|
r: "use 'radius'",
|
|
7575
7988
|
x: "use center: [x, y]",
|
|
7576
7989
|
y: "use center: [x, y]",
|
|
@@ -7580,17 +7993,17 @@ var oa = Math.PI * 2, sa = {
|
|
|
7580
7993
|
cornerRadius: "use 'radius' for the corners' rounding",
|
|
7581
7994
|
n: "use 'sides' (polygon) or 'segments'"
|
|
7582
7995
|
};
|
|
7583
|
-
function
|
|
7584
|
-
let t = "outline.circle()", n =
|
|
7996
|
+
function Ca(e) {
|
|
7997
|
+
let t = "outline.circle()", n = ka(t, e, xa.circle, (e) => ({ radius: e })), r = L(t, "radius", n.radius, 1), i = R(t, "segments", n.segments, 32, 3), [a, o] = Aa(t, "center", n.center);
|
|
7585
7998
|
return Array.from({ length: i }, (e, t) => {
|
|
7586
|
-
let n = t / i *
|
|
7999
|
+
let n = t / i * ba;
|
|
7587
8000
|
return [a + Math.cos(n) * r, o + Math.sin(n) * r];
|
|
7588
8001
|
});
|
|
7589
8002
|
}
|
|
7590
|
-
function
|
|
7591
|
-
let t = "outline.rect()", n =
|
|
8003
|
+
function wa(e) {
|
|
8004
|
+
let t = "outline.rect()", n = ka(t, e, xa.rect, (e) => ({ size: e })), r = L(t, "size", n.size, 1), i = L(t, "width", n.width, r), a = L(t, "height", n.height, r), o = n.radius === void 0 ? 0 : M(t, "radius", n.radius);
|
|
7592
8005
|
(o < 0 || o > Math.min(i, a) / 2) && E(t, `'radius' must be from 0 to half the shorter side (${Math.min(i, a) / 2}), got ${o}`);
|
|
7593
|
-
let s = R(t, "segments", n.segments, 8, 1), [c, l] =
|
|
8006
|
+
let s = R(t, "segments", n.segments, 8, 1), [c, l] = Aa(t, "center", n.center), u = i / 2, d = a / 2;
|
|
7594
8007
|
if (o === 0) return [
|
|
7595
8008
|
[c - u, l - d],
|
|
7596
8009
|
[c + u, l - d],
|
|
@@ -7625,26 +8038,26 @@ function ua(e) {
|
|
|
7625
8038
|
}
|
|
7626
8039
|
return f;
|
|
7627
8040
|
}
|
|
7628
|
-
function
|
|
7629
|
-
let t = "outline.polygon()", n =
|
|
8041
|
+
function Ta(e) {
|
|
8042
|
+
let t = "outline.polygon()", n = ka(t, e, xa.polygon, (e) => ({ radius: e })), r = L(t, "radius", n.radius, 1), i = R(t, "sides", n.sides, 6, 3), a = n.angle === void 0 ? 0 : M(t, "angle", n.angle), [o, s] = Aa(t, "center", n.center);
|
|
7630
8043
|
return Array.from({ length: i }, (e, t) => {
|
|
7631
|
-
let n = a + t / i *
|
|
8044
|
+
let n = a + t / i * ba;
|
|
7632
8045
|
return [o + Math.cos(n) * r, s + Math.sin(n) * r];
|
|
7633
8046
|
});
|
|
7634
8047
|
}
|
|
7635
|
-
function
|
|
7636
|
-
let t = "outline.arc()", n =
|
|
8048
|
+
function Ea(e) {
|
|
8049
|
+
let t = "outline.arc()", n = ka(t, e, xa.arc, null), r = L(t, "radius", n.radius, 1), i = n.from === void 0 ? 0 : M(t, "from", n.from), a = n.to === void 0 ? i + ba : M(t, "to", n.to);
|
|
7637
8050
|
a === i && E(t, "'from' and 'to' are the same angle - there's no arc between them");
|
|
7638
|
-
let o = R(t, "segments", n.segments, Math.max(1, Math.ceil(Math.abs(a - i) /
|
|
8051
|
+
let o = R(t, "segments", n.segments, Math.max(1, Math.ceil(Math.abs(a - i) / ba * 32)), 1), [s, c] = Aa(t, "center", n.center);
|
|
7639
8052
|
return Array.from({ length: o + 1 }, (e, t) => {
|
|
7640
8053
|
let n = i + (a - i) * t / o;
|
|
7641
8054
|
return [s + Math.cos(n) * r, c + Math.sin(n) * r];
|
|
7642
8055
|
});
|
|
7643
8056
|
}
|
|
7644
|
-
function
|
|
7645
|
-
let t = "outline.gear()", n =
|
|
8057
|
+
function Da(e) {
|
|
8058
|
+
let t = "outline.gear()", n = ka(t, e, xa.gear, (e) => ({ radius: e })), r = L(t, "radius", n.radius, 1), i = R(t, "teeth", n.teeth, 24, 3), a = L(t, "depth", n.depth, Math.min(r / 2, r * Math.PI / i));
|
|
7646
8059
|
a >= r && E(t, `'depth' must be less than the radius (${r}), got ${a}`);
|
|
7647
|
-
let [o, s] =
|
|
8060
|
+
let [o, s] = Aa(t, "center", n.center), c = r - a, l = ba / i, u = [];
|
|
7648
8061
|
for (let e = 0; e < i; e++) for (let [t, n] of [
|
|
7649
8062
|
[0, c],
|
|
7650
8063
|
[.12, r],
|
|
@@ -7656,43 +8069,43 @@ function pa(e) {
|
|
|
7656
8069
|
}
|
|
7657
8070
|
return u;
|
|
7658
8071
|
}
|
|
7659
|
-
var
|
|
7660
|
-
circle:
|
|
7661
|
-
rect:
|
|
7662
|
-
polygon:
|
|
7663
|
-
arc:
|
|
7664
|
-
gear:
|
|
7665
|
-
},
|
|
7666
|
-
function
|
|
8072
|
+
var Oa = {
|
|
8073
|
+
circle: Ca,
|
|
8074
|
+
rect: wa,
|
|
8075
|
+
polygon: Ta,
|
|
8076
|
+
arc: Ea,
|
|
8077
|
+
gear: Da
|
|
8078
|
+
}, ka = (e, t, n, r) => I(e, t, n, r, Sa);
|
|
8079
|
+
function Aa(e, t, n) {
|
|
7667
8080
|
if (n === void 0) return [0, 0];
|
|
7668
8081
|
let r = n;
|
|
7669
8082
|
return r && typeof r == "object" && typeof r[0] == "number" && typeof r[1] == "number" && Number.isFinite(r[0]) && Number.isFinite(r[1]) || E(e, `'${t}' must be [x, y], got ${j(n)}`), [r[0], r[1]];
|
|
7670
8083
|
}
|
|
7671
8084
|
// src/geometry/fromPolygons.js
|
|
7672
|
-
var
|
|
7673
|
-
function
|
|
7674
|
-
A(
|
|
8085
|
+
var ja = "fromPolygons()";
|
|
8086
|
+
function Ma(e) {
|
|
8087
|
+
A(ja, e, [
|
|
7675
8088
|
"points",
|
|
7676
8089
|
"polygons",
|
|
7677
8090
|
"edges",
|
|
7678
8091
|
"smooth"
|
|
7679
8092
|
]);
|
|
7680
8093
|
let { points: t, polygons: n } = e ?? {};
|
|
7681
|
-
Array.isArray(t) || E(
|
|
8094
|
+
Array.isArray(t) || E(ja, `'points' must be an array of { x, y, z } or [x, y, z], got ${j(t)}`), Array.isArray(n) || E(ja, `'polygons' must be an array of { vertices: [...] }, got ${j(n)}`);
|
|
7682
8095
|
let r = t.map((e, t) => {
|
|
7683
8096
|
let n = Array.isArray(e) ? e : e && typeof e == "object" ? [
|
|
7684
8097
|
e.x,
|
|
7685
8098
|
e.y,
|
|
7686
8099
|
e.z
|
|
7687
8100
|
] : null;
|
|
7688
|
-
return n && n.length === 3 && n.every(Number.isFinite) || E(
|
|
8101
|
+
return n && n.length === 3 && n.every(Number.isFinite) || E(ja, `point ${t} must be { x, y, z } or [x, y, z] numbers, got ${j(e)}`), n;
|
|
7689
8102
|
});
|
|
7690
8103
|
n.forEach((e, t) => {
|
|
7691
8104
|
let n = e?.vertices;
|
|
7692
|
-
(!Array.isArray(n) || n.length < 3) && E(
|
|
7693
|
-
for (let e of n) (!Number.isInteger(e) || e < 0 || e >= r.length) && E(
|
|
8105
|
+
(!Array.isArray(n) || n.length < 3) && E(ja, `polygon ${t} needs 'vertices' with 3 or more point indices, got ${j(n)}`);
|
|
8106
|
+
for (let e of n) (!Number.isInteger(e) || e < 0 || e >= r.length) && E(ja, `polygon ${t} refers to point ${j(e)} but there are only ${r.length} points`);
|
|
7694
8107
|
let i = e.uvs;
|
|
7695
|
-
i === void 0 || Array.isArray(i) && i.length === n.length * 2 && i.every(Number.isFinite) || E(
|
|
8108
|
+
i === void 0 || Array.isArray(i) && i.length === n.length * 2 && i.every(Number.isFinite) || E(ja, `polygon ${t} 'uvs' must be ${n.length * 2} numbers (a u, v pair per vertex), got ${j(i)}`);
|
|
7696
8109
|
});
|
|
7697
8110
|
let i = [];
|
|
7698
8111
|
n.forEach(({ vertices: e }, t) => {
|
|
@@ -7716,29 +8129,29 @@ function va(e) {
|
|
|
7716
8129
|
return a.computeNormals({ flat: !(e.smooth && !o) });
|
|
7717
8130
|
}
|
|
7718
8131
|
// src/geometry/Curve.js
|
|
7719
|
-
var
|
|
8132
|
+
var Na = ["closed", "tension"], Pa = {
|
|
7720
8133
|
loop: "use 'closed: true'",
|
|
7721
8134
|
smooth: "the curve is always smooth - 'tension' (0-1) sets how tight"
|
|
7722
|
-
},
|
|
8135
|
+
}, Fa = ["segments", "dash"], Ia = { dashed: "use 'dash: [on, off]' - lengths in the curve's units" }, La = [
|
|
7723
8136
|
"radius",
|
|
7724
8137
|
"segments",
|
|
7725
8138
|
"sides"
|
|
7726
|
-
],
|
|
8139
|
+
], Ra = {
|
|
7727
8140
|
tubularSegments: "use 'segments'",
|
|
7728
8141
|
radialSegments: "use 'sides'"
|
|
7729
|
-
},
|
|
8142
|
+
}, za = [
|
|
7730
8143
|
"plane",
|
|
7731
8144
|
"radius",
|
|
7732
8145
|
"center",
|
|
7733
8146
|
"tilt"
|
|
7734
|
-
],
|
|
8147
|
+
], Ba = 48, Va = class {
|
|
7735
8148
|
#e;
|
|
7736
8149
|
#t;
|
|
7737
8150
|
#n;
|
|
7738
8151
|
#r;
|
|
7739
8152
|
constructor(e, t = {}) {
|
|
7740
|
-
(!Array.isArray(e) || e.length < 2) && E("curve()", `needs an array of two or more points, got ${j(e)}`), A("curve()", t,
|
|
7741
|
-
let n = this.#i() *
|
|
8153
|
+
(!Array.isArray(e) || e.length < 2) && E("curve()", `needs an array of two or more points, got ${j(e)}`), A("curve()", t, Na, Pa), this.#e = e.map((e) => z.fromInput(e, "curve()")), this.#t = !!t.closed, this.#n = t.tension === void 0 ? 0 : M("curve()", "tension", t.tension);
|
|
8154
|
+
let n = this.#i() * Ba;
|
|
7742
8155
|
this.#r = new Float64Array(n + 1);
|
|
7743
8156
|
let r = this.#s(0);
|
|
7744
8157
|
for (let e = 1; e <= n; e++) {
|
|
@@ -7764,7 +8177,7 @@ var ya = ["closed", "tension"], ba = {
|
|
|
7764
8177
|
return Array.from({ length: t }, (e, t) => this.at(t / n));
|
|
7765
8178
|
}
|
|
7766
8179
|
line(e = {}) {
|
|
7767
|
-
A("curve.line()", e,
|
|
8180
|
+
A("curve.line()", e, Fa, Ia);
|
|
7768
8181
|
let t = this.#a("curve.line()", e.segments), n = this.length / t, r = [], i = (e, t) => {
|
|
7769
8182
|
let i = Math.max(1, Math.ceil((t - e) / n - 1e-9)), a = this.at(e / this.length);
|
|
7770
8183
|
for (let n = 1; n <= i; n++) {
|
|
@@ -7781,7 +8194,7 @@ var ya = ["closed", "tension"], ba = {
|
|
|
7781
8194
|
return new U({ positions: r });
|
|
7782
8195
|
}
|
|
7783
8196
|
tube(e = {}) {
|
|
7784
|
-
A("curve.tube()", e,
|
|
8197
|
+
A("curve.tube()", e, La, Ra);
|
|
7785
8198
|
let t = e.radius === void 0 ? .1 : M("curve.tube()", "radius", e.radius), n = R("curve.tube()", "sides", e.sides, 8, 3), r = this.#a("curve.tube()", e.segments), i = this.#t ? r : r + 1, a = [], o = [], s = this.tangentAt(0), c = new z(...Math.abs(s[1]) < .9 ? [
|
|
7786
8199
|
0,
|
|
7787
8200
|
1,
|
|
@@ -7836,17 +8249,17 @@ var ya = ["closed", "tension"], ba = {
|
|
|
7836
8249
|
return t;
|
|
7837
8250
|
}
|
|
7838
8251
|
};
|
|
7839
|
-
function
|
|
7840
|
-
return new
|
|
8252
|
+
function Ha(e, t) {
|
|
8253
|
+
return new Va(e, t);
|
|
7841
8254
|
}
|
|
7842
|
-
function
|
|
8255
|
+
function Ua(e = {}) {
|
|
7843
8256
|
let t = e.plane === void 0 ? "xz" : P("ellipse()", "plane", e.plane, [
|
|
7844
8257
|
"xz",
|
|
7845
8258
|
"xy",
|
|
7846
8259
|
"yz"
|
|
7847
8260
|
]), [n, r] = [...t].map((e) => "xyz".indexOf(e)), i = (e) => `radius${"XYZ"[e]}`, a = i(3 - n - r);
|
|
7848
8261
|
A("ellipse()", e, [
|
|
7849
|
-
...
|
|
8262
|
+
...za,
|
|
7850
8263
|
i(n),
|
|
7851
8264
|
i(r)
|
|
7852
8265
|
], { [a]: `an ellipse in '${t}' has '${i(n)}' and '${i(r)}' - set plane for another` });
|
|
@@ -7861,21 +8274,21 @@ function ka(e = {}) {
|
|
|
7861
8274
|
];
|
|
7862
8275
|
f[n] = 1;
|
|
7863
8276
|
let p = Ee(/* @__PURE__ */ new Float32Array(4), f, d);
|
|
7864
|
-
return new
|
|
8277
|
+
return new Va(Array.from({ length: 64 }, (e, t) => {
|
|
7865
8278
|
let i = t / 64 * Math.PI * 2, a = new z();
|
|
7866
8279
|
return a[n] = Math.cos(i) * c, a[r] = Math.sin(i) * l, a.applyQuaternion(p).add(u);
|
|
7867
8280
|
}), { closed: !0 });
|
|
7868
8281
|
}
|
|
7869
8282
|
// src/registry.js
|
|
7870
|
-
var
|
|
7871
|
-
function
|
|
7872
|
-
|
|
8283
|
+
var Wa = /* @__PURE__ */ new Map();
|
|
8284
|
+
function Ga(e) {
|
|
8285
|
+
Wa.set(e.type, e);
|
|
7873
8286
|
}
|
|
7874
|
-
function
|
|
7875
|
-
return
|
|
8287
|
+
function Ka() {
|
|
8288
|
+
return Wa;
|
|
7876
8289
|
}
|
|
7877
8290
|
// src/describe.js
|
|
7878
|
-
var
|
|
8291
|
+
var qa = [
|
|
7879
8292
|
"box",
|
|
7880
8293
|
"sphere",
|
|
7881
8294
|
"plane",
|
|
@@ -7886,27 +8299,27 @@ var Na = [
|
|
|
7886
8299
|
"extrude",
|
|
7887
8300
|
"axes",
|
|
7888
8301
|
"grid"
|
|
7889
|
-
],
|
|
7890
|
-
|
|
8302
|
+
], Ja = null, Ya = () => {
|
|
8303
|
+
Ja ??= new Map([
|
|
7891
8304
|
K,
|
|
7892
|
-
|
|
7893
|
-
|
|
7894
|
-
|
|
7895
|
-
Mt,
|
|
7896
|
-
Nt,
|
|
8305
|
+
_t,
|
|
8306
|
+
lr,
|
|
8307
|
+
Ot,
|
|
7897
8308
|
Pt,
|
|
7898
8309
|
Ft,
|
|
7899
|
-
|
|
7900
|
-
|
|
7901
|
-
|
|
7902
|
-
|
|
7903
|
-
|
|
7904
|
-
|
|
7905
|
-
|
|
8310
|
+
Lt,
|
|
8311
|
+
Rt,
|
|
8312
|
+
Tn,
|
|
8313
|
+
En,
|
|
8314
|
+
mr,
|
|
8315
|
+
hr,
|
|
8316
|
+
_r,
|
|
8317
|
+
vr,
|
|
8318
|
+
yr
|
|
7906
8319
|
].map((e) => [e.type, e]));
|
|
7907
|
-
for (let [e, t] of
|
|
7908
|
-
return
|
|
7909
|
-
},
|
|
8320
|
+
for (let [e, t] of Ka()) Ja.set(e, t);
|
|
8321
|
+
return Ja;
|
|
8322
|
+
}, Xa = {
|
|
7910
8323
|
Mesh: "mesh",
|
|
7911
8324
|
Group: "group",
|
|
7912
8325
|
Object3D: "node",
|
|
@@ -7924,10 +8337,10 @@ var Na = [
|
|
|
7924
8337
|
Scene: "scene",
|
|
7925
8338
|
light: "directional-light",
|
|
7926
8339
|
camera: "perspective-camera"
|
|
7927
|
-
},
|
|
8340
|
+
}, Za = {
|
|
7928
8341
|
chart: "import { chart } from 'phoria2/charts' first, which registers 'chart'",
|
|
7929
8342
|
emitter: "'emitter' descriptions aren't supported yet - use new Emitter() from 'phoria2/particles'"
|
|
7930
|
-
},
|
|
8343
|
+
}, Qa = {
|
|
7931
8344
|
cube: "box",
|
|
7932
8345
|
ball: "sphere",
|
|
7933
8346
|
globe: "sphere",
|
|
@@ -7947,213 +8360,29 @@ var Na = [
|
|
|
7947
8360
|
ExtrudeGeometry: "extrude",
|
|
7948
8361
|
ShapeGeometry: "extrude"
|
|
7949
8362
|
};
|
|
7950
|
-
function
|
|
8363
|
+
function $a(e) {
|
|
7951
8364
|
if (/Material$/.test(e)) return "materials aren't nodes - give a mesh material: { color, roughness, metalness, ... }";
|
|
7952
|
-
let t =
|
|
8365
|
+
let t = Qa[e];
|
|
7953
8366
|
return t ? `geometry isn't a node - give a mesh geometry: { type: '${t}', ... }` : null;
|
|
7954
8367
|
}
|
|
7955
|
-
function
|
|
8368
|
+
function eo(e) {
|
|
7956
8369
|
if (e instanceof K) return e;
|
|
7957
8370
|
(!e || typeof e != "object" || Array.isArray(e)) && E("create()", `expected a description such as { type: 'mesh', ... }, got ${j(e)}`);
|
|
7958
8371
|
let { type: t, ...n } = e;
|
|
7959
|
-
typeof t != "string" && E("create()", `a description needs a 'type': one of ${[...
|
|
7960
|
-
let r =
|
|
8372
|
+
typeof t != "string" && E("create()", `a description needs a 'type': one of ${[...Ya().keys()].join(", ")}`);
|
|
8373
|
+
let r = Ya().get(t);
|
|
7961
8374
|
if (!r) {
|
|
7962
|
-
let e =
|
|
7963
|
-
E("create()", `unknown type '${t}' - ${e ? `use '${e}'` : n ?? `expected one of ${[...
|
|
8375
|
+
let e = Xa[t], n = $a(t) ?? Za[t];
|
|
8376
|
+
E("create()", `unknown type '${t}' - ${e ? `use '${e}'` : n ?? `expected one of ${[...Ya().keys()].join(", ")}${k(t, Ya().keys())}`}`);
|
|
7964
8377
|
}
|
|
7965
|
-
return Array.isArray(n.children) && (n.children = n.children.map((e) =>
|
|
8378
|
+
return Array.isArray(n.children) && (n.children = n.children.map((e) => eo(e))), n.geometry && !(n.geometry instanceof U) && typeof n.geometry == "object" && "type" in n.geometry && (n.geometry = to(n.geometry, `create({ type: '${t}' })`)), new r(n);
|
|
7966
8379
|
}
|
|
7967
|
-
function
|
|
7968
|
-
let { type: n, ...r } = e, i =
|
|
7969
|
-
i && E(t, `geometry type '${n}' - use '${i}'`), P(t, "geometry.type", n,
|
|
7970
|
-
let a =
|
|
8380
|
+
function to(e, t = "createGeometry()") {
|
|
8381
|
+
let { type: n, ...r } = e, i = Qa[n];
|
|
8382
|
+
i && E(t, `geometry type '${n}' - use '${i}'`), P(t, "geometry.type", n, qa);
|
|
8383
|
+
let a = Zi[n];
|
|
7971
8384
|
return a(Object.keys(r).length ? r : void 0);
|
|
7972
8385
|
}
|
|
7973
|
-
|
|
7974
|
-
var Ha = /* @__PURE__ */ t({ Keyboard: () => Ka }), Ua = ":where(.phoria-sr-only) { position: absolute; width: 1px; height: 1px; margin: -1px; padding: 0; overflow: hidden;\n clip: rect(0 0 0 0); clip-path: inset(50%); white-space: nowrap; border: 0; }", Wa = 10, Ga = 0, Ka = class {
|
|
7975
|
-
#e;
|
|
7976
|
-
#t;
|
|
7977
|
-
#n;
|
|
7978
|
-
#r = null;
|
|
7979
|
-
#i;
|
|
7980
|
-
#a;
|
|
7981
|
-
#o;
|
|
7982
|
-
#s = "";
|
|
7983
|
-
#c = !0;
|
|
7984
|
-
#l = [];
|
|
7985
|
-
constructor(e, t, n) {
|
|
7986
|
-
if (this.#e = e, this.#t = t, this.#n = n, !document.getElementById("phoria-sr-style")) {
|
|
7987
|
-
let e = document.createElement("style");
|
|
7988
|
-
e.id = "phoria-sr-style", e.textContent = Ua, document.head.prepend(e);
|
|
7989
|
-
}
|
|
7990
|
-
let r = e.canvas, i = `phoria-keys-${++Ga}`;
|
|
7991
|
-
this.#i = document.createElement("div"), this.#i.className = "phoria-sr-only", this.#i.setAttribute("aria-live", "polite"), this.#i.setAttribute("aria-atomic", "true"), this.#a = document.createElement("div"), this.#a.className = "phoria-sr-only", this.#a.id = i, r.after(this.#i, this.#a), this.#o = [
|
|
7992
|
-
"tabindex",
|
|
7993
|
-
"role",
|
|
7994
|
-
"aria-roledescription",
|
|
7995
|
-
"aria-label",
|
|
7996
|
-
"aria-describedby"
|
|
7997
|
-
].map((e) => [e, r.getAttribute(e)]), r.hasAttribute("tabindex") || (r.tabIndex = 0), r.setAttribute("role", "application"), r.setAttribute("aria-roledescription", "3D view"), r.setAttribute("aria-describedby", i);
|
|
7998
|
-
let a = (e) => this.#d(e), o = () => this.clear(), s = () => this.#u();
|
|
7999
|
-
r.addEventListener("keydown", a), r.addEventListener("blur", o), r.addEventListener("focus", s), this.#l.push(() => {
|
|
8000
|
-
r.removeEventListener("keydown", a), r.removeEventListener("blur", o), r.removeEventListener("focus", s);
|
|
8001
|
-
}), this.#u();
|
|
8002
|
-
}
|
|
8003
|
-
setDescription(e) {
|
|
8004
|
-
this.#c = e === null, this.#s = e ?? "", this.#u();
|
|
8005
|
-
}
|
|
8006
|
-
#u() {
|
|
8007
|
-
let e = this.#p().length, t = this.#c ? $a(this.#e.scene, e) : this.#s;
|
|
8008
|
-
this.#e.canvas.setAttribute("aria-label", t), this.#a.textContent = e ? `Use the arrow keys to move between ${e === 1 ? "the one item" : `${e} items`}, Enter to select, Escape to leave.` : "Nothing here can be selected.";
|
|
8009
|
-
}
|
|
8010
|
-
clear() {
|
|
8011
|
-
this.#r && (this.#r = null, this.#t.focus(null));
|
|
8012
|
-
}
|
|
8013
|
-
#d(e) {
|
|
8014
|
-
if (e.altKey || e.ctrlKey || e.metaKey) return;
|
|
8015
|
-
let t = this.#p(), n = this.#r ? t.findIndex((e) => qa(e, this.#r)) : -1;
|
|
8016
|
-
switch (e.key) {
|
|
8017
|
-
case "ArrowRight":
|
|
8018
|
-
case "ArrowDown":
|
|
8019
|
-
n = n < 0 ? 0 : Math.min(t.length - 1, n + 1);
|
|
8020
|
-
break;
|
|
8021
|
-
case "ArrowLeft":
|
|
8022
|
-
case "ArrowUp":
|
|
8023
|
-
n = n < 0 ? t.length - 1 : Math.max(0, n - 1);
|
|
8024
|
-
break;
|
|
8025
|
-
case "PageDown":
|
|
8026
|
-
n = Math.min(t.length - 1, Math.max(0, n) + Wa);
|
|
8027
|
-
break;
|
|
8028
|
-
case "PageUp":
|
|
8029
|
-
n = Math.max(0, n - Wa);
|
|
8030
|
-
break;
|
|
8031
|
-
case "Home":
|
|
8032
|
-
n = 0;
|
|
8033
|
-
break;
|
|
8034
|
-
case "End":
|
|
8035
|
-
n = t.length - 1;
|
|
8036
|
-
break;
|
|
8037
|
-
case "Enter":
|
|
8038
|
-
case " ":
|
|
8039
|
-
if (!this.#r || n < 0) return;
|
|
8040
|
-
e.preventDefault(), this.#t.press(Ya(t[n]));
|
|
8041
|
-
return;
|
|
8042
|
-
case "Escape":
|
|
8043
|
-
if (!this.#r) return;
|
|
8044
|
-
e.preventDefault(), this.clear(), this.#i.textContent = "";
|
|
8045
|
-
return;
|
|
8046
|
-
default: return;
|
|
8047
|
-
}
|
|
8048
|
-
if (e.preventDefault(), !t.length) {
|
|
8049
|
-
this.#i.textContent = "Nothing here can be selected.";
|
|
8050
|
-
return;
|
|
8051
|
-
}
|
|
8052
|
-
this.#r = t[n];
|
|
8053
|
-
let r = Ya(t[n]);
|
|
8054
|
-
this.#t.focus(r), this.#i.textContent = `${this.#n.label?.(r) ?? this.#f(r)}. ${n + 1} of ${t.length}`;
|
|
8055
|
-
}
|
|
8056
|
-
#f(e) {
|
|
8057
|
-
let t = Za(this.#t.tooltip(e));
|
|
8058
|
-
if (t) return t;
|
|
8059
|
-
let n = e.datum;
|
|
8060
|
-
if (n != null) {
|
|
8061
|
-
if (typeof n != "object") return String(n);
|
|
8062
|
-
let e = Object.entries(n).filter(([, e]) => typeof e != "object" || !e).slice(0, 4).map(([e, t]) => `${e}: ${Qa(t)}`);
|
|
8063
|
-
if (e.length) return e.join(", ");
|
|
8064
|
-
}
|
|
8065
|
-
for (let t = e.node; t; t = t.parent) if (t.name) return t.name;
|
|
8066
|
-
return "Item";
|
|
8067
|
-
}
|
|
8068
|
-
#p() {
|
|
8069
|
-
let e = [], t = [], n = this.#t.viewWide(), r = /* @__PURE__ */ new Set(), i = (a, o, s) => {
|
|
8070
|
-
if (!a.visible || a.pickable === !1) return;
|
|
8071
|
-
let c = !!(a.tooltip || a.onDrag || a.highlight || a.handlersFor("click").length || a.handlersFor("hover").length);
|
|
8072
|
-
if (o ||= c, s = a.highlightWhole ? a : s, a.isDrawable) {
|
|
8073
|
-
if (s) (o || n) && !r.has(s) && (r.add(s), e.push({
|
|
8074
|
-
node: a,
|
|
8075
|
-
index: null,
|
|
8076
|
-
whole: s
|
|
8077
|
-
}));
|
|
8078
|
-
else if ("instanceMatrices" in a) for (let t = 0; t < a.count; t++) !jt(a.instanceMatrices, t) && (o || n && a.datumAt(t) !== null) && e.push({
|
|
8079
|
-
node: a,
|
|
8080
|
-
index: t,
|
|
8081
|
-
whole: null
|
|
8082
|
-
});
|
|
8083
|
-
else if (a.drawMode === "points" && Array.isArray(a.data) || Ja(a)) for (let t = 0; t < a.data.length; t++) (o || n) && e.push({
|
|
8084
|
-
node: a,
|
|
8085
|
-
index: t,
|
|
8086
|
-
whole: null
|
|
8087
|
-
});
|
|
8088
|
-
else if (a.drawMode === "lines" && Array.isArray(a.data)) for (let e = 0; e < a.data.length; e++) (o || n) && t.push({
|
|
8089
|
-
node: a,
|
|
8090
|
-
index: e,
|
|
8091
|
-
whole: null
|
|
8092
|
-
});
|
|
8093
|
-
else (c || (o || n) && (a.name || a.datumAt(null) !== null)) && e.push({
|
|
8094
|
-
node: a,
|
|
8095
|
-
index: null,
|
|
8096
|
-
whole: null
|
|
8097
|
-
});
|
|
8098
|
-
}
|
|
8099
|
-
for (let e of a.children) i(e, o, s);
|
|
8100
|
-
};
|
|
8101
|
-
return i(this.#e.scene, !1, null), e.concat(t);
|
|
8102
|
-
}
|
|
8103
|
-
dispose() {
|
|
8104
|
-
for (let e of this.#l) e();
|
|
8105
|
-
let e = this.#e.canvas;
|
|
8106
|
-
for (let [t, n] of this.#o) n === null ? e.removeAttribute(t) : e.setAttribute(t, n);
|
|
8107
|
-
this.#i.remove(), this.#a.remove();
|
|
8108
|
-
}
|
|
8109
|
-
}, qa = (e, t) => e.node === t.node && e.index === t.index, Ja = (e) => e.drawMode === "triangles" && !("instanceMatrices" in e) && Array.isArray(e.data) && e.data.length === e.geometry.vertexCount;
|
|
8110
|
-
function Ya({ node: e, index: t, whole: n }) {
|
|
8111
|
-
let r = e, i = t !== null && r.drawMode === "points", a = t !== null && Ja(r), o = t !== null && r.drawMode === "lines", s;
|
|
8112
|
-
if (n) s = n.bounds.getCenter();
|
|
8113
|
-
else if (t !== null && "instanceMatrices" in r) {
|
|
8114
|
-
e.updateWorld();
|
|
8115
|
-
let n = r.geometry.bounds.getCenter();
|
|
8116
|
-
s = Xa(r.worldMatrix, Xa(r.instanceMatrices.subarray(t * 16, t * 16 + 16), n));
|
|
8117
|
-
} else if (i || a) {
|
|
8118
|
-
let n = r.geometry.positions;
|
|
8119
|
-
e.updateWorld(), s = Xa(r.worldMatrix, new z(n[t * 3], n[t * 3 + 1], n[t * 3 + 2]));
|
|
8120
|
-
} else if (o) {
|
|
8121
|
-
let n = r.geometry.positions, i = r.geometry.indices, a = i ? i[t * 2] : t * 2, o = i ? i[t * 2 + 1] : t * 2 + 1;
|
|
8122
|
-
e.updateWorld(), s = Xa(r.worldMatrix, new z((n[a * 3] + n[o * 3]) / 2, (n[a * 3 + 1] + n[o * 3 + 1]) / 2, (n[a * 3 + 2] + n[o * 3 + 2]) / 2));
|
|
8123
|
-
} else s = e.bounds.getCenter();
|
|
8124
|
-
return {
|
|
8125
|
-
node: e,
|
|
8126
|
-
point: s,
|
|
8127
|
-
distance: 0,
|
|
8128
|
-
normal: null,
|
|
8129
|
-
face: i || o ? t : null,
|
|
8130
|
-
instance: t !== null && !i && !a && !o ? t : null,
|
|
8131
|
-
uv: null,
|
|
8132
|
-
datum: a ? r.data[t] ?? null : r.datumAt?.(t) ?? null
|
|
8133
|
-
};
|
|
8134
|
-
}
|
|
8135
|
-
function Xa(e, t) {
|
|
8136
|
-
let [n, r, i] = t;
|
|
8137
|
-
return new z(e[0] * n + e[4] * r + e[8] * i + e[12], e[1] * n + e[5] * r + e[9] * i + e[13], e[2] * n + e[6] * r + e[10] * i + e[14]);
|
|
8138
|
-
}
|
|
8139
|
-
function Za(e) {
|
|
8140
|
-
if (e == null || e === !1 || e === "") return "";
|
|
8141
|
-
if (typeof e == "string" || typeof e == "number") return String(e).replace(/\s*\n\s*/g, ", ");
|
|
8142
|
-
if (globalThis.Node !== void 0 && e instanceof globalThis.Node) return (e.textContent ?? "").trim();
|
|
8143
|
-
if (typeof e == "object") {
|
|
8144
|
-
let t = e, n = t.rows ? (Array.isArray(t.rows) ? t.rows : Object.entries(t.rows)).map(([e, t]) => `${e}: ${Qa(t)}`) : [];
|
|
8145
|
-
return [t.title, ...n].filter((e) => e !== void 0 && e !== "").join(", ");
|
|
8146
|
-
}
|
|
8147
|
-
return "";
|
|
8148
|
-
}
|
|
8149
|
-
var Qa = (e) => typeof e == "number" ? e.toLocaleString() : String(e);
|
|
8150
|
-
function $a(e, t) {
|
|
8151
|
-
let n = [];
|
|
8152
|
-
return e.traverse((t) => {
|
|
8153
|
-
let r = t.summary;
|
|
8154
|
-
t !== e && t.visible && typeof r == "function" && n.push(r.call(t));
|
|
8155
|
-
}), n.length || n.push(t ? `3D view of ${t === 1 ? "one item" : `${t} items`}` : "3D view"), n.join(". ");
|
|
8156
|
-
}
|
|
8157
|
-
export { Pt as $, Sr as A, E as At, Ln as B, vr as C, z as Ct, Dr as D, A as Dt, xr as E, P as Et, dr as F, a as Ft, Cn as G, Tn as H, fr as I, s as It, It as J, Sn as K, nr as L, ur as M, x as Mt, cr as N, r as Nt, Cr as O, j as Ot, or as P, o as Pt, Ft as Q, tr as R, mr as S, B as St, br as T, M as Tt, Dn as U, Mn as V, xn as W, Tt as X, Jt as Y, Mt as Z, Hi as _, H as _t, ka as a, Qe as at, ii as b, ae as bt, ea as c, U as ct, $i as d, De as dt, Et as et, Yi as f, Oe as ft, Ui as g, Se as gt, Ji as h, Te as ht, Oa as i, K as it, sr as j, F as jt, Tr as k, k as kt, Bi as l, Ne as lt, qi as m, Ae as mt, ja as n, ht as nt, va as o, W as ot, ta as p, Ee as pt, mn as q, Da as r, G as rt, ma as s, He as st, Ba as t, Nt as tt, Wi as u, je as ut, Ki as v, se as vt, yr as w, T as wt, Rr as x, V as xt, mi as y, ne as yt, Yn as z };
|
|
8386
|
+
export { Lt as $, kr as A, k as At, Bn as B, Tr as C, B as Ct, Pr as D, P as Dt, Or as E, M as Et, vr as F, o as Ft, En as G, On as H, yr as I, a as It, zt as J, Tn as K, lr as L, s as Lt, _r as M, F as Mt, hr as N, x as Nt, Ar as O, A as Ot, pr as P, r as Pt, Rt as Q, cr as R, xr as S, V as St, Dr as T, T as Tt, An as U, Fn as V, wn as W, Dt as X, Zt as Y, Pt as Z, na as _, Se as _t, Ua as a, K as at, vi as b, ne as bt, ma as c, We as ct, pa as d, je as dt, Ot as et, la as f, De as ft, ra as g, Te as gt, ca as h, Ae as ht, Ha as i, G as it, mr as j, E as jt, Mr as k, j as kt, ea as l, U as lt, sa as m, Ee as mt, Ga as n, Nt as nt, Ma as o, et as ot, ha as p, Oe as pt, _n as q, Va as r, _t as rt, Oa as s, W as st, eo as t, Ft as tt, ia as u, Ne as ut, oa as v, H as vt, Er as w, z as wt, qr as x, ae as xt, Oi as y, se as yt, Qn as z };
|
|
8158
8387
|
|
|
8159
8388
|
//# sourceMappingURL=core.js.map
|