I’ve got an error when I’m upgrading 4.0.3 stable version of babylonjs to 4.1.0-beta.27
This error is very strange and it seems a bug in beta version.
Here is the detail of the error that I’ve got.
TS2322: Type ‘import(“babylonjs/Maths/math”).Vector3’ is not assignable to type ‘import(“babylonjs/Maths/math.vector”).Vector3’.
I’ve checked where it is happening.
this.camera.position = new bjs.Vector3(0, 0, -250);
I think the error happens here.
I am not sure what is the best solution for solving this problem. I couldn’t find any discussion about such kind of problem here.
Here, this.meshBase is a variable of BABYLON.Mesh type
No overload matches this call.
Overload 1 of 2, ‘(gravity: Vector3, plugin?: IPhysicsEnginePlugin): boolean’, gave the following error.
Argument of type ‘import(“babylonjs/Maths/math.vector”).Vector3’ is not assignable to parameter of type ‘import(“babylonjs/Maths/math”).Vector3’.
The types of ‘toQuaternion().equals’ are incompatible between these types.
Type ‘(otherQuaternion: import(“babylonjs/types”).DeepImmutableObject<import(“babylonjs/Maths/math.vector”).Quaternion>) => boolean’ is not assignable to type ‘(otherQuaternion: import(“babylonjs/types”).DeepImmutableObject<import(“babylonjs/Maths/math”).Quaternion>) => boolean’.
Types of parameters ‘otherQuaternion’ and ‘otherQuaternion’ are incompatible.
Property ‘equalsWithEpsilon’ is missing in type ‘import(“babylonjs/types”).DeepImmutableObject<import(“babylonjs/Maths/math”).Quaternion>’ but required in type ‘import(“babylonjs/types”).DeepImmutableObject<import(“babylonjs/Maths/math.vector”).Quaternion>’.
Overload 2 of 2, ‘(gravity: Vector3, plugin?: IPhysicsEnginePlugin): boolean’, gave the following error.
Argument of type ‘CannonJSPlugin’ is not assignable to parameter of type ‘IPhysicsEnginePlugin’.
Types of property ‘setGravity’ are incompatible.
Type ‘(gravity: Vector3) => void’ is not assignable to type ‘{ (gravity: Vector3): void; (gravity: Vector3): void; }’.
Types of parameters ‘gravity’ and ‘gravity’ are incompatible.
Type ‘Vector3’ is missing the following properties from type ‘Vector3’: negateInPlace, negateToRef, crossts(2769)
babylon.module.d.ts(3558, 9): ‘equalsWithEpsilon’ is declared here.
With code:
this.bjsScene.enablePhysics(this.bjsScene.gravity, new bjs.CannonJSPlugin(true, undefined, CANNON));
Here this.bjsScene is a variable of BABYLON.Scene type.
Is there any document I can refer for migration?
Please help me to solve this problems as well.
Can you make sure you only import the newest babylon version and have removed all reference to the old one?
Also - what version of typescript are you using? might be an issue as well.
When I try referencing a mesh (or an abstractmesh) as an IPhysicsEnabledObject my compiler lets me do that without a problem, so there must be some incompatibilities in the project itself (which I hope are easy to find and fix)
my mistake was mixing BABYLON.Types with types imported directly. ie:
//this doesnt work
import { Vector3 } from 'babylonjs';
const light = new BABYLON.HemisphericLight("light", new Vector3(0, 10, -5), scene)
//this does work
import { HemisphericLight, Vector3 } from 'babylonjs';
const light = new HemisphericLight("light", new Vector3(0, 10, -5), scene)