From b4cec2075e7c358b73fa929e3413462b26ef6082 Mon Sep 17 00:00:00 2001 From: LinkunGao Date: Tue, 5 Nov 2024 15:21:57 +1300 Subject: [PATCH 1/2] fix sphere function issue --- src/Utils/segmentation/DrawToolCore.ts | 8 +++++--- src/index.ts | 4 ++-- 2 files changed, 7 insertions(+), 5 deletions(-) diff --git a/src/Utils/segmentation/DrawToolCore.ts b/src/Utils/segmentation/DrawToolCore.ts index c61b6be..be0a60f 100644 --- a/src/Utils/segmentation/DrawToolCore.ts +++ b/src/Utils/segmentation/DrawToolCore.ts @@ -455,7 +455,7 @@ export class DrawToolCore extends CommToolsData { ); let mouseX = e.offsetX / this.nrrd_states.sizeFoctor; let mouseY = e.offsetY / this.nrrd_states.sizeFoctor; - + // record mouseX,Y, and enable crosshair function this.nrrd_states.sphereOrigin[this.protectedData.axis] = [ mouseX, @@ -1215,8 +1215,8 @@ export class DrawToolCore extends CommToolsData { Math.min(this.nrrd_states.sphereRadius, 50) ); // get mouse position - const mouseX = this.nrrd_states.sphereOrigin[this.protectedData.axis][0] * this.nrrd_states.sizeFoctor; - const mouseY = this.nrrd_states.sphereOrigin[this.protectedData.axis][1] * this.nrrd_states.sizeFoctor; + const mouseX = this.nrrd_states.sphereOrigin[this.protectedData.axis][0] ; + const mouseY = this.nrrd_states.sphereOrigin[this.protectedData.axis][1]; this.drawSphere(mouseX, mouseY, this.nrrd_states.sphereRadius); }; return sphereEvent; @@ -1254,6 +1254,8 @@ export class DrawToolCore extends CommToolsData { drawSphere(mouseX: number, mouseY: number, radius: number) { + console.log(radius); + // clear canvas const [canvas, ctx] = this.clearSphereCanvas() this.drawSphereCore(ctx as CanvasRenderingContext2D, mouseX, mouseY, radius,this.gui_states.fillColor); diff --git a/src/index.ts b/src/index.ts index b48a07a..da7a42e 100644 --- a/src/index.ts +++ b/src/index.ts @@ -44,10 +44,10 @@ import { IPaintImage, ICommXYZ } from "./Utils/segmentation/coreTools/coreType"; import "./css/style.css"; -export const REVISION = "v2.1.1"; +export const REVISION = "v2.1.2"; console.log( - "%cCopper3D Visualisation %cBeta:v2.1.1", + "%cCopper3D Visualisation %cBeta:v2.1.2", "padding: 3px;color:white; background:#023047", "padding: 3px;color:white; background:#f50a25" ); From a434f7ff42aae851fae217cbb75c913337cebf9f Mon Sep 17 00:00:00 2001 From: LinkunGao Date: Tue, 5 Nov 2024 15:45:12 +1300 Subject: [PATCH 2/2] update threejs --- package-lock.json | 84 +++++++++++++++-------- package.json | 4 +- src/Controls/Copper3dTrackballControls.ts | 18 ++--- src/Loader/copperNrrdLoader.ts | 4 +- src/Renderer/copperMSceneRenderer.ts | 2 +- src/Utils/utils.ts | 1 + src/types/types.ts | 1 + 7 files changed, 73 insertions(+), 41 deletions(-) diff --git a/package-lock.json b/package-lock.json index d5793ab..81dcb4b 100644 --- a/package-lock.json +++ b/package-lock.json @@ -10,7 +10,7 @@ "license": "Apache-2.0", "dependencies": { "@types/dat.gui": "^0.7.9", - "@types/three": "^0.152.0", + "@types/three": "^0.169.0", "copper3d_plugin_heart_k": "^1.0.14", "dat.gui": "^0.7.9", "dicom-parser": "^1.8.13", @@ -18,7 +18,7 @@ "file-saver": "^2.0.5", "glsl-blend-soft-light": "^1.0.5", "glsl-film-grain": "^1.0.4", - "three": "^0.161.0" + "three": "^0.170.0" }, "devDependencies": { "@rollup/plugin-image": "^2.1.1", @@ -199,7 +199,9 @@ } }, "node_modules/@tweenjs/tween.js": { - "version": "18.6.4", + "version": "23.1.3", + "resolved": "https://registry.npmjs.org/@tweenjs/tween.js/-/tween.js-23.1.3.tgz", + "integrity": "sha512-vJmvvwFxYuGnF2axRtPYocag6Clbb5YS7kLL+SO/TeVFzHqDIWrNKYtcsPMibjDx9O+bu+psAy9NKfWklassUA==", "license": "MIT" }, "node_modules/@types/dat.gui": { @@ -237,24 +239,35 @@ "license": "MIT" }, "node_modules/@types/three": { - "version": "0.152.1", + "version": "0.169.0", + "resolved": "https://registry.npmjs.org/@types/three/-/three-0.169.0.tgz", + "integrity": "sha512-oan7qCgJBt03wIaK+4xPWclYRPG9wzcg7Z2f5T8xYTNEF95kh0t0lklxLLYBDo7gQiGLYzE6iF4ta7nXF2bcsw==", "license": "MIT", "dependencies": { - "@tweenjs/tween.js": "~18.6.4", + "@tweenjs/tween.js": "~23.1.3", "@types/stats.js": "*", "@types/webxr": "*", - "fflate": "~0.6.9", - "lil-gui": "~0.17.0" + "@webgpu/types": "*", + "fflate": "~0.8.2", + "meshoptimizer": "~0.18.1" } }, "node_modules/@types/three/node_modules/fflate": { - "version": "0.6.10", + "version": "0.8.2", + "resolved": "https://registry.npmjs.org/fflate/-/fflate-0.8.2.tgz", + "integrity": "sha512-cPJU47OaAoCbg0pBvzsgpTPhmhqI5eJjh/JIu8tPj5q+T7iLvW/JAYUqmE7KOB4R1ZyEhzBaIQpQpardBF5z8A==", "license": "MIT" }, "node_modules/@types/webxr": { "version": "0.5.7", "license": "MIT" }, + "node_modules/@webgpu/types": { + "version": "0.1.50", + "resolved": "https://registry.npmjs.org/@webgpu/types/-/types-0.1.50.tgz", + "integrity": "sha512-GjG3CQV7SyWk/lEXqFPuKchRPHIBbD317Gj8NUqqB+UOnQlOYtjGLCTRIWzO9Ta698LVzlBCSE9XKqBSWpIDmg==", + "license": "BSD-3-Clause" + }, "node_modules/@yarn-tool/resolve-package": { "version": "1.0.47", "dev": true, @@ -1312,10 +1325,6 @@ "node": ">= 0.8.0" } }, - "node_modules/lil-gui": { - "version": "0.17.0", - "license": "MIT" - }, "node_modules/lilconfig": { "version": "2.1.0", "dev": true, @@ -1406,6 +1415,12 @@ "dev": true, "license": "MIT" }, + "node_modules/meshoptimizer": { + "version": "0.18.1", + "resolved": "https://registry.npmjs.org/meshoptimizer/-/meshoptimizer-0.18.1.tgz", + "integrity": "sha512-ZhoIoL7TNV4s5B6+rx5mC//fw8/POGyNxS/DZyCJeiZ12ScLfVwRE/GfsxwiTkMYYD5DmK2/JXnEVXqL4rF+Sw==", + "license": "MIT" + }, "node_modules/mini-svg-data-uri": { "version": "1.4.4", "dev": true, @@ -2691,9 +2706,10 @@ } }, "node_modules/three": { - "version": "0.161.0", - "resolved": "https://registry.npmjs.org/three/-/three-0.161.0.tgz", - "integrity": "sha512-LC28VFtjbOyEu5b93K0bNRLw1rQlMJ85lilKsYj6dgTu+7i17W+JCCEbvrpmNHF1F3NAUqDSWq50UD7w9H2xQw==" + "version": "0.170.0", + "resolved": "https://registry.npmjs.org/three/-/three-0.170.0.tgz", + "integrity": "sha512-FQK+LEpYc0fBD+J8g6oSEyyNzjp+Q7Ks1C568WWaoMRLW+TkNNWmenWeGgJjV105Gd+p/2ql1ZcjYvNiPZBhuQ==", + "license": "MIT" }, "node_modules/through2": { "version": "2.0.5", @@ -2938,7 +2954,9 @@ "dev": true }, "@tweenjs/tween.js": { - "version": "18.6.4" + "version": "23.1.3", + "resolved": "https://registry.npmjs.org/@tweenjs/tween.js/-/tween.js-23.1.3.tgz", + "integrity": "sha512-vJmvvwFxYuGnF2axRtPYocag6Clbb5YS7kLL+SO/TeVFzHqDIWrNKYtcsPMibjDx9O+bu+psAy9NKfWklassUA==" }, "@types/dat.gui": { "version": "0.7.11" @@ -2969,23 +2987,33 @@ "version": "0.17.2" }, "@types/three": { - "version": "0.152.1", + "version": "0.169.0", + "resolved": "https://registry.npmjs.org/@types/three/-/three-0.169.0.tgz", + "integrity": "sha512-oan7qCgJBt03wIaK+4xPWclYRPG9wzcg7Z2f5T8xYTNEF95kh0t0lklxLLYBDo7gQiGLYzE6iF4ta7nXF2bcsw==", "requires": { - "@tweenjs/tween.js": "~18.6.4", + "@tweenjs/tween.js": "~23.1.3", "@types/stats.js": "*", "@types/webxr": "*", - "fflate": "~0.6.9", - "lil-gui": "~0.17.0" + "@webgpu/types": "*", + "fflate": "~0.8.2", + "meshoptimizer": "~0.18.1" }, "dependencies": { "fflate": { - "version": "0.6.10" + "version": "0.8.2", + "resolved": "https://registry.npmjs.org/fflate/-/fflate-0.8.2.tgz", + "integrity": "sha512-cPJU47OaAoCbg0pBvzsgpTPhmhqI5eJjh/JIu8tPj5q+T7iLvW/JAYUqmE7KOB4R1ZyEhzBaIQpQpardBF5z8A==" } } }, "@types/webxr": { "version": "0.5.7" }, + "@webgpu/types": { + "version": "0.1.50", + "resolved": "https://registry.npmjs.org/@webgpu/types/-/types-0.1.50.tgz", + "integrity": "sha512-GjG3CQV7SyWk/lEXqFPuKchRPHIBbD317Gj8NUqqB+UOnQlOYtjGLCTRIWzO9Ta698LVzlBCSE9XKqBSWpIDmg==" + }, "@yarn-tool/resolve-package": { "version": "1.0.47", "dev": true, @@ -3694,9 +3722,6 @@ "type-check": "~0.3.2" } }, - "lil-gui": { - "version": "0.17.0" - }, "lilconfig": { "version": "2.1.0", "dev": true @@ -3762,6 +3787,11 @@ "version": "2.0.0", "dev": true }, + "meshoptimizer": { + "version": "0.18.1", + "resolved": "https://registry.npmjs.org/meshoptimizer/-/meshoptimizer-0.18.1.tgz", + "integrity": "sha512-ZhoIoL7TNV4s5B6+rx5mC//fw8/POGyNxS/DZyCJeiZ12ScLfVwRE/GfsxwiTkMYYD5DmK2/JXnEVXqL4rF+Sw==" + }, "mini-svg-data-uri": { "version": "1.4.4", "dev": true @@ -4509,9 +4539,9 @@ } }, "three": { - "version": "0.161.0", - "resolved": "https://registry.npmjs.org/three/-/three-0.161.0.tgz", - "integrity": "sha512-LC28VFtjbOyEu5b93K0bNRLw1rQlMJ85lilKsYj6dgTu+7i17W+JCCEbvrpmNHF1F3NAUqDSWq50UD7w9H2xQw==" + "version": "0.170.0", + "resolved": "https://registry.npmjs.org/three/-/three-0.170.0.tgz", + "integrity": "sha512-FQK+LEpYc0fBD+J8g6oSEyyNzjp+Q7Ks1C568WWaoMRLW+TkNNWmenWeGgJjV105Gd+p/2ql1ZcjYvNiPZBhuQ==" }, "through2": { "version": "2.0.5", diff --git a/package.json b/package.json index 2ced5f2..952bba9 100644 --- a/package.json +++ b/package.json @@ -47,7 +47,7 @@ }, "dependencies": { "@types/dat.gui": "^0.7.9", - "@types/three": "^0.152.0", + "@types/three": "^0.169.0", "copper3d_plugin_heart_k": "^1.0.14", "dat.gui": "^0.7.9", "dicom-parser": "^1.8.13", @@ -55,6 +55,6 @@ "file-saver": "^2.0.5", "glsl-blend-soft-light": "^1.0.5", "glsl-film-grain": "^1.0.4", - "three": "^0.161.0" + "three": "^0.170.0" } } diff --git a/src/Controls/Copper3dTrackballControls.ts b/src/Controls/Copper3dTrackballControls.ts index 260672c..238faec 100644 --- a/src/Controls/Copper3dTrackballControls.ts +++ b/src/Controls/Copper3dTrackballControls.ts @@ -384,7 +384,7 @@ class Copper3dTrackballControls extends EventDispatcher { scope.object.lookAt(scope.target); if (lastPosition.distanceToSquared(scope.object.position) > EPS) { - scope.dispatchEvent(_changeEvent); + scope.dispatchEvent(_changeEvent as never); lastPosition.copy(scope.object.position); } @@ -395,7 +395,7 @@ class Copper3dTrackballControls extends EventDispatcher { lastPosition.distanceToSquared(scope.object.position) > EPS || lastZoom !== scope.object.zoom ) { - scope.dispatchEvent(_changeEvent); + scope.dispatchEvent(_changeEvent as never); lastPosition.copy(scope.object.position); lastZoom = scope.object.zoom; @@ -420,7 +420,7 @@ class Copper3dTrackballControls extends EventDispatcher { scope.object.lookAt(scope.target); - scope.dispatchEvent(_changeEvent); + scope.dispatchEvent(_changeEvent as never); lastPosition.copy(scope.object.position); lastZoom = scope.object.zoom; @@ -538,7 +538,7 @@ class Copper3dTrackballControls extends EventDispatcher { _panEnd.copy(_panStart); } - scope.dispatchEvent(_startEvent); + scope.dispatchEvent(_startEvent as never); } function onMouseMove(event: PointerEvent) { @@ -557,7 +557,7 @@ class Copper3dTrackballControls extends EventDispatcher { function onMouseUp() { _state = STATE.NONE; - scope.dispatchEvent(_endEvent); + scope.dispatchEvent(_endEvent as never); } function onMouseWheel(event: WheelEvent) { @@ -584,8 +584,8 @@ class Copper3dTrackballControls extends EventDispatcher { break; } - scope.dispatchEvent(_startEvent); - scope.dispatchEvent(_endEvent); + scope.dispatchEvent(_startEvent as never); + scope.dispatchEvent(_endEvent as never); } function onTouchStart(event: PointerEvent) { @@ -626,7 +626,7 @@ class Copper3dTrackballControls extends EventDispatcher { break; } - scope.dispatchEvent(_startEvent); + scope.dispatchEvent(_startEvent as never); } function onTouchMove(event: PointerEvent) { @@ -709,7 +709,7 @@ class Copper3dTrackballControls extends EventDispatcher { break; } - scope.dispatchEvent(_endEvent); + scope.dispatchEvent(_endEvent as never); } function contextmenu(event: MouseEvent) { diff --git a/src/Loader/copperNrrdLoader.ts b/src/Loader/copperNrrdLoader.ts index baba2da..7c41033 100644 --- a/src/Loader/copperNrrdLoader.ts +++ b/src/Loader/copperNrrdLoader.ts @@ -435,9 +435,9 @@ export function getWholeSlices( export function addBoxHelper( scene: copperScene, volume: any, - boxCube?: THREE.Object3D + boxCube?: THREE.Object3D ) { - let obj: THREE.Object3D; + let obj: THREE.Object3D; boxCube ? (obj = boxCube) : (obj = cube); const boxHelper = new THREE.BoxHelper(obj); diff --git a/src/Renderer/copperMSceneRenderer.ts b/src/Renderer/copperMSceneRenderer.ts index 40af8c7..72a2b55 100644 --- a/src/Renderer/copperMSceneRenderer.ts +++ b/src/Renderer/copperMSceneRenderer.ts @@ -39,7 +39,7 @@ export class copperMSceneRenderer { init() { // this.renderer.physicallyCorrectLights = true; // this.renderer.outputEncoding = THREE.sRGBEncoding; - this.renderer.useLegacyLights = true; + // this.renderer.useLegacyLights = true; this.renderer.outputColorSpace = THREE.SRGBColorSpace; this.pmremGenerator.compileEquirectangularShader(); diff --git a/src/Utils/utils.ts b/src/Utils/utils.ts index 22a350f..95c8380 100644 --- a/src/Utils/utils.ts +++ b/src/Utils/utils.ts @@ -1,3 +1,4 @@ +import * as THREE from "three"; export function fullScreenListenner( container: HTMLDivElement | HTMLCanvasElement ) { diff --git a/src/types/types.ts b/src/types/types.ts index ec420e4..ea79660 100644 --- a/src/types/types.ts +++ b/src/types/types.ts @@ -2,6 +2,7 @@ import { copperScene } from "../Scene/copperScene"; import { baseScene } from "../Scene/baseScene"; import { copperMScene } from "../Scene/copperMScene"; import { GUI } from "dat.gui"; +import * as THREE from "three"; interface SceneMapType { [key: string]: copperScene | baseScene | copperMScene;