Skip to content

Commit 66ea8b2

Browse files
authored
Merge pull request #216 from yashschandra/main
download button added
2 parents 83153ff + 15683a0 commit 66ea8b2

File tree

4 files changed

+30
-13
lines changed

4 files changed

+30
-13
lines changed

.gitignore

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -163,9 +163,11 @@ cython_debug/
163163
outputs/
164164

165165
# Ignore folders only used for build dependencies
166-
_Pre_Builds/_Build_Dependencies
166+
_Pre_Builds/_Build_Dependencies
167167
_Pre_Builds/_Build_Wheels
168168
_Pre_Builds/_Libs
169169

170170
models/
171-
output/
171+
output/
172+
173+
.idea

web/html/threeVisualizer.html

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
<link type="text/css" rel="stylesheet" href="/extensions/ComfyUI-3D-Pack/style/sharedStyle.css">
99
</head>
1010

11-
<body>
11+
<body>
1212
<div id="progress-container">
1313
<dialog open id="progress-dialog">
1414
<p>
@@ -48,6 +48,7 @@
4848
]
4949
});
5050
</script>
51+
<button type="button" id="download-button">Download</button>
5152
<input type="text" id="color-picker" class="coloris" value="rgb(128, 128, 128)"></input>
5253
</body>
5354

web/js/threeVisualizer.js

Lines changed: 15 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ const container = document.getElementById( 'container' );
1515
const progressDialog = document.getElementById("progress-dialog");
1616
const progressIndicator = document.getElementById("progress-indicator");
1717
const colorPicker = document.getElementById("color-picker");
18+
const downloadButton = document.getElementById("download-button");
1819

1920
const renderer = new THREE.WebGLRenderer( { antialias: true } );
2021
renderer.setPixelRatio( window.devicePixelRatio );
@@ -56,9 +57,14 @@ const clock = new THREE.Clock();
5657
var lastTimestamp = "";
5758
var needUpdate = false;
5859
let mixer;
60+
let currentURL;
61+
62+
downloadButton.addEventListener('click', e => {
63+
window.open(currentURL, '_blank');
64+
});
5965

6066
function frameUpdate() {
61-
67+
6268
var filepath = visualizer.getAttribute("filepath");
6369
var timestamp = visualizer.getAttribute("timestamp");
6470
if (timestamp == lastTimestamp){
@@ -100,12 +106,12 @@ async function main(filepath="") {
100106
if (/^.+\.[a-zA-Z]+$/.test(filepath)){
101107

102108
let params = {"filepath": filepath};
103-
const url = api.apiURL('/viewfile?' + new URLSearchParams(params));
109+
currentURL = api.apiURL('/viewfile?' + new URLSearchParams(params));
104110

105111
var filepathSplit = filepath.split('.');
106112
var fileExt = filepathSplit.pop().toLowerCase();
107-
var filepathNoExt = filepathSplit.join(".");
108-
113+
var filepathNoExt = filepathSplit.join(".");
114+
109115
if (fileExt == "obj"){
110116
const loader = new OBJLoader();
111117

@@ -118,16 +124,16 @@ async function main(filepath="") {
118124
mtl.preload();
119125
loader.setMaterials( mtl );
120126
}, onProgress, onError );
121-
122-
loader.load( url, function ( obj ) {
127+
128+
loader.load( currentURL, function ( obj ) {
123129
obj.scale.setScalar( 5 );
124130
scene.add( obj );
125131
obj.traverse(node => {
126132
if (node.material && node.material.map == null) {
127133
node.material.vertexColors = true;
128134
}
129135
});
130-
136+
131137
}, onProgress, onError );
132138

133139
} else if (fileExt == "glb") {
@@ -136,7 +142,7 @@ async function main(filepath="") {
136142
const loader = new GLTFLoader();
137143
loader.setDRACOLoader( dracoLoader );
138144

139-
loader.load( url, function ( gltf ) {
145+
loader.load( currentURL, function ( gltf ) {
140146
const model = gltf.scene;
141147
//model.position.set( 1, 1, 0 );
142148
model.scale.set( 3, 3, 3 );
@@ -146,7 +152,7 @@ async function main(filepath="") {
146152
gltf.animations.forEach((clip) => {
147153
mixer.clipAction(clip).play();
148154
});
149-
155+
150156
}, onProgress, onError );
151157

152158
} else if (fileExt == "ply") {

web/style/sharedStyle.css

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,4 +63,12 @@ progress::-moz-progress-bar {
6363
height: 24px;
6464
border: 2px solid #aaa;
6565
border-radius: 5px;
66-
}
66+
}
67+
68+
#download-button {
69+
margin-left: 5px;
70+
margin-top: 10px;
71+
position: absolute;
72+
z-index: 10;
73+
left: 180px;
74+
}

0 commit comments

Comments
 (0)