Давайте использовать этот компонент в качестве примера:
var THREE = window.THREE;
var AFRAME = window.AFRAME;
AFRAME.registerComponent("stalker", {
schema: { targetId: { type: "string", default: "camera" }, flip: { type: "boolean", default: false } },
update: function () {
this.target = !!document.getElementById(this.data.targetId) ? document.getElementById(this.data.targetId) : document.getElementById("camera");
},
tick: function() {
let targetDirection = this.target.object3D.getWorldPosition(new THREE.Vector3());
let oppositeDirection = new THREE.Vector3().subVectors(this.el.object3D.getWorldPosition(new THREE.Vector3()), this.target.object3D.getWorldPosition(new THREE.Vector3())).add(this.el.object3D.getWorldPosition(new THREE.Vector3()))
this.data.flip ? this.el.object3D.lookAt(oppositeDirection) : this.el.object3D.lookAt(targetDirection);
}
});
Как будет выглядеть документация по этому компоненту?