|
@@ -121,10 +121,16 @@ export const taggingGets = {
|
|
|
},
|
|
|
[SCENE_TYPE.mesh]: async (scene: Scene, options: string[]) => {
|
|
|
const tags: Tagings = [];
|
|
|
- if (options.includes("hot")) {
|
|
|
+ const prev = `/scene_view_data/${scene.m}`;
|
|
|
+ const config = await getSceneApi(scene.type, `${prev}/data/scene.json`)
|
|
|
+ .then((url) => fetch(url))
|
|
|
+ .then((res) => res.json())
|
|
|
+ .catch(() => ({ version: 0, billboards: 0, tags: 0 }));
|
|
|
+
|
|
|
+ if (options.includes("hot") && config.tags) {
|
|
|
const medias = await getSceneApi(
|
|
|
scene.type,
|
|
|
- `/scene_view_data/${scene.m}/user/hot.json`
|
|
|
+ `${prev}/user/hot.json?_=${config.version}`
|
|
|
)
|
|
|
.then((url) => fetch(url))
|
|
|
.then((res) => res.json())
|
|
@@ -134,7 +140,7 @@ export const taggingGets = {
|
|
|
if (!validNum(media.position.x) || !validNum(media.position.y)) return;
|
|
|
return getSceneApi(
|
|
|
scene.type,
|
|
|
- `/scene_view_data/KK-t-ThCAj9SjuKB/user/${media.icon}`
|
|
|
+ `${prev}/user/${media.icon}`
|
|
|
// `/v4-test/www/sdk/images/tag/${media.icon}`
|
|
|
)
|
|
|
.then((url) => {
|
|
@@ -146,10 +152,10 @@ export const taggingGets = {
|
|
|
await Promise.all(reqs);
|
|
|
}
|
|
|
|
|
|
- if (options.includes("signage")) {
|
|
|
+ if (options.includes("signage") && config.billboards) {
|
|
|
const signages = await getSceneApi(
|
|
|
scene.type,
|
|
|
- `/scene_view_data/${scene.m}/user/billboards.json`
|
|
|
+ `${prev}/user/billboards.json?_=${config.version}`
|
|
|
)
|
|
|
.then((url) => fetch(url))
|
|
|
.then((res) => res.json())
|
|
@@ -157,10 +163,7 @@ export const taggingGets = {
|
|
|
|
|
|
signages.forEach((signage: any) => {
|
|
|
if (!validNum(signage.pos.x) || !validNum(signage.pos.y)) return;
|
|
|
- return getSceneApi(
|
|
|
- scene.type,
|
|
|
- `/v4-test/www/sdk/images/billboard/${signage.icon}.png`
|
|
|
- )
|
|
|
+ return getSceneApi(scene.type, `${prev}/user/${signage.icon}.png`)
|
|
|
.then((url) => {
|
|
|
tags.push({ url, position: signage.pos });
|
|
|
})
|
|
@@ -197,32 +200,51 @@ export const lineGets = {
|
|
|
return { name: "1楼", geos: [tags.map((item) => item.position)] };
|
|
|
},
|
|
|
[SCENE_TYPE.mesh]: async (scene: Scene) => {
|
|
|
- const { floors } = await getSceneApi(
|
|
|
- scene.type,
|
|
|
- `/scene_view_data/${scene.m}/data/floorplan_cad.json?_=${Date.now()}`
|
|
|
- )
|
|
|
- .then((url) => fetch(url))
|
|
|
- .then((res) => res.json())
|
|
|
- .catch(() => ({ floors: [] }));
|
|
|
- const data = floors.map((floor: any) => ({
|
|
|
- name: floor.name,
|
|
|
- thumb: `https://4dkk.4dage.com/scene_view_data/${scene.m}/images/floor_${floor.id}.png`,
|
|
|
- box: {
|
|
|
- bound: {
|
|
|
- ...floor.cadInfo.cadBoundingBox,
|
|
|
- y_min: -floor.cadInfo.cadBoundingBox.y_max,
|
|
|
- y_max: -floor.cadInfo.cadBoundingBox.y_min,
|
|
|
+ const prev = `/scene_view_data/${scene.m}/data/`;
|
|
|
+ const [{ floors }, bounds] = await Promise.all([
|
|
|
+ getSceneApi(scene.type, `${prev}floorplan_cad.json?_=${Date.now()}`)
|
|
|
+ .then((url) => fetch(url))
|
|
|
+ .then((res) => res.json())
|
|
|
+ .catch(() => ({ floors: [] })),
|
|
|
+ getSceneApi(scene.type, `${prev}floorplan/info.json`)
|
|
|
+ .then((url) => fetch(url))
|
|
|
+ .then((res) => res.json())
|
|
|
+ .then((data) => data.floors)
|
|
|
+ .catch(() => []),
|
|
|
+ ]);
|
|
|
+
|
|
|
+ const data: any = [];
|
|
|
+
|
|
|
+ const reqs = floors.map((floor: any, ndx: number) => {
|
|
|
+ const bound = {
|
|
|
+ ...(floor.cadInfo.cadBoundingBox || {}),
|
|
|
+ ...(bounds[ndx]?.bound || {}),
|
|
|
+ };
|
|
|
+ const item: any = {
|
|
|
+ name: floor.name,
|
|
|
+ thumb: "",
|
|
|
+ box: {
|
|
|
+ bound: {
|
|
|
+ ...bound,
|
|
|
+ y_min: -bound.y_max,
|
|
|
+ y_max: -bound.y_min,
|
|
|
+ },
|
|
|
+ rotate: floor.cadInfo.res,
|
|
|
+ scale: floor.cadInfo.currentScale,
|
|
|
},
|
|
|
- rotate: floor.cadInfo.res,
|
|
|
- scale: floor.cadInfo.currentScale,
|
|
|
- },
|
|
|
- geos: extractConnectedSegments(floor.segment).map((geo) => {
|
|
|
- return geo.map((id) => {
|
|
|
- const p = floor["vertex-xy"].find((item: any) => item.id === id);
|
|
|
- return { x: p.x, y: -p.y } as Pos;
|
|
|
- })
|
|
|
- }),
|
|
|
- }));
|
|
|
+ geos: extractConnectedSegments(floor.segment).map((geo) => {
|
|
|
+ return geo.map((id) => {
|
|
|
+ const p = floor["vertex-xy"].find((item: any) => item.id === id);
|
|
|
+ return { x: p.x, y: -p.y } as Pos;
|
|
|
+ });
|
|
|
+ }),
|
|
|
+ };
|
|
|
+ data.push(item);
|
|
|
+ return getSceneApi(scene.type, `${prev}floorplan/floor_${floor.subgroup}.png`)
|
|
|
+ .then((url) => (item.thumb = url))
|
|
|
+ .catch(() => (item.thumb = ""));
|
|
|
+ });
|
|
|
+ await Promise.all(reqs);
|
|
|
return data;
|
|
|
},
|
|
|
[SCENE_TYPE.cloud]: async (scene: Scene) => {
|