0

I've been trying to add texture

  var bumptexture = THREE.ImageUtils.loadTexture('grid.jpg');
  var normaltexture = THREE.ImageUtils.loadTexture("normal.jpg");
  var diffusetexture = THREE.ImageUtils.loadTexture("diffuse.jpg");

  var material2 = new THREE.MeshPhongMaterial({
color: 0xaaaaaa,
ambient: 0xaaaaaa,
specular: 0x333333,
map: diffusetexture,
bumpMap: bumptexture,
bumpMapScale: 1,
normalMap:normaltexture,
normalScale: (1,1),
shininess: 10

But I keep on receiving this error.

[.CommandBufferContext]RENDER WARNING: there is no texture bound to the unit 1 test.html:1 [.CommandBufferContext]RENDER WARNING: there is no texture bound to the unit 0 test.html:1 [.CommandBufferContext]RENDER WARNING: there is no texture bound to the unit 1

I'm using three.js

piyushj
  • 1,546
  • 5
  • 21
  • 29
A12J
  • 1
  • 1
  • 1
    i don't get this error.can you show a live example on jsfiddle? and which three.js version are you using ? – Madhawa Priyashantha May 31 '16 at 09:30
  • a fiddle will be tough since the code is loading textures asynchronously. This may in fact be the issue. Be sure the textures are loaded assets before attempting to use them. No onLoad function is specified in any texture load in the code supplied in the question. See this particular answer: http://stackoverflow.com/a/36115889/3311552 – Radio May 31 '16 at 15:05

1 Answers1

0

i'm not sure if this will help but i had a similar problam and used promises to fixed it. The problem was that it was loading asynchronously and by the time my code was ready to run my texture hadnt loaded yet an was thowing a warning.So try wrapping your texture in a promise. I hope this helps