npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

rosefinch-viewer

v1.0.0-dev1.1

Published

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

Downloads

3

Readme

VIM WebGL Viewer

npm Website

Documentation

https://vimaec.github.io/rosefinch-viewer/api/

Live Demo

Overview

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

Using the Viewer from a Web Page

The following is an example of the simplest usage of the VIM viewer:

<html>
  <head>
    <title>VIM Viewer</title>
  </head>
  <body>
    <script src="https://unpkg.com/[email protected]/build/three.min.js"></script>
    <script src="https://unpkg.com/rosefinch-viewer"></script>
    <script>
      const viewer = new VIM.Viewer()

      viewer.loadVim('https://vim.azureedge.net/samples/residence.vim', {
        rotation: { x: 270, y: 0, z: 0 },
      })
    </script>
  </body>
</html>

You can also try it out in a JsFiddle!

Running Locally

  • Checkout repo
  • Run npm install to install all dependencies
  • Run npm run dev to launch a dev-server and watch for change
  • Navigate to http://localhost:3000 in your browser

Folder Structure

  • docs - this is the root folder for the GitHub page at https://vimaec.github.io/rosefinch-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 and loader.
  • dist - created by running the build script for creating a distributable package. It contains five items after running the build script:
    • dist\rosefinch-viewer.es.js - an EcmaScript module
    • dist\rosefinch-viewer.es.js.map - Typescript source map file map for the EcmaScript module
    • dist\rosefinch-viewer.iife.js - an immediately-invocable function expression (IIFE) intended for consumption from a web-page
    • dist\rosefinch-viewer.iife.js.map - Typescript source map file map for the IIFE
    • types\ - A folder containing Typescript type declarations for the package.

For Contributors

Making a Pre-Release

  1. First develop and test the feature using npm run dev
  2. Login to npm if needed using npm login
  3. Assure that git status is clean
  4. Use npm run release-dev to create a pre-release NPM package.
  5. Change the docs/index-dev.html to use the newly published package.
  6. Use npm run serve-docs to test the npm dev package locally.
  7. When satisfied merge current PR into main.

Making a Patch Release

  1. Make sure the dev release is working properly at https://vimaec.github.io/rosefinch-viewer/index-dev.html
  2. Login to npm if needed using npm login
  3. Use npm run release-patch to create a patch release NPM package.
  4. Change the docs/index.html to use the newly published package.
  5. Push the the new docs/index.html to main.
  6. Make sure https://vimaec.github.io/rosefinch-viewer/index.html is working as expected.

Scripts

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 - launch a dev environment using Vite
  • build - compiles an IIFE JavaScript module and ES module using Vite and the configuration file, placing the output in the dist folder.
  • bump-dev - increments the pre-release version of the NPM package, with the id dev. This will update the package.json version number with a pre-release tag and number value (e.g. 1.0.0-dev.42). It will also create corresponding tag and commit it to Git.
  • publish-dev - publishes the current package to NPM with a dev tag, as opposed to the default tag latest.
  • serve-docs - launches a web-server with the docs folder as the root folder, for testing a published NPM packages (tagged develop or latest) locally
  • release-patch - Increments the patch number and publishes an NPM package using the default tag (@latest). Intended to be called from the main branch only after the pre-release package has been created and tested.
  • release-dev - Increments the prerelease number and publishes an NPM prerelease package using the @dev tag. Intended to be called from the main branch after the features has been tested and built locally.
  • eslint - Runs eslint and reports all syntactic inconsistencies.
  • documentation - Generates api documentation at docs/api.
  • declarations - Generates typescript declrations at dist/types.

Contributing:

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

The Sources and Dependencies

The distributable files do not contain the underlying source for Three.JS to avoid duplication. Please include Three.JS on your own.

Camera Controls

Keyboard

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

Mouse

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

Touch

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/)

Vim

Vim class diagram

The Viewer provides methods to load and unload Vims.

Object is the highest level api and acts as a bridge between BIM, G3d and THREE objects.

A Vim contains a Document which contains the raw BIM and g3d information parsed from the file.

A Vim contains the Settings used when loading was called.

A Vim contains a Scene which contains the generated THREE objects to render the Vim.

All raw G3d and BIM data is stored using the BFast format.

mesh.ts Takes G3d data and THREE.BufferGeometry and generates THREE.Meshs.

geometry.ts Takes G3d and generates THREE.BufferGeometry

How To

Frame camera on an element

const vim = viewer.vims[0] // or keep vim reference from load
const object = vim.getObjectsFromElementId(ELEMENT_ID)[0]
viewer.camera.frame(object)

Highlight an element

const vim = viewer.vims[0] // or keep vim reference from load
const object = vim.getObjectsFromElementId(ELEMENT_ID)[0]
const wireframe = object.createWireframe()
viewer.renderer.add(wireframe)

// To remove hightlight
// viewer.renderer.removeObject(wireframe)
// wireframe.geometry.dispose()

Change Color of an element

const vim = viewer.vims[0] // or keep vim reference from load
const objects = vim.getObjectsFromElementId(ELEMENT_ID) // Many element can share the same id
objects?.forEach((o) => (o.color = new THREE.Color(1, 0, 0)))

// Revert to original color
// object.color = undefined

Replace or add behavior on click

const base = new DefaultInputScheme(viewer)
const customScheme = {
  onIdleAction(hit) {
    console.log('onIdleAction')
    base.onIdleAction(hit)
  },
  onKeyAction(key) {
    console.log('onKeyAction')
    return base.onKeyAction(key)
  },
  onMainAction(hit) {
    console.log('onMainAction')
    base.onMainAction(hit)
  },
}

viewer.inputs.scheme = customScheme

Load from a custom http request

// Make request as usual
const xhr = new XMLHttpRequest()
// Specify response type ArrayBuffer
xhr.responseType = 'arraybuffer'
xhr.open('GET', url)
xhr.send()
xhr.onload = () => {
  // Load vim by passing the array buffer
  viewer.loadVim(xhr.response, {
    rotation: { x: 270, y: 0, z: 0 },
  })
}