We moved to a new js flavor (was es5, now es2021), and finally it is not correct to use new on anything other than a constructor. Remove the new, and everything will work as expected. Color.FromHexString returns a new color as a static method.
heyas, may I know what classes are affected ? It seems like my codes no longer work (breaks back-compat) and its not limited to Color class only. Is there a list anywhere for reference ?
let newColor;
if (typeof color === "number"){
newColor = new Color3(color, color, color);
} else if (typeof color === "string"){
switch(color){
case "red":
newColor = new Color3.Red();
break;
case "yellow":
newColor = new Color3.Yellow();
break;
}
}
if (obj.AI && obj.AI.userCanSelect === true){
obj.overlayColor = newColor;
obj.renderOverlay = state;
}
newColor = new Color3.Yellow(); is throwing errors but newColor = new Color3(color, color, color); isn’t. So, which is correct? ditto for the ton of diffuseColors etc in materials…
ah-ha )) BUT this work little strange! As sample next two line code from one my file :
scene.clearColor = Color3.White(); // good work
scene.ambientColor = Color3(0.95, 0.95, 0.95); // get error - TypeError: Class constructor _Color3 cannot be invoked without ‘new’