I am attempting to combine two objects (bar and circle) to create a ping pong racket in three js,
Even after using
var parent = new THREE.Object3D();
, the objects remain separate
This is the code for my function :
function addPaddle() {
var paddleGeometry = new THREE.CylinderGeometry(20, 90, 20, 64, 64),
paddleMaterial = new THREE.MeshLambertMaterial({ color: 0xff0000 }),
paddle = new THREE.Mesh(paddleGeometry, paddleMaterial)
paddle.rotation.x = 30
var barre = new THREE.CubeGeometry(20, 20, 170)
var materialBarre1 = new THREE.MeshBasicMaterial({
color: 0xff0000,
side: THREE.DoubleSide,
})
var barre = new THREE.Mesh(barre, materialBarre1)
var parent = new THREE.Object3D()
parent.add(paddle)
parent.add(barre)
scene.add(parent)
barre.rotation.y = 180
barre.position.x = 100
barre.position.z = 2000
barre.position.y = 300
return paddle
}