使用 DeviceOrientationControls 旋转对象而不是相机 [英] Rotating object instead of camera with DeviceOrientationControls

查看:57
本文介绍了使用 DeviceOrientationControls 旋转对象而不是相机的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

所以我使用来自 THREE.js 的 DeviceOrientationControls 在 VR 中旋转对象,类似于 google cardboards 应用程序在展览体验中的作用.通过将 THREE.DeviceOrientationControls(camera) 中的camera"替换为scene",我已经部分成功地做到了这一点.但是,场景中还包含有 EdgesHelper 帮助的立方体周围的边.

So I am using DeviceOrientationControls from THREE.js to rotate the object around in VR, similar to how google cardboards app does in the exhibit experience. I have partially succeeded in doing this by replacing "camera" in THREE.DeviceOrientationControls(camera) with "scene". However, the scene also contains edges around the cube with the help EdgesHelper.

var edge = new THREE.EdgesHelper(mesh, 0x000000);

var edges = new THREE.EdgesHelper(mesh, 0x000000);

发生的情况是边缘与物体的其余部分是分开的,所以当我在 VR 中使用它时,物体像它应该移动的那样移动,但物体的边缘(轮廓)移动不同.对解决此问题有帮助吗?

What happens is the Edges are seperate from the rest of the object, so when I use it in VR, the object moves like it should, but the edges(outline) of the object move differently. Any help with resolving this?

推荐答案

您可以像这样自己实现EdgesHelper":

You can implement an "EdgesHelper" yourself like so:

var geometry = new THREE.EdgesGeometry( mesh.geometry );
var material = new THREE.LineBasicMaterial( { color: 0xffff00, linewidth: 2 } );
var edges = new THREE.LineSegments( geometry, material );
mesh.add( edges );

three.js r.73

three.js r.73

这篇关于使用 DeviceOrientationControls 旋转对象而不是相机的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