浏览代码

Merge branch 'master' into merge-selection

bill 2 月之前
父节点
当前提交
04fac0d2f2

+ 1 - 1
package.json

@@ -1,7 +1,7 @@
 {
   "name": "drawing-board-service",
   "private": true,
-  "version": "0.0.0",
+  "version": "1.0.0",
   "type": "module",
   "scripts": {
     "dev:fuse": "vite --mode=fusedev",

+ 1 - 1
src/core/components/icon/icon.ts

@@ -56,7 +56,7 @@ export const getIconStyle = async (
 ) => {
   const svgContent = parseSvgContent(await getSvgContent(url));
   if (!fixed) {
-    if (width / height < svgContent.width / svgContent.height) {
+    if (width / height > svgContent.width / svgContent.height) {
       width = (svgContent.width / svgContent.height) * height;
     } else {
       height = (svgContent.height / svgContent.width) * width;

+ 2 - 0
src/core/components/serial/serial-group.vue

@@ -153,6 +153,8 @@ const syncTable = (table: TableData) => {
       }
       table.content.push(cols);
     }
+    
+
     isUpdate = true;
   }
   return isUpdate;

+ 7 - 7
src/example/constant.ts

@@ -5,18 +5,18 @@ export const iconGroups = [
       {
         name: "门",
         children: [
-          { icon: "cad-men", name: "门" },
-          { icon: "cad-shuangkaimen", name: "双开门" },
-          { icon: "cad-yimen", name: "移门" },
-          { icon: "cad-yakou", name: "哑口" },
+          { wall: true, icon: "cad-men", name: "门" },
+          { wall: true, icon: "cad-shuangkaimen", name: "双开门" },
+          { wall: true, icon: "cad-yimen", name: "移门" },
+          { wall: true, icon: "cad-yakou", name: "哑口" },
         ],
       },
       {
         name: "窗",
         children: [
-          { icon: "cad-chuang", name: "窗" },
-          { icon: "cad-piaochuang", name: "飘窗" },
-          { icon: "cad-luodichuang", name: "落地窗" },
+          { wall: true, icon: "cad-chuang", name: "窗" },
+          { wall: true, icon: "cad-piaochuang", name: "飘窗" },
+          { wall: true, icon: "cad-luodichuang", name: "落地窗" },
         ],
       },
       {

+ 2 - 2
src/example/fuse/views/overview/header.vue

@@ -129,8 +129,8 @@ const setViewToTableCover = async () => {
   draw.config.showCompass = false;
 
   draw.config.labelLineConfig.type = "auto";
-  draw.config.labelLineConfig.strokeWidth = 2;
-  draw.config.labelLineConfig.fontSize = 10;
+  draw.config.labelLineConfig.fontSize = width / 60;
+  draw.config.labelLineConfig.strokeWidth = draw.config.labelLineConfig.fontSize / 10;
 
   await nextTick();
   draw.config.labelLineConfig.showOffset = padding - 5;

+ 1 - 2
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,

+ 40 - 8
src/example/platform/platform-resource.ts

@@ -3,6 +3,7 @@ import { extractConnectedSegments } from "@/utils/polygon";
 import { validNum } from "@/utils/shared";
 import { aiIconMap, iconGroups } from "../constant";
 import { Euler, MathUtils, Object3D, Quaternion, Vector3 } from "three";
+import { getSvgContent, parseSvgContent } from "@/utils/resource";
 
 export enum SCENE_TYPE {
   fuse = "fuse",
@@ -42,7 +43,7 @@ export type Taging = {
   url: string;
   position: Pos & { z: number };
   size?: Size;
-  fixed?: boolean
+  fixed?: boolean;
   rotate?: number;
   name?: string;
   pixel?: boolean;
@@ -92,7 +93,9 @@ const getBillYaw = (bill: any) => {
   let billboard = new Object3D();
   let plane = new Object3D();
   billboard.add(plane);
-  billboard.quaternion.copy({x: bill.qua[0], y: bill.qua[1], z: bill.qua[2], w: bill.qua[3]}).normalize(); //qua数据里的
+  billboard.quaternion
+    .copy({ x: bill.qua[0], y: bill.qua[1], z: bill.qua[2], w: bill.qua[3] })
+    .normalize(); //qua数据里的
   plane.quaternion.setFromAxisAngle(
     new Vector3(0, 0, 1),
     MathUtils.degToRad(-bill.faceAngle)
@@ -102,7 +105,7 @@ const getBillYaw = (bill: any) => {
   const right = new Vector3(1, 0, 0); //令躺倒时的旋转轴
 
   let qua = plane.getWorldQuaternion(new Quaternion());
-  const ld = isLieDown(billboard.quaternion)
+  const ld = isLieDown(billboard.quaternion);
   if (!ld) {
     //使朝其后方躺倒后再求angle
     let rotAxis = right.clone().applyQuaternion(qua); //旋转轴
@@ -257,9 +260,9 @@ export const taggingGets = {
               })
             : getSceneApi("oss", `${prev}/user/${signage.icon}`);
 
-        const yRotate = getBillYaw(signage)
+        const yRotate = getBillYaw(signage);
 
-        console.log(signage)
+        console.log(signage);
         return getIcon
           .then((url) => {
             tags.push({
@@ -276,7 +279,7 @@ export const taggingGets = {
               size: {
                 // width: signage.width * (signage.scaleRatio / 100),
                 // height: signage.height * (signage.scaleRatio / 100),
-                width: signage.width ,
+                width: signage.width,
                 height: signage.height,
               },
             });
@@ -294,6 +297,7 @@ export const taggingGets = {
       .then((url) => fetch(url))
       .then((res) => res.json())
       .then((datas) => {
+        const loadPromises: Promise<void>[] = [];
         for (const data of datas) {
           const reg = data.imagePath.match(/floor_(\d)\.png/);
           const subgroup = reg ? Number(reg[1]) : undefined;
@@ -312,33 +316,61 @@ export const taggingGets = {
                 ? (aiIconMap as any)[shape.category]
                 : shape.category;
             let name = "";
+            let isWall = false;
             for (const group of iconGroups) {
               for (const itemGroup of group.children) {
                 for (const item of itemGroup.children) {
                   if (item.icon === icon) {
                     name = item.name;
+                    isWall = "wall" in item && item.wall;
                   }
                 }
               }
             }
             const isTag = icon === "Tag";
             if (name || isTag) {
-              tags.push({
+              const item = {
                 isText: isTag,
                 position: pos,
+                rotate: 0,
                 url: isTag
                   ? shape.name
                   : `./icons/${icon ? icon : "circle"}.svg`,
                 name,
                 pixel: true,
+                fixed: false,
                 size,
                 subgroup,
-              } as any);
+              };
+              if (isWall) {
+                const wh = Math.max(item.size.width, item.size.height);
+                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);
+              }
             } else {
               console.error("找不到ai家具", icon, name, pos);
             }
           }
         }
+        return Promise.all(loadPromises)
       })
       .catch((e) => {
         console.error(e);