Skip to content

Commit

Permalink
PATCH: fix: use new viewer apis to handle viewpoints
Browse files Browse the repository at this point in the history
  • Loading branch information
NicolasRichel committed Feb 5, 2024
1 parent 8ebb48e commit 1b71111
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 19 deletions.
13 changes: 7 additions & 6 deletions src/components/bcf-topic-form/BcfTopicForm.vue
Original file line number Diff line number Diff line change
Expand Up @@ -346,10 +346,10 @@ export default {
const createViewpoints = () => {
Promise.all(
($viewer?.globalContext.getViewers() ?? [])
.filter(viewer => viewer.getLoadedModels().length > 0)
.map(viewer =>
viewer.getViewpoint().then(viewpoint => viewpointsToCreate.value.push(viewpoint))
($viewer?.globalContext.localContexts ?? [])
.filter(ctx => ctx.viewer && ctx.loadedModels.length > 0)
.map(ctx =>
ctx.getViewpoint().then(viewpoint => viewpointsToCreate.value.push(viewpoint))
)
);
};
Expand Down Expand Up @@ -449,8 +449,9 @@ export default {
let newTopic;
if (isCreation.value) {
if ($viewer) {
data.models = $viewer.globalContext.getViewers()
.flatMap(v => v.getLoadedModels().map(m => m.id));
data.models = $viewer.globalContext.localContexts
.filter(ctx => ctx.viewer)
.flatMap(ctx => ctx.loadedModelIds);
}
newTopic = await service.createTopic(props.project, data);
} else {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -215,10 +215,10 @@ export default {
}
};
const createViewpoint = async ({ viewer }) => {
unhighlightViewer(viewer);
const createViewpoint = async ({ context }) => {
unhighlightViewer(context);
viewerSelectVisible.value = false;
viewpoint.value = await viewer.getViewpoint();
viewpoint.value = await context.getViewpoint();
};
const canEditComment = comment => {
Expand Down
21 changes: 11 additions & 10 deletions src/utils/viewer.js
Original file line number Diff line number Diff line change
@@ -1,16 +1,17 @@
export function getViewerOptions($viewer) {
return $viewer.globalContext.getViewers()
.map((v, i) => ({ key: `${i}-${v.plugin.name}`, index: i, name: v.plugin.name, viewer: v }));
return $viewer.globalContext.localContexts
.filter(ctx => ctx.viewer)
.map((ctx, i) => ({ key: ctx.id, index: i, name: ctx.viewer.$plugin.name, context: ctx }));
}

export function highlightViewer(viewer) {
viewer.$viewer.localContext.el.style.boxSizing = "border-box";
viewer.$viewer.localContext.el.style.border = "2px solid var(--color-primary)";
viewer.$viewer.localContext.el.style.opacity = ".85";
export function highlightViewer(context) {
context.el.style.boxSizing = "border-box";
context.el.style.border = "2px solid var(--color-primary)";
context.el.style.opacity = ".85";
}

export function unhighlightViewer(viewer) {
viewer.$viewer.localContext.el.style.boxSizing = "";
viewer.$viewer.localContext.el.style.border = "";
viewer.$viewer.localContext.el.style.opacity = "";
export function unhighlightViewer(context) {
context.el.style.boxSizing = "";
context.el.style.border = "";
context.el.style.opacity = "";
}

0 comments on commit 1b71111

Please sign in to comment.