@realsee/dnalogel 2.0.0-alpha.26-beta → 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 +4 -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
package/dist/index.js
CHANGED
|
@@ -589,17 +589,19 @@ class RoomLabelItem extends internal.SvelteComponent {
|
|
|
589
589
|
|
|
590
590
|
/* src/ModelRoomLabelPlugin/RoomLabelItems.svelte generated by Svelte v3.47.0 */
|
|
591
591
|
|
|
592
|
+
const { Map: Map_1 } = internal.globals;
|
|
593
|
+
|
|
592
594
|
function add_css$l(target) {
|
|
593
595
|
internal.append_styles(target, "svelte-9eg4zi", ".room-labels-container.svelte-9eg4zi{width:100%;height:100%;position:relative;color:#fff}");
|
|
594
596
|
}
|
|
595
597
|
|
|
596
598
|
function get_each_context$9(ctx, list, i) {
|
|
597
599
|
const child_ctx = ctx.slice();
|
|
598
|
-
child_ctx[
|
|
600
|
+
child_ctx[12] = list[i];
|
|
599
601
|
return child_ctx;
|
|
600
602
|
}
|
|
601
603
|
|
|
602
|
-
// (
|
|
604
|
+
// (82:2) {#each roomLabels as roomLableItem (roomLableItem.id)}
|
|
603
605
|
function create_each_block$9(key_1, ctx) {
|
|
604
606
|
let first;
|
|
605
607
|
let roomlabelitem;
|
|
@@ -607,7 +609,7 @@ function create_each_block$9(key_1, ctx) {
|
|
|
607
609
|
|
|
608
610
|
roomlabelitem = new RoomLabelItem({
|
|
609
611
|
props: {
|
|
610
|
-
roomLabel: /*roomLableItem*/ ctx[
|
|
612
|
+
roomLabel: /*roomLableItem*/ ctx[12],
|
|
611
613
|
five: /*five*/ ctx[1]
|
|
612
614
|
}
|
|
613
615
|
});
|
|
@@ -628,7 +630,7 @@ function create_each_block$9(key_1, ctx) {
|
|
|
628
630
|
p(new_ctx, dirty) {
|
|
629
631
|
ctx = new_ctx;
|
|
630
632
|
const roomlabelitem_changes = {};
|
|
631
|
-
if (dirty & /*roomLabels*/ 1) roomlabelitem_changes.roomLabel = /*roomLableItem*/ ctx[
|
|
633
|
+
if (dirty & /*roomLabels*/ 1) roomlabelitem_changes.roomLabel = /*roomLableItem*/ ctx[12];
|
|
632
634
|
if (dirty & /*five*/ 2) roomlabelitem_changes.five = /*five*/ ctx[1];
|
|
633
635
|
roomlabelitem.$set(roomlabelitem_changes);
|
|
634
636
|
},
|
|
@@ -651,11 +653,11 @@ function create_each_block$9(key_1, ctx) {
|
|
|
651
653
|
function create_fragment$p(ctx) {
|
|
652
654
|
let div;
|
|
653
655
|
let each_blocks = [];
|
|
654
|
-
let each_1_lookup = new
|
|
656
|
+
let each_1_lookup = new Map_1();
|
|
655
657
|
let div_resize_listener;
|
|
656
658
|
let current;
|
|
657
659
|
let each_value = /*roomLabels*/ ctx[0];
|
|
658
|
-
const get_key = ctx => /*roomLableItem*/ ctx[
|
|
660
|
+
const get_key = ctx => /*roomLableItem*/ ctx[12].id;
|
|
659
661
|
|
|
660
662
|
for (let i = 0; i < each_value.length; i += 1) {
|
|
661
663
|
let child_ctx = get_each_context$9(ctx, each_value, i);
|
|
@@ -672,7 +674,7 @@ function create_fragment$p(ctx) {
|
|
|
672
674
|
}
|
|
673
675
|
|
|
674
676
|
internal.attr(div, "class", "room-labels-container svelte-9eg4zi");
|
|
675
|
-
internal.add_render_callback(() => /*div_elementresize_handler*/ ctx[
|
|
677
|
+
internal.add_render_callback(() => /*div_elementresize_handler*/ ctx[6].call(div));
|
|
676
678
|
},
|
|
677
679
|
m(target, anchor) {
|
|
678
680
|
internal.insert(target, div, anchor);
|
|
@@ -681,7 +683,7 @@ function create_fragment$p(ctx) {
|
|
|
681
683
|
each_blocks[i].m(div, null);
|
|
682
684
|
}
|
|
683
685
|
|
|
684
|
-
div_resize_listener = internal.add_resize_listener(div, /*div_elementresize_handler*/ ctx[
|
|
686
|
+
div_resize_listener = internal.add_resize_listener(div, /*div_elementresize_handler*/ ctx[6].bind(div));
|
|
685
687
|
current = true;
|
|
686
688
|
},
|
|
687
689
|
p(ctx, [dirty]) {
|
|
@@ -721,22 +723,17 @@ function create_fragment$p(ctx) {
|
|
|
721
723
|
}
|
|
722
724
|
|
|
723
725
|
function instance$p($$self, $$props, $$invalidate) {
|
|
726
|
+
let rendererSize;
|
|
724
727
|
let { five } = $$props;
|
|
725
728
|
let { roomLabels } = $$props;
|
|
726
729
|
let containerWidth;
|
|
727
730
|
let containerHeight;
|
|
731
|
+
let shownFloor = null;
|
|
728
732
|
|
|
729
|
-
function getLabelVisible(
|
|
730
|
-
// 先看是不是在当前展示的楼层上
|
|
731
|
-
const isLabelInFloor = five.model.shownFloor === null || roomLabelItem.floorIndex === five.model.shownFloor;
|
|
732
|
-
|
|
733
|
-
if (!isLabelInFloor) return false;
|
|
734
|
-
|
|
735
|
-
// 再看是不是被模型遮挡
|
|
733
|
+
function getLabelVisible(item) {
|
|
736
734
|
const raycaster = new THREE.Raycaster();
|
|
737
|
-
|
|
738
735
|
const cameraPosition = five.camera.position.clone();
|
|
739
|
-
const position = new THREE.Vector3(
|
|
736
|
+
const position = new THREE.Vector3(item.position.x, item.position.y, item.position.z);
|
|
740
737
|
const vectorDistance = position.distanceTo(cameraPosition);
|
|
741
738
|
raycaster.set(cameraPosition.clone(), position.clone().sub(cameraPosition).normalize());
|
|
742
739
|
const [intersection] = five.model.intersectRaycaster(raycaster);
|
|
@@ -744,53 +741,60 @@ function instance$p($$self, $$props, $$invalidate) {
|
|
|
744
741
|
return true;
|
|
745
742
|
}
|
|
746
743
|
|
|
747
|
-
function getLabelTransform(
|
|
748
|
-
const position = new THREE.Vector3(
|
|
744
|
+
function getLabelTransform(item, rendererSize) {
|
|
745
|
+
const position = new THREE.Vector3(item.position.x, item.position.y, item.position.z);
|
|
749
746
|
const mouse = position.clone().project(five.camera);
|
|
750
|
-
const xOffset = Math.ceil((mouse.x + 1) / 2 *
|
|
751
|
-
const yOffset = Math.ceil((-mouse.y + 1) / 2 *
|
|
747
|
+
const xOffset = Math.ceil((mouse.x + 1) / 2 * rendererSize.x);
|
|
748
|
+
const yOffset = Math.ceil((-mouse.y + 1) / 2 * rendererSize.y);
|
|
752
749
|
return `translate(${xOffset}px, ${yOffset}px)`;
|
|
753
750
|
}
|
|
754
751
|
|
|
755
|
-
function getFormatedRoomLabels(
|
|
756
|
-
|
|
757
|
-
|
|
758
|
-
|
|
752
|
+
function getFormatedRoomLabels(rendererSize) {
|
|
753
|
+
// 因为 item distance 需要重复计算,所以缓存一下
|
|
754
|
+
const distanceMap = new Map();
|
|
755
|
+
|
|
756
|
+
function getItemDistance(item) {
|
|
757
|
+
const cacheDistance = distanceMap.get(item.id);
|
|
758
|
+
if (cacheDistance) return cacheDistance;
|
|
759
|
+
const { x, y, z } = item.position;
|
|
760
|
+
const distance = new THREE.Vector3(x, y, z).clone().distanceTo(five.camera.position);
|
|
761
|
+
distanceMap.set(item.id, distance);
|
|
762
|
+
return distance;
|
|
763
|
+
}
|
|
759
764
|
|
|
760
|
-
|
|
765
|
+
const formatedItems = roomLabels.map(item => {
|
|
766
|
+
const visible = getLabelVisible(item);
|
|
761
767
|
|
|
762
|
-
|
|
763
|
-
|
|
768
|
+
const transform = visible
|
|
769
|
+
? getLabelTransform(item, rendererSize)
|
|
770
|
+
: item.transform;
|
|
764
771
|
|
|
765
|
-
|
|
766
|
-
});
|
|
772
|
+
const itemDistance = getItemDistance(item);
|
|
767
773
|
|
|
768
|
-
|
|
769
|
-
|
|
770
|
-
distance: new THREE.Vector3(...Object.values(roomLabelItem.position)).clone().distanceTo(five.camera.position)
|
|
771
|
-
})).sort((a, b) => a.distance - b.distance);
|
|
774
|
+
// visible === true 的 item 中,distance 比自己小的 item 个数
|
|
775
|
+
const minItemLen = roomLabels.filter(item => item.visible && getItemDistance(item) < itemDistance).length;
|
|
772
776
|
|
|
773
|
-
|
|
774
|
-
|
|
775
|
-
if (sortIndex !== undefined) return Object.assign(Object.assign({}, roomLabelItem), { zIndex: sortIndex * 10 });
|
|
776
|
-
return roomLabelItem;
|
|
777
|
+
const zIndex = minItemLen * 10;
|
|
778
|
+
return Object.assign(Object.assign({}, item), { visible, transform, zIndex });
|
|
777
779
|
});
|
|
780
|
+
|
|
781
|
+
return formatedItems;
|
|
778
782
|
}
|
|
779
783
|
|
|
780
784
|
function onFiveCameraUpdate() {
|
|
781
|
-
$$invalidate(0, roomLabels = getFormatedRoomLabels(
|
|
785
|
+
$$invalidate(0, roomLabels = getFormatedRoomLabels(rendererSize));
|
|
786
|
+
}
|
|
787
|
+
|
|
788
|
+
function onFiveModelShownFloorChange(floorIndex) {
|
|
789
|
+
$$invalidate(4, shownFloor = floorIndex);
|
|
782
790
|
}
|
|
783
791
|
|
|
784
792
|
five.on('cameraUpdate', onFiveCameraUpdate);
|
|
785
|
-
five.on('modelShownFloorChange',
|
|
793
|
+
five.on('modelShownFloorChange', onFiveModelShownFloorChange);
|
|
786
794
|
|
|
787
795
|
svelte.onDestroy(() => {
|
|
788
796
|
five.off('cameraUpdate', onFiveCameraUpdate);
|
|
789
|
-
five.off('modelShownFloorChange',
|
|
790
|
-
});
|
|
791
|
-
|
|
792
|
-
svelte.onMount(() => {
|
|
793
|
-
onFiveCameraUpdate();
|
|
797
|
+
five.off('modelShownFloorChange', onFiveModelShownFloorChange);
|
|
794
798
|
});
|
|
795
799
|
|
|
796
800
|
function div_elementresize_handler() {
|
|
@@ -805,7 +809,39 @@ function instance$p($$self, $$props, $$invalidate) {
|
|
|
805
809
|
if ('roomLabels' in $$props) $$invalidate(0, roomLabels = $$props.roomLabels);
|
|
806
810
|
};
|
|
807
811
|
|
|
808
|
-
|
|
812
|
+
$$self.$$.update = () => {
|
|
813
|
+
if ($$self.$$.dirty & /*containerWidth, containerHeight*/ 12) {
|
|
814
|
+
$$invalidate(5, rendererSize = { x: containerWidth, y: containerHeight });
|
|
815
|
+
}
|
|
816
|
+
|
|
817
|
+
if ($$self.$$.dirty & /*rendererSize*/ 32) {
|
|
818
|
+
{
|
|
819
|
+
// rendererSize 变化时,触发 reRender
|
|
820
|
+
$$invalidate(0, roomLabels = getFormatedRoomLabels(rendererSize));
|
|
821
|
+
}
|
|
822
|
+
}
|
|
823
|
+
|
|
824
|
+
if ($$self.$$.dirty & /*roomLabels, shownFloor*/ 17) {
|
|
825
|
+
{
|
|
826
|
+
// shownFloor 变化时,更新 item visible
|
|
827
|
+
$$invalidate(0, roomLabels = roomLabels.map(item => {
|
|
828
|
+
const isLabelInFloor = shownFloor === null || item.floorIndex === shownFloor;
|
|
829
|
+
const visible = isLabelInFloor ? item.visible : false;
|
|
830
|
+
return Object.assign(Object.assign({}, item), { visible });
|
|
831
|
+
}));
|
|
832
|
+
}
|
|
833
|
+
}
|
|
834
|
+
};
|
|
835
|
+
|
|
836
|
+
return [
|
|
837
|
+
roomLabels,
|
|
838
|
+
five,
|
|
839
|
+
containerWidth,
|
|
840
|
+
containerHeight,
|
|
841
|
+
shownFloor,
|
|
842
|
+
rendererSize,
|
|
843
|
+
div_elementresize_handler
|
|
844
|
+
];
|
|
809
845
|
}
|
|
810
846
|
|
|
811
847
|
class RoomLabelItems extends internal.SvelteComponent {
|
|
@@ -14410,7 +14446,7 @@ function get_each_context(ctx, list, i) {
|
|
|
14410
14446
|
return child_ctx;
|
|
14411
14447
|
}
|
|
14412
14448
|
|
|
14413
|
-
// (
|
|
14449
|
+
// (163:1) {#each renderItemLabels as itemLabelItem (itemLabelItem.id)}
|
|
14414
14450
|
function create_each_block(key_1, ctx) {
|
|
14415
14451
|
let first;
|
|
14416
14452
|
let itemlabelitem;
|
package/dist/index.umd.js
CHANGED
|
@@ -578,17 +578,19 @@
|
|
|
578
578
|
|
|
579
579
|
/* src/ModelRoomLabelPlugin/RoomLabelItems.svelte generated by Svelte v3.47.0 */
|
|
580
580
|
|
|
581
|
+
const { Map: Map_1 } = internal.globals;
|
|
582
|
+
|
|
581
583
|
function add_css$l(target) {
|
|
582
584
|
internal.append_styles(target, "svelte-9eg4zi", ".room-labels-container.svelte-9eg4zi{width:100%;height:100%;position:relative;color:#fff}");
|
|
583
585
|
}
|
|
584
586
|
|
|
585
587
|
function get_each_context$9(ctx, list, i) {
|
|
586
588
|
const child_ctx = ctx.slice();
|
|
587
|
-
child_ctx[
|
|
589
|
+
child_ctx[12] = list[i];
|
|
588
590
|
return child_ctx;
|
|
589
591
|
}
|
|
590
592
|
|
|
591
|
-
// (
|
|
593
|
+
// (82:2) {#each roomLabels as roomLableItem (roomLableItem.id)}
|
|
592
594
|
function create_each_block$9(key_1, ctx) {
|
|
593
595
|
let first;
|
|
594
596
|
let roomlabelitem;
|
|
@@ -596,7 +598,7 @@
|
|
|
596
598
|
|
|
597
599
|
roomlabelitem = new RoomLabelItem({
|
|
598
600
|
props: {
|
|
599
|
-
roomLabel: /*roomLableItem*/ ctx[
|
|
601
|
+
roomLabel: /*roomLableItem*/ ctx[12],
|
|
600
602
|
five: /*five*/ ctx[1]
|
|
601
603
|
}
|
|
602
604
|
});
|
|
@@ -617,7 +619,7 @@
|
|
|
617
619
|
p(new_ctx, dirty) {
|
|
618
620
|
ctx = new_ctx;
|
|
619
621
|
const roomlabelitem_changes = {};
|
|
620
|
-
if (dirty & /*roomLabels*/ 1) roomlabelitem_changes.roomLabel = /*roomLableItem*/ ctx[
|
|
622
|
+
if (dirty & /*roomLabels*/ 1) roomlabelitem_changes.roomLabel = /*roomLableItem*/ ctx[12];
|
|
621
623
|
if (dirty & /*five*/ 2) roomlabelitem_changes.five = /*five*/ ctx[1];
|
|
622
624
|
roomlabelitem.$set(roomlabelitem_changes);
|
|
623
625
|
},
|
|
@@ -640,11 +642,11 @@
|
|
|
640
642
|
function create_fragment$p(ctx) {
|
|
641
643
|
let div;
|
|
642
644
|
let each_blocks = [];
|
|
643
|
-
let each_1_lookup = new
|
|
645
|
+
let each_1_lookup = new Map_1();
|
|
644
646
|
let div_resize_listener;
|
|
645
647
|
let current;
|
|
646
648
|
let each_value = /*roomLabels*/ ctx[0];
|
|
647
|
-
const get_key = ctx => /*roomLableItem*/ ctx[
|
|
649
|
+
const get_key = ctx => /*roomLableItem*/ ctx[12].id;
|
|
648
650
|
|
|
649
651
|
for (let i = 0; i < each_value.length; i += 1) {
|
|
650
652
|
let child_ctx = get_each_context$9(ctx, each_value, i);
|
|
@@ -661,7 +663,7 @@
|
|
|
661
663
|
}
|
|
662
664
|
|
|
663
665
|
internal.attr(div, "class", "room-labels-container svelte-9eg4zi");
|
|
664
|
-
internal.add_render_callback(() => /*div_elementresize_handler*/ ctx[
|
|
666
|
+
internal.add_render_callback(() => /*div_elementresize_handler*/ ctx[6].call(div));
|
|
665
667
|
},
|
|
666
668
|
m(target, anchor) {
|
|
667
669
|
internal.insert(target, div, anchor);
|
|
@@ -670,7 +672,7 @@
|
|
|
670
672
|
each_blocks[i].m(div, null);
|
|
671
673
|
}
|
|
672
674
|
|
|
673
|
-
div_resize_listener = internal.add_resize_listener(div, /*div_elementresize_handler*/ ctx[
|
|
675
|
+
div_resize_listener = internal.add_resize_listener(div, /*div_elementresize_handler*/ ctx[6].bind(div));
|
|
674
676
|
current = true;
|
|
675
677
|
},
|
|
676
678
|
p(ctx, [dirty]) {
|
|
@@ -710,22 +712,17 @@
|
|
|
710
712
|
}
|
|
711
713
|
|
|
712
714
|
function instance$p($$self, $$props, $$invalidate) {
|
|
715
|
+
let rendererSize;
|
|
713
716
|
let { five } = $$props;
|
|
714
717
|
let { roomLabels } = $$props;
|
|
715
718
|
let containerWidth;
|
|
716
719
|
let containerHeight;
|
|
720
|
+
let shownFloor = null;
|
|
717
721
|
|
|
718
|
-
function getLabelVisible(
|
|
719
|
-
// 先看是不是在当前展示的楼层上
|
|
720
|
-
const isLabelInFloor = five.model.shownFloor === null || roomLabelItem.floorIndex === five.model.shownFloor;
|
|
721
|
-
|
|
722
|
-
if (!isLabelInFloor) return false;
|
|
723
|
-
|
|
724
|
-
// 再看是不是被模型遮挡
|
|
722
|
+
function getLabelVisible(item) {
|
|
725
723
|
const raycaster = new THREE.Raycaster();
|
|
726
|
-
|
|
727
724
|
const cameraPosition = five.camera.position.clone();
|
|
728
|
-
const position = new THREE.Vector3(
|
|
725
|
+
const position = new THREE.Vector3(item.position.x, item.position.y, item.position.z);
|
|
729
726
|
const vectorDistance = position.distanceTo(cameraPosition);
|
|
730
727
|
raycaster.set(cameraPosition.clone(), position.clone().sub(cameraPosition).normalize());
|
|
731
728
|
const [intersection] = five.model.intersectRaycaster(raycaster);
|
|
@@ -733,53 +730,60 @@
|
|
|
733
730
|
return true;
|
|
734
731
|
}
|
|
735
732
|
|
|
736
|
-
function getLabelTransform(
|
|
737
|
-
const position = new THREE.Vector3(
|
|
733
|
+
function getLabelTransform(item, rendererSize) {
|
|
734
|
+
const position = new THREE.Vector3(item.position.x, item.position.y, item.position.z);
|
|
738
735
|
const mouse = position.clone().project(five.camera);
|
|
739
|
-
const xOffset = Math.ceil((mouse.x + 1) / 2 *
|
|
740
|
-
const yOffset = Math.ceil((-mouse.y + 1) / 2 *
|
|
736
|
+
const xOffset = Math.ceil((mouse.x + 1) / 2 * rendererSize.x);
|
|
737
|
+
const yOffset = Math.ceil((-mouse.y + 1) / 2 * rendererSize.y);
|
|
741
738
|
return `translate(${xOffset}px, ${yOffset}px)`;
|
|
742
739
|
}
|
|
743
740
|
|
|
744
|
-
function getFormatedRoomLabels(
|
|
745
|
-
|
|
746
|
-
|
|
747
|
-
|
|
741
|
+
function getFormatedRoomLabels(rendererSize) {
|
|
742
|
+
// 因为 item distance 需要重复计算,所以缓存一下
|
|
743
|
+
const distanceMap = new Map();
|
|
744
|
+
|
|
745
|
+
function getItemDistance(item) {
|
|
746
|
+
const cacheDistance = distanceMap.get(item.id);
|
|
747
|
+
if (cacheDistance) return cacheDistance;
|
|
748
|
+
const { x, y, z } = item.position;
|
|
749
|
+
const distance = new THREE.Vector3(x, y, z).clone().distanceTo(five.camera.position);
|
|
750
|
+
distanceMap.set(item.id, distance);
|
|
751
|
+
return distance;
|
|
752
|
+
}
|
|
748
753
|
|
|
749
|
-
|
|
754
|
+
const formatedItems = roomLabels.map(item => {
|
|
755
|
+
const visible = getLabelVisible(item);
|
|
750
756
|
|
|
751
|
-
|
|
752
|
-
|
|
757
|
+
const transform = visible
|
|
758
|
+
? getLabelTransform(item, rendererSize)
|
|
759
|
+
: item.transform;
|
|
753
760
|
|
|
754
|
-
|
|
755
|
-
});
|
|
761
|
+
const itemDistance = getItemDistance(item);
|
|
756
762
|
|
|
757
|
-
|
|
758
|
-
|
|
759
|
-
distance: new THREE.Vector3(...Object.values(roomLabelItem.position)).clone().distanceTo(five.camera.position)
|
|
760
|
-
})).sort((a, b) => a.distance - b.distance);
|
|
763
|
+
// visible === true 的 item 中,distance 比自己小的 item 个数
|
|
764
|
+
const minItemLen = roomLabels.filter(item => item.visible && getItemDistance(item) < itemDistance).length;
|
|
761
765
|
|
|
762
|
-
|
|
763
|
-
|
|
764
|
-
if (sortIndex !== undefined) return Object.assign(Object.assign({}, roomLabelItem), { zIndex: sortIndex * 10 });
|
|
765
|
-
return roomLabelItem;
|
|
766
|
+
const zIndex = minItemLen * 10;
|
|
767
|
+
return Object.assign(Object.assign({}, item), { visible, transform, zIndex });
|
|
766
768
|
});
|
|
769
|
+
|
|
770
|
+
return formatedItems;
|
|
767
771
|
}
|
|
768
772
|
|
|
769
773
|
function onFiveCameraUpdate() {
|
|
770
|
-
$$invalidate(0, roomLabels = getFormatedRoomLabels(
|
|
774
|
+
$$invalidate(0, roomLabels = getFormatedRoomLabels(rendererSize));
|
|
775
|
+
}
|
|
776
|
+
|
|
777
|
+
function onFiveModelShownFloorChange(floorIndex) {
|
|
778
|
+
$$invalidate(4, shownFloor = floorIndex);
|
|
771
779
|
}
|
|
772
780
|
|
|
773
781
|
five.on('cameraUpdate', onFiveCameraUpdate);
|
|
774
|
-
five.on('modelShownFloorChange',
|
|
782
|
+
five.on('modelShownFloorChange', onFiveModelShownFloorChange);
|
|
775
783
|
|
|
776
784
|
svelte.onDestroy(() => {
|
|
777
785
|
five.off('cameraUpdate', onFiveCameraUpdate);
|
|
778
|
-
five.off('modelShownFloorChange',
|
|
779
|
-
});
|
|
780
|
-
|
|
781
|
-
svelte.onMount(() => {
|
|
782
|
-
onFiveCameraUpdate();
|
|
786
|
+
five.off('modelShownFloorChange', onFiveModelShownFloorChange);
|
|
783
787
|
});
|
|
784
788
|
|
|
785
789
|
function div_elementresize_handler() {
|
|
@@ -794,7 +798,39 @@
|
|
|
794
798
|
if ('roomLabels' in $$props) $$invalidate(0, roomLabels = $$props.roomLabels);
|
|
795
799
|
};
|
|
796
800
|
|
|
797
|
-
|
|
801
|
+
$$self.$$.update = () => {
|
|
802
|
+
if ($$self.$$.dirty & /*containerWidth, containerHeight*/ 12) {
|
|
803
|
+
$$invalidate(5, rendererSize = { x: containerWidth, y: containerHeight });
|
|
804
|
+
}
|
|
805
|
+
|
|
806
|
+
if ($$self.$$.dirty & /*rendererSize*/ 32) {
|
|
807
|
+
{
|
|
808
|
+
// rendererSize 变化时,触发 reRender
|
|
809
|
+
$$invalidate(0, roomLabels = getFormatedRoomLabels(rendererSize));
|
|
810
|
+
}
|
|
811
|
+
}
|
|
812
|
+
|
|
813
|
+
if ($$self.$$.dirty & /*roomLabels, shownFloor*/ 17) {
|
|
814
|
+
{
|
|
815
|
+
// shownFloor 变化时,更新 item visible
|
|
816
|
+
$$invalidate(0, roomLabels = roomLabels.map(item => {
|
|
817
|
+
const isLabelInFloor = shownFloor === null || item.floorIndex === shownFloor;
|
|
818
|
+
const visible = isLabelInFloor ? item.visible : false;
|
|
819
|
+
return Object.assign(Object.assign({}, item), { visible });
|
|
820
|
+
}));
|
|
821
|
+
}
|
|
822
|
+
}
|
|
823
|
+
};
|
|
824
|
+
|
|
825
|
+
return [
|
|
826
|
+
roomLabels,
|
|
827
|
+
five,
|
|
828
|
+
containerWidth,
|
|
829
|
+
containerHeight,
|
|
830
|
+
shownFloor,
|
|
831
|
+
rendererSize,
|
|
832
|
+
div_elementresize_handler
|
|
833
|
+
];
|
|
798
834
|
}
|
|
799
835
|
|
|
800
836
|
class RoomLabelItems extends internal.SvelteComponent {
|
|
@@ -14399,7 +14435,7 @@
|
|
|
14399
14435
|
return child_ctx;
|
|
14400
14436
|
}
|
|
14401
14437
|
|
|
14402
|
-
// (
|
|
14438
|
+
// (163:1) {#each renderItemLabels as itemLabelItem (itemLabelItem.id)}
|
|
14403
14439
|
function create_each_block(key_1, ctx) {
|
|
14404
14440
|
let first;
|
|
14405
14441
|
let itemlabelitem;
|