提交 356f0441 编写于 作者: M Mr.doob

Examples: Improved webgl_clipping_intersection.

上级 00bd806e
......@@ -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
......@@ -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 );
......@@ -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 ++ ) {
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册