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 +1 -1
- package/ThreeBase.js +14 -14
- package/package.json +1 -1
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
|
-
|
|
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
|
-
|
|
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.
|
|
105
|
-
|
|
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.
|
|
198
|
-
|
|
197
|
+
this.renderer.setPixelRatio(Math.max(window.devicePixelRatio, this.minDevicePixelRatio)),
|
|
198
|
+
this.renderer.setSize(width, height);
|
|
199
199
|
// 设置帧缓存区的尺寸
|
|
200
|
-
this.baseRenderTarget.setSize(width *
|
|
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.
|
|
203
|
-
|
|
204
|
-
|
|
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.
|
|
493
|
-
glow_pass(this.renderer, camera, obj, this.baseDepthTexture, this.
|
|
494
|
-
bloom_pass(this.renderer, camera, obj, this.baseRenderTarget, this.baseDepthTexture, this.
|
|
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.
|
|
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
|
}
|