Three.js MeshPhongMaterial normalScale抛出错误

时间:2016-06-05 20:21:48

标签: javascript three.js

我有一个名为'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 );

1 个答案:

答案 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