Skip to content
Snippets Groups Projects
Unverified Commit fec321a5 authored by Kevin Lee's avatar Kevin Lee Committed by GitHub
Browse files

Merge pull request #41 from mozilla/feature/spawn_positions

update spawn positions
parents d31150ee ec715434
No related branches found
No related tags found
No related merge requests found
AFRAME.registerComponent("spawn-controller", {
schema: {
radius: { type: "number", default: 1 }
},
init() {
const el = this.el;
const center = el.getAttribute("position");
const angleRad = Math.random() * 2 * Math.PI;
const circlePoint = this.getPointOnCircle(this.data.radius, angleRad);
const worldPoint = {
x: circlePoint.x + center.x,
y: center.y,
z: circlePoint.z + center.z
};
el.setAttribute("position", worldPoint);
const angleDeg = angleRad * THREE.Math.RAD2DEG;
const angleToCenter = -1 * angleDeg + 90;
el.setAttribute("rotation", { x: 0, y: angleToCenter, z: 0 });
},
getPointOnCircle(radius, angleRad) {
const x = Math.cos(angleRad) * radius;
const z = Math.sin(angleRad) * radius;
return { x: x, z: z };
}
});
......@@ -23,6 +23,7 @@ import "./components/split-axis-events";
import "./components/networked-video-player";
import "./components/offset-relative-to";
import "./components/cached-gltf-model";
import "./components/spawn-controller";
import "./systems/personal-space-bubble";
import registerNetworkScheams from "./network-schemas";
......
......@@ -119,6 +119,7 @@
personal-space-bubble
look-controls
networked="template: #head-template; showLocalTemplate: false;"
spawn-controller="radius: 4"
></a-entity>
<a-entity
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment