简体   繁体   中英

Three.js MeshPhongMaterial normalScale throwing error

I've got a MeshPhongMaterial named 'material' like so:

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')
    });

Everything works and is applied, including the map and normalMap. The problem is, when I try to add a normalScale property, it throws the following error:

Uncaught TypeError: Failed to execute 'uniform2fv' on 'WebGLRenderingContext': No function was found that matched the signature provided.

I've used normalScale before and with the right syntax, and it's been working until recently. Without normalScale everything is fine. I am using revision 77. My question is why is this happening and what causes this error? How can I use normalScale without three.js throwing the error? I've used Chrome DevTools to get the line where the error is thrown in three.js source:

if ( v.x === undefined ) gl.uniform2fv( this.addr, v );

You are not setting normalScale properly:

var material = new THREE.MeshPhongMaterial( {

    normalMap: THREE.ImageUtils.loadTexture('assets/images/8k-earth-normal.jpg'),

    normalScale: new THREE.Vector3( 0.1, 0.1 );

) };

Alternatively, after the material is instantiated:

material.normalScale.set( 0.1, 0.1 );

three.js r.77

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM