mpetroff / pannellum

Pannellum is a lightweight, free, and open source panorama viewer for the web.
https://pannellum.org/
MIT License
4.15k stars 710 forks source link

lookAt callback fires for every property #1154

Closed aproni34f closed 1 year ago

aproni34f commented 1 year ago

The way this function is constructed, if you are calling lookAt(pitch, yaw...) callback is fired for every property. Is this a desired behavior since animated is the same time for all? Shouldnt you return one callback for all properties?

this.lookAt = function(pitch, yaw, hfov, animated, callback, callbackArgs) {
animated = animated == undefined ? 1000: Number(animated);
console.log(animated)
if (pitch !== undefined && Math.abs(pitch - config.pitch) > eps) {
    this.setPitch(pitch, animated, callback, callbackArgs);
    callback = undefined;
}
if (yaw !== undefined && Math.abs(yaw - config.yaw) > eps) {
    this.setYaw(yaw, animated, callback, callbackArgs);
    callback = undefined;
}
if (hfov !== undefined && Math.abs(hfov - config.hfov) > eps) {
    this.setHfov(hfov, animated, callback, callbackArgs);
    callback = undefined;
}
if (typeof callback == 'function')
    callback(callbackArgs);
return this;
}
mpetroff commented 1 year ago

callback is fired for every property

No, it isn't. It is only fired once. After the first time, the callback variable is set to undefined, so it isn't used again.