Browse Source

在 core目录中,新增三个关于异常处理的类;材质和模型的类文件,抛出异常的代码,贴图类构造函数形参添加了默认值

master
yuanjiajia 3 years ago
parent
commit
3670088c90
  1. 1
      composer.json
  2. 28
      examples/print.php
  3. 21
      src/core/AutuHandle.php
  4. 10
      src/core/RenderException .php
  5. 31
      src/core/SceneException.php
  6. 127
      src/scene/materials/Disney.php
  7. 15
      src/scene/materials/MaterialsBase.php
  8. 53
      src/scene/materials/Metal.php
  9. 25
      src/scene/materials/Mix.php
  10. 27
      src/scene/objects/Objects.php
  11. 7
      src/scene/texture/map/Blend.php
  12. 7
      src/scene/texture/map/Clouds.php
  13. 8
      src/scene/texture/map/ImageMap.php
  14. 7
      src/scene/texture/mapping/Triplanar.php
  15. 3
      src/scene/texture/transform/NormalMap.php

1
composer.json

@ -6,7 +6,6 @@
"autoload": {
"psr-4": {
"Blobt\\Luxcore\\": "src/"
}
},
"authors": [

28
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;
?>

21
src/core/AutuHandle.php

@ -0,0 +1,21 @@
<?php
namespace Blobt\Luxcore\core;
class AutuHandle
{
public function init()
{
set_exception_handler([$this,'exception']);
}
public function exception($e)
{
die($e);
}
}
(new AutuHandle)->init();
?>

10
src/core/RenderException .php

@ -0,0 +1,10 @@
<?php
namespace Blobt\Luxcore\core;
class RenderException extends \Exception
{
}
?>

31
src/core/SceneException.php

@ -0,0 +1,31 @@
<?php
namespace Blobt\Luxcore\core;
class SceneException extends \Exception
{
function __toString()
{
switch($this->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";
}
}
}
?>

127
src/scene/materials/Disney.php

@ -1,9 +1,7 @@
<?php
namespace Blobt\Luxcore\scene\materials;
use __PHP_Incomplete_Class;
use Blobt\Luxcore\core\Base;
use Blobt\Luxcore\core;
use Blobt\Luxcore\scene\Scene;
@ -13,7 +11,7 @@ class Disney extends MaterialsBase
const TYPE_DISNEY = 'disney';
/**
* @var string 漫反射颜色,一个小数形式的RGB色值,或是一个textures(贴图数组)中的某个键名
* @var string 漫反射颜色,一个小数形式的RGB色值,或是一个textures(贴图数组)中的某个键名sd
*/
public $basecolor = "0.7 0.7 0.7";
@ -105,7 +103,7 @@ class Disney extends MaterialsBase
{
$this->type = self::TYPE_DISNEY;
$this->id = Scene::createID();
Base::__construct($config);
core\Base::__construct($config);
}
public function setBaseColor($color)
@ -115,9 +113,10 @@ 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;
@ -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;

15
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";
}
}
}
?>

53
src/scene/materials/Metal.php

@ -1,7 +1,7 @@
<?php
namespace Blobt\Luxcore\scene\materials;
use Blobt\Luxcore\core\Base;
use Blobt\Luxcore\core;
use Blobt\Luxcore\scene\Scene;
class Metal extends MaterialsBase
@ -49,7 +49,7 @@ class Metal extends MaterialsBase
{
$this->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;

25
src/scene/materials/Mix.php

@ -1,7 +1,7 @@
<?php
namespace Blobt\Luxcore\scene\materials;
use Blobt\Luxcore\core\Base;
use Blobt\Luxcore\core;
use Blobt\Luxcore\scene\Scene;
class Mix extends MaterialsBase
@ -32,7 +32,7 @@ class Mix extends MaterialsBase
{
$this->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;

27
src/scene/objects/Objects.php

@ -1,7 +1,7 @@
<?php
namespace Blobt\Luxcore\scene\objects;
use Blobt\Luxcore\core\Base;
use Blobt\Luxcore\core;
use Blobt\Luxcore\scene\BaseCfg;
use Blobt\Luxcore\scene\Scene;
@ -41,7 +41,7 @@ class Objects extends BaseCfg
public function __construct($config = [])
{
$this->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";
}
}
}
?>

7
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);

7
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);

8
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);
}
}
?>

7
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);

3
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);

Loading…
Cancel
Save