I’m trying to ‘copy’ the applied position of a gltf model to create a ‘point cloud’, but I can’t seem to figure out how to apply the rotations / if there is a better way of approaching this.
Eg: I want the point cloud to follow the applied position / scale / rotations of the displayed model, rather the default T-pose.
Fiddle: Edit fiddle - JSFiddle - Code Playground
const geometries = [] // Attempt 1 - Collect geometries
gltf.scene.traverse((child) => {
if (child.isMesh && child.geometry) {
const geometry = child.geometry.clone()
// geometry.applyMatrix4(child.matrixWorld) // I thought this would be required, but it makes it small
const positionAttribute = geometry.attributes.position
if (positionAttribute) {
const cleanGeometry = new THREE.BufferGeometry()
cleanGeometry.setAttribute('position', positionAttribute)
geometries.push(cleanGeometry)
}
}
})
const pointGeom1 = BufferGeometryUtils.mergeGeometries(geometries, false)
const pointCloud1 = new THREE.Points(pointGeom1, new THREE.PointsMaterial({color: 0xff0000, size: 0.001}))
scene.add(pointCloud1)
Any pointers would be fantastic. I’ve tried the merging geometry, collecting vertex positions and also sampling the meshes without any luck. Thanks very much