更新系統樣式 |使用local modal
This commit is contained in:
parent
af6a15d931
commit
66b31cef54
@ -39,80 +39,120 @@ const forgeDom = ref(null);
|
|||||||
|
|
||||||
const initViewer = (container) => {
|
const initViewer = (container) => {
|
||||||
return new Promise(function (resolve, reject) {
|
return new Promise(function (resolve, reject) {
|
||||||
Autodesk.Viewing.Initializer({ getAccessToken }, function () {
|
// Autodesk.Viewing.Initializer({ getAccessToken }, function () {
|
||||||
const config = {
|
// const config = {
|
||||||
extensions: ["Autodesk.DataVisualization", "Autodesk.DocumentBrowser"],
|
// extensions: ["Autodesk.DataVisualization", "Autodesk.DocumentBrowser"],
|
||||||
};
|
// };
|
||||||
let viewer = new Autodesk.Viewing.GuiViewer3D(container, config);
|
// let viewer = new Autodesk.Viewing.GuiViewer3D(container, config);
|
||||||
Autodesk.Viewing.Private.InitParametersSetting.alpha = true;
|
// Autodesk.Viewing.Private.InitParametersSetting.alpha = true;
|
||||||
viewer.start();
|
// viewer.start();
|
||||||
resolve(viewer);
|
// resolve(viewer);
|
||||||
});
|
// });
|
||||||
});
|
|
||||||
};
|
|
||||||
|
|
||||||
const loadModel = (viewer, urn) => {
|
Autodesk.Viewing.Initializer(
|
||||||
return new Promise(function (resolve, reject) {
|
{
|
||||||
async function onDocumentLoadSuccess(doc) {
|
env: "Local",
|
||||||
viewer.setGroundShadow(false);
|
language: "en",
|
||||||
viewer.impl.renderer().setClearAlpha(0); //clear alpha channel
|
},
|
||||||
viewer.impl.glrenderer().setClearColor(0xffffff, 0); //set transparent background, color code does not matter
|
function () {
|
||||||
viewer.impl.invalidate(true); //trigger rendering
|
const config = {
|
||||||
|
extensions: [
|
||||||
const documentNode = await viewer.loadDocumentNode(
|
"Autodesk.DataVisualization",
|
||||||
doc,
|
"Autodesk.DocumentBrowser",
|
||||||
doc.getRoot().getDefaultGeometry()
|
],
|
||||||
);
|
};
|
||||||
updateDataVisualization(viewer)
|
let viewer = new Autodesk.Viewing.GuiViewer3D(container, config);
|
||||||
resolve(documentNode);
|
Autodesk.Viewing.Private.InitParametersSetting.alpha = true;
|
||||||
}
|
viewer.start();
|
||||||
function onDocumentLoadFailure(code, message, errors) {
|
resolve(viewer);
|
||||||
reject({ code, message, errors });
|
}
|
||||||
}
|
|
||||||
Autodesk.Viewing.Document.load(
|
|
||||||
"urn:" + urn,
|
|
||||||
onDocumentLoadSuccess,
|
|
||||||
onDocumentLoadFailure
|
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
const initForge = () => {
|
// 使用本地 .svf 文件加載模型
|
||||||
getUrn().then((res) => {
|
const loadModel = (viewer, filePath) => {
|
||||||
if (!res.isSuccess) return;
|
return new Promise((resolve, reject) => {
|
||||||
|
viewer.loadModel(
|
||||||
initViewer(forgeDom.value).then((viewer) => {
|
filePath,
|
||||||
loadModel(viewer, res.data[0].urn_3D).then(() => {
|
{},
|
||||||
viewer.addEventListener(
|
(model) => {
|
||||||
Autodesk.Viewing.GEOMETRY_LOADED_EVENT,
|
viewer.impl.invalidate(true);
|
||||||
async function () {
|
viewer.fitToView();
|
||||||
console.log(
|
resolve(model);
|
||||||
"Autodesk.Viewing.GEOMETRY_LOADED_EVENT",
|
console.log("模型加載完成");
|
||||||
viewer.isLoadDone()
|
},
|
||||||
);
|
reject
|
||||||
// updateForgeViewer(viewer);
|
);
|
||||||
createSprites()
|
|
||||||
hideAllObjects();
|
|
||||||
}
|
|
||||||
);
|
|
||||||
viewer.addEventListener(
|
|
||||||
Autodesk.Viewing.CAMERA_CHANGE_EVENT,
|
|
||||||
function (e) {
|
|
||||||
// viewer.isLoadDone() &&
|
|
||||||
// updateDbidPosition(this, subscribeData.value);
|
|
||||||
console.log(
|
|
||||||
"camera position changed: ",
|
|
||||||
NOP_VIEWER.navigation.getTarget(),
|
|
||||||
e.camera.position
|
|
||||||
);
|
|
||||||
}
|
|
||||||
);
|
|
||||||
|
|
||||||
});
|
|
||||||
});
|
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
|
// const loadModel = (viewer, urn) => {
|
||||||
|
// return new Promise(function (resolve, reject) {
|
||||||
|
// async function onDocumentLoadSuccess(doc) {
|
||||||
|
// viewer.setGroundShadow(false);
|
||||||
|
// viewer.impl.renderer().setClearAlpha(0); //clear alpha channel
|
||||||
|
// viewer.impl.glrenderer().setClearColor(0xffffff, 0); //set transparent background, color code does not matter
|
||||||
|
// viewer.impl.invalidate(true); //trigger rendering
|
||||||
|
|
||||||
|
// const documentNode = await viewer.loadDocumentNode(
|
||||||
|
// doc,
|
||||||
|
// doc.getRoot().getDefaultGeometry()
|
||||||
|
// );
|
||||||
|
// updateDataVisualization(viewer)
|
||||||
|
// resolve(documentNode);
|
||||||
|
// }
|
||||||
|
// function onDocumentLoadFailure(code, message, errors) {
|
||||||
|
// reject({ code, message, errors });
|
||||||
|
// }
|
||||||
|
// Autodesk.Viewing.Document.load(
|
||||||
|
// "urn:" + urn,
|
||||||
|
// onDocumentLoadSuccess,
|
||||||
|
// onDocumentLoadFailure
|
||||||
|
// );
|
||||||
|
// });
|
||||||
|
// };
|
||||||
|
|
||||||
|
const initForge = async () => {
|
||||||
|
// getUrn().then((res) => {
|
||||||
|
// if (!res.isSuccess) return;
|
||||||
|
|
||||||
|
// initViewer(forgeDom.value).then((viewer) => {
|
||||||
|
// loadModel(viewer, res.data[0].urn_3D).then(() => {
|
||||||
|
// viewer.addEventListener(
|
||||||
|
// Autodesk.Viewing.GEOMETRY_LOADED_EVENT,
|
||||||
|
// async function () {
|
||||||
|
// console.log(
|
||||||
|
// "Autodesk.Viewing.GEOMETRY_LOADED_EVENT",
|
||||||
|
// viewer.isLoadDone()
|
||||||
|
// );
|
||||||
|
// // updateForgeViewer(viewer);
|
||||||
|
// createSprites()
|
||||||
|
// hideAllObjects();
|
||||||
|
// }
|
||||||
|
// );
|
||||||
|
// viewer.addEventListener(
|
||||||
|
// Autodesk.Viewing.CAMERA_CHANGE_EVENT,
|
||||||
|
// function (e) {
|
||||||
|
// // viewer.isLoadDone() &&
|
||||||
|
// // updateDbidPosition(this, subscribeData.value);
|
||||||
|
// console.log(
|
||||||
|
// "camera position changed: ",
|
||||||
|
// NOP_VIEWER.navigation.getTarget(),
|
||||||
|
// e.camera.position
|
||||||
|
// );
|
||||||
|
// }
|
||||||
|
// );
|
||||||
|
|
||||||
|
// });
|
||||||
|
// });
|
||||||
|
// });
|
||||||
|
const FILE_BASEURL = import.meta.env.VITE_FILE_API_BASEURL;
|
||||||
|
const viewer = await initViewer(forgeDom.value)
|
||||||
|
const filePath = `${FILE_BASEURL}/upload/forge/0.svf`;
|
||||||
|
await loadModel(viewer, filePath)
|
||||||
|
};
|
||||||
|
|
||||||
onMounted(() => {
|
onMounted(() => {
|
||||||
console.log("Forge 加載");
|
console.log("Forge 加載");
|
||||||
initForge();
|
initForge();
|
||||||
|
@ -116,27 +116,29 @@ provide("system_deviceList", { data, subscribeData, currentFloor, updateCurrentF
|
|||||||
|
|
||||||
<template>
|
<template>
|
||||||
<SystemFloorBar />
|
<SystemFloorBar />
|
||||||
<div class="grid grid-cols-2 gap-5 mb-5">
|
<div class="grid grid-cols-2 gap-5 mt-8 mb-4">
|
||||||
<div class="col-span-1 my-5 h-[80vh]">
|
<div class="col-span-1 h-[80vh] flex flex-col justify-between">
|
||||||
<div class="flex mb-4 items-center">
|
<div>
|
||||||
<span class="flex items-center mr-3" v-if="statusList?.device_normal_text">
|
<div class="flex mb-4 items-center">
|
||||||
<span class="w-7 h-7 rounded-full inline-block mr-1"
|
<span class="flex items-center mr-3" v-if="statusList?.device_normal_text">
|
||||||
:style="{ backgroundColor: statusList.device_normal_color }"></span>
|
<span class="w-7 h-7 rounded-full inline-block mr-1"
|
||||||
<span>{{ statusList.device_normal_text }}</span>
|
:style="{ backgroundColor: statusList.device_normal_color }"></span>
|
||||||
</span>
|
<span>{{ statusList.device_normal_text }}</span>
|
||||||
<span class="flex items-center mr-3" v-if="statusList?.device_close_text">
|
</span>
|
||||||
<span class="w-7 h-7 rounded-full inline-block mr-1"
|
<span class="flex items-center mr-3" v-if="statusList?.device_close_text">
|
||||||
:style="{ backgroundColor: statusList.device_close_color }"></span>
|
<span class="w-7 h-7 rounded-full inline-block mr-1"
|
||||||
<span>{{ statusList.device_close_text }}</span>
|
:style="{ backgroundColor: statusList.device_close_color }"></span>
|
||||||
</span>
|
<span>{{ statusList.device_close_text }}</span>
|
||||||
<span class="flex items-center mr-3" v-if="statusList?.device_error_text">
|
</span>
|
||||||
<span class="w-7 h-7 rounded-full inline-block mr-1"
|
<span class="flex items-center mr-3" v-if="statusList?.device_error_text">
|
||||||
:style="{ backgroundColor: statusList.device_error_color }"></span>
|
<span class="w-7 h-7 rounded-full inline-block mr-1"
|
||||||
<span>{{ statusList.device_error_text }}</span>
|
:style="{ backgroundColor: statusList.device_error_color }"></span>
|
||||||
</span>
|
<span>{{ statusList.device_error_text }}</span>
|
||||||
|
</span>
|
||||||
|
</div>
|
||||||
|
<SystemSubBar class="mt-2 mb-4" />
|
||||||
</div>
|
</div>
|
||||||
<SystemSubBar class="mt-2 mb-4" />
|
<div class="max-h-[75vh] pr-2 overflow-y-auto">
|
||||||
<div class="max-h-[75vh] pr-2 my-2 overflow-y-auto">
|
|
||||||
<RouterView />
|
<RouterView />
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
Loading…
Reference in New Issue
Block a user