Skip to content

Commit 68269fb

Browse files
committed
Examples clean up.
1 parent 54163bc commit 68269fb

10 files changed

Lines changed: 49 additions & 41 deletions

examples/js/postprocessing/BloomPass.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ THREE.BloomPass = function ( strength, kernelSize, sigma, resolution ) {
6969
this.camera = new THREE.OrthographicCamera( -1, 1, 1, -1, 0, 1 );
7070
this.scene = new THREE.Scene();
7171

72-
this.quad = new THREE.Mesh( new THREE.PlaneGeometry( 2, 2 ), null );
72+
this.quad = new THREE.Mesh( new THREE.PlaneBufferGeometry( 2, 2 ), null );
7373
this.scene.add( this.quad );
7474

7575
};

examples/js/postprocessing/BokehPass.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ THREE.BokehPass = function ( scene, camera, params ) {
6161
this.camera2 = new THREE.OrthographicCamera( -1, 1, 1, -1, 0, 1 );
6262
this.scene2 = new THREE.Scene();
6363

64-
this.quad2 = new THREE.Mesh( new THREE.PlaneGeometry( 2, 2 ), null );
64+
this.quad2 = new THREE.Mesh( new THREE.PlaneBufferGeometry( 2, 2 ), null );
6565
this.scene2.add( this.quad2 );
6666

6767
};

examples/js/postprocessing/DotScreenPass.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ THREE.DotScreenPass = function ( center, angle, scale ) {
3131
this.camera = new THREE.OrthographicCamera( -1, 1, 1, -1, 0, 1 );
3232
this.scene = new THREE.Scene();
3333

34-
this.quad = new THREE.Mesh( new THREE.PlaneGeometry( 2, 2 ), null );
34+
this.quad = new THREE.Mesh( new THREE.PlaneBufferGeometry( 2, 2 ), null );
3535
this.scene.add( this.quad );
3636

3737
};

examples/js/postprocessing/FilmPass.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ THREE.FilmPass = function ( noiseIntensity, scanlinesIntensity, scanlinesCount,
3232
this.camera = new THREE.OrthographicCamera( -1, 1, 1, -1, 0, 1 );
3333
this.scene = new THREE.Scene();
3434

35-
this.quad = new THREE.Mesh( new THREE.PlaneGeometry( 2, 2 ), null );
35+
this.quad = new THREE.Mesh( new THREE.PlaneBufferGeometry( 2, 2 ), null );
3636
this.scene.add( this.quad );
3737

3838
};

