The issue about use furMaterial

When I create a material using ‘new BABYLON.FurMaterial()’, the browser throws an error: ‘TypeError: n.FurMaterial is not a constructor’. Then, I loaded ‘https://cdn.babylonjs.com/materialsLibrary/babylon.furMaterial.js’ following the documentation, and also tried ‘import {FurMaterial} from ‘babylonjs-materials/babylon.furMaterial.js’’, and then creating a new material using ‘new BABYLON.FurMaterial()’ or ‘new FurMaterial()’, but I get different errors: ‘Cannot read properties of undefined (reading ‘ShaderStore’)’ and ‘Unable to compile effect’, and so on. Did I do something wrong or miss something? In the playground, I don’t have to worry about these issues; I can use it directly. However, in my local project, these problems occur."

Welcome aboard!

The babylon.furMaterial.js is UMD, so I don’t think you have to import things from it. As long as it is referenced in your page, it should work.

Would you have a link to your project so that we can have a better look of what’s going on?

My test project URL is “https://test.lorearth.com/”, please take a look.

You must also reference the main Babylon package:

image

You should add a reference to https://cdn.babylonjs.com/v6.20.2/babylon.js before the reference to the fur material.

I’m tried to do it, but it didn’t work. by the way, I imported babylonjs in js, why do I need to reference it in html?

I am not sure when you mean by “imported babylon in js” could you share a repro with the sources ?

Please make it as tiny as possible as we can not go through full apps.

3 Likes

I’m fixed it, just follow your way to add a reference to https://cdn.babylonjs.com/v6.20.2/babylon.js before the reference to the fur material. But I have a new problem that is use “material.diffuseTexture = new BABYLON.Texture(‘./src/1.jpg’, scene)” it didn’t work. the ground’s color is black.

This will be hard to tell without a repro to investigate. Could you repro this one in the playground?

Everything works fine in playground, it’s only when I build the project locally that I encounter the above problem

It’s probably that ./src/1.jpg is either not found or not served correctly. Try to look at the console of the browser in case there’s an error.

If it is a build/setup issue, a minimal git repro could help I guess.