import type { Five } from '@realsee/five'; import * as THREE from 'three'; import type { DigitalModelPlayer } from './DigitalStateMachine'; export declare const DEFAULT_DIGITAL_PERFORMANCE_NAME_MAX_LENGTH = 30; /** 规范化名牌文本,使用 Unicode code point 计数,避免 emoji 被截成半个字符。 */ export declare function normalizeDigitalPerformanceName(value: unknown, maxLength?: number): string; export interface DigitalPerformanceNameplateBinding { id: string; player: DigitalModelPlayer; /** 用于计算包围盒和世界坐标的数字人模型根节点。 */ model: THREE.Object3D; } export interface DigitalPerformanceNameplateRenderContext { id: string; text: string; player: DigitalModelPlayer; model: THREE.Object3D; } export interface DigitalPerformanceNameplateOptions { /** 名牌最多展示的 Unicode 字符数,默认 30。 */ maxLength?: number; /** 相对模型包围盒顶部的世界坐标偏移,默认 [0, 0.12, 0]。 */ offset?: [number, number, number]; /** 自定义名牌文本,默认使用 displayName ?? name。 */ getText?: (player: DigitalModelPlayer) => string | undefined | null; /** 自定义名牌元素;不传时创建默认气泡 div。 */ createElement?: (context: DigitalPerformanceNameplateRenderContext) => HTMLElement; /** 自定义名牌更新逻辑;不传时将 textContent 更新为当前文本。 */ updateElement?: (element: HTMLElement, context: DigitalPerformanceNameplateRenderContext) => void; /** 名牌元素 class。 */ className?: string; /** 名牌元素的额外内联样式。 */ style?: Record; /** overlay 容器 class。 */ containerClassName?: string; /** overlay 容器的额外内联样式。 */ containerStyle?: Record; /** * 调试:是否显示每个绑定模型的世界包围盒(THREE.BoxHelper),用于核对名牌锚点。 * 默认 false,不影响名牌本身。 */ debugBoundingBox?: boolean; } /** * DigitalPerformance 的 2D 名牌层。 * * 它只负责「模型世界坐标 → 播放器 overlay DOM」和名牌生命周期, * 由 Legacy/V2 controller 在各自的模型帧更新完成后调用 update(),因此两个播放器共用同一套 DOM 规则。 */ export declare class DigitalPerformanceNameplate { private readonly five; private options; private parent; private container; private bindings; private nameOverrides; private enabled; /** 是否由本层自动挂载到 five canvas 父容器(插件内置模式),无需调用方提供容器。 */ private autoMount; private readonly onResize; private readonly anchor; private readonly box; private readonly offset; private readonly debugBoxes; private debugBoxesVisible; constructor(five: Five, options?: DigitalPerformanceNameplateOptions); /** 将 overlay 挂到 Five canvas 的父级或业务提供的全屏相对定位容器。 */ mount(parent: HTMLElement, options?: DigitalPerformanceNameplateOptions): void; /** * 内置自动挂载:把 overlay 挂到 five canvas 的父容器(与 canvas 同级),调用方无需提供容器。 * canvas 尚未进入 DOM 时不报错,会在后续 update() 中自动重试挂载。 */ enableAutoMount(options?: DigitalPerformanceNameplateOptions): void; /** 移除 overlay,但保留 bindings;重新挂载(含换容器)时会复用 bindings。 */ unmount(): void; /** 更新当前章节的角色绑定;id 是角色唯一键,同一模型复用时也不会互相覆盖。 */ setBindings(bindings: DigitalPerformanceNameplateBinding[]): void; /** 实时更新指定角色名称,不需要重新加载模型或动画资源。 */ updateName(id: string, value: string): void; setEnabled(enabled: boolean): void; /** * 调试:显示/隐藏每个绑定模型的世界包围盒(THREE.BoxHelper)。 * 包围盒与名牌锚点使用的是同一个 Box3(setFromObject(model)),用于核对名牌定位。 * 默认关闭;不影响名牌本身。 */ setBoundingBoxVisible(visible: boolean): void; /** 应用 `options.debugBoundingBox`;未配置时保持现状(不覆盖运行时的 setBoundingBoxVisible)。 */ private applyDebugBoundingBoxOption; isEnabled(): boolean; /** 在数字人模型变换完成后调用,更新所有当前章节名牌的位置和可见性。 */ update(): void; dispose(): void; /** 内置自动挂载的实际执行:解析 five canvas 的父容器并 mount;条件不满足时静默跳过。 */ private tryAutoMount; private getMaxLength; private getText; private ensureElement; private applyElementContent; private hideElement; private applyContainerStyle; private applyElementStyle; /** * 注入名牌气泡箭头的伪元素样式。 * 该样式是模块级全局资源(选择器为 .digital-performance-nameplate::after), * 因此只在 mount 时按 id 幂等注入一次,而不是在每个名牌元素创建时重复注入。 * 当调用方完全自定义了 className 时,箭头选择器不会命中,也就无需注入。 */ private injectArrowStyle; private isObjectVisible; /** 同步单个绑定的调试包围盒;未开启时 no-op。 */ private syncDebugBox; private removeDebugBox; private clearDebugBoxes; private getScreenPosition; }