场景
# Scene (opens new window)
# background (opens new window)
场景的背景,可以是Color (opens new window)、Texture (opens new window)、CubeTexture (opens new window)
# environment (opens new window)
给场景中所有物体添加默认贴图
// 把材质的envMap去掉,添加scene.environment,效果相同
const sphereGeometry = new THREE.SphereBufferGeometry(1, 20, 20);
const material = new THREE.MeshStandardMaterial({
metalness: 0.7,
roughness: 0.1,
// envMap: envMapTexture,
});
const sphere = new THREE.Mesh(sphereGeometry, material);
scene.add(sphere);
// 给场景添加背景
scene.background = envMapTexture;
// // 给场景所有的物体添加默认的环境贴图
scene.environment = envMapTexture;
1
2
3
4
5
6
7
8
9
10
11
12
13
14
2
3
4
5
6
7
8
9
10
11
12
13
14
# traverse
遍历场景中所有物体(包括子物体)
# getObjectById
根据id查找物体
# getObjectByName
根据名称查找物体
编辑 (opens new window)
上次更新: 2022/11/02