浏览代码

better shaderMaterial clone func

David Catuhe 5 年之前
父节点
当前提交
23d05fa285
共有 1 个文件被更改,包括 7 次插入2 次删除
  1. 7 2
      src/Materials/shaderMaterial.ts

+ 7 - 2
src/Materials/shaderMaterial.ts

@@ -742,11 +742,16 @@ export class ShaderMaterial extends Material {
      * @returns the cloned material
      */
     public clone(name: string): ShaderMaterial {
-        var newShaderMaterial = new ShaderMaterial(name, this.getScene(), this._shaderPath, this._options);
+        var result = SerializationHelper.Clone(() => new ShaderMaterial(name, this.getScene(), this._shaderPath, this._options), this);
 
-        return newShaderMaterial;
+        result.name = name;
+        result.id = name;
+
+        return result;
     }
 
+
+
     /**
      * Disposes the material
      * @param forceDisposeEffect specifies if effects should be forcefully disposed