简体   繁体   English

three.js更改分辨率

[英]three.js changing resolution

I have a question that may sound simply stupid and it's about resolution in THREE.js. 我有一个听起来可能很愚蠢的问题,它与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. 我对OpenGL及其周围的一些框架很熟悉,因此很明显,我终于对webGL感兴趣,因此对Three.js也很感兴趣。 I tried some simple demos and decided to write something on my own, but here's a problem: 我尝试了一些简单的演示,并决定自己编写一些东西,但这是一个问题:

How can i accomplish having canvas with size of 640x480 px, but rendering the 320x240px scene on it's full size? 我如何才能完成具有640x480像素大小的画布,但是在其全尺寸上渲染320x240px场景的情况?

For example just for performance, or more artistic/oldScholl look? 例如仅出于表演目的,还是更具艺术感/ oldScholl外观?

Thanks in advance. 提前致谢。

You can use CSS. 您可以使用CSS。 Set the canvas to 320x240px using html attributes or JavaScript, then use CSS to set it to 640x480px. 使用html属性或JavaScript将画布设置为320x240px,然后使用CSS将其设置为640x480px。 This should scale the canvas and its contents. 这应该缩放画布及其内容。

For example: 例如:

<canvas id="c" width="128" height="128"></canvas>
#c {
    width: 256px;
    height: 256px;
}

http://jsfiddle.net/jwy6a/ http://jsfiddle.net/jwy6a/

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM