我有一个名为'material'的MeshPhongMaterial,如下所示:
var material = new THREE.MeshPhongMaterial({
map: THREE.ImageUtils.loadTexture('assets/images/8k-earth-diffuse.jpg'),
normalMap: THREE.ImageUtils.loadTexture('assets/images/8k-earth-normal.jpg'),
normalScale: (0.1, 0.1),
specularMap: THREE.ImageUtils.loadTexture('assets/images/8k-earth-spec.png'),
specular: new THREE.Color('grey')
});
一切正常并应用,包括地图和normalMap。问题是,当我尝试添加normalScale
属性时,会抛出以下错误:
Uncaught TypeError: Failed to execute 'uniform2fv' on 'WebGLRenderingContext': No function was found that matched the signature provided.
我之前使用normalScale
并使用了正确的语法,直到最近才开始工作。没有normalScale
一切都很好。我正在使用修订版77.我的问题是为什么会发生这种情况以及导致此错误的原因?如果没有three.js抛出错误,我如何使用normalScale
?我已经使用Chrome DevTools来获取在three.js源中引发错误的行:
if ( v.x === undefined ) gl.uniform2fv( this.addr, v );
答案 0 :(得分:2)
您没有正确设置normalScale
:
var material = new THREE.MeshPhongMaterial( {
normalMap: THREE.ImageUtils.loadTexture('assets/images/8k-earth-normal.jpg'),
normalScale: new THREE.Vector3( 0.1, 0.1 );
) };
或者,在实例化材料之后:
material.normalScale.set( 0.1, 0.1 );
three.js r.77