-
Notifications
You must be signed in to change notification settings - Fork 2
/
satellite_class.js
53 lines (44 loc) · 1.31 KB
/
satellite_class.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
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
import * as THREE from "https://cdn.skypack.dev/three@0.129.0/build/three.module.js";
import { GLTFLoader } from "https://cdn.skypack.dev/three@0.129.0/examples/jsm/loaders/GLTFLoader.js";
export class Satellite{
constructor(vel, acc, scale, resetPos, resetVel){
this.resetPos = resetPos
this.resetVel = resetVel
this.velocity = vel;
this.acc = acc;
this.scale = scale;
this.object = null;
this.view_target = new THREE.Object3D;
this.view_follow = new THREE.Object3D;
}
set scl(scale) {
this.scale = scale
this.object.scale.set(this.scale, this.scale, this.scale);
}
get scl() {
return this.scale
}
async loadModel(scene, modelPath){
const loader = new GLTFLoader();
const giltf = await loader.loadAsync( modelPath )
this.object = giltf.scene;
this.object.scale.set(this.scale, this.scale, this.scale);
scene.add(this.object)
}
get pos() {
return this.object.position
}
set pos(vec) {
this.object.position.x = vec.x
this.object.position.y = vec.y
this.object.position.z = vec.z
}
get vel() {
return this.velocity
}
set vel(vec) {
this.velocity.x = vec.x
this.velocity.y = vec.y
this.velocity.z = vec.z
}
}