@yangyongtao/gaea 1.1.24 → 1.1.25

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 (2) hide show
  1. package/package.json +1 -1
  2. package/src/GaeaMethods.js +70 -1
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@yangyongtao/gaea",
3
- "version": "1.1.24",
3
+ "version": "1.1.25",
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",
@@ -289,6 +289,8 @@ export class GaeaApp {
289
289
  this.layerCategories = this.config.layerCategories || [];
290
290
  this._screenIconList = [];
291
291
  this._hiddenCategories = new Set();
292
+ this._tilesetMap = {}; // 已加载的 3D Tiles 引用,key 为 tileset 名称
293
+ this._flattenTool = null; // 压平绘制工具
292
294
  this._secIsClickArr = [];
293
295
  this._secScreenIconKeyValue = {};
294
296
  this._groundPolygonElements = [];
@@ -1180,6 +1182,7 @@ export class GaeaApp {
1180
1182
  const tilesetUrl = typeof item === 'string' ? item : item.jsonUrl
1181
1183
  const name = typeof item === 'string' ? '' : (item.tilName || '')
1182
1184
  const height = typeof item === 'string' ? 0 : (item.height || 0)
1185
+ const enableFlatten = typeof item === 'object' ? (item.enableFlatten || false) : false
1183
1186
  const tileset = new Gaea.Gaea3DTileset()
1184
1187
  tileset.Name = name
1185
1188
  tileset.TilesetUrl = tilesetUrl
@@ -1188,6 +1191,7 @@ export class GaeaApp {
1188
1191
  tileset.SkipLevelOfDetail = false
1189
1192
  tileset.IsZUp = true
1190
1193
  tileset.RecalculateNormals = true
1194
+ tileset.EnabledFlatten = enableFlatten
1191
1195
  tileset.BaseUrl = tilesetUrl.slice(0, tilesetUrl.lastIndexOf('/') + 1)
1192
1196
  tileset.InitTileSet(name, tilesetUrl)
1193
1197
  tileset.MaximumMemoryUsage = 512
@@ -1196,10 +1200,75 @@ export class GaeaApp {
1196
1200
  tileset.LocalOffset = new Gaea.Vector3(0, height, 0)
1197
1201
  }
1198
1202
  Gaea.World.Instance.RenderableObjectList.AddLast(tileset)
1199
- console.log('[GaeaApp] 3D Tiles 已加载:', name || tilesetUrl, height ? `高度: ${height}` : '')
1203
+ if (name) {
1204
+ this._tilesetMap[name] = tileset
1205
+ }
1206
+ console.log('[GaeaApp] 3D Tiles 已加载:', name || tilesetUrl, height ? `高度: ${height}` : '', enableFlatten ? '(压平已启用)' : '')
1200
1207
  return tileset
1201
1208
  };
1202
1209
 
1210
+ // ---- 倾斜摄影压平 ----
1211
+
1212
+ /**
1213
+ * 进入倾斜摄影压平绘制模式
1214
+ * 调用后可以在 3D Tiles 上绘制多边形,多边形区域内将被压平
1215
+ * @param {string} [tilesetName] - 目标 3D Tiles 名称(不传则默认使用第一个已加载的 tileset)
1216
+ */
1217
+ startFlattenDraw = (tilesetName) => {
1218
+ // 查找目标 tileset
1219
+ let tileset = null
1220
+ if (tilesetName) {
1221
+ tileset = this._tilesetMap[tilesetName]
1222
+ if (!tileset) {
1223
+ console.warn(`[GaeaApp] startFlattenDraw: 未找到 tileset "${tilesetName}"`)
1224
+ return
1225
+ }
1226
+ } else {
1227
+ // 取第一个有名字的 tileset
1228
+ const keys = Object.keys(this._tilesetMap)
1229
+ if (keys.length === 0) {
1230
+ console.warn('[GaeaApp] startFlattenDraw: 没有已加载的 3D Tiles')
1231
+ return
1232
+ }
1233
+ tileset = this._tilesetMap[keys[0]]
1234
+ }
1235
+
1236
+ tileset.EnabledFlatten = true
1237
+
1238
+ if (!this._flattenTool) {
1239
+ this._flattenTool = new Gaea.FlattenTool()
1240
+ this._flattenTool.NeedIntersectWithMesh = false
1241
+ this._flattenTool.IsMovingIntersectWithMesh = false
1242
+ }
1243
+
1244
+ Gaea.World.Instance.SetCurrentTool(this._flattenTool)
1245
+ Gaea.World.Instance.CurrentTool = this._flattenTool
1246
+ console.log('[GaeaApp] 压平绘制模式已启动:', tileset.Name || tileset.TilesetUrl)
1247
+ };
1248
+
1249
+ /**
1250
+ * 设置压平高度
1251
+ * @param {number} height - 压平目标高度
1252
+ */
1253
+ setFlattenHeight = (height) => {
1254
+ if (!this._flattenTool) {
1255
+ console.warn('[GaeaApp] setFlattenHeight: 尚未启用压平绘制模式,请先调用 startFlattenDraw()')
1256
+ return
1257
+ }
1258
+ this._flattenTool.Gdtvalue = height
1259
+ console.log('[GaeaApp] 压平高度已设置为:', height)
1260
+ };
1261
+
1262
+ /**
1263
+ * 结束压平绘制模式(保留已绘制的压平效果)
1264
+ */
1265
+ stopFlattenDraw = () => {
1266
+ Gaea.World.Instance.SetCurrentTool(null)
1267
+ Gaea.World.Instance.CurrentTool = null
1268
+ this._flattenTool = null
1269
+ console.log('[GaeaApp] 压平绘制模式已退出')
1270
+ };
1271
+
1203
1272
  /**
1204
1273
  * 根据经纬度飞到指定位置
1205
1274
  * @param {number} lat - 纬度