@realsee/dnalogel 2.0.0-alpha.13 → 2.0.0-alpha.16
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 +56 -0
- package/README.md +78 -28
- package/dist/ModelItemLabelPlugin/index.js +72 -83
- package/dist/ModelItemLabelPlugin/typings.d.ts +2 -1
- package/dist/ModelRoomLabelPlugin/index.js +1 -0
- package/dist/ModelTVVideoPlugin/index.d.ts +4 -0
- package/dist/ModelTVVideoPlugin/index.js +326 -0
- package/dist/ModelTVVideoPlugin/typings.d.ts +25 -0
- package/dist/ModelTVVideoPlugin/utils/parseData.d.ts +2 -0
- package/dist/PanoMeasurePlugin/index.js +2 -2
- package/dist/index.d.ts +3 -0
- package/dist/index.es.js +349 -86
- package/dist/index.js +349 -85
- package/dist/index.umd.js +349 -85
- package/docs/assets/main.js +1 -1
- 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 +78 -33
- 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 -0
- package/docs/interfaces/ModelItemLabelPluginExportReturnsType.html +1 -0
- package/docs/interfaces/ModelItemLabelPluginParametersType.html +1 -0
- package/docs/interfaces/ModelRoomLabelPluginData.html +1 -1
- package/docs/interfaces/ModelTVVideoPluginData.html +1 -0
- package/docs/interfaces/ModelTVVideoPluginExportType.html +1 -0
- package/docs/interfaces/ModelTVVideoPluginParameterType.html +1 -0
- 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 +48 -61
- package/libs/ModelItemLabelPlugin/index.js +5 -57
- package/libs/ModelItemLabelPlugin/typings.d.ts +2 -1
- package/libs/ModelItemLabelPlugin/typings.js +1 -0
- package/libs/ModelRoomLabelPlugin/Controller.js +1 -0
- package/libs/ModelTVVideoPlugin/index.d.ts +4 -0
- package/libs/ModelTVVideoPlugin/index.js +263 -0
- package/libs/ModelTVVideoPlugin/typings.d.ts +25 -0
- package/libs/ModelTVVideoPlugin/typings.js +7 -0
- package/libs/ModelTVVideoPlugin/utils/parseData.d.ts +2 -0
- package/libs/ModelTVVideoPlugin/utils/parseData.js +13 -0
- package/libs/index.d.ts +3 -0
- package/libs/index.js +1 -1
- package/package.json +2 -1
package/dist/index.js
CHANGED
|
@@ -919,6 +919,7 @@ class ModelRoomLabelController {
|
|
|
919
919
|
this.container.style.pointerEvents = 'none';
|
|
920
920
|
this.container.style.left = '0';
|
|
921
921
|
this.container.style.top = '0';
|
|
922
|
+
this.container.style.zIndex = '5';
|
|
922
923
|
// five listener
|
|
923
924
|
this.five.once('dispose', () => this.dispose());
|
|
924
925
|
this.five.on('modeChange', this.onFiveModeChange);
|
|
@@ -10660,10 +10661,10 @@ if (typeof undefined$1 === 'function' && undefined$1.amd) {
|
|
|
10660
10661
|
|
|
10661
10662
|
var Hammer = hammer.exports;
|
|
10662
10663
|
|
|
10663
|
-
var Hammer$1 = /*#__PURE__*/_mergeNamespaces({
|
|
10664
|
+
var Hammer$1 = /*#__PURE__*/Object.freeze(/*#__PURE__*/_mergeNamespaces({
|
|
10664
10665
|
__proto__: null,
|
|
10665
10666
|
'default': Hammer
|
|
10666
|
-
}, [hammer.exports]);
|
|
10667
|
+
}, [hammer.exports]));
|
|
10667
10668
|
|
|
10668
10669
|
// uuid
|
|
10669
10670
|
function S4() {
|
|
@@ -14279,6 +14280,7 @@ var DISPLAY_STRATEGY_TYPE;
|
|
|
14279
14280
|
DISPLAY_STRATEGY_TYPE["SMALL"] = "small";
|
|
14280
14281
|
DISPLAY_STRATEGY_TYPE["MIDLLE"] = "middle";
|
|
14281
14282
|
DISPLAY_STRATEGY_TYPE["LARGE"] = "large";
|
|
14283
|
+
DISPLAY_STRATEGY_TYPE["EXTRA_LARGE"] = "x-large";
|
|
14282
14284
|
})(DISPLAY_STRATEGY_TYPE || (DISPLAY_STRATEGY_TYPE = {}));
|
|
14283
14285
|
|
|
14284
14286
|
/* src/ModelItemLabelPlugin/ItemLabelItem.svelte generated by Svelte v3.47.0 */
|
|
@@ -14392,6 +14394,21 @@ class ItemLabelItem extends internal.SvelteComponent {
|
|
|
14392
14394
|
}
|
|
14393
14395
|
}
|
|
14394
14396
|
|
|
14397
|
+
/**
|
|
14398
|
+
* 创建一个防抖动函数,该函数会在 wait 毫秒后调用 func 方法
|
|
14399
|
+
* @param func - 要防抖动的函数
|
|
14400
|
+
* @param [wait=0] - 需要延迟的毫秒数
|
|
14401
|
+
*/
|
|
14402
|
+
function debounce(func, wait = 200) {
|
|
14403
|
+
let last;
|
|
14404
|
+
return function (...args) {
|
|
14405
|
+
clearTimeout(last);
|
|
14406
|
+
last = setTimeout(() => {
|
|
14407
|
+
func(...args);
|
|
14408
|
+
}, wait);
|
|
14409
|
+
};
|
|
14410
|
+
}
|
|
14411
|
+
|
|
14395
14412
|
/* src/ModelItemLabelPlugin/ItemLabelComponent.svelte generated by Svelte v3.47.0 */
|
|
14396
14413
|
|
|
14397
14414
|
function add_css(target) {
|
|
@@ -14400,11 +14417,11 @@ function add_css(target) {
|
|
|
14400
14417
|
|
|
14401
14418
|
function get_each_context(ctx, list, i) {
|
|
14402
14419
|
const child_ctx = ctx.slice();
|
|
14403
|
-
child_ctx[
|
|
14420
|
+
child_ctx[28] = list[i];
|
|
14404
14421
|
return child_ctx;
|
|
14405
14422
|
}
|
|
14406
14423
|
|
|
14407
|
-
// (
|
|
14424
|
+
// (162:1) {#each renderItemLabels as itemLabelItem (itemLabelItem.id)}
|
|
14408
14425
|
function create_each_block(key_1, ctx) {
|
|
14409
14426
|
let first;
|
|
14410
14427
|
let itemlabelitem;
|
|
@@ -14412,7 +14429,7 @@ function create_each_block(key_1, ctx) {
|
|
|
14412
14429
|
|
|
14413
14430
|
itemlabelitem = new ItemLabelItem({
|
|
14414
14431
|
props: {
|
|
14415
|
-
itemLabel: /*itemLabelItem*/ ctx[
|
|
14432
|
+
itemLabel: /*itemLabelItem*/ ctx[28],
|
|
14416
14433
|
hooks: /*hooks*/ ctx[0]
|
|
14417
14434
|
}
|
|
14418
14435
|
});
|
|
@@ -14433,7 +14450,7 @@ function create_each_block(key_1, ctx) {
|
|
|
14433
14450
|
p(new_ctx, dirty) {
|
|
14434
14451
|
ctx = new_ctx;
|
|
14435
14452
|
const itemlabelitem_changes = {};
|
|
14436
|
-
if (dirty & /*renderItemLabels*/ 2) itemlabelitem_changes.itemLabel = /*itemLabelItem*/ ctx[
|
|
14453
|
+
if (dirty & /*renderItemLabels*/ 2) itemlabelitem_changes.itemLabel = /*itemLabelItem*/ ctx[28];
|
|
14437
14454
|
if (dirty & /*hooks*/ 1) itemlabelitem_changes.hooks = /*hooks*/ ctx[0];
|
|
14438
14455
|
itemlabelitem.$set(itemlabelitem_changes);
|
|
14439
14456
|
},
|
|
@@ -14460,7 +14477,7 @@ function create_fragment(ctx) {
|
|
|
14460
14477
|
let div_resize_listener;
|
|
14461
14478
|
let current;
|
|
14462
14479
|
let each_value = /*renderItemLabels*/ ctx[1];
|
|
14463
|
-
const get_key = ctx => /*itemLabelItem*/ ctx[
|
|
14480
|
+
const get_key = ctx => /*itemLabelItem*/ ctx[28].id;
|
|
14464
14481
|
|
|
14465
14482
|
for (let i = 0; i < each_value.length; i += 1) {
|
|
14466
14483
|
let child_ctx = get_each_context(ctx, each_value, i);
|
|
@@ -14477,7 +14494,8 @@ function create_fragment(ctx) {
|
|
|
14477
14494
|
}
|
|
14478
14495
|
|
|
14479
14496
|
internal.attr(div, "class", "item-labels-container svelte-rmdeb");
|
|
14480
|
-
internal.add_render_callback(() => /*div_elementresize_handler*/ ctx[
|
|
14497
|
+
internal.add_render_callback(() => /*div_elementresize_handler*/ ctx[10].call(div));
|
|
14498
|
+
internal.set_style(div, "opacity", /*itemsVisible*/ ctx[4] ? 1 : 0, false);
|
|
14481
14499
|
},
|
|
14482
14500
|
m(target, anchor) {
|
|
14483
14501
|
internal.insert(target, div, anchor);
|
|
@@ -14486,7 +14504,7 @@ function create_fragment(ctx) {
|
|
|
14486
14504
|
each_blocks[i].m(div, null);
|
|
14487
14505
|
}
|
|
14488
14506
|
|
|
14489
|
-
div_resize_listener = internal.add_resize_listener(div, /*div_elementresize_handler*/ ctx[
|
|
14507
|
+
div_resize_listener = internal.add_resize_listener(div, /*div_elementresize_handler*/ ctx[10].bind(div));
|
|
14490
14508
|
current = true;
|
|
14491
14509
|
},
|
|
14492
14510
|
p(ctx, [dirty]) {
|
|
@@ -14496,6 +14514,10 @@ function create_fragment(ctx) {
|
|
|
14496
14514
|
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);
|
|
14497
14515
|
internal.check_outros();
|
|
14498
14516
|
}
|
|
14517
|
+
|
|
14518
|
+
if (dirty & /*itemsVisible*/ 16) {
|
|
14519
|
+
internal.set_style(div, "opacity", /*itemsVisible*/ ctx[4] ? 1 : 0, false);
|
|
14520
|
+
}
|
|
14499
14521
|
},
|
|
14500
14522
|
i(local) {
|
|
14501
14523
|
if (current) return;
|
|
@@ -14545,6 +14567,14 @@ function instance($$self, $$props, $$invalidate) {
|
|
|
14545
14567
|
// 计算重叠
|
|
14546
14568
|
let cssOffsetLists = [];
|
|
14547
14569
|
|
|
14570
|
+
// 动画过程中 itemsVisible 为 false
|
|
14571
|
+
let itemsVisible = true;
|
|
14572
|
+
|
|
14573
|
+
/**
|
|
14574
|
+
* 可见性策略:
|
|
14575
|
+
* 1、当前楼层(假设先不考虑多楼层)
|
|
14576
|
+
* 2、模型未被遮挡(一个 box 有没有被遮挡的计算? TODO)
|
|
14577
|
+
* */
|
|
14548
14578
|
const getLabelVisible = (five, itemLabel) => {
|
|
14549
14579
|
// 虚拟 VR 仅有一层,不考虑楼层信息
|
|
14550
14580
|
const raycaster = new Raycaster();
|
|
@@ -14598,6 +14628,8 @@ function instance($$self, $$props, $$invalidate) {
|
|
|
14598
14628
|
return Math.ceil(-38.9 * itemSpaceHeight + 130);
|
|
14599
14629
|
case DISPLAY_STRATEGY_TYPE.LARGE:
|
|
14600
14630
|
return Math.ceil(-44.44 * itemSpaceHeight + 140);
|
|
14631
|
+
case DISPLAY_STRATEGY_TYPE.EXTRA_LARGE:
|
|
14632
|
+
return Math.ceil(-92.59 * itemSpaceHeight + 300);
|
|
14601
14633
|
}
|
|
14602
14634
|
}
|
|
14603
14635
|
|
|
@@ -14644,15 +14676,27 @@ function instance($$self, $$props, $$invalidate) {
|
|
|
14644
14676
|
addDataUpdateListener();
|
|
14645
14677
|
});
|
|
14646
14678
|
|
|
14679
|
+
const handleCameraUpdateCallback = () => {
|
|
14680
|
+
$$invalidate(4, itemsVisible = false);
|
|
14681
|
+
handleCameraUpdate();
|
|
14682
|
+
};
|
|
14683
|
+
|
|
14647
14684
|
svelte.onMount(() => {
|
|
14648
14685
|
$$invalidate(1, renderItemLabels = itemLabels);
|
|
14649
14686
|
curItemLabels = itemLabels;
|
|
14650
14687
|
onItemLabelUpdate();
|
|
14651
|
-
|
|
14652
|
-
// five.on('cameraUpdate', onItemLabelUpdate)
|
|
14653
14688
|
addResizeListener();
|
|
14689
|
+
five.on('cameraUpdate', handleCameraUpdateCallback);
|
|
14654
14690
|
});
|
|
14655
14691
|
|
|
14692
|
+
const handleCameraUpdate = debounce(
|
|
14693
|
+
() => {
|
|
14694
|
+
$$invalidate(4, itemsVisible = true);
|
|
14695
|
+
onItemLabelUpdate();
|
|
14696
|
+
},
|
|
14697
|
+
300
|
|
14698
|
+
);
|
|
14699
|
+
|
|
14656
14700
|
const addResizeListener = () => {
|
|
14657
14701
|
wrapperSize = {
|
|
14658
14702
|
width: wrapper.clientWidth,
|
|
@@ -14666,7 +14710,6 @@ function instance($$self, $$props, $$invalidate) {
|
|
|
14666
14710
|
if (curItemLabels !== itemLabels) {
|
|
14667
14711
|
$$invalidate(1, renderItemLabels = itemLabels);
|
|
14668
14712
|
curItemLabels = itemLabels;
|
|
14669
|
-
console.log('--debug--update--');
|
|
14670
14713
|
onItemLabelUpdate();
|
|
14671
14714
|
}
|
|
14672
14715
|
};
|
|
@@ -14684,13 +14727,11 @@ function instance($$self, $$props, $$invalidate) {
|
|
|
14684
14727
|
});
|
|
14685
14728
|
|
|
14686
14729
|
svelte.onDestroy(() => {
|
|
14687
|
-
|
|
14730
|
+
five.off('cameraUpdate', handleCameraUpdateCallback);
|
|
14688
14731
|
resizeObserver.unobserve(wrapper);
|
|
14689
|
-
|
|
14690
|
-
|
|
14691
|
-
|
|
14692
|
-
wrapperSize = { width: 0, height: 0 };
|
|
14693
|
-
});
|
|
14732
|
+
}); // curItemLabels = null
|
|
14733
|
+
// renderItemLabels = null
|
|
14734
|
+
// wrapperSize = { width: 0, height: 0 }
|
|
14694
14735
|
|
|
14695
14736
|
function div_elementresize_handler() {
|
|
14696
14737
|
containerWidth = this.clientWidth;
|
|
@@ -14700,12 +14741,12 @@ function instance($$self, $$props, $$invalidate) {
|
|
|
14700
14741
|
}
|
|
14701
14742
|
|
|
14702
14743
|
$$self.$$set = $$props => {
|
|
14703
|
-
if ('five' in $$props) $$invalidate(
|
|
14704
|
-
if ('modelOcclusionEnable' in $$props) $$invalidate(
|
|
14705
|
-
if ('itemLabels' in $$props) $$invalidate(
|
|
14706
|
-
if ('wrapper' in $$props) $$invalidate(
|
|
14744
|
+
if ('five' in $$props) $$invalidate(5, five = $$props.five);
|
|
14745
|
+
if ('modelOcclusionEnable' in $$props) $$invalidate(6, modelOcclusionEnable = $$props.modelOcclusionEnable);
|
|
14746
|
+
if ('itemLabels' in $$props) $$invalidate(7, itemLabels = $$props.itemLabels);
|
|
14747
|
+
if ('wrapper' in $$props) $$invalidate(8, wrapper = $$props.wrapper);
|
|
14707
14748
|
if ('hooks' in $$props) $$invalidate(0, hooks = $$props.hooks);
|
|
14708
|
-
if ('displayStrategyType' in $$props) $$invalidate(
|
|
14749
|
+
if ('displayStrategyType' in $$props) $$invalidate(9, displayStrategyType = $$props.displayStrategyType);
|
|
14709
14750
|
};
|
|
14710
14751
|
|
|
14711
14752
|
return [
|
|
@@ -14713,6 +14754,7 @@ function instance($$self, $$props, $$invalidate) {
|
|
|
14713
14754
|
renderItemLabels,
|
|
14714
14755
|
containerWidth,
|
|
14715
14756
|
containerHeight,
|
|
14757
|
+
itemsVisible,
|
|
14716
14758
|
five,
|
|
14717
14759
|
modelOcclusionEnable,
|
|
14718
14760
|
itemLabels,
|
|
@@ -14733,12 +14775,12 @@ class ItemLabelComponent extends internal.SvelteComponent {
|
|
|
14733
14775
|
create_fragment,
|
|
14734
14776
|
internal.safe_not_equal,
|
|
14735
14777
|
{
|
|
14736
|
-
five:
|
|
14737
|
-
modelOcclusionEnable:
|
|
14738
|
-
itemLabels:
|
|
14739
|
-
wrapper:
|
|
14778
|
+
five: 5,
|
|
14779
|
+
modelOcclusionEnable: 6,
|
|
14780
|
+
itemLabels: 7,
|
|
14781
|
+
wrapper: 8,
|
|
14740
14782
|
hooks: 0,
|
|
14741
|
-
displayStrategyType:
|
|
14783
|
+
displayStrategyType: 9
|
|
14742
14784
|
},
|
|
14743
14785
|
add_css
|
|
14744
14786
|
);
|
|
@@ -14762,7 +14804,7 @@ const ModelItemLabelPlugin = (five$1, params) => {
|
|
|
14762
14804
|
app: undefined,
|
|
14763
14805
|
hooks: new five.Subscribe(),
|
|
14764
14806
|
modelOcclusionEnable: (_a = params === null || params === void 0 ? void 0 : params.modelOcclusionEnable) !== null && _a !== void 0 ? _a : true,
|
|
14765
|
-
displayStrategyType: (_b = params === null || params === void 0 ? void 0 : params.displayStrategyType) !== null && _b !== void 0 ? _b : DISPLAY_STRATEGY_TYPE.SMALL
|
|
14807
|
+
displayStrategyType: (_b = params === null || params === void 0 ? void 0 : params.displayStrategyType) !== null && _b !== void 0 ? _b : DISPLAY_STRATEGY_TYPE.SMALL,
|
|
14766
14808
|
};
|
|
14767
14809
|
pluginState.container.setAttribute('class', 'model-item-label-plugin-container');
|
|
14768
14810
|
pluginState.container.style.cssText = `
|
|
@@ -14771,8 +14813,9 @@ const ModelItemLabelPlugin = (five$1, params) => {
|
|
|
14771
14813
|
top: 0;
|
|
14772
14814
|
width: 100%;
|
|
14773
14815
|
height: 100%;
|
|
14774
|
-
|
|
14816
|
+
z-index: 5;
|
|
14775
14817
|
`;
|
|
14818
|
+
pluginState.container.style.pointerEvents = 'none'; // 写到 cssText 里不生效
|
|
14776
14819
|
const appendTo = (wrapper) => {
|
|
14777
14820
|
pluginState.wrapper = wrapper;
|
|
14778
14821
|
wrapper.appendChild(pluginState.container);
|
|
@@ -14780,7 +14823,6 @@ const ModelItemLabelPlugin = (five$1, params) => {
|
|
|
14780
14823
|
return true;
|
|
14781
14824
|
};
|
|
14782
14825
|
const load = (data) => {
|
|
14783
|
-
console.log('🐶--当前标签总条数: ', data.model_item_labels.length);
|
|
14784
14826
|
pluginState.itemLabels = parseModelItemLabelPluginData(data);
|
|
14785
14827
|
render();
|
|
14786
14828
|
};
|
|
@@ -14802,40 +14844,6 @@ const ModelItemLabelPlugin = (five$1, params) => {
|
|
|
14802
14844
|
removeListener4Five();
|
|
14803
14845
|
pluginState.container.remove();
|
|
14804
14846
|
};
|
|
14805
|
-
const handleRerender = () => {
|
|
14806
|
-
if (!pluginState.enabled || !pluginState.fiveModeEnabled)
|
|
14807
|
-
return;
|
|
14808
|
-
disable();
|
|
14809
|
-
};
|
|
14810
|
-
const rerender = (a, b, c) => {
|
|
14811
|
-
if (!pluginState.fiveModeEnabled)
|
|
14812
|
-
return;
|
|
14813
|
-
if (!c)
|
|
14814
|
-
return;
|
|
14815
|
-
enable();
|
|
14816
|
-
render();
|
|
14817
|
-
};
|
|
14818
|
-
const handleInteriaPanRerender = (a, b) => {
|
|
14819
|
-
if (!pluginState.fiveModeEnabled)
|
|
14820
|
-
return;
|
|
14821
|
-
if (!b)
|
|
14822
|
-
return;
|
|
14823
|
-
enable();
|
|
14824
|
-
render();
|
|
14825
|
-
};
|
|
14826
|
-
const handleWantsPanGesture = (pose, final) => {
|
|
14827
|
-
if (pose) {
|
|
14828
|
-
handleRerender();
|
|
14829
|
-
}
|
|
14830
|
-
};
|
|
14831
|
-
const handlePanGesture = (pose, final) => {
|
|
14832
|
-
if (!pluginState.fiveModeEnabled)
|
|
14833
|
-
return;
|
|
14834
|
-
if (!final)
|
|
14835
|
-
return;
|
|
14836
|
-
enable();
|
|
14837
|
-
render();
|
|
14838
|
-
};
|
|
14839
14847
|
const render = () => {
|
|
14840
14848
|
var _a;
|
|
14841
14849
|
if (!pluginState.wrapper)
|
|
@@ -14871,32 +14879,14 @@ const ModelItemLabelPlugin = (five$1, params) => {
|
|
|
14871
14879
|
const addListener4Five = () => {
|
|
14872
14880
|
five$1.on('modeChange', onFiveModeChange);
|
|
14873
14881
|
five$1.once('dispose', dispose);
|
|
14874
|
-
// five.on('wantsGesture', handleRerender)
|
|
14875
|
-
// five.on('gesture', rerender)
|
|
14876
|
-
five$1.on('wantsMouseWheel', handleRerender);
|
|
14877
|
-
five$1.on('mouseWheel', rerender);
|
|
14878
|
-
five$1.on('wantsInteriaPan', handleRerender);
|
|
14879
|
-
five$1.on('interiaPan', handleInteriaPanRerender);
|
|
14880
|
-
five$1.on('wantsPanGesture', handleWantsPanGesture);
|
|
14881
|
-
five$1.on('panGesture', handlePanGesture);
|
|
14882
|
-
five$1.on('wantsPinchGesture', handleRerender);
|
|
14883
|
-
five$1.on('pinchGesture', rerender);
|
|
14884
14882
|
};
|
|
14885
14883
|
// 取消 five 监听
|
|
14886
14884
|
const removeListener4Five = () => {
|
|
14887
14885
|
five$1.off('modeChange', onFiveModeChange);
|
|
14888
|
-
// five.off('wantsGesture', handleRerender)
|
|
14889
|
-
// five.off('gesture', rerender)
|
|
14890
|
-
five$1.off('wantsMouseWheel', handleRerender);
|
|
14891
|
-
five$1.off('mouseWheel', rerender);
|
|
14892
|
-
five$1.off('wantsInteriaPan', handleRerender);
|
|
14893
|
-
five$1.off('interiaPan', handleInteriaPanRerender);
|
|
14894
|
-
five$1.off('wantsPanGesture', handleWantsPanGesture);
|
|
14895
|
-
five$1.off('panGesture', handlePanGesture);
|
|
14896
|
-
five$1.off('wantsPinchGesture', handleRerender);
|
|
14897
|
-
five$1.off('pinchGesture', rerender);
|
|
14898
14886
|
};
|
|
14899
14887
|
const onFiveModeChange = (mode) => {
|
|
14888
|
+
if (!pluginState.enabled)
|
|
14889
|
+
return;
|
|
14900
14890
|
if (mode !== five.Five.Mode.Floorplan) {
|
|
14901
14891
|
pluginState.fiveModeEnabled = false;
|
|
14902
14892
|
render();
|
|
@@ -14918,6 +14908,279 @@ const ModelItemLabelPlugin = (five$1, params) => {
|
|
|
14918
14908
|
};
|
|
14919
14909
|
};
|
|
14920
14910
|
|
|
14911
|
+
var DIRECTION;
|
|
14912
|
+
(function (DIRECTION) {
|
|
14913
|
+
DIRECTION["TOP_LEFT"] = "topLeft";
|
|
14914
|
+
DIRECTION["TOP_RIGHT"] = "topRight";
|
|
14915
|
+
DIRECTION["BOTTOM_LEFT"] = "bottomLeft";
|
|
14916
|
+
DIRECTION["BOTTOM_RIGHT"] = "bottomRight";
|
|
14917
|
+
})(DIRECTION || (DIRECTION = {}));
|
|
14918
|
+
|
|
14919
|
+
function parseModelTVVideoPoints(points) {
|
|
14920
|
+
if (points.length === 0)
|
|
14921
|
+
return [];
|
|
14922
|
+
if (Array.isArray(points[0]))
|
|
14923
|
+
return points;
|
|
14924
|
+
let newPoints = [];
|
|
14925
|
+
points.map(point => {
|
|
14926
|
+
const newPoint = [point[DIRECTION.TOP_LEFT], point[DIRECTION.BOTTOM_LEFT], point[DIRECTION.BOTTOM_RIGHT], point[DIRECTION.TOP_RIGHT]];
|
|
14927
|
+
newPoints.push(newPoint);
|
|
14928
|
+
});
|
|
14929
|
+
return newPoints;
|
|
14930
|
+
}
|
|
14931
|
+
|
|
14932
|
+
const ModelTVVideoPlugin = (five, { videoElement }) => {
|
|
14933
|
+
const state = {
|
|
14934
|
+
videoMeshes: [],
|
|
14935
|
+
videoTextureEnabled: false,
|
|
14936
|
+
videoSource: '',
|
|
14937
|
+
rectPoints: [],
|
|
14938
|
+
enabled: false,
|
|
14939
|
+
videoElement: videoElement,
|
|
14940
|
+
};
|
|
14941
|
+
const setMuted = (muted) => {
|
|
14942
|
+
if (state.videoTexture) {
|
|
14943
|
+
state.videoTexture.image.muted = muted;
|
|
14944
|
+
state.videoTexture.image.play();
|
|
14945
|
+
}
|
|
14946
|
+
};
|
|
14947
|
+
const getMuted = () => {
|
|
14948
|
+
if (state.videoTexture)
|
|
14949
|
+
return state.videoTexture.image.muted;
|
|
14950
|
+
else
|
|
14951
|
+
return true;
|
|
14952
|
+
};
|
|
14953
|
+
const enable = () => {
|
|
14954
|
+
if (state.enabled)
|
|
14955
|
+
return;
|
|
14956
|
+
if (!state.videoTexture)
|
|
14957
|
+
return;
|
|
14958
|
+
state.enabled = true;
|
|
14959
|
+
state.videoMeshes = createPanoVideoMeshes();
|
|
14960
|
+
console.log('state.videoMeshes', state.videoMeshes);
|
|
14961
|
+
state.videoMeshes.forEach((mesh) => five.scene.add(mesh));
|
|
14962
|
+
const play = () => {
|
|
14963
|
+
console.log('play', state.videoTexture);
|
|
14964
|
+
if (!state.videoTexture)
|
|
14965
|
+
return;
|
|
14966
|
+
const timeupdate = () => {
|
|
14967
|
+
var _a;
|
|
14968
|
+
if (!state.videoTexture)
|
|
14969
|
+
return;
|
|
14970
|
+
(_a = state.videoTexture) === null || _a === void 0 ? void 0 : _a.image.removeEventListener('timeupdate', timeupdate);
|
|
14971
|
+
state.videoTextureEnabled = true;
|
|
14972
|
+
state.videoMeshes.forEach((mesh) => {
|
|
14973
|
+
if (mesh.material.map !== state.videoTexture)
|
|
14974
|
+
mesh.material.map = state.videoTexture;
|
|
14975
|
+
});
|
|
14976
|
+
five.needsRender = true;
|
|
14977
|
+
};
|
|
14978
|
+
state.videoTexture.image.addEventListener('timeupdate', timeupdate);
|
|
14979
|
+
if (state.videoTexture && state.videoMeshes.length) {
|
|
14980
|
+
state.videoTexture.image.play();
|
|
14981
|
+
}
|
|
14982
|
+
};
|
|
14983
|
+
if (five.model.loaded)
|
|
14984
|
+
play();
|
|
14985
|
+
else {
|
|
14986
|
+
return five.once('modelLoaded', () => play());
|
|
14987
|
+
}
|
|
14988
|
+
};
|
|
14989
|
+
const disable = () => {
|
|
14990
|
+
if (!state.enabled)
|
|
14991
|
+
return;
|
|
14992
|
+
state.enabled = false;
|
|
14993
|
+
state.videoMeshes.forEach((mesh) => {
|
|
14994
|
+
mesh.geometry.dispose();
|
|
14995
|
+
mesh.material.dispose();
|
|
14996
|
+
five.scene.remove(mesh);
|
|
14997
|
+
if (state.videoTexture)
|
|
14998
|
+
state.videoTexture.image.pause();
|
|
14999
|
+
});
|
|
15000
|
+
state.videoMeshes = [];
|
|
15001
|
+
five.needsRender = true;
|
|
15002
|
+
};
|
|
15003
|
+
const createPanoVideoMeshes = () => {
|
|
15004
|
+
return state.rectPoints.map((points, index) => {
|
|
15005
|
+
const geometry = new THREE__namespace.BufferGeometry();
|
|
15006
|
+
const segments = 128;
|
|
15007
|
+
const verticesArray = [];
|
|
15008
|
+
verticesArray.push(points[0].x, points[0].y, points[0].z);
|
|
15009
|
+
for (let i = 1; i < segments; i++) {
|
|
15010
|
+
verticesArray.push(points[0].x + ((points[1].x - points[0].x) * i) / segments, points[0].y + ((points[1].y - points[0].y) * i) / segments, points[0].z + ((points[1].z - points[0].z) * i) / segments);
|
|
15011
|
+
}
|
|
15012
|
+
verticesArray.push(points[1].x, points[1].y, points[1].z);
|
|
15013
|
+
verticesArray.push(points[2].x, points[2].y, points[2].z);
|
|
15014
|
+
for (let i = 1; i < segments; i++) {
|
|
15015
|
+
verticesArray.push(points[2].x + ((points[3].x - points[2].x) * i) / segments, points[2].y + ((points[3].y - points[2].y) * i) / segments, points[2].z + ((points[3].z - points[2].z) * i) / segments);
|
|
15016
|
+
}
|
|
15017
|
+
verticesArray.push(points[3].x, points[3].y, points[3].z);
|
|
15018
|
+
const uvArray = [];
|
|
15019
|
+
uvArray.push(0, 1);
|
|
15020
|
+
for (let i = 1; i < segments; i++) {
|
|
15021
|
+
uvArray.push(0, 1 - i / segments);
|
|
15022
|
+
}
|
|
15023
|
+
uvArray.push(0, 0);
|
|
15024
|
+
uvArray.push(1, 0);
|
|
15025
|
+
for (let i = 1; i < segments; i++) {
|
|
15026
|
+
uvArray.push(1, i / segments);
|
|
15027
|
+
}
|
|
15028
|
+
uvArray.push(1, 1);
|
|
15029
|
+
const indicesArray = [];
|
|
15030
|
+
for (let i = 0; i < segments; i++) {
|
|
15031
|
+
indicesArray.push(i, i + 1, segments * 2 - i, i, segments * 2 - i, segments * 2 + 1 - i);
|
|
15032
|
+
}
|
|
15033
|
+
geometry.setAttribute('position', new THREE__namespace.BufferAttribute(new Float32Array(verticesArray), 3));
|
|
15034
|
+
geometry.setAttribute('uv', new THREE__namespace.BufferAttribute(new Float32Array(uvArray), 2));
|
|
15035
|
+
geometry.setIndex(new THREE__namespace.BufferAttribute(new Uint32Array(indicesArray), 1));
|
|
15036
|
+
const material = new THREE__namespace.MeshBasicMaterial({
|
|
15037
|
+
map: state.videoTextureEnabled ? state.videoTexture : state.imageTexture,
|
|
15038
|
+
side: THREE__namespace.DoubleSide,
|
|
15039
|
+
});
|
|
15040
|
+
const mesh = new THREE__namespace.Mesh(geometry, material);
|
|
15041
|
+
mesh.renderOrder = 1;
|
|
15042
|
+
mesh.name = `ModelTVVideoPlugin-${index}-${performance.now()}`;
|
|
15043
|
+
return mesh;
|
|
15044
|
+
});
|
|
15045
|
+
};
|
|
15046
|
+
const getImageTexture = (source) => {
|
|
15047
|
+
const texture = new THREE__namespace.TextureLoader().load(source);
|
|
15048
|
+
texture.minFilter = THREE__namespace.LinearFilter;
|
|
15049
|
+
texture.magFilter = THREE__namespace.LinearFilter;
|
|
15050
|
+
texture.format = THREE__namespace.RGBFormat;
|
|
15051
|
+
return texture;
|
|
15052
|
+
};
|
|
15053
|
+
const getVideoTexture = (source, video) => {
|
|
15054
|
+
return new Promise((resolve, reject) => {
|
|
15055
|
+
const xhr = new XMLHttpRequest();
|
|
15056
|
+
xhr.onreadystatechange = () => {
|
|
15057
|
+
if (xhr.readyState == 4) {
|
|
15058
|
+
if (xhr.status == 200) {
|
|
15059
|
+
const url = window.URL || window.webkitURL;
|
|
15060
|
+
video = video || document.createElement('video');
|
|
15061
|
+
video.crossOrigin = 'anonymous';
|
|
15062
|
+
video.autoplay = true;
|
|
15063
|
+
video.muted = true;
|
|
15064
|
+
video.loop = true;
|
|
15065
|
+
video.playsInline = true;
|
|
15066
|
+
video.src = url.createObjectURL(xhr.response);
|
|
15067
|
+
const texture = new THREE__namespace.VideoTexture(video);
|
|
15068
|
+
texture.minFilter = THREE__namespace.LinearFilter;
|
|
15069
|
+
texture.magFilter = THREE__namespace.LinearFilter;
|
|
15070
|
+
texture.format = THREE__namespace.RGBFormat;
|
|
15071
|
+
resolve(Object.assign(texture, { videoSource: source }));
|
|
15072
|
+
}
|
|
15073
|
+
else {
|
|
15074
|
+
reject(new Error('Video download Error: ' + xhr.status));
|
|
15075
|
+
}
|
|
15076
|
+
}
|
|
15077
|
+
};
|
|
15078
|
+
xhr.onerror = (error) => reject(error);
|
|
15079
|
+
xhr.open('GET', source);
|
|
15080
|
+
xhr.responseType = 'blob';
|
|
15081
|
+
xhr.send();
|
|
15082
|
+
});
|
|
15083
|
+
};
|
|
15084
|
+
const load = (data, videoElement) => __awaiter(void 0, void 0, void 0, function* () {
|
|
15085
|
+
const { video_src, video_poster_src, points } = data;
|
|
15086
|
+
state.videoSource = video_src;
|
|
15087
|
+
// TODO 存疑,先处理多一次遍历 o(2n)
|
|
15088
|
+
state.rectPoints = parseModelTVVideoPoints(points)
|
|
15089
|
+
.map((items) => items.map(({ x, y, z }) => new THREE__namespace.Vector3(x, y, z)));
|
|
15090
|
+
state.imageTexture = getImageTexture(video_poster_src);
|
|
15091
|
+
if (videoElement) {
|
|
15092
|
+
state.videoElement = videoElement;
|
|
15093
|
+
}
|
|
15094
|
+
state.videoTexture = yield getVideoTexture(state.videoSource, state.videoElement);
|
|
15095
|
+
state.enabled = !!data.enable;
|
|
15096
|
+
if (state.enabled)
|
|
15097
|
+
enable();
|
|
15098
|
+
});
|
|
15099
|
+
const dispose = () => {
|
|
15100
|
+
disable();
|
|
15101
|
+
state.videoTexture = undefined;
|
|
15102
|
+
five.off('modeChange', () => setMuted(true));
|
|
15103
|
+
five.off('wantsTapGesture', (raycaster) => {
|
|
15104
|
+
if (!state.enabled)
|
|
15105
|
+
return;
|
|
15106
|
+
const [intersect] = raycaster.intersectObjects(five.scene.children, true);
|
|
15107
|
+
if (!!intersect && /^video/.test(intersect.object.name)) {
|
|
15108
|
+
if (state.videoTexture)
|
|
15109
|
+
setMuted(!state.videoTexture.image.muted);
|
|
15110
|
+
return false;
|
|
15111
|
+
}
|
|
15112
|
+
});
|
|
15113
|
+
five.off('panoArrived', () => {
|
|
15114
|
+
if (!state.enabled)
|
|
15115
|
+
return;
|
|
15116
|
+
if (getMuted())
|
|
15117
|
+
return;
|
|
15118
|
+
const cameraPosition = five.camera.position;
|
|
15119
|
+
const visible = state.rectPoints.find((points) => {
|
|
15120
|
+
const centerVector = points.reduce((total, curr) => new THREE__namespace.Vector3(total.x + curr.x / points.length, total.y + curr.y / points.length, total.z + curr.z / points.length), new THREE__namespace.Vector3());
|
|
15121
|
+
return (points.map((point) => new THREE__namespace.Vector3((point.x + centerVector.x) / 2, (point.y + centerVector.y) / 2, (point.z + centerVector.z) / 2)).filter((vector) => {
|
|
15122
|
+
vector = vector.clone().sub(cameraPosition).normalize();
|
|
15123
|
+
const raycaster = new THREE__namespace.Raycaster(cameraPosition, vector);
|
|
15124
|
+
const [intersect] = raycaster.intersectObjects(five.scene.children, true);
|
|
15125
|
+
return !!intersect && /^video/.test(intersect.object.name);
|
|
15126
|
+
}).length >= 2);
|
|
15127
|
+
});
|
|
15128
|
+
if (!visible)
|
|
15129
|
+
setMuted(true);
|
|
15130
|
+
});
|
|
15131
|
+
five.off('renderFrame', () => {
|
|
15132
|
+
// console.log('renderFrame', state.videoMeshes)
|
|
15133
|
+
state.videoMeshes.forEach((meshes) => {
|
|
15134
|
+
if (meshes)
|
|
15135
|
+
//@ts-ignore
|
|
15136
|
+
meshes.needsRender = true;
|
|
15137
|
+
});
|
|
15138
|
+
});
|
|
15139
|
+
};
|
|
15140
|
+
five.on('modeChange', () => setMuted(true));
|
|
15141
|
+
five.on('wantsTapGesture', (raycaster) => {
|
|
15142
|
+
if (!state.enabled)
|
|
15143
|
+
return;
|
|
15144
|
+
const targetMesh = five.scene.children.find(item => /^ModelTVVideoPlugin/.test(item.name));
|
|
15145
|
+
if (!targetMesh)
|
|
15146
|
+
return;
|
|
15147
|
+
const intersectObjects = raycaster.intersectObjects([targetMesh]);
|
|
15148
|
+
if (intersectObjects.length === 0)
|
|
15149
|
+
return;
|
|
15150
|
+
if (state.videoTexture)
|
|
15151
|
+
setMuted(!state.videoTexture.image.muted); // TODO toggle video play
|
|
15152
|
+
return false;
|
|
15153
|
+
});
|
|
15154
|
+
five.on('panoArrived', () => {
|
|
15155
|
+
if (!state.enabled)
|
|
15156
|
+
return;
|
|
15157
|
+
if (getMuted())
|
|
15158
|
+
return;
|
|
15159
|
+
const cameraPosition = five.camera.position;
|
|
15160
|
+
const visible = state.rectPoints.find((points) => {
|
|
15161
|
+
const centerVector = points.reduce((total, curr) => new THREE__namespace.Vector3(total.x + curr.x / points.length, total.y + curr.y / points.length, total.z + curr.z / points.length), new THREE__namespace.Vector3());
|
|
15162
|
+
return (points.map((point) => new THREE__namespace.Vector3((point.x + centerVector.x) / 2, (point.y + centerVector.y) / 2, (point.z + centerVector.z) / 2)).filter((vector) => {
|
|
15163
|
+
vector = vector.clone().sub(cameraPosition).normalize();
|
|
15164
|
+
const raycaster = new THREE__namespace.Raycaster(cameraPosition, vector);
|
|
15165
|
+
const [intersect] = raycaster.intersectObjects(five.scene.children, true);
|
|
15166
|
+
return !!intersect && /^video/.test(intersect.object.name);
|
|
15167
|
+
}).length >= 2);
|
|
15168
|
+
});
|
|
15169
|
+
if (!visible)
|
|
15170
|
+
setMuted(true);
|
|
15171
|
+
});
|
|
15172
|
+
five.on('renderFrame', () => {
|
|
15173
|
+
// console.log('renderFrame', state.videoMeshes)
|
|
15174
|
+
state.videoMeshes.forEach((meshes) => {
|
|
15175
|
+
if (meshes)
|
|
15176
|
+
//@ts-ignore
|
|
15177
|
+
meshes.needsRender = true;
|
|
15178
|
+
});
|
|
15179
|
+
});
|
|
15180
|
+
Object.assign(window, { $state: state });
|
|
15181
|
+
return { enable, disable, load, dispose };
|
|
15182
|
+
};
|
|
15183
|
+
|
|
14921
15184
|
exports.CSS3DRenderPlugin = CSS3DRenderPlugin;
|
|
14922
15185
|
exports.CameraMovementPlugin = CameraMovementPlugin;
|
|
14923
15186
|
exports.ModelChassisCompassPlugin = ModelChassisCompassPlugin;
|
|
@@ -14925,6 +15188,7 @@ exports.ModelEntryDoorGuidePlugin = ModelEntryDoorGuidePlugin;
|
|
|
14925
15188
|
exports.ModelFloorplanPlugin = ModelFloorplanPlugin;
|
|
14926
15189
|
exports.ModelItemLabelPlugin = ModelItemLabelPlugin;
|
|
14927
15190
|
exports.ModelRoomLabelPlugin = ModelRoomLabelPlugin;
|
|
15191
|
+
exports.ModelTVVideoPlugin = ModelTVVideoPlugin;
|
|
14928
15192
|
exports.ModelViewPlugin = ModelViewPlugin;
|
|
14929
15193
|
exports.PanoCompassPlugin = PanoCompassPlugin;
|
|
14930
15194
|
exports.PanoCursorRaycasterPlugin = PanoCursorRaycasterPlugin;
|