Avoid changing the internal vectors the engine use. Try creating a new one somewhere in your initialize method and use that:
// in initialize
this.vec = new pc.Vec3();
// in your flyTo() method
const position = this.vec.copy(this.entity.getPosition());
position.lerp(pointA.getPosition(), pointB.getPosition(), percent);
this.entity.setPosition(position);
what should be wrong if it not interpolates but goes and goes above the limit value I see hmm?
for example when I pick the wheels then the percent goes above 1, so above 100%
looks like its updating over and over this.time += dt;
but not always in other states it interpolates from point A to B
Neither as they both set time to 0 before calling flyTo each frame. I don’t know what triggers the transition in the first place but if it’s on a button press, that will be where to reset values.
The value of alpha, which in your case is stored in percent variable, should be from 0 to 1. When you add let percent = this.time / this.duration;, your this.time always grows, making percent grow too indefinitely, way over value of 1. This will result in camera “overshooting” the target position.
You should add a check and reset it to 1, if it is over it. Something like:
let percent = this.time / this.duration;
if (percent > 1) {
percent = 1;
}
Also, as @yaustar mentioned, you should reset this.time to 0, before your update(dt) method on event that symbolizes the start of a lerp sequence. This will allow the percent variable to grow from 0 to 1 again.