Skip to content

Commit b44e0ef

Browse files
authored
Merge pull request #174 from LinkunGao/release/v1.13.10
Release/v1.13.10
2 parents 7b433c7 + 1550c93 commit b44e0ef

File tree

12 files changed

+282
-56
lines changed

12 files changed

+282
-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.7'
25+
release = 'v1.13.10'
2626

2727

2828
# -- General configuration ---------------------------------------------------
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
# Transfer large file to backend
2+
3+
- try async await
4+
- not work
5+
- try web worker
6+
- not work: when use the original object.
7+
- test deep copy the object: will cost `50s`
8+
- Good news: the deep copy not affect the draw function on canvas
9+
- Bad news: Causes browser crashes, if deal with the deep copy too many times.
10+
- test pruning PaintImages array first, then use deep copy to deal with the object.
11+
- Good news: pruning Array only include Uint8ClampedArray cause `0s`
12+
- Good news: reformat the Uint8ClampedArray to normal list cause `1ms`
13+
- Bad news: deep copy the object still cost `50s`
14+
- test pruning PaintImages array(to Uint8ClampedArray[]), then reformat it without the deep copy.
15+
- Bad news: the reformat array without deep copy will affect the paint function on canvas.
16+
- test axios send the Uint8ClampedArray[] direactly
17+
- Bad news: the JSON cannot convert the Uint8ClampedArray[] when use the axios.
18+
- Choose solution with Web worker, deepcopy, reformat array, axios.
19+
- deepCopy: `40s`
20+
- reformat data: `1ms`
21+
- axios send to backend: `2~4ms`

docs/source/release/release.md

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1299,3 +1299,19 @@ const resetMainAreaSize = (factor: number) => {
12991299
## Release v1.13.9
13001300

13011301
- remove the gltf-exporter for test in nuxt.js
1302+
1303+
## Release v1.13.10
1304+
1305+
- solved the eraser size issue.
1306+
- add opts in draw function.
1307+
```ts
1308+
interface nrrdDrawImageOptType {
1309+
getMaskData?: (
1310+
masks: paintImageType[],
1311+
len: number,
1312+
width: number,
1313+
height: number
1314+
) => void;
1315+
}
1316+
```
1317+
- We can use this callback function to get the mask data.

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.9",
4+
"version": "1.13.10",
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 & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +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+
import ExportGltf from "../Utils/gltfExporter";
89
import { optType, stateType, modelVisualisationDataType } from "../types/types";
910

1011
export default class baseRenderer {
@@ -23,6 +24,7 @@ export default class baseRenderer {
2324
private visualiseFolder: GUI | null;
2425
private visualCtrls: Array<GUIController> = [];
2526
private cameraFolder: GUI | null;
27+
private exporter: ExportGltf | null = null;
2628

2729
constructor(container: HTMLDivElement, options?: optType) {
2830
this.container = container;
@@ -55,14 +57,14 @@ export default class baseRenderer {
5557
directColor: 0xffffff,
5658
bgColor1: "#5454ad",
5759
bgColor2: "#18e5a7",
58-
// exportGltf: () => {
59-
// if (!this.exporter) {
60-
// this.exporter = new ExportGltf({
61-
// animations: this.currentScene.exportContent.animations,
62-
// });
63-
// }
64-
// this.exporter.export(this.currentScene.exportContent);
65-
// },
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+
},
6668
};
6769
this.visualiseFolder = null;
6870
this.cameraFolder = null;

src/Scene/copperScene.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -119,6 +119,7 @@ export default class copperScene extends baseScene {
119119

120120
models.forEach((model) => {
121121
const geometries: Array<THREE.BufferGeometry> = [];
122+
122123
model.urls.forEach((url, index) => {
123124
vtkLoader.load(url, (geometry) => {
124125
geometry.center();

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+
}

0 commit comments

Comments
 (0)