@qispace/vue3-player 0.0.15 → 0.1.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/vue-components/config/vite.config.d.ts +2 -0
- package/dist/vue-components/config/vite.config.dev.d.ts +2 -0
- package/dist/vue-components/config/vite.config.web-components.d.ts +2 -0
- package/dist/vue-components/src/components/apartmentChooser/VApartmentChooser.vue.d.ts +129 -0
- package/dist/vue-components/src/components/apartmentChooser/VApartmentChooserNavigation.vue.d.ts +46 -0
- package/dist/vue-components/src/components/apartmentChooser/VApartmentChooserRaster.vue.d.ts +77 -0
- package/dist/vue-components/src/components/apartmentChooser/VApartmentChooserRotator.vue.d.ts +43 -0
- package/dist/vue-components/src/components/apartmentChooser/VApartmentChooserSvg.vue.d.ts +77 -0
- package/dist/vue-components/src/components/apartmentChooser/index.d.ts +5 -0
- package/dist/vue-components/src/components/apartmentChooser/types.d.ts +13 -0
- package/dist/vue-components/src/components/buildingPicker/VBuildingChooser.vue.d.ts +93 -0
- package/dist/vue-components/src/components/buildingPicker/VBuildingChooserRaster.vue.d.ts +97 -0
- package/dist/vue-components/src/components/buildingPicker/VBuildingChooserRasterOverlay.vue.d.ts +46 -0
- package/dist/vue-components/src/components/buildingPicker/VBuildingChooserSceneImageStack.vue.d.ts +27 -0
- package/dist/vue-components/src/components/buildingPicker/VBuildingChooserSunSimControl.vue.d.ts +37 -0
- package/dist/vue-components/src/components/buildingPicker/VBuildingChooserSvg.vue.d.ts +102 -0
- package/dist/vue-components/src/components/buildingPicker/index.d.ts +6 -0
- package/dist/vue-components/src/components/buildingPicker/types.d.ts +11 -0
- package/dist/{components → vue-components/src/components}/index.d.ts +1 -1
- package/dist/vue-components/src/components/shared/VFloatingCard.vue.d.ts +30 -0
- package/dist/vue-components/src/components/shared/VHoverProbe.vue.d.ts +4 -0
- package/dist/vue-components/src/components/shared/VNorthDirection.vue.d.ts +15 -0
- package/dist/vue-components/src/components/shared/VZoomBox.vue.d.ts +60 -0
- package/dist/vue-components/src/components/shared/index.d.ts +4 -0
- package/dist/vue-components/src/components/virtualTour/VCompass.vue.d.ts +15 -0
- package/dist/vue-components/src/components/virtualTour/VDisclaimer.vue.d.ts +2 -0
- package/dist/vue-components/src/components/virtualTour/VFloorLevel.vue.d.ts +38 -0
- package/dist/vue-components/src/components/virtualTour/VFullScreenButton.vue.d.ts +19 -0
- package/dist/vue-components/src/components/virtualTour/VInteriorSelector.vue.d.ts +21 -0
- package/dist/vue-components/src/components/virtualTour/VPlayer.vue.d.ts +74 -0
- package/dist/vue-components/src/components/virtualTour/VSettingsUI.vue.d.ts +23 -0
- package/dist/vue-components/src/components/virtualTour/VSingleImage.vue.d.ts +31 -0
- package/dist/vue-components/src/components/virtualTour/VSocialShare.vue.d.ts +2 -0
- package/dist/vue-components/src/components/virtualTour/VTimeOfDay.vue.d.ts +34 -0
- package/dist/vue-components/src/components/virtualTour/VTutorial.vue.d.ts +19 -0
- package/dist/vue-components/src/components/virtualTour/VViewModeToggle.vue.d.ts +19 -0
- package/dist/vue-components/src/components/virtualTour/VVirtualTour.vue.d.ts +156 -0
- package/dist/vue-components/src/components/virtualTour/VWaypointCarousel.vue.d.ts +25 -0
- package/dist/vue-components/src/components/virtualTour/index.d.ts +1 -0
- package/dist/vue-components/src/components/virtualTour/minimap/VMiniMap.vue.d.ts +35 -0
- package/dist/vue-components/src/components/virtualTour/minimap/VMiniMapMap.vue.d.ts +25 -0
- package/dist/vue-components/src/components/virtualTour/minimap/VMinimapCompass.vue.d.ts +19 -0
- package/dist/vue-components/src/components/virtualTour/minimap/VMoveable.vue.d.ts +18 -0
- package/dist/vue-components/src/components/virtualTour/minimap/VRotationMarker.vue.d.ts +15 -0
- package/dist/vue-components/src/components/virtualTour/minimap/VSunSimulationSlider.vue.d.ts +23 -0
- package/dist/vue-components/src/components/virtualTour/minimap/index.d.ts +1 -0
- package/dist/vue-components/src/lib/apartmentChooser/BuildingViewerModel.d.ts +18 -0
- package/dist/vue-components/src/lib/apartmentChooser/RotationStep.d.ts +10 -0
- package/dist/vue-components/src/lib/apartmentChooser/SceneRotator.d.ts +10 -0
- package/dist/vue-components/src/lib/apartmentChooser/index.d.ts +3 -0
- package/dist/vue-components/src/lib/buildingPicker/BuildingMap.d.ts +7 -0
- package/dist/vue-components/src/lib/buildingPicker/BuildingPickerResourceProvider.d.ts +27 -0
- package/dist/vue-components/src/lib/buildingPicker/CanvasRaster.d.ts +8 -0
- package/dist/vue-components/src/lib/buildingPicker/DayOfYearSelector.d.ts +12 -0
- package/dist/vue-components/src/lib/buildingPicker/SampleRaster.d.ts +5 -0
- package/dist/vue-components/src/lib/buildingPicker/index.d.ts +5 -0
- package/dist/vue-components/src/lib/shared/BatchLoadTracker.d.ts +17 -0
- package/dist/vue-components/src/lib/shared/I18N.d.ts +7 -0
- package/dist/vue-components/src/lib/shared/ResourceLoader.d.ts +5 -0
- package/dist/vue-components/src/lib/shared/index.d.ts +3 -0
- package/dist/vue-components/src/lib/virtualTour/CameraSnapshot.d.ts +5 -0
- package/dist/vue-components/src/lib/virtualTour/FullscreenModel.d.ts +13 -0
- package/dist/vue-components/src/vue-components.d.ts +2 -0
- package/dist/vue-components/src/vue-components.esm.d.ts +4 -0
- package/dist/vue-components/src/web-components.d.ts +11 -0
- package/dist/vue-components/style.css +1 -0
- package/dist/vue-components/vue3-player.js +4744 -0
- package/dist/vue-components/vue3-player.umd.cjs +1 -0
- package/package.json +25 -15
- package/dist/components/apartmentChooser/QiApartmentChooser.vue.d.ts +0 -2
- package/dist/components/apartmentChooser/QiApartmentChooserNavigation.vue.d.ts +0 -51
- package/dist/components/apartmentChooser/QiApartmentChooserRaster.vue.d.ts +0 -2
- package/dist/components/apartmentChooser/QiApartmentChooserRotator.vue.d.ts +0 -65
- package/dist/components/apartmentChooser/QiApartmentChooserSvg.vue.d.ts +0 -2
- package/dist/components/buildingPicker/QiBuildingChooser.vue.d.ts +0 -121
- package/dist/components/buildingPicker/QiBuildingChooserRaster.vue.d.ts +0 -2
- package/dist/components/buildingPicker/QiBuildingChooserRasterOverlay.vue.d.ts +0 -53
- package/dist/components/buildingPicker/QiBuildingChooserSceneImageStack.vue.d.ts +0 -32
- package/dist/components/buildingPicker/QiBuildingChooserSunSimControl.vue.d.ts +0 -42
- package/dist/components/buildingPicker/QiBuildingChooserSvg.vue.d.ts +0 -2
- package/dist/components/shared/QiFloatingCard.vue.d.ts +0 -18
- package/dist/components/shared/QiHoverProbe.vue.d.ts +0 -4
- package/dist/components/shared/QiNorthDirection.vue.d.ts +0 -21
- package/dist/components/shared/QiZoomBox.vue.d.ts +0 -83
- package/dist/components/virtualTourV2/Compass.vue.d.ts +0 -22
- package/dist/components/virtualTourV2/Disclaimer.vue.d.ts +0 -4
- package/dist/components/virtualTourV2/FloorLevel.vue.d.ts +0 -27
- package/dist/components/virtualTourV2/FullScreenButton.vue.d.ts +0 -14
- package/dist/components/virtualTourV2/InteriorSelector.vue.d.ts +0 -24
- package/dist/components/virtualTourV2/Player.vue.d.ts +0 -82
- package/dist/components/virtualTourV2/SettingsUI.vue.d.ts +0 -105
- package/dist/components/virtualTourV2/SingleImage.vue.d.ts +0 -26
- package/dist/components/virtualTourV2/SocialShare.vue.d.ts +0 -10
- package/dist/components/virtualTourV2/TimeOfDay.vue.d.ts +0 -27
- package/dist/components/virtualTourV2/Tutorial.vue.d.ts +0 -23
- package/dist/components/virtualTourV2/ViewModeToggle.vue.d.ts +0 -16
- package/dist/components/virtualTourV2/VirtualTourV2.vue.d.ts +0 -322
- package/dist/components/virtualTourV2/WaypointCarousel.vue.d.ts +0 -31
- package/dist/components/virtualTourV2/index.d.ts +0 -1
- package/dist/components/virtualTourV2/minimapv2/MiniMapMap.vue.d.ts +0 -82
- package/dist/components/virtualTourV2/minimapv2/MiniMapV2.vue.d.ts +0 -78
- package/dist/components/virtualTourV2/minimapv2/MinimapCompass.vue.d.ts +0 -30
- package/dist/components/virtualTourV2/minimapv2/Moveable.vue.d.ts +0 -8
- package/dist/components/virtualTourV2/minimapv2/RotationMarkerV2.vue.d.ts +0 -12
- package/dist/components/virtualTourV2/minimapv2/SunsimulationSlider.vue.d.ts +0 -48
- package/dist/components/virtualTourV2/minimapv2/index.d.ts +0 -1
- package/dist/style.css +0 -1
- package/dist/vue3-player.js +0 -5414
- package/dist/vue3-player.umd.cjs +0 -1
- package/src/components/apartmentChooser/QiApartmentChooser.vue +0 -319
- package/src/components/apartmentChooser/QiApartmentChooserNavigation.vue +0 -88
- package/src/components/apartmentChooser/QiApartmentChooserRaster.vue +0 -408
- package/src/components/apartmentChooser/QiApartmentChooserRotator.vue +0 -202
- package/src/components/apartmentChooser/QiApartmentChooserSvg.vue +0 -257
- package/src/components/apartmentChooser/index.js +0 -5
- package/src/components/buildingPicker/QiBuildingChooser.vue +0 -61
- package/src/components/buildingPicker/QiBuildingChooserRaster.vue +0 -312
- package/src/components/buildingPicker/QiBuildingChooserRasterOverlay.vue +0 -96
- package/src/components/buildingPicker/QiBuildingChooserSceneImageStack.vue +0 -89
- package/src/components/buildingPicker/QiBuildingChooserSunSimControl.vue +0 -257
- package/src/components/buildingPicker/QiBuildingChooserSvg.vue +0 -414
- package/src/components/buildingPicker/index.js +0 -6
- package/src/components/index.ts +0 -4
- package/src/components/shared/QiFloatingCard.vue +0 -76
- package/src/components/shared/QiHoverProbe.vue +0 -22
- package/src/components/shared/QiNorthDirection.vue +0 -27
- package/src/components/shared/QiZoomBox.vue +0 -322
- package/src/components/shared/index.js +0 -4
- package/src/components/virtualTourV2/Compass.vue +0 -37
- package/src/components/virtualTourV2/Disclaimer.vue +0 -41
- package/src/components/virtualTourV2/FloorLevel.vue +0 -73
- package/src/components/virtualTourV2/FullScreenButton.vue +0 -23
- package/src/components/virtualTourV2/InteriorSelector.vue +0 -90
- package/src/components/virtualTourV2/ManualSlideShow.vue +0 -198
- package/src/components/virtualTourV2/ManualSlideShowPlayer.vue +0 -159
- package/src/components/virtualTourV2/Player.vue +0 -300
- package/src/components/virtualTourV2/ScrollHelper.vue +0 -74
- package/src/components/virtualTourV2/SettingsUI.vue +0 -355
- package/src/components/virtualTourV2/SingleImage.vue +0 -36
- package/src/components/virtualTourV2/SocialShare.vue +0 -163
- package/src/components/virtualTourV2/TimeOfDay.vue +0 -50
- package/src/components/virtualTourV2/Tutorial.vue +0 -690
- package/src/components/virtualTourV2/ViewModeToggle.vue +0 -24
- package/src/components/virtualTourV2/VirtualTourV2.vue +0 -875
- package/src/components/virtualTourV2/WaypointCarousel.vue +0 -162
- package/src/components/virtualTourV2/index.ts +0 -20
- package/src/components/virtualTourV2/minimapv2/MiniMapMap.vue +0 -262
- package/src/components/virtualTourV2/minimapv2/MiniMapV2.vue +0 -110
- package/src/components/virtualTourV2/minimapv2/MinimapCompass.vue +0 -39
- package/src/components/virtualTourV2/minimapv2/Moveable.vue +0 -208
- package/src/components/virtualTourV2/minimapv2/RotationMarkerV2.vue +0 -79
- package/src/components/virtualTourV2/minimapv2/SunsimulationSlider.vue +0 -203
- package/src/components/virtualTourV2/minimapv2/index.ts +0 -1
- /package/dist/{lib → vue-components/src/lib}/index.d.ts +0 -0
|
@@ -1,408 +0,0 @@
|
|
|
1
|
-
<template>
|
|
2
|
-
<div id="canvas">
|
|
3
|
-
<canvas
|
|
4
|
-
v-show="!viewModel.isRotating"
|
|
5
|
-
id="canvas-mask"
|
|
6
|
-
ref="canvasMask"
|
|
7
|
-
:style="canvasStyle"
|
|
8
|
-
@click="clickCanvas"
|
|
9
|
-
></canvas>
|
|
10
|
-
<qi-hover-probe ref="hoverProbe" />
|
|
11
|
-
</div>
|
|
12
|
-
</template>
|
|
13
|
-
|
|
14
|
-
<script>
|
|
15
|
-
import { ResourceLoader } from "@/lib/shared/ResourceLoader";
|
|
16
|
-
import QiHoverProbe from "@/components/shared/QiHoverProbe.vue";
|
|
17
|
-
import throttle from "@/lib/apartmentChooser/throttle";
|
|
18
|
-
|
|
19
|
-
export default {
|
|
20
|
-
name: "QiApartmentChooserRaster",
|
|
21
|
-
components: { QiHoverProbe },
|
|
22
|
-
mixins: [throttle],
|
|
23
|
-
props: {
|
|
24
|
-
cdnFileResolver: { type: Function, required: true },
|
|
25
|
-
viewModel: { type: Object, required: true },
|
|
26
|
-
selectedUnitId: { type: String, default: null },
|
|
27
|
-
unitCallback: { type: Function, default: (aptId) => aptId },
|
|
28
|
-
canGoToUnitCallback: { type: Function, default: () => true },
|
|
29
|
-
sceneData: { type: Array, default: [] },
|
|
30
|
-
colorCallback: {
|
|
31
|
-
type: Function,
|
|
32
|
-
default: () => ({ r: 108, g: 0, b: 108, a: 144, s: 2 }),
|
|
33
|
-
},
|
|
34
|
-
drawObserver: {
|
|
35
|
-
type: [Object, Array, String, Number, Boolean],
|
|
36
|
-
default: null,
|
|
37
|
-
},
|
|
38
|
-
},
|
|
39
|
-
emits: ["select-unit", "go-to-unit", "hover-over", "hover-out"],
|
|
40
|
-
data() {
|
|
41
|
-
return {
|
|
42
|
-
pos: { x: 0, y: 0, width: 0, height: 0 },
|
|
43
|
-
canvas: null,
|
|
44
|
-
canvasBg: null,
|
|
45
|
-
canvasWidth: 0,
|
|
46
|
-
canvasHeight: 0,
|
|
47
|
-
context: null,
|
|
48
|
-
contextBg: null,
|
|
49
|
-
image: null,
|
|
50
|
-
imageData: null,
|
|
51
|
-
originalImageData: null,
|
|
52
|
-
hoverApartmentIndex: -1,
|
|
53
|
-
showApartmentCard: false,
|
|
54
|
-
cursorX: null,
|
|
55
|
-
cursorY: null,
|
|
56
|
-
rasterImages: {},
|
|
57
|
-
vueCanvasCursor: "auto",
|
|
58
|
-
timeout: null,
|
|
59
|
-
windowListener: undefined,
|
|
60
|
-
resourceLoader: new ResourceLoader(),
|
|
61
|
-
apartmentIndexRasterMap: {},
|
|
62
|
-
};
|
|
63
|
-
},
|
|
64
|
-
computed: {
|
|
65
|
-
isHoverable() {
|
|
66
|
-
return this.$refs.hoverProbe.isHoverEnabled;
|
|
67
|
-
},
|
|
68
|
-
rasterUrl() {
|
|
69
|
-
return this.cdnFileResolver(
|
|
70
|
-
`/scenedata${this.viewModel.currentScene}.png`
|
|
71
|
-
);
|
|
72
|
-
},
|
|
73
|
-
rasterImage() {
|
|
74
|
-
return this.rasterUrl in this.rasterImages
|
|
75
|
-
? this.rasterImages[this.rasterUrl]
|
|
76
|
-
: null;
|
|
77
|
-
},
|
|
78
|
-
hoverApartment() {
|
|
79
|
-
if (this.hoverApartmentIndex < 0) {
|
|
80
|
-
return false;
|
|
81
|
-
}
|
|
82
|
-
|
|
83
|
-
const apartment = this.sceneData.find(
|
|
84
|
-
(x) => x.index === this.hoverApartmentIndex
|
|
85
|
-
);
|
|
86
|
-
|
|
87
|
-
if (apartment) {
|
|
88
|
-
return this.unitCallback
|
|
89
|
-
? this.unitCallback(apartment.apartmentId)
|
|
90
|
-
: apartment.apartmentId;
|
|
91
|
-
} else {
|
|
92
|
-
return false;
|
|
93
|
-
}
|
|
94
|
-
},
|
|
95
|
-
canvasStyle() {
|
|
96
|
-
return {
|
|
97
|
-
width: this.canvasWidth + "px",
|
|
98
|
-
height: this.canvasHeight + "px",
|
|
99
|
-
cursor: this.vueCanvasCursor,
|
|
100
|
-
};
|
|
101
|
-
},
|
|
102
|
-
hoverBehaviourIdentifier() {
|
|
103
|
-
return `hover-${this.showApartmentCard ? "over" : "out"}-${
|
|
104
|
-
this.hoverApartment
|
|
105
|
-
? typeof this.hoverApartment === "object" &&
|
|
106
|
-
"unitId" in this.hoverApartment
|
|
107
|
-
? this.hoverApartment.unitId
|
|
108
|
-
: this.hoverApartment
|
|
109
|
-
: ""
|
|
110
|
-
}`;
|
|
111
|
-
},
|
|
112
|
-
},
|
|
113
|
-
watch: {
|
|
114
|
-
rasterUrl: {
|
|
115
|
-
handler() {
|
|
116
|
-
if (!this.rasterImages[this.rasterUrl]) {
|
|
117
|
-
this.resourceLoader
|
|
118
|
-
.loadImageData(this.rasterUrl)
|
|
119
|
-
.then((objectURL) => {
|
|
120
|
-
this.rasterImages = {
|
|
121
|
-
...this.rasterImages,
|
|
122
|
-
[this.rasterUrl]: objectURL,
|
|
123
|
-
};
|
|
124
|
-
});
|
|
125
|
-
}
|
|
126
|
-
},
|
|
127
|
-
immediate: true,
|
|
128
|
-
},
|
|
129
|
-
rasterImage() {
|
|
130
|
-
if (this.rasterImage) {
|
|
131
|
-
this.init();
|
|
132
|
-
}
|
|
133
|
-
},
|
|
134
|
-
"viewModel.currentScene": {
|
|
135
|
-
handler() {
|
|
136
|
-
this.draw();
|
|
137
|
-
},
|
|
138
|
-
immediate: true,
|
|
139
|
-
},
|
|
140
|
-
"viewModel.isRotating"() {
|
|
141
|
-
this.draw();
|
|
142
|
-
},
|
|
143
|
-
drawObserver() {
|
|
144
|
-
// This is here to trigger redraws on change, nothing else
|
|
145
|
-
this.draw();
|
|
146
|
-
},
|
|
147
|
-
selectedUnitId() {
|
|
148
|
-
this.draw();
|
|
149
|
-
},
|
|
150
|
-
hoverApartment() {
|
|
151
|
-
this.draw();
|
|
152
|
-
if (this.hoverApartment) {
|
|
153
|
-
this.vueCanvasCursor = "pointer";
|
|
154
|
-
} else {
|
|
155
|
-
this.vueCanvasCursor = "auto";
|
|
156
|
-
}
|
|
157
|
-
},
|
|
158
|
-
hoverBehaviourIdentifier() {
|
|
159
|
-
this.$emit(this.showApartmentCard ? "hover-over" : "hover-out", {
|
|
160
|
-
hoverApartment: this.hoverApartment,
|
|
161
|
-
closeHandler: () => this.closeDialog(),
|
|
162
|
-
});
|
|
163
|
-
},
|
|
164
|
-
pos() {
|
|
165
|
-
this.$emit("pos", this.pos);
|
|
166
|
-
},
|
|
167
|
-
},
|
|
168
|
-
mounted() {
|
|
169
|
-
this.windowListener = () => {
|
|
170
|
-
clearTimeout(this.timeout);
|
|
171
|
-
this.updateCanvasSize();
|
|
172
|
-
// resize needs to happen one more time after last event to make sure everything is synced
|
|
173
|
-
// could check if widths align document.getElementById('canvas').offsetWidth and rerun if needed
|
|
174
|
-
this.timeout = setTimeout(() => {
|
|
175
|
-
this.updateCanvasSize();
|
|
176
|
-
}, 50);
|
|
177
|
-
};
|
|
178
|
-
window.addEventListener("resize", this.windowListener);
|
|
179
|
-
this.updateCanvasSize();
|
|
180
|
-
},
|
|
181
|
-
beforeUnmount() {
|
|
182
|
-
window.removeEventListener("resize", this.windowListener);
|
|
183
|
-
for (const key in this.rasterImages) {
|
|
184
|
-
URL.revokeObjectURL(this.rasterImages[key]);
|
|
185
|
-
}
|
|
186
|
-
},
|
|
187
|
-
methods: {
|
|
188
|
-
init() {
|
|
189
|
-
this.canvas = this.$refs.canvasMask;
|
|
190
|
-
this.context = this.canvas.getContext("2d", { willReadFrequently: true });
|
|
191
|
-
this.image = new Image();
|
|
192
|
-
this.image.onload = () => {
|
|
193
|
-
this.setupDraw();
|
|
194
|
-
this.canvas.addEventListener(
|
|
195
|
-
"mousemove",
|
|
196
|
-
this.throttle(this.handleMouseMove, 50)
|
|
197
|
-
);
|
|
198
|
-
};
|
|
199
|
-
this.image.src = this.rasterImage;
|
|
200
|
-
},
|
|
201
|
-
handleMouseMove(e) {
|
|
202
|
-
const index = this.getApartmentIndexByCursorPosition(
|
|
203
|
-
e.offsetX,
|
|
204
|
-
e.offsetY
|
|
205
|
-
);
|
|
206
|
-
this.showApartmentCard = index >= 0;
|
|
207
|
-
this.hoverApartmentIndex = index;
|
|
208
|
-
this.pos = {
|
|
209
|
-
x: e.offsetX,
|
|
210
|
-
y: e.offsetY,
|
|
211
|
-
width: this.canvasWidth,
|
|
212
|
-
height: this.canvasHeight,
|
|
213
|
-
};
|
|
214
|
-
},
|
|
215
|
-
clickCanvas(e) {
|
|
216
|
-
const index = this.getApartmentIndexByCursorPosition(
|
|
217
|
-
e.offsetX,
|
|
218
|
-
e.offsetY
|
|
219
|
-
);
|
|
220
|
-
if (index < 0) return;
|
|
221
|
-
if (this.isHoverable) {
|
|
222
|
-
this.goToApartmentByIndex(index);
|
|
223
|
-
}
|
|
224
|
-
},
|
|
225
|
-
setImageData() {
|
|
226
|
-
if (this.image && this.image.width) {
|
|
227
|
-
this.canvas.width = this.image.width;
|
|
228
|
-
this.canvas.height = this.image.height;
|
|
229
|
-
this.context.drawImage(
|
|
230
|
-
this.image,
|
|
231
|
-
0,
|
|
232
|
-
0,
|
|
233
|
-
this.image.width,
|
|
234
|
-
this.image.height
|
|
235
|
-
);
|
|
236
|
-
this.originalImageData = this.context.getImageData(
|
|
237
|
-
0,
|
|
238
|
-
0,
|
|
239
|
-
this.canvas.width,
|
|
240
|
-
this.canvas.height
|
|
241
|
-
);
|
|
242
|
-
this.imageData = this.context.getImageData(
|
|
243
|
-
0,
|
|
244
|
-
0,
|
|
245
|
-
this.canvas.width,
|
|
246
|
-
this.canvas.height
|
|
247
|
-
);
|
|
248
|
-
|
|
249
|
-
const data = this.originalImageData.data;
|
|
250
|
-
this.apartmentIndexRasterMap = {};
|
|
251
|
-
for (let i = 0; i < data.length; i += 4) {
|
|
252
|
-
this.apartmentIndexRasterMap[data[i]] = [];
|
|
253
|
-
}
|
|
254
|
-
for (let i = 3; i < data.length; i += 4) {
|
|
255
|
-
if (data[i] === 255 && data[i - 3] in this.apartmentIndexRasterMap) {
|
|
256
|
-
this.apartmentIndexRasterMap[data[i - 3]].push(i - 3);
|
|
257
|
-
}
|
|
258
|
-
}
|
|
259
|
-
}
|
|
260
|
-
},
|
|
261
|
-
getApartmentIndexByCursorPosition(x, y) {
|
|
262
|
-
this.cursorX = x;
|
|
263
|
-
this.cursorY = y;
|
|
264
|
-
|
|
265
|
-
const widthScale = this.canvas.offsetWidth / this.canvas.width;
|
|
266
|
-
const heightScale = this.canvas.offsetHeight / this.canvas.height;
|
|
267
|
-
const rasterCursorX = (x / widthScale).toFixed();
|
|
268
|
-
const rasterCursorY = (y / heightScale).toFixed();
|
|
269
|
-
|
|
270
|
-
const index = rasterCursorY * (this.canvas.width * 4) + rasterCursorX * 4;
|
|
271
|
-
const apartmentIndex = this.originalImageData.data[index];
|
|
272
|
-
const isApartment = this.originalImageData.data[index + 3] > 0;
|
|
273
|
-
return isApartment ? apartmentIndex : -1;
|
|
274
|
-
},
|
|
275
|
-
getApartmentIndexById(id) {
|
|
276
|
-
const apartment = this.sceneData.find((x) => x.apartmentId === id);
|
|
277
|
-
return !apartment ? -1 : apartment.index;
|
|
278
|
-
},
|
|
279
|
-
highlightApartments() {
|
|
280
|
-
const apartments = this.getApartmentsInRaster();
|
|
281
|
-
apartments.forEach((apartment) => {
|
|
282
|
-
if (apartment.index >= 0) {
|
|
283
|
-
const pixels = this.getApartmentPixelsByIndex(apartment.index);
|
|
284
|
-
const aptId = this.getApartmentIdByIndex(apartment.index);
|
|
285
|
-
let type = "idle";
|
|
286
|
-
if (
|
|
287
|
-
!this.hoverApartment &&
|
|
288
|
-
this.selectedUnitId &&
|
|
289
|
-
aptId === this.selectedUnitId
|
|
290
|
-
) {
|
|
291
|
-
type = "selected";
|
|
292
|
-
} else if (
|
|
293
|
-
this.hoverApartment &&
|
|
294
|
-
this.hoverApartmentIndex === apartment.index
|
|
295
|
-
) {
|
|
296
|
-
type = "hover";
|
|
297
|
-
}
|
|
298
|
-
const unit = this.unitCallback ? this.unitCallback(aptId) : aptId;
|
|
299
|
-
if (unit) {
|
|
300
|
-
const color = this.colorCallback(unit, type);
|
|
301
|
-
if (color) {
|
|
302
|
-
for (let i = 0; i < pixels.length; i++) {
|
|
303
|
-
this.imageData.data[pixels[i]] = color.r; // R
|
|
304
|
-
this.imageData.data[pixels[i] + 1] = color.g; // G
|
|
305
|
-
this.imageData.data[pixels[i] + 2] = color.b; // B
|
|
306
|
-
this.imageData.data[pixels[i] + 3] = color.a; // A
|
|
307
|
-
}
|
|
308
|
-
}
|
|
309
|
-
}
|
|
310
|
-
}
|
|
311
|
-
});
|
|
312
|
-
},
|
|
313
|
-
// GETTING APARTMENT DATA
|
|
314
|
-
// Returns the index of each RGBA value of a given apartment
|
|
315
|
-
getApartmentPixelsByIndex(apartmentIndex) {
|
|
316
|
-
return !this.originalImageData
|
|
317
|
-
? false
|
|
318
|
-
: this.apartmentIndexRasterMap[apartmentIndex];
|
|
319
|
-
},
|
|
320
|
-
getApartmentIdByIndex(apartmentIndex) {
|
|
321
|
-
const apartment = this.sceneData.find((x) => x.index === apartmentIndex);
|
|
322
|
-
return apartment && apartment.apartmentId;
|
|
323
|
-
},
|
|
324
|
-
getApartmentsInRaster() {
|
|
325
|
-
if (this.originalImageData) {
|
|
326
|
-
const uniqueIndices = Object.keys(this.apartmentIndexRasterMap).map(
|
|
327
|
-
(i) => parseInt(i)
|
|
328
|
-
);
|
|
329
|
-
// Filter scenedata down to only one object per unique apartment
|
|
330
|
-
const filteredSceneData = this.sceneData.filter((x) =>
|
|
331
|
-
uniqueIndices.includes(x.index)
|
|
332
|
-
);
|
|
333
|
-
return filteredSceneData;
|
|
334
|
-
} else {
|
|
335
|
-
return [];
|
|
336
|
-
}
|
|
337
|
-
},
|
|
338
|
-
goToApartmentByIndex(index) {
|
|
339
|
-
const apartmentId = this.getApartmentIdByIndex(index);
|
|
340
|
-
this.goToApartmentById(apartmentId);
|
|
341
|
-
},
|
|
342
|
-
goToApartmentById(apartmentId) {
|
|
343
|
-
const arg = this.unitCallback
|
|
344
|
-
? this.unitCallback(apartmentId)
|
|
345
|
-
: apartmentId;
|
|
346
|
-
this.$emit("select-unit", arg);
|
|
347
|
-
if (arg && this.canGoToUnitCallback(arg)) {
|
|
348
|
-
this.$emit("go-to-unit", arg);
|
|
349
|
-
}
|
|
350
|
-
},
|
|
351
|
-
setAlpha(alpha = 0) {
|
|
352
|
-
if (!this.imageData) {
|
|
353
|
-
return;
|
|
354
|
-
}
|
|
355
|
-
|
|
356
|
-
const data = this.imageData.data;
|
|
357
|
-
for (let i = 3; i < data.length; i += 4) {
|
|
358
|
-
data[i] = alpha;
|
|
359
|
-
}
|
|
360
|
-
},
|
|
361
|
-
updateCanvasSize() {
|
|
362
|
-
if (!this.$el) {
|
|
363
|
-
return false;
|
|
364
|
-
}
|
|
365
|
-
|
|
366
|
-
this.canvasWidth = this.$el.offsetWidth;
|
|
367
|
-
this.canvasHeight = this.$el.offsetHeight;
|
|
368
|
-
},
|
|
369
|
-
setupDraw() {
|
|
370
|
-
this.setImageData();
|
|
371
|
-
this.draw();
|
|
372
|
-
},
|
|
373
|
-
draw() {
|
|
374
|
-
this.setAlpha();
|
|
375
|
-
this.highlightApartments();
|
|
376
|
-
if (this.context && this.imageData) {
|
|
377
|
-
this.context.putImageData(this.imageData, 0, 0);
|
|
378
|
-
}
|
|
379
|
-
},
|
|
380
|
-
closeDialog() {
|
|
381
|
-
this.showApartmentCard = false;
|
|
382
|
-
},
|
|
383
|
-
},
|
|
384
|
-
};
|
|
385
|
-
</script>
|
|
386
|
-
|
|
387
|
-
<style scoped>
|
|
388
|
-
#canvas {
|
|
389
|
-
position: absolute;
|
|
390
|
-
top: 0;
|
|
391
|
-
width: 100%;
|
|
392
|
-
user-select: none;
|
|
393
|
-
touch-action: none;
|
|
394
|
-
padding-top: 56.25%;
|
|
395
|
-
}
|
|
396
|
-
#canvas-mask {
|
|
397
|
-
position: absolute;
|
|
398
|
-
top: 0;
|
|
399
|
-
max-width: 100%;
|
|
400
|
-
z-index: 4;
|
|
401
|
-
user-select: none;
|
|
402
|
-
}
|
|
403
|
-
@media only screen and (min-width: 1280px) {
|
|
404
|
-
#canvas {
|
|
405
|
-
border-radius: 10px;
|
|
406
|
-
}
|
|
407
|
-
}
|
|
408
|
-
</style>
|
|
@@ -1,202 +0,0 @@
|
|
|
1
|
-
<template>
|
|
2
|
-
<div>
|
|
3
|
-
<div
|
|
4
|
-
v-if="loadTracker.isError"
|
|
5
|
-
class="fill-parent d-flex justify-center align-center blue-grey lighten-5"
|
|
6
|
-
>
|
|
7
|
-
<v-icon x-large>mdi-alert-circle-outline</v-icon>
|
|
8
|
-
</div>
|
|
9
|
-
<div v-else-if="!isPreloaded" class="frame-container">
|
|
10
|
-
<picture class="frame-image">
|
|
11
|
-
<source :srcset="activeFrame.sourceSet" :type="activeFrame.type" />
|
|
12
|
-
<img
|
|
13
|
-
:src="activeFrame.defaultPath"
|
|
14
|
-
@load="isPreloaded = true"
|
|
15
|
-
@error="loadTracker.errorDetected()"
|
|
16
|
-
/>
|
|
17
|
-
</picture>
|
|
18
|
-
</div>
|
|
19
|
-
<div v-else id="image-stack" class="frame-container">
|
|
20
|
-
<picture
|
|
21
|
-
v-for="img in images"
|
|
22
|
-
:key="img.index"
|
|
23
|
-
:alt="img.index"
|
|
24
|
-
:class="{ 'frame-image': true, show: img.show }"
|
|
25
|
-
>
|
|
26
|
-
<source :srcset="img.sourceSet" type="image/jpeg" />
|
|
27
|
-
<img
|
|
28
|
-
:src="img.defaultPath"
|
|
29
|
-
alt="Building image"
|
|
30
|
-
@load="loadTracker.partLoaded()"
|
|
31
|
-
@error="loadTracker.errorDetected()"
|
|
32
|
-
/>
|
|
33
|
-
</picture>
|
|
34
|
-
</div>
|
|
35
|
-
</div>
|
|
36
|
-
</template>
|
|
37
|
-
|
|
38
|
-
<script>
|
|
39
|
-
import { BatchLoadTracker } from '@/lib/shared/BatchLoadTracker'
|
|
40
|
-
import { SceneRotator } from '@/lib/apartmentChooser/SceneRotator'
|
|
41
|
-
|
|
42
|
-
const totalFrameCount = 64
|
|
43
|
-
const totalScenesCount = 4
|
|
44
|
-
const fps = 120
|
|
45
|
-
|
|
46
|
-
export default {
|
|
47
|
-
name: 'QiApartmentChooserRotator',
|
|
48
|
-
props: {
|
|
49
|
-
viewModel: { type: Object, required: true },
|
|
50
|
-
build: { type: String, default: '' },
|
|
51
|
-
cdnFileResolver: { type: Function, required: true },
|
|
52
|
-
cardinalFrames: { type: Array, required: true },
|
|
53
|
-
},
|
|
54
|
-
emits: ['loaded', 'error', 'progress'],
|
|
55
|
-
data() {
|
|
56
|
-
const frames = this.createFrames()
|
|
57
|
-
return {
|
|
58
|
-
loadTracker: new BatchLoadTracker(frames.length)
|
|
59
|
-
.onLoadFinished(() => this.$emit('loaded'))
|
|
60
|
-
.onLoadProgress((percent) => this.$emit('progress', percent))
|
|
61
|
-
.onLoadError(() => this.$emit('error')),
|
|
62
|
-
sceneRotator: new SceneRotator(this.cardinalFrames, totalFrameCount),
|
|
63
|
-
images: frames,
|
|
64
|
-
isPreloaded: false,
|
|
65
|
-
}
|
|
66
|
-
},
|
|
67
|
-
computed: {
|
|
68
|
-
activeFrame() {
|
|
69
|
-
return this.images.find((f) => f.show)
|
|
70
|
-
},
|
|
71
|
-
},
|
|
72
|
-
watch: {
|
|
73
|
-
'viewModel.currentScene'(newVal, oldVal) {
|
|
74
|
-
const direction = this.getDirection(oldVal, newVal)
|
|
75
|
-
const sceneCount = this.getSceneCountBetween(oldVal, newVal)
|
|
76
|
-
this.rotateInDirection(oldVal, direction, sceneCount)
|
|
77
|
-
},
|
|
78
|
-
},
|
|
79
|
-
created() {
|
|
80
|
-
this.rotateComplete()
|
|
81
|
-
},
|
|
82
|
-
methods: {
|
|
83
|
-
rotateInDirection(fromScene, direction, sceneCount) {
|
|
84
|
-
if (this.viewModel.isRotating) {
|
|
85
|
-
return
|
|
86
|
-
}
|
|
87
|
-
|
|
88
|
-
this.viewModel.isRotating = true
|
|
89
|
-
this.rotationStep(
|
|
90
|
-
this.sceneRotator.start(
|
|
91
|
-
direction,
|
|
92
|
-
fromScene % totalScenesCount,
|
|
93
|
-
sceneCount
|
|
94
|
-
)
|
|
95
|
-
)
|
|
96
|
-
},
|
|
97
|
-
rotationStep(step) {
|
|
98
|
-
setTimeout(() => {
|
|
99
|
-
this.images[step.frameIndex].show = false
|
|
100
|
-
const nextStep = step.nextFrame()
|
|
101
|
-
this.images[nextStep.frameIndex].show = true
|
|
102
|
-
if (nextStep.atEnd) {
|
|
103
|
-
this.rotateComplete()
|
|
104
|
-
} else {
|
|
105
|
-
window.requestAnimationFrame(() => this.rotationStep(nextStep))
|
|
106
|
-
}
|
|
107
|
-
}, 1000 / fps)
|
|
108
|
-
},
|
|
109
|
-
rotateComplete() {
|
|
110
|
-
const finalFrameIndex = this.sceneRotator.startFrameIndexForScene(
|
|
111
|
-
this.viewModel.currentScene % totalScenesCount
|
|
112
|
-
)
|
|
113
|
-
if (finalFrameIndex in this.images) {
|
|
114
|
-
this.images[finalFrameIndex].show = true
|
|
115
|
-
}
|
|
116
|
-
this.viewModel.isRotating = false
|
|
117
|
-
},
|
|
118
|
-
createFrames() {
|
|
119
|
-
const arr = []
|
|
120
|
-
for (let i = 0; i < totalFrameCount; i++) {
|
|
121
|
-
const { sourceSet, defaultPath } = this.frameImageSource(i)
|
|
122
|
-
arr.push({
|
|
123
|
-
index: i,
|
|
124
|
-
sourceSet,
|
|
125
|
-
defaultPath,
|
|
126
|
-
show: false,
|
|
127
|
-
})
|
|
128
|
-
}
|
|
129
|
-
return arr
|
|
130
|
-
},
|
|
131
|
-
frameImageSource(frameIndex) {
|
|
132
|
-
const filename = ('0000' + (frameIndex + 1)).slice(-4)
|
|
133
|
-
const buildSuffix = this.build ? `?v=${this.build}` : ''
|
|
134
|
-
const sourceSet = [
|
|
135
|
-
`${this.cdnFileResolver(`/480/${filename}.jpg${buildSuffix}`)} 480w`,
|
|
136
|
-
`${this.cdnFileResolver(`/960/${filename}.jpg${buildSuffix}`)} 960w`,
|
|
137
|
-
`${this.cdnFileResolver(`/1280/${filename}.jpg${buildSuffix}`)} 1280w`,
|
|
138
|
-
].join(',')
|
|
139
|
-
const defaultPath = this.cdnFileResolver(
|
|
140
|
-
`/480/${filename}.jpg${buildSuffix}`
|
|
141
|
-
)
|
|
142
|
-
return { sourceSet, defaultPath }
|
|
143
|
-
},
|
|
144
|
-
getSceneCountBetween(fromScene, toScene) {
|
|
145
|
-
const halfCircle = totalScenesCount / 2
|
|
146
|
-
const absDistance = Math.abs(fromScene - toScene)
|
|
147
|
-
return absDistance > halfCircle
|
|
148
|
-
? totalScenesCount - absDistance
|
|
149
|
-
: absDistance
|
|
150
|
-
},
|
|
151
|
-
getDirection(fromScene, toScene) {
|
|
152
|
-
if (fromScene === toScene) {
|
|
153
|
-
return 0
|
|
154
|
-
}
|
|
155
|
-
|
|
156
|
-
const distance = Math.abs(fromScene - toScene)
|
|
157
|
-
const internal = distance < totalScenesCount / 2
|
|
158
|
-
return (internal && fromScene < toScene) ||
|
|
159
|
-
(!internal && fromScene > toScene)
|
|
160
|
-
? 1
|
|
161
|
-
: -1
|
|
162
|
-
},
|
|
163
|
-
},
|
|
164
|
-
}
|
|
165
|
-
</script>
|
|
166
|
-
|
|
167
|
-
<style scoped>
|
|
168
|
-
.frame-container {
|
|
169
|
-
position: relative;
|
|
170
|
-
max-width: 100%;
|
|
171
|
-
top: 0;
|
|
172
|
-
left: 0;
|
|
173
|
-
bottom: 185px;
|
|
174
|
-
padding-top: 56%;
|
|
175
|
-
z-index: 1;
|
|
176
|
-
overflow: hidden;
|
|
177
|
-
}
|
|
178
|
-
.frame-image {
|
|
179
|
-
position: absolute;
|
|
180
|
-
top: 0;
|
|
181
|
-
width: 100%;
|
|
182
|
-
height: 100%;
|
|
183
|
-
}
|
|
184
|
-
.frame-image img {
|
|
185
|
-
min-width: 100%;
|
|
186
|
-
max-width: 100%;
|
|
187
|
-
z-index: 0;
|
|
188
|
-
}
|
|
189
|
-
#image-stack picture {
|
|
190
|
-
visibility: hidden;
|
|
191
|
-
}
|
|
192
|
-
#image-stack picture.show {
|
|
193
|
-
visibility: visible;
|
|
194
|
-
}
|
|
195
|
-
.fill-parent {
|
|
196
|
-
position: absolute;
|
|
197
|
-
top: 0;
|
|
198
|
-
bottom: 0;
|
|
199
|
-
left: 0;
|
|
200
|
-
right: 0;
|
|
201
|
-
}
|
|
202
|
-
</style>
|