Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 5 additions & 4 deletions opencad_viewport/src/App.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,8 @@ import { ChatPanel } from "./components/ChatPanel";
import { FeatureTreePanel } from "./components/FeatureTreePanel";
import { SketchEditor } from "./components/SketchEditor";
import { Viewport3D } from "./components/Viewport3D";
import { mockFeatureTree, mockMeshes, mockSketch } from "./mock/mockData";
import { mockMeshes } from "./mock/mockData";
import { createEmptyTree, createEmptySketch } from "./types";
import type { ChatOperationExecution, FeatureNodeView, FeatureTreeView, MeshPayload, SketchPayload } from "./types";

const FALLBACK_MESH_Y_OFFSET_SCALE = 0.35;
Expand Down Expand Up @@ -56,9 +57,9 @@ function createFallbackMesh(node: FeatureNodeView, index: number): MeshPayload {

export default function App(): JSX.Element {
const api = useMemo(() => new OpenCadApiClient(), []);
const [tree, setTree] = useState<FeatureTreeView>(mockFeatureTree);
const [meshes, setMeshes] = useState<MeshPayload[]>(mockMeshes);
const [sketch, setSketch] = useState<SketchPayload>(mockSketch);
const [tree, setTree] = useState<FeatureTreeView>(createEmptyTree);
const [meshes, setMeshes] = useState<MeshPayload[]>([]);
const [sketch, setSketch] = useState<SketchPayload>(createEmptySketch);
const [selectedNodeId, setSelectedNodeId] = useState<string>(tree.root_id);

const selectedShapeId = tree.nodes[selectedNodeId]?.shape_id ?? null;
Expand Down
14 changes: 14 additions & 0 deletions opencad_viewport/src/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,16 @@ export interface FeatureTreeView {
revision: number;
}

export function createEmptyTree(): FeatureTreeView {
return {
root_id: "root",
active_branch: "main",
revision: 0,
nodes: {
},
};
}

export interface MeshPayload {
shapeId: string;
vertices: number[] | Float32Array;
Expand Down Expand Up @@ -84,6 +94,10 @@ export interface SketchPayload {
constraints: SketchConstraint[];
}

export function createEmptySketch(): SketchPayload {
return { entities: {}, constraints: [] };
}

export interface SolverResult {
status: "SOLVED" | "OVERCONSTRAINED" | "UNDERCONSTRAINED";
sketch: SketchPayload;
Expand Down
Loading