Open sirkitree opened 9 years ago
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.
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...
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?
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...
...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?
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.
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?
Yes, I certainly would.
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: