@realsee/dnalogel 0.1.2 → 0.1.3

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.
Files changed (53) hide show
  1. package/data/XJ6NMLWnkAY3Rdx8.d.ts +843 -0
  2. package/data/XJ6NMLWnkAY3Rdx8.js +7987 -0
  3. package/data/jd6oMOzPxnQ3BvxY_B7yw51J9rXlhYhjhGTOgRVqu6WeEqjNX.d.ts +85 -0
  4. package/data/jd6oMOzPxnQ3BvxY_B7yw51J9rXlhYhjhGTOgRVqu6WeEqjNX.js +509 -0
  5. package/data/vLykj3NWrllMrG06.d.ts +2 -0
  6. package/data/vLykj3NWrllMrG06.js +197 -2
  7. package/data/zxMawr9raSg8LYjG.d.ts +53 -0
  8. package/data/zxMawr9raSg8LYjG.js +588 -0
  9. package/package.json +2 -2
  10. package/plugins/AutoPreloadPlugin/index.d.ts +23 -0
  11. package/plugins/AutoPreloadPlugin/index.js +85 -0
  12. package/plugins/CSS3DRenderPlugin/index.d.ts +3 -2
  13. package/plugins/CSS3DRenderPlugin/index.js +49 -44
  14. package/plugins/ModelChassisCompassPlugin/index.d.ts +7 -3
  15. package/plugins/ModelChassisCompassPlugin/index.js +13 -26
  16. package/plugins/ModelEntryDoorGuidePlugin/index.d.ts +13 -1
  17. package/plugins/ModelEntryDoorGuidePlugin/index.js +212 -2
  18. package/plugins/ModelRoomLabelPlugin/Controller.d.ts +35 -0
  19. package/plugins/ModelRoomLabelPlugin/Controller.js +147 -0
  20. package/plugins/ModelRoomLabelPlugin/RoomLabelItem.d.ts +8 -0
  21. package/plugins/ModelRoomLabelPlugin/RoomLabelItem.js +48 -0
  22. package/plugins/ModelRoomLabelPlugin/RoomLabelItems.d.ts +7 -0
  23. package/plugins/ModelRoomLabelPlugin/RoomLabelItems.js +149 -0
  24. package/plugins/ModelRoomLabelPlugin/index.d.ts +8 -0
  25. package/plugins/ModelRoomLabelPlugin/index.js +16 -0
  26. package/plugins/ModelRoomLabelPlugin/typings.d.ts +35 -0
  27. package/plugins/ModelRoomLabelPlugin/typings.js +5 -0
  28. package/plugins/ModelRoomLabelPlugin/utils/parseData.d.ts +3 -0
  29. package/plugins/ModelRoomLabelPlugin/utils/parseData.js +29 -0
  30. package/plugins/PanoMaskSelectorPlugin/compare.d.ts +1 -0
  31. package/plugins/PanoMaskSelectorPlugin/compare.js +15 -0
  32. package/plugins/PanoMaskSelectorPlugin/createBox.d.ts +7 -0
  33. package/plugins/PanoMaskSelectorPlugin/createBox.js +61 -0
  34. package/plugins/PanoMaskSelectorPlugin/createTextures.d.ts +3 -0
  35. package/plugins/PanoMaskSelectorPlugin/createTextures.js +29 -0
  36. package/plugins/PanoMaskSelectorPlugin/fragmentShader.d.ts +1 -0
  37. package/plugins/PanoMaskSelectorPlugin/fragmentShader.js +8 -0
  38. package/plugins/PanoMaskSelectorPlugin/index.d.ts +49 -0
  39. package/plugins/PanoMaskSelectorPlugin/index.js +262 -0
  40. package/plugins/PanoMaskSelectorPlugin/vertexShader.d.ts +1 -0
  41. package/plugins/PanoMaskSelectorPlugin/vertexShader.js +8 -0
  42. package/plugins/floorplan/ModelFloorplanPlugin/components/Camera.js +4 -2
  43. package/plugins/floorplan/ModelFloorplanPlugin/components/Compass.js +2 -1
  44. package/plugins/floorplan/ModelFloorplanPlugin/components/NowFloor/RoomLabels.js +5 -2
  45. package/plugins/floorplan/ModelFloorplanPlugin/components/index.js +1 -1
  46. package/shared-utils/createCanvasTextTexture.d.ts +8 -0
  47. package/shared-utils/createCanvasTextTexture.js +29 -0
  48. package/shared-utils/three/transfromToMeshBasicMaterial.d.ts +2 -0
  49. package/shared-utils/three/transfromToMeshBasicMaterial.js +27 -0
  50. package/typedoc/plugins.d.ts +2 -0
  51. package/typedoc/plugins.js +39 -1
  52. package/data/wYnRjQ4KZoV1yPoG.d.ts +0 -114
  53. package/data/wYnRjQ4KZoV1yPoG.js +0 -512
