Aymeric Rabot 0b338cf647
feat(editor): live floor-stacking, unified handle system, slab-hole editing + interaction polish (#375)
- Live slab-stacking Y previews for all floor-placed kinds (item/shelf/spawn/column/stair) during placement + both move pathways, via a shared core resolver; canonical positions unchanged.
- Unified 3D handle system (one drag pipeline + one visual primitive) with forgiving invisible hit-areas on every handle, kept on EDITOR_LAYER so they don't poison the MRT scene pass.
- Hover + click-to-edit slab holes in 3D (manual hole -> hole editor; stair/elevator hole -> select owner); generic cross-arrow polygon-move grip; normalized handle interaction colors.
- NaN-safe node mutations + non-finite shadow-light bounds guard.
- Built on #373 (level-scoped alignment / registry slab tool); #373 owns X/Z alignment, this owns Y floor-stacking.
2026-06-05 16:24:48 -04:00

87 lines
2.8 KiB
TypeScript

import type { HandleDescriptor, NodeDefinition, SpawnNode as SpawnNodeType } from '@pascal-app/core'
import { buildSpawnFloorplan } from './floorplan'
import { spawnParametrics } from './parametrics'
import { SpawnNode } from './schema'
const SPAWN_FOOTPRINT = 0.6
const MOVE_FRONT_OFFSET = 0.35
function spawnMoveHandle(): HandleDescriptor<SpawnNodeType> {
return {
kind: 'translate',
placement: {
// Low to the floor at the front edge (matches the item move grip).
position: () => [0, 0.02, SPAWN_FOOTPRINT / 2 + MOVE_FRONT_OFFSET],
},
apply: (_n, pos) => ({ position: [pos[0], pos[1], pos[2]] }),
snapExtents: () => [SPAWN_FOOTPRINT, SPAWN_FOOTPRINT],
}
}
export const spawnDefinition: NodeDefinition<typeof SpawnNode> = {
kind: 'spawn',
schemaVersion: 1,
schema: SpawnNode,
category: 'site',
defaults: () => ({
object: 'node',
parentId: null,
visible: true,
metadata: {},
position: [0, 0, 0],
rotation: 0,
}),
capabilities: {
movable: { axes: ['x', 'z'], gridSnap: true },
rotatable: {
axes: ['y'],
snapAngles: [0, Math.PI / 4, Math.PI / 2, (3 * Math.PI) / 4, Math.PI],
},
duplicable: false, // singleton per level
deletable: true,
selectable: { hitVolume: 'bbox' },
// Spawn is a singleton anchor — no meaning as a reusable preset.
presettable: false,
// Slab elevation lift via the generic `<FloorElevationSystem>`. The
// spawn marker is a 1.8m-tall figure with a ~0.6m ring footprint.
floorPlaced: {
footprint: () => ({ dimensions: [0.6, 1.8, 0.6], rotation: [0, 0, 0] }),
},
},
parametrics: spawnParametrics,
handles: [spawnMoveHandle()],
renderer: {
kind: 'parametric',
module: () => import('./renderer'),
},
// Stage C migration: floor-plan rendering via def.floorplan.
// floorplan-panel.tsx's `floorplanSpawnEntries` short-circuits to []
// when `nodeRegistry.has('spawn')`, so this builder is the single
// path. FloorplanRegistryLayer renders + handles click-to-select;
// FloorplanRegistryActionMenu handles move / duplicate (disabled) /
// delete. Legacy spawn click handlers in FloorplanNodeLayer become
// dead code once Phase 6 cleanup removes the [] entries path.
floorplan: buildSpawnFloorplan,
tool: () => import('./tool'),
toolHints: [
{ key: 'Left click', label: 'Place spawn point' },
{ key: 'Esc', label: 'Cancel' },
],
presentation: {
label: 'Spawn Point',
description: 'Player or camera origin within a level. One per level.',
icon: { kind: 'url', src: '/icons/site.png' },
paletteSection: 'structure',
paletteOrder: 90, // bottom of structure list — matches legacy palette order
},
mcp: {
description: 'A singleton spawn point marker placed inside a level.',
},
}