我正在使用aframe-teleport-controls,我想知道追踪用户位置的最佳方式是什么。
我一直在寻找,我发现了两种方法。
1 - 我使用传送控制器的位置,这几乎就是用户的位置。
var teleportControls = el.closest('a-scene').querySelector('[teleport-controls]');
var worldPos = new THREE.Vector3();
worldPos.setFromMatrixPosition(teleportControls.object3D.matrixWorld);
console.log(worldPos);
2 - 我在场景中定义了一个相机元素,并使用了他的位置。
var teleportControls = el.closest('a-scene').querySelector('a-camera');
var worldPos = new THREE.Vector3();
worldPos.setFromMatrixPosition(teleportControls.object3D.matrixWorld);
console.log(worldPos);
我不确定这是一个好习惯,我怎么能听到用户改变他的位置?
感谢您阅读本文。
答案 0 :(得分:1)
当用户传送(在source here中找到)时,控制器元素(不是摄像机)将发出A selector's specificity is calculated as follows:
count 1 if the declaration is from is a 'style' attribute rather than a rule with a selector, 0 otherwise (= a) (In HTML, values of an element's "style" attribute are style sheet rules. These rules have no selectors, so a=1, b=0, c=0, and d=0.)
count the number of ID attributes in the selector (= b)
count the number of other attributes and pseudo-classes in the selector (= c)
count the number of element names and pseudo-elements in the selector (= d)
The specificity is based only on the form of the selector. In particular, a selector of the form "[id=p33]" is counted as an attribute selector (a=0, b=0, c=1, d=0), even if the id attribute is defined as an "ID" in the source document's DTD.
Concatenating the four numbers a-b-c-d (in a number system with a large base) gives the specificity.
事件。检测这些事件的最简单方法是在事件冒泡时监听场景元素。
Finally, sort by order specified: if two declarations have the same weight, origin and specificity, the latter specified wins. Declarations in imported style sheets are considered to be before any declarations in the style sheet itself.