-
Notifications
You must be signed in to change notification settings - Fork 202
Convert model with OSG
To convert model in osgjs format, the natural way is to use the osgjs plugin in OSG. Because model are used in WebGL, at this time ( WebGL 1.0 ) the geometry with more than 16 bits index can't be displayed. To handle this there is an additional plugin in osg called gles, that convert scene to a opengl es 2.0 specification format.
If you dont have any system with osg available you can get one through docker
docker pull trigrou/osg
using docker to call osgconv from inside docker terminal (at least under windows)
docker run trigrou/osg osgconv
Typically the command line to convert a model into osgjs is like:
osgconv model.osg.gles model.osgjs
there are some extra options that can help depending on your context
- useExternalBinaryArray : create binary files for vertex arrays
- mergeAllBinaryFiles : merge all binary files into one to avoid multi request on a server
- inlineImages : insert base64 encoded images instead of referring to them
- disableCompactBuffer : keep source types and do not try to optimize buffers size
- disableStrictJson : do not clean string (to utf8) or floating point (should be finite) values
Most of the time to have smaller files and improve loading in a web context you will want to do something like this:
osgconv -O "useExternalBinaryArray mergeAllBinaryFiles" file.osg.gles file.osgjs
Also you could probably gzip the binary files generated and change their name to the osgjs file to reference the gz files. Maybe we should do it automatically in the plugin, but right now it's manual.