-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathbasic_orbit.js
26 lines (21 loc) · 918 Bytes
/
basic_orbit.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
import * as THREE from "https://cdn.skypack.dev/[email protected]/build/three.module.js";
export class BasicOrbit{
constructor(scene, radiusA, radiusB, positionX, positionY, color, rotation=0){
this.path = new THREE.EllipseCurve(positionX, positionY, radiusA, radiusB, 0, 2*Math.PI, false, rotation);
this.path.arcLengthDivisions = 8000;
this.points = this.path.getPoints(8000);
const geometry = new THREE.BufferGeometry().setFromPoints(this.points);
const material = new THREE.LineBasicMaterial({ color: color });
this.originalColor = color
this.orbitLine = new THREE.Line(geometry, material);
this.orbitLine.rotateX(Math.PI/2 + rotation);
this.orbitLine.renderOrder = 1000;
scene.add(this.orbitLine);
}
getPoint(t, vector) {
this.path.getPoint(t, vector);
}
getLine() {
return this.orbitLine
}
}