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
[.CommandBufferContext] RENDER警告:没有纹理绑定到单元1 test.html:1 [.CommandBufferContext] RENDER警告:没有纹理绑定到单元0 test.html:1 [.CommandBufferContext] RENDER警告:那里没有纹理绑定到单元1
I'm using three.js
我正在使用three.js
1 个解决方案
#1
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
我不确定这是否会有所帮助,但我有一个类似的problam并使用promises来修复它。问题是它是异步加载,当我的代码准备好运行时,我的纹理没有加载但是还有一个警告。所以尝试将纹理包装在一个承诺中。我希望这有帮助
#1
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
我不确定这是否会有所帮助,但我有一个类似的problam并使用promises来修复它。问题是它是异步加载,当我的代码准备好运行时,我的纹理没有加载但是还有一个警告。所以尝试将纹理包装在一个承诺中。我希望这有帮助