BABYLON.GridMaterial() is not a constructor

I’m unable to run this command, because there isnt any GidMaterial() on my app, i got nothing working trying to add this gridmaterial to ground.

Could someone help me? I’m trying to use svelte + babylonjs

import * as BABYLON from ‘babylonjs’;

export const createScene = (canvas) => {
const engine = new BABYLON.Engine(canvas, true);
const scene = new BABYLON.Scene(engine);
scene.clearColor = new BABYLON.Color4(0.8, 0.8, 0.8, 1);

const camera = new BABYLON.ArcRotateCamera(“Camera”, Math.PI / 2, Math.PI / 2, 2, new BABYLON.Vector3(0, 20, -20), scene);
camera.setTarget(new BABYLON.Vector3(0,20,0));
camera.attachControl(canvas, true);

const light = new BABYLON.HemisphericLight(“light”, new BABYLON.Vector3(0, 10, 0), scene);
light.intensity = 0.7;

const material = new BABYLON.StandardMaterial(“material”, scene);
material.emissiveColor = new BABYLON.Color3(0.3, 0.3, 0.3);

// var gridMaterial = new BABYLON.GridMaterial(“default”, scene);
var ground = BABYLON.Mesh.CreateGround(“ground”, 10000, 10000, 1, scene, false);
// ground.material = gridMaterial;

engine.runRenderLoop(() => {
scene.render();
});

window.addEventListener(‘resize’, () => {
engine.resize();
});

return scene;
}

If i uncomment those 2 lines, the app stop working.

Hi. grid material is separate module Grid Material | Babylon.js Documentation
Or you can use node material grid https://playground.babylonjs.com/#VTSHNV#1

1 Like

Thanks!!!