@realsee/dnalogel 0.1.7-alpha.1 → 0.1.7-alpha.10

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 (144) hide show
  1. package/components/GLTFView/index.d.ts +30 -1
  2. package/components/GLTFView/index.js +35 -3
  3. package/data/81zxMaeVKLQU93OZMG.d.ts +49 -0
  4. package/data/81zxMaeVKLQU93OZMG.js +633 -0
  5. package/data/PrXel3aqGbp34JQn.js +139 -1
  6. package/data/_vLykj3NWrllMrG06.d.ts +95 -0
  7. package/data/_vLykj3NWrllMrG06.js +1 -0
  8. package/data/vLykj3NWrllMrG06.js +335 -71
  9. package/libs/gltf-viewer/coordsToDirection.d.ts +1 -1
  10. package/libs/gltf-viewer/index.d.ts +25 -3
  11. package/libs/gltf-viewer/index.js +169 -52
  12. package/package.json +3 -3
  13. package/plugins/CSS3DRenderPlugin/index.js +15 -10
  14. package/plugins/CSS3DRenderPlugin/utils/createResizeObserver.d.ts +7 -0
  15. package/plugins/CSS3DRenderPlugin/utils/createResizeObserver.js +34 -0
  16. package/plugins/ModelChassisCompassPlugin/index.d.ts +1 -1
  17. package/plugins/ModelChassisCompassPlugin/index.js +2 -1
  18. package/plugins/ModelEntryDoorGuidePlugin/index.d.ts +4 -0
  19. package/plugins/ModelEntryDoorGuidePlugin/index.js +13 -7
  20. package/plugins/ModelRoomLabelPlugin/Controller.js +1 -0
  21. package/plugins/ModelRoomLabelPlugin/RoomLabelItem.js +5 -5
  22. package/plugins/ModelRoomLabelPlugin/index.d.ts +4 -0
  23. package/plugins/ModelRoomLabelPlugin/index.js +7 -2
  24. package/plugins/PanoMaskSelectorPlugin/fragmentShader.d.ts +1 -1
  25. package/plugins/PanoMaskSelectorPlugin/fragmentShader.js +1 -1
  26. package/plugins/PanoMeasurePlugin/Controller/BaseController.d.ts +36 -0
  27. package/plugins/PanoMeasurePlugin/Controller/BaseController.js +103 -0
  28. package/plugins/PanoMeasurePlugin/Controller/EditController.d.ts +52 -0
  29. package/plugins/PanoMeasurePlugin/Controller/EditController.js +341 -0
  30. package/plugins/PanoMeasurePlugin/Controller/ShortcutKeyController.d.ts +12 -0
  31. package/plugins/PanoMeasurePlugin/Controller/ShortcutKeyController.js +69 -0
  32. package/plugins/PanoMeasurePlugin/Controller/WatchController.d.ts +25 -0
  33. package/plugins/PanoMeasurePlugin/Controller/WatchController.js +371 -0
  34. package/plugins/PanoMeasurePlugin/Controller/index.d.ts +61 -0
  35. package/plugins/PanoMeasurePlugin/Controller/index.js +230 -0
  36. package/plugins/PanoMeasurePlugin/Model/index.d.ts +38 -0
  37. package/plugins/PanoMeasurePlugin/Model/index.js +235 -0
  38. package/plugins/PanoMeasurePlugin/Model/line.d.ts +30 -0
  39. package/plugins/PanoMeasurePlugin/Model/line.js +121 -0
  40. package/plugins/PanoMeasurePlugin/Model/point.d.ts +16 -0
  41. package/plugins/PanoMeasurePlugin/Model/point.js +68 -0
  42. package/plugins/PanoMeasurePlugin/Model/polyline.d.ts +16 -0
  43. package/plugins/PanoMeasurePlugin/Model/polyline.js +109 -0
  44. package/plugins/PanoMeasurePlugin/Modules/DeleteDom/_Assets/delete.svg.d.ts +2 -0
  45. package/plugins/PanoMeasurePlugin/Modules/DeleteDom/_Assets/delete.svg.js +11 -0
  46. package/plugins/PanoMeasurePlugin/Modules/DeleteDom/_Assets/delete_bg.png.d.ts +2 -0
  47. package/plugins/PanoMeasurePlugin/Modules/DeleteDom/_Assets/delete_bg.png.js +11 -0
  48. package/plugins/PanoMeasurePlugin/Modules/DeleteDom/_Assets/delete_hover_bg.png.d.ts +2 -0
  49. package/plugins/PanoMeasurePlugin/Modules/DeleteDom/_Assets/delete_hover_bg.png.js +11 -0
  50. package/plugins/PanoMeasurePlugin/Modules/DeleteDom/index.d.ts +22 -0
  51. package/plugins/PanoMeasurePlugin/Modules/DeleteDom/index.js +182 -0
  52. package/plugins/PanoMeasurePlugin/Modules/FiveHelper.d.ts +11 -0
  53. package/plugins/PanoMeasurePlugin/Modules/FiveHelper.js +66 -0
  54. package/plugins/PanoMeasurePlugin/Modules/GuideController.d.ts +18 -0
  55. package/plugins/PanoMeasurePlugin/Modules/GuideController.js +107 -0
  56. package/plugins/PanoMeasurePlugin/Modules/Magnifier.d.ts +24 -0
  57. package/plugins/PanoMeasurePlugin/Modules/Magnifier.js +139 -0
  58. package/plugins/PanoMeasurePlugin/Modules/UIController/HTML.d.ts +6 -0
  59. package/plugins/PanoMeasurePlugin/Modules/UIController/HTML.js +26 -0
  60. package/plugins/PanoMeasurePlugin/Modules/UIController/MainBtnController.d.ts +18 -0
  61. package/plugins/PanoMeasurePlugin/Modules/UIController/MainBtnController.js +169 -0
  62. package/plugins/PanoMeasurePlugin/Modules/UIController/Revoke/index.d.ts +12 -0
  63. package/plugins/PanoMeasurePlugin/Modules/UIController/Revoke/index.js +59 -0
  64. package/plugins/PanoMeasurePlugin/Modules/UIController/index.d.ts +16 -0
  65. package/plugins/PanoMeasurePlugin/Modules/UIController/index.js +123 -0
  66. package/plugins/PanoMeasurePlugin/Modules/UIController/style.d.ts +17 -0
  67. package/plugins/PanoMeasurePlugin/Modules/UIController/style.js +103 -0
  68. package/plugins/PanoMeasurePlugin/index.d.ts +7 -0
  69. package/plugins/PanoMeasurePlugin/index.js +20 -0
  70. package/plugins/PanoMeasurePlugin/typings/data.d.ts +28 -0
  71. package/plugins/PanoMeasurePlugin/typings/data.js +7 -0
  72. package/plugins/PanoMeasurePlugin/typings/event.type.d.ts +28 -0
  73. package/plugins/PanoMeasurePlugin/typings/event.type.js +7 -0
  74. package/plugins/PanoMeasurePlugin/typings/utils.type.d.ts +1 -0
  75. package/plugins/PanoMeasurePlugin/typings/utils.type.js +7 -0
  76. package/plugins/PanoMeasurePlugin/utils/clearGroup.d.ts +2 -0
  77. package/plugins/PanoMeasurePlugin/utils/clearGroup.js +16 -0
  78. package/plugins/PanoMeasurePlugin/utils/constants.d.ts +4 -0
  79. package/plugins/PanoMeasurePlugin/utils/constants.js +47 -0
  80. package/plugins/PanoMeasurePlugin/utils/distanceDom.d.ts +28 -0
  81. package/plugins/PanoMeasurePlugin/utils/distanceDom.js +147 -0
  82. package/plugins/PanoMeasurePlugin/utils/findAssociatedLines.d.ts +2 -0
  83. package/plugins/PanoMeasurePlugin/utils/findAssociatedLines.js +37 -0
  84. package/plugins/PanoMeasurePlugin/utils/findClosestPoint.d.ts +10 -0
  85. package/plugins/PanoMeasurePlugin/utils/findClosestPoint.js +49 -0
  86. package/plugins/PanoMeasurePlugin/utils/getIntersectionFromEvent.d.ts +4 -0
  87. package/plugins/PanoMeasurePlugin/utils/getIntersectionFromEvent.js +20 -0
  88. package/plugins/PanoMeasurePlugin/utils/getPointFromHammerEvent.d.ts +10 -0
  89. package/plugins/PanoMeasurePlugin/utils/getPointFromHammerEvent.js +33 -0
  90. package/plugins/PanoMeasurePlugin/utils/ironbox.d.ts +1 -0
  91. package/plugins/PanoMeasurePlugin/utils/ironbox.js +14 -0
  92. package/plugins/PanoMeasurePlugin/utils/isNDCPointInScreen.d.ts +2 -0
  93. package/plugins/PanoMeasurePlugin/utils/isNDCPointInScreen.js +16 -0
  94. package/plugins/PanoMeasurePlugin/utils/line.d.ts +17 -0
  95. package/plugins/PanoMeasurePlugin/utils/line.js +61 -0
  96. package/plugins/PanoMeasurePlugin/utils/math.d.ts +17 -0
  97. package/plugins/PanoMeasurePlugin/utils/math.js +57 -0
  98. package/plugins/PanoMeasurePlugin/utils/mouseGroup.d.ts +2 -0
  99. package/plugins/PanoMeasurePlugin/utils/mouseGroup.js +42 -0
  100. package/plugins/PanoMeasurePlugin/utils/ndc2Screen.d.ts +5 -0
  101. package/plugins/PanoMeasurePlugin/utils/ndc2Screen.js +16 -0
  102. package/plugins/PanoRulerPlugin/index.d.ts +4 -0
  103. package/plugins/PanoRulerPlugin/index.js +6 -1
  104. package/plugins/floorplan/Assets/floorplanExtraObject.d.ts +1 -1
  105. package/plugins/floorplan/Assets/floorplanExtraObject.js +3 -3
  106. package/plugins/floorplan/ModelFloorplanPlugin/Controller.d.ts +5 -2
  107. package/plugins/floorplan/ModelFloorplanPlugin/Controller.js +22 -11
  108. package/plugins/floorplan/ModelFloorplanPlugin/components/Camera.js +4 -4
  109. package/plugins/floorplan/ModelFloorplanPlugin/components/Compass.js +5 -5
  110. package/plugins/floorplan/ModelFloorplanPlugin/components/NowFloor/RoomLabels.js +2 -2
  111. package/plugins/floorplan/ModelFloorplanPlugin/components/NowFloor/RoomMaterial.d.ts +11 -0
  112. package/plugins/floorplan/ModelFloorplanPlugin/components/NowFloor/RoomMaterial.js +174 -0
  113. package/plugins/floorplan/ModelFloorplanPlugin/components/NowFloor/RuleLabels.d.ts +8 -0
  114. package/plugins/floorplan/ModelFloorplanPlugin/components/NowFloor/RuleLabels.js +178 -0
  115. package/plugins/floorplan/ModelFloorplanPlugin/components/NowFloor/index.d.ts +2 -0
  116. package/plugins/floorplan/ModelFloorplanPlugin/components/NowFloor/index.js +14 -2
  117. package/plugins/floorplan/ModelFloorplanPlugin/components/index.d.ts +3 -0
  118. package/plugins/floorplan/ModelFloorplanPlugin/components/index.js +1 -1
  119. package/plugins/floorplan/ModelFloorplanPlugin/typings/utility.d.ts +2 -0
  120. package/plugins/floorplan/ModelFloorplanPlugin/typings/utility.js +7 -0
  121. package/plugins/floorplan/ModelFloorplanPlugin/utils/constant.d.ts +1 -1
  122. package/plugins/floorplan/ModelFloorplanPlugin/utils/constant.js +1 -1
  123. package/plugins/floorplan/PanoFloorplanRadarPlugin/Content/Camera.js +1 -0
  124. package/plugins/floorplan/PanoFloorplanRadarPlugin/Content/Camera.style.js +4 -4
  125. package/plugins/floorplan/PanoFloorplanRadarPlugin/Content/NowFloor/ExtraObjects.js +2 -2
  126. package/plugins/floorplan/PanoFloorplanRadarPlugin/Controller.d.ts +1 -1
  127. package/plugins/floorplan/PanoFloorplanRadarPlugin/Controller.js +3 -3
  128. package/plugins/floorplan/TopviewFloorplanPlugin/Controller.d.ts +3 -0
  129. package/plugins/floorplan/TopviewFloorplanPlugin/Controller.js +16 -6
  130. package/plugins/floorplan/index.d.ts +4 -0
  131. package/plugins/floorplan/index.js +13 -0
  132. package/plugins/floorplan/typings/floorplanData.d.ts +2 -0
  133. package/plugins/floorplan/typings/floorplanServerData.d.ts +3 -1
  134. package/plugins/floorplan/typings/floorplanServerData.js +3 -3
  135. package/plugins/floorplan/utils/formatData.js +3 -2
  136. package/shared-utils/changeModelCanvasOpacity.d.ts +2 -0
  137. package/shared-utils/{changeModelCanvansOpacity.js → changeModelCanvasOpacity.js} +2 -2
  138. package/shared-utils/math/evenNumber.d.ts +3 -1
  139. package/shared-utils/math/evenNumber.js +4 -2
  140. package/shared-utils/removeArrayItem.d.ts +7 -0
  141. package/shared-utils/removeArrayItem.js +22 -0
  142. package/shared-utils/three/loadTexture.d.ts +2 -2
  143. package/shared-utils/three/loadTexture.js +21 -2
  144. package/shared-utils/changeModelCanvansOpacity.d.ts +0 -2
