This package has been deprecated

Author message:

Package no longer supported. Contact Support at https://www.npmjs.com/support for more info.

babylon-node-material-loader
TypeScript icon, indicating that this package has built-in type declarations

1.0.1 • Public • Published

Babylon Node-Material Loader

Webpack loader for node material files created with the node-material-editor.

npm install --save-dev babylon-node-material-loader

Usage

Just create a new material for your current scene. Then load all the material properties by calling the exported function on you material.

import applyMaterial from './test.bnm';

const testMaterial = new NodeMaterial('test', myScene);
applyMaterial(testMaterial);

This is especially nice for react-babylonjs where you can just load the material in a ref like this:

import applyMaterial from './test.bnm';

export default function Test() {
  return (
    <plane name="plane">
      <nodeMaterial name="test" ref={applyMaterial} />
    </plane>
  );
}

Webpack Config

I found it easiest to give the material json files a custom file type. I chose bnm for babylon-node-material, but it can be anything you want.

In your webpack.config.js add this:

module.exports = {
  module: {
    rules: [
      {
        test: /\.bnm$/i,
        use: ['babylon-node-material-loader'],
      },
    ],
  },
};

Typescript Config

If you are using typescript this declaration tells the compiler what the loaded result looks like:

declare module "*.bnm" {
  import { NodeMaterial } from "@babylonjs/core";

  const apply: (material: NodeMaterial) => void;

  export default apply;
}

Readme

Keywords

none

Package Sidebar

Install

npm i babylon-node-material-loader

Weekly Downloads

1

Version

1.0.1

License

MIT

Unpacked Size

58.2 MB

Total Files

12

Last publish

Collaborators

  • flostellbrink