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.
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(
cubes[i].key,
{ height: 5, width: 5, depth: 12 },
scene
);
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;
arrCubes.push(cube);
}
//************** End Fetch Cubes **********/
var parentt = new BABYLON.TransformNode("parentt", scene);
parentt.position = new BABYLON.Vector3(8000, 6000, 300);
parentt.setPivotPoint(parentt.position);
console.log(parentt);
for (let i = 0; i < arrCubes.length; i++) {
arrCubes[i].parent = parentt;
}
parentt.rotation.x = 90;