大小不变的 Three.js 对象 [英] Three.js object with constant size

查看:55
本文介绍了大小不变的 Three.js 对象的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在开发一个绘图程序,我需要的是一个具有恒定大小的 THREE.Object3D 元素 - 就像线条总是 1px.换句话说,我试图将一个大小始终与观众相同的对象放在舞台上(所以如果你靠近它,它的大小不会改变).THREE.Line 有类似的机制——它总是 1px 宽.我需要创建一个(或者也可能是其他形状).最好的方法是什么?

I'm working on a drawing program and what I need is a THREE.Object3D element that would have a constant size - just like the line has always 1px. In other words, I'm trying to put to the stage an object which size would be always the same to the viewer (so if you got closer to it, it's size wouldn't change). Similar mechanism is with THREE.Line - it's always 1px wide. I need to create a circle (or maybe other shapes also). What's the best way to do that?

推荐答案

听起来您需要使用正交相机 -- 例如

Sounds like you need to use an orthographic camera -- e.g.

var camOrtho = new THREE.OrthographicCamera(-width/2, width/2, height/2,-height/2, -100,100);

如果宽度"和高度"是画布的大小.

if "width" and "heaight" are the size of your canvas.

只需使用它而不是典型的透视相机.

Just use that rather than the typical persective camera.

这篇关于大小不变的 Three.js 对象的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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