echan00
February 18, 2022, 4:13pm
#1
Many GUI examples are using the Rectangle class and adding an animation to them, e.g https://www.babylonjs-playground.com/#XCPP9Y#8180
I’m wondering how come I’m getting the error Property 'animations' does not exist on type 'Rectangle'
Is it possible because I’m importing the library this way? (I was previously getting the problem with BABYLON.GUI
not being found)
import { AssetsManager, Color3, CubeTexture, ... } from "babylonjs";
import { AdvancedDynamicTexture, Rectangle } from 'babylonjs-gui';
jelster
February 18, 2022, 7:11pm
#2
You’re not crazy, the property doesn’t exist on the Rectangle… not without a small intervention on your part.
Add a new array to the rectangle named animations and then see if the example works in your code:
myRectangle.animations = [];
1 Like
echan00
February 18, 2022, 7:16pm
#3
Hmmm, that’s exactly what I have. I copied the code directly from the example:
rect1.animations = [];
EDIT: elsewhere I’m also getting similar errors using GUI classes, e.g
TS2339: Property 'parseFromSnippetAsync' does not exist on type 'AdvancedDynamicTexture'.
TS2339: Property 'text' does not exist on type 'Control'.
echan00
February 18, 2022, 7:41pm
#4
resolve with
rect1['animations'] = [];
1 Like
roland
February 19, 2022, 1:12pm
#5
IMHO @jelster has provided the solution. If you are on TypeScript in your project that changes the situation a bit. So you have to:
1 Like
roland
February 19, 2022, 1:18pm
#6
Are you on BJ 4.2.1?
Because
is available in BJS5+ only.
1 Like
echan00
February 19, 2022, 2:04pm
#7
@roland many thanks for the confirmation
1 Like
roland
February 19, 2022, 2:09pm
#8
@echan00 Thank you for marking my response as a solution however I still believe @jelster deserves the solution tag Let’s be fair with him! If he decides otherwise you can change it to the more elaborated version provided by me. Thank you!
1 Like
sebavan
February 21, 2022, 8:54pm
#9
I added the tag to @jelster for the moment
1 Like