|
|
@@ -9,7 +9,12 @@ import {
|
|
|
WallTaggingInfo,
|
|
|
} from "./platform-resource";
|
|
|
import { lineLen, Pos, zeroEq } from "@/utils/math";
|
|
|
-import { aiIconMap, getIconItem, styleIconMap, traceIconMap } from "../constant";
|
|
|
+import {
|
|
|
+ aiIconMap,
|
|
|
+ getIconItem,
|
|
|
+ styleIconMap,
|
|
|
+ traceIconMap,
|
|
|
+} from "../constant";
|
|
|
import {
|
|
|
Euler,
|
|
|
MathUtils,
|
|
|
@@ -24,7 +29,9 @@ import { extractConnectedSegments } from "@/utils/polygon";
|
|
|
const fetchResource = genCache(
|
|
|
(scene: Scene) => scene.m,
|
|
|
async (scene: Scene) => {
|
|
|
- const prev = `${scene.mapping ? '/' + scene.mapping : ''}/scene_view_data/${scene.m}`;
|
|
|
+ const prev = `${scene.mapping ? "/" + scene.mapping : ""}/scene_view_data/${
|
|
|
+ scene.m
|
|
|
+ }`;
|
|
|
let version = Date.now();
|
|
|
const get = (url: string, def?: any) =>
|
|
|
getSceneApi("oss", `${prev}${url}?_=${version}`)
|
|
|
@@ -36,7 +43,6 @@ const fetchResource = genCache(
|
|
|
version: 0,
|
|
|
billboards: 0,
|
|
|
tags: 0,
|
|
|
- orientation: 0,
|
|
|
});
|
|
|
version = config.version;
|
|
|
|
|
|
@@ -140,7 +146,9 @@ export const getCoverLine = async (
|
|
|
reqs.push(
|
|
|
getSceneApi(
|
|
|
"oss",
|
|
|
- `${scene.mapping ? '/' + scene.mapping : ''}/scene_view_data/${scene.m}/data/floorplan/floor_${floor.subgroup}.png`
|
|
|
+ `${scene.mapping ? "/" + scene.mapping : ""}/scene_view_data/${
|
|
|
+ scene.m
|
|
|
+ }/data/floorplan/floor_${floor.subgroup}.png`
|
|
|
)
|
|
|
.then((url) => (item.thumb = url))
|
|
|
.catch(() => {})
|
|
|
@@ -153,9 +161,9 @@ export const getCoverLine = async (
|
|
|
|
|
|
export const getCompass = async (scene: Scene) => {
|
|
|
const { config, userFloorpan } = await fetchResource(scene);
|
|
|
- return userFloorpan !== undefined
|
|
|
- ? userFloorpan.compass
|
|
|
- : MathUtils.radToDeg(Number(config.orientation || 0));
|
|
|
+ return "orientation" in config
|
|
|
+ ? MathUtils.radToDeg(Number(config.orientation || 0))
|
|
|
+ : userFloorpan?.compass || 0;
|
|
|
};
|
|
|
|
|
|
export const getHotTaggingInfos = async (scene: Scene, scale: number) => {
|
|
|
@@ -166,7 +174,12 @@ export const getHotTaggingInfos = async (scene: Scene, scale: number) => {
|
|
|
for (const hot of hots) {
|
|
|
if (!validNum(hot.position.x) || !validNum(hot.position.y)) continue;
|
|
|
reqs.push(
|
|
|
- getSceneApi("oss", `${scene.mapping ? '/' + scene.mapping : ''}/scene_view_data/${scene.m}/user/${hot.icon}`)
|
|
|
+ getSceneApi(
|
|
|
+ "oss",
|
|
|
+ `${scene.mapping ? "/" + scene.mapping : ""}/scene_view_data/${
|
|
|
+ scene.m
|
|
|
+ }/user/${hot.icon}`
|
|
|
+ )
|
|
|
.then((url) =>
|
|
|
infos.push({
|
|
|
position: { x: hot.position.x * scale, y: hot.position.y * scale },
|
|
|
@@ -183,7 +196,7 @@ export const getHotTaggingInfos = async (scene: Scene, scale: number) => {
|
|
|
|
|
|
const getTraceAttri = async (icon: string, trace: any) => {
|
|
|
const size = {
|
|
|
- width: trace.visiSetting.scale,
|
|
|
+ width: trace.visiSetting.scale,
|
|
|
height: trace.visiSetting.scale,
|
|
|
};
|
|
|
const attrib: any = {
|
|
|
@@ -191,7 +204,7 @@ const getTraceAttri = async (icon: string, trace: any) => {
|
|
|
size,
|
|
|
angle: trace.visiSetting.angle,
|
|
|
};
|
|
|
-
|
|
|
+
|
|
|
if (trace.iconType === 2 || !trace.tag3d?.object) {
|
|
|
return attrib;
|
|
|
}
|
|
|
@@ -220,7 +233,7 @@ const getTraceAttri = async (icon: string, trace: any) => {
|
|
|
const scale = new Vector3();
|
|
|
mat.decompose(position, quat, scale);
|
|
|
|
|
|
- const euler = new Euler().setFromQuaternion(quat, 'XYZ')
|
|
|
+ const euler = new Euler().setFromQuaternion(quat, "XYZ");
|
|
|
return {
|
|
|
...attrib,
|
|
|
angle: MathUtils.radToDeg(euler.y),
|
|
|
@@ -236,9 +249,8 @@ export const getTraceTaggingInfos = async (
|
|
|
const { traces } = await fetchResource(scene);
|
|
|
const infos: TaggingInfo[] = [];
|
|
|
const reqs: Promise<any>[] = [];
|
|
|
-
|
|
|
|
|
|
- console.log('traces', traces)
|
|
|
+ console.log("traces", traces);
|
|
|
for (const trace of traces) {
|
|
|
if (
|
|
|
!validNum(trace.position?.x) ||
|
|
|
@@ -260,7 +272,12 @@ export const getTraceTaggingInfos = async (
|
|
|
? styleMap
|
|
|
? Promise.resolve(`./icons/${styleMap}.svg`)
|
|
|
: getSceneApi("./", `./traces/${icon}.svg`)
|
|
|
- : getSceneApi("oss", `${scene.mapping ? '/' + scene.mapping : ''}/scene_edit_data/${scene.m}/user/${icon}`);
|
|
|
+ : getSceneApi(
|
|
|
+ "oss",
|
|
|
+ `${scene.mapping ? "/" + scene.mapping : ""}/scene_edit_data/${
|
|
|
+ scene.m
|
|
|
+ }/user/${icon}`
|
|
|
+ );
|
|
|
|
|
|
const name = (styleMap && getIconItem(styleMap)?.name) || "";
|
|
|
const getAttr = getIcon.then(async (url) => getTraceAttri(url, trace));
|
|
|
@@ -278,7 +295,7 @@ export const getTraceTaggingInfos = async (
|
|
|
? Math.ceil(trace.position.y * scale * 10) / 10
|
|
|
: Math.floor(trace.position.y * scale * 10) / 10,
|
|
|
},
|
|
|
- key: 'trace',
|
|
|
+ key: "trace",
|
|
|
rotate: attr.angle,
|
|
|
size: {
|
|
|
width: attr.size.width * scale,
|
|
|
@@ -356,7 +373,12 @@ export const getBillTaggingInfos = async (
|
|
|
`/sdk/images/billboard/${bill.icon}.png`
|
|
|
);
|
|
|
})
|
|
|
- : getSceneApi("oss", `${scene.mapping ? '/' + scene.mapping : ''}/scene_view_data/${scene.m}/user/${bill.icon}`);
|
|
|
+ : getSceneApi(
|
|
|
+ "oss",
|
|
|
+ `${scene.mapping ? "/" + scene.mapping : ""}/scene_view_data/${
|
|
|
+ scene.m
|
|
|
+ }/user/${bill.icon}`
|
|
|
+ );
|
|
|
|
|
|
const yRotate = getBillYaw(bill);
|
|
|
const name = (styleMap && getIconItem(styleMap)?.name) || "";
|
|
|
@@ -562,7 +584,7 @@ export const getResource = async ({
|
|
|
let coverLine: CoverLine;
|
|
|
|
|
|
const compass = await getCompass(scene);
|
|
|
-
|
|
|
+ console.log(compass);
|
|
|
const reqs: Promise<any>[] = [
|
|
|
getCompass(scene),
|
|
|
getCoverLine(scene, key, scale)
|