From cc1e0b2053e7ba6579bbb7e79181df561248d53c Mon Sep 17 00:00:00 2001 From: Last <253458536@qq.com> Date: Tue, 6 May 2025 14:10:16 +0800 Subject: [PATCH] =?UTF-8?q?=E5=90=88=E5=B9=B6=E5=8F=82=E6=95=B0=E5=87=8F?= =?UTF-8?q?=E5=B0=91=E5=91=BD=E5=90=8D?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- index.html | 19 ++++++++++--------- 1 file changed, 10 insertions(+), 9 deletions(-) diff --git a/index.html b/index.html index 961397b..66eff7f 100644 --- a/index.html +++ b/index.html @@ -22,22 +22,23 @@ document.body.appendChild(renderer.domElement); // 2. 添加立方体 - const geometry = new THREE.BoxGeometry(1, 1, 1); - const material = new THREE.MeshStandardMaterial({ color: 0xff0000, roughness: 0.5, metalness: 0.8 }); // 红色,中等粗糙度,高金属感 - const cube = new THREE.Mesh(geometry, material); + const cube = new THREE.Mesh( + new THREE.BoxGeometry(1, 1, 1), + new THREE.MeshStandardMaterial({ color: 0xff0000, roughness: 0.5, metalness: 0.8 }) // 红色,中等粗糙度,高金属感 + ); scene.add(cube); // 添加地面 - const planeGeometry = new THREE.PlaneGeometry(10, 10); // 地面大小 - const planeMaterial = new THREE.MeshStandardMaterial({ color: 0x808080, roughness: 0.5, metalness: 0.8 }); // 红色,中等粗糙度,高金属感 - const plane = new THREE.Mesh(planeGeometry, planeMaterial); + const plane = new THREE.Mesh( + new THREE.PlaneGeometry(10, 10), // 地面大小 + new THREE.MeshStandardMaterial({ color: 0x808080, roughness: 0.5, metalness: 0.8 }) // 红色,中等粗糙度,高金属感 + ); plane.rotation.x = -Math.PI / 2; // 旋转地面,使其水平 - plane.position.y = -1; // 将地面放置在立方体下方 + plane.position.y = -1; // 将地面放置在立方体下方 scene.add(plane); // 添加光源 - const ambientLight = new THREE.AmbientLight(0x404040, 1); // 环境光,柔和的白光 - scene.add(ambientLight); + scene.add(new THREE.AmbientLight(0x404040, 1)); // 环境光,柔和的白光 const directionalLight = new THREE.DirectionalLight(0xffffff, 0.8); // 平行光 directionalLight.position.set(5, 5, 5); // 设置光源位置 scene.add(directionalLight);