3d-model-manger

A 3D Model Manger

Usage no npm install needed!

<script type="module">
  import dModelManger from 'https://cdn.skypack.dev/3d-model-manger';
</script>

README

3D Model Manger

About

3D Model Manger is an NPM package for managing 3d models.

Table Of Contents

Install

Type in $ npm install 3d-model-manger in you shell.

Usage

const modelManger = require('3d-model-manger'); // imports 3d-model-manger
const modelPath = "cube.obj"; // enter your model path here! (currently only supports .obj files)

console.log(parseRead(readModel("cube.obj"))); // returns object with vertex data and class data

Docs

readModel

Reads file data from 3d model files (obj) and returns an array

Syntax: readModel(filePath)

Parameters:

Parameter Type Default Description
filePath String The Path of the read file

Example:

const modelManger = require('3d-model-manger'); // imports 3d-model-manger
const modelPath = "cube.obj"; // enter your model path here! (currently only supports .obj files)

console.log(readModel("cube.obj"));
/* returns : {
  modelType: 'obj',
  modelData: "# Blender v2.76 (sub 0) OBJ File: ''\n" +
    '# www.blender.org\n' +
    'mtllib cube.mtl\n' +
    'o Cube\n' +
    'v 1.000000 -1.000000 -1.000000\n' +
    'v 1.000000 -1.000000 1.000000\n' +
    'v -1.000000 -1.000000 1.000000\n' +
    'v -1.000000 -1.000000 -1.000000\n' +
    ...
  }
*/

parseRead

Parses the object given by the readModel() function and converts it into an easy-to-use object

Syntax: parseRead(Modeldata, [options])

Parameters:

Parameter Type Default Description
Modeldata String The Path
of the read file
options Object options

Example:

const modelManger = require('3d-model-manger'); // imports 3d-model-manger
const modelPath = "cube.obj"; // enter your model path here! (currently only supports .obj files)

console.log(parseRead(readModel("cube.obj")));
/* returns : {
     Vertices: [[Vertex], [Vertex], [Vertex], [Vertex], etc],
     Faces: [[Face], [Face], [Face], [Face], etc]
  }
*/