首页
学习
活动
专区
工具
TVP
发布
社区首页 >问答首页 >threejs添加PointLight无效问题?

threejs添加PointLight无效问题?

提问于 2023-10-23 10:00:42
回答 0关注 0查看 266
代码语言:js
复制
	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);
	})

PointLight无效
PointLight无效

用的MeshLambertMaterial兰伯特材质加点光源,但是却无法显示出来,求帮忙看下,谢谢!

回答

和开发者交流更多问题细节吧,去 写回答
相关文章

相似问题

相关问答用户
领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档