Skip to content
Snippets Groups Projects
Commit 6c957f1e authored by Alexander Rose's avatar Alexander Rose
Browse files

fix ExplodeStructureRepresentation3D to use root structure

parent 3b7616bd
No related branches found
No related tags found
No related merge requests found
...@@ -278,23 +278,24 @@ const ExplodeStructureRepresentation3D = PluginStateTransform.BuiltIn({ ...@@ -278,23 +278,24 @@ const ExplodeStructureRepresentation3D = PluginStateTransform.BuiltIn({
canAutoUpdate() { canAutoUpdate() {
return true; return true;
}, },
apply({ a, params }) { apply({ a, params, spine }) {
const rootStructure = spine.getRootOfType(SO.Molecule.Structure)!.data;
const structure = a.data.source.data; const structure = a.data.source.data;
const unitTransforms = new StructureUnitTransforms(structure); const unitTransforms = new StructureUnitTransforms(rootStructure);
explodeStructure(structure, unitTransforms, params.t); explodeStructure(structure, unitTransforms, params.t);
return new SO.Molecule.Structure.Representation3DState({ return new SO.Molecule.Structure.Representation3DState({
state: { unitTransforms }, state: { unitTransforms },
initialState: { unitTransforms: new StructureUnitTransforms(structure) }, initialState: { unitTransforms: new StructureUnitTransforms(rootStructure) },
info: structure, info: rootStructure,
source: a source: a
}, { label: `Explode T = ${params.t.toFixed(2)}` }); }, { label: `Explode T = ${params.t.toFixed(2)}` });
}, },
update({ a, b, newParams, oldParams }) { update({ a, b, newParams, oldParams, spine }) {
const structure = b.data.info as Structure; const rootStructure = spine.getRootOfType(SO.Molecule.Structure)!.data;
if (a.data.source.data !== structure) return StateTransformer.UpdateResult.Recreate; if (b.data.info !== rootStructure) return StateTransformer.UpdateResult.Recreate;
if (oldParams.t === newParams.t) return StateTransformer.UpdateResult.Unchanged; if (oldParams.t === newParams.t) return StateTransformer.UpdateResult.Unchanged;
const unitTransforms = b.data.state.unitTransforms!; const unitTransforms = b.data.state.unitTransforms!;
explodeStructure(structure, unitTransforms, newParams.t); explodeStructure(rootStructure, unitTransforms, newParams.t);
b.label = `Explode T = ${newParams.t.toFixed(2)}`; b.label = `Explode T = ${newParams.t.toFixed(2)}`;
b.data.source = a; b.data.source = a;
return StateTransformer.UpdateResult.Updated; return StateTransformer.UpdateResult.Updated;
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment