Can a Reflector.js mirror cast a shadow?

Is it possible to make a mirror object cast a shadow on its base? I’ve combined a couple of three.js examples here to illustrate what I want to do.

First, here’s a typical three.js way of casting a shadow:

    var boxMesh = new THREE.Mesh( boxGeometry, cubeMat );
	boxMesh.position.set( -0.5, 0.25, -1 );
	boxMesh.castShadow = true;
	scene.add( boxMesh );

And here’s a Reflector.js object:

        var geometry = new THREE.CircleBufferGeometry( 0.25, 16 );
	    var pedestalMirror = new THREE.Reflector( geometry, {
		clipBias: 0.003,
		textureWidth: WIDTH * window.devicePixelRatio,
		textureHeight: HEIGHT * window.devicePixelRatio,
		color: 0x777777,
		recursion: 1
		} );
	pedestalMirror.position.y = 1.75;
            scene.add( pedestalMirror );

So pedestalMirror.castShadow = true; will not work.
Any suggestions would be greatly appreciated!!

Yes, a reflector can cast shadow. But since CircleBufferGeometry is like PlaneBufferGeoemtry a flat geometry, you have to do the following:

pedestalMirror.material.shadowSide = THREE.FrontSide;

three.js culls front faces when generating shadows. If this is done with flat geometries, there is nothing left for shadow calculation. The presented code ensures that this does not happen in your case.

4 Likes

Thx Mugen87, great answer! You’re a Titan!