fix extra rebuild

This commit is contained in:
wass08
2026-02-10 14:07:56 +09:00
parent 80cb039f86
commit b4375792ab
7 changed files with 28 additions and 8 deletions
+1 -1
View File
@@ -28,7 +28,7 @@ export default function Editor() {
<ActionMenu /> <ActionMenu />
<PanelManager /> <PanelManager />
<SidebarProvider className="fixed z-100"> <SidebarProvider className="fixed z-20">
<AppSidebar /> <AppSidebar />
</SidebarProvider> </SidebarProvider>
<Viewer selectionManager="custom"> <Viewer selectionManager="custom">
@@ -29,7 +29,9 @@ export function ItemPanel() {
// Mark parent wall as dirty if item is attached to wall // Mark parent wall as dirty if item is attached to wall
if (node.asset.attachTo === 'wall' && node.parentId) { if (node.asset.attachTo === 'wall' && node.parentId) {
requestAnimationFrame(() => {
useScene.getState().dirtyNodes.add(node.parentId as AnyNode['id']) useScene.getState().dirtyNodes.add(node.parentId as AnyNode['id'])
})
} }
}, },
[selectedId, node, updateNode], [selectedId, node, updateNode],
@@ -64,9 +64,14 @@ export function NumberInput({
const deltaValue = deltaX * step const deltaValue = deltaX * step
const newValue = clamp(startValueRef.current + deltaValue) const newValue = clamp(startValueRef.current + deltaValue)
finalValue = Number.parseFloat(newValue.toFixed(precision)) const newFinalValue = Number.parseFloat(newValue.toFixed(precision))
// Only call onChange if value actually changed (avoid extra processing on tiny moves)
if (newFinalValue !== finalValue) {
finalValue = newFinalValue
onChange(finalValue) onChange(finalValue)
} }
}
const handleMouseUp = () => { const handleMouseUp = () => {
setIsDragging(false) setIsDragging(false)
@@ -345,6 +345,7 @@ function LevelsSection() {
const nodes = useScene((state) => state.nodes); const nodes = useScene((state) => state.nodes);
const createNode = useScene((state) => state.createNode); const createNode = useScene((state) => state.createNode);
const updateNode = useScene((state) => state.updateNode); const updateNode = useScene((state) => state.updateNode);
const deleteNode = useScene((state) => state.deleteNode);
const selectedBuildingId = useViewer((state) => state.selection.buildingId); const selectedBuildingId = useViewer((state) => state.selection.buildingId);
const selectedLevelId = useViewer((state) => state.selection.levelId); const selectedLevelId = useViewer((state) => state.selection.levelId);
const setSelection = useViewer((state) => state.setSelection); const setSelection = useViewer((state) => state.setSelection);
@@ -493,6 +494,15 @@ function LevelsSection() {
> >
References References
</button> </button>
{level.level !== 0 && (
<button
className="flex items-center gap-2 w-full px-3 py-1.5 rounded text-sm hover:bg-accent hover:text-red-600 cursor-pointer"
onClick={() => deleteNode(level.id)}
>
<Trash2 className="w-3.5 h-3.5" />
Delete
</button>
)}
</PopoverContent> </PopoverContent>
</Popover> </Popover>
</div> </div>
+3 -3
View File
@@ -1,6 +1,5 @@
{ {
"lockfileVersion": 1, "lockfileVersion": 1,
"configVersion": 0,
"workspaces": { "workspaces": {
"": { "": {
"name": "editor", "name": "editor",
@@ -63,13 +62,14 @@
}, },
"packages/core": { "packages/core": {
"name": "@pascal-app/core", "name": "@pascal-app/core",
"version": "0.1.10", "version": "0.1.11",
"dependencies": { "dependencies": {
"dedent": "^1.7.1", "dedent": "^1.7.1",
"idb-keyval": "^6.2.2", "idb-keyval": "^6.2.2",
"mitt": "^3.0.1", "mitt": "^3.0.1",
"nanoid": "^5.1.6", "nanoid": "^5.1.6",
"three-bvh-csg": "^0.0.17", "three-bvh-csg": "^0.0.17",
"three-mesh-bvh": "^0.9.8",
"zod": "^4.3.5", "zod": "^4.3.5",
"zundo": "^2.3.0", "zundo": "^2.3.0",
"zustand": "^5", "zustand": "^5",
@@ -127,7 +127,7 @@
}, },
"packages/viewer": { "packages/viewer": {
"name": "@pascal-app/viewer", "name": "@pascal-app/viewer",
"version": "0.1.10", "version": "0.1.11",
"dependencies": { "dependencies": {
"zustand": "^5", "zustand": "^5",
}, },
+1
View File
@@ -33,6 +33,7 @@
"mitt": "^3.0.1", "mitt": "^3.0.1",
"nanoid": "^5.1.6", "nanoid": "^5.1.6",
"three-bvh-csg": "^0.0.17", "three-bvh-csg": "^0.0.17",
"three-mesh-bvh": "^0.9.8",
"zod": "^4.3.5", "zod": "^4.3.5",
"zundo": "^2.3.0", "zundo": "^2.3.0",
"zustand": "^5" "zustand": "^5"
@@ -21,6 +21,7 @@ const csgEvaluator = new Evaluator()
// WALL SYSTEM // WALL SYSTEM
// ============================================================================ // ============================================================================
let useFrameNb = 0;
export const WallSystem = () => { export const WallSystem = () => {
const dirtyNodes = useScene((state) => state.dirtyNodes) const dirtyNodes = useScene((state) => state.dirtyNodes)
const clearDirty = useScene((state) => state.clearDirty) const clearDirty = useScene((state) => state.clearDirty)
@@ -33,7 +34,7 @@ export const WallSystem = () => {
// Collect dirty walls and their levels // Collect dirty walls and their levels
const dirtyWallsByLevel = new Map<string, Set<string>>() const dirtyWallsByLevel = new Map<string, Set<string>>()
useFrameNb += 1;
dirtyNodes.forEach((id) => { dirtyNodes.forEach((id) => {
const node = nodes[id] const node = nodes[id]
if (!node || node.type !== 'wall') return if (!node || node.type !== 'wall') return
@@ -106,6 +107,7 @@ function updateWallGeometry(wallId: string, miterData: WallMiterData) {
const node = nodes[wallId as WallNode['id']] const node = nodes[wallId as WallNode['id']]
if (!node || node.type !== 'wall') return if (!node || node.type !== 'wall') return
const mesh = sceneRegistry.nodes.get(wallId) as THREE.Mesh const mesh = sceneRegistry.nodes.get(wallId) as THREE.Mesh
if (!mesh) return if (!mesh) return