gltf-parser-plugin 1.1.8 → 1.1.10
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,4 +1,5 @@
|
|
|
1
1
|
import { Box3 } from 'three';
|
|
2
|
+
import { BufferGeometry } from 'three';
|
|
2
3
|
import { Color } from 'three';
|
|
3
4
|
import { Euler } from 'three';
|
|
4
5
|
import { EventDispatcher } from 'three';
|
|
@@ -12,26 +13,30 @@ import { Vector3 } from 'three';
|
|
|
12
13
|
import { WebGLRenderer } from 'three';
|
|
13
14
|
|
|
14
15
|
/**
|
|
15
|
-
*
|
|
16
|
-
* 在 propertyData 的键作为变量名的上下文中执行 `Boolean(expr)`
|
|
17
|
-
*
|
|
18
|
-
* 实现:对每个表达式字符串只编译一次 `new Function('data', 'with(d){...}')`,
|
|
19
|
-
* 避免按「表达式 × 属性键集合」重复编译,也避免每次求值排序/拼接 cacheKey。
|
|
16
|
+
* 遍历 style 的 show 与 conditions,对每个出现过的字符串表达式只编译一次
|
|
20
17
|
*/
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
18
|
+
export declare function buildStyleConditionEvaluatorMap(config: {
|
|
19
|
+
show?: string;
|
|
20
|
+
conditions?: StyleCondition[];
|
|
21
|
+
}): Map<string, StyleConditionEvaluator>;
|
|
25
22
|
|
|
26
23
|
/** 可解析为 THREE.Color 的输入 */
|
|
27
24
|
export declare type ColorInput = number | string | Color;
|
|
28
25
|
|
|
26
|
+
/**
|
|
27
|
+
* 编译单个表达式;失败返回 null(无模块级缓存)
|
|
28
|
+
*/
|
|
29
|
+
export declare function compileStyleCondition(expr: string): StyleConditionEvaluator | null;
|
|
30
|
+
|
|
29
31
|
/**
|
|
30
32
|
* 同步解析 `data:application/x-gzip;base64,...`:base64 → 二进制 → gunzip → UTF-8 文本。
|
|
31
33
|
*/
|
|
32
34
|
export declare function decodeGzipBase64DataUriSync(dataUri: string): string;
|
|
33
35
|
|
|
34
|
-
export declare function evaluateStyleCondition(expr: string | boolean, propertyData: Record<string, unknown> | null): boolean;
|
|
36
|
+
export declare function evaluateStyleCondition(expr: string | boolean, propertyData: Record<string, unknown> | null, evaluators?: ReadonlyMap<string, StyleConditionEvaluator>): boolean;
|
|
37
|
+
|
|
38
|
+
/** 从构件材质提取贴图,供 material 回调使用 */
|
|
39
|
+
export declare function extractStyleMaterialMaps(material: Material): StyleMaterialMaps;
|
|
35
40
|
|
|
36
41
|
/**
|
|
37
42
|
* Hit object feature information interface
|
|
@@ -292,9 +297,10 @@ export declare class GLTFParserPlugin implements MeshHelperHost {
|
|
|
292
297
|
*/
|
|
293
298
|
setStyle(style: StyleConfig | null): void;
|
|
294
299
|
/**
|
|
295
|
-
*
|
|
300
|
+
* 当前样式配置。赋值与 `setStyle(...)` 等价,例如 `plugin.style = { show, conditions }`。
|
|
296
301
|
*/
|
|
297
302
|
get style(): StyleConfig | null;
|
|
303
|
+
set style(style: StyleConfig | null);
|
|
298
304
|
/**
|
|
299
305
|
* 清除构件样式
|
|
300
306
|
*/
|
|
@@ -362,11 +368,17 @@ export declare interface GLTFParserPluginOptions {
|
|
|
362
368
|
* @default false
|
|
363
369
|
*/
|
|
364
370
|
useIndexedDB?: boolean;
|
|
371
|
+
/**
|
|
372
|
+
* 初始构件样式,语义与 `setStyle` / `plugin.style` 相同。
|
|
373
|
+
* 在 `init` 内会在已遍历到的瓦片场景就绪后应用;后续瓦片通过 `load-model` / `tiles-load-end` 触发收集器更新并重应用样式。
|
|
374
|
+
*/
|
|
375
|
+
style?: StyleConfig | null;
|
|
365
376
|
}
|
|
366
377
|
|
|
367
|
-
/**
|
|
378
|
+
/** 条件命中后的外观:材质可为简写、函数或 Material;位姿与 setStyle 一致 */
|
|
368
379
|
export declare interface HighlightAppearance {
|
|
369
|
-
material: HighlightMaterial;
|
|
380
|
+
material: HighlightMaterial | StyleMaterialResolver;
|
|
381
|
+
mesh?: StyleMeshFactory;
|
|
370
382
|
translation?: StyleVec3Input;
|
|
371
383
|
scale?: StyleVec3Input;
|
|
372
384
|
rotation?: StyleEulerInput;
|
|
@@ -503,7 +515,13 @@ export declare interface StructureNode {
|
|
|
503
515
|
|
|
504
516
|
/** 条件命中后的外观:材质必填,位姿可选(未传则不改对应分量) */
|
|
505
517
|
export declare interface StyleAppearance {
|
|
506
|
-
|
|
518
|
+
/** 直接材质,或根据 {@link StyleMaterialMaps} 从原构件材质生成 */
|
|
519
|
+
material: Material | StyleMaterialResolver;
|
|
520
|
+
/**
|
|
521
|
+
* 可选:自定义 Mesh 构建;默认仅替换 geometry/material。
|
|
522
|
+
* 返回的 Mesh 会将其 geometry、material 写回当前 split mesh,uuid 不变。
|
|
523
|
+
*/
|
|
524
|
+
mesh?: StyleMeshFactory;
|
|
507
525
|
translation?: StyleVec3Input;
|
|
508
526
|
scale?: StyleVec3Input;
|
|
509
527
|
rotation?: StyleEulerInput;
|
|
@@ -514,6 +532,8 @@ export declare interface StyleAppearance {
|
|
|
514
532
|
/** 条件项:[条件表达式或 true, 外观对象] */
|
|
515
533
|
export declare type StyleCondition = [string | boolean, StyleAppearance];
|
|
516
534
|
|
|
535
|
+
export declare type StyleConditionEvaluator = (data: Record<string, unknown>) => boolean;
|
|
536
|
+
|
|
517
537
|
/** 样式配置 */
|
|
518
538
|
export declare interface StyleConfig {
|
|
519
539
|
show?: string;
|
|
@@ -523,6 +543,28 @@ export declare interface StyleConfig {
|
|
|
523
543
|
/** 与 Euler 等价:Three 的 Euler,或 [x,y,z] / [x,y,z,order] */
|
|
524
544
|
export declare type StyleEulerInput = Euler | readonly number[];
|
|
525
545
|
|
|
546
|
+
/**
|
|
547
|
+
* 从构件原始材质上可读取的常见贴图(供 material 为函数时使用,如解构 { map, normalMap })
|
|
548
|
+
*/
|
|
549
|
+
export declare interface StyleMaterialMaps {
|
|
550
|
+
map?: Texture | null;
|
|
551
|
+
normalMap?: Texture | null;
|
|
552
|
+
metalnessMap?: Texture | null;
|
|
553
|
+
roughnessMap?: Texture | null;
|
|
554
|
+
aoMap?: Texture | null;
|
|
555
|
+
emissiveMap?: Texture | null;
|
|
556
|
+
}
|
|
557
|
+
|
|
558
|
+
/**
|
|
559
|
+
* 基于原始贴图生成最终材质(与直接传入 Material 实例二选一)
|
|
560
|
+
*/
|
|
561
|
+
export declare type StyleMaterialResolver = (maps: StyleMaterialMaps) => Material;
|
|
562
|
+
|
|
563
|
+
/**
|
|
564
|
+
* 用几何与(解析后的)材质构建 Mesh;返回值会合并回同一 mesh 实例以保持收集器引用
|
|
565
|
+
*/
|
|
566
|
+
export declare type StyleMeshFactory = (geometry: BufferGeometry, material: Material) => Mesh;
|
|
567
|
+
|
|
526
568
|
/** 与 Vector3 等价:Three 的 Vector3 或长度≥3 的 [x,y,z] 数组 */
|
|
527
569
|
export declare type StyleVec3Input = Vector3 | readonly number[];
|
|
528
570
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "gltf-parser-plugin",
|
|
3
|
-
"version": "1.1.
|
|
3
|
+
"version": "1.1.10",
|
|
4
4
|
"description": "A plugin for parsing GLTF files",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./build/gltf-parser-plugin.module.js",
|
|
@@ -34,9 +34,9 @@
|
|
|
34
34
|
"@typescript-eslint/parser": "^8.57.2",
|
|
35
35
|
"eslint": "^10.1.0",
|
|
36
36
|
"typescript": "^5.8.2",
|
|
37
|
-
"vite": "^8.0.
|
|
37
|
+
"vite": "^8.0.3",
|
|
38
38
|
"vite-plugin-dts": "^4.5.4",
|
|
39
|
-
"vitest": "^4.1.
|
|
39
|
+
"vitest": "^4.1.2"
|
|
40
40
|
},
|
|
41
41
|
"dependencies": {
|
|
42
42
|
"3d-tiles-renderer": "^0.4.23",
|