osgjs models "not well formed"

187 views
Skip to first unread message

John Culbertson

unread,
Jan 22, 2013, 11:00:05 PM1/22/13
to os...@googlegroups.com
Let me preface that I'm not an expert in js programming.  :)

I'm having trouble getting any of the .osgjs models to load locally.  I thought it might be a problem with my build of osg.js, but even when I copy the working files from the osgjs.org examples (e.g. osgjs/examples/ssao/ - index page, main.js, osg.js, and raceship.osgjs (updating references to be local, of course)), it tells me that the .osgjs model is "not well-formed".  This happens in the ssao example and the cubemap example (the only other example I can find that loads an osgjs model). 

Any ideas?

Thanks,

John

Cedric Pinson

unread,
Jan 23, 2013, 6:58:27 PM1/23/13
to os...@googlegroups.com
Hi John,
Could you send the console log ? the other point is that some example needs to have a local server because of xhr.

Cedric Pinson
Provide OpenGL, WebGL services
+33 659 598 614 - 
http://cedricpinson.com - http://osgjs.org - http://sketchfab.com

John Culbertson

unread,
Jan 30, 2013, 9:19:38 PM1/30/13
to os...@googlegroups.com
Hi Cedric/trigrou,

Sorry for not replying earlier.  I've gotten rid of that specific problem.  I'm not sure the specific reason I was getting that error, but it may have been due to using a OS/browser/driver combination that didn't fully support WebGL.  I've upgraded, and now I'm able to see your examples correctly - I hadn't even realized that some of them were displaying "broken" before!

Anyways, I'm still stuck; I still can't display models that I've converted using the osgjs converter.

1. osgconv doesn't give any indication of error when I convert (using default options):

found 1 tristrip, total vertexes 4 should result to 6 after connection
found 2 tristrip, total vertexes 8 should result to 12 after connection
found 1 tristrip, total vertexes 4 should result to 6 after connection
found 4 tristrip, total vertexes 16 should result to 24 after connection
found 3 tristrip, total vertexes 12 should result to 18 after connection
found 1 tristrip, total vertexes 5 should result to 7 after connection
found 3 tristrip, total vertexes 12 should result to 18 after connection
found 3 tristrip, total vertexes 12 should result to 18 after connection
found 1 tristrip, total vertexes 5 should result to 7 after connection
found 4 tristrip, total vertexes 16 should result to 24 after connection
found 7 tristrip, total vertexes 30 should result to 44 after connection
found 2 tristrip, total vertexes 8 should result to 12 after connection
SceneNbTriangles:120870
SceneNbVertexes:362526
Data written to 'newModel.osgjs'.

2. All I've done is take the working cubemap example, and change the model loaded by main.js from "monkey.osgjs" to "newModel.osgjs", where newModel.osgjs is the model I'm trying to view.  The console log (using Chrome) is as follows:

loading newModel.osgjs osg.js:3
  1. Uncaught SyntaxError: Unexpected token } main.js:191
    1. req.onreadystatechangemain.js:191

3. The model I'm trying to display is pretty large - 16.5M - could that be the problem?

Thanks,

John

Cedric Pinson

unread,
Jan 30, 2013, 9:25:25 PM1/30/13
to os...@googlegroups.com
Hi John,
First did you try with simple model ? else do you have an the example of your model that produces the bug. The last think I would suggest is that maybe the url of your model is not good ( maybe a typo ) and you try to parse an error that is not a json string.

Anyway send more information I will help for sure

Cedric Pinson
Provide OpenGL, WebGL services
+33 659 598 614 - 
http://cedricpinson.com - http://osgjs.org - http://sketchfab.com

--
You received this message because you are subscribed to the Google Groups "osgjs" group.
To unsubscribe from this group and stop receiving emails from it, send an email to osgjs+un...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.
 
 

Morakot Pilouk

unread,
Jun 3, 2013, 1:59:33 AM6/3/13
to os...@googlegroups.com
I ran into the same problem. Investigated the resulting .osgjs file and found that there is an extra comma after the "Size": xxxx and before the next closing "}". This is how it appears after ran the osgconv:

"Size": 6075, }

I changed this to:

"Size": 6075 }

I searched for all the "Size:" and removed the extra commas and the model loading went through just fine.

Cedric Pinson

unread,
Jun 3, 2013, 1:36:56 PM6/3/13
to os...@googlegroups.com
Which version of the exporter are you using ? I guess it must be fixed on my version, because I am using it and it works.
Could you point me on the version you used ?


Cedric Pinson
Provide OpenGL, WebGL services
+33 659 598 614 - 
http://cedricpinson.com - http://osgjs.org - http://sketchfab.com

Morakot Pilouk

unread,
Jun 4, 2013, 11:57:04 PM6/4/13
to os...@googlegroups.com
I pulled source from the master branch at https://github.com/cedricpinson/osg a few days ago and built on my local machine. The plugins folder under bin is osgPlugins-3.1.4.

Soewono Effendi

unread,
Jun 16, 2013, 7:01:55 AM6/16/13
to os...@googlegroups.com
I had similiar problem:
Please see /master/src/osgPlugins/osgjs/JSON_Objects.cpp:
===
    str << JSONObjectBase::indent() << "\"Size\": " << array->getNumElements() << "," << std::endl;


    if (_useExternalBinaryArray) {
...
==

If "_useExternalBinaryArray" is not specified, the generated JSON file is malformed.
Btw. http://jsonlint.org/ is a great help.

regards,
-sef

Cedric Pinson

unread,
Jun 16, 2013, 7:46:51 AM6/16/13
to os...@googlegroups.com
Hi,
Ok it makes sense and easy to fix. I will make a quick fix.

Regards,
Cedric
Reply all
Reply to author
Forward
0 new messages