|
@@ -1,8 +1,9 @@
|
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 } from "three";
|
|
3
|
+import { Object3D, Mesh, TextureLoader, HemisphereLight, Color, AmbientLight, PlaneBufferGeometry, MeshPhongMaterial, Vector3 } from "three";
|
4
|
4
|
|
5
|
5
|
import { GameController } from "./controller"
|
|
6
|
+import { OrbitNavigator, KeyPoint } from "./navigator";
|
6
|
7
|
|
7
|
8
|
export class ReeGame {
|
8
|
9
|
|
|
@@ -90,9 +91,18 @@ export class ReeGame {
|
90
|
91
|
}
|
91
|
92
|
|
92
|
93
|
static setUpdate(obj: Object3D, fn: Function) {
|
|
94
|
+ let v = fn;
|
|
95
|
+ if ("update" in obj && (typeof obj["update"] == "function")) {
|
|
96
|
+ var f: Function = obj["update"];
|
|
97
|
+ v = () => {
|
|
98
|
+ f.call(obj, obj);
|
|
99
|
+ fn.call(obj, obj);
|
|
100
|
+ };
|
|
101
|
+ }
|
|
102
|
+
|
93
|
103
|
Object.defineProperty(obj, "update", {
|
94
|
104
|
writable: true,
|
95
|
|
- value: fn
|
|
105
|
+ value: v
|
96
|
106
|
});
|
97
|
107
|
}
|
98
|
108
|
|
|
@@ -103,8 +113,6 @@ export class ReeGame {
|
103
|
113
|
loadScene(callback: Function) {
|
104
|
114
|
|
105
|
115
|
this.gltfLoader.load("./scenes/campus/Unity2GLTF.gltf", gltf => {
|
106
|
|
- console.log(gltf);
|
107
|
|
-
|
108
|
116
|
this.scene.add(gltf.scene);
|
109
|
117
|
this.scene.background = new THREE.Color('rgb(191,196,234)');
|
110
|
118
|
//添加一个地板
|
|
@@ -124,6 +132,12 @@ export class ReeGame {
|
124
|
132
|
|
125
|
133
|
let game = new ReeGame();
|
126
|
134
|
game.loadScene(() => {
|
127
|
|
-
|
|
135
|
+ let points: KeyPoint[] = [];
|
|
136
|
+ points.push(new KeyPoint(new Vector3(0, 0, 0)));
|
|
137
|
+ points.push(new KeyPoint(new Vector3(0, 4, 0)));
|
|
138
|
+ points.push(new KeyPoint(new Vector3(0, 0, 4)));
|
|
139
|
+ points.push(new KeyPoint(new Vector3(4, 0, 0)));
|
|
140
|
+ let orbit: OrbitNavigator = new OrbitNavigator(game.camera, points);
|
|
141
|
+ orbit.start();
|
128
|
142
|
});
|
129
|
143
|
|