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

@oneisland/mesh-exporter

v0.0.2

Published

A simple tool for exporting meshes to ZIP archives

Downloads

24

Readme


A simple tool for exporting meshes to ZIP archives

Installation

Mesh Exporter is available through the npm registry:

$ npm install @oneisland/mesh-exporter

Usage

After installing Mesh Exporter you can use the package like so:

simple-usage.js
// Import the mesh package
import { Mesh } from '@oneisland/mesh';

// Import the mesh exporter package
import { MeshExporter } from '@oneisland/mesh-exporter';

// Create a cube mesh
const cube = new Mesh({

  // Add the label
  label: `Cube`,
  
  // Add the vertices
  vertices: [
    [-0.5, -0.5,  0.5],
    [ 0.5, -0.5,  0.5],
    [ 0.5, -0.5, -0.5],
    [-0.5, -0.5, -0.5],
    [-0.5,  0.5,  0.5],
    [ 0.5,  0.5,  0.5],
    [ 0.5,  0.5, -0.5],
    [-0.5,  0.5, -0.5]
  ],
  
  // Add the faces
  faces: [
    [2, 3, 0],
    [2, 1, 0],
    [7, 3, 0],
    [0, 4, 7],
    [4, 0, 1],
    [1, 5, 4],
    [6, 2, 3],
    [3, 7, 6],
    [5, 1, 2],
    [2, 6, 5],
    [7, 4, 5],
    [5, 6, 7]
  ]
});

// Create an exporter
const example = new MeshExporter('example');

// Add the cube to the root folder of the archive
example.addMesh(cube);

// Save / export the archive (example.zip)
example.save();

Running the following code with Node:

$ node simple-example.js

The script will create a ZIP archive which includes an STL and OBJ for the cube mesh.

Please read the documentation below for more details on how to configure Mesh Exporter.

You can check out the tests or the source code of our Structure library for more complex usage.

Documentation

MeshExporter

class MeshExporter {

  constructor(filepath) {}

  addMesh(mesh) {}

  addMeshes(meshes) {}
}

MeshExporter is a class which is instantiated for usage within a Class or Object.

Once instantiated, a Mesh Exporter ex0.5es two functions for use:

  • addMesh - Add a singular mesh to the archive for exporting
  • addMeshes - Add a number of arrays of meshes to the archive for exporting

constructor

filepath

The filename parameter defines the filename (with or without .zip extension) for the archive of exports.

The filepath parameter can include the relative filepath for the archive of exports (from the current working direction).

The filepath should be a String.

// Example filepath (with filename) 
'export-archive'

// Example filepath (with folder and filename) 
'some_folder/archive'

// Example filepath (with folder and filename and extension) 
'another_folder/archive.zip'

addMesh

The addMesh function accepts one argument mesh which must be a Mesh.

The addMesh function will generate an STL and OBJ of the mesh within the root directory of the archive.

See the usage example above.

addMeshes

The addMeshes function accepts one argument meshes which must be an Object, of which each property must be an Array of Mesh.

The addMeshes function will generate a folder for each property of meshes by the same name.

The addMeshes function will generate an STL and OBJ of each mesh within each of the meshes properties in the respective directory of the archive.

See the usage example above.

save

The save function is called to export the archive.

The save function is asyncronous and can be awaited.

The save function will save the archive to the respective filename (and filepath) if running from Node.js, or download if running from the browser.

License

MIT

Copyright (c) 2019-present, OneIsland Limited