CesiumGS / obj2gltf

Convert OBJ assets to glTF
Apache License 2.0
1.71k stars 307 forks source link

Cannot read property 'isTTY' of undefined #11

Closed hamogu closed 8 years ago

hamogu commented 8 years ago
melkor:/melkor/d1/guenther/projects/threejs/OBJ2GLTF> node bin/obj2gltf.js ../obj/test5.obj ../obj/test5.gltf

readline.js:74
    terminal = !!output.isTTY;
                       ^
TypeError: Cannot read property 'isTTY' of undefined
    at new Interface (readline.js:74:24)
    at Object.exports.createInterface (readline.js:40:10)
    at getObjInfo (/melkor/d1/guenther/projects/threejs/OBJ2GLTF/lib/obj.js:310:27)
    at parseObj (/melkor/d1/guenther/projects/threejs/OBJ2GLTF/lib/obj.js:17:5)
    at convert (/melkor/d1/guenther/projects/threejs/OBJ2GLTF/lib/convert.js:36:5)
    at Object.<anonymous> (/melkor/d1/guenther/projects/threejs/OBJ2GLTF/bin/obj2gltf.js:35:1)
    at Module._compile (module.js:456:26)
    at Object.Module._extensions..js (module.js:474:10)
    at Module.load (module.js:356:32)
    at Function.Module._load (module.js:312:12)
lilleyse commented 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?

hamogu commented 8 years ago

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)
hamogu commented 8 years ago

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
hamogu commented 8 years ago

Thank you so much for your quick responses!

lilleyse commented 8 years ago

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.

hamogu commented 8 years ago

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.)

lilleyse commented 8 years ago

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.

zhanfenghai commented 7 years ago

@lilleyse hi,i got the same error. i tried to read a file like xx.html. here is my code image

lilleyse commented 7 years ago

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.