@realsee/dnalogel 0.1.5 → 0.1.7-alpha.4

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 (151) hide show
  1. package/components/GLTFView/index.d.ts +104 -0
  2. package/components/GLTFView/index.js +181 -0
  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.js +335 -71
  7. package/libs/gltf-viewer/Subscribe.d.ts +76 -0
  8. package/libs/gltf-viewer/Subscribe.js +231 -0
  9. package/libs/gltf-viewer/coordsMoveByOffset.d.ts +13 -0
  10. package/libs/gltf-viewer/coordsMoveByOffset.js +22 -0
  11. package/libs/gltf-viewer/coordsToDirection.d.ts +5 -0
  12. package/{components/PBRView/index.js → libs/gltf-viewer/coordsToDirection.js} +14 -18
  13. package/libs/gltf-viewer/formatRad.d.ts +1 -0
  14. package/libs/gltf-viewer/formatRad.js +13 -0
  15. package/libs/gltf-viewer/getFrameTime.d.ts +1 -0
  16. package/libs/gltf-viewer/getFrameTime.js +28 -0
  17. package/libs/gltf-viewer/index.d.ts +69 -0
  18. package/libs/gltf-viewer/index.js +744 -0
  19. package/libs/gltf-viewer/mouseWheel.d.ts +2 -0
  20. package/libs/gltf-viewer/mouseWheel.js +59 -0
  21. package/libs/gltf-viewer/requestAnimationFrame.d.ts +1 -0
  22. package/libs/gltf-viewer/requestAnimationFrame.js +18 -0
  23. package/libs/gltf-viewer/requestAnimationFrameInterval.d.ts +1 -0
  24. package/libs/gltf-viewer/requestAnimationFrameInterval.js +31 -0
  25. package/libs/gltf-viewer/uuid.d.ts +4 -0
  26. package/libs/gltf-viewer/uuid.js +28 -0
  27. package/package.json +5 -4
  28. package/plugins/ModelEntryDoorGuidePlugin/index.d.ts +6 -2
  29. package/plugins/ModelEntryDoorGuidePlugin/index.js +22 -14
  30. package/plugins/ModelRoomLabelPlugin/Controller.js +1 -0
  31. package/plugins/ModelRoomLabelPlugin/RoomLabelItem.js +5 -5
  32. package/plugins/ModelRoomLabelPlugin/index.d.ts +4 -0
  33. package/plugins/ModelRoomLabelPlugin/index.js +7 -2
  34. package/plugins/PanoMaskSelectorPlugin/createBox.js +3 -0
  35. package/plugins/PanoMaskSelectorPlugin/index.js +3 -1
  36. package/plugins/PanoMeasurePlugin/Controller/BaseController.d.ts +36 -0
  37. package/plugins/PanoMeasurePlugin/Controller/BaseController.js +103 -0
  38. package/plugins/PanoMeasurePlugin/Controller/EditController.d.ts +52 -0
  39. package/plugins/PanoMeasurePlugin/Controller/EditController.js +341 -0
  40. package/plugins/PanoMeasurePlugin/Controller/ShortcutKeyController.d.ts +12 -0
  41. package/plugins/PanoMeasurePlugin/Controller/ShortcutKeyController.js +69 -0
  42. package/plugins/PanoMeasurePlugin/Controller/WatchController.d.ts +25 -0
  43. package/plugins/PanoMeasurePlugin/Controller/WatchController.js +371 -0
  44. package/plugins/PanoMeasurePlugin/Controller/index.d.ts +61 -0
  45. package/plugins/PanoMeasurePlugin/Controller/index.js +230 -0
  46. package/plugins/PanoMeasurePlugin/Model/index.d.ts +38 -0
  47. package/plugins/PanoMeasurePlugin/Model/index.js +235 -0
  48. package/plugins/PanoMeasurePlugin/Model/line.d.ts +30 -0
  49. package/plugins/PanoMeasurePlugin/Model/line.js +121 -0
  50. package/plugins/PanoMeasurePlugin/Model/point.d.ts +16 -0
  51. package/plugins/PanoMeasurePlugin/Model/point.js +68 -0
  52. package/plugins/PanoMeasurePlugin/Model/polyline.d.ts +16 -0
  53. package/plugins/PanoMeasurePlugin/Model/polyline.js +109 -0
  54. package/plugins/PanoMeasurePlugin/Modules/DeleteDom/_Assets/delete.svg.d.ts +2 -0
  55. package/plugins/PanoMeasurePlugin/Modules/DeleteDom/_Assets/delete.svg.js +11 -0
  56. package/plugins/PanoMeasurePlugin/Modules/DeleteDom/_Assets/delete_bg.png.d.ts +2 -0
  57. package/plugins/PanoMeasurePlugin/Modules/DeleteDom/_Assets/delete_bg.png.js +11 -0
  58. package/plugins/PanoMeasurePlugin/Modules/DeleteDom/_Assets/delete_hover_bg.png.d.ts +2 -0
  59. package/plugins/PanoMeasurePlugin/Modules/DeleteDom/_Assets/delete_hover_bg.png.js +11 -0
  60. package/plugins/PanoMeasurePlugin/Modules/DeleteDom/index.d.ts +22 -0
  61. package/plugins/PanoMeasurePlugin/Modules/DeleteDom/index.js +182 -0
  62. package/plugins/PanoMeasurePlugin/Modules/FiveHelper.d.ts +11 -0
  63. package/plugins/PanoMeasurePlugin/Modules/FiveHelper.js +66 -0
  64. package/plugins/PanoMeasurePlugin/Modules/GuideController.d.ts +18 -0
  65. package/plugins/PanoMeasurePlugin/Modules/GuideController.js +107 -0
  66. package/plugins/PanoMeasurePlugin/Modules/Magnifier.d.ts +24 -0
  67. package/plugins/PanoMeasurePlugin/Modules/Magnifier.js +139 -0
  68. package/plugins/PanoMeasurePlugin/Modules/UIController/HTML.d.ts +6 -0
  69. package/plugins/PanoMeasurePlugin/Modules/UIController/HTML.js +26 -0
  70. package/plugins/PanoMeasurePlugin/Modules/UIController/MainBtnController.d.ts +18 -0
  71. package/plugins/PanoMeasurePlugin/Modules/UIController/MainBtnController.js +169 -0
  72. package/plugins/PanoMeasurePlugin/Modules/UIController/Revoke/index.d.ts +12 -0
  73. package/plugins/PanoMeasurePlugin/Modules/UIController/Revoke/index.js +59 -0
  74. package/plugins/PanoMeasurePlugin/Modules/UIController/index.d.ts +16 -0
  75. package/plugins/PanoMeasurePlugin/Modules/UIController/index.js +123 -0
  76. package/plugins/PanoMeasurePlugin/Modules/UIController/style.d.ts +17 -0
  77. package/plugins/PanoMeasurePlugin/Modules/UIController/style.js +103 -0
  78. package/plugins/PanoMeasurePlugin/index.d.ts +7 -0
  79. package/plugins/PanoMeasurePlugin/index.js +20 -0
  80. package/plugins/PanoMeasurePlugin/typings/data.d.ts +28 -0
  81. package/plugins/PanoMeasurePlugin/typings/data.js +7 -0
  82. package/plugins/PanoMeasurePlugin/typings/event.type.d.ts +28 -0
  83. package/plugins/PanoMeasurePlugin/typings/event.type.js +7 -0
  84. package/plugins/PanoMeasurePlugin/typings/utils.type.d.ts +1 -0
  85. package/plugins/PanoMeasurePlugin/typings/utils.type.js +7 -0
  86. package/plugins/PanoMeasurePlugin/utils/clearGroup.d.ts +2 -0
  87. package/plugins/PanoMeasurePlugin/utils/clearGroup.js +16 -0
  88. package/plugins/PanoMeasurePlugin/utils/constants.d.ts +4 -0
  89. package/plugins/PanoMeasurePlugin/utils/constants.js +47 -0
  90. package/plugins/PanoMeasurePlugin/utils/distanceDom.d.ts +28 -0
  91. package/plugins/PanoMeasurePlugin/utils/distanceDom.js +147 -0
  92. package/plugins/PanoMeasurePlugin/utils/findAssociatedLines.d.ts +2 -0
  93. package/plugins/PanoMeasurePlugin/utils/findAssociatedLines.js +37 -0
  94. package/plugins/PanoMeasurePlugin/utils/findClosestPoint.d.ts +10 -0
  95. package/plugins/PanoMeasurePlugin/utils/findClosestPoint.js +49 -0
  96. package/plugins/PanoMeasurePlugin/utils/getIntersectionFromEvent.d.ts +4 -0
  97. package/plugins/PanoMeasurePlugin/utils/getIntersectionFromEvent.js +20 -0
  98. package/plugins/PanoMeasurePlugin/utils/getPointFromHammerEvent.d.ts +10 -0
  99. package/plugins/PanoMeasurePlugin/utils/getPointFromHammerEvent.js +33 -0
  100. package/plugins/PanoMeasurePlugin/utils/ironbox.d.ts +1 -0
  101. package/plugins/PanoMeasurePlugin/utils/ironbox.js +14 -0
  102. package/plugins/PanoMeasurePlugin/utils/isNDCPointInScreen.d.ts +2 -0
  103. package/plugins/PanoMeasurePlugin/utils/isNDCPointInScreen.js +16 -0
  104. package/plugins/PanoMeasurePlugin/utils/line.d.ts +17 -0
  105. package/plugins/PanoMeasurePlugin/utils/line.js +61 -0
  106. package/plugins/PanoMeasurePlugin/utils/math.d.ts +17 -0
  107. package/plugins/PanoMeasurePlugin/utils/math.js +57 -0
  108. package/plugins/PanoMeasurePlugin/utils/mouseGroup.d.ts +2 -0
  109. package/plugins/PanoMeasurePlugin/utils/mouseGroup.js +42 -0
  110. package/plugins/PanoMeasurePlugin/utils/ndc2Screen.d.ts +5 -0
  111. package/plugins/PanoMeasurePlugin/utils/ndc2Screen.js +16 -0
  112. package/plugins/PanoRulerPlugin/index.d.ts +4 -0
  113. package/plugins/PanoRulerPlugin/index.js +6 -1
  114. package/plugins/PanoTVVideoPlugin/index.d.ts +2 -0
  115. package/plugins/PanoTVVideoPlugin/index.js +20 -14
  116. package/plugins/floorplan/ModelFloorplanPlugin/Controller.d.ts +5 -2
  117. package/plugins/floorplan/ModelFloorplanPlugin/Controller.js +22 -11
  118. package/plugins/floorplan/ModelFloorplanPlugin/components/Camera.js +4 -4
  119. package/plugins/floorplan/ModelFloorplanPlugin/components/Compass.js +5 -5
  120. package/plugins/floorplan/ModelFloorplanPlugin/components/NowFloor/RoomLabels.js +2 -2
  121. package/plugins/floorplan/ModelFloorplanPlugin/components/NowFloor/RoomMaterial.d.ts +11 -0
  122. package/plugins/floorplan/ModelFloorplanPlugin/components/NowFloor/RoomMaterial.js +174 -0
  123. package/plugins/floorplan/ModelFloorplanPlugin/components/NowFloor/RuleLabels.d.ts +8 -0
  124. package/plugins/floorplan/ModelFloorplanPlugin/components/NowFloor/RuleLabels.js +179 -0
  125. package/plugins/floorplan/ModelFloorplanPlugin/components/NowFloor/index.d.ts +2 -0
  126. package/plugins/floorplan/ModelFloorplanPlugin/components/NowFloor/index.js +14 -2
  127. package/plugins/floorplan/ModelFloorplanPlugin/components/index.d.ts +3 -0
  128. package/plugins/floorplan/ModelFloorplanPlugin/components/index.js +1 -1
  129. package/plugins/floorplan/ModelFloorplanPlugin/typings/utility.d.ts +2 -0
  130. package/plugins/floorplan/ModelFloorplanPlugin/typings/utility.js +7 -0
  131. package/plugins/floorplan/ModelFloorplanPlugin/utils/constant.d.ts +1 -1
  132. package/plugins/floorplan/ModelFloorplanPlugin/utils/constant.js +1 -1
  133. package/plugins/floorplan/PanoFloorplanRadarPlugin/Content/Camera.js +1 -0
  134. package/plugins/floorplan/PanoFloorplanRadarPlugin/Content/Camera.style.js +4 -4
  135. package/plugins/floorplan/PanoFloorplanRadarPlugin/Content/NowFloor/ExtraObjects.js +2 -2
  136. package/plugins/floorplan/TopviewFloorplanPlugin/Controller.js +3 -3
  137. package/plugins/floorplan/index.d.ts +4 -0
  138. package/plugins/floorplan/index.js +13 -0
  139. package/plugins/floorplan/typings/floorplanData.d.ts +2 -0
  140. package/plugins/floorplan/typings/floorplanServerData.d.ts +2 -0
  141. package/plugins/floorplan/utils/formatData.js +2 -1
  142. package/shared-utils/changeModelCanvasOpacity.d.ts +2 -0
  143. package/shared-utils/{changeModelCanvansOpacity.js → changeModelCanvasOpacity.js} +2 -2
  144. package/shared-utils/removeArrayItem.d.ts +7 -0
  145. package/shared-utils/removeArrayItem.js +22 -0
  146. package/shared-utils/three/loadTexture.d.ts +2 -2
  147. package/shared-utils/three/loadTexture.js +21 -2
  148. package/typedoc/libs.d.ts +1 -0
  149. package/typedoc/libs.js +7 -0
  150. package/components/PBRView/index.d.ts +0 -14
  151. package/shared-utils/changeModelCanvansOpacity.d.ts +0 -2
