@realsee/dnalogel 3.77.4 → 3.77.6
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/CHANGELOG.md +20 -11
- package/dist/DigitalPerformancePlugin/controller/index.d.ts +224 -0
- package/dist/DigitalPerformancePlugin/core/DigitalHuman.d.ts +55 -0
- package/dist/DigitalPerformancePlugin/core/DigitalPlayground.d.ts +40 -0
- package/dist/DigitalPerformancePlugin/core/DigitalStateMachine.d.ts +150 -0
- package/dist/DigitalPerformancePlugin/core/Trace.d.ts +9 -0
- package/dist/DigitalPerformancePlugin/index.d.ts +11 -0
- package/dist/DigitalPerformancePlugin/mock.d.ts +76 -0
- package/dist/DigitalPerformancePlugin/typings/index.d.ts +79 -0
- package/dist/PanoTagPlugin/controller/Tag/BaseTag.d.ts +5 -1
- package/dist/PanoTagPlugin/controller/Tag/BoxTag.d.ts +119 -0
- package/dist/PanoTagPlugin/controller/Tag/MaskTag.d.ts +257 -0
- package/dist/PanoTagPlugin/controller/Tag/MaskTag.shaders.d.ts +10 -0
- package/dist/PanoTagPlugin/controller/Tag/PolygonTag.d.ts +112 -0
- package/dist/PanoTagPlugin/controller/TagRender.d.ts +1 -1
- package/dist/PanoTagPlugin/controller/index.d.ts +55 -2
- package/dist/PanoTagPlugin/typings/controller.d.ts +10 -0
- package/dist/PanoTagPlugin/typings/tag/Tag.d.ts +8 -3
- package/dist/PanoTagPlugin/typings/tag/Utils.d.ts +50 -1
- package/dist/PanoTagPlugin/utils/sculptDataToBoxPosition.d.ts +6 -0
- package/dist/PanoTagPlugin/utils/tag/tagCheck.d.ts +6 -0
- package/dist/PanoTagPlugin/utils/tagPosition.d.ts +12 -3
- package/dist/index.cjs.js +188 -92
- package/dist/index.d.ts +1 -0
- package/dist/index.js +17508 -14249
- package/dist/index.umd.js +184 -88
- package/libs/CruisePlugin/Move.js +7 -2
- package/libs/CruisePlugin/Work.js +7 -2
- package/libs/CruisePlugin/index.js +11 -6
- package/libs/DigitalPerformancePlugin/controller/index.d.ts +2 -2
- package/libs/DigitalPerformancePlugin/controller/index.js +164 -173
- package/libs/DigitalPerformancePlugin/core/DigitalHuman.d.ts +16 -6
- package/libs/DigitalPerformancePlugin/core/DigitalHuman.js +128 -102
- package/libs/DigitalPerformancePlugin/core/DigitalPlayground.d.ts +11 -5
- package/libs/DigitalPerformancePlugin/core/DigitalPlayground.js +84 -74
- package/libs/DigitalPerformancePlugin/core/DigitalStateMachine.d.ts +7 -0
- package/libs/DigitalPerformancePlugin/mock.d.ts +6 -0
- package/libs/DigitalPerformancePlugin/mock.js +272 -274
- package/libs/GuideLinePlugin/Controller.js +9 -4
- package/libs/GuideLinePlugin/GuideLineItem.js +7 -2
- package/libs/GuideLinePlugin/GuideLineModeItem.js +7 -2
- package/libs/GuideLinePlugin/index.js +11 -6
- package/libs/PanoTagPlugin/Components/TagItem.js +122 -122
- package/libs/PanoTagPlugin/controller/Tag/BaseTag.d.ts +5 -1
- package/libs/PanoTagPlugin/controller/Tag/BaseTag.js +320 -289
- package/libs/PanoTagPlugin/controller/Tag/BoxTag.d.ts +119 -0
- package/libs/PanoTagPlugin/controller/Tag/BoxTag.js +515 -0
- package/libs/PanoTagPlugin/controller/Tag/MaskTag.d.ts +257 -0
- package/libs/PanoTagPlugin/controller/Tag/MaskTag.js +815 -0
- package/libs/PanoTagPlugin/controller/Tag/MaskTag.shaders.d.ts +10 -0
- package/libs/PanoTagPlugin/controller/Tag/MaskTag.shaders.js +94 -0
- package/libs/PanoTagPlugin/controller/Tag/PolygonTag.d.ts +112 -0
- package/libs/PanoTagPlugin/controller/Tag/PolygonTag.js +478 -0
- package/libs/PanoTagPlugin/controller/TagRender.d.ts +1 -1
- package/libs/PanoTagPlugin/controller/TagUtil.js +19 -17
- package/libs/PanoTagPlugin/controller/index.d.ts +55 -2
- package/libs/PanoTagPlugin/controller/index.js +261 -148
- package/libs/PanoTagPlugin/index.js +16 -11
- package/libs/PanoTagPlugin/typings/controller.d.ts +10 -0
- package/libs/PanoTagPlugin/typings/tag/Tag.d.ts +8 -3
- package/libs/PanoTagPlugin/typings/tag/Utils.d.ts +50 -1
- package/libs/PanoTagPlugin/utils/addDebugPoints.js +27 -13
- package/libs/PanoTagPlugin/utils/index.js +29 -26
- package/libs/PanoTagPlugin/utils/sculptDataToBoxPosition.d.ts +6 -0
- package/libs/PanoTagPlugin/utils/sculptDataToBoxPosition.js +18 -0
- package/libs/PanoTagPlugin/utils/tag/tagCheck.d.ts +6 -0
- package/libs/PanoTagPlugin/utils/tag/tagCheck.js +26 -14
- package/libs/PanoTagPlugin/utils/tagPosition.d.ts +12 -3
- package/libs/PanoTagPlugin/utils/tagPosition.js +49 -16
- package/libs/base/BasePlugin.js +1 -1
- package/libs/index.d.ts +1 -0
- package/libs/index.js +166 -150
- package/libs/shared-utils/logger.js +1 -1
- package/package.json +2 -2
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
import * as THREE from 'three';
|
|
2
|
+
import type { DigitalChapter } from '../core/DigitalStateMachine';
|
|
3
|
+
export type { DigitalScript, DigitalChapter, DigitalModelPlayer, DigitalSubTitlePlayer, DigitalCameraPlayer, DigitalModelKeyframe, DigitalSubTitleKeyframe, DigitalCameraKeyframe, DigitalModelState, DigitalSubTitleState, DigitalCameraState, DigitalModelPlayerItem, DigitalModelPlayerEffect, DigitalEffectKeyframe, DigitalDataState, DigitalDataPlayer, KeyframeType, StateType, } from '../core/DigitalStateMachine';
|
|
4
|
+
export interface DigitalPerformancePluginConfig {
|
|
5
|
+
autoPlay?: boolean;
|
|
6
|
+
loop?: boolean;
|
|
7
|
+
debug?: boolean;
|
|
8
|
+
}
|
|
9
|
+
export interface GlobalProgress {
|
|
10
|
+
currentTime: number;
|
|
11
|
+
totalTime: number;
|
|
12
|
+
percentage: number;
|
|
13
|
+
currentChapterIndex: number;
|
|
14
|
+
currentChapterTime: number;
|
|
15
|
+
currentChapter?: DigitalChapter;
|
|
16
|
+
}
|
|
17
|
+
export interface ChapterTimeInfo {
|
|
18
|
+
chapterIndex: number;
|
|
19
|
+
chapterName: string;
|
|
20
|
+
startTime: number;
|
|
21
|
+
duration: number;
|
|
22
|
+
endTime: number;
|
|
23
|
+
chapter: DigitalChapter;
|
|
24
|
+
}
|
|
25
|
+
export interface ChapterLocation {
|
|
26
|
+
chapterIndex: number;
|
|
27
|
+
chapterTime: number;
|
|
28
|
+
chapter: DigitalChapter;
|
|
29
|
+
}
|
|
30
|
+
export type ProgressListener = (progress: GlobalProgress) => void;
|
|
31
|
+
export interface ProgressBarEvents {
|
|
32
|
+
'progress-changed': ProgressListener;
|
|
33
|
+
'chapter-changed': (chapterIndex: number, chapter: DigitalChapter) => void;
|
|
34
|
+
'seek-started': (targetTime: number) => void;
|
|
35
|
+
'seek-completed': (actualTime: number) => void;
|
|
36
|
+
'playback-started': (startTime: number) => void;
|
|
37
|
+
'playback-completed': () => void;
|
|
38
|
+
}
|
|
39
|
+
export interface ExtendedAnimationConfig {
|
|
40
|
+
url: string;
|
|
41
|
+
repeat: boolean;
|
|
42
|
+
switchDuration?: number;
|
|
43
|
+
isOver?: boolean;
|
|
44
|
+
}
|
|
45
|
+
export interface DigitalItemKeyframe {
|
|
46
|
+
visible: boolean;
|
|
47
|
+
timeStamp: number;
|
|
48
|
+
position?: number[];
|
|
49
|
+
quaternion?: number[];
|
|
50
|
+
scale?: number[];
|
|
51
|
+
}
|
|
52
|
+
export interface DigitalItemState {
|
|
53
|
+
visible: boolean;
|
|
54
|
+
translation?: THREE.Vector3;
|
|
55
|
+
quaternion?: THREE.Quaternion;
|
|
56
|
+
scale?: THREE.Vector3;
|
|
57
|
+
keyframeIndex: number;
|
|
58
|
+
isFinal: boolean;
|
|
59
|
+
}
|
|
60
|
+
export interface DigitalEffectState {
|
|
61
|
+
visible: boolean;
|
|
62
|
+
image?: string;
|
|
63
|
+
intensity?: number;
|
|
64
|
+
color?: THREE.Color;
|
|
65
|
+
scale?: THREE.Vector3;
|
|
66
|
+
keyframeIndex: number;
|
|
67
|
+
isFinal: boolean;
|
|
68
|
+
}
|
|
69
|
+
export interface TracePoint {
|
|
70
|
+
position: THREE.Vector3;
|
|
71
|
+
timestamp: number;
|
|
72
|
+
}
|
|
73
|
+
export interface TraceManager {
|
|
74
|
+
tracePoints: THREE.Vector3[];
|
|
75
|
+
maxPoints: number;
|
|
76
|
+
addPoint(point: THREE.Vector3): void;
|
|
77
|
+
clear(): void;
|
|
78
|
+
getPoints(): THREE.Vector3[];
|
|
79
|
+
}
|
|
@@ -12,7 +12,9 @@ import type { PartialObjectDeep } from '../../../typings/typings';
|
|
|
12
12
|
import type { LiteralUnion } from 'type-fest';
|
|
13
13
|
import type { CSS3DObjectPlus } from '../../../shared-utils/CSS3DRender/CSS3DObject';
|
|
14
14
|
import type { Rectangle } from '../../../Sculpt/Objects/Rectangle';
|
|
15
|
-
import { Line } from '@realsee/five/line';
|
|
15
|
+
import type { Line } from '@realsee/five/line';
|
|
16
|
+
import type { Box } from '../../../Sculpt/Objects/Box';
|
|
17
|
+
import type { Polygon } from '../../../Sculpt/typings';
|
|
16
18
|
/**
|
|
17
19
|
* @description 标签实例
|
|
18
20
|
* @property `id` 标签id
|
|
@@ -88,6 +90,8 @@ export declare abstract class BaseTag<C extends TagContentType = TagContentType,
|
|
|
88
90
|
dispose: () => void;
|
|
89
91
|
};
|
|
90
92
|
rectanglePlane?: Rectangle;
|
|
93
|
+
boxShape?: Box;
|
|
94
|
+
polygonShape?: Polygon;
|
|
91
95
|
dom?: HTMLDivElement;
|
|
92
96
|
contentDom?: HTMLDivElement;
|
|
93
97
|
initialConfig: TagData['config'];
|
|
@@ -0,0 +1,119 @@
|
|
|
1
|
+
import type PanoTagPluginController from '..';
|
|
2
|
+
import type { TagContentType, Tag as TagData, TagInstance, ArrayPosition, TagClickParams } from '../..';
|
|
3
|
+
import { BaseTag } from './BaseTag';
|
|
4
|
+
import * as THREE from 'three';
|
|
5
|
+
import type { PartialObjectDeep } from '../../../typings/typings';
|
|
6
|
+
import type { Tag } from '../..';
|
|
7
|
+
import { Box } from '../../../Sculpt/Objects/Box';
|
|
8
|
+
export type BoxTagInterface<C extends TagContentType = TagContentType> = TagInstance<C, '3DBox'>;
|
|
9
|
+
/**
|
|
10
|
+
* 3DBox 类型的标签
|
|
11
|
+
* 使用 Sculpt Box 进行渲染,避免复杂的坐标转换
|
|
12
|
+
*/
|
|
13
|
+
export declare class BoxTag<C extends TagContentType = TagContentType> extends BaseTag<C, '3DBox'> {
|
|
14
|
+
boxShape?: Box;
|
|
15
|
+
private tagStyle?;
|
|
16
|
+
private clickEventDispose?;
|
|
17
|
+
private domClickDispose?;
|
|
18
|
+
screenPosition: {
|
|
19
|
+
leftPx: number;
|
|
20
|
+
topPx: number;
|
|
21
|
+
scale: number;
|
|
22
|
+
} | null;
|
|
23
|
+
constructor(plugin: PanoTagPluginController, tagData: TagData);
|
|
24
|
+
/**
|
|
25
|
+
* 获取 Box 样式配置(合并用户配置和默认值)
|
|
26
|
+
*/
|
|
27
|
+
private getBoxStyle;
|
|
28
|
+
/**
|
|
29
|
+
* 更新 Box 样式
|
|
30
|
+
*/
|
|
31
|
+
private updateBoxStyle;
|
|
32
|
+
/**
|
|
33
|
+
* 更新标签数据
|
|
34
|
+
*/
|
|
35
|
+
set(tag: PartialObjectDeep<Tag<C, '3DBox'>>, deepMerge?: boolean): void;
|
|
36
|
+
/**
|
|
37
|
+
* 设置标签数据
|
|
38
|
+
*/
|
|
39
|
+
setData(...data: Parameters<InstanceType<typeof BaseTag<C, '3DBox'>>['setData']>): void;
|
|
40
|
+
/**
|
|
41
|
+
* 获取盒子的中心点
|
|
42
|
+
*/
|
|
43
|
+
getCenter(): ArrayPosition;
|
|
44
|
+
/**
|
|
45
|
+
* 获取盒子的8个角点坐标
|
|
46
|
+
*/
|
|
47
|
+
getCorners(): THREE.Vector3[];
|
|
48
|
+
/**
|
|
49
|
+
* 计算盒子的法向量
|
|
50
|
+
*/
|
|
51
|
+
computeNormal(): THREE.Vector3;
|
|
52
|
+
/**
|
|
53
|
+
* 初始化 Sculpt Box
|
|
54
|
+
*/
|
|
55
|
+
private initializeSculptBox;
|
|
56
|
+
/**
|
|
57
|
+
* 设置点击事件
|
|
58
|
+
*/
|
|
59
|
+
private setupClickEvents;
|
|
60
|
+
/**
|
|
61
|
+
* 清理点击事件
|
|
62
|
+
*/
|
|
63
|
+
private cleanupClickEvents;
|
|
64
|
+
/**
|
|
65
|
+
* 更新 Sculpt Box 的数据
|
|
66
|
+
*/
|
|
67
|
+
private updateSculptBox;
|
|
68
|
+
/**
|
|
69
|
+
* 启用编辑器
|
|
70
|
+
* 用于编辑已存在的 Box
|
|
71
|
+
*/
|
|
72
|
+
editorEnable(): Promise<void>;
|
|
73
|
+
/**
|
|
74
|
+
* 禁用编辑器
|
|
75
|
+
*/
|
|
76
|
+
editorDisable(): void;
|
|
77
|
+
/**
|
|
78
|
+
* 从 Sculpt Box 同步 position 到 BoxTag
|
|
79
|
+
*/
|
|
80
|
+
private syncBoxPositionFromSculpt;
|
|
81
|
+
/**
|
|
82
|
+
* 将 BoxPosition 转换为 Sculpt 需要的数据格式
|
|
83
|
+
*/
|
|
84
|
+
private boxPositionToSculptData;
|
|
85
|
+
/**
|
|
86
|
+
* @description 点击事件处理
|
|
87
|
+
*/
|
|
88
|
+
onClick(params: Pick<TagClickParams, 'target'>): void;
|
|
89
|
+
/**
|
|
90
|
+
* @description 展开自己,收起其他标签
|
|
91
|
+
*/
|
|
92
|
+
unfoldAndFoldOthers(): void;
|
|
93
|
+
/**
|
|
94
|
+
* 展开标签详情
|
|
95
|
+
*/
|
|
96
|
+
unfold(): void;
|
|
97
|
+
/**
|
|
98
|
+
* 折叠标签详情
|
|
99
|
+
*/
|
|
100
|
+
fold(): void;
|
|
101
|
+
/**
|
|
102
|
+
* 设置展开/折叠状态
|
|
103
|
+
*/
|
|
104
|
+
setUnfold(unfolded: boolean): void;
|
|
105
|
+
/**
|
|
106
|
+
* 更新屏幕位置(用于在 2D UI 中显示内容)
|
|
107
|
+
* 显示在 Box 最右侧的顶点位置
|
|
108
|
+
*/
|
|
109
|
+
updateScreenPosition(): void;
|
|
110
|
+
get centerPosition(): THREE.Vector3;
|
|
111
|
+
/**
|
|
112
|
+
* 应用可见性变化
|
|
113
|
+
*/
|
|
114
|
+
applyVisible(): void;
|
|
115
|
+
/**
|
|
116
|
+
* 销毁标签
|
|
117
|
+
*/
|
|
118
|
+
dispose(): void;
|
|
119
|
+
}
|
|
@@ -0,0 +1,257 @@
|
|
|
1
|
+
import type PanoTagPluginController from '..';
|
|
2
|
+
import type { TagContentType, Tag as TagData, TagInstance, TagClickParams } from '../..';
|
|
3
|
+
import { BaseTag } from './BaseTag';
|
|
4
|
+
import * as THREE from 'three';
|
|
5
|
+
import type { PartialObjectDeep } from '../../../typings/typings';
|
|
6
|
+
import type { Tag } from '../..';
|
|
7
|
+
import type { State as FiveState } from '@realsee/five';
|
|
8
|
+
import type { AnimeParams } from 'animejs';
|
|
9
|
+
export type MaskTagInterface<C extends TagContentType = TagContentType> = TagInstance<C, 'Mask'>;
|
|
10
|
+
/**
|
|
11
|
+
* Mask 类型的标签
|
|
12
|
+
* 基于全景图 mask 和颜色区域进行物体标记
|
|
13
|
+
*/
|
|
14
|
+
export declare class MaskTag<C extends TagContentType = TagContentType> extends BaseTag<C, 'Mask'> {
|
|
15
|
+
/**
|
|
16
|
+
* Mask 纹理缓存(静态,所有 MaskTag 实例共享)
|
|
17
|
+
* key: mask URL 或 canvas 的 symbol, value: { texture: THREE.Texture, refCount: number, abortController?: AbortController }
|
|
18
|
+
*/
|
|
19
|
+
private static maskTextureCache;
|
|
20
|
+
/**
|
|
21
|
+
* Canvas 到 Symbol 的映射(用于缓存 canvas 纹理)
|
|
22
|
+
*/
|
|
23
|
+
private static canvasSymbolMap;
|
|
24
|
+
/** 同点位共用 mesh:key = meshKey(panoIndex + maskKey), value = 共享数据 */
|
|
25
|
+
private static sharedMeshRegistry;
|
|
26
|
+
/**
|
|
27
|
+
* mask 图片 URL 或 Canvas 元素(2:1 全景图格式)
|
|
28
|
+
*/
|
|
29
|
+
maskUrl: string | HTMLCanvasElement;
|
|
30
|
+
/**
|
|
31
|
+
* 目标颜色(RGB 格式)
|
|
32
|
+
*/
|
|
33
|
+
targetColor: [number, number, number];
|
|
34
|
+
/**
|
|
35
|
+
* mask 渲染的 mesh 对象(使用 Sphere)
|
|
36
|
+
*/
|
|
37
|
+
maskMesh?: THREE.Mesh;
|
|
38
|
+
/**
|
|
39
|
+
* mask 纹理对象
|
|
40
|
+
*/
|
|
41
|
+
private maskTexture?;
|
|
42
|
+
/**
|
|
43
|
+
* 是否正在加载 mask
|
|
44
|
+
*/
|
|
45
|
+
private loadingMask;
|
|
46
|
+
/**
|
|
47
|
+
* 资源是否已释放
|
|
48
|
+
*/
|
|
49
|
+
private _disposed;
|
|
50
|
+
/**
|
|
51
|
+
* 标签样式配置
|
|
52
|
+
*/
|
|
53
|
+
private tagStyle?;
|
|
54
|
+
/**
|
|
55
|
+
* 点击事件清理函数
|
|
56
|
+
*/
|
|
57
|
+
private clickEventDispose?;
|
|
58
|
+
/** 当前 tag 在共享 style 纹理中的下标(color 即 id) */
|
|
59
|
+
private sharedStyleIndex;
|
|
60
|
+
/** 共享 mesh 的 registry key,用于 updateMaskStyle / dispose 查找 entry */
|
|
61
|
+
private _sharedMeshKey;
|
|
62
|
+
constructor(plugin: PanoTagPluginController, tagData: TagData);
|
|
63
|
+
private getColorKey;
|
|
64
|
+
/** 同点位共用一个 mesh,key 仅用 panoIndex(string/canvas 切换时不会因 key 不同而重复创建) */
|
|
65
|
+
private static getMeshKey;
|
|
66
|
+
/**
|
|
67
|
+
* 初始化/挂载到同点位共享 mesh,用 appendStyleToMaterial 注册本 tag 的 style(color 即 id)
|
|
68
|
+
*/
|
|
69
|
+
private initializeMaskMesh;
|
|
70
|
+
/** 构建用于 mergedTexture 的 style 对象(color 作 id),tolerance 0–255 */
|
|
71
|
+
private buildStyleForMaterial;
|
|
72
|
+
private static createSharedMesh;
|
|
73
|
+
/** 仅更新材质中某一 slot 的 style(用于 enable/disable/updateMaskStyle) */
|
|
74
|
+
private updateStyleSlotInMaterial;
|
|
75
|
+
private setupSharedMeshRaycast;
|
|
76
|
+
/**
|
|
77
|
+
* 计算法向量
|
|
78
|
+
* Mask 标签返回向上的法向量(因为是贴在 cube 面上)
|
|
79
|
+
*/
|
|
80
|
+
computeNormal(): THREE.Vector3;
|
|
81
|
+
/**
|
|
82
|
+
* 不把共享 mesh 作为 blink 目标,闪烁通过本 tag 的 style opacity 动画实现
|
|
83
|
+
*/
|
|
84
|
+
protected getAdditionalBlinkTargets(): any | any[] | null;
|
|
85
|
+
/**
|
|
86
|
+
* 闪烁仅针对本 tag:通过改变本 tag 在 merged texture 中的 opacity 实现
|
|
87
|
+
*/
|
|
88
|
+
blink(animeConfig?: Partial<AnimeParams>): Promise<void>;
|
|
89
|
+
/**
|
|
90
|
+
* 更新标签数据
|
|
91
|
+
*/
|
|
92
|
+
set(tag: PartialObjectDeep<Tag<C, 'Mask'>>, deepMerge?: boolean): void;
|
|
93
|
+
/** 供 rebuildEntryMaterial 使用:返回当前 tag 的 style 对象 */
|
|
94
|
+
getStyleForMaterial(): {
|
|
95
|
+
color: number[];
|
|
96
|
+
tolerance: number;
|
|
97
|
+
highlightColor: number[];
|
|
98
|
+
opacity: number;
|
|
99
|
+
};
|
|
100
|
+
/**
|
|
101
|
+
* 重写 getVisible 方法
|
|
102
|
+
* Mask 标签仅在当前点位可见
|
|
103
|
+
*/
|
|
104
|
+
getVisible(fiveState?: Partial<FiveState>): boolean;
|
|
105
|
+
/**
|
|
106
|
+
* 重写 computeVisible 方法
|
|
107
|
+
* 增加 Mask 特有的可见性检查逻辑,用于 whyHide 功能
|
|
108
|
+
*/
|
|
109
|
+
protected computeVisible(_fiveState?: Partial<FiveState>): {
|
|
110
|
+
value: boolean;
|
|
111
|
+
reason?: any;
|
|
112
|
+
};
|
|
113
|
+
/**
|
|
114
|
+
* 点击事件处理
|
|
115
|
+
*/
|
|
116
|
+
onClick(params: Pick<TagClickParams, 'target'>): void;
|
|
117
|
+
/**
|
|
118
|
+
* 展开自己,收起其他标签
|
|
119
|
+
*/
|
|
120
|
+
unfoldAndFoldOthers(): void;
|
|
121
|
+
/**
|
|
122
|
+
* 展开标签详情
|
|
123
|
+
*/
|
|
124
|
+
unfold(): void;
|
|
125
|
+
/**
|
|
126
|
+
* 折叠标签详情
|
|
127
|
+
*/
|
|
128
|
+
fold(): void;
|
|
129
|
+
/**
|
|
130
|
+
* 设置展开/折叠状态
|
|
131
|
+
*/
|
|
132
|
+
setUnfold(unfolded: boolean): void;
|
|
133
|
+
/**
|
|
134
|
+
* 更新屏幕位置
|
|
135
|
+
*/
|
|
136
|
+
updateScreenPosition(): void;
|
|
137
|
+
/**
|
|
138
|
+
* 应用可见性变化(通过 style opacity 控制展示,共享 mesh 保持 visible)
|
|
139
|
+
*/
|
|
140
|
+
applyVisible(): void;
|
|
141
|
+
/**
|
|
142
|
+
* 更新 mesh 的位置和旋转(跟随观察者)
|
|
143
|
+
* 参考 itemMask 实现
|
|
144
|
+
*/
|
|
145
|
+
private updateMeshTransform;
|
|
146
|
+
/**
|
|
147
|
+
* 步骤1:从材质中解析出 styleList
|
|
148
|
+
* @param {THREE.ShaderMaterial} material - 目标材质
|
|
149
|
+
* @returns {Array} 解析后的 styleList
|
|
150
|
+
*/
|
|
151
|
+
private parseStyleListFromMaterial;
|
|
152
|
+
/**
|
|
153
|
+
* 步骤2:更新材质的样式纹理(追加新元素后)
|
|
154
|
+
* @param {THREE.ShaderMaterial} material - 目标材质
|
|
155
|
+
* @param {Array} newStyle - 要追加的新样式对象
|
|
156
|
+
*/
|
|
157
|
+
private appendStyleToMaterial;
|
|
158
|
+
/**
|
|
159
|
+
* 获取 Mask 样式配置(合并用户配置和默认值)
|
|
160
|
+
*/
|
|
161
|
+
private getMaskStyle;
|
|
162
|
+
/**
|
|
163
|
+
* 设置点击事件(仅当 raycast 命中本 tag 的 color 时触发)
|
|
164
|
+
*/
|
|
165
|
+
private setupClickEvents;
|
|
166
|
+
/**
|
|
167
|
+
* 清理点击事件
|
|
168
|
+
*/
|
|
169
|
+
private cleanupClickEvents;
|
|
170
|
+
/**
|
|
171
|
+
* 重新加载 mask 图:从旧点位 mesh 注销,再按新 maskUrl 初始化
|
|
172
|
+
*/
|
|
173
|
+
private reloadMask;
|
|
174
|
+
/**
|
|
175
|
+
* changeTagById 改 mask 时:只更新共享 mesh 的 texture,不 unregister
|
|
176
|
+
* 有 entry 则换图;无 entry 则走完整初始化
|
|
177
|
+
*/
|
|
178
|
+
private updateSharedMeshTexture;
|
|
179
|
+
/**
|
|
180
|
+
* 更新当前 tag 在共享材质中的 style slot(color/style 控制展示)
|
|
181
|
+
*/
|
|
182
|
+
updateMaskStyle(): void;
|
|
183
|
+
/**
|
|
184
|
+
* 更新 Canvas 纹理(仅当 maskUrl 为 Canvas 时有效)
|
|
185
|
+
* 当 canvas 内容发生变化时,调用此方法更新渲染
|
|
186
|
+
*/
|
|
187
|
+
updateCanvasTexture(): void;
|
|
188
|
+
/**
|
|
189
|
+
* 清理当前标签:从共享材质中删除本 tag 的样式槽,并更新材质;
|
|
190
|
+
* 若该点位已无其他 tag 则销毁 mesh 并释放纹理。
|
|
191
|
+
*/
|
|
192
|
+
private disposeMaskResources;
|
|
193
|
+
/**
|
|
194
|
+
* 清理 MaskTag 特有的资源(公开方法)
|
|
195
|
+
*/
|
|
196
|
+
dispose(): void;
|
|
197
|
+
/**
|
|
198
|
+
* 禁用标签(通过 style opacity=0 隐藏,不拆 mesh)
|
|
199
|
+
*/
|
|
200
|
+
disable(): void;
|
|
201
|
+
/**
|
|
202
|
+
* 启用标签(恢复 style 展示)
|
|
203
|
+
*/
|
|
204
|
+
enable(): void;
|
|
205
|
+
/**
|
|
206
|
+
* 销毁标签(重写父类方法)
|
|
207
|
+
*/
|
|
208
|
+
destroy(): void;
|
|
209
|
+
/**
|
|
210
|
+
* 清除所有点位共享 mesh(重新 load 数据前调用)
|
|
211
|
+
*/
|
|
212
|
+
static clearSharedMeshRegistry(): void;
|
|
213
|
+
/**
|
|
214
|
+
* 将 style 列表写入材质(用于重建材质)
|
|
215
|
+
*/
|
|
216
|
+
private static writeStyleListToMaterial;
|
|
217
|
+
/**
|
|
218
|
+
* destroy 后重建该点位材质,更新剩余 tag 的 styleIndex
|
|
219
|
+
*/
|
|
220
|
+
private static rebuildEntryMaterial;
|
|
221
|
+
/**
|
|
222
|
+
* 获取 mask 的缓存 key
|
|
223
|
+
* @param maskSource mask URL 或 Canvas
|
|
224
|
+
* @returns 缓存 key
|
|
225
|
+
*/
|
|
226
|
+
private static getMaskCacheKey;
|
|
227
|
+
/**
|
|
228
|
+
* 加载 Mask 纹理(静态方法,支持缓存和引用计数)
|
|
229
|
+
* @param maskSource mask 图片 URL 或 Canvas 元素
|
|
230
|
+
* @returns Promise<THREE.Texture>
|
|
231
|
+
*/
|
|
232
|
+
private static loadMaskTexture;
|
|
233
|
+
/**
|
|
234
|
+
* 释放 Mask 纹理(静态方法)
|
|
235
|
+
* @param maskSource mask 图片 URL 或 Canvas 元素
|
|
236
|
+
*/
|
|
237
|
+
private static releaseMaskTexture;
|
|
238
|
+
/**
|
|
239
|
+
* 获取当前缓存的纹理统计信息(用于性能监控和调试)
|
|
240
|
+
* @returns 缓存统计信息
|
|
241
|
+
*/
|
|
242
|
+
static getCacheStats(): {
|
|
243
|
+
totalCached: number;
|
|
244
|
+
totalRefCount: number;
|
|
245
|
+
estimatedMemoryMB: number;
|
|
246
|
+
cacheEntries: Array<{
|
|
247
|
+
source: string;
|
|
248
|
+
refCount: number;
|
|
249
|
+
sizeMB: number;
|
|
250
|
+
}>;
|
|
251
|
+
};
|
|
252
|
+
/**
|
|
253
|
+
* 强制清理所有缓存的纹理(用于内存管理,谨慎使用)
|
|
254
|
+
* 注意:这会释放所有纹理,即使它们仍在使用中
|
|
255
|
+
*/
|
|
256
|
+
static clearAllCache(): void;
|
|
257
|
+
}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Mask 标签的 Shader 代码
|
|
3
|
+
* 参考 itemMask 插件实现
|
|
4
|
+
*/
|
|
5
|
+
/**
|
|
6
|
+
* Vertex Shader
|
|
7
|
+
*/
|
|
8
|
+
export declare const maskVertexShader = "\nvarying vec2 vUv;\nvoid main() {\n vUv = uv;\n gl_Position = projectionMatrix * modelViewMatrix * vec4(position, 1.0);\n}\n";
|
|
9
|
+
/** 多 style:mergedTexture 中每组 3 像素为 color(id)/tolerance+highlight/opacity,用 color 作 id 匹配 */
|
|
10
|
+
export declare const maskFragmentShaderMulti = "\n#define RESOLUTION 2048.0\n#define MAX_GROUPS 64\n#define STRICT_MATCH 0.5/255.0\n\nvarying vec2 vUv;\nuniform sampler2D map;\nuniform sampler2D mergedTexture;\nuniform float groupCount;\nuniform float textureWidth;\nuniform float pixelsPerGroup;\n\nfloat colorGap(vec3 a, vec3 b) {\n return abs(a.r - b.r) + abs(a.g - b.g) + abs(a.b - b.b);\n}\n\nvec4 readStyleColor(float groupIndex) {\n float px = groupIndex * pixelsPerGroup;\n float texX = (px + 0.5) / textureWidth;\n return texture2D(mergedTexture, vec2(texX, 0.5));\n}\n\nvec4 readStyleToleranceHighlight(float groupIndex) {\n float px = groupIndex * pixelsPerGroup + 1.0;\n float texX = (px + 0.5) / textureWidth;\n return texture2D(mergedTexture, vec2(texX, 0.5));\n}\n\nfloat readStyleOpacity(float groupIndex) {\n float px = groupIndex * pixelsPerGroup + 2.0;\n float texX = (px + 0.5) / textureWidth;\n return texture2D(mergedTexture, vec2(texX, 0.5)).r;\n}\n\nfloat detectEdge(sampler2D map, vec2 uv, vec3 matchColor, float tolerance) {\n vec4 centerColor = texture2D(map, uv);\n if (colorGap(centerColor.rgb, matchColor) >= tolerance) return 0.0;\n float step = 1.0 / RESOLUTION;\n vec4 u = texture2D(map, uv + vec2(0.0, -step));\n vec4 l = texture2D(map, uv + vec2(-step, 0.0));\n vec4 r = texture2D(map, uv + vec2(step, 0.0));\n vec4 d = texture2D(map, uv + vec2(0.0, step));\n bool edge = colorGap(u.rgb, matchColor) >= tolerance || colorGap(l.rgb, matchColor) >= tolerance\n || colorGap(r.rgb, matchColor) >= tolerance || colorGap(d.rgb, matchColor) >= tolerance;\n return edge ? 1.0 : 0.0;\n}\n\nvoid main() {\n vec4 image = texture2D(map, vUv);\n if (image.r == 0.0 && image.g == 0.0 && image.b == 0.0) discard;\n\n // WebGL 1.0 \u8981\u6C42\u5FAA\u73AF\u7EC8\u6B62\u6761\u4EF6\u5FC5\u987B\u662F\u7F16\u8BD1\u65F6\u5E38\u91CF\uFF0C\u6240\u4EE5\u7528 MAX_GROUPS\uFF0C\u5FAA\u73AF\u5185\u68C0\u67E5 groupCount\n for (float i = 0.0; i < float(MAX_GROUPS); i += 1.0) {\n if (i < groupCount) {\n vec4 styleColor = readStyleColor(i);\n vec3 colorRgb = styleColor.rgb;\n float tol = readStyleToleranceHighlight(i).r * 3.0;\n vec3 highlight = readStyleToleranceHighlight(i).gba;\n float opacity = readStyleOpacity(i);\n \n if (opacity > 0.0) {\n float gap = colorGap(image.rgb, colorRgb);\n if (gap > STRICT_MATCH) continue;\n float smoothRange = 0.01;\n float matchFactor = 1.0 - smoothstep(tol - smoothRange, tol + smoothRange, gap);\n if (matchFactor > 0.0) {\n float isEdge = detectEdge(map, vUv, colorRgb, tol);\n float alpha = mix(opacity, 1.0, isEdge);\n alpha *= max(matchFactor, 0.9);\n gl_FragColor = vec4(highlight, alpha);\n return;\n }\n }\n }\n }\n discard;\n}\n";
|
|
@@ -0,0 +1,112 @@
|
|
|
1
|
+
import type PanoTagPluginController from '..';
|
|
2
|
+
import type { TagContentType, Tag as TagData, TagInstance, ArrayPosition, TagClickParams } from '../..';
|
|
3
|
+
import { BaseTag } from './BaseTag';
|
|
4
|
+
import * as THREE from 'three';
|
|
5
|
+
import type { PartialObjectDeep } from '../../../typings/typings';
|
|
6
|
+
import type { Tag } from '../..';
|
|
7
|
+
import { Polygon } from '../../../Sculpt/Objects/Polygon';
|
|
8
|
+
export type PolygonTagInterface<C extends TagContentType = TagContentType> = TagInstance<C, 'Polygon'>;
|
|
9
|
+
/**
|
|
10
|
+
* Polygon 类型的标签
|
|
11
|
+
* 使用 Sculpt Polygon 进行渲染
|
|
12
|
+
*/
|
|
13
|
+
export declare class PolygonTag<C extends TagContentType = TagContentType> extends BaseTag<C, 'Polygon'> {
|
|
14
|
+
polygonShape?: Polygon;
|
|
15
|
+
private tagStyle?;
|
|
16
|
+
private clickEventDispose?;
|
|
17
|
+
private domClickDispose?;
|
|
18
|
+
screenPosition: {
|
|
19
|
+
leftPx: number;
|
|
20
|
+
topPx: number;
|
|
21
|
+
scale: number;
|
|
22
|
+
} | null;
|
|
23
|
+
constructor(plugin: PanoTagPluginController, tagData: TagData);
|
|
24
|
+
/**
|
|
25
|
+
* 获取 Polygon 样式配置(合并用户配置和默认值)
|
|
26
|
+
*/
|
|
27
|
+
private getPolygonStyle;
|
|
28
|
+
/**
|
|
29
|
+
* 更新 Polygon 样式
|
|
30
|
+
*/
|
|
31
|
+
private updatePolygonStyle;
|
|
32
|
+
/**
|
|
33
|
+
* 更新标签数据
|
|
34
|
+
*/
|
|
35
|
+
set(tag: PartialObjectDeep<Tag<C, 'Polygon'>>, deepMerge?: boolean): void;
|
|
36
|
+
/**
|
|
37
|
+
* 获取多边形的所有角点(世界坐标)
|
|
38
|
+
*/
|
|
39
|
+
getCorners(): THREE.Vector3[];
|
|
40
|
+
getCenter(): ArrayPosition;
|
|
41
|
+
/**
|
|
42
|
+
* 计算多边形的法向量
|
|
43
|
+
* 使用前三个点来计算平面的法向量
|
|
44
|
+
*/
|
|
45
|
+
computeNormal(): THREE.Vector3 | undefined;
|
|
46
|
+
/**
|
|
47
|
+
* 初始化 Sculpt Polygon
|
|
48
|
+
*/
|
|
49
|
+
private initializeSculptPolygon;
|
|
50
|
+
/**
|
|
51
|
+
* 设置点击事件
|
|
52
|
+
*/
|
|
53
|
+
private setupClickEvents;
|
|
54
|
+
/**
|
|
55
|
+
* 清理点击事件
|
|
56
|
+
*/
|
|
57
|
+
private cleanupClickEvents;
|
|
58
|
+
/**
|
|
59
|
+
* 更新 Sculpt Polygon 的数据
|
|
60
|
+
*/
|
|
61
|
+
private updateSculptPolygon;
|
|
62
|
+
/**
|
|
63
|
+
* 启用编辑器
|
|
64
|
+
* 用于编辑已存在的 Polygon
|
|
65
|
+
*/
|
|
66
|
+
editorEnable(): Promise<void>;
|
|
67
|
+
/**
|
|
68
|
+
* 禁用编辑器
|
|
69
|
+
*/
|
|
70
|
+
editorDisable(): void;
|
|
71
|
+
/**
|
|
72
|
+
* 同步 Sculpt Polygon 的数据到 PolygonPosition
|
|
73
|
+
*/
|
|
74
|
+
private syncPolygonPositionFromSculpt;
|
|
75
|
+
/**
|
|
76
|
+
* @description 点击事件处理
|
|
77
|
+
*/
|
|
78
|
+
onClick(params: Pick<TagClickParams, 'target'>): void;
|
|
79
|
+
/**
|
|
80
|
+
* @description 展开自己,收起其他标签
|
|
81
|
+
*/
|
|
82
|
+
unfoldAndFoldOthers(): void;
|
|
83
|
+
/**
|
|
84
|
+
* 展开标签详情
|
|
85
|
+
*/
|
|
86
|
+
unfold(): void;
|
|
87
|
+
/**
|
|
88
|
+
* 折叠标签详情
|
|
89
|
+
*/
|
|
90
|
+
fold(): void;
|
|
91
|
+
/**
|
|
92
|
+
* 设置展开/折叠状态
|
|
93
|
+
*/
|
|
94
|
+
setUnfold(unfolded: boolean): void;
|
|
95
|
+
/**
|
|
96
|
+
* 获取多边形的中心点
|
|
97
|
+
*/
|
|
98
|
+
private getPolygonCenter;
|
|
99
|
+
/**
|
|
100
|
+
* 更新屏幕位置(用于在 2D UI 中显示内容)
|
|
101
|
+
* 显示在 Polygon 最右侧的顶点位置
|
|
102
|
+
*/
|
|
103
|
+
updateScreenPosition(): void;
|
|
104
|
+
/**
|
|
105
|
+
* 应用可见性变化
|
|
106
|
+
*/
|
|
107
|
+
applyVisible(): void;
|
|
108
|
+
/**
|
|
109
|
+
* 销毁标签
|
|
110
|
+
*/
|
|
111
|
+
dispose(): void;
|
|
112
|
+
}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import type { TagObjectGroup, TagGLTFObjectGroup, ImagePlaneGroup, TagContentType, ElementRenderer, TagRendererMap, TagContentTypeMapping } from '../typings';
|
|
2
2
|
import type { TemporaryState } from '../typings';
|
|
3
|
-
import TagContainerSvelte from '../Components/TagContainer.svelte';
|
|
3
|
+
import type TagContainerSvelte from '../Components/TagContainer.svelte';
|
|
4
4
|
import type { Five } from '@realsee/five';
|
|
5
5
|
import { TagUtil } from './TagUtil';
|
|
6
6
|
export declare abstract class TagRender extends TagUtil {
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import type { Tag, TagId, Tags, State, ContentTypeConfigKey } from '../typings';
|
|
2
2
|
import type { TagClickParams, TagConfigByKey, TagContentType } from '..';
|
|
3
3
|
import type { ArrayPosition } from '../typings';
|
|
4
|
-
import {
|
|
4
|
+
import type { Five } from '@realsee/five';
|
|
5
5
|
import { TagRender } from './TagRender';
|
|
6
6
|
import type { PartialObjectDeep } from '../../typings/typings';
|
|
7
7
|
export declare const pluginFlag: (name: string) => string;
|
|
@@ -28,8 +28,13 @@ declare class PanoTagPluginController extends TagRender {
|
|
|
28
28
|
load(data: Tags): Promise<void>;
|
|
29
29
|
/**
|
|
30
30
|
* @description 添加标签
|
|
31
|
+
* @param tag 标签或标签数组
|
|
32
|
+
* @param options 可选配置
|
|
33
|
+
* @param options.updateMaskUrl 是否更新 mask。若为 true 且该 panoIndex 已有 Mask 标签,仅更新其 maskUrl(不变 color、style),并添加新标签
|
|
31
34
|
*/
|
|
32
|
-
addTag(tag: Tag | Tag[]
|
|
35
|
+
addTag(tag: Tag | Tag[], options?: {
|
|
36
|
+
updateMaskUrl?: boolean;
|
|
37
|
+
}): Promise<void>;
|
|
33
38
|
/**
|
|
34
39
|
* @description 改变配置
|
|
35
40
|
*/
|
|
@@ -103,6 +108,19 @@ declare class PanoTagPluginController extends TagRender {
|
|
|
103
108
|
* @description 改变tag任意属性
|
|
104
109
|
*/
|
|
105
110
|
changeTagById<C extends TagContentType = TagContentType>(id: TagId, tag: PartialObjectDeep<Tag<C>>, deepMerge?: boolean): void;
|
|
111
|
+
/**
|
|
112
|
+
* @description 批量更新指定点位的 Mask 图
|
|
113
|
+
* @param maskUpdates 包含点位索引和对应 mask 的数组
|
|
114
|
+
* @example
|
|
115
|
+
* changeMask([
|
|
116
|
+
* { index: 0, mask: 'https://example.com/mask1.png' },
|
|
117
|
+
* { index: 1, mask: canvasElement }
|
|
118
|
+
* ])
|
|
119
|
+
*/
|
|
120
|
+
changeMask(maskUpdates: Array<{
|
|
121
|
+
index: number;
|
|
122
|
+
mask: string | HTMLCanvasElement;
|
|
123
|
+
}>): void;
|
|
106
124
|
/**
|
|
107
125
|
* @description 销毁tag
|
|
108
126
|
*/
|
|
@@ -166,6 +184,41 @@ declare class PanoTagPluginController extends TagRender {
|
|
|
166
184
|
* @returns 是否为有效的 ArrayPosition
|
|
167
185
|
*/
|
|
168
186
|
private isValidArrayPosition;
|
|
187
|
+
/**
|
|
188
|
+
* 更新当前点位的 Mask 标签
|
|
189
|
+
* Mask 标签仅在当前点位可见
|
|
190
|
+
*/
|
|
191
|
+
private updateMaskTagsForCurrentPano;
|
|
192
|
+
/**
|
|
193
|
+
* 获取所有 Mask 类型的标签
|
|
194
|
+
*/
|
|
195
|
+
get filterMaskTag(): (import("./Tag/BaseTag").BaseTag<"Panorama" | "Model" | "Custom" | "Audio" | "Text" | "ImageText" | "Image" | "Video" | "Link" | "Sticker" | "VRLink" | "PanoLink" | "Marketing" | "MediaPlane" | "MediaModel" | "Unknown", import("..").StickType> & {
|
|
196
|
+
[key: string]: any;
|
|
197
|
+
})[];
|
|
198
|
+
/**
|
|
199
|
+
* 获取 MaskTag 性能统计信息(用于性能监控和调试)
|
|
200
|
+
* @returns 性能统计信息
|
|
201
|
+
*/
|
|
202
|
+
getMaskTagPerformanceStats(): {
|
|
203
|
+
totalMaskTags: number;
|
|
204
|
+
visibleMaskTags: number;
|
|
205
|
+
textureCache: {
|
|
206
|
+
totalCached: number;
|
|
207
|
+
totalRefCount: number;
|
|
208
|
+
estimatedMemoryMB: number;
|
|
209
|
+
cacheEntries: {
|
|
210
|
+
source: string;
|
|
211
|
+
refCount: number;
|
|
212
|
+
sizeMB: number;
|
|
213
|
+
}[];
|
|
214
|
+
};
|
|
215
|
+
currentPanoIndex: number;
|
|
216
|
+
};
|
|
217
|
+
/**
|
|
218
|
+
* 清理所有 MaskTag 纹理缓存(用于内存管理)
|
|
219
|
+
* 注意:这会释放所有纹理缓存,谨慎使用
|
|
220
|
+
*/
|
|
221
|
+
clearMaskTagCache(): void;
|
|
169
222
|
}
|
|
170
223
|
export default PanoTagPluginController;
|
|
171
224
|
export { PanoTagPluginController };
|