在做Three.js开发的时候,它本身是不显示光源的,这就很难受,往往加了光源,找不到它放置的位置。
three.js本身不显示光源,可以通过其他方式显示,在光源的防止位置上加一个球即可
function createLightHelper(light) { const geometry = new THREE.BoxGeometry(0.1, 0.1, 0.1); const material = new THREE.MeshBasicMaterial({ color: 0xff0000, wireframe: true }); const helper = new THREE.Mesh(geometry, material); helper.position.copy(light.position); scene.add(helper); return helper;
} const light = new THREE.PointLight(0xffffff, 1, 100);
light.position.set(0, 10, 0);
scene.add(light); const lightHelper = createLightHelper(light);