|
@@ -1,6 +1,6 @@
|
1
|
1
|
import * as THREE from "three"
|
2
|
2
|
import { GLTFLoader } from 'three/examples/jsm/loaders/GLTFLoader'
|
3
|
|
-import { Object3D, Mesh, TextureLoader, HemisphereLight, Color, AmbientLight, PlaneBufferGeometry, MeshPhongMaterial, Vector3 } from "three";
|
|
3
|
+import { Object3D, Mesh, TextureLoader, HemisphereLight, Color, AmbientLight, PlaneBufferGeometry, MeshPhongMaterial, Vector3, Scene } from "three";
|
4
|
4
|
|
5
|
5
|
import { GameController } from "./controller"
|
6
|
6
|
import { OrbitNavigator, KeyPoint } from "./navigator";
|
|
@@ -27,6 +27,7 @@ export class ReeGame {
|
27
|
27
|
this.camera.position.z = 1;
|
28
|
28
|
|
29
|
29
|
this.scene = new THREE.Scene();
|
|
30
|
+ this.scene.add(this.camera);
|
30
|
31
|
|
31
|
32
|
this.light = new HemisphereLight(new Color(0XFFFFFF), new Color(0x000000), 1);
|
32
|
33
|
this.light.position.set(0, 15, 0);
|
|
@@ -57,9 +58,8 @@ export class ReeGame {
|
57
|
58
|
|
58
|
59
|
private updateObjects(obj: Object3D) {
|
59
|
60
|
|
60
|
|
- if ("update" in obj && (typeof obj["update"] == "function")) {
|
61
|
|
- var f: Function = obj["update"];
|
62
|
|
- f.call(obj, obj);
|
|
61
|
+ if (obj.userData.update && (typeof obj.userData.update == "function")) {
|
|
62
|
+ obj.userData.update.call(obj, obj);
|
63
|
63
|
}
|
64
|
64
|
|
65
|
65
|
if (obj.children && obj.children.length > 0) {
|
|
@@ -91,18 +91,15 @@ export class ReeGame {
|
91
|
91
|
|
92
|
92
|
static setUpdate(obj: Object3D, fn: Function) {
|
93
|
93
|
let v = fn;
|
94
|
|
- if ("update" in obj && (typeof obj["update"] == "function")) {
|
95
|
|
- var f: Function = obj["update"];
|
|
94
|
+
|
|
95
|
+ if (obj.userData.update && (typeof obj.userData.update == "function")) {
|
|
96
|
+ var f: Function = obj.userData.update;
|
96
|
97
|
v = () => {
|
97
|
98
|
f.call(obj, obj);
|
98
|
99
|
fn.call(obj, obj);
|
99
|
100
|
};
|
100
|
101
|
}
|
101
|
|
-
|
102
|
|
- Object.defineProperty(obj, "update", {
|
103
|
|
- writable: true,
|
104
|
|
- value: v
|
105
|
|
- });
|
|
102
|
+ obj.userData.update = v;
|
106
|
103
|
}
|
107
|
104
|
|
108
|
105
|
/**
|
|
@@ -131,12 +128,16 @@ export class ReeGame {
|
131
|
128
|
|
132
|
129
|
let game = new ReeGame();
|
133
|
130
|
game.loadScene(() => {
|
|
131
|
+
|
134
|
132
|
let points: KeyPoint[] = [];
|
135
|
|
- points.push(new KeyPoint(new Vector3(0, 0, 0)));
|
136
|
|
- points.push(new KeyPoint(new Vector3(0, 4, 0)));
|
137
|
|
- points.push(new KeyPoint(new Vector3(0, 0, 4)));
|
138
|
|
- points.push(new KeyPoint(new Vector3(4, 0, 0)));
|
139
|
|
- let orbit: OrbitNavigator = new OrbitNavigator(game.camera, points);
|
140
|
|
- orbit.start();
|
|
133
|
+ points.push(new KeyPoint(new Vector3(2, 2, 2), new Vector3(0, 2, 0)));
|
|
134
|
+ points.push(new KeyPoint(new Vector3(-20, 15, -20), new Vector3(0, 2, 0)));
|
|
135
|
+ points.push(new KeyPoint(new Vector3(-20, 15, 20), new Vector3(0, 2, 0)));
|
|
136
|
+ points.push(new KeyPoint(new Vector3(20, 15, 20), new Vector3(0, 2, 0)));
|
|
137
|
+ points.push(new KeyPoint(new Vector3(20, 20, -20),new Vector3(0, 2, 0)));
|
|
138
|
+ points.push(new KeyPoint(new Vector3(2, 2, 2)));
|
|
139
|
+ let nav: OrbitNavigator = new OrbitNavigator(game.camera, points, 200, true);
|
|
140
|
+
|
|
141
|
+ nav.start();
|
141
|
142
|
});
|
142
|
143
|
|