Thank you very much for your quick reply. Looks like you are answering all the problems
So, yeah, your solution works, but I don’t think it is a good one; and I am not willing to use it.
BabylonJS has an animation system, that allows to easily make tweens (see below). I think it will be beneficial to the engine if the GUI can be animated with the animation system.
Basically, I believe that we should be able to use the below on any properties of any target object in BabylonJS:
private static createAnimation (target : any, targetProperty:string, startValue:any, endValue:any,
duration:number, loopMode:number, easingFunction?:BABYLON.EasingFunction, easingMode:number=BABYLON.EasingFunction.EASINGMODE_EASEIN) : BABYLON.Animation {
if(startValue.constructor !== endValue.constructor){
throw new Error("Tween: start and end values should be of the same type! type of: " + startValue.constructor + ", " + endValue.constructor);
}
let animation_type = this.inferAnimationType(startValue);
if(animation_type === null)
throw new Error("Tween: the value type (endValue/startValue) is not supported!")
let totalFrame = this.frameRate*duration;
let animation = new BABYLON.Animation("Tween." + target.name + "." + targetProperty,
targetProperty, this.frameRate,
animation_type, loopMode);
let keyFrames = [];
keyFrames.push({
frame: 0,
value: startValue,
});
keyFrames.push({
frame: totalFrame,
value: endValue,
});
animation.setKeys(keyFrames);
if(easingFunction){
easingFunction.setEasingMode(easingMode);
animation.setEasingFunction(easingFunction);
}
return animation
}
I noticed that now, the GUI controller/container’s size (width, height) and position (top, let) have the type ValueAndUnit
. Would it be possible to make this ValueAndUnit
type compatible with the animation system? If not, could we add a Vector2 property position
which would overwrite top
and left
if used? A little bit as it is done with rotation and quaternion?
It seems to me that it would be a very good improvement for managing complex menu animation.