VIM Viewer - Plan View
by simon_vimaec
HTML
<script src="https://unpkg.com/vim-webgl-viewer@2.0.2"></script>
CSS
/* Makes full screen and remove scrollbars */
html,
body {
height: 100%;
margin: 0;
padding: 0;
overflow: hidden;
background: radial-gradient(circle at center, #d8d8e6, #8a8a8a);
touch-action: none; /* This prevents touches from being eaten up by the browser. */
}
JavaScript
async function runDemo() {
// Create a viewer with top down orthographic view and locked camera.
const viewer = new VIM.Viewer({
camera:{
allowedMovement: new VIM.THREE.Vector3(1, 0, 1),
allowedRotation: new VIM.THREE.Vector3(0, 1),
forward: new VIM.THREE.Vector3(0, -1, 0),
orthographic: true
}
})
// 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)
},
(p) => console.log(`Downloading Vim (${(p.loaded / 1000).toFixed(0)} kb)`)
)
// Load all geometry from the vim.
vim.loadAll()
// Add the vim to the viewer.
viewer.add(vim)
//Need force=true because axis are locked.
viewer.camera.snap(true).frame(vim)
}
runDemo()