Hi
I’m in this mobile AR app I’m developing and I have an UI-button that I have hooked up to change the size/with of the model rendered over the AR marker.
The button fires an event, the ArMarker script listens to it and changes it’s attribute (this.width
) value accordingly. I console log this value and it is indeed changed.
But then in the update method, I log the same value, and it is never changed there. I feel I must be missing something fundamentally, like, can I not change script attribute values from code? or is this some type of “by reference” problem? this is a number though, no complex datatype.
stripped code:
ArMarker.prototype.onToggleScale = function() {
this.width = 1.5;
console.log("setting this.width:" + this.width);
};
// update code called every frame
ArMarker.prototype.update = function(dt) {
if (this.active) {
var timeSinceLastSeen = (Date.now() - this.lastSeen) / 1000;
if (timeSinceLastSeen > this.deactivationTime) {
this.hideChildren();
this.active = false;
}
console.log("this.width:" + this.width);
if (this.width > 0){
this.entity.setLocalScale(1 / this.width, 1 / this.width, 1 / this.width);
}
}
};