@realsee/dnalogel 0.1.5 → 0.1.7-alpha.11

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