Commit 640491ab authored by ninglx's avatar ninglx

修正避免gltf模型重复加载报错

parent e5509379
...@@ -10,6 +10,15 @@ export default { ...@@ -10,6 +10,15 @@ export default {
maxZoom: 20.5, maxZoom: 20.5,
pitch: 60, pitch: 60,
}, },
mapIcons: {
cross: require('../../assets/images/holo/location-yellow.png'),
event: require('../../assets/images/holo/事件-点标.svg'),
milli: require('../../assets/images/holo/毫米波雷达.png'),
laser: require('../../assets/images/holo/激光雷达.png'),
weather: require('../../assets/images/holo/气象监测仪.png'),
camera: require('../../assets/images/holo/视频相机.png'),
sign: require('../../assets/images/holo/信号机.png'),
},
// rasterRoad: 'http://10.100.1.59:8883/tile?lid=traffic&get=map&cache=off&x={x}&y={y}&z={z}', // rasterRoad: 'http://10.100.1.59:8883/tile?lid=traffic&get=map&cache=off&x={x}&y={y}&z={z}',
rasterRoad: 'http://10.100.4.14:8883/tile?lid=traffic&get=map&cache=on&x={x}&y={y}&z={z}', rasterRoad: 'http://10.100.4.14:8883/tile?lid=traffic&get=map&cache=on&x={x}&y={y}&z={z}',
} }
...@@ -185,11 +185,7 @@ export default { ...@@ -185,11 +185,7 @@ export default {
this.$destroy(); this.$destroy();
next(); next();
}, },
mounted() { mounted() {},
this.$nextTick(() => {
this.initMap();
});
},
methods: { methods: {
checkallChange(e) { checkallChange(e) {
if (e) { if (e) {
...@@ -207,31 +203,6 @@ export default { ...@@ -207,31 +203,6 @@ export default {
} }
}, },
getList() {}, getList() {},
initMap() {
mapMethods = this.$refs.wMap;
map = mapMethods.initMap();
scene = new Scene({
logoVisible: false,
map: new Mapbox({
mapInstance: map,
}),
});
scene.on("loaded", () => {
scene.addImage(
"cross",
require("../../assets/images/holo/路况-黄.svg")
);
});
map.on("click", (e) => {
console.log(e.lngLat);
});
scene.on("zoomend", (e) => {
console.log(map.getZoom());
});
scene.on("moveend", (e) => {
console.log(map.getPitch());
});
},
}, },
beforeDestroy() {}, beforeDestroy() {},
......
...@@ -185,11 +185,7 @@ export default { ...@@ -185,11 +185,7 @@ export default {
this.$destroy(); this.$destroy();
next(); next();
}, },
mounted() { mounted() {},
this.$nextTick(() => {
this.initMap();
});
},
methods: { methods: {
checkallChange(e) { checkallChange(e) {
if (e) { if (e) {
...@@ -207,31 +203,6 @@ export default { ...@@ -207,31 +203,6 @@ export default {
} }
}, },
getList() {}, getList() {},
initMap() {
mapMethods = this.$refs.wMap;
map = mapMethods.initMap();
scene = new Scene({
logoVisible: false,
map: new Mapbox({
mapInstance: map,
}),
});
scene.on("loaded", () => {
scene.addImage(
"cross",
require("../../assets/images/holo/路况-黄.svg")
);
});
map.on("click", (e) => {
console.log(e.lngLat);
});
scene.on("zoomend", (e) => {
console.log(map.getZoom());
});
scene.on("moveend", (e) => {
console.log(map.getPitch());
});
},
}, },
beforeDestroy() {}, beforeDestroy() {},
......
...@@ -472,7 +472,7 @@ export default { ...@@ -472,7 +472,7 @@ export default {
this.sceneLoaded = true; this.sceneLoaded = true;
scene.addImage( scene.addImage(
"cross", "cross",
require("../../assets/images/holo/路况-黄.svg") require("../../assets/images/holo/location-yellow.png")
); );
crossInfo().then((res) => { crossInfo().then((res) => {
// debugger; // debugger;
......
...@@ -78,8 +78,8 @@ export default { ...@@ -78,8 +78,8 @@ export default {
}, },
}, },
mapImgUrls: { mapImgUrls: {
carSymbolImage: require("../../assets/images/shop-15.png"), // carSymbolImage: require("../../assets/images/shop-15.png"),
passerbyImage: require("../../assets/images/passerby.png"), // passerbyImage: require("../../assets/images/passerby.png"),
}, },
vehicleDetailData: {}, vehicleDetailData: {},
dialogVisible: { dialogVisible: {
......
...@@ -83,8 +83,8 @@ export default { ...@@ -83,8 +83,8 @@ export default {
}, },
}, },
mapImgUrls: { mapImgUrls: {
carSymbolImage: require("../../assets/images/shop-15.png"), // carSymbolImage: require("../../assets/images/shop-15.png"),
passerbyImage: require("../../assets/images/passerby.png"), // passerbyImage: require("../../assets/images/passerby.png"),
}, },
vehicleDetailData: {}, vehicleDetailData: {},
dialogVisible: { dialogVisible: {
......
...@@ -115,7 +115,6 @@ let map, ...@@ -115,7 +115,6 @@ let map,
}, },
modelArr = [], modelArr = [],
lightModels = [], lightModels = [],
passerbyModel,
lightModel, lightModel,
vehicleTypeNum = 0, vehicleTypeNum = 0,
vehicleModels = {}; vehicleModels = {};
...@@ -135,6 +134,7 @@ export default { ...@@ -135,6 +134,7 @@ export default {
computed: {}, computed: {},
data() { data() {
return { return {
mapConfig,
boxesShow: true, boxesShow: true,
crossDetailData: "", crossDetailData: "",
currentCheck: "", currentCheck: "",
...@@ -173,14 +173,6 @@ export default { ...@@ -173,14 +173,6 @@ export default {
map.setZoom(18); map.setZoom(18);
map.setPitch(0); map.setPitch(0);
map.setMinZoom(17.5); map.setMinZoom(17.5);
// this.regisAndSendWs("callPasserby", {
// dataType: "5",
// ...this.getBoundsLnglat(),
// });
// this.regisAndSendWs("callLight", {
// dataType: "4",
// ...this.getBoundsLnglat(),
// });
}, },
updateHeatMap(type, content) { updateHeatMap(type, content) {
// console.log(type); // console.log(type);
...@@ -373,31 +365,10 @@ export default { ...@@ -373,31 +365,10 @@ export default {
[map, scene] = mapMethods.initMap(); [map, scene] = mapMethods.initMap();
scene.on("loaded", () => { scene.on("loaded", () => {
this.sceneLoaded = true; this.sceneLoaded = true;
scene.addImage( for (let key in mapConfig.mapIcons) {
"cross", scene.addImage(key, mapConfig.mapIcons[key]);
require("../../assets/images/holo/路况-黄.svg") }
); if (!vehicleModels.car0) {
scene.addImage(
"event",
require("../../assets/images/holo/事件-点标.svg")
);
scene.addImage(
"milli",
require("../../assets/images/holo/毫米波雷达.png")
);
scene.addImage(
"laser",
require("../../assets/images/holo/激光雷达.png")
);
scene.addImage(
"weather",
require("../../assets/images/holo/气象监测仪.png")
);
scene.addImage(
"camera",
require("../../assets/images/holo/视频相机.png")
);
scene.addImage("sign", require("../../assets/images/holo/信号机.png"));
for (let key in dict.vehicleTypes) { for (let key in dict.vehicleTypes) {
console.log("key", key); console.log("key", key);
loader.load(`gltf/car${key}.gltf`, (gltf) => { loader.load(`gltf/car${key}.gltf`, (gltf) => {
...@@ -406,22 +377,12 @@ export default { ...@@ -406,22 +377,12 @@ export default {
gltf = null; gltf = null;
}); });
} }
// this.loadModuleByDRACOLoader("gltf/", "smallcar.glb").then((res) => {
// vehicleModel = res;
//
// this.switchfirst();
// });
this.loadModuleByDRACOLoader("gltf/", "passerby.gltf").then((res) => {
passerbyModel = res;
});
this.loadModuleByDRACOLoader("gltf/", "Ludeng.glb").then((res) => { this.loadModuleByDRACOLoader("gltf/", "Ludeng.glb").then((res) => {
// console.log("res", res);
lightModel = res; lightModel = res;
// map.flyTo({ zoom: 18 });
}); });
}
this.switchfirst();
}); });
this.switchfirst();
scene.on("click", (e) => { scene.on("click", (e) => {
console.log(e.lngLat); console.log(e.lngLat);
}); });
...@@ -457,22 +418,6 @@ export default { ...@@ -457,22 +418,6 @@ export default {
console.log("allCrossInfo", res.content); console.log("allCrossInfo", res.content);
}); });
} }
// 路口图层 点击 flyto 展示视频
// if (scene.getZoom() >= 17) {
// console.log("cc", map.getCenter());
// for (let cross of this.allCrossInfo)
// if (
// turf.distance(
// [map.getCenter().lng, map.getCenter().lat],
// [cross.location.split(",")[0], cross.location.split(",")[1]],
// {
// units: "kilometers",
// }
// ) < 0.05
// ) {
// console.log("yyyyyyyyyyyyyyy");
// }
// }
// 层级>=17 展示行人 & 灯态 // 层级>=17 展示行人 & 灯态
if (scene.getZoom() >= 17) { if (scene.getZoom() >= 17) {
// this.showCard = false; // this.showCard = false;
...@@ -1000,14 +945,12 @@ export default { ...@@ -1000,14 +945,12 @@ export default {
} }
} }
}, },
// 可关闭弹框关闭事件 // 可关闭弹框关闭事件
actionFinished(id, success) { actionFinished(id, success) {
this.dialogVisible[id] = false; this.dialogVisible[id] = false;
if (success) { if (success) {
} }
}, },
// 比较车辆ws前后两次数据差异 // 比较车辆ws前后两次数据差异
diff(oldData, newData) { diff(oldData, newData) {
// id 只在 newData 中存在且不在 oldData 中存在的即为 add // id 只在 newData 中存在且不在 oldData 中存在的即为 add
...@@ -1018,7 +961,6 @@ export default { ...@@ -1018,7 +961,6 @@ export default {
const commen = oldData.filter((e) => newData.find((c) => c.id === e.id)); const commen = oldData.filter((e) => newData.find((c) => c.id === e.id));
return { add, dele, commen }; return { add, dele, commen };
}, },
// videoList 删除单个 video // videoList 删除单个 video
deleteVideo(item) { deleteVideo(item) {
let index = this.videoListData.indexOf(item); let index = this.videoListData.indexOf(item);
...@@ -1080,7 +1022,6 @@ export default { ...@@ -1080,7 +1022,6 @@ export default {
layers[key][layer] = null; layers[key][layer] = null;
} }
} }
// scene.removeAllLayer();
if (scene) { if (scene) {
scene.removeAllLayer(); scene.removeAllLayer();
scene.destroy(); scene.destroy();
......
...@@ -70,8 +70,11 @@ export function addCrossPoint(scene, msg, offset, callback) { ...@@ -70,8 +70,11 @@ export function addCrossPoint(scene, msg, offset, callback) {
offsets: offset, offsets: offset,
}) })
.shape('cross') .shape('cross')
.size(12) .size(16)
.active(true) .active({
color: '#ffffff',
mix: 0.6,
})
.on('click', (e) => { .on('click', (e) => {
callback(e) callback(e)
}) })
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment