[SOLVED] _aabVer clone prototype

This question does not appear to have been asked yet.

I am cloning an entity and then placing it somewhere in the scene.

https://developer.playcanvas.com/en/api/pc.Entity.html#clone

    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
    e.setPosition(float32vectors);

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.

https://developer.playcanvas.com/en/api/pc.Entity.html#clone

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 wanted to understand how to clone an object and be able to then manipulate it somehow later on. In this particular instance I want to clone and store the entity in an array and then later on in the code somewhere be able to pop off the last entity in the array. I know how that works in javascript … where I was getting stuck is in Playcanvas scope in the prototypes and where to put the code to initialise it and how to call it from outside the script I attached to the entity from Chome console. Simple stuff really when you know how.

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.