To take advantage of tree shaking I started to import every class I use seperatly.
import { Scene, Engine, ArcRotateCamera, HemisphericLight, StandardMaterial,Material, Vector3, Color3, Color4, Mesh, AbstractMesh, PointerEventTypes, DynamicTexture } from 'babylonjs';
before I imported it like
import * as BABYLON from 'babylonjs';
After changing this line I removed every “BABYLON” before any babylon class.
The code still works, but my IDE is complaining following things:
Severity Code Description Project File Line Suppression State
Error TS2322 (TS) Type 'StandardMaterial' is not assignable to type 'Material'.
Types of property 'customShaderNameResolve' are incompatible.
Type '(shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: string[] | import("babylonjs/Materials/materialDefines").MaterialDefines, attributes?: string[], options?: import("babylonjs/Materials/material").ICustomShaderNameResolveOptions) => string' is not assignable to type '(shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: string[] | BABYLON.MaterialDefines, attributes?: string[], options?: BABYLON.ICustomShaderNameResolveOptions) => string'.
Types of parameters 'defines' and 'defines' are incompatible.
Type 'string[] | BABYLON.MaterialDefines' is not assignable to type 'string[] | import("babylonjs/Materials/materialDefines").MaterialDefines'.
Type 'MaterialDefines' is not assignable to type 'string[] | MaterialDefines'.
Type 'MaterialDefines' is missing the following properties from type 'string[]': length, pop, push, concat, and 25 more.
In this particular example I try to assign the material of a mesh to a pre defined material.
mesh.material = myMaterial:
myMaterial is type of StandardMaterial
mesh.material is of type Material
myMaterial is of type StandardMaterial.
The code works in the browser without problems, but my IDE (Visual Studio 2019) im complaining.