Skip to content

Commit

Permalink
Maintenance (#8802)
Browse files Browse the repository at this point in the history
* Legacy: Moved EventDispatcher.prototype.apply.

* WebGLShadowMap: Renamed face selection parameters.

* WebGLShadowMap: Clarified code.

* WebGLShadowMap: Renamed face selection parameters.
  • Loading branch information
tschw authored and mrdoob committed May 4, 2016
1 parent fdca37f commit 79ad4be
Show file tree
Hide file tree
Showing 11 changed files with 53 additions and 52 deletions.
8 changes: 4 additions & 4 deletions docs/api/renderers/WebGLRenderer.html
Expand Up @@ -105,13 +105,13 @@ <h3>[property:Integer shadowMap.type]</h3>
<div>Defines shadow map type (unfiltered, percentage close filtering, percentage close filtering with bilinear filtering in shader)</div>
<div>Options are THREE.BasicShadowMap, THREE.PCFShadowMap, THREE.PCFSoftShadowMap. Default is THREE.PCFShadowMap.</div>

<h3>[property:Boolean shadowMap.flipSidedFaces]</h3>
<h3>[property:Boolean shadowMap.renderReverseSided]</h3>

<div>Whether to flip front and back sides of surfaces when rendering the shadow map. The default is true.</div>
<div>Default is true. Whether to render the opposite side as specified by the material into the shadow map. When disabled, an appropriate shadow.bias must be set on the light source for surfaces that can both cast and receive shadows at the same time to render correctly.</div>

<h3>[property:Boolean shadowMap.allowDoubleSided]</h3>
<h3>[property:Boolean shadowMap.renderSingleSided]</h3>

<div>Whether to allow double sided shadow rendering, off by default. When enabled, an appropriate shadow.bias must be set on the light source to keep surfaces from casting a shadow on themselves that will not render properly. When disabled, double sided faces are treated like front-facing ones.</div>
<div>Default is true. Whether to treat materials specified as double-sided as if they were specified as front-sided when rendering the shadow map. When disabled, an appropriate shadow.bias must be set on the light source for surfaces that can both cast and receive shadows at the same time to render correctly.</div>

<h3>[property:Integer maxMorphTargets]</h3>

Expand Down
2 changes: 1 addition & 1 deletion examples/webgl_clipping_advanced.html
Expand Up @@ -267,7 +267,7 @@

renderer = new THREE.WebGLRenderer();
renderer.shadowMap.enabled = true;
renderer.shadowMap.allowDoubleSided = true;
renderer.shadowMap.renderSingleSided = false;
renderer.setPixelRatio( window.devicePixelRatio );
renderer.setSize( window.innerWidth, window.innerHeight );
window.addEventListener( 'resize', onWindowResize, false );
Expand Down
2 changes: 1 addition & 1 deletion examples/webgl_lights_hemisphere.html
Expand Up @@ -226,7 +226,7 @@
renderer.gammaOutput = true;

renderer.shadowMap.enabled = true;
renderer.shadowMap.flipSidedFaces = false;
renderer.shadowMap.renderReverseSided = false;

// STATS

Expand Down
2 changes: 1 addition & 1 deletion examples/webgl_loader_ply.html
Expand Up @@ -126,7 +126,7 @@
renderer.gammaOutput = true;

renderer.shadowMap.enabled = true;
renderer.shadowMap.flipSidedFaces = false;
renderer.shadowMap.renderReverseSided = false;

container.appendChild( renderer.domElement );

Expand Down
2 changes: 1 addition & 1 deletion examples/webgl_loader_stl.html
Expand Up @@ -180,7 +180,7 @@
renderer.gammaOutput = true;

renderer.shadowMap.enabled = true;
renderer.shadowMap.flipSidedFaces = false;
renderer.shadowMap.renderReverseSided = false;

container.appendChild( renderer.domElement );

Expand Down
2 changes: 1 addition & 1 deletion examples/webgl_materials_bumpmap.html
Expand Up @@ -135,7 +135,7 @@
container.appendChild( renderer.domElement );

renderer.shadowMap.enabled = true;
renderer.shadowMap.flipSidedFaces = false;
renderer.shadowMap.renderReverseSided = false;

//

Expand Down
2 changes: 1 addition & 1 deletion examples/webgl_materials_bumpmap_skin.html
Expand Up @@ -140,7 +140,7 @@
container.appendChild( renderer.domElement );

renderer.shadowMap.enabled = true;
renderer.shadowMap.flipSidedFaces = false;
renderer.shadowMap.renderReverseSided = false;

renderer.autoClear = false;

Expand Down
2 changes: 1 addition & 1 deletion examples/webgl_materials_cubemap_dynamic.html
Expand Up @@ -184,7 +184,7 @@

// SHADOW

renderer.shadowMap.flipSidedFaces = false;
renderer.shadowMap.renderReverseSided = false;
renderer.shadowMap.enabled = true;

// STATS
Expand Down
28 changes: 23 additions & 5 deletions src/Three.Legacy.js
Expand Up @@ -472,6 +472,25 @@ Object.defineProperties( THREE.ShaderMaterial.prototype, {

//

THREE.EventDispatcher.prototype = Object.assign( Object.create( {

// Note: Extra base ensures these properties are not 'assign'ed.

constructor: THREE.EventDispatcher,

apply: function( target ) {

console.warn( "THREE.EventDispatcher: .apply is deprecated, " +
"just inherit or Object.assign the prototype to mix-in." );

Object.assign( target, this );

}

} ), THREE.EventDispatcher.prototype );

//

Object.defineProperties( THREE.WebGLRenderer.prototype, {
supportsFloatTextures: {
value: function () {
Expand Down Expand Up @@ -577,13 +596,12 @@ Object.defineProperties( THREE.WebGLRenderer.prototype, {

Object.defineProperty( THREE.WebGLShadowMap.prototype, 'cullFace', {
set: function( cullFace ) {
var flipSided = ( cullFace !== THREE.CullFaceBack );
console.warn( "WebGLRenderer: .shadowMap.cullFace is deprecated. " +
" Set .shadowMap.flipSidedFaces to " + flipSided + "." );
this.flipSidedFaces = flipSided;
var value = ( cullFace !== THREE.CullFaceBack );
console.warn( "WebGLRenderer: .shadowMap.cullFace is deprecated. Set .shadowMap.renderReverseSided to " + value + "." );
this.renderReverseSided = value;
},
get: function() {
return this.flipSidedFaces ? THREE.CullFaceFront : THREE.CullFaceBack;
return this.renderReverseSided ? THREE.CullFaceFront : THREE.CullFaceBack;
}
} );

Expand Down
35 changes: 3 additions & 32 deletions src/core/EventDispatcher.js
Expand Up @@ -4,39 +4,10 @@

THREE.EventDispatcher = function () {};

//
// [Deprecation]
//
Object.assign( THREE.EventDispatcher.prototype, {

THREE.EventDispatcher.prototype = Object.assign( Object.create( {

constructor: THREE.EventDispatcher,

apply: function ( object ) {

console.warn( "THREE.EventDispatcher: .apply is deprecated, " +
"just inherit or Object.assign the prototype to mix-in." );

object.addEventListener = THREE.EventDispatcher.prototype.addEventListener;
object.hasEventListener = THREE.EventDispatcher.prototype.hasEventListener;
object.removeEventListener = THREE.EventDispatcher.prototype.removeEventListener;
object.dispatchEvent = THREE.EventDispatcher.prototype.dispatchEvent;

}

// Notes:
// - The prototype chain ensures that Object.assign will not copy the
// properties within this block.
// - When .constructor is not explicitly set, it is not copied either,
// so use the disabled code below so doesn't need to be clobbered.

} ), {

//
// [/Deprecation]
//

//Object.assign( THREE.EventDispatcher.prototype, {
// Note: *No* constructor here, this would clobber that property
// of the target class when used as a mixin.

addEventListener: function ( type, listener ) {

Expand Down
20 changes: 16 additions & 4 deletions src/renderers/webgl/WebGLShadowMap.js
Expand Up @@ -91,8 +91,8 @@ THREE.WebGLShadowMap = function ( _renderer, _lights, _objects ) {

this.type = THREE.PCFShadowMap;

this.flipSidedFaces = true;
this.allowDoubleSided = false;
this.renderReverseSided = true;
this.renderSingleSided = true;

this.render = function ( scene, camera ) {

Expand Down Expand Up @@ -358,8 +358,20 @@ THREE.WebGLShadowMap = function ( _renderer, _lights, _objects ) {
result.wireframe = material.wireframe;

var side = material.side;
if ( ! scope.allowDoubleSided ) side &= 1;
if ( scope.flipSidedFaces && side < 2 ) side ^= 1;

if ( scope.renderSingleSided && side == THREE.DoubleSide ) {

side = THREE.FrontSide;

}

if ( scope.renderReverseSided ) {

if ( side === THREE.FrontSide ) side = THREE.BackSide;
else if ( side === THREE.BackSide ) side = THREE.FrontSide;

}

result.side = side;

result.clipShadows = material.clipShadows;
Expand Down

0 comments on commit 79ad4be

Please sign in to comment.