|
|
@ -19,6 +19,8 @@ class MatHelper{ |
|
|
|
|
|
|
|
const OPEN = 1 | true; |
|
|
|
const CLOSE = 0 | false; |
|
|
|
const COLOR_SPACE_SRGB = 2.2; |
|
|
|
const COLOR_SPACE_NO = 1; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@ -26,12 +28,16 @@ class MatHelper{ |
|
|
|
/** |
|
|
|
* 十六进制颜色 转换为 浮点数颜色 |
|
|
|
*/ |
|
|
|
static function hex2floatColor($hexColor, $scale = 1, $gamma = 2.2){ |
|
|
|
static function hex2floatColor($hexColor, $scale = 1, $gamma = self::COLOR_SPACE_SRGB){ |
|
|
|
// 十六进制颜色 转 RGB色
|
|
|
|
$color = Factory::fromString(trim($hexColor)); |
|
|
|
$color = $color->toRgb(); |
|
|
|
|
|
|
|
// RGB色 转 浮点数RGB颜色
|
|
|
|
$floatColor = ''; |
|
|
|
$hexColor = trim($hexColor); |
|
|
|
$r = (hexdec(substr($hexColor, 1, 2))/255 * $scale) ** $gamma; |
|
|
|
$g = (hexdec(substr($hexColor, 3, 2))/255 * $scale) ** $gamma; |
|
|
|
$b = (hexdec(substr($hexColor, 5, 2))/255 * $scale) ** $gamma; |
|
|
|
$r = ($color->red() / 255 * $scale) ** $gamma; |
|
|
|
$g = ($color->green() / 255 * $scale) ** $gamma; |
|
|
|
$b = ($color->blue() / 255 * $scale) ** $gamma; |
|
|
|
$floatColor = "$r $g $b"; |
|
|
|
return $floatColor; |
|
|
|
} |
|
|
@ -39,7 +45,7 @@ class MatHelper{ |
|
|
|
/** |
|
|
|
* 获得 十六进制颜色 同色调 的 最大亮度 |
|
|
|
*/ |
|
|
|
static function colorMaxBrightness($hexColor,$scale){ |
|
|
|
static function colorMaxBrightness($hexColor,$scale = 1){ |
|
|
|
// 十六进制颜色 转 HSB色
|
|
|
|
$color = Factory::fromString($hexColor); |
|
|
|
$color = $color->toHsb(); |
|
|
@ -427,7 +433,10 @@ class MatHelper{ |
|
|
|
$matOriginal->matParams->translucencyColor |
|
|
|
)); |
|
|
|
$material->setBaseColor( self::hex2floatColor( |
|
|
|
self::colorMaxBrightness($matOriginal->matParams->translucencyColor, $translucencyIntensity), |
|
|
|
self::colorMaxBrightness( |
|
|
|
$matOriginal->matParams->translucencyColor, |
|
|
|
$translucencyIntensity ** (1/2.2) |
|
|
|
), |
|
|
|
1 - $translucencyIntensity |
|
|
|
)); |
|
|
|
// $material->setSpecular(
|
|
|
|