Merge branch 'main' of github.com:sudhir9297/editor into feat/wall-room-creation
This commit is contained in:
@@ -7,11 +7,23 @@ export { type Collection, type CollectionId, generateCollectionId } from './coll
|
||||
// Material
|
||||
export {
|
||||
DEFAULT_MATERIALS,
|
||||
MaterialMapPropertiesSchema,
|
||||
MaterialMapsSchema,
|
||||
MaterialPreset,
|
||||
MaterialPresetPayloadSchema,
|
||||
MaterialProperties,
|
||||
MaterialSchema,
|
||||
MaterialTarget,
|
||||
TextureWrapMode,
|
||||
resolveMaterial,
|
||||
} from './material'
|
||||
export type {
|
||||
MaterialMapProperties,
|
||||
MaterialMaps,
|
||||
MaterialPresetPayload,
|
||||
MaterialTarget as MaterialTargetValue,
|
||||
TextureWrapMode as TextureWrapModeValue,
|
||||
} from './material'
|
||||
export { BuildingNode } from './nodes/building'
|
||||
export { CeilingNode } from './nodes/ceiling'
|
||||
export { DoorNode, DoorSegment } from './nodes/door'
|
||||
|
||||
@@ -25,6 +25,7 @@ export const MaterialProperties = z.object({
|
||||
export type MaterialProperties = z.infer<typeof MaterialProperties>
|
||||
|
||||
export const MaterialSchema = z.object({
|
||||
id: z.string().optional(),
|
||||
preset: MaterialPreset.optional(),
|
||||
properties: MaterialProperties.optional(),
|
||||
texture: z
|
||||
@@ -37,6 +38,67 @@ export const MaterialSchema = z.object({
|
||||
})
|
||||
export type MaterialSchema = z.infer<typeof MaterialSchema>
|
||||
|
||||
export const MaterialTarget = z.enum([
|
||||
'wall',
|
||||
'roof',
|
||||
'roof-segment',
|
||||
'stair',
|
||||
'stair-segment',
|
||||
'fence',
|
||||
'slab',
|
||||
'ceiling',
|
||||
'door',
|
||||
'window',
|
||||
])
|
||||
export type MaterialTarget = z.infer<typeof MaterialTarget>
|
||||
|
||||
export const TextureWrapMode = z.enum(['Repeat', 'ClampToEdge', 'MirroredRepeat'])
|
||||
export type TextureWrapMode = z.infer<typeof TextureWrapMode>
|
||||
|
||||
export const MaterialMapsSchema = z.object({
|
||||
albedoMap: z.string().optional(),
|
||||
metalnessMap: z.string().optional(),
|
||||
roughnessMap: z.string().optional(),
|
||||
normalMap: z.string().optional(),
|
||||
displacementMap: z.string().optional(),
|
||||
aoMap: z.string().optional(),
|
||||
emissiveMap: z.string().optional(),
|
||||
bumpMap: z.string().optional(),
|
||||
alphaMap: z.string().optional(),
|
||||
lightMap: z.string().optional(),
|
||||
})
|
||||
export type MaterialMaps = z.infer<typeof MaterialMapsSchema>
|
||||
|
||||
export const MaterialMapPropertiesSchema = z.object({
|
||||
color: z.string().default('#ffffff'),
|
||||
roughness: z.number().min(0).max(1).default(0.5),
|
||||
metalness: z.number().min(0).max(1).default(0),
|
||||
repeatX: z.number().default(1),
|
||||
repeatY: z.number().default(1),
|
||||
rotation: z.number().default(0),
|
||||
wrapS: TextureWrapMode.default('Repeat'),
|
||||
wrapT: TextureWrapMode.default('Repeat'),
|
||||
normalScaleX: z.number().default(1),
|
||||
normalScaleY: z.number().default(1),
|
||||
emissiveIntensity: z.number().default(1),
|
||||
displacementScale: z.number().default(0.02),
|
||||
transparent: z.boolean().default(false),
|
||||
flipY: z.boolean().default(true),
|
||||
bumpScale: z.number().default(1),
|
||||
emissiveColor: z.string().default('#000000'),
|
||||
aoMapIntensity: z.number().default(1),
|
||||
side: z.number().default(0),
|
||||
opacity: z.number().min(0).max(1).default(1),
|
||||
lightMapIntensity: z.number().default(1),
|
||||
})
|
||||
export type MaterialMapProperties = z.infer<typeof MaterialMapPropertiesSchema>
|
||||
|
||||
export const MaterialPresetPayloadSchema = z.object({
|
||||
maps: MaterialMapsSchema,
|
||||
mapProperties: MaterialMapPropertiesSchema,
|
||||
})
|
||||
export type MaterialPresetPayload = z.infer<typeof MaterialPresetPayloadSchema>
|
||||
|
||||
export const DEFAULT_MATERIALS: Record<MaterialPreset, MaterialProperties> = {
|
||||
white: {
|
||||
color: '#ffffff',
|
||||
|
||||
@@ -9,6 +9,7 @@ export const CeilingNode = BaseNode.extend({
|
||||
type: nodeType('ceiling'),
|
||||
children: z.array(ItemNode.shape.id).default([]),
|
||||
material: MaterialSchema.optional(),
|
||||
materialPreset: z.string().optional(),
|
||||
polygon: z.array(z.tuple([z.number(), z.number()])),
|
||||
holes: z.array(z.array(z.tuple([z.number(), z.number()]))).default([]),
|
||||
height: z.number().default(2.5), // Height in meters
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
import dedent from 'dedent'
|
||||
import { z } from 'zod'
|
||||
import { BaseNode, nodeType, objectId } from '../base'
|
||||
import { MaterialSchema } from '../material'
|
||||
|
||||
export const FenceStyle = z.enum(['slat', 'rail', 'privacy'])
|
||||
export const FenceBaseStyle = z.enum(['floating', 'grounded'])
|
||||
@@ -8,6 +9,8 @@ export const FenceBaseStyle = z.enum(['floating', 'grounded'])
|
||||
export const FenceNode = BaseNode.extend({
|
||||
id: objectId('fence'),
|
||||
type: nodeType('fence'),
|
||||
material: MaterialSchema.optional(),
|
||||
materialPreset: z.string().optional(),
|
||||
start: z.tuple([z.number(), z.number()]),
|
||||
end: z.tuple([z.number(), z.number()]),
|
||||
height: z.number().default(1.8),
|
||||
|
||||
@@ -11,6 +11,7 @@ export const RoofSegmentNode = BaseNode.extend({
|
||||
id: objectId('rseg'),
|
||||
type: nodeType('roof-segment'),
|
||||
material: MaterialSchema.optional(),
|
||||
materialPreset: z.string().optional(),
|
||||
position: z.tuple([z.number(), z.number(), z.number()]).default([0, 0, 0]),
|
||||
// Rotation around Y axis in radians
|
||||
rotation: z.number().default(0),
|
||||
|
||||
@@ -8,6 +8,7 @@ export const RoofNode = BaseNode.extend({
|
||||
id: objectId('roof'),
|
||||
type: nodeType('roof'),
|
||||
material: MaterialSchema.optional(),
|
||||
materialPreset: z.string().optional(),
|
||||
position: z.tuple([z.number(), z.number(), z.number()]).default([0, 0, 0]),
|
||||
// Rotation around Y axis in radians
|
||||
rotation: z.number().default(0),
|
||||
|
||||
@@ -7,6 +7,7 @@ export const SlabNode = BaseNode.extend({
|
||||
id: objectId('slab'),
|
||||
type: nodeType('slab'),
|
||||
material: MaterialSchema.optional(),
|
||||
materialPreset: z.string().optional(),
|
||||
polygon: z.array(z.tuple([z.number(), z.number()])),
|
||||
holes: z.array(z.array(z.tuple([z.number(), z.number()]))).default([]),
|
||||
elevation: z.number().default(0.05), // Elevation in meters
|
||||
|
||||
@@ -15,6 +15,7 @@ export const StairSegmentNode = BaseNode.extend({
|
||||
id: objectId('sseg'),
|
||||
type: nodeType('stair-segment'),
|
||||
material: MaterialSchema.optional(),
|
||||
materialPreset: z.string().optional(),
|
||||
position: z.tuple([z.number(), z.number(), z.number()]).default([0, 0, 0]),
|
||||
// Rotation around Y axis in radians
|
||||
rotation: z.number().default(0),
|
||||
|
||||
@@ -16,6 +16,7 @@ export const StairNode = BaseNode.extend({
|
||||
id: objectId('stair'),
|
||||
type: nodeType('stair'),
|
||||
material: MaterialSchema.optional(),
|
||||
materialPreset: z.string().optional(),
|
||||
position: z.tuple([z.number(), z.number(), z.number()]).default([0, 0, 0]),
|
||||
// Rotation around Y axis in radians
|
||||
rotation: z.number().default(0),
|
||||
|
||||
@@ -13,8 +13,10 @@ export const WallNode = BaseNode.extend({
|
||||
.array(z.union([ItemNode.shape.id, DoorNode.shape.id, WindowNode.shape.id]))
|
||||
.default([]),
|
||||
material: MaterialSchema.optional(),
|
||||
materialPreset: z.string().optional(),
|
||||
thickness: z.number().optional(),
|
||||
height: z.number().optional(),
|
||||
curveOffset: z.number().optional(),
|
||||
// e.g., start/end points for path
|
||||
start: z.tuple([z.number(), z.number()]),
|
||||
end: z.tuple([z.number(), z.number()]),
|
||||
@@ -26,6 +28,7 @@ export const WallNode = BaseNode.extend({
|
||||
Wall node - used to represent a wall in the building
|
||||
- thickness: thickness in meters
|
||||
- height: height in meters
|
||||
- curveOffset: midpoint sagitta offset used to bend the wall into an arc
|
||||
- start: start point of the wall in level coordinate system
|
||||
- end: end point of the wall in level coordinate system
|
||||
- size: size of the wall in grid units
|
||||
|
||||
Reference in New Issue
Block a user