Skip to content

Commit

Permalink
Merge pull request #48 from LinkunGao/pwa
Browse files Browse the repository at this point in the history
Pwa
  • Loading branch information
LinkunGao authored Nov 21, 2024
2 parents df59fa0 + c1fe6c0 commit 36c98c3
Show file tree
Hide file tree
Showing 5 changed files with 113 additions and 14 deletions.
32 changes: 32 additions & 0 deletions frontend/components/model/LeftModel.vue
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,7 @@ export default {
this.container = this.$refs.leftContainer;
this.modelToScenes = this.$modelToScenes();
this.leftPanelText = this.$leftPanelText();
this.previoursCameras = this.$previoursCameras();
this.container.appendChild(this.baseContainer);
Expand Down Expand Up @@ -122,6 +123,18 @@ export default {
this.navPanelName = modelName;
this.loadModel(this.modelUrlsArray[this.navPanelName][0], this.navPanelName+"left");
this.swicthDescription();
this.previoursCameras["left"][this.navPanelName] = {
"up": {
"x": this.scene.camera.up.x,
"y": this.scene.camera.up.y,
"z": this.scene.camera.up.z,
},
"position": {
"x": this.scene.camera.position.x,
"y": this.scene.camera.position.y,
"z": this.scene.camera.position.z,
}
};
},
start() {
Expand All @@ -138,6 +151,8 @@ export default {
this.scene = this.baseRenderer.getSceneByName(model_name);
if (this.scene === undefined) {
console.log("Creating new scene");
this.scene = this.baseRenderer.createScene(model_name);
this.scene.addLights();
this.scene.controls.rotateSpeed = 3.0;
Expand Down Expand Up @@ -168,6 +183,23 @@ export default {
this.modelToScenes[model_name] = this.scene;
}else{
this.baseRenderer.setCurrentScene(this.scene);
if(!!this.previoursCameras["left"][this.navPanelName]){
setTimeout(() => {
this.scene.camera.up.set(
this.previoursCameras["left"][this.navPanelName]["up"].x,
this.previoursCameras["left"][this.navPanelName]["up"].y,
this.previoursCameras["left"][this.navPanelName]["up"].z
);
this.scene.camera.position.set(
this.previoursCameras["left"][this.navPanelName]["position"].x,
this.previoursCameras["left"][this.navPanelName]["position"].y,
this.previoursCameras["left"][this.navPanelName]["position"].z
);
}, 200);
}
}
this.scene.onWindowResize();
},
Expand Down
40 changes: 33 additions & 7 deletions frontend/components/model/Model.vue
Original file line number Diff line number Diff line change
Expand Up @@ -146,6 +146,7 @@ export default {
this.modelName = this.$model().name;
this.middlePanelText = this.$middlePanelText();
this.nrrdImages = this.$nrrdImages();
this.previoursCameras = this.$previoursCameras();
if(this.modelName === "benign_cyst"){
this.tab2 = "2D Ultrasound";
Expand Down Expand Up @@ -212,6 +213,7 @@ export default {
loadBar1.progress.innerHTML = "Loading image...";
this.scene = this.baseRenderer.getSceneByName(modelName);
if (this.scene === undefined) {
this.scene = this.baseRenderer.createScene(modelName);
// this.scene.controls.staticMoving = true;
Expand Down Expand Up @@ -289,13 +291,25 @@ export default {
}else{
loadingContainer.style.display = "none";
this.baseRenderer.setCurrentScene(this.scene);
if(this.currentView === "2D Mammogram"){
this.scene.controls.noRotate = true;
this.scene.controls.noPan = true;
this.removeContainerListener();
}else{
this.addContainerListener();
}
setTimeout(() => {
this.scene.camera.up.set(
this.previoursCameras["middle"][this.modelName]["up"].x,
this.previoursCameras["middle"][this.modelName]["up"].y,
this.previoursCameras["middle"][this.modelName]["up"].z
);
this.scene.camera.position.set(
this.previoursCameras["middle"][this.modelName]["position"].x,
this.previoursCameras["middle"][this.modelName]["position"].y,
this.previoursCameras["middle"][this.modelName]["position"].z
);
if(this.currentView === "2D Mammogram"){
this.scene.controls.noRotate = true;
this.scene.controls.noPan = true;
this.removeContainerListener();
}else{
this.addContainerListener();
}
}, 200);
}
this.loadFirstTime = false;
this.scene.onWindowResize();
Expand Down Expand Up @@ -336,6 +350,18 @@ export default {
beforeDestroy() {
// Wirte code before destory this component
this.previoursCameras["middle"][this.modelName] = {
"up": {
"x": this.scene.camera.up.x,
"y": this.scene.camera.up.y,
"z": this.scene.camera.up.z,
},
"position": {
"x": this.scene.camera.position.x,
"y": this.scene.camera.position.y,
"z": this.scene.camera.position.z,
}
};
this.removeContainerListener();
},
};
Expand Down
28 changes: 27 additions & 1 deletion frontend/components/model/PanelControls.vue
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,7 @@ export default {
this.container = this.$refs.rightContainer;
this.rightPanelText = this.$rightPanelText();
this.nrrdImages = this.$nrrdImages();
this.previoursCameras = this.$previoursCameras();
this.container.appendChild(this.baseContainer);
Expand Down Expand Up @@ -199,7 +200,20 @@ export default {
this.modelToScenes[modelName] = this.scene;
}else{
this.baseRenderer.setCurrentScene(this.scene);
this.addContainerListener();
setTimeout(() => {
this.scene.camera.up.set(
this.previoursCameras["right"][this.modelName]["up"].x,
this.previoursCameras["right"][this.modelName]["up"].y,
this.previoursCameras["right"][this.modelName]["up"].z
);
this.scene.camera.position.set(
this.previoursCameras["right"][this.modelName]["position"].x,
this.previoursCameras["right"][this.modelName]["position"].y,
this.previoursCameras["right"][this.modelName]["position"].z
);
this.addContainerListener();
}, 200);
}
this.scene.onWindowResize();
},
Expand Down Expand Up @@ -247,6 +261,18 @@ export default {
},
},
beforeDestroy() {
this.previoursCameras["right"][this.modelName] = {
"up": {
"x": this.scene.camera.up.x,
"y": this.scene.camera.up.y,
"z": this.scene.camera.up.z,
},
"position": {
"x": this.scene.camera.position.x,
"y": this.scene.camera.position.y,
"z": this.scene.camera.position.z,
}
};
// Wirte code before destory this component
this.removeContainerListener();
},
Expand Down
18 changes: 12 additions & 6 deletions frontend/plugins/copper.js
Original file line number Diff line number Diff line change
Expand Up @@ -74,11 +74,19 @@ const raycaster = (scene, container, nrrdSliceZ, nrrdMesh, nrrdMaxIndex) => {
if (event.button === 0) {
startY = event.clientY;
userMouseDown = true;
container.style.cursor = "pointer";
scene.controls.noRotate = true;
}
}

const mouseUp = (event) => {
// findMesh = false;
scene.controls.noRotate = false;
userMouseDown = false;
container.style.cursor = "auto";
// container.removeEventListener("pointerdown", mouseDown);
// container.removeEventListener("pointerup", mouseUp);

}

const mouseMove = (event) => {
Expand Down Expand Up @@ -108,19 +116,17 @@ const raycaster = (scene, container, nrrdSliceZ, nrrdMesh, nrrdMaxIndex) => {

if(!!a.intersectedObject){
if(!findMesh){
scene.controls.noRotate = true;
container.style.cursor = "pointer";
container.addEventListener("pointerdown", mouseDown);
container.addEventListener("pointerup", mouseUp);
}
findMesh = true;
}else{
findMesh = false;
scene.controls.noRotate = false;
userMouseDown = false;
container.style.cursor = "auto";
// scene.controls.noRotate = false;
// userMouseDown = false;
// container.style.cursor = "auto";
container.removeEventListener("pointerdown", mouseDown);
container.removeEventListener("pointerup", mouseUp);
// container.removeEventListener("pointerup", mouseUp);
}
}
return {mouseMove, mouseDown, mouseUp};
Expand Down
9 changes: 9 additions & 0 deletions frontend/plugins/data.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 36c98c3

Please sign in to comment.