gltf-parser-plugin 1.0.6 → 1.0.8

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,35 @@
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;
10
33
  /**
11
34
  * Create a GLTFParserPlugin instance
12
35
  * @param options configuration options
@@ -15,14 +38,9 @@ export declare class GLTFParserPlugin {
15
38
  /**
16
39
  * Plugin initialization, called by TilesRenderer
17
40
  */
18
- init(tiles: any): void;
41
+ init(tiles: TilesRenderer): void;
19
42
  /**
20
43
  * 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
44
  */
27
45
  fetchData(url: string, options?: RequestInit): Promise<Response | ArrayBuffer | object>;
28
46
  /**
@@ -30,6 +48,56 @@ export declare class GLTFParserPlugin {
30
48
  */
31
49
  clearCache(): Promise<void>;
32
50
  parseTile(buffer: ArrayBuffer, tile: any, extension: any, uri: string, abortSignal: AbortSignal): Promise<any>;
51
+ /**
52
+ * Load model callback
53
+ */
54
+ private _onLoadModelCB;
55
+ /**
56
+ * Tiles load end callback
57
+ */
58
+ private _onTilesLoadEndCB;
59
+ private _onLoadModel;
60
+ private _notifyCollectors;
61
+ _registerCollector(collector: MeshCollector): void;
62
+ _unregisterCollector(collector: MeshCollector): void;
63
+ private _updateWebGLLimits;
64
+ /**
65
+ * Dynamically calculate FEATURE_ID_COUNT based on WebGL limits and current oid count
66
+ */
67
+ private _calculateFeatureIdCount;
68
+ /**
69
+ * Set up shader modification for hiding specific features
70
+ */
71
+ private _setupMaterial;
72
+ /**
73
+ * Query feature information from intersection
74
+ */
75
+ queryFeatureFromIntersection(hit: Intersection): FeatureInfo;
76
+ /**
77
+ * 内部方法:根据 oid 获取 mesh 数组
78
+ */
79
+ _getMeshesByOidInternal(oid: number): Mesh[];
80
+ /**
81
+ * 根据 oid 获取 MeshCollector
82
+ * MeshCollector 会监听瓦片变化,自动更新 meshes 并触发 mesh-change 事件
83
+ */
84
+ getMeshCollectorByOid(oid: number): MeshCollector;
85
+ /**
86
+ * Hide the corresponding part of the original mesh according to the OID array
87
+ */
88
+ hideByOids(oids: number[]): void;
89
+ /**
90
+ * Restore the display of the corresponding mesh according to the OID array
91
+ */
92
+ unhideByOids(oids: number[]): void;
93
+ /**
94
+ * Restore the original materials of the mesh
95
+ */
96
+ unhide(): void;
97
+ /**
98
+ * Get the current feature ID count
99
+ */
100
+ getFeatureIdCount(): number;
33
101
  /**
34
102
  * Plugin disposal
35
103
  */
@@ -39,7 +107,11 @@ export declare class GLTFParserPlugin {
39
107
  /**
40
108
  * GLTFParserPlugin configuration options
41
109
  */
42
- declare interface GLTFParserPluginOptions {
110
+ export declare interface GLTFParserPluginOptions {
111
+ /**
112
+ * WebGLRenderer instance, required for mesh helper features (hideByOids, etc.)
113
+ */
114
+ renderer?: WebGLRenderer;
43
115
  /**
44
116
  * Whether to enable metadata support
45
117
  * Includes EXT_mesh_features and EXT_structural_metadata extensions
@@ -71,4 +143,35 @@ declare interface GLTFParserPluginOptions {
71
143
 
72
144
  declare type MaterialBuilder = (matData: unknown, textureMap: Map<number, Texture>) => Material;
73
145
 
146
+ export declare interface MeshChangeEvent {
147
+ type: "mesh-change";
148
+ meshes: Mesh[];
149
+ }
150
+
151
+ /**
152
+ * MeshCollector - 用于监听和收集特定 oid 对应的 mesh
153
+ * 随着瓦片变化,会自动更新 meshes 并触发 mesh-change 事件
154
+ */
155
+ export declare class MeshCollector extends EventDispatcher<MeshCollectorEventMap> {
156
+ private oid;
157
+ private plugin;
158
+ private _meshes;
159
+ private _disposed;
160
+ constructor(oid: number, plugin: MeshHelperHost);
161
+ get meshes(): Mesh[];
162
+ _updateMeshes(): void;
163
+ getOid(): number;
164
+ dispose(): void;
165
+ }
166
+
167
+ export declare type MeshCollectorEventMap = {
168
+ "mesh-change": MeshChangeEvent;
169
+ };
170
+
171
+ declare interface MeshHelperHost {
172
+ _registerCollector(collector: MeshCollector): void;
173
+ _unregisterCollector(collector: MeshCollector): void;
174
+ _getMeshesByOidInternal(oid: number): Mesh[];
175
+ }
176
+
74
177
  export { }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "gltf-parser-plugin",
3
- "version": "1.0.6",
3
+ "version": "1.0.8",
4
4
  "description": "A plugin for parsing GLTF files",
5
5
  "type": "module",
6
6
  "main": "./build/gltf-parser-plugin.module.js",
@@ -28,11 +28,11 @@
28
28
  "author": "maptalks",
29
29
  "license": "MIT",
30
30
  "devDependencies": {
31
- "@types/node": "^25.2.3",
32
- "@types/three": "^0.182.0",
33
- "@typescript-eslint/eslint-plugin": "^8.55.0",
34
- "@typescript-eslint/parser": "^8.55.0",
35
- "eslint": "^10.0.0",
31
+ "@types/node": "^25.3.0",
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",
36
36
  "typescript": "^5.9.3",
37
37
  "vite": "^7.3.1",
38
38
  "vite-plugin-dts": "^4.5.4",
@@ -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.182.0"
45
+ "three": "^0.183.1"
46
46
  }
47
47
  }