### Clone and Build Project from Source Source: https://ifclite.dev/docs/guide/installation Commands to clone the repository, install dependencies, and start the development viewer. ```bash # Clone the repository GIT_LFS_SKIP_SMUDGE=1 git clone https://github.com/LTplus-AG/ifc-lite.git cd ifc-lite # Install dependencies pnpm install # Build all packages (uses pre-built WASM) pnpm build # Start the viewer pnpm dev ``` -------------------------------- ### Install Client Dependencies Source: https://ifclite.dev/docs/guide/quickstart Install the required client and renderer packages via npm. ```bash npm install @ifc-lite/server-client @ifc-lite/renderer ``` -------------------------------- ### Install @ifc-lite packages Source: https://ifclite.dev/docs/tutorials/threejs-integration Install the necessary parser and data packages via npm. ```bash npm install @ifc-lite/parser @ifc-lite/data ``` -------------------------------- ### Install and Run IFCLite Native Binary Source: https://ifclite.dev/docs/guide/installation Methods for installing the server via npm and executing the binary directly or via npx. ```bash # Install the server-bin package npm install -g @ifc-lite/server-bin # Start the server (downloads binary on first run) ifc-lite-server # Or use npx npx @ifc-lite/server-bin ``` -------------------------------- ### Start the IFC Lite Server Source: https://ifclite.dev/docs/guide/quickstart Commands to launch the server using Docker or the native binary. ```bash # Using Docker docker run -p 3001:8080 ghcr.io/ltplus-ag/ifc-lite-server # Or using native binary npx @ifc-lite/server-bin ``` -------------------------------- ### Start the IFClite Server Source: https://ifclite.dev/docs/guide/server Methods to launch the server using Docker, the npm binary, or from source. ```shell docker run -p 3001:8080 \ -v ifc-cache:/app/cache \ ghcr.io/ltplus-ag/ifc-lite-server ``` ```shell npx @ifc-lite/server-bin ``` ```shell cd apps/server cargo run --release ``` -------------------------------- ### Verifying Client-Side Installation Source: https://ifclite.dev/docs/guide/installation Verify the parser installation by loading an IFC file and checking schema metadata. ```javascript import { IfcParser } from '@ifc-lite/parser'; const parser = new IfcParser(); const buffer = await fetch('model.ifc').then(r => r.arrayBuffer()); const store = await parser.parseColumnar(buffer); console.log('Schema:', store.schemaVersion); console.log('Entities:', store.entityCount); ``` -------------------------------- ### Install Python Geometry Library Source: https://ifclite.dev/docs/guide/installation Install the native geometry tessellation package for Python. ```bash pip install ifclite-geom ``` -------------------------------- ### Initialize Project and Dependencies Source: https://ifclite.dev/docs/tutorials/building-viewer Commands to create a new Vite project with TypeScript and install the required IFC-lite packages. ```bash # Create new project mkdir my-ifc-viewer cd my-ifc-viewer # Initialize with Vite + TypeScript npm create vite@latest . -- --template vanilla-ts # Install dependencies npm install @ifc-lite/parser @ifc-lite/geometry @ifc-lite/renderer @ifc-lite/query ``` -------------------------------- ### Install IFClite packages Source: https://ifclite.dev/docs/guide/quickstart Add the core parser, geometry, and renderer packages to an existing project. ```bash npm install @ifc-lite/parser @ifc-lite/geometry @ifc-lite/renderer ``` -------------------------------- ### Install IFClite Packages via Package Manager Source: https://ifclite.dev/docs/guide/installation Install core, rendering, server, or IFC5 support packages using your preferred package manager. ```bash # Core parsing (client-side) pnpm add @ifc-lite/parser # With rendering pnpm add @ifc-lite/parser @ifc-lite/geometry @ifc-lite/renderer # Server client SDK pnpm add @ifc-lite/server-client # IFC5 support pnpm add @ifc-lite/ifcx ``` ```bash # Core parsing (client-side) npm install @ifc-lite/parser # With rendering npm install @ifc-lite/parser @ifc-lite/geometry @ifc-lite/renderer # Server client SDK npm install @ifc-lite/server-client # IFC5 support npm install @ifc-lite/ifcx ``` ```bash # Core parsing (client-side) yarn add @ifc-lite/parser # With rendering yarn add @ifc-lite/parser @ifc-lite/geometry @ifc-lite/renderer # Server client SDK yarn add @ifc-lite/server-client # IFC5 support yarn add @ifc-lite/ifcx ``` -------------------------------- ### Install R3F dependencies Source: https://ifclite.dev/docs/tutorials/threejs-integration Install the required packages for IFC-Lite geometry processing and React-Three-Fiber integration. ```bash npm install @ifc-lite/geometry three @react-three/fiber @react-three/drei ``` -------------------------------- ### Spatial Indexing and Frustum Culling Example Source: https://ifclite.dev/docs/api/typescript Demonstrates initializing geometry, building a spatial index, and rendering with frustum culling enabled. ```typescript import { GeometryProcessor } from '@ifc-lite/geometry'; import { buildSpatialIndex } from '@ifc-lite/spatial'; import { Renderer } from '@ifc-lite/renderer'; const geometry = new GeometryProcessor(); await geometry.init(); const result = await geometry.process(new Uint8Array(buffer)); // Build spatial index for frustum culling const spatialIndex = buildSpatialIndex(result.meshes); const renderer = new Renderer(canvas); await renderer.init(); renderer.loadGeometry(result); // Render with frustum culling renderer.render({ enableFrustumCulling: true, spatialIndex }); ``` -------------------------------- ### Complex SQL Query Examples Source: https://ifclite.dev/docs/guide/querying Advanced SQL examples for joining relationships, calculating aggregates, and filtering based on missing properties. ```sql -- Find walls with their storey names -- ContainsElements edges run storey (source_id) -> element (target_id) SELECT e.express_id, e.name as wall_name, s.name as storey_name FROM entities e JOIN relationships r ON e.express_id = r.target_id JOIN entities s ON r.source_id = s.express_id WHERE e.type LIKE 'IfcWall%' AND r.rel_type = 'ContainsElements' AND s.type = 'IfcBuildingStorey'; -- Calculate total area by entity type SELECT e.type, SUM(q.value) as total_area FROM entities e JOIN quantities q ON e.express_id = q.entity_id WHERE q.quantity_name = 'NetArea' GROUP BY e.type ORDER BY total_area DESC; -- Find walls with missing fire ratings SELECT e.express_id, e.name, e.type FROM entities e WHERE e.type LIKE 'IfcWall%' AND NOT EXISTS ( SELECT 1 FROM properties p WHERE p.entity_id = e.express_id AND p.pset_name = 'Pset_WallCommon' AND p.prop_name = 'FireRating' ); ``` -------------------------------- ### Install IFC Lite dependencies manually Source: https://ifclite.dev/docs/tutorials/threejs-integration Add the required geometry and Three.js packages to an existing project. ```bash npm install @ifc-lite/geometry three npm install -D @types/three ``` -------------------------------- ### Initialize Main Application Entry Point Source: https://ifclite.dev/docs/tutorials/building-viewer Sets up the viewer instance, event listeners for file loading, and property selection callbacks. ```typescript // src/main.ts import { IfcViewer } from './viewer'; import { updateStatus, renderProperties } from './ui'; import './style.css'; async function main() { // Get elements const canvas = document.getElementById('viewer') as HTMLCanvasElement; const fileInput = document.getElementById('file-input') as HTMLInputElement; const propertiesPanel = document.getElementById('properties') as HTMLElement; // Create viewer const viewer = new IfcViewer(canvas); // Set up callbacks viewer.onProgress = updateStatus; // onProgress delivers a "phase: percent%" string viewer.onSelect = (expressId) => { if (expressId) { const entity = viewer.getEntity(expressId); const props = viewer.getProperties(expressId); if (entity) { renderProperties(propertiesPanel, expressId, entity, props || []); } } else { propertiesPanel.innerHTML = '
Click an element to view properties
'; } }; // Initialize try { await viewer.init(); updateStatus('Ready - Drop an IFC file'); } catch (error) { updateStatus('WebGPU not supported'); console.error(error); return; } // File input handler fileInput.addEventListener('change', async () => { const file = fileInput.files?.[0]; if (!file) return; updateStatus(`Loading ${file.name}...`); try { const result = await viewer.loadFile(file); updateStatus(`Loaded ${result.entityCount} entities`); } catch (error) { updateStatus('Error loading file'); console.error(error); } }); } main(); ``` -------------------------------- ### Initialize IFClite Projects with CLI Source: https://ifclite.dev/docs/guide/installation Use the create-ifc-lite CLI to scaffold projects based on specific templates. ```bash npx create-ifc-lite my-app cd my-app npm install npm run parse sample.ifc ``` ```bash npx create-ifc-lite my-viewer --template react cd my-viewer npm install npm run dev ``` ```bash npx create-ifc-lite my-viewer --template threejs cd my-viewer npm install npm run dev ``` ```bash npx create-ifc-lite my-viewer --template babylonjs cd my-viewer npm install npm run dev ``` ```bash npx create-ifc-lite my-backend --template server cd my-backend npm install npm run server:start npm run example sample.ifc ``` ```bash npx create-ifc-lite my-backend --template server-native cd my-backend npm install npm run server:start ``` -------------------------------- ### Prototyping with CDN Source: https://ifclite.dev/docs/guide/installation Use this for quick prototyping without a build step. Requires an HTTP server environment. ```html ``` -------------------------------- ### GET /api/v1/health Source: https://ifclite.dev/docs/guide/server Performs a liveness health check on the server. ```APIDOC ## GET /api/v1/health ### Description Performs a liveness health check on the server. This endpoint is always open. ### Method GET ### Endpoint /api/v1/health ``` -------------------------------- ### Connect to Server from Client Source: https://ifclite.dev/docs/guide/server Initialize the server client and perform a health check. ```javascript import { IfcServerClient } from '@ifc-lite/server-client'; const client = new IfcServerClient({ baseUrl: 'http://localhost:3001' }); // Health check const health = await client.health(); console.log('Server status:', health.status); ``` -------------------------------- ### GET /api/v1/cache/check/{hash} Source: https://ifclite.dev/docs/guide/server Checks if a file is cached based on its hash. ```APIDOC ## GET /api/v1/cache/check/{hash} ### Description Checks if a file is cached based on its hash. Returns 200 if cached, 404 otherwise. ### Method GET ### Endpoint /api/v1/cache/check/{hash} ### Parameters #### Path Parameters - **hash** (string) - Required - The hash of the file to check. ``` -------------------------------- ### Scaffold a new IFC Lite project Source: https://ifclite.dev/docs/tutorials/threejs-integration Use the CLI to initialize a project with the Three.js template. ```bash npx create-ifc-lite my-viewer --template threejs cd my-viewer npm install npm run dev ``` -------------------------------- ### Build IFCLite Server from Source Source: https://ifclite.dev/docs/guide/installation Compiling the server binary from the repository workspace using Cargo. ```bash cargo build --release -p ifc-lite-server ./target/release/ifc-lite-server ``` -------------------------------- ### Run development and production commands Source: https://ifclite.dev/docs/tutorials/building-viewer Use these commands to manage the application lifecycle during development and deployment. ```bash # Start development server npm run dev # Build for production npm run build ``` -------------------------------- ### Initialize and parse IFC via CLI Source: https://ifclite.dev/docs Use the create-ifc-lite tool to scaffold a new project and parse an IFC file directly from the command line. ```bash npx create-ifc-lite my-app cd my-app && npm install && npm run parse ./model.ifc ``` -------------------------------- ### Scaffold Three.js or Babylon.js viewers Source: https://ifclite.dev/docs Use the CLI to generate projects pre-configured for Three.js or Babylon.js integration. ```bash npx create-ifc-lite my-viewer --template threejs # Three.js npx create-ifc-lite my-viewer --template babylonjs # Babylon.js ``` -------------------------------- ### Initialize Client and Load IFC File Source: https://ifclite.dev/docs/guide/quickstart Connect to the server and parse an IFC file using the Parquet format for optimized performance. ```typescript import { IfcServerClient } from '@ifc-lite/server-client'; import { Renderer } from '@ifc-lite/renderer'; async function main() { const canvas = document.getElementById('viewer') as HTMLCanvasElement; const renderer = new Renderer(canvas); await renderer.init(); // Connect to server const client = new IfcServerClient({ baseUrl: 'http://localhost:3001' }); // Load file (input element or drag-drop) const fileInput = document.getElementById('file-input') as HTMLInputElement; const file = fileInput?.files?.[0]; if (!file) return; // Parse with Parquet format (15x smaller than JSON) const result = await client.parseParquet(file); console.log(`Parsed ${result.meshes.length} meshes`); console.log(`Cache key: ${result.cache_key}`); // On repeat loads, the server will return cached data instantly // (client computes file hash and checks cache before uploading) } main(); ``` -------------------------------- ### Initialize and render a model Source: https://ifclite.dev/docs/guide/quickstart Shows how to initialize the renderer and load geometry using either streaming or the GeometryProcessor. ```typescript import { Renderer } from '@ifc-lite/renderer'; import { GeometryProcessor } from '@ifc-lite/geometry'; const canvas = document.getElementById('viewer') as HTMLCanvasElement; const renderer = new Renderer(canvas); await renderer.init(); // Option 1: Add meshes from server response (streaming) renderer.addMeshes(result.meshes); // Option 2: Load geometry from GeometryProcessor result const geometry = new GeometryProcessor(); await geometry.init(); const meshes = []; for await (const event of geometry.processAdaptive(new Uint8Array(buffer))) { if (event.type === 'batch') meshes.push(...event.meshes); } renderer.loadGeometry(meshes); // Fit camera to model renderer.fitToView(); // Start render loop function animate() { renderer.render(); requestAnimationFrame(animate); } animate(); ``` -------------------------------- ### Deployment Commands Source: https://ifclite.dev/docs/guide/server Common CLI commands for deploying the server to Railway, Fly.io, and Kubernetes environments. ```bash # Railway deployment railway up # Fly.io deployment fly deploy # Kubernetes kubectl apply -f k8s/deployment.yaml ``` -------------------------------- ### Scaffold a server backend Source: https://ifclite.dev/docs Generate a backend project template for handling IFC files on the server. ```bash npx create-ifc-lite my-backend --template server cd my-backend && npm install && npm run server:start ``` -------------------------------- ### createBCFProject Source: https://ifclite.dev/docs/api/typescript Initializes a new BCF project instance. ```APIDOC ## createBCFProject(options?: { name?: string; version?: '2.1' | '3.0' }): BCFProject ### Description Creates a new BCFProject instance with optional name and version settings. ### Parameters - **options** (Object) - Optional - Configuration for the project including name and version ('2.1' or '3.0'). ### Response - **BCFProject** (Object) - The initialized project. ``` -------------------------------- ### IfcServerClient Constructor Source: https://ifclite.dev/docs/guide/server Initializes a new instance of the IfcServerClient. ```APIDOC ## IfcServerClient(options) ### Description Initializes the client with a base URL and optional timeout. ### Parameters - **options** (object) - Required - **baseUrl** (string) - Required - The server URL. - **timeout** (number) - Optional - Request timeout in milliseconds (default: 300000). ``` -------------------------------- ### Initialize IfcServerClient Source: https://ifclite.dev/docs/guide/server Instantiate the client with a base URL and optional timeout configuration. ```typescript import { IfcServerClient } from '@ifc-lite/server-client'; const client = new IfcServerClient({ baseUrl: 'http://localhost:3001', timeout: 300000 // 5 minutes (default) }); ``` -------------------------------- ### Initialize manual rendering pipeline Source: https://ifclite.dev/docs Manually configure the renderer and geometry processor to display IFC models in a canvas. ```javascript import { IfcParser } from '@ifc-lite/parser'; import { GeometryProcessor } from '@ifc-lite/geometry'; import { Renderer } from '@ifc-lite/renderer'; const renderer = new Renderer(canvas); await renderer.init(); const geometry = new GeometryProcessor(); await geometry.init(); const parser = new IfcParser(); const store = await parser.parseColumnar(buffer); const meshes = []; for await (const event of geometry.processAdaptive(new Uint8Array(buffer))) { if (event.type === 'batch') meshes.push(...event.meshes); } renderer.loadGeometry(meshes); renderer.fitToView(); renderer.render(); ``` -------------------------------- ### Run IFCLite Server with Docker Source: https://ifclite.dev/docs/guide/installation Commands to deploy the official IFCLite container, including options for persistent storage and environment variable configuration. ```bash # Run the official container docker run -p 3001:8080 ghcr.io/ltplus-ag/ifc-lite-server # With persistent cache docker run -p 3001:8080 -v ifc-cache:/app/cache ghcr.io/ltplus-ag/ifc-lite-server # With environment configuration docker run -p 3001:8080 \ -e RUST_LOG=info \ -e MAX_FILE_SIZE_MB=500 \ -e WORKER_THREADS=8 \ ghcr.io/ltplus-ag/ifc-lite-server ``` -------------------------------- ### BCF Project Creation and Mutation Source: https://ifclite.dev/docs/api/typescript Helpers for initializing BCF projects and managing topics, comments, and viewpoints. ```typescript function createBCFProject(options?: { name?: string; version?: '2.1' | '3.0' }): BCFProject; function createBCFTopic(options: { title: string; author: string; /* ... */ }): BCFTopic; function createBCFComment(options: { author: string; comment: string }): BCFComment; function addTopicToProject(project: BCFProject, topic: BCFTopic): void; function addCommentToTopic(topic: BCFTopic, comment: BCFComment): void; function addViewpointToTopic(topic: BCFTopic, viewpoint: BCFViewpoint): void; function updateTopicStatus(/* topic, status, ... */): void; ``` -------------------------------- ### Create an IFC file with IfcCreator Source: https://ifclite.dev/docs/api/typescript Initializes a new IFC project and adds a building storey and wall element. ```typescript import { IfcCreator } from '@ifc-lite/create'; const creator = new IfcCreator({ Name: 'My Project' }); const storey = creator.addIfcBuildingStorey({ Name: 'Ground Floor', Elevation: 0 }); creator.addIfcWall(storey, { Start: [0, 0, 0], End: [5, 0, 0], Thickness: 0.2, Height: 3, }); const { content } = creator.toIfc(); ``` -------------------------------- ### Scaffold a React-based viewer Source: https://ifclite.dev/docs Generate a new viewer project using the React template. ```bash npx create-ifc-lite my-viewer --template react cd my-viewer && npm install && npm run dev ``` -------------------------------- ### Implement IFC viewer logic Source: https://ifclite.dev/docs/guide/quickstart Initialize the renderer, process IFC geometry, and render the model in the browser. ```typescript // main.ts import { IfcParser } from '@ifc-lite/parser'; import { GeometryProcessor } from '@ifc-lite/geometry'; import { Renderer } from '@ifc-lite/renderer'; async function main() { // Get the canvas element const canvas = document.getElementById('viewer') as HTMLCanvasElement; // Initialize the renderer const renderer = new Renderer(canvas); await renderer.init(); // Initialize the geometry processor (loads WASM) const geometry = new GeometryProcessor(); await geometry.init(); // Load an IFC file const response = await fetch('model.ifc'); const buffer = await response.arrayBuffer(); // Parse the IFC file (columnar mode for best performance) const parser = new IfcParser(); const store = await parser.parseColumnar(buffer, { onProgress: ({ phase, percent }) => { console.log(`Parsing: ${phase} ${percent}%`); } }); console.log(`Parsed ${store.entityCount} entities`); // Process geometry from the IFC buffer const meshes = []; for await (const event of geometry.processAdaptive(new Uint8Array(buffer))) { if (event.type === 'batch') meshes.push(...event.meshes); } console.log(`Extracted ${meshes.length} meshes`); // Load geometry into renderer (creates GPU buffers and batches) renderer.loadGeometry(meshes); // Fit camera to model bounds renderer.fitToView(); // Example: Query entities from the parsed store // The store variable from parser.parseColumnar() is available here in the same scope const wallIds = store.entityIndex.byType.get('IFCWALL') ?? []; console.log(`Found ${wallIds.length} walls`); // Start render loop function animate() { renderer.render(); requestAnimationFrame(animate); } animate(); // Add camera controls (see below) setupCameraControls(canvas, renderer); } main(); ``` -------------------------------- ### ProjectParams Interface Source: https://ifclite.dev/docs/api/typescript Configuration interface for initializing a new IFC project. ```typescript interface ProjectParams { Name?: string; Description?: string; Schema?: 'IFC2X3' | 'IFC4' | 'IFC4X3'; LengthUnit?: string; // 'METRE' (default), 'MILLIMETRE', 'FOOT' Author?: string; Organization?: string; } ``` -------------------------------- ### GeometryProcessor.init() Source: https://ifclite.dev/docs/api/typescript Initializes the WASM environment. This must be called before any geometry processing or export operations. ```APIDOC ## init() ### Description Initializes the WASM kernel required for geometry processing. ### Signature `init(): Promise