I am trying to animate a camera zoom to a location while looking at an object.
I have been working on this problem for a few days now. My first test was to create a coneGeo and animate that to the location I wanted so I can visually see if my math works. It works.
I start for the camera’s position and use CubucBezierCurve3 to plot a path to follow. I use LineCurve3 to create a smooth lookAt.
let loc = hex.loc
loc.y = hex.height - 40
let camera = this.camera.curObj
let start = camera.position
let c0 = new THREE.Vector3(loc.x, loc.y + 50, loc.z)
let c1 = new THREE.Vector3(loc.x, loc.y + 10, loc.z)
let end = new THREE.Vector3(loc.x, loc.y, loc.z)
let curve = new THREE.CubicBezierCurve3(start, c0, c1, end)
let pts = curve.getSpacedPoints(6)
let look = new THREE.LineCurve3(start, end)
let lks = look.getSpacedPoints(6)
I then create a setInterval routine to “animate” the movement. each time the position and look at changes
let loc = lookPath[idx]
ptr.lookAt(loc.x, loc.y, loc.z)
let whr = camPath[idx]
ptr.position.set(whr.x, whr.y, whr.z)
idx += 1
The cone wirk just fine but when I try it with the camera, lookAt always looks at 0, 0, 0 and the final position is much different that what I set it at
I verify both visually and math
` console.log('REN', this.camera.curObj.position)
I disable orbit controls before I start this operation.
1> First, How do I printout what the camera is really looking at? getWorldDirection returns NaN, NaN, NaN
2> Second, What can I do to debug this problem? I am lost