Hello,
Just started with Babylon.js this morning (I downloaded the files today). I want to use the normalMaterial from the materialsLibrary but I can't seem to get it to work.
Here's my code:
<!doctype html> <html> <head> <meta charset="utf-8"> <title>Babylon Learning</title> <style> html, body { overflow: hidden; width: 100%; height: 100%; margin: 0; padding: 0; } #renderCanvas { width: 100%; height: 100%; touch-action: none; } </style> <script src="../lib/hand/bin/hand.js"></script> <script src="../lib/oimo/build/oimo.js"></script> <script src="../lib/babylon/dist/babylon.2.2.max.js"></script> <script src="../lib/babylon/materialsLibrary/dist/babylon.normalMaterial.js"></script> </head> <body> <canvas id="renderCanvas"></canvas> <script type="text/javascript"> var canvas = document.querySelector("#renderCanvas"); var engine = new BABYLON.Engine(canvas, true); var scene, camera; var lights = {}; var materials = {}; var ground, sphere; var createScene = function () { // Scene scene = new BABYLON.Scene(engine); scene.clearColor = new BABYLON.Color3(.1, .1, .1); // Camera camera = new BABYLON.FreeCamera("camera1", new BABYLON.Vector3(0, 5, -10), scene); camera.setTarget(BABYLON.Vector3.Zero()); camera.attachControl(canvas, false); // Lights lights.hemi = new BABYLON.HemisphericLight("hemi", new BABYLON.Vector3(0, 1, 0), scene); lights.hemi.intensity = .5; // Materials materials.normal = new BABYLON.NormalMaterial("normal", scene); // Init Objects sphere = BABYLON.Mesh.CreateSphere("sphere1", 16, 2, scene); sphere.material = materials.normal; sphere.position.y = 1; ground = BABYLON.Mesh.CreateGround("ground1", 6, 6, 2, scene); ground.material = materials.normal; // return scene; }; var scene = createScene(); engine.runRenderLoop(function () { scene.render(); }); window.addEventListener("resize", function () { engine.resize(); }); </script> </body> </html>
And the console error:
Uncaught TypeError: Cannot read property 'prototype' of undefined __extends @ babylon.2.2.max.js:4 (anonymous function) @ babylon.normalMaterial.js:7 BABYLON @ babylon.normalMaterial.js:60 (anonymous function) @ babylon.normalMaterial.js:455
Thanks in advance