【问题标题】:What is the meaning of render.domElement, what this argument meant for?render.domElement 是什么意思,这个参数是什么意思?
【发布时间】:2019-07-20 07:35:11
【问题描述】:

我正在学习以一种深刻的方式操作three_js 代码。我面对最后一行,想知道最后一行是什么意思。在 MDN 上找不到任何参考资料。

var scene = new THREE.Scene(); // scene initialization
var camera = new THREE.PerspectiveCamera( 75, window.innerWidth / window.innerHeight, 0.1, 1000 ); // see syntax one line below
// syntax: .PerspectiveCamera(FOV, aspectRatio, nearClippingPlane, farClippingPlane);

var renderer = new THREE.WebGLRenderer(); // WebGLRenderer initialization 
renderer.setSize( window.innerWidth, window.innerHeight ); // render aspectRatio

document.body.appendChild( renderer.domElement );

将渲染器作为节点附加到 document.BODY 可能是 <canvas>

【问题讨论】:

    标签: javascript three.js


    【解决方案1】:

    renderer.domElement 指的是场景将被渲染的<canvas> 元素。
    它要么由渲染器自动生成,要么是您通过 THREE.WebGLRenderer 函数接受的参数对象传递给渲染器的画布。
    请参阅:Line 61Line 78WebGLRenderer

    所以最后一行只是将这个<canvas> 作为body 的子元素附加到您的html 页面中。原来如此。

    【讨论】:

      猜你喜欢
      • 2018-10-29
      • 2011-04-11
      • 2017-05-25
      • 1970-01-01
      • 1970-01-01
      • 2010-10-03
      • 2013-08-17
      • 2011-09-04
      相关资源
      最近更新 更多