Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

vim-webgl-viewer

Package Overview
Dependencies
Maintainers
1
Versions
698
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

vim-webgl-viewer

A high-performance 3D viewer and VIM file loader built on top of Three.JS.

  • 1.0.0-dev.2
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
134
decreased by-41.99%
Maintainers
1
Weekly downloads
 
Created
Source

VIM Three.JS 3D Viewer

The VIM Three.JS 3D Viewer is an open-source and easy to configure and use 3D model viewer built as a thin wrapper on top of the popular Three.JS WebGL framework. It is enhanced with a loader for the VIM format which is specialized in the transfer of large AEC data.

The VIM Three.JS 3D viewer combines the Three.JS library with several common loaders and utilities, to reduce boilerplate code. It can be simply included via script tags or consumed using esm imports.

Running Locally:

  • Checkout repo

  • Run npm install to install all dependencies

  • Run npm run dev to launch a dev-server and watching for changes

  • Run npm run build to compile and bundle everything for publishing. Resulting files end up in ./dist

  • Navigate to http://localhost:3000 in your browser

Contributing:

  • Source code is formatted using prettier-eslint using the standardjs format.
  • On VSCode it is recommended to install ESLint and Prettier ESLint extensions.

Features

  • Orbit controls - movement with the mouse
  • Default scene set-up:
    • Ground plane
    • Two shadowed lights
    • Slow model rotation
  • Automatic phong material
  • UI controls for changing various settings
  • Frame rate and memory statistics

Supported File Formats

  • .vim
  • .obj
  • .ply
  • .stl
  • .g3d
  • .dae
  • .3ds
  • .pdb
  • .pcb
  • .gcode
  • .gltf
  • .fbx

Using the Model Viewer

Virtually the simplest usage of the VIM viewer is the following example:

<html>
<head>
    <title>VIM Viewer</title>
</head>
<body>
    <script src="https://unpkg.com/three@0.133.1/build/three.min.js"></script>
    <script src="./vim-webgl-viewer.iife.js"></script>
    <script>
        var viewer = new vim.Viewer();
        viewer.view({
            url: 'https://vim.azureedge.net/samples/residence.vim',
            object: {
                rotation: { x: 270 },
            },
            plane: {
                show: false
            },
            showStats: true
        });
    </script> 
</body>
</html>

If you want to use esm imports, you do it as follows:

// This will work if you use a bundler and installed the viewer via npm
import { Viewer } from 'vim-webgl-viewer'

// That will work if you use the bundled file directly
// However, you still need to have threejs installed via npm and use a bundler
import { Viewer } from './dist/vim-webgl-viewer.es.js'

const viewer = new Viewer();
viewer.view({
    url: './residence.vim',
    object: {
        scale: 0.1,
        rotation: { x: 270 },
        position: { y: 0 }
    },
    plane: {
        show: false
    },
    showStats: true
});

API

TBD

The Sources and Dependencies

The distributable file vim-webgl-viewer.iife.js does not contain the underlying source for Three.JS to avoid duplication. Please include Three.JS on your own. However, it comes bundled with:

  • Dat.GUI
  • The vim-webgl-viewer.js source file which encapsulates common Three JS boiler plate

Meshes, Nodes and Elements

The viewer is broadly divided into three layer.

Meshes: The scene is rendered using a collection of InstancedMesh, specific object are refered by a (Mesh, instanceIndex) pair.
Nodes: The vim scene is a collection of nodes with a transform and a geometry, each node will result in zero or one object added to Three to be rendered. Nodes are refered by Index.
Elements: objects from the original the bim software containing rich data. Each element can have from 0 to N nodes associated with it. Elements are refered to by Id or Index.

Exemple:
A table from Revit has elementId 12321
it gets exported into 5 nodes, 4 legs and a table top.
the 5 nodes are rendered using 2 meshes, one for the table top, one for all 4 legs.

Keywords

FAQs

Package last updated on 30 Oct 2021

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc