Skip to content

Commit

Permalink
Merge pull request #969 from vorth/fix-orientation
Browse files Browse the repository at this point in the history
Fixing symmetry change orientations in online vZome
  • Loading branch information
vorth authored Jan 26, 2025
2 parents a9b47c8 + d55cd93 commit 31ac6cc
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 13 deletions.
2 changes: 1 addition & 1 deletion online/src/viewer/context/viewer.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ const ViewerProvider = ( props ) =>
}

subscribeFor( 'SYMMETRY_CHANGED', ( { orientations } ) => {
setScene( 'orientations', reconcile( orientations ) );
setScene( 'orientations', orientations );
});

subscribeFor( 'SCENES_DISCOVERED', ( payload ) => {
Expand Down
9 changes: 8 additions & 1 deletion online/src/worker/legacy/controllers/editor.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import { PickingController } from './picking.js';
import { BuildPlaneController } from './buildplane.js';
import { modelToJS } from "../json.js";
import { export2d, export3d, export3dDocument } from "../exporters.js";
import { resolveBuildPlanes } from '../scenes.js';


export class EditorController extends com.vzome.desktop.controller.DefaultController
Expand All @@ -29,7 +30,7 @@ export class EditorController extends com.vzome.desktop.controller.DefaultContro
this.clientEvents .errorReported(message);
}

initialize( renderingChanges )
initialize()
{
const { renderedModel, toolsModel, bookmarkFactory, history,
fieldApp, legacyField, editor, editContext } = this.legacyDesign;
Expand Down Expand Up @@ -159,6 +160,12 @@ export class EditorController extends com.vzome.desktop.controller.DefaultContro
let symmetrySystem = this.symmController .getOrbitSource();
this.legacyDesign .setSymmetrySystem( symmetrySystem.getName() );

const planes = resolveBuildPlanes( symmetrySystem .buildPlanes );
const { orientations, symmetry, permutations } = symmetrySystem;
const scalars = [ symmetry .getField() .getAffineScalar() .evaluate() ]; //TODO get them all!
const resourcePath = symmetrySystem .getModelResourcePath();
this.clientEvents .symmetryChanged( { orientations, permutations, scalars, planes, resourcePath } );

// TODO: test this change with buildPlane
this.getSubController( 'buildPlane' ) .setOrbitSource( symmetrySystem );

Expand Down
23 changes: 12 additions & 11 deletions online/src/worker/legacy/controllers/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,20 +3,13 @@ import { com } from '../core-java.js';
import { documentFactory, parse } from '../core.js'
import { Interpreter, RenderHistory, Step } from '../interpreter.js';
import { ControllerWrapper } from './wrapper.js';
import { renderedModelTransducer, resolveBuildPlanes } from '../scenes.js';
import { renderedModelTransducer } from '../scenes.js';
import { EditorController } from './editor.js';
import { serializeVZomeXml } from '../serializer.js';

const createControllers = ( design, renderingChanges, clientEvents ) =>
{
const { getOrbitSource, renderedModel } = design;

const orbitSource = getOrbitSource();
const planes = resolveBuildPlanes( orbitSource .buildPlanes );
const { orientations, symmetry, permutations } = orbitSource;
const scalars = [ symmetry .getField() .getAffineScalar() .evaluate() ]; //TODO get them all!
const resourcePath = orbitSource .getModelResourcePath();
clientEvents .symmetryChanged( { orientations, permutations, scalars, planes, resourcePath } );
const { renderedModel } = design;

const controller = new EditorController( design, clientEvents ); // this is the equivalent of DocumentController
const symmLabel = controller .initialize();
Expand Down Expand Up @@ -113,7 +106,16 @@ const initializeDesign = ( loading, polygons, legacyDesign, clientEvents ) =>
snapshots = [];
}

const wrapper = createControllers( legacyDesign, renderingChanges, clientEvents );
const rendered = { lighting, camera, embedding, orientations, polygons, shapes, instances, snapshots, scenes };
const renderedClientEvents = {
...clientEvents,
symmetryChanged: details => {
rendered.orientations = details.orientations; // this enables future rendering to be with the right orientations
clientEvents .symmetryChanged( details );
}
}

const wrapper = createControllers( legacyDesign, renderingChanges, renderedClientEvents );

wrapper.snapCamera = snapCamera;

Expand All @@ -132,7 +134,6 @@ const initializeDesign = ( loading, polygons, legacyDesign, clientEvents ) =>

wrapper.serializeVZomeXml = ( camera, lighting ) => serializeVZomeXml( legacyDesign, camera, lighting, scenes );

const rendered = { lighting, camera, embedding, orientations, polygons, shapes, instances, snapshots, scenes };
return { wrapper, rendered };
}

Expand Down

0 comments on commit 31ac6cc

Please sign in to comment.