合并参数减少命名
This commit is contained in:
19
index.html
19
index.html
@@ -22,22 +22,23 @@
|
|||||||
document.body.appendChild(renderer.domElement);
|
document.body.appendChild(renderer.domElement);
|
||||||
|
|
||||||
// 2. 添加立方体
|
// 2. 添加立方体
|
||||||
const geometry = new THREE.BoxGeometry(1, 1, 1);
|
const cube = new THREE.Mesh(
|
||||||
const material = new THREE.MeshStandardMaterial({ color: 0xff0000, roughness: 0.5, metalness: 0.8 }); // 红色,中等粗糙度,高金属感
|
new THREE.BoxGeometry(1, 1, 1),
|
||||||
const cube = new THREE.Mesh(geometry, material);
|
new THREE.MeshStandardMaterial({ color: 0xff0000, roughness: 0.5, metalness: 0.8 }) // 红色,中等粗糙度,高金属感
|
||||||
|
);
|
||||||
scene.add(cube);
|
scene.add(cube);
|
||||||
|
|
||||||
// 添加地面
|
// 添加地面
|
||||||
const planeGeometry = new THREE.PlaneGeometry(10, 10); // 地面大小
|
const plane = new THREE.Mesh(
|
||||||
const planeMaterial = new THREE.MeshStandardMaterial({ color: 0x808080, roughness: 0.5, metalness: 0.8 }); // 红色,中等粗糙度,高金属感
|
new THREE.PlaneGeometry(10, 10), // 地面大小
|
||||||
const plane = new THREE.Mesh(planeGeometry, planeMaterial);
|
new THREE.MeshStandardMaterial({ color: 0x808080, roughness: 0.5, metalness: 0.8 }) // 红色,中等粗糙度,高金属感
|
||||||
|
);
|
||||||
plane.rotation.x = -Math.PI / 2; // 旋转地面,使其水平
|
plane.rotation.x = -Math.PI / 2; // 旋转地面,使其水平
|
||||||
plane.position.y = -1; // 将地面放置在立方体下方
|
plane.position.y = -1; // 将地面放置在立方体下方
|
||||||
scene.add(plane);
|
scene.add(plane);
|
||||||
|
|
||||||
// 添加光源
|
// 添加光源
|
||||||
const ambientLight = new THREE.AmbientLight(0x404040, 1); // 环境光,柔和的白光
|
scene.add(new THREE.AmbientLight(0x404040, 1)); // 环境光,柔和的白光
|
||||||
scene.add(ambientLight);
|
|
||||||
const directionalLight = new THREE.DirectionalLight(0xffffff, 0.8); // 平行光
|
const directionalLight = new THREE.DirectionalLight(0xffffff, 0.8); // 平行光
|
||||||
directionalLight.position.set(5, 5, 5); // 设置光源位置
|
directionalLight.position.set(5, 5, 5); // 设置光源位置
|
||||||
scene.add(directionalLight);
|
scene.add(directionalLight);
|
||||||
|
Reference in New Issue
Block a user