Rotation in child and parent

Hi everyone

I have 4000 cubes, and I have built them with the aid of the json file, then I put them as a child of one Box, to rotate whole of my structure. the Box is in the (0,0,0) point, and the other cubes are in near of (8000,6000,300) point, the problem is when I rotate the box , the other cube rotate on orbit, but i want just to rotate on their local point, I mean i want to rotate whole of 4000 cubes as a one structure in terms of X.Y and Z axis.

this is an example of one cube:

and these are screen shot of my design:

this is the with no rotation:

and when i want to rotate it in y axis (45 degree) the structure move on orbit.

i don’t want to move the structure, i just want to rotate on X,Y and Z axis.

note: the Box is in (0,0,0) point and the cubes of structure are in about (8000,6000,300) points.

I fail to see the problem in your PG?

the problem is I want to know how can I rotate the structure (which has include 4000 cubes) like a single mesh?

Set the pilot at (8000,6000,300) and its pivot point to the same value:

should i write pilot instead of parent in the code?

I didn’t reuse the cylinder you named pilot, I created a TransformNode instead that I named “parent”.

You can use the “pilot” mesh instead of my TransformNode if you want, just replace all occurrences of my “parent” variable by “pilot”.

sorry for taking your precious time again, should I set parent at exact point of 4000 cubes center?

You should set it at the center of rotation you want for the 4000 cubes as a whole.

Given your description, it seems it is (8000,6000,300) but I may have misunderstood what you said.

i have a json file which has X,Y,Z and size of 4000 cubes, I fetched the json file and built cubes with the for loop,
this part of my code:
//**************Fetch Cubes **********/
// cube factory and transition color
const color1 = new BABYLON.Color3(0, 0, 1);
const color2 = new BABYLON.Color3(0, 1, 1);
var arrCubes = [];

async function fetchUsers() {
const response = await fetch("./BlockModelFinal.json");
const cubes = await response.json();
for (let i = 0; i < cubes.length; i++) {
// console.log(cubes[i]);
const cube = new BABYLON.MeshBuilder.CreateBox(
{ height: 5, width: 5, depth: 12 },

  const mat = new BABYLON.StandardMaterial("mat" + cubes[i].key, scene);
  mat.diffuseColor = new BABYLON.Color3.Lerp(color1, color2, cubes[i].G);
  mat.specularColor = new BABYLON.Color3(0, 0, 0);
  cube.material = mat;

  cube.position.x = cubes[i].X;

  cube.position.y = cubes[i].Y;

  cube.position.z = cubes[i].Z;


  //************** End Fetch Cubes **********/

var parentt = new BABYLON.TransformNode("parentt", scene);
parentt.position = new BABYLON.Vector3(8000, 6000, 300);

for (let i = 0; i < arrCubes.length; i++) {
  arrCubes[i].parent = parentt;

parentt.rotation.x = 90;

i did above code, but the structure goes out of camera view.

Please, make it work in a PG (, it will be easier for everyone to see what’s going on.

Note that you can put your json in the PG, even if it is several MBytes.

i coudnt upload the json file on PG. How can i upload it?

You don’t need to upload it, just do:

const cubes = ...the data of your json pasted here...


const cubes = {
1 Like

ok i will do it now

i have done it in the following link, but i get error ( createEngine function must return an engine )

You do not need 4000 cubes to see an issue 10 would surely be enough. Too far to scroll down to see your code. Just ones the furthest apart

sorry. this is with 10 of them:

You did not update the right mesh in your orientateX / orientateY methods.

Contrary to what I said, the position of the dummy mesh should be (0,0,0), only the pivot point matrix should be set to the big value:


thank you so much :pray: :pray: :pray: :pray: