import { registerToolcraftRendererPipeline } from "../../rendering"; import type { ToolcraftProductModuleDefinition } from "../../modules/contract/module-definition"; import type { ToolcraftProductBase } from "../../schema/product-base"; import { resolveToolcraftProductDefinition } from "../../schema/resolve-toolcraft-product-definition"; import type { ToolcraftControlSchema } from "../../schema/types"; import type { ToolcraftAppPorts } from "./toolcraft-app-ports"; export const PRODUCT_SCENE =
; export function createBase( controls: Record = { intensity: { applicability: { mode: "always" as const }, defaultValue: 50, label: "Intensity", max: 100, min: 0, target: "product.intensity", type: "slider", }, }, ): ToolcraftProductBase { return { canvas: { enabled: true, size: { height: 180, unit: "px", width: 320 }, }, identity: { id: "composed-product", title: "Composed Product" }, panels: { controls: { sections: [{ controls, id: "product", title: "Product" }], title: "Composed Product", }, }, toolbar: { history: true, zoom: true }, }; } export function createModelBase(): ToolcraftProductBase { return createBase({ model: { applicability: { mode: "always" as const }, assetKind: "model", label: "Model", target: "source.model", type: "fileDrop", }, orientation: { applicability: { mode: "always" as const }, defaultValue: { position: [3, 3, 3], up: [0, 1, 0] }, keyframeable: false, label: false, target: "view.orbit", type: "orientationGizmo", }, }); } export function createModelOnlyBase(): ToolcraftProductBase { return createBase({ model: { applicability: { mode: "always" as const }, assetKind: "model", label: "Model", target: "source.model", type: "fileDrop", }, }); } export function createSpatialBase(): ToolcraftProductBase { return createBase({ orientation: { applicability: { mode: "always" as const }, defaultValue: { position: [3, 3, 3], up: [0, 1, 0] }, keyframeable: false, label: false, target: "view.orbit", type: "orientationGizmo", }, }); } export function resolveProduct( modules: readonly ToolcraftProductModuleDefinition[] = [], base: ToolcraftProductBase = createBase(), ) { return resolveToolcraftProductDefinition({ base, modules }); } export const rasterRenderer = Object.freeze({ baseFileName: "raster", renderFrame: () => undefined, }); export const vectorRenderer = Object.freeze({ baseFileName: "vector", renderFrame: () => undefined, }); export const pipelineRegistration = registerToolcraftRendererPipeline<{}>()({ interactionInvalidation: [], passes: [], runtimeId: "composition-test-v1", }); export function unsafeToolcraftAppPorts(value: object): ToolcraftAppPorts { return value as ToolcraftAppPorts; }