I was loading some pcd files in a scene for some side project, and I had to use the geometry after loading it in the scene for raycasting and rotation. But I was getting variable undefined error. Here is my sample code:
var points_geometry = undefined
var load_pcd = function(){
loader.load('./arma_Red.pcd',function(points){
var buffer_geo = new THREE.BufferGeometry()
buffer_geo.setAttribute('position',new THREE.Float32BufferAttribute(points.geometry.attributes.position.array,3))
var pts_mat = new THREE.PointsMaterial({color: 0xff00ff})
points_geometry = new THREE.Points(buffer_geo,pts_mat)
scene.add(points_geometry)
})
}
var animate = function(){
renderer.render(scene,camera)
controls.update()
requestAnimationFrame(animate)
}
load_pcd()
console.log(points_geometry)
animate()
I am getting points_geometry as undefined after calling load_pcd function. Please help me out with this