examples/js/postprocessing/GlitchPass.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ THREE.GlitchPass = function ( dt_size ) {
3131
this.camera = new THREE.OrthographicCamera( -1, 1, 1, -1, 0, 1 );
3232
this.scene = new THREE.Scene();
3333

34-
this.quad = new THREE.Mesh( new THREE.PlaneGeometry( 2, 2 ), null );
34+
this.quad = new THREE.Mesh( new THREE.PlaneBufferGeometry( 2, 2 ), null );
3535
this.scene.add( this.quad );
3636

3737
this.goWild=false;

examples/js/postprocessing/SavePass.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ THREE.SavePass = function ( renderTarget ) {
3838
this.camera = new THREE.OrthographicCamera( -1, 1, 1, -1, 0, 1 );
3939
this.scene = new THREE.Scene();
4040

41-
this.quad = new THREE.Mesh( new THREE.PlaneGeometry( 2, 2 ), null );
41+
this.quad = new THREE.Mesh( new THREE.PlaneBufferGeometry( 2, 2 ), null );
4242
this.scene.add( this.quad );
4343

4444
};

examples/js/postprocessing/ShaderPass.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ THREE.ShaderPass = function ( shader, textureID ) {
2626
this.camera = new THREE.OrthographicCamera( -1, 1, 1, -1, 0, 1 );
2727
this.scene = new THREE.Scene();
2828

29-
this.quad = new THREE.Mesh( new THREE.PlaneGeometry( 2, 2 ), null );
29+
this.quad = new THREE.Mesh( new THREE.PlaneBufferGeometry( 2, 2 ), null );
3030
this.scene.add( this.quad );
3131

3232
};

examples/js/postprocessing/TexturePass.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ THREE.TexturePass = function ( texture, opacity ) {
2929
this.camera = new THREE.OrthographicCamera( -1, 1, 1, -1, 0, 1 );
3030
this.scene = new THREE.Scene();
3131

32-
this.quad = new THREE.Mesh( new THREE.PlaneGeometry( 2, 2 ), null );
32+
this.quad = new THREE.Mesh( new THREE.PlaneBufferGeometry( 2, 2 ), null );
3333
this.scene.add( this.quad );
3434

3535
};

examples/webgl_effects_vr.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@
3636
<body>
3737
<div class="button">Start VR Mode</div>
3838

39-
<script src="../build/three.js"></script>
39+
<script src="../build/three.min.js"></script>
4040
<script src="js/effects/VREffect.js"></script>
4141
<script src="js/controls/VRControls.js"></script>
4242
<script src="js/libs/stats.min.js"></script>

examples/webgl_materials_cubemap_dynamic.html

Lines changed: 40 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -396,7 +396,12 @@
396396

397397
renderer.autoClear = false;
398398

399-
var renderTargetParameters = { minFilter: THREE.LinearFilter, magFilter: THREE.LinearFilter, format: THREE.RGBFormat, stencilBuffer: false };
399+
var renderTargetParameters = {
400+
minFilter: THREE.LinearFilter,
401+
magFilter: THREE.LinearFilter,
402+
format: THREE.RGBFormat,
403+
stencilBuffer: false
404+
};
400405
renderTarget = new THREE.WebGLRenderTarget( SCREEN_WIDTH, SCREEN_HEIGHT, renderTargetParameters );
401406

402407
effectSave = new THREE.SavePass( new THREE.WebGLRenderTarget( SCREEN_WIDTH, SCREEN_HEIGHT, renderTargetParameters ) );
@@ -495,7 +500,7 @@
495500
groundBasic = new THREE.MeshBasicMaterial( { color: 0xffffff, map: texture } );
496501
groundBasic.color.setHSL( 0.1, 0.9, 0.7 );
497502

498-
ground = new THREE.Mesh( new THREE.PlaneGeometry( 50000, 50000 ), groundBasic );
503+
ground = new THREE.Mesh( new THREE.PlaneBufferGeometry( 50000, 50000 ), groundBasic );
499504
ground.position.y = - 215;
500505
ground.rotation.x = - Math.PI / 2;
501506
scene.add( ground );
@@ -525,45 +530,42 @@
525530

526531
//
527532

528-
function addObject( geometry, color, x, y, z, sy ) {
533+
var canvas = document.createElement( 'canvas' );
534+
canvas.width = 128;
535+
canvas.height = 128;
529536

530-
var object = new THREE.Mesh( geometry, new THREE.MeshLambertMaterial( { color: color, ambient: color } ) );
531-
object.position.set( x, y, z );
532-
object.castShadow = true;
533-
object.receiveShadow = true;
534-
scene.add( object );
537+
var context = canvas.getContext( '2d' );
538+
var gradient = context.createRadialGradient( canvas.width / 2, canvas.height / 2, 0, canvas.width / 2, canvas.height / 2, canvas.width / 2 );
539+
gradient.addColorStop( 0.1, 'rgba(0,0,0,1)' );
540+
gradient.addColorStop( 1, 'rgba(0,0,0,0)' );
535541

536-
//
537-
538-
var canvas = document.createElement( 'canvas' );
539-
canvas.width = 128;
540-
canvas.height = 128;
542+
context.fillStyle = gradient;
543+
context.fillRect( 0, 0, canvas.width, canvas.height );
541544

542-
var context = canvas.getContext( '2d' );
543-
var gradient = context.createRadialGradient( canvas.width / 2, canvas.height / 2, 0, canvas.width / 2, canvas.height / 2, canvas.width / 2 );
544-
gradient.addColorStop( 0.1, 'rgba(0,0,0,1)' );
545-
gradient.addColorStop( 1, 'rgba(0,0,0,0)' );
545+
//
546546

547-
context.fillStyle = gradient;
548-
context.fillRect( 0, 0, canvas.width, canvas.height );
547+
var shadowTexture = new THREE.Texture( canvas );
548+
shadowTexture.needsUpdate = true;
549549

550-
//
550+
var shadowPlane = new THREE.PlaneBufferGeometry( 400, 400 );
551+
var shadowMaterial = new THREE.MeshBasicMaterial( {
551552

552-
var shadowTexture = new THREE.Texture( canvas );
553-
shadowTexture.needsUpdate = true;
553+
opacity: 0.35, transparent: true, map: shadowTexture,
554+
polygonOffset: false, polygonOffsetFactor: -0.5, polygonOffsetUnits: 1
554555

555-
var shadowPlane = new THREE.PlaneGeometry( 400, 400 );
556-
var shadowMaterial = new THREE.MeshBasicMaterial( {
556+
} );
557557

558-
opacity: 0.35, transparent: true, map: shadowTexture,
559-
polygonOffset: false, polygonOffsetFactor: -0.5, polygonOffsetUnits: 1
558+
function addObject( geometry, color, x, y, z, sy ) {
560559

561-
} );
560+
var object = new THREE.Mesh( geometry, new THREE.MeshLambertMaterial( { color: color, ambient: color } ) );
561+
object.position.set( x, y, z );
562+
object.castShadow = true;
563+
object.receiveShadow = true;
564+
scene.add( object );
562565

563566
var shadow = new THREE.Mesh( shadowPlane, shadowMaterial );
564567
shadow.position.y = sy;
565568
shadow.rotation.x = - Math.PI / 2;
566-
567569
object.add( shadow );
568570

569571
}
@@ -572,7 +574,12 @@
572574

573575
function generateDropShadowTexture( object, width, height, bluriness ) {
574576

575-
var renderTargetParameters = { minFilter: THREE.LinearMipmapLinearFilter, magFilter: THREE.LinearFilter, format: THREE.RGBAFormat, stencilBuffer: false };
577+
var renderTargetParameters = {
578+
minFilter: THREE.LinearMipmapLinearFilter,
579+
magFilter: THREE.LinearFilter,
580+
format: THREE.RGBAFormat,
581+
stencilBuffer: false
582+
};
576583
var shadowTarget = new THREE.WebGLRenderTarget( width, height, renderTargetParameters );
577584

578585
var shadowMaterial = new THREE.MeshBasicMaterial( { color: 0x000000 } );
@@ -639,7 +646,6 @@
639646

640647
}
641648

642-
643649
//
644650

645651
function addCar( object, x, y, z, s ) {
@@ -672,7 +678,7 @@
672678
var shadowWidth = ss * ( bb.max.z - bb.min.z );
673679
var shadowHeight = 1.25 * ss * ( bb.max.x - bb.min.x );
674680

675-
var shadowPlane = new THREE.PlaneGeometry( shadowWidth, shadowHeight );
681+
var shadowPlane = new THREE.PlaneBufferGeometry( shadowWidth, shadowHeight );
676682
var shadowMaterial = new THREE.MeshBasicMaterial( {
677683
color: 0xffffff, opacity: 0.5, transparent: true, map: shadowTexture,
678684
polygonOffset: false, polygonOffsetFactor: -0.5, polygonOffsetUnits: 1
@@ -979,7 +985,9 @@
979985

980986
camera.lookAt( cameraTarget );
981987

982-
renderer.clearTarget( null );
988+
renderer.setRenderTarget( null );
989+
990+
renderer.clear();
983991
composer.render( 0.1 );
984992

985993
renderer.shadowMapEnabled = false;

0 commit comments

Comments
 (0)