@yangyongtao/gaea 1.0.3 → 1.1.0

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.
Files changed (137) hide show
  1. package/README.md +158 -67
  2. package/package.json +28 -7
  3. package/public/Gaea.apple-touch-icon.png +0 -0
  4. package/public/Gaea.apple-touch-icon.png.import +35 -0
  5. package/public/Gaea.audio.worklet.js +211 -0
  6. package/public/Gaea.html +245 -0
  7. package/public/Gaea.icon.png +0 -0
  8. package/public/Gaea.icon.png.import +35 -0
  9. package/public/Gaea.js +782 -0
  10. package/public/Gaea.png +0 -0
  11. package/public/Gaea.png.import +35 -0
  12. package/public/Gaea.worker.js +1 -0
  13. package/public/GaeaApp.html +275 -0
  14. package/public/GaeaMethods.js +4342 -0
  15. package/public/GaeaModule.html +276 -0
  16. package/public/config.js +76 -0
  17. package/public/constants.js +185 -0
  18. package/public/favicon.ico +0 -0
  19. package/public/image/1.png +0 -0
  20. package/public/image/12-min-min.gif +0 -0
  21. package/public/image/3.png +0 -0
  22. package/public/image/labelImg//345/217/263/350/276/271.png +0 -0
  23. package/public/image/labelImg//345/267/246/350/276/271.png +0 -0
  24. package/public/image/labelImg//346/260/264/344/275/215.png +0 -0
  25. package/public/image/screenIcon//345/205/266/344/273/226.png +0 -0
  26. package/public/image/screenIcon//345/256/211/345/205/250/347/233/221/346/265/213/350/201/232/345/220/210-/347/272/242.png +0 -0
  27. package/public/image/screenIcon//345/256/211/345/205/250/347/233/221/346/265/213/350/201/232/345/220/210-/347/273/277.png +0 -0
  28. package/public/image/screenIcon//346/212/242/351/231/251/345/215/225/344/275/215.png +0 -0
  29. package/public/image/screenIcon//346/226/255/351/235/242.png +0 -0
  30. package/public/image/screenIcon//346/227/240/344/272/272/346/234/272.png +0 -0
  31. package/public/image/screenIcon//346/227/240/344/272/272/346/234/272/345/237/272/345/234/260.png +0 -0
  32. package/public/image/screenIcon//346/260/264/345/272/223/347/253/231.png +0 -0
  33. package/public/image/screenIcon//346/260/264/346/226/207/346/265/213/347/253/231.png +0 -0
  34. package/public/image/screenIcon//346/260/264/351/227/270.png +0 -0
  35. package/public/image/screenIcon//346/262/263/351/201/223/347/253/231-/346/227/240/346/225/260/346/215/256.png +0 -0
  36. package/public/image/screenIcon//346/262/263/351/201/223/347/253/231-/346/255/243/345/270/270.png +0 -0
  37. package/public/image/screenIcon//346/262/263/351/201/223/347/253/231-/350/266/205/344/277/235.png +0 -0
  38. package/public/image/screenIcon//346/262/263/351/201/223/347/253/231-/350/266/205/350/255/246.png +0 -0
  39. package/public/image/screenIcon//346/263/265/347/253/231-/347/201/260.png +0 -0
  40. package/public/image/screenIcon//346/263/265/347/253/231-/347/273/277.png +0 -0
  41. package/public/image/screenIcon//346/265/201/351/207/217/346/265/213/347/253/231.png +0 -0
  42. package/public/image/screenIcon//346/265/267/345/241/230-1/347/272/247.png +0 -0
  43. package/public/image/screenIcon//346/265/267/345/241/230-2/347/272/247.png +0 -0
  44. package/public/image/screenIcon//346/265/267/345/241/230-3/347/272/247.png +0 -0
  45. package/public/image/screenIcon//346/265/267/345/241/230-4/347/272/247.png +0 -0
  46. package/public/image/screenIcon//346/265/267/345/241/230-5/347/272/247.png +0 -0
  47. package/public/image/screenIcon//346/265/267/345/241/230-/346/251/231.png +0 -0
  48. package/public/image/screenIcon//346/265/267/345/241/230-/347/272/242.png +0 -0
  49. package/public/image/screenIcon//346/265/267/345/241/230-/347/273/277.png +0 -0
  50. package/public/image/screenIcon//346/265/267/345/241/230-/350/247/204/346/250/241/344/273/245/344/270/213.png +0 -0
  51. package/public/image/screenIcon//346/265/267/345/241/230-/351/273/204.png +0 -0
  52. package/public/image/screenIcon//346/265/267/345/241/230.png +0 -0
  53. package/public/image/screenIcon//346/275/256/344/275/215.png +0 -0
  54. package/public/image/screenIcon//346/275/256/344/275/215/347/253/231-/346/227/240/346/225/260/346/215/256.png +0 -0
  55. package/public/image/screenIcon//346/275/256/344/275/215/347/253/231-/346/255/243/345/270/270.png +0 -0
  56. package/public/image/screenIcon//346/275/256/344/275/215/347/253/231-/350/266/205/344/277/235.png +0 -0
  57. package/public/image/screenIcon//346/275/256/344/275/215/347/253/231-/350/266/205/350/255/246.png +0 -0
  58. package/public/image/screenIcon//347/211/251/350/265/204/344/273/223/345/272/223.png +0 -0
  59. package/public/image/screenIcon//347/220/203/346/234/272-/345/205/263.png +0 -0
  60. package/public/image/screenIcon//347/220/203/346/234/272-/345/274/200.png +0 -0
  61. package/public/image/screenIcon//347/220/203/346/234/272-/347/272/242.png +0 -0
  62. package/public/image/screenIcon//350/247/206/351/242/221/347/233/221/346/216/247.png +0 -0
  63. package/public/image/screenIcon//351/227/270/351/227/250-/347/201/260.png +0 -0
  64. package/public/image/screenIcon//351/227/270/351/227/250-/347/273/277.png +0 -0
  65. package/public/image/screenIcon//351/230/262/346/264/252/344/273/223/345/272/223.png +0 -0
  66. package/public/image/screenIcon//351/232/220/346/202/243.png +0 -0
  67. package/public/image/screenIcon//351/233/250/351/207/217/347/253/231-/346/265/205/350/223/235.png +0 -0
  68. package/public/image/screenIcon//351/233/250/351/207/217/347/253/231-/347/201/260.png +0 -0
  69. package/public/image/screenIcon//351/233/250/351/207/217/347/253/231-/347/262/211.png +0 -0
  70. package/public/image/screenIcon//351/233/250/351/207/217/347/253/231-/347/272/242.png +0 -0
  71. package/public/image/screenIcon//351/233/250/351/207/217/347/253/231-/347/273/277.png +0 -0
  72. package/public/image/screenIcon//351/233/250/351/207/217/347/253/231-/350/223/235.png +0 -0
  73. package/public/image/screenIcon//351/233/250/351/207/217/347/253/231-/351/273/204.png +0 -0
  74. package/public/image/screenIcon//351/233/250/351/207/217/347/253/231-/351/273/221.png +0 -0
  75. package/public/image/screenIcon//351/243/216/351/200/237.png +0 -0
  76. package/public/image/screenIcon//351/243/216/351/200/237/346/265/213/347/253/231.png +0 -0
  77. package/public/image//346/260/264/346/226/207.gif +0 -0
  78. package/public/image//350/211/262/345/270/246.png +0 -0
  79. package/public/index.html +22 -0
  80. package/public/index.js +185662 -0
  81. package/public/jsWebControl-1.0.0.min.js +31 -0
  82. package/public/jsencrypt.min.js +1 -0
  83. package/public/math/Box2.js +203 -0
  84. package/public/math/Box3.js +532 -0
  85. package/public/math/Color.js +605 -0
  86. package/public/math/ColorManagement.js +74 -0
  87. package/public/math/Cylindrical.js +61 -0
  88. package/public/math/EngineUtils.js +81 -0
  89. package/public/math/Euler.js +315 -0
  90. package/public/math/Frustum.js +162 -0
  91. package/public/math/Interpolant.js +241 -0
  92. package/public/math/Line3.js +115 -0
  93. package/public/math/MathUtils.js +345 -0
  94. package/public/math/Matrix3.js +365 -0
  95. package/public/math/Matrix4.js +858 -0
  96. package/public/math/Plane.js +205 -0
  97. package/public/math/Quaternion.js +724 -0
  98. package/public/math/Ray.js +493 -0
  99. package/public/math/Sphere.js +243 -0
  100. package/public/math/Spherical.js +86 -0
  101. package/public/math/SphericalHarmonics3.js +243 -0
  102. package/public/math/Triangle.js +299 -0
  103. package/public/math/Vector2.js +464 -0
  104. package/public/math/Vector3.js +715 -0
  105. package/public/math/Vector4.js +644 -0
  106. package/public/math/interpolants/CubicInterpolant.js +151 -0
  107. package/public/math/interpolants/DiscreteInterpolant.js +26 -0
  108. package/public/math/interpolants/LinearInterpolant.js +38 -0
  109. package/public/math/interpolants/QuaternionLinearInterpolant.js +39 -0
  110. package/public/static/Cloud.png +0 -0
  111. package/public/static/Global2.jpg +0 -0
  112. package/public/static/css/main.css +170 -0
  113. package/public/static/geojson//346/265/267/345/241/230.geojson +99 -0
  114. package/public/static/img/loading.gif +0 -0
  115. package/public/static/js/app.js +359 -0
  116. package/public/static/js/appcontroller.js +207 -0
  117. package/public/static/js/dist/game.dev.js +137 -0
  118. package/public/static/js/env.js +74 -0
  119. package/public/static/js/event/event.js +107 -0
  120. package/public/static/js/init.js +8 -0
  121. package/public/static/js/initcloudmorph.js +1 -0
  122. package/public/static/js/log.js +35 -0
  123. package/public/static/js/network/ajax.js +29 -0
  124. package/public/static/js/network/rtcp.js +172 -0
  125. package/public/static/js/network/socket.js +106 -0
  126. package/public/web-control.min.js +2 -0
  127. package/scripts/postinstall.mjs +127 -0
  128. package/src/GaeaMethods.js +68 -405
  129. package/src/components/FlyAlongRoute.vue +1 -0
  130. package/src/components/WeatherControl.vue +2 -0
  131. package/src/directives/vDrag.js +70 -0
  132. package/src/index.js +1 -8
  133. package/src/plugin.js +16 -0
  134. package/src/utils.js +10 -21
  135. package/src/vite-plugin.js +117 -0
  136. package/public/static/1111.res +0 -0
  137. package/src/config.js +0 -40
