@yangyongtao/gaea 1.0.0 → 1.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +1 -1
- package/src/GaeaMethods.js +24 -2
package/package.json
CHANGED
package/src/GaeaMethods.js
CHANGED
|
@@ -48,6 +48,18 @@ function rgbToGaeaColor(rgb) {
|
|
|
48
48
|
}
|
|
49
49
|
|
|
50
50
|
|
|
51
|
+
// ==================== Gaea 检查 ====================
|
|
52
|
+
|
|
53
|
+
function checkGaea() {
|
|
54
|
+
const G = window.Gaea;
|
|
55
|
+
if (!G || !G.World || !G.World.Instance) {
|
|
56
|
+
console.warn('Gaea 尚未加载完毕,请确保在 Gaea 初始化之后再调用此方法');
|
|
57
|
+
return null;
|
|
58
|
+
}
|
|
59
|
+
return G;
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
|
|
51
63
|
// ==================== GaeaApp 类 ====================
|
|
52
64
|
|
|
53
65
|
import { Tween, Group, Easing } from '@tweenjs/tween.js';
|
|
@@ -94,7 +106,8 @@ export class GaeaApp {
|
|
|
94
106
|
return null;
|
|
95
107
|
}
|
|
96
108
|
|
|
97
|
-
const Gaea =
|
|
109
|
+
const Gaea = checkGaea();
|
|
110
|
+
if (!Gaea) return null;
|
|
98
111
|
const resName = 'pointIcon.res';
|
|
99
112
|
|
|
100
113
|
if (!this._pointIconLoaded) {
|
|
@@ -156,7 +169,8 @@ export class GaeaApp {
|
|
|
156
169
|
* @param {Object} opts - { height, step, duration, xrotation, lockEye, minZoom, maxZoom }
|
|
157
170
|
*/
|
|
158
171
|
async flyAlongPath(lineData, opts = {}) {
|
|
159
|
-
const Gaea =
|
|
172
|
+
const Gaea = checkGaea();
|
|
173
|
+
if (!Gaea) return Promise.reject(new Error('Gaea 未加载'));
|
|
160
174
|
const {
|
|
161
175
|
height = 150, step = 1000, duration = 20,
|
|
162
176
|
xrotation = -30, lockEye = true, minZoom = 0, maxZoom = 400
|
|
@@ -264,6 +278,10 @@ export class GaeaApp {
|
|
|
264
278
|
_initWeather() {
|
|
265
279
|
if (this._weatherInited) return;
|
|
266
280
|
const Gaea = window.Gaea;
|
|
281
|
+
if (!Gaea || !Gaea.World || !Gaea.World.Instance) {
|
|
282
|
+
console.warn('Gaea 尚未加载完毕,无法初始化天气');
|
|
283
|
+
return;
|
|
284
|
+
}
|
|
267
285
|
this._fullScreenQuad = Gaea.World.Instance.FullScreenQuad;
|
|
268
286
|
this._sky = Gaea.MeshInstance.ConvertBy(Gaea.World.Instance.GetNode('Sky'));
|
|
269
287
|
this._sun = Gaea.Sun.ConvertBy(Gaea.World.Instance.GetNode('Sun'));
|
|
@@ -335,6 +353,10 @@ export class GaeaApp {
|
|
|
335
353
|
/** 初始化基础环境(关闭默认雾、设置默认光照等) */
|
|
336
354
|
initDefaultEnvironment() {
|
|
337
355
|
const Gaea = window.Gaea;
|
|
356
|
+
if (!Gaea || !Gaea.World || !Gaea.World.Instance) {
|
|
357
|
+
console.warn('Gaea 尚未加载完毕,请确保在 Gaea 初始化之后调用此方法');
|
|
358
|
+
return;
|
|
359
|
+
}
|
|
338
360
|
|
|
339
361
|
// 关闭默认雾
|
|
340
362
|
const fogEnv = Gaea.Environment.ConvertBy(
|