欢迎您访问程序员文章站本站旨在为大家提供分享程序员计算机编程知识!
您现在的位置是: 首页

平面直角坐标

程序员文章站 2022-03-02 11:54:30
...

平面直角坐标


更多有趣示例 尽在 知屋安砖社区

示例

平面直角坐标

HTML

<!DOCTYPE html>


<html>
	<title>Threejs</title>
	<body>
	</body>
</html>

CSS

body {
	margin: 0;
	overflow: hidden;
}

JS

function init() {
	const scene = new THREE.Scene();
	const camera = new THREE.PerspectiveCamera(45, window.innerWidth / window.innerHeight, 0.1, 1000);
	camera.position.set(0, 0, 10);
  camera.lookAt(0, 0, 0);
	const renderer = new THREE.WebGLRenderer();
	
	const axes = new THREE.AxesHelper(5);
	scene.add(axes);
	
	// 输入代码
	
	
	document.body.appendChild(renderer.domElement);
	function resize() {
		camera.aspect = window.innerWidth / window.innerHeight;
		camera.updateProjectionMatrix();
		renderer.setSize(window.innerWidth, window.innerHeight);
	}
	window.addEventListener('resize', resize);
	resize();
	function renderScene() {
		requestAnimationFrame(renderScene);
		renderer.render(scene, camera);
	}
	renderScene();
}


window.onload = init;