feat(all): 迁移扩展相关功能

This commit is contained in:
plum
2026-04-08 15:34:43 +08:00
parent ad2dd979eb
commit d7c0dba569
278 changed files with 25207 additions and 62 deletions
+38
View File
@@ -0,0 +1,38 @@
import type { Object3D } from "three";
export const UIPANEL_TYPES = new Set(["UIPanel", "UIPanelBlock", "UIPanelText", "UIPanelInline", "UIPanelInlineBlock"]);
/**
* 判断是否是UIPanel 3D对象
*/
export function isUIPanelObject(object:Object3D | null){
return object && object.type === "UIPanel" && object.options;
}
export function isUIPanelRelatedObject(object: Object3D | null) {
if (!object) return false;
if (UIPANEL_TYPES.has(object.type)) return true;
// return Boolean(findUIPanelNodeId(object));
if (object.metadata?.__uiPanelRootId || object.metadata?.__uiPanelNodeId) return true;
return false;
}
export function findUIPanelRoot(object: Object3D | null) {
let current: Object3D | null = object;
while (current) {
if (isUIPanelObject(current)) return current;
current = current.parent;
}
return null;
}
export function findUIPanelNodeId(object: Object3D | null) {
let current: any = object;
while (current) {
const nodeId = current.metadata?.__uiPanelNodeId;
if (nodeId) return nodeId as string;
current = current.parent;
}
return null;
}