update: clean map hierarchy and mesh model names
🔍 Lint / 🪄 Check lint (pull_request) Has been cancelled
🔍 Lint / 🎨 Check format (pull_request) Has been cancelled
🔍 Lint / 🔎 Typecheck (pull_request) Has been cancelled
📊 Quality / 🔒 Security Audit (pull_request) Has been cancelled
📊 Quality / 📋 Dependency Freshness (pull_request) Has been cancelled
📊 Quality / 📦 Bundle Size (pull_request) Has been cancelled
🔍 Lint / 🏗 Build (pull_request) Has been cancelled

This commit is contained in:
Tom Boullay
2026-05-14 17:25:39 +02:00
parent cea2856fd0
commit cdd919c010
6 changed files with 15433 additions and 75317 deletions
+38 -5
View File
@@ -1,4 +1,4 @@
import type { MapNode } from "../../types/editor/editor";
import type { HierarchicalMapNode, MapNode } from "../../types/editor/editor";
function isRecord(value: unknown): value is Record<string, unknown> {
return typeof value === "object" && value !== null;
@@ -26,10 +26,43 @@ function isMapNode(value: unknown): value is MapNode {
);
}
export function parseMapNodes(value: unknown): MapNode[] {
if (!Array.isArray(value) || !value.every(isMapNode)) {
throw new Error("Invalid map node data");
function isHierarchicalMapNode(value: unknown): value is HierarchicalMapNode {
if (!isMapNode(value)) {
return false;
}
return value;
if (!("children" in value)) {
return true;
}
return (
value.children === undefined ||
(Array.isArray(value.children) &&
value.children.every(isHierarchicalMapNode))
);
}
function flattenMapNode(node: HierarchicalMapNode): MapNode[] {
const mapNode: MapNode = {
name: node.name,
type: node.type,
position: node.position,
rotation: node.rotation,
scale: node.scale,
};
const childNodes = node.children?.flatMap(flattenMapNode) ?? [];
return [mapNode, ...childNodes];
}
export function parseMapNodes(value: unknown): MapNode[] {
if (Array.isArray(value) && value.every(isHierarchicalMapNode)) {
return value.flatMap(flattenMapNode);
}
if (isHierarchicalMapNode(value)) {
return flattenMapNode(value);
}
throw new Error("Invalid map node data");
}
+1 -1
View File
@@ -20,7 +20,7 @@ function disposeMaterial(material: THREE.Material): void {
material.dispose();
for (const key of Object.keys(material)) {
const value = (material as Record<string, unknown>)[key];
const value = (material as unknown as Record<string, unknown>)[key];
if (value instanceof THREE.Texture) {
value.dispose();
}