@yangyongtao/gaea 1.1.19 → 1.1.20
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 +18 -19
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@yangyongtao/gaea",
|
|
3
|
-
"version": "1.1.
|
|
3
|
+
"version": "1.1.20",
|
|
4
4
|
"description": "Gaea 3D visualization component library - Vue 3 components based on Godot WASM engine. Includes WMTS layer loading, camera view control, Vite plugin auto-injection, etc.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "src/index.cjs",
|
package/src/GaeaMethods.js
CHANGED
|
@@ -275,7 +275,6 @@ export class GaeaApp {
|
|
|
275
275
|
this._secIsClickArr = [];
|
|
276
276
|
this._secScreenIconKeyValue = {};
|
|
277
277
|
this._groundPolygonElements = [];
|
|
278
|
-
this._categoryIcons = {};
|
|
279
278
|
this.tweenGroup = new TWEEN.Group();
|
|
280
279
|
this._tourConfig = {
|
|
281
280
|
'沿浦水闸': { direction: [-0.5, 0.3, 0.3], positionList: [
|
|
@@ -806,18 +805,13 @@ export class GaeaApp {
|
|
|
806
805
|
};
|
|
807
806
|
console.log('[GaeaApp] 开始创建屏幕图标... categories:', cats.length);
|
|
808
807
|
let count = 0;
|
|
809
|
-
this._categoryIcons = {};
|
|
810
808
|
for (const cat of cats) {
|
|
811
809
|
if (!cat.children?.length) continue;
|
|
812
|
-
this._categoryIcons[cat.key] = [];
|
|
813
810
|
const cfg = catConfig[cat.key] || { img: '', method: 'textImage', visibleRange: [10, 50000], offset: [-40, -35], drawLine: false };
|
|
814
811
|
for (const child of cat.children) {
|
|
815
812
|
if (!child.position) continue;
|
|
816
813
|
count++;
|
|
817
814
|
try {
|
|
818
|
-
const safeId = child.text.replace(/[^a-zA-Z0-9\u4e00-\u9fa5]/g, '_');
|
|
819
|
-
const divId = 'gaea-icon-' + safeId;
|
|
820
|
-
this._categoryIcons[cat.key].push(divId);
|
|
821
815
|
this.addScreenIcon({
|
|
822
816
|
name: child.text,
|
|
823
817
|
text: child.text,
|
|
@@ -828,6 +822,7 @@ export class GaeaApp {
|
|
|
828
822
|
visibleRange: cfg.visibleRange,
|
|
829
823
|
anchorType: cfg.anchorType,
|
|
830
824
|
drawLine: cfg.drawLine,
|
|
825
|
+
category: cat.key,
|
|
831
826
|
onClick: (name, data) => {
|
|
832
827
|
if (cfg.onClick) cfg.onClick(name, { ...child, ...data });
|
|
833
828
|
},
|
|
@@ -848,24 +843,28 @@ export class GaeaApp {
|
|
|
848
843
|
* @param {boolean} visible 是否可见
|
|
849
844
|
*/
|
|
850
845
|
setCategoryVisible(categoryKey, visible) {
|
|
851
|
-
const
|
|
852
|
-
if (!
|
|
853
|
-
|
|
854
|
-
|
|
855
|
-
|
|
846
|
+
const items = this._screenIconList.filter(item => item.category === categoryKey);
|
|
847
|
+
if (!items.length) return;
|
|
848
|
+
items.forEach(item => {
|
|
849
|
+
if (visible) {
|
|
850
|
+
item.element.UseAutoVisible();
|
|
851
|
+
item.element.EnablePick = true;
|
|
852
|
+
} else {
|
|
853
|
+
item.element.ForceSetVisible(false);
|
|
854
|
+
item.element.EnablePick = false;
|
|
855
|
+
}
|
|
856
856
|
});
|
|
857
857
|
}
|
|
858
858
|
|
|
859
859
|
/**
|
|
860
|
-
*
|
|
860
|
+
* 获取某个分类的当前可见性(根据第一个图标判断)
|
|
861
861
|
* @param {string} categoryKey
|
|
862
862
|
* @returns {boolean}
|
|
863
863
|
*/
|
|
864
864
|
getCategoryVisible(categoryKey) {
|
|
865
|
-
const
|
|
866
|
-
if (!
|
|
867
|
-
|
|
868
|
-
return el ? el.style.display !== 'none' : true;
|
|
865
|
+
const item = this._screenIconList.find(item => item.category === categoryKey);
|
|
866
|
+
if (!item) return true;
|
|
867
|
+
return item.element.Visible !== false;
|
|
869
868
|
}
|
|
870
869
|
|
|
871
870
|
// ---- 公开方法 ----
|
|
@@ -1210,7 +1209,7 @@ export class GaeaApp {
|
|
|
1210
1209
|
* 添加屏幕图标(参考 ht_3dview 三种创建方式)
|
|
1211
1210
|
* @param {string} opts.method - 'textImage' | 'styled' | 'imageOnly'
|
|
1212
1211
|
*/
|
|
1213
|
-
addScreenIcon({ name, text, imgUrl, position, method = 'textImage', offset = [0, 0], visibleRange = [10, 50000], anchorType = 6, drawLine = false, onClick, type = null, divId: externalDivId, elementName, elementChildrenIndex } = {}) {
|
|
1212
|
+
addScreenIcon({ name, text, imgUrl, position, method = 'textImage', offset = [0, 0], visibleRange = [10, 50000], anchorType = 6, drawLine = false, onClick, type = null, category = null, divId: externalDivId, elementName, elementChildrenIndex } = {}) {
|
|
1214
1213
|
const safeId = name.replace(/[^a-zA-Z0-9\u4e00-\u9fa5]/g, '_');
|
|
1215
1214
|
const divId = externalDivId || 'gaea-icon-' + safeId;
|
|
1216
1215
|
|
|
@@ -1313,7 +1312,7 @@ export class GaeaApp {
|
|
|
1313
1312
|
console.log('[GaeaApp] child:', !!child);
|
|
1314
1313
|
if (child) {
|
|
1315
1314
|
child.AddChild(screen, false);
|
|
1316
|
-
const screenItem = { element: screen, type: type || null };
|
|
1315
|
+
const screenItem = { element: screen, type: type || null, category };
|
|
1317
1316
|
this._screenIconList.push(screenItem);
|
|
1318
1317
|
return screen;
|
|
1319
1318
|
}
|
|
@@ -1324,7 +1323,7 @@ export class GaeaApp {
|
|
|
1324
1323
|
|
|
1325
1324
|
screen.GeographyPosition = new Gaea.Vector3(position.x, position.y, position.z || 0);
|
|
1326
1325
|
Gaea.World.Instance.RenderableObjectList.AddLast(screen);
|
|
1327
|
-
const screenItem = { element: screen, type: type || null };
|
|
1326
|
+
const screenItem = { element: screen, type: type || null, category };
|
|
1328
1327
|
this._screenIconList.push(screenItem);
|
|
1329
1328
|
return screen;
|
|
1330
1329
|
}
|