提交 5e40bfb2 编写于 作者: M Mugen87

Examples: webgl_materials_cubemap_dynamic2 clean up

上级 87fe20b7
...@@ -40,12 +40,8 @@ ...@@ -40,12 +40,8 @@
var count = 0, cubeCamera1, cubeCamera2; var count = 0, cubeCamera1, cubeCamera2;
var fov = 60, var lon = 0, lat = 0;
isUserInteracting = false, var phi = 0, theta = 0;
onMouseDownMouseX = 0, onMouseDownMouseY = 0,
lon = 0, onMouseDownLon = 0,
lat = 0, onMouseDownLat = 0,
phi = 0, theta = 0;
var textureLoader = new THREE.TextureLoader(); var textureLoader = new THREE.TextureLoader();
...@@ -60,11 +56,11 @@ ...@@ -60,11 +56,11 @@
function init( texture ) { function init( texture ) {
camera = new THREE.PerspectiveCamera( fov, window.innerWidth / window.innerHeight, 1, 1000 ); camera = new THREE.PerspectiveCamera( 60, window.innerWidth / window.innerHeight, 1, 1000 );
scene = new THREE.Scene(); scene = new THREE.Scene();
var mesh = new THREE.Mesh( new THREE.SphereGeometry( 500, 32, 16 ), new THREE.MeshBasicMaterial( { map: texture } ) ); var mesh = new THREE.Mesh( new THREE.SphereBufferGeometry( 500, 32, 16 ), new THREE.MeshBasicMaterial( { map: texture } ) );
mesh.scale.x = -1; mesh.scale.x = -1;
scene.add( mesh ); scene.add( mesh );
...@@ -88,13 +84,13 @@ ...@@ -88,13 +84,13 @@
envMap: cubeCamera2.renderTarget.texture envMap: cubeCamera2.renderTarget.texture
} ); } );
sphere = new THREE.Mesh( new THREE.IcosahedronGeometry( 20, 3 ), material ); sphere = new THREE.Mesh( new THREE.IcosahedronBufferGeometry( 20, 3 ), material );
scene.add( sphere ); scene.add( sphere );
cube = new THREE.Mesh( new THREE.BoxGeometry( 20, 20, 20 ), material ); cube = new THREE.Mesh( new THREE.BoxBufferGeometry( 20, 20, 20 ), material );
scene.add( cube ); scene.add( cube );
torus = new THREE.Mesh( new THREE.TorusKnotGeometry( 10, 5, 100, 25 ), material ); torus = new THREE.Mesh( new THREE.TorusKnotBufferGeometry( 10, 5, 100, 25 ), material );
scene.add( torus ); scene.add( torus );
// //
...@@ -104,14 +100,15 @@ ...@@ -104,14 +100,15 @@
window.addEventListener( 'resize', onWindowResized, false ); window.addEventListener( 'resize', onWindowResized, false );
onWindowResized( null );
} }
function onWindowResized( event ) { function onWindowResized( event ) {
renderer.setSize( window.innerWidth, window.innerHeight ); renderer.setSize( window.innerWidth, window.innerHeight );
camera.projectionMatrix.makePerspective( fov, window.innerWidth / window.innerHeight, 1, 1100 );
camera.aspect = window.innerWidth / window.innerHeight;
camera.updateProjectionMatrix();
} }
function onDocumentMouseDown( event ) { function onDocumentMouseDown( event ) {
...@@ -145,9 +142,8 @@ ...@@ -145,9 +142,8 @@
function onDocumentMouseWheel( event ) { function onDocumentMouseWheel( event ) {
fov += event.deltaY * 0.05; camera.fov += ( event.deltaY * 0.05 );
camera.updateProjectionMatrix();
camera.projectionMatrix.makePerspective( fov, window.innerWidth / window.innerHeight, 1, 1100 );
} }
...@@ -188,8 +184,6 @@ ...@@ -188,8 +184,6 @@
camera.lookAt( scene.position ); camera.lookAt( scene.position );
sphere.visible = false; // *cough*
// pingpong // pingpong
if ( count % 2 === 0 ) { if ( count % 2 === 0 ) {
...@@ -206,8 +200,6 @@ ...@@ -206,8 +200,6 @@
count ++; count ++;
sphere.visible = true; // *cough*
renderer.render( scene, camera ); renderer.render( scene, camera );
} }
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册