@@ -11,8 +11,16 @@ export interface GLTFViewerConfig {
11
11
  backgroundHDR?: string;
12
12
  pixelRatio?: number;
13
13
  initial?: Partial<GLTFViewerState>;
14
- pointLight?: THREE.PointLight;
15
- directionalLight?: THREE.DirectionalLight;
14
+ pointLight?: THREE.PointLight | false;
15
+ directionalLight?: THREE.DirectionalLight | false;
16
+ ambientLight?: THREE.AmbientLight | false;
17
+ logarithmicDepthBuffer?: boolean;
18
+ minFov?: number;
19
+ maxFov?: number;
20
+ toneMapping?: {
21
+ toneMapping?: THREE.ToneMapping;
22
+ toneMappingExposure?: number;
23
+ };
16
24
  }
17
25
  export interface GLTFViewerState {
18
26
  fov: number;
@@ -23,7 +31,7 @@ export declare type GLTFViewerEventMap = {
23
31
  'stateChange'(state: GLTFViewerState): void;
24
32
  'progressing'(progressing: number): void;
25
33
  'willLoad'(): void;
26
- 'loaded'(gltf: GLTF): void;
34
+ 'loaded'(gltf: GLTF, scene: THREE.Scene, renderer: THREE.WebGLRenderer): void;
27
35
  'loadError'(error: ErrorEvent): void;
28
36
  };
29
37
  export declare class GLTFViewer extends Subscribe<GLTFViewerEventMap> {
@@ -39,9 +47,14 @@ export declare class GLTFViewer extends Subscribe<GLTFViewerEventMap> {
39
47
  latitude?: number;
40
48
  longitude?: number;
41
49
  });
50
+ set minFov(fov: number);
51
+ get minFov(): number;
52
+ set maxFov(fov: number);
53
+ get maxFov(): number;
42
54
  /**
43
55
  *
44
56
  * @param url glTF 模型CDN地址
57
+ * @param options adaptive 是否开启自适应fov
45
58
  */
46
59
  load(url: string): void;
47
60
  /**
@@ -50,8 +63,17 @@ export declare class GLTFViewer extends Subscribe<GLTFViewerEventMap> {
50
63
  * @param size
51
64
  */
52
65
  appendTo(container: HTMLDivElement, size?: GLTFViewerSize): void;
66
+ /**
67
+ * 刷新:如果传递宽高则以该宽高重新绘制;否则,以父容器的宽高重新绘制。
68
+ * @param size
69
+ */
70
+ refresh(size?: GLTFViewerSize): void;
53
71
  /**
54
72
  * 销毁
55
73
  */
56
74
  dispose(): void;
75
+ /**
76
+ * 响应式fov
77
+ */
78
+ fitFov(): void;
57
79
  }
