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

mniobjparser

v0.1.2

Published

A parse for mesh file MNIObj

Downloads

3

Readme

This package provides a tool to parse MNI OBJ mesh/surface files. Those are generally generated by CIVET as an output of extracting the white/grey matter from MRI data.
Both CIVET and this package are being developed and maintained by MCIN lab.

DEMO, see the examples folder of the repo.
DOCUMENTATION

Read more about the MNI OBJ file format here.

How to

In a npm project

$ npm install --save mniobjparser

Then use import (e.g. in a Rollup project):

import { MniObjParser } from 'mniobjparser';
...
var myParser = new MniObjParser();

In a stand alone webpage

<script src="mniobjparser/dist/mniobjparser.umd.js"></script>
<!-- OR the minified version -->
<script src="mniobjparser/dist/mniobjparser.umd.min.js"></script>

Then use it with a reference to its module:

var myParser = new mniobjparser.MniObjParser();

Then, no matter in what context you are using it, the following is the same. A MNI OBJ file is a (potentially very long) text file, and depending on your project you may waht to open such files from the local machine using a open file dialog or from a distant server with an AJAX request. This is your choice and this quick how to will not cover this part, so in the following we assume that your Javascript code already has access to the very long String content of a MNI OBJ file.

// parse the string content or the MNI OBJ file:
myParser.parse( largeMniObjString )

// Check if the parsing went ok:
if( !parser.isValid() ){
  alert("Invalid MNI OBJ file.\n" + "ERROR: " + parser.getErrorMessage());
  return;
}

// get the position of all the vertices as [x, y, z, x, y, z, ... ]
var positions = parser.getRawVertices();  // Float32Array

// get the index of the vertices involved in faces. These are the index from the "positions" array
// [index0, index1, index2, index0, index1, index2, ... ] , each are triangles
var indices = parser.getShapeRawIndices(); // Uint32Array

// get the list of normal vectors (unit) as [x, y, z, x, y, z, ... ]
var normals = parser.getRawNormals(); // Float32Array

// get all the colors per vertex as [r, g, b, a, r, g, b, a, ... ]
var colors = parser.getRawColors(); // Uint8Array

// get some material information, not mandatory to reconstruct the mesh
var surfaceProperties = parser.getSurfaceProperties(); // object

Then, using ThreeJS (or other) you can rebuild the mesh, just like in this example.