Question

In my code i add the cube2 to the cube1:

  var cube = new THREE.Mesh(new THREE.CubeGeometry(255, 255, 255),new THREE.MeshBasicMaterial( { color: 0x000000, wireframe: true } ));

  var cube2 = new THREE.Mesh(new THREE.CubeGeometry(100, 100, 100), new THREE.MeshBasicMaterial( { color: 0xff0000 }));

  cube.add(cube2);
  scene.add(cube);

Then it looks like this: enter image description here

But i would like to have the red cude cube2 at in the corner of my wireframe cube cube1:

I tried this: But it didnt worked correctly because it only moved my cube somwhere in the space:

  cube2.position = new THREE.Vector3(1, 1, 1)

So what can i do ? Thanks

Was it helpful?

Solution

I think this should do the trick:

cube2.position.x = ( 255 - 100 ) / 2;
cube2.position.y = ( 255 - 100 ) / 2;
cube2.position.z = ( 255 - 100 ) / 2;
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top