slab type
This commit is contained in:
@@ -1,6 +1,6 @@
|
||||
import type { ThreeEvent } from '@react-three/fiber'
|
||||
import mitt from 'mitt'
|
||||
import type { BuildingNode, ItemNode, WallNode, ZoneNode } from '../schema'
|
||||
import type { BuildingNode, ItemNode, SlabNode, WallNode, ZoneNode } from '../schema'
|
||||
import type { AnyNode } from '../schema/types'
|
||||
|
||||
// Base event interfaces
|
||||
@@ -22,6 +22,7 @@ export type WallEvent = NodeEvent<WallNode>
|
||||
export type ItemEvent = NodeEvent<ItemNode>
|
||||
export type BuildingEvent = NodeEvent<BuildingNode>
|
||||
export type ZoneEvent = NodeEvent<ZoneNode>
|
||||
export type SlabEvent = NodeEvent<SlabNode>
|
||||
|
||||
// Event suffixes - exported for use in hooks
|
||||
export const eventSuffixes = [
|
||||
|
||||
@@ -8,10 +8,10 @@ export { ItemNode } from './nodes/item'
|
||||
export { LevelNode } from './nodes/level'
|
||||
// Nodes
|
||||
export { SiteNode } from './nodes/site'
|
||||
export { SlabNode, SlabPolygon } from './nodes/slab'
|
||||
export { WallNode } from './nodes/wall'
|
||||
// Zones
|
||||
export { ZoneNode } from './nodes/zone'
|
||||
export type { ZonePolygon } from './nodes/zone'
|
||||
export { ZoneNode } from './nodes/zone'
|
||||
export type { AnyNodeId, AnyNodeType } from './types'
|
||||
// Union types
|
||||
export { AnyNode } from './types'
|
||||
|
||||
@@ -1,14 +1,14 @@
|
||||
import dedent from 'dedent'
|
||||
import { z } from 'zod'
|
||||
import { BaseNode, nodeType, objectId } from '../base'
|
||||
import { SlabNode } from './slab'
|
||||
import { WallNode } from './wall'
|
||||
import { ZoneNode } from './zone'
|
||||
|
||||
|
||||
export const LevelNode = BaseNode.extend({
|
||||
id: objectId('level'),
|
||||
type: nodeType('level'),
|
||||
children: z.array(z.union([WallNode.shape.id, ZoneNode.shape.id])).default([]),
|
||||
children: z.array(z.union([WallNode.shape.id, ZoneNode.shape.id, SlabNode.shape.id])).default([]),
|
||||
// Specific props
|
||||
level: z.number().default(0),
|
||||
}).describe(
|
||||
|
||||
@@ -0,0 +1,24 @@
|
||||
import dedent from 'dedent'
|
||||
import { z } from 'zod'
|
||||
import { BaseNode, nodeType, objectId } from '../base'
|
||||
|
||||
// Polygon boundary for zone area - array of [x, z] coordinates
|
||||
export const SlabPolygon = z.array(z.tuple([z.number(), z.number()]))
|
||||
|
||||
export const SlabNode = BaseNode.extend({
|
||||
id: objectId('slab'),
|
||||
type: nodeType('slab'),
|
||||
// Specific props
|
||||
// Polygon boundary - array of [x, z] coordinates defining the slab
|
||||
polygon: SlabPolygon,
|
||||
elevation: z.number().default(0.05), // Elevation in meters
|
||||
}).describe(
|
||||
dedent`
|
||||
Slab node - used to represent a slab/floor in the building
|
||||
- polygon: array of [x, z] points defining the slab boundary
|
||||
- elevation: elevation in meters
|
||||
`,
|
||||
)
|
||||
|
||||
export type SlabNode = z.infer<typeof SlabNode>
|
||||
export type SlabPolygon = z.infer<typeof SlabPolygon>
|
||||
@@ -3,6 +3,7 @@ import { BuildingNode } from './nodes/building'
|
||||
import { ItemNode } from './nodes/item'
|
||||
import { LevelNode } from './nodes/level'
|
||||
import { SiteNode } from './nodes/site'
|
||||
import { SlabNode } from './nodes/slab'
|
||||
import { WallNode } from './nodes/wall'
|
||||
import { ZoneNode } from './nodes/zone'
|
||||
|
||||
@@ -13,6 +14,7 @@ export const AnyNode = z.discriminatedUnion('type', [
|
||||
WallNode,
|
||||
ItemNode,
|
||||
ZoneNode,
|
||||
SlabNode,
|
||||
])
|
||||
|
||||
export type AnyNode = z.infer<typeof AnyNode>
|
||||
|
||||
Reference in New Issue
Block a user