Skip to content

Commit

Permalink
Merge pull request #206 from LinkunGao/release/v1.14.0
Browse files Browse the repository at this point in the history
Release/v1.14.0
  • Loading branch information
LinkunGao authored Apr 4, 2023
2 parents 7ff5c2b + e7243f1 commit 9c89a4a
Show file tree
Hide file tree
Showing 9 changed files with 147 additions and 56 deletions.
2 changes: 1 addition & 1 deletion docs/source/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
author = 'LinkunGao'

# The full version, including alpha/beta/rc tags
release = 'v1.13.33'
release = 'v1.14.0'


# -- General configuration ---------------------------------------------------
Expand Down
19 changes: 19 additions & 0 deletions docs/source/release/release.md
Original file line number Diff line number Diff line change
Expand Up @@ -1560,3 +1560,22 @@ copperNrrdLoader(
)
sceneIn?.loadNrrd(url, loadBar1, false, funa, opts);
```

## Release v1.14.0

- Update objloader.
- now the callback function works.
- can get mesh out side.
- Update CopperMScene.
- set the trackball control as default controller.
- Update copper3d_nrrd_plugin.
- display as micorns, not the pixels.
- pixels \* spacing = mm
- addressed the threejs loader to load the 16-bits nrrds.
- addressed the spacing issue among each direction of nrrd.
- Update nrrd_tools to fit the new nrrd volume format by threejs loader.
- drag function.
- paint function.
- save mask data function.
- undo function.
- crosshair function.
18 changes: 9 additions & 9 deletions package-lock.json

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

4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "copper3d_visualisation",
"description": "A 3d visualisation package base on threejs provides multiple scenes and Nrrd image load funtion.",
"version": "1.13.33",
"version": "1.14.0",
"main": "dist/bundle.umd.js",
"moudle": "dist/bundle.esm.js",
"types": "dist/types/index.d.ts",
Expand Down Expand Up @@ -48,7 +48,7 @@
"@types/dat.gui": "^0.7.9",
"@types/three": "^0.140.0",
"copper3d_plugin_heart_k": "^1.0.14",
"copper3d_plugin_nrrd": "^1.3.0",
"copper3d_plugin_nrrd": "^1.3.1",
"dat.gui": "^0.7.9",
"dicom-parser": "^1.8.13",
"fflate": "^0.7.3",
Expand Down
10 changes: 5 additions & 5 deletions src/Loader/copperNrrdLoader.ts
Original file line number Diff line number Diff line change
Expand Up @@ -68,10 +68,10 @@ export function copperNrrdLoader(
const initIndexY = Math.floor(dimensions[1] / 2);
const initIndexX = Math.floor(dimensions[0] / 2);

const sliceZ = volume.extractSlice("z", initIndexZ);
const sliceY = volume.extractSlice("y", initIndexY);
const sliceZ = volume.extractSlice("z", initIndexZ * ratio[2]);
const sliceY = volume.extractSlice("y", initIndexY * ratio[1]);
//x plane
const sliceX = volume.extractSlice("x", initIndexX);
const sliceX = volume.extractSlice("x", initIndexX * ratio[0]);
sliceZ.initIndex = initIndexZ;
sliceY.initIndex = initIndexY;
sliceX.initIndex = initIndexX;
Expand All @@ -98,13 +98,13 @@ export function copperNrrdLoader(

if (gui) {
gui
.add(sliceX, "index", 0, volume.RASDimensions[0], 1)
.add(sliceX, "index", 0, volume.RASDimensions[0] - 1, 1)
.name("indexX")
.onChange(function () {
sliceX.repaint.call(sliceX);
});
gui
.add(sliceY, "index", 0, volume.RASDimensions[1], 1)
.add(sliceY, "index", 0, volume.RASDimensions[1] - 1, 1)
.name("indexY")
.onChange(function () {
sliceY.repaint.call(sliceY);
Expand Down
2 changes: 1 addition & 1 deletion src/Scene/commonSceneMethod.ts
Original file line number Diff line number Diff line change
Expand Up @@ -293,7 +293,7 @@ export default class commonScene {
!!callback && callback(obj);
}, // called when loading is in progresses
(xhr: any) => {
console.log((xhr.loaded / xhr.total) * 100 + "% loaded");
// console.log((xhr.loaded / xhr.total) * 100 + "% loaded");
},
// called when loading has errors
(error: any) => {
Expand Down
56 changes: 54 additions & 2 deletions src/Scene/copperMScene.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import { TrackballControls } from "three/examples/jsm/controls/TrackballControls
import { OrbitControls } from "three/examples/jsm/controls/OrbitControls";
import { GLTF } from "three/examples/jsm/loaders/GLTFLoader";
import { copperGltfLoader } from "../Loader/copperGltfLoader";
import { objLoader } from "../Loader/copperOBJLoader";
import { isPickedModel, throttle } from "../Utils/raycaster";
import {
mouseMovePositionType,
Expand All @@ -17,6 +18,7 @@ import { isIOS } from "../Utils/utils";

import commonScene from "./commonSceneMethod";


const IS_IOS = isIOS();

export default class copperMScene extends commonScene {
Expand Down Expand Up @@ -66,8 +68,10 @@ export default class copperMScene extends commonScene {
this.vignette.mesh.renderOrder = -1;

this.copperControl = new Controls(this.camera);
// this.controls = new TrackballControls(this.camera, container);
this.controls = new OrbitControls(this.camera, this.container);
this.controls = new TrackballControls(this.camera, this.container);
this.controls.rotateSpeed = 0.02;
this.controls.staticMoving = true
// this.controls = new OrbitControls(this.camera, this.container);
this.preRenderCallbackFunctions = {
index: 0,
cache: [],
Expand Down Expand Up @@ -126,6 +130,7 @@ export default class copperMScene extends commonScene {
default:
this.controls = new TrackballControls(this.camera, this.container);
this.controls.rotateSpeed = 0.01;
this.controls.staticMoving = true
break;
}
}
Expand Down Expand Up @@ -251,6 +256,53 @@ export default class copperMScene extends commonScene {
copperNrrdLoader1(url, this.scene, this.container, callback);
}

loadOBJ(url: string, callback?: (mesh: THREE.Group) => void) {
objLoader.load(
url,
(obj) => {
obj.traverse((child) => {
if ((child as THREE.Mesh).isMesh) {
// (child as THREE.Mesh).material = new THREE.MeshStandardMaterial({
// side: THREE.DoubleSide,
// color: 0xffffff,
// });
// ((child as THREE.Mesh).material as THREE.MeshPhongMaterial).color =
// new THREE.Color(0xffffff);
}
});
const box = new THREE.Box3().setFromObject(obj);
const size = box.getSize(new THREE.Vector3()).length();
const center = box.getCenter(new THREE.Vector3());

this.controls.maxDistance = size * 10;
obj.position.x += obj.position.x - center.x;
obj.position.y += obj.position.y - center.y;
obj.position.z += obj.position.z - center.z;

if (!this.cameraPositionFlag) {
this.camera.position.copy(center);
this.camera.position.x += size / 2.0;
this.camera.position.y += size / 5.0;
this.camera.position.z += size / 2.0;
this.camera.lookAt(center);
this.viewPoint = this.setViewPoint(
this.camera as THREE.PerspectiveCamera,
[center.x, center.y, center.z]
);
}
this.scene.add(obj);
!!callback && callback(obj);
}, // called when loading is in progresses
(xhr: any) => {
// console.log((xhr.loaded / xhr.total) * 100 + "% loaded");
},
// called when loading has errors
(error: any) => {
console.log("An error happened");
}
);
}

drawWholeNrrd(nrrdSlices: nrrdSliceType) {
getWholeSlices(
nrrdSlices,
Expand Down
Loading

0 comments on commit 9c89a4a

Please sign in to comment.