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

New collada loader #2954

Closed
crobi opened this issue Jan 21, 2013 · 24 comments
Closed

New collada loader #2954

crobi opened this issue Jan 21, 2013 · 24 comments

Comments

@crobi
Copy link
Contributor

crobi commented Jan 21, 2013

Since the current three.js collada loader has many limitations due to its design, I have implemented my own collada loader. If you are interested, I would like to share the code with the three.js project. Please have a look and tell me what you think - suggestions are always welcome.

About the loader:

  • It has the same interface as the current loader.
  • It is written in coffeescript, which is a script language that compiles into javascript. This will be the biggest problem for sharing with three.js.
  • I tried to follow the spec as closely as possible, with a proper implementation of all collada element addressing (and after reading the spec, I don't blame anyone for taking shortcuts...).
  • The loader outputs messages to help finding problems, such as if a feature is not implemented or if there's an error in the collada document (exporters are not perfect either).
  • To avoid unnecessary code, I do not plan to ever support some features such as non-triangle geometry or collada documents that are split to multiple files.
  • Some collada elements are not implemented yet, such as lights or cameras.
  • The loader supports animated skinned meshes and converts them to morph-animated meshes, similar to the current loader. Additionally, it has an intermediate representation of skinned meshes that looks similar to the way skinned meshes are saved in three.js JSON files, so outputting skin-animated meshes should not be difficult to implement.
  • The loader supports diffuse, specular, and normal maps for materials.

Some links:

@mrdoob
Copy link
Owner

mrdoob commented Jan 21, 2013

Since the current three.js collada loader has many limitations due to its design

This is news to me. What limitations does it have?

  • It is written in coffeescript, which is a script language that compiles into javascript. This will be the biggest problem for sharing with three.js.

Oh! :/

@bhouston
Copy link
Contributor

@crobi, it would be best to not introduce coffee script into Three.js. But given that you can compile coffee script to JavaScript, couldn't you just compile it to JavaScript and then clean up the source code? If you keep it in JavaScript a lot more people can contribute to it.

@crobi
Copy link
Contributor Author

crobi commented Jan 21, 2013

This is news to me. What limitations does it have?

Well, limitations might have been a strong word. A year ago when I looked at the ColladaLoader it did not handle properly materials with multiple textures and some animated meshes. When looking at the code and trying to fix that I had the impression that it did not properly handle the collada address syntax. Although when I look at the code now, I don't remember what parts I thought would be wrong. Also, I had trouble understanding the code and adding new features. So I thought that rewriting the whole loader would be easier than trying to fix it (what a mistake...).

If you are not interested in the new loader, I can also try to collect a list of bugs that the old loader has. I have a set of animated meshes that do not work, but they are proprietary - if you want to use them for testing, send me a private message.

It would be best to not introduce coffee script into Three.js

I know this is a problem and am not sure how to solve it. For the type of code used in the loader, the coffeescript version is just so much nicer than the javascript version that I do not want to abandon it. And contributing to both versions would not work.
However, if there is interest in my loader, I could provide a clean javascript version where I and other people could contribute to.

@bhouston
Copy link
Contributor

@crobi, for shared projects that you want a lot of users of it is always best to use the lowest common denominator technology as it provides the most flexibility. This is why Linux and Windows NT core is generally C even though C++ existed when they were first created. Generally Linus doesn't accept C++ code in the core of Linux even if it is nicely written, it just doesn't happen. Cutting edge technologies are great for end user applications but putting them into core libraries, especially when previously they were not used in the core libraries, is generally a really hard sell. Three.js is all around very conservative on the JavaScript techniques it deploys and this in part makes it very accessible and also everyone had a good understanding of its performance characteristics.

I am all for a better Collada loader but putting it into Coffeescript is really challenging for an otherwise non-Coffeescript library.

You would have to change the style a bit in the JavaScript version, but the benefit would be that there would be a mass of people contributing to it, such as myself, rather than just having to maintain it more on your own or with a smaller group of people.

@bhouston
Copy link
Contributor

@crobi, there is only 6kb difference (~5%) between the coffeescript and javascript versions, that isn't that much of a savings in terms of keystrokes. I think it is very well written though. :-)

@crobi
Copy link
Contributor Author

crobi commented Jan 21, 2013

@bhouston, I understand that putting coffeescript into three.js is not an option. The options I see is not including my loader in three.js at all, or converting it to javascript.

I'm offering my implementation for other people here, but before I spend many hours changing the code style I wanted to know whether there is enough interest in having it as part of three.js :)

that isn't that much of a savings in terms of keystrokes

Note that the javascript version has all comments stripped and a big part of the code is just long class and property names. You save quite a lot of vertical space, though, and the code is more concise (see this vs this).

@gero3
Copy link
Contributor

gero3 commented Jan 21, 2013

Sorry about the late response. I created 2 pull requests for you to check out

  • crobi/ColladaAnimationCompress#10: This makes the colladaloader work with r55
  • crobi/ColladaAnimationCompress#11: This makes sure you don't spread too many globals around

This will help you along the way to get supported for inside three.js.
What I'm still missing in your colladaLoader:

  • Nodes and Library_Nodes: I don't know if this is specified in de specification
  • Camera support: It wasn't implemented.

@bhouston
Copy link
Contributor

@crobi, @mrdoob I should say that @mrdoob is the decider on these matters, not myself. If he wants to expand Three.js to include CoffeeScript code that is his decision to make.

@crobi
Copy link
Contributor Author

crobi commented Jan 21, 2013

@gero3 thanks for the contributions, I merged your pull requests

What I'm still missing in your colladaLoader

library_nodes, library_visual_scenes, cameras, and lights are not supported yet. Until the future of my loader is decided, please open new issues in my repository for feature requests. If you have an example file for the features you need, even better.

@mrdoob
Copy link
Owner

mrdoob commented Jan 21, 2013

@crobi, @mrdoob I should say that @mrdoob is the decider on these matters, not myself. If he wants to expand Three.js to include CoffeeScript code that is his decision to make.

At this point the decision of adding something to the lib is based on whether the contributor will maintain the code and fix bugs that may arise.

For instance, the creator of the current ColladaLoader is not maintaining it so it becomes my responsibility. However, we're lucky that people have been trying to patch it to get stuff fixed or improved, but the situation is not ideal.

Nowadays I tend to include things on the lib that I have under control or that I know that won't create many problems. Adding a second ColladaLoader would make the problem bigger. Add CoffeeScript to the lib would make even more problems. I can just imagine people asking how to use the ColladaLoader and having to teach them what CoffeeScript is and how to compile it.

So yeah, I would rather try to fix the bugs you found in the current ColladaLoader (which I don't find to be that bad really).

Also, ColladaLoader still doesn't handle skinning animation properly. Before doing a new version of the loader I would wait to have the current one fully working. Otherwise we end up with 2 loaders that are half implemented.

@crobi crobi mentioned this issue Jan 21, 2013
7 tasks
@crobi
Copy link
Contributor Author

crobi commented Feb 6, 2013

Base on this discussion, I have decided to keep my loader as an external project that is compatible with, but not part of three.js. Let me know if you are interested in an example (something like this) that advertises this alternative loader. Otherwise, you can close this issue.

@mrdoob
Copy link
Owner

mrdoob commented Feb 6, 2013

Yeah... if only it wasn't written in coffescript it would be great to add it to the lib and keep improving it, hopefully replacing the currently non-maintained one.

@reddozen
Copy link

Coffeescript to JS converter....
cs2js.nodejitsu.com/

@crobi
Copy link
Contributor Author

crobi commented Mar 26, 2013

Coffeescript is always compiled into javascript and as far as I can see, that "converter" is just a frontend for the normal coffeescript compiler.

The problem here is that the generated javascript code is ugly/unreadable and we don't want to maintain coffeescript code within three.js

@reddozen
Copy link

I can definitely understand that. I will say this though, you're solution is the only one I've been able to find that can render and animate my models. It's been painful to find something that works.

@lukyer
Copy link

lukyer commented Mar 26, 2013

what a shame you haven't started developing this loader using pure javascript ... coffee script killed this opportunity (to have good colladaLoader in three.js). Thank you anyway!

@crobi
Copy link
Contributor Author

crobi commented Apr 17, 2013

For anyone interested, I have updated the source code of my loader. It now uses a simpler prototype-based syntax so that the generated javascript looks more like hand-written code.

I have also added strict type annotations for the closure compiler, which increases the file size quite a bit - a significant part of the source code are now comments. The annotations should be easy to remove with a regex if you don't like them.

@arcanis
Copy link
Contributor

arcanis commented May 16, 2013

Just for your information, your loader does not seems to be able to load some files which were previously loaded by the 'old' loader (cf this branch which does not work, whereas gh-pages works correctly).

@crobi
Copy link
Contributor Author

crobi commented May 16, 2013

Do you have an example file which does not work? If so, please open a ticket on https://github.com/rmx/threejs-collada, I'll look into this.

I have noticed that people have been contributing to the built-in collada loader recently, so there might be files that load better with the built-in loader.

@crobi
Copy link
Contributor Author

crobi commented Jul 7, 2014

I am no longer maintaining this alternative collada loader, since I became convinced that COLLADA is about the worst runtime asset format (it's still ok for content exchange between modeling applications).

That being said, my loader still handles a lot of files that fail to load using the built-in COLLADA loader, so if anyone is willing to take over, feel free to reuse whatever parts of the code you want.

Personally, I have reused large parts of the code to play with a converter that converts COLLADA to an experimental webgl runtime asset format. COLLADA files that took over a second to parse now load, animate, and render in under 5ms total.

@mrdoob
Copy link
Owner

mrdoob commented Jul 8, 2014

@crobi do you have some files that our loader fail to parse properly?

@crobi
Copy link
Contributor Author

crobi commented Jul 8, 2014

I have added a comment to #5017. There are probably more issues, I have based my comment on feedback from other people that used my loader because the built in one did not handle their files.

Even if a lot of issues were fixed in the built in loader recently, COLLADA is just a very complex format and I am sure you will keep getting COLLADA-related issues in the future. My loader was not free of bugs either. Maybe if you get a new issue you can have whoever is responsible for the loader have a look at my implementation, just in case my loader happens to handle it differently.

@lukyer
Copy link

lukyer commented Jul 11, 2014

Hi,
last year i wrote Bachelor thesis about distributed WebGL rendering scenes from Blender exported into COLLADA .DAE files. All COLLADA loaders i tried (including this one) unfortunately didn't work well. This format is too much generous for Web usage. Animations, dependent animations, Beziere approximations and many other wasn't implemented in these loaders.

So i wrote another COLLADA loader especially for this usage (exported animations from Blender) on server side (PHP) with conversion into by me designed JSON structure. My advice is - don't use COLLADA loaders, look for another exchange format or write your own special parser like i did.

Working example: http://bp.lukyer.cz (sorry for low server resources, try small models, parser is expensive to run on this cheap server, localhost is OK)

Link to thesis: https://wis.fit.vutbr.cz/FIT/st/rp.php/rp/2012/BP/15557.pdf . Sorry for Czech language, but i'm willing to try to translate parts someone could be interested in. Feel free to write me if you're interested in.

Regards,
Lukáš Svačina.

overviewseq
join
debug

@reddozen
Copy link

I moved onto Babylon.js. While three.js is a nice package, it wasn't for me.


From: lukyer notifications@github.com
To: mrdoob/three.js three.js@noreply.github.com
Cc: reddozen admin@diviniaro.com
Sent: Friday, July 11, 2014 9:11 AM
Subject: Re: [three.js] New collada loader (#2954)

Hi,
last year i wrote Bachelor thesis about distributed WebGL rendering scenes from Blender exported into COLLADA .DAE files. All COLLADA loaders i tried (including this one) unfortunately didn't work well. This format is too much generous for Web usage. Animations, dependent animations, Beziere approximations and many other wasn't implemented in these loaders.
So i wrote another COLLADA loader especially for this usage (exported animations from Blender) on server side (PHP) with conversion into by me designed JSON structure. My advice is - don't use COLLADA loaders, look for another exchange format or write your own special parser like i did.
Working example: http://bp.lukyer.cz (sorry for low server resources, try small models, parser is expensive to run on this cheap server, localhost is OK)
Link to thesis: https://wis.fit.vutbr.cz/FIT/st/rp.php/rp/2012/BP/15557.pdf . Sorry for Czech language, but i'm willing to try to translate parts someone could be interested in. Feel free to write me if you're interested in.
Regards,
Lukáš Svačina.


Reply to this email directly or view it on GitHub.

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

No branches or pull requests

8 participants