Jump to content

Problem with appendChild


arcadi

Recommended Posts

Hi, I am designing a web application, and I have troubles when I update a view in aproximatetly the 50th time. I put the 3D object in the view using:

new_view =new Viewer( 3D_Object, 250, 250, 5); document.getElementById(0).appendChild(new_view.gl.canvas);

And when I want to update the view, because I manipulate this 3D object, I use:

old_view = new_view;new_view =new Viewer( 3D_Object, 250, 250, 5); document.getElementById(0).removeChild(old_view.gl.canvas);document.getElementById(0).appendChild(new_view.gl.canvas);

The updates work well in the firts 49 times aproximatetly, but in the time 50 the program hangs. In the firts times:zobyg3.jpg When the code breaks in the 50th time:2rc0mfm.jpg What is wrong? Tanks

Link to comment
Share on other sites

Thanks for the reply. I cannot hang the web, because It's a offline application. I put the webpage in a zip (I passed the antiviruses). Proba6.html is the webpage, and It needs the libraries: csg.js, lightgl.js and viewer.js. The file INFO.txt, is a text file that contains the tool coordinates and workpiece dimensions. It needs to be in C: directory. For see the piece, It only works with chrome with the extention "--allow-file-access-from-files" for read the text file, like the direct acces that I put in the zip. A lot of thanks... I am very desperate because is the last thing that I need for my final project...

CSG_TOOL.zip

Link to comment
Share on other sites

I try your code, see the same thing, I think there is no problem with removeChild or appendChild, please notice 'viewers' variable in viewer.js, after each 500ms, it will contain one more Viewer object, I see Chrome process in Task Manager raise its using memory -> hanging. Try to put viewers = [] in front of viewers.push(this) at line 38, everything will be fine!

Link to comment
Share on other sites

Thanks for the reply. I talked to the CSG.js creator. He believed that change the command "vista = new Viewer(final, 500, 500, 10)" for "vista.mesh = final.toMesh" and "vista.onDraw()".Because I was creating a lot of viewers... I will try it later and put here the conclusions. Also I will try that you say. A lot of thanks!

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...