@@ -23,12 +23,12 @@ Object.defineProperty(exports, "__esModule", {
23
23
  });
24
24
  exports.GLTFViewer = void 0;
25
25
 
26
+ require("core-js/modules/es.object.assign.js");
27
+
26
28
  require("core-js/modules/es.function.bind.js");
27
29
 
28
30
  require("core-js/modules/web.timers.js");
29
31
 
30
- require("core-js/modules/es.object.assign.js");
31
-
32
32
  require("core-js/modules/es.object.to-string.js");
33
33
 
34
34
  require("core-js/modules/es.promise.js");
@@ -37,10 +37,10 @@ require("core-js/modules/es.date.to-string.js");
37
37
 
38
38
  require("core-js/modules/es.regexp.to-string.js");
39
39
 
40
- require("core-js/modules/es.number.is-integer.js");
41
-
42
40
  require("core-js/modules/es.number.constructor.js");
43
41
 
42
+ require("core-js/modules/es.array.concat.js");
43
+
44
44
  var _assertThisInitialized2 = _interopRequireDefault(require("@babel/runtime/helpers/assertThisInitialized"));
45
45
 
46
46
  var _inherits2 = _interopRequireDefault(require("@babel/runtime/helpers/inherits"));
@@ -67,8 +67,6 @@ var _coordsMoveByOffset = require("./coordsMoveByOffset");
67
67
 
