Skip to content

Commit

Permalink
Examples: Improved webgl_clipping_intersection.
Browse files Browse the repository at this point in the history
  • Loading branch information
mrdoob committed Mar 27, 2019
1 parent 00bd806 commit 356f044
Showing 1 changed file with 14 additions and 13 deletions.
27 changes: 14 additions & 13 deletions examples/webgl_clipping_intersection.html
Original file line number Diff line number Diff line change
Expand Up @@ -49,30 +49,32 @@

camera = new THREE.PerspectiveCamera( 40, window.innerWidth / window.innerHeight, 1, 200 );

camera.position.set( - 20, 30, 40 );
camera.position.set( - 1.5, 2.5, 3.0 );

var controls = new THREE.OrbitControls( camera, renderer.domElement );
controls.addEventListener( 'change', render ); // use only if there is no animation loop
controls.minDistance = 10;
controls.maxDistance = 100;
controls.minDistance = 1;
controls.maxDistance = 10;
controls.enablePan = false;

var light = new THREE.HemisphereLight( 0xffffff, 0x080808, 1 );
var light = new THREE.HemisphereLight( 0xffffff, 0x080808, 1.5 );
light.position.set( - 1.25, 1, 1.25 );
scene.add( light );

scene.add( new THREE.AmbientLight( 0x505050 ) );
// var helper = new THREE.CameraHelper( light.shadow.camera );
// scene.add( helper );

//

var group = new THREE.Group();

for ( var i = 1; i < 25; i ++ ) {
for ( var i = 1; i <= 30; i += 2 ) {

var geometry = new THREE.SphereBufferGeometry( i / 2, 48, 24 );
var geometry = new THREE.SphereBufferGeometry( i / 30, 48, 24 );

var material = new THREE.MeshLambertMaterial( {

color: new THREE.Color( Math.sin( i * 0.5 ) * 0.5 + 0.5, Math.cos( i * 1.5 ) * 0.5 + 0.5, Math.sin( i * 4.5 + 0 ) * 0.5 + 0.5 ),
color: new THREE.Color().setHSL( Math.random(), 0.5, 0.5 ),
side: THREE.DoubleSide,
clippingPlanes: clipPlanes,
clipIntersection: params.clipIntersection
Expand All @@ -88,10 +90,9 @@
// helpers

var helpers = new THREE.Group();
helpers.add( new THREE.AxesHelper( 20 ) );
helpers.add( new THREE.PlaneHelper( clipPlanes[ 0 ], 30, 0xff0000 ) );
helpers.add( new THREE.PlaneHelper( clipPlanes[ 1 ], 30, 0x00ff00 ) );
helpers.add( new THREE.PlaneHelper( clipPlanes[ 2 ], 30, 0x0000ff ) );
helpers.add( new THREE.PlaneHelper( clipPlanes[ 0 ], 2, 0xff0000 ) );
helpers.add( new THREE.PlaneHelper( clipPlanes[ 1 ], 2, 0x00ff00 ) );
helpers.add( new THREE.PlaneHelper( clipPlanes[ 2 ], 2, 0x0000ff ) );
helpers.visible = false;
scene.add( helpers );

Expand All @@ -113,7 +114,7 @@

} );

gui.add( params, 'planeConstant', - 16, 16 ).step( 1 ).name( 'plane constant' ).onChange( function ( value ) {
gui.add( params, 'planeConstant', - 1, 1 ).step( 0.01 ).name( 'plane constant' ).onChange( function ( value ) {

for ( var j = 0; j < clipPlanes.length; j ++ ) {

Expand Down

0 comments on commit 356f044

Please sign in to comment.