gltf-parser-plugin 1.1.0 → 1.1.2

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/build/index.d.ts CHANGED
@@ -1,9 +1,11 @@
1
+ import { Box3 } from 'three';
1
2
  import { EventDispatcher } from 'three';
2
3
  import { Intersection } from 'three';
3
4
  import { Material } from 'three';
4
5
  import { Mesh } from 'three';
5
6
  import { Texture } from 'three';
6
7
  import { TilesRenderer } from '3d-tiles-renderer';
8
+ import { Vector2 } from 'three';
7
9
  import { WebGLRenderer } from 'three';
8
10
 
9
11
  /**
@@ -27,6 +29,13 @@ export declare class GLTFParserPlugin implements MeshHelperHost {
27
29
  private _structureData;
28
30
  private _oidNodeMap;
29
31
  private _structurePromise;
32
+ private _modelInfo;
33
+ private _modelInfoPromise;
34
+ private _frozenOids;
35
+ private _isolatedOids;
36
+ private _trackedMeshes;
37
+ private _meshListeners;
38
+ private _isPluginRemoving;
30
39
  oids: number[];
31
40
  private renderer;
32
41
  private splitMeshCache;
@@ -71,6 +80,34 @@ export declare class GLTFParserPlugin implements MeshHelperHost {
71
80
  * 首次调用时会自动请求
72
81
  */
73
82
  getStructureData(): Promise<StructureData | null>;
83
+ private _pointInPolygon;
84
+ private _segmentsIntersect;
85
+ private _polygonIntersectsRect;
86
+ /**
87
+ * 选择包围盒范围内的构件(包含相交和包含两种情况)
88
+ * @param box 查询用的 Box3 范围,坐标系与 structure.json 中 bbox 一致
89
+ * @returns 范围内所有构件的 oid 数组
90
+ */
91
+ selectByBox(box: Box3): Promise<number[]>;
92
+ /**
93
+ * 选择多边形(平面投影)范围内的构件(包含相交和包含两种情况)
94
+ * @param polygon 多边形顶点数组(Vector2),按顺序连接构成闭合多边形
95
+ * @param axis 投影平面,决定使用 bbox 的哪两个轴做 2D 判定
96
+ * - 'xz'(默认):俯视图,取 bbox 的 x/z 坐标
97
+ * - 'xy':正视图,取 bbox 的 x/y 坐标
98
+ * - 'yz':侧视图,取 bbox 的 y/z 坐标
99
+ * @returns 范围内所有构件的 oid 数组
100
+ */
101
+ selectByPolygon(polygon: Vector2[], axis?: "xy" | "xz" | "yz"): Promise<number[]>;
102
+ private _getModelInfoUrl;
103
+ private _fetchModelInfo;
104
+ private _ensureModelInfoLoaded;
105
+ /**
106
+ * 获取 modelInfo.json 数据
107
+ * 包含模型的基本信息:动画支持、材质数量、顶点数、三角形数等
108
+ * 首次调用时会自动从 tileset URL 推导并请求 modelInfo.json
109
+ */
110
+ getModelInfo(): Promise<ModelInfo | null>;
74
111
  /**
75
112
  * Load model callback
76
113
  */
@@ -94,8 +131,62 @@ export declare class GLTFParserPlugin implements MeshHelperHost {
94
131
  private _setupMaterial;
95
132
  /**
96
133
  * Query feature information from intersection
134
+ * Respects freeze and isolate filters
97
135
  */
98
136
  queryFeatureFromIntersection(hit: Intersection): FeatureInfo;
137
+ private _isOidBlocked;
138
+ private _trackMesh;
139
+ private _untrackMesh;
140
+ private _onCollectorMeshChange;
141
+ private _syncCollectorMeshes;
142
+ /**
143
+ * 冻结指定构件,被冻结的构件不再响应任何交互和事件
144
+ */
145
+ freezeByOids(oids: number[]): void;
146
+ /**
147
+ * 冻结单个构件
148
+ */
149
+ freezeByOid(oid: number): void;
150
+ /**
151
+ * 解冻指定构件
152
+ */
153
+ unfreezeByOids(oids: number[]): void;
154
+ /**
155
+ * 解冻单个构件
156
+ */
157
+ unfreezeByOid(oid: number): void;
158
+ /**
159
+ * 解冻全部构件
160
+ */
161
+ unfreeze(): void;
162
+ /**
163
+ * 获取当前被冻结的 OID 数组
164
+ */
165
+ getFrozenOids(): number[];
166
+ /**
167
+ * 隔离指定构件,隔离模式下只有被隔离的构件才能响应交互和事件
168
+ */
169
+ isolateByOids(oids: number[]): void;
170
+ /**
171
+ * 往隔离集合中添加单个构件
172
+ */
173
+ isolateByOid(oid: number): void;
174
+ /**
175
+ * 取消隔离指定构件
176
+ */
177
+ unisolateByOids(oids: number[]): void;
178
+ /**
179
+ * 从隔离集合中移除单个构件
180
+ */
181
+ unisolateByOid(oid: number): void;
182
+ /**
183
+ * 取消全部隔离,恢复所有构件的交互能力
184
+ */
185
+ unisolate(): void;
186
+ /**
187
+ * 获取当前被隔离的 OID 数组
188
+ */
189
+ getIsolatedOids(): number[];
99
190
  /**
100
191
  * 内部方法:根据 oid 获取 mesh 数组
101
192
  */
@@ -198,6 +289,19 @@ declare interface MeshHelperHost {
198
289
  _getMeshesByOidInternal(oid: number): Mesh[];
199
290
  }
200
291
 
292
+ /**
293
+ * modelInfo.json 的数据结构
294
+ */
295
+ export declare interface ModelInfo {
296
+ animatable: boolean;
297
+ images: number;
298
+ materials: number;
299
+ pbr: boolean;
300
+ textures: number;
301
+ triangles: number;
302
+ vertices: number;
303
+ }
304
+
201
305
  /**
202
306
  * structure.json 的完整数据结构
203
307
  */
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "gltf-parser-plugin",
3
- "version": "1.1.0",
3
+ "version": "1.1.2",
4
4
  "description": "A plugin for parsing GLTF files",
5
5
  "type": "module",
6
6
  "main": "./build/gltf-parser-plugin.module.js",
@@ -28,20 +28,20 @@
28
28
  "author": "maptalks",
29
29
  "license": "MIT",
30
30
  "devDependencies": {
31
- "@types/node": "^25.3.3",
31
+ "@types/node": "^25.4.0",
32
32
  "@types/three": "^0.183.1",
33
- "@typescript-eslint/eslint-plugin": "^8.56.1",
34
- "@typescript-eslint/parser": "^8.56.1",
35
- "eslint": "^10.0.2",
33
+ "@typescript-eslint/eslint-plugin": "^8.57.0",
34
+ "@typescript-eslint/parser": "^8.57.0",
35
+ "eslint": "^10.0.3",
36
36
  "typescript": "^5.9.3",
37
37
  "vite": "^7.3.1",
38
38
  "vite-plugin-dts": "^4.5.4",
39
39
  "vitest": "^4.0.18"
40
40
  },
41
41
  "dependencies": {
42
- "3d-tiles-renderer": "^0.4.21",
43
- "@maptalks/gltf-loader": "^0.124.3",
44
- "@maptalks/transcoders.draco": "^0.124.3",
42
+ "3d-tiles-renderer": "^0.4.22",
43
+ "@maptalks/gltf-loader": "^0.124.4",
44
+ "@maptalks/transcoders.draco": "^0.124.4",
45
45
  "three": "^0.183.2"
46
46
  }
47
47
  }