基于threejs开发自动驾驶模拟系统视图计算

 演示地址:产品列表 https://threelab.cn/pro/#/carCarme

        从事自动驾驶开发也有几年了,一直在做基于webgl+three三维引擎开发。

在工作中,经常会遇到车辆视角问题,比如 正视角,侧视角,后世界等等,这样来回切换,让展示的效果更炫酷一些。

通过数学计算和three相关的接口结合,计算相关的角度问题。

initSceneMain() {
			this.scene = new THREE.Scene();
			this.camera = new THREE.PerspectiveCamera(75, window.innerWidth / window.innerHeight, 1, 10000);

			this.renderer = new THREE.WebGLRenderer({ antialias: true });

			this.renderer.toneMapping = THREE.ACESFilmicToneMapping;
			this.renderer.toneMappingExposure = 0.85;
			this.renderer.useLegacyLights = false;

			this.renderer.setPixelRatio(window.devicePixelRatio);
			this.renderer.setSize(window.innerWidth, window.innerHeight);
			// document.body.appendChild(this.renderer.domElement);
			document.getElementById("map").appendChild(this.renderer.domElement);

			this.controls = new OrbitControls(this.camera, this.renderer.domElement);



			const ambientLight = new THREE.AmbientLight(0xcccccc);
			this.scene.add(ambientLight);
			var directionalLight = new THREE.DirectionalLight(0xffffff, 1);
			directionalLight.position.set(0, 0, 1000);
			this.scene.add(directionalLight);


			this.camera.up.set(0, 0, 1);
			this.camera.position.z = 5;


			this.controls.addEventListener("start", () => {
				this.isMove = true;
			});
			this.controls.addEventListener("end", () => {
				this.isMove = false;
			});

		},

点击运行后的效果

侧视图

 

 

 

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值