Error setting skyMaterial as skybox' material

Hi,

I’m trying to set the material of a skybox to a SkyMaterial.
I’m importing the latest babylon.js and materials libraries in my HTML.

My code:

const skyboxMaterial = new BABYLON.SkyMaterial(‘skyMaterial’, scene);
skyboxMaterial.backFaceCulling = false;
const skybox = BABYLON.MeshBuilder.CreateSphere(‘skyBox’, { diameter: 1000, sideOrientation: 2 }, scene);
skybox.material = skyboxMaterial;

This works in the playground and also in the TypeScript project I took it from.
The error I get is as follows:

Uncaught TypeError: babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__.Quaternion.FromUnitVectorsToRef is not a function at SkyMaterial…/sky/skyMaterial.ts.SkyMaterial.bindForSubMesh (babylonjs.materials.js:5671)

Not sure why this happens. I made sure to get all the latest babylon files and import them. Anyone know what I’m doing wrong?

Hey do you mind reproducing it in the PG?

Not at all:

https://playground.babylonjs.com/#FUN65H

This runs fine in the playground though…
The line that causes the error for me is 65:
skybox.material = skyboxMaterial;

ok so makes sure you are on the latest version

how do you reference babylonjs in your project?

Hmm ok so I updated from 4.20 to the latest preview version and it works now…? Well cool I guess :slight_smile:

I was referencing the js files locally (downloaded them to lib folder). Initially used the ones linked on the site here, but now switched to the preview files on github (overwritten the local files, paths are the same).

1 Like