An Issue with MixMaterial and TerrainMaterial functionality

I’m trying to create a story/game that involves a textured terrain, so to avoid jagged faces between different textures, I turned to the creation of a MixMaterial. See a PG here. It works just fine :slight_smile:

However, when I try to run it locally with BJS 4.1 using the same script as the PG, I get this error at :

TypeError: BABYLON.MixMaterial is not a constructor

Anyone know why? Do I need to get an “addon” script for BJS 4.1 for this functionality?

I also tried TerrainMaterial and get the same error.

cheers, gryff :slight_smile:

Are you including @babylonjs/materials?

Stackblitz seems to work, but I have all the dependencies installed.

@Devin_Wright : I’m not a typescript user Devin. I just model then add javascripts to my projects using babylon4.1.js in the script list on my index.html page.

That is why I asked if there was an “addon” script of some kind.

cheers, gryff :slight_smile:

Ahh I see. Where exactly are you getting babylon4.1.js? Are you by chance grabbing it from here?

I think you also will need to include <script src=""></script> in your html maybe.


@Devin_Wright : Ok, I seem to have it working now. So TY for your ideas and pointers. Only issue seems to be a little more laggy initially - but then I have no idea of the complexities of what is going on.

Now to test with a more complex terrain.

So TY again - a big help :slight_smile:

cheers, gryff :slight_smile:

I used version 4.2.0, I encountered the same problem as you, how did you solve it?

Are you sure you use the same version for all the scripts ? and are you able to repro in a playground ?

My problem is that I can display it on the playground. Then I take the code from the demo and apply it locally. The console prompts that babylon.mixmaterial is undefined

But do you have the scripts like this in your page:

<script src=""></script>
<script src=""></script>

My project uses Vue. I have imported the following. How can I import babylonjs.materials.min.js

you are not importing babylonjs-materials


Thank you. It does solve my problem, but I have a question. Where should I check these packages that need to be imported separately?

Is it not part of the doc for those materials ?