效果颜色:{{ formData.color ? formData.color : "" }}
@@ -221,6 +262,23 @@ const props = defineProps({
type: String
});
const emits = defineEmits(["confirm"]);
+const selectedFormData = ref({
+ type: 1,
+ color: ""
+});
+const selectedHideList = ref([]); // 选中要隐藏的构件
+const selectedColorList = ref([]); // 选中要着色的构件
+const typeOptions = ref([
+ { label: "隐藏", value: 1 },
+ { label: "着色", value: 2 }
+]);
+const treeProps = {
+ label: "name",
+ children: "children"
+};
+const treeData = ref
([]);
+const checkedKeys = ref([]);
+const expandedKeys = ref([]);
const formData: any = ref({});
const configJson = ref({
scene: {
@@ -234,6 +292,10 @@ const configJson = ref({
fullscreenButton: true, // 全屏按钮
contextmenu: { hasDefault: true } // 右键菜单
},
+ terrain: {
+ url: "//data.mars3d.cn/terrain",
+ show: true
+ },
basemaps: [
{
name: "天地图影像",
@@ -249,6 +311,18 @@ let graphicLayer: any;
let thisLayer: any; // 选中的图层
let thisAlbuginea: any; // 选中的白膜
let tiles3dLayer: any;
+// 删除选中数据
+const deleteSelected = (type: any, index: any) => {
+ if (type == 1) {
+ selectedHideList.value.splice(index, 1);
+ } else if (type == 2) {
+ selectedColorList.value.splice(index, 1);
+ }
+};
+const handleCheckChange = (e: any, obj: any) => {
+ console.log(e);
+ console.log(obj);
+};
// 修改模型当前配置
const editModelConfig = async () => {
let requestData = {
@@ -462,6 +536,49 @@ const getPointPositionInfo = async () => {
await initMars3d(configJson.value);
}
};
+// 获取白膜构件数据详情
+const name2text = (o: any) => {
+ o.text = o.name;
+
+ // 这块为了避免tree控件里的id不统一,所以加改变一下
+ o.eleid = o.id;
+ o.id = undefined;
+
+ if ((!o.text || o.text.trim() === "") && o.type) {
+ o.text = o.type;
+ }
+
+ if (o.children) {
+ for (let i = 0; i < o.children.length; i++) {
+ name2text(o.children[i]);
+ }
+ }
+};
+const querySceneTreeData = (url: any) => {
+ const scenetree = url.substring(0, url.lastIndexOf("/") + 1) + "scenetree.json";
+ return mars3d.Util.fetchJson({ url: scenetree });
+};
+const getAlbugineaTreeData = (model: any) => {
+ querySceneTreeData(model)
+ .then(function (scene: any) {
+ const data = [];
+ if (scene.scenes) {
+ for (let i = 0; i < scene.scenes.length; i++) {
+ const node = scene.scenes[i];
+ name2text(node);
+ data.push(node);
+ }
+ } else {
+ name2text(scene);
+ data.push(scene);
+ }
+ treeData.value = data;
+ console.log(treeData.value);
+ })
+ .catch(function (error) {
+ console.log("加载JSON出错", error);
+ });
+};
// 获取白膜数据详情
const getAlbugineaInfo = async () => {
let requestData = {
@@ -490,6 +607,7 @@ const getAlbugineaInfo = async () => {
}
tiles3dLayer = new mars3d.layer.TilesetLayer(showObj);
map.addLayer(tiles3dLayer);
+ getAlbugineaTreeData(result.url);
// configJson.value.layers = [
// {
// id: result.id,
@@ -554,6 +672,9 @@ const random = (min: any, max: any) => {
const initMars3d = async (option: any) => {
console.log(666);
map = new mars3d.Map("mars3dContainer", option);
+ map.fixedLight = true; // 固定光照,避免gltf模型随时间存在亮度不一致。
+ // 固定光照时间
+ map.clock.currentTime = Cesium.JulianDate.fromDate(new Date("2022-11-01 12:00:00"));
// 创建矢量数据图层
graphicLayer = new mars3d.layer.GraphicLayer();
map.addLayer(graphicLayer);