React import 'createStandardMaterial' is not defined

newb here thanks for any info

Attempting react / babylon.js integration
Cannot figure how to import createStandardMaterial
error
‘createStandardMaterial’ is not defined

code ----

import React from “react”;
import { ArcRotateCamera, Vector3, HemisphericLight, MeshBuilder, StandardMaterial, Color3 } from “@babylonjs/core”;
import SceneComponent from “./SceneComponent”;

const onSceneReady = (scene) => {
const camera = new ArcRotateCamera(“Camera”, 0, 0, 10, new Vector3(0, 0, 0), scene);
camera.setPosition(new Vector3(0, 0, 20));
const canvas = scene.getEngine().getRenderingCanvas();
camera.attachControl(canvas, true);
const light = new HemisphericLight(“light”, new Vector3(0, 1, 0), scene);
light.intensity = 0.7;
var sphere = MeshBuilder.CreateSphere(“sphere”, {diameter: 1, segments: 32}, scene);
sphere.material = createStandardMaterial(“sphereMaterial”, {diffuseColor: Color3.Red()}, scene);
sphere.position.x = 0;
sphere.position.y = 1;
sphere.position.z = 2;
};

const onRender = (scene) => {
// nothing happening
};

Try using…
sphere.material = new StandardMaterial("sphereMaterial", scene); sphere.material.diffuseColor = Color3.Red();
:slight_smile:

1 Like

Thanks!