I want the objects to be possible to scale as individual objects and after they are scaled, they are merged to one object like the snippet i gave, but i don’t want the scaling part to be hard coded.
I want the user to be able to scale the objects to size tehy want and after that they are merged
const LGeometry = new THREE.BoxGeometry(30, 30, 10);
LGeometry.translate(0, 15, 20);
const LGeometry2 = new THREE.BoxGeometry(10, 30, 50);
LGeometry2.translate(20, 15, 0);
const buildingLGeo = BufferGeometryUtils.mergeGeometries([LGeometry, LGeometry2]);
currentBuilding = new THREE.Mesh(
buildingLGeo,
new THREE.MeshBasicMaterial({ color: 0xff0000 })
);
scene.add(currentBuilding);
currently made it something like this, but it still needs the scaling
bvh could be a good solution, it’s fast enough for runtime translorms. this example isn’t using a slider but it applies the changes runtime, it’s react but bvh is vanilla.
I believe you can save each mesh separately and then add them to a parent. Afterwards, you should be able to position, rotate and scale each of those meshes separately. However, if you make one of those meshes a child of another mesh, then changes to the parent of that second level mesh will carry through to the child. That may be an advantage or create problems.
You can do the same thing with a Group or an Object3D, but my understanding is that using those formats adds to complexity.
No need to merge geometries unless you want a third mesh.
If you need a common parent, you can create a “dummy” mesh (e.g. a tiny cube) to act as the parent. Or you can create a Group and add the meshes to the Group (a Group can be the common parent of all kinds of things).