@realsee/dnalogel 2.0.0-alpha.11 → 2.0.0-alpha.12
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 +3 -0
- package/dist/ModelItemLabelPlugin/events.type.d.ts +9 -0
- package/dist/ModelItemLabelPlugin/index.d.ts +4 -0
- package/dist/ModelItemLabelPlugin/index.js +678 -0
- package/dist/ModelItemLabelPlugin/typings.d.ts +55 -0
- package/dist/ModelItemLabelPlugin/utils/parseData.d.ts +3 -0
- package/dist/ModelRoomLabelPlugin/index.js +1 -1
- package/dist/PanoSpatialTagPlugin/index.js +9 -9
- package/dist/index.d.ts +1 -0
- package/dist/index.es.js +810 -166
- package/dist/index.js +809 -163
- package/dist/index.umd.js +812 -167
- package/docs/assets/search.js +1 -1
- 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/index.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/ModelRoomLabelPluginData.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 +1 -1
- package/docs/modules.html +12 -12
- package/libs/ModelItemLabelPlugin/ItemLabelComponent.js +420 -0
- package/libs/ModelItemLabelPlugin/ItemLabelItem.js +133 -0
- package/libs/ModelItemLabelPlugin/events.type.d.ts +9 -0
- package/libs/ModelItemLabelPlugin/events.type.js +1 -0
- package/libs/ModelItemLabelPlugin/index.d.ts +4 -0
- package/libs/ModelItemLabelPlugin/index.js +170 -0
- package/libs/ModelItemLabelPlugin/typings.d.ts +55 -0
- package/libs/ModelItemLabelPlugin/typings.js +6 -0
- package/libs/ModelItemLabelPlugin/utils/parseData.d.ts +3 -0
- package/libs/ModelItemLabelPlugin/utils/parseData.js +7 -0
- package/libs/ModelRoomLabelPlugin/RoomLabelItems.js +1 -1
- package/libs/PanoSpatialTagPlugin/Components/tag.js +9 -9
- package/libs/index.d.ts +1 -0
- package/libs/index.js +2 -0
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { SubscribeEventMap } from '@realsee/five';
|
|
2
|
+
import { ItemLabel } from "./typings";
|
|
3
|
+
export interface ItemLabelEvent extends SubscribeEventMap {
|
|
4
|
+
/**
|
|
5
|
+
* 点击标签
|
|
6
|
+
*/
|
|
7
|
+
onLabelClick: (itemLabel: ItemLabel) => void;
|
|
8
|
+
}
|
|
9
|
+
export declare type PluginEvent = ItemLabelEvent;
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import type { FivePlugin } from "@realsee/five";
|
|
2
|
+
import { ModelItemLabelPluginExportReturnsType, ModelItemLabelPluginParametersType } from "./typings";
|
|
3
|
+
export declare const ModelItemLabelPlugin: FivePlugin<ModelItemLabelPluginParametersType, ModelItemLabelPluginExportReturnsType>;
|
|
4
|
+
export default ModelItemLabelPlugin;
|
|
@@ -0,0 +1,678 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
|
+
|
|
5
|
+
var five = require('@realsee/five');
|
|
6
|
+
var internal = require('svelte/internal');
|
|
7
|
+
var svelte = require('svelte');
|
|
8
|
+
var THREE = require('three');
|
|
9
|
+
var classNames = require('classnames');
|
|
10
|
+
|
|
11
|
+
function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
|
|
12
|
+
|
|
13
|
+
function _interopNamespace(e) {
|
|
14
|
+
if (e && e.__esModule) return e;
|
|
15
|
+
var n = Object.create(null);
|
|
16
|
+
if (e) {
|
|
17
|
+
Object.keys(e).forEach(function (k) {
|
|
18
|
+
if (k !== 'default') {
|
|
19
|
+
var d = Object.getOwnPropertyDescriptor(e, k);
|
|
20
|
+
Object.defineProperty(n, k, d.get ? d : {
|
|
21
|
+
enumerable: true,
|
|
22
|
+
get: function () { return e[k]; }
|
|
23
|
+
});
|
|
24
|
+
}
|
|
25
|
+
});
|
|
26
|
+
}
|
|
27
|
+
n["default"] = e;
|
|
28
|
+
return Object.freeze(n);
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
var THREE__namespace = /*#__PURE__*/_interopNamespace(THREE);
|
|
32
|
+
var classNames__default = /*#__PURE__*/_interopDefaultLegacy(classNames);
|
|
33
|
+
|
|
34
|
+
var DISPLAY_STRATEGY_TYPE;
|
|
35
|
+
(function (DISPLAY_STRATEGY_TYPE) {
|
|
36
|
+
DISPLAY_STRATEGY_TYPE["SMALL"] = "small";
|
|
37
|
+
DISPLAY_STRATEGY_TYPE["MIDLLE"] = "middle";
|
|
38
|
+
DISPLAY_STRATEGY_TYPE["LARGE"] = "large";
|
|
39
|
+
})(DISPLAY_STRATEGY_TYPE || (DISPLAY_STRATEGY_TYPE = {}));
|
|
40
|
+
|
|
41
|
+
/* src/ModelItemLabelPlugin/ItemLabelItem.svelte generated by Svelte v3.47.0 */
|
|
42
|
+
|
|
43
|
+
function add_css$1(target) {
|
|
44
|
+
internal.append_styles(target, "svelte-1mttyji", ".item-label-item.svelte-1mttyji{position:absolute;z-index:0;transform:none;cursor:pointer;pointer-events:none;user-select:none;opacity:0}.item-label-item.visible.svelte-1mttyji{opacity:1;animation:svelte-1mttyji-fadeIn .3s ease-in}.item-label-item__text-wrap.svelte-1mttyji::before{content:'';position:absolute;width:100%;height:100%;background-color:rgba(0, 0, 0, .3);filter:blur(16px);z-index:-1}.item-label-item__text-wrap.svelte-1mttyji{padding:6px 6px 0;position:absolute;height:20px;pointer-events:all;background-size:100% 100%;background-repeat:no-repeat;white-space:nowrap;line-height:10px;font-size:11px;font-weight:bold;color:#FFEAC0;transform:translate(-50%, 0);display:flex;justify-content:center;align-items:center}.item-label-item__text.svelte-1mttyji{padding-bottom:4px;border-top:0 solid;border-left:0 solid;border-right:0 solid;border-bottom:1px solid;border-image:linear-gradient(to right, rgba(234, 208, 154, 0), rgba(234, 208, 154, 100), rgba(234, 208, 154, 0)) 4.5 1 4.5}.item-label-item__bar.svelte-1mttyji{position:absolute;bottom:0;width:1px;background-image:linear-gradient(to bottom, rgba(234, 208, 154, 0), rgba(234, 208, 154, 1))}@keyframes svelte-1mttyji-fadeIn{from{opacity:0\n }to{opacity:1\n }}");
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
function create_fragment$1(ctx) {
|
|
48
|
+
let div2;
|
|
49
|
+
let div0;
|
|
50
|
+
let span;
|
|
51
|
+
|
|
52
|
+
let t0_value = (/*itemLabel*/ ctx[0].name.length > 6
|
|
53
|
+
? `${/*itemLabel*/ ctx[0].name.slice(0, 6)}...`
|
|
54
|
+
: /*itemLabel*/ ctx[0].name) + "";
|
|
55
|
+
|
|
56
|
+
let t0;
|
|
57
|
+
let t1;
|
|
58
|
+
let div1;
|
|
59
|
+
let div2_class_value;
|
|
60
|
+
let mounted;
|
|
61
|
+
let dispose;
|
|
62
|
+
|
|
63
|
+
return {
|
|
64
|
+
c() {
|
|
65
|
+
div2 = internal.element("div");
|
|
66
|
+
div0 = internal.element("div");
|
|
67
|
+
span = internal.element("span");
|
|
68
|
+
t0 = internal.text(t0_value);
|
|
69
|
+
t1 = internal.space();
|
|
70
|
+
div1 = internal.element("div");
|
|
71
|
+
internal.attr(span, "class", "item-label-item__text svelte-1mttyji");
|
|
72
|
+
internal.attr(div0, "class", "item-label-item__text-wrap svelte-1mttyji");
|
|
73
|
+
internal.set_style(div0, "top", `-${/*itemLabel*/ ctx[0].strokeLength + 26}px`);
|
|
74
|
+
internal.attr(div1, "class", "item-label-item__bar svelte-1mttyji");
|
|
75
|
+
internal.set_style(div1, "height", `${/*itemLabel*/ ctx[0].strokeLength}px`);
|
|
76
|
+
internal.attr(div2, "class", div2_class_value = "" + (internal.null_to_empty(classNames__default["default"]("item-label-item", { visible: /*itemLabel*/ ctx[0].visible })) + " svelte-1mttyji"));
|
|
77
|
+
internal.set_style(div2, "z-index", /*itemLabel*/ ctx[0].zIndex, false);
|
|
78
|
+
internal.set_style(div2, "transform", /*itemLabel*/ ctx[0].transform, false);
|
|
79
|
+
},
|
|
80
|
+
m(target, anchor) {
|
|
81
|
+
internal.insert(target, div2, anchor);
|
|
82
|
+
internal.append(div2, div0);
|
|
83
|
+
internal.append(div0, span);
|
|
84
|
+
internal.append(span, t0);
|
|
85
|
+
internal.append(div2, t1);
|
|
86
|
+
internal.append(div2, div1);
|
|
87
|
+
|
|
88
|
+
if (!mounted) {
|
|
89
|
+
dispose = internal.listen(span, "click", /*onClick*/ ctx[1]);
|
|
90
|
+
mounted = true;
|
|
91
|
+
}
|
|
92
|
+
},
|
|
93
|
+
p(ctx, [dirty]) {
|
|
94
|
+
if (dirty & /*itemLabel*/ 1 && t0_value !== (t0_value = (/*itemLabel*/ ctx[0].name.length > 6
|
|
95
|
+
? `${/*itemLabel*/ ctx[0].name.slice(0, 6)}...`
|
|
96
|
+
: /*itemLabel*/ ctx[0].name) + "")) internal.set_data(t0, t0_value);
|
|
97
|
+
|
|
98
|
+
if (dirty & /*itemLabel*/ 1) {
|
|
99
|
+
internal.set_style(div0, "top", `-${/*itemLabel*/ ctx[0].strokeLength + 26}px`);
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
if (dirty & /*itemLabel*/ 1) {
|
|
103
|
+
internal.set_style(div1, "height", `${/*itemLabel*/ ctx[0].strokeLength}px`);
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
if (dirty & /*itemLabel*/ 1 && div2_class_value !== (div2_class_value = "" + (internal.null_to_empty(classNames__default["default"]("item-label-item", { visible: /*itemLabel*/ ctx[0].visible })) + " svelte-1mttyji"))) {
|
|
107
|
+
internal.attr(div2, "class", div2_class_value);
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
if (dirty & /*itemLabel*/ 1) {
|
|
111
|
+
internal.set_style(div2, "z-index", /*itemLabel*/ ctx[0].zIndex, false);
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
if (dirty & /*itemLabel*/ 1) {
|
|
115
|
+
internal.set_style(div2, "transform", /*itemLabel*/ ctx[0].transform, false);
|
|
116
|
+
}
|
|
117
|
+
},
|
|
118
|
+
i: internal.noop,
|
|
119
|
+
o: internal.noop,
|
|
120
|
+
d(detaching) {
|
|
121
|
+
if (detaching) internal.detach(div2);
|
|
122
|
+
mounted = false;
|
|
123
|
+
dispose();
|
|
124
|
+
}
|
|
125
|
+
};
|
|
126
|
+
}
|
|
127
|
+
|
|
128
|
+
function instance$1($$self, $$props, $$invalidate) {
|
|
129
|
+
let { itemLabel } = $$props;
|
|
130
|
+
let { hooks } = $$props;
|
|
131
|
+
|
|
132
|
+
function onClick() {
|
|
133
|
+
console.log('__onclick___: ', itemLabel);
|
|
134
|
+
hooks.emit('onLabelClick', itemLabel);
|
|
135
|
+
}
|
|
136
|
+
|
|
137
|
+
$$self.$$set = $$props => {
|
|
138
|
+
if ('itemLabel' in $$props) $$invalidate(0, itemLabel = $$props.itemLabel);
|
|
139
|
+
if ('hooks' in $$props) $$invalidate(2, hooks = $$props.hooks);
|
|
140
|
+
};
|
|
141
|
+
|
|
142
|
+
return [itemLabel, onClick, hooks];
|
|
143
|
+
}
|
|
144
|
+
|
|
145
|
+
class ItemLabelItem extends internal.SvelteComponent {
|
|
146
|
+
constructor(options) {
|
|
147
|
+
super();
|
|
148
|
+
internal.init(this, options, instance$1, create_fragment$1, internal.safe_not_equal, { itemLabel: 0, hooks: 2 }, add_css$1);
|
|
149
|
+
}
|
|
150
|
+
}
|
|
151
|
+
|
|
152
|
+
/* src/ModelItemLabelPlugin/ItemLabelComponent.svelte generated by Svelte v3.47.0 */
|
|
153
|
+
|
|
154
|
+
function add_css(target) {
|
|
155
|
+
internal.append_styles(target, "svelte-rmdeb", ".item-labels-container.svelte-rmdeb{width:100%;height:100%;position:relative}");
|
|
156
|
+
}
|
|
157
|
+
|
|
158
|
+
function get_each_context(ctx, list, i) {
|
|
159
|
+
const child_ctx = ctx.slice();
|
|
160
|
+
child_ctx[26] = list[i];
|
|
161
|
+
return child_ctx;
|
|
162
|
+
}
|
|
163
|
+
|
|
164
|
+
// (179:1) {#each renderItemLabels as itemLabelItem (itemLabelItem.id)}
|
|
165
|
+
function create_each_block(key_1, ctx) {
|
|
166
|
+
let first;
|
|
167
|
+
let itemlabelitem;
|
|
168
|
+
let current;
|
|
169
|
+
|
|
170
|
+
itemlabelitem = new ItemLabelItem({
|
|
171
|
+
props: {
|
|
172
|
+
itemLabel: /*itemLabelItem*/ ctx[26],
|
|
173
|
+
hooks: /*hooks*/ ctx[0]
|
|
174
|
+
}
|
|
175
|
+
});
|
|
176
|
+
|
|
177
|
+
return {
|
|
178
|
+
key: key_1,
|
|
179
|
+
first: null,
|
|
180
|
+
c() {
|
|
181
|
+
first = internal.empty();
|
|
182
|
+
internal.create_component(itemlabelitem.$$.fragment);
|
|
183
|
+
this.first = first;
|
|
184
|
+
},
|
|
185
|
+
m(target, anchor) {
|
|
186
|
+
internal.insert(target, first, anchor);
|
|
187
|
+
internal.mount_component(itemlabelitem, target, anchor);
|
|
188
|
+
current = true;
|
|
189
|
+
},
|
|
190
|
+
p(new_ctx, dirty) {
|
|
191
|
+
ctx = new_ctx;
|
|
192
|
+
const itemlabelitem_changes = {};
|
|
193
|
+
if (dirty & /*renderItemLabels*/ 2) itemlabelitem_changes.itemLabel = /*itemLabelItem*/ ctx[26];
|
|
194
|
+
if (dirty & /*hooks*/ 1) itemlabelitem_changes.hooks = /*hooks*/ ctx[0];
|
|
195
|
+
itemlabelitem.$set(itemlabelitem_changes);
|
|
196
|
+
},
|
|
197
|
+
i(local) {
|
|
198
|
+
if (current) return;
|
|
199
|
+
internal.transition_in(itemlabelitem.$$.fragment, local);
|
|
200
|
+
current = true;
|
|
201
|
+
},
|
|
202
|
+
o(local) {
|
|
203
|
+
internal.transition_out(itemlabelitem.$$.fragment, local);
|
|
204
|
+
current = false;
|
|
205
|
+
},
|
|
206
|
+
d(detaching) {
|
|
207
|
+
if (detaching) internal.detach(first);
|
|
208
|
+
internal.destroy_component(itemlabelitem, detaching);
|
|
209
|
+
}
|
|
210
|
+
};
|
|
211
|
+
}
|
|
212
|
+
|
|
213
|
+
function create_fragment(ctx) {
|
|
214
|
+
let div;
|
|
215
|
+
let each_blocks = [];
|
|
216
|
+
let each_1_lookup = new Map();
|
|
217
|
+
let div_resize_listener;
|
|
218
|
+
let current;
|
|
219
|
+
let each_value = /*renderItemLabels*/ ctx[1];
|
|
220
|
+
const get_key = ctx => /*itemLabelItem*/ ctx[26].id;
|
|
221
|
+
|
|
222
|
+
for (let i = 0; i < each_value.length; i += 1) {
|
|
223
|
+
let child_ctx = get_each_context(ctx, each_value, i);
|
|
224
|
+
let key = get_key(child_ctx);
|
|
225
|
+
each_1_lookup.set(key, each_blocks[i] = create_each_block(key, child_ctx));
|
|
226
|
+
}
|
|
227
|
+
|
|
228
|
+
return {
|
|
229
|
+
c() {
|
|
230
|
+
div = internal.element("div");
|
|
231
|
+
|
|
232
|
+
for (let i = 0; i < each_blocks.length; i += 1) {
|
|
233
|
+
each_blocks[i].c();
|
|
234
|
+
}
|
|
235
|
+
|
|
236
|
+
internal.attr(div, "class", "item-labels-container svelte-rmdeb");
|
|
237
|
+
internal.add_render_callback(() => /*div_elementresize_handler*/ ctx[9].call(div));
|
|
238
|
+
},
|
|
239
|
+
m(target, anchor) {
|
|
240
|
+
internal.insert(target, div, anchor);
|
|
241
|
+
|
|
242
|
+
for (let i = 0; i < each_blocks.length; i += 1) {
|
|
243
|
+
each_blocks[i].m(div, null);
|
|
244
|
+
}
|
|
245
|
+
|
|
246
|
+
div_resize_listener = internal.add_resize_listener(div, /*div_elementresize_handler*/ ctx[9].bind(div));
|
|
247
|
+
current = true;
|
|
248
|
+
},
|
|
249
|
+
p(ctx, [dirty]) {
|
|
250
|
+
if (dirty & /*renderItemLabels, hooks*/ 3) {
|
|
251
|
+
each_value = /*renderItemLabels*/ ctx[1];
|
|
252
|
+
internal.group_outros();
|
|
253
|
+
each_blocks = internal.update_keyed_each(each_blocks, dirty, get_key, 1, ctx, each_value, each_1_lookup, div, internal.outro_and_destroy_block, create_each_block, null, get_each_context);
|
|
254
|
+
internal.check_outros();
|
|
255
|
+
}
|
|
256
|
+
},
|
|
257
|
+
i(local) {
|
|
258
|
+
if (current) return;
|
|
259
|
+
|
|
260
|
+
for (let i = 0; i < each_value.length; i += 1) {
|
|
261
|
+
internal.transition_in(each_blocks[i]);
|
|
262
|
+
}
|
|
263
|
+
|
|
264
|
+
current = true;
|
|
265
|
+
},
|
|
266
|
+
o(local) {
|
|
267
|
+
for (let i = 0; i < each_blocks.length; i += 1) {
|
|
268
|
+
internal.transition_out(each_blocks[i]);
|
|
269
|
+
}
|
|
270
|
+
|
|
271
|
+
current = false;
|
|
272
|
+
},
|
|
273
|
+
d(detaching) {
|
|
274
|
+
if (detaching) internal.detach(div);
|
|
275
|
+
|
|
276
|
+
for (let i = 0; i < each_blocks.length; i += 1) {
|
|
277
|
+
each_blocks[i].d();
|
|
278
|
+
}
|
|
279
|
+
|
|
280
|
+
div_resize_listener();
|
|
281
|
+
}
|
|
282
|
+
};
|
|
283
|
+
}
|
|
284
|
+
|
|
285
|
+
let cssHeight = 26;
|
|
286
|
+
let basicWidth = 11;
|
|
287
|
+
|
|
288
|
+
function instance($$self, $$props, $$invalidate) {
|
|
289
|
+
const { Raycaster, Vector3 } = THREE__namespace;
|
|
290
|
+
let { five } = $$props;
|
|
291
|
+
let { modelOcclusionEnable } = $$props;
|
|
292
|
+
let { itemLabels } = $$props;
|
|
293
|
+
let { wrapper } = $$props;
|
|
294
|
+
let { hooks } = $$props;
|
|
295
|
+
let { displayStrategyType } = $$props;
|
|
296
|
+
let curItemLabels = null;
|
|
297
|
+
let renderItemLabels = null;
|
|
298
|
+
let wrapperSize = { width: 0, height: 0 };
|
|
299
|
+
let containerWidth;
|
|
300
|
+
let containerHeight;
|
|
301
|
+
|
|
302
|
+
// 计算重叠
|
|
303
|
+
let cssOffsetLists = [];
|
|
304
|
+
|
|
305
|
+
const getLabelVisible = (five, itemLabel) => {
|
|
306
|
+
// 虚拟 VR 仅有一层,不考虑楼层信息
|
|
307
|
+
const raycaster = new Raycaster();
|
|
308
|
+
|
|
309
|
+
const cameraPosition = five.camera.position.clone();
|
|
310
|
+
const modelPosition = new Vector3(itemLabel.modelPosition[0], itemLabel.modelPosition[1], itemLabel.modelPosition[2]);
|
|
311
|
+
|
|
312
|
+
// 计算点到相机的位置
|
|
313
|
+
const vectorDistance = modelPosition.distanceTo(cameraPosition);
|
|
314
|
+
|
|
315
|
+
raycaster.set(cameraPosition.clone(), modelPosition.clone().sub(cameraPosition).normalize());
|
|
316
|
+
const [intersection] = five.model.intersectRaycaster(raycaster);
|
|
317
|
+
return !(intersection && intersection.distance + 1 < vectorDistance);
|
|
318
|
+
};
|
|
319
|
+
|
|
320
|
+
// cssOffset 获取
|
|
321
|
+
const getLabelCssOffset = (five, itemLabel) => {
|
|
322
|
+
const modelPosition = new Vector3(itemLabel.modelPosition[0], itemLabel.modelPosition[1], itemLabel.modelPosition[2]);
|
|
323
|
+
const cssPosition = five.project2d(modelPosition);
|
|
324
|
+
const xOffset = cssPosition?.x;
|
|
325
|
+
const yOffset = cssPosition?.y;
|
|
326
|
+
return [xOffset, yOffset];
|
|
327
|
+
};
|
|
328
|
+
|
|
329
|
+
const getLabelTransform = cssOffset => {
|
|
330
|
+
return `translate(${cssOffset[0]}px, ${cssOffset[1]}px)`;
|
|
331
|
+
};
|
|
332
|
+
|
|
333
|
+
// 重叠计算
|
|
334
|
+
const isOverlap = (cssOffset, widthOffset) => {
|
|
335
|
+
if (cssOffsetLists.length === 0) {
|
|
336
|
+
return false;
|
|
337
|
+
}
|
|
338
|
+
|
|
339
|
+
const hasOverlapPoint = cssOffsetLists.find(item => cssOffset[0] >= item[0] - widthOffset && cssOffset[0] <= item[0] + widthOffset || cssOffset[1] >= item[1] - cssHeight && cssOffset[1] <= item[1] + cssHeight);
|
|
340
|
+
return !!hasOverlapPoint;
|
|
341
|
+
};
|
|
342
|
+
|
|
343
|
+
function getStrokeLength(itemSpaceHeight, type) {
|
|
344
|
+
switch (type) {
|
|
345
|
+
case DISPLAY_STRATEGY_TYPE.SMALL:
|
|
346
|
+
return Math.ceil(-27.78 * itemSpaceHeight + 85);
|
|
347
|
+
case DISPLAY_STRATEGY_TYPE.MIDLLE:
|
|
348
|
+
return Math.ceil(-38.9 * itemSpaceHeight + 130);
|
|
349
|
+
case DISPLAY_STRATEGY_TYPE.LARGE:
|
|
350
|
+
return Math.ceil(-44.44 * itemSpaceHeight + 140);
|
|
351
|
+
}
|
|
352
|
+
}
|
|
353
|
+
|
|
354
|
+
const getFormatedItemLabels = (five, labels) => {
|
|
355
|
+
// 计算位置 & 可见性
|
|
356
|
+
const newLabels = labels.map(label => {
|
|
357
|
+
const cssOffset = getLabelCssOffset(five, label);
|
|
358
|
+
const curLabelWidth = label.name.length * basicWidth;
|
|
359
|
+
const strokeLength = getStrokeLength(label.modelPosition[1], displayStrategyType);
|
|
360
|
+
|
|
361
|
+
// 是否加入碰撞检测
|
|
362
|
+
const naturalVisible = modelOcclusionEnable
|
|
363
|
+
? getLabelVisible(five, label)
|
|
364
|
+
: true;
|
|
365
|
+
|
|
366
|
+
const visible = naturalVisible && !isOverlap([cssOffset[0], cssOffset[1] + strokeLength], curLabelWidth);
|
|
367
|
+
if (!visible) return { ...label, visible };
|
|
368
|
+
cssOffsetLists.push(cssOffset);
|
|
369
|
+
|
|
370
|
+
// position
|
|
371
|
+
const transform = getLabelTransform(cssOffset);
|
|
372
|
+
|
|
373
|
+
return {
|
|
374
|
+
...label,
|
|
375
|
+
visible,
|
|
376
|
+
transform,
|
|
377
|
+
strokeLength
|
|
378
|
+
};
|
|
379
|
+
});
|
|
380
|
+
|
|
381
|
+
const sortedItemLabelItems = newLabels.filter(({ visible }) => visible).map(label => ({
|
|
382
|
+
itemLabelItem: label,
|
|
383
|
+
distance: new Vector3(label.modelPosition[0], label.modelPosition[1], label.modelPosition[2]).clone().distanceTo(five.camera.position)
|
|
384
|
+
})).sort((a, b) => a.distance - b.distance);
|
|
385
|
+
|
|
386
|
+
return newLabels.map(label => {
|
|
387
|
+
const sortIndex = sortedItemLabelItems.findIndex(item => item.itemLabelItem.id === label.id);
|
|
388
|
+
if (sortIndex !== undefined) return { ...label, zIndex: sortIndex * 10 };
|
|
389
|
+
return label;
|
|
390
|
+
});
|
|
391
|
+
};
|
|
392
|
+
|
|
393
|
+
const onItemLabelUpdate = () => {
|
|
394
|
+
cssOffsetLists = [];
|
|
395
|
+
$$invalidate(1, renderItemLabels = getFormatedItemLabels(five, renderItemLabels));
|
|
396
|
+
};
|
|
397
|
+
|
|
398
|
+
svelte.beforeUpdate(() => {
|
|
399
|
+
addDataUpdateListener();
|
|
400
|
+
});
|
|
401
|
+
|
|
402
|
+
svelte.onMount(() => {
|
|
403
|
+
$$invalidate(1, renderItemLabels = itemLabels);
|
|
404
|
+
curItemLabels = itemLabels;
|
|
405
|
+
onItemLabelUpdate();
|
|
406
|
+
|
|
407
|
+
// five.on('cameraUpdate', onItemLabelUpdate)
|
|
408
|
+
addResizeListener();
|
|
409
|
+
});
|
|
410
|
+
|
|
411
|
+
const addResizeListener = () => {
|
|
412
|
+
wrapperSize = {
|
|
413
|
+
width: wrapper.clientWidth,
|
|
414
|
+
height: wrapper.clientHeight
|
|
415
|
+
};
|
|
416
|
+
|
|
417
|
+
resizeObserver.observe(wrapper);
|
|
418
|
+
};
|
|
419
|
+
|
|
420
|
+
const addDataUpdateListener = () => {
|
|
421
|
+
if (curItemLabels !== itemLabels) {
|
|
422
|
+
$$invalidate(1, renderItemLabels = itemLabels);
|
|
423
|
+
curItemLabels = itemLabels;
|
|
424
|
+
console.log('--debug--update--');
|
|
425
|
+
onItemLabelUpdate();
|
|
426
|
+
}
|
|
427
|
+
};
|
|
428
|
+
|
|
429
|
+
const resizeObserver = new ResizeObserver(entries => {
|
|
430
|
+
const entry = entries[0];
|
|
431
|
+
const target = entry.target;
|
|
432
|
+
const curWidth = target.clientWidth;
|
|
433
|
+
const curHeight = target.clientHeight;
|
|
434
|
+
|
|
435
|
+
if (wrapperSize.width !== curWidth || wrapperSize.height !== curHeight) {
|
|
436
|
+
wrapperSize = { width: curWidth, height: curHeight };
|
|
437
|
+
onItemLabelUpdate();
|
|
438
|
+
}
|
|
439
|
+
});
|
|
440
|
+
|
|
441
|
+
svelte.onDestroy(() => {
|
|
442
|
+
// five.off('cameraUpdate', onItemLabelUpdate)
|
|
443
|
+
resizeObserver.unobserve(wrapper);
|
|
444
|
+
|
|
445
|
+
curItemLabels = null;
|
|
446
|
+
$$invalidate(1, renderItemLabels = null);
|
|
447
|
+
wrapperSize = { width: 0, height: 0 };
|
|
448
|
+
});
|
|
449
|
+
|
|
450
|
+
function div_elementresize_handler() {
|
|
451
|
+
containerWidth = this.clientWidth;
|
|
452
|
+
containerHeight = this.clientHeight;
|
|
453
|
+
$$invalidate(2, containerWidth);
|
|
454
|
+
$$invalidate(3, containerHeight);
|
|
455
|
+
}
|
|
456
|
+
|
|
457
|
+
$$self.$$set = $$props => {
|
|
458
|
+
if ('five' in $$props) $$invalidate(4, five = $$props.five);
|
|
459
|
+
if ('modelOcclusionEnable' in $$props) $$invalidate(5, modelOcclusionEnable = $$props.modelOcclusionEnable);
|
|
460
|
+
if ('itemLabels' in $$props) $$invalidate(6, itemLabels = $$props.itemLabels);
|
|
461
|
+
if ('wrapper' in $$props) $$invalidate(7, wrapper = $$props.wrapper);
|
|
462
|
+
if ('hooks' in $$props) $$invalidate(0, hooks = $$props.hooks);
|
|
463
|
+
if ('displayStrategyType' in $$props) $$invalidate(8, displayStrategyType = $$props.displayStrategyType);
|
|
464
|
+
};
|
|
465
|
+
|
|
466
|
+
return [
|
|
467
|
+
hooks,
|
|
468
|
+
renderItemLabels,
|
|
469
|
+
containerWidth,
|
|
470
|
+
containerHeight,
|
|
471
|
+
five,
|
|
472
|
+
modelOcclusionEnable,
|
|
473
|
+
itemLabels,
|
|
474
|
+
wrapper,
|
|
475
|
+
displayStrategyType,
|
|
476
|
+
div_elementresize_handler
|
|
477
|
+
];
|
|
478
|
+
}
|
|
479
|
+
|
|
480
|
+
class ItemLabelComponent extends internal.SvelteComponent {
|
|
481
|
+
constructor(options) {
|
|
482
|
+
super();
|
|
483
|
+
|
|
484
|
+
internal.init(
|
|
485
|
+
this,
|
|
486
|
+
options,
|
|
487
|
+
instance,
|
|
488
|
+
create_fragment,
|
|
489
|
+
internal.safe_not_equal,
|
|
490
|
+
{
|
|
491
|
+
five: 4,
|
|
492
|
+
modelOcclusionEnable: 5,
|
|
493
|
+
itemLabels: 6,
|
|
494
|
+
wrapper: 7,
|
|
495
|
+
hooks: 0,
|
|
496
|
+
displayStrategyType: 8
|
|
497
|
+
},
|
|
498
|
+
add_css
|
|
499
|
+
);
|
|
500
|
+
}
|
|
501
|
+
}
|
|
502
|
+
|
|
503
|
+
/** @description 转成内部所需数据 */
|
|
504
|
+
function parseModelItemLabelPluginData(data) {
|
|
505
|
+
return data.model_item_labels.map(label => ({
|
|
506
|
+
modelPosition: [label.position[0], label.position[1] + label.size[1], label.position[2]],
|
|
507
|
+
...label
|
|
508
|
+
}));
|
|
509
|
+
}
|
|
510
|
+
|
|
511
|
+
const ModelItemLabelPlugin = (five$1, params) => {
|
|
512
|
+
const pluginState = {
|
|
513
|
+
container: document.createElement('div'),
|
|
514
|
+
data: null,
|
|
515
|
+
enabled: true,
|
|
516
|
+
fiveModeEnabled: undefined,
|
|
517
|
+
itemLabels: [],
|
|
518
|
+
wrapper: null,
|
|
519
|
+
app: undefined,
|
|
520
|
+
hooks: new five.Subscribe(),
|
|
521
|
+
modelOcclusionEnable: params?.modelOcclusionEnable ?? true,
|
|
522
|
+
displayStrategyType: params?.displayStrategyType ?? DISPLAY_STRATEGY_TYPE.SMALL
|
|
523
|
+
};
|
|
524
|
+
pluginState.container.setAttribute('class', 'model-item-label-plugin-container');
|
|
525
|
+
pluginState.container.style.cssText = `
|
|
526
|
+
position: absolute;
|
|
527
|
+
left: 0;
|
|
528
|
+
top: 0;
|
|
529
|
+
width: 100%;
|
|
530
|
+
height: 100%;
|
|
531
|
+
pointerEvents: none;
|
|
532
|
+
`;
|
|
533
|
+
const appendTo = (wrapper) => {
|
|
534
|
+
pluginState.wrapper = wrapper;
|
|
535
|
+
wrapper.appendChild(pluginState.container);
|
|
536
|
+
render();
|
|
537
|
+
return true;
|
|
538
|
+
};
|
|
539
|
+
const load = (data) => {
|
|
540
|
+
console.log('🐶--当前标签总条数: ', data.model_item_labels.length);
|
|
541
|
+
pluginState.itemLabels = parseModelItemLabelPluginData(data);
|
|
542
|
+
render();
|
|
543
|
+
};
|
|
544
|
+
const enable = () => {
|
|
545
|
+
if (pluginState.enabled)
|
|
546
|
+
return true;
|
|
547
|
+
pluginState.enabled = true;
|
|
548
|
+
render();
|
|
549
|
+
return true;
|
|
550
|
+
};
|
|
551
|
+
const disable = () => {
|
|
552
|
+
if (!pluginState.enabled)
|
|
553
|
+
return true;
|
|
554
|
+
pluginState.enabled = false;
|
|
555
|
+
render();
|
|
556
|
+
return true;
|
|
557
|
+
};
|
|
558
|
+
const dispose = () => {
|
|
559
|
+
removeListener4Five();
|
|
560
|
+
pluginState.container.remove();
|
|
561
|
+
};
|
|
562
|
+
const handleRerender = () => {
|
|
563
|
+
if (!pluginState.enabled || !pluginState.fiveModeEnabled)
|
|
564
|
+
return;
|
|
565
|
+
disable();
|
|
566
|
+
};
|
|
567
|
+
const rerender = (a, b, c) => {
|
|
568
|
+
if (!pluginState.fiveModeEnabled)
|
|
569
|
+
return;
|
|
570
|
+
if (!c)
|
|
571
|
+
return;
|
|
572
|
+
enable();
|
|
573
|
+
render();
|
|
574
|
+
};
|
|
575
|
+
const handleInteriaPanRerender = (a, b) => {
|
|
576
|
+
if (!pluginState.fiveModeEnabled)
|
|
577
|
+
return;
|
|
578
|
+
if (!b)
|
|
579
|
+
return;
|
|
580
|
+
enable();
|
|
581
|
+
render();
|
|
582
|
+
};
|
|
583
|
+
const handleWantsPanGesture = (pose, final) => {
|
|
584
|
+
if (pose) {
|
|
585
|
+
handleRerender();
|
|
586
|
+
}
|
|
587
|
+
};
|
|
588
|
+
const handlePanGesture = (pose, final) => {
|
|
589
|
+
if (!pluginState.fiveModeEnabled)
|
|
590
|
+
return;
|
|
591
|
+
if (!final)
|
|
592
|
+
return;
|
|
593
|
+
enable();
|
|
594
|
+
render();
|
|
595
|
+
};
|
|
596
|
+
const render = () => {
|
|
597
|
+
if (!pluginState.wrapper)
|
|
598
|
+
return;
|
|
599
|
+
// 只要不可展示,销毁容器
|
|
600
|
+
if (!pluginState.enabled || !pluginState.fiveModeEnabled) {
|
|
601
|
+
pluginState.app?.$destroy();
|
|
602
|
+
pluginState.app = undefined;
|
|
603
|
+
return;
|
|
604
|
+
}
|
|
605
|
+
// 正常显示时,分为 app 存在和不存在两种情况,如果存在,传值,不存在则初始化并传值
|
|
606
|
+
if (!pluginState.app) {
|
|
607
|
+
pluginState.app = new ItemLabelComponent({
|
|
608
|
+
target: pluginState.container,
|
|
609
|
+
props: {
|
|
610
|
+
five: five$1,
|
|
611
|
+
modelOcclusionEnable: pluginState.modelOcclusionEnable,
|
|
612
|
+
itemLabels: pluginState.itemLabels,
|
|
613
|
+
wrapper: pluginState.wrapper,
|
|
614
|
+
hooks: pluginState.hooks,
|
|
615
|
+
displayStrategyType: pluginState.displayStrategyType
|
|
616
|
+
}
|
|
617
|
+
});
|
|
618
|
+
}
|
|
619
|
+
else {
|
|
620
|
+
pluginState.app.$set({
|
|
621
|
+
five: five$1,
|
|
622
|
+
itemLabels: pluginState.itemLabels
|
|
623
|
+
});
|
|
624
|
+
}
|
|
625
|
+
};
|
|
626
|
+
// 添加 five 监听
|
|
627
|
+
const addListener4Five = () => {
|
|
628
|
+
five$1.on('modeChange', onFiveModeChange);
|
|
629
|
+
five$1.once('dispose', dispose);
|
|
630
|
+
// five.on('wantsGesture', handleRerender)
|
|
631
|
+
// five.on('gesture', rerender)
|
|
632
|
+
five$1.on('wantsMouseWheel', handleRerender);
|
|
633
|
+
five$1.on('mouseWheel', rerender);
|
|
634
|
+
five$1.on('wantsInteriaPan', handleRerender);
|
|
635
|
+
five$1.on('interiaPan', handleInteriaPanRerender);
|
|
636
|
+
five$1.on('wantsPanGesture', handleWantsPanGesture);
|
|
637
|
+
five$1.on('panGesture', handlePanGesture);
|
|
638
|
+
five$1.on('wantsPinchGesture', handleRerender);
|
|
639
|
+
five$1.on('pinchGesture', rerender);
|
|
640
|
+
};
|
|
641
|
+
// 取消 five 监听
|
|
642
|
+
const removeListener4Five = () => {
|
|
643
|
+
five$1.off('modeChange', onFiveModeChange);
|
|
644
|
+
// five.off('wantsGesture', handleRerender)
|
|
645
|
+
// five.off('gesture', rerender)
|
|
646
|
+
five$1.off('wantsMouseWheel', handleRerender);
|
|
647
|
+
five$1.off('mouseWheel', rerender);
|
|
648
|
+
five$1.off('wantsInteriaPan', handleRerender);
|
|
649
|
+
five$1.off('interiaPan', handleInteriaPanRerender);
|
|
650
|
+
five$1.off('wantsPanGesture', handleWantsPanGesture);
|
|
651
|
+
five$1.off('panGesture', handlePanGesture);
|
|
652
|
+
five$1.off('wantsPinchGesture', handleRerender);
|
|
653
|
+
five$1.off('pinchGesture', rerender);
|
|
654
|
+
};
|
|
655
|
+
const onFiveModeChange = (mode) => {
|
|
656
|
+
if (mode !== five.Five.Mode.Floorplan) {
|
|
657
|
+
pluginState.fiveModeEnabled = false;
|
|
658
|
+
render();
|
|
659
|
+
return;
|
|
660
|
+
}
|
|
661
|
+
five$1.once('initAnimationEnded', () => {
|
|
662
|
+
pluginState.fiveModeEnabled = five$1.currentMode === five.Five.Mode.Floorplan;
|
|
663
|
+
render();
|
|
664
|
+
});
|
|
665
|
+
};
|
|
666
|
+
addListener4Five();
|
|
667
|
+
return {
|
|
668
|
+
appendTo,
|
|
669
|
+
load,
|
|
670
|
+
enable,
|
|
671
|
+
disable,
|
|
672
|
+
dispose,
|
|
673
|
+
hooks: pluginState.hooks
|
|
674
|
+
};
|
|
675
|
+
};
|
|
676
|
+
|
|
677
|
+
exports.ModelItemLabelPlugin = ModelItemLabelPlugin;
|
|
678
|
+
exports["default"] = ModelItemLabelPlugin;
|