Skip to content

Commit 9c89a4a

Browse files
authored
Merge pull request #206 from LinkunGao/release/v1.14.0
Release/v1.14.0
2 parents 7ff5c2b + e7243f1 commit 9c89a4a

File tree

9 files changed

+147
-56
lines changed

9 files changed

+147
-56
lines changed

docs/source/conf.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@
2222
author = 'LinkunGao'
2323

2424
# The full version, including alpha/beta/rc tags
25-
release = 'v1.13.33'
25+
release = 'v1.14.0'
2626

2727

2828
# -- General configuration ---------------------------------------------------

docs/source/release/release.md

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1560,3 +1560,22 @@ copperNrrdLoader(
15601560
)
15611561
sceneIn?.loadNrrd(url, loadBar1, false, funa, opts);
15621562
```
1563+
1564+
## Release v1.14.0
1565+
1566+
- Update objloader.
1567+
- now the callback function works.
1568+
- can get mesh out side.
1569+
- Update CopperMScene.
1570+
- set the trackball control as default controller.
1571+
- Update copper3d_nrrd_plugin.
1572+
- display as micorns, not the pixels.
1573+
- pixels \* spacing = mm
1574+
- addressed the threejs loader to load the 16-bits nrrds.
1575+
- addressed the spacing issue among each direction of nrrd.
1576+
- Update nrrd_tools to fit the new nrrd volume format by threejs loader.
1577+
- drag function.
1578+
- paint function.
1579+
- save mask data function.
1580+
- undo function.
1581+
- crosshair function.

package-lock.json

Lines changed: 9 additions & 9 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"name": "copper3d_visualisation",
33
"description": "A 3d visualisation package base on threejs provides multiple scenes and Nrrd image load funtion.",
4-
"version": "1.13.33",
4+
"version": "1.14.0",
55
"main": "dist/bundle.umd.js",
66
"moudle": "dist/bundle.esm.js",
77
"types": "dist/types/index.d.ts",
@@ -48,7 +48,7 @@
4848
"@types/dat.gui": "^0.7.9",
4949
"@types/three": "^0.140.0",
5050
"copper3d_plugin_heart_k": "^1.0.14",
51-
"copper3d_plugin_nrrd": "^1.3.0",
51+
"copper3d_plugin_nrrd": "^1.3.1",
5252
"dat.gui": "^0.7.9",
5353
"dicom-parser": "^1.8.13",
5454
"fflate": "^0.7.3",

src/Loader/copperNrrdLoader.ts

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -68,10 +68,10 @@ export function copperNrrdLoader(
6868
const initIndexY = Math.floor(dimensions[1] / 2);
6969
const initIndexX = Math.floor(dimensions[0] / 2);
7070

71-
const sliceZ = volume.extractSlice("z", initIndexZ);
72-
const sliceY = volume.extractSlice("y", initIndexY);
71+
const sliceZ = volume.extractSlice("z", initIndexZ * ratio[2]);
72+
const sliceY = volume.extractSlice("y", initIndexY * ratio[1]);
7373
//x plane
74-
const sliceX = volume.extractSlice("x", initIndexX);
74+
const sliceX = volume.extractSlice("x", initIndexX * ratio[0]);
7575
sliceZ.initIndex = initIndexZ;
7676
sliceY.initIndex = initIndexY;
7777
sliceX.initIndex = initIndexX;
@@ -98,13 +98,13 @@ export function copperNrrdLoader(
9898

9999
if (gui) {
100100
gui
101-
.add(sliceX, "index", 0, volume.RASDimensions[0], 1)
101+
.add(sliceX, "index", 0, volume.RASDimensions[0] - 1, 1)
102102
.name("indexX")
103103
.onChange(function () {
104104
sliceX.repaint.call(sliceX);
105105
});
106106
gui
107-
.add(sliceY, "index", 0, volume.RASDimensions[1], 1)
107+
.add(sliceY, "index", 0, volume.RASDimensions[1] - 1, 1)
108108
.name("indexY")
109109
.onChange(function () {
110110
sliceY.repaint.call(sliceY);

src/Scene/commonSceneMethod.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -293,7 +293,7 @@ export default class commonScene {
293293
!!callback && callback(obj);
294294
}, // called when loading is in progresses
295295
(xhr: any) => {
296-
console.log((xhr.loaded / xhr.total) * 100 + "% loaded");
296+
// console.log((xhr.loaded / xhr.total) * 100 + "% loaded");
297297
},
298298
// called when loading has errors
299299
(error: any) => {

src/Scene/copperMScene.ts

Lines changed: 54 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ import { TrackballControls } from "three/examples/jsm/controls/TrackballControls
66
import { OrbitControls } from "three/examples/jsm/controls/OrbitControls";
77
import { GLTF } from "three/examples/jsm/loaders/GLTFLoader";
88
import { copperGltfLoader } from "../Loader/copperGltfLoader";
9+
import { objLoader } from "../Loader/copperOBJLoader";
910
import { isPickedModel, throttle } from "../Utils/raycaster";
1011
import {
1112
mouseMovePositionType,
@@ -17,6 +18,7 @@ import { isIOS } from "../Utils/utils";
1718

1819
import commonScene from "./commonSceneMethod";
1920

21+
2022
const IS_IOS = isIOS();
2123

2224
export default class copperMScene extends commonScene {
@@ -66,8 +68,10 @@ export default class copperMScene extends commonScene {
6668
this.vignette.mesh.renderOrder = -1;
6769

6870
this.copperControl = new Controls(this.camera);
69-
// this.controls = new TrackballControls(this.camera, container);
70-
this.controls = new OrbitControls(this.camera, this.container);
71+
this.controls = new TrackballControls(this.camera, this.container);
72+
this.controls.rotateSpeed = 0.02;
73+
this.controls.staticMoving = true
74+
// this.controls = new OrbitControls(this.camera, this.container);
7175
this.preRenderCallbackFunctions = {
7276
index: 0,
7377
cache: [],
@@ -126,6 +130,7 @@ export default class copperMScene extends commonScene {
126130
default:
127131
this.controls = new TrackballControls(this.camera, this.container);
128132
this.controls.rotateSpeed = 0.01;
133+
this.controls.staticMoving = true
129134
break;
130135
}
131136
}
@@ -251,6 +256,53 @@ export default class copperMScene extends commonScene {
251256
copperNrrdLoader1(url, this.scene, this.container, callback);
252257
}
253258

259+
loadOBJ(url: string, callback?: (mesh: THREE.Group) => void) {
260+
objLoader.load(
261+
url,
262+
(obj) => {
263+
obj.traverse((child) => {
264+
if ((child as THREE.Mesh).isMesh) {
265+
// (child as THREE.Mesh).material = new THREE.MeshStandardMaterial({
266+
// side: THREE.DoubleSide,
267+
// color: 0xffffff,
268+
// });
269+
// ((child as THREE.Mesh).material as THREE.MeshPhongMaterial).color =
270+
// new THREE.Color(0xffffff);
271+
}
272+
});
273+
const box = new THREE.Box3().setFromObject(obj);
274+
const size = box.getSize(new THREE.Vector3()).length();
275+
const center = box.getCenter(new THREE.Vector3());
276+
277+
this.controls.maxDistance = size * 10;
278+
obj.position.x += obj.position.x - center.x;
279+
obj.position.y += obj.position.y - center.y;
280+
obj.position.z += obj.position.z - center.z;
281+
282+
if (!this.cameraPositionFlag) {
283+
this.camera.position.copy(center);
284+
this.camera.position.x += size / 2.0;
285+
this.camera.position.y += size / 5.0;
286+
this.camera.position.z += size / 2.0;
287+
this.camera.lookAt(center);
288+
this.viewPoint = this.setViewPoint(
289+
this.camera as THREE.PerspectiveCamera,
290+
[center.x, center.y, center.z]
291+
);
292+
}
293+
this.scene.add(obj);
294+
!!callback && callback(obj);
295+
}, // called when loading is in progresses
296+
(xhr: any) => {
297+
// console.log((xhr.loaded / xhr.total) * 100 + "% loaded");
298+
},
299+
// called when loading has errors
300+
(error: any) => {
301+
console.log("An error happened");
302+
}
303+
);
304+
}
305+
254306
drawWholeNrrd(nrrdSlices: nrrdSliceType) {
255307
getWholeSlices(
256308
nrrdSlices,

0 commit comments

Comments
 (0)