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.
TypeScript ai-agentsbill-of-materialserpinventory-managementleanmanufacturingmanufacturing-execution-systemmcp-servermesmrpopen-source-erppostgresqlproduction-planningqmsquality-management-systemreact-routerself-hostedsupabasetraceabilitytypescript
- Bumped viewer lib and rolled back the new progress bar
Gaurav Bhatt953c45361f48
diff --git a/package-lock.json b/package-lock.jsonindex d6f84abdfc..15685974f9 100644--- a/package-lock.json+++ b/package-lock.json@@ -19238,12 +19238,14 @@}},"node_modules/online-3d-viewer": {- "version": "0.15.0",+ "version": "0.18.0",+ "resolved": "https://registry.npmjs.org/online-3d-viewer/-/online-3d-viewer-0.18.0.tgz",+ "integrity": "sha512-y7ZlV/zkakNUyjqcXz6XecA7vXgLEUnaAey9tyx8o6/wcdV64RfjXAQOjGXGY2JOZoDi4Cg1ic9icSWMWAvRQA==","license": "MIT","dependencies": {"@simonwep/pickr": "1.9.0","fflate": "0.8.2",- "three": "0.163.0"+ "three": "0.176.0"}},"node_modules/online-3d-viewer/node_modules/fflate": {@@ -23720,7 +23722,9 @@}},"node_modules/three": {- "version": "0.163.0",+ "version": "0.176.0",+ "resolved": "https://registry.npmjs.org/three/-/three-0.176.0.tgz",+ "integrity": "sha512-PWRKYWQo23ojf9oZSlRGH8K09q7nRSWx6LY/HF/UUrMdYgN9i1e2OwJYHoQjwc6HF/4lvvYLC5YC1X8UJL2ZpA==","license": "MIT"},"node_modules/throat": {@@ -27692,7 +27696,7 @@"input-otp": "^1.4.2","intl-parse-accept-language": "^1.0.0","is-hotkey": "^0.2.0",- "online-3d-viewer": "0.15.0",+ "online-3d-viewer": "0.18.0","prism-react-renderer": "^2.3.1","react-aria-components": "1.0.1","react-colorful": "^5.6.1",diff --git a/packages/react/package.json b/packages/react/package.jsonindex 1766665f7e..ff42496ffe 100644--- a/packages/react/package.json+++ b/packages/react/package.json@@ -65,7 +65,7 @@"input-otp": "^1.4.2","intl-parse-accept-language": "^1.0.0","is-hotkey": "^0.2.0",- "online-3d-viewer": "0.15.0",+ "online-3d-viewer": "0.18.0","prism-react-renderer": "^2.3.1","react-aria-components": "1.0.1","react-colorful": "^5.6.1",diff --git a/packages/react/src/ModelViewer.tsx b/packages/react/src/ModelViewer.tsxindex 8e9a578023..f1547f9ab1 100644--- a/packages/react/src/ModelViewer.tsx+++ b/packages/react/src/ModelViewer.tsx@@ -4,7 +4,7 @@ import { useLocale } from "react-aria-components";import * as THREE from "three";import { useMount } from "./hooks";import { IconButton } from "./IconButton";-import { Progress } from "./Progress";+import { Spinner } from "./Spinner";import { Tabs, TabsContent, TabsList, TabsTrigger } from "./Tabs";import { cn } from "./utils/cn";@@ -35,15 +35,12 @@ export function ModelViewer({const parentDiv = useRef<HTMLDivElement>(null);const viewerRef = useRef<OV.EmbeddedViewer | null>(null);const animationFrameRef = useRef<number | null>(null);- const progressIntervalRef = useRef<NodeJS.Timeout | null>(null);const [isLoading, setIsLoading] = useState(true);- const [loadingProgress, setLoadingProgress] = useState(0);- const [error, setError] = useState<string | null>(null);const [unitSystem, setUnitSystem] = useState<UnitSystem>("metric");const [modelInfo, setModelInfo] = useState<{- surfaceArea: number;- volume: number;dimensions: { x: number; y: number; z: number };+ surfaceArea: number | null;+ volume: number | null;} | null>(null);useMount(() => {@@ -63,102 +60,76 @@ export function ModelViewer({: new OV.RGBAColor(255, 255, 255, 0),defaultColor: new OV.RGBColor(0, 125, 125),onModelLoaded: () => {- try {- if (viewerRef.current) {- const viewer3D = viewerRef.current.GetViewer();- updateColor(color ?? (isDarkMode ? darkColor : lightColor));-- viewer3D.Resize(- parentDiv.current?.clientWidth,- parentDiv.current?.clientHeight- );+ if (viewerRef.current) {+ const viewer3D = viewerRef.current.GetViewer();+ updateColor(color ?? (isDarkMode ? darkColor : lightColor));++ viewer3D.Resize(+ parentDiv.current?.clientWidth,+ parentDiv.current?.clientHeight+ );- const boundingSphere = viewer3D.GetBoundingSphere(() => true);- if (boundingSphere) {- const scene = viewer3D.scene;- const center = boundingSphere.center;- const radius = boundingSphere.radius;- const camera = viewer3D.GetCamera();- const direction = new OV.Coord3D(1, 1, 1);- const eye = new OV.Coord3D(- center.x + direction.x * radius * 1.5,- center.y + direction.y * radius * 1.5,- center.z + direction.z * radius * 1.5- );- camera.center = center;- camera.eye = eye;- camera.up = new OV.Coord3D(0, 1, 0);- viewer3D.SetCamera(camera);-- // Add ambient light for overall illumination- const ambientLight = new THREE.AmbientLight(0xffffff, 0.5);- scene.add(ambientLight);-- // Add directional lights for isometric highlights- const dirLight1 = new THREE.DirectionalLight(0xffffff, 0.8);- dirLight1.position.set(1, 1, 1);- scene.add(dirLight1);-- const dirLight2 = new THREE.DirectionalLight(0xffffff, 0.4);- dirLight2.position.set(-1, 0.5, -1);- scene.add(dirLight2);-- // Add subtle point light for depth- const pointLight = new THREE.PointLight(0xffffff, 0.3);- pointLight.position.set(0, radius * 2, 0);- scene.add(pointLight);-- viewer3D.Render();- }-- let model;- if (withProperties) {- model = viewer.GetModel();- }-- if (model) {- // Calculate model dimensions and properties- const boundingBox = OV.GetBoundingBox(model);- const surfaceArea = OV.CalculateSurfaceArea(model);- const volume = OV.CalculateVolume(model);- const dimensions = {- x: boundingBox.max.x - boundingBox.min.x,- y: boundingBox.max.y - boundingBox.min.y,- z: boundingBox.max.z - boundingBox.min.z- };-- setModelInfo({- surfaceArea,- volume,- dimensions- });- }+ const boundingSphere = viewer3D.GetBoundingSphere(() => true);+ if (boundingSphere) {+ const scene = viewer3D.scene;+ const center = boundingSphere.center;+ const radius = boundingSphere.radius;+ const camera = viewer3D.GetCamera();+ const direction = new OV.Coord3D(1, 1, 1);+ const eye = new OV.Coord3D(+ center.x + direction.x * radius * 1.5,+ center.y + direction.y * radius * 1.5,+ center.z + direction.z * radius * 1.5+ );+ camera.center = center;+ camera.eye = eye;+ camera.up = new OV.Coord3D(0, 1, 0);+ viewer3D.SetCamera(camera);++ // Add ambient light for overall illumination+ const ambientLight = new THREE.AmbientLight(0xffffff, 0.5);+ scene.add(ambientLight);++ // Add directional lights for isometric highlights+ const dirLight1 = new THREE.DirectionalLight(0xffffff, 0.8);+ dirLight1.position.set(1, 1, 1);+ scene.add(dirLight1);++ const dirLight2 = new THREE.DirectionalLight(0xffffff, 0.4);+ dirLight2.position.set(-1, 0.5, -1);+ scene.add(dirLight2);++ // Add subtle point light for depth+ const pointLight = new THREE.PointLight(0xffffff, 0.3);+ pointLight.position.set(0, radius * 2, 0);+ scene.add(pointLight);++ viewer3D.Render();}- // Clear progress interval and set to 100%- if (progressIntervalRef.current) {- clearInterval(progressIntervalRef.current);- progressIntervalRef.current = null;+ let model;+ if (withProperties) {+ model = viewer.GetModel();}- setLoadingProgress(100);-- // Small delay before hiding loading state to show 100% completion- setTimeout(() => {- setIsLoading(false);- setError(null);- }, 200);- } catch (err) {- if (progressIntervalRef.current) {- clearInterval(progressIntervalRef.current);- progressIntervalRef.current = null;++ if (model) {+ // Calculate only dimensions (fast) - surface area and volume are on-demand+ const boundingBox = OV.GetBoundingBox(model);+ const dimensions = {+ x: boundingBox.max.x - boundingBox.min.x,+ y: boundingBox.max.y - boundingBox.min.y,+ z: boundingBox.max.z - boundingBox.min.z+ };++ setModelInfo({+ dimensions,+ surfaceArea: null,+ volume: null+ });}- setError(- err instanceof Error- ? err.message- : "Failed to initialize model viewer"- );- setIsLoading(false);}++ setIsLoading(false);}});@@ -166,8 +137,7 @@ export function ModelViewer({if (file) {loadFile(file);- }- if (url) {+ } else if (url) {loadUrl(url);}}@@ -180,12 +150,6 @@ export function ModelViewer({animationFrameRef.current = null;}- // Clear progress interval- if (progressIntervalRef.current) {- clearInterval(progressIntervalRef.current);- progressIntervalRef.current = null;- }-if (viewerRef.current !== null && parentDiv.current !== null) {delete viewerRef.current.model;viewerRef.current.viewer.renderer.resetState();@@ -307,15 +271,15 @@ export function ModelViewer({switch (viewType) {case "front":eye = new OV.Coord3D(center.x, center.y, center.z + distance);- up = new OV.Coord3D(0, 1, 0); // Standard up for front view+ up = new OV.Coord3D(0, 1, 0);break;case "top":eye = new OV.Coord3D(center.x, center.y + distance, center.z);- up = new OV.Coord3D(0, 0, -1); // Looking down, up vector points towards negative Z+ up = new OV.Coord3D(0, 0, -1);break;case "side":eye = new OV.Coord3D(center.x + distance, center.y, center.z);- up = new OV.Coord3D(0, 1, 0); // Standard up for side view+ up = new OV.Coord3D(0, 1, 0);break;case "isometric":default:@@ -324,7 +288,7 @@ export function ModelViewer({center.y + radius * 1.5,center.z + radius * 1.5);- up = new OV.Coord3D(0, 1, 0); // Standard up for isometric+ up = new OV.Coord3D(0, 1, 0);break;}@@ -339,35 +303,7 @@ export function ModelViewer({const viewer = viewerRef.current;if (!viewer) return;- setError(null);- setLoadingProgress(0);-- // Clear any existing progress interval- if (progressIntervalRef.current) {- clearInterval(progressIntervalRef.current);- }-- try {- // Simulate progress for file loading- progressIntervalRef.current = setInterval(() => {- setLoadingProgress((prev) => {- if (prev >= 90) {- return prev;- }- return prev + 10;- });- }, 100);-- viewer.LoadModelFromFileList([file]);- } catch (err) {- if (progressIntervalRef.current) {- clearInterval(progressIntervalRef.current);- }- setError(- err instanceof Error ? err.message : "Failed to load model file"- );- setIsLoading(false);- }+ viewer.LoadModelFromFileList([file]);}function loadUrl(url: string) {@@ -375,34 +311,7 @@ export function ModelViewer({if (!viewerRef.current) return;const viewer = viewerRef.current;if (!viewer) return;-- setError(null);- setLoadingProgress(0);-- // Clear any existing progress interval- if (progressIntervalRef.current) {- clearInterval(progressIntervalRef.current);- }-- try {- // Simulate progress for URL loading- progressIntervalRef.current = setInterval(() => {- setLoadingProgress((prev) => {- if (prev >= 90) {- return prev;- }- return prev + 10;- });- }, 100);-- viewer.LoadModelFromUrlList([url]);- } catch (err) {- if (progressIntervalRef.current) {- clearInterval(progressIntervalRef.current);- }- setError(err instanceof Error ? err.message : "Failed to load model URL");- setIsLoading(false);- }+ viewer.LoadModelFromUrlList([url]);}function updateColor(color: string) {@@ -520,103 +429,62 @@ export function ModelViewer({role={"img"}aria-label="Canvas showing the model in the 3D Viewer"className={cn(- "h-full w-full tems-center justify-center rounded-lg border border-border bg-gradient-to-bl from-card from-50% via-card to-background min-h-[400px] shadow-md dark:border-none dark:shadow-[inset_0_0.5px_0_rgb(255_255_255_/_0.08),_inset_0_0_1px_rgb(255_255_255_/_0.24),_0_0_0_0.5px_rgb(0,0,0,1),0px_0px_4px_rgba(0,_0,_0,_0.08)] relative",+ "h-full w-full items-center justify-center rounded-lg border border-border bg-gradient-to-bl from-card from-50% via-card to-background min-h-[400px] shadow-md dark:border-none dark:shadow-[inset_0_0.5px_0_rgb(255_255_255_/_0.08),_inset_0_0_1px_rgb(255_255_255_/_0.24),_0_0_0_0.5px_rgb(0,0,0,1),0px_0px_4px_rgba(0,_0,_0,_0.08)] relative",className)}>{isLoading ? (- <div className="absolute inset-0 bg-card h-full w-full flex flex-col gap-3 items-center justify-center">- {loadingProgress > 0 && (- <div className="flex flex-col items-center gap-2">- <Progress- value={loadingProgress}- className="w-48"- indicatorClassName="bg-foreground"- />- <span className="text-xs text-muted-foreground">- Loading model... {loadingProgress}%- </span>- </div>- )}- </div>- ) : error ? (- <div className="absolute inset-0 bg-card h-full w-full flex flex-col gap-3 items-center justify-center p-6 text-center">- <svg- xmlns="http://www.w3.org/2000/svg"- width="48"- height="48"- viewBox="0 0 24 24"- fill="none"- stroke="currentColor"- strokeWidth="2"- strokeLinecap="round"- strokeLinejoin="round"- className="text-destructive"- >- <circle cx="12" cy="12" r="10" />- <line x1="12" y1="8" x2="12" y2="12" />- <line x1="12" y1="16" x2="12.01" y2="16" />- </svg>- <div>- <h3 className="font-semibold text-sm mb-1">- Failed to load model- </h3>- <p className="text-xs text-muted-foreground max-w-md">{error}</p>- </div>+ <div className="absolute inset-0 bg-card h-full w-full flex items-center justify-center">+ <Spinner className="w-10 h-10" /></div>) : (<><pre id="model-viewer-canvas" aria-hidden className="sr-only" />{resetZoomButton && (- <div className="absolute bottom-2 right-2 z-20 flex flex-col gap-1">- <div className="flex gap-1">- <IconButton- aria-label="Reset zoom"- icon={- <svg- xmlns="http://www.w3.org/2000/svg"- width="20"- height="20"- viewBox="0 0 24 24"- fill="none"- stroke="currentColor"- strokeWidth="2"- strokeLinecap="round"- strokeLinejoin="round"- >- <path d="M3 7V5a2 2 0 0 1 2-2h2" />- <path d="M17 3h2a2 2 0 0 1 2 2v2" />- <path d="M21 17v2a2 2 0 0 1-2 2h-2" />- <path d="M7 21H5a2 2 0 0 1-2-2v-2" />- <rect width="10" height="8" x="7" y="8" rx="1" />- </svg>- }- variant="ghost"- onClick={resetZoom}- />- <IconButton- aria-label="Front view"- className="h-7 w-7"- icon={<span className="text-[10px] font-semibold">F</span>}- variant="ghost"- onClick={() => setCameraView("front")}- />- <IconButton- aria-label="Top view"- className="h-7 w-7"- icon={<span className="text-[10px] font-semibold">T</span>}- variant="ghost"- onClick={() => setCameraView("top")}- />- <IconButton- aria-label="Side view"- className="h-7 w-7"- icon={<span className="text-[10px] font-semibold">S</span>}- variant="ghost"- onClick={() => setCameraView("side")}- />- </div>+ <div className="absolute bottom-2 right-2 z-20 flex gap-1">+ <IconButton+ aria-label="Reset zoom"+ icon={+ <svg+ xmlns="http://www.w3.org/2000/svg"+ width="24"+ height="24"+ viewBox="0 0 24 24"+ fill="none"+ stroke="currentColor"+ strokeWidth="2"+ strokeLinecap="round"+ strokeLinejoin="round"+ >+ <path d="M3 7V5a2 2 0 0 1 2-2h2" />+ <path d="M17 3h2a2 2 0 0 1 2 2v2" />+ <path d="M21 17v2a2 2 0 0 1-2 2h-2" />+ <path d="M7 21H5a2 2 0 0 1-2-2v-2" />+ <rect width="10" height="8" x="7" y="8" rx="1" />+ </svg>+ }+ variant="ghost"+ onClick={resetZoom}+ />+ <IconButton+ aria-label="Front view"+ icon={<span className="text-xs font-bold">F</span>}+ variant="ghost"+ onClick={() => setCameraView("front")}+ />+ <IconButton+ aria-label="Top view"+ icon={<span className="text-xs font-bold">T</span>}+ variant="ghost"+ onClick={() => setCameraView("top")}+ />+ <IconButton+ aria-label="Side view"+ icon={<span className="text-xs font-bold">S</span>}+ variant="ghost"+ onClick={() => setCameraView("side")}+ /></div>)}{modelInfo && withProperties && (