68
68
  var _getFrameTime = require("./getFrameTime");
69
69
 
70
- var _formatRad = require("./formatRad");
71
-
72
70
  var _coordsToDirection = require("./coordsToDirection");
73
71
 
74
72
  var _mouseWheel = require("./mouseWheel");
@@ -79,6 +77,8 @@ var _uuid = _interopRequireDefault(require("./uuid"));
79
77
 
80
78
  var _Subscribe2 = require("./Subscribe");
81
79
 
80
+ var _formatRad = require("./formatRad");
81
+
82
82
  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); }
83
83
 
84
84
  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; }
@@ -89,8 +89,8 @@ function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Re
89
89
 
90
90
  var defaultPos = {
91
91
  longitude: 0,
92
- latitude: -0.3,
93
- fov: 35
92
+ latitude: 0,
93
+ fov: 0
94
94
  };
95
95
  var ERROR_NO_CONTROLLER = 'GLTFViewer 实例丢失';
96
96
  var loader = new _GLTFLoader.GLTFLoader();
@@ -100,11 +100,16 @@ var Controller = /*#__PURE__*/function () {
100
100
  var _this = this;
101
101
 
102
102
  (0, _classCallCheck2["default"])(this, Controller);
103
- (0, _defineProperty2["default"])(this, "fov", 35);
103
+ (0, _defineProperty2["default"])(this, "fov", 0);
104
104
  (0, _defineProperty2["default"])(this, "longitude", 0);
105
- (0, _defineProperty2["default"])(this, "latitude", -0.3);
105
+ (0, _defineProperty2["default"])(this, "latitude", 0);
106
106
  (0, _defineProperty2["default"])(this, "needsRender", false);
107
- // 异步事件回调
107
+ this.config = Object.assign({
108
+ maxFov: 120,
109
+ minFov: 1,
110
+ logarithmicDepthBuffer: true
111
+ }, config); // 异步事件回调
112
+
108
113
  this.callbacks = callbacks; // 默认状态参数
109
114
 
110
115
  var initial = config.initial || {};
@@ -131,11 +136,18 @@ var Controller = /*#__PURE__*/function () {
131
136
 
132
137
  this.renderer = new THREE.WebGLRenderer({
133
138
  antialias: config.antialias,
134
- alpha: true
139
+ alpha: true,
140
+ logarithmicDepthBuffer: config.logarithmicDepthBuffer
135
141
  });
136
142
  this.renderer.outputEncoding = THREE.sRGBEncoding;
137
- this.renderer.toneMapping = THREE.ReinhardToneMapping;
138
- this.renderer.toneMappingExposure = 1.5;
143
+
144
+ if (config.toneMapping) {
145
+ var _config$toneMapping = config.toneMapping,
146
+ toneMapping = _config$toneMapping.toneMapping,
147
+ toneMappingExposure = _config$toneMapping.toneMappingExposure;
148
+ if (toneMapping) this.renderer.toneMapping = toneMapping;
149
+ if (toneMappingExposure !== undefined) this.renderer.toneMappingExposure = toneMappingExposure;
150
+ }
139
151
 
140
152
  if (config.backgroundColor) {
141
153
  this.renderer.setClearColor(config.backgroundColor, 0);
@@ -147,13 +159,24 @@ var Controller = /*#__PURE__*/function () {
147
159
  } // 相机
148
160
 
149
161
 
150
- this.camera = new THREE.PerspectiveCamera(this.fov, 1, 0.1, 10000); // 光照
162
+ this.camera = new THREE.PerspectiveCamera(this.fov, 1, 0.1, 1500); // 光照
163
+
164
+ if (config.pointLight !== false) {
165
+ this.pointLight = config.pointLight || new THREE.PointLight(0xfffffff, 1, 1500);
166
+ this.scene.add(this.pointLight);
167
+ }
168
+
169
+ if (config.directionalLight !== false) {
170
+ this.directionLight = config.directionalLight || new THREE.DirectionalLight(0xfffffff, 0.1);
171
+ this.directionLight.position.setY(-1);
172
+ this.scene.add(this.directionLight);
173
+ }
174
+
175
+ if (config.ambientLight !== false) {
176
+ this.ambientLight = config.ambientLight || new THREE.AmbientLight(0xfffffff);
177
+ this.scene.add(this.ambientLight);
178
+ } // 背景 HDR
151
179
 
152
- this.pointLight = config.pointLight || new THREE.PointLight(0xfffffff, 0.9, 10000);
153
- this.scene.add(this.pointLight);
154
- this.directionLight = config.directionalLight || new THREE.DirectionalLight(0xfffffff, 0.1);
155
- this.directionLight.position.setY(-1);
156
- this.scene.add(this.directionLight); // 背景 HDR
157
180
 
158
181
  if (config.backgroundHDR) {
159
182
  var pmremGenerator = new THREE.PMREMGenerator(this.renderer);
@@ -205,6 +228,16 @@ var Controller = /*#__PURE__*/function () {
205
228
  }
206
229
 
207
230
  (0, _createClass2["default"])(Controller, [{
231
+ key: "minFov",
232
+ get: function get() {
233
+ return this.config.minFov || 1;
234
+ }
235
+ }, {
236
+ key: "maxFov",
237
+ get: function get() {
238
+ return this.config.maxFov || 120;
239
+ }
240
+ }, {
208
241
  key: "pause",
209
242
  value: function pause() {// nothing todo
210
243
  }
@@ -212,8 +245,7 @@ var Controller = /*#__PURE__*/function () {
212
245
  key: "clear",
213
246
  value: function clear() {
214
247
  if (this.target) {
215
- this.scene.remove(this.target.scene); // disposeObject(this.target)
216
-
248
+ this.scene.remove(this.target.scene);
217
249
  this.update(defaultPos);
218
250
  this.target = undefined;
219
251
  }
@@ -251,6 +283,8 @@ var Controller = /*#__PURE__*/function () {
251
283
  _this3.target.scene.visible = true;
252
284
 
253
285
  _this3.update({});
286
+
287
+ _this3.callbacks.loaded(object, _this3.scene, _this3.renderer);
254
288
  }
255
289
  }, 50);
256
290
  }
@@ -310,33 +344,61 @@ var Controller = /*#__PURE__*/function () {
310
344
  latitude = state.latitude;
311
345
  }
312
346
 
313
- var center = new THREE.Vector3();
314
- var box = new THREE.Box3();
347
+ if (!this.target || !this.target.scene) return;
348
+ var boxHelper = new THREE.BoxHelper(this.target.scene, 0x2bb8aa);
315
349
 
316
- if (this.target) {
317
- box.expandByObject(this.target.scene);
318
- box.getCenter(center);
319
- }
350
+ var _ref = boxHelper.geometry.boundingSphere || {},
351
+ center = _ref.center,
352
+ radius = _ref.radius;
320
353
 
354
+ if (!center || !radius) return;
355
+ var box = new THREE.Box3();
356
+ box.expandByObject(this.target.scene);
357
+ box.getCenter(center);
321
358
  longitude = (0, _formatRad.formatRad)(longitude);
322
- latitude = Math.max(-Math.PI / 2 + 0.01, Math.min(+Math.PI / 2, latitude));
323
- var distance = Math.max(center.distanceTo(box.min), center.distanceTo(box.max));
359
+ latitude = Math.max(-Math.PI / 2 + 0.01, Math.min(+Math.PI / 2, latitude)); // 距离
360
+
361
+ var distance = radius / Math.sin(Math.PI / 4) * 3;
362
+ {// debug
363
+ // const geometry = new THREE.SphereGeometry(radius, 32, 16)
364
+ // const material = new THREE.MeshBasicMaterial({ color: 0x0000aa, wireframe: true })
365
+ // const sphere = new THREE.Mesh(geometry, material)
366
+ // sphere.position.copy(center.clone())
367
+ // this.scene.add(sphere)
368
+ } // 朝向
369
+
324
370
  var direction = (0, _coordsToDirection.coordsToDirection)({
325
371
  longitude: longitude,
326
372
  latitude: latitude
327
373
  });
328
- direction.setLength(distance * 3);
374
+ direction.setLength(distance);
329
375
  this.camera.position.copy(center.clone().add(direction));
330
376
  this.camera.lookAt(center);
331
- var lightDirection = (0, _coordsToDirection.coordsToDirection)({
332
- longitude: longitude,
333
- latitude: -Math.PI / 6
334
- });
335
- lightDirection.setLength(distance * 3);
336
- this.pointLight.position.copy(center.clone().add(lightDirection));
377
+
378
+ if (this.pointLight) {
379
+ var lightDirection = (0, _coordsToDirection.coordsToDirection)({
380
+ longitude: longitude,
381
+ latitude: -Math.PI / 6
382
+ });
383
+ lightDirection.setLength(distance * 3);
384
+ this.pointLight.position.copy(center.clone().add(lightDirection));
385
+ }
386
+
387
+ var calcFov = function calcFov(distance, width, r) {
388
+ var vertical = r < 1 ? width / r : width;
389
+ var fov = Math.atan(vertical / distance / 2) * 2 * (180 / Math.PI);
390
+ return fov;
391
+ };
392
+
393
+ var d = this.camera.position.distanceTo(center);
394
+
395
+ if (fov === 0) {
396
+ fov = calcFov(d, radius * 2, this.renderer.domElement.offsetWidth / this.renderer.domElement.offsetHeight);
397
+ }
398
+
399
+ fov = Math.max(this.minFov, Math.min(this.maxFov, fov));
337
400
 
338
401
  if (fov !== this.fov) {
339
- fov = Math.max(25, Math.min(60, fov));
340
402
  this.camera.fov = fov;
341
403
  this.camera.updateProjectionMatrix();
342
404
  }
@@ -439,8 +501,9 @@ var Controller = /*#__PURE__*/function () {
439
501
  return;
440
502
  }
441
503
 
504
+ var fov = this.__pinchCurrentFov ? this.__pinchCurrentFov / scale : 1;
442
505
  this.update({
443
- fov: (this.__pinchCurrentFov || 0) / scale
506
+ fov: fov
444
507
  });
445
508
  }
446
509
  }, {
@@ -482,8 +545,9 @@ var Controller = /*#__PURE__*/function () {
482
545
  key: "__onMouseWheel",
483
546
  value: function __onMouseWheel(event) {
484
547
  this.__interiaMovement = false;
548
+ var fov = this.fov - event.delta;
485
549
  this.update({
486
- fov: this.fov - event.delta
550
+ fov: fov <= 1 ? 1 : fov
487
551
  });
488
552
  }
489
553
  }, {
@@ -497,8 +561,6 @@ var Controller = /*#__PURE__*/function () {
497
561
  loader.load(url, function (gltf) {
498
562
  _this6.setTarget(gltf);
499
563
 
500
- _this6.callbacks.loaded(gltf);
501
-
502
564
  resolve(true);
503
565
  }, function (xhr) {
504
566
  _this6.callbacks.progressing(xhr.loaded / xhr.total * 100);
@@ -551,13 +613,16 @@ var GLTFViewer = /*#__PURE__*/function (_Subscribe) {
551
613
  willLoad: function willLoad() {
552
614
  return _this7.emit('willLoad');
553
615
  },
554
- loaded: function loaded(gltf) {
555
- return _this7.emit('loaded', gltf);
616
+ loaded: function loaded(gltf, scene, renderer) {
617
+ return _this7.emit('loaded', gltf, scene, renderer);
556
618
  },
557
619
  loadError: function loadError(error) {
558
620
  return _this7.emit('loadError', error);
559
621
  }
560
622
  });
623
+ Object.assign(window, {
624
+ $controller: controller
625
+ });
561
626
  caches[_this7.uuid] = controller;
562
627
  return _this7;
563
628
  }
@@ -574,12 +639,12 @@ var GLTFViewer = /*#__PURE__*/function (_Subscribe) {
574
639
  }, {
575
640
  set: function set(obj, prop, value) {
576
641
  if (prop === 'fov') {
577
- if (!Number.isInteger(value)) {
642
+ if (Number(value) === NaN) {
578
643
  throw new TypeError('The fov is not an number');
579
644
  }
580
645
 
581
- if (value > 60 || value < 20) {
582
- throw new RangeError('The fov seems invalid~ fov: [20, 60]');
646
+ if (value > controller.maxFov || value < controller.minFov) {
647
+ throw new RangeError("The fov seems invalid~ fov: [".concat(controller.minFov, ", ").concat(controller.maxFov, "]"));
583
648
  }
584
649
  }
585
650
 
@@ -592,10 +657,10 @@ var GLTFViewer = /*#__PURE__*/function (_Subscribe) {
592
657
  });
593
658
  return proxy;
594
659
  },
595
- set: function set(_ref) {
596
- var fov = _ref.fov,
597
- latitude = _ref.latitude,
598
- longitude = _ref.longitude;
660
+ set: function set(_ref2) {
661
+ var fov = _ref2.fov,
662
+ latitude = _ref2.latitude,
663
+ longitude = _ref2.longitude;
599
664
  var controller = caches[this.uuid];
600
665
  if (!controller) throw new Error(ERROR_NO_CONTROLLER);
601
666
  controller.update({
@@ -604,11 +669,38 @@ var GLTFViewer = /*#__PURE__*/function (_Subscribe) {
604
669
  longitude: longitude === undefined ? controller.longitude : longitude
605
670
  });
606
671
  }
672
+ }, {
673
+ key: "minFov",
674
+ get: function get() {
675
+ var controller = caches[this.uuid];
676
+ if (!controller) throw new Error(ERROR_NO_CONTROLLER);
677
+ return controller.minFov;
678
+ },
679
+ set: function set(fov) {
680
+ var controller = caches[this.uuid];
681
+ if (!controller) throw new Error(ERROR_NO_CONTROLLER);
682
+ controller.config.minFov = fov;
683
+ controller.update({});
684
+ }
685
+ }, {
686
+ key: "maxFov",
687
+ get: function get() {
688
+ var controller = caches[this.uuid];
689
+ if (!controller) throw new Error(ERROR_NO_CONTROLLER);
690
+ return controller.maxFov;
691
+ }
607
692
  /**
608
693
  *
609
694
  * @param url glTF 模型CDN地址
695
+ * @param options adaptive 是否开启自适应fov
610
696
  */
611
-
697
+ ,
698
+ set: function set(fov) {
699
+ var controller = caches[this.uuid];
700
+ if (!controller) throw new Error(ERROR_NO_CONTROLLER);
701
+ controller.config.maxFov = fov;
702
+ controller.update({});
703
+ }
612
704
  }, {
613
705
  key: "load",
614
706
  value: function load(url) {
@@ -629,6 +721,18 @@ var GLTFViewer = /*#__PURE__*/function (_Subscribe) {
629
721
  if (!controller) throw new Error(ERROR_NO_CONTROLLER);
630
722
  controller.appendTo(container, size);
631
723
  }
724
+ /**
725
+ * 刷新:如果传递宽高则以该宽高重新绘制;否则,以父容器的宽高重新绘制。
726
+ * @param size
727
+ */
728
+
729
+ }, {
730
+ key: "refresh",
731
+ value: function refresh(size) {
732
+ var controller = caches[this.uuid];
733
+ if (!controller) throw new Error(ERROR_NO_CONTROLLER);
734
+ controller.refresh(size);
735
+ }
632
736
  /**
633
737
  * 销毁
634
738
  */
@@ -641,6 +745,19 @@ var GLTFViewer = /*#__PURE__*/function (_Subscribe) {
641
745
  if (controller.dispose) controller.dispose();
642
746
  delete caches[this.uuid];
643
747
  }
748
+ /**
749
+ * 响应式fov
750
+ */
751
+
752
+ }, {
753
+ key: "fitFov",
754
+ value: function fitFov() {
755
+ var controller = caches[this.uuid];
756
+ if (!controller) throw new Error(ERROR_NO_CONTROLLER);
757
+ controller.update({
758
+ fov: 0
759
+ });
760
+ }
644
761
  }]);
645
762
  return GLTFViewer;
646
763
  }(_Subscribe2.Subscribe);
package/package.json CHANGED
@@ -1,10 +1,10 @@
1
1
  {
2
2
  "name": "@realsee/dnalogel",
3
- "version": "0.1.7-alpha.1",
4
- "description": "如视前端 Componets、Plugins 兼部分 SDKs \"Dnalogel\" 库。",
3
+ "version": "0.1.7-alpha.10",
4
+ "description": "如视前端 Components、Plugins 兼部分 SDKs \"Dnalogel\" 库。",
5
5
  "author": "BEIKE REALSEE TECHNOLOGY (HK) LIMITED",
6
6
  "peerDependencies": {
7
- "@realsee/five": "^5.0.0-alpha.52",
7
+ "@realsee/five": "^5.0.0-alpha.84",
8
8
  "@tweenjs/tween.js": "^18.6.4",
9
9
  "@types/styled-jsx": "^2.2.9",
10
10
  "hammerjs": "^2.0.8",
@@ -47,6 +47,8 @@ var _centerPoint = _interopRequireDefault(require("../../shared-utils/three/cent
47
47
 
48
48
  var _transformPositionToVector = _interopRequireDefault(require("../../shared-utils/three/transformPositionToVector3"));
49
49
 
50
+ var _createResizeObserver = _interopRequireDefault(require("./utils/createResizeObserver"));
51
+
50
52
  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); }
51
53
 
52
54
  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; }
@@ -125,13 +127,19 @@ var CSS3DRenderPlugin = function CSS3DRenderPlugin(five) {
125
127
  var render = function () {
126
128
  if (!inited) {
127
129
  var css3DRendererSetSize = function css3DRendererSetSize() {
128
- var rendererWidth = (0, _evenNumber["default"])(fiveElement.clientWidth);
129
- var rendererHeight = (0, _evenNumber["default"])(fiveElement.clientHeight);
130
+ // 这里evenNumber策略是遇到奇数会加1,不知道为啥会触发滚动条显示,导致fiveElement变小,fiveElement变小又触发了这里的resize,宽高变小,滚动条消失,然后又触发resize。。。无限循环
131
+ // 为了规避上面这种情况,evenNumber设置了一个参数,遇到奇数可选择减一
132
+ var rendererWidth = (0, _evenNumber["default"])(fiveElement.clientWidth, {
133
+ smaller: true
134
+ });
135
+ var rendererHeight = (0, _evenNumber["default"])(fiveElement.clientHeight, {
136
+ smaller: true
137
+ });
130
138
  css3DRenderer.setSize(rendererWidth, rendererHeight);
131
139
  };
132
140
 
133
141
  css3DRendererSetSize();
134
- resizeObserver = new ResizeObserver(css3DRendererSetSize);
142
+ resizeObserver = (0, _createResizeObserver["default"])(css3DRendererSetSize, fiveElement);
135
143
  css3DRenderer.domElement.style.position = 'absolute';
136
144
  css3DRenderer.domElement.style.top = '0';
137
145
  css3DRenderer.domElement.style.userSelect = 'none';
@@ -144,10 +152,10 @@ var CSS3DRenderPlugin = function CSS3DRenderPlugin(five) {
144
152
  };
145
153
 
146
154
  return function () {
147
- var _resizeObserver;
155
+ var _resizeObserver, _resizeObserver$obser;
148
156
 
149
157
  scene.add(css3DObject);
150
- (_resizeObserver = resizeObserver) === null || _resizeObserver === void 0 ? void 0 : _resizeObserver.observe(fiveElement);
158
+ (_resizeObserver = resizeObserver) === null || _resizeObserver === void 0 ? void 0 : (_resizeObserver$obser = _resizeObserver.observe) === null || _resizeObserver$obser === void 0 ? void 0 : _resizeObserver$obser.call(_resizeObserver);
151
159
  renderEveryFrame();
152
160
 
153
161
  if (mode === 'behind' && mesh) {
@@ -190,9 +198,9 @@ var CSS3DRenderPlugin = function CSS3DRenderPlugin(five) {
190
198
  if (mode === 'behind') state.behindMode = undefined;
191
199
 
192
200
  if (!state.behindMode && !state.frontMode) {
193
- var _resizeObserver2;
201
+ var _resizeObserver2, _resizeObserver2$unob;
194
202
 
195
- (_resizeObserver2 = resizeObserver) === null || _resizeObserver2 === void 0 ? void 0 : _resizeObserver2.unobserve(fiveElement);
203
+ (_resizeObserver2 = resizeObserver) === null || _resizeObserver2 === void 0 ? void 0 : (_resizeObserver2$unob = _resizeObserver2.unobserve) === null || _resizeObserver2$unob === void 0 ? void 0 : _resizeObserver2$unob.call(_resizeObserver2);
196
204
  }
197
205
  }
198
206
 
@@ -209,9 +217,6 @@ var CSS3DRenderPlugin = function CSS3DRenderPlugin(five) {
209
217
  state.disposeCallbacks.push(dispose);
210
218
  }
211
219
 
212
- console.log({
213
- autoRender: autoRender
214
- });
215
220
  if (autoRender) render();
216
221
  return {
217
222
  container: container,
@@ -0,0 +1,7 @@
1
+ /**
2
+ * @description: 究极简陋的 ResizeObserver polyfill
3
+ */
4
+ export default function createResizeObserver(func: () => any, element?: HTMLElement): {
5
+ observe: () => void;
6
+ unobserve: () => void;
7
+ };
@@ -0,0 +1,34 @@
1
+ "use strict";
2
+
3
+ require("core-js/modules/es.object.define-property.js");
4
+
5
+ Object.defineProperty(exports, "__esModule", {
6
+ value: true
7
+ });
8
+ exports["default"] = createResizeObserver;
9
+
10
+ /**
11
+ * @description: 究极简陋的 ResizeObserver polyfill
12
+ */
13
+ function createResizeObserver(func, element) {
14
+ if (!element || typeof ResizeObserver === 'undefined') {
15
+ return {
16
+ observe: function observe() {
17
+ return window.addEventListener('resize', func);
18
+ },
19
+ unobserve: function unobserve() {
20
+ return window.removeEventListener('resize', func);
21
+ }
22
+ };
23
+ } else {
24
+ var observer = new ResizeObserver(func);
25
+ return {
26
+ observe: function observe() {
27
+ return observer.observe(element);
28
+ },
29
+ unobserve: function unobserve() {
30
+ return observer.unobserve(element);
31
+ }
32
+ };
33
+ }
34
+ }
@@ -15,5 +15,5 @@ export interface ModelChassisCompassPluginExportType {
15
15
  /**
16
16
  * 模型底盘指南针插件
17
17
  */
18
- declare const ModelChassisCompassPlugin: FivePlugin<ModelChassisCompassPluginParameterType, ModelChassisCompassPluginExportType>;
18
+ export declare const ModelChassisCompassPlugin: FivePlugin<ModelChassisCompassPluginParameterType, ModelChassisCompassPluginExportType>;
19
19
  export default ModelChassisCompassPlugin;
@@ -21,7 +21,7 @@ var _typeof = require("@babel/runtime/helpers/typeof");
21
21
  Object.defineProperty(exports, "__esModule", {
22
22
  value: true
23
23
  });
24
- exports["default"] = void 0;
24
+ exports["default"] = exports.ModelChassisCompassPlugin = void 0;
25
25
 
26
26
  var _regenerator = _interopRequireDefault(require("@babel/runtime/regenerator"));
27
27
 
@@ -153,5 +153,6 @@ var ModelChassisCompassPlugin = function ModelChassisCompassPlugin(five, params)
153
153
  };
154
154
  };
155
155
 
156
+ exports.ModelChassisCompassPlugin = ModelChassisCompassPlugin;
156
157
  var _default = ModelChassisCompassPlugin;
157
158
  exports["default"] = _default;
@@ -19,4 +19,8 @@ export interface ModelEntryDoorGuidePluginExportType {
19
19
  * 模型入户门引导插件
20
20
  */
21
21
  declare const ModelEntryDoorGuidePlugin: FivePlugin<ModelEntryDoorGuidePluginParameterType, ModelEntryDoorGuidePluginExportType>;
22
+ export declare const modelEntryDoorGuidePluginServerParams: {
23
+ name: string;
24
+ version: number;
25
+ };
22
26
  export default ModelEntryDoorGuidePlugin;
@@ -19,7 +19,7 @@ var _typeof = require("@babel/runtime/helpers/typeof");
19
19
  Object.defineProperty(exports, "__esModule", {
20
20
  value: true
21
21
  });
22
- exports["default"] = void 0;
22
+ exports.modelEntryDoorGuidePluginServerParams = exports["default"] = void 0;
23
23
 
24
24
  var _regenerator = _interopRequireDefault(require("@babel/runtime/regenerator"));
25
25
 
@@ -216,23 +216,24 @@ var ModelEntryDoorGuidePlugin = function ModelEntryDoorGuidePlugin(five, params)
216
216
  five.needsRender = true;
217
217
  };
218
218
 
219
- var modeChangeHandler = function modeChangeHandler(mode) {
220
- return mode === 'Floorplan' ? show() : hide();
219
+ var modeChangeHandler = function modeChangeHandler(config) {
220
+ return function (mode) {
221
+ return mode === 'Floorplan' ? show(config) : hide();
222
+ };
221
223
  };
222
224
 
223
225
  var enable = function enable(config) {
224
226
  if (state.enabled) return true;
225
227
  state.enabled = true;
226
- modeChangeHandler(five.currentMode);
227
- five.on('modeChange', modeChangeHandler);
228
- show(config);
228
+ modeChangeHandler(config)(five.currentMode);
229
+ five.on('modeChange', modeChangeHandler(config));
229
230
  return true;
230
231
  };
231
232
 
232
233
  var disable = function disable() {
233
234
  if (!state.enabled) return true;
234
235
  state.enabled = false;
235
- five.off('modeChange', modeChangeHandler);
236
+ five.off('modeChange', modeChangeHandler());
236
237
  return true;
237
238
  };
238
239
 
@@ -243,5 +244,10 @@ var ModelEntryDoorGuidePlugin = function ModelEntryDoorGuidePlugin(five, params)
243
244
  };
244
245
  };
245
246
 
247
+ var modelEntryDoorGuidePluginServerParams = {
248
+ name: 'ModelEntryDoorGuidePlugin',
249
+ version: 0
250
+ };
251
+ exports.modelEntryDoorGuidePluginServerParams = modelEntryDoorGuidePluginServerParams;
246
252
  var _default = ModelEntryDoorGuidePlugin;
247
253
  exports["default"] = _default;
@@ -71,6 +71,7 @@ var ModelRoomLabelController = /*#__PURE__*/function () {
71
71
  this.container.style.width = '100%';
72
72
  this.container.style.height = '100%';
73
73
  this.container.style.position = 'absolute';
74
+ this.container.style.pointerEvents = 'none';
74
75
  this.container.style.left = '0';
75
76
  this.container.style.top = '0'; // five lisenter
76
77