dbawel Posted October 24, 2014 Share Posted October 24, 2014 I am brand new to babylon.js, and am not able to render textures on simple objects. Most of the script below was taken directly from GitHub to see if it was a syntax mistake, and even when I launch this HTML file into Chrome, a simple sphere won't render - simply a blank canvas. I can assign all other material attributes except textures. If anyone can identify what the issue might be, I would really appreciate it. I've tried placing textures in different folders, and now at the root folder. Thank you. <html xmlns="http://www.w3.org/1999/xhtml"><head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8"/> <title>Babylon - Basic scene</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="babylon.js"></script> <script src="hand.js"></script> <script src="cannon.js"></script> <!-- optional physics engine --></head> <body> <canvas id="renderCanvas"></canvas> <script type="text/javascript"> var CreateBumpScene = function (engine) { var scene = new BABYLON.Scene(engine); var camera = new BABYLON.ArcRotateCamera("Camera", 0, 0, 10, BABYLON.Vector3.Zero(), scene); var light = new BABYLON.PointLight("Omni", new BABYLON.Vector3(20, 100, 2), scene); var sphere = BABYLON.Mesh.CreateSphere("Sphere", 16, 3, scene); var material = new BABYLON.StandardMaterial("kosh", scene); material.bumpTexture = new BABYLON.Texture("/refMap.jpg", scene); material.diffuseColor = new BABYLON.Color3(1, 0, 0); sphere.material = material; camera.setPosition(new BABYLON.Vector3(-5, 5, 0)); scene.registerBeforeRender(function() { sphere.rotation.y += 0.02; }); return scene;}; var scene = createScene(); engine.runRenderLoop(function () { scene.render(); }); window.addEventListener("resize", function () { engine.resize(); }); </script> </body></html> Quote Link to comment Share on other sites More sharing options...
GameMonetize Posted October 24, 2014 Share Posted October 24, 2014 You have to host your page in a web server else you won't be able to load your texture (Security restriction), In the meantime you can also use the playground: www.babylonjs.com/playground Quote Link to comment Share on other sites More sharing options...
dbawel Posted October 24, 2014 Author Share Posted October 24, 2014 Thank you. I thought there was away around this, but I guess not. I appreciate the quick response. 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.