WizPip
WizPip

Reputation: 378

Three.js PointLight fails with over 2 lights

Take a look at this fiddle:

http://jsfiddle.net/PRz4G/

You can see four white points about a blue one. Each of those points is supposed to have a light in the same place, but three of them have failed to work.

Look at this array in the fiddle:

var lights = {
    0: [712699, 0, 0],
    1: [732699, 0, 0],
    2: [722699, 10000, 0],
    3: [722699, -10000, 0],
    //4:[722699, 0, 10000],
    //5:[722699, 0, -10000]
};

If you comment out 2 and 3 as well, you can see that two lights render successfully. Uncomment 2 and we're back down to one working light. Uncomment 3 and 4 and now we have a full shader initialisation error.

What did I do wrong?

Update: The problem was display driver specific and is now working for me

Upvotes: 1

Views: 618

Answers (2)

WestLangley
WestLangley

Reputation: 104783

EDIT: This answer refers to an older version of three.js, and is no longer relevant. The maxLights parameter has been removed.


First of all, you need to set the maxLights parameter:

renderer: new THREE.WebGLRenderer( { maxLights: 6 } );

It defaults to 4, otherwise. With this change, I see 6 lights.

Your demo, as written, works for me, also. (4 lamps cast light onto the sphere.)

You may be having a hardware issue, too, preventing more than 2 lights. It could be an inferior GPU.

The good news is your code works with this change. :-)

Upvotes: 1

Sayris
Sayris

Reputation: 1070

You can resolve this issue with Chrome, but you must edit the shortcut and add

C:\Program Files (x86)\Google\Chrome\Application\chrome.exe" --use-gl=desktop

With this you can cast any light as you want.

Upvotes: 0

Related Questions