This question does not appear to have been asked yet.
I am cloning an entity and then placing it somewhere in the scene.
var cloned = pc.app.root.findByName("theNameOfTheEntity");
var e = cloned.clone(); // Clone Entity
cloned.parent.addChild(e); // Add it as a sibling to the original
How do I keep track of the history of the clones and let the user delete the last entity in the array if they make a mistake.
I am stuck in console where I am able to find _aabVer here — pc.app.root.findByName(‘rust’)._aabbVer ---- but I cannot figure out how to delete those clones.
You are creating clones and you want the user to delete the history sort of like undo? You could have an array in your script and when you create a new clone push it to the array. Then when the user destroys the entity you remove it from the array…
Yes exactly what my question is. But trying to understand the scope of where to run those commands is where I am getting stuck.
Or in other words … does anyone have any code examples I can look at?
What exactly would you like code examples for? Adding stuff to arrays is I guess self explanatory - you could have a script that stores this array and when you clone entities you add the cloned entities to the array in that script.
You want users to delete the last entity if they make a mistake you say. What do you mean exactly - how do you want users to delete the entity? What is a mistake? What is the context of your application?
Nevermind - I figured it out- https://playcanvas.com/editor/code/490487?tabs=8333508
I just wish there were more simple examples like in the tutorial section as a lot of those are really excellent.
Thanks for taking a look @valos , hopefully the code above will help someone else in the future.