瀏覽代碼

Update README.md

mrdoob 3 年之前
父節點
當前提交
1a81867bcb
共有 1 個文件被更改,包括 15 次插入20 次删除
  1. 15 20
      README.md

+ 15 - 20
README.md

@@ -24,32 +24,27 @@ The aim of the project is to create an easy to use, lightweight, cross-browser,
 This code creates a scene, a camera, and a geometric cube, and it adds the cube to the scene. It then creates a `WebGL` renderer for the scene and camera, and it adds that viewport to the `document.body` element. Finally, it animates the cube within the scene for the camera.
 
 ```javascript
-import * as THREE from './js/three.module.js';
+import * as THREE from 'three';
 
-let camera, scene, renderer;
-let geometry, material, mesh;
+// init
 
-init();
+const camera = new THREE.PerspectiveCamera( 70, window.innerWidth / window.innerHeight, 0.01, 10 );
+camera.position.z = 1;
 
-function init() {
+const scene = new THREE.Scene();
 
-	camera = new THREE.PerspectiveCamera( 70, window.innerWidth / window.innerHeight, 0.01, 10 );
-	camera.position.z = 1;
+const geometry = new THREE.BoxGeometry( 0.2, 0.2, 0.2 );
+const material = new THREE.MeshNormalMaterial();
 
-	scene = new THREE.Scene();
+const mesh = new THREE.Mesh( geometry, material );
+scene.add( mesh );
 
-	geometry = new THREE.BoxGeometry( 0.2, 0.2, 0.2 );
-	material = new THREE.MeshNormalMaterial();
+const renderer = new THREE.WebGLRenderer( { antialias: true } );
+renderer.setSize( window.innerWidth, window.innerHeight );
+renderer.setAnimationLoop( animation );
+document.body.appendChild( renderer.domElement );
 
-	mesh = new THREE.Mesh( geometry, material );
-	scene.add( mesh );
-
-	renderer = new THREE.WebGLRenderer( { antialias: true } );
-	renderer.setSize( window.innerWidth, window.innerHeight );
-	renderer.setAnimationLoop( animation );
-	document.body.appendChild( renderer.domElement );
-
-}
+// animation loop
 
 function animation( time ) {
 
@@ -61,7 +56,7 @@ function animation( time ) {
 }
 ```
 
-If everything went well, you should see [this](https://jsfiddle.net/vy29n6aj/).
+If everything went well, you should see [this](https://jsfiddle.net/7u84j6kp/).
 
 ### Cloning this repository ###