Skip to content

Commit

Permalink
material.shading ==> material.flatShading
Browse files Browse the repository at this point in the history
  • Loading branch information
WestLangley committed Jul 9, 2017
1 parent b76e734 commit 848a181
Show file tree
Hide file tree
Showing 57 changed files with 113 additions and 130 deletions.
2 changes: 1 addition & 1 deletion examples/js/crossfade/scenes.js
Expand Up @@ -87,7 +87,7 @@ function Scene ( type, numObjects, cameraZ, fov, rotationSpeed, clearColor ) {

this.rotationSpeed = rotationSpeed;

var defaultMaterial = new THREE.MeshPhongMaterial( { color: 0xffffff, shading: THREE.FlatShading, vertexColors: THREE.VertexColors } );
var defaultMaterial = new THREE.MeshPhongMaterial( { color: 0xffffff, flatShading: true, vertexColors: THREE.VertexColors } );
this.mesh = new THREE.Mesh( generateGeometry( type, numObjects ), defaultMaterial );
this.scene.add( this.mesh );

Expand Down
8 changes: 4 additions & 4 deletions examples/js/renderers/RaytracingWorker.js
Expand Up @@ -267,7 +267,7 @@ THREE.RaytracingRendererWorker = function () {
// the same normal can be reused for all lights
// (should be possible to cache even more)

computePixelNormal( normalVector, localPoint, material.shading, face, vertices );
computePixelNormal( normalVector, localPoint, material.flatShading, face, vertices );
normalVector.applyMatrix3( _object.normalMatrix ).normalize();

normalComputed = true;
Expand Down Expand Up @@ -397,16 +397,16 @@ THREE.RaytracingRendererWorker = function () {
var tmpVec2 = new THREE.Vector3();
var tmpVec3 = new THREE.Vector3();

return function computePixelNormal( outputVector, point, shading, face, vertices ) {
return function computePixelNormal( outputVector, point, flatShading, face, vertices ) {

var faceNormal = face.normal;
var vertexNormals = face.vertexNormals;

if ( shading === THREE.FlatShading ) {
if ( flatShading === true ) {

outputVector.copy( faceNormal );

} else if ( shading === THREE.SmoothShading ) {
} else {

// compute barycentric coordinates

Expand Down
2 changes: 1 addition & 1 deletion examples/misc_controls_orbit.html
Expand Up @@ -82,7 +82,7 @@
// world

var geometry = new THREE.CylinderGeometry( 0, 10, 30, 4, 1 );
var material = new THREE.MeshPhongMaterial( { color:0xffffff, shading: THREE.FlatShading } );
var material = new THREE.MeshPhongMaterial( { color: 0xffffff, flatShading: true } );

for ( var i = 0; i < 500; i ++ ) {

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

for ( var i = 0; i < 500; i ++ ) {

material = new THREE.MeshPhongMaterial( { specular: 0xffffff, shading: THREE.FlatShading, vertexColors: THREE.VertexColors } );
material = new THREE.MeshPhongMaterial( { specular: 0xffffff, flatShading: true, vertexColors: THREE.VertexColors } );

var mesh = new THREE.Mesh( geometry, material );
mesh.position.x = Math.floor( Math.random() * 20 - 10 ) * 20;
Expand Down
2 changes: 1 addition & 1 deletion examples/misc_controls_trackball.html
Expand Up @@ -85,7 +85,7 @@
scene.fog = new THREE.FogExp2( 0xcccccc, 0.002 );

var geometry = new THREE.CylinderGeometry( 0, 10, 30, 4, 1 );
var material = new THREE.MeshPhongMaterial( { color:0xffffff, shading: THREE.FlatShading } );
var material = new THREE.MeshPhongMaterial( { color:0xffffff, flatShading: true } );

for ( var i = 0; i < 500; i ++ ) {

Expand Down
2 changes: 1 addition & 1 deletion examples/misc_lights_test.html
Expand Up @@ -71,7 +71,7 @@
// Spheres

geometry = new THREE.SphereGeometry( 100, 16, 8 );
material = new THREE.MeshPhongMaterial( { color: 0xffffff, shading: THREE.FlatShading, overdraw: 0.5, shininess: 0 } );
material = new THREE.MeshPhongMaterial( { color: 0xffffff, flatShading: true, overdraw: 0.5, shininess: 0 } );

for ( var i = 0; i < 30; i ++ ) {

Expand Down
6 changes: 3 additions & 3 deletions examples/misc_sound.html
Expand Up @@ -86,9 +86,9 @@

var sphere = new THREE.SphereGeometry( 20, 32, 16 );

material1 = new THREE.MeshPhongMaterial( { color: 0xffaa00, shading: THREE.FlatShading, shininess: 0 } );
material2 = new THREE.MeshPhongMaterial( { color: 0xff2200, shading: THREE.FlatShading, shininess: 0 } );
material3 = new THREE.MeshPhongMaterial( { color: 0x6622aa, shading: THREE.FlatShading, shininess: 0 } );
material1 = new THREE.MeshPhongMaterial( { color: 0xffaa00, flatShading: true, shininess: 0 } );
material2 = new THREE.MeshPhongMaterial( { color: 0xff2200, flatShading: true, shininess: 0 } );
material3 = new THREE.MeshPhongMaterial( { color: 0x6622aa, flatShading: true, shininess: 0 } );

// sound spheres

Expand Down
20 changes: 10 additions & 10 deletions examples/raytracing_sandbox.html
Expand Up @@ -45,47 +45,47 @@
specular: 0x222222,
shininess: 150,
vertexColors: THREE.NoColors,
shading: THREE.SmoothShading
flatShading: false
} );

var phongMaterialBox = new THREE.MeshPhongMaterial( {
color: 0xffffff,
specular: 0x111111,
shininess: 100,
vertexColors: THREE.NoColors,
shading: THREE.FlatShading
flatShading: true
} );

var phongMaterialBoxBottom = new THREE.MeshPhongMaterial( {
color: 0x666666,
specular: 0x111111,
shininess: 100,
vertexColors: THREE.NoColors,
shading: THREE.FlatShading
flatShading: true
} );

var phongMaterialBoxLeft = new THREE.MeshPhongMaterial( {
color: 0x990000,
specular: 0x111111,
shininess: 100,
vertexColors: THREE.NoColors,
shading: THREE.FlatShading
flatShading: true
} );

var phongMaterialBoxRight = new THREE.MeshPhongMaterial( {
color: 0x0066ff,
specular: 0x111111,
shininess: 100,
vertexColors: THREE.NoColors,
shading: THREE.FlatShading
flatShading: true
} );

var mirrorMaterialFlat = new THREE.MeshPhongMaterial( {
color: 0x000000,
specular: 0xff8888,
shininess: 10000,
vertexColors: THREE.NoColors,
shading: THREE.FlatShading
flatShading: true
} );
mirrorMaterialFlat.mirror = true;
mirrorMaterialFlat.reflectivity = 1;
Expand All @@ -95,7 +95,7 @@
specular: 0xaaaaaa,
shininess: 10000,
vertexColors: THREE.NoColors,
shading: THREE.FlatShading
flatShading: true
} );
mirrorMaterialFlatDark.mirror = true;
mirrorMaterialFlatDark.reflectivity = 1;
Expand All @@ -105,7 +105,7 @@
specular: 0x222222,
shininess: 10000,
vertexColors: THREE.NoColors,
shading: THREE.SmoothShading
flatShading: false
} );
mirrorMaterialSmooth.mirror = true;
mirrorMaterialSmooth.reflectivity = 0.3;
Expand All @@ -115,7 +115,7 @@
specular: 0x00ff00,
shininess: 10000,
vertexColors: THREE.NoColors,
shading: THREE.FlatShading
flatShading: true
} );
glassMaterialFlat.glass = true;
glassMaterialFlat.reflectivity = 0.5;
Expand All @@ -125,7 +125,7 @@
specular: 0xffaa55,
shininess: 10000,
vertexColors: THREE.NoColors,
shading: THREE.SmoothShading
flatShading: false
} );
glassMaterialSmooth.glass = true;
glassMaterialSmooth.reflectivity = 0.25;
Expand Down
4 changes: 2 additions & 2 deletions examples/webgl2_sandbox.html
Expand Up @@ -81,8 +81,8 @@
new THREE.MeshBasicMaterial( { color: 0xffaa00, wireframe: true } ),
new THREE.MeshBasicMaterial( { map: texture1, fog: false } ),
new THREE.MeshLambertMaterial( { color: 0xdddddd } ),
new THREE.MeshPhongMaterial( { color: 0xdddddd, specular: 0x009900, shininess: 30, shading: THREE.FlatShading } ),
new THREE.MeshPhongMaterial( { color: 0xdddddd, specular: 0x009900, shininess: 30, shading: THREE.SmoothShading } )
new THREE.MeshPhongMaterial( { color: 0xdddddd, specular: 0x009900, shininess: 30, flatShading: true } ),
new THREE.MeshPhongMaterial( { color: 0xdddddd, specular: 0x009900, shininess: 30 } )

];

