@realsee/dnalogel 2.0.0-alpha.24 → 2.0.0-alpha.26
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/CHANGELOG.md +7 -0
- package/dist/ModelItemLabelPlugin/index.js +1 -1
- package/dist/ModelRoomLabelPlugin/index.js +82 -46
- package/dist/index.es.js +84 -48
- package/dist/index.js +83 -47
- package/dist/index.umd.js +83 -47
- package/docs/classes/ModelRoomLabelController.html +6 -6
- package/docs/enums/FLOOR_PLAN_ATTACHED_TO.html +1 -1
- package/docs/enums/ModelFloorplanErrorType.html +1 -1
- package/docs/interfaces/LineJson.html +1 -1
- package/docs/interfaces/ModelChassisCompassPluginData.html +1 -1
- package/docs/interfaces/ModelChassisCompassPluginExportType.html +1 -1
- package/docs/interfaces/ModelChassisCompassPluginParameterType.html +1 -1
- package/docs/interfaces/ModelEntryDoorGuidePluginData.html +1 -1
- package/docs/interfaces/ModelEntryDoorGuidePluginExportType.html +1 -1
- package/docs/interfaces/ModelFloorplanParameterType.html +1 -1
- package/docs/interfaces/ModelFloorplanViewEvent.html +2 -2
- package/docs/interfaces/ModelItemLabelPluginData.html +1 -1
- package/docs/interfaces/ModelItemLabelPluginExportReturnsType.html +1 -1
- package/docs/interfaces/ModelItemLabelPluginParametersType.html +1 -1
- package/docs/interfaces/ModelRoomLabelPluginData.html +1 -1
- package/docs/interfaces/ModelTVVideoPluginData.html +1 -1
- package/docs/interfaces/ModelTVVideoPluginExportType.html +1 -1
- package/docs/interfaces/ModelTVVideoPluginParameterType.html +1 -1
- package/docs/interfaces/PanoCompassPluginData.html +1 -1
- package/docs/interfaces/PanoCompassPluginParameterType.html +1 -1
- package/docs/interfaces/PanoCursorRaycasterPluginExportType.html +6 -6
- package/docs/interfaces/PanoRulerPluginExportType.html +1 -1
- package/docs/interfaces/PanoRulerPluginOptions.html +1 -1
- package/docs/interfaces/PanoRulerPluginParameterType.html +1 -1
- package/docs/interfaces/PanoSpatialTagPluginData.html +1 -1
- package/docs/interfaces/PanoSpatialTagPluginExportType.html +1 -1
- package/docs/interfaces/PanoSpatialTagPluginParameterType.html +1 -1
- package/docs/interfaces/PointJson.html +1 -1
- package/docs/interfaces/RoomLabel.html +7 -7
- package/docs/interfaces/TopviewFloorplanPluginParameterType.html +8 -8
- package/docs/modules.html +12 -12
- package/libs/ModelItemLabelPlugin/ItemLabelComponent.js +1 -1
- package/libs/ModelRoomLabelPlugin/RoomLabelItems.js +83 -47
- package/package.json +2 -2
|
@@ -11,6 +11,7 @@ import {
|
|
|
11
11
|
detach,
|
|
12
12
|
element,
|
|
13
13
|
empty,
|
|
14
|
+
globals,
|
|
14
15
|
group_outros,
|
|
15
16
|
init,
|
|
16
17
|
insert,
|
|
@@ -22,7 +23,8 @@ import {
|
|
|
22
23
|
update_keyed_each
|
|
23
24
|
} from "svelte/internal";
|
|
24
25
|
|
|
25
|
-
|
|
26
|
+
const { Map: Map_1 } = globals;
|
|
27
|
+
import { onDestroy } from 'svelte';
|
|
26
28
|
import { Raycaster, Vector3 } from 'three';
|
|
27
29
|
import RoomLabelItem from './RoomLabelItem';
|
|
28
30
|
|
|
@@ -32,11 +34,11 @@ function add_css(target) {
|
|
|
32
34
|
|
|
33
35
|
function get_each_context(ctx, list, i) {
|
|
34
36
|
const child_ctx = ctx.slice();
|
|
35
|
-
child_ctx[
|
|
37
|
+
child_ctx[12] = list[i];
|
|
36
38
|
return child_ctx;
|
|
37
39
|
}
|
|
38
40
|
|
|
39
|
-
// (
|
|
41
|
+
// (82:2) {#each roomLabels as roomLableItem (roomLableItem.id)}
|
|
40
42
|
function create_each_block(key_1, ctx) {
|
|
41
43
|
let first;
|
|
42
44
|
let roomlabelitem;
|
|
@@ -44,7 +46,7 @@ function create_each_block(key_1, ctx) {
|
|
|
44
46
|
|
|
45
47
|
roomlabelitem = new RoomLabelItem({
|
|
46
48
|
props: {
|
|
47
|
-
roomLabel: /*roomLableItem*/ ctx[
|
|
49
|
+
roomLabel: /*roomLableItem*/ ctx[12],
|
|
48
50
|
five: /*five*/ ctx[1]
|
|
49
51
|
}
|
|
50
52
|
});
|
|
@@ -65,7 +67,7 @@ function create_each_block(key_1, ctx) {
|
|
|
65
67
|
p(new_ctx, dirty) {
|
|
66
68
|
ctx = new_ctx;
|
|
67
69
|
const roomlabelitem_changes = {};
|
|
68
|
-
if (dirty & /*roomLabels*/ 1) roomlabelitem_changes.roomLabel = /*roomLableItem*/ ctx[
|
|
70
|
+
if (dirty & /*roomLabels*/ 1) roomlabelitem_changes.roomLabel = /*roomLableItem*/ ctx[12];
|
|
69
71
|
if (dirty & /*five*/ 2) roomlabelitem_changes.five = /*five*/ ctx[1];
|
|
70
72
|
roomlabelitem.$set(roomlabelitem_changes);
|
|
71
73
|
},
|
|
@@ -88,11 +90,11 @@ function create_each_block(key_1, ctx) {
|
|
|
88
90
|
function create_fragment(ctx) {
|
|
89
91
|
let div;
|
|
90
92
|
let each_blocks = [];
|
|
91
|
-
let each_1_lookup = new
|
|
93
|
+
let each_1_lookup = new Map_1();
|
|
92
94
|
let div_resize_listener;
|
|
93
95
|
let current;
|
|
94
96
|
let each_value = /*roomLabels*/ ctx[0];
|
|
95
|
-
const get_key = ctx => /*roomLableItem*/ ctx[
|
|
97
|
+
const get_key = ctx => /*roomLableItem*/ ctx[12].id;
|
|
96
98
|
|
|
97
99
|
for (let i = 0; i < each_value.length; i += 1) {
|
|
98
100
|
let child_ctx = get_each_context(ctx, each_value, i);
|
|
@@ -109,7 +111,7 @@ function create_fragment(ctx) {
|
|
|
109
111
|
}
|
|
110
112
|
|
|
111
113
|
attr(div, "class", "room-labels-container svelte-185yvaa");
|
|
112
|
-
add_render_callback(() => /*div_elementresize_handler*/ ctx[
|
|
114
|
+
add_render_callback(() => /*div_elementresize_handler*/ ctx[6].call(div));
|
|
113
115
|
},
|
|
114
116
|
m(target, anchor) {
|
|
115
117
|
insert(target, div, anchor);
|
|
@@ -118,7 +120,7 @@ function create_fragment(ctx) {
|
|
|
118
120
|
each_blocks[i].m(div, null);
|
|
119
121
|
}
|
|
120
122
|
|
|
121
|
-
div_resize_listener = add_resize_listener(div, /*div_elementresize_handler*/ ctx[
|
|
123
|
+
div_resize_listener = add_resize_listener(div, /*div_elementresize_handler*/ ctx[6].bind(div));
|
|
122
124
|
current = true;
|
|
123
125
|
},
|
|
124
126
|
p(ctx, [dirty]) {
|
|
@@ -158,22 +160,17 @@ function create_fragment(ctx) {
|
|
|
158
160
|
}
|
|
159
161
|
|
|
160
162
|
function instance($$self, $$props, $$invalidate) {
|
|
163
|
+
let rendererSize;
|
|
161
164
|
let { five } = $$props;
|
|
162
165
|
let { roomLabels } = $$props;
|
|
163
166
|
let containerWidth;
|
|
164
167
|
let containerHeight;
|
|
168
|
+
let shownFloor = null;
|
|
165
169
|
|
|
166
|
-
function getLabelVisible(
|
|
167
|
-
// 先看是不是在当前展示的楼层上
|
|
168
|
-
const isLabelInFloor = five.model.shownFloor === null || roomLabelItem.floorIndex === five.model.shownFloor;
|
|
169
|
-
|
|
170
|
-
if (!isLabelInFloor) return false;
|
|
171
|
-
|
|
172
|
-
// 再看是不是被模型遮挡
|
|
170
|
+
function getLabelVisible(item) {
|
|
173
171
|
const raycaster = new Raycaster();
|
|
174
|
-
|
|
175
172
|
const cameraPosition = five.camera.position.clone();
|
|
176
|
-
const position = new Vector3(
|
|
173
|
+
const position = new Vector3(item.position.x, item.position.y, item.position.z);
|
|
177
174
|
const vectorDistance = position.distanceTo(cameraPosition);
|
|
178
175
|
raycaster.set(cameraPosition.clone(), position.clone().sub(cameraPosition).normalize());
|
|
179
176
|
const [intersection] = five.model.intersectRaycaster(raycaster);
|
|
@@ -181,53 +178,60 @@ function instance($$self, $$props, $$invalidate) {
|
|
|
181
178
|
return true;
|
|
182
179
|
}
|
|
183
180
|
|
|
184
|
-
function getLabelTransform(
|
|
185
|
-
const position = new Vector3(
|
|
181
|
+
function getLabelTransform(item, rendererSize) {
|
|
182
|
+
const position = new Vector3(item.position.x, item.position.y, item.position.z);
|
|
186
183
|
const mouse = position.clone().project(five.camera);
|
|
187
|
-
const xOffset = Math.ceil((mouse.x + 1) / 2 *
|
|
188
|
-
const yOffset = Math.ceil((-mouse.y + 1) / 2 *
|
|
184
|
+
const xOffset = Math.ceil((mouse.x + 1) / 2 * rendererSize.x);
|
|
185
|
+
const yOffset = Math.ceil((-mouse.y + 1) / 2 * rendererSize.y);
|
|
189
186
|
return `translate(${xOffset}px, ${yOffset}px)`;
|
|
190
187
|
}
|
|
191
188
|
|
|
192
|
-
function getFormatedRoomLabels(
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
189
|
+
function getFormatedRoomLabels(rendererSize) {
|
|
190
|
+
// 因为 item distance 需要重复计算,所以缓存一下
|
|
191
|
+
const distanceMap = new Map();
|
|
192
|
+
|
|
193
|
+
function getItemDistance(item) {
|
|
194
|
+
const cacheDistance = distanceMap.get(item.id);
|
|
195
|
+
if (cacheDistance) return cacheDistance;
|
|
196
|
+
const { x, y, z } = item.position;
|
|
197
|
+
const distance = new Vector3(x, y, z).clone().distanceTo(five.camera.position);
|
|
198
|
+
distanceMap.set(item.id, distance);
|
|
199
|
+
return distance;
|
|
200
|
+
}
|
|
196
201
|
|
|
197
|
-
|
|
202
|
+
const formatedItems = roomLabels.map(item => {
|
|
203
|
+
const visible = getLabelVisible(item);
|
|
198
204
|
|
|
199
|
-
|
|
200
|
-
|
|
205
|
+
const transform = visible
|
|
206
|
+
? getLabelTransform(item, rendererSize)
|
|
207
|
+
: item.transform;
|
|
201
208
|
|
|
202
|
-
|
|
203
|
-
});
|
|
209
|
+
const itemDistance = getItemDistance(item);
|
|
204
210
|
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
distance: new Vector3(...Object.values(roomLabelItem.position)).clone().distanceTo(five.camera.position)
|
|
208
|
-
})).sort((a, b) => a.distance - b.distance);
|
|
211
|
+
// visible === true 的 item 中,distance 比自己小的 item 个数
|
|
212
|
+
const minItemLen = roomLabels.filter(item => item.visible && getItemDistance(item) < itemDistance).length;
|
|
209
213
|
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
if (sortIndex !== undefined) return Object.assign(Object.assign({}, roomLabelItem), { zIndex: sortIndex * 10 });
|
|
213
|
-
return roomLabelItem;
|
|
214
|
+
const zIndex = minItemLen * 10;
|
|
215
|
+
return Object.assign(Object.assign({}, item), { visible, transform, zIndex });
|
|
214
216
|
});
|
|
217
|
+
|
|
218
|
+
return formatedItems;
|
|
215
219
|
}
|
|
216
220
|
|
|
217
221
|
function onFiveCameraUpdate() {
|
|
218
|
-
$$invalidate(0, roomLabels = getFormatedRoomLabels(
|
|
222
|
+
$$invalidate(0, roomLabels = getFormatedRoomLabels(rendererSize));
|
|
223
|
+
}
|
|
224
|
+
|
|
225
|
+
function onFiveModelShownFloorChange(floorIndex) {
|
|
226
|
+
$$invalidate(4, shownFloor = floorIndex);
|
|
219
227
|
}
|
|
220
228
|
|
|
221
229
|
five.on('cameraUpdate', onFiveCameraUpdate);
|
|
222
|
-
five.on('modelShownFloorChange',
|
|
230
|
+
five.on('modelShownFloorChange', onFiveModelShownFloorChange);
|
|
223
231
|
|
|
224
232
|
onDestroy(() => {
|
|
225
233
|
five.off('cameraUpdate', onFiveCameraUpdate);
|
|
226
|
-
five.off('modelShownFloorChange',
|
|
227
|
-
});
|
|
228
|
-
|
|
229
|
-
onMount(() => {
|
|
230
|
-
onFiveCameraUpdate();
|
|
234
|
+
five.off('modelShownFloorChange', onFiveModelShownFloorChange);
|
|
231
235
|
});
|
|
232
236
|
|
|
233
237
|
function div_elementresize_handler() {
|
|
@@ -242,7 +246,39 @@ function instance($$self, $$props, $$invalidate) {
|
|
|
242
246
|
if ('roomLabels' in $$props) $$invalidate(0, roomLabels = $$props.roomLabels);
|
|
243
247
|
};
|
|
244
248
|
|
|
245
|
-
|
|
249
|
+
$$self.$$.update = () => {
|
|
250
|
+
if ($$self.$$.dirty & /*containerWidth, containerHeight*/ 12) {
|
|
251
|
+
$: $$invalidate(5, rendererSize = { x: containerWidth, y: containerHeight });
|
|
252
|
+
}
|
|
253
|
+
|
|
254
|
+
if ($$self.$$.dirty & /*rendererSize*/ 32) {
|
|
255
|
+
$: {
|
|
256
|
+
// rendererSize 变化时,触发 reRender
|
|
257
|
+
$$invalidate(0, roomLabels = getFormatedRoomLabels(rendererSize));
|
|
258
|
+
}
|
|
259
|
+
}
|
|
260
|
+
|
|
261
|
+
if ($$self.$$.dirty & /*roomLabels, shownFloor*/ 17) {
|
|
262
|
+
$: {
|
|
263
|
+
// shownFloor 变化时,更新 item visible
|
|
264
|
+
$$invalidate(0, roomLabels = roomLabels.map(item => {
|
|
265
|
+
const isLabelInFloor = shownFloor === null || item.floorIndex === shownFloor;
|
|
266
|
+
const visible = isLabelInFloor ? item.visible : false;
|
|
267
|
+
return Object.assign(Object.assign({}, item), { visible });
|
|
268
|
+
}));
|
|
269
|
+
}
|
|
270
|
+
}
|
|
271
|
+
};
|
|
272
|
+
|
|
273
|
+
return [
|
|
274
|
+
roomLabels,
|
|
275
|
+
five,
|
|
276
|
+
containerWidth,
|
|
277
|
+
containerHeight,
|
|
278
|
+
shownFloor,
|
|
279
|
+
rendererSize,
|
|
280
|
+
div_elementresize_handler
|
|
281
|
+
];
|
|
246
282
|
}
|
|
247
283
|
|
|
248
284
|
class Component extends SvelteComponent {
|
package/package.json
CHANGED
|
@@ -7,7 +7,7 @@
|
|
|
7
7
|
"repository": "https://github.com/realsee-developer/dnalogel.git",
|
|
8
8
|
"description": "如视 VR 看房插件合集",
|
|
9
9
|
"private": false,
|
|
10
|
-
"version": "2.0.0-alpha.
|
|
10
|
+
"version": "2.0.0-alpha.26",
|
|
11
11
|
"license": "SEE LICENSE IN TERMS.txt",
|
|
12
12
|
"scripts": {
|
|
13
13
|
"build": "yarn run tsb && yarn run build:rollup && yarn build:docs",
|
|
@@ -27,7 +27,7 @@
|
|
|
27
27
|
],
|
|
28
28
|
"devDependencies": {
|
|
29
29
|
"@babel/core": "^7.17.5",
|
|
30
|
-
"@realsee/five": "^5.0.0-alpha.
|
|
30
|
+
"@realsee/five": "^5.0.0-alpha.127",
|
|
31
31
|
"@rollup/plugin-alias": "^3.1.9",
|
|
32
32
|
"@rollup/plugin-commonjs": "^21.1.0",
|
|
33
33
|
"@rollup/plugin-typescript": "^8.3.2",
|