Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Loading an object #13

Open
sirkitree opened this issue Oct 31, 2015 · 8 comments
Open

Loading an object #13

sirkitree opened this issue Oct 31, 2015 · 8 comments

Comments

@sirkitree
Copy link

This library is really great, thank you so much!

I'm wondering if you have an example of loading an object (.obj) file and material with it. There doesn't seem to be any out of the box functionality to do that, so would you still need to use Three's OBJLoader?

It'd be really useful to be able to do something like:

VR.load({
  path: 'path-to-obj-file'
});
@sirkitree
Copy link
Author

I wrote up some code to see how this might look. Here's a prototype:

/**
 * objLocation should be the http location of the file without the extension.
 * we will automatically assume that an obj file and an mtl file are present.
 * ex: https://raw.githubusercontent.com/bitgridio/models/gh-pages/lullabot/Body
 */
var loadObjMtl = function(objLocation) {
  var loader = new THREE.OBJMTLLoader(manager)
  loader.load(
    objLocation + '.obj',
    objLocation + '.mtl',
    function(obj) {
      console.log(obj)
      VR.scene.add(obj)
    },
    function(xhr) {
      console.log(xhr.loaded + ' bytes loaded')
    },
    function(xhr) {
      console.log('Error loading object')
    }
  )
}

loadObjMtl('https://raw.githubusercontent.com/bitgridio/models/gh-pages/lullabot/Body')
loadObjMtl('https://raw.githubusercontent.com/bitgridio/models/gh-pages/lullabot/Headd')

If you think something like this would be a good addition to this library, let me know and I'll look at your source and see what might be a good way to implement it as a VR.prototype or something.

@brianchirls
Copy link
Contributor

This is a good idea. I'll see if I can whip something up. There are a couple things I need to think about though...

  1. Is there a good place for people to host obj files if they don't have their own servers? Need CORS headers.
  2. What's the best way to design the API to allow for multiple object formats?
  3. How many different object formats do we need to support? Each one comes at a cost of making the script file a bit larger.

@sirkitree
Copy link
Author

Not sure about the first two, but for the third I'd suggests starting with .obj (these can have multiple textures though so not sure that my approach in assuming .mtl is going to pan out), .dae (collada), .fbx?

@brianchirls
Copy link
Contributor

I think I will start with obj since it seems to be the most popular. Collada is also popular, but I think the files are quite large and slow to parse. So they're not great for deployment on the web.

I've put off building this because everything else about the library is meant to be as self-contained as possible, for people who may not have easy access to their own servers. jsbin is fine for hosting prototype code; imgur.com is good at hosting images. But I haven't found a good place to store video, audio or 3d models. So it's unlikely this feature will be used by some beginners. I would like to find a way to solve that problem. I'm open to suggestions...

@brianchirls
Copy link
Contributor

...might be cool to build a github repo full of open source models, kind of like npm or homebrew. They could be served by github pages, or maybe someone will donate CDN space. Could be a fair bit of work to dig up the models and make sure they're in usable formats at consistent scales and with working materials/textures.

What do you think?

@sirkitree
Copy link
Author

I help run http://vrsites.com/ where we do some hosting of models and rooms for http://janusvr.com/. The goal of that site is to help teach people to make JanusVR rooms and provide some basic hosting capabilities. Might be an option to point people to, but I do prefer putting things up on GitHub cuz they're so damned fast.

@brianchirls
Copy link
Contributor

I'm kind of excited about this idea. I'm gonna run it by some folks at Mozilla Festival this weekend. What if I set up an empty repo with notes and some issues for discussion? Would you be interested in participating at least in some ideas of how to put it together, or possibly contributing code and/or models?

@sirkitree
Copy link
Author

Yes, I certainly would.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants