@qy_better_lib/hooks 0.2.18 → 0.2.20
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/lib/use-three/index.mjs +15 -13
- package/package.json +1 -1
package/lib/use-three/index.mjs
CHANGED
|
@@ -528,9 +528,15 @@ function use_renderer(current_three) {
|
|
|
528
528
|
last_render_time = timestamp;
|
|
529
529
|
try {
|
|
530
530
|
if (current_three.scene && current_three.camera && current_three.renderer) {
|
|
531
|
-
|
|
531
|
+
let hasCustomRender = false;
|
|
532
|
+
if (render_action) {
|
|
533
|
+
render_action();
|
|
534
|
+
hasCustomRender = true;
|
|
535
|
+
}
|
|
536
|
+
if (!hasCustomRender) {
|
|
537
|
+
current_three.renderer.render(current_three.scene, current_three.camera);
|
|
538
|
+
}
|
|
532
539
|
current_three.css2Renderer?.render(current_three.scene, current_three.camera);
|
|
533
|
-
current_three.renderer.render(current_three.scene, current_three.camera);
|
|
534
540
|
}
|
|
535
541
|
} catch (error) {
|
|
536
542
|
console.error("Three.js render error:", error);
|
|
@@ -964,7 +970,7 @@ function use_effect_composer(current_three) {
|
|
|
964
970
|
}
|
|
965
971
|
function enable_effect(use_ssao = true, ssao_options) {
|
|
966
972
|
if (!current_three.renderer) {
|
|
967
|
-
console.error("
|
|
973
|
+
console.error("渲染器未初始化");
|
|
968
974
|
return null;
|
|
969
975
|
}
|
|
970
976
|
const composer = new EffectComposer(current_three.renderer);
|
|
@@ -987,7 +993,7 @@ function use_effect_composer(current_three) {
|
|
|
987
993
|
}
|
|
988
994
|
function enable_fxaa(composer) {
|
|
989
995
|
if (!composer || !current_three.renderer) {
|
|
990
|
-
console.error("Composer
|
|
996
|
+
console.error("Composer或渲染器未初始化");
|
|
991
997
|
return;
|
|
992
998
|
}
|
|
993
999
|
const { width, height } = get_container_size();
|
|
@@ -1001,7 +1007,7 @@ function use_effect_composer(current_three) {
|
|
|
1001
1007
|
}
|
|
1002
1008
|
function enable_unreal_bloom(composer, strength = 0.4, radius = 1.5, threshold = 0.2) {
|
|
1003
1009
|
if (!composer) {
|
|
1004
|
-
console.error("Composer
|
|
1010
|
+
console.error("Composer未初始化");
|
|
1005
1011
|
return null;
|
|
1006
1012
|
}
|
|
1007
1013
|
const { width, height } = get_container_size();
|
|
@@ -1014,13 +1020,12 @@ function use_effect_composer(current_three) {
|
|
|
1014
1020
|
threshold
|
|
1015
1021
|
// 阈值:亮度达到多少时触发光晕
|
|
1016
1022
|
);
|
|
1017
|
-
bloom_pass.renderToScreen = true;
|
|
1018
1023
|
composer.addPass(bloom_pass);
|
|
1019
1024
|
return bloom_pass;
|
|
1020
1025
|
}
|
|
1021
1026
|
function enable_outline(composer) {
|
|
1022
1027
|
if (!composer || !current_three.scene || !current_three.camera) {
|
|
1023
|
-
console.error("Composer
|
|
1028
|
+
console.error("Composer,场景、相机未初始化");
|
|
1024
1029
|
return null;
|
|
1025
1030
|
}
|
|
1026
1031
|
const { width, height } = get_container_size();
|
|
@@ -1029,13 +1034,12 @@ function use_effect_composer(current_three) {
|
|
|
1029
1034
|
current_three.scene,
|
|
1030
1035
|
current_three.camera
|
|
1031
1036
|
);
|
|
1032
|
-
outline_pass.renderToScreen = true;
|
|
1033
1037
|
composer.addPass(outline_pass);
|
|
1034
1038
|
return outline_pass;
|
|
1035
1039
|
}
|
|
1036
1040
|
function set_out_line(outline_pass, objects, out_line_options = {}) {
|
|
1037
1041
|
if (!outline_pass) {
|
|
1038
|
-
console.error("
|
|
1042
|
+
console.error("轮廓高亮Pass未初始化");
|
|
1039
1043
|
return;
|
|
1040
1044
|
}
|
|
1041
1045
|
const default_options = {
|
|
@@ -1070,7 +1074,7 @@ function use_effect_composer(current_three) {
|
|
|
1070
1074
|
}
|
|
1071
1075
|
function enable_film_effect(composer, options = {}) {
|
|
1072
1076
|
if (!composer) {
|
|
1073
|
-
console.error("Composer
|
|
1077
|
+
console.error("Composer未初始化");
|
|
1074
1078
|
return null;
|
|
1075
1079
|
}
|
|
1076
1080
|
const default_options = {
|
|
@@ -1087,17 +1091,15 @@ function use_effect_composer(current_three) {
|
|
|
1087
1091
|
grayscale
|
|
1088
1092
|
// 灰度模式
|
|
1089
1093
|
);
|
|
1090
|
-
film_pass.renderToScreen = true;
|
|
1091
1094
|
composer.addPass(film_pass);
|
|
1092
1095
|
return film_pass;
|
|
1093
1096
|
}
|
|
1094
1097
|
function enable_grayscale(composer) {
|
|
1095
1098
|
if (!composer) {
|
|
1096
|
-
console.error("Composer
|
|
1099
|
+
console.error("Composer未初始化");
|
|
1097
1100
|
return null;
|
|
1098
1101
|
}
|
|
1099
1102
|
const grayscale_pass = new ShaderPass(LuminosityShader);
|
|
1100
|
-
grayscale_pass.renderToScreen = true;
|
|
1101
1103
|
composer.addPass(grayscale_pass);
|
|
1102
1104
|
return grayscale_pass;
|
|
1103
1105
|
}
|