Closed Arsakes closed 8 years ago
I'll take a look at this on Monday and add a few tests using require.js to our test suite, since it seems to cause problems more often than it should. Thanks for the report!
I wasn't able to reproduce this on our side. I've attached a zip containing one of the test scenes I created, you should see an empty gray canvas followed by a canvas with a light purple background and a yellow square. Both XML3D and jquery are loaded through requirejs as you described above.
Could you check for any differences in the way this scene loads the scripts and your usage that leads to the error?
There are few differences
but the one I've found the be the reason is the dom element I append display: none
(It becomes visible only after every requirejs module has loaded fully).
I've assumed it holds no relevance sorry for that.
Btw I'm (clearly) no expert on require.js but shouldn't you use it the usual way that is - reference some main script from
<script data-main="scripts/main.js" src="scripts/require.js"></script>
Ahh, yeah that would cause problems. Elements with display: none
have no width or height, and XML3D needs those to initialize (among other things) the canvas and the camera parameters.
If you want to hide the element while everything loads using visibility: hidden
would be compatible with XML3D. The element will be invisible but will still be part of the page flow and have width and height properties. If you don't want it in the page flow either you could use position: absolute
and keep it off screen until loading is finished, as long as it has valid dimensions it should work.
I'll add a note about this in our Wiki at least.
Thanks, I've just came to smiliar conclusions, I should have investigated it more closely before reporting sorry - you can close the issue.
No problem, it was still useful to see that this is a potential problem that people might run into. In fact I think I'll add a check for null width and height so people will at least see a more helpful error message in the console in the future.
Concerns latest commit: 1b2394bc106cb3c70ff82a6c5cc70e2aafe809c9. http://www.xml3d.org/xml3d/script/xml3d-5.0.0-min.js Following js code produces error: (XML3D is loaded using require.js)
The error message:
The
<xml3d></xml3d>
html code works properly when used on static page.