gltf-parser-plugin 1.0.7 → 1.0.9

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,12 +1,36 @@
1
+ import { EventDispatcher } from 'three';
2
+ import { Intersection } from 'three';
1
3
  import { Material } from 'three';
4
+ import { Mesh } from 'three';
2
5
  import { Texture } from 'three';
6
+ import { TilesRenderer } from '3d-tiles-renderer';
7
+ import { WebGLRenderer } from 'three';
3
8
 
4
- export declare class GLTFParserPlugin {
9
+ /**
10
+ * Hit object feature information interface
11
+ */
12
+ export declare interface FeatureInfo {
13
+ oid?: number;
14
+ featureId?: number;
15
+ features?: number[];
16
+ propertyData?: object;
17
+ isValid: boolean;
18
+ error?: string;
19
+ }
20
+
21
+ export declare class GLTFParserPlugin implements MeshHelperHost {
5
22
  name: string;
6
23
  private tiles;
7
24
  private _loader;
8
25
  private readonly _gltfRegex;
9
26
  private readonly _options;
27
+ oids: number[];
28
+ private renderer;
29
+ private splitMeshCache;
30
+ private maxUniformVectors;
31
+ private featureIdCount;
32
+ private collectors;
33
+ private collectorCache;
10
34
  /**
11
35
  * Create a GLTFParserPlugin instance
12
36
  * @param options configuration options
@@ -15,14 +39,9 @@ export declare class GLTFParserPlugin {
15
39
  /**
16
40
  * Plugin initialization, called by TilesRenderer
17
41
  */
18
- init(tiles: any): void;
42
+ init(tiles: TilesRenderer): void;
19
43
  /**
20
44
  * Fetch tile data with IndexedDB caching support
21
- * If data exists in IndexedDB, return cached data without network request
22
- * If not cached, fetch from network and store in IndexedDB
23
- * @param url The processed URL (used as cache key)
24
- * @param options Fetch options
25
- * @returns Cached data (ArrayBuffer for binary, parsed JSON for .json) or Response on error
26
45
  */
27
46
  fetchData(url: string, options?: RequestInit): Promise<Response | ArrayBuffer | object>;
28
47
  /**
@@ -30,6 +49,57 @@ export declare class GLTFParserPlugin {
30
49
  */
31
50
  clearCache(): Promise<void>;
32
51
  parseTile(buffer: ArrayBuffer, tile: any, extension: any, uri: string, abortSignal: AbortSignal): Promise<any>;
52
+ /**
53
+ * Load model callback
54
+ */
55
+ private _onLoadModelCB;
56
+ /**
57
+ * Tiles load end callback
58
+ */
59
+ private _onTilesLoadEndCB;
60
+ private _onLoadModel;
61
+ private _notifyCollectors;
62
+ _registerCollector(collector: MeshCollector): void;
63
+ _unregisterCollector(collector: MeshCollector): void;
64
+ private _updateWebGLLimits;
65
+ /**
66
+ * Dynamically calculate FEATURE_ID_COUNT based on WebGL limits and current oid count
67
+ */
68
+ private _calculateFeatureIdCount;
69
+ /**
70
+ * Set up shader modification for hiding specific features
71
+ */
72
+ private _setupMaterial;
73
+ /**
74
+ * Query feature information from intersection
75
+ */
76
+ queryFeatureFromIntersection(hit: Intersection): FeatureInfo;
77
+ /**
78
+ * 内部方法:根据 oid 获取 mesh 数组
79
+ */
80
+ _getMeshesByOidInternal(oid: number): Mesh[];
81
+ /**
82
+ * 根据 oid 获取 MeshCollector
83
+ * MeshCollector 会监听瓦片变化,自动更新 meshes 并触发 mesh-change 事件
84
+ * 内部缓存:相同 oid 多次调用会返回同一个 collector 实例
85
+ */
86
+ getMeshCollectorByOid(oid: number): MeshCollector;
87
+ /**
88
+ * Hide the corresponding part of the original mesh according to the OID array
89
+ */
90
+ hideByOids(oids: number[]): void;
91
+ /**
92
+ * Restore the display of the corresponding mesh according to the OID array
93
+ */
94
+ unhideByOids(oids: number[]): void;
95
+ /**
96
+ * Restore the original materials of the mesh
97
+ */
98
+ unhide(): void;
99
+ /**
100
+ * Get the current feature ID count
101
+ */
102
+ getFeatureIdCount(): number;
33
103
  /**
34
104
  * Plugin disposal
35
105
  */
@@ -39,7 +109,11 @@ export declare class GLTFParserPlugin {
39
109
  /**
40
110
  * GLTFParserPlugin configuration options
41
111
  */
42
- declare interface GLTFParserPluginOptions {
112
+ export declare interface GLTFParserPluginOptions {
113
+ /**
114
+ * WebGLRenderer instance, required for mesh helper features (hideByOids, etc.)
115
+ */
116
+ renderer?: WebGLRenderer;
43
117
  /**
44
118
  * Whether to enable metadata support
45
119
  * Includes EXT_mesh_features and EXT_structural_metadata extensions
@@ -71,4 +145,35 @@ declare interface GLTFParserPluginOptions {
71
145
 
72
146
  declare type MaterialBuilder = (matData: unknown, textureMap: Map<number, Texture>) => Material;
73
147
 
148
+ export declare interface MeshChangeEvent {
149
+ type: "mesh-change";
150
+ meshes: Mesh[];
151
+ }
152
+
153
+ /**
154
+ * MeshCollector - 用于监听和收集特定 oid 对应的 mesh
155
+ * 随着瓦片变化,会自动更新 meshes 并触发 mesh-change 事件
156
+ */
157
+ export declare class MeshCollector extends EventDispatcher<MeshCollectorEventMap> {
158
+ private oid;
159
+ private plugin;
160
+ private _meshes;
161
+ private _disposed;
162
+ constructor(oid: number, plugin: MeshHelperHost);
163
+ get meshes(): Mesh[];
164
+ _updateMeshes(): void;
165
+ getOid(): number;
166
+ dispose(): void;
167
+ }
168
+
169
+ export declare type MeshCollectorEventMap = {
170
+ "mesh-change": MeshChangeEvent;
171
+ };
172
+
173
+ declare interface MeshHelperHost {
174
+ _registerCollector(collector: MeshCollector): void;
175
+ _unregisterCollector(collector: MeshCollector): void;
176
+ _getMeshesByOidInternal(oid: number): Mesh[];
177
+ }
178
+
74
179
  export { }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "gltf-parser-plugin",
3
- "version": "1.0.7",
3
+ "version": "1.0.9",
4
4
  "description": "A plugin for parsing GLTF files",
5
5
  "type": "module",
6
6
  "main": "./build/gltf-parser-plugin.module.js",
@@ -28,7 +28,7 @@
28
28
  "author": "maptalks",
29
29
  "license": "MIT",
30
30
  "devDependencies": {
31
- "@types/node": "^25.3.0",
31
+ "@types/node": "^25.3.3",
32
32
  "@types/three": "^0.183.1",
33
33
  "@typescript-eslint/eslint-plugin": "^8.56.1",
34
34
  "@typescript-eslint/parser": "^8.56.1",
@@ -42,6 +42,6 @@
42
42
  "3d-tiles-renderer": "^0.4.21",
43
43
  "@maptalks/gltf-loader": "^0.124.3",
44
44
  "@maptalks/transcoders.draco": "^0.124.3",
45
- "three": "^0.183.1"
45
+ "three": "^0.183.2"
46
46
  }
47
47
  }