xml3d / xml3d.js

The WebGL/JS implementation of XML3D
Other
75 stars 25 forks source link

Adding multiple lights at once during runtime results in LightManager error #118

Closed ghost closed 9 years ago

ghost commented 9 years ago

Dynamically adding multiple lights at once during runtime results in the following message:

Assertion failed Light values changed for a light that is not managed by this LightManager

followed by

TypeError: Start offset is negative

at Float32Array.set (native) at https://xml3d.cg.uni-saarland.de/xml3d/script/xml3d-4.9.js:14000:26 at Array.forEach (native) ...

See the following fiddle: https://jsfiddle.net/pz4wpbc9/4/ You won't see any output, there are no objects in the scene. Look at the console instead for the messages mentioned above. Apparently one of the lights added works while the rest produces the error. In a scene with objects you would see that only one of the added lights is actually working (the first?).

This happens in both Chrome and Firefox.

ghost commented 9 years ago

I just tested the same fiddle with IE11 and Safari. Both produce errors as well.

This is the output from IE:

TypeError: Die Eigenschaft "type" eines undefinierten oder Nullverweises kann nicht abgerufen werden.

at Anonymous function (https://xml3d.cg.uni-saarland.de/xml3d/script/xml3d-4.9.js:13998:13) at LightModel.prototype.fillLightParameters (https://xml3d.cg.uni-saarland.de/xml3d/script/xml3d-4.9.js:13996:9) ...

Whenever I add the exact same lights directly to the html (ie not adding them during runtime) it works in all browsers. Not sure if these errors are related, but since they occur only 2 lines apart I added this as a comment and not as a new issue.

csvurt commented 9 years ago

I can confirm this, looks like a bug in the way the "shader" attribute mutation is handled for light elements.

Thanks for the fiddle, we'll take a look at this and release a hotfix for 4.9 together with the fix for #113.

csvurt commented 9 years ago

v4.9.1 was just released and should fix this issue.