Setting MeshStandardMaterials.lights to false yields errors

I’m trying to conditionally let lights affect materials (presence of lightMap), but setting lights = false on MeshStandardMaterial yields errors and the mesh disappears from the scene.

The following error is thrown at ~3 errors per second:

three.module.js:11061 Uncaught TypeError: Cannot read property 'toArray' of undefined
    at flatten (three.module.js:11061)
    at PureArrayUniform.setValueV3fArray [as setValue] (three.module.js:11400)
    at Function.push../node_modules/three/build/three.module.js.WebGLUniforms.upload (three.module.js:11628)
    at setProgram (three.module.js:16866)
    at WebGLRenderer.renderBufferDirect (three.module.js:16068)
    at renderObject (three.module.js:16535)
    at renderObjects (three.module.js:16516)
    at WebGLRenderer.render (three.module.js:16393)
    at Viewer.render (Viewer.js:80)
    at Viewer.js:70

I’m not sure if this is a Three.JS bug or a bug in my code but i wouldn’t know where to go from here.


The light property can only be changed for ShaderMaterial and RawShaderMaterial. For all other materials it is considered to be read-only.

I’ve tried to clarify the docs once but unfortunately the PR was not merged:

1 Like

Ah, that’s a shame.

Would you know of a way to get lightMaps working in MeshStandardMaterial?

Currently it doesn’t really work when there is light (AmbientLight) as light maps are additive if i understand correctly.

I don’t really have a good background in 3d modelling and materials sadly.

If you want to use an unlit material with a light map, use MeshBasicMaterial instead.

1 Like