mirror of
https://github.com/xibyte/jsketcher
synced 2025-12-09 18:02:50 +01:00
keep viewport in sync with inplace sketcher
This commit is contained in:
parent
14e1222d84
commit
b136bfee5e
2 changed files with 12 additions and 0 deletions
|
|
@ -14,6 +14,7 @@ import {
|
|||
Matrix4, Raycaster, Box3
|
||||
} from "three";
|
||||
import {TransformControls} from "three/examples/jsm/controls/TransformControls";
|
||||
import {stream} from "lstream";
|
||||
|
||||
export default class SceneSetUp {
|
||||
workingSphere: number;
|
||||
|
|
@ -31,6 +32,7 @@ export default class SceneSetUp {
|
|||
trackballControls: CADTrackballControls;
|
||||
transformControls: TransformControls;
|
||||
updateControlsAndHelpers: () => void;
|
||||
viewportSizeUpdate$ = stream();
|
||||
|
||||
constructor(container, onRendered) {
|
||||
|
||||
|
|
@ -93,6 +95,7 @@ export default class SceneSetUp {
|
|||
this.updatePerspectiveCameraViewport();
|
||||
this.updateOrthographicCameraViewport();
|
||||
this.renderer.setSize( this.container.clientWidth, this.container.clientHeight );
|
||||
this.viewportSizeUpdate$.next();
|
||||
this.render();
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -6,6 +6,7 @@ import {createEssentialAppContext} from "sketcher/sketcherContext";
|
|||
import {ORIGIN} from "math/vector";
|
||||
import {lookAtFace} from "cad/actions/usabilityActions";
|
||||
import {Styles} from "sketcher/styles";
|
||||
import {createFunctionList} from "gems/func";
|
||||
|
||||
export class InPlaceSketcher {
|
||||
|
||||
|
|
@ -35,6 +36,8 @@ export class InPlaceSketcher {
|
|||
let container = viewer3d.sceneSetup.container;
|
||||
let canvas = document.createElement('canvas');
|
||||
canvas.style.position = 'absolute';
|
||||
canvas.style.left = 0;
|
||||
canvas.style.top = 0;
|
||||
canvas.style.right = 0;
|
||||
canvas.style.bottom = 0;
|
||||
|
||||
|
|
@ -53,6 +56,11 @@ export class InPlaceSketcher {
|
|||
this.viewer.io.loadSketch(sketchData);
|
||||
this.ctx.streams.sketcher.sketchingFace.next(face);
|
||||
this.ctx.streams.sketcher.sketcherAppContext.next(this.sketcherAppContext);
|
||||
|
||||
this.disposers = createFunctionList();
|
||||
this.disposers.add(
|
||||
this.ctx.viewer.sceneSetup.viewportSizeUpdate$.attach(this.onCameraChange)
|
||||
);
|
||||
}
|
||||
|
||||
get sketchStorageKey() {
|
||||
|
|
@ -72,6 +80,7 @@ export class InPlaceSketcher {
|
|||
this.ctx.streams.sketcher.sketchingFace.next(null);
|
||||
this.ctx.streams.sketcher.sketcherAppContext.next(null);
|
||||
this.ctx.workbenchService.switchToDefaultWorkbench();
|
||||
this.disposers.call();
|
||||
viewer3d.requestRender();
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue