@realsee/dnalogel 0.1.7-alpha.4 → 0.1.7-alpha.5

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.
@@ -6,7 +6,7 @@ export declare type GLTFViewPropTypes = {
6
6
  refs?: (gltfViewer: GLTFViewer) => void;
7
7
  } & GLTFViewerConfig;
8
8
  /**
9
- * **GLTFViewer** 预览 `glTF` 模型文件(支持.gltf和.glb格式),附带光照等效果。
9
+ * **GLTFViewer** 预览 `glTF` 模型文件(支持 `.gltf` 和 `.glb` 格式),附带光照等效果等配置。
10
10
  *
11
11
  * ### Usage
12
12
  *
@@ -96,6 +96,12 @@ export declare type GLTFViewPropTypes = {
96
96
  * pointLight?: THREE.PointLight | false
97
97
  * directionalLight?: THREE.DirectionalLight | false
98
98
  * ambientLight?: THREE.AmbientLight | false
99
+ * // 色调映射
100
+ * toneMapping?: {
101
+ * toneMapping?: THREE.ToneMapping
102
+ * toneMappingExposure?: number
103
+ * }
104
+ *
99
105
  * ```
100
106
  * 自带三种默认光照配置,你可以提供自己的光照实例。如果设置 `pointLight: false` 则禁用该光照效果。
101
107
  *
@@ -36,7 +36,7 @@ function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "functio
36
36
  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; }
37
37
 
38
38
  /**
39
- * **GLTFViewer** 预览 `glTF` 模型文件(支持.gltf和.glb格式),附带光照等效果。
39
+ * **GLTFViewer** 预览 `glTF` 模型文件(支持 `.gltf` 和 `.glb` 格式),附带光照等效果等配置。
40
40
  *
41
41
  * ### Usage
42
42
  *
@@ -126,6 +126,12 @@ function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj &&
126
126
  * pointLight?: THREE.PointLight | false
127
127
  * directionalLight?: THREE.DirectionalLight | false
128
128
  * ambientLight?: THREE.AmbientLight | false
129
+ * // 色调映射
130
+ * toneMapping?: {
131
+ * toneMapping?: THREE.ToneMapping
132
+ * toneMappingExposure?: number
133
+ * }
134
+ *
129
135
  * ```
130
136
  * 自带三种默认光照配置,你可以提供自己的光照实例。如果设置 `pointLight: false` 则禁用该光照效果。
131
137
  *
@@ -16,7 +16,10 @@ export interface GLTFViewerConfig {
16
16
  ambientLight?: THREE.AmbientLight | false;
17
17
  minFov?: number;
18
18
  maxFov?: number;
19
- toneMapping?: boolean;
19
+ toneMapping?: {
20
+ toneMapping?: THREE.ToneMapping;
21
+ toneMappingExposure?: number;
22
+ };
20
23
  }
21
24
  export interface GLTFViewerState {
22
25
  fov: number;
@@ -43,14 +46,16 @@ export declare class GLTFViewer extends Subscribe<GLTFViewerEventMap> {
43
46
  latitude?: number;
44
47
  longitude?: number;
45
48
  });
49
+ set minFov(fov: number);
50
+ get minFov(): number;
51
+ set maxFov(fov: number);
52
+ get maxFov(): number;
46
53
  /**
47
54
  *
48
55
  * @param url glTF 模型CDN地址
49
56
  * @param options adaptive 是否开启自适应fov
50
57
  */
51
- load(url: string, options?: {
52
- adaptive: boolean;
53
- }): void;
58
+ load(url: string): void;
54
59
  /**
55
60
  * 挂载
56
61
  * @param container
@@ -66,4 +71,8 @@ export declare class GLTFViewer extends Subscribe<GLTFViewerEventMap> {
66
71
  * 销毁
67
72
  */
68
73
  dispose(): void;
74
+ /**
75
+ * 响应式fov
76
+ */
77
+ fitFov(): void;
69
78
  }
@@ -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");
@@ -102,7 +102,10 @@ var Controller = /*#__PURE__*/function () {
102
102
  (0, _defineProperty2["default"])(this, "longitude", 0);
103
103
  (0, _defineProperty2["default"])(this, "latitude", 0);
104
104
  (0, _defineProperty2["default"])(this, "needsRender", false);
105
- this.config = config; // 异步事件回调
105
+ this.config = Object.assign({
106
+ maxFov: 120,
107
+ minFov: 1
108
+ }, config); // 异步事件回调
106
109
 
107
110
  this.callbacks = callbacks; // 默认状态参数
108
111
 
@@ -135,8 +138,11 @@ var Controller = /*#__PURE__*/function () {
135
138
  this.renderer.outputEncoding = THREE.sRGBEncoding;
136
139
 
137
140
  if (config.toneMapping) {
138
- this.renderer.toneMapping = THREE.ReinhardToneMapping;
139
- this.renderer.toneMappingExposure = 1.5;
141
+ var _config$toneMapping = config.toneMapping,
142
+ toneMapping = _config$toneMapping.toneMapping,
143
+ toneMappingExposure = _config$toneMapping.toneMappingExposure;
144
+ if (toneMapping) this.renderer.toneMapping = toneMapping;
145
+ if (toneMappingExposure !== undefined) this.renderer.toneMappingExposure = toneMappingExposure;
140
146
  }
141
147
 
142
148
  if (config.backgroundColor) {
@@ -149,10 +155,10 @@ var Controller = /*#__PURE__*/function () {
149
155
  } // 相机
150
156
 
151
157
 
152
- this.camera = new THREE.PerspectiveCamera(this.fov, 1, 0.1, 1000); // 光照
158
+ this.camera = new THREE.PerspectiveCamera(this.fov, 1, 0.1, 1500); // 光照
153
159
 
154
160
  if (config.pointLight !== false) {
155
- this.pointLight = config.pointLight || new THREE.PointLight(0xfffffff, 1, 10000);
161
+ this.pointLight = config.pointLight || new THREE.PointLight(0xfffffff, 1, 1500);
156
162
  this.scene.add(this.pointLight);
157
163
  }
158
164
 
@@ -267,18 +273,14 @@ var Controller = /*#__PURE__*/function () {
267
273
 
268
274
  this.target = object;
269
275
  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
-
276
+ this.scene.add(this.target.scene);
277
277
  setTimeout(function () {
278
278
  if (object === _this3.target) {
279
279
  _this3.target.scene.visible = true;
280
280
 
281
281
  _this3.update({});
282
+
283
+ _this3.callbacks.loaded(object);
282
284
  }
283
285
  }, 50);
284
286
  }
@@ -388,34 +390,13 @@ var Controller = /*#__PURE__*/function () {
388
390
  fov = calcFov(d, radius * 2, this.renderer.domElement.offsetWidth / this.renderer.domElement.offsetHeight);
389
391
  }
390
392
 
393
+ fov = Math.max(this.minFov, Math.min(this.maxFov, fov));
394
+
391
395
  if (fov !== this.fov) {
392
- fov = Math.max(this.minFov, Math.min(this.maxFov, fov));
393
396
  this.camera.fov = fov;
394
397
  this.camera.updateProjectionMatrix();
395
398
  }
396
399
 
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
400
  var needsRender = this.fov !== fov || this.longitude !== longitude || this.latitude !== latitude;
420
401
  Object.assign(this, {
421
402
  longitude: longitude,
@@ -574,8 +555,6 @@ var Controller = /*#__PURE__*/function () {
574
555
  loader.load(url, function (gltf) {
575
556
  _this6.setTarget(gltf);
576
557
 
577
- _this6.callbacks.loaded(gltf);
578
-
579
558
  resolve(true);
580
559
  }, function (xhr) {
581
560
  _this6.callbacks.progressing(xhr.loaded / xhr.total * 100);
@@ -684,18 +663,42 @@ var GLTFViewer = /*#__PURE__*/function (_Subscribe) {
684
663
  longitude: longitude === undefined ? controller.longitude : longitude
685
664
  });
686
665
  }
666
+ }, {
667
+ key: "minFov",
668
+ get: function get() {
669
+ var controller = caches[this.uuid];
670
+ if (!controller) throw new Error(ERROR_NO_CONTROLLER);
671
+ return controller.minFov;
672
+ },
673
+ set: function set(fov) {
674
+ var controller = caches[this.uuid];
675
+ if (!controller) throw new Error(ERROR_NO_CONTROLLER);
676
+ controller.config.minFov = fov;
677
+ controller.update({});
678
+ }
679
+ }, {
680
+ key: "maxFov",
681
+ get: function get() {
682
+ var controller = caches[this.uuid];
683
+ if (!controller) throw new Error(ERROR_NO_CONTROLLER);
684
+ return controller.maxFov;
685
+ }
687
686
  /**
688
687
  *
689
688
  * @param url glTF 模型CDN地址
690
689
  * @param options adaptive 是否开启自适应fov
691
690
  */
692
-
691
+ ,
692
+ set: function set(fov) {
693
+ var controller = caches[this.uuid];
694
+ if (!controller) throw new Error(ERROR_NO_CONTROLLER);
695
+ console.log('maxFov', controller.config);
696
+ controller.config.maxFov = fov;
697
+ controller.update({});
698
+ }
693
699
  }, {
694
700
  key: "load",
695
701
  value: function load(url) {
696
- var options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {
697
- adaptive: true
698
- };
699
702
  var controller = caches[this.uuid];
700
703
  if (!controller) throw new Error(ERROR_NO_CONTROLLER);
701
704
  controller.load(url);
@@ -737,6 +740,19 @@ var GLTFViewer = /*#__PURE__*/function (_Subscribe) {
737
740
  if (controller.dispose) controller.dispose();
738
741
  delete caches[this.uuid];
739
742
  }
743
+ /**
744
+ * 响应式fov
745
+ */
746
+
747
+ }, {
748
+ key: "fitFov",
749
+ value: function fitFov() {
750
+ var controller = caches[this.uuid];
751
+ if (!controller) throw new Error(ERROR_NO_CONTROLLER);
752
+ controller.update({
753
+ fov: 0
754
+ });
755
+ }
740
756
  }]);
741
757
  return GLTFViewer;
742
758
  }(_Subscribe2.Subscribe);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@realsee/dnalogel",
3
- "version": "0.1.7-alpha.4",
3
+ "version": "0.1.7-alpha.5",
4
4
  "description": "如视前端 Components、Plugins 兼部分 SDKs \"Dnalogel\" 库。",
5
5
  "author": "BEIKE REALSEE TECHNOLOGY (HK) LIMITED",
6
6
  "peerDependencies": {
@@ -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;