Closed WitoldKosowski closed 8 years ago
Might have been a quick fix :)
I've just deployed it to the xml3d.js hosted at xml3d.org, could you test your application again and see if it works properly now?
After the fix it does visualize the model so that's great.
However what is still not ok, is that the camera.js doesn't work. I can't rotate, zoom or pan the visualized model.
I think you'll need to initialize the camera after the XML3D element has been initialized. I would use a framedrawn listener on the XML3D element after you insert it into the DOM:
$('#VisualizerContainer').html(data.result.ResponseView);
$("#myxml3d").on("framedrawn", function() {
var cam = new XML3D.Xml3dSceneController($("#myxml3d")[0]);
});
Yes, that did the trick, although I had to use the load event instead of framedrawn, because the model got very crazy after I zoomed in/out or panned the view.
So I used:
$('#VisualizerContainer').html(data.result.ResponseView);
$("#myxml3d").on("load", function () {
var cam = new XML3D.Xml3dSceneController($("#myxml3d")[0]);
});
So this solved my problem completely and I think this issue can be closed. :)
You're right the load event is a better choice, if you don't remove the framedrawn listener after the first frame it re-initializes the camera every frame :o
Thanks for the example code! I'm glad we could finally squash this bug.
Hi, I'm having a problem with loading new xml3d objects dynamically. What I am trying to achieve is to use xml3d to visualize a 3d .stl file, which has been uploaded using ajax file upload. Once the file gets uploaded, the server returns a json response containing some html, which is inserted via jquery to a specific container. The document already contains all the necessary xml3d scripts, including xml3d.js, camera.js and the xml3d-stl-pligin.js.
After the html with the xml3d tag gets inserted to the container, the model does not get visualized. The app is an ASP.NET MVC web app, tested it on the current Chrome, Firefox, Opera and IE11 and the model is not getting visualized in any of them.
You can find a snippet below.
Main document's head part: (1)
Main document's body part: (2)
The after-upload html response part: (3)
A piece of javascript from the file uploader: (4)