3d Models in JSON

5,241 views
Skip to first unread message

pangwa

unread,
Sep 23, 2011, 11:10:11 AM9/23/11
to PhiloGL
Hi All,

Is there any free 3d models in json format online? I'm looking a 3d
tree model to use in my prototype. But haven't found it...

thanks!

Nicolas Garcia Belmonte

unread,
Sep 23, 2011, 12:24:37 PM9/23/11
to phi...@googlegroups.com
PhiloGL only provides simple shapes... I know there's
http://ourbricks.com/ but I'm not sure what format they provide. It
shouldn't be hard to transform from OBJ to json though, I think
three.js has a converter here:

https://github.com/mrdoob/three.js/blob/master/utils/exporters/convert_obj_three.py

it shuld be pretty easy to adap this one to your desired json format.

--
Nicolas Garcia Belmonte - http://philogb.github.com/

Autumn Kulaga

unread,
Mar 22, 2013, 9:05:40 AM3/22/13
to phi...@googlegroups.com
I followed your suggestion above, use convert_obj_three.py, but I am having some issues. (To start experimenting with this framework I followed lesson 14). 

When I use this json model in Threejs it uploads fine however using the same json with PhiloJS results in a different drawing pattern. I opened the .json and compared it to teapot. I see the differences, but should I need to modify anything? Also, is 'uv' in threejs the same as 'texCoord' in philo?
Do you have documentation on the order Philo draws/connects the verts? 

And/ or is there another converter available since last September?
Thank you in advanced!

Rob

unread,
Mar 22, 2013, 4:04:26 PM3/22/13
to phi...@googlegroups.com
And/ or is there another converter available since last September?
Yes! Well.. sort of! I've been working on a STL/Obj/AMF javascript parser (P3D.js) that might be of use here. Instead of converting your models to json server side my library works by converting them to javascript objects on the client side in a WebWorker.

The documentation is a bit out of date but you can see an example of it in action (with Three.js in this case) at http://d1plo1d.github.com/p3d/examples/

I use P3D with PhiloGL myself however getting a simplified demo of that working has proven a bit tricky.

So in the meantime, If you'd like an example of P3D in use with PhiloGL that works I use it extensively in my ctrlpanel project, apologies in advance for the code though.. it's in needs of a refactor: https://github.com/D1plo1d/ctrlpanel/blob/master/assets/js/viewer.coffee

Bug Reports and Pull Requests welcome.

Cheers,
Rob

--
You received this message because you are subscribed to the Google Groups "PhiloGL" group.
To unsubscribe from this group and stop receiving emails from it, send an email to philogl+u...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.
 
 

Autumn Kulaga

unread,
Mar 31, 2013, 6:40:09 PM3/31/13
to phi...@googlegroups.com
Thank you for your help! and Sorry for the delayed response...

I have been trying to figure out a fix with to the json before introducing another framework (modifying the .json from threejs) however this did not seem to work. So I pulled P3D and I am attempting to follow the documentation, this is what I have but it does not work:

  new PhiloGL.IO.XHR({
    url: 'heart.obj',
    onSuccess: function(url) {
      p3d = new P3D url
      //(p3d) -> for chunk, i in p3d.chunks
      //console.log "loading #{p3d.filename} chunk ##{i}";

      heart = new PhiloGL.O3D.Model();
      heart[attr] = p3d[attr] for attr in ["vertices", "normals", "indices"];
      //var json = JSON.parse(text);
      //json.colors = [1, 1, 1, 1];
      //json.textures = 'heart_Diffuse.jpg';
      //var heart = new PhiloGL.O3D.Model(json);

      animateObject(heart);
    }
  }).send();
Part of the issue is I am learning json/coffeeScript to figure this out so any hints are appreciated.
I get that I am declaring url before creating the variable and I am still working through it, but I am kind of just taking shots in the dark.

My file follows example file #14 from philoJS's lessons. And in this example PhiloGL.IO.XHR is created to load the json. When using P3D, do I not need to do this b/c I will be loading just the obj?
To implement P3D, I mainly followed: https://github.com/D1plo1d/p3d#example-1-webgl-chunks-and-ajax . But also tried to follow your 
coffeeScript example. But since I don't really understand coffeeScript ( yet ;) ) it is hard to follow how it all comes together. 

Thanks again for the help!

Rob

unread,
Apr 1, 2013, 6:29:53 PM4/1/13
to phi...@googlegroups.com
No problem! Also apologies for the coffeescript, I'm going to try and get a js example online ASAP.

My file follows example file #14 from philoJS's lessons. And in this example PhiloGL.IO.XHR is created to load the json. When using P3D, do I not need to do this b/c I will be loading just the obj?
Exactly! So without using PhiloGL.IO.XHR you should be able to do something along the lines of:

url = "./my-obj-url.obj"

new P3D(url, function(p3d) {
heart = new PhiloGL.O3D.Model();
heart[attr] = p3d[attr] for attr in ["vertices", "normals", "indices"];
animateObject(heart);
});

The main problem I can see with your code is that it copied the p3d object's verts, normals and indices to philogl immediately after creating the P3D object. This is a problem since P3D works asynchronously, parsing 3d models in a background thread. So if you copy it immediately it will not have had time yet to parse the 3d model and the verts, normals and indices will be empty. Instead you should wait for the p3d object's callback like I did in the code above to copy everything over to the philogl object since P3D will only call it's callback function once the 3d model has been loaded.

- Rob
Reply all
Reply to author
Forward
0 new messages