@@ -1,12 +1,13 @@
1
1
  import { FivePlugin } from '@realsee/five';
2
2
  import { Vector3 } from 'three';
3
3
  import { CSS3DObject } from 'three/examples/jsm/renderers/CSS3DRenderer';
4
+ import { Vector3Position } from '../../typings/math.type';
4
5
  export declare type CSS3DRenderPluginParameterType = undefined;
5
6
  export interface CSS3DRenderPluginExportType {
6
7
  /**
7
8
  * @description: 根据传入的四个点位创建一个3d dom容器,可以通过ReactDom.render()的方式将react组件放到容器中
8
9
  * @param {Five} five
9
- * @param {Vector3[]} points: 矩形四个点坐标
10
+ * @param {Vector3[] | Vector3Position[]} points: 矩形四个点坐标
10
11
  * @param {number} config.ratio: 1px对应多少米,默认为 0.002,即1px对应2mm
11
12
  * @param {number} config.dpr: dpr, 默认为1
12
13
  * @param {HTMLElement} config.container: HTMLElement
@@ -15,7 +16,7 @@ export interface CSS3DRenderPluginExportType {
15
16
  * @param {HTMLElement} config.behindFiveContainer: 如果config.mode为'behind',需要传入容器,并确保此容器位five下方,且中间没有其他dom元素遮挡
16
17
  * @return {{ container: HTMLElement; dispose: () => void }}: container: dom容器, dispose: 清理函数
17
18
  */
18
- create3DDomContainer: (points: Vector3[], config?: {
19
+ create3DDomContainer: (points: Vector3[] | Vector3Position[], config?: {
19
20
  ratio?: number;
20
21
  dpr?: number;
21
22
  autoRender?: boolean;
@@ -15,6 +15,8 @@ var _evenNumber = _interopRequireDefault(require("../../shared-utils/math/evenNu
15
15
 
16
16
  var _centerPoint = _interopRequireDefault(require("../../shared-utils/three/centerPoint"));
17
17
 
18
+ var _transformPositionToVector = _interopRequireDefault(require("../../shared-utils/three/transformPositionToVector3"));
19
+
18
20
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
19
21
 
20
22
  function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
@@ -39,8 +41,10 @@ var CSS3DRenderPlugin = function CSS3DRenderPlugin(five) {
39
41
  params[_key] = arguments[_key];
40
42
  }
41
43
 
42
- var points = params[0],
43
- config = params[1];
44
+ var points = params[0].map(function (point) {
45
+ return point instanceof THREE.Vector3 ? point : (0, _transformPositionToVector["default"])(point);
46
+ });
47
+ var config = params[1];
44
48
  if ((points === null || points === void 0 ? void 0 : points.length) < 4) return console.error('points must be equal or greater than than 4');
45
49
  if (!(five !== null && five !== void 0 && (_five$model = five.model) !== null && _five$model !== void 0 && _five$model.loaded)) return console.error('five.model.loaded is: ', five === null || five === void 0 ? void 0 : (_five$model2 = five.model) === null || _five$model2 === void 0 ? void 0 : _five$model2.loaded);
46
50
  var fiveElement = five.getElement();
@@ -52,7 +56,8 @@ var CSS3DRenderPlugin = function CSS3DRenderPlugin(five) {
52
56
  var mode = (config === null || config === void 0 ? void 0 : config.mode) || 'front';
53
57
  var autoRender = (_config$autoRender = config === null || config === void 0 ? void 0 : config.autoRender) !== null && _config$autoRender !== void 0 ? _config$autoRender : true;
54
58
  var behindFiveContainer = (config === null || config === void 0 ? void 0 : config.behindFiveContainer) || fiveElement.parentElement || document.body;
55
- var container = (config === null || config === void 0 ? void 0 : config.container) || document.createElement('div'); // 获取css3DObject, 如果mode为behind的话,一起获取mesh
59
+ var container = (config === null || config === void 0 ? void 0 : config.container) || document.createElement('div');
60
+ container.classList.add('__Dnalogel-plugin--CSS3DRenderPlugin'); // 获取css3DObject, 如果mode为behind的话,一起获取mesh
56
61
 
57
62
  var _createObject = createObject(points, {
58
63
  ratio: ratio,
@@ -71,8 +76,6 @@ var CSS3DRenderPlugin = function CSS3DRenderPlugin(five) {
71
76
  var stopRenderFlag = false;
72
77
  var requestAnimationFrameId = null;
73
78
 
74
- var render = function render() {};
75
-
76
79
  if (behindModeUnInited) {
77
80
  state.behindMode = {
78
81
  scene: new THREE.Scene(),
@@ -91,45 +94,47 @@ var CSS3DRenderPlugin = function CSS3DRenderPlugin(five) {
91
94
  scene = _ref.scene,
92
95
  css3DRenderer = _ref.css3DRenderer;
93
96
 
94
- if (!inited) {
95
- var css3DRendererSetSize = function css3DRendererSetSize() {
96
- var rendererWidth = (0, _evenNumber["default"])(fiveElement.clientWidth);
97
- var rendererHeight = (0, _evenNumber["default"])(fiveElement.clientHeight);
98
- css3DRenderer.setSize(rendererWidth, rendererHeight);
99
- };
100
-
101
- css3DRendererSetSize();
102
- resizeObserver = new ResizeObserver(css3DRendererSetSize);
103
- css3DRenderer.domElement.style.position = 'absolute';
104
- css3DRenderer.domElement.style.top = '0';
105
- css3DRenderer.domElement.style.userSelect = 'none';
106
- css3DRenderer.domElement.style.pointerEvents = 'none';
107
-
108
- var renderEveryFrame = function renderEveryFrame() {
109
- if (stopRenderFlag) return;
110
- requestAnimationFrameId = requestAnimationFrame(renderEveryFrame);
111
- css3DRenderer.render(scene, five.camera);
112
- };
113
-
114
- render = function render() {
115
- var _resizeObserver;
116
-
117
- scene.add(css3DObject);
118
- (_resizeObserver = resizeObserver) === null || _resizeObserver === void 0 ? void 0 : _resizeObserver.observe(fiveElement);
119
- renderEveryFrame();
120
-
121
- if (mode === 'behind' && mesh) {
122
- five.scene.add(mesh);
123
- disposers.push(function () {
124
- return mesh && five.scene.remove(mesh);
125
- });
126
- }
127
- };
128
- } else {
129
- render = function render() {
130
- scene.add(css3DObject);
131
- };
132
- }
97
+ var render = function () {
98
+ if (!inited) {
99
+ var css3DRendererSetSize = function css3DRendererSetSize() {
100
+ var rendererWidth = (0, _evenNumber["default"])(fiveElement.clientWidth);
101
+ var rendererHeight = (0, _evenNumber["default"])(fiveElement.clientHeight);
102
+ css3DRenderer.setSize(rendererWidth, rendererHeight);
103
+ };
104
+
105
+ css3DRendererSetSize();
106
+ resizeObserver = new ResizeObserver(css3DRendererSetSize);
107
+ css3DRenderer.domElement.style.position = 'absolute';
108
+ css3DRenderer.domElement.style.top = '0';
109
+ css3DRenderer.domElement.style.userSelect = 'none';
110
+ css3DRenderer.domElement.style.pointerEvents = 'none';
111
+
112
+ var renderEveryFrame = function renderEveryFrame() {
113
+ if (stopRenderFlag) return;
114
+ requestAnimationFrameId = requestAnimationFrame(renderEveryFrame);
115
+ css3DRenderer.render(scene, five.camera);
116
+ };
117
+
118
+ return function () {
119
+ var _resizeObserver;
120
+
121
+ scene.add(css3DObject);
122
+ (_resizeObserver = resizeObserver) === null || _resizeObserver === void 0 ? void 0 : _resizeObserver.observe(fiveElement);
123
+ renderEveryFrame();
124
+
125
+ if (mode === 'behind' && mesh) {
126
+ five.scene.add(mesh);
127
+ disposers.push(function () {
128
+ return mesh && five.scene.remove(mesh);
129
+ });
130
+ }
131
+ };
132
+ } else {
133
+ return function () {
134
+ scene.add(css3DObject);
135
+ };
136
+ }
137
+ }();
133
138
 
134
139
  if (frontModeUnInited) {
135
140
  var wrapper = fiveElement.parentElement || document.body;
@@ -1,12 +1,16 @@
1
1
  import type { FivePlugin } from '@realsee/five';
2
2
  export interface ModelChassisCompassPluginParameterType {
3
- northRad?: number;
4
- fbxUrl?: string;
3
+ north_rad?: number;
4
+ fbx_url?: string;
5
+ }
6
+ export interface ModelChassisCompassPluginData {
7
+ north_rad?: number;
8
+ fbx_url?: string;
5
9
  }
6
10
  export interface ModelChassisCompassPluginExportType {
7
11
  enable: () => void;
8
12
  disable: () => void;
9
- load: (northRad?: number, fbxUrl?: string) => Promise<boolean>;
13
+ load: (data?: ModelChassisCompassPluginData) => Promise<boolean>;
10
14
  }
11
15
  /**
12
16
  * 模型底盘指南针插件
@@ -13,6 +13,8 @@ var _FBXLoader = require("three/examples/jsm/loaders/FBXLoader");
13
13
 
14
14
  var _object3d2LocalMatrix = _interopRequireDefault(require("../../shared-utils/object3d2LocalMatrix"));
15
15
 
16
+ var _transfromToMeshBasicMaterial = _interopRequireDefault(require("../../shared-utils/three/transfromToMeshBasicMaterial"));
17
+
16
18
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
17
19
 
18
20
  function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
@@ -27,21 +29,21 @@ function _asyncToGenerator(fn) { return function () { var self = this, args = ar
27
29
  * 模型底盘指南针插件
28
30
  */
29
31
  var ModelChassisCompassPlugin = function ModelChassisCompassPlugin(five, params) {
30
- var defaultFbxUrl = params.fbxUrl || '//vrlab-static.ljcdn.com/release/web/v3/dipan3/dipan.FBX';
31
- var defaultNorthRad = params.northRad || undefined; // 局部状态
32
+ var defaultFbxUrl = params.fbx_url || '//vrlab-static.ljcdn.com/release/web/v3/dipan3/dipan.FBX';
33
+ var defaultNorthRad = params.north_rad || undefined; // 局部状态
32
34
 
33
35
  var state = {};
34
36
 
35
37
  var load = /*#__PURE__*/function () {
36
- var _ref = _asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee(northRad, fbxUrl) {
37
- var bounding, xOffset, zOffset, maxOffset, fbxLoader, object, rotation, _five$model$bounding, _five$model$bounding$, xMax, zMax, _five$model$bounding$2, xMin, yMin, zMin, position, scale;
38
+ var _ref = _asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee(data) {
39
+ var fbxUrl, northRad, bounding, xOffset, zOffset, maxOffset, fbxLoader, object, rotation, _five$model$bounding, _five$model$bounding$, xMax, zMax, _five$model$bounding$2, xMin, yMin, zMin, position, scale;
38
40
 
39
41
  return regeneratorRuntime.wrap(function _callee$(_context) {
40
42
  while (1) {
41
43
  switch (_context.prev = _context.next) {
42
44
  case 0:
43
- fbxUrl = fbxUrl || defaultFbxUrl;
44
- northRad = northRad || defaultNorthRad;
45
+ fbxUrl = (data === null || data === void 0 ? void 0 : data.fbx_url) || defaultFbxUrl;
46
+ northRad = (data === null || data === void 0 ? void 0 : data.north_rad) || defaultNorthRad;
45
47
 
46
48
  if (northRad) {
47
49
  _context.next = 4;
@@ -61,25 +63,10 @@ var ModelChassisCompassPlugin = function ModelChassisCompassPlugin(five, params)
61
63
 
62
64
  case 11:
63
65
  object = _context.sent;
64
- object.traverse(function (ele) {
65
- if (ele.type === 'Mesh') {
66
- var _ele$parent;
67
-
68
- var mesh = ele;
69
- var materialConf = Object.assign({
70
- map: mesh.material.map || {}
71
- }, {
72
- transparent: true,
73
- side: THREE.DoubleSide,
74
- blending: THREE.AdditiveBlending
75
- });
76
- mesh.material = new THREE.MeshBasicMaterial(materialConf);
77
- mesh.renderOrder = 1;
78
-
79
- if (((_ele$parent = ele.parent) === null || _ele$parent === void 0 ? void 0 : _ele$parent.type) === 'Mesh') {
80
- ele.renderOrder = ele.parent.renderOrder + 1;
81
- }
82
- }
66
+ (0, _transfromToMeshBasicMaterial["default"])(object, {
67
+ transparent: true,
68
+ side: THREE.DoubleSide,
69
+ blending: THREE.AdditiveBlending
83
70
  });
84
71
  rotation = [0, northRad - Math.PI / 2, 0];
85
72
  _five$model$bounding = five.model.bounding, _five$model$bounding$ = _five$model$bounding.max, xMax = _five$model$bounding$.x, zMax = _five$model$bounding$.z, _five$model$bounding$2 = _five$model$bounding.min, xMin = _five$model$bounding$2.x, yMin = _five$model$bounding$2.y, zMin = _five$model$bounding$2.z;
@@ -106,7 +93,7 @@ var ModelChassisCompassPlugin = function ModelChassisCompassPlugin(five, params)
106
93
  }, _callee);
107
94
  }));
108
95
 
109
- return function load(_x, _x2) {
96
+ return function load(_x) {
110
97
  return _ref.apply(this, arguments);
111
98
  };
112
99
  }();
@@ -1,7 +1,19 @@
1
1
  import type { FivePlugin } from '@realsee/five';
2
- export interface ModelEntryDoorGuidePluginParameterType {
2
+ import { Vector3Position } from '../../typings/math.type';
3
+ export interface ModelEntryDoorGuidePluginData {
4
+ position: Vector3Position;
5
+ rad: number;
6
+ fbx_url?: string;
3
7
  }
8
+ export declare type ModelEntryDoorGuidePluginParameterType = {
9
+ animationEnabled?: boolean;
10
+ } & ModelEntryDoorGuidePluginData;
4
11
  export interface ModelEntryDoorGuidePluginExportType {
12
+ enable: (config?: {
13
+ animationEnable?: boolean;
14
+ }) => boolean;
15
+ disable: () => boolean;
16
+ load: (data?: Partial<ModelEntryDoorGuidePluginData>) => Promise<boolean>;
5
17
  }
6
18
  /**
7
19
  * 模型入户门引导插件
@@ -1,15 +1,225 @@
1
1
  "use strict";
2
2
 
3
+ function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); }
4
+
3
5
  Object.defineProperty(exports, "__esModule", {
4
6
  value: true
5
7
  });
6
8
  exports["default"] = void 0;
7
9
 
10
+ var THREE = _interopRequireWildcard(require("three"));
11
+
12
+ var _FBXLoader = require("three/examples/jsm/loaders/FBXLoader");
13
+
14
+ var _createCanvasTextTexture = _interopRequireDefault(require("../../shared-utils/createCanvasTextTexture"));
15
+
16
+ var _transformPositionToVector = _interopRequireDefault(require("../../shared-utils/three/transformPositionToVector3"));
17
+
18
+ var _transfromToMeshBasicMaterial = _interopRequireDefault(require("../../shared-utils/three/transfromToMeshBasicMaterial"));
19
+
20
+ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
21
+
22
+ function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
23
+
24
+ function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || _typeof(obj) !== "object" && typeof obj !== "function") { return { "default": obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj["default"] = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
25
+
26
+ function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) { try { var info = gen[key](arg); var value = info.value; } catch (error) { reject(error); return; } if (info.done) { resolve(value); } else { Promise.resolve(value).then(_next, _throw); } }
27
+
28
+ function _asyncToGenerator(fn) { return function () { var self = this, args = arguments; return new Promise(function (resolve, reject) { var gen = fn.apply(self, args); function _next(value) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "next", value); } function _throw(err) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "throw", err); } _next(undefined); }); }; }
29
+
8
30
  /**
9
31
  * 模型入户门引导插件
10
32
  */
11
- var ModelEntryDoorGuidePlugin = function ModelEntryDoorGuidePlugin() {
12
- return {};
33
+ var ModelEntryDoorGuidePlugin = function ModelEntryDoorGuidePlugin(five, params) {
34
+ var _params$animationEnab, _params$position, _params$rad;
35
+
36
+ // 局部状态
37
+ var state = {};
38
+ var defaultAnimationEnable = (_params$animationEnab = params.animationEnabled) !== null && _params$animationEnab !== void 0 ? _params$animationEnab : true;
39
+ var defaultModelPosition = (_params$position = params.position) !== null && _params$position !== void 0 ? _params$position : undefined;
40
+ var defaultRad = (_params$rad = params.rad) !== null && _params$rad !== void 0 ? _params$rad : undefined;
41
+ var defaultFbxUrl = params.fbx_url || '//vrlab-image4.ljcdn.com/release/web/entryDoorMini/Anim_Door1.fbx';
42
+ var mixers = [];
43
+
44
+ var load = /*#__PURE__*/function () {
45
+ var _ref = _asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee(data) {
46
+ var _data$position, _data$position2, _data$rad, _data$fbx_url, _object$children, _object$children$, _object$children$$chi, _object$children$$chi2;
47
+
48
+ var modelPosition, rad, fbxUrl, object, textMesh;
49
+ return regeneratorRuntime.wrap(function _callee$(_context) {
50
+ while (1) {
51
+ switch (_context.prev = _context.next) {
52
+ case 0:
53
+ if (!(((_data$position = data === null || data === void 0 ? void 0 : data.position) !== null && _data$position !== void 0 ? _data$position : defaultModelPosition) === undefined)) {
54
+ _context.next = 2;
55
+ break;
56
+ }
57
+
58
+ return _context.abrupt("return", Promise.reject("ModelEntryDoorGuidePlugin.load(): position is undefined"));
59
+
60
+ case 2:
61
+ modelPosition = (0, _transformPositionToVector["default"])((_data$position2 = data === null || data === void 0 ? void 0 : data.position) !== null && _data$position2 !== void 0 ? _data$position2 : defaultModelPosition);
62
+ rad = (_data$rad = data === null || data === void 0 ? void 0 : data.rad) !== null && _data$rad !== void 0 ? _data$rad : defaultRad;
63
+ fbxUrl = (_data$fbx_url = data === null || data === void 0 ? void 0 : data.fbx_url) !== null && _data$fbx_url !== void 0 ? _data$fbx_url : defaultFbxUrl;
64
+ state.rad = rad;
65
+
66
+ if (!(rad === undefined)) {
67
+ _context.next = 8;
68
+ break;
69
+ }
70
+
71
+ return _context.abrupt("return", Promise.reject("ModelEntryDoorGuidePlugin.load(): rad is ".concat(rad)));
72
+
73
+ case 8:
74
+ _context.next = 10;
75
+ return new _FBXLoader.FBXLoader().loadAsync(fbxUrl);
76
+
77
+ case 10:
78
+ object = _context.sent;
79
+ // 设置位置
80
+ object.position.copy(modelPosition);
81
+ object.rotation.z = rad;
82
+ object.scale.set(0.8, 0.8, 0.8);
83
+ (0, _transfromToMeshBasicMaterial["default"])(object, {
84
+ transparent: true,
85
+ side: THREE.DoubleSide
86
+ });
87
+ textMesh = (_object$children = object.children) === null || _object$children === void 0 ? void 0 : (_object$children$ = _object$children[0]) === null || _object$children$ === void 0 ? void 0 : (_object$children$$chi = _object$children$.children) === null || _object$children$$chi === void 0 ? void 0 : (_object$children$$chi2 = _object$children$$chi[3]) === null || _object$children$$chi2 === void 0 ? void 0 : _object$children$$chi2.clone();
88
+
89
+ if (textMesh) {
90
+ _context.next = 18;
91
+ break;
92
+ }
93
+
94
+ return _context.abrupt("return", Promise.reject("ModelEntryDoorGuidePlugin.load(): textMesh is ".concat(textMesh)));
95
+
96
+ case 18:
97
+ textMesh.material = new THREE.MeshBasicMaterial({
98
+ transparent: true,
99
+ map: (0, _createCanvasTextTexture["default"])('入户门')
100
+ });
101
+ textMesh.renderOrder = 3;
102
+ object.children[0].add(textMesh);
103
+ state.object = object;
104
+ return _context.abrupt("return", true);
105
+
106
+ case 23:
107
+ case "end":
108
+ return _context.stop();
109
+ }
110
+ }
111
+ }, _callee);
112
+ }));
113
+
114
+ return function load(_x) {
115
+ return _ref.apply(this, arguments);
116
+ };
117
+ }();
118
+
119
+ var initAnimation = function initAnimation() {
120
+ if (state.animation) return;
121
+ if (!state.object) return console.error('ModelEntryDoorGuidePlugin.initAnimation(): state.object is ', state.object); // action
122
+
123
+ var animationSpeed = 1;
124
+ var mixer = new THREE.AnimationMixer(state.object);
125
+ mixers.push(mixer);
126
+ var action = mixer.clipAction(state.object.animations[0]);
127
+ action.timeScale = animationSpeed;
128
+ var stopAnimation;
129
+
130
+ var requestAnimationFrameLoop = function requestAnimationFrameLoop() {
131
+ var index = 0;
132
+ var oldTime = 0;
133
+ var minDeltaTime = 1000 / 30;
134
+
135
+ var animation = function animation(time) {
136
+ index = requestAnimationFrame(animation);
137
+ var deltaTime = time - oldTime;
138
+ if (deltaTime < minDeltaTime) return;
139
+ oldTime = time;
140
+ mixers.forEach(function (mixer) {
141
+ return mixer.update(deltaTime / 1000);
142
+ });
143
+ five.needsRender = true;
144
+ };
145
+
146
+ index = requestAnimationFrame(animation);
147
+ return function () {
148
+ cancelAnimationFrame(index);
149
+ };
150
+ };
151
+
152
+ var play = function play() {
153
+ if (stopAnimation) return;
154
+ action.play();
155
+ stopAnimation = requestAnimationFrameLoop(); // 开始播动画时,rotation可能会还原
156
+
157
+ requestAnimationFrame(function () {
158
+ if (state.object && state.object.rotation.z !== state.rad) state.object.rotation.z = state.rad;
159
+ });
160
+ };
161
+
162
+ var stop = function stop() {
163
+ var _stopAnimation;
164
+
165
+ action.stop();
166
+ (_stopAnimation = stopAnimation) === null || _stopAnimation === void 0 ? void 0 : _stopAnimation();
167
+ stopAnimation = undefined;
168
+ };
169
+
170
+ var animation = {
171
+ play: play,
172
+ stop: stop
173
+ };
174
+ state.animation = animation;
175
+ };
176
+
177
+ var show = function show(config) {
178
+ var _config$animationEnab;
179
+
180
+ if (!state.object) return console.error('ModelEntryDoorGuidePlugin.enable(): object is ', state.object);
181
+ var animationEnable = (_config$animationEnab = config === null || config === void 0 ? void 0 : config.animationEnable) !== null && _config$animationEnab !== void 0 ? _config$animationEnab : defaultAnimationEnable;
182
+
183
+ if (animationEnable) {
184
+ if (!state.animation) initAnimation();
185
+ state.animation.play();
186
+ }
187
+
188
+ five.scene.add(state.object);
189
+ five.needsRender = true;
190
+ };
191
+
192
+ var hide = function hide() {
193
+ if (!state.object) return;
194
+ if (state.animation) state.animation.stop();
195
+ five.scene.remove(state.object);
196
+ five.needsRender = true;
197
+ };
198
+
199
+ var modeChangeHandler = function modeChangeHandler(mode) {
200
+ return mode === 'Floorplan' ? show() : hide();
201
+ };
202
+
203
+ var enable = function enable(config) {
204
+ if (state.enabled) return true;
205
+ state.enabled = true;
206
+ five.on('modeChange', modeChangeHandler);
207
+ show(config);
208
+ return true;
209
+ };
210
+
211
+ var disable = function disable() {
212
+ if (!state.enabled) return true;
213
+ state.enabled = false;
214
+ five.off('modeChange', modeChangeHandler);
215
+ return true;
216
+ };
217
+
218
+ return {
219
+ load: load,
220
+ enable: enable,
221
+ disable: disable
222
+ };
13
223
  };
14
224
 
15
225
  var _default = ModelEntryDoorGuidePlugin;
@@ -0,0 +1,35 @@
1
+ import { Five } from '@realsee/five';
2
+ import { ModelRoomLabelPluginData } from './typings';
3
+ export declare type ModelRoomLabelPluginParameters = undefined;
4
+ export declare class ModelRoomLabelController {
5
+ private five;
6
+ private enabled;
7
+ private fiveModeEnabled;
8
+ private wrapper?;
9
+ private roomLabels;
10
+ private container;
11
+ constructor(five: Five);
12
+ dispose(): void;
13
+ /** 加载数据 */
14
+ load(data: ModelRoomLabelPluginData): void;
15
+ /** 设置插件容器 */
16
+ appendTo(wrapper: Element): this;
17
+ /** 禁用插件功能
18
+ * @description
19
+ * - 如果当前正在展示中,会清除所有展示的 DOM
20
+ * - 如果当前未展示,即使后续 Five 状态满足展示要求,也不会展示
21
+ * */
22
+ disable(): this;
23
+ /** 启用插件功能
24
+ * @description
25
+ * - 如果当前符合展示条件,会立刻展示
26
+ * - 如果不符合展示条件,会等待 Five 状态满足条件后再展示
27
+ */
28
+ enable(): this;
29
+ /** 监听 Five Mode 变化
30
+ * @description
31
+ * Mode 不符合要求时,立刻消失,满足要求时,需要等待动画结束再展示
32
+ */
33
+ private onFiveModeChange;
34
+ private render;
35
+ }