Fix BIM model version switching
This commit is contained in:
parent
1c687681de
commit
31bb673b44
|
|
@ -318,6 +318,7 @@ let modelVersionHistory = null;
|
||||||
let modelVersionHistoryLoading = false;
|
let modelVersionHistoryLoading = false;
|
||||||
let modelVersionUploading = false;
|
let modelVersionUploading = false;
|
||||||
let versionHistoryModal = null;
|
let versionHistoryModal = null;
|
||||||
|
let loadModelAsyncRef = null;
|
||||||
let emptyWheelNavigationRestoreTimer = null;
|
let emptyWheelNavigationRestoreTimer = null;
|
||||||
let lastSurfaceDollyFactor = null;
|
let lastSurfaceDollyFactor = null;
|
||||||
let lastSurfaceDollyFactorAt = 0;
|
let lastSurfaceDollyFactorAt = 0;
|
||||||
|
|
@ -4864,6 +4865,10 @@ const refreshModelVersionHistory = async ({ silent = false } = {}) => {
|
||||||
};
|
};
|
||||||
|
|
||||||
const openModelVersion = async (version) => {
|
const openModelVersion = async (version) => {
|
||||||
|
if (!loadModelAsyncRef) {
|
||||||
|
showError("Загрузчик модели еще не готов");
|
||||||
|
return;
|
||||||
|
}
|
||||||
const viewerSrc = getVersionViewerSrc(version);
|
const viewerSrc = getVersionViewerSrc(version);
|
||||||
const viewerType = getVersionViewerType(version);
|
const viewerType = getVersionViewerType(version);
|
||||||
if (!viewerSrc || !viewerType) {
|
if (!viewerSrc || !viewerType) {
|
||||||
|
|
@ -4886,25 +4891,33 @@ const openModelVersion = async (version) => {
|
||||||
artifactSrc: normalizeModelSettingsSrc(viewerSrc) || viewerSrc,
|
artifactSrc: normalizeModelSettingsSrc(viewerSrc) || viewerSrc,
|
||||||
viewerSettings: null,
|
viewerSettings: null,
|
||||||
};
|
};
|
||||||
const settings = await fetchModelSettings(settingsSrc).catch(() => null);
|
try {
|
||||||
if (settings?.viewerSettings) {
|
const settings = await fetchModelSettings(settingsSrc).catch(() => null);
|
||||||
meta.viewerSettings = settings.viewerSettings;
|
if (settings?.viewerSettings) {
|
||||||
|
meta.viewerSettings = settings.viewerSettings;
|
||||||
|
}
|
||||||
|
await loadModelAsyncRef({
|
||||||
|
type: viewerType,
|
||||||
|
url: viewerSrc,
|
||||||
|
name: version.originalFilename || previousEntry?.name || "model",
|
||||||
|
replace: true,
|
||||||
|
preserveMeta: true,
|
||||||
|
id: previousEntry?.model?.id || "model",
|
||||||
|
meta,
|
||||||
|
});
|
||||||
|
modelVersionHistory = {
|
||||||
|
...(modelVersionHistory || {}),
|
||||||
|
currentVersion: version.version || modelVersionHistory?.currentVersion || null,
|
||||||
|
currentVersionId: version.versionId || modelVersionHistory?.currentVersionId || null,
|
||||||
|
versions: modelVersionHistory?.versions || meta.versions || [],
|
||||||
|
};
|
||||||
|
updateModelVersionControl();
|
||||||
|
setStatus(`Открыта версия v${version.version || ""}`.trim());
|
||||||
|
} catch (err) {
|
||||||
|
console.error(err);
|
||||||
|
showError(err.message || "Не удалось открыть версию модели");
|
||||||
|
updateModelVersionControl();
|
||||||
}
|
}
|
||||||
await loadModelAsync({
|
|
||||||
type: viewerType,
|
|
||||||
url: viewerSrc,
|
|
||||||
name: version.originalFilename || previousEntry?.name || "model",
|
|
||||||
replace: true,
|
|
||||||
id: previousEntry?.model?.id || "model",
|
|
||||||
meta,
|
|
||||||
});
|
|
||||||
modelVersionHistory = {
|
|
||||||
...(modelVersionHistory || {}),
|
|
||||||
currentVersion: version.version || modelVersionHistory?.currentVersion || null,
|
|
||||||
currentVersionId: version.versionId || modelVersionHistory?.currentVersionId || null,
|
|
||||||
versions: modelVersionHistory?.versions || meta.versions || [],
|
|
||||||
};
|
|
||||||
updateModelVersionControl();
|
|
||||||
};
|
};
|
||||||
|
|
||||||
const uploadModelVersion = async (file) => {
|
const uploadModelVersion = async (file) => {
|
||||||
|
|
@ -6051,7 +6064,7 @@ const initViewer = async () => {
|
||||||
const loadModel = (options) => {
|
const loadModel = (options) => {
|
||||||
const debugOptions = options || {};
|
const debugOptions = options || {};
|
||||||
try {
|
try {
|
||||||
const { type, url, name = "", replace = true, id: forcedId, meta, edges } = options;
|
const { type, url, name = "", replace = true, id: forcedId, meta, edges, preserveMeta = false } = options;
|
||||||
const modelSettings = meta?.viewerSettings;
|
const modelSettings = meta?.viewerSettings;
|
||||||
const normalizedType = normalizeType(type, typeof url === "string" ? url : "");
|
const normalizedType = normalizeType(type, typeof url === "string" ? url : "");
|
||||||
const inferredType = normalizedType || normalizeType(guessTypeFromName(typeof url === "string" ? url : ""));
|
const inferredType = normalizedType || normalizeType(guessTypeFromName(typeof url === "string" ? url : ""));
|
||||||
|
|
@ -6062,7 +6075,7 @@ const initViewer = async () => {
|
||||||
}
|
}
|
||||||
|
|
||||||
if (replace) {
|
if (replace) {
|
||||||
destroyAllModels({ preserveMeta: isLoadingSavedProject });
|
destroyAllModels({ preserveMeta: preserveMeta || isLoadingSavedProject });
|
||||||
}
|
}
|
||||||
|
|
||||||
if (modelSettings) {
|
if (modelSettings) {
|
||||||
|
|
@ -6215,6 +6228,7 @@ const initViewer = async () => {
|
||||||
model.on("loaded", () => resolve(model));
|
model.on("loaded", () => resolve(model));
|
||||||
model.on("error", (err) => reject(new Error(err?.message || err)));
|
model.on("error", (err) => reject(new Error(err?.message || err)));
|
||||||
});
|
});
|
||||||
|
loadModelAsyncRef = loadModelAsync;
|
||||||
|
|
||||||
const loadStartupModelFromQuery = async () => {
|
const loadStartupModelFromQuery = async () => {
|
||||||
const params = new URLSearchParams(window.location.search);
|
const params = new URLSearchParams(window.location.search);
|
||||||
|
|
|
||||||
|
|
@ -697,6 +697,6 @@
|
||||||
<input id="fileInput" class="hidden" type="file"
|
<input id="fileInput" class="hidden" type="file"
|
||||||
accept=".xkt,.glb,.gltf,.bim,.las,.laz,.obj,.stl">
|
accept=".xkt,.glb,.gltf,.bim,.las,.laz,.obj,.stl">
|
||||||
|
|
||||||
<script type="module" src="/dcViewer.js?v=57"></script>
|
<script type="module" src="/dcViewer.js?v=58"></script>
|
||||||
</body>
|
</body>
|
||||||
</html>
|
</html>
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue