diff --git a/composer.json b/composer.json index 6e6f5a4..5da1a01 100644 --- a/composer.json +++ b/composer.json @@ -6,7 +6,6 @@ "autoload": { "psr-4": { "Blobt\\Luxcore\\": "src/" - } }, "authors": [ diff --git a/examples/print.php b/examples/print.php index 950783f..84a10c8 100644 --- a/examples/print.php +++ b/examples/print.php @@ -3,16 +3,16 @@ namespace Blobt\Luxcore\scene; -use Blobt\Luxcore\scene\materials; -use Blobt\Luxcore\scene\materials\Emission; -use Blobt\Luxcore\scene\objects; -use Blobt\Luxcore\scene\render; -use Blobt\Luxcore\scene\texture; include dirname(dirname(__FILE__)) . "/vendor/autoload.php"; +include dirname(dirname(__FILE__)) . "/src/core/AutuHandle.php"; + + + /* + echo '>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>渲染配置参数>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>'; echo "\n\n\n\n"; @@ -83,21 +83,22 @@ $scene = new Scene();//创建一个场景, //添加第一个模型 -$obj = new objects\Objects( [ 'ply' => 'mesh-10086.ply','appliedtransformation' => '1 0 0 0 0 1 0 0 0 0 1 0 0 0 0 1' ] ); //创建一个的模型 + +$obj = new objects\Objects( null,[ 'ply' => 'mesh-10086.ply','appliedtransformation' => '1 0 0 0 0 1 0 0 0 0 1 0 0 0 0 1' ] ); //创建一个的模型 -$cloudsMap = new texture\map\Clouds( new texture\mapping\Mapping() ); //创建一个 Clouds类的贴图对象 -//$scene->registerTexture($cloudsMap); //将这个对象注册到 Scene +$cloudsMap = new texture\map\Clouds(); //创建一个 Clouds类的贴图对象 +$scene->registerTexture($cloudsMap); //将这个对象注册到 Scene -$imageMap = new texture\map\ImageMap( new texture\mapping\Mapping() ); //创建一个 ImageMap类的贴图对象 -//$scene->registerTexture($imageMap); //将这个对象注册到 Scene +$imageMap = new texture\map\ImageMap(); //创建一个 ImageMap类的贴图对象 +$scene->registerTexture($imageMap); //将这个对象注册到 Scene -$blend = new texture\map\Blend( new texture\mapping\Mapping() ); //创建一个 Blend类的贴图对象 -$scene->registerTexture($blend); //将这个对象注册到 Scene +$blend = new texture\map\Blend(); //创建一个 Blend类的贴图对象 +$scene->registerTexture($blend); //将这个对象注册到 Scene $disney = new materials\Disney(); //创建一个 Disney 材质对象 -$disney->setBaseColor($cloudsMap); //为 basecolor 指定一个贴图对象,如果这个对象没有注册到Scenn,则 set函数抛出异常,以下同理 +$disney->setBaseColor($cloudsMap); //为 basecolor 指定一个贴图对象,如果这个对象没有注册到Scene,则 set函数抛出异常,以下同理 $disney->setMetallic($blend); $disney->setBumptex($imageMap); $scene->registerMaterial($disney); //将这个对象注册到 Scene @@ -132,5 +133,4 @@ $scene->addObject($obj); //将模型添加到场景中 echo $scene; - ?> diff --git a/src/core/AutuHandle.php b/src/core/AutuHandle.php new file mode 100644 index 0000000..f1bd644 --- /dev/null +++ b/src/core/AutuHandle.php @@ -0,0 +1,21 @@ +init(); + +?> diff --git a/src/core/RenderException .php b/src/core/RenderException .php new file mode 100644 index 0000000..e5c62e2 --- /dev/null +++ b/src/core/RenderException .php @@ -0,0 +1,10 @@ + diff --git a/src/core/SceneException.php b/src/core/SceneException.php new file mode 100644 index 0000000..962446d --- /dev/null +++ b/src/core/SceneException.php @@ -0,0 +1,31 @@ +code) + { + + case 1: + $this->message = '警告! 你在位置:'.explode("\n",$this->message)[0]."\n". + '为当前通道赋值是一个未注册的 '.explode("\n",$this->message)[1].'对象,程序已经提前终止!!!'; + return $this->message; + break; + + case 2; + return $this->message = "举例,后面修改!\n"; + break; + + default: + return $this->message = "未知的错误类型!举例,后面修改!\n"; + } + + } + +} + +?> diff --git a/src/scene/materials/Disney.php b/src/scene/materials/Disney.php index 7c49081..24e1616 100644 --- a/src/scene/materials/Disney.php +++ b/src/scene/materials/Disney.php @@ -1,9 +1,7 @@ type = self::TYPE_DISNEY; $this->id = Scene::createID(); - Base::__construct($config); + core\Base::__construct($config); } public function setBaseColor($color) @@ -114,13 +112,14 @@ class Disney extends MaterialsBase { if( $color->cards != null ) $this->basecolor = $color->cards; else - { - $backtrace = debug_backtrace(); - $backtrace = $backtrace[0]['file'].':'.$backtrace[0]['line']."\n"; - $this->printException($backtrace,$color); + { + $message = debug_backtrace(); + $message = $message[0]['file'].':'.$message[0]['line']."\n"; + $message .= array_reverse(explode('\\', get_class($color)))[0]; + throw new core\SceneException($message,1); } } - else $this->basecolor = $color; + else $this->basecolor = $color; } public function setSubsurface($color) @@ -130,9 +129,10 @@ class Disney extends MaterialsBase if( $color->cards != null ) $this->subsurface = $color->cards; else { - $backtrace = debug_backtrace(); - $backtrace = $backtrace[0]['file'].':'.$backtrace[0]['line']."\n"; - $this->printException($backtrace,$color); + $message = debug_backtrace(); + $message = $message[0]['file'].':'.$message[0]['line']."\n"; + $message .= array_reverse(explode('\\', get_class($color)))[0]; + throw new core\SceneException($message,1); } } else $this->subsurface = $color; @@ -145,9 +145,10 @@ class Disney extends MaterialsBase if( $color->cards != null ) $this->metallic = $color->cards; else { - $backtrace = debug_backtrace(); - $backtrace = $backtrace[0]['file'].':'.$backtrace[0]['line']."\n"; - $this->printException($backtrace,$color); + $message = debug_backtrace(); + $message = $message[0]['file'].':'.$message[0]['line']."\n"; + $message .= array_reverse(explode('\\', get_class($color)))[0]; + throw new core\SceneException($message,1); } } else $this->metallic = $color; @@ -160,9 +161,10 @@ class Disney extends MaterialsBase if( $color->cards != null ) $this->specular = $color->cards; else { - $backtrace = debug_backtrace(); - $backtrace = $backtrace[0]['file'].':'.$backtrace[0]['line']."\n"; - $this->printException($backtrace,$color); + $message = debug_backtrace(); + $message = $message[0]['file'].':'.$message[0]['line']."\n"; + $message .= array_reverse(explode('\\', get_class($color)))[0]; + throw new core\SceneException($message,1); } } else $this->specular = $color; @@ -175,9 +177,10 @@ class Disney extends MaterialsBase if( $color->cards != null ) $this->speculartint = $color->cards; else { - $backtrace = debug_backtrace(); - $backtrace = $backtrace[0]['file'].':'.$backtrace[0]['line']."\n"; - $this->printException($backtrace,$color); + $message = debug_backtrace(); + $message = $message[0]['file'].':'.$message[0]['line']."\n"; + $message .= array_reverse(explode('\\', get_class($color)))[0]; + throw new core\SceneException($message,1); } } else $this->speculartint = $color; @@ -190,9 +193,10 @@ class Disney extends MaterialsBase if( $color->cards != null ) $this->roughness = $color->cards; else { - $backtrace = debug_backtrace(); - $backtrace = $backtrace[0]['file'].':'.$backtrace[0]['line']."\n"; - $this->printException($backtrace,$color); + $message = debug_backtrace(); + $message = $message[0]['file'].':'.$message[0]['line']."\n"; + $message .= array_reverse(explode('\\', get_class($color)))[0]; + throw new core\SceneException($message,1); } } else $this->roughness = $color; @@ -205,9 +209,10 @@ class Disney extends MaterialsBase if( $color->cards != null ) $this->anisotropic = $color->cards; else { - $backtrace = debug_backtrace(); - $backtrace = $backtrace[0]['file'].':'.$backtrace[0]['line']."\n"; - $this->printException($backtrace,$color); + $message = debug_backtrace(); + $message = $message[0]['file'].':'.$message[0]['line']."\n"; + $message .= array_reverse(explode('\\', get_class($color)))[0]; + throw new core\SceneException($message,1); } } else $this->anisotropic = $color; @@ -220,9 +225,10 @@ class Disney extends MaterialsBase if( $color->cards != null ) $this->sheen = $color->cards; else { - $backtrace = debug_backtrace(); - $backtrace = $backtrace[0]['file'].':'.$backtrace[0]['line']."\n"; - $this->printException($backtrace,$color); + $message = debug_backtrace(); + $message = $message[0]['file'].':'.$message[0]['line']."\n"; + $message .= array_reverse(explode('\\', get_class($color)))[0]; + throw new core\SceneException($message,1); } } else $this->sheen = $color; @@ -235,9 +241,10 @@ class Disney extends MaterialsBase if( $color->cards != null ) $this->sheentint = $color->cards; else { - $backtrace = debug_backtrace(); - $backtrace = $backtrace[0]['file'].':'.$backtrace[0]['line']."\n"; - $this->printException($backtrace,$color); + $message = debug_backtrace(); + $message = $message[0]['file'].':'.$message[0]['line']."\n"; + $message .= array_reverse(explode('\\', get_class($color)))[0]; + throw new core\SceneException($message,1); } } else $this->sheentint = $color; @@ -250,9 +257,10 @@ class Disney extends MaterialsBase if( $color->cards != null ) $this->clearcoat = $color->cards; else { - $backtrace = debug_backtrace(); - $backtrace = $backtrace[0]['file'].':'.$backtrace[0]['line']."\n"; - $this->printException($backtrace,$color); + $message = debug_backtrace(); + $message = $message[0]['file'].':'.$message[0]['line']."\n"; + $message .= array_reverse(explode('\\', get_class($color)))[0]; + throw new core\SceneException($message,1); } } else $this->clearcoat = $color; @@ -265,9 +273,10 @@ class Disney extends MaterialsBase if( $color->cards != null ) $this->clearcoatgloss = $color->cards; else { - $backtrace = debug_backtrace(); - $backtrace = $backtrace[0]['file'].':'.$backtrace[0]['line']."\n"; - $this->printException($backtrace,$color); + $message = debug_backtrace(); + $message = $message[0]['file'].':'.$message[0]['line']."\n"; + $message .= array_reverse(explode('\\', get_class($color)))[0]; + throw new core\SceneException($message,1); } } else $this->clearcoatgloss = $color; @@ -280,9 +289,10 @@ class Disney extends MaterialsBase if( $color->cards != null ) $this->transparencyFront = $color->cards; else { - $backtrace = debug_backtrace(); - $backtrace = $backtrace[0]['file'].':'.$backtrace[0]['line']."\n"; - $this->printException($backtrace,$color); + $message = debug_backtrace(); + $message = $message[0]['file'].':'.$message[0]['line']."\n"; + $message .= array_reverse(explode('\\', get_class($color)))[0]; + throw new core\SceneException($message,1); } } else $this->transparencyFront = $color; @@ -295,9 +305,10 @@ class Disney extends MaterialsBase if( $color->cards != null ) $this->transparencyBack = $color->cards; else { - $backtrace = debug_backtrace(); - $backtrace = $backtrace[0]['file'].':'.$backtrace[0]['line']."\n"; - $this->printException($backtrace,$color); + $message = debug_backtrace(); + $message = $message[0]['file'].':'.$message[0]['line']."\n"; + $message .= array_reverse(explode('\\', get_class($color)))[0]; + throw new core\SceneException($message,1); } } else $this->transparencyBack = $color; @@ -310,9 +321,10 @@ class Disney extends MaterialsBase if( $color->cards != null ) $this->filmamount = $color->cards; else { - $backtrace = debug_backtrace(); - $backtrace = $backtrace[0]['file'].':'.$backtrace[0]['line']."\n"; - $this->printException($backtrace,$color); + $message = debug_backtrace(); + $message = $message[0]['file'].':'.$message[0]['line']."\n"; + $message .= array_reverse(explode('\\', get_class($color)))[0]; + throw new core\SceneException($message,1); } } else $this->filmamount = $color; @@ -324,9 +336,10 @@ class Disney extends MaterialsBase if( $color->cards != null ) $this->filmthickness = $color->cards; else { - $backtrace = debug_backtrace(); - $backtrace = $backtrace[0]['file'].':'.$backtrace[0]['line']."\n"; - $this->printException($backtrace,$color); + $message = debug_backtrace(); + $message = $message[0]['file'].':'.$message[0]['line']."\n"; + $message .= array_reverse(explode('\\', get_class($color)))[0]; + throw new core\SceneException($message,1); } } else $this->filmthickness = $color; @@ -339,9 +352,10 @@ class Disney extends MaterialsBase if( $color->cards != null ) $this->filmior = $color->cards; else { - $backtrace = debug_backtrace(); - $backtrace = $backtrace[0]['file'].':'.$backtrace[0]['line']."\n"; - $this->printException($backtrace,$color); + $message = debug_backtrace(); + $message = $message[0]['file'].':'.$message[0]['line']."\n"; + $message .= array_reverse(explode('\\', get_class($color)))[0]; + throw new core\SceneException($message,1); } } else $this->filmior = $color; @@ -354,9 +368,10 @@ class Disney extends MaterialsBase if( $color->cards != null ) $this->bumptex = $color->cards; else { - $backtrace = debug_backtrace(); - $backtrace = $backtrace[0]['file'].':'.$backtrace[0]['line']."\n"; - $this->printException($backtrace,$color); + $message = debug_backtrace(); + $message = $message[0]['file'].':'.$message[0]['line']."\n"; + $message .= array_reverse(explode('\\', get_class($color)))[0]; + throw new core\SceneException($message,1); } } else $this->bumptex = $color; diff --git a/src/scene/materials/MaterialsBase.php b/src/scene/materials/MaterialsBase.php index c41a0e9..043b423 100644 --- a/src/scene/materials/MaterialsBase.php +++ b/src/scene/materials/MaterialsBase.php @@ -101,21 +101,6 @@ class MaterialsBase extends BaseCfg $this->volumeExterior = $color; } - protected function printException($backtrace,$temp) - { - try - { - $className = get_class($temp); - $className = array_reverse(explode('\\', $className))[0]; - $backtrace .= "你为当前通道赋值是一个未注册的 {$className}对象,这会导致一个默认值的渲染结果!!!"; - throw new \Exception($backtrace,0); - } - catch( \Exception $err ) - { - echo '警告:在'.$err->getMessage()."\n\n"; - } - } - } ?> diff --git a/src/scene/materials/Metal.php b/src/scene/materials/Metal.php index e8ef905..ca9d90b 100644 --- a/src/scene/materials/Metal.php +++ b/src/scene/materials/Metal.php @@ -1,7 +1,7 @@ type = self::TYPE_METAL; $this->id = Scene::createID(); - Base::__construct($config); + core\Base::__construct($config); } public function setRefraction($color) @@ -59,9 +59,10 @@ class Metal extends MaterialsBase if( $color->cards != null ) $this->kr = $color->cards; else { - $backtrace = debug_backtrace(); - $backtrace = $backtrace[0]['file'].':'.$backtrace[0]['line']."\n"; - $this->printException($backtrace,$color); + $message = debug_backtrace(); + $message = $message[0]['file'].':'.$message[0]['line']."\n"; + $message .= array_reverse(explode('\\', get_class($color)))[0]; + throw new core\SceneException($message,1); } } else $this->kr = $color; @@ -75,9 +76,10 @@ class Metal extends MaterialsBase if( $color->cards != null ) $this->fresnel = $color->cards; else { - $backtrace = debug_backtrace(); - $backtrace = $backtrace[0]['file'].':'.$backtrace[0]['line']."\n"; - $this->printException($backtrace,$color); + $message = debug_backtrace(); + $message = $message[0]['file'].':'.$message[0]['line']."\n"; + $message .= array_reverse(explode('\\', get_class($color)))[0]; + throw new core\SceneException($message,1); } } else $this->fresnel = $color; @@ -91,9 +93,10 @@ class Metal extends MaterialsBase if( $color->cards != null ) $this->uroughness = $color->cards; else { - $backtrace = debug_backtrace(); - $backtrace = $backtrace[0]['file'].':'.$backtrace[0]['line']."\n"; - $this->printException($backtrace,$color); + $message = debug_backtrace(); + $message = $message[0]['file'].':'.$message[0]['line']."\n"; + $message .= array_reverse(explode('\\', get_class($color)))[0]; + throw new core\SceneException($message,1); } } else $this->uroughness = $color; @@ -106,9 +109,10 @@ class Metal extends MaterialsBase if( $color->cards != null ) $this->vroughness = $color->cards; else { - $backtrace = debug_backtrace(); - $backtrace = $backtrace[0]['file'].':'.$backtrace[0]['line']."\n"; - $this->printException($backtrace,$color); + $message = debug_backtrace(); + $message = $message[0]['file'].':'.$message[0]['line']."\n"; + $message .= array_reverse(explode('\\', get_class($color)))[0]; + throw new core\SceneException($message,1); } } else $this->vroughness = $color; @@ -121,9 +125,10 @@ class Metal extends MaterialsBase if( $color->cards != null ) $this->transparencyFront = $color->cards; else { - $backtrace = debug_backtrace(); - $backtrace = $backtrace[0]['file'].':'.$backtrace[0]['line']."\n"; - $this->printException($backtrace,$color); + $message = debug_backtrace(); + $message = $message[0]['file'].':'.$message[0]['line']."\n"; + $message .= array_reverse(explode('\\', get_class($color)))[0]; + throw new core\SceneException($message,1); } } else $this->transparencyFront = $color; @@ -136,9 +141,10 @@ class Metal extends MaterialsBase if( $color->cards != null ) $this->transparencyBack = $color->cards; else { - $backtrace = debug_backtrace(); - $backtrace = $backtrace[0]['file'].':'.$backtrace[0]['line']."\n"; - $this->printException($backtrace,$color); + $message = debug_backtrace(); + $message = $message[0]['file'].':'.$message[0]['line']."\n"; + $message .= array_reverse(explode('\\', get_class($color)))[0]; + throw new core\SceneException($message,1); } } else $this->transparencyBack = $color; @@ -151,9 +157,10 @@ class Metal extends MaterialsBase if( $color->cards != null ) $this->bumptex = $color->cards; else { - $backtrace = debug_backtrace(); - $backtrace = $backtrace[0]['file'].':'.$backtrace[0]['line']."\n"; - $this->printException($backtrace,$color); + $message = debug_backtrace(); + $message = $message[0]['file'].':'.$message[0]['line']."\n"; + $message .= array_reverse(explode('\\', get_class($color)))[0]; + throw new core\SceneException($message,1); } } else $this->bumptex = $color; diff --git a/src/scene/materials/Mix.php b/src/scene/materials/Mix.php index 1c8f2a7..1f019fe 100644 --- a/src/scene/materials/Mix.php +++ b/src/scene/materials/Mix.php @@ -1,7 +1,7 @@ type = self::TYPE_MIX; $this->id = Scene::createID(); - Base::__construct($config); + core\Base::__construct($config); } public function setMaterial1($Material) @@ -42,9 +42,10 @@ class Mix extends MaterialsBase if( $Material->cards != null ) $this->material1 = $Material->cards; else { - $backtrace = debug_backtrace(); - $backtrace = $backtrace[0]['file'].':'.$backtrace[0]['line']."\n"; - $this->printException($backtrace,$Material); + $message = debug_backtrace(); + $message = $message[0]['file'].':'.$message[0]['line']."\n"; + $message .= array_reverse(explode('\\', get_class($Material)))[0]; + throw new core\SceneException($message,1); } } else $this->material1 = $Material; @@ -57,9 +58,10 @@ class Mix extends MaterialsBase if( $Material->cards != null ) $this->material2 = $Material->cards; else { - $backtrace = debug_backtrace(); - $backtrace = $backtrace[0]['file'].':'.$backtrace[0]['line']."\n"; - $this->printException($backtrace,$Material); + $message = debug_backtrace(); + $message = $message[0]['file'].':'.$message[0]['line']."\n"; + $message .= array_reverse(explode('\\', get_class($Material)))[0]; + throw new core\SceneException($message,1); } } else $this->material2 = $Material; @@ -72,9 +74,10 @@ class Mix extends MaterialsBase if( $color->cards != null ) $this->amount = $color->cards; else { - $backtrace = debug_backtrace(); - $backtrace = $backtrace[0]['file'].':'.$backtrace[0]['line']."\n"; - $this->printException($backtrace,$color); + $message = debug_backtrace(); + $message = $message[0]['file'].':'.$message[0]['line']."\n"; + $message .= array_reverse(explode('\\', get_class($color)))[0]; + throw new core\SceneException($message,1); } } else $this->amount = $color; diff --git a/src/scene/objects/Objects.php b/src/scene/objects/Objects.php index 28e7fd6..21e1143 100644 --- a/src/scene/objects/Objects.php +++ b/src/scene/objects/Objects.php @@ -1,7 +1,7 @@ id = Scene::createID(); - Base::__construct($config); + core\Base::__construct($config); } public function setMaterial($material) @@ -51,30 +51,15 @@ class Objects extends BaseCfg if( $material->cards != null ) $this->material = $material->cards; else { - $backtrace = debug_backtrace(); - $backtrace = $backtrace[0]['file'].':'.$backtrace[0]['line']."\n"; - $this->printException($backtrace,$material); + $message = debug_backtrace(); + $message = $message[0]['file'].':'.$message[0]['line']."\n"; + $message .= array_reverse(explode('\\', get_class($material)))[0]; + throw new core\SceneException($message,1); } } else $this->material = $material; } - private function printException($backtrace,$temp) - { - try - { - $className = get_class($temp); - $className = array_reverse(explode('\\', $className))[0]; - $backtrace .= "你为当前通道赋值是一个未注册的 {$className}对象,这会导致一个默认值的渲染结果!!!"; - throw new \Exception($backtrace,0); - } - catch( \Exception $err ) - { - echo '警告:在'.$err->getMessage()."\n\n"; - } - } - - } ?> diff --git a/src/scene/texture/TextureBase.php b/src/scene/texture/TextureBase.php index 81267fb..820bec4 100644 --- a/src/scene/texture/TextureBase.php +++ b/src/scene/texture/TextureBase.php @@ -20,7 +20,7 @@ class TextureBase extends BaseCfg /** * @var string 储存个由Scene类颁发的注册信息 */ - public $cards; + public $cards; } ?> diff --git a/src/scene/texture/map/Blend.php b/src/scene/texture/map/Blend.php index bce1091..e9727d6 100644 --- a/src/scene/texture/map/Blend.php +++ b/src/scene/texture/map/Blend.php @@ -57,11 +57,12 @@ class Blend extends TextureBase public $mapping; /** - * @param $mapping 必须传入一个 Mapping类对象 + * @param $mapping 如需自定义铺贴参数,必须传入一个 Mapping类对象,否则使用一个默认的铺贴参数 */ - public function __construct(Mapping $mapping,$config = []) + public function __construct(Mapping $mapping = null,$config = []) { - $this->mapping = $mapping; + if( $mapping != null )$this->mapping = $mapping; + else $this->mapping = new Mapping(); $this->type = self::TYPE_BLENDER_BLEND; $this->id = Scene::createID(); Base::__construct($config); diff --git a/src/scene/texture/map/Clouds.php b/src/scene/texture/map/Clouds.php index bbb0056..9a2614b 100644 --- a/src/scene/texture/map/Clouds.php +++ b/src/scene/texture/map/Clouds.php @@ -69,11 +69,12 @@ class Clouds extends TextureBase public $mapping; /** - * @param $mapping 必须传入一个 Mapping类对象 + * @param $mapping 如需自定义铺贴参数,必须传入一个 Mapping类对象,否则使用一个默认的铺贴参数 */ - public function __construct(Mapping $mapping,$config = []) + public function __construct(Mapping $mapping = null,$config = []) { - $this->mapping = $mapping; + if( $mapping != null )$this->mapping = $mapping; + else $this->mapping = new Mapping(); $this->type = self::TYPE_BLENDER_CLOUDS; $this->id = Scene::createID(); Base::__construct($config); diff --git a/src/scene/texture/map/ImageMap.php b/src/scene/texture/map/ImageMap.php index be4110f..942f075 100644 --- a/src/scene/texture/map/ImageMap.php +++ b/src/scene/texture/map/ImageMap.php @@ -44,17 +44,17 @@ class ImageMap extends TextureBase public $storage = 'byte'; /** - * @param object $mapping 必须传入一个 Mapping类对象 + * @param object $mapping 如需自定义铺贴参数,必须传入一个 Mapping类对象,否则使用一个默认的铺贴参数 */ - public function __construct(Mapping $mapping,$config = []) + public function __construct(Mapping $mapping = null,$config = []) { - $this->mapping = $mapping; + if( $mapping != null )$this->mapping = $mapping; + else $this->mapping = new Mapping(); $this->type = self::TYPE_IMAGEMAP; $this->id = Scene::createID(); Base::__construct($config); } - } ?> diff --git a/src/scene/texture/mapping/Triplanar.php b/src/scene/texture/mapping/Triplanar.php index b408118..a907c59 100644 --- a/src/scene/texture/mapping/Triplanar.php +++ b/src/scene/texture/mapping/Triplanar.php @@ -37,11 +37,12 @@ class Triplanar extends TextureBase public $mapping; /** - * @param $mapping 必须传入一个 Mapping类对象 + * @param $mapping 如需自定义铺贴参数,必须传入一个 Mapping类对象,否则使用一个默认的铺贴参数 */ - public function __construct(Mapping $mapping,$config = []) + public function __construct(Mapping $mapping = null,$config = []) { - $this->mapping = $mapping; + if( $mapping != null )$this->mapping = $mapping; + else $this->mapping = new Mapping(); $this->type = self::TYPE_TRIPLANAR; $this->id = Scene::createID(); Base::__construct($config); diff --git a/src/scene/texture/transform/NormalMap.php b/src/scene/texture/transform/NormalMap.php index 210c5c4..50a84e1 100644 --- a/src/scene/texture/transform/NormalMap.php +++ b/src/scene/texture/transform/NormalMap.php @@ -25,9 +25,8 @@ class ImageMap extends TextureBase /** * @param $mapping 必须传入一个 Mapping类对象 */ - public function __construct(Mapping $mapping,$config = []) + public function __construct($config = []) { - $this->mapping = $mapping; $this->type = self::TYPE_NORMALMAP; $this->id = Scene::createID(); Base::__construct($config);