@almadar/ui 4.51.16 → 4.52.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 +1940 -1802
- package/dist/avl/index.js +694 -556
- package/dist/components/atoms/Aside.d.ts +15 -0
- package/dist/components/atoms/Dialog.d.ts +18 -0
- package/dist/components/atoms/index.d.ts +2 -0
- package/dist/components/index.cjs +1523 -1406
- package/dist/components/index.js +500 -383
- package/dist/components/molecules/CalendarGrid.d.ts +14 -1
- package/dist/components/molecules/SidePanel.d.ts +7 -2
- package/dist/components/molecules/Tabs.d.ts +10 -2
- package/dist/components/molecules/avl/avl-preview-types.d.ts +24 -3
- package/dist/components/organisms/game/three/index.cjs +175 -185
- package/dist/components/organisms/game/three/index.js +12 -22
- package/dist/docs/index.cjs +7 -17
- package/dist/docs/index.js +8 -18
- package/dist/marketing/index.cjs +22 -27
- package/dist/marketing/index.js +23 -28
- package/dist/providers/index.cjs +1619 -1504
- package/dist/providers/index.js +728 -613
- package/dist/runtime/index.cjs +1658 -1543
- package/dist/runtime/index.js +732 -617
- package/package.json +1 -1
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
var
|
|
3
|
+
var React10 = require('react');
|
|
4
4
|
var fiber = require('@react-three/fiber');
|
|
5
5
|
var THREE6 = require('three');
|
|
6
6
|
var jsxRuntime = require('react/jsx-runtime');
|
|
@@ -35,7 +35,7 @@ function _interopNamespace(e) {
|
|
|
35
35
|
return Object.freeze(n);
|
|
36
36
|
}
|
|
37
37
|
|
|
38
|
-
var
|
|
38
|
+
var React10__default = /*#__PURE__*/_interopDefault(React10);
|
|
39
39
|
var THREE6__namespace = /*#__PURE__*/_interopNamespace(THREE6);
|
|
40
40
|
|
|
41
41
|
var __defProp = Object.defineProperty;
|
|
@@ -43,8 +43,8 @@ var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { en
|
|
|
43
43
|
var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value);
|
|
44
44
|
function Scene3D({ background = "#1a1a2e", fog, children }) {
|
|
45
45
|
const { scene } = fiber.useThree();
|
|
46
|
-
const initializedRef =
|
|
47
|
-
|
|
46
|
+
const initializedRef = React10.useRef(false);
|
|
47
|
+
React10.useEffect(() => {
|
|
48
48
|
if (initializedRef.current) return;
|
|
49
49
|
initializedRef.current = true;
|
|
50
50
|
if (background.startsWith("#") || background.startsWith("rgb")) {
|
|
@@ -65,7 +65,7 @@ function Scene3D({ background = "#1a1a2e", fog, children }) {
|
|
|
65
65
|
}, [scene, background, fog]);
|
|
66
66
|
return /* @__PURE__ */ jsxRuntime.jsx(jsxRuntime.Fragment, { children });
|
|
67
67
|
}
|
|
68
|
-
var Camera3D =
|
|
68
|
+
var Camera3D = React10.forwardRef(
|
|
69
69
|
({
|
|
70
70
|
mode = "isometric",
|
|
71
71
|
position = [10, 10, 10],
|
|
@@ -78,10 +78,10 @@ var Camera3D = React21.forwardRef(
|
|
|
78
78
|
onChange
|
|
79
79
|
}, ref) => {
|
|
80
80
|
const { camera, set, viewport } = fiber.useThree();
|
|
81
|
-
const controlsRef =
|
|
82
|
-
const initialPosition =
|
|
83
|
-
const initialTarget =
|
|
84
|
-
|
|
81
|
+
const controlsRef = React10.useRef(null);
|
|
82
|
+
const initialPosition = React10.useRef(new THREE6__namespace.Vector3(...position));
|
|
83
|
+
const initialTarget = React10.useRef(new THREE6__namespace.Vector3(...target));
|
|
84
|
+
React10.useEffect(() => {
|
|
85
85
|
let newCamera;
|
|
86
86
|
if (mode === "isometric") {
|
|
87
87
|
const aspect = viewport.aspect;
|
|
@@ -112,7 +112,7 @@ var Camera3D = React21.forwardRef(
|
|
|
112
112
|
onChange(camera);
|
|
113
113
|
}
|
|
114
114
|
});
|
|
115
|
-
|
|
115
|
+
React10.useImperativeHandle(ref, () => ({
|
|
116
116
|
getCamera: () => camera,
|
|
117
117
|
setPosition: (x, y, z) => {
|
|
118
118
|
camera.position.set(x, y, z);
|
|
@@ -254,7 +254,7 @@ function Canvas3DLoadingState({
|
|
|
254
254
|
] });
|
|
255
255
|
}
|
|
256
256
|
var log = logger.createLogger("almadar:ui:game:canvas3d:error-boundary");
|
|
257
|
-
var Canvas3DErrorBoundary = class extends
|
|
257
|
+
var Canvas3DErrorBoundary = class extends React10.Component {
|
|
258
258
|
constructor(props) {
|
|
259
259
|
super(props);
|
|
260
260
|
__publicField(this, "handleReset", () => {
|
|
@@ -334,12 +334,12 @@ function detectAssetRoot(modelUrl) {
|
|
|
334
334
|
return modelUrl.substring(0, modelUrl.lastIndexOf("/") + 1);
|
|
335
335
|
}
|
|
336
336
|
function useGLTFModel(url, resourceBasePath) {
|
|
337
|
-
const [state, setState] =
|
|
337
|
+
const [state, setState] = React10.useState({
|
|
338
338
|
model: null,
|
|
339
339
|
isLoading: false,
|
|
340
340
|
error: null
|
|
341
341
|
});
|
|
342
|
-
|
|
342
|
+
React10.useEffect(() => {
|
|
343
343
|
if (!url) {
|
|
344
344
|
setState({ model: null, isLoading: false, error: null });
|
|
345
345
|
return;
|
|
@@ -387,7 +387,7 @@ function ModelLoader({
|
|
|
387
387
|
resourceBasePath
|
|
388
388
|
}) {
|
|
389
389
|
const { model: loadedModel, isLoading, error } = useGLTFModel(url, resourceBasePath);
|
|
390
|
-
const model =
|
|
390
|
+
const model = React10.useMemo(() => {
|
|
391
391
|
if (!loadedModel) return null;
|
|
392
392
|
const cloned = loadedModel.clone();
|
|
393
393
|
cloned.traverse((child) => {
|
|
@@ -398,13 +398,13 @@ function ModelLoader({
|
|
|
398
398
|
});
|
|
399
399
|
return cloned;
|
|
400
400
|
}, [loadedModel, castShadow, receiveShadow]);
|
|
401
|
-
const scaleArray =
|
|
401
|
+
const scaleArray = React10.useMemo(() => {
|
|
402
402
|
if (typeof scale === "number") {
|
|
403
403
|
return [scale, scale, scale];
|
|
404
404
|
}
|
|
405
405
|
return scale;
|
|
406
406
|
}, [scale]);
|
|
407
|
-
const rotationRad =
|
|
407
|
+
const rotationRad = React10.useMemo(() => {
|
|
408
408
|
return [
|
|
409
409
|
rotation[0] * Math.PI / 180,
|
|
410
410
|
rotation[1] * Math.PI / 180,
|
|
@@ -491,8 +491,8 @@ function PhysicsObject3D({
|
|
|
491
491
|
onGroundHit,
|
|
492
492
|
onCollision
|
|
493
493
|
}) {
|
|
494
|
-
const groupRef =
|
|
495
|
-
const physicsStateRef =
|
|
494
|
+
const groupRef = React10.useRef(null);
|
|
495
|
+
const physicsStateRef = React10.useRef({
|
|
496
496
|
id: entityId,
|
|
497
497
|
x: initialPosition[0],
|
|
498
498
|
y: initialPosition[1],
|
|
@@ -509,8 +509,8 @@ function PhysicsObject3D({
|
|
|
509
509
|
mass,
|
|
510
510
|
state: "Active"
|
|
511
511
|
});
|
|
512
|
-
const groundHitRef =
|
|
513
|
-
|
|
512
|
+
const groundHitRef = React10.useRef(false);
|
|
513
|
+
React10.useEffect(() => {
|
|
514
514
|
if (groupRef.current) {
|
|
515
515
|
groupRef.current.position.set(
|
|
516
516
|
initialPosition[0],
|
|
@@ -791,21 +791,21 @@ var DEFAULT_OPTIONS = {
|
|
|
791
791
|
};
|
|
792
792
|
function useThree3(options = {}) {
|
|
793
793
|
const opts = { ...DEFAULT_OPTIONS, ...options };
|
|
794
|
-
const containerRef =
|
|
795
|
-
const canvasRef =
|
|
796
|
-
const rendererRef =
|
|
797
|
-
const sceneRef =
|
|
798
|
-
const cameraRef =
|
|
799
|
-
const controlsRef =
|
|
800
|
-
const gridHelperRef =
|
|
801
|
-
const rafRef =
|
|
802
|
-
const [isReady, setIsReady] =
|
|
803
|
-
const [dimensions, setDimensions] =
|
|
804
|
-
const initialCameraPosition =
|
|
794
|
+
const containerRef = React10.useRef(null);
|
|
795
|
+
const canvasRef = React10.useRef(null);
|
|
796
|
+
const rendererRef = React10.useRef(null);
|
|
797
|
+
const sceneRef = React10.useRef(null);
|
|
798
|
+
const cameraRef = React10.useRef(null);
|
|
799
|
+
const controlsRef = React10.useRef(null);
|
|
800
|
+
const gridHelperRef = React10.useRef(null);
|
|
801
|
+
const rafRef = React10.useRef(0);
|
|
802
|
+
const [isReady, setIsReady] = React10.useState(false);
|
|
803
|
+
const [dimensions, setDimensions] = React10.useState({ width: 0, height: 0 });
|
|
804
|
+
const initialCameraPosition = React10.useMemo(
|
|
805
805
|
() => new THREE6__namespace.Vector3(...opts.cameraPosition),
|
|
806
806
|
[]
|
|
807
807
|
);
|
|
808
|
-
|
|
808
|
+
React10.useEffect(() => {
|
|
809
809
|
if (!containerRef.current) return;
|
|
810
810
|
const container = containerRef.current;
|
|
811
811
|
const { clientWidth, clientHeight } = container;
|
|
@@ -898,7 +898,7 @@ function useThree3(options = {}) {
|
|
|
898
898
|
scene.clear();
|
|
899
899
|
};
|
|
900
900
|
}, []);
|
|
901
|
-
|
|
901
|
+
React10.useEffect(() => {
|
|
902
902
|
if (!cameraRef.current || !containerRef.current) return;
|
|
903
903
|
const container = containerRef.current;
|
|
904
904
|
const { clientWidth, clientHeight } = container;
|
|
@@ -933,20 +933,20 @@ function useThree3(options = {}) {
|
|
|
933
933
|
animate();
|
|
934
934
|
}
|
|
935
935
|
}, [opts.cameraMode]);
|
|
936
|
-
const setCameraPosition =
|
|
936
|
+
const setCameraPosition = React10.useCallback((x, y, z) => {
|
|
937
937
|
if (cameraRef.current) {
|
|
938
938
|
cameraRef.current.position.set(x, y, z);
|
|
939
939
|
controlsRef.current?.update();
|
|
940
940
|
}
|
|
941
941
|
}, []);
|
|
942
|
-
const lookAt =
|
|
942
|
+
const lookAt = React10.useCallback((x, y, z) => {
|
|
943
943
|
if (cameraRef.current) {
|
|
944
944
|
cameraRef.current.lookAt(x, y, z);
|
|
945
945
|
controlsRef.current?.target.set(x, y, z);
|
|
946
946
|
controlsRef.current?.update();
|
|
947
947
|
}
|
|
948
948
|
}, []);
|
|
949
|
-
const resetCamera =
|
|
949
|
+
const resetCamera = React10.useCallback(() => {
|
|
950
950
|
if (cameraRef.current) {
|
|
951
951
|
cameraRef.current.position.copy(initialCameraPosition);
|
|
952
952
|
cameraRef.current.lookAt(0, 0, 0);
|
|
@@ -956,7 +956,7 @@ function useThree3(options = {}) {
|
|
|
956
956
|
}
|
|
957
957
|
}
|
|
958
958
|
}, [initialCameraPosition]);
|
|
959
|
-
const fitView =
|
|
959
|
+
const fitView = React10.useCallback(
|
|
960
960
|
(bounds) => {
|
|
961
961
|
if (!cameraRef.current) return;
|
|
962
962
|
const centerX = (bounds.minX + bounds.maxX) / 2;
|
|
@@ -987,20 +987,20 @@ function useThree3(options = {}) {
|
|
|
987
987
|
}
|
|
988
988
|
function useAssetLoader(options = {}) {
|
|
989
989
|
const { preloadUrls = [], loader: customLoader } = options;
|
|
990
|
-
const loaderRef =
|
|
991
|
-
const [state, setState] =
|
|
990
|
+
const loaderRef = React10.useRef(customLoader || new AssetLoader());
|
|
991
|
+
const [state, setState] = React10.useState({
|
|
992
992
|
isLoading: false,
|
|
993
993
|
progress: 0,
|
|
994
994
|
loaded: 0,
|
|
995
995
|
total: 0,
|
|
996
996
|
errors: []
|
|
997
997
|
});
|
|
998
|
-
|
|
998
|
+
React10.useEffect(() => {
|
|
999
999
|
if (preloadUrls.length > 0) {
|
|
1000
1000
|
preload(preloadUrls);
|
|
1001
1001
|
}
|
|
1002
1002
|
}, []);
|
|
1003
|
-
const updateProgress =
|
|
1003
|
+
const updateProgress = React10.useCallback((loaded, total) => {
|
|
1004
1004
|
setState((prev) => ({
|
|
1005
1005
|
...prev,
|
|
1006
1006
|
loaded,
|
|
@@ -1008,7 +1008,7 @@ function useAssetLoader(options = {}) {
|
|
|
1008
1008
|
progress: total > 0 ? Math.round(loaded / total * 100) : 0
|
|
1009
1009
|
}));
|
|
1010
1010
|
}, []);
|
|
1011
|
-
const loadModel =
|
|
1011
|
+
const loadModel = React10.useCallback(
|
|
1012
1012
|
async (url) => {
|
|
1013
1013
|
setState((prev) => ({ ...prev, isLoading: true }));
|
|
1014
1014
|
try {
|
|
@@ -1031,7 +1031,7 @@ function useAssetLoader(options = {}) {
|
|
|
1031
1031
|
},
|
|
1032
1032
|
[]
|
|
1033
1033
|
);
|
|
1034
|
-
const loadOBJ =
|
|
1034
|
+
const loadOBJ = React10.useCallback(
|
|
1035
1035
|
async (url) => {
|
|
1036
1036
|
setState((prev) => ({ ...prev, isLoading: true }));
|
|
1037
1037
|
try {
|
|
@@ -1054,7 +1054,7 @@ function useAssetLoader(options = {}) {
|
|
|
1054
1054
|
},
|
|
1055
1055
|
[]
|
|
1056
1056
|
);
|
|
1057
|
-
const loadTexture =
|
|
1057
|
+
const loadTexture = React10.useCallback(
|
|
1058
1058
|
async (url) => {
|
|
1059
1059
|
setState((prev) => ({ ...prev, isLoading: true }));
|
|
1060
1060
|
try {
|
|
@@ -1077,7 +1077,7 @@ function useAssetLoader(options = {}) {
|
|
|
1077
1077
|
},
|
|
1078
1078
|
[]
|
|
1079
1079
|
);
|
|
1080
|
-
const preload =
|
|
1080
|
+
const preload = React10.useCallback(
|
|
1081
1081
|
async (urls) => {
|
|
1082
1082
|
setState((prev) => ({
|
|
1083
1083
|
...prev,
|
|
@@ -1116,27 +1116,27 @@ function useAssetLoader(options = {}) {
|
|
|
1116
1116
|
},
|
|
1117
1117
|
[updateProgress]
|
|
1118
1118
|
);
|
|
1119
|
-
const hasModel =
|
|
1119
|
+
const hasModel = React10.useCallback((url) => {
|
|
1120
1120
|
return loaderRef.current.hasModel(url);
|
|
1121
1121
|
}, []);
|
|
1122
|
-
const hasTexture =
|
|
1122
|
+
const hasTexture = React10.useCallback((url) => {
|
|
1123
1123
|
return loaderRef.current.hasTexture(url);
|
|
1124
1124
|
}, []);
|
|
1125
|
-
const getModel =
|
|
1125
|
+
const getModel = React10.useCallback((url) => {
|
|
1126
1126
|
try {
|
|
1127
1127
|
return loaderRef.current.getModel(url);
|
|
1128
1128
|
} catch {
|
|
1129
1129
|
return void 0;
|
|
1130
1130
|
}
|
|
1131
1131
|
}, []);
|
|
1132
|
-
const getTexture =
|
|
1132
|
+
const getTexture = React10.useCallback((url) => {
|
|
1133
1133
|
try {
|
|
1134
1134
|
return loaderRef.current.getTexture(url);
|
|
1135
1135
|
} catch {
|
|
1136
1136
|
return void 0;
|
|
1137
1137
|
}
|
|
1138
1138
|
}, []);
|
|
1139
|
-
const clearCache =
|
|
1139
|
+
const clearCache = React10.useCallback(() => {
|
|
1140
1140
|
loaderRef.current.clearCache();
|
|
1141
1141
|
setState({
|
|
1142
1142
|
isLoading: false,
|
|
@@ -1160,25 +1160,25 @@ function useAssetLoader(options = {}) {
|
|
|
1160
1160
|
};
|
|
1161
1161
|
}
|
|
1162
1162
|
function useSceneGraph() {
|
|
1163
|
-
const nodesRef =
|
|
1164
|
-
const addNode =
|
|
1163
|
+
const nodesRef = React10.useRef(/* @__PURE__ */ new Map());
|
|
1164
|
+
const addNode = React10.useCallback((node) => {
|
|
1165
1165
|
const existing = nodesRef.current.get(node.id);
|
|
1166
1166
|
if (existing) {
|
|
1167
1167
|
existing.mesh.removeFromParent();
|
|
1168
1168
|
}
|
|
1169
1169
|
nodesRef.current.set(node.id, node);
|
|
1170
1170
|
}, []);
|
|
1171
|
-
const removeNode =
|
|
1171
|
+
const removeNode = React10.useCallback((id) => {
|
|
1172
1172
|
const node = nodesRef.current.get(id);
|
|
1173
1173
|
if (node) {
|
|
1174
1174
|
node.mesh.removeFromParent();
|
|
1175
1175
|
nodesRef.current.delete(id);
|
|
1176
1176
|
}
|
|
1177
1177
|
}, []);
|
|
1178
|
-
const getNode =
|
|
1178
|
+
const getNode = React10.useCallback((id) => {
|
|
1179
1179
|
return nodesRef.current.get(id);
|
|
1180
1180
|
}, []);
|
|
1181
|
-
const updateNodePosition =
|
|
1181
|
+
const updateNodePosition = React10.useCallback(
|
|
1182
1182
|
(id, x, y, z) => {
|
|
1183
1183
|
const node = nodesRef.current.get(id);
|
|
1184
1184
|
if (node) {
|
|
@@ -1188,7 +1188,7 @@ function useSceneGraph() {
|
|
|
1188
1188
|
},
|
|
1189
1189
|
[]
|
|
1190
1190
|
);
|
|
1191
|
-
const updateNodeGridPosition =
|
|
1191
|
+
const updateNodeGridPosition = React10.useCallback(
|
|
1192
1192
|
(id, gridX, gridZ) => {
|
|
1193
1193
|
const node = nodesRef.current.get(id);
|
|
1194
1194
|
if (node) {
|
|
@@ -1197,7 +1197,7 @@ function useSceneGraph() {
|
|
|
1197
1197
|
},
|
|
1198
1198
|
[]
|
|
1199
1199
|
);
|
|
1200
|
-
const getNodeAtGrid =
|
|
1200
|
+
const getNodeAtGrid = React10.useCallback(
|
|
1201
1201
|
(x, z, type) => {
|
|
1202
1202
|
return Array.from(nodesRef.current.values()).find((node) => {
|
|
1203
1203
|
const matchesGrid = node.gridPosition.x === x && node.gridPosition.z === z;
|
|
@@ -1206,10 +1206,10 @@ function useSceneGraph() {
|
|
|
1206
1206
|
},
|
|
1207
1207
|
[]
|
|
1208
1208
|
);
|
|
1209
|
-
const getNodesByType =
|
|
1209
|
+
const getNodesByType = React10.useCallback((type) => {
|
|
1210
1210
|
return Array.from(nodesRef.current.values()).filter((node) => node.type === type);
|
|
1211
1211
|
}, []);
|
|
1212
|
-
const getNodesInBounds =
|
|
1212
|
+
const getNodesInBounds = React10.useCallback(
|
|
1213
1213
|
(minX, maxX, minZ, maxZ) => {
|
|
1214
1214
|
return Array.from(nodesRef.current.values()).filter((node) => {
|
|
1215
1215
|
const { x, z } = node.gridPosition;
|
|
@@ -1218,13 +1218,13 @@ function useSceneGraph() {
|
|
|
1218
1218
|
},
|
|
1219
1219
|
[]
|
|
1220
1220
|
);
|
|
1221
|
-
const clearNodes =
|
|
1221
|
+
const clearNodes = React10.useCallback(() => {
|
|
1222
1222
|
nodesRef.current.forEach((node) => {
|
|
1223
1223
|
node.mesh.removeFromParent();
|
|
1224
1224
|
});
|
|
1225
1225
|
nodesRef.current.clear();
|
|
1226
1226
|
}, []);
|
|
1227
|
-
const countNodes =
|
|
1227
|
+
const countNodes = React10.useCallback((type) => {
|
|
1228
1228
|
if (!type) {
|
|
1229
1229
|
return nodesRef.current.size;
|
|
1230
1230
|
}
|
|
@@ -1246,9 +1246,9 @@ function useSceneGraph() {
|
|
|
1246
1246
|
}
|
|
1247
1247
|
function useRaycaster(options) {
|
|
1248
1248
|
const { camera, canvas, cellSize = 1, offsetX = 0, offsetZ = 0 } = options;
|
|
1249
|
-
const raycaster =
|
|
1250
|
-
const mouse =
|
|
1251
|
-
const clientToNDC =
|
|
1249
|
+
const raycaster = React10.useRef(new THREE6__namespace.Raycaster());
|
|
1250
|
+
const mouse = React10.useRef(new THREE6__namespace.Vector2());
|
|
1251
|
+
const clientToNDC = React10.useCallback(
|
|
1252
1252
|
(clientX, clientY) => {
|
|
1253
1253
|
if (!canvas) {
|
|
1254
1254
|
return { x: 0, y: 0 };
|
|
@@ -1261,7 +1261,7 @@ function useRaycaster(options) {
|
|
|
1261
1261
|
},
|
|
1262
1262
|
[canvas]
|
|
1263
1263
|
);
|
|
1264
|
-
const isWithinCanvas =
|
|
1264
|
+
const isWithinCanvas = React10.useCallback(
|
|
1265
1265
|
(clientX, clientY) => {
|
|
1266
1266
|
if (!canvas) return false;
|
|
1267
1267
|
const rect = canvas.getBoundingClientRect();
|
|
@@ -1269,7 +1269,7 @@ function useRaycaster(options) {
|
|
|
1269
1269
|
},
|
|
1270
1270
|
[canvas]
|
|
1271
1271
|
);
|
|
1272
|
-
const getIntersection =
|
|
1272
|
+
const getIntersection = React10.useCallback(
|
|
1273
1273
|
(clientX, clientY, objects) => {
|
|
1274
1274
|
if (!camera || !canvas) return null;
|
|
1275
1275
|
const ndc = clientToNDC(clientX, clientY);
|
|
@@ -1292,7 +1292,7 @@ function useRaycaster(options) {
|
|
|
1292
1292
|
},
|
|
1293
1293
|
[camera, canvas, clientToNDC]
|
|
1294
1294
|
);
|
|
1295
|
-
const getAllIntersections =
|
|
1295
|
+
const getAllIntersections = React10.useCallback(
|
|
1296
1296
|
(clientX, clientY, objects) => {
|
|
1297
1297
|
if (!camera || !canvas) return [];
|
|
1298
1298
|
const ndc = clientToNDC(clientX, clientY);
|
|
@@ -1311,7 +1311,7 @@ function useRaycaster(options) {
|
|
|
1311
1311
|
},
|
|
1312
1312
|
[camera, canvas, clientToNDC]
|
|
1313
1313
|
);
|
|
1314
|
-
const getGridCoordinates =
|
|
1314
|
+
const getGridCoordinates = React10.useCallback(
|
|
1315
1315
|
(clientX, clientY) => {
|
|
1316
1316
|
if (!camera || !canvas) return null;
|
|
1317
1317
|
const ndc = clientToNDC(clientX, clientY);
|
|
@@ -1329,7 +1329,7 @@ function useRaycaster(options) {
|
|
|
1329
1329
|
},
|
|
1330
1330
|
[camera, canvas, cellSize, offsetX, offsetZ, clientToNDC]
|
|
1331
1331
|
);
|
|
1332
|
-
const getTileAtPosition =
|
|
1332
|
+
const getTileAtPosition = React10.useCallback(
|
|
1333
1333
|
(clientX, clientY, scene) => {
|
|
1334
1334
|
if (!camera || !canvas) return null;
|
|
1335
1335
|
const tileMeshes = [];
|
|
@@ -1452,10 +1452,10 @@ var fallbackEventBus = {
|
|
|
1452
1452
|
}
|
|
1453
1453
|
};
|
|
1454
1454
|
function useEventBus() {
|
|
1455
|
-
const context =
|
|
1455
|
+
const context = React10.useContext(providers.EventBusContext);
|
|
1456
1456
|
const baseBus = context ?? getGlobalEventBus() ?? fallbackEventBus;
|
|
1457
1457
|
const scope = providers.useTraitScope();
|
|
1458
|
-
return
|
|
1458
|
+
return React10.useMemo(() => {
|
|
1459
1459
|
if (!scope) {
|
|
1460
1460
|
return {
|
|
1461
1461
|
...baseBus,
|
|
@@ -1491,7 +1491,7 @@ function useEventBus() {
|
|
|
1491
1491
|
}
|
|
1492
1492
|
function useEmitEvent() {
|
|
1493
1493
|
const eventBus = useEventBus();
|
|
1494
|
-
return
|
|
1494
|
+
return React10.useCallback(
|
|
1495
1495
|
(type, payload, source) => {
|
|
1496
1496
|
eventBus.emit(type, payload, source);
|
|
1497
1497
|
},
|
|
@@ -1518,9 +1518,9 @@ function useGameCanvas3DEvents(options) {
|
|
|
1518
1518
|
onUnitAnimation
|
|
1519
1519
|
} = options;
|
|
1520
1520
|
const emit = useEmitEvent();
|
|
1521
|
-
const optionsRef =
|
|
1521
|
+
const optionsRef = React10.useRef(options);
|
|
1522
1522
|
optionsRef.current = options;
|
|
1523
|
-
const handleTileClick =
|
|
1523
|
+
const handleTileClick = React10.useCallback(
|
|
1524
1524
|
(tile, event) => {
|
|
1525
1525
|
if (tileClickEvent) {
|
|
1526
1526
|
emit(tileClickEvent, {
|
|
@@ -1536,7 +1536,7 @@ function useGameCanvas3DEvents(options) {
|
|
|
1536
1536
|
},
|
|
1537
1537
|
[tileClickEvent, emit]
|
|
1538
1538
|
);
|
|
1539
|
-
const handleUnitClick =
|
|
1539
|
+
const handleUnitClick = React10.useCallback(
|
|
1540
1540
|
(unit, event) => {
|
|
1541
1541
|
if (unitClickEvent) {
|
|
1542
1542
|
emit(unitClickEvent, {
|
|
@@ -1555,7 +1555,7 @@ function useGameCanvas3DEvents(options) {
|
|
|
1555
1555
|
},
|
|
1556
1556
|
[unitClickEvent, emit]
|
|
1557
1557
|
);
|
|
1558
|
-
const handleFeatureClick =
|
|
1558
|
+
const handleFeatureClick = React10.useCallback(
|
|
1559
1559
|
(feature, event) => {
|
|
1560
1560
|
if (featureClickEvent) {
|
|
1561
1561
|
emit(featureClickEvent, {
|
|
@@ -1570,7 +1570,7 @@ function useGameCanvas3DEvents(options) {
|
|
|
1570
1570
|
},
|
|
1571
1571
|
[featureClickEvent, emit]
|
|
1572
1572
|
);
|
|
1573
|
-
const handleCanvasClick =
|
|
1573
|
+
const handleCanvasClick = React10.useCallback(
|
|
1574
1574
|
(event) => {
|
|
1575
1575
|
if (canvasClickEvent) {
|
|
1576
1576
|
emit(canvasClickEvent, {
|
|
@@ -1583,7 +1583,7 @@ function useGameCanvas3DEvents(options) {
|
|
|
1583
1583
|
},
|
|
1584
1584
|
[canvasClickEvent, emit]
|
|
1585
1585
|
);
|
|
1586
|
-
const handleTileHover =
|
|
1586
|
+
const handleTileHover = React10.useCallback(
|
|
1587
1587
|
(tile, event) => {
|
|
1588
1588
|
if (tile) {
|
|
1589
1589
|
if (tileHoverEvent) {
|
|
@@ -1603,7 +1603,7 @@ function useGameCanvas3DEvents(options) {
|
|
|
1603
1603
|
},
|
|
1604
1604
|
[tileHoverEvent, tileLeaveEvent, emit]
|
|
1605
1605
|
);
|
|
1606
|
-
const handleUnitAnimation =
|
|
1606
|
+
const handleUnitAnimation = React10.useCallback(
|
|
1607
1607
|
(unitId, state) => {
|
|
1608
1608
|
if (unitAnimationEvent) {
|
|
1609
1609
|
emit(unitAnimationEvent, {
|
|
@@ -1616,7 +1616,7 @@ function useGameCanvas3DEvents(options) {
|
|
|
1616
1616
|
},
|
|
1617
1617
|
[unitAnimationEvent, emit]
|
|
1618
1618
|
);
|
|
1619
|
-
const handleCameraChange =
|
|
1619
|
+
const handleCameraChange = React10.useCallback(
|
|
1620
1620
|
(position) => {
|
|
1621
1621
|
if (cameraChangeEvent) {
|
|
1622
1622
|
emit(cameraChangeEvent, {
|
|
@@ -1662,17 +1662,17 @@ function TileRenderer({
|
|
|
1662
1662
|
validMoves = [],
|
|
1663
1663
|
attackTargets = []
|
|
1664
1664
|
}) {
|
|
1665
|
-
const meshRef =
|
|
1666
|
-
const geometry =
|
|
1665
|
+
const meshRef = React10.useRef(null);
|
|
1666
|
+
const geometry = React10.useMemo(() => {
|
|
1667
1667
|
return new THREE6__namespace.BoxGeometry(cellSize * 0.95, 0.2, cellSize * 0.95);
|
|
1668
1668
|
}, [cellSize]);
|
|
1669
|
-
const material =
|
|
1669
|
+
const material = React10.useMemo(() => {
|
|
1670
1670
|
return new THREE6__namespace.MeshStandardMaterial({
|
|
1671
1671
|
roughness: 0.8,
|
|
1672
1672
|
metalness: 0.1
|
|
1673
1673
|
});
|
|
1674
1674
|
}, []);
|
|
1675
|
-
const { positions, colors, tileMap } =
|
|
1675
|
+
const { positions, colors, tileMap } = React10.useMemo(() => {
|
|
1676
1676
|
const pos = [];
|
|
1677
1677
|
const cols = [];
|
|
1678
1678
|
const map = /* @__PURE__ */ new Map();
|
|
@@ -1702,7 +1702,7 @@ function TileRenderer({
|
|
|
1702
1702
|
});
|
|
1703
1703
|
return { positions: pos, colors: cols, tileMap: map };
|
|
1704
1704
|
}, [tiles, cellSize, offsetX, offsetZ, terrainColors, selectedTileIds, validMoves, attackTargets]);
|
|
1705
|
-
|
|
1705
|
+
React10.useEffect(() => {
|
|
1706
1706
|
if (!meshRef.current || !useInstancing) return;
|
|
1707
1707
|
const mesh = meshRef.current;
|
|
1708
1708
|
mesh.count = positions.length;
|
|
@@ -1806,10 +1806,10 @@ function TileRenderer({
|
|
|
1806
1806
|
return /* @__PURE__ */ jsxRuntime.jsx("group", { children: renderIndividualTiles() });
|
|
1807
1807
|
}
|
|
1808
1808
|
function UnitVisual({ unit, position, isSelected, onClick }) {
|
|
1809
|
-
const groupRef =
|
|
1810
|
-
const [animationState, setAnimationState] =
|
|
1811
|
-
const [isHovered, setIsHovered] =
|
|
1812
|
-
const teamColor =
|
|
1809
|
+
const groupRef = React10.useRef(null);
|
|
1810
|
+
const [animationState, setAnimationState] = React10.useState("idle");
|
|
1811
|
+
const [isHovered, setIsHovered] = React10.useState(false);
|
|
1812
|
+
const teamColor = React10.useMemo(() => {
|
|
1813
1813
|
if (unit.faction === "player" || unit.team === "player") return 4491519;
|
|
1814
1814
|
if (unit.faction === "enemy" || unit.team === "enemy") return 16729156;
|
|
1815
1815
|
if (unit.faction === "neutral" || unit.team === "neutral") return 16777028;
|
|
@@ -1821,11 +1821,11 @@ function UnitVisual({ unit, position, isSelected, onClick }) {
|
|
|
1821
1821
|
groupRef.current.position.y = y;
|
|
1822
1822
|
}
|
|
1823
1823
|
});
|
|
1824
|
-
const healthPercent =
|
|
1824
|
+
const healthPercent = React10.useMemo(() => {
|
|
1825
1825
|
if (unit.health === void 0 || unit.maxHealth === void 0) return 1;
|
|
1826
1826
|
return Math.max(0, Math.min(1, unit.health / unit.maxHealth));
|
|
1827
1827
|
}, [unit.health, unit.maxHealth]);
|
|
1828
|
-
const healthColor =
|
|
1828
|
+
const healthColor = React10.useMemo(() => {
|
|
1829
1829
|
if (healthPercent > 0.5) return "#44aa44";
|
|
1830
1830
|
if (healthPercent > 0.25) return "#aaaa44";
|
|
1831
1831
|
return "#ff4444";
|
|
@@ -1886,7 +1886,7 @@ function UnitRenderer({
|
|
|
1886
1886
|
onAnimationStateChange,
|
|
1887
1887
|
animationSpeed = 1
|
|
1888
1888
|
}) {
|
|
1889
|
-
const handleUnitClick =
|
|
1889
|
+
const handleUnitClick = React10__default.default.useCallback(
|
|
1890
1890
|
(unit) => {
|
|
1891
1891
|
onUnitClick?.(unit);
|
|
1892
1892
|
},
|
|
@@ -2100,10 +2100,10 @@ function detectAssetRoot3(modelUrl) {
|
|
|
2100
2100
|
return modelUrl.substring(0, modelUrl.lastIndexOf("/") + 1);
|
|
2101
2101
|
}
|
|
2102
2102
|
function useGLTFModel2(url) {
|
|
2103
|
-
const [model, setModel] =
|
|
2104
|
-
const [isLoading, setIsLoading] =
|
|
2105
|
-
const [error, setError] =
|
|
2106
|
-
|
|
2103
|
+
const [model, setModel] = React10.useState(null);
|
|
2104
|
+
const [isLoading, setIsLoading] = React10.useState(false);
|
|
2105
|
+
const [error, setError] = React10.useState(null);
|
|
2106
|
+
React10.useEffect(() => {
|
|
2107
2107
|
if (!url) {
|
|
2108
2108
|
setModel(null);
|
|
2109
2109
|
return;
|
|
@@ -2135,9 +2135,9 @@ function FeatureModel({
|
|
|
2135
2135
|
onClick,
|
|
2136
2136
|
onHover
|
|
2137
2137
|
}) {
|
|
2138
|
-
const groupRef =
|
|
2138
|
+
const groupRef = React10.useRef(null);
|
|
2139
2139
|
const { model: loadedModel, isLoading } = useGLTFModel2(feature.assetUrl);
|
|
2140
|
-
const model =
|
|
2140
|
+
const model = React10.useMemo(() => {
|
|
2141
2141
|
if (!loadedModel) return null;
|
|
2142
2142
|
const cloned = loadedModel.clone();
|
|
2143
2143
|
cloned.scale.setScalar(0.3);
|
|
@@ -2255,7 +2255,7 @@ function CameraController({
|
|
|
2255
2255
|
onCameraChange
|
|
2256
2256
|
}) {
|
|
2257
2257
|
const { camera } = fiber.useThree();
|
|
2258
|
-
|
|
2258
|
+
React10.useEffect(() => {
|
|
2259
2259
|
if (onCameraChange) {
|
|
2260
2260
|
onCameraChange({
|
|
2261
2261
|
x: camera.position.x,
|
|
@@ -2266,7 +2266,7 @@ function CameraController({
|
|
|
2266
2266
|
}, [camera.position, onCameraChange]);
|
|
2267
2267
|
return null;
|
|
2268
2268
|
}
|
|
2269
|
-
var GameCanvas3D =
|
|
2269
|
+
var GameCanvas3D = React10.forwardRef(
|
|
2270
2270
|
({
|
|
2271
2271
|
tiles = [],
|
|
2272
2272
|
units = [],
|
|
@@ -2311,10 +2311,10 @@ var GameCanvas3D = React21.forwardRef(
|
|
|
2311
2311
|
selectedUnitId = null,
|
|
2312
2312
|
children
|
|
2313
2313
|
}, ref) => {
|
|
2314
|
-
const containerRef =
|
|
2315
|
-
const controlsRef =
|
|
2316
|
-
const [hoveredTile, setHoveredTile] =
|
|
2317
|
-
const [internalError, setInternalError] =
|
|
2314
|
+
const containerRef = React10.useRef(null);
|
|
2315
|
+
const controlsRef = React10.useRef(null);
|
|
2316
|
+
const [hoveredTile, setHoveredTile] = React10.useState(null);
|
|
2317
|
+
const [internalError, setInternalError] = React10.useState(null);
|
|
2318
2318
|
const { isLoading: assetsLoading, progress, loaded, total } = useAssetLoader({
|
|
2319
2319
|
preloadUrls: preloadAssets,
|
|
2320
2320
|
loader: customAssetLoader
|
|
@@ -2335,7 +2335,7 @@ var GameCanvas3D = React21.forwardRef(
|
|
|
2335
2335
|
onTileHover,
|
|
2336
2336
|
onUnitAnimation
|
|
2337
2337
|
});
|
|
2338
|
-
const gridBounds =
|
|
2338
|
+
const gridBounds = React10.useMemo(() => {
|
|
2339
2339
|
if (tiles.length === 0) {
|
|
2340
2340
|
return { minX: 0, maxX: 10, minZ: 0, maxZ: 10 };
|
|
2341
2341
|
}
|
|
@@ -2348,14 +2348,14 @@ var GameCanvas3D = React21.forwardRef(
|
|
|
2348
2348
|
maxZ: Math.max(...zs)
|
|
2349
2349
|
};
|
|
2350
2350
|
}, [tiles]);
|
|
2351
|
-
const cameraTarget =
|
|
2351
|
+
const cameraTarget = React10.useMemo(() => {
|
|
2352
2352
|
return [
|
|
2353
2353
|
(gridBounds.minX + gridBounds.maxX) / 2,
|
|
2354
2354
|
0,
|
|
2355
2355
|
(gridBounds.minZ + gridBounds.maxZ) / 2
|
|
2356
2356
|
];
|
|
2357
2357
|
}, [gridBounds]);
|
|
2358
|
-
const gridConfig =
|
|
2358
|
+
const gridConfig = React10.useMemo(
|
|
2359
2359
|
() => ({
|
|
2360
2360
|
...DEFAULT_GRID_CONFIG,
|
|
2361
2361
|
offsetX: -(gridBounds.maxX - gridBounds.minX) / 2,
|
|
@@ -2363,7 +2363,7 @@ var GameCanvas3D = React21.forwardRef(
|
|
|
2363
2363
|
}),
|
|
2364
2364
|
[gridBounds]
|
|
2365
2365
|
);
|
|
2366
|
-
const gridToWorld2 =
|
|
2366
|
+
const gridToWorld2 = React10.useCallback(
|
|
2367
2367
|
(x, z, y = 0) => {
|
|
2368
2368
|
const worldX = (x - gridBounds.minX) * gridConfig.cellSize;
|
|
2369
2369
|
const worldZ = (z - gridBounds.minZ) * gridConfig.cellSize;
|
|
@@ -2371,7 +2371,7 @@ var GameCanvas3D = React21.forwardRef(
|
|
|
2371
2371
|
},
|
|
2372
2372
|
[gridBounds, gridConfig]
|
|
2373
2373
|
);
|
|
2374
|
-
|
|
2374
|
+
React10.useImperativeHandle(ref, () => ({
|
|
2375
2375
|
getCameraPosition: () => {
|
|
2376
2376
|
if (controlsRef.current) {
|
|
2377
2377
|
const pos = controlsRef.current.object.position;
|
|
@@ -2409,19 +2409,19 @@ var GameCanvas3D = React21.forwardRef(
|
|
|
2409
2409
|
features
|
|
2410
2410
|
})
|
|
2411
2411
|
}));
|
|
2412
|
-
const handleTileClick =
|
|
2412
|
+
const handleTileClick = React10.useCallback(
|
|
2413
2413
|
(tile, event) => {
|
|
2414
2414
|
eventHandlers.handleTileClick(tile, event);
|
|
2415
2415
|
},
|
|
2416
2416
|
[eventHandlers]
|
|
2417
2417
|
);
|
|
2418
|
-
const handleUnitClick =
|
|
2418
|
+
const handleUnitClick = React10.useCallback(
|
|
2419
2419
|
(unit, event) => {
|
|
2420
2420
|
eventHandlers.handleUnitClick(unit, event);
|
|
2421
2421
|
},
|
|
2422
2422
|
[eventHandlers]
|
|
2423
2423
|
);
|
|
2424
|
-
const handleFeatureClick =
|
|
2424
|
+
const handleFeatureClick = React10.useCallback(
|
|
2425
2425
|
(feature, event) => {
|
|
2426
2426
|
if (event) {
|
|
2427
2427
|
eventHandlers.handleFeatureClick(feature, event);
|
|
@@ -2429,7 +2429,7 @@ var GameCanvas3D = React21.forwardRef(
|
|
|
2429
2429
|
},
|
|
2430
2430
|
[eventHandlers]
|
|
2431
2431
|
);
|
|
2432
|
-
const handleTileHover =
|
|
2432
|
+
const handleTileHover = React10.useCallback(
|
|
2433
2433
|
(tile, event) => {
|
|
2434
2434
|
setHoveredTile(tile);
|
|
2435
2435
|
if (event) {
|
|
@@ -2438,7 +2438,7 @@ var GameCanvas3D = React21.forwardRef(
|
|
|
2438
2438
|
},
|
|
2439
2439
|
[eventHandlers]
|
|
2440
2440
|
);
|
|
2441
|
-
const cameraConfig =
|
|
2441
|
+
const cameraConfig = React10.useMemo(() => {
|
|
2442
2442
|
const size = Math.max(
|
|
2443
2443
|
gridBounds.maxX - gridBounds.minX,
|
|
2444
2444
|
gridBounds.maxZ - gridBounds.minZ
|
|
@@ -2463,7 +2463,7 @@ var GameCanvas3D = React21.forwardRef(
|
|
|
2463
2463
|
};
|
|
2464
2464
|
}
|
|
2465
2465
|
}, [cameraMode, gridBounds]);
|
|
2466
|
-
const DefaultTileRenderer =
|
|
2466
|
+
const DefaultTileRenderer = React10.useCallback(
|
|
2467
2467
|
({ tile, position }) => {
|
|
2468
2468
|
const isSelected = tile.id ? selectedTileIds.includes(tile.id) : false;
|
|
2469
2469
|
const isHovered = hoveredTile?.id === tile.id;
|
|
@@ -2501,7 +2501,7 @@ var GameCanvas3D = React21.forwardRef(
|
|
|
2501
2501
|
},
|
|
2502
2502
|
[selectedTileIds, hoveredTile, validMoves, attackTargets, handleTileClick, handleTileHover]
|
|
2503
2503
|
);
|
|
2504
|
-
const DefaultUnitRenderer =
|
|
2504
|
+
const DefaultUnitRenderer = React10.useCallback(
|
|
2505
2505
|
({ unit, position }) => {
|
|
2506
2506
|
const isSelected = selectedUnitId === unit.id;
|
|
2507
2507
|
const color = unit.faction === "player" ? 4491519 : unit.faction === "enemy" ? 16729156 : 16777028;
|
|
@@ -2559,7 +2559,7 @@ var GameCanvas3D = React21.forwardRef(
|
|
|
2559
2559
|
},
|
|
2560
2560
|
[selectedUnitId, handleUnitClick]
|
|
2561
2561
|
);
|
|
2562
|
-
const DefaultFeatureRenderer =
|
|
2562
|
+
const DefaultFeatureRenderer = React10.useCallback(
|
|
2563
2563
|
({
|
|
2564
2564
|
feature,
|
|
2565
2565
|
position
|
|
@@ -2764,6 +2764,8 @@ GameCanvas3D.displayName = "GameCanvas3D";
|
|
|
2764
2764
|
function cn(...inputs) {
|
|
2765
2765
|
return tailwindMerge.twMerge(clsx.clsx(inputs));
|
|
2766
2766
|
}
|
|
2767
|
+
|
|
2768
|
+
// components/atoms/Box.tsx
|
|
2767
2769
|
var paddingStyles = {
|
|
2768
2770
|
none: "p-0",
|
|
2769
2771
|
xs: "p-1",
|
|
@@ -2866,7 +2868,7 @@ var positionStyles = {
|
|
|
2866
2868
|
fixed: "fixed",
|
|
2867
2869
|
sticky: "sticky"
|
|
2868
2870
|
};
|
|
2869
|
-
var Box =
|
|
2871
|
+
var Box = React10__default.default.forwardRef(
|
|
2870
2872
|
({
|
|
2871
2873
|
padding,
|
|
2872
2874
|
paddingX,
|
|
@@ -2896,58 +2898,46 @@ var Box = React21__default.default.forwardRef(
|
|
|
2896
2898
|
...rest
|
|
2897
2899
|
}, ref) => {
|
|
2898
2900
|
const eventBus = useEventBus();
|
|
2899
|
-
const handleClick =
|
|
2901
|
+
const handleClick = React10.useCallback((e) => {
|
|
2900
2902
|
if (action) {
|
|
2901
2903
|
e.stopPropagation();
|
|
2902
2904
|
eventBus.emit(`UI:${action}`, actionPayload ?? {});
|
|
2903
2905
|
}
|
|
2904
2906
|
onClick?.(e);
|
|
2905
2907
|
}, [action, actionPayload, eventBus, onClick]);
|
|
2906
|
-
const handleMouseEnter =
|
|
2908
|
+
const handleMouseEnter = React10.useCallback((e) => {
|
|
2907
2909
|
if (hoverEvent) {
|
|
2908
2910
|
eventBus.emit(`UI:${hoverEvent}`, { hovered: true });
|
|
2909
2911
|
}
|
|
2910
2912
|
onMouseEnter?.(e);
|
|
2911
2913
|
}, [hoverEvent, eventBus, onMouseEnter]);
|
|
2912
|
-
const handleMouseLeave =
|
|
2914
|
+
const handleMouseLeave = React10.useCallback((e) => {
|
|
2913
2915
|
if (hoverEvent) {
|
|
2914
2916
|
eventBus.emit(`UI:${hoverEvent}`, { hovered: false });
|
|
2915
2917
|
}
|
|
2916
2918
|
onMouseLeave?.(e);
|
|
2917
2919
|
}, [hoverEvent, eventBus, onMouseLeave]);
|
|
2918
2920
|
const isClickable = action || onClick;
|
|
2919
|
-
|
|
2920
|
-
|
|
2921
|
-
Comp,
|
|
2921
|
+
return React10__default.default.createElement(
|
|
2922
|
+
Component2,
|
|
2922
2923
|
{
|
|
2923
2924
|
ref,
|
|
2924
2925
|
className: cn(
|
|
2925
|
-
// Padding
|
|
2926
2926
|
padding && paddingStyles[padding],
|
|
2927
2927
|
paddingX && paddingXStyles[paddingX],
|
|
2928
2928
|
paddingY && paddingYStyles[paddingY],
|
|
2929
|
-
// Margin
|
|
2930
2929
|
margin && marginStyles[margin],
|
|
2931
2930
|
marginX && marginXStyles[marginX],
|
|
2932
2931
|
marginY && marginYStyles[marginY],
|
|
2933
|
-
// Background
|
|
2934
2932
|
bgStyles[bg],
|
|
2935
|
-
// Border - uses theme variables
|
|
2936
2933
|
border && "border-[length:var(--border-width)] border-border",
|
|
2937
|
-
// Rounded
|
|
2938
2934
|
roundedStyles[rounded],
|
|
2939
|
-
// Shadow
|
|
2940
2935
|
shadowStyles[shadow],
|
|
2941
|
-
// Display
|
|
2942
2936
|
display && displayStyles[display],
|
|
2943
|
-
// Dimensions
|
|
2944
2937
|
fullWidth && "w-full",
|
|
2945
2938
|
fullHeight && "h-full",
|
|
2946
|
-
// Overflow
|
|
2947
2939
|
overflow && overflowStyles[overflow],
|
|
2948
|
-
// Position
|
|
2949
2940
|
position && positionStyles[position],
|
|
2950
|
-
// Cursor for clickable
|
|
2951
2941
|
isClickable && "cursor-pointer",
|
|
2952
2942
|
className
|
|
2953
2943
|
),
|
|
@@ -2955,9 +2945,9 @@ var Box = React21__default.default.forwardRef(
|
|
|
2955
2945
|
onMouseEnter: hoverEvent || onMouseEnter ? handleMouseEnter : void 0,
|
|
2956
2946
|
onMouseLeave: hoverEvent || onMouseLeave ? handleMouseLeave : void 0,
|
|
2957
2947
|
style: maxWidth ? { maxWidth, ...rest.style } : rest.style,
|
|
2958
|
-
...rest
|
|
2959
|
-
|
|
2960
|
-
|
|
2948
|
+
...rest
|
|
2949
|
+
},
|
|
2950
|
+
children
|
|
2961
2951
|
);
|
|
2962
2952
|
}
|
|
2963
2953
|
);
|
|
@@ -4107,10 +4097,10 @@ var Avl3DOrbitalNode = ({
|
|
|
4107
4097
|
position,
|
|
4108
4098
|
onClick
|
|
4109
4099
|
}) => {
|
|
4110
|
-
const groupRef =
|
|
4111
|
-
const [hovered, setHovered] =
|
|
4112
|
-
const scale =
|
|
4113
|
-
const currentScale =
|
|
4100
|
+
const groupRef = React10.useRef(null);
|
|
4101
|
+
const [hovered, setHovered] = React10.useState(false);
|
|
4102
|
+
const scale = React10.useMemo(() => 0.6 + Math.min(traitCount, 8) * 0.3, [traitCount]);
|
|
4103
|
+
const currentScale = React10.useRef(scale);
|
|
4114
4104
|
const targetScale = hovered ? scale * 1.06 : scale;
|
|
4115
4105
|
fiber.useFrame((_, delta) => {
|
|
4116
4106
|
if (!groupRef.current) return;
|
|
@@ -4252,7 +4242,7 @@ var Avl3DCrossWire = ({
|
|
|
4252
4242
|
eventName,
|
|
4253
4243
|
color = AVL_3D_COLORS.crossWire
|
|
4254
4244
|
}) => {
|
|
4255
|
-
const { tubeArgs, midpoint } =
|
|
4245
|
+
const { tubeArgs, midpoint } = React10.useMemo(() => {
|
|
4256
4246
|
const curve = arcCurve3D(from, to, 2);
|
|
4257
4247
|
const mid = curve.getPoint(0.5);
|
|
4258
4248
|
return {
|
|
@@ -4291,9 +4281,9 @@ var Avl3DApplicationScene = ({
|
|
|
4291
4281
|
data,
|
|
4292
4282
|
onOrbitalClick
|
|
4293
4283
|
}) => {
|
|
4294
|
-
const groupRef =
|
|
4295
|
-
const [, setHoverTrigger] =
|
|
4296
|
-
const orbitalPositions =
|
|
4284
|
+
const groupRef = React10.useRef(null);
|
|
4285
|
+
const [, setHoverTrigger] = React10.useState(0);
|
|
4286
|
+
const orbitalPositions = React10.useMemo(() => {
|
|
4297
4287
|
const baseRadius = Math.max(4, data.orbitals.length * 1.5);
|
|
4298
4288
|
if (data.crossLinks.length === 0) {
|
|
4299
4289
|
return goldenSpiralPositions(data.orbitals.length, baseRadius);
|
|
@@ -4306,7 +4296,7 @@ var Avl3DApplicationScene = ({
|
|
|
4306
4296
|
})).filter((e) => e.from >= 0 && e.to >= 0);
|
|
4307
4297
|
return forceDirectedPositions(data.orbitals.length, edges, baseRadius);
|
|
4308
4298
|
}, [data.orbitals, data.crossLinks]);
|
|
4309
|
-
const positionByName =
|
|
4299
|
+
const positionByName = React10.useMemo(() => {
|
|
4310
4300
|
const map = /* @__PURE__ */ new Map();
|
|
4311
4301
|
data.orbitals.forEach((orb, i) => {
|
|
4312
4302
|
const pos = orbitalPositions[i];
|
|
@@ -4389,7 +4379,7 @@ var Avl3DEntityCore = ({
|
|
|
4389
4379
|
position,
|
|
4390
4380
|
fields
|
|
4391
4381
|
}) => {
|
|
4392
|
-
const coreRef =
|
|
4382
|
+
const coreRef = React10.useRef(null);
|
|
4393
4383
|
fiber.useFrame((_, delta) => {
|
|
4394
4384
|
if (!coreRef.current) return;
|
|
4395
4385
|
coreRef.current.rotation.y += delta * 0.3;
|
|
@@ -4542,8 +4532,8 @@ function TraitOrbit({
|
|
|
4542
4532
|
onClick,
|
|
4543
4533
|
onHover
|
|
4544
4534
|
}) {
|
|
4545
|
-
const groupRef =
|
|
4546
|
-
const angleRef =
|
|
4535
|
+
const groupRef = React10.useRef(null);
|
|
4536
|
+
const angleRef = React10.useRef(Math.random() * Math.PI * 2);
|
|
4547
4537
|
fiber.useFrame((_, delta) => {
|
|
4548
4538
|
angleRef.current += delta * speed;
|
|
4549
4539
|
if (!groupRef.current) return;
|
|
@@ -4674,9 +4664,9 @@ var Avl3DOrbitalScene = ({
|
|
|
4674
4664
|
highlightedTrait,
|
|
4675
4665
|
onTraitHighlight
|
|
4676
4666
|
}) => {
|
|
4677
|
-
const [localHighlight, setLocalHighlight] =
|
|
4667
|
+
const [localHighlight, setLocalHighlight] = React10.useState(null);
|
|
4678
4668
|
const activeHighlight = highlightedTrait ?? localHighlight;
|
|
4679
|
-
const traitOrbits =
|
|
4669
|
+
const traitOrbits = React10.useMemo(() => {
|
|
4680
4670
|
return data.traits.map((trait, i) => ({
|
|
4681
4671
|
name: trait.name,
|
|
4682
4672
|
radius: 3 + i * 1.2,
|
|
@@ -4687,7 +4677,7 @@ var Avl3DOrbitalScene = ({
|
|
|
4687
4677
|
transitionCount: trait.transitionCount
|
|
4688
4678
|
}));
|
|
4689
4679
|
}, [data.traits]);
|
|
4690
|
-
const pagePositions =
|
|
4680
|
+
const pagePositions = React10.useMemo(() => {
|
|
4691
4681
|
const outerRadius = 3 + data.traits.length * 1.2 + 1.5;
|
|
4692
4682
|
return data.pages.map((_, i) => {
|
|
4693
4683
|
const angle = 2 * Math.PI * i / data.pages.length - Math.PI / 2;
|
|
@@ -4751,12 +4741,12 @@ var Avl3DStateNode = ({
|
|
|
4751
4741
|
outgoingCount = 0,
|
|
4752
4742
|
onClick
|
|
4753
4743
|
}) => {
|
|
4754
|
-
const [hovered, setHovered] =
|
|
4744
|
+
const [hovered, setHovered] = React10.useState(false);
|
|
4755
4745
|
const baseColor = active ? AVL_3D_COLORS.stateActive : AVL_3D_COLORS.stateIdle;
|
|
4756
4746
|
const emissiveColor = active ? AVL_3D_COLORS.stateActive : AVL_3D_COLORS.stateEdge;
|
|
4757
4747
|
const emissiveIntensity = active ? 2 : hovered ? 0.8 : 0.3;
|
|
4758
4748
|
const targetScale = hovered ? 1.08 : 1;
|
|
4759
|
-
const currentScale =
|
|
4749
|
+
const currentScale = React10.useRef(1);
|
|
4760
4750
|
fiber.useFrame((_, delta) => {
|
|
4761
4751
|
currentScale.current = THREE6.MathUtils.damp(currentScale.current, targetScale, 6, delta);
|
|
4762
4752
|
});
|
|
@@ -4930,8 +4920,8 @@ var Avl3DTransitionArc = ({
|
|
|
4930
4920
|
onClick,
|
|
4931
4921
|
color = AVL_3D_COLORS.transitionArc
|
|
4932
4922
|
}) => {
|
|
4933
|
-
const [hovered, setHovered] =
|
|
4934
|
-
const { tubeArgs, labelPos, guardPos, arrowPos, arrowQuat, effectPositions } =
|
|
4923
|
+
const [hovered, setHovered] = React10.useState(false);
|
|
4924
|
+
const { tubeArgs, labelPos, guardPos, arrowPos, arrowQuat, effectPositions } = React10.useMemo(() => {
|
|
4935
4925
|
const offset = 1.5 + index * 0.8;
|
|
4936
4926
|
const curve = isSelf ? selfLoopCurve3D(from, 1.2) : arcCurve3D(from, to, offset);
|
|
4937
4927
|
const mid = curve.getPoint(0.5);
|
|
@@ -5064,7 +5054,7 @@ var Avl3DTraitScene = ({
|
|
|
5064
5054
|
data,
|
|
5065
5055
|
onTransitionClick
|
|
5066
5056
|
}) => {
|
|
5067
|
-
const statePositions =
|
|
5057
|
+
const statePositions = React10.useMemo(() => {
|
|
5068
5058
|
const radius = Math.max(3, data.states.length * 0.8);
|
|
5069
5059
|
const positions = fibonacciSpherePositions(data.states.length, radius);
|
|
5070
5060
|
const posMap = /* @__PURE__ */ new Map();
|
|
@@ -5074,7 +5064,7 @@ var Avl3DTraitScene = ({
|
|
|
5074
5064
|
});
|
|
5075
5065
|
return posMap;
|
|
5076
5066
|
}, [data.states]);
|
|
5077
|
-
const transitionIndices =
|
|
5067
|
+
const transitionIndices = React10.useMemo(() => {
|
|
5078
5068
|
const pairCount = /* @__PURE__ */ new Map();
|
|
5079
5069
|
return data.transitions.map((t) => {
|
|
5080
5070
|
const key = `${t.from}->${t.to}`;
|
|
@@ -5083,7 +5073,7 @@ var Avl3DTraitScene = ({
|
|
|
5083
5073
|
return idx;
|
|
5084
5074
|
});
|
|
5085
5075
|
}, [data.transitions]);
|
|
5086
|
-
const transitionCounts =
|
|
5076
|
+
const transitionCounts = React10.useMemo(() => {
|
|
5087
5077
|
const incoming = /* @__PURE__ */ new Map();
|
|
5088
5078
|
const outgoing = /* @__PURE__ */ new Map();
|
|
5089
5079
|
for (const t of data.transitions) {
|
|
@@ -5193,11 +5183,11 @@ var Avl3DExprTree = ({
|
|
|
5193
5183
|
expression,
|
|
5194
5184
|
position
|
|
5195
5185
|
}) => {
|
|
5196
|
-
const layoutResults =
|
|
5186
|
+
const layoutResults = React10.useMemo(() => {
|
|
5197
5187
|
const origin = { x: position[0], y: position[1], z: position[2] };
|
|
5198
5188
|
return treeLayout3D(expression, origin, 2.5, 1.5);
|
|
5199
5189
|
}, [expression, position]);
|
|
5200
|
-
const edges =
|
|
5190
|
+
const edges = React10.useMemo(() => {
|
|
5201
5191
|
const result = [];
|
|
5202
5192
|
function collectEdges(node, parentPos) {
|
|
5203
5193
|
const entry = layoutResults.find((r) => r.node === node);
|
|
@@ -5477,7 +5467,7 @@ var Avl3DEffects = ({
|
|
|
5477
5467
|
const dof = DOF_CONFIG[level];
|
|
5478
5468
|
const sparkles = SPARKLE_CONFIGS[level];
|
|
5479
5469
|
const stars = STARS_CONFIG[level];
|
|
5480
|
-
const starsKey =
|
|
5470
|
+
const starsKey = React10.useMemo(() => `stars-${level}`, [level]);
|
|
5481
5471
|
return /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
|
|
5482
5472
|
/* @__PURE__ */ jsxRuntime.jsx(
|
|
5483
5473
|
drei.Stars,
|
|
@@ -5541,16 +5531,16 @@ var DEFAULT_CONFIG2 = {
|
|
|
5541
5531
|
modelOverrides: {},
|
|
5542
5532
|
effectsEnabled: true
|
|
5543
5533
|
};
|
|
5544
|
-
var Avl3DContext =
|
|
5534
|
+
var Avl3DContext = React10.createContext(DEFAULT_CONFIG2);
|
|
5545
5535
|
function useAvl3DConfig() {
|
|
5546
|
-
return
|
|
5536
|
+
return React10.useContext(Avl3DContext);
|
|
5547
5537
|
}
|
|
5548
5538
|
function CameraController2({ targetPosition, targetLookAt, animated }) {
|
|
5549
5539
|
const { camera } = fiber.useThree();
|
|
5550
|
-
const targetPosVec =
|
|
5551
|
-
const targetLookVec =
|
|
5552
|
-
const isAnimating =
|
|
5553
|
-
|
|
5540
|
+
const targetPosVec = React10.useRef(new THREE6__namespace.Vector3(...targetPosition));
|
|
5541
|
+
const targetLookVec = React10.useRef(new THREE6__namespace.Vector3(...targetLookAt));
|
|
5542
|
+
const isAnimating = React10.useRef(false);
|
|
5543
|
+
React10.useEffect(() => {
|
|
5554
5544
|
const newTarget = new THREE6__namespace.Vector3(...targetPosition);
|
|
5555
5545
|
const newLookAt = new THREE6__namespace.Vector3(...targetLookAt);
|
|
5556
5546
|
if (!newTarget.equals(targetPosVec.current) || !newLookAt.equals(targetLookVec.current)) {
|
|
@@ -5579,8 +5569,8 @@ function CameraController2({ targetPosition, targetLookAt, animated }) {
|
|
|
5579
5569
|
return null;
|
|
5580
5570
|
}
|
|
5581
5571
|
function SceneFade({ animating, children }) {
|
|
5582
|
-
const groupRef =
|
|
5583
|
-
const opacityRef =
|
|
5572
|
+
const groupRef = React10.useRef(null);
|
|
5573
|
+
const opacityRef = React10.useRef(1);
|
|
5584
5574
|
fiber.useFrame((_, delta) => {
|
|
5585
5575
|
if (!groupRef.current) return;
|
|
5586
5576
|
const target = animating ? 0 : 1;
|
|
@@ -5603,7 +5593,7 @@ var Avl3DViewer = ({
|
|
|
5603
5593
|
effects = true,
|
|
5604
5594
|
modelOverrides = {}
|
|
5605
5595
|
}) => {
|
|
5606
|
-
const schema =
|
|
5596
|
+
const schema = React10.useMemo(() => {
|
|
5607
5597
|
if (typeof schemaProp === "string") {
|
|
5608
5598
|
try {
|
|
5609
5599
|
return JSON.parse(schemaProp);
|
|
@@ -5613,12 +5603,12 @@ var Avl3DViewer = ({
|
|
|
5613
5603
|
}
|
|
5614
5604
|
return schemaProp;
|
|
5615
5605
|
}, [schemaProp]);
|
|
5616
|
-
const configValue =
|
|
5606
|
+
const configValue = React10.useMemo(() => ({
|
|
5617
5607
|
modelOverrides,
|
|
5618
5608
|
effectsEnabled: effects
|
|
5619
5609
|
}), [modelOverrides, effects]);
|
|
5620
|
-
const [state, dispatch] =
|
|
5621
|
-
|
|
5610
|
+
const [state, dispatch] = React10.useReducer(zoomReducer, initialZoomState);
|
|
5611
|
+
React10.useEffect(() => {
|
|
5622
5612
|
if (initialOrbital) {
|
|
5623
5613
|
dispatch({ type: "ZOOM_INTO_ORBITAL", orbital: initialOrbital, targetPosition: { x: 0, y: 0 } });
|
|
5624
5614
|
setTimeout(() => dispatch({ type: "ANIMATION_COMPLETE" }), 0);
|
|
@@ -5630,35 +5620,35 @@ var Avl3DViewer = ({
|
|
|
5630
5620
|
}
|
|
5631
5621
|
}
|
|
5632
5622
|
}, [initialOrbital, initialTrait]);
|
|
5633
|
-
|
|
5623
|
+
React10.useEffect(() => {
|
|
5634
5624
|
onZoomChange?.(state.level, {
|
|
5635
5625
|
orbital: state.selectedOrbital ?? void 0,
|
|
5636
5626
|
trait: state.selectedTrait ?? void 0
|
|
5637
5627
|
});
|
|
5638
5628
|
}, [state.level, state.selectedOrbital, state.selectedTrait, onZoomChange]);
|
|
5639
|
-
|
|
5629
|
+
React10.useEffect(() => {
|
|
5640
5630
|
if (!state.animating) return;
|
|
5641
5631
|
const timer = setTimeout(() => {
|
|
5642
5632
|
dispatch({ type: "ANIMATION_COMPLETE" });
|
|
5643
5633
|
}, 800);
|
|
5644
5634
|
return () => clearTimeout(timer);
|
|
5645
5635
|
}, [state.animating]);
|
|
5646
|
-
const handleKeyDown =
|
|
5636
|
+
const handleKeyDown = React10.useCallback((e) => {
|
|
5647
5637
|
if (e.key === "Escape") {
|
|
5648
5638
|
dispatch({ type: "ZOOM_OUT" });
|
|
5649
5639
|
}
|
|
5650
5640
|
}, []);
|
|
5651
|
-
const handleOrbitalClick =
|
|
5641
|
+
const handleOrbitalClick = React10.useCallback((name) => {
|
|
5652
5642
|
dispatch({ type: "ZOOM_INTO_ORBITAL", orbital: name, targetPosition: { x: 0, y: 0 } });
|
|
5653
5643
|
}, []);
|
|
5654
|
-
const handleTraitClick =
|
|
5644
|
+
const handleTraitClick = React10.useCallback((name) => {
|
|
5655
5645
|
dispatch({ type: "ZOOM_INTO_TRAIT", trait: name, targetPosition: { x: 0, y: 0 } });
|
|
5656
5646
|
}, []);
|
|
5657
|
-
const [highlightedTrait, setHighlightedTrait] =
|
|
5658
|
-
const handleTransitionClick =
|
|
5647
|
+
const [highlightedTrait, setHighlightedTrait] = React10__default.default.useState(null);
|
|
5648
|
+
const handleTransitionClick = React10.useCallback((index) => {
|
|
5659
5649
|
dispatch({ type: "ZOOM_INTO_TRANSITION", transitionIndex: index, targetPosition: { x: 0, y: 0 } });
|
|
5660
5650
|
}, []);
|
|
5661
|
-
const handleBreadcrumbClick =
|
|
5651
|
+
const handleBreadcrumbClick = React10.useCallback((targetLevel) => {
|
|
5662
5652
|
const levelOrder = ["application", "orbital", "trait", "transition"];
|
|
5663
5653
|
const currentIdx = levelOrder.indexOf(state.level);
|
|
5664
5654
|
const targetIdx = levelOrder.indexOf(targetLevel);
|
|
@@ -5667,7 +5657,7 @@ var Avl3DViewer = ({
|
|
|
5667
5657
|
}
|
|
5668
5658
|
}, [state.level]);
|
|
5669
5659
|
const cameraConfig = CAMERA_POSITIONS[state.level];
|
|
5670
|
-
const sceneContent =
|
|
5660
|
+
const sceneContent = React10.useMemo(() => {
|
|
5671
5661
|
switch (state.level) {
|
|
5672
5662
|
case "application": {
|
|
5673
5663
|
const data = parseApplicationLevel(schema);
|
|
@@ -5741,7 +5731,7 @@ var Avl3DViewer = ({
|
|
|
5741
5731
|
gap: "xs",
|
|
5742
5732
|
align: "center",
|
|
5743
5733
|
className: "absolute top-2 left-2 z-10 bg-surface/80 backdrop-blur rounded-md px-3 py-1.5",
|
|
5744
|
-
children: breadcrumbs.map((crumb, i) => /* @__PURE__ */ jsxRuntime.jsxs(
|
|
5734
|
+
children: breadcrumbs.map((crumb, i) => /* @__PURE__ */ jsxRuntime.jsxs(React10__default.default.Fragment, { children: [
|
|
5745
5735
|
i > 0 && /* @__PURE__ */ jsxRuntime.jsx(Typography, { variant: "small", color: "muted", className: "mx-1", children: "/" }),
|
|
5746
5736
|
i < breadcrumbs.length - 1 ? /* @__PURE__ */ jsxRuntime.jsx(
|
|
5747
5737
|
Box,
|