@almadar/ui 5.73.0 → 5.75.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 +42285 -42752
- package/dist/avl/index.css +0 -504
- package/dist/avl/index.js +42495 -42961
- package/dist/components/core/atoms/index.d.ts +1 -1
- package/dist/components/core/molecules/RepeatableFormSection.d.ts +6 -5
- package/dist/components/core/molecules/index.d.ts +1 -1
- package/dist/components/core/organisms/index.d.ts +1 -1
- package/dist/components/core/templates/index.d.ts +12 -12
- package/dist/components/game/{organisms/puzzles/sequencer → 2d}/ActionPalette.d.ts +1 -1
- package/dist/components/game/{organisms/puzzles/sequencer → 2d}/ActionTile.d.ts +2 -2
- package/dist/components/game/{organisms → 2d}/BattleBoard.d.ts +2 -2
- package/dist/components/game/{templates → 2d}/BattleTemplate.d.ts +3 -3
- package/dist/components/game/{organisms → 2d}/BoardgameBoard.d.ts +4 -4
- package/dist/components/game/{organisms/puzzles/builder → 2d}/BuilderBoard.d.ts +1 -1
- package/dist/components/game/2d/Canvas2D.d.ts +161 -0
- package/dist/components/game/{organisms → 2d}/CanvasEffect.d.ts +3 -3
- package/dist/components/game/{templates → 2d}/CardBattlerTemplate.d.ts +1 -1
- package/dist/components/game/{organisms → 2d}/CastleBoard.d.ts +1 -1
- package/dist/components/game/{templates → 2d}/CastleTemplate.d.ts +3 -3
- package/dist/components/game/{templates → 2d}/CityBuilderTemplate.d.ts +1 -1
- package/dist/components/game/{organisms/puzzles/classifier → 2d}/ClassifierBoard.d.ts +1 -1
- package/dist/components/game/2d/ControlGrid.d.ts +41 -0
- package/dist/components/game/{organisms/puzzles/debugger → 2d}/DebuggerBoard.d.ts +1 -1
- package/dist/components/game/{organisms/puzzles/event-handler → 2d}/EventHandlerBoard.d.ts +1 -1
- package/dist/components/game/{organisms → 2d}/FishingBoard.d.ts +1 -1
- package/dist/components/game/{organisms → 2d}/GameAudioProvider.d.ts +1 -1
- package/dist/components/game/2d/GameCard.d.ts +26 -0
- package/dist/components/game/2d/HealthBar.d.ts +26 -0
- package/dist/components/game/{organisms → 2d}/HexStrategyBoard.d.ts +4 -4
- package/dist/components/game/{organisms → 2d}/HolidayRunnerBoard.d.ts +4 -4
- package/dist/components/game/{molecules → 2d}/IsometricCanvas.d.ts +3 -3
- package/dist/components/game/{organisms → 2d}/MatchPuzzleBoard.d.ts +4 -4
- package/dist/components/game/{organisms → 2d}/MinigolfBoard.d.ts +4 -4
- package/dist/components/game/{organisms/puzzles/negotiator → 2d}/NegotiatorBoard.d.ts +1 -1
- package/dist/components/game/{organisms → 2d}/PinballBoard.d.ts +1 -1
- package/dist/components/game/{organisms → 2d}/PirateBoard.d.ts +4 -4
- package/dist/components/game/{organisms → 2d}/PlatformerBoard.d.ts +9 -14
- package/dist/components/game/{molecules → 2d}/PlatformerCanvas.d.ts +1 -1
- package/dist/components/game/{templates → 2d}/PlatformerTemplate.d.ts +1 -1
- package/dist/components/game/{organisms → 2d}/RacingBoard.d.ts +4 -4
- package/dist/components/game/{organisms → 2d}/RoguelikeBoard.d.ts +1 -1
- package/dist/components/game/{templates → 2d}/RoguelikeTemplate.d.ts +2 -2
- package/dist/components/game/{organisms/puzzles/sequencer → 2d}/SequenceBar.d.ts +1 -1
- package/dist/components/game/{organisms/puzzles/sequencer → 2d}/SequencerBoard.d.ts +1 -1
- package/dist/components/game/{organisms/physics-sim → 2d}/SimulationCanvas.d.ts +1 -1
- package/dist/components/game/{organisms/puzzles/simulator → 2d}/SimulatorBoard.d.ts +1 -1
- package/dist/components/game/{organisms → 2d}/SokobanBoard.d.ts +4 -4
- package/dist/components/game/{organisms → 2d}/SpaceShmupBoard.d.ts +4 -4
- package/dist/components/game/{organisms → 2d}/SpaceStationBoard.d.ts +4 -4
- package/dist/components/game/{organisms → 2d}/SportsBoard.d.ts +4 -4
- package/dist/components/game/{atoms → 2d}/Sprite.d.ts +1 -1
- package/dist/components/game/{organisms/puzzles/state-architect → 2d}/StateArchitectBoard.d.ts +1 -1
- package/dist/components/game/{organisms/puzzles/state-architect → 2d}/StateNode.d.ts +1 -1
- package/dist/components/game/{organisms → 2d}/TanksBoard.d.ts +4 -4
- package/dist/components/game/{templates → 2d}/TopDownShooterTemplate.d.ts +1 -1
- package/dist/components/game/{templates → 2d}/TowerDefenseTemplate.d.ts +1 -1
- package/dist/components/game/{organisms → 2d}/TraitStateViewer.d.ts +1 -1
- package/dist/components/game/{organisms/puzzles/state-architect → 2d}/TransitionArrow.d.ts +1 -1
- package/dist/components/game/{organisms → 2d}/UncontrolledBattleBoard.d.ts +1 -1
- package/dist/components/game/{templates → 2d}/VisualNovelTemplate.d.ts +1 -1
- package/dist/components/game/{organisms → 2d}/WorldMapBoard.d.ts +2 -2
- package/dist/components/game/{templates → 2d}/WorldMapTemplate.d.ts +3 -3
- package/dist/components/game/{templates → 2d}/game3dAssetManifest.d.ts +1 -1
- package/dist/components/game/2d/index.d.ts +122 -0
- package/dist/components/game/{organisms/hooks → 2d}/useBattleState.d.ts +1 -1
- package/dist/components/game/{organisms/hooks → 2d}/useCamera.d.ts +1 -1
- package/dist/components/game/{organisms → 2d}/useCanvasEffects.d.ts +1 -1
- package/dist/components/game/{molecules → 2d}/useUnitSpriteAtlas.d.ts +2 -2
- package/dist/components/game/3d/Canvas3D.d.ts +45 -0
- package/dist/components/game/{molecules/three/renderers → 3d}/FeatureRenderer.d.ts +1 -1
- package/dist/components/game/{molecules/three/renderers → 3d}/FeatureRenderer3D.d.ts +1 -1
- package/dist/components/game/{organisms → 3d}/GameBoard3D.d.ts +2 -2
- package/dist/components/game/{molecules → 3d}/GameCanvas3D.d.ts +3 -3
- package/dist/components/game/{templates → 3d}/GameCanvas3DBattleTemplate.d.ts +2 -2
- package/dist/components/game/{templates → 3d}/GameCanvas3DCastleTemplate.d.ts +2 -2
- package/dist/components/game/{templates → 3d}/GameCanvas3DWorldMapTemplate.d.ts +2 -2
- package/dist/components/game/{molecules/three/components → 3d}/PhysicsObject3D.d.ts +1 -1
- package/dist/components/game/{molecules/three/renderers → 3d}/TileRenderer.d.ts +1 -1
- package/dist/components/game/{molecules/three/renderers → 3d}/UnitRenderer.d.ts +3 -3
- package/dist/components/game/{molecules/three → 3d}/index.cjs +218 -301
- package/dist/components/game/{molecules/three → 3d}/index.css +3 -3
- package/dist/components/game/3d/index.d.ts +41 -0
- package/dist/components/game/{molecules/three → 3d}/index.js +29 -113
- package/dist/components/game/{molecules/three → 3d}/patterns.d.ts +5 -5
- package/dist/components/game/{molecules/three/hooks → 3d}/useAssetLoader.d.ts +1 -1
- package/dist/components/game/{molecules/three/hooks → 3d}/useGameCanvas3DEvents.d.ts +1 -1
- package/dist/components/game/{molecules/three/hooks → 3d}/useThree.d.ts +1 -1
- package/dist/components/game/{organisms/utils → shared}/canvasEffects.d.ts +1 -1
- package/dist/components/game/{organisms/utils → shared}/combatPresets.d.ts +1 -1
- package/dist/components/game/{organisms/types → shared}/game.d.ts +2 -2
- package/dist/components/game/shared/index.d.ts +23 -0
- package/dist/components/game/{organisms/types/isometric.d.ts → shared/isometricTypes.d.ts} +3 -7
- package/dist/components/game/{organisms/utils → shared}/spriteAnimation.d.ts +1 -1
- package/dist/components/game/{organisms/utils → shared}/spriteSheetConstants.d.ts +1 -1
- package/dist/components/index.cjs +24732 -25471
- package/dist/components/index.css +0 -504
- package/dist/components/index.js +24287 -25047
- package/dist/context/index.cjs +5 -7
- package/dist/context/index.js +5 -7
- package/dist/docs/index.cjs +108 -53
- package/dist/docs/index.css +0 -504
- package/dist/docs/index.js +108 -53
- package/dist/hooks/index.cjs +7 -9
- package/dist/hooks/index.js +7 -9
- package/dist/providers/index.cjs +43812 -44279
- package/dist/providers/index.css +0 -504
- package/dist/providers/index.js +43764 -44230
- package/dist/runtime/index.cjs +43783 -44250
- package/dist/runtime/index.css +0 -504
- package/dist/runtime/index.js +43642 -44108
- package/package.json +11 -11
- package/dist/components/game/atoms/HealthBar.d.ts +0 -18
- package/dist/components/game/atoms/XPBar.d.ts +0 -20
- package/dist/components/game/atoms/index.d.ts +0 -25
- package/dist/components/game/molecules/ActionButtons.d.ts +0 -38
- package/dist/components/game/molecules/DPad.d.ts +0 -26
- package/dist/components/game/molecules/index.d.ts +0 -32
- package/dist/components/game/molecules/three/components/index.d.ts +0 -10
- package/dist/components/game/molecules/three/index.d.ts +0 -35
- package/dist/components/game/molecules/three/renderers/index.d.ts +0 -11
- package/dist/components/game/organisms/editor/index.d.ts +0 -9
- package/dist/components/game/organisms/hooks/usePhysics2D.d.ts +0 -45
- package/dist/components/game/organisms/hooks/useSpriteAnimations.d.ts +0 -43
- package/dist/components/game/organisms/index.d.ts +0 -66
- package/dist/components/game/organisms/managers/PhysicsManager.d.ts +0 -103
- package/dist/components/game/organisms/physics-sim/index.d.ts +0 -7
- package/dist/components/game/organisms/puzzles/builder/index.d.ts +0 -2
- package/dist/components/game/organisms/puzzles/classifier/index.d.ts +0 -2
- package/dist/components/game/organisms/puzzles/debugger/index.d.ts +0 -2
- package/dist/components/game/organisms/puzzles/event-handler/index.d.ts +0 -8
- package/dist/components/game/organisms/puzzles/negotiator/index.d.ts +0 -2
- package/dist/components/game/organisms/puzzles/sequencer/index.d.ts +0 -8
- package/dist/components/game/organisms/puzzles/simulator/index.d.ts +0 -2
- package/dist/components/game/organisms/puzzles/state-architect/index.d.ts +0 -10
- package/dist/components/game/templates/index.d.ts +0 -4
- /package/dist/components/game/{atoms → 2d}/ActionButton.d.ts +0 -0
- /package/dist/components/game/{organisms → 2d}/CardBattlerBoard.d.ts +0 -0
- /package/dist/components/game/{molecules → 2d}/CardHand.d.ts +0 -0
- /package/dist/components/game/{atoms → 2d}/ChoiceButton.d.ts +0 -0
- /package/dist/components/game/{organisms → 2d}/CityBuilderBoard.d.ts +0 -0
- /package/dist/components/game/{molecules → 2d}/CombatLog.d.ts +0 -0
- /package/dist/components/game/{atoms → 2d}/ComboCounter.d.ts +0 -0
- /package/dist/components/game/{atoms → 2d}/ControlButton.d.ts +0 -0
- /package/dist/components/game/{molecules → 2d}/CraftingRecipe.d.ts +0 -0
- /package/dist/components/game/{atoms → 2d}/DamageNumber.d.ts +0 -0
- /package/dist/components/game/{molecules → 2d}/DialogueBox.d.ts +0 -0
- /package/dist/components/game/{atoms → 2d}/DialogueBubble.d.ts +0 -0
- /package/dist/components/game/{molecules → 2d}/EnemyPlate.d.ts +0 -0
- /package/dist/components/game/{organisms/puzzles/event-handler → 2d}/EventLog.d.ts +0 -0
- /package/dist/components/game/{organisms → 2d}/GameAudioToggle.d.ts +0 -0
- /package/dist/components/game/{molecules → 2d}/GameCanvas2D.d.ts +0 -0
- /package/dist/components/game/{molecules → 2d}/GameHud.d.ts +0 -0
- /package/dist/components/game/{molecules → 2d}/GameMenu.d.ts +0 -0
- /package/dist/components/game/{molecules → 2d}/GameOverScreen.d.ts +0 -0
- /package/dist/components/game/{templates → 2d}/GameShell.d.ts +0 -0
- /package/dist/components/game/{templates → 2d}/GameTemplate.d.ts +0 -0
- /package/dist/components/game/{molecules → 2d}/HealthPanel.d.ts +0 -0
- /package/dist/components/game/{molecules → 2d}/InventoryGrid.d.ts +0 -0
- /package/dist/components/game/{molecules → 2d}/InventoryPanel.d.ts +0 -0
- /package/dist/components/game/{atoms → 2d}/ItemSlot.d.ts +0 -0
- /package/dist/components/game/{atoms → 2d}/MiniMap.d.ts +0 -0
- /package/dist/components/game/{organisms/puzzles/event-handler → 2d}/ObjectRulePanel.d.ts +0 -0
- /package/dist/components/game/{molecules → 2d}/PowerupSlots.d.ts +0 -0
- /package/dist/components/game/{molecules → 2d}/QuestTracker.d.ts +0 -0
- /package/dist/components/game/{molecules → 2d}/ResourceBar.d.ts +0 -0
- /package/dist/components/game/{atoms → 2d}/ResourceCounter.d.ts +0 -0
- /package/dist/components/game/{organisms/puzzles/event-handler → 2d}/RuleEditor.d.ts +0 -0
- /package/dist/components/game/{molecules → 2d}/ScoreBoard.d.ts +0 -0
- /package/dist/components/game/{atoms → 2d}/ScoreDisplay.d.ts +0 -0
- /package/dist/components/game/{organisms/physics-sim → 2d}/SimulationControls.d.ts +0 -0
- /package/dist/components/game/{organisms/physics-sim → 2d}/SimulationGraph.d.ts +0 -0
- /package/dist/components/game/{molecules → 2d}/StatBadge.d.ts +0 -0
- /package/dist/components/game/{atoms → 2d}/StateIndicator.d.ts +0 -0
- /package/dist/components/game/{organisms/puzzles/state-architect → 2d}/StateJsonView.d.ts +0 -0
- /package/dist/components/game/{atoms → 2d}/StatusEffect.d.ts +0 -0
- /package/dist/components/game/{atoms → 2d}/TimerDisplay.d.ts +0 -0
- /package/dist/components/game/{organisms → 2d}/TopDownShooterBoard.d.ts +0 -0
- /package/dist/components/game/{organisms → 2d}/TowerDefenseBoard.d.ts +0 -0
- /package/dist/components/game/{organisms → 2d}/TraitSlot.d.ts +0 -0
- /package/dist/components/game/{atoms → 2d}/TurnIndicator.d.ts +0 -0
- /package/dist/components/game/{molecules → 2d}/TurnPanel.d.ts +0 -0
- /package/dist/components/game/{molecules → 2d}/UnitCommandBar.d.ts +0 -0
- /package/dist/components/game/{organisms/puzzles/state-architect → 2d}/VariablePanel.d.ts +0 -0
- /package/dist/components/game/{organisms → 2d}/VisualNovelBoard.d.ts +0 -0
- /package/dist/components/game/{atoms → 2d}/WaypointMarker.d.ts +0 -0
- /package/dist/components/game/{organisms/editor → 2d}/editorUtils.d.ts +0 -0
- /package/dist/components/game/{organisms/physics-sim/presets → 2d}/mechanics.d.ts +0 -0
- /package/dist/components/game/{organisms/physics-sim/presets/index.d.ts → 2d/physicsPresets.d.ts} +0 -0
- /package/dist/components/game/{organisms/puzzles/event-handler → 2d}/puzzleObject.d.ts +0 -0
- /package/dist/components/game/{organisms/physics-sim/presets → 2d}/types.d.ts +0 -0
- /package/dist/components/game/{organisms/hooks → 2d}/useGameAudio.d.ts +0 -0
- /package/dist/components/game/{molecules/three/loaders → 3d}/AssetLoader.d.ts +0 -0
- /package/dist/components/game/{molecules/three → 3d}/Camera3D.d.ts +0 -0
- /package/dist/components/game/{molecules/three/components → 3d}/Canvas3DErrorBoundary.d.ts +0 -0
- /package/dist/components/game/{molecules/three/components → 3d}/Canvas3DLoadingState.d.ts +0 -0
- /package/dist/components/game/{molecules/three → 3d}/Lighting3D.d.ts +0 -0
- /package/dist/components/game/{molecules/three/components → 3d}/ModelLoader.d.ts +0 -0
- /package/dist/components/game/{molecules/three → 3d}/Scene3D.d.ts +0 -0
- /package/dist/components/game/{molecules/three/utils → 3d}/culling.d.ts +0 -0
- /package/dist/components/game/{molecules/three/utils → 3d}/grid3D.d.ts +0 -0
- /package/dist/components/game/{molecules/three/hooks → 3d}/useRaycaster.d.ts +0 -0
- /package/dist/components/game/{molecules/three/hooks → 3d}/useSceneGraph.d.ts +0 -0
- /package/dist/components/game/{organisms → shared}/boardEntity.d.ts +0 -0
- /package/dist/components/game/{organisms/utils → shared}/combatEffects.d.ts +0 -0
- /package/dist/components/game/{organisms/types → shared}/effects.d.ts +0 -0
- /package/dist/components/game/{organisms/utils → shared}/isometric.d.ts +0 -0
- /package/dist/components/game/{organisms/utils → shared}/makeAsset.d.ts +0 -0
- /package/dist/components/game/{organisms/types/spriteAnimation.d.ts → shared/spriteAnimationTypes.d.ts} +0 -0
- /package/dist/components/game/{organisms/hooks → shared}/useImageCache.d.ts +0 -0
|
@@ -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');
|
|
@@ -38,7 +38,7 @@ function _interopNamespace(e) {
|
|
|
38
38
|
return Object.freeze(n);
|
|
39
39
|
}
|
|
40
40
|
|
|
41
|
-
var
|
|
41
|
+
var React10__default = /*#__PURE__*/_interopDefault(React10);
|
|
42
42
|
var THREE6__namespace = /*#__PURE__*/_interopNamespace(THREE6);
|
|
43
43
|
var LucideIcons__namespace = /*#__PURE__*/_interopNamespace(LucideIcons);
|
|
44
44
|
|
|
@@ -47,8 +47,8 @@ var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { en
|
|
|
47
47
|
var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value);
|
|
48
48
|
function Scene3D({ background = "#1a1a2e", fog, children }) {
|
|
49
49
|
const { scene } = fiber.useThree();
|
|
50
|
-
const initializedRef =
|
|
51
|
-
|
|
50
|
+
const initializedRef = React10.useRef(false);
|
|
51
|
+
React10.useEffect(() => {
|
|
52
52
|
if (initializedRef.current) return;
|
|
53
53
|
initializedRef.current = true;
|
|
54
54
|
if (background.startsWith("#") || background.startsWith("rgb")) {
|
|
@@ -69,7 +69,7 @@ function Scene3D({ background = "#1a1a2e", fog, children }) {
|
|
|
69
69
|
}, [scene, background, fog]);
|
|
70
70
|
return /* @__PURE__ */ jsxRuntime.jsx(jsxRuntime.Fragment, { children });
|
|
71
71
|
}
|
|
72
|
-
var Camera3D =
|
|
72
|
+
var Camera3D = React10.forwardRef(
|
|
73
73
|
({
|
|
74
74
|
mode = "isometric",
|
|
75
75
|
position = [10, 10, 10],
|
|
@@ -82,10 +82,10 @@ var Camera3D = React11.forwardRef(
|
|
|
82
82
|
onChange
|
|
83
83
|
}, ref) => {
|
|
84
84
|
const { camera, set, viewport } = fiber.useThree();
|
|
85
|
-
const controlsRef =
|
|
86
|
-
const initialPosition =
|
|
87
|
-
const initialTarget =
|
|
88
|
-
|
|
85
|
+
const controlsRef = React10.useRef(null);
|
|
86
|
+
const initialPosition = React10.useRef(new THREE6__namespace.Vector3(...position));
|
|
87
|
+
const initialTarget = React10.useRef(new THREE6__namespace.Vector3(...target));
|
|
88
|
+
React10.useEffect(() => {
|
|
89
89
|
let newCamera;
|
|
90
90
|
if (mode === "isometric") {
|
|
91
91
|
const aspect = viewport.aspect;
|
|
@@ -116,7 +116,7 @@ var Camera3D = React11.forwardRef(
|
|
|
116
116
|
onChange(camera);
|
|
117
117
|
}
|
|
118
118
|
});
|
|
119
|
-
|
|
119
|
+
React10.useImperativeHandle(ref, () => ({
|
|
120
120
|
getCamera: () => camera,
|
|
121
121
|
setPosition: (x, y, z) => {
|
|
122
122
|
camera.position.set(x, y, z);
|
|
@@ -258,7 +258,7 @@ function Canvas3DLoadingState({
|
|
|
258
258
|
] });
|
|
259
259
|
}
|
|
260
260
|
var log = logger.createLogger("almadar:ui:game:canvas3d:error-boundary");
|
|
261
|
-
var Canvas3DErrorBoundary = class extends
|
|
261
|
+
var Canvas3DErrorBoundary = class extends React10.Component {
|
|
262
262
|
constructor(props) {
|
|
263
263
|
super(props);
|
|
264
264
|
__publicField(this, "handleReset", () => {
|
|
@@ -338,12 +338,12 @@ function detectAssetRoot(modelUrl) {
|
|
|
338
338
|
return modelUrl.substring(0, modelUrl.lastIndexOf("/") + 1);
|
|
339
339
|
}
|
|
340
340
|
function useGLTFModel(url, resourceBasePath) {
|
|
341
|
-
const [state, setState] =
|
|
341
|
+
const [state, setState] = React10.useState({
|
|
342
342
|
model: null,
|
|
343
343
|
isLoading: false,
|
|
344
344
|
error: null
|
|
345
345
|
});
|
|
346
|
-
|
|
346
|
+
React10.useEffect(() => {
|
|
347
347
|
if (!url) {
|
|
348
348
|
setState({ model: null, isLoading: false, error: null });
|
|
349
349
|
return;
|
|
@@ -391,7 +391,7 @@ function ModelLoader({
|
|
|
391
391
|
resourceBasePath
|
|
392
392
|
}) {
|
|
393
393
|
const { model: loadedModel, isLoading, error } = useGLTFModel(url, resourceBasePath);
|
|
394
|
-
const model =
|
|
394
|
+
const model = React10.useMemo(() => {
|
|
395
395
|
if (!loadedModel) return null;
|
|
396
396
|
const cloned = SkeletonUtils.clone(loadedModel);
|
|
397
397
|
cloned.updateMatrixWorld(true);
|
|
@@ -403,7 +403,7 @@ function ModelLoader({
|
|
|
403
403
|
});
|
|
404
404
|
return cloned;
|
|
405
405
|
}, [loadedModel, castShadow, receiveShadow]);
|
|
406
|
-
const normFactor =
|
|
406
|
+
const normFactor = React10.useMemo(() => {
|
|
407
407
|
if (!model) return 1;
|
|
408
408
|
const box = new THREE6__namespace.Box3().setFromObject(model);
|
|
409
409
|
const size = new THREE6__namespace.Vector3();
|
|
@@ -412,11 +412,11 @@ function ModelLoader({
|
|
|
412
412
|
if (!Number.isFinite(maxDim) || maxDim < 0.05) return 1;
|
|
413
413
|
return 1 / maxDim;
|
|
414
414
|
}, [model]);
|
|
415
|
-
const scaleArray =
|
|
415
|
+
const scaleArray = React10.useMemo(() => {
|
|
416
416
|
const base = typeof scale === "number" ? [scale, scale, scale] : scale;
|
|
417
417
|
return [base[0] * normFactor, base[1] * normFactor, base[2] * normFactor];
|
|
418
418
|
}, [scale, normFactor]);
|
|
419
|
-
const rotationRad =
|
|
419
|
+
const rotationRad = React10.useMemo(() => {
|
|
420
420
|
return [
|
|
421
421
|
rotation[0] * Math.PI / 180,
|
|
422
422
|
rotation[1] * Math.PI / 180,
|
|
@@ -494,81 +494,11 @@ function PhysicsObject3D({
|
|
|
494
494
|
entityId,
|
|
495
495
|
modelUrl,
|
|
496
496
|
initialPosition = [0, 0, 0],
|
|
497
|
-
|
|
498
|
-
mass = 1,
|
|
499
|
-
gravity = 9.8,
|
|
500
|
-
groundY = 0,
|
|
501
|
-
scale = 1,
|
|
502
|
-
onPhysicsUpdate,
|
|
503
|
-
onGroundHit,
|
|
504
|
-
onCollision
|
|
497
|
+
scale = 1
|
|
505
498
|
}) {
|
|
506
|
-
|
|
507
|
-
const physicsStateRef = React11.useRef({
|
|
508
|
-
id: entityId,
|
|
509
|
-
x: initialPosition[0],
|
|
510
|
-
y: initialPosition[1],
|
|
511
|
-
z: initialPosition[2],
|
|
512
|
-
vx: initialVelocity[0],
|
|
513
|
-
vy: initialVelocity[1],
|
|
514
|
-
vz: initialVelocity[2],
|
|
515
|
-
rx: 0,
|
|
516
|
-
ry: 0,
|
|
517
|
-
rz: 0,
|
|
518
|
-
isGrounded: false,
|
|
519
|
-
gravity,
|
|
520
|
-
friction: 0.8,
|
|
521
|
-
mass,
|
|
522
|
-
state: "Active"
|
|
523
|
-
});
|
|
524
|
-
const groundHitRef = React11.useRef(false);
|
|
525
|
-
React11.useEffect(() => {
|
|
526
|
-
if (groupRef.current) {
|
|
527
|
-
groupRef.current.position.set(
|
|
528
|
-
initialPosition[0],
|
|
529
|
-
initialPosition[1],
|
|
530
|
-
initialPosition[2]
|
|
531
|
-
);
|
|
532
|
-
}
|
|
533
|
-
}, []);
|
|
534
|
-
fiber.useFrame((state, delta) => {
|
|
535
|
-
const physics = physicsStateRef.current;
|
|
536
|
-
if (physics.state !== "Active") return;
|
|
537
|
-
const dt = Math.min(delta, 0.1);
|
|
538
|
-
if (!physics.isGrounded) {
|
|
539
|
-
physics.vy -= physics.gravity * dt;
|
|
540
|
-
}
|
|
541
|
-
physics.x += physics.vx * dt;
|
|
542
|
-
physics.y += physics.vy * dt;
|
|
543
|
-
physics.z += physics.vz * dt;
|
|
544
|
-
const airResistance = Math.pow(0.99, dt * 60);
|
|
545
|
-
physics.vx *= airResistance;
|
|
546
|
-
physics.vz *= airResistance;
|
|
547
|
-
if (physics.y <= groundY) {
|
|
548
|
-
physics.y = groundY;
|
|
549
|
-
if (!physics.isGrounded) {
|
|
550
|
-
physics.isGrounded = true;
|
|
551
|
-
groundHitRef.current = true;
|
|
552
|
-
physics.vx *= physics.friction;
|
|
553
|
-
physics.vz *= physics.friction;
|
|
554
|
-
onGroundHit?.();
|
|
555
|
-
}
|
|
556
|
-
physics.vy = 0;
|
|
557
|
-
} else {
|
|
558
|
-
physics.isGrounded = false;
|
|
559
|
-
}
|
|
560
|
-
if (groupRef.current) {
|
|
561
|
-
groupRef.current.position.set(physics.x, physics.y, physics.z);
|
|
562
|
-
if (!physics.isGrounded) {
|
|
563
|
-
physics.rx += physics.vz * dt * 0.5;
|
|
564
|
-
physics.rz -= physics.vx * dt * 0.5;
|
|
565
|
-
groupRef.current.rotation.set(physics.rx, physics.ry, physics.rz);
|
|
566
|
-
}
|
|
567
|
-
}
|
|
568
|
-
onPhysicsUpdate?.({ ...physics });
|
|
569
|
-
});
|
|
499
|
+
log3.debug("PhysicsObject3D render", { entityId, initialPosition });
|
|
570
500
|
const scaleArray = typeof scale === "number" ? [scale, scale, scale] : scale;
|
|
571
|
-
return /* @__PURE__ */ jsxRuntime.jsx("group", {
|
|
501
|
+
return /* @__PURE__ */ jsxRuntime.jsx("group", { position: initialPosition, scale: scaleArray, children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
572
502
|
ModelLoader,
|
|
573
503
|
{
|
|
574
504
|
url: modelUrl,
|
|
@@ -791,7 +721,7 @@ var AssetLoader = class {
|
|
|
791
721
|
};
|
|
792
722
|
var assetLoader = new AssetLoader();
|
|
793
723
|
|
|
794
|
-
// components/game/
|
|
724
|
+
// components/game/3d/useThree.ts
|
|
795
725
|
var DEFAULT_OPTIONS = {
|
|
796
726
|
cameraMode: "isometric",
|
|
797
727
|
cameraPosition: [10, 10, 10],
|
|
@@ -803,21 +733,21 @@ var DEFAULT_OPTIONS = {
|
|
|
803
733
|
};
|
|
804
734
|
function useThree3(options = {}) {
|
|
805
735
|
const opts = { ...DEFAULT_OPTIONS, ...options };
|
|
806
|
-
const containerRef =
|
|
807
|
-
const canvasRef =
|
|
808
|
-
const rendererRef =
|
|
809
|
-
const sceneRef =
|
|
810
|
-
const cameraRef =
|
|
811
|
-
const controlsRef =
|
|
812
|
-
const gridHelperRef =
|
|
813
|
-
const rafRef =
|
|
814
|
-
const [isReady, setIsReady] =
|
|
815
|
-
const [dimensions, setDimensions] =
|
|
816
|
-
const initialCameraPosition =
|
|
736
|
+
const containerRef = React10.useRef(null);
|
|
737
|
+
const canvasRef = React10.useRef(null);
|
|
738
|
+
const rendererRef = React10.useRef(null);
|
|
739
|
+
const sceneRef = React10.useRef(null);
|
|
740
|
+
const cameraRef = React10.useRef(null);
|
|
741
|
+
const controlsRef = React10.useRef(null);
|
|
742
|
+
const gridHelperRef = React10.useRef(null);
|
|
743
|
+
const rafRef = React10.useRef(0);
|
|
744
|
+
const [isReady, setIsReady] = React10.useState(false);
|
|
745
|
+
const [dimensions, setDimensions] = React10.useState({ width: 0, height: 0 });
|
|
746
|
+
const initialCameraPosition = React10.useMemo(
|
|
817
747
|
() => new THREE6__namespace.Vector3(...opts.cameraPosition),
|
|
818
748
|
[]
|
|
819
749
|
);
|
|
820
|
-
|
|
750
|
+
React10.useEffect(() => {
|
|
821
751
|
if (!containerRef.current) return;
|
|
822
752
|
const container = containerRef.current;
|
|
823
753
|
const { clientWidth, clientHeight } = container;
|
|
@@ -910,7 +840,7 @@ function useThree3(options = {}) {
|
|
|
910
840
|
scene.clear();
|
|
911
841
|
};
|
|
912
842
|
}, []);
|
|
913
|
-
|
|
843
|
+
React10.useEffect(() => {
|
|
914
844
|
if (!cameraRef.current || !containerRef.current) return;
|
|
915
845
|
const container = containerRef.current;
|
|
916
846
|
const { clientWidth, clientHeight } = container;
|
|
@@ -945,20 +875,20 @@ function useThree3(options = {}) {
|
|
|
945
875
|
animate();
|
|
946
876
|
}
|
|
947
877
|
}, [opts.cameraMode]);
|
|
948
|
-
const setCameraPosition =
|
|
878
|
+
const setCameraPosition = React10.useCallback((x, y, z) => {
|
|
949
879
|
if (cameraRef.current) {
|
|
950
880
|
cameraRef.current.position.set(x, y, z);
|
|
951
881
|
controlsRef.current?.update();
|
|
952
882
|
}
|
|
953
883
|
}, []);
|
|
954
|
-
const lookAt =
|
|
884
|
+
const lookAt = React10.useCallback((x, y, z) => {
|
|
955
885
|
if (cameraRef.current) {
|
|
956
886
|
cameraRef.current.lookAt(x, y, z);
|
|
957
887
|
controlsRef.current?.target.set(x, y, z);
|
|
958
888
|
controlsRef.current?.update();
|
|
959
889
|
}
|
|
960
890
|
}, []);
|
|
961
|
-
const resetCamera =
|
|
891
|
+
const resetCamera = React10.useCallback(() => {
|
|
962
892
|
if (cameraRef.current) {
|
|
963
893
|
cameraRef.current.position.copy(initialCameraPosition);
|
|
964
894
|
cameraRef.current.lookAt(0, 0, 0);
|
|
@@ -968,7 +898,7 @@ function useThree3(options = {}) {
|
|
|
968
898
|
}
|
|
969
899
|
}
|
|
970
900
|
}, [initialCameraPosition]);
|
|
971
|
-
const fitView =
|
|
901
|
+
const fitView = React10.useCallback(
|
|
972
902
|
(bounds) => {
|
|
973
903
|
if (!cameraRef.current) return;
|
|
974
904
|
const centerX = (bounds.minX + bounds.maxX) / 2;
|
|
@@ -999,20 +929,20 @@ function useThree3(options = {}) {
|
|
|
999
929
|
}
|
|
1000
930
|
function useAssetLoader(options = {}) {
|
|
1001
931
|
const { preloadUrls = [], loader: customLoader } = options;
|
|
1002
|
-
const loaderRef =
|
|
1003
|
-
const [state, setState] =
|
|
932
|
+
const loaderRef = React10.useRef(customLoader || new AssetLoader());
|
|
933
|
+
const [state, setState] = React10.useState({
|
|
1004
934
|
isLoading: false,
|
|
1005
935
|
progress: 0,
|
|
1006
936
|
loaded: 0,
|
|
1007
937
|
total: 0,
|
|
1008
938
|
errors: []
|
|
1009
939
|
});
|
|
1010
|
-
|
|
940
|
+
React10.useEffect(() => {
|
|
1011
941
|
if (preloadUrls.length > 0) {
|
|
1012
942
|
preload(preloadUrls);
|
|
1013
943
|
}
|
|
1014
944
|
}, []);
|
|
1015
|
-
const updateProgress =
|
|
945
|
+
const updateProgress = React10.useCallback((loaded, total) => {
|
|
1016
946
|
setState((prev) => ({
|
|
1017
947
|
...prev,
|
|
1018
948
|
loaded,
|
|
@@ -1020,7 +950,7 @@ function useAssetLoader(options = {}) {
|
|
|
1020
950
|
progress: total > 0 ? Math.round(loaded / total * 100) : 0
|
|
1021
951
|
}));
|
|
1022
952
|
}, []);
|
|
1023
|
-
const loadModel =
|
|
953
|
+
const loadModel = React10.useCallback(
|
|
1024
954
|
async (url) => {
|
|
1025
955
|
setState((prev) => ({ ...prev, isLoading: true }));
|
|
1026
956
|
try {
|
|
@@ -1043,7 +973,7 @@ function useAssetLoader(options = {}) {
|
|
|
1043
973
|
},
|
|
1044
974
|
[]
|
|
1045
975
|
);
|
|
1046
|
-
const loadOBJ =
|
|
976
|
+
const loadOBJ = React10.useCallback(
|
|
1047
977
|
async (url) => {
|
|
1048
978
|
setState((prev) => ({ ...prev, isLoading: true }));
|
|
1049
979
|
try {
|
|
@@ -1066,7 +996,7 @@ function useAssetLoader(options = {}) {
|
|
|
1066
996
|
},
|
|
1067
997
|
[]
|
|
1068
998
|
);
|
|
1069
|
-
const loadTexture =
|
|
999
|
+
const loadTexture = React10.useCallback(
|
|
1070
1000
|
async (url) => {
|
|
1071
1001
|
setState((prev) => ({ ...prev, isLoading: true }));
|
|
1072
1002
|
try {
|
|
@@ -1089,7 +1019,7 @@ function useAssetLoader(options = {}) {
|
|
|
1089
1019
|
},
|
|
1090
1020
|
[]
|
|
1091
1021
|
);
|
|
1092
|
-
const preload =
|
|
1022
|
+
const preload = React10.useCallback(
|
|
1093
1023
|
async (urls) => {
|
|
1094
1024
|
setState((prev) => ({
|
|
1095
1025
|
...prev,
|
|
@@ -1128,27 +1058,27 @@ function useAssetLoader(options = {}) {
|
|
|
1128
1058
|
},
|
|
1129
1059
|
[updateProgress]
|
|
1130
1060
|
);
|
|
1131
|
-
const hasModel =
|
|
1061
|
+
const hasModel = React10.useCallback((url) => {
|
|
1132
1062
|
return loaderRef.current.hasModel(url);
|
|
1133
1063
|
}, []);
|
|
1134
|
-
const hasTexture =
|
|
1064
|
+
const hasTexture = React10.useCallback((url) => {
|
|
1135
1065
|
return loaderRef.current.hasTexture(url);
|
|
1136
1066
|
}, []);
|
|
1137
|
-
const getModel =
|
|
1067
|
+
const getModel = React10.useCallback((url) => {
|
|
1138
1068
|
try {
|
|
1139
1069
|
return loaderRef.current.getModel(url);
|
|
1140
1070
|
} catch {
|
|
1141
1071
|
return void 0;
|
|
1142
1072
|
}
|
|
1143
1073
|
}, []);
|
|
1144
|
-
const getTexture =
|
|
1074
|
+
const getTexture = React10.useCallback((url) => {
|
|
1145
1075
|
try {
|
|
1146
1076
|
return loaderRef.current.getTexture(url);
|
|
1147
1077
|
} catch {
|
|
1148
1078
|
return void 0;
|
|
1149
1079
|
}
|
|
1150
1080
|
}, []);
|
|
1151
|
-
const clearCache =
|
|
1081
|
+
const clearCache = React10.useCallback(() => {
|
|
1152
1082
|
loaderRef.current.clearCache();
|
|
1153
1083
|
setState({
|
|
1154
1084
|
isLoading: false,
|
|
@@ -1172,25 +1102,25 @@ function useAssetLoader(options = {}) {
|
|
|
1172
1102
|
};
|
|
1173
1103
|
}
|
|
1174
1104
|
function useSceneGraph() {
|
|
1175
|
-
const nodesRef =
|
|
1176
|
-
const addNode =
|
|
1105
|
+
const nodesRef = React10.useRef(/* @__PURE__ */ new Map());
|
|
1106
|
+
const addNode = React10.useCallback((node) => {
|
|
1177
1107
|
const existing = nodesRef.current.get(node.id);
|
|
1178
1108
|
if (existing) {
|
|
1179
1109
|
existing.mesh.removeFromParent();
|
|
1180
1110
|
}
|
|
1181
1111
|
nodesRef.current.set(node.id, node);
|
|
1182
1112
|
}, []);
|
|
1183
|
-
const removeNode =
|
|
1113
|
+
const removeNode = React10.useCallback((id) => {
|
|
1184
1114
|
const node = nodesRef.current.get(id);
|
|
1185
1115
|
if (node) {
|
|
1186
1116
|
node.mesh.removeFromParent();
|
|
1187
1117
|
nodesRef.current.delete(id);
|
|
1188
1118
|
}
|
|
1189
1119
|
}, []);
|
|
1190
|
-
const getNode =
|
|
1120
|
+
const getNode = React10.useCallback((id) => {
|
|
1191
1121
|
return nodesRef.current.get(id);
|
|
1192
1122
|
}, []);
|
|
1193
|
-
const updateNodePosition =
|
|
1123
|
+
const updateNodePosition = React10.useCallback(
|
|
1194
1124
|
(id, x, y, z) => {
|
|
1195
1125
|
const node = nodesRef.current.get(id);
|
|
1196
1126
|
if (node) {
|
|
@@ -1200,7 +1130,7 @@ function useSceneGraph() {
|
|
|
1200
1130
|
},
|
|
1201
1131
|
[]
|
|
1202
1132
|
);
|
|
1203
|
-
const updateNodeGridPosition =
|
|
1133
|
+
const updateNodeGridPosition = React10.useCallback(
|
|
1204
1134
|
(id, gridX, gridZ) => {
|
|
1205
1135
|
const node = nodesRef.current.get(id);
|
|
1206
1136
|
if (node) {
|
|
@@ -1209,7 +1139,7 @@ function useSceneGraph() {
|
|
|
1209
1139
|
},
|
|
1210
1140
|
[]
|
|
1211
1141
|
);
|
|
1212
|
-
const getNodeAtGrid =
|
|
1142
|
+
const getNodeAtGrid = React10.useCallback(
|
|
1213
1143
|
(x, z, type) => {
|
|
1214
1144
|
return Array.from(nodesRef.current.values()).find((node) => {
|
|
1215
1145
|
const matchesGrid = node.gridPosition.x === x && node.gridPosition.z === z;
|
|
@@ -1218,10 +1148,10 @@ function useSceneGraph() {
|
|
|
1218
1148
|
},
|
|
1219
1149
|
[]
|
|
1220
1150
|
);
|
|
1221
|
-
const getNodesByType =
|
|
1151
|
+
const getNodesByType = React10.useCallback((type) => {
|
|
1222
1152
|
return Array.from(nodesRef.current.values()).filter((node) => node.type === type);
|
|
1223
1153
|
}, []);
|
|
1224
|
-
const getNodesInBounds =
|
|
1154
|
+
const getNodesInBounds = React10.useCallback(
|
|
1225
1155
|
(minX, maxX, minZ, maxZ) => {
|
|
1226
1156
|
return Array.from(nodesRef.current.values()).filter((node) => {
|
|
1227
1157
|
const { x, z } = node.gridPosition;
|
|
@@ -1230,13 +1160,13 @@ function useSceneGraph() {
|
|
|
1230
1160
|
},
|
|
1231
1161
|
[]
|
|
1232
1162
|
);
|
|
1233
|
-
const clearNodes =
|
|
1163
|
+
const clearNodes = React10.useCallback(() => {
|
|
1234
1164
|
nodesRef.current.forEach((node) => {
|
|
1235
1165
|
node.mesh.removeFromParent();
|
|
1236
1166
|
});
|
|
1237
1167
|
nodesRef.current.clear();
|
|
1238
1168
|
}, []);
|
|
1239
|
-
const countNodes =
|
|
1169
|
+
const countNodes = React10.useCallback((type) => {
|
|
1240
1170
|
if (!type) {
|
|
1241
1171
|
return nodesRef.current.size;
|
|
1242
1172
|
}
|
|
@@ -1258,9 +1188,9 @@ function useSceneGraph() {
|
|
|
1258
1188
|
}
|
|
1259
1189
|
function useRaycaster(options) {
|
|
1260
1190
|
const { camera, canvas, cellSize = 1, offsetX = 0, offsetZ = 0 } = options;
|
|
1261
|
-
const raycaster =
|
|
1262
|
-
const mouse =
|
|
1263
|
-
const clientToNDC =
|
|
1191
|
+
const raycaster = React10.useRef(new THREE6__namespace.Raycaster());
|
|
1192
|
+
const mouse = React10.useRef(new THREE6__namespace.Vector2());
|
|
1193
|
+
const clientToNDC = React10.useCallback(
|
|
1264
1194
|
(clientX, clientY) => {
|
|
1265
1195
|
if (!canvas) {
|
|
1266
1196
|
return { x: 0, y: 0 };
|
|
@@ -1273,7 +1203,7 @@ function useRaycaster(options) {
|
|
|
1273
1203
|
},
|
|
1274
1204
|
[canvas]
|
|
1275
1205
|
);
|
|
1276
|
-
const isWithinCanvas =
|
|
1206
|
+
const isWithinCanvas = React10.useCallback(
|
|
1277
1207
|
(clientX, clientY) => {
|
|
1278
1208
|
if (!canvas) return false;
|
|
1279
1209
|
const rect = canvas.getBoundingClientRect();
|
|
@@ -1281,7 +1211,7 @@ function useRaycaster(options) {
|
|
|
1281
1211
|
},
|
|
1282
1212
|
[canvas]
|
|
1283
1213
|
);
|
|
1284
|
-
const getIntersection =
|
|
1214
|
+
const getIntersection = React10.useCallback(
|
|
1285
1215
|
(clientX, clientY, objects) => {
|
|
1286
1216
|
if (!camera || !canvas) return null;
|
|
1287
1217
|
const ndc = clientToNDC(clientX, clientY);
|
|
@@ -1304,7 +1234,7 @@ function useRaycaster(options) {
|
|
|
1304
1234
|
},
|
|
1305
1235
|
[camera, canvas, clientToNDC]
|
|
1306
1236
|
);
|
|
1307
|
-
const getAllIntersections =
|
|
1237
|
+
const getAllIntersections = React10.useCallback(
|
|
1308
1238
|
(clientX, clientY, objects) => {
|
|
1309
1239
|
if (!camera || !canvas) return [];
|
|
1310
1240
|
const ndc = clientToNDC(clientX, clientY);
|
|
@@ -1323,7 +1253,7 @@ function useRaycaster(options) {
|
|
|
1323
1253
|
},
|
|
1324
1254
|
[camera, canvas, clientToNDC]
|
|
1325
1255
|
);
|
|
1326
|
-
const getGridCoordinates =
|
|
1256
|
+
const getGridCoordinates = React10.useCallback(
|
|
1327
1257
|
(clientX, clientY) => {
|
|
1328
1258
|
if (!camera || !canvas) return null;
|
|
1329
1259
|
const ndc = clientToNDC(clientX, clientY);
|
|
@@ -1341,7 +1271,7 @@ function useRaycaster(options) {
|
|
|
1341
1271
|
},
|
|
1342
1272
|
[camera, canvas, cellSize, offsetX, offsetZ, clientToNDC]
|
|
1343
1273
|
);
|
|
1344
|
-
const getTileAtPosition =
|
|
1274
|
+
const getTileAtPosition = React10.useCallback(
|
|
1345
1275
|
(clientX, clientY, scene) => {
|
|
1346
1276
|
if (!camera || !canvas) return null;
|
|
1347
1277
|
const tileMeshes = [];
|
|
@@ -1464,10 +1394,10 @@ var fallbackEventBus = {
|
|
|
1464
1394
|
}
|
|
1465
1395
|
};
|
|
1466
1396
|
function useEventBus() {
|
|
1467
|
-
const context =
|
|
1397
|
+
const context = React10.useContext(providers.EventBusContext);
|
|
1468
1398
|
const baseBus = context ?? getGlobalEventBus() ?? fallbackEventBus;
|
|
1469
1399
|
const scope = providers.useTraitScope();
|
|
1470
|
-
return
|
|
1400
|
+
return React10.useMemo(() => {
|
|
1471
1401
|
if (!scope) {
|
|
1472
1402
|
return {
|
|
1473
1403
|
...baseBus,
|
|
@@ -1503,7 +1433,7 @@ function useEventBus() {
|
|
|
1503
1433
|
}
|
|
1504
1434
|
function useEmitEvent() {
|
|
1505
1435
|
const eventBus = useEventBus();
|
|
1506
|
-
return
|
|
1436
|
+
return React10.useCallback(
|
|
1507
1437
|
(type, payload, source) => {
|
|
1508
1438
|
eventBus.emit(type, payload, source);
|
|
1509
1439
|
},
|
|
@@ -1511,7 +1441,7 @@ function useEmitEvent() {
|
|
|
1511
1441
|
);
|
|
1512
1442
|
}
|
|
1513
1443
|
|
|
1514
|
-
// components/game/
|
|
1444
|
+
// components/game/3d/useGameCanvas3DEvents.ts
|
|
1515
1445
|
function useGameCanvas3DEvents(options) {
|
|
1516
1446
|
const {
|
|
1517
1447
|
tileClickEvent,
|
|
@@ -1530,9 +1460,9 @@ function useGameCanvas3DEvents(options) {
|
|
|
1530
1460
|
onUnitAnimation
|
|
1531
1461
|
} = options;
|
|
1532
1462
|
const emit = useEmitEvent();
|
|
1533
|
-
const optionsRef =
|
|
1463
|
+
const optionsRef = React10.useRef(options);
|
|
1534
1464
|
optionsRef.current = options;
|
|
1535
|
-
const handleTileClick =
|
|
1465
|
+
const handleTileClick = React10.useCallback(
|
|
1536
1466
|
(tile, event) => {
|
|
1537
1467
|
if (tileClickEvent) {
|
|
1538
1468
|
emit(tileClickEvent, {
|
|
@@ -1548,7 +1478,7 @@ function useGameCanvas3DEvents(options) {
|
|
|
1548
1478
|
},
|
|
1549
1479
|
[tileClickEvent, emit]
|
|
1550
1480
|
);
|
|
1551
|
-
const handleUnitClick =
|
|
1481
|
+
const handleUnitClick = React10.useCallback(
|
|
1552
1482
|
(unit, event) => {
|
|
1553
1483
|
if (unitClickEvent) {
|
|
1554
1484
|
emit(unitClickEvent, {
|
|
@@ -1567,7 +1497,7 @@ function useGameCanvas3DEvents(options) {
|
|
|
1567
1497
|
},
|
|
1568
1498
|
[unitClickEvent, emit]
|
|
1569
1499
|
);
|
|
1570
|
-
const handleFeatureClick =
|
|
1500
|
+
const handleFeatureClick = React10.useCallback(
|
|
1571
1501
|
(feature, event) => {
|
|
1572
1502
|
if (featureClickEvent) {
|
|
1573
1503
|
emit(featureClickEvent, {
|
|
@@ -1582,7 +1512,7 @@ function useGameCanvas3DEvents(options) {
|
|
|
1582
1512
|
},
|
|
1583
1513
|
[featureClickEvent, emit]
|
|
1584
1514
|
);
|
|
1585
|
-
const handleCanvasClick =
|
|
1515
|
+
const handleCanvasClick = React10.useCallback(
|
|
1586
1516
|
(event) => {
|
|
1587
1517
|
if (canvasClickEvent) {
|
|
1588
1518
|
emit(canvasClickEvent, {
|
|
@@ -1595,7 +1525,7 @@ function useGameCanvas3DEvents(options) {
|
|
|
1595
1525
|
},
|
|
1596
1526
|
[canvasClickEvent, emit]
|
|
1597
1527
|
);
|
|
1598
|
-
const handleTileHover =
|
|
1528
|
+
const handleTileHover = React10.useCallback(
|
|
1599
1529
|
(tile, event) => {
|
|
1600
1530
|
if (tile) {
|
|
1601
1531
|
if (tileHoverEvent) {
|
|
@@ -1615,7 +1545,7 @@ function useGameCanvas3DEvents(options) {
|
|
|
1615
1545
|
},
|
|
1616
1546
|
[tileHoverEvent, tileLeaveEvent, emit]
|
|
1617
1547
|
);
|
|
1618
|
-
const handleUnitAnimation =
|
|
1548
|
+
const handleUnitAnimation = React10.useCallback(
|
|
1619
1549
|
(unitId, state) => {
|
|
1620
1550
|
if (unitAnimationEvent) {
|
|
1621
1551
|
emit(unitAnimationEvent, {
|
|
@@ -1628,7 +1558,7 @@ function useGameCanvas3DEvents(options) {
|
|
|
1628
1558
|
},
|
|
1629
1559
|
[unitAnimationEvent, emit]
|
|
1630
1560
|
);
|
|
1631
|
-
const handleCameraChange =
|
|
1561
|
+
const handleCameraChange = React10.useCallback(
|
|
1632
1562
|
(position) => {
|
|
1633
1563
|
if (cameraChangeEvent) {
|
|
1634
1564
|
emit(cameraChangeEvent, {
|
|
@@ -1674,17 +1604,17 @@ function TileRenderer({
|
|
|
1674
1604
|
validMoves = [],
|
|
1675
1605
|
attackTargets = []
|
|
1676
1606
|
}) {
|
|
1677
|
-
const meshRef =
|
|
1678
|
-
const geometry =
|
|
1607
|
+
const meshRef = React10.useRef(null);
|
|
1608
|
+
const geometry = React10.useMemo(() => {
|
|
1679
1609
|
return new THREE6__namespace.BoxGeometry(cellSize * 0.95, 0.2, cellSize * 0.95);
|
|
1680
1610
|
}, [cellSize]);
|
|
1681
|
-
const material =
|
|
1611
|
+
const material = React10.useMemo(() => {
|
|
1682
1612
|
return new THREE6__namespace.MeshStandardMaterial({
|
|
1683
1613
|
roughness: 0.8,
|
|
1684
1614
|
metalness: 0.1
|
|
1685
1615
|
});
|
|
1686
1616
|
}, []);
|
|
1687
|
-
const { positions, colors, tileMap } =
|
|
1617
|
+
const { positions, colors, tileMap } = React10.useMemo(() => {
|
|
1688
1618
|
const pos = [];
|
|
1689
1619
|
const cols = [];
|
|
1690
1620
|
const map = /* @__PURE__ */ new Map();
|
|
@@ -1714,7 +1644,7 @@ function TileRenderer({
|
|
|
1714
1644
|
});
|
|
1715
1645
|
return { positions: pos, colors: cols, tileMap: map };
|
|
1716
1646
|
}, [tiles, cellSize, offsetX, offsetZ, terrainColors, selectedTileIds, validMoves, attackTargets]);
|
|
1717
|
-
|
|
1647
|
+
React10.useEffect(() => {
|
|
1718
1648
|
if (!meshRef.current || !useInstancing) return;
|
|
1719
1649
|
const mesh = meshRef.current;
|
|
1720
1650
|
mesh.count = positions.length;
|
|
@@ -1843,26 +1773,18 @@ function TileRenderer({
|
|
|
1843
1773
|
return /* @__PURE__ */ jsxRuntime.jsx("group", { children: renderIndividualTiles() });
|
|
1844
1774
|
}
|
|
1845
1775
|
function UnitVisual({ unit, position, isSelected, onClick }) {
|
|
1846
|
-
const
|
|
1847
|
-
const
|
|
1848
|
-
const [isHovered, setIsHovered] = React11.useState(false);
|
|
1849
|
-
const teamColor = React11.useMemo(() => {
|
|
1776
|
+
const [isHovered, setIsHovered] = React10.useState(false);
|
|
1777
|
+
const teamColor = React10.useMemo(() => {
|
|
1850
1778
|
if (unit.faction === "player" || unit.team === "player") return 4491519;
|
|
1851
1779
|
if (unit.faction === "enemy" || unit.team === "enemy") return 16729156;
|
|
1852
1780
|
if (unit.faction === "neutral" || unit.team === "neutral") return 16777028;
|
|
1853
1781
|
return 8947848;
|
|
1854
1782
|
}, [unit.faction, unit.team]);
|
|
1855
|
-
|
|
1856
|
-
if (groupRef.current && animationState === "idle") {
|
|
1857
|
-
const y = position[1] + Math.sin(state.clock.elapsedTime * 2 + position[0]) * 0.05;
|
|
1858
|
-
groupRef.current.position.y = y;
|
|
1859
|
-
}
|
|
1860
|
-
});
|
|
1861
|
-
const healthPercent = React11.useMemo(() => {
|
|
1783
|
+
const healthPercent = React10.useMemo(() => {
|
|
1862
1784
|
if (unit.health === void 0 || unit.maxHealth === void 0) return 1;
|
|
1863
1785
|
return Math.max(0, Math.min(1, unit.health / unit.maxHealth));
|
|
1864
1786
|
}, [unit.health, unit.maxHealth]);
|
|
1865
|
-
const healthColor =
|
|
1787
|
+
const healthColor = React10.useMemo(() => {
|
|
1866
1788
|
if (healthPercent > 0.5) return "#44aa44";
|
|
1867
1789
|
if (healthPercent > 0.25) return "#aaaa44";
|
|
1868
1790
|
return "#ff4444";
|
|
@@ -1870,7 +1792,6 @@ function UnitVisual({ unit, position, isSelected, onClick }) {
|
|
|
1870
1792
|
return /* @__PURE__ */ jsxRuntime.jsxs(
|
|
1871
1793
|
"group",
|
|
1872
1794
|
{
|
|
1873
|
-
ref: groupRef,
|
|
1874
1795
|
position,
|
|
1875
1796
|
onClick,
|
|
1876
1797
|
onPointerEnter: () => setIsHovered(true),
|
|
@@ -1923,7 +1844,7 @@ function UnitRenderer({
|
|
|
1923
1844
|
onAnimationStateChange,
|
|
1924
1845
|
animationSpeed = 1
|
|
1925
1846
|
}) {
|
|
1926
|
-
const handleUnitClick =
|
|
1847
|
+
const handleUnitClick = React10__default.default.useCallback(
|
|
1927
1848
|
(unit) => {
|
|
1928
1849
|
onUnitClick?.(unit);
|
|
1929
1850
|
},
|
|
@@ -2128,7 +2049,7 @@ function FeatureGroup({
|
|
|
2128
2049
|
}) });
|
|
2129
2050
|
}
|
|
2130
2051
|
function FeatureRenderer(props) {
|
|
2131
|
-
const insideCanvas =
|
|
2052
|
+
const insideCanvas = React10.useContext(fiber.context) != null;
|
|
2132
2053
|
if (insideCanvas) return /* @__PURE__ */ jsxRuntime.jsx(FeatureGroup, { ...props });
|
|
2133
2054
|
return /* @__PURE__ */ jsxRuntime.jsxs(fiber.Canvas, { camera: { position: [4, 4, 6], fov: 50 }, style: { width: "100%", height: 360 }, children: [
|
|
2134
2055
|
/* @__PURE__ */ jsxRuntime.jsx("ambientLight", { intensity: 0.6 }),
|
|
@@ -2145,10 +2066,10 @@ function detectAssetRoot3(modelUrl) {
|
|
|
2145
2066
|
return modelUrl.substring(0, modelUrl.lastIndexOf("/") + 1);
|
|
2146
2067
|
}
|
|
2147
2068
|
function useGLTFModel2(url) {
|
|
2148
|
-
const [model, setModel] =
|
|
2149
|
-
const [isLoading, setIsLoading] =
|
|
2150
|
-
const [error, setError] =
|
|
2151
|
-
|
|
2069
|
+
const [model, setModel] = React10.useState(null);
|
|
2070
|
+
const [isLoading, setIsLoading] = React10.useState(false);
|
|
2071
|
+
const [error, setError] = React10.useState(null);
|
|
2072
|
+
React10.useEffect(() => {
|
|
2152
2073
|
if (!url) {
|
|
2153
2074
|
setModel(null);
|
|
2154
2075
|
return;
|
|
@@ -2180,9 +2101,9 @@ function FeatureModel({
|
|
|
2180
2101
|
onClick,
|
|
2181
2102
|
onHover
|
|
2182
2103
|
}) {
|
|
2183
|
-
const groupRef = React11.useRef(null);
|
|
2184
2104
|
const { model: loadedModel, isLoading } = useGLTFModel2(feature.assetUrl?.url);
|
|
2185
|
-
const
|
|
2105
|
+
const baseRotationY = feature.rotation !== void 0 ? feature.rotation * Math.PI / 180 - Math.PI / 4 : -Math.PI / 4;
|
|
2106
|
+
const model = React10.useMemo(() => {
|
|
2186
2107
|
if (!loadedModel) return null;
|
|
2187
2108
|
const cloned = loadedModel.clone();
|
|
2188
2109
|
cloned.scale.setScalar(0.3);
|
|
@@ -2194,14 +2115,6 @@ function FeatureModel({
|
|
|
2194
2115
|
});
|
|
2195
2116
|
return cloned;
|
|
2196
2117
|
}, [loadedModel]);
|
|
2197
|
-
fiber.useFrame((state) => {
|
|
2198
|
-
if (groupRef.current) {
|
|
2199
|
-
const featureRotation = feature.rotation;
|
|
2200
|
-
const baseRotation = featureRotation !== void 0 ? featureRotation * Math.PI / 180 - Math.PI / 4 : -Math.PI / 4;
|
|
2201
|
-
const wobble = isSelected ? Math.sin(state.clock.elapsedTime * 2) * 0.1 : 0;
|
|
2202
|
-
groupRef.current.rotation.y = baseRotation + wobble;
|
|
2203
|
-
}
|
|
2204
|
-
});
|
|
2205
2118
|
if (isLoading) {
|
|
2206
2119
|
return /* @__PURE__ */ jsxRuntime.jsx("group", { position, children: /* @__PURE__ */ jsxRuntime.jsxs("mesh", { rotation: [Math.PI / 2, 0, 0], children: [
|
|
2207
2120
|
/* @__PURE__ */ jsxRuntime.jsx("ringGeometry", { args: [0.3, 0.35, 16] }),
|
|
@@ -2233,8 +2146,8 @@ function FeatureModel({
|
|
|
2233
2146
|
return /* @__PURE__ */ jsxRuntime.jsxs(
|
|
2234
2147
|
"group",
|
|
2235
2148
|
{
|
|
2236
|
-
ref: groupRef,
|
|
2237
2149
|
position,
|
|
2150
|
+
rotation: [0, baseRotationY, 0],
|
|
2238
2151
|
onClick,
|
|
2239
2152
|
onPointerEnter: () => onHover(true),
|
|
2240
2153
|
onPointerLeave: () => onHover(false),
|
|
@@ -2292,7 +2205,7 @@ function preloadFeatures(urls) {
|
|
|
2292
2205
|
});
|
|
2293
2206
|
}
|
|
2294
2207
|
|
|
2295
|
-
// components/game/
|
|
2208
|
+
// components/game/shared/spriteAnimation.ts
|
|
2296
2209
|
function resolveSheetDirection(facing) {
|
|
2297
2210
|
switch (facing) {
|
|
2298
2211
|
case "se":
|
|
@@ -2314,7 +2227,7 @@ function frameRect(frame, row, columns, frameWidth, frameHeight) {
|
|
|
2314
2227
|
};
|
|
2315
2228
|
}
|
|
2316
2229
|
|
|
2317
|
-
// components/game/
|
|
2230
|
+
// components/game/2d/useUnitSpriteAtlas.ts
|
|
2318
2231
|
function unitAtlasUrl(unit) {
|
|
2319
2232
|
return unit.spriteSheet?.url ?? null;
|
|
2320
2233
|
}
|
|
@@ -2327,11 +2240,11 @@ function resolveSheetUrl(atlasUrl, relativeSheetPath) {
|
|
|
2327
2240
|
}
|
|
2328
2241
|
}
|
|
2329
2242
|
function useUnitSpriteAtlas(units) {
|
|
2330
|
-
const atlasCacheRef =
|
|
2331
|
-
const loadingRef =
|
|
2332
|
-
const [pendingCount, setPendingCount] =
|
|
2333
|
-
const [, forceTick] =
|
|
2334
|
-
const atlasUrls =
|
|
2243
|
+
const atlasCacheRef = React10.useRef(/* @__PURE__ */ new Map());
|
|
2244
|
+
const loadingRef = React10.useRef(/* @__PURE__ */ new Set());
|
|
2245
|
+
const [pendingCount, setPendingCount] = React10.useState(0);
|
|
2246
|
+
const [, forceTick] = React10.useState(0);
|
|
2247
|
+
const atlasUrls = React10.useMemo(() => {
|
|
2335
2248
|
const set = /* @__PURE__ */ new Set();
|
|
2336
2249
|
for (const unit of units) {
|
|
2337
2250
|
const url = unitAtlasUrl(unit);
|
|
@@ -2339,7 +2252,7 @@ function useUnitSpriteAtlas(units) {
|
|
|
2339
2252
|
}
|
|
2340
2253
|
return [...set];
|
|
2341
2254
|
}, [units]);
|
|
2342
|
-
|
|
2255
|
+
React10.useEffect(() => {
|
|
2343
2256
|
const cache = atlasCacheRef.current;
|
|
2344
2257
|
const loading = loadingRef.current;
|
|
2345
2258
|
const toLoad = atlasUrls.filter((url) => !cache.has(url) && !loading.has(url));
|
|
@@ -2363,7 +2276,7 @@ function useUnitSpriteAtlas(units) {
|
|
|
2363
2276
|
cancelled = true;
|
|
2364
2277
|
};
|
|
2365
2278
|
}, [atlasUrls]);
|
|
2366
|
-
const sheetUrls =
|
|
2279
|
+
const sheetUrls = React10.useMemo(() => {
|
|
2367
2280
|
const urls = /* @__PURE__ */ new Set();
|
|
2368
2281
|
for (const unit of units) {
|
|
2369
2282
|
const atlasUrl = unitAtlasUrl(unit);
|
|
@@ -2376,7 +2289,7 @@ function useUnitSpriteAtlas(units) {
|
|
|
2376
2289
|
}
|
|
2377
2290
|
return [...urls];
|
|
2378
2291
|
}, [units, pendingCount]);
|
|
2379
|
-
const resolveUnitFrame =
|
|
2292
|
+
const resolveUnitFrame = React10.useCallback((unitId) => {
|
|
2380
2293
|
const unit = units.find((u) => u.id === unitId);
|
|
2381
2294
|
if (!unit) return null;
|
|
2382
2295
|
const atlasUrl = unitAtlasUrl(unit);
|
|
@@ -2416,7 +2329,7 @@ function CameraController({
|
|
|
2416
2329
|
onCameraChange
|
|
2417
2330
|
}) {
|
|
2418
2331
|
const { camera } = fiber.useThree();
|
|
2419
|
-
|
|
2332
|
+
React10.useEffect(() => {
|
|
2420
2333
|
if (onCameraChange) {
|
|
2421
2334
|
onCameraChange({
|
|
2422
2335
|
x: camera.position.x,
|
|
@@ -2433,9 +2346,9 @@ function UnitSpriteBillboard({
|
|
|
2433
2346
|
height = 1.2
|
|
2434
2347
|
}) {
|
|
2435
2348
|
const texture = fiber.useLoader(THREE6__namespace.TextureLoader, sheetUrl);
|
|
2436
|
-
const meshRef =
|
|
2437
|
-
const matRef =
|
|
2438
|
-
const [aspect, setAspect] =
|
|
2349
|
+
const meshRef = React10.useRef(null);
|
|
2350
|
+
const matRef = React10.useRef(null);
|
|
2351
|
+
const [aspect, setAspect] = React10.useState(1);
|
|
2439
2352
|
fiber.useFrame(() => {
|
|
2440
2353
|
const frame = resolveFrame();
|
|
2441
2354
|
if (!frame || !texture.image) return;
|
|
@@ -2468,7 +2381,7 @@ function UnitSpriteBillboard({
|
|
|
2468
2381
|
)
|
|
2469
2382
|
] });
|
|
2470
2383
|
}
|
|
2471
|
-
var GameCanvas3D =
|
|
2384
|
+
var GameCanvas3D = React10.forwardRef(
|
|
2472
2385
|
({
|
|
2473
2386
|
tiles = [],
|
|
2474
2387
|
units = [],
|
|
@@ -2513,11 +2426,11 @@ var GameCanvas3D = React11.forwardRef(
|
|
|
2513
2426
|
unitScale = 1,
|
|
2514
2427
|
children
|
|
2515
2428
|
}, ref) => {
|
|
2516
|
-
const containerRef =
|
|
2517
|
-
const controlsRef =
|
|
2518
|
-
const [hoveredTile, setHoveredTile] =
|
|
2519
|
-
const [internalError, setInternalError] =
|
|
2520
|
-
|
|
2429
|
+
const containerRef = React10.useRef(null);
|
|
2430
|
+
const controlsRef = React10.useRef(null);
|
|
2431
|
+
const [hoveredTile, setHoveredTile] = React10.useState(null);
|
|
2432
|
+
const [internalError, setInternalError] = React10.useState(null);
|
|
2433
|
+
React10.useEffect(() => {
|
|
2521
2434
|
const el = containerRef.current;
|
|
2522
2435
|
if (!el) return;
|
|
2523
2436
|
let node = el;
|
|
@@ -2541,7 +2454,7 @@ var GameCanvas3D = React11.forwardRef(
|
|
|
2541
2454
|
}
|
|
2542
2455
|
}, []);
|
|
2543
2456
|
const { sheetUrls: atlasSheetUrls, resolveUnitFrame } = useUnitSpriteAtlas(units);
|
|
2544
|
-
const preloadUrls =
|
|
2457
|
+
const preloadUrls = React10.useMemo(() => [...preloadAssets, ...atlasSheetUrls], [preloadAssets, atlasSheetUrls]);
|
|
2545
2458
|
const { isLoading: assetsLoading, progress, loaded, total } = useAssetLoader({
|
|
2546
2459
|
preloadUrls,
|
|
2547
2460
|
loader: customAssetLoader
|
|
@@ -2562,7 +2475,7 @@ var GameCanvas3D = React11.forwardRef(
|
|
|
2562
2475
|
onTileHover,
|
|
2563
2476
|
onUnitAnimation
|
|
2564
2477
|
});
|
|
2565
|
-
const gridBounds =
|
|
2478
|
+
const gridBounds = React10.useMemo(() => {
|
|
2566
2479
|
if (tiles.length === 0) {
|
|
2567
2480
|
return { minX: 0, maxX: 10, minZ: 0, maxZ: 10 };
|
|
2568
2481
|
}
|
|
@@ -2575,14 +2488,14 @@ var GameCanvas3D = React11.forwardRef(
|
|
|
2575
2488
|
maxZ: Math.max(...zs)
|
|
2576
2489
|
};
|
|
2577
2490
|
}, [tiles]);
|
|
2578
|
-
const cameraTarget =
|
|
2491
|
+
const cameraTarget = React10.useMemo(() => {
|
|
2579
2492
|
return [
|
|
2580
2493
|
(gridBounds.minX + gridBounds.maxX) / 2,
|
|
2581
2494
|
0,
|
|
2582
2495
|
(gridBounds.minZ + gridBounds.maxZ) / 2
|
|
2583
2496
|
];
|
|
2584
2497
|
}, [gridBounds]);
|
|
2585
|
-
const gridConfig =
|
|
2498
|
+
const gridConfig = React10.useMemo(
|
|
2586
2499
|
() => ({
|
|
2587
2500
|
...DEFAULT_GRID_CONFIG,
|
|
2588
2501
|
offsetX: -(gridBounds.maxX - gridBounds.minX) / 2,
|
|
@@ -2590,7 +2503,7 @@ var GameCanvas3D = React11.forwardRef(
|
|
|
2590
2503
|
}),
|
|
2591
2504
|
[gridBounds]
|
|
2592
2505
|
);
|
|
2593
|
-
const gridToWorld2 =
|
|
2506
|
+
const gridToWorld2 = React10.useCallback(
|
|
2594
2507
|
(x, z, y = 0) => {
|
|
2595
2508
|
const worldX = (x - gridBounds.minX) * gridConfig.cellSize;
|
|
2596
2509
|
const worldZ = (z - gridBounds.minZ) * gridConfig.cellSize;
|
|
@@ -2598,7 +2511,7 @@ var GameCanvas3D = React11.forwardRef(
|
|
|
2598
2511
|
},
|
|
2599
2512
|
[gridBounds, gridConfig]
|
|
2600
2513
|
);
|
|
2601
|
-
|
|
2514
|
+
React10.useImperativeHandle(ref, () => ({
|
|
2602
2515
|
getCameraPosition: () => {
|
|
2603
2516
|
if (controlsRef.current) {
|
|
2604
2517
|
const pos = controlsRef.current.object.position;
|
|
@@ -2636,19 +2549,19 @@ var GameCanvas3D = React11.forwardRef(
|
|
|
2636
2549
|
features
|
|
2637
2550
|
})
|
|
2638
2551
|
}));
|
|
2639
|
-
const handleTileClick =
|
|
2552
|
+
const handleTileClick = React10.useCallback(
|
|
2640
2553
|
(tile, event) => {
|
|
2641
2554
|
eventHandlers.handleTileClick(tile, event);
|
|
2642
2555
|
},
|
|
2643
2556
|
[eventHandlers]
|
|
2644
2557
|
);
|
|
2645
|
-
const handleUnitClick =
|
|
2558
|
+
const handleUnitClick = React10.useCallback(
|
|
2646
2559
|
(unit, event) => {
|
|
2647
2560
|
eventHandlers.handleUnitClick(unit, event);
|
|
2648
2561
|
},
|
|
2649
2562
|
[eventHandlers]
|
|
2650
2563
|
);
|
|
2651
|
-
const handleFeatureClick =
|
|
2564
|
+
const handleFeatureClick = React10.useCallback(
|
|
2652
2565
|
(feature, event) => {
|
|
2653
2566
|
if (event) {
|
|
2654
2567
|
eventHandlers.handleFeatureClick(feature, event);
|
|
@@ -2656,7 +2569,7 @@ var GameCanvas3D = React11.forwardRef(
|
|
|
2656
2569
|
},
|
|
2657
2570
|
[eventHandlers]
|
|
2658
2571
|
);
|
|
2659
|
-
const handleTileHover =
|
|
2572
|
+
const handleTileHover = React10.useCallback(
|
|
2660
2573
|
(tile, event) => {
|
|
2661
2574
|
setHoveredTile(tile);
|
|
2662
2575
|
if (event) {
|
|
@@ -2665,7 +2578,7 @@ var GameCanvas3D = React11.forwardRef(
|
|
|
2665
2578
|
},
|
|
2666
2579
|
[eventHandlers]
|
|
2667
2580
|
);
|
|
2668
|
-
const cameraConfig =
|
|
2581
|
+
const cameraConfig = React10.useMemo(() => {
|
|
2669
2582
|
const size = Math.max(
|
|
2670
2583
|
gridBounds.maxX - gridBounds.minX,
|
|
2671
2584
|
gridBounds.maxZ - gridBounds.minZ,
|
|
@@ -2694,7 +2607,7 @@ var GameCanvas3D = React11.forwardRef(
|
|
|
2694
2607
|
};
|
|
2695
2608
|
}
|
|
2696
2609
|
}, [cameraMode, gridBounds]);
|
|
2697
|
-
const DefaultTileRenderer =
|
|
2610
|
+
const DefaultTileRenderer = React10.useCallback(
|
|
2698
2611
|
({ tile, position }) => {
|
|
2699
2612
|
const isSelected = tile.id ? selectedTileIds.includes(tile.id) : false;
|
|
2700
2613
|
const isHovered = hoveredTile?.id === tile.id;
|
|
@@ -2757,7 +2670,7 @@ var GameCanvas3D = React11.forwardRef(
|
|
|
2757
2670
|
const UNIT_BASE_MODEL_SCALE = 0.5;
|
|
2758
2671
|
const UNIT_BASE_BILLBOARD_HEIGHT = 1.2;
|
|
2759
2672
|
const UNIT_BASE_PRIMITIVE_RADIUS = 0.3;
|
|
2760
|
-
const DefaultUnitRenderer =
|
|
2673
|
+
const DefaultUnitRenderer = React10.useCallback(
|
|
2761
2674
|
({ unit, position }) => {
|
|
2762
2675
|
const isSelected = selectedUnitId === unit.id;
|
|
2763
2676
|
const color = unit.faction === "player" ? 4491519 : unit.faction === "enemy" ? 16729156 : 16777028;
|
|
@@ -2843,7 +2756,7 @@ var GameCanvas3D = React11.forwardRef(
|
|
|
2843
2756
|
},
|
|
2844
2757
|
[selectedUnitId, handleUnitClick, resolveUnitFrame, unitScale, gridConfig]
|
|
2845
2758
|
);
|
|
2846
|
-
const DefaultFeatureRenderer =
|
|
2759
|
+
const DefaultFeatureRenderer = React10.useCallback(
|
|
2847
2760
|
({
|
|
2848
2761
|
feature,
|
|
2849
2762
|
position
|
|
@@ -3051,6 +2964,9 @@ var GameCanvas3D = React11.forwardRef(
|
|
|
3051
2964
|
}
|
|
3052
2965
|
);
|
|
3053
2966
|
GameCanvas3D.displayName = "GameCanvas3D";
|
|
2967
|
+
function Canvas3D(props) {
|
|
2968
|
+
return /* @__PURE__ */ jsxRuntime.jsx(GameCanvas3D, { ...props });
|
|
2969
|
+
}
|
|
3054
2970
|
var DEFAULT_FAMILY = "lucide";
|
|
3055
2971
|
var VALID_FAMILIES = [
|
|
3056
2972
|
"lucide",
|
|
@@ -3101,7 +3017,7 @@ function getIconFamilyServerSnapshot() {
|
|
|
3101
3017
|
return DEFAULT_FAMILY;
|
|
3102
3018
|
}
|
|
3103
3019
|
function useIconFamily() {
|
|
3104
|
-
return
|
|
3020
|
+
return React10.useSyncExternalStore(
|
|
3105
3021
|
subscribeIconFamily,
|
|
3106
3022
|
getIconFamilySnapshot,
|
|
3107
3023
|
getIconFamilyServerSnapshot
|
|
@@ -3123,7 +3039,7 @@ function loadLib(key, importer) {
|
|
|
3123
3039
|
return p;
|
|
3124
3040
|
}
|
|
3125
3041
|
function lazyFamilyIcon(libKey, importer, pick, fallbackName, family) {
|
|
3126
|
-
const Lazy =
|
|
3042
|
+
const Lazy = React10__default.default.lazy(async () => {
|
|
3127
3043
|
const lib = await loadLib(libKey, importer);
|
|
3128
3044
|
const Comp = pick(lib);
|
|
3129
3045
|
if (!Comp) {
|
|
@@ -3133,7 +3049,7 @@ function lazyFamilyIcon(libKey, importer, pick, fallbackName, family) {
|
|
|
3133
3049
|
return { default: Comp };
|
|
3134
3050
|
});
|
|
3135
3051
|
const Wrapped = (props) => /* @__PURE__ */ jsxRuntime.jsx(
|
|
3136
|
-
|
|
3052
|
+
React10__default.default.Suspense,
|
|
3137
3053
|
{
|
|
3138
3054
|
fallback: /* @__PURE__ */ jsxRuntime.jsx(
|
|
3139
3055
|
"span",
|
|
@@ -3799,7 +3715,7 @@ var Icon = ({
|
|
|
3799
3715
|
const directIcon = typeof icon === "string" ? void 0 : icon;
|
|
3800
3716
|
const effectiveName = typeof icon === "string" ? icon : name;
|
|
3801
3717
|
const family = useIconFamily();
|
|
3802
|
-
const RenderedComponent =
|
|
3718
|
+
const RenderedComponent = React10__default.default.useMemo(() => {
|
|
3803
3719
|
if (directIcon) return null;
|
|
3804
3720
|
return effectiveName ? resolveIconForFamily(effectiveName, family) : null;
|
|
3805
3721
|
}, [directIcon, effectiveName, family]);
|
|
@@ -3919,7 +3835,7 @@ function resolveIconProp(value, sizeClass) {
|
|
|
3919
3835
|
const IconComp = value;
|
|
3920
3836
|
return /* @__PURE__ */ jsxRuntime.jsx(IconComp, { className: sizeClass });
|
|
3921
3837
|
}
|
|
3922
|
-
if (
|
|
3838
|
+
if (React10__default.default.isValidElement(value)) {
|
|
3923
3839
|
return value;
|
|
3924
3840
|
}
|
|
3925
3841
|
if (typeof value === "object" && value !== null && isIconLike(value)) {
|
|
@@ -3928,7 +3844,7 @@ function resolveIconProp(value, sizeClass) {
|
|
|
3928
3844
|
}
|
|
3929
3845
|
return value;
|
|
3930
3846
|
}
|
|
3931
|
-
var Button =
|
|
3847
|
+
var Button = React10__default.default.forwardRef(
|
|
3932
3848
|
({
|
|
3933
3849
|
className,
|
|
3934
3850
|
variant = "primary",
|
|
@@ -4074,7 +3990,7 @@ var Typography = ({
|
|
|
4074
3990
|
}) => {
|
|
4075
3991
|
const variant = variantProp ?? (level ? `h${level}` : "body1");
|
|
4076
3992
|
const Component2 = as || defaultElements[variant];
|
|
4077
|
-
return
|
|
3993
|
+
return React10__default.default.createElement(
|
|
4078
3994
|
Component2,
|
|
4079
3995
|
{
|
|
4080
3996
|
id,
|
|
@@ -4147,7 +4063,7 @@ var Stack = ({
|
|
|
4147
4063
|
};
|
|
4148
4064
|
const isHorizontal = direction === "horizontal";
|
|
4149
4065
|
const directionClass = responsive && isHorizontal ? reverse ? "flex-col-reverse md:flex-row-reverse" : "flex-col md:flex-row" : isHorizontal ? reverse ? "flex-row-reverse" : "flex-row" : reverse ? "flex-col-reverse" : "flex-col";
|
|
4150
|
-
return
|
|
4066
|
+
return React10__default.default.createElement(
|
|
4151
4067
|
Component2,
|
|
4152
4068
|
{
|
|
4153
4069
|
className: cn(
|
|
@@ -4172,7 +4088,7 @@ var Stack = ({
|
|
|
4172
4088
|
var VStack = (props) => /* @__PURE__ */ jsxRuntime.jsx(Stack, { direction: "vertical", ...props });
|
|
4173
4089
|
var HStack = (props) => /* @__PURE__ */ jsxRuntime.jsx(Stack, { direction: "horizontal", ...props });
|
|
4174
4090
|
|
|
4175
|
-
// components/game/
|
|
4091
|
+
// components/game/shared/boardEntity.ts
|
|
4176
4092
|
function boardEntity(entity) {
|
|
4177
4093
|
if (!entity) return void 0;
|
|
4178
4094
|
return Array.isArray(entity) ? entity[0] : entity;
|
|
@@ -4240,8 +4156,8 @@ function GameBoard3D({
|
|
|
4240
4156
|
const turn = row ? num(row.turn) : 0;
|
|
4241
4157
|
const currentTeam = row ? str(row.currentTeam) : "player";
|
|
4242
4158
|
const isGameOver = result !== "none";
|
|
4243
|
-
const gameEndEmittedRef =
|
|
4244
|
-
|
|
4159
|
+
const gameEndEmittedRef = React10.useRef(false);
|
|
4160
|
+
React10.useEffect(() => {
|
|
4245
4161
|
if ((result === "victory" || result === "defeat") && gameEndEvent) {
|
|
4246
4162
|
if (!gameEndEmittedRef.current) {
|
|
4247
4163
|
gameEndEmittedRef.current = true;
|
|
@@ -4251,7 +4167,7 @@ function GameBoard3D({
|
|
|
4251
4167
|
gameEndEmittedRef.current = false;
|
|
4252
4168
|
}
|
|
4253
4169
|
}, [result, gameEndEvent, eventBus]);
|
|
4254
|
-
const checkGameEnd =
|
|
4170
|
+
const checkGameEnd = React10.useCallback(() => {
|
|
4255
4171
|
const alivePlayer = entityUnits.filter((u) => unitTeam(u) === "player" && unitHealth(u) > 0);
|
|
4256
4172
|
const aliveEnemy = entityUnits.filter((u) => unitTeam(u) === "enemy" && unitHealth(u) > 0);
|
|
4257
4173
|
if (alivePlayer.length === 0 && gameEndEvent) {
|
|
@@ -4260,7 +4176,7 @@ function GameBoard3D({
|
|
|
4260
4176
|
eventBus.emit(`UI:${gameEndEvent}`, { result: "victory" });
|
|
4261
4177
|
}
|
|
4262
4178
|
}, [entityUnits, gameEndEvent, eventBus]);
|
|
4263
|
-
const handleUnitClickCallback =
|
|
4179
|
+
const handleUnitClickCallback = React10.useCallback((isoUnit) => {
|
|
4264
4180
|
if (phase !== "action" || !selectedUnitId || !attackEvent) return;
|
|
4265
4181
|
const attackerRow = entityUnits.find((u) => str(u.id) === selectedUnitId);
|
|
4266
4182
|
const targetRow = entityUnits.find((u) => str(u.id) === isoUnit.id);
|
|
@@ -4280,13 +4196,13 @@ function GameBoard3D({
|
|
|
4280
4196
|
setTimeout(checkGameEnd, 100);
|
|
4281
4197
|
}
|
|
4282
4198
|
}, [phase, selectedUnitId, entityUnits, attackEvent, eventBus, checkGameEnd]);
|
|
4283
|
-
const handleEndTurn =
|
|
4199
|
+
const handleEndTurn = React10.useCallback(() => {
|
|
4284
4200
|
if (endTurnEvent) eventBus.emit(`UI:${endTurnEvent}`, {});
|
|
4285
4201
|
}, [endTurnEvent, eventBus]);
|
|
4286
|
-
const handleCancel =
|
|
4202
|
+
const handleCancel = React10.useCallback(() => {
|
|
4287
4203
|
if (cancelEvent) eventBus.emit(`UI:${cancelEvent}`, {});
|
|
4288
4204
|
}, [cancelEvent, eventBus]);
|
|
4289
|
-
const handlePlayAgain =
|
|
4205
|
+
const handlePlayAgain = React10.useCallback(() => {
|
|
4290
4206
|
if (playAgainEvent) eventBus.emit(`UI:${playAgainEvent}`, {});
|
|
4291
4207
|
}, [playAgainEvent, eventBus]);
|
|
4292
4208
|
return /* @__PURE__ */ jsxRuntime.jsxs(VStack, { className: cn("game-board-3d block w-full min-h-[85vh] relative", className), children: [
|
|
@@ -4377,24 +4293,24 @@ function GameBoard3D({
|
|
|
4377
4293
|
GameBoard3D.displayName = "GameBoard3D";
|
|
4378
4294
|
function useTapReveal(options = {}) {
|
|
4379
4295
|
const { onReveal, onDismiss, refs, enabled = true } = options;
|
|
4380
|
-
const [revealed, setRevealed] =
|
|
4381
|
-
const onRevealRef =
|
|
4382
|
-
const onDismissRef =
|
|
4296
|
+
const [revealed, setRevealed] = React10.useState(false);
|
|
4297
|
+
const onRevealRef = React10.useRef(onReveal);
|
|
4298
|
+
const onDismissRef = React10.useRef(onDismiss);
|
|
4383
4299
|
onRevealRef.current = onReveal;
|
|
4384
4300
|
onDismissRef.current = onDismiss;
|
|
4385
|
-
const reveal =
|
|
4301
|
+
const reveal = React10.useCallback(() => {
|
|
4386
4302
|
setRevealed((wasRevealed) => {
|
|
4387
4303
|
if (!wasRevealed) onRevealRef.current?.();
|
|
4388
4304
|
return true;
|
|
4389
4305
|
});
|
|
4390
4306
|
}, []);
|
|
4391
|
-
const dismiss =
|
|
4307
|
+
const dismiss = React10.useCallback(() => {
|
|
4392
4308
|
setRevealed((wasRevealed) => {
|
|
4393
4309
|
if (wasRevealed) onDismissRef.current?.();
|
|
4394
4310
|
return false;
|
|
4395
4311
|
});
|
|
4396
4312
|
}, []);
|
|
4397
|
-
const onPointerDown =
|
|
4313
|
+
const onPointerDown = React10.useCallback(
|
|
4398
4314
|
(e) => {
|
|
4399
4315
|
if (!enabled || e.pointerType === "mouse") return;
|
|
4400
4316
|
if (revealed) dismiss();
|
|
@@ -4402,7 +4318,7 @@ function useTapReveal(options = {}) {
|
|
|
4402
4318
|
},
|
|
4403
4319
|
[enabled, revealed, reveal, dismiss]
|
|
4404
4320
|
);
|
|
4405
|
-
|
|
4321
|
+
React10.useEffect(() => {
|
|
4406
4322
|
if (!revealed || typeof document === "undefined") return;
|
|
4407
4323
|
const onDocDown = (ev) => {
|
|
4408
4324
|
const target = ev.target;
|
|
@@ -4522,7 +4438,7 @@ var positionStyles = {
|
|
|
4522
4438
|
fixed: "fixed",
|
|
4523
4439
|
sticky: "sticky"
|
|
4524
4440
|
};
|
|
4525
|
-
var Box =
|
|
4441
|
+
var Box = React10__default.default.forwardRef(
|
|
4526
4442
|
({
|
|
4527
4443
|
padding,
|
|
4528
4444
|
paddingX,
|
|
@@ -4554,20 +4470,20 @@ var Box = React11__default.default.forwardRef(
|
|
|
4554
4470
|
...rest
|
|
4555
4471
|
}, ref) => {
|
|
4556
4472
|
const eventBus = useEventBus();
|
|
4557
|
-
const handleClick =
|
|
4473
|
+
const handleClick = React10.useCallback((e) => {
|
|
4558
4474
|
if (action) {
|
|
4559
4475
|
e.stopPropagation();
|
|
4560
4476
|
eventBus.emit(`UI:${action}`, actionPayload ?? {});
|
|
4561
4477
|
}
|
|
4562
4478
|
onClick?.(e);
|
|
4563
4479
|
}, [action, actionPayload, eventBus, onClick]);
|
|
4564
|
-
const handleMouseEnter =
|
|
4480
|
+
const handleMouseEnter = React10.useCallback((e) => {
|
|
4565
4481
|
if (hoverEvent) {
|
|
4566
4482
|
eventBus.emit(`UI:${hoverEvent}`, { hovered: true });
|
|
4567
4483
|
}
|
|
4568
4484
|
onMouseEnter?.(e);
|
|
4569
4485
|
}, [hoverEvent, eventBus, onMouseEnter]);
|
|
4570
|
-
const handleMouseLeave =
|
|
4486
|
+
const handleMouseLeave = React10.useCallback((e) => {
|
|
4571
4487
|
if (hoverEvent) {
|
|
4572
4488
|
eventBus.emit(`UI:${hoverEvent}`, { hovered: false });
|
|
4573
4489
|
}
|
|
@@ -4575,19 +4491,19 @@ var Box = React11__default.default.forwardRef(
|
|
|
4575
4491
|
}, [hoverEvent, eventBus, onMouseLeave]);
|
|
4576
4492
|
const { triggerProps } = useTapReveal({
|
|
4577
4493
|
enabled: tapReveal && !!hoverEvent,
|
|
4578
|
-
onReveal:
|
|
4494
|
+
onReveal: React10.useCallback(() => {
|
|
4579
4495
|
if (hoverEvent) eventBus.emit(`UI:${hoverEvent}`, { hovered: true });
|
|
4580
4496
|
}, [hoverEvent, eventBus]),
|
|
4581
|
-
onDismiss:
|
|
4497
|
+
onDismiss: React10.useCallback(() => {
|
|
4582
4498
|
if (hoverEvent) eventBus.emit(`UI:${hoverEvent}`, { hovered: false });
|
|
4583
4499
|
}, [hoverEvent, eventBus])
|
|
4584
4500
|
});
|
|
4585
|
-
const handlePointerDown =
|
|
4501
|
+
const handlePointerDown = React10.useCallback((e) => {
|
|
4586
4502
|
if (hoverEvent && tapReveal) triggerProps.onPointerDown(e);
|
|
4587
4503
|
onPointerDown?.(e);
|
|
4588
4504
|
}, [hoverEvent, tapReveal, triggerProps, onPointerDown]);
|
|
4589
4505
|
const isClickable = action || onClick;
|
|
4590
|
-
return
|
|
4506
|
+
return React10__default.default.createElement(
|
|
4591
4507
|
Component2,
|
|
4592
4508
|
{
|
|
4593
4509
|
ref,
|
|
@@ -4623,7 +4539,7 @@ var Box = React11__default.default.forwardRef(
|
|
|
4623
4539
|
);
|
|
4624
4540
|
Box.displayName = "Box";
|
|
4625
4541
|
|
|
4626
|
-
// components/game/
|
|
4542
|
+
// components/game/shared/makeAsset.ts
|
|
4627
4543
|
var ROLE_DEFAULTS = {
|
|
4628
4544
|
tile: { dimension: "2d", animations: ["static"], aspect: "1:1" },
|
|
4629
4545
|
decoration: { dimension: "2d", animations: ["static"], aspect: "1:1" },
|
|
@@ -4647,7 +4563,7 @@ function makeAsset(url, role, overrides = {}) {
|
|
|
4647
4563
|
};
|
|
4648
4564
|
}
|
|
4649
4565
|
|
|
4650
|
-
// components/game/
|
|
4566
|
+
// components/game/2d/game3dAssetManifest.ts
|
|
4651
4567
|
function tileKind(type, passable) {
|
|
4652
4568
|
if (passable === false) return "wall";
|
|
4653
4569
|
if (type === "dirt" || type === "road") return "dirt";
|
|
@@ -5827,10 +5743,10 @@ var Avl3DOrbitalNode = ({
|
|
|
5827
5743
|
position,
|
|
5828
5744
|
onClick
|
|
5829
5745
|
}) => {
|
|
5830
|
-
const groupRef =
|
|
5831
|
-
const [hovered, setHovered] =
|
|
5832
|
-
const scale =
|
|
5833
|
-
const currentScale =
|
|
5746
|
+
const groupRef = React10.useRef(null);
|
|
5747
|
+
const [hovered, setHovered] = React10.useState(false);
|
|
5748
|
+
const scale = React10.useMemo(() => 0.6 + Math.min(traitCount, 8) * 0.3, [traitCount]);
|
|
5749
|
+
const currentScale = React10.useRef(scale);
|
|
5834
5750
|
const targetScale = hovered ? scale * 1.06 : scale;
|
|
5835
5751
|
fiber.useFrame((_, delta) => {
|
|
5836
5752
|
if (!groupRef.current) return;
|
|
@@ -5972,7 +5888,7 @@ var Avl3DCrossWire = ({
|
|
|
5972
5888
|
eventName,
|
|
5973
5889
|
color = AVL_3D_COLORS.crossWire
|
|
5974
5890
|
}) => {
|
|
5975
|
-
const { tubeArgs, midpoint } =
|
|
5891
|
+
const { tubeArgs, midpoint } = React10.useMemo(() => {
|
|
5976
5892
|
const curve = arcCurve3D(from, to, 2);
|
|
5977
5893
|
const mid = curve.getPoint(0.5);
|
|
5978
5894
|
return {
|
|
@@ -6011,9 +5927,9 @@ var Avl3DApplicationScene = ({
|
|
|
6011
5927
|
data,
|
|
6012
5928
|
onOrbitalClick
|
|
6013
5929
|
}) => {
|
|
6014
|
-
const groupRef =
|
|
6015
|
-
const [, setHoverTrigger] =
|
|
6016
|
-
const orbitalPositions =
|
|
5930
|
+
const groupRef = React10.useRef(null);
|
|
5931
|
+
const [, setHoverTrigger] = React10.useState(0);
|
|
5932
|
+
const orbitalPositions = React10.useMemo(() => {
|
|
6017
5933
|
const baseRadius = Math.max(4, data.orbitals.length * 1.5);
|
|
6018
5934
|
if (data.crossLinks.length === 0) {
|
|
6019
5935
|
return goldenSpiralPositions(data.orbitals.length, baseRadius);
|
|
@@ -6026,7 +5942,7 @@ var Avl3DApplicationScene = ({
|
|
|
6026
5942
|
})).filter((e) => e.from >= 0 && e.to >= 0);
|
|
6027
5943
|
return forceDirectedPositions(data.orbitals.length, edges, baseRadius);
|
|
6028
5944
|
}, [data.orbitals, data.crossLinks]);
|
|
6029
|
-
const positionByName =
|
|
5945
|
+
const positionByName = React10.useMemo(() => {
|
|
6030
5946
|
const map = /* @__PURE__ */ new Map();
|
|
6031
5947
|
data.orbitals.forEach((orb, i) => {
|
|
6032
5948
|
const pos = orbitalPositions[i];
|
|
@@ -6109,7 +6025,7 @@ var Avl3DEntityCore = ({
|
|
|
6109
6025
|
position,
|
|
6110
6026
|
fields
|
|
6111
6027
|
}) => {
|
|
6112
|
-
const coreRef =
|
|
6028
|
+
const coreRef = React10.useRef(null);
|
|
6113
6029
|
fiber.useFrame((_, delta) => {
|
|
6114
6030
|
if (!coreRef.current) return;
|
|
6115
6031
|
coreRef.current.rotation.y += delta * 0.3;
|
|
@@ -6262,8 +6178,8 @@ function TraitOrbit({
|
|
|
6262
6178
|
onClick,
|
|
6263
6179
|
onHover
|
|
6264
6180
|
}) {
|
|
6265
|
-
const groupRef =
|
|
6266
|
-
const angleRef =
|
|
6181
|
+
const groupRef = React10.useRef(null);
|
|
6182
|
+
const angleRef = React10.useRef(Math.random() * Math.PI * 2);
|
|
6267
6183
|
fiber.useFrame((_, delta) => {
|
|
6268
6184
|
angleRef.current += delta * speed;
|
|
6269
6185
|
if (!groupRef.current) return;
|
|
@@ -6394,9 +6310,9 @@ var Avl3DOrbitalScene = ({
|
|
|
6394
6310
|
highlightedTrait,
|
|
6395
6311
|
onTraitHighlight
|
|
6396
6312
|
}) => {
|
|
6397
|
-
const [localHighlight, setLocalHighlight] =
|
|
6313
|
+
const [localHighlight, setLocalHighlight] = React10.useState(null);
|
|
6398
6314
|
const activeHighlight = highlightedTrait ?? localHighlight;
|
|
6399
|
-
const traitOrbits =
|
|
6315
|
+
const traitOrbits = React10.useMemo(() => {
|
|
6400
6316
|
return data.traits.map((trait, i) => ({
|
|
6401
6317
|
name: trait.name,
|
|
6402
6318
|
radius: 3 + i * 1.2,
|
|
@@ -6407,7 +6323,7 @@ var Avl3DOrbitalScene = ({
|
|
|
6407
6323
|
transitionCount: trait.transitionCount
|
|
6408
6324
|
}));
|
|
6409
6325
|
}, [data.traits]);
|
|
6410
|
-
const pagePositions =
|
|
6326
|
+
const pagePositions = React10.useMemo(() => {
|
|
6411
6327
|
const outerRadius = 3 + data.traits.length * 1.2 + 1.5;
|
|
6412
6328
|
return data.pages.map((_, i) => {
|
|
6413
6329
|
const angle = 2 * Math.PI * i / data.pages.length - Math.PI / 2;
|
|
@@ -6471,12 +6387,12 @@ var Avl3DStateNode = ({
|
|
|
6471
6387
|
outgoingCount = 0,
|
|
6472
6388
|
onClick
|
|
6473
6389
|
}) => {
|
|
6474
|
-
const [hovered, setHovered] =
|
|
6390
|
+
const [hovered, setHovered] = React10.useState(false);
|
|
6475
6391
|
const baseColor = active ? AVL_3D_COLORS.stateActive : AVL_3D_COLORS.stateIdle;
|
|
6476
6392
|
const emissiveColor = active ? AVL_3D_COLORS.stateActive : AVL_3D_COLORS.stateEdge;
|
|
6477
6393
|
const emissiveIntensity = active ? 2 : hovered ? 0.8 : 0.3;
|
|
6478
6394
|
const targetScale = hovered ? 1.08 : 1;
|
|
6479
|
-
const currentScale =
|
|
6395
|
+
const currentScale = React10.useRef(1);
|
|
6480
6396
|
fiber.useFrame((_, delta) => {
|
|
6481
6397
|
currentScale.current = THREE6.MathUtils.damp(currentScale.current, targetScale, 6, delta);
|
|
6482
6398
|
});
|
|
@@ -6650,8 +6566,8 @@ var Avl3DTransitionArc = ({
|
|
|
6650
6566
|
onClick,
|
|
6651
6567
|
color = AVL_3D_COLORS.transitionArc
|
|
6652
6568
|
}) => {
|
|
6653
|
-
const [hovered, setHovered] =
|
|
6654
|
-
const { tubeArgs, labelPos, guardPos, arrowPos, arrowQuat, effectPositions } =
|
|
6569
|
+
const [hovered, setHovered] = React10.useState(false);
|
|
6570
|
+
const { tubeArgs, labelPos, guardPos, arrowPos, arrowQuat, effectPositions } = React10.useMemo(() => {
|
|
6655
6571
|
const offset = 1.5 + index * 0.8;
|
|
6656
6572
|
const curve = isSelf ? selfLoopCurve3D(from, 1.2) : arcCurve3D(from, to, offset);
|
|
6657
6573
|
const mid = curve.getPoint(0.5);
|
|
@@ -6784,7 +6700,7 @@ var Avl3DTraitScene = ({
|
|
|
6784
6700
|
data,
|
|
6785
6701
|
onTransitionClick
|
|
6786
6702
|
}) => {
|
|
6787
|
-
const statePositions =
|
|
6703
|
+
const statePositions = React10.useMemo(() => {
|
|
6788
6704
|
const radius = Math.max(3, data.states.length * 0.8);
|
|
6789
6705
|
const positions = fibonacciSpherePositions(data.states.length, radius);
|
|
6790
6706
|
const posMap = /* @__PURE__ */ new Map();
|
|
@@ -6794,7 +6710,7 @@ var Avl3DTraitScene = ({
|
|
|
6794
6710
|
});
|
|
6795
6711
|
return posMap;
|
|
6796
6712
|
}, [data.states]);
|
|
6797
|
-
const transitionIndices =
|
|
6713
|
+
const transitionIndices = React10.useMemo(() => {
|
|
6798
6714
|
const pairCount = /* @__PURE__ */ new Map();
|
|
6799
6715
|
return data.transitions.map((t) => {
|
|
6800
6716
|
const key = `${t.from}->${t.to}`;
|
|
@@ -6803,7 +6719,7 @@ var Avl3DTraitScene = ({
|
|
|
6803
6719
|
return idx;
|
|
6804
6720
|
});
|
|
6805
6721
|
}, [data.transitions]);
|
|
6806
|
-
const transitionCounts =
|
|
6722
|
+
const transitionCounts = React10.useMemo(() => {
|
|
6807
6723
|
const incoming = /* @__PURE__ */ new Map();
|
|
6808
6724
|
const outgoing = /* @__PURE__ */ new Map();
|
|
6809
6725
|
for (const t of data.transitions) {
|
|
@@ -6913,11 +6829,11 @@ var Avl3DExprTree = ({
|
|
|
6913
6829
|
expression,
|
|
6914
6830
|
position
|
|
6915
6831
|
}) => {
|
|
6916
|
-
const layoutResults =
|
|
6832
|
+
const layoutResults = React10.useMemo(() => {
|
|
6917
6833
|
const origin = { x: position[0], y: position[1], z: position[2] };
|
|
6918
6834
|
return treeLayout3D(expression, origin, 2.5, 1.5);
|
|
6919
6835
|
}, [expression, position]);
|
|
6920
|
-
const edges =
|
|
6836
|
+
const edges = React10.useMemo(() => {
|
|
6921
6837
|
const result = [];
|
|
6922
6838
|
function collectEdges(node, parentPos) {
|
|
6923
6839
|
const entry = layoutResults.find((r) => r.node === node);
|
|
@@ -7197,7 +7113,7 @@ var Avl3DEffects = ({
|
|
|
7197
7113
|
const dof = DOF_CONFIG[level];
|
|
7198
7114
|
const sparkles = SPARKLE_CONFIGS[level];
|
|
7199
7115
|
const stars = STARS_CONFIG[level];
|
|
7200
|
-
const starsKey =
|
|
7116
|
+
const starsKey = React10.useMemo(() => `stars-${level}`, [level]);
|
|
7201
7117
|
return /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
|
|
7202
7118
|
/* @__PURE__ */ jsxRuntime.jsx(
|
|
7203
7119
|
drei.Stars,
|
|
@@ -7261,16 +7177,16 @@ var DEFAULT_CONFIG2 = {
|
|
|
7261
7177
|
modelOverrides: {},
|
|
7262
7178
|
effectsEnabled: true
|
|
7263
7179
|
};
|
|
7264
|
-
var Avl3DContext =
|
|
7180
|
+
var Avl3DContext = React10.createContext(DEFAULT_CONFIG2);
|
|
7265
7181
|
function useAvl3DConfig() {
|
|
7266
|
-
return
|
|
7182
|
+
return React10.useContext(Avl3DContext);
|
|
7267
7183
|
}
|
|
7268
7184
|
function CameraController2({ targetPosition, targetLookAt, animated }) {
|
|
7269
7185
|
const { camera } = fiber.useThree();
|
|
7270
|
-
const targetPosVec =
|
|
7271
|
-
const targetLookVec =
|
|
7272
|
-
const isAnimating =
|
|
7273
|
-
|
|
7186
|
+
const targetPosVec = React10.useRef(new THREE6__namespace.Vector3(...targetPosition));
|
|
7187
|
+
const targetLookVec = React10.useRef(new THREE6__namespace.Vector3(...targetLookAt));
|
|
7188
|
+
const isAnimating = React10.useRef(false);
|
|
7189
|
+
React10.useEffect(() => {
|
|
7274
7190
|
const newTarget = new THREE6__namespace.Vector3(...targetPosition);
|
|
7275
7191
|
const newLookAt = new THREE6__namespace.Vector3(...targetLookAt);
|
|
7276
7192
|
if (!newTarget.equals(targetPosVec.current) || !newLookAt.equals(targetLookVec.current)) {
|
|
@@ -7299,8 +7215,8 @@ function CameraController2({ targetPosition, targetLookAt, animated }) {
|
|
|
7299
7215
|
return null;
|
|
7300
7216
|
}
|
|
7301
7217
|
function SceneFade({ animating, children }) {
|
|
7302
|
-
const groupRef =
|
|
7303
|
-
const opacityRef =
|
|
7218
|
+
const groupRef = React10.useRef(null);
|
|
7219
|
+
const opacityRef = React10.useRef(1);
|
|
7304
7220
|
fiber.useFrame((_, delta) => {
|
|
7305
7221
|
if (!groupRef.current) return;
|
|
7306
7222
|
const target = animating ? 0 : 1;
|
|
@@ -7324,7 +7240,7 @@ var Avl3DViewer = ({
|
|
|
7324
7240
|
modelOverrides = {}
|
|
7325
7241
|
}) => {
|
|
7326
7242
|
const { t } = hooks.useTranslate();
|
|
7327
|
-
const schema =
|
|
7243
|
+
const schema = React10.useMemo(() => {
|
|
7328
7244
|
if (typeof schemaProp === "string") {
|
|
7329
7245
|
try {
|
|
7330
7246
|
return JSON.parse(schemaProp);
|
|
@@ -7334,12 +7250,12 @@ var Avl3DViewer = ({
|
|
|
7334
7250
|
}
|
|
7335
7251
|
return schemaProp;
|
|
7336
7252
|
}, [schemaProp]);
|
|
7337
|
-
const configValue =
|
|
7253
|
+
const configValue = React10.useMemo(() => ({
|
|
7338
7254
|
modelOverrides,
|
|
7339
7255
|
effectsEnabled: effects
|
|
7340
7256
|
}), [modelOverrides, effects]);
|
|
7341
|
-
const [state, dispatch] =
|
|
7342
|
-
|
|
7257
|
+
const [state, dispatch] = React10.useReducer(zoomReducer, initialZoomState);
|
|
7258
|
+
React10.useEffect(() => {
|
|
7343
7259
|
if (initialOrbital) {
|
|
7344
7260
|
dispatch({ type: "ZOOM_INTO_ORBITAL", orbital: initialOrbital, targetPosition: { x: 0, y: 0 } });
|
|
7345
7261
|
setTimeout(() => dispatch({ type: "ANIMATION_COMPLETE" }), 0);
|
|
@@ -7351,35 +7267,35 @@ var Avl3DViewer = ({
|
|
|
7351
7267
|
}
|
|
7352
7268
|
}
|
|
7353
7269
|
}, [initialOrbital, initialTrait]);
|
|
7354
|
-
|
|
7270
|
+
React10.useEffect(() => {
|
|
7355
7271
|
onZoomChange?.(state.level, {
|
|
7356
7272
|
orbital: state.selectedOrbital ?? void 0,
|
|
7357
7273
|
trait: state.selectedTrait ?? void 0
|
|
7358
7274
|
});
|
|
7359
7275
|
}, [state.level, state.selectedOrbital, state.selectedTrait, onZoomChange]);
|
|
7360
|
-
|
|
7276
|
+
React10.useEffect(() => {
|
|
7361
7277
|
if (!state.animating) return;
|
|
7362
7278
|
const timer = setTimeout(() => {
|
|
7363
7279
|
dispatch({ type: "ANIMATION_COMPLETE" });
|
|
7364
7280
|
}, 800);
|
|
7365
7281
|
return () => clearTimeout(timer);
|
|
7366
7282
|
}, [state.animating]);
|
|
7367
|
-
const handleKeyDown =
|
|
7283
|
+
const handleKeyDown = React10.useCallback((e) => {
|
|
7368
7284
|
if (e.key === "Escape") {
|
|
7369
7285
|
dispatch({ type: "ZOOM_OUT" });
|
|
7370
7286
|
}
|
|
7371
7287
|
}, []);
|
|
7372
|
-
const handleOrbitalClick =
|
|
7288
|
+
const handleOrbitalClick = React10.useCallback((name) => {
|
|
7373
7289
|
dispatch({ type: "ZOOM_INTO_ORBITAL", orbital: name, targetPosition: { x: 0, y: 0 } });
|
|
7374
7290
|
}, []);
|
|
7375
|
-
const handleTraitClick =
|
|
7291
|
+
const handleTraitClick = React10.useCallback((name) => {
|
|
7376
7292
|
dispatch({ type: "ZOOM_INTO_TRAIT", trait: name, targetPosition: { x: 0, y: 0 } });
|
|
7377
7293
|
}, []);
|
|
7378
|
-
const [highlightedTrait, setHighlightedTrait] =
|
|
7379
|
-
const handleTransitionClick =
|
|
7294
|
+
const [highlightedTrait, setHighlightedTrait] = React10__default.default.useState(null);
|
|
7295
|
+
const handleTransitionClick = React10.useCallback((index) => {
|
|
7380
7296
|
dispatch({ type: "ZOOM_INTO_TRANSITION", transitionIndex: index, targetPosition: { x: 0, y: 0 } });
|
|
7381
7297
|
}, []);
|
|
7382
|
-
const handleBreadcrumbClick =
|
|
7298
|
+
const handleBreadcrumbClick = React10.useCallback((targetLevel) => {
|
|
7383
7299
|
const levelOrder = ["application", "orbital", "trait", "transition"];
|
|
7384
7300
|
const currentIdx = levelOrder.indexOf(state.level);
|
|
7385
7301
|
const targetIdx = levelOrder.indexOf(targetLevel);
|
|
@@ -7388,7 +7304,7 @@ var Avl3DViewer = ({
|
|
|
7388
7304
|
}
|
|
7389
7305
|
}, [state.level]);
|
|
7390
7306
|
const cameraConfig = CAMERA_POSITIONS[state.level];
|
|
7391
|
-
const sceneContent =
|
|
7307
|
+
const sceneContent = React10.useMemo(() => {
|
|
7392
7308
|
switch (state.level) {
|
|
7393
7309
|
case "application": {
|
|
7394
7310
|
const data = parseApplicationLevel(schema);
|
|
@@ -7462,7 +7378,7 @@ var Avl3DViewer = ({
|
|
|
7462
7378
|
gap: "xs",
|
|
7463
7379
|
align: "center",
|
|
7464
7380
|
className: "absolute top-2 left-2 z-10 bg-surface/80 backdrop-blur rounded-md px-3 py-1.5",
|
|
7465
|
-
children: breadcrumbs.map((crumb, i) => /* @__PURE__ */ jsxRuntime.jsxs(
|
|
7381
|
+
children: breadcrumbs.map((crumb, i) => /* @__PURE__ */ jsxRuntime.jsxs(React10__default.default.Fragment, { children: [
|
|
7466
7382
|
i > 0 && /* @__PURE__ */ jsxRuntime.jsx(Typography, { variant: "small", color: "muted", className: "mx-1", children: "/" }),
|
|
7467
7383
|
i < breadcrumbs.length - 1 ? /* @__PURE__ */ jsxRuntime.jsx(
|
|
7468
7384
|
Box,
|
|
@@ -7749,6 +7665,7 @@ exports.Avl3DTransitionScene = Avl3DTransitionScene;
|
|
|
7749
7665
|
exports.Avl3DViewer = Avl3DViewer;
|
|
7750
7666
|
exports.CAMERA_POSITIONS = CAMERA_POSITIONS;
|
|
7751
7667
|
exports.Camera3D = Camera3D;
|
|
7668
|
+
exports.Canvas3D = Canvas3D;
|
|
7752
7669
|
exports.Canvas3DErrorBoundary = Canvas3DErrorBoundary;
|
|
7753
7670
|
exports.Canvas3DLoadingState = Canvas3DLoadingState;
|
|
7754
7671
|
exports.FeatureRenderer = FeatureRenderer;
|