three-zoo 0.10.2 → 0.11.1
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/dist/index.js +78 -52
- package/dist/index.js.map +1 -1
- package/dist/index.min.js +1 -1
- package/dist/index.min.js.map +1 -1
- package/package.json +3 -3
package/dist/index.js
CHANGED
|
@@ -720,7 +720,7 @@ class StandardToBasicConverter {
|
|
|
720
720
|
target.wireframe = source.wireframe;
|
|
721
721
|
target.wireframeLinewidth = source.wireframeLinewidth;
|
|
722
722
|
target.vertexColors = source.vertexColors;
|
|
723
|
-
if (config.copyUserData) {
|
|
723
|
+
if (config.copyUserData && source.userData) {
|
|
724
724
|
target.userData = Object.assign({}, source.userData);
|
|
725
725
|
}
|
|
726
726
|
}
|
|
@@ -734,25 +734,27 @@ class StandardToBasicConverter {
|
|
|
734
734
|
*/
|
|
735
735
|
static convertColorProperties(source, target, config) {
|
|
736
736
|
// Base color conversion with brightness compensation
|
|
737
|
-
|
|
738
|
-
|
|
739
|
-
|
|
740
|
-
|
|
741
|
-
|
|
742
|
-
|
|
743
|
-
|
|
744
|
-
|
|
745
|
-
|
|
746
|
-
|
|
747
|
-
|
|
748
|
-
.
|
|
749
|
-
|
|
750
|
-
|
|
737
|
+
if (source.color) {
|
|
738
|
+
target.color = source.color.clone();
|
|
739
|
+
// Apply brightness compensation since BasicMaterial doesn't respond to lighting
|
|
740
|
+
target.color.multiplyScalar(config.brightnessFactor);
|
|
741
|
+
// Adjust for metalness - metallic materials tend to be darker without lighting
|
|
742
|
+
if (source.metalness > 0) {
|
|
743
|
+
const metalnessBrightness = 1 + source.metalness * METALNESS_BRIGHTNESS_FACTOR;
|
|
744
|
+
target.color.multiplyScalar(metalnessBrightness);
|
|
745
|
+
}
|
|
746
|
+
// Combine emissive color if requested
|
|
747
|
+
if (config.combineEmissive && source.emissive) {
|
|
748
|
+
const emissiveContribution = source.emissive
|
|
749
|
+
.clone()
|
|
750
|
+
.multiplyScalar(source.emissiveIntensity * EMISSIVE_CONTRIBUTION_FACTOR);
|
|
751
|
+
target.color.add(emissiveContribution);
|
|
752
|
+
}
|
|
753
|
+
// Ensure color doesn't exceed valid range
|
|
754
|
+
target.color.r = Math.min(target.color.r, 1.0);
|
|
755
|
+
target.color.g = Math.min(target.color.g, 1.0);
|
|
756
|
+
target.color.b = Math.min(target.color.b, 1.0);
|
|
751
757
|
}
|
|
752
|
-
// Ensure color doesn't exceed valid range
|
|
753
|
-
target.color.r = Math.min(target.color.r, 1.0);
|
|
754
|
-
target.color.g = Math.min(target.color.g, 1.0);
|
|
755
|
-
target.color.b = Math.min(target.color.b, 1.0);
|
|
756
758
|
}
|
|
757
759
|
/**
|
|
758
760
|
* Converts texture properties from Standard to Basic material.
|
|
@@ -866,7 +868,7 @@ class StandardToLambertConverter {
|
|
|
866
868
|
target.wireframeLinewidth = source.wireframeLinewidth;
|
|
867
869
|
target.vertexColors = source.vertexColors;
|
|
868
870
|
target.flatShading = source.flatShading;
|
|
869
|
-
if (config.copyUserData) {
|
|
871
|
+
if (config.copyUserData && source.userData) {
|
|
870
872
|
target.userData = Object.assign({}, source.userData);
|
|
871
873
|
}
|
|
872
874
|
}
|
|
@@ -879,20 +881,24 @@ class StandardToLambertConverter {
|
|
|
879
881
|
* @internal
|
|
880
882
|
*/
|
|
881
883
|
static convertColorProperties(source, target, config) {
|
|
882
|
-
|
|
883
|
-
|
|
884
|
-
|
|
885
|
-
|
|
886
|
-
|
|
887
|
-
|
|
888
|
-
|
|
889
|
-
|
|
890
|
-
|
|
891
|
-
|
|
892
|
-
|
|
893
|
-
|
|
894
|
-
|
|
895
|
-
|
|
884
|
+
if (source.color) {
|
|
885
|
+
target.color = source.color.clone();
|
|
886
|
+
// Adjust color based on metalness and roughness for better visual match
|
|
887
|
+
if (source.metalness > 0) {
|
|
888
|
+
// Metallic materials tend to be darker in Lambert shading
|
|
889
|
+
const metalnessFactor = 1 - source.metalness * METALNESS_DARKNESS_FACTOR$1;
|
|
890
|
+
target.color.multiplyScalar(metalnessFactor);
|
|
891
|
+
}
|
|
892
|
+
if (source.roughness > ROUGHNESS_THRESHOLD) {
|
|
893
|
+
// Rough materials appear slightly darker
|
|
894
|
+
const roughnessFactor = config.roughnessColorFactor +
|
|
895
|
+
source.roughness * ROUGHNESS_COLOR_ADJUSTMENT;
|
|
896
|
+
target.color.multiplyScalar(roughnessFactor);
|
|
897
|
+
}
|
|
898
|
+
}
|
|
899
|
+
if (source.emissive) {
|
|
900
|
+
target.emissive = source.emissive.clone();
|
|
901
|
+
}
|
|
896
902
|
target.emissiveIntensity = source.emissiveIntensity;
|
|
897
903
|
}
|
|
898
904
|
/**
|
|
@@ -914,7 +920,9 @@ class StandardToLambertConverter {
|
|
|
914
920
|
// Normal map (Lambert materials support normal mapping)
|
|
915
921
|
if (source.normalMap) {
|
|
916
922
|
target.normalMap = source.normalMap;
|
|
917
|
-
|
|
923
|
+
if (source.normalScale) {
|
|
924
|
+
target.normalScale = source.normalScale.clone();
|
|
925
|
+
}
|
|
918
926
|
}
|
|
919
927
|
// Light map
|
|
920
928
|
if (source.lightMap) {
|
|
@@ -1008,7 +1016,7 @@ class StandardToPhongConverter {
|
|
|
1008
1016
|
target.wireframeLinewidth = source.wireframeLinewidth;
|
|
1009
1017
|
target.vertexColors = source.vertexColors;
|
|
1010
1018
|
target.flatShading = source.flatShading;
|
|
1011
|
-
if (config.copyUserData) {
|
|
1019
|
+
if (config.copyUserData && source.userData) {
|
|
1012
1020
|
target.userData = Object.assign({}, source.userData);
|
|
1013
1021
|
}
|
|
1014
1022
|
}
|
|
@@ -1021,17 +1029,19 @@ class StandardToPhongConverter {
|
|
|
1021
1029
|
* @internal
|
|
1022
1030
|
*/
|
|
1023
1031
|
static convertColorProperties(source, target, config) {
|
|
1024
|
-
|
|
1025
|
-
|
|
1026
|
-
|
|
1027
|
-
|
|
1028
|
-
|
|
1032
|
+
if (source.color) {
|
|
1033
|
+
target.color = source.color.clone();
|
|
1034
|
+
// Adjust color based on metalness
|
|
1035
|
+
if (source.metalness > 0) {
|
|
1036
|
+
const metalnessFactor = 1 - source.metalness * METALNESS_DARKNESS_FACTOR;
|
|
1037
|
+
target.color.multiplyScalar(metalnessFactor);
|
|
1038
|
+
}
|
|
1029
1039
|
}
|
|
1030
1040
|
// Convert roughness to shininess (inverse relationship)
|
|
1031
1041
|
// Roughness 0 = max shininess, Roughness 1 = shininess 0
|
|
1032
1042
|
target.shininess = (1 - source.roughness) * config.maxShininess;
|
|
1033
1043
|
// Calculate specular color from metalness and base color
|
|
1034
|
-
if (source.metalness > 0) {
|
|
1044
|
+
if (source.metalness > 0 && source.color) {
|
|
1035
1045
|
// Metallic materials have tinted specular
|
|
1036
1046
|
target.specular = source.color
|
|
1037
1047
|
.clone()
|
|
@@ -1042,7 +1052,9 @@ class StandardToPhongConverter {
|
|
|
1042
1052
|
const specularValue = config.specularIntensity * (1 - source.roughness);
|
|
1043
1053
|
target.specular = new Color(specularValue, specularValue, specularValue);
|
|
1044
1054
|
}
|
|
1045
|
-
|
|
1055
|
+
if (source.emissive) {
|
|
1056
|
+
target.emissive = source.emissive.clone();
|
|
1057
|
+
}
|
|
1046
1058
|
target.emissiveIntensity = source.emissiveIntensity;
|
|
1047
1059
|
}
|
|
1048
1060
|
/**
|
|
@@ -1064,7 +1076,9 @@ class StandardToPhongConverter {
|
|
|
1064
1076
|
// Normal map
|
|
1065
1077
|
if (source.normalMap) {
|
|
1066
1078
|
target.normalMap = source.normalMap;
|
|
1067
|
-
|
|
1079
|
+
if (source.normalScale) {
|
|
1080
|
+
target.normalScale = source.normalScale.clone();
|
|
1081
|
+
}
|
|
1068
1082
|
}
|
|
1069
1083
|
// Bump map
|
|
1070
1084
|
if (source.bumpMap) {
|
|
@@ -1174,7 +1188,7 @@ class StandardToPhysicalConverter {
|
|
|
1174
1188
|
target.wireframeLinewidth = source.wireframeLinewidth;
|
|
1175
1189
|
target.vertexColors = source.vertexColors;
|
|
1176
1190
|
target.flatShading = source.flatShading;
|
|
1177
|
-
if (config.copyUserData) {
|
|
1191
|
+
if (config.copyUserData && source.userData) {
|
|
1178
1192
|
target.userData = Object.assign({}, source.userData);
|
|
1179
1193
|
}
|
|
1180
1194
|
}
|
|
@@ -1187,8 +1201,12 @@ class StandardToPhysicalConverter {
|
|
|
1187
1201
|
*/
|
|
1188
1202
|
static copyStandardProperties(source, target) {
|
|
1189
1203
|
// Color properties
|
|
1190
|
-
|
|
1191
|
-
|
|
1204
|
+
if (source.color) {
|
|
1205
|
+
target.color = source.color.clone();
|
|
1206
|
+
}
|
|
1207
|
+
if (source.emissive) {
|
|
1208
|
+
target.emissive = source.emissive.clone();
|
|
1209
|
+
}
|
|
1192
1210
|
target.emissiveIntensity = source.emissiveIntensity;
|
|
1193
1211
|
// PBR properties
|
|
1194
1212
|
target.metalness = source.metalness;
|
|
@@ -1216,7 +1234,9 @@ class StandardToPhysicalConverter {
|
|
|
1216
1234
|
if (source.normalMap) {
|
|
1217
1235
|
target.normalMap = source.normalMap;
|
|
1218
1236
|
target.normalMapType = source.normalMapType;
|
|
1219
|
-
|
|
1237
|
+
if (source.normalScale) {
|
|
1238
|
+
target.normalScale = source.normalScale.clone();
|
|
1239
|
+
}
|
|
1220
1240
|
}
|
|
1221
1241
|
// Bump map
|
|
1222
1242
|
if (source.bumpMap) {
|
|
@@ -1345,7 +1365,7 @@ class StandardToToonConverter {
|
|
|
1345
1365
|
target.wireframe = source.wireframe;
|
|
1346
1366
|
target.wireframeLinewidth = source.wireframeLinewidth;
|
|
1347
1367
|
target.vertexColors = source.vertexColors;
|
|
1348
|
-
if (config.copyUserData) {
|
|
1368
|
+
if (config.copyUserData && source.userData) {
|
|
1349
1369
|
target.userData = Object.assign({}, source.userData);
|
|
1350
1370
|
}
|
|
1351
1371
|
}
|
|
@@ -1357,8 +1377,12 @@ class StandardToToonConverter {
|
|
|
1357
1377
|
* @internal
|
|
1358
1378
|
*/
|
|
1359
1379
|
static convertColorProperties(source, target) {
|
|
1360
|
-
|
|
1361
|
-
|
|
1380
|
+
if (source.color) {
|
|
1381
|
+
target.color = source.color.clone();
|
|
1382
|
+
}
|
|
1383
|
+
if (source.emissive) {
|
|
1384
|
+
target.emissive = source.emissive.clone();
|
|
1385
|
+
}
|
|
1362
1386
|
target.emissiveIntensity = source.emissiveIntensity;
|
|
1363
1387
|
}
|
|
1364
1388
|
/**
|
|
@@ -1384,7 +1408,9 @@ class StandardToToonConverter {
|
|
|
1384
1408
|
if (source.normalMap) {
|
|
1385
1409
|
target.normalMap = source.normalMap;
|
|
1386
1410
|
target.normalMapType = source.normalMapType;
|
|
1387
|
-
|
|
1411
|
+
if (source.normalScale) {
|
|
1412
|
+
target.normalScale = source.normalScale.clone();
|
|
1413
|
+
}
|
|
1388
1414
|
}
|
|
1389
1415
|
// Bump map
|
|
1390
1416
|
if (source.bumpMap) {
|