Commit 640491ab authored by ninglx's avatar ninglx

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

parent e5509379
......@@ -10,6 +10,15 @@ export default {
maxZoom: 20.5,
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.4.14:8883/tile?lid=traffic&get=map&cache=on&x={x}&y={y}&z={z}',
}
......@@ -185,11 +185,7 @@ export default {
this.$destroy();
next();
},
mounted() {
this.$nextTick(() => {
this.initMap();
});
},
mounted() {},
methods: {
checkallChange(e) {
if (e) {
......@@ -207,31 +203,6 @@ export default {
}
},
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() {},
......
......@@ -185,11 +185,7 @@ export default {
this.$destroy();
next();
},
mounted() {
this.$nextTick(() => {
this.initMap();
});
},
mounted() {},
methods: {
checkallChange(e) {
if (e) {
......@@ -207,31 +203,6 @@ export default {
}
},
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() {},
......
......@@ -472,7 +472,7 @@ export default {
this.sceneLoaded = true;
scene.addImage(
"cross",
require("../../assets/images/holo/路况-黄.svg")
require("../../assets/images/holo/location-yellow.png")
);
crossInfo().then((res) => {
// debugger;
......
......@@ -78,8 +78,8 @@ export default {
},
},
mapImgUrls: {
carSymbolImage: require("../../assets/images/shop-15.png"),
passerbyImage: require("../../assets/images/passerby.png"),
// carSymbolImage: require("../../assets/images/shop-15.png"),
// passerbyImage: require("../../assets/images/passerby.png"),
},
vehicleDetailData: {},
dialogVisible: {
......
......@@ -83,8 +83,8 @@ export default {
},
},
mapImgUrls: {
carSymbolImage: require("../../assets/images/shop-15.png"),
passerbyImage: require("../../assets/images/passerby.png"),
// carSymbolImage: require("../../assets/images/shop-15.png"),
// passerbyImage: require("../../assets/images/passerby.png"),
},
vehicleDetailData: {},
dialogVisible: {
......
......@@ -115,7 +115,6 @@ let map,
},
modelArr = [],
lightModels = [],
passerbyModel,
lightModel,
vehicleTypeNum = 0,
vehicleModels = {};
......@@ -135,6 +134,7 @@ export default {
computed: {},
data() {
return {
mapConfig,
boxesShow: true,
crossDetailData: "",
currentCheck: "",
......@@ -173,14 +173,6 @@ export default {
map.setZoom(18);
map.setPitch(0);
map.setMinZoom(17.5);
// this.regisAndSendWs("callPasserby", {
// dataType: "5",
// ...this.getBoundsLnglat(),
// });
// this.regisAndSendWs("callLight", {
// dataType: "4",
// ...this.getBoundsLnglat(),
// });
},
updateHeatMap(type, content) {
// console.log(type);
......@@ -373,55 +365,24 @@ export default {
[map, scene] = mapMethods.initMap();
scene.on("loaded", () => {
this.sceneLoaded = true;
scene.addImage(
"cross",
require("../../assets/images/holo/路况-黄.svg")
);
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) {
console.log("key", key);
loader.load(`gltf/car${key}.gltf`, (gltf) => {
vehicleModels[`car${key}`] = gltf.scene;
vehicleTypeNum++;
gltf = null;
for (let key in mapConfig.mapIcons) {
scene.addImage(key, mapConfig.mapIcons[key]);
}
if (!vehicleModels.car0) {
for (let key in dict.vehicleTypes) {
console.log("key", key);
loader.load(`gltf/car${key}.gltf`, (gltf) => {
vehicleModels[`car${key}`] = gltf.scene;
vehicleTypeNum++;
gltf = null;
});
}
this.loadModuleByDRACOLoader("gltf/", "Ludeng.glb").then((res) => {
lightModel = res;
});
}
// 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) => {
// console.log("res", res);
lightModel = res;
// map.flyTo({ zoom: 18 });
});
this.switchfirst();
});
this.switchfirst();
scene.on("click", (e) => {
console.log(e.lngLat);
});
......@@ -457,22 +418,6 @@ export default {
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 展示行人 & 灯态
if (scene.getZoom() >= 17) {
// this.showCard = false;
......@@ -1000,14 +945,12 @@ export default {
}
}
},
// 可关闭弹框关闭事件
actionFinished(id, success) {
this.dialogVisible[id] = false;
if (success) {
}
},
// 比较车辆ws前后两次数据差异
diff(oldData, newData) {
// id 只在 newData 中存在且不在 oldData 中存在的即为 add
......@@ -1018,7 +961,6 @@ export default {
const commen = oldData.filter((e) => newData.find((c) => c.id === e.id));
return { add, dele, commen };
},
// videoList 删除单个 video
deleteVideo(item) {
let index = this.videoListData.indexOf(item);
......@@ -1080,7 +1022,6 @@ export default {
layers[key][layer] = null;
}
}
// scene.removeAllLayer();
if (scene) {
scene.removeAllLayer();
scene.destroy();
......
......@@ -70,8 +70,11 @@ export function addCrossPoint(scene, msg, offset, callback) {
offsets: offset,
})
.shape('cross')
.size(12)
.active(true)
.size(16)
.active({
color: '#ffffff',
mix: 0.6,
})
.on('click', (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