The mesh visibility property cannot be set with an animation in some circumstances

A strange one this that perhaps has something to do with Javascript ‘strict mode’?

In this PG https://playground.babylonjs.com/#99XJ1H#4 lines 123 - 125 and 127 - 129 work with 136,137 and 144,145 when move button is clicked

In this PG https://playground.babylonjs.com/#KI8BJH#28 the corresponding lines 21-23, 25 -27 (called from lines 284, 289) produce the error

TypeError: setting getter-only property “visibility”

when Move Up button clicked

Using the code from PG #28 in a local file with the latest preview version of babylon.max.js the error is reported as on line 5733

Changing to an earlier version 4 of babylon.js ( 3 Dec 2018) there are no problems.

As you can see from this version of the PG https://playground.babylonjs.com/index.html#KI8BJH#30 lines 283 and 290 and this version https://playground.babylonjs.com/index.html#KI8BJH#31 lines 22,23 there is not a problem setting visibility directly outside the animation call.

This is all expected with instanced meshes.

You should either play the animation on the source mesh or not create it as an instance.

The main point so not have the setter affecting the source is to prevent the confusion of why they all changed.

1 Like