@@ -0,0 +1,744 @@
1
+ "use strict";
2
+
3
+ require("core-js/modules/es.reflect.construct.js");
4
+
5
+ require("core-js/modules/es.array.iterator.js");
6
+
7
+ require("core-js/modules/es.string.iterator.js");
8
+
9
+ require("core-js/modules/es.weak-map.js");
10
+
11
+ require("core-js/modules/web.dom-collections.iterator.js");
12
+
13
+ require("core-js/modules/es.object.define-property.js");
14
+
15
+ require("core-js/modules/es.object.get-own-property-descriptor.js");
16
+
17
+ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
18
+
19
+ var _typeof = require("@babel/runtime/helpers/typeof");
20
+
21
+ Object.defineProperty(exports, "__esModule", {
22
+ value: true
23
+ });
24
+ exports.GLTFViewer = void 0;
25
+
26
+ require("core-js/modules/es.function.bind.js");
27
+
28
+ require("core-js/modules/web.timers.js");
29
+
30
+ require("core-js/modules/es.object.assign.js");
31
+
32
+ require("core-js/modules/es.object.to-string.js");
33
+
34
+ require("core-js/modules/es.promise.js");
35
+
36
+ require("core-js/modules/es.date.to-string.js");
37
+
38
+ require("core-js/modules/es.regexp.to-string.js");
39
+
40
+ require("core-js/modules/es.number.constructor.js");
41
+
42
+ require("core-js/modules/es.array.concat.js");
43
+
44
+ var _assertThisInitialized2 = _interopRequireDefault(require("@babel/runtime/helpers/assertThisInitialized"));
45
+
46
+ var _inherits2 = _interopRequireDefault(require("@babel/runtime/helpers/inherits"));
47
+
48
+ var _possibleConstructorReturn2 = _interopRequireDefault(require("@babel/runtime/helpers/possibleConstructorReturn"));
49
+
50
+ var _getPrototypeOf2 = _interopRequireDefault(require("@babel/runtime/helpers/getPrototypeOf"));
51
+
52
+ var _classCallCheck2 = _interopRequireDefault(require("@babel/runtime/helpers/classCallCheck"));
53
+
54
+ var _createClass2 = _interopRequireDefault(require("@babel/runtime/helpers/createClass"));
55
+
56
+ var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
57
+
58
+ var THREE = _interopRequireWildcard(require("three"));
59
+
60
+ var _hammerjs = _interopRequireDefault(require("hammerjs"));
61
+
62
+ var _GLTFLoader = require("three/examples/jsm/loaders/GLTFLoader");
63
+
64
+ var _RGBELoader = require("three/examples/jsm/loaders/RGBELoader");
65
+
66
+ var _coordsMoveByOffset = require("./coordsMoveByOffset");
67
+
68
+ var _getFrameTime = require("./getFrameTime");
69
+
70
+ var _coordsToDirection = require("./coordsToDirection");
71
+
72
+ var _mouseWheel = require("./mouseWheel");
73
+
74
+ var _requestAnimationFrameInterval = require("./requestAnimationFrameInterval");
75
+
76
+ var _uuid = _interopRequireDefault(require("./uuid"));
77
+
78
+ var _Subscribe2 = require("./Subscribe");
79
+
80
+ 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); }
81
+
82
+ 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; }
83
+
84
+ function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = (0, _getPrototypeOf2["default"])(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = (0, _getPrototypeOf2["default"])(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return (0, _possibleConstructorReturn2["default"])(this, result); }; }
85
+
86
+ function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); return true; } catch (e) { return false; } }
87
+
88
+ var defaultPos = {
89
+ longitude: 0,
90
+ latitude: 0,
91
+ fov: 0
92
+ };
93
+ var ERROR_NO_CONTROLLER = 'GLTFViewer 实例丢失';
94
+ var loader = new _GLTFLoader.GLTFLoader();
95
+
96
+ var Controller = /*#__PURE__*/function () {
97
+ function Controller(config, callbacks) {
98
+ var _this = this;
99
+
100
+ (0, _classCallCheck2["default"])(this, Controller);
101
+ (0, _defineProperty2["default"])(this, "fov", 0);
102
+ (0, _defineProperty2["default"])(this, "longitude", 0);
103
+ (0, _defineProperty2["default"])(this, "latitude", 0);
104
+ (0, _defineProperty2["default"])(this, "needsRender", false);
105
+ this.config = config; // 异步事件回调
106
+
107
+ this.callbacks = callbacks; // 默认状态参数
108
+
109
+ var initial = config.initial || {};
110
+
111
+ if (initial.fov !== undefined) {
112
+ this.fov = initial.fov;
113
+ }
114
+
115
+ if (initial.latitude !== undefined) {
116
+ this.latitude = initial.latitude;
117
+ }
118
+
119
+ if (initial.longitude !== undefined) {
120
+ this.longitude = initial.longitude;
121
+ } // 场景
122
+
123
+
124
+ this.scene = new THREE.Scene(); // 背景色值
125
+
126
+ if (config.backgroundColor) {
127
+ this.scene.background = config.backgroundColor;
128
+ } // 渲染器
129
+
130
+
131
+ this.renderer = new THREE.WebGLRenderer({
132
+ antialias: config.antialias,
133
+ alpha: true
134
+ });
135
+ this.renderer.outputEncoding = THREE.sRGBEncoding;
136
+
137
+ if (config.toneMapping) {
138
+ this.renderer.toneMapping = THREE.ReinhardToneMapping;
139
+ this.renderer.toneMappingExposure = 1.5;
140
+ }
141
+
142
+ if (config.backgroundColor) {
143
+ this.renderer.setClearColor(config.backgroundColor, 0);
144
+ } // 像素比
145
+
146
+
147
+ if (config.pixelRatio) {
148
+ this.renderer.setPixelRatio(config.pixelRatio);
149
+ } // 相机
150
+
151
+
152
+ this.camera = new THREE.PerspectiveCamera(this.fov, 1, 0.1, 1000); // 光照
153
+
154
+ if (config.pointLight !== false) {
155
+ this.pointLight = config.pointLight || new THREE.PointLight(0xfffffff, 1, 10000);
156
+ this.scene.add(this.pointLight);
157
+ }
158
+
159
+ if (config.directionalLight !== false) {
160
+ this.directionLight = config.directionalLight || new THREE.DirectionalLight(0xfffffff, 0.1);
161
+ this.directionLight.position.setY(-1);
162
+ this.scene.add(this.directionLight);
163
+ }
164
+
165
+ if (config.ambientLight !== false) {
166
+ this.ambientLight = config.ambientLight || new THREE.AmbientLight(0xfffffff);
167
+ this.scene.add(this.ambientLight);
168
+ } // 背景 HDR
169
+
170
+
171
+ if (config.backgroundHDR) {
172
+ var pmremGenerator = new THREE.PMREMGenerator(this.renderer);
173
+ var rgbLoader = new _RGBELoader.RGBELoader();
174
+ rgbLoader.setDataType(THREE.UnsignedByteType);
175
+ rgbLoader.load(config.backgroundHDR, function (hdrEquirect) {
176
+ var hdrCubeRenderTarget = pmremGenerator.fromEquirectangular(hdrEquirect);
177
+ _this.scene.environment = hdrCubeRenderTarget.texture;
178
+
179
+ if (config.backgroundColor) {
180
+ _this.scene.background = hdrCubeRenderTarget.texture;
181
+ }
182
+
183
+ hdrEquirect.dispose();
184
+ pmremGenerator.dispose();
185
+ _this.needsRender = true;
186
+ });
187
+ pmremGenerator.compileEquirectangularShader();
188
+ }
189
+
190
+ this.__interiaMovement = false;
191
+ var hammerManager = new _hammerjs["default"].Manager(this.element);
192
+ hammerManager.add(new _hammerjs["default"].Pan({
193
+ threshold: 0,
194
+ pointers: 0
195
+ }));
196
+ hammerManager.add(new _hammerjs["default"].Pinch({
197
+ threshold: 0,
198
+ pointers: 2
199
+ }).recognizeWith(hammerManager.get('pan')));
200
+ hammerManager.on('panstart pan', this.__onPanGesture.bind(this));
201
+ hammerManager.on('pinchstart pinch pinchend', this.__onPinchGesture.bind(this));
202
+
203
+ var __onMouseWheel = this.__onMouseWheel.bind(this);
204
+
205
+ (0, _mouseWheel.addMouseWheel)(this.element, __onMouseWheel);
206
+
207
+ this.dispose = function () {
208
+ hammerManager.destroy();
209
+ (0, _mouseWheel.removeMouseWheel)(_this.element, __onMouseWheel);
210
+
211
+ _this.clear();
212
+
213
+ _this.renderer.dispose();
214
+ };
215
+
216
+ this.needsRender = true;
217
+ this.play();
218
+ }
219
+
220
+ (0, _createClass2["default"])(Controller, [{
221
+ key: "minFov",
222
+ get: function get() {
223
+ return this.config.minFov || 1;
224
+ }
225
+ }, {
226
+ key: "maxFov",
227
+ get: function get() {
228
+ return this.config.maxFov || 120;
229
+ }
230
+ }, {
231
+ key: "pause",
232
+ value: function pause() {// nothing todo
233
+ }
234
+ }, {
235
+ key: "clear",
236
+ value: function clear() {
237
+ if (this.target) {
238
+ this.scene.remove(this.target.scene);
239
+ this.update(defaultPos);
240
+ this.target = undefined;
241
+ }
242
+ }
243
+ }, {
244
+ key: "play",
245
+ value: function play() {
246
+ var _this2 = this;
247
+
248
+ this.pause();
249
+
250
+ var _render = function _render() {
251
+ if (_this2.needsRender !== false) _this2.render();
252
+ _this2.needsRender = false;
253
+ };
254
+
255
+ this.pause = (0, _requestAnimationFrameInterval.requestAnimationFrameInterval)(_render);
256
+
257
+ _render();
258
+ }
259
+ }, {
260
+ key: "setTarget",
261
+ value: function setTarget(object) {
262
+ var _this3 = this;
263
+
264
+ if (this.target) {
265
+ this.scene.remove(this.target.scene);
266
+ }
267
+
268
+ this.target = object;
269
+ this.target.scene.visible = false;
270
+ this.scene.add(this.target.scene); // {
271
+ // const boxHelper = new THREE.BoxHelper(this.target.scene, 0x2bb8aa)
272
+ // this.scene.add(boxHelper)
273
+ // const axesHelper = new THREE.AxesHelper(300)
274
+ // this.scene.add(axesHelper)
275
+ // }
276
+
277
+ setTimeout(function () {
278
+ if (object === _this3.target) {
279
+ _this3.target.scene.visible = true;
280
+
281
+ _this3.update({});
282
+ }
283
+ }, 50);
284
+ }
285
+ }, {
286
+ key: "element",
287
+ get: function get() {
288
+ return this.renderer.domElement;
289
+ }
290
+ }, {
291
+ key: "appendTo",
292
+ value: function appendTo(container, size) {
293
+ container.appendChild(this.element);
294
+ this.refresh(size);
295
+ var positionType = window.getComputedStyle(container).position;
296
+
297
+ if (positionType !== 'relative' && positionType !== 'absolute' && positionType !== 'fixed' && positionType !== 'sticky') {
298
+ container.style.position = 'relative';
299
+ }
300
+ }
301
+ }, {
302
+ key: "refresh",
303
+ value: function refresh() {
304
+ var size = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
305
+ var element = this.element;
306
+ var container = element.parentElement;
307
+ if (!container) return;
308
+
309
+ if (container && container.tagName && container.nodeName) {
310
+ var _size$width = size.width,
311
+ width = _size$width === void 0 ? container.offsetWidth : _size$width,
312
+ _size$height = size.height,
313
+ height = _size$height === void 0 ? container.offsetHeight : _size$height;
314
+ this.renderer.setSize(width, height); // 修改摄像机 aspect 比值
315
+
316
+ this.camera.aspect = width / height;
317
+ this.camera.updateProjectionMatrix();
318
+ }
319
+
320
+ this.needsRender = true;
321
+ }
322
+ }, {
323
+ key: "update",
324
+ value: function update(state) {
325
+ var fov = this.fov;
326
+ var longitude = this.longitude;
327
+ var latitude = this.latitude;
328
+
329
+ if (state.fov !== undefined) {
330
+ fov = state.fov;
331
+ }
332
+
333
+ if (state.longitude !== undefined) {
334
+ longitude = state.longitude;
335
+ }
336
+
337
+ if (state.latitude !== undefined) {
338
+ latitude = state.latitude;
339
+ }
340
+
341
+ if (!this.target || !this.target.scene) return;
342
+ var boxHelper = new THREE.BoxHelper(this.target.scene, 0x2bb8aa);
343
+
344
+ var _ref = boxHelper.geometry.boundingSphere || {},
345
+ center = _ref.center,
346
+ radius = _ref.radius;
347
+
348
+ if (!center || !radius) return;
349
+ var box = new THREE.Box3();
350
+ box.expandByObject(this.target.scene);
351
+ box.getCenter(center); // 距离
352
+
353
+ var distance = radius / Math.sin(Math.PI / 4) * 3;
354
+ {// debug
355
+ // const geometry = new THREE.SphereGeometry(radius, 32, 16)
356
+ // const material = new THREE.MeshBasicMaterial({ color: 0x0000aa, wireframe: true })
357
+ // const sphere = new THREE.Mesh(geometry, material)
358
+ // sphere.position.copy(center.clone())
359
+ // this.scene.add(sphere)
360
+ } // 朝向
361
+
362
+ var direction = (0, _coordsToDirection.coordsToDirection)({
363
+ longitude: longitude,
364
+ latitude: latitude
365
+ });
366
+ direction.setLength(distance);
367
+ this.camera.position.copy(center.clone().add(direction));
368
+ this.camera.lookAt(center);
369
+
370
+ if (this.pointLight) {
371
+ var lightDirection = (0, _coordsToDirection.coordsToDirection)({
372
+ longitude: longitude,
373
+ latitude: -Math.PI / 6
374
+ });
375
+ lightDirection.setLength(distance * 3);
376
+ this.pointLight.position.copy(center.clone().add(lightDirection));
377
+ }
378
+
379
+ var calcFov = function calcFov(distance, width, r) {
380
+ var vertical = r < 1 ? width / r : width;
381
+ var fov = Math.atan(vertical / distance / 2) * 2 * (180 / Math.PI);
382
+ return fov;
383
+ };
384
+
385
+ var d = this.camera.position.distanceTo(center);
386
+
387
+ if (fov === 0) {
388
+ fov = calcFov(d, radius * 2, this.renderer.domElement.offsetWidth / this.renderer.domElement.offsetHeight);
389
+ }
390
+
391
+ if (fov !== this.fov) {
392
+ fov = Math.max(this.minFov, Math.min(this.maxFov, fov));
393
+ this.camera.fov = fov;
394
+ this.camera.updateProjectionMatrix();
395
+ }
396
+
397
+ this.camera.updateProjectionMatrix(); // const center = new THREE.Vector3()
398
+ // const box = new THREE.Box3()
399
+ // if (this.target) {
400
+ // box.expandByObject(this.target.scene)
401
+ // box.getCenter(center)
402
+ // }
403
+ // longitude = formatRad(longitude)
404
+ // latitude = Math.max(-Math.PI / 2 + 0.01, Math.min(+Math.PI / 2, latitude))
405
+ // const distance = Math.max(center.distanceTo(box.min), center.distanceTo(box.max))
406
+ // const direction = coordsToDirection({ longitude, latitude })
407
+ // direction.setLength(distance * 3)
408
+ // this.camera.position.copy(center.clone().add(direction))
409
+ // this.camera.lookAt(center)
410
+ // const lightDirection = coordsToDirection({ longitude, latitude: -Math.PI / 6 })
411
+ // lightDirection.setLength(distance * 3)
412
+ // if (this.pointLight) this.pointLight.position.copy(center.clone().add(lightDirection))
413
+ // if (fov !== this.fov) {
414
+ // fov = Math.max(25, Math.min(this.maxFov, fov))
415
+ // this.camera.fov = fov
416
+ // this.camera.updateProjectionMatrix()
417
+ // }
418
+
419
+ var needsRender = this.fov !== fov || this.longitude !== longitude || this.latitude !== latitude;
420
+ Object.assign(this, {
421
+ longitude: longitude,
422
+ latitude: latitude,
423
+ fov: fov
424
+ });
425
+ this.needsRender = true;
426
+
427
+ if (needsRender) {
428
+ this.callbacks.stateChange({
429
+ longitude: longitude,
430
+ latitude: latitude,
431
+ fov: fov
432
+ });
433
+ }
434
+ }
435
+ }, {
436
+ key: "__onPanGesture",
437
+ value: function __onPanGesture(event) {
438
+ var _this4 = this;
439
+
440
+ this.__interiaMovement = false;
441
+ var longitude = this.longitude,
442
+ latitude = this.latitude;
443
+ var center = event.center,
444
+ isFinal = event.isFinal,
445
+ velocityX = event.velocityX,
446
+ velocityY = event.velocityY,
447
+ pointers = event.pointers;
448
+
449
+ var offset = function () {
450
+ if (!(_this4.__lastPanPoint && _this4.__lastPanPoint.pointerLength === pointers.length)) {
451
+ return {
452
+ x: 0,
453
+ y: 0
454
+ };
455
+ }
456
+
457
+ return {
458
+ x: center.x - _this4.__lastPanPoint.x,
459
+ y: center.y - _this4.__lastPanPoint.y
460
+ };
461
+ }();
462
+
463
+ if (!isFinal) {
464
+ var layout = {
465
+ width: this.element.offsetWidth,
466
+ height: this.element.offsetHeight
467
+ };
468
+ this.update((0, _coordsMoveByOffset.coordsMoveByOffset)({
469
+ longitude: longitude,
470
+ latitude: latitude
471
+ }, offset, layout));
472
+ this.__lastPanPoint = {
473
+ pointerLength: pointers.length,
474
+ x: center.x,
475
+ y: center.y
476
+ };
477
+ } else {
478
+ delete this.__lastPanPoint;
479
+ (0, _getFrameTime.getFrameTime)(function (frameTime) {
480
+ _this4.__interiaMovement = true;
481
+ var x = velocityX * frameTime;
482
+ var y = velocityY * frameTime;
483
+ var distance = Math.sqrt(x * x + y * y);
484
+
485
+ if (distance > 100) {
486
+ x = x / distance * 100;
487
+ y = y / distance * 100;
488
+ } // 滑动小于上下15度, 忽略 y 值
489
+
490
+
491
+ if (Math.abs(y / x) < Math.tan(20 / 180 * Math.PI)) y = 0;
492
+
493
+ _this4.__requestInteriaMovement({
494
+ x: x,
495
+ y: y
496
+ });
497
+ });
498
+ }
499
+ }
500
+ }, {
501
+ key: "__onPinchGesture",
502
+ value: function __onPinchGesture(event) {
503
+ this.__interiaMovement = false;
504
+ var scale = event.scale,
505
+ type = event.type;
506
+
507
+ if (type === 'pinchstart') {
508
+ this.__pinchCurrentFov = this.fov;
509
+ return;
510
+ }
511
+
512
+ if (type === 'pinchend') {
513
+ this.__pinchCurrentFov = undefined;
514
+ return;
515
+ }
516
+
517
+ var fov = this.__pinchCurrentFov ? this.__pinchCurrentFov / scale : 1;
518
+ this.update({
519
+ fov: fov
520
+ });
521
+ }
522
+ }, {
523
+ key: "__requestInteriaMovement",
524
+ value: function __requestInteriaMovement(offset) {
525
+ var _this5 = this;
526
+
527
+ if (this.__interiaMovement === false) return;
528
+ var x = offset.x,
529
+ y = offset.y;
530
+ var longitude = this.longitude,
531
+ latitude = this.latitude;
532
+ var friction = 0.9;
533
+ var layout = {
534
+ width: this.element.offsetWidth,
535
+ height: this.element.offsetHeight
536
+ };
537
+ this.update((0, _coordsMoveByOffset.coordsMoveByOffset)({
538
+ longitude: longitude,
539
+ latitude: latitude
540
+ }, {
541
+ x: x,
542
+ y: y
543
+ }, layout));
544
+ var notFinal = Math.abs(x) > 1 || Math.abs(y) > 1;
545
+
546
+ if (notFinal) {
547
+ requestAnimationFrame(function () {
548
+ return _this5.__requestInteriaMovement({
549
+ x: x * friction,
550
+ y: y * friction * 0.7
551
+ });
552
+ });
553
+ } else {
554
+ this.__interiaMovement = false;
555
+ }
556
+ }
557
+ }, {
558
+ key: "__onMouseWheel",
559
+ value: function __onMouseWheel(event) {
560
+ this.__interiaMovement = false;
561
+ var fov = this.fov - event.delta;
562
+ this.update({
563
+ fov: fov <= 1 ? 1 : fov
564
+ });
565
+ }
566
+ }, {
567
+ key: "load",
568
+ value: function load(url) {
569
+ var _this6 = this;
570
+
571
+ return new Promise(function (resolve, reject) {
572
+ _this6.callbacks.willLoad();
573
+
574
+ loader.load(url, function (gltf) {
575
+ _this6.setTarget(gltf);
576
+
577
+ _this6.callbacks.loaded(gltf);
578
+
579
+ resolve(true);
580
+ }, function (xhr) {
581
+ _this6.callbacks.progressing(xhr.loaded / xhr.total * 100);
582
+ }, function (error) {
583
+ _this6.callbacks.loadError(error);
584
+
585
+ reject(error);
586
+ });
587
+ });
588
+ }
589
+ }, {
590
+ key: "render",
591
+ value: function render() {
592
+ this.renderer.render(this.scene, this.camera);
593
+ }
594
+ }]);
595
+ return Controller;
596
+ }();
597
+
598
+ var caches = {};
599
+
600
+ var GLTFViewer = /*#__PURE__*/function (_Subscribe) {
601
+ (0, _inherits2["default"])(GLTFViewer, _Subscribe);
602
+
603
+ var _super = _createSuper(GLTFViewer);
604
+
605
+ function GLTFViewer(config) {
606
+ var _this7;
607
+
608
+ (0, _classCallCheck2["default"])(this, GLTFViewer);
609
+ _this7 = _super.call(this);
610
+ (0, _defineProperty2["default"])((0, _assertThisInitialized2["default"])(_this7), "uuid", (0, _uuid["default"])());
611
+ var controller = new Controller(config, {
612
+ stateChange: function stateChange(state) {
613
+ return _this7.emit('stateChange', state);
614
+ },
615
+ progressing: function (_progressing) {
616
+ function progressing(_x) {
617
+ return _progressing.apply(this, arguments);
618
+ }
619
+
620
+ progressing.toString = function () {
621
+ return _progressing.toString();
622
+ };
623
+
624
+ return progressing;
625
+ }(function (progressing) {
626
+ return _this7.emit('progressing', progressing);
627
+ }),
628
+ willLoad: function willLoad() {
629
+ return _this7.emit('willLoad');
630
+ },
631
+ loaded: function loaded(gltf) {
632
+ return _this7.emit('loaded', gltf);
633
+ },
634
+ loadError: function loadError(error) {
635
+ return _this7.emit('loadError', error);
636
+ }
637
+ });
638
+ Object.assign(window, {
639
+ $controller: controller
640
+ });
641
+ caches[_this7.uuid] = controller;
642
+ return _this7;
643
+ }
644
+
645
+ (0, _createClass2["default"])(GLTFViewer, [{
646
+ key: "state",
647
+ get: function get() {
648
+ var controller = caches[this.uuid];
649
+ if (!controller) throw new Error(ERROR_NO_CONTROLLER);
650
+ var proxy = new Proxy({
651
+ fov: controller.fov,
652
+ latitude: controller.latitude,
653
+ longitude: controller.longitude
654
+ }, {
655
+ set: function set(obj, prop, value) {
656
+ if (prop === 'fov') {
657
+ if (Number(value) === NaN) {
658
+ throw new TypeError('The fov is not an number');
659
+ }
660
+
661
+ if (value > controller.maxFov || value < controller.minFov) {
662
+ throw new RangeError("The fov seems invalid~ fov: [".concat(controller.minFov, ", ").concat(controller.maxFov, "]"));
663
+ }
664
+ }
665
+
666
+ controller.update((0, _defineProperty2["default"])({}, prop, value));
667
+ return true;
668
+ },
669
+ get: function get(obj, prop) {
670
+ return controller[prop];
671
+ }
672
+ });
673
+ return proxy;
674
+ },
675
+ set: function set(_ref2) {
676
+ var fov = _ref2.fov,
677
+ latitude = _ref2.latitude,
678
+ longitude = _ref2.longitude;
679
+ var controller = caches[this.uuid];
680
+ if (!controller) throw new Error(ERROR_NO_CONTROLLER);
681
+ controller.update({
682
+ fov: fov === undefined ? controller.fov : fov,
683
+ latitude: latitude === undefined ? controller.latitude : latitude,
684
+ longitude: longitude === undefined ? controller.longitude : longitude
685
+ });
686
+ }
687
+ /**
688
+ *
689
+ * @param url glTF 模型CDN地址
690
+ * @param options adaptive 是否开启自适应fov
691
+ */
692
+
693
+ }, {
694
+ key: "load",
695
+ value: function load(url) {
696
+ var options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {
697
+ adaptive: true
698
+ };
699
+ var controller = caches[this.uuid];
700
+ if (!controller) throw new Error(ERROR_NO_CONTROLLER);
701
+ controller.load(url);
702
+ }
703
+ /**
704
+ * 挂载
705
+ * @param container
706
+ * @param size
707
+ */
708
+
709
+ }, {
710
+ key: "appendTo",
711
+ value: function appendTo(container, size) {
712
+ var controller = caches[this.uuid];
713
+ if (!controller) throw new Error(ERROR_NO_CONTROLLER);
714
+ controller.appendTo(container, size);
715
+ }
716
+ /**
717
+ * 刷新:如果传递宽高则以该宽高重新绘制;否则,以父容器的宽高重新绘制。
718
+ * @param size
719
+ */
720
+
721
+ }, {
722
+ key: "refresh",
723
+ value: function refresh(size) {
724
+ var controller = caches[this.uuid];
725
+ if (!controller) throw new Error(ERROR_NO_CONTROLLER);
726
+ controller.refresh(size);
727
+ }
728
+ /**
729
+ * 销毁
730
+ */
731
+
732
+ }, {
733
+ key: "dispose",
734
+ value: function dispose() {
735
+ var controller = caches[this.uuid];
736
+ if (!controller) throw new Error(ERROR_NO_CONTROLLER);
737
+ if (controller.dispose) controller.dispose();
738
+ delete caches[this.uuid];
739
+ }
740
+ }]);
741
+ return GLTFViewer;
742
+ }(_Subscribe2.Subscribe);
743
+
744
+ exports.GLTFViewer = GLTFViewer;