1.0.8 • Published 2 years ago

@pattern-x/gemini-viewer v1.0.8

Weekly downloads
-
License
UNLICENSED
Repository
github
Last release
2 years ago

gemini-viewer

WebGL BIM Viewer based on xeoKit-sdk, written with TypeScript.

Installation

To install from npm:

npm install @pattern-x/gemini-viewer

Documentation

The documents are under the ./docs. To generate the documents:

npm run docs

Features

  • Orthographic camera ortho.gif

  • Distance measurement measure_dist.gif

  • Section plane section_plane.gif

  • Section box section_box.gif

  • Navigation cube select.gif

  • Pivot outline.gif

  • Context menu transparent.gif

Examples

To run the demo:

npm run demo

And then, visit demo.

Basic usages for Bimviewer is as followed. For more details, you could refference to gemini-viewer-ui which is a react project build up with gemini-viewer.

import { BimViewer, KeyBoardRotatePlugin } from "@pattern-x/gemini-viewer";

const project = {
    id: "technical_school_normal",
    name: "technical_school_normal",
    thumbnail: "/projects/technical_school_normal/thumbnail.png",
    camera: {
        eye: [-65, 37, 41],
        look: [-15, 0, 15],
        up: [0, 1, 0],
        far: 10000,
    },
    models: [
        {
            name: "technical school normal",
            src: "/projects/technical_school_normal/Technical_school-current_m.gltf",
            position: [0, 0, 0],
            rotation: [0, 0, 0],
            scale: [1, 1, 1],
            edges: true,
            visible: true,
        },
    ],
};

const bimViewer = new BimViewer(
    {
        canvasId: "myCanvas",
        // use default css if navCubeCanvasId or axisGizmoCanvasId not given
        // navCubeCanvasId: "myNavCubeCanvas",
        // axisGizmoCanvasId: "myAxisGizmoCanvas",
        swapYZ: true,
        activeOrthoMode: true,
        // locale: "en"
        skyBoxImgSrc: "images/skybox/default.png"
    },
    project.camera
);

new KeyBoardRotatePlugin(bimViewer.viewer);

// loadProjectModel
let counter = 0; // to indicate how many models are loading
project.models.forEach((modelCfg) => {
    if (modelCfg.visible === false) {
        // visible is true by default
        return; // only load visible ones
    }
    counter++;
    bimViewer.loadModel(modelCfg, (model) => {
        counter--;
        if (counter === 0) {
            if (bimViewer.has2dModel && !bimViewer.has3dModel) {
                bimViewer.active2dMode();
            }
        }
        // Do something with model
        // console.log("model:", model);

        // Gets the image data of the model canvas.
        // console.log(bimViewer.getCanvasImageDataUrl());
    });
});
...

BimViewer Configuration Summary

NameTypeAttributeDescription
canvasIdstringFor Xeokit Viewer.
enableNavCubeboolean- optional - default: trueShows the NavCube.
enableAxisGizmoboolean- optional - default: trueShows the AxisGizmo.
enableToolbarboolean- optional - default: trueShows the toolbar.
enableBottomBarboolean- optional - default: trueshows the bottom-bar.
enableContextMenuboolean- optional - default: trueShows the context-menu.
enableFastNavboolean- optional - default: trueEnables FastNav Viewer plugin that improves interactivity by disabling expensive rendering effects while the Camera is moving.
enableSingleSelectionboolean- optional - default: trueEnable single selection.
spinnerElementIdstring- optionalThe id of customized spinner element. For Xeokit Viewer.scene.
swapYZboolean- optional - default: falseSwaps Y / Z axis.
navCubeCanvasIdstring- optionalThe id of the customized canvas to draw NavCube. It will use the default NavCube when this param is empty.
axisGizmoCanvasIdstring- optionalThe id of the customized canvas to draw AxisGizmo. It will use the default AxisGizmo when this param is empty.
antialiasboolean- optionalFor Xeokit Viewer.scene.
transparentboolean- optionalFor Xeokit Viewer.scene.
gammaInputboolean- optionalFor Xeokit Viewer.scene.
gammaOutputboolean- optionalFor Xeokit Viewer.scene.
backgroundColornumber[]- optionalFor Xeokit Viewer.scene.canvas.
unitsstring- optional - default: "meters"For Xeokit Viewer.scene.metrics.
scalenumber- optionalFor Xeokit Viewer.scene.metrics.
originnumber[]- optionalFor Xeokit Viewer.scene.metrics.
saoEnabledboolean- optionalFor Xeokit Viewer.scene.sao.
pbrEnabledboolean- optionalFor Xeokit Viewer.scene.
activeOrthoModeboolean- optionalEnter ortho mode by default.
locale"cn" | "en"- optional - default: "cn"Sets the default locale.
skyBoxImgSrcstring- optionalThe image src of the skybox. It will use default background color when this param is empty.
1.0.8

2 years ago

1.0.7

2 years ago

1.0.6

2 years ago

1.0.2

3 years ago

1.0.5

3 years ago

1.0.4

3 years ago

1.0.3

3 years ago

1.0.1

3 years ago

1.0.0

3 years ago