project organization
This commit is contained in:
@@ -39,6 +39,12 @@
|
|||||||
"packages/core": {
|
"packages/core": {
|
||||||
"name": "@pascal-app/core",
|
"name": "@pascal-app/core",
|
||||||
"version": "0.0.1",
|
"version": "0.0.1",
|
||||||
|
"dependencies": {
|
||||||
|
"dedent": "^1.7.1",
|
||||||
|
"nanoid": "^5.1.6",
|
||||||
|
"zod": "^4.3.5",
|
||||||
|
"zustand": "^5.0.10",
|
||||||
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"@react-three/drei": "^10",
|
"@react-three/drei": "^10",
|
||||||
"@react-three/fiber": "^9",
|
"@react-three/fiber": "^9",
|
||||||
@@ -457,6 +463,8 @@
|
|||||||
|
|
||||||
"debug": ["debug@4.4.3", "", { "dependencies": { "ms": "^2.1.3" } }, "sha512-RGwwWnwQvkVfavKVt22FGLw+xYSdzARwm0ru6DhTVA3umU5hZc28V3kO4stgYryrTlLpuvgI9GiijltAjNbcqA=="],
|
"debug": ["debug@4.4.3", "", { "dependencies": { "ms": "^2.1.3" } }, "sha512-RGwwWnwQvkVfavKVt22FGLw+xYSdzARwm0ru6DhTVA3umU5hZc28V3kO4stgYryrTlLpuvgI9GiijltAjNbcqA=="],
|
||||||
|
|
||||||
|
"dedent": ["dedent@1.7.1", "", { "peerDependencies": { "babel-plugin-macros": "^3.1.0" }, "optionalPeers": ["babel-plugin-macros"] }, "sha512-9JmrhGZpOlEgOLdQgSm0zxFaYoQon408V1v49aqTWuXENVlnCuY9JBZcXZiCsZQWDjTm5Qf/nIvAy77mXDAjEg=="],
|
||||||
|
|
||||||
"deep-is": ["deep-is@0.1.4", "", {}, "sha512-oIPzksmTg4/MriiaYGO+okXDT7ztn/w3Eptv/+gSIdMdKsJo0u4CfYNFJPy+4SKMuCqGw2wxnA+URMg3t8a/bQ=="],
|
"deep-is": ["deep-is@0.1.4", "", {}, "sha512-oIPzksmTg4/MriiaYGO+okXDT7ztn/w3Eptv/+gSIdMdKsJo0u4CfYNFJPy+4SKMuCqGw2wxnA+URMg3t8a/bQ=="],
|
||||||
|
|
||||||
"deepmerge": ["deepmerge@4.3.1", "", {}, "sha512-3sUqbMEc77XqpdNO7FRyRog+eW3ph+GYCbj+rK+uYyRMuwsVy0rMiVtPn+QJlKFvWP/1PYpapqYn0Me2knFn+A=="],
|
"deepmerge": ["deepmerge@4.3.1", "", {}, "sha512-3sUqbMEc77XqpdNO7FRyRog+eW3ph+GYCbj+rK+uYyRMuwsVy0rMiVtPn+QJlKFvWP/1PYpapqYn0Me2knFn+A=="],
|
||||||
@@ -741,7 +749,7 @@
|
|||||||
|
|
||||||
"ms": ["ms@2.1.3", "", {}, "sha512-6FlzubTLZG3J2a/NVCAleEhjzq5oxgHyaCU9yYXvcLsvoVaHJq/s5xXI6/XXP6tz7R9xAOtHnSO/tXtF3WRTlA=="],
|
"ms": ["ms@2.1.3", "", {}, "sha512-6FlzubTLZG3J2a/NVCAleEhjzq5oxgHyaCU9yYXvcLsvoVaHJq/s5xXI6/XXP6tz7R9xAOtHnSO/tXtF3WRTlA=="],
|
||||||
|
|
||||||
"nanoid": ["nanoid@3.3.11", "", { "bin": { "nanoid": "bin/nanoid.cjs" } }, "sha512-N8SpfPUnUp1bK+PMYW8qSWdl9U+wwNWI4QKxOYDy9JAro3WMX7p2OeVRF9v+347pnakNevPmiHhNmZ2HbFA76w=="],
|
"nanoid": ["nanoid@5.1.6", "", { "bin": { "nanoid": "bin/nanoid.js" } }, "sha512-c7+7RQ+dMB5dPwwCp4ee1/iV/q2P6aK1mTZcfr1BTuVlyW9hJYiMPybJCcnBlQtuSmTIWNeazm/zqNoZSSElBg=="],
|
||||||
|
|
||||||
"natural-compare": ["natural-compare@1.4.0", "", {}, "sha512-OWND8ei3VtNC9h7V60qff3SVobHr996CTwgxubgyQYEpg290h9J0buyECNNJexkFm5sOajh5G116RYA1c8ZMSw=="],
|
"natural-compare": ["natural-compare@1.4.0", "", {}, "sha512-OWND8ei3VtNC9h7V60qff3SVobHr996CTwgxubgyQYEpg290h9J0buyECNNJexkFm5sOajh5G116RYA1c8ZMSw=="],
|
||||||
|
|
||||||
@@ -1011,6 +1019,8 @@
|
|||||||
|
|
||||||
"next/postcss": ["postcss@8.4.31", "", { "dependencies": { "nanoid": "^3.3.6", "picocolors": "^1.0.0", "source-map-js": "^1.0.2" } }, "sha512-PS08Iboia9mts/2ygV3eLpY5ghnUcfLV/EXTOW1E2qYxJKGGBUtNjN76FYHnMs36RmARn41bC0AZmn+rR0OVpQ=="],
|
"next/postcss": ["postcss@8.4.31", "", { "dependencies": { "nanoid": "^3.3.6", "picocolors": "^1.0.0", "source-map-js": "^1.0.2" } }, "sha512-PS08Iboia9mts/2ygV3eLpY5ghnUcfLV/EXTOW1E2qYxJKGGBUtNjN76FYHnMs36RmARn41bC0AZmn+rR0OVpQ=="],
|
||||||
|
|
||||||
|
"postcss/nanoid": ["nanoid@3.3.11", "", { "bin": { "nanoid": "bin/nanoid.cjs" } }, "sha512-N8SpfPUnUp1bK+PMYW8qSWdl9U+wwNWI4QKxOYDy9JAro3WMX7p2OeVRF9v+347pnakNevPmiHhNmZ2HbFA76w=="],
|
||||||
|
|
||||||
"sharp/semver": ["semver@7.7.3", "", { "bin": { "semver": "bin/semver.js" } }, "sha512-SdsKMrI9TdgjdweUSR9MweHA4EJ8YxHn8DFaDisvhVlUOe4BF1tLD7GAj0lIqWVl+dPb/rExr0Btby5loQm20Q=="],
|
"sharp/semver": ["semver@7.7.3", "", { "bin": { "semver": "bin/semver.js" } }, "sha512-SdsKMrI9TdgjdweUSR9MweHA4EJ8YxHn8DFaDisvhVlUOe4BF1tLD7GAj0lIqWVl+dPb/rExr0Btby5loQm20Q=="],
|
||||||
|
|
||||||
"stats-gl/three": ["three@0.170.0", "", {}, "sha512-FQK+LEpYc0fBD+J8g6oSEyyNzjp+Q7Ks1C568WWaoMRLW+TkNNWmenWeGgJjV105Gd+p/2ql1ZcjYvNiPZBhuQ=="],
|
"stats-gl/three": ["three@0.170.0", "", {}, "sha512-FQK+LEpYc0fBD+J8g6oSEyyNzjp+Q7Ks1C568WWaoMRLW+TkNNWmenWeGgJjV105Gd+p/2ql1ZcjYvNiPZBhuQ=="],
|
||||||
@@ -1024,5 +1034,7 @@
|
|||||||
"web/three": ["three@0.182.0", "", {}, "sha512-GbHabT+Irv+ihI1/f5kIIsZ+Ef9Sl5A1Y7imvS5RQjWgtTPfPnZ43JmlYI7NtCRDK9zir20lQpfg8/9Yd02OvQ=="],
|
"web/three": ["three@0.182.0", "", {}, "sha512-GbHabT+Irv+ihI1/f5kIIsZ+Ef9Sl5A1Y7imvS5RQjWgtTPfPnZ43JmlYI7NtCRDK9zir20lQpfg8/9Yd02OvQ=="],
|
||||||
|
|
||||||
"@typescript-eslint/typescript-estree/minimatch/brace-expansion": ["brace-expansion@2.0.2", "", { "dependencies": { "balanced-match": "^1.0.0" } }, "sha512-Jt0vHyM+jmUBqojB7E1NIYadt0vI0Qxjxd2TErW94wDz+E2LAm5vKMXXwg6ZZBTHPuUlDgQHKXvjGBdfcF1ZDQ=="],
|
"@typescript-eslint/typescript-estree/minimatch/brace-expansion": ["brace-expansion@2.0.2", "", { "dependencies": { "balanced-match": "^1.0.0" } }, "sha512-Jt0vHyM+jmUBqojB7E1NIYadt0vI0Qxjxd2TErW94wDz+E2LAm5vKMXXwg6ZZBTHPuUlDgQHKXvjGBdfcF1ZDQ=="],
|
||||||
|
|
||||||
|
"next/postcss/nanoid": ["nanoid@3.3.11", "", { "bin": { "nanoid": "bin/nanoid.cjs" } }, "sha512-N8SpfPUnUp1bK+PMYW8qSWdl9U+wwNWI4QKxOYDy9JAro3WMX7p2OeVRF9v+347pnakNevPmiHhNmZ2HbFA76w=="],
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1 +1,5 @@
|
|||||||
export {}
|
// Store
|
||||||
|
export { default as useScene } from "./store/useScene"
|
||||||
|
|
||||||
|
// Schema
|
||||||
|
export * from "./schema"
|
||||||
|
|||||||
@@ -0,0 +1,16 @@
|
|||||||
|
// Base
|
||||||
|
export { BaseNode, generateId, objectId, nodeType, Material } from "./base"
|
||||||
|
|
||||||
|
// Nodes
|
||||||
|
export { SiteNode } from "./nodes/site"
|
||||||
|
export { BuildingNode } from "./nodes/building"
|
||||||
|
export { LevelNode } from "./nodes/level"
|
||||||
|
export { WallNode } from "./nodes/wall"
|
||||||
|
export { ItemNode } from "./nodes/item"
|
||||||
|
|
||||||
|
// Union types
|
||||||
|
export { AnyNode } from "./types"
|
||||||
|
export type { AnyNodeType, AnyNodeId } from "./types"
|
||||||
|
|
||||||
|
// Camera
|
||||||
|
export { CameraSchema } from "./camera"
|
||||||
@@ -6,7 +6,7 @@ import { WallNode } from "./wall";
|
|||||||
export const LevelNode = BaseNode.extend({
|
export const LevelNode = BaseNode.extend({
|
||||||
id: objectId("level"),
|
id: objectId("level"),
|
||||||
type: nodeType("level"),
|
type: nodeType("level"),
|
||||||
children: z.array(z.discriminatedUnion("type", [WallNode])).default([]),
|
children: z.array(WallNode.shape.id).default([]),
|
||||||
// Specific props
|
// Specific props
|
||||||
level: z.number().default(0),
|
level: z.number().default(0),
|
||||||
}).describe(
|
}).describe(
|
||||||
|
|||||||
@@ -1,5 +1,6 @@
|
|||||||
|
"use client";
|
||||||
|
|
||||||
import { create } from "zustand";
|
import { create } from "zustand";
|
||||||
import { ItemNode } from "../schema/nodes/item";
|
|
||||||
import { LevelNode } from "../schema/nodes/level";
|
import { LevelNode } from "../schema/nodes/level";
|
||||||
import { WallNode } from "../schema/nodes/wall";
|
import { WallNode } from "../schema/nodes/wall";
|
||||||
import { AnyNode, AnyNodeId } from "../schema/types";
|
import { AnyNode, AnyNodeId } from "../schema/types";
|
||||||
@@ -75,79 +76,30 @@ const useScene = create<SceneState>()((set, get) => ({
|
|||||||
|
|
||||||
// Define all nodes flat
|
// Define all nodes flat
|
||||||
const nodes: Record<AnyNodeId, AnyNode> = {
|
const nodes: Record<AnyNodeId, AnyNode> = {
|
||||||
// Level 0
|
[level0.id]: level0,
|
||||||
|
[level1.id]: level1,
|
||||||
wall_0_0: WallNode.parse({
|
[level2.id]: level2,
|
||||||
id: "wall_0_0",
|
[wall0.id]: wall0,
|
||||||
start: [0, 0],
|
[wall1.id]: wall1,
|
||||||
end: [5, 0],
|
[wall2.id]: wall2,
|
||||||
children: ["item_1_1", "item_1_2", "item_1_3"],
|
[wall3.id]: wall3,
|
||||||
}),
|
|
||||||
wall_0_1: WallNode.parse({
|
|
||||||
id: "wall_0_1",
|
|
||||||
start: [0, 0],
|
|
||||||
end: [0, 5],
|
|
||||||
}),
|
|
||||||
wall_0_2: WallNode.parse({
|
|
||||||
id: "wall_0_2",
|
|
||||||
start: [5, 5],
|
|
||||||
end: [0, 5],
|
|
||||||
}),
|
|
||||||
wall_0_3: WallNode.parse({
|
|
||||||
id: "wall_0_3",
|
|
||||||
start: [5, 5],
|
|
||||||
end: [5, 0],
|
|
||||||
}),
|
|
||||||
|
|
||||||
// Level 1
|
|
||||||
level_1: LevelNode.parse({
|
|
||||||
id: "level_1",
|
|
||||||
level: 1,
|
|
||||||
children: ["item_1_0"],
|
|
||||||
}),
|
|
||||||
item_1_0: ItemNode.parse({
|
|
||||||
id: "item_1_0",
|
|
||||||
position: [-1, 0, 0],
|
|
||||||
}),
|
|
||||||
item_1_1: ItemNode.parse({
|
|
||||||
id: "item_1_1",
|
|
||||||
parentId: "wall_0_0",
|
|
||||||
position: [2.5, 0.8, 0],
|
|
||||||
}),
|
|
||||||
item_1_2: ItemNode.parse({
|
|
||||||
id: "item_1_2",
|
|
||||||
parentId: "wall_0_0",
|
|
||||||
position: [1, 0.8, 0],
|
|
||||||
}),
|
|
||||||
item_1_3: ItemNode.parse({
|
|
||||||
id: "item_1_3",
|
|
||||||
parentId: "wall_0_0",
|
|
||||||
position: [4, 0.8, 0],
|
|
||||||
}),
|
|
||||||
|
|
||||||
// Level 2
|
|
||||||
level_2: LevelNode.parse({
|
|
||||||
id: "level_2",
|
|
||||||
level: 2,
|
|
||||||
children: [],
|
|
||||||
}),
|
|
||||||
};
|
};
|
||||||
|
|
||||||
// Root nodes are the levels
|
// Root nodes are the levels
|
||||||
const rootNodeIds = ["level_0", "level_1", "level_2"];
|
const rootNodeIds = [level0.id, level1.id, level2.id];
|
||||||
|
|
||||||
get().dirtyNodes.add("wall_0_0");
|
get().dirtyNodes.add(wall0.id);
|
||||||
get().dirtyNodes.add("wall_0_1");
|
get().dirtyNodes.add(wall1.id);
|
||||||
get().dirtyNodes.add("wall_0_2");
|
get().dirtyNodes.add(wall2.id);
|
||||||
get().dirtyNodes.add("wall_0_3");
|
get().dirtyNodes.add(wall3.id);
|
||||||
set({ nodes, rootNodeIds });
|
set({ nodes, rootNodeIds });
|
||||||
},
|
},
|
||||||
|
|
||||||
markDirty: (id: string) => {
|
markDirty: (id) => {
|
||||||
get().dirtyNodes.add(id);
|
get().dirtyNodes.add(id);
|
||||||
},
|
},
|
||||||
|
|
||||||
clearDirty: (id: string) => {
|
clearDirty: (id) => {
|
||||||
get().dirtyNodes.delete(id);
|
get().dirtyNodes.delete(id);
|
||||||
},
|
},
|
||||||
|
|
||||||
|
|||||||
@@ -2,6 +2,8 @@
|
|||||||
"$schema": "https://json.schemastore.org/tsconfig",
|
"$schema": "https://json.schemastore.org/tsconfig",
|
||||||
"extends": "./base.json",
|
"extends": "./base.json",
|
||||||
"compilerOptions": {
|
"compilerOptions": {
|
||||||
"jsx": "react-jsx"
|
"jsx": "react-jsx",
|
||||||
|
"module": "ESNext",
|
||||||
|
"moduleResolution": "Bundler"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user