Browse Source

Update README.md

mrdoob 1 year ago
parent
commit
d8ff530065
1 changed files with 5 additions and 3 deletions
  1. 5 3
      README.md

+ 5 - 3
README.md

@@ -26,9 +26,11 @@ This code creates a scene, a camera, and a geometric cube, and it adds the cube
 ```javascript
 ```javascript
 import * as THREE from 'three';
 import * as THREE from 'three';
 
 
+const width = window.innerWidth, height = window.innerHeight;
+
 // init
 // init
 
 
-const camera = new THREE.PerspectiveCamera( 70, window.innerWidth / window.innerHeight, 0.01, 10 );
+const camera = new THREE.PerspectiveCamera( 70, width / height, 0.01, 10 );
 camera.position.z = 1;
 camera.position.z = 1;
 
 
 const scene = new THREE.Scene();
 const scene = new THREE.Scene();
@@ -40,7 +42,7 @@ const mesh = new THREE.Mesh( geometry, material );
 scene.add( mesh );
 scene.add( mesh );
 
 
 const renderer = new THREE.WebGLRenderer( { antialias: true } );
 const renderer = new THREE.WebGLRenderer( { antialias: true } );
-renderer.setSize( window.innerWidth, window.innerHeight );
+renderer.setSize( width, height );
 renderer.setAnimationLoop( animation );
 renderer.setAnimationLoop( animation );
 document.body.appendChild( renderer.domElement );
 document.body.appendChild( renderer.domElement );
 
 
@@ -56,7 +58,7 @@ function animation( time ) {
 }
 }
 ```
 ```
 
 
-If everything went well, you should see [this](https://jsfiddle.net/7u84j6kp/).
+If everything went well, you should see [this](https://jsfiddle.net/2nyxkmco/).
 
 
 ### Cloning this repository
 ### Cloning this repository