From e23985a80fd282824b4f6c917992a338f40bdfac Mon Sep 17 00:00:00 2001 From: howard Date: Mon, 26 Apr 2021 12:48:02 -0700 Subject: [PATCH] fix update after dim change and constant axes size --- src/Scene.js | 3 ++- src/axes.js | 4 ++-- src/drawDimension.js | 1 + 3 files changed, 5 insertions(+), 3 deletions(-) diff --git a/src/Scene.js b/src/Scene.js index 6c04b15..b465cc3 100644 --- a/src/Scene.js +++ b/src/Scene.js @@ -364,6 +364,7 @@ function render() { this.camera.left = -canvas.clientWidth / canvas.clientHeight; this.camera.right = canvas.clientWidth / canvas.clientHeight; this.camera.updateProjectionMatrix(); + console.log(this.camera.zoom) this.controls.handleResize() Object.assign(this.rect, this.canvas.getBoundingClientRect().toJSON()) @@ -371,7 +372,7 @@ function render() { } - if (this.axes) this.axes.resize(this.camera.zoom) + if (this.axes) this.axes.resize(this.camera.zoom, this.canvas.clientHeight) this.renderer.render(this.obj3d, this.camera); diff --git a/src/axes.js b/src/axes.js index 3d3ebcd..68a50a8 100644 --- a/src/axes.js +++ b/src/axes.js @@ -32,8 +32,8 @@ class AxesHelper extends THREE.Object3D { return this } - resize(zoom) { - const scale = this.initialZoom / zoom + resize(zoom, canvH) { + const scale = this.initialZoom / zoom * 1000/canvH for (let i = 0; i < this.children.length; i++) { this.children[i].setLength( diff --git a/src/drawDimension.js b/src/drawDimension.js index 6c197ee..3307cf8 100644 --- a/src/drawDimension.js +++ b/src/drawDimension.js @@ -179,6 +179,7 @@ export function updateDim(c_id) { this.scene.render() ev_focus.target.blur() this.updateBoundingSpheres() + this.hasChanged = true } else if (e.key == 'Escape') { ev_focus.target.textContent = value getSelection().empty()