Expand Down
1 change: 0 additions & 1 deletion examples/webgl_camera_logarithmicdepthbuffer.html
Expand Up @@ -190,7 +190,6 @@
color: 0xffffff,
specular: 0x050505,
shininess: 50,
shading: THREE.SmoothShading,
emissive: 0x000000
};

Expand Down
4 changes: 2 additions & 2 deletions examples/webgl_geometry_colors.html
Expand Up @@ -151,8 +151,8 @@

var materials = [

new THREE.MeshPhongMaterial( { color: 0xffffff, shading: THREE.FlatShading, vertexColors: THREE.VertexColors, shininess: 0 } ),
new THREE.MeshBasicMaterial( { color: 0x000000, shading: THREE.FlatShading, wireframe: true, transparent: true } )
new THREE.MeshPhongMaterial( { color: 0xffffff, flatShading: true, vertexColors: THREE.VertexColors, shininess: 0 } ),
new THREE.MeshBasicMaterial( { color: 0x000000, wireframe: true, transparent: true } )

];

Expand Down
4 changes: 0 additions & 4 deletions examples/webgl_geometry_colors_blender.html
Expand Up @@ -105,8 +105,6 @@

function createScene1( geometry, materials ) {

materials[ 0 ].shading = THREE.FlatShading;

mesh = new THREE.Mesh( geometry, materials );
mesh.position.x = 400;
mesh.scale.x = mesh.scale.y = mesh.scale.z = 250;
Expand All @@ -116,8 +114,6 @@

function createScene2( geometry, materials ) {

materials[ 0 ].shading = THREE.FlatShading;

mesh2 = new THREE.Mesh( geometry, materials );
mesh2.position.x = - 400;
mesh2.scale.x = mesh2.scale.y = mesh2.scale.z = 250;
Expand Down
8 changes: 4 additions & 4 deletions examples/webgl_geometry_teapot.html
Expand Up @@ -135,15 +135,15 @@

wireMaterial = new THREE.MeshBasicMaterial( { color: 0xFFFFFF, wireframe: true } ) ;

flatMaterial = new THREE.MeshPhongMaterial( { color: materialColor, specular: 0x0, shading: THREE.FlatShading, side: THREE.DoubleSide } );
flatMaterial = new THREE.MeshPhongMaterial( { color: materialColor, specular: 0x000000, flatShading: true, side: THREE.DoubleSide } );

gouraudMaterial = new THREE.MeshLambertMaterial( { color: materialColor, side: THREE.DoubleSide } );

phongMaterial = new THREE.MeshPhongMaterial( { color: materialColor, shading: THREE.SmoothShading, side: THREE.DoubleSide } );
phongMaterial = new THREE.MeshPhongMaterial( { color: materialColor, side: THREE.DoubleSide } );

texturedMaterial = new THREE.MeshPhongMaterial( { color: materialColor, map: textureMap, shading: THREE.SmoothShading, side: THREE.DoubleSide } );
texturedMaterial = new THREE.MeshPhongMaterial( { color: materialColor, map: textureMap, side: THREE.DoubleSide } );

reflectiveMaterial = new THREE.MeshPhongMaterial( { color: materialColor, envMap: textureCube, shading: THREE.SmoothShading, side: THREE.DoubleSide } );
reflectiveMaterial = new THREE.MeshPhongMaterial( { color: materialColor, envMap: textureCube, side: THREE.DoubleSide } );

// scene itself
scene = new THREE.Scene();
Expand Down
4 changes: 2 additions & 2 deletions examples/webgl_geometry_text.html
Expand Up @@ -182,8 +182,8 @@
}

materials = [
new THREE.MeshPhongMaterial( { color: 0xffffff, shading: THREE.FlatShading } ), // front
new THREE.MeshPhongMaterial( { color: 0xffffff, shading: THREE.SmoothShading } ) // side
new THREE.MeshPhongMaterial( { color: 0xffffff, flatShading: true } ), // front
new THREE.MeshPhongMaterial( { color: 0xffffff } ) // side
];

group = new THREE.Group();
Expand Down
4 changes: 2 additions & 2 deletions examples/webgl_geometry_text_earcut.html
Expand Up @@ -240,8 +240,8 @@
}

