Browse Source

improve Structure.asParent

- handle parent coordinate system not identity
Alexander Rose 3 years ago
parent
commit
74f721ab9f
1 changed files with 2 additions and 4 deletions
  1. 2 4
      src/mol-model/structure/structure/structure.ts

+ 2 - 4
src/mol-model/structure/structure/structure.ts

@@ -384,10 +384,8 @@ class Structure {
     asParent(): Structure {
         if (this._proxy) return this._proxy;
         if (this.parent) {
-            if (!this.parent.coordinateSystem.isIdentity) {
-                throw new Error('parent coordinate system must be identity');
-            }
-            const s = this.coordinateSystem.isIdentity ? this.parent : Structure.transform(this.parent, this.coordinateSystem.matrix);
+            const p = this.parent.coordinateSystem.isIdentity ? this.parent : Structure.transform(this.parent, this.parent.coordinateSystem.inverse);
+            const s = this.coordinateSystem.isIdentity ? p : Structure.transform(p, this.coordinateSystem.matrix);
             this._proxy = new Structure(s.units, s.unitMap, s.unitIndexMap, { ...s.state, dynamicBonds: this.dynamicBonds }, { child: this, target: this.parent });
         } else {
             this._proxy = this;