3D Model Manger is an NPM package for managing 3d models.
Type in $ npm install 3d-model-manger
in you shell.
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
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' +
...
}
*/
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]
}
*/