Преглед изворни кода

- clone enable state for lights and meshes
- handle parent for cloned light

Cedric Guillemet пре 5 година
родитељ
комит
abdad9ab7a
2 измењених фајлова са 11 додато и 2 уклоњено
  1. 8 2
      src/Lights/light.ts
  2. 3 0
      src/Meshes/mesh.ts

+ 8 - 2
src/Lights/light.ts

@@ -586,15 +586,21 @@ export abstract class Light extends Node {
     /**
      * Returns a new Light object, named "name", from the current one.
      * @param name The name of the cloned light
+     * @param newParent The parent of this light, if it has one
      * @returns the new created light
      */
-    public clone(name: string): Nullable<Light> {
+    public clone(name: string, newParent: Nullable<Node> = null): Nullable<Light> {
         let constructor = Light.GetConstructorFromName(this.getTypeID(), name, this.getScene());
 
         if (!constructor) {
             return null;
         }
-        return SerializationHelper.Clone(constructor, this);
+        let clonedLight = SerializationHelper.Clone(constructor, this);
+        if (newParent) {
+            clonedLight.parent = newParent;
+        }
+        clonedLight.setEnabled(this.isEnabled());
+        return clonedLight;
     }
 
     /**

+ 3 - 0
src/Meshes/mesh.ts

@@ -457,6 +457,9 @@ export class Mesh extends AbstractMesh implements IGetSetVerticesData {
                 Tags.AddTagsTo(this, Tags.GetTags(source, true));
             }
 
+            // Enabled
+            this.setEnabled(source.isEnabled());
+
             // Parent
             this.parent = source.parent;