I see that in vector3, x,y,z are accessors
When did this happen?
assessors are hard to serialize
In vector2 and vector4 these are properties
I see that in vector3, x,y,z are accessors
When did this happen?
assessors are hard to serialize
In vector2 and vector4 these are properties
it’s because the setter on vector3 marks as dirty.
Babylon.js/math.vector.ts at master · BabylonJS/Babylon.js (github.com)
vector2 are public properties (not backed by a private _x)
Babylon.js/math.vector.ts at master · BabylonJS/Babylon.js (github.com)
Has this been this way since the beginning ?
I was trying to serialize this and it wasn’t working which is when I noticed this.
I am assuming the same logic could eventually be applied to vector2 and 4.
Somebody might want to track changes to them and might decide to make them accessor too.
No, I think this is a change since 4.2 and corresponds to this entry in the “what’s new” file:
* Improved world matrix caching engine by using dirty mechanism on vector3 and quaternion ([Deltakosh](https://github.com/deltakosh))
@Evgeni_Popov Might it make more sense to perform dirty tracking in a way that doesn’t remove functionality? Changing Vector3
to use the internal properties has created major issues for compatibility.
I guess we are past that now right? The gain of being able to track all the caches dwarfs the compat issue.
Can you btw give me an example of a compat issue? we replaces members by properties so from the suer standpoint what is the difference?
Interface types can’t be used with static methods. Vector3.Distance
does not work with IVector3Like
, even though all other vector and color class static methods work with the interface.
That is why I’m proposing Vector3Dirty
We could also reflag these functions with IVector3Like instead of Vector3
That is not possible because the static methods use the internal Vector3
-only properties (_x
, _y
, _z
)
oh I see