Skip to content

Commit bfaed52

Browse files
author
aardgoose
committed
handle multiple changes
1 parent 2666c84 commit bfaed52

File tree

1 file changed

+10
-21
lines changed

1 file changed

+10
-21
lines changed

src/renderers/common/ClippingContext.js

+10-21
Original file line numberDiff line numberDiff line change
@@ -14,9 +14,6 @@ class ClippingContext {
1414

1515
this.clipIntersection = null;
1616

17-
this.unionOffset = 0;
18-
this.intersectionOffset = 0;
19-
2017
this.intersectionPlanes = [];
2118
this.unionPlanes = [];
2219

@@ -59,6 +56,7 @@ class ClippingContext {
5956
update( parentContext, clippingGroup ) {
6057

6158
let update = false;
59+
let parentChanged = false;
6260

6361
if ( parentContext.version !== this.parentVersion ) {
6462

@@ -70,21 +68,21 @@ class ClippingContext {
7068
this.viewNormalMatrix = parentContext.viewNormalMatrix;
7169
this.shadowPass = parentContext.shadowPass;
7270

71+
parentChanged = true;
72+
7373
}
7474

75-
if ( this.clipIntersection !== clippingGroup.clipIntersection ) {
75+
if ( this.clipIntersection !== clippingGroup.clipIntersection || parentChanged ) {
7676

7777
this.clipIntersection = clippingGroup.clipIntersection;
7878

7979
if ( this.clipIntersection ) {
8080

81-
this.unionPlanes.length = parentContext.unionOffset;
82-
this.unionOffset = parentContext.unionOffset;
81+
this.unionPlanes.length = parentContext.unionPlanes.length;
8382

8483
} else {
8584

86-
this.intersectionPlanes.length = parentContext.intersectionOffset;
87-
this.intersectionOffset = parentContext.intersectionOffset;
85+
this.intersectionPlanes.length = parentContext.intersectionPlanes.length;
8886

8987
}
9088

@@ -95,31 +93,22 @@ class ClippingContext {
9593

9694
let dstClippingPlanes;
9795
let offset;
98-
let dstLength;
9996

10097
if ( this.clipIntersection ) {
10198

10299
dstClippingPlanes = this.intersectionPlanes;
103-
offset = parentContext.intersectionOffset;
104-
105-
dstLength = offset + l;
106-
107-
this.intersectionOffset = dstLength;
100+
offset = parentContext.intersectionPlanes.length;
108101

109102
} else {
110103

111104
dstClippingPlanes = this.unionPlanes;
112-
offset = parentContext.unionOffset;
113-
114-
dstLength = offset + l;
115-
116-
this.unionOffset = dstLength;
105+
offset = parentContext.unionPlanes.length;
117106

118107
}
119108

120-
if ( dstClippingPlanes.length !== dstLength ) {
109+
if ( dstClippingPlanes.length !== offset + l ) {
121110

122-
dstClippingPlanes.length = dstLength;
111+
dstClippingPlanes.length = offset + l;
123112

124113
for ( let i = 0; i < l; i ++ ) {
125114

0 commit comments

Comments
 (0)