質問

I have a small issue with the three.js example fresnel shader.

'lights : true' - if this is 'true' then I get the following error:

Uncaught TypeError: Cannot set property 'value' of undefined 

I'm clueless. Thanks for any suggestions.

役に立ちましたか?

解決

When you set ShaderMaterial.lights = true, the renderer will populate the shader lights uniform parameters for you.

But you have to ensure that your shader has the necessary lights uniforms in the first place.

THREE.FresnelShader does not use lights as written; it relies on an environment map instead. Consequently, setting lights: true will have no effect.

But if you want to do it, and are willing to modify the shader, you have to replace

var shader = THREE.FresnelShader;
var uniforms = THREE.UniformsUtils.clone( shader.uniforms );

with

var shader = THREE.FresnelShader;

var uniforms = THREE.UniformsUtils.merge( [

    THREE.UniformsLib[ "lights" ],
    shader.uniforms

] );

three.js r.59

ライセンス: CC-BY-SA帰属
所属していません StackOverflow
scroll top