Unable to import CellMaterial

Hi, I am trying to use CellMaterial I keep getting problems :sweat_smile: I’m very new to Babylon.js and TypeScript as well, so I’m not sure what I’m doing wrong.

Using TypeScript, I tried var cell = new BABYLON.CellMaterial("cell", this._scene); but there is an error, “CellMaterial does not exist”. I imagine I need to import some .ts definition, which I see from Babylon.js Playground, but I’m not sure where to get this .ts file from.

I also tried using plain JavaScript, and I tried importing Babylon.js/babylon.cellMaterial.js at master · BabylonJS/Babylon.js · GitHub, but then there is another error that says “TypeError: Cannot read property ‘RegisteredTypes’ of undefined at Module…/cell/cellMaterial.ts”.

I think the problem is more of my conceptual understanding rather than this specific implementation? If anyone can point me in the right direction I’ll really appreciate it! I’m also wondering if there’s anything else I’m missing in my learning journey – I went through Babylon 101 briefly (without running any code on my own), but I still feel a bit lost about Babylon (e.g. this, and how to manage game states?) Are there any other ‘guided’ walkthroughs, or is it just the docs and tutorials page for the specific topics?

No worries!
You need to first import babylon.js and then cellmaterial.js

    <script src="https://preview.babylonjs.com/babylon.js"></script>
    <script src="https://preview.babylonjs.com/materialsLibrary/babylonjs.materials.min.js"></script>

That works! Thank you very much!

1 Like