three-base 2.0.125 → 2.0.126

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.
package/ThreeBase.d.ts CHANGED
@@ -4,7 +4,7 @@ import ThreeMouse from "./ThreeMouse";
4
4
  import Transition from "./Transition";
5
5
  export default class ThreeBase extends EventDispatcher {
6
6
  constructor();
7
- devicePixelRatio: number;
7
+ minDevicePixelRatio: number;
8
8
  baseDepthTexture: DepthTexture;
9
9
  baseRenderTarget: WebGLRenderTarget<Texture>;
10
10
  renderTarget: WebGLRenderTarget<Texture>;
package/ThreeBase.js CHANGED
@@ -38,8 +38,8 @@ export default class ThreeBase extends EventDispatcher {
38
38
  });
39
39
  this.init();
40
40
  }
41
- // 设置分辨率
42
- devicePixelRatio = Math.max(window.devicePixelRatio, 2);
41
+ // 设置最小分辨率
42
+ minDevicePixelRatio = 1;
43
43
  // 基础深度纹理
44
44
  baseDepthTexture = (() => {
45
45
  const baseDepthTexture = new DepthTexture(4096, 4096);
@@ -101,8 +101,8 @@ export default class ThreeBase extends EventDispatcher {
101
101
  this.rendererLost = false;
102
102
  }, false);
103
103
  renderer.localClippingEnabled = true;
104
- renderer.setPixelRatio(this.devicePixelRatio);
105
- renderer.autoClear = false;
104
+ renderer.setPixelRatio(Math.max(window.devicePixelRatio, this.minDevicePixelRatio)),
105
+ renderer.autoClear = false;
106
106
  renderer.clear();
107
107
  renderer.outputColorSpace = SRGBColorSpace;
108
108
  // 缓解过暗或者过亮
@@ -194,14 +194,14 @@ export default class ThreeBase extends EventDispatcher {
194
194
  // this.orthographicCamera.bottom = -height / width;
195
195
  this.orthographicCamera.left = -width / height;
196
196
  this.orthographicCamera.right = width / height;
197
- this.renderer.setPixelRatio(this.devicePixelRatio);
198
- this.renderer.setSize(width, height);
197
+ this.renderer.setPixelRatio(Math.max(window.devicePixelRatio, this.minDevicePixelRatio)),
198
+ this.renderer.setSize(width, height);
199
199
  // 设置帧缓存区的尺寸
200
- this.baseRenderTarget.setSize(width * this.devicePixelRatio, height * this.devicePixelRatio);
200
+ this.baseRenderTarget.setSize(width * Math.max(window.devicePixelRatio, this.minDevicePixelRatio), height * Math.max(window.devicePixelRatio, this.minDevicePixelRatio));
201
201
  // 设置深度纹理的尺寸
202
- this.baseDepthTexture.image.width = width * this.devicePixelRatio;
203
- this.baseDepthTexture.image.height = height * this.devicePixelRatio;
204
- this.size.set(width, height);
202
+ this.baseDepthTexture.image.width = width * Math.max(window.devicePixelRatio, this.minDevicePixelRatio),
203
+ this.baseDepthTexture.image.height = height * Math.max(window.devicePixelRatio, this.minDevicePixelRatio),
204
+ this.size.set(width, height);
205
205
  setTimeout(() => {
206
206
  this.needRender = true;
207
207
  }, 100);
@@ -489,15 +489,15 @@ export default class ThreeBase extends EventDispatcher {
489
489
  this.renderer.render(this.scene, camera);
490
490
  // 后处理特效渲染(描边,发光,颜色覆盖,bloom,磨砂玻璃)
491
491
  this.scene.traverseVisible((obj) => {
492
- stroke_pass(this.renderer, camera, obj, this.baseDepthTexture, this.devicePixelRatio);
493
- glow_pass(this.renderer, camera, obj, this.baseDepthTexture, this.devicePixelRatio);
494
- bloom_pass(this.renderer, camera, obj, this.baseRenderTarget, this.baseDepthTexture, this.devicePixelRatio);
492
+ stroke_pass(this.renderer, camera, obj, this.baseDepthTexture, Math.max(window.devicePixelRatio, this.minDevicePixelRatio));
493
+ glow_pass(this.renderer, camera, obj, this.baseDepthTexture, Math.max(window.devicePixelRatio, this.minDevicePixelRatio));
494
+ bloom_pass(this.renderer, camera, obj, this.baseRenderTarget, this.baseDepthTexture, Math.max(window.devicePixelRatio, this.minDevicePixelRatio));
495
495
  });
496
496
  this.renderer.setRenderTarget(null);
497
497
  this.renderer.clear();
498
498
  this.renderRendererTarget(this.baseRenderTarget);
499
499
  this.scene.traverseVisible((obj) => {
500
- cover_pass(this.renderer, camera, obj, this.baseDepthTexture, this.devicePixelRatio);
500
+ cover_pass(this.renderer, camera, obj, this.baseDepthTexture, Math.max(window.devicePixelRatio, this.minDevicePixelRatio));
501
501
  });
502
502
  this.dispatchEvent({ type: "afterRender" });
503
503
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "three-base",
3
- "version": "2.0.125",
3
+ "version": "2.0.126",
4
4
  "description": "three 3d three-base",
5
5
  "publishConfig": {
6
6
  "registry": "https://registry.npmjs.org/"