More models, more problems: can't rotate clones

Hi There,

I load a model like so:

var boidLoad = assetsManager.addMeshTask(
          "skull task",
          "",
          "https://cdn.glitch.com/6275d7c2-459a-4c97-a67e-c45c4e56e749%2FProject%20Name.obj?v=1629227000106",
          "skull.babylon"
        );
        boidLoad.onSuccess = function(task) {
          //task.loadedMeshes[0].parent = null;
          console.log(task.loadedMeshes);
          task.loadedMeshes[1].position = new BABYLON.Vector3(0,5,0);          
          //task.loadedMeshes[0].scale(.1,.1,.1);
          task.loadedMeshes[1]._scaling = new BABYLON.Vector3(.1,.1,.1);
          //console.log(task.loadedMeshes[0]);
          
          //console.log(task.loadedMeshes[1]);
          
          stealthBoid = task.loadedMeshes[1].clone();
        };

Cool. I’ve got it in there. I can even rotate it no problem.

But when I generate the clones and try to rotate them:

          for (let i = 0; i < total; i++) {
            
            //box for the boid body;
            // const box = BABYLON.MeshBuilder.CreateBox("box" + i, {
            //   width: 0.3,
            //   height: 0.5,
            //   depth: 1.0
            // });
            
            const box = stealthBoid.clone();
            box.rotation._y = 1.5708;
            console.log(box);
            
            box.boid = boidsManager.boids[i];
            box.material = redMat; //pbr; //redMat; //brickMaterial; //red mat is the normal one
            models.push(box);
          }

For the life of me, I cannot. Essentially, I have cloned 10 stealth bombers and right now they are flying in the direction of their right wing, as opposed to flying from their center (like a real stealth bomber). I’m trying to rotate each clone 90 degrees, so they are flying correctly.

I correctly rotated the original model, which still didn’t do anything about the clones.

The clones have no parents, so how do I change their rotation so they fly right? The clones are operated using this library (Boids extension), but I don’t think I have to go mucking about in the library, i think I just have to change the orientation of the stealth bombers, right?

(I also try just rotation.y and nada).

That should work. I think you will need to setup a repro in the Playground so that we are able to help.

Looks like your model is oriented in a way, so the local forward is not on the Z-axis.
You can fix this in Blender/Maya/Max, or do it by baking a new transform. I suspect this is why it might be flying sideways using the boids system
https://playground.babylonjs.com/#MYW4D8

Edit: Meant Z-axis. Lol

1 Like

This worked, but where in the docs can I learn about what all this means; I haven’t encountered anything like it before.