I have a file written in three.js to output 3D objects to be controlled by leapmotion. The code doesn't output the objects centered in my screen, they are shifted to top right and only show almost 2 sides not 4 as it should.
我有一个用three.js编写的文件来输出由leapmotion控制的3D对象。代码不输出以我的屏幕为中心的对象,它们被移动到右上方,只显示几乎2个边而不是4个边。
Note the code won't output anything if it is not connected to leapmotion.
请注意,如果代码未连接到leapmotion,代码将不会输出任何内容。
Here is the source file. https://github.com/ellinoran/calderan/blob/master/index.html
这是源文件。 https://github.com/ellinoran/calderan/blob/master/index.html
I attached two images, one that shows how it shown in the browser and the other shows how it should be.
我附上了两张图片,一张显示它在浏览器中的显示方式,另一张显示它应该如何显示。
I am using the latest version of chrome and I run it through wamp server.
我正在使用最新版本的chrome,我通过wamp服务器运行它。
2 个解决方案
#1
0
I'm assuming you've successfully already created the scene, camera and the object rendering to the scene, you can achieve position the object to the center of the screen simple by using this small like of code:
我假设你已经成功地创建了场景,相机和对象渲染到场景,你可以通过使用这个小代码来实现将对象定位到屏幕中心的简单:
camera.lookAt(scene.position);
If doasn't work reply so I can look into the problem further
如果不能回复,那么我可以进一步研究这个问题
#2
0
Also by the way if your object is moving in anyway or repositioning then use the same code but with object name.position
顺便说一句,如果你的对象正在移动或重新定位,那么使用相同的代码,但使用对象name.position
camera.lookAt(objectName.position);
#1
0
I'm assuming you've successfully already created the scene, camera and the object rendering to the scene, you can achieve position the object to the center of the screen simple by using this small like of code:
我假设你已经成功地创建了场景,相机和对象渲染到场景,你可以通过使用这个小代码来实现将对象定位到屏幕中心的简单:
camera.lookAt(scene.position);
If doasn't work reply so I can look into the problem further
如果不能回复,那么我可以进一步研究这个问题
#2
0
Also by the way if your object is moving in anyway or repositioning then use the same code but with object name.position
顺便说一句,如果你的对象正在移动或重新定位,那么使用相同的代码,但使用对象name.position
camera.lookAt(objectName.position);