Closed hamogu closed 8 years ago
Hi, I made some changes to the file reader, can you run the latest code and tell me if it works for you?
Now I get
melkor:/melkor/d1/guenther/projects/threejs/OBJ2GLTF> node bin/obj2gltf.js ../obj/test5.obj ../obj/test5.gltf
buffer.js:803
this.parent.writeFloatLE(value, this.offset + offset, !!noAssert);
^
TypeError: value not a number
at Buffer.writeFloatLE (buffer.js:803:15)
at createGltf (/melkor/d1/guenther/projects/threejs/OBJ2GLTF/lib/gltf.js:69:16)
at /melkor/d1/guenther/projects/threejs/OBJ2GLTF/lib/convert.js:37:9
at LineStream.<anonymous> (/melkor/d1/guenther/projects/threejs/OBJ2GLTF/lib/obj.js:224:9)
at LineStream.emit (events.js:117:20)
at _stream_readable.js:944:16
at process._tickCallback (node.js:448:13)
I've tried a different OBJ file and found this:
/melkor/d1/guenther/projects/threejs/OBJ2GLTF/node_modules/gltf-pipeline/lib/findAccessorMinMax.js:17
var min = new Array(numberOfComponents).fill(Number.POSITIVE_INFINITY);
^
TypeError: Object has no method 'fill'
at findAccessorMinMax (/melkor/d1/guenther/projects/threejs/OBJ2GLTF/node_modules/gltf-pipeline/lib/findAccessorMinMax.js:17:45)
at accessorDefaults (/melkor/d1/guenther/projects/threejs/OBJ2GLTF/node_modules/gltf-pipeline/lib/addDefaults.js:24:30)
at addDefaults (/melkor/d1/guenther/projects/threejs/OBJ2GLTF/node_modules/gltf-pipeline/lib/addDefaults.js:561:5)
at processJSONWithExtras (/melkor/d1/guenther/projects/threejs/OBJ2GLTF/node_modules/gltf-pipeline/lib/gltfPipeline.js:57:5)
at /melkor/d1/guenther/projects/threejs/OBJ2GLTF/node_modules/gltf-pipeline/lib/gltfPipeline.js:115:9
at /melkor/d1/guenther/projects/threejs/OBJ2GLTF/node_modules/gltf-pipeline/lib/loadGltfUris.js:36:9
at /melkor/d1/guenther/projects/threejs/OBJ2GLTF/node_modules/async/lib/async.js:52:16
at done (/melkor/d1/guenther/projects/threejs/OBJ2GLTF/node_modules/async/lib/async.js:246:17)
at /melkor/d1/guenther/projects/threejs/OBJ2GLTF/node_modules/async/lib/async.js:44:16
at /melkor/d1/guenther/projects/threejs/OBJ2GLTF/node_modules/gltf-pipeline/lib/loadGltfUris.js:119:17
I'll past the OBJ file here so you can try it out yourself:
mtllib /melkor/d1/guenther/projects/threejs/obj/test3.mtl
v 10 10 10
v 20 20 20
v 0 0 0
v 0 -51.2692 269.668
g grp1
usemtl mtl1
l 1 2 3 4
f 1
f 2
f 3
f 4
Thank you so much for your quick responses!
For the example you posted we don't support line segments like l 1 2 3 4
right now. Rearranging your example a bit works, but it may not be exactly what you want:
mtllib /melkor/d1/guenther/projects/threejs/obj/test3.mtl
v 10 10 10
v 20 20 20
v 0 0 0
v 0 -51.2692 269.668
g grp1
usemtl mtl1
f 1 2 3 4
Can you also send over your other obj?
/melkor/d1/guenther/projects/threejs/OBJ2GLTF/node_modules/gltf-pipeline/lib/findAccessorMinMax.js:17 var min = new Array(numberOfComponents).fill(Number.POSITIVE_INFINITY); ^ TypeError: Object has no method 'fill'
What version of Node do you have installed? Updating may fix that problem.
The other file is a lot bigger (> 15 MB), and it also contains line line segments, so that's probably a related error. I'm visualizing a ray-trace simulation for a scientific instrument and rays are lines, so I cannot really do without lines. I'll try to work directly with the OBJ format for now, but I'll keep your converter in mind and come back to it later if I have the opportunity!
melkor:/melkor/d1/guenther/projects/threejs/OBJ2GLTF> node --version v0.10.42 (I'm using CentOS and that's the version I get through my package manager.)
Ok, thanks for all the info. Adding support for line segments shouldn't be too bad and I'll update this issue when it's ready.
@lilleyse hi,i got the same error. i tried to read a file like xx.html. here is my code
obj2gltf
isn't using the readline
package anymore, you should investigate with them instead. You could also check out the byline
package which seems to be very solid so far.