item catalog draft
This commit is contained in:
@@ -1,16 +1,17 @@
|
||||
// Base
|
||||
export { BaseNode, generateId, objectId, nodeType, Material } from "./base"
|
||||
export { BaseNode, generateId, objectId, nodeType, Material } from "./base";
|
||||
|
||||
// Nodes
|
||||
export { SiteNode } from "./nodes/site"
|
||||
export { BuildingNode } from "./nodes/building"
|
||||
export { LevelNode } from "./nodes/level"
|
||||
export { WallNode } from "./nodes/wall"
|
||||
export { ItemNode } from "./nodes/item"
|
||||
export { SiteNode } from "./nodes/site";
|
||||
export { BuildingNode } from "./nodes/building";
|
||||
export { LevelNode } from "./nodes/level";
|
||||
export { WallNode } from "./nodes/wall";
|
||||
export { ItemNode } from "./nodes/item";
|
||||
export type { AssetInput } from "./nodes/item";
|
||||
|
||||
// Union types
|
||||
export { AnyNode } from "./types"
|
||||
export type { AnyNodeType, AnyNodeId } from "./types"
|
||||
export { AnyNode } from "./types";
|
||||
export type { AnyNodeType, AnyNodeId } from "./types";
|
||||
|
||||
// Camera
|
||||
export { CameraSchema } from "./camera"
|
||||
export { CameraSchema } from "./camera";
|
||||
|
||||
@@ -2,6 +2,21 @@ import dedent from "dedent";
|
||||
import { z } from "zod";
|
||||
import { BaseNode, nodeType, objectId } from "../base";
|
||||
|
||||
const assetSchema = z.object({
|
||||
category: z.string(),
|
||||
name: z.string(),
|
||||
thumbnail: z.string(),
|
||||
src: z.string(),
|
||||
dimensions: z.tuple([z.number(), z.number(), z.number()]).default([1, 1, 1]), // [w, h, d]
|
||||
attachTo: z.enum(["wall", "wall-side", "ceiling"]).optional(),
|
||||
// These are "Corrective" transforms to normalize the GLB
|
||||
offset: 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]),
|
||||
scale: z.tuple([z.number(), z.number(), z.number()]).default([1, 1, 1]),
|
||||
});
|
||||
|
||||
export type AssetInput = z.input<typeof assetSchema>;
|
||||
|
||||
export const ItemNode = BaseNode.extend({
|
||||
id: objectId("item"),
|
||||
type: nodeType("item"),
|
||||
@@ -9,31 +24,7 @@ export const ItemNode = BaseNode.extend({
|
||||
rotation: z.tuple([z.number(), z.number(), z.number()]).default([0, 0, 0]),
|
||||
side: z.enum(["front", "back"]).optional(),
|
||||
|
||||
asset: z
|
||||
.object({
|
||||
category: z.string(),
|
||||
src: z.string(),
|
||||
dimensions: z
|
||||
.tuple([z.number(), z.number(), z.number()])
|
||||
.default([1, 1, 1]), // [w, h, d]
|
||||
attachTo: z.enum(["wall", "wall-side", "ceiling"]).optional(),
|
||||
// These are "Corrective" transforms to normalize the GLB
|
||||
offset: 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]),
|
||||
scale: z
|
||||
.union([z.number(), z.tuple([z.number(), z.number(), z.number()])])
|
||||
.default(1),
|
||||
})
|
||||
.default({
|
||||
category: "",
|
||||
src: "",
|
||||
dimensions: [1, 1, 1],
|
||||
offset: [0, 0, 0],
|
||||
rotation: [0, 0, 0],
|
||||
scale: 1,
|
||||
}),
|
||||
asset: assetSchema,
|
||||
}).describe(dedent`Item node - used to represent a item in the building
|
||||
- position: position in level coordinate system (or parent coordinate system if attached)
|
||||
- rotation: rotation in level coordinate system (or parent coordinate system if attached)
|
||||
|
||||
Reference in New Issue
Block a user