README Instructions Not Functional
See original GitHub issueBugs
- 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:
- Created 4 years ago
- Comments:11 (6 by maintainers)
Top 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 >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
For anyone else who comes across this problem, the official documentation is incorrect and does not work. The solution is to do:
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.
@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:
In ES6: