https://vimaec.github.io/vim-webgl-viewer/api/
The VIM WebGL Viewer is an open-source high-performance 3D model viewer that specializes in loading extremely large AEC (Architectural/Engineering/Construction) models represented as VIM files.
It is built on top of the popular Three.JS WebGL framework to provide commonly used AEC related features. It can be simply included via script tags or consumed using esm imports.
The VIM file format is a high-performance 3D scene format that supports rich BIM data, and can be easily extended to support other relational or non-relation data sets.
Unlike IFC the VIM format is already tessellated, and ready to render. This results in very fast load times. Unlike glTF the VIM format is faster to load, scales better, and has a consistent structure for relational BIM data.
More information on the vim format can be found here: https://github.com/vimaec/vim
The following is an example of the simplest usage of the VIM viewer:
<html>
<head>
<title>VIM Viewer</title>
</head>
<style>
/*Makes full screen and remove scrollbars*/
html,
body {
height: 100%;
margin: 0;
padding: 0;
overflow: hidden;
/*This prevents touches from being eaten up by the browser.*/
touch-action: none;
}
</style>
<body>
<script src="https://unpkg.com/three@0.143.0"></script>
<script src="https://unpkg.com/vim-webgl-viewer@2.0.0"></script>
<script>
async function load(){
// Create a new viewer.
const viewer = new VIM.Viewer()
// Open the vim file.
const vim = await VIM.open(
'https://vim02.azureedge.net/samples/residence.v1.2.75.vim',
{
rotation: new VIM.THREE.Vector3(270, 0, 0)
}
)
// Load all geometry from vim file.
await vim.loadAll()
// Add loaded vim to the viewer.
viewer.add(vim)
// Immediately frame loaded vim.
viewer.camera.snap().frame(vim)
}
// Need function because you can't have top level async
load()
</script>
</body>
</html>
npm install
to install all dependenciesnpm run dev
to launch a dev-server and watch for changedocs
- this is the root folder for the GitHub page at https://vimaec.github.io/vim-webgl-viewer
. The docs\index.html
file is meant to demo the latest stable patch release, while the docs\index-dev.html
Is meant to test the latest dev release.src
- contains the TypeScript source code for the viewer.dist
- created by running the build script for creating a
distributable package. It contains five items after running the build
script:
dist\vim-webgl-viewer.es.js
- an EcmaScript moduledist\vim-webgl-viewer.es.js.map
- Typescript source map file map for the EcmaScript moduledist\vim-webgl-viewer.iife.js
- an immediately-invocable function expression (IIFE) intended for consumption from a web-pagedist\vim-webgl-viewer.iife.js.map
- Typescript source map file map for the IIFEtypes\
- A folder containing Typescript type declarations for the package.The following scripts are defined in the package.json, and can each be executed from within VSCode by right-clicking the script name, or from the command line by writing npm run <script-name>
where <script-name>
is the name of the script:
dev
- launches a development environment using Vitebuild
- compiles an IIFE JavaScript module and ES module using Vite and the configuration file, placing the output in the dist
folderserve-docs
- launches a web server with the docs
folder as the root folder, for testing a published NPM package (tagged develop or latest) locallyeslint
- runs ESLint and reports all syntactic inconsistenciesdocumentation
- generates API documentation at docs/api
declarations
- generates TypeScript declarations at dist/types
"The distributable files do not contain the underlying source for Three.JS to avoid duplication. Please include Three.JS on your own.
W/Up: Move camera forward
A/Left: Move camera to the left
S/Down: Move camera backward
D/Right: Move camera to the right
E: Move camera up
Q: Move camera down
Shift + direction: faster camera movement
+: Increase camera speed
-: Decrease camera speed
Space bar Toggle orbit mode
Home: Frame model
Escape: Clear selection
F: Frame selection
Hold left click + Move mouse: Rotate camera in current mode
Hold right click + Move mouse: Pan/Tilt camera
Hold middle click + Move mouse: Truck/Pedastal camera
Mouse wheel: Dolly Camera
Left click: Select object
Ctrl + Mouse wheel: Increase/Decrease camera speed
One Finger swipe: Tilt/Pan camera
Two Finger swipe: Truck/Pedestal camera
Two Finger pinch/spread: Dolly Camera
(https://blog.storyblocks.com/video-tutorials/7-basic-camera-movements/)