Options
All
  • Public
  • Public/Protected
  • All
Menu

@pattern-x/gemini-viewer-threejs

gemini-viewer

gemini-viewer is a WebGL based JS SDK. It provides DxfViewer used to view 2d drawings.

Installation

To install from npm:

npm install @pattern-x/gemini-viewer-threejs

Examples for DxfViewer

import { DxfViewer, DxfViewerConfig, DxfModelConfig } from "@pattern-x/gemini-viewer-threejs";

const viewerCfg: DxfViewerConfig = {
containerId: "myCanvas",
enableSpinner: true,
enableLayoutBar: true,
};
const modelCfg: DxfModelConfig = {
modelId: "id_0",
name: "sample",
src: "http://www.abc.com/sample.dxf",
}
const fontFiles = ["http://www.abc.com/hztxt.shx", "http://www.abc.com/simplex.shx"];

const viewer = new DxfViewer(viewerCfg);
await viewer.setFont(fontFiles);
await viewer.loadModelAsync(modelCfg, (event) => {
const progress = (event.loaded * 100) / event.total;
console.log(`Loading progress: ${progress}%`);
});
console.log("Loaded");
viewer.goToHomeView();

Project setup

npm install

Compiles and hot-reloads for development

npm start

Compiles and minifies for production

npm run build

Lints and fixes files

npm run lint

Documentation

npm run docs

Documents will be generated into "./docs" folder.

Upgrade draco

  • Once three.js is upgraded, we'll also need to update draco source files.
    • draco is configed in BimViewer.ts, const decoderPath = 'libs/draco/gltf/', which is a path that must be available from network. We'll need to:
    • Copy node_modules/three/examples/jsm/libs/draco folder to public/three/js/libs/draco
    • This is important because there can be error if the code doesn't match.

Upgrade web-ifc.wasm

wasm is required in order to load ifc file, we'll need to copy: node_modules/three/examples/jsm/loaders/ifc/web-ifc.wasm to /public/three/js/libs/ifc/


End

Generated using TypeDoc