materials = [
new THREE.MeshPhongMaterial( { color: 0xffffff, shading: THREE.FlatShading } ), // front
new THREE.MeshPhongMaterial( { color: 0xffffff, shading: THREE.SmoothShading } ) // side
new THREE.MeshPhongMaterial( { color: 0xffffff, flatShading: true } ), // front
new THREE.MeshPhongMaterial( { color: 0xffffff } ) // side
];

group = new THREE.Group();
Expand Down
4 changes: 2 additions & 2 deletions examples/webgl_geometry_text_pnltri.html
Expand Up @@ -212,8 +212,8 @@
}

materials = [
new THREE.MeshPhongMaterial( { color: 0xffffff, shading: THREE.FlatShading } ), // front
new THREE.MeshPhongMaterial( { color: 0xffffff, shading: THREE.SmoothShading } ) // side
new THREE.MeshPhongMaterial( { color: 0xffffff, flatShading: true } ), // front
new THREE.MeshPhongMaterial( { color: 0xffffff } ) // side
];

group = new THREE.Group();
Expand Down
2 changes: 1 addition & 1 deletion examples/webgl_interactive_cubes_gpu.html
Expand Up @@ -86,7 +86,7 @@
var geometry = new THREE.Geometry(),
pickingGeometry = new THREE.Geometry(),
pickingMaterial = new THREE.MeshBasicMaterial( { vertexColors: THREE.VertexColors } ),
defaultMaterial = new THREE.MeshPhongMaterial({ color: 0xffffff, shading: THREE.FlatShading, vertexColors: THREE.VertexColors, shininess: 0 } );
defaultMaterial = new THREE.MeshPhongMaterial({ color: 0xffffff, flatShading: true, vertexColors: THREE.VertexColors, shininess: 0 } );

