viewer: Fix Dutch roof trim artifacts (#452)
* 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 spiral stair openings and fence handle arrows * Implement roof trim planes and ridge vent clipping * Fix mansard roof and ridge vent placement * Fix mansard merged roof cutouts * Fix Dutch roof gable overhang * Refactor roof segment, ridge vent, and surface geometry Remove Dutch ridge axis abstraction and rework roof edit system, ridge vent clipping geometry, and roof surface placement. Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com> * Simplify Dutch roof shape * Add Dutch roof gable top geometry controls * Fix Dutch roof slope material slots * Render dutch roof tops as double-sided faces * Add auto ridge vent toggle to roof segments Track ridge vent auto-generation via an `autoRidgeVent` metadata flag so geometry changes only regenerate default vents when enabled, treating legacy segments with generated vents as auto-enabled for back-compat. Expose a panel toggle to opt in/out per segment. Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com> * Snap new walls to the floor below Feed the walls of the level directly beneath the active one into the draft snap pipeline as extra references, so a new wall can align with the floor below. They share the same local XZ origin, and the list is kept separate from the current-level walls so the measurement HUD and wall splitting only act on the active level. Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com> * Set Dutch roof shape defaults on type switch Seed the Dutch shape parameters (waist width/height/length, top rake thickness/length) with sensible defaults whenever a segment is created as or switched to Dutch, so the gablet is well-formed regardless of leftover values from the previous roof type. Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com> * Use green accent for corner and endpoint snap markers Color the corner/endpoint snap markers and the vertical cursor pillar green across the 2D floorplan beacon, the 3D alignment guide dots, and the wall snap beacon so snap targets read as a consistent accent. Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com> * Add magnetic wall snapping to the roof tool Snap roof draft corners onto wall corners, midpoints, crossings, and bodies on the active level and the floor below, reusing the wall tool's snap pipeline so the beacon and coloring match. The cursor's ground dot/ring is hidden while a wall snap is active to avoid overlapping the beacon glyph. Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com> * Update auto-generated Next.js route types path Regenerated next-env.d.ts now references ./.next/dev/types/routes.d.ts. Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com> * Show cutaway outline while dragging roof trim Slice an untrimmed segment volume generated from the live node instead of the registry mesh, whose CSG rebuild lags a few frames behind the drag and may still hold placeholder geometry — so the section outline now renders deterministically. Use LineBasicNodeMaterial so the outline draws under the WebGPU pipeline, and export generateRoofSegmentGeometry for the slice source. Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com> * Fill and clip roof trim cutaway, gate it to active drag Add a violet silhouette fill behind the cutaway outline, extend the section slicing to angled diagonal/corner trims via a generic vertical cut plane, and clip each slice to its footprint span so the infinite plane no longer sprouts stray lines across the rest of the roof. The cutaway now renders only while a trim handle is being dragged. Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com> * Separate and extend Dutch roof end slopes Pull the Dutch hip end slopes out of the watertight shingle shell into their own slab wedge so they can be reshaped independently, and extend each end slope inward up its own hip plane until the top edge meets the gablet's inner triangle. Refactor roof-segment shape geometry into a shared roof-segment-shape module. Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com> * Render roof trim cutaway as a material-only section cut Replace the triangle-mesh slicer with a CSG intersection of a thin slab against the untrimmed roof shell, so the cutaway shows red only on real material (wall + deck bands) and leaves the hollow attic empty. Add an analytic surface-edge outline, style both solid red like a SketchUp section, and make the cutaway persist whenever a segment is trimmed. Keep the merged roof shell visible during trim editing (re-trimmed live from each segment's drag override) instead of swapping in the per-segment meshes, whose abutting end-cap faces showed as stray white planes the commit never had. Extend each slab past free cut-line ends only — trimmed ends clamp to the cut line — so the red section stays inside the trim box. Re-export INTERSECTION from the viewer CSG surface for the editor. * Outline roof cutaway by fill silhouette, restyle to destructive red Derive the section-cut outline from the fill geometry's edges (EdgesGeometry) so it traces the real cut shape — wall/deck band boundaries and the hollow-attic edge — instead of just the top surface line. Drop the fill to 85% opacity and recolor both fill and outline to the app's destructive red, matching the delete/destructive UI. * Include roof accessories in trim clipping and red cutaway Roof accessories (chimney, vents, skylight, dormer, gutter, downspout, solar-panel, cupola) now slice at the trim plane like the roof shell and appear in the red section-cut while dragging a trim handle: - Export clipGeometryBySegmentTrim from the viewer as a reusable segment-local trim-clip primitive. - Add a shared useSegmentTrimClippedGeometry hook + TrimClippedMesh wrapper (nodes) that slice accessory geometry by the host segment's live trim override, so the cut tracks the drag. - Wire the clip into all 11 accessory renderers, including skylight glass panes and dormer window glass/frame/sill. - Feed every hosted accessory mesh into the editor's red cutaway, welding triangle-soup geometry (e.g. ridge vent) so CSG INTERSECTION yields a cross-section. - Register skylight in the scene-graph tree-node map so it shows in the outliner when placed on a roof. Co-Authored-By: Claude <noreply@anthropic.com> * Add smooth spline fences with editable curve handles Fences can now be drawn as one continuous Catmull-Rom/Bezier curve via an optional `path` (+ per-point `tangents`), selectable in a Straight/Curved mode toggle. Selected spline fences expose draggable control-point dots (hexagon) and symmetric tangent handles (circle) joined by a violet line, editable in both 2D plan and 3D. Side-move arrows are dropped for splines. Co-Authored-By: Claude <noreply@anthropic.com> * Fix dutch roof ridge vent handling * Fix Dutch ridge vent placement and support * Fix Dutch roof trim artifacts * Fix Dutch roof trim preview geometry * Tag roof trim overlay meshes with EDITOR_LAYER Child meshes relied on a parent group's layer, which three.js does not propagate, so the trim section/rail/plane overlays rendered on the scene layer — getting inked/SSGI-darkened and leaking into thumbnail exports. Co-Authored-By: Claude <noreply@anthropic.com> * Apply Biome cleanup * fix(core): address Dutch roof review feedback * chore: apply biome check cleanup * fix(core): relax Dutch roof surface helper input * fix * Fix biome checks and dev verification * fixes * Remove unsupported Biome noShadow override * Improve roof interactions and fence editing * Fix fence drag and ridge vent default handling * editor: drop wall-snap debug log, gate curved-fence finish hint on draft start Remove the leftover TEMP DIAGNOSTIC console.log in the wall tool's onMove hot path. Curved fences commit on a closing gesture (double-click / Enter) rather than per-click, so surface a 'Finish curve' hint in the fence HUD — but only once a point has been placed and a curve is actually in flight. The draft point count is published from SplineFenceDraft into a small ephemeral editor store (useFenceCurveDraft) that the contextual helper reads, mirroring the existing useSegmentDraftChain pattern. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com> --------- Co-authored-by: Claude Opus 4.6 <noreply@anthropic.com> Co-authored-by: Wassim SAMAD <wass08@gmail.com>
This commit is contained in:
co-authored by
Claude Opus 4.8
Wassim SAMAD
parent
c51e673421
commit
bf25af6add
@@ -175,11 +175,8 @@ function buildGlbColliderWorld(scene: Object3D): GlbColliderWorld | null {
|
||||
merged?.dispose()
|
||||
return null
|
||||
}
|
||||
// biome-ignore lint/suspicious/noExplicitAny: three-mesh-bvh patches the geometry prototype
|
||||
;(merged as any).computeBoundsTree = computeBoundsTree
|
||||
// biome-ignore lint/suspicious/noExplicitAny: three-mesh-bvh patches the geometry prototype
|
||||
;(merged as any).disposeBoundsTree = disposeBoundsTree
|
||||
// biome-ignore lint/suspicious/noExplicitAny: three-mesh-bvh runtime extension
|
||||
;(merged as any).computeBoundsTree({ maxLeafSize: 12, strategy: 0 })
|
||||
merged.computeBoundingBox()
|
||||
|
||||
@@ -199,7 +196,6 @@ function buildGlbColliderWorld(scene: Object3D): GlbColliderWorld | null {
|
||||
mesh,
|
||||
minY: merged.boundingBox?.min.y ?? 0,
|
||||
dispose: () => {
|
||||
// biome-ignore lint/suspicious/noExplicitAny: three-mesh-bvh runtime extension
|
||||
;(merged as any).disposeBoundsTree?.()
|
||||
merged.dispose()
|
||||
},
|
||||
|
||||
@@ -53,6 +53,7 @@ export {
|
||||
csgEvaluator,
|
||||
csgGeometry,
|
||||
csgMaterials,
|
||||
INTERSECTION,
|
||||
prepareBrushForCSG,
|
||||
SUBTRACTION,
|
||||
} from './lib/csg-utils'
|
||||
@@ -141,6 +142,8 @@ export { getRoofMaterialArray } from './systems/roof/roof-materials'
|
||||
// read these through the public surface. No kind-specific helpers
|
||||
// belong here — those live in `@pascal-app/nodes/<kind>/`.
|
||||
export {
|
||||
clipGeometryBySegmentTrim,
|
||||
generateRoofSegmentGeometry,
|
||||
getRoofOuterSurfaceFrameAtPoint,
|
||||
getRoofSegmentBrushes,
|
||||
mapRoofGroupMaterialIndex,
|
||||
|
||||
@@ -111,6 +111,6 @@ export function prepareBrushForCSG(brush: Brush) {
|
||||
brush.updateMatrixWorld()
|
||||
}
|
||||
|
||||
// Re-export Brush + SUBTRACTION + ADDITION so kinds don't need a direct
|
||||
// `three-bvh-csg` dependency.
|
||||
export { ADDITION, Brush, SUBTRACTION } from 'three-bvh-csg'
|
||||
// Re-export Brush + SUBTRACTION + ADDITION + INTERSECTION so kinds don't need a
|
||||
// direct `three-bvh-csg` dependency.
|
||||
export { ADDITION, Brush, INTERSECTION, SUBTRACTION } from 'three-bvh-csg'
|
||||
|
||||
@@ -35,7 +35,7 @@ export const CeilingSystem = () => {
|
||||
// Process dirty ceilings
|
||||
dirtyNodes.forEach((id) => {
|
||||
const node = nodes[id]
|
||||
if (!node || node.type !== 'ceiling') return
|
||||
if (node?.type !== 'ceiling') return
|
||||
|
||||
const mesh = sceneRegistry.nodes.get(id) as THREE.Mesh
|
||||
if (mesh) {
|
||||
|
||||
@@ -139,7 +139,7 @@ export const DoorSystem = () => {
|
||||
|
||||
dirtyNodes.forEach((id) => {
|
||||
const node = nodes[id]
|
||||
if (!node || node.type !== 'door') return
|
||||
if (node?.type !== 'door') return
|
||||
dirtyDoorIds.push(id as AnyNodeId)
|
||||
})
|
||||
|
||||
@@ -161,7 +161,7 @@ export const DoorSystem = () => {
|
||||
}
|
||||
|
||||
const node = nodes[id]
|
||||
if (!node || node.type !== 'door') continue
|
||||
if (node?.type !== 'door') continue
|
||||
const mesh = sceneRegistry.nodes.get(id) as THREE.Mesh
|
||||
if (!mesh) continue // Keep dirty until mesh mounts
|
||||
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
import {
|
||||
type AnyNodeId,
|
||||
type FenceNode,
|
||||
getWallCurveFrameAt,
|
||||
getWallCurveLength,
|
||||
getFenceCenterlineFrameAt,
|
||||
getFenceCenterlineLength,
|
||||
sceneRegistry,
|
||||
useScene,
|
||||
} from '@pascal-app/core'
|
||||
@@ -11,6 +11,7 @@ import * as THREE from 'three'
|
||||
import { mergeGeometries } from 'three/examples/jsm/utils/BufferGeometryUtils.js'
|
||||
|
||||
type FencePart = {
|
||||
geometry?: THREE.BufferGeometry
|
||||
position: [number, number, number]
|
||||
rotationY?: number
|
||||
scale: [number, number, number]
|
||||
@@ -20,8 +21,12 @@ type FencePart = {
|
||||
}
|
||||
|
||||
const MIN_CURVE_SEGMENT_LENGTH = 0.18
|
||||
const HORIZONTAL_FENCE_CURVE_SEGMENT_LENGTH = 0.2
|
||||
|
||||
function createFencePartGeometry(part: FencePart) {
|
||||
if (part.geometry) {
|
||||
return part.geometry
|
||||
}
|
||||
const geometry =
|
||||
part.shape === 'pyramid'
|
||||
? new THREE.ConeGeometry(0.5, 1, 4, 1, false, Math.PI / 4)
|
||||
@@ -36,65 +41,164 @@ function createFencePartGeometry(part: FencePart) {
|
||||
}
|
||||
|
||||
function getFencePointAt(fence: FenceNode, t: number) {
|
||||
const frame = getWallCurveFrameAt(fence, t)
|
||||
const frame = getFenceCenterlineFrameAt(fence, t)
|
||||
return {
|
||||
point: frame.point,
|
||||
tangentAngle: Math.atan2(frame.tangent.y, frame.tangent.x),
|
||||
}
|
||||
}
|
||||
|
||||
function createStraightFenceSpanPart(
|
||||
start: [number, number],
|
||||
end: [number, number],
|
||||
centerY: number,
|
||||
height: number,
|
||||
depth: number,
|
||||
): FencePart | null {
|
||||
const dx = end[0] - start[0]
|
||||
const dz = end[1] - start[1]
|
||||
const length = Math.hypot(dx, dz)
|
||||
if (length <= 1e-4) {
|
||||
return null
|
||||
}
|
||||
|
||||
return {
|
||||
position: [(start[0] + end[0]) / 2, centerY, (start[1] + end[1]) / 2],
|
||||
rotationY: -Math.atan2(dz, dx),
|
||||
scale: [length, height, depth],
|
||||
}
|
||||
}
|
||||
|
||||
function createFenceCurveSpanParts(
|
||||
function createFenceCurveBlockPart(
|
||||
fence: FenceNode,
|
||||
startT: number,
|
||||
endT: number,
|
||||
centerY: number,
|
||||
height: number,
|
||||
depth: number,
|
||||
): FencePart[] {
|
||||
const parts: FencePart[] = []
|
||||
const frameCount = Math.max(
|
||||
1,
|
||||
Math.ceil(
|
||||
(getWallCurveLength(fence) * Math.max(1e-4, endT - startT)) / MIN_CURVE_SEGMENT_LENGTH,
|
||||
),
|
||||
)
|
||||
): FencePart | null {
|
||||
if (endT - startT <= 1e-5) return null
|
||||
const halfHeight = height / 2
|
||||
const halfDepth = depth / 2
|
||||
const centerlineLength = getFenceCenterlineLength(fence)
|
||||
const startDistance = startT * centerlineLength
|
||||
const endDistance = endT * centerlineLength
|
||||
const bottomY = centerY - halfHeight
|
||||
const topY = centerY + halfHeight
|
||||
const corners: Array<[number, number, number]> = []
|
||||
|
||||
let previous = getFencePointAt(fence, startT)
|
||||
for (let index = 1; index <= frameCount; index += 1) {
|
||||
const t = startT + (endT - startT) * (index / frameCount)
|
||||
const current = getFencePointAt(fence, t)
|
||||
const segment = createStraightFenceSpanPart(
|
||||
[previous.point.x, previous.point.y],
|
||||
[current.point.x, current.point.y],
|
||||
for (const t of [startT, endT]) {
|
||||
const frame = getFencePointAt(fence, t)
|
||||
const normalX = -Math.sin(frame.tangentAngle)
|
||||
const normalZ = Math.cos(frame.tangentAngle)
|
||||
|
||||
const outerX = frame.point.x + normalX * halfDepth
|
||||
const outerZ = frame.point.y + normalZ * halfDepth
|
||||
const innerX = frame.point.x - normalX * halfDepth
|
||||
const innerZ = frame.point.y - normalZ * halfDepth
|
||||
|
||||
corners.push(
|
||||
[outerX, bottomY, outerZ],
|
||||
[innerX, bottomY, innerZ],
|
||||
[outerX, topY, outerZ],
|
||||
[innerX, topY, innerZ],
|
||||
)
|
||||
}
|
||||
|
||||
const positions: number[] = []
|
||||
const uvs: number[] = []
|
||||
const pushVertex = (index: number, uv: [number, number]) => {
|
||||
positions.push(...corners[index]!)
|
||||
uvs.push(...uv)
|
||||
}
|
||||
|
||||
const pushQuad = (
|
||||
a: number,
|
||||
b: number,
|
||||
c: number,
|
||||
d: number,
|
||||
uvA: [number, number],
|
||||
uvB: [number, number],
|
||||
uvC: [number, number],
|
||||
uvD: [number, number],
|
||||
) => {
|
||||
pushVertex(a, uvA)
|
||||
pushVertex(b, uvB)
|
||||
pushVertex(c, uvC)
|
||||
pushVertex(a, uvA)
|
||||
pushVertex(c, uvC)
|
||||
pushVertex(d, uvD)
|
||||
}
|
||||
|
||||
const topOuterV = topY
|
||||
const topInnerV = topY + depth
|
||||
const innerTopV = topInnerV
|
||||
const innerBottomV = topInnerV + height
|
||||
const bottomInnerV = bottomY - depth
|
||||
|
||||
pushQuad(
|
||||
0,
|
||||
4,
|
||||
6,
|
||||
2,
|
||||
[startDistance, bottomY],
|
||||
[endDistance, bottomY],
|
||||
[endDistance, topY],
|
||||
[startDistance, topY],
|
||||
)
|
||||
pushQuad(
|
||||
1,
|
||||
3,
|
||||
7,
|
||||
5,
|
||||
[startDistance, innerBottomV],
|
||||
[startDistance, innerTopV],
|
||||
[endDistance, innerTopV],
|
||||
[endDistance, innerBottomV],
|
||||
)
|
||||
pushQuad(
|
||||
2,
|
||||
6,
|
||||
7,
|
||||
3,
|
||||
[startDistance, topOuterV],
|
||||
[endDistance, topOuterV],
|
||||
[endDistance, topInnerV],
|
||||
[startDistance, topInnerV],
|
||||
)
|
||||
pushQuad(
|
||||
0,
|
||||
1,
|
||||
5,
|
||||
4,
|
||||
[startDistance, bottomY],
|
||||
[startDistance, bottomInnerV],
|
||||
[endDistance, bottomInnerV],
|
||||
[endDistance, bottomY],
|
||||
)
|
||||
pushQuad(0, 2, 3, 1, [0, bottomY], [0, topY], [depth, innerTopV], [depth, innerBottomV])
|
||||
pushQuad(4, 5, 7, 6, [0, bottomY], [depth, innerBottomV], [depth, innerTopV], [0, topY])
|
||||
|
||||
const geometry = new THREE.BufferGeometry()
|
||||
geometry.setAttribute(
|
||||
'position',
|
||||
new THREE.Float32BufferAttribute(new Float32Array(positions), 3),
|
||||
)
|
||||
geometry.setAttribute('uv', new THREE.Float32BufferAttribute(new Float32Array(uvs), 2))
|
||||
geometry.setAttribute('uv2', new THREE.Float32BufferAttribute(new Float32Array(uvs), 2))
|
||||
geometry.computeVertexNormals()
|
||||
|
||||
return {
|
||||
geometry,
|
||||
position: [0, 0, 0],
|
||||
scale: [1, 1, 1],
|
||||
}
|
||||
}
|
||||
|
||||
function createFenceCurveBlockParts(
|
||||
fence: FenceNode,
|
||||
startT: number,
|
||||
endT: number,
|
||||
centerY: number,
|
||||
height: number,
|
||||
depth: number,
|
||||
maxSegmentLength = MIN_CURVE_SEGMENT_LENGTH,
|
||||
): FencePart[] {
|
||||
const length = getFenceCenterlineLength(fence) * Math.max(1e-4, endT - startT)
|
||||
const segmentCount = Math.max(1, Math.ceil(length / Math.max(1e-4, maxSegmentLength)))
|
||||
const parts: FencePart[] = []
|
||||
|
||||
for (let index = 0; index < segmentCount; index += 1) {
|
||||
const segmentStartT = startT + (endT - startT) * (index / segmentCount)
|
||||
const segmentEndT = startT + (endT - startT) * ((index + 1) / segmentCount)
|
||||
const part = createFenceCurveBlockPart(
|
||||
fence,
|
||||
segmentStartT,
|
||||
segmentEndT,
|
||||
centerY,
|
||||
height,
|
||||
depth,
|
||||
)
|
||||
if (segment) {
|
||||
parts.push(segment)
|
||||
}
|
||||
previous = current
|
||||
if (part) parts.push(part)
|
||||
}
|
||||
|
||||
return parts
|
||||
@@ -176,7 +280,7 @@ function createHorizontalFenceParts(fence: FenceNode): FenceSlotParts {
|
||||
const base: FencePart[] = []
|
||||
const rail: FencePart[] = []
|
||||
|
||||
const length = Math.max(getWallCurveLength(fence), 0.01)
|
||||
const length = Math.max(getFenceCenterlineLength(fence), 0.01)
|
||||
const panelDepth = Math.max(fence.thickness, 0.03)
|
||||
const clearance = Math.max(fence.groundClearance, 0)
|
||||
const isFloating = fence.baseStyle === 'floating'
|
||||
@@ -191,17 +295,25 @@ function createHorizontalFenceParts(fence: FenceNode): FenceSlotParts {
|
||||
const postWidth = Math.max(fence.postSize * 1.4, 0.04)
|
||||
const postDepth = postWidth
|
||||
const boardDepth = Math.min(panelDepth, postDepth - 0.012)
|
||||
// Stop the horizontal boards / base / rail at the inner faces of the
|
||||
// end posts. Letting curved spans run all the way to t=0/1 makes them
|
||||
// overlap the terminal post mesh and creates the broken seam/notch seen
|
||||
// at curve ends.
|
||||
const edgeInset = Math.max(fence.edgeInset ?? 0.015, postWidth * 0.5)
|
||||
const startInsetT = Math.min(0.499, edgeInset / length)
|
||||
const endInsetT = Math.max(0.501, 1 - edgeInset / length)
|
||||
|
||||
// Grounded fences get a kickboard along the bottom; floating ones don't.
|
||||
if (!isFloating) {
|
||||
base.push(
|
||||
...createFenceCurveSpanParts(
|
||||
...createFenceCurveBlockParts(
|
||||
fence,
|
||||
0,
|
||||
1,
|
||||
startInsetT,
|
||||
endInsetT,
|
||||
baseY + baseHeight / 2,
|
||||
baseHeight,
|
||||
postDepth * 0.92,
|
||||
HORIZONTAL_FENCE_CURVE_SEGMENT_LENGTH,
|
||||
),
|
||||
)
|
||||
}
|
||||
@@ -216,13 +328,14 @@ function createHorizontalFenceParts(fence: FenceNode): FenceSlotParts {
|
||||
// No reveal → one flush panel, so the stacked-board edge seams don't
|
||||
// read as faint lines where the user asked for a smooth surface.
|
||||
infill.push(
|
||||
...createFenceCurveSpanParts(
|
||||
...createFenceCurveBlockParts(
|
||||
fence,
|
||||
0,
|
||||
1,
|
||||
startInsetT,
|
||||
endInsetT,
|
||||
infillBottom + verticalHeight / 2,
|
||||
verticalHeight,
|
||||
boardDepth,
|
||||
HORIZONTAL_FENCE_CURVE_SEGMENT_LENGTH,
|
||||
),
|
||||
)
|
||||
} else {
|
||||
@@ -230,20 +343,31 @@ function createHorizontalFenceParts(fence: FenceNode): FenceSlotParts {
|
||||
const slabHeight = Math.max((verticalHeight - reveal * (boardCount - 1)) / boardCount, 0.02)
|
||||
for (let index = 0; index < boardCount; index += 1) {
|
||||
const centerY = infillBottom + slabHeight / 2 + index * (slabHeight + reveal)
|
||||
infill.push(...createFenceCurveSpanParts(fence, 0, 1, centerY, slabHeight, boardDepth))
|
||||
infill.push(
|
||||
...createFenceCurveBlockParts(
|
||||
fence,
|
||||
startInsetT,
|
||||
endInsetT,
|
||||
centerY,
|
||||
slabHeight,
|
||||
boardDepth,
|
||||
HORIZONTAL_FENCE_CURVE_SEGMENT_LENGTH,
|
||||
),
|
||||
)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Top rail caps the boards.
|
||||
rail.push(
|
||||
...createFenceCurveSpanParts(
|
||||
...createFenceCurveBlockParts(
|
||||
fence,
|
||||
0,
|
||||
1,
|
||||
startInsetT,
|
||||
endInsetT,
|
||||
baseY + baseHeight + verticalHeight + topRailHeight / 2,
|
||||
topRailHeight,
|
||||
Math.max(postDepth * 0.78, 0.02),
|
||||
HORIZONTAL_FENCE_CURVE_SEGMENT_LENGTH,
|
||||
),
|
||||
)
|
||||
|
||||
@@ -287,7 +411,7 @@ function createFenceParts(fence: FenceNode): FenceSlotParts {
|
||||
const infill: FencePart[] = []
|
||||
const base: FencePart[] = []
|
||||
const rail: FencePart[] = []
|
||||
const length = Math.max(getWallCurveLength(fence), 0.01)
|
||||
const length = Math.max(getFenceCenterlineLength(fence), 0.01)
|
||||
const panelDepth = Math.max(fence.thickness, 0.03)
|
||||
const clearance = Math.max(fence.groundClearance, 0)
|
||||
const styleDefaults = getStyleDefaults(fence.style)
|
||||
@@ -306,7 +430,7 @@ function createFenceParts(fence: FenceNode): FenceSlotParts {
|
||||
|
||||
if (!isFloating) {
|
||||
base.push(
|
||||
...createFenceCurveSpanParts(
|
||||
...createFenceCurveBlockParts(
|
||||
fence,
|
||||
0,
|
||||
1,
|
||||
@@ -315,8 +439,9 @@ function createFenceParts(fence: FenceNode): FenceSlotParts {
|
||||
panelDepth * 1.05,
|
||||
),
|
||||
)
|
||||
|
||||
base.push(
|
||||
...createFenceCurveSpanParts(
|
||||
...createFenceCurveBlockParts(
|
||||
fence,
|
||||
0,
|
||||
1,
|
||||
@@ -332,7 +457,6 @@ function createFenceParts(fence: FenceNode): FenceSlotParts {
|
||||
|
||||
for (let index = 0; index < count; index += 1) {
|
||||
const t = count === 1 ? 0.5 : startInsetT + (endInsetT - startInsetT) * (index / (count - 1))
|
||||
const frame = getFencePointAt(fence, t)
|
||||
const isEdgePost = index === 0 || index === count - 1
|
||||
const fullHeightPost = !showInfill || (isFloating && isEdgePost)
|
||||
const postHeight = fullHeightPost
|
||||
@@ -342,17 +466,24 @@ function createFenceParts(fence: FenceNode): FenceSlotParts {
|
||||
|
||||
// End posts are the structural `posts` slot; the intermediate verticals are
|
||||
// the `infill` slats (only present when showInfill adds them).
|
||||
// Depth is 0.001 m shy of the accent rail's `panelDepth * 0.35` so the two
|
||||
// never share a coplanar face where they cross (kills the rail z-fighting).
|
||||
;(isEdgePost ? posts : infill).push({
|
||||
position: [frame.point.x, postY, frame.point.y],
|
||||
rotationY: -frame.tangentAngle,
|
||||
scale: [postWidth, postHeight, Math.max(panelDepth * 0.35 - 0.001, 0.011)],
|
||||
})
|
||||
const slatHalfT = Math.max(0.0005, postWidth / (2 * length))
|
||||
const slatStartT = Math.max(0, t - slatHalfT)
|
||||
const slatEndT = Math.min(1, t + slatHalfT)
|
||||
const slat = createFenceCurveBlockPart(
|
||||
fence,
|
||||
slatStartT,
|
||||
slatEndT,
|
||||
postY,
|
||||
postHeight,
|
||||
Math.max(panelDepth * 0.35 - 0.001, 0.011),
|
||||
)
|
||||
if (slat) {
|
||||
;(isEdgePost ? posts : infill).push(slat)
|
||||
}
|
||||
}
|
||||
|
||||
rail.push(
|
||||
...createFenceCurveSpanParts(
|
||||
...createFenceCurveBlockParts(
|
||||
fence,
|
||||
0,
|
||||
1,
|
||||
@@ -364,7 +495,7 @@ function createFenceParts(fence: FenceNode): FenceSlotParts {
|
||||
|
||||
if (isFloating) {
|
||||
rail.push(
|
||||
...createFenceCurveSpanParts(
|
||||
...createFenceCurveBlockParts(
|
||||
fence,
|
||||
0,
|
||||
1,
|
||||
@@ -421,7 +552,7 @@ export function generateFenceGeometry(fence: FenceNode) {
|
||||
|
||||
function updateFenceGeometry(fenceId: FenceNode['id']) {
|
||||
const node = useScene.getState().nodes[fenceId]
|
||||
if (!node || node.type !== 'fence') return
|
||||
if (node?.type !== 'fence') return
|
||||
|
||||
const mesh = sceneRegistry.nodes.get(fenceId) as THREE.Mesh | undefined
|
||||
if (!mesh) return
|
||||
@@ -443,7 +574,7 @@ export const FenceSystem = () => {
|
||||
const nodes = useScene.getState().nodes
|
||||
dirtyNodes.forEach((id) => {
|
||||
const node = nodes[id]
|
||||
if (!node || node.type !== 'fence') return
|
||||
if (node?.type !== 'fence') return
|
||||
updateFenceGeometry(id as FenceNode['id'])
|
||||
clearDirty(id as AnyNodeId)
|
||||
})
|
||||
|
||||
@@ -29,7 +29,7 @@ export const ItemSystem = () => {
|
||||
|
||||
dirtyNodes.forEach((id) => {
|
||||
const node = nodes[id]
|
||||
if (!node || node.type !== 'item') return
|
||||
if (node?.type !== 'item') return
|
||||
|
||||
const item = node as ItemNode
|
||||
const mesh = sceneRegistry.nodes.get(id) as THREE.Object3D
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -48,7 +48,7 @@ export const SlabSystem = () => {
|
||||
// Process dirty slabs
|
||||
dirtyNodes.forEach((id) => {
|
||||
const node = nodes[id]
|
||||
if (!node || node.type !== 'slab') return
|
||||
if (node?.type !== 'slab') return
|
||||
|
||||
const mesh = sceneRegistry.nodes.get(id) as THREE.Mesh
|
||||
if (mesh) {
|
||||
|
||||
@@ -88,7 +88,7 @@ export const StairSystem = () => {
|
||||
// --- Pass 1b: Sync chained transforms to individual segment meshes (edit mode) ---
|
||||
for (const stairId of parentsNeedingSegmentSync) {
|
||||
const baseStairNode = nodes[stairId]
|
||||
if (!baseStairNode || baseStairNode.type !== 'stair') continue
|
||||
if (baseStairNode?.type !== 'stair') continue
|
||||
// Merge any in-flight drag override (e.g. parent-stair rotate handle)
|
||||
// so slab-elevation spatial queries match where the segments are
|
||||
// actually being rendered. Without this, dragging the rotate gizmo
|
||||
@@ -110,7 +110,7 @@ export const StairSystem = () => {
|
||||
if (stairsProcessed >= MAX_STAIRS_PER_FRAME) break
|
||||
|
||||
const node = nodes[id]
|
||||
if (!node || node.type !== 'stair') {
|
||||
if (node?.type !== 'stair') {
|
||||
pendingStairUpdates.delete(id)
|
||||
continue
|
||||
}
|
||||
@@ -1075,7 +1075,7 @@ function computeAbsoluteHeight(node: StairSegmentNode): number {
|
||||
if (!node.parentId) return 0
|
||||
|
||||
const parent = nodes[node.parentId as AnyNodeId]
|
||||
if (!parent || parent.type !== 'stair') return 0
|
||||
if (parent?.type !== 'stair') return 0
|
||||
|
||||
const stair = parent as StairNode
|
||||
const segments = (stair.children ?? [])
|
||||
|
||||
@@ -103,7 +103,7 @@ export const WallCutout = () => {
|
||||
const wallMesh = sceneRegistry.nodes.get(wallId)
|
||||
if (!wallMesh) return
|
||||
const wallNode = useScene.getState().nodes[wallId as WallNode['id']]
|
||||
if (!wallNode || wallNode.type !== 'wall') return
|
||||
if (wallNode?.type !== 'wall') return
|
||||
|
||||
const hideWall = getWallHideState(wallNode, wallMesh as Mesh, wallMode, u)
|
||||
const isDeleteHighlighted = deleteHoveredWallId === wallId
|
||||
@@ -155,7 +155,7 @@ export const WallCutout = () => {
|
||||
const wallMesh = sceneRegistry.nodes.get(wallId) as Mesh | undefined
|
||||
if (!wallMesh) return
|
||||
const wallNode = useScene.getState().nodes[wallId as AnyNodeId] as WallNode | undefined
|
||||
if (!wallNode || wallNode.type !== 'wall') return
|
||||
if (wallNode?.type !== 'wall') return
|
||||
const mats = getMaterialsForWall(
|
||||
wallNode,
|
||||
useViewer.getState().shading,
|
||||
|
||||
@@ -366,7 +366,7 @@ export const WallSystem = () => {
|
||||
if (hasDirty) {
|
||||
dirtyNodes.forEach((id) => {
|
||||
const node = nodes[id]
|
||||
if (!node || node.type !== 'wall') return
|
||||
if (node?.type !== 'wall') return
|
||||
|
||||
const levelId = node.parentId
|
||||
if (!levelId) return
|
||||
@@ -515,7 +515,7 @@ function getLevelWalls(levelId: string): WallNode[] {
|
||||
const { nodes } = useScene.getState()
|
||||
const level = nodes[levelId as AnyNodeId]
|
||||
|
||||
if (!level || level.type !== 'level') return []
|
||||
if (level?.type !== 'level') return []
|
||||
|
||||
const walls: WallNode[] = []
|
||||
for (const childId of level.children) {
|
||||
@@ -536,7 +536,7 @@ function getLevelWalls(levelId: string): WallNode[] {
|
||||
function updateWallGeometry(wallId: string, miterData: WallMiterData) {
|
||||
const nodes = useScene.getState().nodes
|
||||
const sceneNode = nodes[wallId as WallNode['id']]
|
||||
if (!sceneNode || sceneNode.type !== 'wall') return
|
||||
if (sceneNode?.type !== 'wall') return
|
||||
const node = getEffectiveWall(sceneNode as WallNode)
|
||||
|
||||
const mesh = sceneRegistry.nodes.get(wallId) as THREE.Mesh
|
||||
|
||||
@@ -116,7 +116,7 @@ export const WindowSystem = () => {
|
||||
|
||||
dirtyNodes.forEach((id) => {
|
||||
const node = nodes[id]
|
||||
if (!node || node.type !== 'window') return
|
||||
if (node?.type !== 'window') return
|
||||
dirtyWindowIds.push(id as AnyNodeId)
|
||||
})
|
||||
|
||||
@@ -138,7 +138,7 @@ export const WindowSystem = () => {
|
||||
}
|
||||
|
||||
const node = nodes[id]
|
||||
if (!node || node.type !== 'window') continue
|
||||
if (node?.type !== 'window') continue
|
||||
|
||||
const mesh = sceneRegistry.nodes.get(id) as THREE.Mesh
|
||||
if (!mesh) continue // Keep dirty until mesh mounts
|
||||
|
||||
Reference in New Issue
Block a user