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

@anderpang/obj2json

v1.0.2

Published

blender obj to json

Downloads

5

Readme

obj2json.js

Installation

$ npm i @anderpang/obj2json.js

Usage

 import obj2json from "anderpang/obj2json.js";

or

<script src="./obj2json.js"></script>
import obj2json from "@anderpang/obj2json";

var json=obj2json(`
    # Blender v2.78 (sub 0) OBJ File: ''
    # www.blender.org
    mtllib box.mtl
    o Cube_Cube.001
    v -1.000000 -1.000000 1.000000
    v -1.000000 1.000000 1.000000
    v -1.000000 -1.000000 -1.000000
    v -1.000000 1.000000 -1.000000
    v 1.000000 -1.000000 1.000000
    v 1.000000 1.000000 1.000000
    v 1.000000 -1.000000 -1.000000
    v 1.000000 1.000000 -1.000000
    vn -1.0000 0.0000 0.0000
    vn 0.0000 0.0000 -1.0000
    vn 1.0000 0.0000 0.0000
    vn 0.0000 0.0000 1.0000
    vn 0.0000 -1.0000 0.0000
    vn 0.0000 1.0000 0.0000
    usemtl None
    s off
    f 1//1 2//1 4//1 3//1
    f 3//2 4//2 8//2 7//2
    f 7//3 8//3 6//3 5//3
    f 5//4 6//4 2//4 1//4
    f 3//5 7//5 5//5 1//5
    f 8//6 4//6 2//6 6//6

`);

console.log(json);
// result
/*
{
  vertices: Array(108) [-1, -1, 1, -1, 1, 1, -1, 1, -1, -1, -1, 1, -1, 1, -1, -1, -1, -1, -1, -1, -1, -1, 1, -1, 1, 1, -1, -1, -1, -1, 1, 1, …]
  normals: Array(108) [-1, 0, 0, -1, 0, 0, -1, 0, 0, -1, 0, 0, -1, 0, 0, -1, 0, 0, 0, 0, -1, 0, 0, -1, 0, 0, -1, 0, 0, -1, 0, 0, -1, …]
  colors: Array(144) [0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, …]
  indices: Array(36) [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35]
}
*/
import obj2json from "@anderpang/obj2json";

var json=obj2json({
    files:{
        "box.obj":`
            # Blender v2.78 (sub 0) OBJ File: ''
            # www.blender.org
            mtllib box.mtl
            o Cube_Cube.001
            v -1.000000 -1.000000 1.000000
            v -1.000000 1.000000 1.000000
            v -1.000000 -1.000000 -1.000000
            v -1.000000 1.000000 -1.000000
            v 1.000000 -1.000000 1.000000
            v 1.000000 1.000000 1.000000
            v 1.000000 -1.000000 -1.000000
            v 1.000000 1.000000 -1.000000
            vn -1.0000 0.0000 0.0000
            vn 0.0000 0.0000 -1.0000
            vn 1.0000 0.0000 0.0000
            vn 0.0000 0.0000 1.0000
            vn 0.0000 -1.0000 0.0000
            vn 0.0000 1.0000 0.0000
            usemtl None
            s off
            f 1//1 2//1 4//1 3//1
            f 3//2 4//2 8//2 7//2
            f 7//3 8//3 6//3 5//3
            f 5//4 6//4 2//4 1//4
            f 3//5 7//5 5//5 1//5
            f 8//6 4//6 2//6 6//6
        `,
        "box.mtl":`
            # Blender MTL File: 'None'
            # Material Count: 1

            newmtl None
            Ns 0
            Ka 0.000000 0.000000 0.000000
            Kd 0.8 0.8 0.8
            Ks 0.8 0.8 0.8
            d 1
            illum 2
        `,
        "other.mtl":`
        `
    },
    scale:0.5,
    reverse:false,
    percision:2

  });

console.log(json);
/*
vertices: Array(108) [-0.5, -0.5, 0.5, -0.5, 0.5, 0.5, -0.5, …]
normals: Array(108) [-1, 0, 0, -1, 0, 0, -1, 0, 0, -1, 0, 0, -1, …]
colors: Array(144) [0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 1, …]
indices: Array(36) [0, 1, 2, 3, 4, 5,...]
*/
  • reverse (normals direction)
  • percision (normals and vertices percision) default -1. if 0 then Interger, if 1 then 0.1, if 2 then 0.02...