BitwiseCreative Posted November 27, 2015 Share Posted November 27, 2015 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:7BABYLON @ babylon.normalMaterial.js:60(anonymous function) @ babylon.normalMaterial.js:455Thanks in advance Quote Link to comment Share on other sites More sharing options...
Dad72 Posted November 27, 2015 Share Posted November 27, 2015 I do not know of BABYLON.NormalMaterial("normal", scene), But BABYLON.StandardMaterial("name", scene); This works. But maybe I did not understand what you are trying to do. var material = new BABYLON.StandardMaterial("texture1", scene); material.diffuseColor = new BABYLON.Color3(1.0, 0.2, 0.7); material.diffuseTexture = new BABYLON.Texture("texture.png", scene); material.bumpTexture = new BABYLON.Texture("normalMap.jpg", scene); sphere.material = material; Quote Link to comment Share on other sites More sharing options...
BitwiseCreative Posted November 28, 2015 Author Share Posted November 28, 2015 I do not know of BABYLON.NormalMaterial("normal", scene), But BABYLON.StandardMaterial("name", scene); This works. But maybe I did not understand what you are trying to do.var material = new BABYLON.StandardMaterial("texture1", scene);material.diffuseColor = new BABYLON.Color3(1.0, 0.2, 0.7);material.diffuseTexture = new BABYLON.Texture("texture.png", scene);material.bumpTexture = new BABYLON.Texture("normalMap.jpg", scene);sphere.material = material; I'm trying to load the Normal extension material (located in materialLibrary, e.g., http://doc.babylonjs.com/extensions/Normal). There seems to be an error with the plugin/extension management? The related code is confusing to me, and it doesn't seem to work out of the box, so instead of figuring it out and hacking it to work, I'm posting my issue here to get more eyes on my issue so someone can tell me what I'm doing wrong, and/or to inform the development team in case something got overlooked with the materialLibrary inclusion. Quote Link to comment Share on other sites More sharing options...
GameMonetize Posted November 28, 2015 Share Posted November 28, 2015 doc: http://doc.babylonjs.com/extensions/Normal oh, and by the way this is a babylon.js 2.3 feature Quote Link to comment Share on other sites More sharing options...
BitwiseCreative Posted November 28, 2015 Author Share Posted November 28, 2015 doc: http://doc.babylonjs.com/extensions/Normal oh, and by the way this is a babylon.js 2.3 feature Not sure why you linked me to the doc page considering I posted a link to it in my previous post, and am using the proper code in my original post code example (aren't I?). Am I doing something wrong? Also, are you saying that the NormalMaterial extension that was included in the 2.2 release won't work with 2.2? Sorry, just a bit confused about your response... Quote Link to comment Share on other sites More sharing options...
GameMonetize Posted November 28, 2015 Share Posted November 28, 2015 Nope NormalMaterial (as all materials from material library) was introduced with bjs 2.3. (besides the reference to 2.2 your code seems perfectly correct) Quote Link to comment Share on other sites More sharing options...
BitwiseCreative Posted November 28, 2015 Author Share Posted November 28, 2015 Nope NormalMaterial (as all materials from material library) was introduced with bjs 2.3. (besides the reference to 2.2 your code seems perfectly correct) Gotcha. Thank you for the info and for the time, I appreciate it. Is 2.3 available now? If so, I can't seem to find it. Quote Link to comment Share on other sites More sharing options...
Temechon Posted November 28, 2015 Share Posted November 28, 2015 You can find it here: https://github.com/BabylonJS/Babylon.js/tree/master/dist/preview%20release (babylon.js or babylon.max.js) Quote Link to comment Share on other sites More sharing options...
BitwiseCreative Posted November 28, 2015 Author Share Posted November 28, 2015 You can find it here: https://github.com/BabylonJS/Babylon.js/tree/master/dist/preview%20release (babylon.js or babylon.max.js) Ahh, thank you! NormalMaterial is working now [sOLVED]Thanks everyone for your help. For others: The solution was simply that the materialLibrary extensions weren't compatible with 2.2, but 2.3 was available in the dist/preview release folder. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.