@@ -250,6 +250,8 @@ THREE.ShadowMapPlugin = function ( ) {
250
250
251
251
// render regular objects
252
252
253
+ var objectMaterial , useMorphing , useSkinning ;
254
+
253
255
for ( j = 0 , jl = renderList . length ; j < jl ; j ++ ) {
254
256
255
257
webglObject = renderList [ j ] ;
@@ -262,15 +264,26 @@ THREE.ShadowMapPlugin = function ( ) {
262
264
// culling is overriden globally for all objects
263
265
// while rendering depth map
264
266
267
+ // need to deal with MeshFaceMaterial somehow
268
+ // in that case just use the first of geometry.materials for now
269
+ // (proper solution would require to break objects by materials
270
+ // similarly to regular rendering and then set corresponding
271
+ // depth materials per each chunk instead of just once per object)
272
+
273
+ objectMaterial = getObjectMaterial ( object ) ;
274
+
275
+ useMorphing = object . geometry . morphTargets . length > 0 && objectMaterial . morphTargets ;
276
+ useSkinning = object instanceof THREE . SkinnedMesh && objectMaterial . skinning ;
277
+
265
278
if ( object . customDepthMaterial ) {
266
279
267
280
material = object . customDepthMaterial ;
268
281
269
- } else if ( object instanceof THREE . SkinnedMesh ) {
282
+ } else if ( useSkinning ) {
270
283
271
- material = object . geometry . morphTargets . length ? _depthMaterialMorphSkin : _depthMaterialSkin ;
284
+ material = useMorphing ? _depthMaterialMorphSkin : _depthMaterialSkin ;
272
285
273
- } else if ( object . geometry . morphTargets . length ) {
286
+ } else if ( useMorphing ) {
274
287
275
288
material = _depthMaterialMorph ;
276
289
@@ -462,6 +475,15 @@ THREE.ShadowMapPlugin = function ( ) {
462
475
463
476
}
464
477
478
+ // For the moment just ignore objects that have multiple materials with different animation methods
479
+ // Only the first material will be taken into account for deciding which depth material to use for shadow maps
480
+
481
+ function getObjectMaterial ( object ) {
482
+
483
+ return object . material instanceof THREE . MeshFaceMaterial ? object . geometry . materials [ 0 ] : object . material ;
484
+
485
+ }
486
+
465
487
} ;
466
488
467
489
THREE . ShadowMapPlugin . __projector = new THREE . Projector ( ) ;
0 commit comments