* Add roof surface placement support for items Items (e.g. solar panels) can now be placed on sloped roof surfaces. The placement system computes euler rotation from the roof surface normal so items sit flush on the slope instead of going inside. - Add roofStrategy to placement-strategies with enter/move/click/leave - Wire roof:enter/move/click/leave events in the placement coordinator - Add calculateRoofRotation in placement-math using surface normals - Support full 3D cursor rotation for sloped surfaces - Items on roofs are parented to the level with world-space rotation Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com> * fixed conflict * fix(editor): anchor floorplan cursor to snapped point * fix(nodes): preview floorplan edits through live overrides * feat(editor): add context-aware floorplan modes * fix(nodes): render crisp wall selection hatching * fix(editor): cap floorplan handles at extreme zoom * fix(editor): keep zone labels upright after rotation * refactor(editor): make referenced annotations registry-driven * refactor(nodes): colocate contextual dimension builders * fix(editor): use mode-driven angle snapping * fix(nodes): use mode-driven move snapping * chore(editor): update react scan tooling * refactor(floorplan): streamline construction documentation * refactor(floorplan): remove wall assembly roadmap * fix(floorplan): migrate retired scene data --------- Co-authored-by: Claude Opus 4.6 <noreply@anthropic.com>
43 lines
1.3 KiB
TypeScript
43 lines
1.3 KiB
TypeScript
import {
|
|
type AnyNodeId,
|
|
type FloorplanAffordance,
|
|
type SpawnNode,
|
|
useLiveNodeOverrides,
|
|
useScene,
|
|
} from '@pascal-app/core'
|
|
import { isAngleSnapActive } from '@pascal-app/editor'
|
|
import { rotateAffordanceDelta } from '../shared/rotate-affordance'
|
|
|
|
export const spawnRotateAffordance: FloorplanAffordance<SpawnNode> = {
|
|
start({ node, initialPlanPoint }) {
|
|
const spawnId = node.id as AnyNodeId
|
|
const initialRotation = node.rotation ?? 0
|
|
const cx = node.position[0]
|
|
const cz = node.position[2]
|
|
const initialAngle = Math.atan2(initialPlanPoint[1] - cz, initialPlanPoint[0] - cx)
|
|
let lastRotation = initialRotation
|
|
|
|
return {
|
|
affectedIds: [spawnId],
|
|
apply({ planPoint }) {
|
|
const delta = rotateAffordanceDelta({
|
|
center: [cx, cz],
|
|
initialAngle,
|
|
planPoint,
|
|
free: !isAngleSnapActive(),
|
|
})
|
|
lastRotation = initialRotation - delta
|
|
useLiveNodeOverrides.getState().set(spawnId, { rotation: lastRotation })
|
|
useScene.getState().markDirty(spawnId)
|
|
},
|
|
canCommit() {
|
|
return true
|
|
},
|
|
commit() {
|
|
useLiveNodeOverrides.getState().clear(spawnId)
|
|
useScene.getState().updateNode(spawnId, { rotation: lastRotation })
|
|
},
|
|
}
|
|
},
|
|
}
|