Prechádzať zdrojové kódy

feat: ai图例调优

bill 2 mesiacov pred
rodič
commit
95700958ee

+ 2 - 3
src/example/platform/platform-draw.ts

@@ -18,6 +18,7 @@ import { watchEffect } from "vue";
 import { TextData } from "@/core/components/text";
 
 const scaleResource = (info: AIExposeData, scale: number) => {
+  console.log(info.taggings)
   const floors = info.floors.map((item) => ({
     ...item,
     geos: item.geos.map((geo) =>
@@ -60,7 +61,6 @@ const scaleResource = (info: AIExposeData, scale: number) => {
         if (!floor || !floor.box) return;
         const w = floor.box.bound.x_max - floor.box.bound.x_min;
         const h = floor.box.bound.y_max - floor.box.bound.y_min;
-        console.log(item.size)
         return {
           ...item,
           position: {
@@ -68,7 +68,6 @@ const scaleResource = (info: AIExposeData, scale: number) => {
             y: floor.box.bound.y_min + h * item.position.y,
             z: floor.box.bound.z_min + 0.001,
           },
-          fixed: true,
           size: item.size
             ? {
                 width: item.size!.width * w,
@@ -318,7 +317,7 @@ const drawLayerResource = async (
             item.url,
             item.size?.width,
             item.size?.height,
-            // item.fixed,
+            item.fixed,
           );
         } catch {}
       }

+ 21 - 14
src/example/platform/platform-resource.ts

@@ -4,7 +4,6 @@ import { validNum } from "@/utils/shared";
 import { aiIconMap, iconGroups } from "../constant";
 import { Euler, MathUtils, Object3D, Quaternion, Vector3 } from "three";
 import { getSvgContent, parseSvgContent } from "@/utils/resource";
-import { getIconStyle } from "@/core/components/icon";
 
 export enum SCENE_TYPE {
   fuse = "fuse",
@@ -339,25 +338,33 @@ export const taggingGets = {
                   : `./icons/${icon ? icon : "circle"}.svg`,
                 name,
                 pixel: true,
+                fixed: false,
                 size,
                 subgroup,
               };
               if (isWall) {
                 const wh = Math.max(item.size.width, item.size.height);
-                if (wh === item.size.width) {
-                  item.position.y -= wh / 2;
-                } else {
-                  item.rotate = Math.PI / 2;
-                  loadPromises.push(
-                    getIconStyle(item.url, wh, wh).then((style) => {
-                      item.position.x += style.height / 2;
-                    }).catch(() => {})
-                  );
-                }
-                item.size.width = wh;
-                item.size.height = wh;
+                loadPromises.push(
+                  getSvgContent(item.url).then((svgContent) => {
+                    const content = parseSvgContent(svgContent);
+                    item.fixed = true
+                    // item.size.width = item.size.height = wh
+                    if (wh === item.size.width) {
+                      item.size.width = wh
+                      item.size.height = data.imageWidth / data.imageHeight * (content.height / content.width * wh) 
+                      item.position.y -= item.size.height / 2;
+                    } else {
+                      item.size.height = wh
+                      item.size.width = data.imageHeight / data.imageWidth * (content.width / content.height * wh) 
+                      item.position.x += item.size.height / 2;
+                      item.rotate = Math.PI / 2;
+                    }
+                    tags.push(item as any);
+                  }).catch(() => {})
+                );
+              } else {
+                tags.push(item as any);
               }
-              tags.push(item as any);
             } else {
               console.error("找不到ai家具", icon, name, pos);
             }