Hi,
I would like to create a water material in my project. For that, I just use the below code
import * as BABYLONMATERIAL from 'babylonjs-materials';
var water = new BABYLONMATERIAL.WaterMaterial("water", scene, new BABYLON.Vector2(512, 512));
water.backFaceCulling = true;
water.bumpTexture = new BABYLON.Texture("assets/textures/waterbump.png", scene);
water.windForce = -10;
water.waveHeight = 1.5;
water.bumpHeight = 0.5;
water.windDirection = new BABYLON.Vector2(1, 1);
water.waterColor = new BABYLON.Color3(0, 0, 221 / 255);
water.colorBlendFactor = 0.0;
scene_objects.forEach((obj)=>{
water.addToRenderList(obj);
})
mesh.material = water;
In this, I got an error like below.
cell.fragment.ts:126 Uncaught TypeError: Cannot read properties of undefined (reading 'ShaderStore')
at cell.fragment.ts:126:1
at babylonjs.materials.min.js:1:195684
at babylonjs.materials.min.js:1:195698
at universalModuleDefinition:9:23
at universalModuleDefinition:1:1
http://localhost:4200/src/Shaders/water.vertex.fx 404 (Not Found)
I am familiar with this version. Last time I tried to update the version in a project. at that time material.freeze() was not working. and some other things also got changed. Thats why I just would like to go with this Awesome version 4.2.1
I find it odd it doesn’t work in 4.2.1 to be honest. and I find it odd that material.freeze doesn’t work in 5.X.
Are you sure both versions of core and materials are 4.2.1? could you reproduce the lack of material freeze in the 5.X branch? maybe in the playground?
we won’t fix bug for the older 4.X branch.
Checking the playground with those 2 versions it does seem to work in both 4.2.1 and the latest 5.21.0. material.freeze() seems to run without an issue as well.
Not sure what’s wrong with the project. Can you try using @babylonjs/core and @babylonjs/materials instead of the UMD version? will you be able to share your project and show when it fails?
Uncaught TypeError: Cannot read properties of undefined (reading 'ShaderStore')
at cell.fragment.ts:126:1
at babylonjs.materials.min.js:1:195684
at babylonjs.materials.min.js:1:195698
at universalModuleDefinition:9:23
at universalModuleDefinition:1:1
you can import the water material directly. However, seeing your code - if you load from babylonjs.materials.min.js you are loading from the UMD version and not @babylonjs/materials
Sorry @RaananW . I couldn’t understand this. I am not importing like import * as BABYLONMATERIAL from 'babylonjs-materials' . I am importing like import * as BABYLONMATERIAL from '@babylonjs/materials'. You said, ‘babylonjs-materials’ is the UMD and ‘@babylonjs/materials’ is not. But now you are saying, that too UMD. I am confused now.
Have you tried “rm -rf nodeModules”, “rm -rf package-lock.json” and "retry npm install "?
And did save pakege.json “@babylonjs/core”: “^5.20.0” too?
(delete → “babylonjs-materials”: “^ 4.2.1”, “babylonjs-materials”: “^ 4.2.1”,)
Yes, I deleted the nodeModules folder and package-lock.json then, I removed the babylonjs , babylonjs-materials, babylonjs-loaders Then I executed the npm install. And my current Package.json is