|
@@ -13,7 +13,9 @@ const scaleResource = (info: AIExposeData, scale: number) => {
|
|
|
const floors = info.floors.map((item) => ({
|
|
|
...item,
|
|
|
geos: item.geos.map((geo) =>
|
|
|
- geo.map((p) => ({ x: p.x * scale, y: p.y * scale, z: p.z * scale }))
|
|
|
+ geo.map((p) => {
|
|
|
+ return { x: p.x * scale, y: p.y * scale, z: p.z * scale }
|
|
|
+ })
|
|
|
),
|
|
|
box: item.box && {
|
|
|
...item.box,
|
|
@@ -38,26 +40,32 @@ const scaleResource = (info: AIExposeData, scale: number) => {
|
|
|
y: item.position.y * scale,
|
|
|
z: item.position.z * scale,
|
|
|
},
|
|
|
+ size: item.size
|
|
|
+ ? {
|
|
|
+ width: item.size!.width * scale,
|
|
|
+ height: item.size!.height * scale,
|
|
|
+ }
|
|
|
+ : undefined,
|
|
|
};
|
|
|
} else if (item.subgroup !== undefined) {
|
|
|
- const floor = floors.find(
|
|
|
- (floor) => floor.subgroup === item.subgroup
|
|
|
- );
|
|
|
+ const floor = floors.find((floor) => floor.subgroup === item.subgroup);
|
|
|
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;
|
|
|
-
|
|
|
+
|
|
|
return {
|
|
|
...item,
|
|
|
position: {
|
|
|
- x: (floor.box.bound.x_min + w * item.position.x) ,
|
|
|
- y: (floor.box.bound.y_min + h * item.position.y) ,
|
|
|
- z: (floor.box.bound.z_min + 0.001) ,
|
|
|
- },
|
|
|
- size: {
|
|
|
- width: item.size!.width * w ,
|
|
|
- height: item.size!.height * h ,
|
|
|
+ x: floor.box.bound.x_min + w * item.position.x,
|
|
|
+ y: floor.box.bound.y_min + h * item.position.y,
|
|
|
+ z: floor.box.bound.z_min + 0.001,
|
|
|
},
|
|
|
+ size: item.size
|
|
|
+ ? {
|
|
|
+ width: item.size!.width * w,
|
|
|
+ height: item.size!.height * h,
|
|
|
+ }
|
|
|
+ : undefined,
|
|
|
};
|
|
|
}
|
|
|
})
|
|
@@ -99,9 +107,13 @@ const getResourceLayers = (data: AIExposeData) => {
|
|
|
box,
|
|
|
taggings: data.taggings
|
|
|
.filter((item) => {
|
|
|
- console.log(item, item.position.z, box.bound,
|
|
|
- item.position.z > box.bound.z_min &&
|
|
|
- item.position.z <= box.bound.z_max)
|
|
|
+ // console.log(
|
|
|
+ // item,
|
|
|
+ // item.position.z,
|
|
|
+ // box.bound,
|
|
|
+ // item.position.z > box.bound.z_min &&
|
|
|
+ // item.position.z <= box.bound.z_max
|
|
|
+ // );
|
|
|
return (
|
|
|
item.position.z > box.bound.z_min &&
|
|
|
item.position.z <= box.bound.z_max
|
|
@@ -125,46 +137,49 @@ const drawLayerResource = (
|
|
|
const images: any[] = [];
|
|
|
const createTime = Date.now();
|
|
|
|
|
|
- let sGeo = draw.store.getTypeItems('line')[0]
|
|
|
- let geo: LineData = sGeo ? sGeo : {
|
|
|
- ...getBaseItem(),
|
|
|
- lines: [],
|
|
|
- points: [],
|
|
|
- polygon: [],
|
|
|
- attitude: [1, 0, 0, 1, 0, 0],
|
|
|
- createTime: createTime,
|
|
|
- }
|
|
|
- const geoCtx = getInitCtx()
|
|
|
+ let sGeo = draw.store.getTypeItems("line")[0];
|
|
|
+ let geo: LineData = sGeo
|
|
|
+ ? sGeo
|
|
|
+ : {
|
|
|
+ ...getBaseItem(),
|
|
|
+ lines: [],
|
|
|
+ points: [],
|
|
|
+ polygon: [],
|
|
|
+ attitude: [1, 0, 0, 1, 0, 0],
|
|
|
+ createTime: createTime,
|
|
|
+ };
|
|
|
+ const geoCtx = getInitCtx();
|
|
|
|
|
|
layerResource.geos.forEach((item) => {
|
|
|
bound.update(item);
|
|
|
if (item.length < 1) return;
|
|
|
|
|
|
- let a: string = onlyId(), b: string
|
|
|
- let i = 0
|
|
|
+ let a: string = onlyId(),
|
|
|
+ b: string;
|
|
|
+ let i = 0;
|
|
|
for (i = 0; i < item.length - 1; i++) {
|
|
|
- b = onlyId()
|
|
|
- const lId = onlyId()
|
|
|
- const l = { id: onlyId(), a, b, ...defaultStyle }
|
|
|
- const p = { id: a, ...item[i] }
|
|
|
- geoCtx.add.points[a] = p
|
|
|
- geoCtx.add.lines[lId] = l
|
|
|
- geo.points.push(p)
|
|
|
- geo.lines.push(l)
|
|
|
- a = b
|
|
|
+ b = onlyId();
|
|
|
+ const lId = onlyId();
|
|
|
+ const l = { id: onlyId(), a, b, ...defaultStyle };
|
|
|
+ const p = { id: a, ...item[i] };
|
|
|
+ geoCtx.add.points[a] = p;
|
|
|
+ geoCtx.add.lines[lId] = l;
|
|
|
+ geo.points.push(p);
|
|
|
+ geo.lines.push(l);
|
|
|
+ a = b;
|
|
|
}
|
|
|
- const p = { id: b!, ...item[i] }
|
|
|
- geoCtx.add.points[b!] = p
|
|
|
- geo.points.push(p)
|
|
|
+ const p = { id: b!, ...item[i] };
|
|
|
+ geoCtx.add.points[b!] = p;
|
|
|
+ geo.points.push(p);
|
|
|
});
|
|
|
draw.history.onceTrack(() => {
|
|
|
- geo = normalLineData(geo, geoCtx)
|
|
|
+ geo = normalLineData(geo, geoCtx);
|
|
|
if (sGeo) {
|
|
|
- draw.store.setItem('line', {id: geo.id, value: geo });
|
|
|
+ draw.store.setItem("line", { id: geo.id, value: geo });
|
|
|
} else {
|
|
|
- draw.store.addItem('line', geo);
|
|
|
+ draw.store.addItem("line", geo);
|
|
|
}
|
|
|
- })
|
|
|
+ });
|
|
|
|
|
|
if (layerResource.thumb) {
|
|
|
const box = layerResource.box;
|
|
@@ -191,15 +206,20 @@ const drawLayerResource = (
|
|
|
images.push(
|
|
|
...layerResource.taggings.map((item, ndx) => {
|
|
|
bound.update(item.position);
|
|
|
+ const tf = new Transform()
|
|
|
+ .translate(item.position.x, item.position.y)
|
|
|
+ if (item.rotate) {
|
|
|
+ tf.rotate(item.rotate)
|
|
|
+ }
|
|
|
return {
|
|
|
...getBaseItem(),
|
|
|
...iconDefaultStyle,
|
|
|
name: item.name,
|
|
|
- fill: '#000000',
|
|
|
+ fill: item.url.includes(".svg") ? "#000000" : undefined,
|
|
|
createTime: createTime + layerResource.geos.length + ndx,
|
|
|
url: item.url,
|
|
|
lock: import.meta.env.DEV ? false : true,
|
|
|
- mat: [1, 0, 0, 1, item.position.x, item.position.y],
|
|
|
+ mat: tf.m,
|
|
|
width: item.size ? item.size.width : 100,
|
|
|
height: item.size ? item.size.height : 100,
|
|
|
// width: 30,
|
|
@@ -208,6 +228,7 @@ const drawLayerResource = (
|
|
|
};
|
|
|
})
|
|
|
);
|
|
|
+
|
|
|
draw.store.addItems(
|
|
|
"icon",
|
|
|
images.filter((item) => item.url.includes(".svg"))
|