mrdoob / three.js

JavaScript 3D Library.
https://threejs.org/
MIT License
102.81k stars 35.38k forks source link

Load Model #810

Closed michapixel closed 12 years ago

michapixel commented 12 years ago

I'm using 3dsmax to export my models as json (which i very much like to switch to utf8 but that's another story) via the max-export script (rev.46) . but when i load my model threejs throws a SyntaxError in line 632 wher it says: arguments: Array[1] 0: "/" length: 1 etc.pp.

then it tells me i'm using a deprecated model, which seems to be true, but i used the script from rev.46, so i guess it hasn't been updated yet?!

My question is now: which way is the best (future-proof?) way to load complex models + materials / textures) on localhost.

michapixel commented 12 years ago

Addendum:

i'm now trying to export through blender (2.60), and the file seems to be ok afaict (i'm comparing to 'WaltHeadLo.js' from the examples)

As soon as i load the model:

var loader = modelLoader = new THREE.JSONLoader();
loader.load(url, function(geometry){ // this never gets executed });

i get the Syntaxerror (above), and directly after that a Deprecated warning: "seems to be using old model format"

michapixel commented 12 years ago

btw: when i load the WaltHeadLo version everything works fine. So it's definately a model issue.

Coder2012 commented 12 years ago

I am having the same problem. Creating a really basic model with default lambert texture, converting to js with the python script its always complaining its an old model format.

Coder2012 commented 12 years ago

Also, if I download suzanne.js from your obj examples, I have the same issue. What exactly constitutes an old model format? This is an amazing job you are doing guys, keep up the good work I'm really enjoying learning about this library.

alteredq commented 12 years ago

JSONLoader in r46 has silly error reporting: if you have any unrelated exception in your callback it complains about "old model format".

If you created models with latest tools, they should be ok. If you created models long ago, you'll need to reconvert / reexport them.

If your JSON files has comments at the top, it's old format.

Coder2012 commented 12 years ago

Of course, that makes sense now. After removing all my code in the handler, I was able to remove the error and build up my code line by line until it worked.

Thank you very much.

michapixel commented 12 years ago

why has this been closed?

Coder2012 commented 12 years ago

That might be partially my fault, as I also raised a concern which was addressed by alteredq in this post, I apologise if i've hijacked your issue. Are you certain that no code in your handler for when the model is loaded get's executed? Have you tried with nothing in that handler but still get an deprecated warning? Also have you tried the most basic model you can produce like a cube, and triangulating it.

alteredq commented 12 years ago

@michapixel If you get syntax error at 0 about "/" it seems most likely your model is indeed in the old format (where at top there were comments which JSON doesn't allow).

If your model file on the disk looks ok (stuff coming out of new Blender exporter will not have comments at top), try clearing your cache, ajax requests are sometimes cached too aggressively.

michapixel commented 12 years ago

nope. the model seems to be the problem. although i cannot see what it is, i created a simple new one exported it through 2.60 and it worked fine.

well there they are my three problems again ;-)

alteredq commented 12 years ago

Could you post this problematic model somewhere so that we could check it?

michapixel commented 12 years ago

The MAX-Exporter script seems to always produce "Deprecated file format". I've just created a new file in MAX, added a box and exported it. "Deprecated file format". Any advice here? i know this might be considered as OT. if this is considered as OT by the devs, just write a note.

alteredq commented 12 years ago

I'll just repeat - put the exported JSON file somewhere so we can check. There may be bug in max exporter or you may have missed something.

michapixel commented 12 years ago

i'm just trying to put it up on github.

michapixel commented 12 years ago

btw: i typed my comment in the box without seeing yours (didn't reload).

michapixel commented 12 years ago

https://github.com/michapixel/threejs-models

michapixel commented 12 years ago

I've added the original model too.

alteredq commented 12 years ago

I managed to load your model after reexporting it from Blender.

I found few issues:

michapixel commented 12 years ago

Ok, i've had cache problems as well. now it works for me too. DAMN. Sorry to waste your time.