[英]Accessing and changing the renderer component properties in <a-scene>
下面是我正在使用的 A-Frame 中的代碼片段。 我希望使用 Javascript 中的條件語句訪問和操作渲染器組件的 maxCanvasWidth 和 maxCanvasHeight 屬性。 我不知道該怎么做。
<a-scene renderer ="antialias: true;
colorManagement: true;`
sortObjects: true;
physicallyCorrectLights: true;
maxCanvasWidth: 1920;
maxCanvasHeight: 1920;"></a-scene>
Example pseudo code of what I wish to implement:
<script>
var update = document.queryselector('a-scene');
if(fps < 60){
update.maxCanvasWidth = 800;
update.maxCanvasHeight = 800; }
</script>
renderer
是場景元素的一個屬性,因此您可以使用setAttribute
。 具體參考更新多屬性組件數據的文檔。
例如
const scene = document.querySelector('a-scene');
scene.setAttribute('renderer', 'maxCanvasWidth', 800);
實際上,我能夠弄清楚:
sceneEl = document.querySelector('a-scene');
sceneEl.maxCanvasSize = {height: , width: };
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.