Skip to content

Commit

Permalink
feat(models): add support for photosphere models (wip)
Browse files Browse the repository at this point in the history
  • Loading branch information
NicolasRichel committed Jul 26, 2024
1 parent 0941f26 commit 22f6a90
Show file tree
Hide file tree
Showing 9 changed files with 836 additions and 73 deletions.
715 changes: 650 additions & 65 deletions package-lock.json

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ import IFCManager from "./ifc-manager/IFCManager.vue";
import PDFManager from "./pdf-manager/PDFManager.vue";
import PointCloudManager from "./point-cloud-manager/PointCloudManager.vue";
const { DWG, DXF, IFC, JPEG, META_BUILDING, PDF, PNG, POINT_CLOUD } =
const { DWG, DXF, IFC, JPEG, META_BUILDING, PDF, PHOTOSPHERE, PNG, POINT_CLOUD } =
MODEL_TYPE;
const tabsDef = [
Expand Down Expand Up @@ -132,7 +132,7 @@ const tabsDef = [
id: "photos",
text: "Photos",
icon: "fileImagePolychrome",
modelTypes: [JPEG, PNG],
modelTypes: [JPEG, PHOTOSPHERE, PNG],
component: "DWGManager"
}
];
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,7 @@
@download="downloadModels([$event])"
@view-metaBuilding="$emit('view-metaBuilding', $event)"
@edit-metaBuilding="$emit('edit-metaBuilding', $event)"
@view-photosphereBuilding="$emit('view-photosphereBuilding', $event)"
>
<template #placeholder>
<slot name="tablePlaceholder"></slot>
Expand Down Expand Up @@ -122,7 +123,8 @@ export default {
"edit-metaBuilding",
"file-uploaded",
"tab-changed",
"view-metaBuilding"
"view-metaBuilding",
"view-photosphereBuilding",
],
setup(props, { emit }) {
const { createModel, updateModels } = useModels();
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,79 @@
<template>
<GenericModelsManager
:project="project"
:types="types"
:tabs="tabs"
@file-uploaded="$emit('file-uploaded')"
@view-photosphereBuilding="viewPhotosphereBuilding"
/>
</template>

<script>
import { ref, watch } from "vue";
import { useAppSidePanel } from "../../../app/app-side-panel/app-side-panel.js";
import { segregateBySource } from "../../../../../utils/models.js";
// Components
import GenericModelsManager from "../generic-models-manager/GenericModelsManager.vue";
import PhotosphereBuildingPanel from "./PhotosphereBuildingPanel.vue";
const tabsDef = [{ id: "upload" }, { id: "archive" }];
export default {
components: {
GenericModelsManager
},
props: {
project: {
type: Object,
required: true
},
models: {
type: Array,
required: true
},
types: {
type: Array,
required: true
}
},
emits: ["file-uploaded"],
setup(props) {
const { openSidePanel, closeSidePanel } = useAppSidePanel();
const tabs = ref(tabsDef);
const viewPhotosphereBuilding = model => {
openSidePanel("right", {
component: {
render() {
return h(PhotosphereBuildingPanel, {
onClose: closeSidePanel,
space: props.project.cloud,
project: props.project,
model,
})
}
}
});
};
watch(
() => props.models,
models => {
const modelsBySource = segregateBySource(models);
tabs.value = tabs.value.map(tab => ({
...tab,
label: tab.label || tab.id,
models: modelsBySource[tab.id]
}));
},
{ immediate: true }
);
return {
tabs,
viewPhotosphereBuilding
};
}
};
</script>
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
<script setup>
import apiClient from "../../../../../services/api-client.js";
defineProps({
space: {
type: Object,
required: true
},
project: {
type: Object,
required: true
},
model: {
type: Object,
required: true
},
});
defineEmits(["close"]);
</script>

<template>
<div class="photosphere-building-panel">
<BIMDataButton
class="close"
ghost
rounded
icon
@click="$emit('close')"
>
<BIMDataIconClose size="xxs" fill color="granite-light" />
</BIMDataButton>
<div class="content">
<BIMDataPhotosphereBuilding
:apiClient="apiClient"
:space="space"
:project="project"
:model="model"
:selectable="false"
/>
</div>
</div>
</template>

<style scoped>
.photosphere-building-panel {
position: absolute;
z-index: 0;
top: 0;
left: 0;
width: 100%;
height: 100%;
.close {
position: absolute;
z-index: 1;
top: calc(var(--spacing-unit) / 2);
right: var(--spacing-unit);
}
.content {
height: 100%;
}
}
</style>
2 changes: 2 additions & 0 deletions src/components/specific/models/models-table/ModelsTable.vue
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@
@update="nameEditMode[model.id] = true"
@view-metaBuilding="$emit('view-metaBuilding', $event)"
@edit-metaBuilding="$emit('edit-metaBuilding', $event)"
@view-photosphereBuilding="$emit('view-photosphereBuilding', $event)"
/>
</template>

Expand Down Expand Up @@ -113,6 +114,7 @@ export default {
"upload-canceled",
"upload-failed",
"view-metaBuilding",
"view-photosphereBuilding",
],
setup(props) {
const { t } = useI18n();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,20 @@
icon
@click="onClick('view-metaBuilding')"
>
<BIMDataIconStructure size="s" />
</BIMDataButton>
<BIMDataIconStructure size="s" />
</BIMDataButton>
</template>

<template v-if="model.type === MODEL_TYPE.PHOTOSPHERE">
<BIMDataButton
color="primary"
outline
radius
icon
@click="onClick('view-photosphereBuilding')"
>
<BIMDataIconStructure size="s" />
</BIMDataButton>
</template>

<template v-if="model.type === MODEL_TYPE.IFC">
Expand Down Expand Up @@ -45,9 +57,9 @@

<template
v-else-if="
model.type === MODEL_TYPE.PDF ||
model.type === MODEL_TYPE.META_BUILDING ||
model.type === MODEL_TYPE.JPEG ||
model.type === MODEL_TYPE.META_BUILDING ||
model.type === MODEL_TYPE.PDF ||
model.type === MODEL_TYPE.PNG
"
>
Expand All @@ -70,6 +82,16 @@
/>
</template>

<template v-else-if="model.type === MODEL_TYPE.PHOTOSPHERE">
<ViewerButton
:disabled="!isModelReady"
:project="project"
:model="model"
:window="WINDOWS.PHOTOSPHERE"
text="2D"
/>
</template>

<template v-if="model.document">
<BIMDataButton
class="model-actions-cell__btn"
Expand Down Expand Up @@ -142,7 +164,8 @@ export default {
"download",
"edit-metaBuilding",
"update",
"view-metaBuilding"
"view-metaBuilding",
"view-photosphereBuilding",
],
setup(props, { emit }) {
const {
Expand Down
6 changes: 6 additions & 0 deletions src/config/models.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ const MODEL_TYPE = Object.freeze({
META_BUILDING: "METABUILDING",
OBJ: "OBJ",
PDF: "PDF",
PHOTOSPHERE: "PHOTOSPHERE",
PNG: "PNG",
POINT_CLOUD: "POINT_CLOUD",
});
Expand Down Expand Up @@ -115,6 +116,11 @@ const MODEL_CONFIG = Object.freeze({
window: WINDOWS.PLAN,
icon: "filePdfPolychrome",
},
[MODEL_TYPE.PHOTOSPHERE]: {
ext: [MODEL_EXTENSIONS.JPEG, MODEL_EXTENSIONS.JPG],
window: WINDOWS.PHOTOSPHERE,
icon: "fileImagePolychrome",
},
[MODEL_TYPE.PNG]: {
ext: [MODEL_EXTENSIONS.PNG],
window: WINDOWS.PLAN,
Expand Down
1 change: 1 addition & 0 deletions src/config/viewer.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ const WINDOWS = Object.freeze({
DXF: "dxf",
IFC2D: "2d",
IFC3D: "3d",
PHOTOSPHERE: "photosphere",
PLAN: "plan",
POINT_CLOUD: "pointCloud"
});
Expand Down

0 comments on commit 22f6a90

Please sign in to comment.