Jelajahi Sumber

fix typo + remove useless check + remove unwanted change

Julien Barrois 7 tahun lalu
induk
melakukan
6cddc4734b
2 mengubah file dengan 12 tambahan dan 11 penghapusan
  1. 3 0
      src/Mesh/babylon.mesh.ts
  2. 9 11
      src/babylon.node.ts

+ 3 - 0
src/Mesh/babylon.mesh.ts

@@ -281,6 +281,9 @@
                     Tags.AddTagsTo(this, Tags.GetTags(source, true));
                 }
 
+                // Parent
+                this.parent = source.parent;
+
                 // Pivot
                 this.setPivotMatrix(source.getPivotMatrix());
 

+ 9 - 11
src/babylon.node.ts

@@ -111,7 +111,7 @@
         public _worldMatrixDeterminant = 0;        
 
         /** @hidden */
-        private _sceneRootNodsIndex = -1;
+        private _sceneRootNodesIndex = -1;
 
         /**
          * Gets a boolean indicating if the node has been disposed
@@ -129,8 +129,6 @@
                 return;
             }
 
-            const previousParentNode = this._parentNode;
-
             // Remove self from list of children of parent
             if (this._parentNode && this._parentNode._children !== undefined && this._parentNode._children !== null) {
                 var index = this._parentNode._children.indexOf(this);
@@ -138,7 +136,7 @@
                     this._parentNode._children.splice(index, 1);
                 }
 
-                if (!parent) this.addToSceneRootNodes();
+                this.addToSceneRootNodes();
             }
 
             // Store new parent
@@ -151,7 +149,7 @@
                 }
                 this._parentNode._children.push(this);
 
-                if (!previousParentNode) this.removeFromSceneRootNodes();
+                this.removeFromSceneRootNodes();
             }
 
             // Enabled state
@@ -163,20 +161,20 @@
         }
 
         private addToSceneRootNodes() {
-            if (this._sceneRootNodsIndex === -1) {
-                this._sceneRootNodsIndex = this._scene.rootNodes.length;
+            if (this._sceneRootNodesIndex === -1) {
+                this._sceneRootNodesIndex = this._scene.rootNodes.length;
                 this._scene.rootNodes.push(this);
             }
         }
 
         private removeFromSceneRootNodes() {
-            if (this._sceneRootNodsIndex !== -1) {
+            if (this._sceneRootNodesIndex !== -1) {
                 const rootNodes = this._scene.rootNodes;
                 const lastIdx = rootNodes.length - 1;
-                rootNodes[this._sceneRootNodsIndex] = rootNodes[lastIdx];
-                rootNodes[this._sceneRootNodsIndex]._sceneRootNodsIndex = this._sceneRootNodsIndex;
+                rootNodes[this._sceneRootNodesIndex] = rootNodes[lastIdx];
+                rootNodes[this._sceneRootNodesIndex]._sceneRootNodesIndex = this._sceneRootNodesIndex;
                 this._scene.rootNodes.pop();
-                this._sceneRootNodsIndex = -1;
+                this._sceneRootNodesIndex = -1;
             }
         }