- This topic has 18 replies, 5 voices, and was last updated 4 years, 1 month ago by Yuri Kovelenov.
-
AuthorPosts
-
2019-09-08 at 12:06 pm #18501madbatCustomer
Hey!
I can append scene and clone objects, But how do I remove objects that I have cloned?
Like what you do with verge3d :)// Patrik
2019-09-09 at 7:03 am #18508Yuri KovelenovStaff2019-09-09 at 7:47 am #18514zjbcoolCustomerOh,I think we can create a partical system using puzzle now.
2019-09-09 at 8:06 am #18520Yuri KovelenovStaffpartical system using puzzle now
Would be interesting to see if this can work
2019-09-09 at 2:43 pm #18531jemCustomerHi Yuri,
I do not wish to complicate this topic, but I do wonder if the remove() function is sufficient to completely remove an object and its data from memory? There are a few threads about this on Stack Exchange and a page in the Three documentation (https://threejs.org/docs/#manual/en/introduction/How-to-dispose-of-objects). I wrote a function to do this that removes the object from the scene and also disposes of the data. My hope was this approach would free up memory better than using remove() alone. What is the opinion of the Soft8soft team?
Thank you.//A function to fully dispose of objects. //This is useful to dispose of cloned objects. app.ExternalInterface.disposeOfObjects = function (objects) { for (var i = 0; i < objects.length; i++) { if (typeof objects !== 'undefined') { var meshToBeDeleted = app.scene.getObjectByName(objects); app.scene.remove(meshToBeDeleted); meshToBeDeleted.geometry.dispose(); meshToBeDeleted.material.dispose(); meshToBeDeleted = undefined; } } };
Jeremy Wernick
2019-09-09 at 2:57 pm #18533Yuri KovelenovStaffif the remove() function is sufficient to completely remove an object and its data from memory?
Indeed, calling dispose() for both geometry and the material is necessary to free memory occupied by an object’s resources. Thank for sharing the snippet!
2019-09-09 at 3:19 pm #18535jemCustomerOops. I was editing my previous post in an attempt to fix the formatting of the JavaScript code and the forum software seems to have deleted the post. Apparently square brackets can cause issues. At risk of double posting, here is my original post that Yuri responded to (with the JS code now included as an image).
———————-
Hi Yuri,
I do not wish to complicate this topic, but I do wonder if the remove() function is sufficient to completely remove an object and its data from memory? There are a few threads about this on Stack Exchange and a page in the Three documentation (https://threejs.org/docs/#manual/en/introduction/How-to-dispose-of-objects). I wrote a function to do this that removes the object from the scene and also disposes of the data. My hope was this approach would free up memory better than using remove() alone. What is the opinion of the Soft8soft team?
Thank you.Jeremy Wernick
2019-09-09 at 3:32 pm #18538Yuri KovelenovStaff2019-09-10 at 4:39 pm #18545madbatCustomerThanks for quick reply.
2020-09-28 at 8:56 am #33480matthewCustomerHello,
I am not proficient in JS and cannot figure out how to remove every clone created besides the last one created (every next one still exists after I click the remove button). Here are my puzzles:
2020-09-28 at 9:17 am #33483Yuri KovelenovStaff2020-09-28 at 9:19 am #33484matthewCustomerOh sorry, I hope here it is:
2020-09-28 at 9:21 am #33487matthewCustomer2020-09-28 at 9:31 am #33488Yuri KovelenovStaffGot it! In fact, there is no longer need to use code, since an object can now be removed with this puzzle:
https://www.soft8soft.com/docs/manual/en/puzzles/Objects.html#remove
2020-09-28 at 9:52 am #33489matthewCustomerThat’s great Yuri, however problem still remains. I need to remove every cloned object at each click of the button. For example – if I create 4 clones I want to be able to delete them all with each click deleting last one object added. Right now I can only delete exactly the last object cloned and rest of them remain on the scene. Puzzles below:
How do I target every object in the list of cloned objects – and delete them one by one? I assume the problem is with the cloning puzzle itself. There should be a loop adding an object inside the array/list for each click but I can’t seem to figure it out – pls help ^_^
-
AuthorPosts
- You must be logged in to reply to this topic.