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

Cleaned up cloth example.

上级 24f0c753
...@@ -128,7 +128,7 @@ ...@@ -128,7 +128,7 @@
var clothGeometry; var clothGeometry;
var sphere; var sphere;
var object, arrow; var object;
var rotate = true; var rotate = true;
...@@ -143,7 +143,6 @@ ...@@ -143,7 +143,6 @@
// scene // scene
scene = new THREE.Scene(); scene = new THREE.Scene();
scene.fog = new THREE.Fog( 0xcce0ff, 500, 10000 ); scene.fog = new THREE.Fog( 0xcce0ff, 500, 10000 );
// camera // camera
...@@ -164,7 +163,7 @@ ...@@ -164,7 +163,7 @@
light.position.multiplyScalar( 1.3 ); light.position.multiplyScalar( 1.3 );
light.castShadow = true; light.castShadow = true;
//light.shadowCameraVisible = true; // light.shadowCameraVisible = true;
light.shadowMapWidth = 1024; light.shadowMapWidth = 1024;
light.shadowMapHeight = 1024; light.shadowMapHeight = 1024;
...@@ -187,7 +186,14 @@ ...@@ -187,7 +186,14 @@
clothTexture.wrapS = clothTexture.wrapT = THREE.RepeatWrapping; clothTexture.wrapS = clothTexture.wrapT = THREE.RepeatWrapping;
clothTexture.anisotropy = 16; clothTexture.anisotropy = 16;
var clothMaterial = new THREE.MeshPhongMaterial( { alphaTest: 0.5, color: 0xffffff, specular: 0x030303, emissive: 0x111111, shiness: 10, map: clothTexture, side: THREE.DoubleSide } ); var clothMaterial = new THREE.MeshPhongMaterial( {
specular: 0x030303,
emissive: 0x111111,
shiness: 10,
map: clothTexture,
side: THREE.DoubleSide,
alphaTest: 0.5
} );
// cloth geometry // cloth geometry
clothGeometry = new THREE.ParametricGeometry( clothFunction, cloth.w, cloth.h ); clothGeometry = new THREE.ParametricGeometry( clothFunction, cloth.w, cloth.h );
...@@ -205,7 +211,12 @@ ...@@ -205,7 +211,12 @@
object.receiveShadow = true; object.receiveShadow = true;
scene.add( object ); scene.add( object );
object.customDepthMaterial = new THREE.ShaderMaterial( { uniforms: uniforms, vertexShader: vertexShader, fragmentShader: fragmentShader, side: THREE.DoubleSide } ); object.customDepthMaterial = new THREE.ShaderMaterial( {
uniforms: uniforms,
vertexShader: vertexShader,
fragmentShader: fragmentShader,
side: THREE.DoubleSide
} );
// sphere // sphere
...@@ -217,12 +228,6 @@ ...@@ -217,12 +228,6 @@
sphere.receiveShadow = true; sphere.receiveShadow = true;
scene.add( sphere ); scene.add( sphere );
// arrow
arrow = new THREE.ArrowHelper( new THREE.Vector3( 0, 1, 0 ), new THREE.Vector3( 0, 0, 0 ), 50, 0xff0000 );
arrow.position.set( -200, 0, -200 );
// scene.add( arrow );
// ground // ground
var groundTexture = THREE.ImageUtils.loadTexture( "textures/terrain/grasslight-big.jpg" ); var groundTexture = THREE.ImageUtils.loadTexture( "textures/terrain/grasslight-big.jpg" );
...@@ -327,8 +332,6 @@ ...@@ -327,8 +332,6 @@
windStrength = Math.cos( time / 7000 ) * 20 + 40; windStrength = Math.cos( time / 7000 ) * 20 + 40;
windForce.set( Math.sin( time / 2000 ), Math.cos( time / 3000 ), Math.sin( time / 1000 ) ).normalize().multiplyScalar( windStrength ); windForce.set( Math.sin( time / 2000 ), Math.cos( time / 3000 ), Math.sin( time / 1000 ) ).normalize().multiplyScalar( windStrength );
arrow.setLength( windStrength );
arrow.setDirection( windForce );
simulate(time); simulate(time);
render(); render();
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册