Skip to content

Open-source manufacturing ERP, MES and QMS. Quoting, MRP, inventory, shop floor, quality and lot/serial traceability on one Postgres schema, with a REST API and MCP server. Self-host or use Carbon Cloud.

1.2 KB
Raw Blame
// SPDX-License-Identifier: AGPL-3.0-only
// Carbon (github.com/crbnos/carbon). Modified or adapted versions of this file,
// including ports, remain AGPLv3; serving them over a network requires releasing their source.

// The raw (WASM) fallback tier: renders the user's original upload through the
// SAME ModelCanvas as the artifact tiers — one renderer, one set of chrome.
// Lazy chunk: its occt-import-js WASM only downloads when this tier actually
// mounts (i.e. a model with no server artifact yet).

import { useMemo } from "react";
import { ModelCanvas, type ModelCanvasProps } from "../ModelCanvas";
import { loadRawModel } from "./loadRawModel";

export type RawModelCanvasProps = Omit<
  ModelCanvasProps,
  "glbUrl" | "loadObject"
> & {
  url?: string | null;
  file?: File | null;
  /** Format is detected from this (file name or storage path). */
  filename: string;
};

export function RawModelCanvas({
  url = null,
  file = null,
  filename,
  ...canvasProps
}: RawModelCanvasProps) {
  const loadObject = useMemo(
    () => () => loadRawModel({ url, file, filename }),
    [url, file, filename]
  );
  return <ModelCanvas glbUrl={null} loadObject={loadObject} {...canvasProps} />;
}