slab type

This commit is contained in:
wass08
2026-01-27 07:05:37 +09:00
parent 374860f4de
commit 8b1fbb4c1d
5 changed files with 32 additions and 5 deletions
+2 -1
View File
@@ -1,6 +1,6 @@
import type { ThreeEvent } from '@react-three/fiber' import type { ThreeEvent } from '@react-three/fiber'
import mitt from 'mitt' 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' import type { AnyNode } from '../schema/types'
// Base event interfaces // Base event interfaces
@@ -22,6 +22,7 @@ export type WallEvent = NodeEvent<WallNode>
export type ItemEvent = NodeEvent<ItemNode> export type ItemEvent = NodeEvent<ItemNode>
export type BuildingEvent = NodeEvent<BuildingNode> export type BuildingEvent = NodeEvent<BuildingNode>
export type ZoneEvent = NodeEvent<ZoneNode> export type ZoneEvent = NodeEvent<ZoneNode>
export type SlabEvent = NodeEvent<SlabNode>
// Event suffixes - exported for use in hooks // Event suffixes - exported for use in hooks
export const eventSuffixes = [ export const eventSuffixes = [
+2 -2
View File
@@ -8,10 +8,10 @@ export { ItemNode } from './nodes/item'
export { LevelNode } from './nodes/level' export { LevelNode } from './nodes/level'
// Nodes // Nodes
export { SiteNode } from './nodes/site' export { SiteNode } from './nodes/site'
export { SlabNode, SlabPolygon } from './nodes/slab'
export { WallNode } from './nodes/wall' export { WallNode } from './nodes/wall'
// Zones
export { ZoneNode } from './nodes/zone'
export type { ZonePolygon } from './nodes/zone' export type { ZonePolygon } from './nodes/zone'
export { ZoneNode } from './nodes/zone'
export type { AnyNodeId, AnyNodeType } from './types' export type { AnyNodeId, AnyNodeType } from './types'
// Union types // Union types
export { AnyNode } from './types' export { AnyNode } from './types'
+2 -2
View File
@@ -1,14 +1,14 @@
import dedent from 'dedent' import dedent from 'dedent'
import { z } from 'zod' import { z } from 'zod'
import { BaseNode, nodeType, objectId } from '../base' import { BaseNode, nodeType, objectId } from '../base'
import { SlabNode } from './slab'
import { WallNode } from './wall' import { WallNode } from './wall'
import { ZoneNode } from './zone' import { ZoneNode } from './zone'
export const LevelNode = BaseNode.extend({ export const LevelNode = BaseNode.extend({
id: objectId('level'), id: objectId('level'),
type: nodeType('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 // Specific props
level: z.number().default(0), level: z.number().default(0),
}).describe( }).describe(
+24
View File
@@ -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>
+2
View File
@@ -3,6 +3,7 @@ import { BuildingNode } from './nodes/building'
import { ItemNode } from './nodes/item' import { ItemNode } from './nodes/item'
import { LevelNode } from './nodes/level' import { LevelNode } from './nodes/level'
import { SiteNode } from './nodes/site' import { SiteNode } from './nodes/site'
import { SlabNode } from './nodes/slab'
import { WallNode } from './nodes/wall' import { WallNode } from './nodes/wall'
import { ZoneNode } from './nodes/zone' import { ZoneNode } from './nodes/zone'
@@ -13,6 +14,7 @@ export const AnyNode = z.discriminatedUnion('type', [
WallNode, WallNode,
ItemNode, ItemNode,
ZoneNode, ZoneNode,
SlabNode,
]) ])
export type AnyNode = z.infer<typeof AnyNode> export type AnyNode = z.infer<typeof AnyNode>