Underscored properties for gui elements

Hi again, I want to access _currentMeasure property for instance but I can’t call it directly, what should i do?

I am on a phone so heres an untested answer that should probably work.

  1. Call computeWorldMatrices on the instance and then then try printing the value.

  2. Try printing the value inside scene.render.

the first is 3d option as I found out and the second one actually works but I can’t realize why :smiley:

1 Like

Its because the value is not calculated initially, but rather after a couple of frames. Ill look through the docs and let you know if I find a function to force compute it.

Oh, I appreciate it, I just found scene property called executeOnceBeforeRender and can store currentmeasure in a variable there, I can also get current measure in render function but need one extra boolean variable to do this at once only. :heart_eyes:

Could not find a function to force compute the values. Your approach seems like the way to go.

Along similar lines, there is also a onBeforeDrawObservable on the rectangle itself. You can perhaps try storing the _currentMeasure value within it if you want rectangle logic to be contained within the rectangle itself.

rectangle.onBeforeDrawObsevable.add(() => {
    measure = rectangle._currentMeasure;

Though I suppose if that gets called each frame you’ll have to still use a boolean. :cry:

1 Like

It works here. Just add a setTimeout of 500 milliseconds and you get the _currentMeasure

haha :sweat_smile: great