Skip to content

Commit 786cd57

Browse files
authored
Merge pull request #204 from LinkunGao/release/v1.13.32
update the ts format in gui
2 parents 264c355 + c889cb9 commit 786cd57

File tree

7 files changed

+86
-19
lines changed

7 files changed

+86
-19
lines changed

package-lock.json

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

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@
4545
"typescript": "^4.6.4"
4646
},
4747
"dependencies": {
48-
"@types/dat.gui": "^0.7.7",
48+
"@types/dat.gui": "^0.7.9",
4949
"@types/three": "^0.140.0",
5050
"copper3d_plugin_heart_k": "^1.0.14",
5151
"copper3d_plugin_nrrd": "^1.3.0",

src/Loader/copperNrrdLoader.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -396,7 +396,7 @@ export function getWholeSlices(
396396
// // : (slicesX[index].visible = true);
397397
// }
398398
});
399-
gui.add(controls, "enabled").name("controls");
399+
gui.add(controls as any, "enabled").name("controls");
400400
}
401401

402402
export function addBoxHelper(

src/Renderer/baseRenderer.ts

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -240,7 +240,7 @@ export default class baseRenderer {
240240

241241
modelChildrenArray.forEach((item) => {
242242
const ctrl = (this.visualiseFolder as GUI)
243-
.add(item, "visible")
243+
.add(item as any, "visible")
244244
.name(item.name)
245245
.onChange(() => {
246246
this.currentScene.updateModelChildrenVisualisation(item.mesh);
@@ -261,8 +261,8 @@ export default class baseRenderer {
261261
});
262262
}
263263

264-
this.cameraFolder?.add(this.currentScene.camera, "near");
265-
this.cameraFolder?.add(this.currentScene.camera, "far");
264+
this.cameraFolder?.add(this.currentScene.camera as any, "near");
265+
this.cameraFolder?.add(this.currentScene.camera as any, "far");
266266
const subCameraFolders = this.cameraFolder?.__folders;
267267
for (let key in subCameraFolders) {
268268
if (Object.prototype.hasOwnProperty.call(subCameraFolders, key)) {
@@ -271,13 +271,13 @@ export default class baseRenderer {
271271
}
272272
}
273273
const position = this.cameraFolder?.addFolder("position") as GUI;
274-
position.add(this.currentScene.camera.position, "x");
275-
position.add(this.currentScene.camera.position, "y");
276-
position.add(this.currentScene.camera.position, "z");
274+
position.add(this.currentScene.camera.position as any, "x");
275+
position.add(this.currentScene.camera.position as any, "y");
276+
position.add(this.currentScene.camera.position as any, "z");
277277
const up = this.cameraFolder?.addFolder("up") as GUI;
278-
up.add(this.currentScene.camera.up, "x");
279-
up.add(this.currentScene.camera.up, "y");
280-
up.add(this.currentScene.camera.up, "z");
278+
up.add(this.currentScene.camera.up as any, "x");
279+
up.add(this.currentScene.camera.up as any, "y");
280+
up.add(this.currentScene.camera.up as any, "z");
281281
}
282282
count += 1;
283283
}, 3000);

src/Scene/commonSceneMethod.ts

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -204,7 +204,12 @@ export default class commonScene {
204204
});
205205

206206
const finishLoad = (copperVolume: copperVolumeType) => {
207-
if (gui) gui.add(this, "depthStep").min(0.01).max(1).step(0.01);
207+
if (gui)
208+
gui
209+
.add(this as any, "depthStep")
210+
.min(0.01)
211+
.max(1)
212+
.step(0.01);
208213
const texture2d = createTexture2D_Array(
209214
copperVolume,
210215
depth,
@@ -275,7 +280,16 @@ export default class commonScene {
275280
objLoader.load(
276281
url,
277282
(obj) => {
283+
obj.traverse((child) => {
284+
if ((child as THREE.Mesh).isMesh) {
285+
(child as THREE.Mesh).material = new THREE.MeshStandardMaterial({
286+
side: THREE.DoubleSide,
287+
color: 0xfff000,
288+
});
289+
}
290+
});
278291
this.scene.add(obj);
292+
!!callback && callback(obj);
279293
}, // called when loading is in progresses
280294
(xhr: any) => {
281295
console.log((xhr.loaded / xhr.total) * 100 + "% loaded");

src/Scene/copperScene.ts

Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ import { pickModelDefault } from "../Utils/raycaster";
88
import { copperNrrdLoader, optsType } from "../Loader/copperNrrdLoader";
99
import { copperVtkLoader, copperMultipleVtk } from "../Loader/copperVtkLoader";
1010
import { createTexture2D_Array, createTexture2D_Zip } from "../Utils/texture2d";
11+
import { objLoader } from "../Loader/copperOBJLoader";
1112
import baseScene from "./baseScene";
1213
import { GUI } from "dat.gui";
1314
import { copperDicomLoader } from "../Loader/copperDicomLoader";
@@ -95,6 +96,52 @@ export default class copperScene extends baseScene {
9596
}
9697
);
9798
}
99+
// loadOBJ(url: string, callback?: (mesh: THREE.Group) => void) {
100+
// objLoader.load(
101+
// url,
102+
// (obj) => {
103+
// obj.traverse((child) => {
104+
// if ((child as THREE.Mesh).isMesh) {
105+
// // (child as THREE.Mesh).material = new THREE.MeshStandardMaterial({
106+
// // side: THREE.DoubleSide,
107+
// // color: 0xffffff,
108+
// // });
109+
// // ((child as THREE.Mesh).material as THREE.MeshPhongMaterial).color =
110+
// // new THREE.Color(0xffffff);
111+
// }
112+
// });
113+
// const box = new THREE.Box3().setFromObject(obj);
114+
// const size = box.getSize(new THREE.Vector3()).length();
115+
// const center = box.getCenter(new THREE.Vector3());
116+
117+
// this.controls.maxDistance = size * 10;
118+
// obj.position.x += obj.position.x - center.x;
119+
// obj.position.y += obj.position.y - center.y;
120+
// obj.position.z += obj.position.z - center.z;
121+
122+
// if (!this.cameraPositionFlag) {
123+
// this.camera.position.copy(center);
124+
// this.camera.position.x += size / 2.0;
125+
// this.camera.position.y += size / 5.0;
126+
// this.camera.position.z += size / 2.0;
127+
// this.camera.lookAt(center);
128+
// this.viewPoint = this.setViewPoint(
129+
// this.camera as THREE.PerspectiveCamera,
130+
// [center.x, center.y, center.z]
131+
// );
132+
// }
133+
// this.scene.add(obj);
134+
// !!callback && callback(obj);
135+
// }, // called when loading is in progresses
136+
// (xhr: any) => {
137+
// console.log((xhr.loaded / xhr.total) * 100 + "% loaded");
138+
// },
139+
// // called when loading has errors
140+
// (error: any) => {
141+
// console.log("An error happened");
142+
// }
143+
// );
144+
// }
98145

99146
loadVtk(url: string) {
100147
copperVtkLoader(url, this.scene, this.content);

src/Utils/texture2d.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ export function createTexture2D_Array(
6464
texture.needsUpdate = true;
6565
if (gui) {
6666
gui
67-
.add(copperVolume, "windowWidth")
67+
.add(copperVolume as any, "windowWidth")
6868
.min(1)
6969
.max(copperVolume.windowWidth * 2)
7070
.step(1)
@@ -73,7 +73,7 @@ export function createTexture2D_Array(
7373
updateTexture(copperVolume);
7474
});
7575
gui
76-
.add(copperVolume, "windowCenter")
76+
.add(copperVolume as any, "windowCenter")
7777
.min(1)
7878
.max(copperVolume.windowCenter * 2)
7979
.step(1)

0 commit comments

Comments
 (0)