question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

README Instructions Not Functional

See original GitHub issue

Bugs

  • Expected result:

Following the README should add access to various materials as explained at: https://doc.babylonjs.com/extensions/grid#using-the-grid-material and demoed at: https://www.babylonjs-playground.com/#1UFGZH#12

  • Current result:

Following the README does not work. BABYLON gives property errors. e.g.

Property 'GridMaterial' does not exist on type 'typeof import("babylonjs")'.ts(2339)

from

const groundMaterial = new BABYLON.GridMaterial("groundMaterial", this._scene);

This is occurring on a simple barebones app created with npx create-react-app my-app --typescript.

package.json

  "dependencies": {
    "@types/jest": "24.0.18",
    "@types/node": "12.7.4",
    "@types/react": "16.9.2",
    "@types/react-dom": "16.9.0",
    "babylonjs": "^4.0.3",
    "babylonjs-loaders": "^4.0.3",
    "babylonjs-materials": "^4.0.3",
    "react": "^16.9.0",
    "react-dom": "^16.9.0",
    "react-scripts": "3.1.1",
    "typescript": "3.6.2"
  },

tsconfig.json

{
  "compilerOptions": {
    "target": "es5",
    "lib": [
      "dom",
      "dom.iterable",
      "esnext"
    ],
    "allowJs": true,
    "skipLibCheck": true,
    "esModuleInterop": true,
    "allowSyntheticDefaultImports": true,
    "strict": true,
    "forceConsistentCasingInFileNames": true,
    "module": "esnext",
    "moduleResolution": "node",
    "resolveJsonModule": true,
    "isolatedModules": true,
    "noEmit": true,
    "jsx": "react"
  },
  "include": [
    "src"
  ],
  "types": [
    "babylonjs",
    "babylonjs-materials",
  ]
}

Canvas.tsx contains the following at the top.

import * as BABYLON from "babylonjs";
import "babylonjs-materials";
...


Issue Analytics

  • State:closed
  • Created 4 years ago
  • Comments:11 (6 by maintainers)

github_iconTop GitHub Comments

4reactions
gpreslandcommented, Sep 4, 2019

For anyone else who comes across this problem, the official documentation is incorrect and does not work. The solution is to do:

import * as BABYLON from "babylonjs";
import * as MATERIALS from "babylonjs-materials";

and use MATERIALS when you want access to the Babylon materials.

That said, there are various other bugs I’ve run in to where the current documentation and examples do not reflect the actual source code, resulting in TypeScript error where you cannot compile. My solution unfortunately has to be to stick with Three.js until these issues in Babylon and/or its documentation get resolved.

1reaction
sebavancommented, Jun 11, 2020

@jaqmol could you share the code you tried and first doc page you looked at ?

I will add the relevant info to those docs.

Basically it should just work by default by importing from the materials-library from ts:

In ES5:

import { GridMaterial } from 'babylonjs-materials';

In ES6:

import { GridMaterial } from '@babylonjs/materials/grid/gridMaterial';
Read more comments on GitHub >

github_iconTop Results From Across the Web

How to Write a Good README File for Your GitHub Project
What is a README File? In simple words, we can describe a README file as a guide that gives users a detailed description...
Read more >
Writing a README
The best way to generate installation instructions is to clone your project and then walk through all the steps necessary to get the...
Read more >
Make a README
A README is a text file that introduces and explains a project. It contains information that is commonly required to understand what the...
Read more >
README.md template | Documenting your project - Drupal
Information about content and formatting of project README files.
Read more >
README File – Everything you Need to Know - Great Learning
The interviewer might go to your project but might not understand a single piece of code. But if there is a readme file,...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found