Skip to content

Commit

Permalink
Merge branch 'develop'
Browse files Browse the repository at this point in the history
  • Loading branch information
NicolasRichel committed Feb 6, 2024
2 parents 8ebb48e + 7b9efbf commit ac4daca
Show file tree
Hide file tree
Showing 6 changed files with 46 additions and 32 deletions.
4 changes: 2 additions & 2 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@bimdata/bcf-components",
"version": "6.2.0",
"version": "6.2.1-rc.6",
"files": [
"src",
"vue3-plugin.js"
Expand Down
17 changes: 10 additions & 7 deletions src/components/bcf-topic-form/BcfTopicForm.vue
Original file line number Diff line number Diff line change
Expand Up @@ -346,11 +346,13 @@ 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(async ctx => {
const viewpoint = ctx.getViewpoint();
viewpoint.snapshot = await ctx.getSnapshot();
viewpointsToCreate.value.push(viewpoint);
})
);
};
Expand Down Expand Up @@ -449,8 +451,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 @@ -46,8 +46,8 @@
<template #element="{ element }">
<div
style="width: 100%"
@mouseenter="highlightViewer(element.viewer)"
@mouseleave="unhighlightViewer(element.viewer)"
@mouseenter="highlightViewer(element.context)"
@mouseleave="unhighlightViewer(element.context)"
>
{{ `(${element.index}) ${element.name}` }}
</div>
Expand Down Expand Up @@ -96,7 +96,7 @@
<script>
import { onMounted, inject, ref, watch, onBeforeUnmount } from "vue";
import service from "../../../service.js";
import { getViewerOptions, highlightViewer, unhighlightViewer } from "../../../utils/viewer.js";
import { getViewerOptions, getViewerViewpoint, highlightViewer, unhighlightViewer } from "../../../utils/viewer.js";
// Components
import TopicComment from "./topic-comment/TopicComment.vue";
Expand Down Expand Up @@ -150,10 +150,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 getViewerViewpoint(context);
};
const deleteViewpoint = () => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -104,8 +104,8 @@
<template #element="{ element }">
<div
style="width: 100%"
@mouseenter="highlightViewer(element.viewer)"
@mouseleave="unhighlightViewer(element.viewer)"
@mouseenter="highlightViewer(element.context)"
@mouseleave="unhighlightViewer(element.context)"
>
{{ `(${element.index}) ${element.name}` }}
</div>
Expand Down Expand Up @@ -139,7 +139,7 @@
<script>
import { inject, onMounted, ref, onBeforeUnmount } from "vue";
import service from "../../../../service.js";
import { getViewerOptions, highlightViewer, unhighlightViewer } from "../../../../utils/viewer.js";
import { getViewerOptions, getViewerViewpoint, highlightViewer, unhighlightViewer } from "../../../../utils/viewer.js";
// TODO: should be imported from DS
import UserAvatar from "../../../user-avatar/UserAvatar.vue";
Expand Down 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 getViewerViewpoint(context);
};
const canEditComment = comment => {
Expand Down
31 changes: 21 additions & 10 deletions src/utils/viewer.js
Original file line number Diff line number Diff line change
@@ -1,16 +1,27 @@
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 && ctx.loadedModels.length > 0)
.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 async function getViewerViewpoint(context) {
const ctx = context.viewer.$viewer.localContext;
return {
...ctx.getViewpoint(),
snapshot: await ctx.getSnapshot()
};
}

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

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

0 comments on commit ac4daca

Please sign in to comment.