Skip to content

Commit e11a369

Browse files
committed
Fix missing initialization of local matrix for light elements
1 parent 62a2a9d commit e11a369

File tree

2 files changed

+10
-10
lines changed

2 files changed

+10
-10
lines changed

src/renderer/renderer/adapter/light.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ XML3D.createClass(LightRenderAdapter, SceneElementAdapter, {
2727
parent: parentNode
2828
});
2929
this.updateVisibility();
30+
this.updateLocalMatrix();
3031
},
3132

3233
attributeChangedCallback: function (name, oldValue, newValue) {

src/renderer/renderer/scene/renderlight.js

Lines changed: 9 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -92,15 +92,13 @@ XML3D.extend(RenderLight.prototype, {
9292
this.scene.emit(EVENT_TYPE.LIGHT_STRUCTURE_CHANGED, this, removed);
9393
},
9494

95-
updateWorldMatrix: function () {
96-
if (this.parent) {
97-
this.parent.getWorldMatrix(tmp_worldMatrix);
98-
var page = this.page;
99-
var offset = this.offset;
100-
XML3D.math.mat4.multiplyOffset(page, offset + WORLD_MATRIX_OFFSET, page, offset + LOCAL_MATRIX_OFFSET, tmp_worldMatrix, 0);
101-
// We change position / direction of the light
102-
this.lightValueChanged();
103-
}
95+
updateWorldMatrix: function (sourceMat4) {
96+
var page = this.page;
97+
var offset = this.offset;
98+
XML3D.math.mat4.multiplyOffset(page, offset + WORLD_MATRIX_OFFSET, page, offset + LOCAL_MATRIX_OFFSET, sourceMat4, 0);
99+
// We change position / direction of the light
100+
this.lightValueChanged();
101+
this.transformDirty = false;
104102
},
105103

106104
visibilityChanged: function (newVal) {
@@ -109,7 +107,8 @@ XML3D.extend(RenderLight.prototype, {
109107
},
110108

111109
setTransformDirty: function () {
112-
this.updateWorldMatrix();
110+
this.parent.getWorldMatrix(tmp_worldMatrix);
111+
this.updateWorldMatrix(tmp_worldMatrix);
113112
},
114113

115114
remove: function () {

0 commit comments

Comments
 (0)