Asset Container Names and Animations

Hello everyone!

Thanks to @sebavan and @jeff2365, I’m making progress with understanding asset containers. The community help here is awesome!

The example I’m working with is HERE.

Here are the issues:

  1. Animations don’t seem to carry over to the duplicates. I tried adding new animation functions for the duplicates, but the scene crashes.

  2. The duplicates can be named, but I’m not sure if it’s possible to give them unique names (for instance: box1, box2, box3). In the example, I gave the duplicates the name of “iBox1,” but that same name was applied to both duplicates.

The goal is to generate duplicates from the container template, then assign the duplicates random properties (scale, animations values, etc.).

The code below is for instances, but it seems that something similar could be applied to asset container duplicates.

for (var index = 0; index < boxNumber - 1; index++) {
let instance = box.createInstance(“box” + index);
instance.position.x = 200 - Math.random() * 400;
instance.position.z = 200 - Math.random() * 400;
instance.alwaysSelectAsActiveMesh = true;
};

Hello! maybe a repro in the playground could help us what you need/miss ?

Hello @Deltakosh!

Of course, here’s the playground again: https://www.babylonjs-playground.com/#5NFRVE#40

Well the animation here is done manually. So this should be:
https://www.babylonjs-playground.com/#5NFRVE#41

I see, thank you. That definitely works, but I don’t understand the use of “target” instead of referencing the mesh (“box”). I picked the name rotateBox for the variable, but is that actually some type of command by coincidence?

Well this is more a JS question :slight_smile:
target is the variable name for the rotateBox function

I understand. Thanks again for the help! :smiley: :+1: