Skip to content

Commit e402f32

Browse files
committedOct 10, 2012
Fixed shadows getting animated when skinning / morphing was disabled for the regular rendering.
Fixes mrdoob#2489 Doesn't deal yet properly with MeshFaceMaterial and having mesh chunks with different animation statuses.
1 parent 845a268 commit e402f32

File tree

3 files changed

+33650
-33606
lines changed

3 files changed

+33650
-33606
lines changed
 

‎build/three.js

+33,546-33,524
Large diffs are not rendered by default.

‎build/three.min.js

+79-79
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

‎src/extras/renderers/plugins/ShadowMapPlugin.js

+25-3
Original file line numberDiff line numberDiff line change
@@ -250,6 +250,8 @@ THREE.ShadowMapPlugin = function ( ) {
250250

251251
// render regular objects
252252

253+
var objectMaterial, useMorphing, useSkinning;
254+
253255
for ( j = 0, jl = renderList.length; j < jl; j ++ ) {
254256

255257
webglObject = renderList[ j ];
@@ -262,15 +264,26 @@ THREE.ShadowMapPlugin = function ( ) {
262264
// culling is overriden globally for all objects
263265
// while rendering depth map
264266

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+
265278
if ( object.customDepthMaterial ) {
266279

267280
material = object.customDepthMaterial;
268281

269-
} else if ( object instanceof THREE.SkinnedMesh ) {
282+
} else if ( useSkinning ) {
270283

271-
material = object.geometry.morphTargets.length ? _depthMaterialMorphSkin : _depthMaterialSkin;
284+
material = useMorphing ? _depthMaterialMorphSkin : _depthMaterialSkin;
272285

273-
} else if ( object.geometry.morphTargets.length ) {
286+
} else if ( useMorphing ) {
274287

275288
material = _depthMaterialMorph;
276289

@@ -462,6 +475,15 @@ THREE.ShadowMapPlugin = function ( ) {
462475

463476
}
464477

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+
465487
};
466488

467489
THREE.ShadowMapPlugin.__projector = new THREE.Projector();

0 commit comments

Comments
 (0)
Please sign in to comment.