Procházet zdrojové kódy

Merge pull request #7804 from sebavan/master

Nightly
sebavan před 5 roky
rodič
revize
cde5ab2b7a

+ 5 - 0
dist/preview release/babylon.d.ts

@@ -57452,6 +57452,11 @@ declare module BABYLON {
          */
         loadFromSerialization(source: any, rootUrl?: string): void;
         /**
+         * Makes a duplicate of the current material.
+         * @param name - name to use for the new material.
+         */
+        clone(name: string): NodeMaterial;
+        /**
          * Creates a node material from parsed material data
          * @param source defines the JSON representation of the material
          * @param scene defines the hosting scene

Rozdílová data souboru nebyla zobrazena, protože soubor je příliš velký
+ 1 - 1
dist/preview release/babylon.js


Rozdílová data souboru nebyla zobrazena, protože soubor je příliš velký
+ 31 - 17
dist/preview release/babylon.max.js


Rozdílová data souboru nebyla zobrazena, protože soubor je příliš velký
+ 1 - 1
dist/preview release/babylon.max.js.map


+ 10 - 0
dist/preview release/babylon.module.d.ts

@@ -60114,6 +60114,11 @@ declare module "babylonjs/Materials/Node/nodeMaterial" {
          */
         loadFromSerialization(source: any, rootUrl?: string): void;
         /**
+         * Makes a duplicate of the current material.
+         * @param name - name to use for the new material.
+         */
+        clone(name: string): NodeMaterial;
+        /**
          * Creates a node material from parsed material data
          * @param source defines the JSON representation of the material
          * @param scene defines the hosting scene
@@ -131151,6 +131156,11 @@ declare module BABYLON {
          */
         loadFromSerialization(source: any, rootUrl?: string): void;
         /**
+         * Makes a duplicate of the current material.
+         * @param name - name to use for the new material.
+         */
+        clone(name: string): NodeMaterial;
+        /**
          * Creates a node material from parsed material data
          * @param source defines the JSON representation of the material
          * @param scene defines the hosting scene

+ 5 - 0
dist/preview release/documentation.d.ts

@@ -57452,6 +57452,11 @@ declare module BABYLON {
          */
         loadFromSerialization(source: any, rootUrl?: string): void;
         /**
+         * Makes a duplicate of the current material.
+         * @param name - name to use for the new material.
+         */
+        clone(name: string): NodeMaterial;
+        /**
          * Creates a node material from parsed material data
          * @param source defines the JSON representation of the material
          * @param scene defines the hosting scene

+ 10 - 0
dist/preview release/viewer/babylon.module.d.ts

@@ -60114,6 +60114,11 @@ declare module "babylonjs/Materials/Node/nodeMaterial" {
          */
         loadFromSerialization(source: any, rootUrl?: string): void;
         /**
+         * Makes a duplicate of the current material.
+         * @param name - name to use for the new material.
+         */
+        clone(name: string): NodeMaterial;
+        /**
          * Creates a node material from parsed material data
          * @param source defines the JSON representation of the material
          * @param scene defines the hosting scene
@@ -131151,6 +131156,11 @@ declare module BABYLON {
          */
         loadFromSerialization(source: any, rootUrl?: string): void;
         /**
+         * Makes a duplicate of the current material.
+         * @param name - name to use for the new material.
+         */
+        clone(name: string): NodeMaterial;
+        /**
          * Creates a node material from parsed material data
          * @param source defines the JSON representation of the material
          * @param scene defines the hosting scene

Rozdílová data souboru nebyla zobrazena, protože soubor je příliš velký
+ 6 - 6
dist/preview release/viewer/babylon.viewer.js


Rozdílová data souboru nebyla zobrazena, protože soubor je příliš velký
+ 1 - 1
dist/preview release/viewer/babylon.viewer.max.js


+ 17 - 0
src/Materials/Node/nodeMaterial.ts

@@ -1285,6 +1285,23 @@ export class NodeMaterial extends PushMaterial {
     }
 
     /**
+     * Makes a duplicate of the current material.
+     * @param name - name to use for the new material.
+     */
+    public clone(name: string): NodeMaterial {
+        const serializationObject = this.serialize();
+
+        const clone = SerializationHelper.Clone(() => new NodeMaterial(name, this.getScene(), this.options), this);
+        clone.id = name;
+        clone.name = name;
+
+        clone.loadFromSerialization(serializationObject);
+        clone.build();
+
+        return clone;
+    }
+
+    /**
      * Creates a node material from parsed material data
      * @param source defines the JSON representation of the material
      * @param scene defines the hosting scene