From 3c142193b921e0ad824cec01540189cf1cf262ba Mon Sep 17 00:00:00 2001 From: XD1729 <67259379+XD1729@users.noreply.github.com> Date: Tue, 13 Jul 2021 01:10:18 +0800 Subject: [PATCH 1/5] =?UTF-8?q?=E6=B7=BB=E5=8A=A0=E4=BA=86=E4=B8=AD?= =?UTF-8?q?=E6=96=87=E6=B3=A8=E9=87=8A?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ...st-scene.html => NOTE-02-first-scene.html} | 32 +++++++++---------- 1 file changed, 16 insertions(+), 16 deletions(-) rename chapter-01/{02-first-scene.html => NOTE-02-first-scene.html} (61%) diff --git a/chapter-01/02-first-scene.html b/chapter-01/NOTE-02-first-scene.html similarity index 61% rename from chapter-01/02-first-scene.html rename to chapter-01/NOTE-02-first-scene.html index ea1ffff2..aae7f4f4 100644 --- a/chapter-01/02-first-scene.html +++ b/chapter-01/NOTE-02-first-scene.html @@ -25,7 +25,7 @@ // once everything is loaded, we run our Three.js stuff. function init() { - // create a scene, that will hold all our elements such as objects, cameras and lights. + // create a scene场景画面, that will hold all our elements such as objects, cameras and lights. var scene = new THREE.Scene(); // create a camera, which defines where we're looking at. @@ -34,20 +34,20 @@ // create a render and set the size var renderer = new THREE.WebGLRenderer(); renderer.setClearColorHex(); - renderer.setClearColor(new THREE.Color(0xEEEEEE)); - renderer.setSize(window.innerWidth, window.innerHeight); + renderer.setClearColor(new THREE.Color(0xEEEEEE));//设置场景的背景色 + renderer.setSize(window.innerWidth, window.innerHeight);//window.innerWidth和window.innerHeight将整个页面窗口指定为渲染区域 // show axes in the screen - var axes = new THREE.AxisHelper(20); - scene.add(axes); + var axes = new THREE.AxisHelper(20);//坐标轴轴线粗细为20 + scene.add(axes);//将轴添加到场景中 // create the ground plane - var planeGeometry = new THREE.PlaneGeometry(60, 20); - var planeMaterial = new THREE.MeshBasicMaterial({color: 0xcccccc}); - var plane = new THREE.Mesh(planeGeometry, planeMaterial); + var planeGeometry = new THREE.PlaneGeometry(60, 20);//平面大小宽60, 长20 + var planeMaterial = new THREE.MeshBasicMaterial({color: 0xcccccc});//创建基本材质来设置平面外观 + var plane = new THREE.Mesh(planeGeometry, planeMaterial);//将大小和外观组合进Mesh对象并赋值给平面变量 - // rotate and position the plane - plane.rotation.x = -0.5 * Math.PI; + //在将平面添加到场景之前,还需要设置平面的位置. + plane.rotation.x = -0.5 * Math.PI;//先将平面围绕x轴旋转90度,然后使用position属性来定义其在场景中的位置 plane.position.x = 15; plane.position.y = 0; plane.position.z = 0; @@ -57,7 +57,7 @@ // create a cube var cubeGeometry = new THREE.BoxGeometry(4, 4, 4); - var cubeMaterial = new THREE.MeshBasicMaterial({color: 0xff0000, wireframe: true}); + var cubeMaterial = new THREE.MeshBasicMaterial({color: 0xff0000, wireframe: true});//将线框(wireframe)属性设置为true,这样物体就不会被渲染为实体物体 var cube = new THREE.Mesh(cubeGeometry, cubeMaterial); // position the cube @@ -81,20 +81,20 @@ // add the sphere to the scene scene.add(sphere); - // position and point the camera to the center of the scene + //摄像机将决定哪些东西会被渲染到场景中 position and point the camera to the center of the scene camera.position.x = -30; camera.position.y = 40; camera.position.z = 30; - camera.lookAt(scene.position); + camera.lookAt(scene.position);//用lookAt方法指向场景的中心,默认状态下摄像机是指向(0,0,0)位置 - // add the output of the renderer to the html element + //将渲染的结果添加到HTML框架的