@@ -0,0 +1,117 @@
1
+ /**
2
+ * Gaea Vite 插件
3
+ *
4
+ * 自动完成:
5
+ * 1. 在 HTML 中注入 <script src="/Gaea.js">(消费者无需手动添加)
6
+ * 2. 提供 /Gaea.js /Gaea.wasm /Gaea.pck 等静态文件
7
+ * 3. 设置 COEP/COOP 头(SharedArrayBuffer 必需)
8
+ * 4. 检测跨域隔离状态并自动刷新
9
+ *
10
+ * 消费者用法(vite.config.js):
11
+ * import { gaeaVitePlugin } from '@yangyongtao/gaea/plugin';
12
+ * export default defineConfig({ plugins: [vue(), gaeaVitePlugin()] });
13
+ */
14
+ import path from 'path';
15
+ import fs from 'fs';
16
+ import { fileURLToPath } from 'url';
17
+
18
+ const __filename = fileURLToPath(import.meta.url);
19
+ const __dirname = path.dirname(__filename);
20
+ const pkgPublic = path.resolve(__dirname, '..', 'public');
21
+
22
+ const MIME = {
23
+ '.wasm': 'application/wasm',
24
+ '.pck': 'application/octet-stream',
25
+ '.js': 'application/javascript',
26
+ '.png': 'image/png',
27
+ '.jpg': 'image/jpeg',
28
+ '.res': 'application/octet-stream',
29
+ };
30
+
31
+ const COEP_HEADERS = {
32
+ 'Cross-Origin-Opener-Policy': 'same-origin',
33
+ 'Cross-Origin-Embedder-Policy': 'require-corp',
34
+ };
35
+
36
+ export default function gaeaVitePlugin() {
37
+ return {
38
+ name: 'vite-plugin-gaea',
39
+ enforce: 'pre',
40
+
41
+ config() {
42
+ return {
43
+ server: { headers: COEP_HEADERS },
44
+ };
45
+ },
46
+
47
+ configureServer(server) {
48
+ server.middlewares.stack.unshift({
49
+ route: '',
50
+ handle: function gaeaServe(req, res, next) {
51
+ const url = req.url.split('?')[0];
52
+
53
+ const gaeaTopFiles = [
54
+ 'Gaea.js', 'Gaea.wasm', 'Gaea.pck', 'Gaea.worker.js',
55
+ 'Gaea.audio.worklet.js', 'index.js', 'config.js', 'constants.js',
56
+ ];
57
+ const gaeaDirs = ['math/', 'static/'];
58
+
59
+ let relative = null;
60
+ for (const name of gaeaTopFiles) {
61
+ if (url === '/' + name) { relative = name; break; }
62
+ }
63
+ if (!relative) {
64
+ for (const dir of gaeaDirs) {
65
+ if (url.startsWith('/' + dir)) {
66
+ relative = url.replace(/^\//, '');
67
+ break;
68
+ }
69
+ }
70
+ }
71
+
72
+ if (!relative) return next();
73
+
74
+ const filePath = path.join(pkgPublic, relative);
75
+ try {
76
+ const ext = path.extname(filePath).toLowerCase();
77
+ const buf = fs.readFileSync(filePath);
78
+ res.writeHead(200, {
79
+ 'Content-Type': MIME[ext] || 'application/octet-stream',
80
+ 'Cross-Origin-Opener-Policy': 'same-origin',
81
+ 'Cross-Origin-Embedder-Policy': 'require-corp',
82
+ });
83
+ res.end(buf);
84
+ } catch {
85
+ next();
86
+ }
87
+ },
88
+ });
89
+ },
90
+
91
+ transformIndexHtml(html) {
92
+ // 自动注入 Gaea.js(消费者无需在 HTML 中手动写 <script src="/Gaea.js">)
93
+ if (!html.includes('/Gaea.js')) {
94
+ html = html.replace(
95
+ '</body>',
96
+ ` <script type="text/javascript" src="/Gaea.js"></script>\n</body>`
97
+ );
98
+ }
99
+
100
+ // 跨域隔离检测
101
+ html = html.replace(
102
+ '</head>',
103
+ `<script>
104
+ if (!window.crossOriginIsolated) {
105
+ if (!location.search.includes('gaea_isolated=1')) {
106
+ location.replace(location.href.split('?')[0] + '?gaea_isolated=1');
107
+ } else {
108
+ console.warn('Gaea: 跨域隔离未生效,请关闭所有 localhost 标签页后重新打开');
109
+ }
110
+ }
111
+ </script></head>`
112
+ );
113
+
114
+ return html;
115
+ },
116
+ };
117
+ }
Binary file
package/src/config.js DELETED
@@ -1,40 +0,0 @@
1
- /**
2
- * Gaea 3D Viewer 配置模块
3
- * 使用者可通过 setConfig() 在应用初始化时注入配置
4
- */
5
-
6
- const defaultConfig = {
7
- // Gaea 服务地址
8
- serveUrl: 'http://localhost:8088/gaeaExplorerServer/',
9
- // 静态资源 Base URL(如 http://localhost:9012)
10
- serveLocal: '',
11
- // 初始相机定位 { x: lat, y: lng, z: alt }
12
- defaultPosition: { x: 27.380913, y: 120.449982, z: 80000 },
13
- // 地形 TMS 服务
14
- terrainList: {},
15
- // 开发模式
16
- developmentMode: true,
17
- };
18
-
19
- let currentConfig = { ...defaultConfig };
20
-
21
- /**
22
- * 设置全局配置(在初始化 Gaea 之前调用)
23
- * @param {Object} config - 配置对象
24
- * @param {string} config.serveUrl - Gaea 服务 URL
25
- * @param {string} config.serveLocal - 静态资源 Base URL(必传)
26
- * @param {Object} config.defaultPosition - 初始定位
27
- * @param {Object} config.terrainList - 地形图层
28
- */
29
- export function setConfig(config) {
30
- currentConfig = { ...currentConfig, ...config };
31
- }
32
-
33
- /**
34
- * 获取当前配置
35
- */
36
- export function getConfig() {
37
- return { ...currentConfig };
38
- }
39
-
40
- export default currentConfig;