fix level window tools
This commit is contained in:
@@ -1,13 +1,16 @@
|
||||
import { type AnyNodeId, type ItemNode, useScene, type WallNode, type WindowNode } from '@pascal-app/core'
|
||||
|
||||
/**
|
||||
* Converts wall-local (X along wall, Y = height) to world XYZ.
|
||||
* Wall-local Y maps directly to world Y; X maps along the wall direction.
|
||||
* Converts wall-local (X along wall, Y = height above level floor) to world XYZ.
|
||||
* Wall XZ uses level-local coordinates (levels only offset in Y, not XZ).
|
||||
* Pass levelYOffset (the level group's current world Y) so the cursor lands at the
|
||||
* correct world height when the cursor group is at the scene root.
|
||||
*/
|
||||
export function wallLocalToWorld(
|
||||
wallNode: WallNode,
|
||||
localX: number,
|
||||
localY: number,
|
||||
levelYOffset = 0,
|
||||
): [number, number, number] {
|
||||
const wallAngle = Math.atan2(
|
||||
wallNode.end[1] - wallNode.start[1],
|
||||
@@ -15,7 +18,7 @@ export function wallLocalToWorld(
|
||||
)
|
||||
return [
|
||||
wallNode.start[0] + localX * Math.cos(wallAngle),
|
||||
localY,
|
||||
localY + levelYOffset,
|
||||
wallNode.start[1] + localX * Math.sin(wallAngle),
|
||||
]
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user