0

我正在尝试编写一个 AFrame 组件来检查对象的旋转。但是,我不确定如何编写 if 语句进行检查。

我已经知道旋转属性返回一个集合中的 x,y,z。但是我不确定如何检查它。

var rotation = document.querySelector('#checkItem').getAttribute('rotation');

if (rotation === {x: 0, y: 90, z: 00}) {
   document.querySelector('#key').setAttribute('visible');
}


4

1 回答 1

0

在 JS 中,您必须检查各个属性:

if (rotation.x === 0 && rotation.y === 90 && rotation.z === 0) { ... }
于 2019-05-12T05:44:20.347 回答