How to tweak attributes in editor?
for example I want to adjust distance when orbiting the camera
this.on('attr:distance', function (value, prev) {
this.distance = value;
});
but I get
Maximum call stack size exceeded
I saw https://playcanvas.com/project/437946/overview/live-script-attribute-tweaking
but I want to tweak numbers not entites
ah maybe because I have in update
this.distance = 2;
and then in inititialize the value from update is and then maximum call stack exceeded?
no, still the issue, I can tweak the distance but still the error appears
yes I have it
CameraAnim.attributes.add('distance', {type: 'number'});
but I get
Maximum call stack size exceeded
I am checking your project and I don’t see any CameraAnim script or a numeric attribute in your live-tweaking.js script.
Maybe it’s a different project?
1 Like
yes this is different project ok so here is the scene
https://playcanvas.com/editor/scene/1095036
So not sure why your project gets that error, but you don’t really need the event handler to tweak the distance attribute. Each time you change the value in editor the camera distance gets updated, if I comment out this:
initialize() {
this.currentAngle = this.targetAngle = this.height = this.distance = 0;
this.animSpeed = 5;
// this.on('attr:distance', function (value, prev) {
// this.distance = value;
// });
}
1 Like
yaustar
February 21, 2021, 4:37pm
#10
It looks like the statement was an infinite loop as it was setting a value to itself. Setting a value to this.distance
probably fires the attr event
3 Likes