|
@@ -1,7 +1,7 @@
|
|
import { Pos, Size } from "@/utils/math";
|
|
import { Pos, Size } from "@/utils/math";
|
|
import { extractConnectedSegments } from "@/utils/polygon";
|
|
import { extractConnectedSegments } from "@/utils/polygon";
|
|
import { validNum } from "@/utils/shared";
|
|
import { validNum } from "@/utils/shared";
|
|
-import { aiIconMap, iconGroups } from "../constant";
|
|
|
|
|
|
+import { aiIconMap, getIconItem, iconGroups, styleIconMap } from "../constant";
|
|
import { Euler, MathUtils, Object3D, Quaternion, Vector3 } from "three";
|
|
import { Euler, MathUtils, Object3D, Quaternion, Vector3 } from "three";
|
|
import { getSvgContent, parseSvgContent } from "@/utils/resource";
|
|
import { getSvgContent, parseSvgContent } from "@/utils/resource";
|
|
|
|
|
|
@@ -249,15 +249,18 @@ export const taggingGets = {
|
|
|
|
|
|
const reqs = signages.map((signage: any) => {
|
|
const reqs = signages.map((signage: any) => {
|
|
if (!validNum(signage.pos[0]) || !validNum(signage.pos[2])) return;
|
|
if (!validNum(signage.pos[0]) || !validNum(signage.pos[2])) return;
|
|
|
|
+ const styleMap = (styleIconMap as any)[signage.icon];
|
|
const getIcon =
|
|
const getIcon =
|
|
signage.icon.indexOf("style-") === 0
|
|
signage.icon.indexOf("style-") === 0
|
|
- ? getSceneApi("./", `./styles/${signage.icon}.svg`).catch((e) => {
|
|
|
|
- console.error(e);
|
|
|
|
- return getSceneApi(
|
|
|
|
- "ossRoot",
|
|
|
|
- `/sdk/images/billboard/${signage.icon}.png`
|
|
|
|
- );
|
|
|
|
- })
|
|
|
|
|
|
+ ? styleMap
|
|
|
|
+ ? Promise.resolve(`./icons/${styleMap}.svg`)
|
|
|
|
+ : getSceneApi("./", `./styles/${signage.icon}.svg`).catch((e) => {
|
|
|
|
+ console.error(e);
|
|
|
|
+ return getSceneApi(
|
|
|
|
+ "ossRoot",
|
|
|
|
+ `/sdk/images/billboard/${signage.icon}.png`
|
|
|
|
+ );
|
|
|
|
+ })
|
|
: getSceneApi("oss", `${prev}/user/${signage.icon}`);
|
|
: getSceneApi("oss", `${prev}/user/${signage.icon}`);
|
|
|
|
|
|
const yRotate = getBillYaw(signage);
|
|
const yRotate = getBillYaw(signage);
|
|
@@ -265,8 +268,11 @@ export const taggingGets = {
|
|
console.log(signage);
|
|
console.log(signage);
|
|
return getIcon
|
|
return getIcon
|
|
.then((url) => {
|
|
.then((url) => {
|
|
|
|
+ const name = (styleMap && getIconItem(styleMap)?.name) || ''
|
|
|
|
+
|
|
tags.push({
|
|
tags.push({
|
|
url,
|
|
url,
|
|
|
|
+ name,
|
|
position: {
|
|
position: {
|
|
x: signage.pos[0],
|
|
x: signage.pos[0],
|
|
y: signage.pos[2],
|
|
y: signage.pos[2],
|
|
@@ -315,18 +321,11 @@ export const taggingGets = {
|
|
shape.category in aiIconMap
|
|
shape.category in aiIconMap
|
|
? (aiIconMap as any)[shape.category]
|
|
? (aiIconMap as any)[shape.category]
|
|
: 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 itemIcon = getIconItem(icon)
|
|
|
|
+ const name = itemIcon?.name
|
|
|
|
+ const isWall = itemIcon && "wall" in itemIcon ? itemIcon.wall : false;
|
|
const isTag = icon === "Tag";
|
|
const isTag = icon === "Tag";
|
|
if (name || isTag) {
|
|
if (name || isTag) {
|
|
const item = {
|
|
const item = {
|
|
@@ -345,23 +344,29 @@ export const taggingGets = {
|
|
if (isWall) {
|
|
if (isWall) {
|
|
const wh = Math.max(item.size.width, item.size.height);
|
|
const wh = Math.max(item.size.width, item.size.height);
|
|
loadPromises.push(
|
|
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.width = wh
|
|
|
|
- item.size.height = data.imageWidth / data.imageHeight * (content.height / content.width * wh)
|
|
|
|
- item.position.x += item.size.height / 2;
|
|
|
|
- item.rotate = Math.PI / 2;
|
|
|
|
- }
|
|
|
|
- tags.push(item as any);
|
|
|
|
- }).catch(() => {})
|
|
|
|
|
|
+ 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.width = wh;
|
|
|
|
+ item.size.height =
|
|
|
|
+ (data.imageWidth / data.imageHeight) *
|
|
|
|
+ ((content.height / content.width) * wh);
|
|
|
|
+ item.position.x += item.size.height / 2;
|
|
|
|
+ item.rotate = Math.PI / 2;
|
|
|
|
+ }
|
|
|
|
+ tags.push(item as any);
|
|
|
|
+ })
|
|
|
|
+ .catch(() => {})
|
|
);
|
|
);
|
|
} else {
|
|
} else {
|
|
tags.push(item as any);
|
|
tags.push(item as any);
|
|
@@ -371,7 +376,7 @@ export const taggingGets = {
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
- return Promise.all(loadPromises)
|
|
|
|
|
|
+ return Promise.all(loadPromises);
|
|
})
|
|
})
|
|
.catch((e) => {
|
|
.catch((e) => {
|
|
console.error(e);
|
|
console.error(e);
|