Import of Vector3 results in error

Hi I hope I don’t miss anything because I’m new to the framework.
I use webpack and imported Vector3 with default es6 syntax.
import { Vector3 } from '@babylonjs/core';

The following line results in an error:
const camera = new ArcRotateCamera('camera', -Math.PI / 2, Math.PI / 2.5, 3, new Vector3(0, 0, 0), scene);

main.js:2 Uncaught TypeError: Cannot set property ‘_isDirty’ of undefined

When I use BABYLON.Vector3 with * import the error disappears.

Hi @Heinz,

Welcome to the forum!

You seem to be doing everything correctly. You could try loading the vector directly from its location:

import { Vector3 } from "@babylonjs/core/Maths/math.vector";

But both should work. Care to share your project setup? would be great to see what went wrong.

That was quick. The alternative import didn’t fix it.
I have uploaded my Testproject to Github:


Two issues to solve and it works:

your webpack file contains this:

externals: {
    '@babylonjs/core': 'BABYLON'

which defines the package as external, making it not load. The reason BABYLON worked is the second issue: you are loading the UMD version of the babylon-loaders package. Move it to the es6 version of the loaders:

"dependencies": {
    "@babylonjs/core": "^4.2.0",
    "@babylonjs/loaders": "^4.2.0",
    "validator": "^13.5.1"

and it compiles and shows a nice hello world :slight_smile:

EDIT - wait, something went wrong. will be right with you on this one :slight_smile:

So - 2 more issues found :slight_smile:

You are loading babylon from the CDN in yout html file, which loads babylon twice.
And, in your hemispheric light, you don’t use new before the Vector3.

Thanks for your help.
The externals was actually intended to speed up development.

In my project I have now removed the loader. Now I have again the original problem that I can import Engine, Scene and so on but Vector3 doesn’t work.

I hope I don’t waste your time too much but would be nice if you could have a quick look again.

Check my edit, there were 2 more issues

I have already seen these. Maybe I’m general on the wrong path. My goal was to use ES6 Syntax but temporarily load the Babylon Library from CDN to speed up build times. This did work as far as I can tell for Objects like Scene and Engine, but failed for Vector3.
I’m currently not sure if the approach is general not possible or if I’m doing something wrong.

As said I don’t want to waste your time too much - so totally fine if you ignore it…


The reason the vector3 failed is the lack of “new” in your hemispheric light. It will compile much faster if you loaded the full path object, and of course you can use externals but then don’t include the package at all, as it is not needed. Maybe just for syntax correctness in your editor, but that’s a bit confusing :slight_smile:

Ah - :expressionless: - now I see - stupid me.
Thanks again for your help

1 Like