【问题标题】:AFRAME: How to use Three's render property setPixelRatio on A-Frame?AFRAME:如何在 A-Frame 上使用 Three 的渲染属性 setPixelRatio?
【发布时间】:2022-06-14 22:36:10
【问题描述】:

Three.js 有一个渲染器属性 setPixelRatio,我想将其设置为 2。

查看A-Frame docs,没有看到对应的属性。

有谁知道将它实现到 A-Frame 项目中的方法吗?

【问题讨论】:

    标签: three.js aframe


    【解决方案1】:

    您需要一个自定义组件。只需将其添加到您的脑海中(或将其放在单独的 JS 文件中,然后引用)。

        <script>
          AFRAME.registerComponent('pixel-ratio', {
            schema: {
              type: 'number'
            },
            update: function() {
               this.el.sceneEl.renderer.setPixelRatio(this.data)
            }
          })
        </script>
    

    然后像这样声明你的&lt;a-scene&gt;

    <a-scene pixel-ratio="2">
    </a-scene>
    

    在 Three.js 文档中,我没有看到关于何时可以调用 setPixelRation 的任何限制,所以这应该可以正常工作。

    您还可以随时通过更改a-scene上的pixel-ratio属性来调整像素比例

    此处的故障示例: https://glitch.com/edit/#!/set-pixel-ratio

    【讨论】:

      猜你喜欢
      • 2018-05-04
      • 1970-01-01
      • 2016-07-17
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2017-11-29
      • 1970-01-01
      相关资源
      最近更新 更多