Previous Thread  Next Thread

chat icon Blender in Webgl

Jena

Posted: Fri Nov 11, 2011 7:04 pm
Joined: 11 Nov 2011
Posts: 1
Hello,

I'm trying to export Blender models to Javascript.
With the aim to develop a simple webgl game.
Although, I'm new in Blender and have no idea how to export Blender models to Javascript. Any ideas?


Kind regards
Jena
Reply with quote


tmpest

Posted: Fri Jan 13, 2012 8:23 pm
Joined: 13 Jan 2012
Posts: 1
Jena wrote:

Although, I'm new in Blender and have no idea how to export Blender models to Javascript. Any ideas?


Hello, Jena!

WebGL requires a "loader" to perform the loading of a model. There is no "JavaScript" format for 3D models, per se. WebGL, like the full OpenGL are basic frameworks and do not provide a "native" format for the 3D models they display. In fact, you will find yourself writing the actual code to turn each polygon into a GL instance to display it! You will also be writing libraries to do transformations on them to turn, twist, animate... blah, blah. Lots of work on your part!

Basically, in a Graphics Library environment nothing is built for you. You will need to look for things called "loaders" to interpret the 3D models into the GL language for you.

Luckily, you have many loaders in the open source domain but I would look for OBJ (also called wavefront) and COLLADA (which is owned by the WebGL defining body, but I may be mistaken).

In short, in WebGL you will either need to find an "engine" with a pre-built loader or you will have to build it yourself.

Once you have that hurdle over, its super simple to export from Blender what you need. Blender supports many, many formats.
_________________
---------------------------------------------
tmpest
Reply with quote


zidarsk8

Posted: Sat Feb 04, 2012 2:59 am
Joined: 03 Feb 2012
Posts: 2
I have had a project like that a while back and these are the things I have learned (it may be a bit outdated now)

One nice way of making models in WebGL is usign SpiderGL, a javascript library that can import collada files: http://spidergl.org/example.php?id=10. All you have to do is export your blender model as a collada file.

I have had some problems wit this, cause it did not allow me to do all the stuff I wanted, so I came up with this (i's very limited but just what i wanted, vertices and faces and nothing more):
- export blender file as .obj
- convert .obj into a json presentation of the object (i used this script https://github.com/zidarsk8/Fri/blob/master/static/blenderFiles/convert.py , and again ... it's limited and buggy, i just wrote this to learn)
- draw vertices as i see fit in javascript since i have a json where all my vertices normals and faces are stored. (in the bottom of this horrible mess, you'll find something that uses the json and actually draws it https://github.com/zidarsk8/Fri/blob/master/static/js/friWalker.js )


So, use SpiderGL if you want to get something done, Use the second method if you just want to learn more and see how stuff is actually made deep down.[/url]
Reply with quote


johngflower

Posted: Fri Feb 10, 2012 1:27 am
Joined: 01 Nov 2008
Posts: 25
Thanks Zidarsk. I'd been thinking about using WebGL to show Blender models. Your explanation of what can and can't be done was useful.
Reply with quote


 
Jump to:  
Powered by phpBB © 2001, 2005 phpBB Group