@almadar/ui 5.18.0 → 5.19.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 +7432 -7675
- package/dist/avl/index.d.cts +8 -0
- package/dist/avl/index.js +6297 -6540
- package/dist/components/atoms/DayCell.d.ts +3 -2
- package/dist/components/index.cjs +7640 -7877
- package/dist/components/index.js +6691 -6925
- package/dist/components/{organisms → molecules}/ContentRenderer.d.ts +1 -1
- package/dist/components/{organisms → molecules}/FormSection.d.ts +1 -1
- package/dist/components/molecules/avl/ModuleCard.d.ts +8 -0
- package/dist/components/molecules/index.d.ts +17 -1
- package/dist/components/organisms/game/GameAudioProvider.d.ts +6 -0
- package/dist/components/organisms/game/GameAudioToggle.d.ts +4 -2
- package/dist/components/organisms/game/three/index.cjs +180 -172
- package/dist/components/organisms/game/three/index.js +18 -10
- package/dist/components/organisms/game/three/renderers/FeatureRenderer.d.ts +7 -13
- package/dist/components/organisms/index.d.ts +0 -18
- package/dist/providers/index.cjs +7024 -7275
- package/dist/providers/index.js +6259 -6510
- package/dist/runtime/index.cjs +7063 -7314
- package/dist/runtime/index.js +6262 -6513
- package/package.json +3 -3
- package/dist/components/molecules/CodeExample.d.ts +0 -23
- package/dist/components/organisms/Meter.d.ts +0 -59
- package/dist/components/organisms/Table.d.ts +0 -100
- /package/dist/components/{organisms → molecules}/Chart.d.ts +0 -0
- /package/dist/components/{organisms → molecules}/CodeViewer.d.ts +0 -0
- /package/dist/components/{organisms → molecules}/ConfirmDialog.d.ts +0 -0
- /package/dist/components/{organisms → molecules}/DocumentViewer.d.ts +0 -0
- /package/dist/components/{organisms → molecules}/GraphCanvas.d.ts +0 -0
- /package/dist/components/{organisms → molecules}/Header.d.ts +0 -0
- /package/dist/components/{organisms → molecules}/JazariStateMachine.d.ts +0 -0
- /package/dist/components/{organisms → molecules}/Navigation.d.ts +0 -0
- /package/dist/components/{organisms → molecules}/OrbitalVisualization.d.ts +0 -0
- /package/dist/components/{organisms → molecules}/PageHeader.d.ts +0 -0
- /package/dist/components/{organisms → molecules}/Section.d.ts +0 -0
- /package/dist/components/{organisms → molecules}/Sidebar.d.ts +0 -0
- /package/dist/components/{organisms → molecules}/SignaturePad.d.ts +0 -0
- /package/dist/components/{organisms → molecules}/Split.d.ts +0 -0
- /package/dist/components/{organisms → molecules}/WizardContainer.d.ts +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
var
|
|
3
|
+
var React11 = 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 React11__default = /*#__PURE__*/_interopDefault(React11);
|
|
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 = React11.useRef(false);
|
|
47
|
+
React11.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 = React11.forwardRef(
|
|
69
69
|
({
|
|
70
70
|
mode = "isometric",
|
|
71
71
|
position = [10, 10, 10],
|
|
@@ -78,10 +78,10 @@ var Camera3D = React10.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 = React11.useRef(null);
|
|
82
|
+
const initialPosition = React11.useRef(new THREE6__namespace.Vector3(...position));
|
|
83
|
+
const initialTarget = React11.useRef(new THREE6__namespace.Vector3(...target));
|
|
84
|
+
React11.useEffect(() => {
|
|
85
85
|
let newCamera;
|
|
86
86
|
if (mode === "isometric") {
|
|
87
87
|
const aspect = viewport.aspect;
|
|
@@ -112,7 +112,7 @@ var Camera3D = React10.forwardRef(
|
|
|
112
112
|
onChange(camera);
|
|
113
113
|
}
|
|
114
114
|
});
|
|
115
|
-
|
|
115
|
+
React11.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 React11.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] = React11.useState({
|
|
338
338
|
model: null,
|
|
339
339
|
isLoading: false,
|
|
340
340
|
error: null
|
|
341
341
|
});
|
|
342
|
-
|
|
342
|
+
React11.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 = React11.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 = React11.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 = React11.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 = React11.useRef(null);
|
|
495
|
+
const physicsStateRef = React11.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 = React11.useRef(false);
|
|
513
|
+
React11.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 = React11.useRef(null);
|
|
795
|
+
const canvasRef = React11.useRef(null);
|
|
796
|
+
const rendererRef = React11.useRef(null);
|
|
797
|
+
const sceneRef = React11.useRef(null);
|
|
798
|
+
const cameraRef = React11.useRef(null);
|
|
799
|
+
const controlsRef = React11.useRef(null);
|
|
800
|
+
const gridHelperRef = React11.useRef(null);
|
|
801
|
+
const rafRef = React11.useRef(0);
|
|
802
|
+
const [isReady, setIsReady] = React11.useState(false);
|
|
803
|
+
const [dimensions, setDimensions] = React11.useState({ width: 0, height: 0 });
|
|
804
|
+
const initialCameraPosition = React11.useMemo(
|
|
805
805
|
() => new THREE6__namespace.Vector3(...opts.cameraPosition),
|
|
806
806
|
[]
|
|
807
807
|
);
|
|
808
|
-
|
|
808
|
+
React11.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
|
+
React11.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 = React11.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 = React11.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 = React11.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 = React11.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 = React11.useRef(customLoader || new AssetLoader());
|
|
991
|
+
const [state, setState] = React11.useState({
|
|
992
992
|
isLoading: false,
|
|
993
993
|
progress: 0,
|
|
994
994
|
loaded: 0,
|
|
995
995
|
total: 0,
|
|
996
996
|
errors: []
|
|
997
997
|
});
|
|
998
|
-
|
|
998
|
+
React11.useEffect(() => {
|
|
999
999
|
if (preloadUrls.length > 0) {
|
|
1000
1000
|
preload(preloadUrls);
|
|
1001
1001
|
}
|
|
1002
1002
|
}, []);
|
|
1003
|
-
const updateProgress =
|
|
1003
|
+
const updateProgress = React11.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 = React11.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 = React11.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 = React11.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 = React11.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 = React11.useCallback((url) => {
|
|
1120
1120
|
return loaderRef.current.hasModel(url);
|
|
1121
1121
|
}, []);
|
|
1122
|
-
const hasTexture =
|
|
1122
|
+
const hasTexture = React11.useCallback((url) => {
|
|
1123
1123
|
return loaderRef.current.hasTexture(url);
|
|
1124
1124
|
}, []);
|
|
1125
|
-
const getModel =
|
|
1125
|
+
const getModel = React11.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 = React11.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 = React11.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 = React11.useRef(/* @__PURE__ */ new Map());
|
|
1164
|
+
const addNode = React11.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 = React11.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 = React11.useCallback((id) => {
|
|
1179
1179
|
return nodesRef.current.get(id);
|
|
1180
1180
|
}, []);
|
|
1181
|
-
const updateNodePosition =
|
|
1181
|
+
const updateNodePosition = React11.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 = React11.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 = React11.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 = React11.useCallback((type) => {
|
|
1210
1210
|
return Array.from(nodesRef.current.values()).filter((node) => node.type === type);
|
|
1211
1211
|
}, []);
|
|
1212
|
-
const getNodesInBounds =
|
|
1212
|
+
const getNodesInBounds = React11.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 = React11.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 = React11.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 = React11.useRef(new THREE6__namespace.Raycaster());
|
|
1250
|
+
const mouse = React11.useRef(new THREE6__namespace.Vector2());
|
|
1251
|
+
const clientToNDC = React11.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 = React11.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 = React11.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 = React11.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 = React11.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 = React11.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 = React11.useContext(providers.EventBusContext);
|
|
1456
1456
|
const baseBus = context ?? getGlobalEventBus() ?? fallbackEventBus;
|
|
1457
1457
|
const scope = providers.useTraitScope();
|
|
1458
|
-
return
|
|
1458
|
+
return React11.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 React11.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 = React11.useRef(options);
|
|
1522
1522
|
optionsRef.current = options;
|
|
1523
|
-
const handleTileClick =
|
|
1523
|
+
const handleTileClick = React11.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 = React11.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 = React11.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 = React11.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 = React11.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 = React11.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 = React11.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 = React11.useRef(null);
|
|
1666
|
+
const geometry = React11.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 = React11.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 } = React11.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
|
+
React11.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 = React11.useRef(null);
|
|
1810
|
+
const [animationState, setAnimationState] = React11.useState("idle");
|
|
1811
|
+
const [isHovered, setIsHovered] = React11.useState(false);
|
|
1812
|
+
const teamColor = React11.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 = React11.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 = React11.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 = React11__default.default.useCallback(
|
|
1890
1890
|
(unit) => {
|
|
1891
1891
|
onUnitClick?.(unit);
|
|
1892
1892
|
},
|
|
@@ -2063,15 +2063,14 @@ function FeatureVisual({
|
|
|
2063
2063
|
}
|
|
2064
2064
|
);
|
|
2065
2065
|
}
|
|
2066
|
-
function
|
|
2066
|
+
function FeatureGroup({
|
|
2067
2067
|
features,
|
|
2068
2068
|
cellSize = 1,
|
|
2069
2069
|
offsetX = 0,
|
|
2070
2070
|
offsetZ = 0,
|
|
2071
2071
|
onFeatureClick,
|
|
2072
2072
|
onFeatureHover,
|
|
2073
|
-
selectedFeatureIds = []
|
|
2074
|
-
featureColors
|
|
2073
|
+
selectedFeatureIds = []
|
|
2075
2074
|
}) {
|
|
2076
2075
|
return /* @__PURE__ */ jsxRuntime.jsx("group", { children: features.map((feature) => {
|
|
2077
2076
|
const x = (feature.x - offsetX) * cellSize;
|
|
@@ -2091,6 +2090,15 @@ function FeatureRenderer({
|
|
|
2091
2090
|
);
|
|
2092
2091
|
}) });
|
|
2093
2092
|
}
|
|
2093
|
+
function FeatureRenderer(props) {
|
|
2094
|
+
const insideCanvas = React11.useContext(fiber.context) != null;
|
|
2095
|
+
if (insideCanvas) return /* @__PURE__ */ jsxRuntime.jsx(FeatureGroup, { ...props });
|
|
2096
|
+
return /* @__PURE__ */ jsxRuntime.jsxs(fiber.Canvas, { camera: { position: [4, 4, 6], fov: 50 }, style: { width: "100%", height: 360 }, children: [
|
|
2097
|
+
/* @__PURE__ */ jsxRuntime.jsx("ambientLight", { intensity: 0.6 }),
|
|
2098
|
+
/* @__PURE__ */ jsxRuntime.jsx("directionalLight", { position: [5, 8, 5], intensity: 0.8 }),
|
|
2099
|
+
/* @__PURE__ */ jsxRuntime.jsx(FeatureGroup, { ...props })
|
|
2100
|
+
] });
|
|
2101
|
+
}
|
|
2094
2102
|
var log5 = logger.createLogger("almadar:ui:game:feature-renderer");
|
|
2095
2103
|
function detectAssetRoot3(modelUrl) {
|
|
2096
2104
|
const idx = modelUrl.indexOf("/3d/");
|
|
@@ -2100,10 +2108,10 @@ function detectAssetRoot3(modelUrl) {
|
|
|
2100
2108
|
return modelUrl.substring(0, modelUrl.lastIndexOf("/") + 1);
|
|
2101
2109
|
}
|
|
2102
2110
|
function useGLTFModel2(url) {
|
|
2103
|
-
const [model, setModel] =
|
|
2104
|
-
const [isLoading, setIsLoading] =
|
|
2105
|
-
const [error, setError] =
|
|
2106
|
-
|
|
2111
|
+
const [model, setModel] = React11.useState(null);
|
|
2112
|
+
const [isLoading, setIsLoading] = React11.useState(false);
|
|
2113
|
+
const [error, setError] = React11.useState(null);
|
|
2114
|
+
React11.useEffect(() => {
|
|
2107
2115
|
if (!url) {
|
|
2108
2116
|
setModel(null);
|
|
2109
2117
|
return;
|
|
@@ -2135,9 +2143,9 @@ function FeatureModel({
|
|
|
2135
2143
|
onClick,
|
|
2136
2144
|
onHover
|
|
2137
2145
|
}) {
|
|
2138
|
-
const groupRef =
|
|
2146
|
+
const groupRef = React11.useRef(null);
|
|
2139
2147
|
const { model: loadedModel, isLoading } = useGLTFModel2(feature.assetUrl);
|
|
2140
|
-
const model =
|
|
2148
|
+
const model = React11.useMemo(() => {
|
|
2141
2149
|
if (!loadedModel) return null;
|
|
2142
2150
|
const cloned = loadedModel.clone();
|
|
2143
2151
|
cloned.scale.setScalar(0.3);
|
|
@@ -2255,7 +2263,7 @@ function CameraController({
|
|
|
2255
2263
|
onCameraChange
|
|
2256
2264
|
}) {
|
|
2257
2265
|
const { camera } = fiber.useThree();
|
|
2258
|
-
|
|
2266
|
+
React11.useEffect(() => {
|
|
2259
2267
|
if (onCameraChange) {
|
|
2260
2268
|
onCameraChange({
|
|
2261
2269
|
x: camera.position.x,
|
|
@@ -2266,7 +2274,7 @@ function CameraController({
|
|
|
2266
2274
|
}, [camera.position, onCameraChange]);
|
|
2267
2275
|
return null;
|
|
2268
2276
|
}
|
|
2269
|
-
var GameCanvas3D =
|
|
2277
|
+
var GameCanvas3D = React11.forwardRef(
|
|
2270
2278
|
({
|
|
2271
2279
|
tiles = [],
|
|
2272
2280
|
units = [],
|
|
@@ -2311,10 +2319,10 @@ var GameCanvas3D = React10.forwardRef(
|
|
|
2311
2319
|
selectedUnitId = null,
|
|
2312
2320
|
children
|
|
2313
2321
|
}, ref) => {
|
|
2314
|
-
const containerRef =
|
|
2315
|
-
const controlsRef =
|
|
2316
|
-
const [hoveredTile, setHoveredTile] =
|
|
2317
|
-
const [internalError, setInternalError] =
|
|
2322
|
+
const containerRef = React11.useRef(null);
|
|
2323
|
+
const controlsRef = React11.useRef(null);
|
|
2324
|
+
const [hoveredTile, setHoveredTile] = React11.useState(null);
|
|
2325
|
+
const [internalError, setInternalError] = React11.useState(null);
|
|
2318
2326
|
const { isLoading: assetsLoading, progress, loaded, total } = useAssetLoader({
|
|
2319
2327
|
preloadUrls: preloadAssets,
|
|
2320
2328
|
loader: customAssetLoader
|
|
@@ -2335,7 +2343,7 @@ var GameCanvas3D = React10.forwardRef(
|
|
|
2335
2343
|
onTileHover,
|
|
2336
2344
|
onUnitAnimation
|
|
2337
2345
|
});
|
|
2338
|
-
const gridBounds =
|
|
2346
|
+
const gridBounds = React11.useMemo(() => {
|
|
2339
2347
|
if (tiles.length === 0) {
|
|
2340
2348
|
return { minX: 0, maxX: 10, minZ: 0, maxZ: 10 };
|
|
2341
2349
|
}
|
|
@@ -2348,14 +2356,14 @@ var GameCanvas3D = React10.forwardRef(
|
|
|
2348
2356
|
maxZ: Math.max(...zs)
|
|
2349
2357
|
};
|
|
2350
2358
|
}, [tiles]);
|
|
2351
|
-
const cameraTarget =
|
|
2359
|
+
const cameraTarget = React11.useMemo(() => {
|
|
2352
2360
|
return [
|
|
2353
2361
|
(gridBounds.minX + gridBounds.maxX) / 2,
|
|
2354
2362
|
0,
|
|
2355
2363
|
(gridBounds.minZ + gridBounds.maxZ) / 2
|
|
2356
2364
|
];
|
|
2357
2365
|
}, [gridBounds]);
|
|
2358
|
-
const gridConfig =
|
|
2366
|
+
const gridConfig = React11.useMemo(
|
|
2359
2367
|
() => ({
|
|
2360
2368
|
...DEFAULT_GRID_CONFIG,
|
|
2361
2369
|
offsetX: -(gridBounds.maxX - gridBounds.minX) / 2,
|
|
@@ -2363,7 +2371,7 @@ var GameCanvas3D = React10.forwardRef(
|
|
|
2363
2371
|
}),
|
|
2364
2372
|
[gridBounds]
|
|
2365
2373
|
);
|
|
2366
|
-
const gridToWorld2 =
|
|
2374
|
+
const gridToWorld2 = React11.useCallback(
|
|
2367
2375
|
(x, z, y = 0) => {
|
|
2368
2376
|
const worldX = (x - gridBounds.minX) * gridConfig.cellSize;
|
|
2369
2377
|
const worldZ = (z - gridBounds.minZ) * gridConfig.cellSize;
|
|
@@ -2371,7 +2379,7 @@ var GameCanvas3D = React10.forwardRef(
|
|
|
2371
2379
|
},
|
|
2372
2380
|
[gridBounds, gridConfig]
|
|
2373
2381
|
);
|
|
2374
|
-
|
|
2382
|
+
React11.useImperativeHandle(ref, () => ({
|
|
2375
2383
|
getCameraPosition: () => {
|
|
2376
2384
|
if (controlsRef.current) {
|
|
2377
2385
|
const pos = controlsRef.current.object.position;
|
|
@@ -2409,19 +2417,19 @@ var GameCanvas3D = React10.forwardRef(
|
|
|
2409
2417
|
features
|
|
2410
2418
|
})
|
|
2411
2419
|
}));
|
|
2412
|
-
const handleTileClick =
|
|
2420
|
+
const handleTileClick = React11.useCallback(
|
|
2413
2421
|
(tile, event) => {
|
|
2414
2422
|
eventHandlers.handleTileClick(tile, event);
|
|
2415
2423
|
},
|
|
2416
2424
|
[eventHandlers]
|
|
2417
2425
|
);
|
|
2418
|
-
const handleUnitClick =
|
|
2426
|
+
const handleUnitClick = React11.useCallback(
|
|
2419
2427
|
(unit, event) => {
|
|
2420
2428
|
eventHandlers.handleUnitClick(unit, event);
|
|
2421
2429
|
},
|
|
2422
2430
|
[eventHandlers]
|
|
2423
2431
|
);
|
|
2424
|
-
const handleFeatureClick =
|
|
2432
|
+
const handleFeatureClick = React11.useCallback(
|
|
2425
2433
|
(feature, event) => {
|
|
2426
2434
|
if (event) {
|
|
2427
2435
|
eventHandlers.handleFeatureClick(feature, event);
|
|
@@ -2429,7 +2437,7 @@ var GameCanvas3D = React10.forwardRef(
|
|
|
2429
2437
|
},
|
|
2430
2438
|
[eventHandlers]
|
|
2431
2439
|
);
|
|
2432
|
-
const handleTileHover =
|
|
2440
|
+
const handleTileHover = React11.useCallback(
|
|
2433
2441
|
(tile, event) => {
|
|
2434
2442
|
setHoveredTile(tile);
|
|
2435
2443
|
if (event) {
|
|
@@ -2438,7 +2446,7 @@ var GameCanvas3D = React10.forwardRef(
|
|
|
2438
2446
|
},
|
|
2439
2447
|
[eventHandlers]
|
|
2440
2448
|
);
|
|
2441
|
-
const cameraConfig =
|
|
2449
|
+
const cameraConfig = React11.useMemo(() => {
|
|
2442
2450
|
const size = Math.max(
|
|
2443
2451
|
gridBounds.maxX - gridBounds.minX,
|
|
2444
2452
|
gridBounds.maxZ - gridBounds.minZ
|
|
@@ -2463,7 +2471,7 @@ var GameCanvas3D = React10.forwardRef(
|
|
|
2463
2471
|
};
|
|
2464
2472
|
}
|
|
2465
2473
|
}, [cameraMode, gridBounds]);
|
|
2466
|
-
const DefaultTileRenderer =
|
|
2474
|
+
const DefaultTileRenderer = React11.useCallback(
|
|
2467
2475
|
({ tile, position }) => {
|
|
2468
2476
|
const isSelected = tile.id ? selectedTileIds.includes(tile.id) : false;
|
|
2469
2477
|
const isHovered = hoveredTile?.id === tile.id;
|
|
@@ -2501,7 +2509,7 @@ var GameCanvas3D = React10.forwardRef(
|
|
|
2501
2509
|
},
|
|
2502
2510
|
[selectedTileIds, hoveredTile, validMoves, attackTargets, handleTileClick, handleTileHover]
|
|
2503
2511
|
);
|
|
2504
|
-
const DefaultUnitRenderer =
|
|
2512
|
+
const DefaultUnitRenderer = React11.useCallback(
|
|
2505
2513
|
({ unit, position }) => {
|
|
2506
2514
|
const isSelected = selectedUnitId === unit.id;
|
|
2507
2515
|
const color = unit.faction === "player" ? 4491519 : unit.faction === "enemy" ? 16729156 : 16777028;
|
|
@@ -2559,7 +2567,7 @@ var GameCanvas3D = React10.forwardRef(
|
|
|
2559
2567
|
},
|
|
2560
2568
|
[selectedUnitId, handleUnitClick]
|
|
2561
2569
|
);
|
|
2562
|
-
const DefaultFeatureRenderer =
|
|
2570
|
+
const DefaultFeatureRenderer = React11.useCallback(
|
|
2563
2571
|
({
|
|
2564
2572
|
feature,
|
|
2565
2573
|
position
|
|
@@ -2868,7 +2876,7 @@ var positionStyles = {
|
|
|
2868
2876
|
fixed: "fixed",
|
|
2869
2877
|
sticky: "sticky"
|
|
2870
2878
|
};
|
|
2871
|
-
var Box =
|
|
2879
|
+
var Box = React11__default.default.forwardRef(
|
|
2872
2880
|
({
|
|
2873
2881
|
padding,
|
|
2874
2882
|
paddingX,
|
|
@@ -2898,27 +2906,27 @@ var Box = React10__default.default.forwardRef(
|
|
|
2898
2906
|
...rest
|
|
2899
2907
|
}, ref) => {
|
|
2900
2908
|
const eventBus = useEventBus();
|
|
2901
|
-
const handleClick =
|
|
2909
|
+
const handleClick = React11.useCallback((e) => {
|
|
2902
2910
|
if (action) {
|
|
2903
2911
|
e.stopPropagation();
|
|
2904
2912
|
eventBus.emit(`UI:${action}`, actionPayload ?? {});
|
|
2905
2913
|
}
|
|
2906
2914
|
onClick?.(e);
|
|
2907
2915
|
}, [action, actionPayload, eventBus, onClick]);
|
|
2908
|
-
const handleMouseEnter =
|
|
2916
|
+
const handleMouseEnter = React11.useCallback((e) => {
|
|
2909
2917
|
if (hoverEvent) {
|
|
2910
2918
|
eventBus.emit(`UI:${hoverEvent}`, { hovered: true });
|
|
2911
2919
|
}
|
|
2912
2920
|
onMouseEnter?.(e);
|
|
2913
2921
|
}, [hoverEvent, eventBus, onMouseEnter]);
|
|
2914
|
-
const handleMouseLeave =
|
|
2922
|
+
const handleMouseLeave = React11.useCallback((e) => {
|
|
2915
2923
|
if (hoverEvent) {
|
|
2916
2924
|
eventBus.emit(`UI:${hoverEvent}`, { hovered: false });
|
|
2917
2925
|
}
|
|
2918
2926
|
onMouseLeave?.(e);
|
|
2919
2927
|
}, [hoverEvent, eventBus, onMouseLeave]);
|
|
2920
2928
|
const isClickable = action || onClick;
|
|
2921
|
-
return
|
|
2929
|
+
return React11__default.default.createElement(
|
|
2922
2930
|
Component2,
|
|
2923
2931
|
{
|
|
2924
2932
|
ref,
|
|
@@ -4114,10 +4122,10 @@ var Avl3DOrbitalNode = ({
|
|
|
4114
4122
|
position,
|
|
4115
4123
|
onClick
|
|
4116
4124
|
}) => {
|
|
4117
|
-
const groupRef =
|
|
4118
|
-
const [hovered, setHovered] =
|
|
4119
|
-
const scale =
|
|
4120
|
-
const currentScale =
|
|
4125
|
+
const groupRef = React11.useRef(null);
|
|
4126
|
+
const [hovered, setHovered] = React11.useState(false);
|
|
4127
|
+
const scale = React11.useMemo(() => 0.6 + Math.min(traitCount, 8) * 0.3, [traitCount]);
|
|
4128
|
+
const currentScale = React11.useRef(scale);
|
|
4121
4129
|
const targetScale = hovered ? scale * 1.06 : scale;
|
|
4122
4130
|
fiber.useFrame((_, delta) => {
|
|
4123
4131
|
if (!groupRef.current) return;
|
|
@@ -4259,7 +4267,7 @@ var Avl3DCrossWire = ({
|
|
|
4259
4267
|
eventName,
|
|
4260
4268
|
color = AVL_3D_COLORS.crossWire
|
|
4261
4269
|
}) => {
|
|
4262
|
-
const { tubeArgs, midpoint } =
|
|
4270
|
+
const { tubeArgs, midpoint } = React11.useMemo(() => {
|
|
4263
4271
|
const curve = arcCurve3D(from, to, 2);
|
|
4264
4272
|
const mid = curve.getPoint(0.5);
|
|
4265
4273
|
return {
|
|
@@ -4298,9 +4306,9 @@ var Avl3DApplicationScene = ({
|
|
|
4298
4306
|
data,
|
|
4299
4307
|
onOrbitalClick
|
|
4300
4308
|
}) => {
|
|
4301
|
-
const groupRef =
|
|
4302
|
-
const [, setHoverTrigger] =
|
|
4303
|
-
const orbitalPositions =
|
|
4309
|
+
const groupRef = React11.useRef(null);
|
|
4310
|
+
const [, setHoverTrigger] = React11.useState(0);
|
|
4311
|
+
const orbitalPositions = React11.useMemo(() => {
|
|
4304
4312
|
const baseRadius = Math.max(4, data.orbitals.length * 1.5);
|
|
4305
4313
|
if (data.crossLinks.length === 0) {
|
|
4306
4314
|
return goldenSpiralPositions(data.orbitals.length, baseRadius);
|
|
@@ -4313,7 +4321,7 @@ var Avl3DApplicationScene = ({
|
|
|
4313
4321
|
})).filter((e) => e.from >= 0 && e.to >= 0);
|
|
4314
4322
|
return forceDirectedPositions(data.orbitals.length, edges, baseRadius);
|
|
4315
4323
|
}, [data.orbitals, data.crossLinks]);
|
|
4316
|
-
const positionByName =
|
|
4324
|
+
const positionByName = React11.useMemo(() => {
|
|
4317
4325
|
const map = /* @__PURE__ */ new Map();
|
|
4318
4326
|
data.orbitals.forEach((orb, i) => {
|
|
4319
4327
|
const pos = orbitalPositions[i];
|
|
@@ -4396,7 +4404,7 @@ var Avl3DEntityCore = ({
|
|
|
4396
4404
|
position,
|
|
4397
4405
|
fields
|
|
4398
4406
|
}) => {
|
|
4399
|
-
const coreRef =
|
|
4407
|
+
const coreRef = React11.useRef(null);
|
|
4400
4408
|
fiber.useFrame((_, delta) => {
|
|
4401
4409
|
if (!coreRef.current) return;
|
|
4402
4410
|
coreRef.current.rotation.y += delta * 0.3;
|
|
@@ -4549,8 +4557,8 @@ function TraitOrbit({
|
|
|
4549
4557
|
onClick,
|
|
4550
4558
|
onHover
|
|
4551
4559
|
}) {
|
|
4552
|
-
const groupRef =
|
|
4553
|
-
const angleRef =
|
|
4560
|
+
const groupRef = React11.useRef(null);
|
|
4561
|
+
const angleRef = React11.useRef(Math.random() * Math.PI * 2);
|
|
4554
4562
|
fiber.useFrame((_, delta) => {
|
|
4555
4563
|
angleRef.current += delta * speed;
|
|
4556
4564
|
if (!groupRef.current) return;
|
|
@@ -4681,9 +4689,9 @@ var Avl3DOrbitalScene = ({
|
|
|
4681
4689
|
highlightedTrait,
|
|
4682
4690
|
onTraitHighlight
|
|
4683
4691
|
}) => {
|
|
4684
|
-
const [localHighlight, setLocalHighlight] =
|
|
4692
|
+
const [localHighlight, setLocalHighlight] = React11.useState(null);
|
|
4685
4693
|
const activeHighlight = highlightedTrait ?? localHighlight;
|
|
4686
|
-
const traitOrbits =
|
|
4694
|
+
const traitOrbits = React11.useMemo(() => {
|
|
4687
4695
|
return data.traits.map((trait, i) => ({
|
|
4688
4696
|
name: trait.name,
|
|
4689
4697
|
radius: 3 + i * 1.2,
|
|
@@ -4694,7 +4702,7 @@ var Avl3DOrbitalScene = ({
|
|
|
4694
4702
|
transitionCount: trait.transitionCount
|
|
4695
4703
|
}));
|
|
4696
4704
|
}, [data.traits]);
|
|
4697
|
-
const pagePositions =
|
|
4705
|
+
const pagePositions = React11.useMemo(() => {
|
|
4698
4706
|
const outerRadius = 3 + data.traits.length * 1.2 + 1.5;
|
|
4699
4707
|
return data.pages.map((_, i) => {
|
|
4700
4708
|
const angle = 2 * Math.PI * i / data.pages.length - Math.PI / 2;
|
|
@@ -4758,12 +4766,12 @@ var Avl3DStateNode = ({
|
|
|
4758
4766
|
outgoingCount = 0,
|
|
4759
4767
|
onClick
|
|
4760
4768
|
}) => {
|
|
4761
|
-
const [hovered, setHovered] =
|
|
4769
|
+
const [hovered, setHovered] = React11.useState(false);
|
|
4762
4770
|
const baseColor = active ? AVL_3D_COLORS.stateActive : AVL_3D_COLORS.stateIdle;
|
|
4763
4771
|
const emissiveColor = active ? AVL_3D_COLORS.stateActive : AVL_3D_COLORS.stateEdge;
|
|
4764
4772
|
const emissiveIntensity = active ? 2 : hovered ? 0.8 : 0.3;
|
|
4765
4773
|
const targetScale = hovered ? 1.08 : 1;
|
|
4766
|
-
const currentScale =
|
|
4774
|
+
const currentScale = React11.useRef(1);
|
|
4767
4775
|
fiber.useFrame((_, delta) => {
|
|
4768
4776
|
currentScale.current = THREE6.MathUtils.damp(currentScale.current, targetScale, 6, delta);
|
|
4769
4777
|
});
|
|
@@ -4937,8 +4945,8 @@ var Avl3DTransitionArc = ({
|
|
|
4937
4945
|
onClick,
|
|
4938
4946
|
color = AVL_3D_COLORS.transitionArc
|
|
4939
4947
|
}) => {
|
|
4940
|
-
const [hovered, setHovered] =
|
|
4941
|
-
const { tubeArgs, labelPos, guardPos, arrowPos, arrowQuat, effectPositions } =
|
|
4948
|
+
const [hovered, setHovered] = React11.useState(false);
|
|
4949
|
+
const { tubeArgs, labelPos, guardPos, arrowPos, arrowQuat, effectPositions } = React11.useMemo(() => {
|
|
4942
4950
|
const offset = 1.5 + index * 0.8;
|
|
4943
4951
|
const curve = isSelf ? selfLoopCurve3D(from, 1.2) : arcCurve3D(from, to, offset);
|
|
4944
4952
|
const mid = curve.getPoint(0.5);
|
|
@@ -5071,7 +5079,7 @@ var Avl3DTraitScene = ({
|
|
|
5071
5079
|
data,
|
|
5072
5080
|
onTransitionClick
|
|
5073
5081
|
}) => {
|
|
5074
|
-
const statePositions =
|
|
5082
|
+
const statePositions = React11.useMemo(() => {
|
|
5075
5083
|
const radius = Math.max(3, data.states.length * 0.8);
|
|
5076
5084
|
const positions = fibonacciSpherePositions(data.states.length, radius);
|
|
5077
5085
|
const posMap = /* @__PURE__ */ new Map();
|
|
@@ -5081,7 +5089,7 @@ var Avl3DTraitScene = ({
|
|
|
5081
5089
|
});
|
|
5082
5090
|
return posMap;
|
|
5083
5091
|
}, [data.states]);
|
|
5084
|
-
const transitionIndices =
|
|
5092
|
+
const transitionIndices = React11.useMemo(() => {
|
|
5085
5093
|
const pairCount = /* @__PURE__ */ new Map();
|
|
5086
5094
|
return data.transitions.map((t) => {
|
|
5087
5095
|
const key = `${t.from}->${t.to}`;
|
|
@@ -5090,7 +5098,7 @@ var Avl3DTraitScene = ({
|
|
|
5090
5098
|
return idx;
|
|
5091
5099
|
});
|
|
5092
5100
|
}, [data.transitions]);
|
|
5093
|
-
const transitionCounts =
|
|
5101
|
+
const transitionCounts = React11.useMemo(() => {
|
|
5094
5102
|
const incoming = /* @__PURE__ */ new Map();
|
|
5095
5103
|
const outgoing = /* @__PURE__ */ new Map();
|
|
5096
5104
|
for (const t of data.transitions) {
|
|
@@ -5200,11 +5208,11 @@ var Avl3DExprTree = ({
|
|
|
5200
5208
|
expression,
|
|
5201
5209
|
position
|
|
5202
5210
|
}) => {
|
|
5203
|
-
const layoutResults =
|
|
5211
|
+
const layoutResults = React11.useMemo(() => {
|
|
5204
5212
|
const origin = { x: position[0], y: position[1], z: position[2] };
|
|
5205
5213
|
return treeLayout3D(expression, origin, 2.5, 1.5);
|
|
5206
5214
|
}, [expression, position]);
|
|
5207
|
-
const edges =
|
|
5215
|
+
const edges = React11.useMemo(() => {
|
|
5208
5216
|
const result = [];
|
|
5209
5217
|
function collectEdges(node, parentPos) {
|
|
5210
5218
|
const entry = layoutResults.find((r) => r.node === node);
|
|
@@ -5484,7 +5492,7 @@ var Avl3DEffects = ({
|
|
|
5484
5492
|
const dof = DOF_CONFIG[level];
|
|
5485
5493
|
const sparkles = SPARKLE_CONFIGS[level];
|
|
5486
5494
|
const stars = STARS_CONFIG[level];
|
|
5487
|
-
const starsKey =
|
|
5495
|
+
const starsKey = React11.useMemo(() => `stars-${level}`, [level]);
|
|
5488
5496
|
return /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
|
|
5489
5497
|
/* @__PURE__ */ jsxRuntime.jsx(
|
|
5490
5498
|
drei.Stars,
|
|
@@ -5548,16 +5556,16 @@ var DEFAULT_CONFIG2 = {
|
|
|
5548
5556
|
modelOverrides: {},
|
|
5549
5557
|
effectsEnabled: true
|
|
5550
5558
|
};
|
|
5551
|
-
var Avl3DContext =
|
|
5559
|
+
var Avl3DContext = React11.createContext(DEFAULT_CONFIG2);
|
|
5552
5560
|
function useAvl3DConfig() {
|
|
5553
|
-
return
|
|
5561
|
+
return React11.useContext(Avl3DContext);
|
|
5554
5562
|
}
|
|
5555
5563
|
function CameraController2({ targetPosition, targetLookAt, animated }) {
|
|
5556
5564
|
const { camera } = fiber.useThree();
|
|
5557
|
-
const targetPosVec =
|
|
5558
|
-
const targetLookVec =
|
|
5559
|
-
const isAnimating =
|
|
5560
|
-
|
|
5565
|
+
const targetPosVec = React11.useRef(new THREE6__namespace.Vector3(...targetPosition));
|
|
5566
|
+
const targetLookVec = React11.useRef(new THREE6__namespace.Vector3(...targetLookAt));
|
|
5567
|
+
const isAnimating = React11.useRef(false);
|
|
5568
|
+
React11.useEffect(() => {
|
|
5561
5569
|
const newTarget = new THREE6__namespace.Vector3(...targetPosition);
|
|
5562
5570
|
const newLookAt = new THREE6__namespace.Vector3(...targetLookAt);
|
|
5563
5571
|
if (!newTarget.equals(targetPosVec.current) || !newLookAt.equals(targetLookVec.current)) {
|
|
@@ -5586,8 +5594,8 @@ function CameraController2({ targetPosition, targetLookAt, animated }) {
|
|
|
5586
5594
|
return null;
|
|
5587
5595
|
}
|
|
5588
5596
|
function SceneFade({ animating, children }) {
|
|
5589
|
-
const groupRef =
|
|
5590
|
-
const opacityRef =
|
|
5597
|
+
const groupRef = React11.useRef(null);
|
|
5598
|
+
const opacityRef = React11.useRef(1);
|
|
5591
5599
|
fiber.useFrame((_, delta) => {
|
|
5592
5600
|
if (!groupRef.current) return;
|
|
5593
5601
|
const target = animating ? 0 : 1;
|
|
@@ -5610,7 +5618,7 @@ var Avl3DViewer = ({
|
|
|
5610
5618
|
effects = true,
|
|
5611
5619
|
modelOverrides = {}
|
|
5612
5620
|
}) => {
|
|
5613
|
-
const schema =
|
|
5621
|
+
const schema = React11.useMemo(() => {
|
|
5614
5622
|
if (typeof schemaProp === "string") {
|
|
5615
5623
|
try {
|
|
5616
5624
|
return JSON.parse(schemaProp);
|
|
@@ -5620,12 +5628,12 @@ var Avl3DViewer = ({
|
|
|
5620
5628
|
}
|
|
5621
5629
|
return schemaProp;
|
|
5622
5630
|
}, [schemaProp]);
|
|
5623
|
-
const configValue =
|
|
5631
|
+
const configValue = React11.useMemo(() => ({
|
|
5624
5632
|
modelOverrides,
|
|
5625
5633
|
effectsEnabled: effects
|
|
5626
5634
|
}), [modelOverrides, effects]);
|
|
5627
|
-
const [state, dispatch] =
|
|
5628
|
-
|
|
5635
|
+
const [state, dispatch] = React11.useReducer(zoomReducer, initialZoomState);
|
|
5636
|
+
React11.useEffect(() => {
|
|
5629
5637
|
if (initialOrbital) {
|
|
5630
5638
|
dispatch({ type: "ZOOM_INTO_ORBITAL", orbital: initialOrbital, targetPosition: { x: 0, y: 0 } });
|
|
5631
5639
|
setTimeout(() => dispatch({ type: "ANIMATION_COMPLETE" }), 0);
|
|
@@ -5637,35 +5645,35 @@ var Avl3DViewer = ({
|
|
|
5637
5645
|
}
|
|
5638
5646
|
}
|
|
5639
5647
|
}, [initialOrbital, initialTrait]);
|
|
5640
|
-
|
|
5648
|
+
React11.useEffect(() => {
|
|
5641
5649
|
onZoomChange?.(state.level, {
|
|
5642
5650
|
orbital: state.selectedOrbital ?? void 0,
|
|
5643
5651
|
trait: state.selectedTrait ?? void 0
|
|
5644
5652
|
});
|
|
5645
5653
|
}, [state.level, state.selectedOrbital, state.selectedTrait, onZoomChange]);
|
|
5646
|
-
|
|
5654
|
+
React11.useEffect(() => {
|
|
5647
5655
|
if (!state.animating) return;
|
|
5648
5656
|
const timer = setTimeout(() => {
|
|
5649
5657
|
dispatch({ type: "ANIMATION_COMPLETE" });
|
|
5650
5658
|
}, 800);
|
|
5651
5659
|
return () => clearTimeout(timer);
|
|
5652
5660
|
}, [state.animating]);
|
|
5653
|
-
const handleKeyDown =
|
|
5661
|
+
const handleKeyDown = React11.useCallback((e) => {
|
|
5654
5662
|
if (e.key === "Escape") {
|
|
5655
5663
|
dispatch({ type: "ZOOM_OUT" });
|
|
5656
5664
|
}
|
|
5657
5665
|
}, []);
|
|
5658
|
-
const handleOrbitalClick =
|
|
5666
|
+
const handleOrbitalClick = React11.useCallback((name) => {
|
|
5659
5667
|
dispatch({ type: "ZOOM_INTO_ORBITAL", orbital: name, targetPosition: { x: 0, y: 0 } });
|
|
5660
5668
|
}, []);
|
|
5661
|
-
const handleTraitClick =
|
|
5669
|
+
const handleTraitClick = React11.useCallback((name) => {
|
|
5662
5670
|
dispatch({ type: "ZOOM_INTO_TRAIT", trait: name, targetPosition: { x: 0, y: 0 } });
|
|
5663
5671
|
}, []);
|
|
5664
|
-
const [highlightedTrait, setHighlightedTrait] =
|
|
5665
|
-
const handleTransitionClick =
|
|
5672
|
+
const [highlightedTrait, setHighlightedTrait] = React11__default.default.useState(null);
|
|
5673
|
+
const handleTransitionClick = React11.useCallback((index) => {
|
|
5666
5674
|
dispatch({ type: "ZOOM_INTO_TRANSITION", transitionIndex: index, targetPosition: { x: 0, y: 0 } });
|
|
5667
5675
|
}, []);
|
|
5668
|
-
const handleBreadcrumbClick =
|
|
5676
|
+
const handleBreadcrumbClick = React11.useCallback((targetLevel) => {
|
|
5669
5677
|
const levelOrder = ["application", "orbital", "trait", "transition"];
|
|
5670
5678
|
const currentIdx = levelOrder.indexOf(state.level);
|
|
5671
5679
|
const targetIdx = levelOrder.indexOf(targetLevel);
|
|
@@ -5674,7 +5682,7 @@ var Avl3DViewer = ({
|
|
|
5674
5682
|
}
|
|
5675
5683
|
}, [state.level]);
|
|
5676
5684
|
const cameraConfig = CAMERA_POSITIONS[state.level];
|
|
5677
|
-
const sceneContent =
|
|
5685
|
+
const sceneContent = React11.useMemo(() => {
|
|
5678
5686
|
switch (state.level) {
|
|
5679
5687
|
case "application": {
|
|
5680
5688
|
const data = parseApplicationLevel(schema);
|
|
@@ -5748,7 +5756,7 @@ var Avl3DViewer = ({
|
|
|
5748
5756
|
gap: "xs",
|
|
5749
5757
|
align: "center",
|
|
5750
5758
|
className: "absolute top-2 left-2 z-10 bg-surface/80 backdrop-blur rounded-md px-3 py-1.5",
|
|
5751
|
-
children: breadcrumbs.map((crumb, i) => /* @__PURE__ */ jsxRuntime.jsxs(
|
|
5759
|
+
children: breadcrumbs.map((crumb, i) => /* @__PURE__ */ jsxRuntime.jsxs(React11__default.default.Fragment, { children: [
|
|
5752
5760
|
i > 0 && /* @__PURE__ */ jsxRuntime.jsx(Typography, { variant: "small", color: "muted", className: "mx-1", children: "/" }),
|
|
5753
5761
|
i < breadcrumbs.length - 1 ? /* @__PURE__ */ jsxRuntime.jsx(
|
|
5754
5762
|
Box,
|