const stats = new Stats();
document.getElementById('test').appendChild(stats.domElement)
console.log('three', THREE.Scene);
const scene = new THREE.Scene();
// box接收6个参数,x,y,z,
const geometry = new THREE.BoxGeometry(50, 50, 50);
const material = new THREE.MeshLambertMaterial({ color: 0x00ff00,side : THREE.DoubleSide });
const mesh = new THREE.Mesh(geometry, material);
scene.add(mesh)
// 实例化相机,PerspectiveCamera\OrthographicCamera 透视相机加正交相机
const camera = new THREE.PerspectiveCamera(50,800/600,1,3500);
camera.position.set(292, 223, 185);
// 相机对着物体
camera.lookAt(mesh.position);
// 辅助线
const axesHelper = new THREE.AxesHelper(100);
scene.add(axesHelper)
const light = new THREE.PointLight(0xffffff,1.0,4500)
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);
})
用的MeshLambertMaterial兰伯特材质加点光源,但是却无法显示出来,求帮忙看下,谢谢!
相似问题