thrrejs引用PointLight,却没有效果,求帮忙看下,用的mesh材质也没问题,页面也能渲染模型,移动点光源的坐标也没用
import * as THREE from 'three'
import { OrbitControls } from 'three/examples/jsm/controls/OrbitControls'
const init = () => {
console.log('three', THREE.Scene);
const scene = new THREE.Scene();
// box接收6个参数,x,y,z,
const geometry = new THREE.BoxGeometry(50, 50, 50);
// 创建材质对象,加16进制颜色
const material = new THREE.MeshPhongMaterial({ color: 0x00ff00 });
const mesh = new THREE.Mesh(geometry, material);
mesh.receiveShadow = true;
scene.add(mesh)
// 实例化相机,PerspectiveCamera\OrthographicCamera 透视相机加正交相机
// param: fav-上下角,aspect宽高比,near,far
const camera = new THREE.PerspectiveCamera(50,800/600,1,3500);
camera.position.set(200, 200, 200)
// 相机对着物体
camera.lookAt(mesh.position);
// 辅助线
const axesHelper = new THREE.AxesHelper(100);
scene.add(axesHelper)
const light = new THREE.PointLight(0xffffff,1,3500)
light.position.set(110,50,0)
scene.add(light)
const lightHelp = new THREE.PointLightHelper(light,10)
scene.add(lightHelp)
// 渲染器
const renderer = new THREE.WebGLRenderer();
renderer.setSize(800, 600);
renderer.render(scene, camera);
// html插入canvas渲染3d
let containers = document.getElementById('containers');
containers.appendChild(renderer.domElement)
// controls 相机控件
const controls = new OrbitControls(camera, renderer.domElement)
controls.addEventListener('change',()=>{
renderer.render(scene, camera);
})
}
setTimeout(()=>{
init()
},500)