Add node example.

This commit is contained in:
kovacsv 2021-10-06 19:12:43 +02:00
parent e1ad5cd0d0
commit 8fa4a0bcdd
6 changed files with 215 additions and 0 deletions

View File

@ -0,0 +1,86 @@
solid STL generated by MeshLab
facet normal 0.000000e+00 -1.000000e+00 0.000000e+00
outer loop
vertex 0.000000e+00 0.000000e+00 0.000000e+00
vertex 1.000000e+00 0.000000e+00 0.000000e+00
vertex 1.000000e+00 0.000000e+00 1.000000e+00
endloop
endfacet
facet normal 0.000000e+00 -1.000000e+00 0.000000e+00
outer loop
vertex 0.000000e+00 0.000000e+00 0.000000e+00
vertex 1.000000e+00 0.000000e+00 1.000000e+00
vertex 0.000000e+00 0.000000e+00 1.000000e+00
endloop
endfacet
facet normal 1.000000e+00 0.000000e+00 0.000000e+00
outer loop
vertex 1.000000e+00 0.000000e+00 0.000000e+00
vertex 1.000000e+00 1.000000e+00 0.000000e+00
vertex 1.000000e+00 1.000000e+00 1.000000e+00
endloop
endfacet
facet normal 1.000000e+00 0.000000e+00 0.000000e+00
outer loop
vertex 1.000000e+00 0.000000e+00 0.000000e+00
vertex 1.000000e+00 1.000000e+00 1.000000e+00
vertex 1.000000e+00 0.000000e+00 1.000000e+00
endloop
endfacet
facet normal 0.000000e+00 1.000000e+00 0.000000e+00
outer loop
vertex 1.000000e+00 1.000000e+00 0.000000e+00
vertex 0.000000e+00 1.000000e+00 0.000000e+00
vertex 0.000000e+00 1.000000e+00 1.000000e+00
endloop
endfacet
facet normal 0.000000e+00 1.000000e+00 -0.000000e+00
outer loop
vertex 1.000000e+00 1.000000e+00 0.000000e+00
vertex 0.000000e+00 1.000000e+00 1.000000e+00
vertex 1.000000e+00 1.000000e+00 1.000000e+00
endloop
endfacet
facet normal -1.000000e+00 0.000000e+00 0.000000e+00
outer loop
vertex 0.000000e+00 1.000000e+00 0.000000e+00
vertex 0.000000e+00 0.000000e+00 0.000000e+00
vertex 0.000000e+00 0.000000e+00 1.000000e+00
endloop
endfacet
facet normal -1.000000e+00 0.000000e+00 0.000000e+00
outer loop
vertex 0.000000e+00 1.000000e+00 0.000000e+00
vertex 0.000000e+00 0.000000e+00 1.000000e+00
vertex 0.000000e+00 1.000000e+00 1.000000e+00
endloop
endfacet
facet normal 0.000000e+00 0.000000e+00 -1.000000e+00
outer loop
vertex 0.000000e+00 0.000000e+00 0.000000e+00
vertex 0.000000e+00 1.000000e+00 0.000000e+00
vertex 1.000000e+00 1.000000e+00 0.000000e+00
endloop
endfacet
facet normal 0.000000e+00 0.000000e+00 -1.000000e+00
outer loop
vertex 0.000000e+00 0.000000e+00 0.000000e+00
vertex 1.000000e+00 1.000000e+00 0.000000e+00
vertex 1.000000e+00 0.000000e+00 0.000000e+00
endloop
endfacet
facet normal 0.000000e+00 0.000000e+00 1.000000e+00
outer loop
vertex 0.000000e+00 0.000000e+00 1.000000e+00
vertex 1.000000e+00 0.000000e+00 1.000000e+00
vertex 1.000000e+00 1.000000e+00 1.000000e+00
endloop
endfacet
facet normal 0.000000e+00 0.000000e+00 1.000000e+00
outer loop
vertex 0.000000e+00 0.000000e+00 1.000000e+00
vertex 1.000000e+00 1.000000e+00 1.000000e+00
vertex 0.000000e+00 1.000000e+00 1.000000e+00
endloop
endfacet
endsolid vcg

Binary file not shown.

Binary file not shown.

After

Width:  |  Height:  |  Size: 55 KiB

View File

@ -0,0 +1,25 @@
newmtl Red
Ka 0.000000 0.000000 0.000000
Kd 0.800000 0.000000 0.000000
Ks 0.500000 0.500000 0.500000
newmtl Green
Ka 0.000000 0.000000 0.000000
Kd 0.000000 0.800000 0.000000
Ks 0.500000 0.500000 0.500000
newmtl Blue
Ka 0.000000 0.000000 0.000000
Kd 0.000000 0.000000 0.800000
Ks 0.500000 0.500000 0.500000
newmtl White
Ka 0.000000 0.000000 0.000000
Kd 0.800000 0.800000 0.800000
Ks 0.500000 0.500000 0.500000
newmtl Texture
Ka 0.000000 0.000000 0.000000
Kd 0.800000 0.800000 0.800000
Ks 0.500000 0.500000 0.500000
map_Kd cube_texture.png

View File

@ -0,0 +1,38 @@
# Cube with Materials
mtllib cube_with_materials.mtl
g Cube
v 0.0 0.0 0.0
v 1.0 0.0 0.0
v 1.0 1.0 0.0
v 0.0 1.0 0.0
v 0.0 0.0 1.0
v 1.0 0.0 1.0
v 1.0 1.0 1.0
v 0.0 1.0 1.0
vn 1.0 0.0 0.0
vn -1.0 0.0 0.0
vn 0.0 1.0 0.0
vn 0.0 -1.0 0.0
vn 0.0 0.0 1.0
vn 0.0 0.0 -1.0
vt 0.0 0.0
vt 1.0 0.0
vt 1.0 1.0
vt 0.0 1.0
usemtl Red
f 1/1/4 2/2/4 6/3/4 5/4/4
usemtl Green
f 2/1/1 3/2/1 7/3/1 6/4/1
usemtl Blue
f 3/1/3 4/2/3 8/3/3 7/4/3
usemtl Texture
f 4/1/2 1/2/2 5/3/2 8/4/2
usemtl White
f 1/1/6 4/2/6 3/3/6 2/4/6
f 5/1/5 6/2/5 7/3/5 8/4/5

View File

@ -0,0 +1,66 @@
var fs = require ('fs');
require ('../../build/final/website/o3dv/o3dv.min.js');
let importer = new OV.Importer ();
let FileObject = function (name)
{
this.name = name;
};
let files = [
new FileObject ('cube_meshlab_ascii.stl')
];
global.FileReader = class
{
static DONE = 2;
readAsText (fileObject)
{
let content = fs.readFileSync (fileObject.name).toString ();
if (content !== null) {
this.onloadend ({
target : {
readyState : FileReader.DONE,
result : content
}
});
} else {
this.onerror ();
}
}
readAsArrayBuffer (fileObject)
{
let content = fs.readFileSync (fileObject.name);
if (content !== null) {
var arrayBuffer = new ArrayBuffer (content.length);
var uint8Array = new Uint8Array (arrayBuffer);
for (let i = 0; i < content.length; ++i) {
uint8Array[i] = content[i];
}
this.onloadend ({
target : {
readyState : FileReader.DONE,
result : arrayBuffer
}
});
} else {
this.onerror ();
}
}
};
importer.LoadFilesFromFileObjects (files, function () {
let settings = new OV.ImportSettings ();
importer.Import (settings, {
onSuccess : function (importResult) {
console.log (importResult);
},
onError : function (importError) {
console.log (importError);
}
});
});