beam: pass model settings source to viewer
This commit is contained in:
parent
31dca29560
commit
15c9fb1df1
|
|
@ -70,6 +70,17 @@ const getUsableBeamViewerUrl = (url: string | undefined): string | undefined =>
|
|||
}
|
||||
};
|
||||
|
||||
const withBeamViewerSettingsSrc = (url: string | undefined, settingsSrc: string | undefined): string | undefined => {
|
||||
if (!url || !settingsSrc) return url;
|
||||
try {
|
||||
const parsedUrl = new URL(url, "http://localhost");
|
||||
if (!parsedUrl.searchParams.has("settingsSrc")) parsedUrl.searchParams.set("settingsSrc", settingsSrc);
|
||||
return parsedUrl.toString();
|
||||
} catch (_error) {
|
||||
return url;
|
||||
}
|
||||
};
|
||||
|
||||
const getPreviewType = (extension: string) => {
|
||||
const normalizedExtension = extension.toLowerCase();
|
||||
if (IMAGE_EXTENSIONS.has(normalizedExtension)) return "image";
|
||||
|
|
@ -101,6 +112,7 @@ const buildSyncedBeamViewerAttachment = (
|
|||
previewAvailable: true,
|
||||
viewerUrl: buildBeamViewerUrl({
|
||||
name: fullFileName,
|
||||
settingsSrc: status.sourceSrc || beamViewer.conversion?.sourceSrc || beamViewer.src,
|
||||
src: status.artifactUrl,
|
||||
type: artifactType,
|
||||
}),
|
||||
|
|
@ -146,14 +158,17 @@ export const IssueAttachmentsListItem = observer(function IssueAttachmentsListIt
|
|||
const attachmentService = useMemo(() => new IssueAttachmentService(issueServiceType), [issueServiceType]);
|
||||
const resolvedArtifactUrl = beamConversionStatus?.status === "ready" ? beamConversionStatus.artifactUrl : undefined;
|
||||
const storedModelViewerUrl = getUsableBeamViewerUrl(beamViewer?.viewerUrl);
|
||||
const beamViewerSettingsSrc = beamConversionStatus?.sourceSrc || beamViewer?.conversion?.sourceSrc || beamViewer?.src;
|
||||
const storedModelViewerUrlWithSettings = withBeamViewerSettingsSrc(storedModelViewerUrl, beamViewerSettingsSrc);
|
||||
const modelViewerUrl =
|
||||
(resolvedArtifactUrl
|
||||
? buildBeamViewerUrl({
|
||||
name: fullFileName,
|
||||
settingsSrc: beamViewerSettingsSrc,
|
||||
src: resolvedArtifactUrl,
|
||||
type: beamConversionStatus?.artifactType || "gltf",
|
||||
})
|
||||
: undefined) || storedModelViewerUrl;
|
||||
: undefined) || storedModelViewerUrlWithSettings;
|
||||
const modelDownloadUrl = beamViewer?.downloadUrl || beamViewer?.src;
|
||||
const previewDownloadUrl = modelDownloadUrl || fileURL;
|
||||
const isBeamModel = isBeamModelFile(fullFileName);
|
||||
|
|
|
|||
|
|
@ -121,12 +121,18 @@ export const isBeamModelFile = (name: string | undefined): boolean => !!getBeamM
|
|||
|
||||
export const isBeamDirectViewerFile = (name: string | undefined): boolean => !!getBeamDirectModelTypeFromName(name);
|
||||
|
||||
export const buildBeamViewerUrl = (params: { name?: string; src: string; type?: string | null }): string => {
|
||||
export const buildBeamViewerUrl = (params: {
|
||||
name?: string;
|
||||
settingsSrc?: string;
|
||||
src: string;
|
||||
type?: string | null;
|
||||
}): string => {
|
||||
const viewerUrl = new URL(getBeamViewerBaseUrl());
|
||||
viewerUrl.searchParams.set("url", params.src);
|
||||
if (params.type) viewerUrl.searchParams.set("type", params.type);
|
||||
if (params.type === "gltf" || params.type === "glb") viewerUrl.searchParams.set("edges", "false");
|
||||
if (params.name) viewerUrl.searchParams.set("name", params.name);
|
||||
if (params.settingsSrc) viewerUrl.searchParams.set("settingsSrc", params.settingsSrc);
|
||||
return viewerUrl.toString();
|
||||
};
|
||||
|
||||
|
|
@ -237,6 +243,7 @@ export const uploadBeamModelFile = (
|
|||
...baseAttachment,
|
||||
viewerUrl: buildBeamViewerUrl({
|
||||
name: file.name,
|
||||
settingsSrc: downloadUrl.toString(),
|
||||
src: downloadUrl.toString(),
|
||||
type: directViewerType,
|
||||
}),
|
||||
|
|
|
|||
Loading…
Reference in New Issue