three.js改变分辨率 [英] three.js changing resolution

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

问题描述

我有一个问题可能听起来很愚蠢,这是关于THREE.js的解决方案。
我很常见OpenGL和很少的框架,所以很明显我终于对webGL感兴趣,因此感兴趣的是Three.js。我尝试了一些简单的演示,并决定自己写一些东西,但这里有一个问题:

I have a question that may sound simply stupid and it's about resolution in THREE.js. I am common with OpenGL and few frameworks around it, so it's pretty obvious that i finally got interested with webGL and therefore Three.js. I tried some simple demos and decided to write something on my own, but here's a problem:

我怎样才能完成尺寸为640x480像素的画布,但渲染320x240px它的全尺寸?

How can i accomplish having canvas with size of 640x480 px, but rendering the 320x240px scene on it's full size?

例如,只是为了表现,还是更多艺术/旧的样子?

For example just for performance, or more artistic/oldScholl look?

提前致谢。

推荐答案

您可以使用CSS。使用html属性或JavaScript将画布设置为320x240px,然后使用CSS将其设置为640x480px。这应该缩放画布及其内容。

You can use CSS. Set the canvas to 320x240px using html attributes or JavaScript, then use CSS to set it to 640x480px. This should scale the canvas and its contents.

例如:

<canvas id="c" width="128" height="128"></canvas>



#c {
    width: 256px;
    height: 256px;
}

http://jsfiddle.net/jwy6a/

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

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