Skip to content

Commit b4e136a

Browse files
committed
Update preview nodes
- Support custom background color in preview node - Fix Preview node does not update automatically with same mesh name - Add system config file that allow custom clients IP address
1 parent f442e09 commit b4e136a

14 files changed

+195
-45
lines changed

README.md

Lines changed: 13 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@
3838

3939
- **Preview 3DGS and 3D Mesh**: 3D Visualization inside ComfyUI:
4040
- Using [gsplat.js](https://github.com/huggingface/gsplat.js/tree/main) and [three.js](https://github.com/mrdoob/three.js/tree/dev) for 3DGS & 3D Mesh visualization respectively
41+
- Custumizable background base on JS library: [mdbassit/Coloris](https://github.com/mdbassit/Coloris)
4142

4243
<video controls autoplay loop src="https://github.com/MrForExample/ComfyUI-3D-Pack/assets/62230687/9f3c56b1-afb3-4bf1-8845-ab1025a87463"></video>
4344

@@ -64,7 +65,8 @@
6465
- **Gaussian Splatting Orbit Renderer**
6566
- Render 3DGS to images sequences or video, given a 3DGS file and camera poses generated by **Stack Orbit Camera Poses** node
6667

67-
- Bake Multi-View images into UVTexture of given 3D mesh using [Nvdiffrast](https://github.com/NVlabs/nvdiffrast), supports:
68+
- **Multi-View images to UVTexture**
69+
- Bake Multi-View images into UVTexture of given 3D mesh using [Nvdiffrast](https://github.com/NVlabs/nvdiffrast), supports:
6870
- Export to .obj, .ply, .glb
6971

7072
- **NeuS**
@@ -81,6 +83,9 @@
8183
- **Switch Axis for 3DGS & 3D Mesh**
8284
- Since different algorithms likely use different coordinate system, so the ability to re-mapping the axis of coordinate is crucial for passing generated result between differnt nodes.
8385

86+
- **[Customizable system config file](configs/system.conf)**
87+
- Custom clients IP address
88+
8489
## Roadmap:
8590
- [x] Add DMTet algorithm to allow conversion from points cloud(Gaussian/.ply) to mesh (.obj, .ply, .glb)
8691

@@ -92,16 +97,17 @@
9297

9398
- [x] Integrate [LGM: Large Multi-View Gaussian Model for High-Resolution 3D Content Creation](https://me.kiui.moe/lgm/)
9499

95-
- [ ] Add a general SDS/ISM Optimization algorithm to allow training 3D representations with diffusion model, *The real fun starts here* ;)
96-
- Need to do some in-depth research on Interval Score Matching (ISM), since math behind it makes perfect sense and also there are so many ways we could improve upon the result obtained from [LucidDreamer](https://github.com/EnVision-Research/LucidDreamer)
100+
- [ ] Add camera pose estimation from raw multi-views images
101+
102+
- [ ] Add & Improve a few best MVS algorithms (e.g instant-ngp, NeuS2, GaussianPro, etc.)
97103

98-
- [ ] Improve 3DGS to Mesh conversion algorithms:
104+
- [ ] Improve 3DGS/Nerf to Mesh conversion algorithms:
99105
- Support to training DMTet with images(RGB, Alpha, Normal Map)
100106
- Find better methods to converts 3DGS or Points Cloud to Mesh (Normal maps reconstruction maybe?)
101107

102-
- [ ] Add Structure from motion (SfM) initialization for 3DGS (Better first guess -> Faster convergence & Better result)
103-
104-
- [ ] Add a few best Nerf algorithms (No idea yet, [instant-ngp](https://github.com/NVlabs/instant-ngp) maybe?)
108+
- Add a general SDS/ISM Optimization algorithm to allow training 3D representations with diffusion model
109+
- Need to do some in-depth research on Interval Score Matching (ISM), since math behind it makes perfect sense and also there are so many ways we could improve upon the result obtained from [LucidDreamer](https://github.com/EnVision-Research/LucidDreamer)
110+
- On Hold since runtime cost to generate an is too big (3+hours for an average RTX GPU like 3080)
105111

106112
## Install:
107113

__init__.py

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import os
22
import sys
33
import folder_paths as comfy_paths
4+
from pyhocon import ConfigFactory
45

56
ROOT_PATH = os.path.join(comfy_paths.get_folder_paths("custom_nodes")[0], "ComfyUI-3D-Pack")
67
sys.path.append(ROOT_PATH)
@@ -9,7 +10,16 @@
910
import __main__
1011
import importlib
1112
import inspect
12-
from .webserver.server import server
13+
from .webserver.server import server, set_web_conf
14+
15+
conf_path = os.path.join(ROOT_PATH, "configs/system.conf")
16+
# Configuration
17+
f = open(conf_path)
18+
conf_text = f.read()
19+
f.close()
20+
sys_conf = ConfigFactory.parse_string(conf_text)
21+
22+
set_web_conf(sys_conf['web'])
1323

1424
NODE_CLASS_MAPPINGS = {}
1525
NODE_DISPLAY_NAME_MAPPINGS = {}

configs/system.conf

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
web{
2+
clients_ip = [
3+
127.0.0.1,
4+
0.0.0.0
5+
]
6+
}

web/html/gsVisualizer.html

Lines changed: 40 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -4,19 +4,20 @@
44
<meta charset="UTF-8" />
55
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
66
<link rel="stylesheet" href="/extensions/ComfyUI-3D-Pack/style/gsStyle.css">
7-
<link type="text/css" rel="stylesheet" href="/extensions/ComfyUI-3D-Pack/style/progressStyle.css">
7+
<link type="text/css" rel="stylesheet" href="/extensions/ComfyUI-3D-Pack/style/libs/coloris.min.css">
8+
<link type="text/css" rel="stylesheet" href="/extensions/ComfyUI-3D-Pack/style/sharedStyle.css">
89
</head>
910
<body>
10-
<div id="root">
11-
<div id="progress-container">
12-
<dialog open id="progress-dialog">
13-
<p>
14-
<label for="progress-indicator">Loading scene...</label>
15-
</p>
16-
<progress max="100" id="progress-indicator"></progress>
17-
</dialog>
18-
</div>
11+
<div id="progress-container">
12+
<dialog open id="progress-dialog">
13+
<p>
14+
<label for="progress-indicator">Loading scene...</label>
15+
</p>
16+
<progress max="100" id="progress-indicator"></progress>
17+
</dialog>
18+
</div>
1919

20+
<div id="container">
2021
<canvas id="canvas"></canvas>
2122
<script type="importmap">
2223
{
@@ -25,7 +26,35 @@
2526
}
2627
}
2728
</script>
28-
<script id="visualizer" type="module" filepath="" crossorigin src="/extensions/ComfyUI-3D-Pack/js/gsVisualizer.js"></script>
29+
<script id="visualizer" type="module" filepath="" timestamp="" crossorigin src="/extensions/ComfyUI-3D-Pack/js/gsVisualizer.js"></script>
2930
</div>
31+
32+
<script src="/extensions/ComfyUI-3D-Pack/js/libs/coloris.min.js"></script>
33+
<script>
34+
Coloris({
35+
el: '.coloris',
36+
theme: 'polaroid',
37+
themeMode: 'dark',
38+
format: 'rgb',
39+
alpha: false,
40+
swatches: [
41+
'rgb(0, 0, 0)',
42+
'rgb(128, 128, 128)',
43+
'rgb(255, 255, 255)',
44+
'rgb(132, 188, 218)',
45+
'rgb(128, 227, 119)',
46+
'rgb(213, 96, 98)'
47+
]
48+
});
49+
50+
const canvas = document.getElementById("canvas");
51+
const handleClick = () => {
52+
Coloris.close();
53+
document.activeElement.blur();
54+
};
55+
canvas.addEventListener('click', handleClick);
56+
57+
</script>
58+
<input type="text" id="color-picker" class="coloris" value="rgb(0, 0, 0)"></input>
3059
</body>
3160
</html>

web/html/threeVisualizer.html

Lines changed: 33 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,11 @@
44
<meta charset="utf-8">
55
<meta name="viewport" content="width=device-width, user-scalable=no, minimum-scale=1.0, maximum-scale=1.0">
66
<link type="text/css" rel="stylesheet" href="/extensions/ComfyUI-3D-Pack/style/threeStyle.css">
7-
<link type="text/css" rel="stylesheet" href="/extensions/ComfyUI-3D-Pack/style/progressStyle.css">
7+
<link type="text/css" rel="stylesheet" href="/extensions/ComfyUI-3D-Pack/style/libs/coloris.min.css">
8+
<link type="text/css" rel="stylesheet" href="/extensions/ComfyUI-3D-Pack/style/sharedStyle.css">
89
</head>
910

10-
<body>
11+
<body>
1112
<div id="progress-container">
1213
<dialog open id="progress-dialog">
1314
<p>
@@ -17,16 +18,37 @@
1718
</dialog>
1819
</div>
1920

20-
<div id="container"></div>
21-
<script type="importmap">
22-
{
23-
"imports": {
24-
"three": "https://unpkg.com/three@latest/build/three.module.js",
25-
"three/addons/": "https://unpkg.com/three@latest/examples/jsm/"
26-
}
27-
}
21+
<div id="container">
22+
<script type="importmap">
23+
{
24+
"imports": {
25+
"three": "https://unpkg.com/three@latest/build/three.module.js",
26+
"three/addons/": "https://unpkg.com/three@latest/examples/jsm/"
27+
}
28+
}
29+
</script>
30+
<script id="visualizer" type="module" filepath="" timestamp="" crossorigin src="/extensions/ComfyUI-3D-Pack/js/threeVisualizer.js"></script>
31+
</div>
32+
33+
<script src="/extensions/ComfyUI-3D-Pack/js/libs/coloris.min.js"></script>
34+
<script>
35+
Coloris({
36+
el: '.coloris',
37+
theme: 'polaroid',
38+
themeMode: 'dark',
39+
format: 'rgb',
40+
alpha: false,
41+
swatches: [
42+
'rgb(0, 0, 0)',
43+
'rgb(128, 128, 128)',
44+
'rgb(255, 255, 255)',
45+
'rgb(132, 188, 218)',
46+
'rgb(128, 227, 119)',
47+
'rgb(213, 96, 98)'
48+
]
49+
});
2850
</script>
29-
<script id="visualizer" type="module" filepath="" crossorigin src="/extensions/ComfyUI-3D-Pack/js/threeVisualizer.js"></script>
51+
<input type="text" id="color-picker" class="coloris" value="rgb(0, 0, 0)"></input>
3052
</body>
3153

3254
</html>

web/js/LittlestTokyo.glb

-3.94 MB
Binary file not shown.

web/js/gsVisualizer.js

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,12 @@
11
import * as SPLAT from 'gsplat';
22
import { api } from '/scripts/api.js'
3+
import {getRGBValue} from '/extensions/ComfyUI-3D-Pack/js/sharedFunctions.js';
34

45
const visualizer = document.getElementById("visualizer");
56
const canvas = document.getElementById("canvas");
67
const progressDialog = document.getElementById("progress-dialog");
78
const progressIndicator = document.getElementById("progress-indicator");
9+
const colorPicker = document.getElementById("color-picker");
810

911
const renderer = new SPLAT.WebGLRenderer(canvas);
1012
const scene = new SPLAT.Scene();
@@ -19,14 +21,14 @@ const handleResize = () => {
1921
handleResize();
2022
window.addEventListener("resize", handleResize);
2123

22-
23-
var lastFilepath = "";
24+
var lastTimestamp = "";
2425
var needUpdate = false;
2526

2627
function frameUpdate() {
2728

2829
var filepath = visualizer.getAttribute("filepath");
29-
if (filepath == lastFilepath){
30+
var timestamp = visualizer.getAttribute("timestamp");
31+
if (timestamp == lastTimestamp){
3032
if (needUpdate){
3133
controls.update();
3234
renderer.render( scene, camera );
@@ -36,8 +38,13 @@ function frameUpdate() {
3638
needUpdate = false;
3739
scene.reset();
3840
progressDialog.open = true;
39-
lastFilepath = filepath;
40-
main(lastFilepath);
41+
lastTimestamp = timestamp;
42+
main(filepath);
43+
}
44+
45+
var color = getRGBValue(colorPicker.value);
46+
if (color[0] != renderer.backgroundColor.r || color[1] != renderer.backgroundColor.g || color[2] != renderer.backgroundColor.b){
47+
renderer.backgroundColor = new SPLAT.Color32(color[0], color[1], color[2], 255); // It will automatically update background color in preview scene
4148
}
4249
};
4350

0 commit comments

Comments
 (0)