Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
118 changes: 114 additions & 4 deletions packages/core/src/material-library.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3442,7 +3442,9 @@ export const MATERIAL_CATALOG: MaterialCatalogItem[] = [
bumpScale: 1,
emissiveColor: '#000000',
aoMapIntensity: 1,
side: 2,
// FrontSide — DoubleSide on a NodeMaterial poisons the WebGPU MRT scene
// pass (window/door glass relies on this). It's the only glass we use.
side: 0,
opacity: 0.3,
lightMapIntensity: 1,
},
Expand Down Expand Up @@ -3860,6 +3862,44 @@ export const MATERIAL_CATALOG: MaterialCatalogItem[] = [
},
},
},
{
id: 'concrete-plate',
label: 'Concrete Plate',
category: 'concrete',
surfaces: ['wall', 'floor'],
description: 'Smooth cast concrete plate',
previewThumbnailUrl: '/material/concrete/concrete_plate/concrete_plate_thumb.webp',
preset: {
maps: {
albedoMap: '/material/concrete/concrete_plate/concrete_plate_basecolor_512.ktx2',
normalMap: '/material/concrete/concrete_plate/concrete_plate_normal_512.ktx2',
roughnessMap: '/material/concrete/concrete_plate/concrete_plate_roughness_512.ktx2',
aoMap: '/material/concrete/concrete_plate/concrete_plate_ao_512.ktx2',
},
mapProperties: {
color: '#ffffff',
roughness: 0.8,
metalness: 0,
repeatX: 0.5,
repeatY: 0.5,
rotation: 0,
wrapS: 'Repeat',
wrapT: 'Repeat',
normalScaleX: 1,
normalScaleY: 1,
emissiveIntensity: 1,
displacementScale: 0,
transparent: false,
flipY: false,
bumpScale: 1,
emissiveColor: '#000000',
aoMapIntensity: 1,
side: 0,
opacity: 1,
lightMapIntensity: 1,
},
},
},
{
id: 'concrete-stucco',
label: 'White Stucco',
Expand Down Expand Up @@ -3915,7 +3955,7 @@ export const MATERIAL_CATALOG: MaterialCatalogItem[] = [
mapProperties: {
color: '#ffffff',
roughness: 0.4,
metalness: 1,
metalness: 0.6,
repeatX: 1,
repeatY: 1,
rotation: 0,
Expand Down Expand Up @@ -3954,7 +3994,7 @@ export const MATERIAL_CATALOG: MaterialCatalogItem[] = [
mapProperties: {
color: '#ffffff',
roughness: 0.3,
metalness: 1,
metalness: 0.6,
repeatX: 1,
repeatY: 1,
rotation: 0,
Expand Down Expand Up @@ -3995,7 +4035,77 @@ export const MATERIAL_CATALOG: MaterialCatalogItem[] = [
mapProperties: {
color: '#ffffff',
roughness: 0.45,
metalness: 1,
metalness: 0.6,
repeatX: 1,
repeatY: 1,
rotation: 0,
wrapS: 'Repeat',
wrapT: 'Repeat',
normalScaleX: 1,
normalScaleY: 1,
emissiveIntensity: 1,
displacementScale: 0,
transparent: false,
flipY: false,
bumpScale: 1,
emissiveColor: '#000000',
aoMapIntensity: 1,
side: 0,
opacity: 1,
lightMapIntensity: 1,
},
},
},
{
// Parameter-only metal (no texture maps) — a worked example of a non-PBR
// catalog finish driven purely by three.js material settings.
id: 'metal-brass',
label: 'Brass',
category: 'metal',
surfaces: ['furniture', 'wall'],
description: 'Polished brass (flat metal, no maps)',
previewColor: '#b08d57',
preset: {
maps: {},
mapProperties: {
color: '#b08d57',
roughness: 0.35,
metalness: 0.9,
repeatX: 1,
repeatY: 1,
rotation: 0,
wrapS: 'Repeat',
wrapT: 'Repeat',
normalScaleX: 1,
normalScaleY: 1,
emissiveIntensity: 1,
displacementScale: 0,
transparent: false,
flipY: false,
bumpScale: 1,
emissiveColor: '#000000',
aoMapIntensity: 1,
side: 0,
opacity: 1,
lightMapIntensity: 1,
},
},
},
{
// Parameter-only chrome (no texture maps) — moderate metalness so it reads
// as bright metal under direct/ambient light without needing an env map.
id: 'metal-chrome',
label: 'Chrome',
category: 'metal',
surfaces: ['furniture', 'wall'],
description: 'Polished chrome (flat metal, no maps)',
previewColor: '#c8ccce',
preset: {
maps: {},
mapProperties: {
color: '#c8ccce',
roughness: 0.2,
metalness: 0.6,
repeatX: 1,
repeatY: 1,
rotation: 0,
Expand Down
10 changes: 9 additions & 1 deletion packages/core/src/registry/types.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import type { ComponentType } from 'react'
import type { BufferGeometry, Object3D } from 'three'
import type { BufferGeometry, Object3D, Ray } from 'three'
import type { ZodObject, z } from 'zod'
import type { MaterialSchema } from '../schema/material'
import type { SceneMaterial, SceneMaterialId } from '../schema/scene-material'
Expand Down Expand Up @@ -1212,6 +1212,14 @@ export type PaintResolveArgs = {
hitObjectName?: string
/** Optional: the three.js object that received the pointer hit. Items read userData.slotId off it. */
hitObject?: Object3D
/**
* Optional: the pointer's world ray, so a kind can re-raycast its OWN subtree
* to pick the precise sub-mesh under the cursor — independent of what the
* shared scene raycast hit first. Door/window use this: their opening proxy
* (a proud invisible cutout) wins the scene raycast over the wall in front of
* the recessed door body, then they re-raycast their parts to find the slot.
*/
ray?: Ray
}

export type PaintPatchArgs = {
Expand Down
1 change: 1 addition & 0 deletions packages/core/src/schema/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -154,6 +154,7 @@ export type { WallSurfaceMaterialSpec, WallSurfaceSide } from './nodes/wall'
export {
getEffectiveWallSurfaceMaterial,
getWallSurfaceMaterialSignature,
WALL_SLOT_DEFAULT,
WallNode,
} from './nodes/wall'
export { WindowNode, WindowType } from './nodes/window'
Expand Down
4 changes: 4 additions & 0 deletions packages/core/src/schema/nodes/ceiling.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,10 @@ export const CeilingNode = BaseNode.extend({
children: z.array(ItemNode.shape.id).default([]),
material: MaterialSchema.optional(),
materialPreset: z.string().optional(),
// Per-slot material overrides on the unified slot model, mirroring
// `ShelfNode.slots`. Key = slot id (`surface`), value = a `MaterialRef`
// (`library:<id>` / `scene:<id>`). Absent = the declared slot default.
slots: z.record(z.string(), z.string()).optional(),
polygon: z.array(z.tuple([z.number(), z.number()])),
holes: z.array(z.array(z.tuple([z.number(), z.number()]))).default([]),
holeMetadata: z.array(SurfaceHoleMetadata).default([]),
Expand Down
4 changes: 4 additions & 0 deletions packages/core/src/schema/nodes/door.ts
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,10 @@ export const DoorNode = BaseNode.extend({
id: objectId('door'),
type: nodeType('door'),
material: MaterialSchema.optional(),
// Per-slot material overrides on the unified slot model. Keys: `panel` (the
// door body), `glass`. Value = a `MaterialRef` (`library:<id>` / `scene:<id>`).
// Absent = the body/glass default. Mirrors `ShelfNode.slots`.
slots: z.record(z.string(), z.string()).optional(),

position: z.tuple([z.number(), z.number(), z.number()]).default([0, 0, 0]),
rotation: z.tuple([z.number(), z.number(), z.number()]).default([0, 0, 0]),
Expand Down
4 changes: 4 additions & 0 deletions packages/core/src/schema/nodes/slab.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,10 @@ export const SlabNode = BaseNode.extend({
type: nodeType('slab'),
material: MaterialSchema.optional(),
materialPreset: z.string().optional(),
// Per-slot material overrides on the unified slot model, mirroring
// `ShelfNode.slots`. Key = slot id (`surface`), value = a `MaterialRef`
// (`library:<id>` / `scene:<id>`). Absent = the declared slot default.
slots: z.record(z.string(), z.string()).optional(),
polygon: z.array(z.tuple([z.number(), z.number()])),
holes: z.array(z.array(z.tuple([z.number(), z.number()]))).default([]),
holeMetadata: z.array(SurfaceHoleMetadata).default([]),
Expand Down
10 changes: 10 additions & 0 deletions packages/core/src/schema/nodes/wall.ts
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,16 @@ export type WallNode = z.infer<typeof WallNode>

export type WallSurfaceSide = 'interior' | 'exterior'

// Declared default appearance for an unpainted wall face in colored mode —
// visual parity with the retired DEFAULT_WALL_MATERIAL. Lives in core so the
// slot declaration (nodes) and the material resolver (viewer) share one value.
// May be a `#rrggbb` colour or a `library:<id>` ref. Textures-off still
// collapses to the themed wall role (the escape hatch).
export const WALL_SLOT_DEFAULT: Record<WallSurfaceSide, string> = {
interior: 'library:concrete-plate',
exterior: 'library:concrete-plate',
}

export type WallSurfaceMaterialSpec = {
material?: z.infer<typeof MaterialSchema>
materialPreset?: string
Expand Down
4 changes: 4 additions & 0 deletions packages/core/src/schema/nodes/window.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,10 @@ export const WindowNode = BaseNode.extend({
id: objectId('window'),
type: nodeType('window'),
material: MaterialSchema.optional(),
// Per-slot material overrides on the unified slot model. Keys: `frame`,
// `glass`. Value = a `MaterialRef` (`library:<id>` / `scene:<id>`). Absent =
// the frame/glass default. Mirrors `ShelfNode.slots`.
slots: z.record(z.string(), z.string()).optional(),

position: z.tuple([z.number(), z.number(), z.number()]).default([0, 0, 0]),
rotation: z.tuple([z.number(), z.number(), z.number()]).default([0, 0, 0]),
Expand Down
9 changes: 8 additions & 1 deletion packages/editor/src/components/editor/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,13 @@ import {
spatialGridManager,
useScene,
} from '@pascal-app/core'
import { type HoverStyles, InteractiveSystem, useViewer, Viewer } from '@pascal-app/viewer'
import {
type HoverStyles,
InteractiveSystem,
SceneEnvironment,
useViewer,
Viewer,
} from '@pascal-app/viewer'
import { memo, type ReactNode, useCallback, useEffect, useRef, useState } from 'react'
import { ViewerOverlay } from '../../components/viewer-overlay'
import { ViewerZoneSystem } from '../../components/viewer-zone-system'
Expand Down Expand Up @@ -602,6 +608,7 @@ const ViewerSceneContent = memo(function ViewerSceneContent({
const noEditing = isVersionPreviewMode || isFirstPersonMode || isStudioMode
return (
<>
<SceneEnvironment />
{!(isFirstPersonMode || isStudioMode) && <SelectionManager />}
{!noEditing && <BoxSelectTool />}
{!noEditing && <NodeArrowHandles />}
Expand Down
18 changes: 10 additions & 8 deletions packages/editor/src/components/editor/selection-manager.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -907,6 +907,7 @@ export const SelectionManager = () => {
localPosition: event.localPosition as readonly [number, number, number] | undefined,
hitObjectName: event.nativeEvent.object?.name,
hitObject: getEventObject(event),
ray: event.nativeEvent.ray,
})
const compatible = role !== null && paintEnabled
return {
Expand Down Expand Up @@ -1059,13 +1060,7 @@ export const SelectionManager = () => {
// before any of the legacy roof / stair / single-surface arms
// below run.

if (
node.type === 'fence' ||
node.type === 'column' ||
node.type === 'slab' ||
node.type === 'ceiling' ||
node.type === 'shelf'
) {
if (node.type === 'fence' || node.type === 'column' || node.type === 'shelf') {
const compatible = paintEnabled

return {
Expand Down Expand Up @@ -1094,7 +1089,7 @@ export const SelectionManager = () => {
}
}

const disabledNodeTypes = ['window', 'door', 'zone']
const disabledNodeTypes = ['zone']
if (disabledNodeTypes.includes(node.type)) {
return {
key: `${node.type}:${node.id}:unsupported`,
Expand Down Expand Up @@ -1191,13 +1186,19 @@ export const SelectionManager = () => {

for (const type of subscribedKinds) {
emitter.on(`${type}:enter` as any, onEnter as any)
// Re-evaluate on move so the hover preview tracks the cursor across a
// kind's sub-parts (door/window panel↔frame↔glass↔hardware, wall
// interior↔exterior) — not just on the initial enter. onEnter is
// idempotent (no-ops when the resolved part is unchanged).
emitter.on(`${type}:move` as any, onEnter as any)
emitter.on(`${type}:leave` as any, onLeave as any)
emitter.on(`${type}:click` as any, onClick as any)
}

return () => {
for (const type of subscribedKinds) {
emitter.off(`${type}:enter` as any, onEnter as any)
emitter.off(`${type}:move` as any, onEnter as any)
emitter.off(`${type}:leave` as any, onLeave as any)
emitter.off(`${type}:click` as any, onClick as any)
}
Expand Down Expand Up @@ -1558,6 +1559,7 @@ export const SelectionManager = () => {
localPosition: event.localPosition as readonly [number, number, number] | undefined,
hitObjectName: event.nativeEvent.object?.name,
hitObject: getEventObject(event),
ray: event.nativeEvent.ray,
})
if (role) {
setSelectedMaterialTargetForNode(nodeToSelect, role as MaterialTargetRole)
Expand Down
2 changes: 0 additions & 2 deletions packages/editor/src/lib/material-paint.ts
Original file line number Diff line number Diff line change
Expand Up @@ -382,8 +382,6 @@ export function resolveActivePaintMaterialFromSelection(params: {
if (
(selectedNode.type === 'fence' ||
selectedNode.type === 'column' ||
selectedNode.type === 'slab' ||
selectedNode.type === 'ceiling' ||
selectedNode.type === 'shelf') &&
selectedMaterialTarget.role === 'surface'
) {
Expand Down
6 changes: 6 additions & 0 deletions packages/nodes/src/ceiling/definition.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,10 @@ import {
ceilingMoveVertexAffordance,
} from './floorplan-affordances'
import { ceilingFloorplanMoveTarget } from './floorplan-move'
import { ceilingPaint } from './paint'
import { ceilingParametrics } from './parametrics'
import { CeilingNode } from './schema'
import { ceilingSlots } from './slots'

const HEIGHT_HANDLE_OFFSET = 0.22
const MIN_CEILING_HEIGHT = 0.5
Expand Down Expand Up @@ -102,6 +104,10 @@ export const ceilingDefinition: NodeDefinition<typeof CeilingNode> = {
},
duplicable: true,
deletable: true,
// Unified slot model: one paintable underside surface with a declared
// default, painted through the registry `capabilities.paint` dispatch.
slots: () => ceilingSlots(),
paint: ceilingPaint,
},

relations: {
Expand Down
Loading
Loading