Spaces:
Running
Running
Commit
•
e7b5357
1
Parent(s):
62c50cd
vertex count, adjust highlight color
Browse files- src/routes/Viewer.svelte +5 -0
- src/routes/Vote.svelte +10 -0
- src/routes/viewers/BabylonViewer.ts +4 -13
- src/routes/viewers/IViewer.ts +1 -1
- src/routes/viewers/SplatViewer.ts +4 -0
- static/global.css +18 -1
src/routes/Viewer.svelte
CHANGED
@@ -88,6 +88,11 @@
|
|
88 |
</div>
|
89 |
</div>
|
90 |
<canvas class="viewer-canvas" bind:this={canvas} width={800} height={600}> </canvas>
|
|
|
|
|
|
|
|
|
|
|
91 |
<div class="mode-toggle">
|
92 |
<label>
|
93 |
<input
|
|
|
88 |
</div>
|
89 |
</div>
|
90 |
<canvas class="viewer-canvas" bind:this={canvas} width={800} height={600}> </canvas>
|
91 |
+
<div class="stats">
|
92 |
+
{#if viewer}
|
93 |
+
<p>vertex count: {viewer.vertexCount}</p>
|
94 |
+
{/if}
|
95 |
+
</div>
|
96 |
<div class="mode-toggle">
|
97 |
<label>
|
98 |
<input
|
src/routes/Vote.svelte
CHANGED
@@ -178,6 +178,11 @@
|
|
178 |
</div>
|
179 |
</div>
|
180 |
<canvas bind:this={canvasA} class="viewer-canvas" id="canvas1"> </canvas>
|
|
|
|
|
|
|
|
|
|
|
181 |
<div class="mode-toggle">
|
182 |
<label>
|
183 |
<input
|
@@ -207,6 +212,11 @@
|
|
207 |
</div>
|
208 |
</div>
|
209 |
<canvas bind:this={canvasB} class="viewer-canvas" id="canvas2"></canvas>
|
|
|
|
|
|
|
|
|
|
|
210 |
<div class="mode-toggle">
|
211 |
<label>
|
212 |
<input
|
|
|
178 |
</div>
|
179 |
</div>
|
180 |
<canvas bind:this={canvasA} class="viewer-canvas" id="canvas1"> </canvas>
|
181 |
+
<div class="stats">
|
182 |
+
{#if viewerA}
|
183 |
+
<p>vertex count: {viewerA.vertexCount}</p>
|
184 |
+
{/if}
|
185 |
+
</div>
|
186 |
<div class="mode-toggle">
|
187 |
<label>
|
188 |
<input
|
|
|
212 |
</div>
|
213 |
</div>
|
214 |
<canvas bind:this={canvasB} class="viewer-canvas" id="canvas2"></canvas>
|
215 |
+
<div class="stats">
|
216 |
+
{#if viewerB}
|
217 |
+
<p>vertex count: {viewerB.vertexCount}</p>
|
218 |
+
{/if}
|
219 |
+
</div>
|
220 |
<div class="mode-toggle">
|
221 |
<label>
|
222 |
<input
|
src/routes/viewers/BabylonViewer.ts
CHANGED
@@ -10,7 +10,7 @@ export class BabylonViewer implements IViewer {
|
|
10 |
scene: BABYLON.Scene;
|
11 |
camera: BABYLON.ArcRotateCamera;
|
12 |
|
13 |
-
|
14 |
|
15 |
private _originalColors: Map<
|
16 |
BABYLON.AbstractMesh,
|
@@ -109,11 +109,11 @@ export class BabylonViewer implements IViewer {
|
|
109 |
|
110 |
scaleFactor = standardSize / size;
|
111 |
}
|
112 |
-
this.
|
113 |
this.scene.meshes.forEach((mesh) => {
|
114 |
mesh.setParent(parentNode);
|
115 |
if (mesh.getTotalVertices() > 0) {
|
116 |
-
this.
|
117 |
}
|
118 |
});
|
119 |
parentNode.position = center.scale(-1 * scaleFactor);
|
@@ -160,7 +160,7 @@ export class BabylonViewer implements IViewer {
|
|
160 |
emissiveColor: material.emissiveColor,
|
161 |
});
|
162 |
material.albedoColor = new BABYLON.Color3(0, 0, 0);
|
163 |
-
material.emissiveColor = new BABYLON.Color3(1, 0.
|
164 |
}
|
165 |
});
|
166 |
} else {
|
@@ -176,13 +176,4 @@ export class BabylonViewer implements IViewer {
|
|
176 |
});
|
177 |
}
|
178 |
}
|
179 |
-
|
180 |
-
getStats(): { name: string; value: any }[] {
|
181 |
-
const fps = this.engine.getFps().toFixed();
|
182 |
-
const triangleCount = this.triangleCount.toLocaleString();
|
183 |
-
return [
|
184 |
-
{ name: "FPS", value: fps },
|
185 |
-
{ name: "Triangles", value: triangleCount },
|
186 |
-
];
|
187 |
-
}
|
188 |
}
|
|
|
10 |
scene: BABYLON.Scene;
|
11 |
camera: BABYLON.ArcRotateCamera;
|
12 |
|
13 |
+
vertexCount: number = 0;
|
14 |
|
15 |
private _originalColors: Map<
|
16 |
BABYLON.AbstractMesh,
|
|
|
109 |
|
110 |
scaleFactor = standardSize / size;
|
111 |
}
|
112 |
+
this.vertexCount = 0;
|
113 |
this.scene.meshes.forEach((mesh) => {
|
114 |
mesh.setParent(parentNode);
|
115 |
if (mesh.getTotalVertices() > 0) {
|
116 |
+
this.vertexCount += mesh.getTotalVertices();
|
117 |
}
|
118 |
});
|
119 |
parentNode.position = center.scale(-1 * scaleFactor);
|
|
|
160 |
emissiveColor: material.emissiveColor,
|
161 |
});
|
162 |
material.albedoColor = new BABYLON.Color3(0, 0, 0);
|
163 |
+
material.emissiveColor = new BABYLON.Color3(1, 0.13, 0);
|
164 |
}
|
165 |
});
|
166 |
} else {
|
|
|
176 |
});
|
177 |
}
|
178 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
179 |
}
|
src/routes/viewers/IViewer.ts
CHANGED
@@ -1,7 +1,7 @@
|
|
1 |
export interface IViewer {
|
|
|
2 |
loadScene(url: string, onProgress?: (progress: number) => void): Promise<void>;
|
3 |
dispose(): void;
|
4 |
capture(): Promise<string | null>;
|
5 |
setRenderMode(mode: string): void;
|
6 |
-
getStats(): { name: string; value: any }[];
|
7 |
}
|
|
|
1 |
export interface IViewer {
|
2 |
+
vertexCount: number;
|
3 |
loadScene(url: string, onProgress?: (progress: number) => void): Promise<void>;
|
4 |
dispose(): void;
|
5 |
capture(): Promise<string | null>;
|
6 |
setRenderMode(mode: string): void;
|
|
|
7 |
}
|
src/routes/viewers/SplatViewer.ts
CHANGED
@@ -12,6 +12,8 @@ export class SplatViewer implements IViewer {
|
|
12 |
|
13 |
disposed: boolean = false;
|
14 |
|
|
|
|
|
15 |
constructor(canvas: HTMLCanvasElement) {
|
16 |
this.canvas = canvas;
|
17 |
|
@@ -38,6 +40,8 @@ export class SplatViewer implements IViewer {
|
|
38 |
throw new Error("Unsupported file format");
|
39 |
}
|
40 |
|
|
|
|
|
41 |
const frame = () => {
|
42 |
this.controls.update();
|
43 |
this.renderer.render(this.scene, this.camera);
|
|
|
12 |
|
13 |
disposed: boolean = false;
|
14 |
|
15 |
+
vertexCount: number = 0;
|
16 |
+
|
17 |
constructor(canvas: HTMLCanvasElement) {
|
18 |
this.canvas = canvas;
|
19 |
|
|
|
40 |
throw new Error("Unsupported file format");
|
41 |
}
|
42 |
|
43 |
+
this.vertexCount = this.splat.data.vertexCount;
|
44 |
+
|
45 |
const frame = () => {
|
46 |
this.controls.update();
|
47 |
this.renderer.render(this.scene, this.camera);
|
static/global.css
CHANGED
@@ -165,7 +165,7 @@ body {
|
|
165 |
gap: 10px;
|
166 |
justify-content: center;
|
167 |
align-items: center;
|
168 |
-
padding: 10px;
|
169 |
flex-wrap: wrap;
|
170 |
}
|
171 |
|
@@ -290,6 +290,23 @@ body {
|
|
290 |
width: 100%;
|
291 |
}
|
292 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
293 |
.label {
|
294 |
font-weight: bold;
|
295 |
justify-content: flex-end;
|
|
|
165 |
gap: 10px;
|
166 |
justify-content: center;
|
167 |
align-items: center;
|
168 |
+
padding: 10px 10px 20px 10px;
|
169 |
flex-wrap: wrap;
|
170 |
}
|
171 |
|
|
|
290 |
width: 100%;
|
291 |
}
|
292 |
|
293 |
+
.stats {
|
294 |
+
position: absolute;
|
295 |
+
top: 0;
|
296 |
+
left: 0;
|
297 |
+
color: #aaa;
|
298 |
+
display: flex;
|
299 |
+
margin: 0;
|
300 |
+
padding: 0;
|
301 |
+
font-size: 12px;
|
302 |
+
gap: 10px;
|
303 |
+
}
|
304 |
+
|
305 |
+
.stats p {
|
306 |
+
margin: 0;
|
307 |
+
padding: 10px;
|
308 |
+
}
|
309 |
+
|
310 |
.label {
|
311 |
font-weight: bold;
|
312 |
justify-content: flex-end;
|