@almadar/ui 5.143.0 → 5.145.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/dist/avl/index.cjs +89 -9
- package/dist/avl/index.js +91 -11
- package/dist/{avl-schema-parser-0hkiHOq3.d.ts → avl-schema-parser-BRJ77Yze.d.ts} +12 -2
- package/dist/{avl-schema-parser-BZ8pICOS.d.cts → avl-schema-parser-DVmrgdwc.d.cts} +12 -2
- package/dist/{cn-CvImTgKH.d.cts → cn-BdGFhYe3.d.cts} +1 -1
- package/dist/{cn-DryTiahe.d.ts → cn-DNkqAWZK.d.ts} +1 -1
- package/dist/components/index.cjs +186 -135
- package/dist/components/index.d.cts +7 -5
- package/dist/components/index.d.ts +7 -5
- package/dist/components/index.js +187 -136
- package/dist/lib/drawable/three/index.cjs +187 -134
- package/dist/lib/drawable/three/index.d.cts +3 -3
- package/dist/lib/drawable/three/index.d.ts +3 -3
- package/dist/lib/drawable/three/index.js +162 -109
- package/dist/lib/index.d.cts +2 -2
- package/dist/lib/index.d.ts +2 -2
- package/dist/marketing/index.cjs +6 -1
- package/dist/marketing/index.js +6 -1
- package/dist/{paintDispatch-D3-5_cOb.d.cts → paintDispatch-Cb_hQj4Y.d.cts} +7 -1
- package/dist/{paintDispatch-D3-5_cOb.d.ts → paintDispatch-Cb_hQj4Y.d.ts} +7 -1
- package/dist/providers/index.cjs +82 -7
- package/dist/providers/index.js +83 -8
- package/dist/runtime/index.cjs +89 -9
- package/dist/runtime/index.js +91 -11
- package/package.json +5 -4
|
@@ -4,7 +4,7 @@ var React3 = require('react');
|
|
|
4
4
|
var providers = require('@almadar/ui/providers');
|
|
5
5
|
var logger = require('@almadar/logger');
|
|
6
6
|
var fiber = require('@react-three/fiber');
|
|
7
|
-
var
|
|
7
|
+
var THREE5 = require('three');
|
|
8
8
|
var RoomEnvironment_js = require('three/examples/jsm/environments/RoomEnvironment.js');
|
|
9
9
|
var drei = require('@react-three/drei');
|
|
10
10
|
var jsxRuntime = require('react/jsx-runtime');
|
|
@@ -39,7 +39,7 @@ function _interopNamespace(e) {
|
|
|
39
39
|
}
|
|
40
40
|
|
|
41
41
|
var React3__default = /*#__PURE__*/_interopDefault(React3);
|
|
42
|
-
var
|
|
42
|
+
var THREE5__namespace = /*#__PURE__*/_interopNamespace(THREE5);
|
|
43
43
|
|
|
44
44
|
var __defProp = Object.defineProperty;
|
|
45
45
|
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
@@ -531,7 +531,7 @@ function Lighting3D({
|
|
|
531
531
|
"directionalLightHelper",
|
|
532
532
|
{
|
|
533
533
|
args: [
|
|
534
|
-
new
|
|
534
|
+
new THREE5__namespace.DirectionalLight(directionalColor, directionalIntensity),
|
|
535
535
|
5
|
|
536
536
|
]
|
|
537
537
|
}
|
|
@@ -588,8 +588,8 @@ function FollowCamera3D({
|
|
|
588
588
|
offset
|
|
589
589
|
}) {
|
|
590
590
|
const { camera } = fiber.useThree();
|
|
591
|
-
const look = React3.useRef(new
|
|
592
|
-
const goal = React3.useRef(new
|
|
591
|
+
const look = React3.useRef(new THREE5__namespace.Vector3(target[0], target[1], target[2]));
|
|
592
|
+
const goal = React3.useRef(new THREE5__namespace.Vector3());
|
|
593
593
|
fiber.useFrame((_, delta) => {
|
|
594
594
|
const t = Math.min(1, delta * 5);
|
|
595
595
|
goal.current.set(target[0] + offset[0], target[1] + offset[1], target[2] + offset[2]);
|
|
@@ -789,6 +789,10 @@ var atlasCache = /* @__PURE__ */ new Map();
|
|
|
789
789
|
function isTilesheet(a) {
|
|
790
790
|
return typeof a.tileWidth === "number";
|
|
791
791
|
}
|
|
792
|
+
function isSpriteSheetAtlas(a) {
|
|
793
|
+
const s = a;
|
|
794
|
+
return typeof s.frameWidth === "number" && typeof s.frameHeight === "number" && typeof s.animations === "object";
|
|
795
|
+
}
|
|
792
796
|
function getAtlas(url, onReady) {
|
|
793
797
|
if (atlasCache.has(url)) return atlasCache.get(url) ?? void 0;
|
|
794
798
|
atlasCache.set(url, void 0);
|
|
@@ -825,6 +829,7 @@ function subRectFor(atlas, sprite) {
|
|
|
825
829
|
sh: atlas.tileHeight
|
|
826
830
|
};
|
|
827
831
|
}
|
|
832
|
+
if (isSpriteSheetAtlas(atlas)) return null;
|
|
828
833
|
const st = atlas.subTextures[sprite];
|
|
829
834
|
if (!st) return null;
|
|
830
835
|
return { sx: st.x, sy: st.y, sw: st.width, sh: st.height };
|
|
@@ -918,12 +923,12 @@ function ModelLoader({
|
|
|
918
923
|
if (!loadedModel) return null;
|
|
919
924
|
const cloned = SkeletonUtils.clone(loadedModel);
|
|
920
925
|
cloned.updateMatrixWorld(true);
|
|
921
|
-
const tintColor = tint ? new
|
|
926
|
+
const tintColor = tint ? new THREE5__namespace.Color(tint) : null;
|
|
922
927
|
cloned.traverse((child) => {
|
|
923
|
-
if (child instanceof
|
|
928
|
+
if (child instanceof THREE5__namespace.Mesh) {
|
|
924
929
|
child.castShadow = castShadow;
|
|
925
930
|
child.receiveShadow = receiveShadow;
|
|
926
|
-
if (tintColor && child.material instanceof
|
|
931
|
+
if (tintColor && child.material instanceof THREE5__namespace.MeshStandardMaterial) {
|
|
927
932
|
const mat = child.material.clone();
|
|
928
933
|
mat.color.multiply(tintColor);
|
|
929
934
|
child.material = mat;
|
|
@@ -932,7 +937,7 @@ function ModelLoader({
|
|
|
932
937
|
});
|
|
933
938
|
return cloned;
|
|
934
939
|
}, [loadedModel, castShadow, receiveShadow, tint]);
|
|
935
|
-
const mixer = React3.useMemo(() => model ? new
|
|
940
|
+
const mixer = React3.useMemo(() => model ? new THREE5__namespace.AnimationMixer(model) : null, [model]);
|
|
936
941
|
React3.useEffect(() => {
|
|
937
942
|
if (!mixer || !animation || clips.length === 0) return;
|
|
938
943
|
const wanted = animation.toLowerCase();
|
|
@@ -949,8 +954,8 @@ function ModelLoader({
|
|
|
949
954
|
});
|
|
950
955
|
const normFactor = React3.useMemo(() => {
|
|
951
956
|
if (!model) return 1;
|
|
952
|
-
const box = new
|
|
953
|
-
const size = new
|
|
957
|
+
const box = new THREE5__namespace.Box3().setFromObject(model);
|
|
958
|
+
const size = new THREE5__namespace.Vector3();
|
|
954
959
|
box.getSize(size);
|
|
955
960
|
const maxDim = Math.max(size.x, size.y, size.z);
|
|
956
961
|
if (!Number.isFinite(maxDim) || maxDim < 0.05) return 1;
|
|
@@ -1040,7 +1045,7 @@ var warnUnsupported3d = (kind) => {
|
|
|
1040
1045
|
warnedUnsupported.add(kind);
|
|
1041
1046
|
mesh3dLog.warn("unsupported drawable kind on the 3D backend \u2014 skipped", { kind });
|
|
1042
1047
|
};
|
|
1043
|
-
var CrossOriginTextureLoader = class extends
|
|
1048
|
+
var CrossOriginTextureLoader = class extends THREE5__namespace.TextureLoader {
|
|
1044
1049
|
constructor() {
|
|
1045
1050
|
super();
|
|
1046
1051
|
this.crossOrigin = "anonymous";
|
|
@@ -1058,7 +1063,7 @@ function useBillboardTexture(url) {
|
|
|
1058
1063
|
url,
|
|
1059
1064
|
(texture) => {
|
|
1060
1065
|
if (!active) return;
|
|
1061
|
-
texture.colorSpace =
|
|
1066
|
+
texture.colorSpace = THREE5__namespace.SRGBColorSpace;
|
|
1062
1067
|
setState({ texture, error: false });
|
|
1063
1068
|
},
|
|
1064
1069
|
void 0,
|
|
@@ -1111,7 +1116,7 @@ function SpriteBillboard({ node, world, cellSize = 1, groupOpacity = 1 }) {
|
|
|
1111
1116
|
}, [texture, frame, node.height, node.width, anchor, cellSize]);
|
|
1112
1117
|
const groundGeometry = React3__default.default.useMemo(() => {
|
|
1113
1118
|
if (anchor !== "top-left" || !texture || !atlasReady) return null;
|
|
1114
|
-
const g = new
|
|
1119
|
+
const g = new THREE5__namespace.PlaneGeometry(size.width, size.height);
|
|
1115
1120
|
g.rotateX(-Math.PI / 2);
|
|
1116
1121
|
return g;
|
|
1117
1122
|
}, [anchor, texture, atlasReady, size.width, size.height]);
|
|
@@ -1119,15 +1124,15 @@ function SpriteBillboard({ node, world, cellSize = 1, groupOpacity = 1 }) {
|
|
|
1119
1124
|
if (anchor === "top-left") {
|
|
1120
1125
|
return /* @__PURE__ */ jsxRuntime.jsx("group", { position: [world[0] + size.width / 2, 0.02, world[2] + size.height / 2], children: /* @__PURE__ */ jsxRuntime.jsxs("mesh", { rotation: [-Math.PI / 2, 0, 0], children: [
|
|
1121
1126
|
/* @__PURE__ */ jsxRuntime.jsx("planeGeometry", { args: [size.width, size.height] }),
|
|
1122
|
-
/* @__PURE__ */ jsxRuntime.jsx("meshBasicMaterial", { color: textureError ? 16729156 : 8947848, transparent: true, opacity: 0.6, side:
|
|
1127
|
+
/* @__PURE__ */ jsxRuntime.jsx("meshBasicMaterial", { color: textureError ? 16729156 : 8947848, transparent: true, opacity: 0.6, side: THREE5__namespace.DoubleSide })
|
|
1123
1128
|
] }) });
|
|
1124
1129
|
}
|
|
1125
1130
|
return /* @__PURE__ */ jsxRuntime.jsx("group", { position: [world[0], world[1] + size.height / 2, world[2]], children: /* @__PURE__ */ jsxRuntime.jsxs("mesh", { children: [
|
|
1126
1131
|
/* @__PURE__ */ jsxRuntime.jsx("planeGeometry", { args: [size.width, size.height] }),
|
|
1127
|
-
/* @__PURE__ */ jsxRuntime.jsx("meshBasicMaterial", { color: textureError ? 16729156 : 8947848, transparent: true, opacity: 0.6, side:
|
|
1132
|
+
/* @__PURE__ */ jsxRuntime.jsx("meshBasicMaterial", { color: textureError ? 16729156 : 8947848, transparent: true, opacity: 0.6, side: THREE5__namespace.DoubleSide })
|
|
1128
1133
|
] }) });
|
|
1129
1134
|
}
|
|
1130
|
-
texture.magFilter = texture.minFilter =
|
|
1135
|
+
texture.magFilter = texture.minFilter = THREE5__namespace.NearestFilter;
|
|
1131
1136
|
texture.needsUpdate = true;
|
|
1132
1137
|
if (frame) {
|
|
1133
1138
|
texture.repeat.set(frame.w / size.imgW, frame.h / size.imgH);
|
|
@@ -1140,7 +1145,7 @@ function SpriteBillboard({ node, world, cellSize = 1, groupOpacity = 1 }) {
|
|
|
1140
1145
|
map: texture,
|
|
1141
1146
|
transparent: true,
|
|
1142
1147
|
alphaTest: 0.1,
|
|
1143
|
-
side:
|
|
1148
|
+
side: THREE5__namespace.DoubleSide,
|
|
1144
1149
|
opacity: (node.opacity ?? 1) * groupOpacity
|
|
1145
1150
|
}
|
|
1146
1151
|
) }) });
|
|
@@ -1153,7 +1158,7 @@ function SpriteBillboard({ node, world, cellSize = 1, groupOpacity = 1 }) {
|
|
|
1153
1158
|
map: texture,
|
|
1154
1159
|
transparent: true,
|
|
1155
1160
|
alphaTest: 0.1,
|
|
1156
|
-
side:
|
|
1161
|
+
side: THREE5__namespace.DoubleSide,
|
|
1157
1162
|
opacity: node.opacity ?? 1
|
|
1158
1163
|
}
|
|
1159
1164
|
)
|
|
@@ -1222,7 +1227,7 @@ function Shape3D({ node, projector, groupOpacity = 1 }) {
|
|
|
1222
1227
|
}
|
|
1223
1228
|
case "poly": {
|
|
1224
1229
|
if (!node.points || node.points.length === 0) return null;
|
|
1225
|
-
const s = new
|
|
1230
|
+
const s = new THREE5__namespace.Shape();
|
|
1226
1231
|
node.points.forEach((p, i) => {
|
|
1227
1232
|
if (i === 0) s.moveTo(p.x, p.y);
|
|
1228
1233
|
else s.lineTo(p.x, p.y);
|
|
@@ -1240,7 +1245,7 @@ function Shape3D({ node, projector, groupOpacity = 1 }) {
|
|
|
1240
1245
|
}
|
|
1241
1246
|
return /* @__PURE__ */ jsxRuntime.jsx("group", { ref: groupRef, position: [world[0], world[1] + 0.02, world[2]], children: /* @__PURE__ */ jsxRuntime.jsxs("mesh", { rotation: [-Math.PI / 2, 0, 0], children: [
|
|
1242
1247
|
geometry,
|
|
1243
|
-
/* @__PURE__ */ jsxRuntime.jsx("meshBasicMaterial", { ref: materialRef, color, transparent: true, opacity: (node.opacity ?? 1) * groupOpacity, side:
|
|
1248
|
+
/* @__PURE__ */ jsxRuntime.jsx("meshBasicMaterial", { ref: materialRef, color, transparent: true, opacity: (node.opacity ?? 1) * groupOpacity, side: THREE5__namespace.DoubleSide })
|
|
1244
1249
|
] }) });
|
|
1245
1250
|
}
|
|
1246
1251
|
function Text3D({ node, projector, groupOpacity = 1 }) {
|
|
@@ -1262,6 +1267,18 @@ function Text3D({ node, projector, groupOpacity = 1 }) {
|
|
|
1262
1267
|
) });
|
|
1263
1268
|
}
|
|
1264
1269
|
var GROUND_ROTATION = [-Math.PI / 2, 0, 0];
|
|
1270
|
+
var textureCache = /* @__PURE__ */ new Map();
|
|
1271
|
+
function getMeshTexture(url) {
|
|
1272
|
+
const cached = textureCache.get(url);
|
|
1273
|
+
if (cached) return cached;
|
|
1274
|
+
const texture = new THREE5__namespace.TextureLoader().load(url);
|
|
1275
|
+
texture.flipY = false;
|
|
1276
|
+
texture.colorSpace = THREE5__namespace.SRGBColorSpace;
|
|
1277
|
+
texture.wrapS = THREE5__namespace.RepeatWrapping;
|
|
1278
|
+
texture.wrapT = THREE5__namespace.RepeatWrapping;
|
|
1279
|
+
textureCache.set(url, texture);
|
|
1280
|
+
return texture;
|
|
1281
|
+
}
|
|
1265
1282
|
function polyhedronGeometry(node, cellSize) {
|
|
1266
1283
|
const verts = node.vertices;
|
|
1267
1284
|
const faces = node.faces;
|
|
@@ -1282,8 +1299,16 @@ function polyhedronGeometry(node, cellSize) {
|
|
|
1282
1299
|
index.push(a, c, b);
|
|
1283
1300
|
}
|
|
1284
1301
|
if (index.length === 0) return null;
|
|
1285
|
-
const geometry = new
|
|
1286
|
-
geometry.setAttribute("position", new
|
|
1302
|
+
const geometry = new THREE5__namespace.BufferGeometry();
|
|
1303
|
+
geometry.setAttribute("position", new THREE5__namespace.BufferAttribute(positions, 3));
|
|
1304
|
+
if (node.uvs && node.uvs.length === verts.length) {
|
|
1305
|
+
const uv = new Float32Array(verts.length * 2);
|
|
1306
|
+
for (let i = 0; i < verts.length; i++) {
|
|
1307
|
+
uv[i * 2] = node.uvs[i][0];
|
|
1308
|
+
uv[i * 2 + 1] = node.uvs[i][1];
|
|
1309
|
+
}
|
|
1310
|
+
geometry.setAttribute("uv", new THREE5__namespace.BufferAttribute(uv, 2));
|
|
1311
|
+
}
|
|
1287
1312
|
geometry.setIndex(index);
|
|
1288
1313
|
geometry.computeVertexNormals();
|
|
1289
1314
|
const skin = node.skin;
|
|
@@ -1296,8 +1321,8 @@ function polyhedronGeometry(node, cellSize) {
|
|
|
1296
1321
|
skinWeight[i * 4 + k] = skin.weights[i][k] ?? 0;
|
|
1297
1322
|
}
|
|
1298
1323
|
}
|
|
1299
|
-
geometry.setAttribute("skinIndex", new
|
|
1300
|
-
geometry.setAttribute("skinWeight", new
|
|
1324
|
+
geometry.setAttribute("skinIndex", new THREE5__namespace.BufferAttribute(skinIndex, 4));
|
|
1325
|
+
geometry.setAttribute("skinWeight", new THREE5__namespace.BufferAttribute(skinWeight, 4));
|
|
1301
1326
|
}
|
|
1302
1327
|
const size = Math.max(bounds.max[0] - bounds.min[0], bounds.max[1] - bounds.min[1], bounds.max[2] - bounds.min[2]) * cellSize;
|
|
1303
1328
|
return { geometry, lift: -bounds.min[2] * cellSize, size };
|
|
@@ -1339,9 +1364,9 @@ function meshGeometry(node, cellSize) {
|
|
|
1339
1364
|
}
|
|
1340
1365
|
var warnedPolyhedronOutline = false;
|
|
1341
1366
|
var SIDE_MAP = {
|
|
1342
|
-
front:
|
|
1343
|
-
back:
|
|
1344
|
-
double:
|
|
1367
|
+
front: THREE5__namespace.FrontSide,
|
|
1368
|
+
back: THREE5__namespace.BackSide,
|
|
1369
|
+
double: THREE5__namespace.DoubleSide
|
|
1345
1370
|
};
|
|
1346
1371
|
function meshMaterial(mat, opacity, ref) {
|
|
1347
1372
|
const m = mat ?? {};
|
|
@@ -1350,7 +1375,8 @@ function meshMaterial(mat, opacity, ref) {
|
|
|
1350
1375
|
color: m.color ?? "#ffffff",
|
|
1351
1376
|
transparent: opacity < 1,
|
|
1352
1377
|
opacity,
|
|
1353
|
-
side: SIDE_MAP[m.side ?? "front"]
|
|
1378
|
+
side: SIDE_MAP[m.side ?? "front"],
|
|
1379
|
+
...m.map ? { map: getMeshTexture(m.map) } : {}
|
|
1354
1380
|
};
|
|
1355
1381
|
const emissive = m.emissive ? { emissive: m.emissive, emissiveIntensity: m.emissiveIntensity ?? 1 } : {};
|
|
1356
1382
|
switch (m.kind ?? "standard") {
|
|
@@ -1408,13 +1434,13 @@ function SkinnedPolyhedron3D({
|
|
|
1408
1434
|
if (mesh.skeleton && mesh.skeleton.bones.length === bones.length && mesh.skeleton.bones.every((b, i) => b === bones[i])) return;
|
|
1409
1435
|
if (skin.inverseBindMatrices.length !== bones.length) return;
|
|
1410
1436
|
const inverses = skin.inverseBindMatrices.map((m) => {
|
|
1411
|
-
const mat = new
|
|
1437
|
+
const mat = new THREE5__namespace.Matrix4().fromArray(m);
|
|
1412
1438
|
mat.elements[12] *= cellSize;
|
|
1413
1439
|
mat.elements[13] *= cellSize;
|
|
1414
1440
|
mat.elements[14] *= cellSize;
|
|
1415
1441
|
return mat;
|
|
1416
1442
|
});
|
|
1417
|
-
mesh.bind(new
|
|
1443
|
+
mesh.bind(new THREE5__namespace.Skeleton(bones, inverses), new THREE5__namespace.Matrix4());
|
|
1418
1444
|
}, [registryTick, skin, boneStore, geometry, cellSize]);
|
|
1419
1445
|
React3.useEffect(() => {
|
|
1420
1446
|
const mesh = meshRef.current;
|
|
@@ -1521,7 +1547,7 @@ function Mesh3D({
|
|
|
1521
1547
|
"meshBasicMaterial",
|
|
1522
1548
|
{
|
|
1523
1549
|
color: node.outline.color ?? "#101014",
|
|
1524
|
-
side:
|
|
1550
|
+
side: THREE5__namespace.BackSide,
|
|
1525
1551
|
transparent: opacity < 1,
|
|
1526
1552
|
opacity
|
|
1527
1553
|
}
|
|
@@ -1567,7 +1593,7 @@ function Group3D({
|
|
|
1567
1593
|
const parentStore = React3.useContext(BoneRegistryContext);
|
|
1568
1594
|
const scopedStore = React3.useMemo(() => node.skeleton ? new BoneStore() : null, [node.skeleton]);
|
|
1569
1595
|
const boneStore = scopedStore ?? parentStore;
|
|
1570
|
-
const boneObject = React3.useMemo(() => node.bone ? new
|
|
1596
|
+
const boneObject = React3.useMemo(() => node.bone ? new THREE5__namespace.Bone() : null, [node.bone]);
|
|
1571
1597
|
React3.useEffect(() => {
|
|
1572
1598
|
if (!node.bone || !boneStore || !boneObject) return;
|
|
1573
1599
|
return boneStore.register(node.bone, boneObject);
|
|
@@ -1607,10 +1633,26 @@ function cn(...inputs) {
|
|
|
1607
1633
|
}
|
|
1608
1634
|
var DEFAULT_GRID_CONFIG = {
|
|
1609
1635
|
cellSize: 1};
|
|
1636
|
+
function CameraPose({
|
|
1637
|
+
position,
|
|
1638
|
+
fov,
|
|
1639
|
+
controls
|
|
1640
|
+
}) {
|
|
1641
|
+
const camera = fiber.useThree((s) => s.camera);
|
|
1642
|
+
React3.useEffect(() => {
|
|
1643
|
+
camera.position.set(position[0], position[1], position[2]);
|
|
1644
|
+
if (camera.isPerspectiveCamera) {
|
|
1645
|
+
camera.fov = fov;
|
|
1646
|
+
camera.updateProjectionMatrix();
|
|
1647
|
+
}
|
|
1648
|
+
controls.current?.update();
|
|
1649
|
+
}, [camera, position, fov, controls]);
|
|
1650
|
+
return null;
|
|
1651
|
+
}
|
|
1610
1652
|
function RoomEnvironment3D() {
|
|
1611
1653
|
const { gl, scene } = fiber.useThree(({ gl: gl2, scene: scene2 }) => ({ gl: gl2, scene: scene2 }));
|
|
1612
1654
|
React3.useEffect(() => {
|
|
1613
|
-
const pmremGenerator = new
|
|
1655
|
+
const pmremGenerator = new THREE5__namespace.PMREMGenerator(gl);
|
|
1614
1656
|
const envTexture = pmremGenerator.fromScene(new RoomEnvironment_js.RoomEnvironment(), 0.04).texture;
|
|
1615
1657
|
scene.environment = envTexture;
|
|
1616
1658
|
return () => {
|
|
@@ -1646,6 +1688,7 @@ var Canvas3DHost = React3.forwardRef(
|
|
|
1646
1688
|
keyUpMap,
|
|
1647
1689
|
pixelsPerUnit,
|
|
1648
1690
|
fov,
|
|
1691
|
+
azimuth,
|
|
1649
1692
|
lighting,
|
|
1650
1693
|
post,
|
|
1651
1694
|
children,
|
|
@@ -1739,7 +1782,7 @@ var Canvas3DHost = React3.forwardRef(
|
|
|
1739
1782
|
getCameraPosition: () => {
|
|
1740
1783
|
if (controlsRef.current) {
|
|
1741
1784
|
const pos = controlsRef.current.object.position;
|
|
1742
|
-
return new
|
|
1785
|
+
return new THREE5__namespace.Vector3(pos.x, pos.y, pos.z);
|
|
1743
1786
|
}
|
|
1744
1787
|
return null;
|
|
1745
1788
|
},
|
|
@@ -1779,20 +1822,28 @@ var Canvas3DHost = React3.forwardRef(
|
|
|
1779
1822
|
const cz = cameraTarget[2];
|
|
1780
1823
|
const d = size * 1;
|
|
1781
1824
|
const fovDeg = fov ?? 45;
|
|
1782
|
-
|
|
1783
|
-
|
|
1784
|
-
|
|
1785
|
-
|
|
1786
|
-
|
|
1787
|
-
|
|
1788
|
-
|
|
1789
|
-
|
|
1790
|
-
|
|
1791
|
-
|
|
1792
|
-
|
|
1793
|
-
|
|
1794
|
-
|
|
1795
|
-
|
|
1825
|
+
const base = (() => {
|
|
1826
|
+
switch (cameraMode) {
|
|
1827
|
+
case "isometric":
|
|
1828
|
+
return { position: [cx + d, d * 0.8, cz + d], fov: fovDeg };
|
|
1829
|
+
case "top-down":
|
|
1830
|
+
return { position: [cx, d * 2, cz + d * 0.35], fov: fovDeg };
|
|
1831
|
+
case "front":
|
|
1832
|
+
return { position: [cx, d * 0.32, cz + d * 1.15], fov: fovDeg };
|
|
1833
|
+
case "follow":
|
|
1834
|
+
return { position: [cx, d * 0.5, cz + d], fov: fovDeg };
|
|
1835
|
+
case "perspective":
|
|
1836
|
+
default:
|
|
1837
|
+
return { position: [cx + d, d, cz + d], fov: fovDeg };
|
|
1838
|
+
}
|
|
1839
|
+
})();
|
|
1840
|
+
if (!azimuth) return base;
|
|
1841
|
+
const ox = base.position[0] - cx;
|
|
1842
|
+
const oz = base.position[2] - cz;
|
|
1843
|
+
const c = Math.cos(azimuth);
|
|
1844
|
+
const s = Math.sin(azimuth);
|
|
1845
|
+
return { position: [cx + ox * c - oz * s, base.position[1], cz + ox * s + oz * c], fov: base.fov };
|
|
1846
|
+
}, [cameraMode, gridBounds, cellSize, cameraTarget, fov, azimuth]);
|
|
1796
1847
|
const followWorld = React3.useMemo(() => {
|
|
1797
1848
|
if (followTarget) return drawableProjector.toWorld(followTarget);
|
|
1798
1849
|
return cameraTarget;
|
|
@@ -1853,6 +1904,7 @@ var Canvas3DHost = React3.forwardRef(
|
|
|
1853
1904
|
{
|
|
1854
1905
|
shadows,
|
|
1855
1906
|
flat: lighting?.toneMapping === "none",
|
|
1907
|
+
gl: { preserveDrawingBuffer: true },
|
|
1856
1908
|
camera: {
|
|
1857
1909
|
position: cameraConfig.position,
|
|
1858
1910
|
fov: cameraConfig.fov,
|
|
@@ -1867,6 +1919,7 @@ var Canvas3DHost = React3.forwardRef(
|
|
|
1867
1919
|
},
|
|
1868
1920
|
children: [
|
|
1869
1921
|
/* @__PURE__ */ jsxRuntime.jsx(CameraController3D, { onCameraChange: eventHandlers.handleCameraChange }),
|
|
1922
|
+
/* @__PURE__ */ jsxRuntime.jsx(CameraPose, { position: cameraConfig.position, fov: cameraConfig.fov, controls: controlsRef }),
|
|
1870
1923
|
(cameraMode === "follow" || cameraMode === "chase") && /* @__PURE__ */ jsxRuntime.jsx(FollowCamera3D, { target: followWorld, offset: followOffset }),
|
|
1871
1924
|
/* @__PURE__ */ jsxRuntime.jsx(
|
|
1872
1925
|
Lighting3D,
|
|
@@ -1947,7 +2000,7 @@ var Canvas3DHost = React3.forwardRef(
|
|
|
1947
2000
|
dampingFactor: 0.05,
|
|
1948
2001
|
enableZoom: true,
|
|
1949
2002
|
enablePan: true,
|
|
1950
|
-
touches: { ONE:
|
|
2003
|
+
touches: { ONE: THREE5__namespace.TOUCH.ROTATE, TWO: THREE5__namespace.TOUCH.DOLLY_PAN },
|
|
1951
2004
|
minDistance: 2,
|
|
1952
2005
|
maxDistance: 100,
|
|
1953
2006
|
maxPolarAngle: Math.PI / 2 - 0.1
|
|
@@ -1970,15 +2023,15 @@ function Scene3D({ background = "#1a1a2e", fog, children }) {
|
|
|
1970
2023
|
if (initializedRef.current) return;
|
|
1971
2024
|
initializedRef.current = true;
|
|
1972
2025
|
if (background.startsWith("#") || background.startsWith("rgb")) {
|
|
1973
|
-
scene.background = new
|
|
2026
|
+
scene.background = new THREE5__namespace.Color(background);
|
|
1974
2027
|
} else {
|
|
1975
|
-
const loader = new
|
|
2028
|
+
const loader = new THREE5__namespace.TextureLoader();
|
|
1976
2029
|
loader.load(background, (texture) => {
|
|
1977
2030
|
scene.background = texture;
|
|
1978
2031
|
});
|
|
1979
2032
|
}
|
|
1980
2033
|
if (fog) {
|
|
1981
|
-
scene.fog = new
|
|
2034
|
+
scene.fog = new THREE5__namespace.Fog(fog.color, fog.near, fog.far);
|
|
1982
2035
|
}
|
|
1983
2036
|
return () => {
|
|
1984
2037
|
scene.background = null;
|
|
@@ -2001,14 +2054,14 @@ var Camera3D = React3.forwardRef(
|
|
|
2001
2054
|
}, ref) => {
|
|
2002
2055
|
const { camera, set, viewport } = fiber.useThree();
|
|
2003
2056
|
const controlsRef = React3.useRef(null);
|
|
2004
|
-
const initialPosition = React3.useRef(new
|
|
2005
|
-
const initialTarget = React3.useRef(new
|
|
2057
|
+
const initialPosition = React3.useRef(new THREE5__namespace.Vector3(...position));
|
|
2058
|
+
const initialTarget = React3.useRef(new THREE5__namespace.Vector3(...target));
|
|
2006
2059
|
React3.useEffect(() => {
|
|
2007
2060
|
let newCamera;
|
|
2008
2061
|
if (mode === "isometric") {
|
|
2009
2062
|
const aspect = viewport.aspect;
|
|
2010
2063
|
const size = 10 / zoom;
|
|
2011
|
-
newCamera = new
|
|
2064
|
+
newCamera = new THREE5__namespace.OrthographicCamera(
|
|
2012
2065
|
-size * aspect,
|
|
2013
2066
|
size * aspect,
|
|
2014
2067
|
size,
|
|
@@ -2017,7 +2070,7 @@ var Camera3D = React3.forwardRef(
|
|
|
2017
2070
|
1e3
|
|
2018
2071
|
);
|
|
2019
2072
|
} else {
|
|
2020
|
-
newCamera = new
|
|
2073
|
+
newCamera = new THREE5__namespace.PerspectiveCamera(fov, viewport.aspect, 0.1, 1e3);
|
|
2021
2074
|
}
|
|
2022
2075
|
newCamera.position.copy(initialPosition.current);
|
|
2023
2076
|
newCamera.lookAt(initialTarget.current.x, initialTarget.current.y, initialTarget.current.z);
|
|
@@ -2058,8 +2111,8 @@ var Camera3D = React3.forwardRef(
|
|
|
2058
2111
|
}
|
|
2059
2112
|
},
|
|
2060
2113
|
getViewBounds: () => {
|
|
2061
|
-
const min = new
|
|
2062
|
-
const max = new
|
|
2114
|
+
const min = new THREE5__namespace.Vector3(-10, -10, -10);
|
|
2115
|
+
const max = new THREE5__namespace.Vector3(10, 10, 10);
|
|
2063
2116
|
return { min, max };
|
|
2064
2117
|
}
|
|
2065
2118
|
}));
|
|
@@ -2101,7 +2154,7 @@ var AssetLoader = class {
|
|
|
2101
2154
|
__publicField(this, "textureCache");
|
|
2102
2155
|
__publicField(this, "loadingPromises");
|
|
2103
2156
|
this.objLoader = new OBJLoader_js.OBJLoader();
|
|
2104
|
-
this.textureLoader = new
|
|
2157
|
+
this.textureLoader = new THREE5__namespace.TextureLoader();
|
|
2105
2158
|
this.modelCache = /* @__PURE__ */ new Map();
|
|
2106
2159
|
this.textureCache = /* @__PURE__ */ new Map();
|
|
2107
2160
|
this.loadingPromises = /* @__PURE__ */ new Map();
|
|
@@ -2175,7 +2228,7 @@ var AssetLoader = class {
|
|
|
2175
2228
|
return this.loadingPromises.get(`texture:${url}`);
|
|
2176
2229
|
}
|
|
2177
2230
|
const loadPromise = this.textureLoader.loadAsync(url).then((texture) => {
|
|
2178
|
-
texture.colorSpace =
|
|
2231
|
+
texture.colorSpace = THREE5__namespace.SRGBColorSpace;
|
|
2179
2232
|
this.textureCache.set(url, texture);
|
|
2180
2233
|
this.loadingPromises.delete(`texture:${url}`);
|
|
2181
2234
|
return texture;
|
|
@@ -2249,7 +2302,7 @@ var AssetLoader = class {
|
|
|
2249
2302
|
});
|
|
2250
2303
|
this.modelCache.forEach((model) => {
|
|
2251
2304
|
model.scene.traverse((child) => {
|
|
2252
|
-
if (child instanceof
|
|
2305
|
+
if (child instanceof THREE5__namespace.Mesh) {
|
|
2253
2306
|
child.geometry.dispose();
|
|
2254
2307
|
if (Array.isArray(child.material)) {
|
|
2255
2308
|
child.material.forEach((m) => m.dispose());
|
|
@@ -2299,21 +2352,21 @@ function useThree5(options = {}) {
|
|
|
2299
2352
|
const [isReady, setIsReady] = React3.useState(false);
|
|
2300
2353
|
const [dimensions, setDimensions] = React3.useState({ width: 0, height: 0 });
|
|
2301
2354
|
const initialCameraPosition = React3.useMemo(
|
|
2302
|
-
() => new
|
|
2355
|
+
() => new THREE5__namespace.Vector3(...opts.cameraPosition),
|
|
2303
2356
|
[]
|
|
2304
2357
|
);
|
|
2305
2358
|
React3.useEffect(() => {
|
|
2306
2359
|
if (!containerRef.current) return;
|
|
2307
2360
|
const container = containerRef.current;
|
|
2308
2361
|
const { clientWidth, clientHeight } = container;
|
|
2309
|
-
const scene = new
|
|
2310
|
-
scene.background = new
|
|
2362
|
+
const scene = new THREE5__namespace.Scene();
|
|
2363
|
+
scene.background = new THREE5__namespace.Color(opts.backgroundColor);
|
|
2311
2364
|
sceneRef.current = scene;
|
|
2312
2365
|
let camera;
|
|
2313
2366
|
const aspect = clientWidth / clientHeight;
|
|
2314
2367
|
if (opts.cameraMode === "isometric") {
|
|
2315
2368
|
const size = 10;
|
|
2316
|
-
camera = new
|
|
2369
|
+
camera = new THREE5__namespace.OrthographicCamera(
|
|
2317
2370
|
-size * aspect,
|
|
2318
2371
|
size * aspect,
|
|
2319
2372
|
size,
|
|
@@ -2322,11 +2375,11 @@ function useThree5(options = {}) {
|
|
|
2322
2375
|
1e3
|
|
2323
2376
|
);
|
|
2324
2377
|
} else {
|
|
2325
|
-
camera = new
|
|
2378
|
+
camera = new THREE5__namespace.PerspectiveCamera(45, aspect, 0.1, 1e3);
|
|
2326
2379
|
}
|
|
2327
2380
|
camera.position.copy(initialCameraPosition);
|
|
2328
2381
|
cameraRef.current = camera;
|
|
2329
|
-
const renderer = new
|
|
2382
|
+
const renderer = new THREE5__namespace.WebGLRenderer({
|
|
2330
2383
|
antialias: true,
|
|
2331
2384
|
alpha: true,
|
|
2332
2385
|
canvas: canvasRef.current || void 0
|
|
@@ -2334,7 +2387,7 @@ function useThree5(options = {}) {
|
|
|
2334
2387
|
renderer.setSize(clientWidth, clientHeight);
|
|
2335
2388
|
renderer.setPixelRatio(Math.min(window.devicePixelRatio, 2));
|
|
2336
2389
|
renderer.shadowMap.enabled = opts.shadows;
|
|
2337
|
-
renderer.shadowMap.type =
|
|
2390
|
+
renderer.shadowMap.type = THREE5__namespace.PCFSoftShadowMap;
|
|
2338
2391
|
rendererRef.current = renderer;
|
|
2339
2392
|
const controls = new OrbitControls_js.OrbitControls(camera, renderer.domElement);
|
|
2340
2393
|
controls.enableDamping = true;
|
|
@@ -2343,16 +2396,16 @@ function useThree5(options = {}) {
|
|
|
2343
2396
|
controls.maxDistance = 100;
|
|
2344
2397
|
controls.maxPolarAngle = Math.PI / 2 - 0.1;
|
|
2345
2398
|
controlsRef.current = controls;
|
|
2346
|
-
const ambientLight = new
|
|
2399
|
+
const ambientLight = new THREE5__namespace.AmbientLight(16777215, 0.6);
|
|
2347
2400
|
scene.add(ambientLight);
|
|
2348
|
-
const directionalLight = new
|
|
2401
|
+
const directionalLight = new THREE5__namespace.DirectionalLight(16777215, 0.8);
|
|
2349
2402
|
directionalLight.position.set(10, 20, 10);
|
|
2350
2403
|
directionalLight.castShadow = opts.shadows;
|
|
2351
2404
|
directionalLight.shadow.mapSize.width = 2048;
|
|
2352
2405
|
directionalLight.shadow.mapSize.height = 2048;
|
|
2353
2406
|
scene.add(directionalLight);
|
|
2354
2407
|
if (opts.showGrid) {
|
|
2355
|
-
const gridHelper = new
|
|
2408
|
+
const gridHelper = new THREE5__namespace.GridHelper(
|
|
2356
2409
|
opts.gridSize,
|
|
2357
2410
|
opts.gridSize,
|
|
2358
2411
|
4473924,
|
|
@@ -2370,10 +2423,10 @@ function useThree5(options = {}) {
|
|
|
2370
2423
|
const handleResize = () => {
|
|
2371
2424
|
const { clientWidth: width, clientHeight: height } = container;
|
|
2372
2425
|
setDimensions({ width, height });
|
|
2373
|
-
if (camera instanceof
|
|
2426
|
+
if (camera instanceof THREE5__namespace.PerspectiveCamera) {
|
|
2374
2427
|
camera.aspect = width / height;
|
|
2375
2428
|
camera.updateProjectionMatrix();
|
|
2376
|
-
} else if (camera instanceof
|
|
2429
|
+
} else if (camera instanceof THREE5__namespace.OrthographicCamera) {
|
|
2377
2430
|
const aspect2 = width / height;
|
|
2378
2431
|
const size = 10;
|
|
2379
2432
|
camera.left = -size * aspect2;
|
|
@@ -2404,7 +2457,7 @@ function useThree5(options = {}) {
|
|
|
2404
2457
|
let newCamera;
|
|
2405
2458
|
if (opts.cameraMode === "isometric") {
|
|
2406
2459
|
const size = 10;
|
|
2407
|
-
newCamera = new
|
|
2460
|
+
newCamera = new THREE5__namespace.OrthographicCamera(
|
|
2408
2461
|
-size * aspect,
|
|
2409
2462
|
size * aspect,
|
|
2410
2463
|
size,
|
|
@@ -2413,7 +2466,7 @@ function useThree5(options = {}) {
|
|
|
2413
2466
|
1e3
|
|
2414
2467
|
);
|
|
2415
2468
|
} else {
|
|
2416
|
-
newCamera = new
|
|
2469
|
+
newCamera = new THREE5__namespace.PerspectiveCamera(45, aspect, 0.1, 1e3);
|
|
2417
2470
|
}
|
|
2418
2471
|
newCamera.position.copy(currentPos);
|
|
2419
2472
|
cameraRef.current = newCamera;
|
|
@@ -2743,8 +2796,8 @@ function useSceneGraph() {
|
|
|
2743
2796
|
}
|
|
2744
2797
|
function useRaycaster(options) {
|
|
2745
2798
|
const { camera, canvas, cellSize = 1, offsetX = 0, offsetZ = 0 } = options;
|
|
2746
|
-
const raycaster = React3.useRef(new
|
|
2747
|
-
const mouse = React3.useRef(new
|
|
2799
|
+
const raycaster = React3.useRef(new THREE5__namespace.Raycaster());
|
|
2800
|
+
const mouse = React3.useRef(new THREE5__namespace.Vector2());
|
|
2748
2801
|
const clientToNDC = React3.useCallback(
|
|
2749
2802
|
(clientX, clientY) => {
|
|
2750
2803
|
if (!canvas) {
|
|
@@ -2814,8 +2867,8 @@ function useRaycaster(options) {
|
|
|
2814
2867
|
const ndc = clientToNDC(clientX, clientY);
|
|
2815
2868
|
mouse.current.set(ndc.x, ndc.y);
|
|
2816
2869
|
raycaster.current.setFromCamera(mouse.current, camera);
|
|
2817
|
-
const plane = new
|
|
2818
|
-
const target = new
|
|
2870
|
+
const plane = new THREE5__namespace.Plane(new THREE5__namespace.Vector3(0, 1, 0), 0);
|
|
2871
|
+
const target = new THREE5__namespace.Vector3();
|
|
2819
2872
|
const intersection = raycaster.current.ray.intersectPlane(plane, target);
|
|
2820
2873
|
if (intersection) {
|
|
2821
2874
|
const gridX = Math.round((target.x - offsetX) / cellSize);
|
|
@@ -2853,7 +2906,7 @@ function useRaycaster(options) {
|
|
|
2853
2906
|
return {
|
|
2854
2907
|
gridX: gridCoords.x,
|
|
2855
2908
|
gridZ: gridCoords.z,
|
|
2856
|
-
worldPosition: new
|
|
2909
|
+
worldPosition: new THREE5__namespace.Vector3(
|
|
2857
2910
|
gridCoords.x * cellSize + offsetX,
|
|
2858
2911
|
0,
|
|
2859
2912
|
gridCoords.z * cellSize + offsetZ
|
|
@@ -2883,7 +2936,7 @@ var DEFAULT_CONFIG = {
|
|
|
2883
2936
|
};
|
|
2884
2937
|
function gridToWorld(gridX, gridZ, config = DEFAULT_CONFIG) {
|
|
2885
2938
|
const opts = { ...DEFAULT_CONFIG, ...config };
|
|
2886
|
-
return new
|
|
2939
|
+
return new THREE5__namespace.Vector3(
|
|
2887
2940
|
gridX * opts.cellSize + opts.offsetX,
|
|
2888
2941
|
opts.elevation,
|
|
2889
2942
|
gridZ * opts.cellSize + opts.offsetZ
|
|
@@ -2897,17 +2950,17 @@ function worldToGrid(worldX, worldZ, config = DEFAULT_CONFIG) {
|
|
|
2897
2950
|
};
|
|
2898
2951
|
}
|
|
2899
2952
|
function raycastToPlane(camera, mouseX, mouseY, planeY = 0) {
|
|
2900
|
-
const raycaster = new
|
|
2901
|
-
const mouse = new
|
|
2953
|
+
const raycaster = new THREE5__namespace.Raycaster();
|
|
2954
|
+
const mouse = new THREE5__namespace.Vector2(mouseX, mouseY);
|
|
2902
2955
|
raycaster.setFromCamera(mouse, camera);
|
|
2903
|
-
const plane = new
|
|
2904
|
-
const target = new
|
|
2956
|
+
const plane = new THREE5__namespace.Plane(new THREE5__namespace.Vector3(0, 1, 0), -planeY);
|
|
2957
|
+
const target = new THREE5__namespace.Vector3();
|
|
2905
2958
|
const intersection = raycaster.ray.intersectPlane(plane, target);
|
|
2906
2959
|
return intersection ? target : null;
|
|
2907
2960
|
}
|
|
2908
2961
|
function raycastToObjects(camera, mouseX, mouseY, objects) {
|
|
2909
|
-
const raycaster = new
|
|
2910
|
-
const mouse = new
|
|
2962
|
+
const raycaster = new THREE5__namespace.Raycaster();
|
|
2963
|
+
const mouse = new THREE5__namespace.Vector2(mouseX, mouseY);
|
|
2911
2964
|
raycaster.setFromCamera(mouse, camera);
|
|
2912
2965
|
const intersects = raycaster.intersectObjects(objects, true);
|
|
2913
2966
|
return intersects.length > 0 ? intersects[0] : null;
|
|
@@ -2959,14 +3012,14 @@ function getCellsInRadius(centerX, centerZ, radius) {
|
|
|
2959
3012
|
return cells;
|
|
2960
3013
|
}
|
|
2961
3014
|
function createGridHighlight(color = 16776960, opacity = 0.3) {
|
|
2962
|
-
const geometry = new
|
|
2963
|
-
const material = new
|
|
3015
|
+
const geometry = new THREE5__namespace.PlaneGeometry(0.95, 0.95);
|
|
3016
|
+
const material = new THREE5__namespace.MeshBasicMaterial({
|
|
2964
3017
|
color,
|
|
2965
3018
|
transparent: true,
|
|
2966
3019
|
opacity,
|
|
2967
|
-
side:
|
|
3020
|
+
side: THREE5__namespace.DoubleSide
|
|
2968
3021
|
});
|
|
2969
|
-
const mesh = new
|
|
3022
|
+
const mesh = new THREE5__namespace.Mesh(geometry, material);
|
|
2970
3023
|
mesh.rotation.x = -Math.PI / 2;
|
|
2971
3024
|
mesh.position.y = 0.01;
|
|
2972
3025
|
return mesh;
|
|
@@ -2979,31 +3032,31 @@ function normalizeMouseCoordinates(clientX, clientY, element) {
|
|
|
2979
3032
|
};
|
|
2980
3033
|
}
|
|
2981
3034
|
function isInFrustum(position, camera, padding = 0) {
|
|
2982
|
-
const frustum = new
|
|
2983
|
-
const projScreenMatrix = new
|
|
3035
|
+
const frustum = new THREE5__namespace.Frustum();
|
|
3036
|
+
const projScreenMatrix = new THREE5__namespace.Matrix4();
|
|
2984
3037
|
projScreenMatrix.multiplyMatrices(camera.projectionMatrix, camera.matrixWorldInverse);
|
|
2985
3038
|
frustum.setFromProjectionMatrix(projScreenMatrix);
|
|
2986
|
-
const sphere = new
|
|
3039
|
+
const sphere = new THREE5__namespace.Sphere(position, padding);
|
|
2987
3040
|
return frustum.intersectsSphere(sphere);
|
|
2988
3041
|
}
|
|
2989
3042
|
function filterByFrustum(positions, camera, padding = 0) {
|
|
2990
|
-
const frustum = new
|
|
2991
|
-
const projScreenMatrix = new
|
|
3043
|
+
const frustum = new THREE5__namespace.Frustum();
|
|
3044
|
+
const projScreenMatrix = new THREE5__namespace.Matrix4();
|
|
2992
3045
|
projScreenMatrix.multiplyMatrices(camera.projectionMatrix, camera.matrixWorldInverse);
|
|
2993
3046
|
frustum.setFromProjectionMatrix(projScreenMatrix);
|
|
2994
3047
|
return positions.filter((position) => {
|
|
2995
|
-
const sphere = new
|
|
3048
|
+
const sphere = new THREE5__namespace.Sphere(position, padding);
|
|
2996
3049
|
return frustum.intersectsSphere(sphere);
|
|
2997
3050
|
});
|
|
2998
3051
|
}
|
|
2999
3052
|
function getVisibleIndices(positions, camera, padding = 0) {
|
|
3000
|
-
const frustum = new
|
|
3001
|
-
const projScreenMatrix = new
|
|
3053
|
+
const frustum = new THREE5__namespace.Frustum();
|
|
3054
|
+
const projScreenMatrix = new THREE5__namespace.Matrix4();
|
|
3002
3055
|
const visible = /* @__PURE__ */ new Set();
|
|
3003
3056
|
projScreenMatrix.multiplyMatrices(camera.projectionMatrix, camera.matrixWorldInverse);
|
|
3004
3057
|
frustum.setFromProjectionMatrix(projScreenMatrix);
|
|
3005
3058
|
positions.forEach((position, index) => {
|
|
3006
|
-
const sphere = new
|
|
3059
|
+
const sphere = new THREE5__namespace.Sphere(position, padding);
|
|
3007
3060
|
if (frustum.intersectsSphere(sphere)) {
|
|
3008
3061
|
visible.add(index);
|
|
3009
3062
|
}
|
|
@@ -3027,7 +3080,7 @@ function updateInstanceLOD(instancedMesh, positions, camera, lodDistances) {
|
|
|
3027
3080
|
return lodIndices;
|
|
3028
3081
|
}
|
|
3029
3082
|
function cullInstancedMesh(instancedMesh, positions, visibleIndices) {
|
|
3030
|
-
const dummy = new
|
|
3083
|
+
const dummy = new THREE5__namespace.Object3D();
|
|
3031
3084
|
let visibleCount = 0;
|
|
3032
3085
|
positions.forEach((position, index) => {
|
|
3033
3086
|
if (visibleIndices.has(index)) {
|
|
@@ -4194,25 +4247,25 @@ function orbitRingPositions(count, radius, tilt) {
|
|
|
4194
4247
|
return positions;
|
|
4195
4248
|
}
|
|
4196
4249
|
function arcCurve3D(from, to, offset) {
|
|
4197
|
-
const start = new
|
|
4198
|
-
const end = new
|
|
4199
|
-
const mid = new
|
|
4200
|
-
const dir = new
|
|
4201
|
-
const up = new
|
|
4202
|
-
const perp = new
|
|
4250
|
+
const start = new THREE5.Vector3(...from);
|
|
4251
|
+
const end = new THREE5.Vector3(...to);
|
|
4252
|
+
const mid = new THREE5.Vector3().addVectors(start, end).multiplyScalar(0.5);
|
|
4253
|
+
const dir = new THREE5.Vector3().subVectors(end, start).normalize();
|
|
4254
|
+
const up = new THREE5.Vector3(0, 1, 0);
|
|
4255
|
+
const perp = new THREE5.Vector3().crossVectors(dir, up).normalize();
|
|
4203
4256
|
if (perp.length() < 1e-3) {
|
|
4204
|
-
perp.crossVectors(dir, new
|
|
4257
|
+
perp.crossVectors(dir, new THREE5.Vector3(1, 0, 0)).normalize();
|
|
4205
4258
|
}
|
|
4206
4259
|
const control = mid.clone().add(perp.multiplyScalar(offset));
|
|
4207
4260
|
control.y += Math.abs(offset) * 0.3;
|
|
4208
|
-
return new
|
|
4261
|
+
return new THREE5.QuadraticBezierCurve3(start, control, end);
|
|
4209
4262
|
}
|
|
4210
4263
|
function selfLoopCurve3D(position, loopRadius) {
|
|
4211
|
-
const base = new
|
|
4212
|
-
const start = base.clone().add(new
|
|
4213
|
-
const end = base.clone().add(new
|
|
4214
|
-
const control = base.clone().add(new
|
|
4215
|
-
return new
|
|
4264
|
+
const base = new THREE5.Vector3(...position);
|
|
4265
|
+
const start = base.clone().add(new THREE5.Vector3(-loopRadius * 0.3, 0, 0));
|
|
4266
|
+
const end = base.clone().add(new THREE5.Vector3(loopRadius * 0.3, 0, 0));
|
|
4267
|
+
const control = base.clone().add(new THREE5.Vector3(0, loopRadius, 0));
|
|
4268
|
+
return new THREE5.QuadraticBezierCurve3(start, control, end);
|
|
4216
4269
|
}
|
|
4217
4270
|
function treeLayout3D(node, origin, horizontalSpacing, verticalSpacing = 2) {
|
|
4218
4271
|
const results = [];
|
|
@@ -4379,7 +4432,7 @@ var Avl3DOrbitalNode = ({
|
|
|
4379
4432
|
if (!groupRef.current) return;
|
|
4380
4433
|
groupRef.current.rotation.y += delta * (hovered ? 0.4 : 0.2);
|
|
4381
4434
|
groupRef.current.rotation.x += delta * 0.05;
|
|
4382
|
-
currentScale.current =
|
|
4435
|
+
currentScale.current = THREE5.MathUtils.damp(currentScale.current, targetScale, 6, delta);
|
|
4383
4436
|
});
|
|
4384
4437
|
const baseBrightness = 0.3 + Math.min(pageCount, 5) * 0.05;
|
|
4385
4438
|
const emissiveIntensity = hovered ? 0.8 : baseBrightness;
|
|
@@ -5021,7 +5074,7 @@ var Avl3DStateNode = ({
|
|
|
5021
5074
|
const targetScale = hovered ? 1.08 : 1;
|
|
5022
5075
|
const currentScale = React3.useRef(1);
|
|
5023
5076
|
fiber.useFrame((_, delta) => {
|
|
5024
|
-
currentScale.current =
|
|
5077
|
+
currentScale.current = THREE5.MathUtils.damp(currentScale.current, targetScale, 6, delta);
|
|
5025
5078
|
});
|
|
5026
5079
|
const scale = currentScale.current;
|
|
5027
5080
|
return /* @__PURE__ */ jsxRuntime.jsxs("group", { position, children: [
|
|
@@ -5201,9 +5254,9 @@ var Avl3DTransitionArc = ({
|
|
|
5201
5254
|
const guardPt = curve.getPoint(0.3);
|
|
5202
5255
|
const arrowPt = curve.getPoint(0.9);
|
|
5203
5256
|
const arrowTangent = curve.getTangent(0.9);
|
|
5204
|
-
const upVec = new
|
|
5205
|
-
const tangentVec = new
|
|
5206
|
-
const quat = new
|
|
5257
|
+
const upVec = new THREE5.Vector3(0, 1, 0);
|
|
5258
|
+
const tangentVec = new THREE5.Vector3(arrowTangent.x, arrowTangent.y, arrowTangent.z).normalize();
|
|
5259
|
+
const quat = new THREE5.Quaternion().setFromUnitVectors(upVec, tangentVec);
|
|
5207
5260
|
const effectPositions2 = [];
|
|
5208
5261
|
for (let ei = 0; ei < 4; ei++) {
|
|
5209
5262
|
const t = 0.7 + ei * 0.05;
|
|
@@ -5427,14 +5480,14 @@ function operatorColor(label) {
|
|
|
5427
5480
|
return "#4A90D9";
|
|
5428
5481
|
}
|
|
5429
5482
|
function edgeGeometry(parent, child) {
|
|
5430
|
-
const p = new
|
|
5431
|
-
const c = new
|
|
5432
|
-
const mid = new
|
|
5433
|
-
const dir = new
|
|
5483
|
+
const p = new THREE5.Vector3(parent.x, parent.y, parent.z);
|
|
5484
|
+
const c = new THREE5.Vector3(child.x, child.y, child.z);
|
|
5485
|
+
const mid = new THREE5.Vector3().addVectors(p, c).multiplyScalar(0.5);
|
|
5486
|
+
const dir = new THREE5.Vector3().subVectors(c, p);
|
|
5434
5487
|
const length = dir.length();
|
|
5435
|
-
const yAxis = new
|
|
5488
|
+
const yAxis = new THREE5.Vector3(0, 1, 0);
|
|
5436
5489
|
const angle = yAxis.angleTo(dir.normalize());
|
|
5437
|
-
const axis = new
|
|
5490
|
+
const axis = new THREE5.Vector3().crossVectors(yAxis, dir).normalize();
|
|
5438
5491
|
if (axis.length() < 1e-3) {
|
|
5439
5492
|
return {
|
|
5440
5493
|
position: [mid.x, mid.y, mid.z],
|
|
@@ -5810,12 +5863,12 @@ function useAvl3DConfig() {
|
|
|
5810
5863
|
}
|
|
5811
5864
|
function CameraController({ targetPosition, targetLookAt, animated }) {
|
|
5812
5865
|
const { camera } = fiber.useThree();
|
|
5813
|
-
const targetPosVec = React3.useRef(new
|
|
5814
|
-
const targetLookVec = React3.useRef(new
|
|
5866
|
+
const targetPosVec = React3.useRef(new THREE5__namespace.Vector3(...targetPosition));
|
|
5867
|
+
const targetLookVec = React3.useRef(new THREE5__namespace.Vector3(...targetLookAt));
|
|
5815
5868
|
const isAnimating = React3.useRef(false);
|
|
5816
5869
|
React3.useEffect(() => {
|
|
5817
|
-
const newTarget = new
|
|
5818
|
-
const newLookAt = new
|
|
5870
|
+
const newTarget = new THREE5__namespace.Vector3(...targetPosition);
|
|
5871
|
+
const newLookAt = new THREE5__namespace.Vector3(...targetLookAt);
|
|
5819
5872
|
if (!newTarget.equals(targetPosVec.current) || !newLookAt.equals(targetLookVec.current)) {
|
|
5820
5873
|
targetPosVec.current.copy(newTarget);
|
|
5821
5874
|
targetLookVec.current.copy(newLookAt);
|
|
@@ -5830,9 +5883,9 @@ function CameraController({ targetPosition, targetLookAt, animated }) {
|
|
|
5830
5883
|
fiber.useFrame((_, delta) => {
|
|
5831
5884
|
if (!isAnimating.current) return;
|
|
5832
5885
|
const speed = 3;
|
|
5833
|
-
camera.position.x =
|
|
5834
|
-
camera.position.y =
|
|
5835
|
-
camera.position.z =
|
|
5886
|
+
camera.position.x = THREE5__namespace.MathUtils.damp(camera.position.x, targetPosVec.current.x, speed, delta);
|
|
5887
|
+
camera.position.y = THREE5__namespace.MathUtils.damp(camera.position.y, targetPosVec.current.y, speed, delta);
|
|
5888
|
+
camera.position.z = THREE5__namespace.MathUtils.damp(camera.position.z, targetPosVec.current.z, speed, delta);
|
|
5836
5889
|
camera.lookAt(targetLookVec.current);
|
|
5837
5890
|
const dist = camera.position.distanceTo(targetPosVec.current);
|
|
5838
5891
|
if (dist < 0.05) {
|
|
@@ -5847,7 +5900,7 @@ function SceneFade({ animating, children }) {
|
|
|
5847
5900
|
fiber.useFrame((_, delta) => {
|
|
5848
5901
|
if (!groupRef.current) return;
|
|
5849
5902
|
const target = animating ? 0 : 1;
|
|
5850
|
-
opacityRef.current =
|
|
5903
|
+
opacityRef.current = THREE5__namespace.MathUtils.damp(opacityRef.current, target, 5, delta);
|
|
5851
5904
|
groupRef.current.visible = opacityRef.current > 0.05;
|
|
5852
5905
|
const s = 0.9 + opacityRef.current * 0.1;
|
|
5853
5906
|
groupRef.current.scale.setScalar(s);
|