Skip to content

Commit e66f1ee

Browse files
authored
Merge pull request #178 from LinkunGao/release/v1.13.14
Release/v1.13.14
2 parents 8bb66cd + 61d5257 commit e66f1ee

File tree

8 files changed

+88
-7
lines changed

8 files changed

+88
-7
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.13'
25+
release = 'v1.13.14'
2626

2727

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

docs/source/release/release.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1410,3 +1410,8 @@ const resetMainAreaSize = (factor: number) => {
14101410
}
14111411
```
14121412
- We can in getCopperVolume() function to update the volume windowWidth and windowCenter
1413+
1414+
## Release v1.13.14
1415+
1416+
- re-add the export gltf function.
1417+
- use these version to develop the nrrd tools app.

package-lock.json

Lines changed: 2 additions & 2 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
@@ -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.13",
4+
"version": "1.13.14",
55
"main": "dist/bundle.umd.js",
66
"moudle": "dist/bundle.esm.js",
77
"types": "dist/types/index.d.ts",

src/Renderer/baseRenderer.ts

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ import { environments, environmentType } from "../lib/environment/index";
55
import { RGBELoader } from "three/examples/jsm/loaders/RGBELoader";
66
import Stats from "three/examples/jsm/libs/stats.module";
77
import { GUI, GUIController } from "dat.gui";
8-
8+
import ExportGltf from "../Utils/gltfExporter";
99
import { optType, stateType, modelVisualisationDataType } from "../types/types";
1010

1111
export default class baseRenderer {
@@ -24,6 +24,7 @@ export default class baseRenderer {
2424
private visualiseFolder: GUI | null;
2525
private visualCtrls: Array<GUIController> = [];
2626
private cameraFolder: GUI | null;
27+
private exporter: ExportGltf | null = null;
2728

2829
constructor(container: HTMLDivElement, options?: optType) {
2930
this.container = container;
@@ -56,6 +57,14 @@ export default class baseRenderer {
5657
directColor: 0xffffff,
5758
bgColor1: "#5454ad",
5859
bgColor2: "#18e5a7",
60+
exportGltf: () => {
61+
if (!this.exporter) {
62+
this.exporter = new ExportGltf({
63+
animations: this.currentScene.exportContent.animations,
64+
});
65+
}
66+
this.exporter.export(this.currentScene.exportContent);
67+
},
5968
};
6069
this.visualiseFolder = null;
6170
this.cameraFolder = null;

src/Scene/copperScene.ts

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -151,11 +151,21 @@ export default class copperScene extends baseScene {
151151
) => {
152152
let { vtkmaterial } = copperMultipleVtk(model.opts);
153153
let geometry = geometries[0];
154+
const position = geometry.attributes.position;
154155
geometries.forEach((child, index) => {
155156
if (index === 0) {
156157
geometry = child;
157158
geometry.morphAttributes.position = [];
158159
} else {
160+
// if (index == 1) {
161+
// geometry.morphAttributes.position.push(position);
162+
// }
163+
// if (index == 6) {
164+
// geometry.morphAttributes.position.push(child.attributes.position);
165+
// }
166+
// if (index == 7) {
167+
// geometry.morphAttributes.position.push(position);
168+
// }
159169
geometry.morphAttributes.position.push(child.attributes.position);
160170
}
161171
});
@@ -171,6 +181,7 @@ export default class copperScene extends baseScene {
171181
let j = 0;
172182
let tracks = [];
173183
let duration = geometries.length - 1;
184+
// let duration = 5;
174185
for (let i = 0; i < duration; i++) {
175186
const track = new THREE.KeyframeTrack(
176187
`${mesh.name}.morphTargetInfluences[${i}]`,

src/Utils/gltfExporter.ts

Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
import { GLTFExporter } from "three/examples/jsm/exporters/GLTFExporter";
2+
import { optionsGltfExporterType } from "../types/types";
3+
4+
export default class ExportGltf {
5+
private gltfExporter: GLTFExporter = new GLTFExporter();
6+
private options: optionsGltfExporterType = {
7+
trs: false,
8+
onlyVisible: true,
9+
truncateDrawRange: true,
10+
binary: false,
11+
maxTextureSize: 40960000000,
12+
animations: [],
13+
};
14+
private link: HTMLAnchorElement;
15+
16+
constructor(opts: optionsGltfExporterType) {
17+
Object.assign(this.options, opts);
18+
this.link = document.createElement("a");
19+
this.link.style.display = "none";
20+
document.body.appendChild(this.link);
21+
}
22+
23+
export(input: any) {
24+
const name: string = input.name ? input.name : "export";
25+
this.gltfExporter.parse(
26+
input,
27+
(result) => {
28+
if (result instanceof ArrayBuffer) {
29+
this.saveArrayBuffer(result, name + ".glb");
30+
} else {
31+
const output = JSON.stringify(result, null, 2);
32+
this.saveString(output, name + ".gltf");
33+
}
34+
},
35+
function (error) {
36+
console.log("An error happened during parsing", error);
37+
},
38+
this.options
39+
);
40+
}
41+
42+
save(blob: Blob, fileName: string) {
43+
this.link.href = URL.createObjectURL(blob);
44+
this.link.download = fileName;
45+
this.link.click();
46+
}
47+
saveString(text: string, fileName: string) {
48+
this.save(new Blob([text], { type: "text/plain" }), fileName);
49+
}
50+
saveArrayBuffer(buffer: ArrayBuffer, fileName: string) {
51+
this.save(
52+
new Blob([buffer], { type: "application/octet-stream" }),
53+
fileName
54+
);
55+
}
56+
}

src/index.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -36,10 +36,10 @@ import {
3636

3737
import "./css/style.css";
3838

39-
export const REVISION = "v1.13.13";
39+
export const REVISION = "v1.13.14";
4040

4141
console.log(
42-
"%cCopper3D Visualisation %cBeta:v1.13.13",
42+
"%cCopper3D Visualisation %cBeta:v1.13.14",
4343
"padding: 3px;color:white; background:#023047",
4444
"padding: 3px;color:white; background:#f50a25"
4545
);

0 commit comments

Comments
 (0)