leorus Posted April 25, 2014 Share Posted April 25, 2014 I have recently started to make a simple game with babylon.js. I have created a scene and a sphere(ball). When I tried to apply texture to the sphere with the following code:var ballTex = new BABYLON.StandardMaterial("texture1", scene);ballTex.diffuseTexture = new BABYLON.Texture("ball2.png", scene);ball.material = ballTex; But the sphere is not visible.I tried full path and then also same thing happened.But when I applied color withballTex.diffuseColor = new BABYLON.Color3(1.0, 0, 0);ball.material = ballTex;the sphere is viosibel. What and where is the problem? leorus Quote Link to comment Share on other sites More sharing options...
jahow Posted April 25, 2014 Share Posted April 25, 2014 Hi, I encountered the same problem and it was in my case a problem of file path. When the texture is not found the mesh is drawn with the diffuse color. Do you have an error in the console that would help narrow down the problem ? Also where is the texture file located relative to the html page running BabylonJS ? Also, it's hard to suggest anything without a bit of context. Do you have other textured meshes that display correctly? Quote Link to comment Share on other sites More sharing options...
GameMonetize Posted April 25, 2014 Share Posted April 25, 2014 this is a problem with your texture. could you try to use f12 tools to see what the network monitor is telling about this file? Quote Link to comment Share on other sites More sharing options...
leorus Posted April 25, 2014 Author Share Posted April 25, 2014 the ball2.png file is in the same dir as the html file. I have also placed the same file in its parent dir also. There is no error message in the console. The html file is in babylon\breakout\bout\index.html. the png file is in both babylon\breakout and babylo9n\breakout\bout dirs. I tries to apply texture to other object also. but, same thing happens - that object alos vanishes from the scene. leorus Quote Link to comment Share on other sites More sharing options...
Xanmia Posted April 25, 2014 Share Posted April 25, 2014 What happens if you use emissiveTexture instead of diffuseTexture? Quote Link to comment Share on other sites More sharing options...
GameMonetize Posted April 25, 2014 Share Posted April 25, 2014 Could you share it on a web server so I can take a look? Quote Link to comment Share on other sites More sharing options...
leorus Posted April 26, 2014 Author Share Posted April 26, 2014 I have tried diffuse, specular and emmisive , but the same thing happens.web links:|www.namchennai.com/babylone/Breakout/BOut/index.html ( with diffuse color) andwww.namchennai.com/babylone/Breakout/BOut/index1.html ( with diffuse Texture).The code is attached:applyTextures();function applyTextures() { var ballTex = new BABYLON.StandardMaterial("texture1", scene); ballTex.diffuseTexture = new BABYLON.Texture("ball2.png", scene); //ballTex.diffuseColor = new BABYLON.Color3(1.0, 0, 0); ball.material = ballTex; var wallTex = new BABYLON.StandardMaterial("texture1", scene); wallTex.diffuseColor = new BABYLON.Color3(0, 0, 1.0); wallTex.alpha = 0.5; //wallTex.diffuseTexture = new BABYLON.Texture("Wall.jpg", scene); Lwall.material = wallTex; Rwall.material = wallTex; ceiling.material = wallTex; ground.material = wallTex; } Quote Link to comment Share on other sites More sharing options...
gwenael Posted April 26, 2014 Share Posted April 26, 2014 You seem to have edited your post. I had the following line in the notification email that I got for your post: ballTex.emissiveTexture = new BABYLON.Texture("C:\users\admin\Documents\babylone\BreakOut\BOut\ball2.png", scene); Your issue could be relative to:http://www.html5gamedevs.com/topic/5255-using-non-minified-babylonjs-version/?p=32599 And since you are on Windows, this tool could help you: https://github.com/BabylonJS/Babylon.js/tree/master/Tools/BuildOurOwnBabylonJS 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.