please check this project for possible bugs … I can’t see what I am missing
https://playcanvas.com/editor/scene/1142210
- camera will not orbit
please check this project for possible bugs … I can’t see what I am missing
https://playcanvas.com/editor/scene/1142210
I have just written this as [SOLVED], but this is not the whole truth (the project is still not working, and I will put it in the category of ‘some sort of server instability’ … maybe not repo-updates or backups - but still related to the actual harddisk-container: I moved the content and it worked [?] )
If somebody/some admins has/have the answer to the mystery - please let me know :-j
The reason it doesn’t work is because of this added code:
OrbitCamera.prototype.update = function(dt) {
// Add inertia, if any
var t = this.inertiaFactor === 0 ? 1 : Math.min(dt / this.inertiaFactor, 1);
this._distance = pc.math.lerp(this._distance, this._targetDistance, t);
this._yaw = pc.math.lerp(this._yaw, this._targetYaw, t);
this._pitch = pc.math.lerp(this._pitch, this._targetPitch, t);
if(this.vaultState === false){ this._updatePosition(); }
};
Specifically
if(this.vaultState === false){ this._updatePosition(); }
this.vaultState
is undefined so updatePosition is never called.
Refer to https://stackoverflow.com/questions/19277458/why-does-undefined-equals-false-return-false/19277873 on why.
ahh … ok - I did copy that orbit-script from a project to another with that alteration (was actually looking for that to be sure I did not include that vaultstate) … guess I missed it; only one line :-/
So in short in relation to: https://stackoverflow.com/questions/19277458/why-does-undefined-equals-false-return-false/19277873
It’s because it isn’t an error. It’s defined behaviour in JS.
This is where debugging techniques and processes are useful to finding code logic issues like this.
related to working with try/catch (compile or not compile)?
If I wrote:
if(this.vaultState === false){ this._updatePosition(); } console.log(this.vaultState);
Using a try / catch wouldn’t change anything as no exception is thrown.
That would run without code errors and print out undefined
in the console.log.
The way I debugged it was:
if(this.vaultState === false){ this._updatePosition(); }
)this.vaultState
value was set (it wasn’t so therefore is undefined and this if statement would evaluate to false)