Skip to content

Commit a430f83

Browse files
committed
fix styles & remove logical duplication
1 parent a41b679 commit a430f83

File tree

1 file changed

+12
-11
lines changed

1 file changed

+12
-11
lines changed

src/core/PathTracingSceneGenerator.js

Lines changed: 12 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -73,8 +73,6 @@ function getLights( objects ) {
7373

7474
}
7575

76-
let materialUuids = null;
77-
7876
export class PathTracingSceneGenerator {
7977

8078
get initialized() {
@@ -97,6 +95,7 @@ export class PathTracingSceneGenerator {
9795
this._bvhWorker = null;
9896
this._pendingGenerate = null;
9997
this._buildAsync = false;
98+
this._materialUuids = null;
10099

101100
}
102101

@@ -178,27 +177,29 @@ export class PathTracingSceneGenerator {
178177
// generate the geometry
179178
const result = staticGeometryGenerator.generate( geometry );
180179
const materials = result.materials;
181-
let needsMaterialIndexUpdate = result.changeType !== NO_CHANGE || materialUuids === null || materialUuids.length !== length;
182-
for ( let index = 0, length = materials.length; ( index < length ) && ! needsMaterialIndexUpdate; index ++ ) {
180+
let needsMaterialIndexUpdate = result.changeType !== NO_CHANGE || this._materialUuids === null || this._materialUuids.length !== length;
181+
if ( ! needsMaterialIndexUpdate ) {
183182

184-
if ( materialUuids === null || materialUuids.length !== length ) {
183+
for ( let i = 0, length = materials.length; ( i < length ); i ++ ) {
185184

186-
needsMaterialIndexUpdate = true;
187-
break;
185+
const material = materials[ i ];
186+
if ( material.uuid !== this._materialUuids[ i ] ) {
188187

189-
}
188+
needsMaterialIndexUpdate = true;
189+
break;
190190

191-
const material = materials[ index ];
192-
if ( material.uuid !== materialUuids[ index ] ) needsMaterialIndexUpdate = true;
191+
}
192+
193+
}
193194

194195
}
195196

196-
materialUuids = materials.map( material => material.uuid );
197197
const textures = getTextures( materials );
198198
const { lights, iesTextures } = getLights( objects );
199199
if ( needsMaterialIndexUpdate ) {
200200

201201
updateMaterialIndexAttribute( geometry, materials, materials );
202+
this._materialUuids = materials.map( material => material.uuid );
202203

203204
}
204205

0 commit comments

Comments
 (0)