'的语义是什么;this.object.position'在Three.JS's轨迹球

What is the semantic meaning of 'this.object.position' in Three.JS's trackball?

本文关键字:JS Three 轨迹球 this 语义 是什么 object position      更新时间:2023-09-26

我花了一些时间试图弄清楚这个.object.position在这个Trackball控件中应该代表什么:https://github.com/mrdoob/three.js/blob/master/examples/js/controls/TrackballControls.js

作者不仅保存了位置的原始值(用于重置目的),而且在每帧后位置发生变化(或不发生变化)时都会跟踪lastPosition。

... // the first half of the constructor
var lastPosition = new THREE.Vector3();
... // more initialization

// for reset
this.position0 = this.object.position.clone();

起初,我认为它代表相机的位置,但也有一个"this.eye"变量,所以这将是一个冲突。然后我认为这与绘图表面在DOM上的位置有关,但由于它是一个大小为3的向量,因此该理论也没有太大的分量。

我知道这可能是一个愚蠢的问题,但我真的很感激能朝着正确的方向前进。

感谢阅读

this.object.position是相机位置。(见注释)

CCD_ 2是从this.targetthis.object.position的矢量。目标是摄影机绕其旋转的点。

_eye.subVectors( _this.object.position, _this.target );

注意:这是假设相机是而不是另一个平移或旋转对象的子对象——在这种情况下,控件将无法正常工作。

three.js r.58