when I use Object3D(const tubeGroup= new Object3D()
)
TubeGeometry(const tubeGeometry = new TubeGeometry()
).
I want update Object3D position.
now , I use box3 and Box3Helper,then use box.setFromObject(tubeGeometry )
and box.getCenter(p)
final tubeGroup.position.copy(p)
.
but I find tubeGroup will be offset.
const tubeGroup = new Object3D()
const path = [new Vector3(0, 0, 3), new Vector3(3, 0, 7), new Vector3(-4, 0, 7)]
const points = new CatmullRomCurve3(path) // .getPoints(50)
const mesh = new Mesh(
new TubeGeometry(points, 64, 0.2, 24, false),
new MeshBasicMaterial({
side: DoubleSide,
color: 0xff0000,
transparent: true,
opacity: 0.6,
})
)
// mesh.position = new Vector3(0,0,0)
tubeGroup.add(mesh)
scene.add(tubeGroup)
// tubeGroup.position = Vector3(0,0,0)
use box3 and box3Helper
let box = new Box3()
let box3Helper = new Box3Helper(box)
box.setFromObject(tubeGroup)
let p = new Vector3()
box.getCenter(p)
mesh.position.copy(p)
before
after
expect:
this tubeGroup position is the box3.getCenter()
and geometry still in it’s original position.