function applyVertexColors( g, c ) {

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

var sphereGeometry = new THREE.SphereGeometry( 0.1, 32, 32 );
var sphereMaterial = new THREE.MeshBasicMaterial( { color: 0xff0000, shading: THREE.FlatShading } );
var sphereMaterial = new THREE.MeshBasicMaterial( { color: 0xff0000 } );

for ( var i = 0; i < 40; i++ ) {

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

loader.load( 'models/animated/flamingo.js', function( geometry ) {

var material = new THREE.MeshPhongMaterial( { color: 0xffffff, specular: 0xffffff, shininess: 20, morphTargets: true, vertexColors: THREE.FaceColors, shading: THREE.FlatShading } );
var material = new THREE.MeshPhongMaterial( { color: 0xffffff, specular: 0xffffff, shininess: 20, morphTargets: true, vertexColors: THREE.FaceColors, flatShading: true } );
var mesh = new THREE.Mesh( geometry, material );

var s = 0.35;
Expand Down
4 changes: 2 additions & 2 deletions examples/webgl_loader_collada_kinematics.html
Expand Up @@ -66,8 +66,8 @@

if ( child instanceof THREE.Mesh ) {

child.geometry.computeFaceNormals();
child.material.shading = THREE.FlatShading;
// model does not have normals
child.material.flatShading = true;

}

Expand Down
3 changes: 1 addition & 2 deletions examples/webgl_loader_gltf2.html
Expand Up @@ -184,8 +184,7 @@

if (sceneInfo.addGround) {
var groundMaterial = new THREE.MeshPhongMaterial({
color: 0xFFFFFF,
shading: THREE.SmoothShading
color: 0xFFFFFF
});
ground = new THREE.Mesh( new THREE.PlaneBufferGeometry(512, 512), groundMaterial);

Expand Down
18 changes: 9 additions & 9 deletions examples/webgl_loader_obj2.html
Expand Up @@ -106,7 +106,7 @@

this.controls = null;

this.smoothShading = true;
this.flatShading = false;
this.doubleSide = false;

this.cube = null;
Expand Down Expand Up @@ -245,14 +245,14 @@
this.renderer.render( this.scene, this.camera );
};

OBJLoader2Example.prototype.alterSmoothShading = function () {
OBJLoader2Example.prototype.alterShading = function () {

var scope = this;
scope.smoothShading = ! scope.smoothShading;
console.log( scope.smoothShading ? 'Enabling SmoothShading' : 'Enabling FlatShading');
scope.flatShading = ! scope.flatShading;
console.log( scope.flatShading ? 'Enabling flat shading' : 'Enabling smooth shading');

scope.traversalFunction = function ( material ) {
material.shading = scope.smoothShading ? THREE.SmoothShading : THREE.FlatShading;
material.flatShading = scope.flatShading;
material.needsUpdate = true;
};
var scopeTraverse = function ( object3d ) {
Expand Down Expand Up @@ -304,7 +304,7 @@

// Init dat.gui and controls
var OBJLoader2Control = function() {
this.smoothShading = app.smoothShading;
this.flatShading = app.flatShading;
this.doubleSide = app.doubleSide;
};
var objLoader2Control = new OBJLoader2Control();
Expand All @@ -317,10 +317,10 @@
var menuDiv = document.getElementById( 'dat' );
menuDiv.appendChild(gui.domElement);
var folderQueue = gui.addFolder( 'OBJLoader2 Options' );
var controlSmooth = folderQueue.add( objLoader2Control, 'smoothShading' ).name( 'Smooth Shading' );
var controlSmooth = folderQueue.add( objLoader2Control, 'flatShading' ).name( 'Flat Shading' );
controlSmooth.onChange( function( value ) {
console.log( 'Setting smoothShading to: ' + value );
app.alterSmoothShading();
console.log( 'Setting flatShading to: ' + value );
app.alterShading();
});

var controlDouble = folderQueue.add( objLoader2Control, 'doubleSide' ).name( 'Double Side Materials' );
Expand Down

0 comments on commit 848a181

Please sign in to comment.