18 lines
1.2 KiB
TypeScript
18 lines
1.2 KiB
TypeScript
import { blockedGate, capabilityIssue, readyGate, type CapabilityGateResult } from "./capability-gates";
|
|
import type { NonMeshDataIR } from "./scene-ir";
|
|
|
|
const previewableTypes = new Set<NonMeshDataIR["type"]>(["CURVE", "SURFACE", "FONT", "METABALL", "POINT_CLOUD", "CURVES", "HAIR"]);
|
|
|
|
export function gateNonMeshData(data: NonMeshDataIR): CapabilityGateResult {
|
|
const hasSourceGeometry = data.geometryStatus === "available" || data.geometryStatus === "binary";
|
|
if ((hasSourceGeometry || (data.evaluatedGeometry?.length ?? 0) > 0) && previewableTypes.has(data.type)) {
|
|
const representation = (data.evaluatedGeometry?.length ?? 0) > 0 ? "EVALUATED" : data.geometryStatus === "binary" ? "BINARY" : "PREVIEW";
|
|
return readyGate("N-015", `NON_MESH_${data.type}_${representation}`);
|
|
}
|
|
const code = data.errorCode ?? (data.type === "VOLUME" ? "NON_MESH_RESOURCE_MISSING" : "NON_MESH_DATA_UNSUPPORTED");
|
|
const message = data.geometryStatus === "blocked"
|
|
? `${data.type} data is blocked: ${code}`
|
|
: `${data.type} data is available only as a summary; editable/evaluated preview is not supported`;
|
|
return blockedGate("N-015", `NON_MESH_${data.type}`, [capabilityIssue(code, message, `nonMeshData.${data.id}`)]);
|
|
}
|