Hi,
I want to place certain cubes at defined locations
eg cube 1 (0,0,0)
cube 2 (10,0,0)
but when i created the cube the cube is not placed at the corner rather at the center of the axis.
is there any way to place the cube at the correct position.
i have a tooltip and need to display correct positions
hence want the cubes to start from the corner of the axis and not the center .
Do you create a new geometry for each box? You should only use one box geometry in a 1 unit size, offset it by half like your first cube and then scale the mesh of it for different sizes. If you need a geometry for each box offset the geometry by half of the size in each axis.
Hi, i was following this thread, and i have been trying to achieve kind of the same goal but unfortunately did not succeed. I am new to threejs and i have been trying to make a 3D cube , by assigning it to a point having x,y,z co-ordinates on a cartesian plane.
also, cube.position.set(x,y,z) did not work for me.
Yes it works easy that way. @ThreejsNewbie. Thanks! my coordinates were reversed actually. I went ahead and also created a matrix of cubes.
here i assigned it to co-ordinates from the cartesian plane, i intend to take the co-ordinates of a point from the user , which has a separate function. i hope it makes sense.
var geometry = new THREE.BoxGeometry(h, d, w)
var material = new THREE.MeshPhongMaterial({ color: 0x0000ff })
var cube = new THREE.Mesh(geometry, material)
cube.position.set(x, z, -y)
cube.material.opacity = 0
scene.add(cube)
var temp = {}
temp.originX = x
temp.originY = z
temp.originZ = -y