|
@@ -10,8 +10,17 @@ import {
|
|
} from "./platform-resource";
|
|
} from "./platform-resource";
|
|
import { lineLen, Pos, zeroEq } from "@/utils/math";
|
|
import { lineLen, Pos, zeroEq } from "@/utils/math";
|
|
import { aiIconMap, getIconItem, styleIconMap } from "../constant";
|
|
import { aiIconMap, getIconItem, styleIconMap } from "../constant";
|
|
-import { MathUtils, Object3D, Quaternion, Vector3 } from "three";
|
|
|
|
|
|
+import {
|
|
|
|
+ Euler,
|
|
|
|
+ MathUtils,
|
|
|
|
+ Matrix4,
|
|
|
|
+ Matrix4Tuple,
|
|
|
|
+ Object3D,
|
|
|
|
+ Quaternion,
|
|
|
|
+ Vector3,
|
|
|
|
+} from "three";
|
|
import { extractConnectedSegments } from "@/utils/polygon";
|
|
import { extractConnectedSegments } from "@/utils/polygon";
|
|
|
|
+import { getImage } from "@/utils/resource";
|
|
|
|
|
|
const fetchResource = genCache(
|
|
const fetchResource = genCache(
|
|
(scene: Scene) => scene.m,
|
|
(scene: Scene) => scene.m,
|
|
@@ -32,17 +41,26 @@ const fetchResource = genCache(
|
|
});
|
|
});
|
|
version = config.version;
|
|
version = config.version;
|
|
|
|
|
|
- const [userFloorpan, floorplan, hots, billboards, ais, cadInfo, cad] =
|
|
|
|
- await Promise.all([
|
|
|
|
- get("/user/floorplan.json"),
|
|
|
|
- get("/data/floorplan.json", { floors: [] }),
|
|
|
|
- get("/user/hot.json", []),
|
|
|
|
- get("/user/billboards.json", []),
|
|
|
|
- get("/data/floorplan/ai.json", []),
|
|
|
|
- get("/data/floorplan/info.json", { floors: [] }),
|
|
|
|
- get("/data/floorplan_cad.json", { floors: [] }),
|
|
|
|
- ]);
|
|
|
|
-
|
|
|
|
|
|
+ const [
|
|
|
|
+ userFloorpan,
|
|
|
|
+ floorplan,
|
|
|
|
+ hots,
|
|
|
|
+ billboards,
|
|
|
|
+ ais,
|
|
|
|
+ cadInfo,
|
|
|
|
+ cad,
|
|
|
|
+ traces,
|
|
|
|
+ ] = await Promise.all([
|
|
|
|
+ get("/user/floorplan.json"),
|
|
|
|
+ get("/data/floorplan.json", { floors: [] }),
|
|
|
|
+ get("/user/hot.json", []),
|
|
|
|
+ get("/user/billboards.json", []),
|
|
|
|
+ get("/data/floorplan/ai.json", []),
|
|
|
|
+ get("/data/floorplan/info.json", { floors: [] }),
|
|
|
|
+ get("/data/floorplan_cad.json", { floors: [] }),
|
|
|
|
+ get("/user/evidence.json", { floors: [] }),
|
|
|
|
+ ]);
|
|
|
|
+
|
|
return {
|
|
return {
|
|
userFloorpan,
|
|
userFloorpan,
|
|
hots,
|
|
hots,
|
|
@@ -52,6 +70,7 @@ const fetchResource = genCache(
|
|
cad,
|
|
cad,
|
|
cadInfo,
|
|
cadInfo,
|
|
config,
|
|
config,
|
|
|
|
+ traces,
|
|
};
|
|
};
|
|
},
|
|
},
|
|
150000
|
|
150000
|
|
@@ -164,6 +183,116 @@ export const getHotTaggingInfos = async (scene: Scene, scale: number) => {
|
|
return infos;
|
|
return infos;
|
|
};
|
|
};
|
|
|
|
|
|
|
|
+const getTraceAttri = async (icon: string, trace: any) => {
|
|
|
|
+ const size = {
|
|
|
|
+ width: trace.visiSetting.scale,
|
|
|
|
+ height: trace.visiSetting.scale,
|
|
|
|
+ };
|
|
|
|
+ const attrib: any = {
|
|
|
|
+ url: icon,
|
|
|
|
+ size,
|
|
|
|
+ angle: trace.visiSetting.angle,
|
|
|
|
+ };
|
|
|
|
+
|
|
|
|
+ if (trace.iconType === 2 || !trace.tag3d?.object) {
|
|
|
|
+ return attrib;
|
|
|
|
+ }
|
|
|
|
+ const getPath = (children: any, name: string): any[] | undefined => {
|
|
|
|
+ for (const item of children) {
|
|
|
|
+ if (item.name === name) {
|
|
|
|
+ return [item];
|
|
|
|
+ } else if (item.children) {
|
|
|
|
+ const childPath = getPath(item.children, name);
|
|
|
|
+ if (childPath) {
|
|
|
|
+ return [item, ...childPath];
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ };
|
|
|
|
+ const path = getPath([trace.tag3d.object], "sprite");
|
|
|
|
+
|
|
|
|
+ if (!path) return attrib;
|
|
|
|
+
|
|
|
|
+ const mat = new Matrix4();
|
|
|
|
+ for (const node of path) {
|
|
|
|
+ mat.multiply(new Matrix4(...(node.matrix as Matrix4Tuple)));
|
|
|
|
+ }
|
|
|
|
+ const position = new Vector3();
|
|
|
|
+ const quat = new Quaternion();
|
|
|
|
+ const scale = new Vector3();
|
|
|
|
+ mat.decompose(position, quat, scale);
|
|
|
|
+
|
|
|
|
+ const euler = new Euler().setFromQuaternion(quat, 'XYZ')
|
|
|
|
+ return {
|
|
|
|
+ ...attrib,
|
|
|
|
+ angle: MathUtils.radToDeg(euler.y),
|
|
|
|
+ };
|
|
|
|
+};
|
|
|
|
+
|
|
|
|
+// 痕迹物证
|
|
|
|
+export const getTraceTaggingInfos = async (
|
|
|
|
+ scene: Scene,
|
|
|
|
+ scale: number,
|
|
|
|
+ floorIndex: number
|
|
|
|
+) => {
|
|
|
|
+ const { traces } = await fetchResource(scene);
|
|
|
|
+ const infos: TaggingInfo[] = [];
|
|
|
|
+ const reqs: Promise<any>[] = [];
|
|
|
|
+
|
|
|
|
+ for (const trace of traces) {
|
|
|
|
+ if (
|
|
|
|
+ !validNum(trace.position.x) ||
|
|
|
|
+ !validNum(trace.position.z) ||
|
|
|
|
+ ("floorIndex" in trace && trace.floorIndex !== floorIndex) ||
|
|
|
|
+ trace.iconType === 0
|
|
|
|
+ )
|
|
|
|
+ continue;
|
|
|
|
+
|
|
|
|
+ const isSys = trace.icon.indexOf("/") > -1;
|
|
|
|
+ const icon = isSys
|
|
|
|
+ ? trace.icon.substring(trace.lastIndexOf("/") + 1)
|
|
|
|
+ : trace.icon;
|
|
|
|
+ const styleMap = (styleIconMap as any)[icon];
|
|
|
|
+
|
|
|
|
+ if (!icon) continue;
|
|
|
|
+
|
|
|
|
+ const getIcon = isSys
|
|
|
|
+ ? styleMap
|
|
|
|
+ ? Promise.resolve(`./icons/${styleMap}.svg`)
|
|
|
|
+ : getSceneApi("./", `./traces/${icon}.svg`)
|
|
|
|
+ : getSceneApi("oss", `/scene_edit_data/${scene.m}/user/${icon}`);
|
|
|
|
+
|
|
|
|
+ const name = (styleMap && getIconItem(styleMap)?.name) || "";
|
|
|
|
+ const getAttr = getIcon.then(async (url) => getTraceAttri(url, trace));
|
|
|
|
+
|
|
|
|
+ reqs.push(
|
|
|
|
+ getAttr
|
|
|
|
+ .then((attr) => ({
|
|
|
|
+ url: attr.url,
|
|
|
|
+ name,
|
|
|
|
+ position: {
|
|
|
|
+ x: trace.position.x * scale,
|
|
|
|
+ y: trace.position.z * scale,
|
|
|
|
+ z:
|
|
|
|
+ trace.position.y < 0
|
|
|
|
+ ? Math.ceil(trace.position.y * scale * 10) / 10
|
|
|
|
+ : Math.floor(trace.position.y * scale * 10) / 10,
|
|
|
|
+ },
|
|
|
|
+ rotate: attr.angle,
|
|
|
|
+ size: {
|
|
|
|
+ width: attr.size.width * scale,
|
|
|
|
+ height: attr.size.height * scale,
|
|
|
|
+ },
|
|
|
|
+ }))
|
|
|
|
+ .then((info) => infos.push(info))
|
|
|
|
+ .catch(() => {})
|
|
|
|
+ );
|
|
|
|
+ }
|
|
|
|
+ await Promise.all(reqs);
|
|
|
|
+
|
|
|
|
+ return infos;
|
|
|
|
+};
|
|
|
|
+
|
|
const getBillYaw = (bill: any) => {
|
|
const getBillYaw = (bill: any) => {
|
|
function isLieDown(quaternion: Quaternion) {
|
|
function isLieDown(quaternion: Quaternion) {
|
|
let direction = new Vector3(0, 0, -1).applyQuaternion(quaternion);
|
|
let direction = new Vector3(0, 0, -1).applyQuaternion(quaternion);
|
|
@@ -215,7 +344,6 @@ export const getBillTaggingInfos = async (
|
|
)
|
|
)
|
|
continue;
|
|
continue;
|
|
|
|
|
|
- console.log(bill.subgroup , subgroup)
|
|
|
|
const styleMap = (styleIconMap as any)[bill.icon];
|
|
const styleMap = (styleIconMap as any)[bill.icon];
|
|
const getIcon =
|
|
const getIcon =
|
|
bill.icon.indexOf("style-") === 0
|
|
bill.icon.indexOf("style-") === 0
|
|
@@ -423,9 +551,10 @@ export const getResource = async ({
|
|
scale,
|
|
scale,
|
|
}: ResourceArgs) => {
|
|
}: ResourceArgs) => {
|
|
const data = await fetchResource(scene);
|
|
const data = await fetchResource(scene);
|
|
- const floor = data.floorplan.floors.find(
|
|
|
|
|
|
+ const floorIndex = data.floorplan.floors.findIndex(
|
|
(item: any) => item.name === floorName
|
|
(item: any) => item.name === floorName
|
|
);
|
|
);
|
|
|
|
+ const floor = data.floorplan.floors[floorIndex];
|
|
const key = floor.subgroup;
|
|
const key = floor.subgroup;
|
|
const taggings: TaggingInfo[] = [];
|
|
const taggings: TaggingInfo[] = [];
|
|
const wallTaggings: WallTaggingInfo[] = [];
|
|
const wallTaggings: WallTaggingInfo[] = [];
|
|
@@ -459,6 +588,14 @@ export const getResource = async ({
|
|
getBillTaggingInfos(scene, scale, key).then((ts) => taggings.push(...ts))
|
|
getBillTaggingInfos(scene, scale, key).then((ts) => taggings.push(...ts))
|
|
);
|
|
);
|
|
}
|
|
}
|
|
|
|
+ console.error(syncs);
|
|
|
|
+ if (syncs.includes("traces")) {
|
|
|
|
+ reqs.push(
|
|
|
|
+ getTraceTaggingInfos(scene, scale, floorIndex).then((ts) =>
|
|
|
|
+ taggings.push(...ts)
|
|
|
|
+ )
|
|
|
|
+ );
|
|
|
|
+ }
|
|
|
|
|
|
await Promise.all(reqs);
|
|
await Promise.all(reqs);
|
|
|
|
|