simview 6.3.1__tar.gz → 6.4.0__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- {simview-6.3.1/simview.egg-info → simview-6.4.0}/PKG-INFO +1 -1
- {simview-6.3.1 → simview-6.4.0}/pyproject.toml +1 -1
- {simview-6.3.1 → simview-6.4.0}/simview/model.py +15 -1
- {simview-6.3.1 → simview-6.4.0}/simview/scene.py +10 -2
- {simview-6.3.1 → simview-6.4.0}/simview/static/js/SimView.js +17 -22
- {simview-6.3.1 → simview-6.4.0}/simview/static/js/components/InteractionController.js +38 -1
- {simview-6.3.1 → simview-6.4.0}/simview/static/js/config.js +2 -1
- {simview-6.3.1 → simview-6.4.0}/simview/static/js/objects/Body.js +33 -8
- {simview-6.3.1 → simview-6.4.0}/simview/static/js/ui/BodyStateWindow.js +3 -0
- {simview-6.3.1 → simview-6.4.0}/simview/static/js/ui/Controls.js +78 -11
- {simview-6.3.1 → simview-6.4.0}/simview/static/js/ui/Legend.js +4 -2
- {simview-6.3.1 → simview-6.4.0/simview.egg-info}/PKG-INFO +1 -1
- {simview-6.3.1 → simview-6.4.0}/tests/test_pointcloud_features.py +15 -0
- {simview-6.3.1 → simview-6.4.0}/LICENSE +0 -0
- {simview-6.3.1 → simview-6.4.0}/MANIFEST.in +0 -0
- {simview-6.3.1 → simview-6.4.0}/README.md +0 -0
- {simview-6.3.1 → simview-6.4.0}/setup.cfg +0 -0
- {simview-6.3.1 → simview-6.4.0}/simview/__init__.py +0 -0
- {simview-6.3.1 → simview-6.4.0}/simview/__main__.py +0 -0
- {simview-6.3.1 → simview-6.4.0}/simview/columnar.py +0 -0
- {simview-6.3.1 → simview-6.4.0}/simview/diff.py +0 -0
- {simview-6.3.1 → simview-6.4.0}/simview/info.py +0 -0
- {simview-6.3.1 → simview-6.4.0}/simview/launcher.py +0 -0
- {simview-6.3.1 → simview-6.4.0}/simview/live.py +0 -0
- {simview-6.3.1 → simview-6.4.0}/simview/merge.py +0 -0
- {simview-6.3.1 → simview-6.4.0}/simview/preload.py +0 -0
- {simview-6.3.1 → simview-6.4.0}/simview/py.typed +0 -0
- {simview-6.3.1 → simview-6.4.0}/simview/remote.py +0 -0
- {simview-6.3.1 → simview-6.4.0}/simview/render.py +0 -0
- {simview-6.3.1 → simview-6.4.0}/simview/server.py +0 -0
- {simview-6.3.1 → simview-6.4.0}/simview/state.py +0 -0
- {simview-6.3.1 → simview-6.4.0}/simview/static/css/controls.css +0 -0
- {simview-6.3.1 → simview-6.4.0}/simview/static/js/components/AnimationController.js +0 -0
- {simview-6.3.1 → simview-6.4.0}/simview/static/js/components/BatchManager.js +0 -0
- {simview-6.3.1 → simview-6.4.0}/simview/static/js/components/Scene.js +0 -0
- {simview-6.3.1 → simview-6.4.0}/simview/static/js/components/StateStore.js +0 -0
- {simview-6.3.1 → simview-6.4.0}/simview/static/js/components/WindowedField.js +0 -0
- {simview-6.3.1 → simview-6.4.0}/simview/static/js/main.js +0 -0
- {simview-6.3.1 → simview-6.4.0}/simview/static/js/objects/Polyline.js +0 -0
- {simview-6.3.1 → simview-6.4.0}/simview/static/js/objects/StaticObject.js +0 -0
- {simview-6.3.1 → simview-6.4.0}/simview/static/js/objects/Terrain.js +0 -0
- {simview-6.3.1 → simview-6.4.0}/simview/static/js/objects/colormap.js +0 -0
- {simview-6.3.1 → simview-6.4.0}/simview/static/js/objects/similarity.js +0 -0
- {simview-6.3.1 → simview-6.4.0}/simview/static/js/objects/utils.js +0 -0
- {simview-6.3.1 → simview-6.4.0}/simview/static/js/ui/AnalysisPanel.js +0 -0
- {simview-6.3.1 → simview-6.4.0}/simview/static/js/ui/BatchLegend.js +0 -0
- {simview-6.3.1 → simview-6.4.0}/simview/static/js/ui/ErrorMetrics.js +0 -0
- {simview-6.3.1 → simview-6.4.0}/simview/static/js/ui/PlaybackControls.js +0 -0
- {simview-6.3.1 → simview-6.4.0}/simview/static/js/ui/ScalarPlotter.js +0 -0
- {simview-6.3.1 → simview-6.4.0}/simview/static/js/ui/TerrainProfile.js +0 -0
- {simview-6.3.1 → simview-6.4.0}/simview/static/js/ui/chartControls.js +0 -0
- {simview-6.3.1 → simview-6.4.0}/simview/static/js/utils/batchPresets.js +0 -0
- {simview-6.3.1 → simview-6.4.0}/simview/static/js/utils/batchVisibility.js +0 -0
- {simview-6.3.1 → simview-6.4.0}/simview/static/js/utils/blobCodec.js +0 -0
- {simview-6.3.1 → simview-6.4.0}/simview/static/js/utils/blobWindow.js +0 -0
- {simview-6.3.1 → simview-6.4.0}/simview/static/js/utils/bodyTransforms.js +0 -0
- {simview-6.3.1 → simview-6.4.0}/simview/static/js/utils/cameraRange.js +0 -0
- {simview-6.3.1 → simview-6.4.0}/simview/static/js/utils/csv.js +0 -0
- {simview-6.3.1 → simview-6.4.0}/simview/static/js/utils/episodes.js +0 -0
- {simview-6.3.1 → simview-6.4.0}/simview/static/js/utils/errorMath.js +0 -0
- {simview-6.3.1 → simview-6.4.0}/simview/static/js/utils/html.js +0 -0
- {simview-6.3.1 → simview-6.4.0}/simview/static/js/utils/interpolate.js +0 -0
- {simview-6.3.1 → simview-6.4.0}/simview/static/js/utils/keyboard.js +0 -0
- {simview-6.3.1 → simview-6.4.0}/simview/static/js/utils/liveFollow.js +0 -0
- {simview-6.3.1 → simview-6.4.0}/simview/static/js/utils/scalarSeries.js +0 -0
- {simview-6.3.1 → simview-6.4.0}/simview/static/js/utils/terrainSample.js +0 -0
- {simview-6.3.1 → simview-6.4.0}/simview/static/js/utils/uplot.js +0 -0
- {simview-6.3.1 → simview-6.4.0}/simview/static/js/utils/viewState.js +0 -0
- {simview-6.3.1 → simview-6.4.0}/simview/static/js/utils/viewerDefaults.js +0 -0
- {simview-6.3.1 → simview-6.4.0}/simview/static/js/utils/visibleRanges.js +0 -0
- {simview-6.3.1 → simview-6.4.0}/simview/static/js/vendor/js-colormaps.js +0 -0
- {simview-6.3.1 → simview-6.4.0}/simview/static/lib/three-0.174.0/addons/controls/OrbitControls.js +0 -0
- {simview-6.3.1 → simview-6.4.0}/simview/static/lib/three-0.174.0/addons/libs/lil-gui.module.min.js +0 -0
- {simview-6.3.1 → simview-6.4.0}/simview/static/lib/three-0.174.0/three.core.js +0 -0
- {simview-6.3.1 → simview-6.4.0}/simview/static/lib/three-0.174.0/three.module.js +0 -0
- {simview-6.3.1 → simview-6.4.0}/simview/static/lib/uPlot-1.6.32/uPlot.esm.js +0 -0
- {simview-6.3.1 → simview-6.4.0}/simview/static/lib/uPlot-1.6.32/uPlot.min.css +0 -0
- {simview-6.3.1 → simview-6.4.0}/simview/static/textures/contacts/red-cross0.png +0 -0
- {simview-6.3.1 → simview-6.4.0}/simview/static/textures/points/ball1.png +0 -0
- {simview-6.3.1 → simview-6.4.0}/simview/templates/index.html +0 -0
- {simview-6.3.1 → simview-6.4.0}/simview/terrain.py +0 -0
- {simview-6.3.1 → simview-6.4.0}/simview/utils.py +0 -0
- {simview-6.3.1 → simview-6.4.0}/simview/view.py +0 -0
- {simview-6.3.1 → simview-6.4.0}/simview.egg-info/SOURCES.txt +0 -0
- {simview-6.3.1 → simview-6.4.0}/simview.egg-info/dependency_links.txt +0 -0
- {simview-6.3.1 → simview-6.4.0}/simview.egg-info/entry_points.txt +0 -0
- {simview-6.3.1 → simview-6.4.0}/simview.egg-info/requires.txt +0 -0
- {simview-6.3.1 → simview-6.4.0}/simview.egg-info/top_level.txt +0 -0
- {simview-6.3.1 → simview-6.4.0}/tests/test_batch_selection.py +0 -0
- {simview-6.3.1 → simview-6.4.0}/tests/test_cli.py +0 -0
- {simview-6.3.1 → simview-6.4.0}/tests/test_columnar_ondisk.py +0 -0
- {simview-6.3.1 → simview-6.4.0}/tests/test_columnar_states.py +0 -0
- {simview-6.3.1 → simview-6.4.0}/tests/test_contacts.py +0 -0
- {simview-6.3.1 → simview-6.4.0}/tests/test_diff.py +0 -0
- {simview-6.3.1 → simview-6.4.0}/tests/test_embed_defaults.py +0 -0
- {simview-6.3.1 → simview-6.4.0}/tests/test_episodes.py +0 -0
- {simview-6.3.1 → simview-6.4.0}/tests/test_info.py +0 -0
- {simview-6.3.1 → simview-6.4.0}/tests/test_launcher.py +0 -0
- {simview-6.3.1 → simview-6.4.0}/tests/test_live.py +0 -0
- {simview-6.3.1 → simview-6.4.0}/tests/test_merge.py +0 -0
- {simview-6.3.1 → simview-6.4.0}/tests/test_preload.py +0 -0
- {simview-6.3.1 → simview-6.4.0}/tests/test_remote.py +0 -0
- {simview-6.3.1 → simview-6.4.0}/tests/test_roundtrip.py +0 -0
- {simview-6.3.1 → simview-6.4.0}/tests/test_scene.py +0 -0
- {simview-6.3.1 → simview-6.4.0}/tests/test_server.py +0 -0
- {simview-6.3.1 → simview-6.4.0}/tests/test_show.py +0 -0
- {simview-6.3.1 → simview-6.4.0}/tests/test_terrain.py +0 -0
- {simview-6.3.1 → simview-6.4.0}/tests/test_terrain_query.py +0 -0
- {simview-6.3.1 → simview-6.4.0}/tests/test_trajectory.py +0 -0
- {simview-6.3.1 → simview-6.4.0}/tests/test_utils.py +0 -0
- {simview-6.3.1 → simview-6.4.0}/tests/test_view.py +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: simview
|
|
3
|
-
Version: 6.
|
|
3
|
+
Version: 6.4.0
|
|
4
4
|
Summary: THREE.js-based simulation visualization tool
|
|
5
5
|
Author-email: Jan Vlk <vlkjan6@fel.cvut.cz>, Ales Kucera <kuceral4@fel.cvut.cz>, David Korcak <david.korcak@gmail.com>
|
|
6
6
|
License-Expression: BSD-3-Clause
|
|
@@ -488,6 +488,7 @@ class SimViewBody:
|
|
|
488
488
|
points: torch.Tensor,
|
|
489
489
|
color: torch.Tensor | None = None,
|
|
490
490
|
embedding: torch.Tensor | None = None,
|
|
491
|
+
color_layers: dict[str, torch.Tensor] | None = None,
|
|
491
492
|
**kwargs,
|
|
492
493
|
) -> "SimViewBody":
|
|
493
494
|
"""Build a point-cloud body from `(N, 3)` `points`.
|
|
@@ -497,7 +498,10 @@ class SimViewBody:
|
|
|
497
498
|
an optional per-point K-wide feature vector (e.g. a reduced-dim PCA
|
|
498
499
|
projection of a learned backbone's features) enabling the viewer's
|
|
499
500
|
click-to-similarity color mode: cosine similarity to a clicked point,
|
|
500
|
-
computed entirely in-browser from this data.
|
|
501
|
+
computed entirely in-browser from this data. `color_layers` maps a
|
|
502
|
+
name to another (N, 3) RGB coloring (e.g. a class or session label);
|
|
503
|
+
each becomes an extra choice of the viewer's "Point Color Mode", shown
|
|
504
|
+
by every body that ships a layer of that name. All are stored as
|
|
501
505
|
``__b64__`` blobs."""
|
|
502
506
|
if points.ndim != 2 or points.shape[1] != 3:
|
|
503
507
|
raise ValueError(
|
|
@@ -517,6 +521,16 @@ class SimViewBody:
|
|
|
517
521
|
f"embedding must have shape ({N}, K) matching points; got {tuple(embedding.shape)}."
|
|
518
522
|
)
|
|
519
523
|
shape_extra["embedding"] = embedding
|
|
524
|
+
if color_layers:
|
|
525
|
+
shape_extra["colorLayers"] = {}
|
|
526
|
+
for layer, rgb in color_layers.items():
|
|
527
|
+
if layer in ("pca", "similarity"):
|
|
528
|
+
raise ValueError(f"color layer name {layer!r} is reserved.")
|
|
529
|
+
if tuple(rgb.shape) != (N, 3):
|
|
530
|
+
raise ValueError(
|
|
531
|
+
f"color layer {layer!r} must have shape ({N}, 3); got {tuple(rgb.shape)}."
|
|
532
|
+
)
|
|
533
|
+
shape_extra["colorLayers"][layer] = _encode_blob(rgb.cpu().numpy())
|
|
520
534
|
# Per-point `color` lives in the shape, so it can't go through
|
|
521
535
|
# `create`'s kwargs (where `color` is the body-level tint).
|
|
522
536
|
body = SimViewBody.create(
|
|
@@ -794,6 +794,7 @@ class SimulationScene:
|
|
|
794
794
|
points: torch.Tensor,
|
|
795
795
|
color: torch.Tensor | None = None,
|
|
796
796
|
embedding: torch.Tensor | None = None,
|
|
797
|
+
color_layers: dict[str, torch.Tensor] | None = None,
|
|
797
798
|
**kwargs,
|
|
798
799
|
) -> None:
|
|
799
800
|
"""Add a point-cloud body named `body_name` to the model.
|
|
@@ -802,11 +803,18 @@ class SimulationScene:
|
|
|
802
803
|
`(N, 3)` per-point RGB in [0, 1] for static vertex-colored rendering.
|
|
803
804
|
`embedding` is an optional `(N, K)` per-point feature vector (e.g. a
|
|
804
805
|
reduced-dim PCA projection) enabling the viewer's click-to-similarity
|
|
805
|
-
color mode.
|
|
806
|
+
color mode. `color_layers` maps names to extra `(N, 3)` RGB colorings
|
|
807
|
+
selectable as "Point Color Mode" choices. Other `**kwargs` go to
|
|
808
|
+
`SimViewBody.create`.
|
|
806
809
|
"""
|
|
807
810
|
self.model.add_body(
|
|
808
811
|
SimViewBody.create_pointcloud(
|
|
809
|
-
body_name,
|
|
812
|
+
body_name,
|
|
813
|
+
points,
|
|
814
|
+
color=color,
|
|
815
|
+
embedding=embedding,
|
|
816
|
+
color_layers=color_layers,
|
|
817
|
+
**kwargs,
|
|
810
818
|
)
|
|
811
819
|
)
|
|
812
820
|
|
|
@@ -436,24 +436,26 @@ export class SimView {
|
|
|
436
436
|
// appendBodyHistories has run (see BodyStateWindow.updateBodyList).
|
|
437
437
|
if (this.bodyStateWindow) this.bodyStateWindow.updateBodyList();
|
|
438
438
|
if (this.uiControls) this.uiControls.updateTrackBodyOptions();
|
|
439
|
-
|
|
440
|
-
this.errorMetrics.onHistoryReady();
|
|
441
|
-
}
|
|
442
|
-
this.maybeAttachTerrainProfile();
|
|
439
|
+
this.maybeAttachTrajectoryPanels();
|
|
443
440
|
}
|
|
444
441
|
|
|
445
|
-
// The Terrain
|
|
442
|
+
// The Error Metrics and Terrain tabs need a body with an actual trajectory to sample
|
|
446
443
|
// terrain along (a static point cloud with no states doesn't count),
|
|
447
444
|
// which is only known once appendBodyHistories() has filled each body's
|
|
448
|
-
// validStates.
|
|
449
|
-
|
|
450
|
-
|
|
445
|
+
// validStates. Error Metrics compares batches over time, so it needs the
|
|
446
|
+
// same plus at least two batches; a static scene gets neither tab.
|
|
447
|
+
maybeAttachTrajectoryPanels() {
|
|
451
448
|
if (!hasBodyTrajectory(this.bodies)) return;
|
|
452
|
-
|
|
453
|
-
|
|
449
|
+
this.analysisPanel ??= new AnalysisPanel(this);
|
|
450
|
+
if (this.batchManager.simBatches >= 2 && !this.errorMetrics) {
|
|
451
|
+
this.errorMetrics = new ErrorMetrics(this);
|
|
452
|
+
this.errorMetrics.onHistoryReady();
|
|
453
|
+
this.analysisPanel.attach("errorMetrics", this.errorMetrics, this.errorMetrics.content);
|
|
454
|
+
}
|
|
455
|
+
if (this.terrain && !this.terrainProfile) {
|
|
456
|
+
this.terrainProfile = new TerrainProfile(this);
|
|
457
|
+
this.analysisPanel.attach("terrain", this.terrainProfile, this.terrainProfile.content);
|
|
454
458
|
}
|
|
455
|
-
this.terrainProfile = new TerrainProfile(this);
|
|
456
|
-
this.analysisPanel.attach("terrain", this.terrainProfile, this.terrainProfile.content);
|
|
457
459
|
}
|
|
458
460
|
|
|
459
461
|
// Resolves and records position/orientation (and contacts, vectors, ...)
|
|
@@ -562,13 +564,10 @@ export class SimView {
|
|
|
562
564
|
// so the camera's clipping/orbit range can stop being a guess.
|
|
563
565
|
this.scene.applySceneExtent(this.terrain.bounds);
|
|
564
566
|
const hasScalars = model.scalarNames && model.scalarNames.length > 0;
|
|
565
|
-
|
|
566
|
-
//
|
|
567
|
-
// maybeAttachTerrainProfile).
|
|
568
|
-
if (hasScalars || hasErrorMetrics) {
|
|
569
|
-
this.analysisPanel = new AnalysisPanel(this);
|
|
570
|
-
}
|
|
567
|
+
// The Error Metrics and Terrain tabs are attached later, from
|
|
568
|
+
// onStoreReady (see maybeAttachTrajectoryPanels).
|
|
571
569
|
if (hasScalars) {
|
|
570
|
+
this.analysisPanel = new AnalysisPanel(this);
|
|
572
571
|
console.debug(
|
|
573
572
|
"Initializing scalar plotter for scalars",
|
|
574
573
|
model.scalarNames
|
|
@@ -577,10 +576,6 @@ export class SimView {
|
|
|
577
576
|
const { tabBar, plotArea } = this.scalarPlotter;
|
|
578
577
|
this.analysisPanel.attach("scalars", this.scalarPlotter, tabBar, plotArea);
|
|
579
578
|
}
|
|
580
|
-
if (hasErrorMetrics) {
|
|
581
|
-
this.errorMetrics = new ErrorMetrics(this);
|
|
582
|
-
this.analysisPanel.attach("errorMetrics", this.errorMetrics, this.errorMetrics.content);
|
|
583
|
-
}
|
|
584
579
|
this.interactionController = new InteractionController(this);
|
|
585
580
|
this.uiControls = new UIControls(this);
|
|
586
581
|
this.bodyStateWindow = new BodyStateWindow(this);
|
|
@@ -103,7 +103,7 @@ export class InteractionController {
|
|
|
103
103
|
const similarityActive = this.app.uiState?.pointColorMode === "similarity";
|
|
104
104
|
if (!probeActive && !similarityActive) return;
|
|
105
105
|
|
|
106
|
-
this
|
|
106
|
+
this.#setRayFromClick(e);
|
|
107
107
|
// THREE's raycaster ignores `visible`, so hidden objects (a focused-
|
|
108
108
|
// mode batch's point cloud that was built earlier, a hidden body) are
|
|
109
109
|
// filtered out here or a click lands on something not on screen.
|
|
@@ -162,6 +162,36 @@ export class InteractionController {
|
|
|
162
162
|
this.hideTerrainTooltip();
|
|
163
163
|
}
|
|
164
164
|
|
|
165
|
+
// In split screen each half is rendered with the camera shifted to its
|
|
166
|
+
// batch and a half-width aspect (Scene.animate); raycast the same way, or
|
|
167
|
+
// a click in either half picks whatever sits under it in the full view.
|
|
168
|
+
#setRayFromClick(e) {
|
|
169
|
+
const app = this.app;
|
|
170
|
+
const camera = app.scene.camera;
|
|
171
|
+
const bm = app.batchManager;
|
|
172
|
+
if (!(app.uiState?.splitScreen && bm && bm.simBatches >= 2)) {
|
|
173
|
+
this.raycaster.setFromCamera(this.mouse, camera);
|
|
174
|
+
return;
|
|
175
|
+
}
|
|
176
|
+
const width = window.innerWidth;
|
|
177
|
+
const height = window.innerHeight;
|
|
178
|
+
const right = e.clientX >= width / 2;
|
|
179
|
+
const batch = right ? (app.uiState.splitBatchB ?? 1) : (app.uiState.splitBatchA ?? 0);
|
|
180
|
+
const offset = bm.getBatchOffset(batch);
|
|
181
|
+
const active = bm.getBatchOffset(bm.currentlyActiveBatch);
|
|
182
|
+
const delta = [offset.x - active.x, offset.y - active.y, offset.z - active.z];
|
|
183
|
+
const ndc = this.mouse.clone();
|
|
184
|
+
ndc.x = ((e.clientX - (right ? width / 2 : 0)) / (width / 2)) * 2 - 1;
|
|
185
|
+
const cam = camera.clone();
|
|
186
|
+
cam.aspect = width / 2 / height;
|
|
187
|
+
cam.updateProjectionMatrix();
|
|
188
|
+
cam.position.x += delta[0];
|
|
189
|
+
cam.position.y += delta[1];
|
|
190
|
+
cam.position.z += delta[2];
|
|
191
|
+
cam.updateMatrixWorld();
|
|
192
|
+
this.raycaster.setFromCamera(ndc, cam);
|
|
193
|
+
}
|
|
194
|
+
|
|
165
195
|
// Point-cloud analog of showTerrainTooltip: recolors the whole body by
|
|
166
196
|
// cosine similarity to the clicked point instead of showing a props
|
|
167
197
|
// tooltip (there's no single "value" to display -- the whole point of
|
|
@@ -170,6 +200,13 @@ export class InteractionController {
|
|
|
170
200
|
const body = this.app.bodies.get(hit.object.userData.bodyName);
|
|
171
201
|
if (!body) return;
|
|
172
202
|
body.recolorBySimilarity(hit.index);
|
|
203
|
+
if (this.app.uiState?.linkPointSimilarity) {
|
|
204
|
+
for (const other of this.app.bodies.values()) {
|
|
205
|
+
if (other !== body && other.pointEmbedding && other.pointCount === body.pointCount) {
|
|
206
|
+
other.recolorBySimilarity(hit.index);
|
|
207
|
+
}
|
|
208
|
+
}
|
|
209
|
+
}
|
|
173
210
|
this.#hideTooltipText();
|
|
174
211
|
if (this.probeSphere) {
|
|
175
212
|
this.probeSphere.position.copy(hit.point);
|
|
@@ -44,7 +44,8 @@ export const UI_DEFAULT_CONFIG = {
|
|
|
44
44
|
terrainColorMap: "magma", // Default colormap
|
|
45
45
|
terrainColorMode: "height", // "height", or any named terrain property (e.g. friction, stiffness)
|
|
46
46
|
terrainProbe: false, // interactive terrain probe on click
|
|
47
|
-
pointColorMode: "pca", // "pca"
|
|
47
|
+
pointColorMode: "pca", // "pca", "similarity" (point clouds with embeddings) or a color layer name
|
|
48
|
+
linkPointSimilarity: false, // a point click recolors every same-size point cloud
|
|
48
49
|
};
|
|
49
50
|
|
|
50
51
|
export const FREQ_CONFIG = {
|
|
@@ -8,7 +8,7 @@ import {
|
|
|
8
8
|
createArrow,
|
|
9
9
|
toFlatFloat32Array,
|
|
10
10
|
} from "./utils.js";
|
|
11
|
-
import { getCallableFromColorMapName } from "./colormap.js";
|
|
11
|
+
import { colormapLUT, getCallableFromColorMapName, NO_DATA_COLOR } from "./colormap.js";
|
|
12
12
|
import { cosineSimilarityToQuery } from "./similarity.js";
|
|
13
13
|
|
|
14
14
|
export class Body {
|
|
@@ -311,6 +311,7 @@ export class Body {
|
|
|
311
311
|
this.pointColors = null;
|
|
312
312
|
this.pointEmbedding = null;
|
|
313
313
|
this.embeddingDim = 0;
|
|
314
|
+
this.pointColorLayers = new Map(); // name -> flat RGB, see showColorLayer
|
|
314
315
|
this.selectedPointIndex = null;
|
|
315
316
|
|
|
316
317
|
// Initialize instanced representations
|
|
@@ -319,6 +320,9 @@ export class Body {
|
|
|
319
320
|
if (shape.color) {
|
|
320
321
|
this.pointColors = toFlatFloat32Array(shape.color);
|
|
321
322
|
}
|
|
323
|
+
for (const [layer, rgb] of Object.entries(shape.colorLayers || {})) {
|
|
324
|
+
this.pointColorLayers.set(layer, toFlatFloat32Array(rgb));
|
|
325
|
+
}
|
|
322
326
|
if (shape.embedding) {
|
|
323
327
|
this.pointEmbedding = toFlatFloat32Array(shape.embedding);
|
|
324
328
|
this.embeddingDim = this.pointCount
|
|
@@ -456,7 +460,8 @@ export class Body {
|
|
|
456
460
|
source.geometry,
|
|
457
461
|
source.config,
|
|
458
462
|
true,
|
|
459
|
-
|
|
463
|
+
// A batch built after a recolor (layer, similarity) matches the others.
|
|
464
|
+
this.shownPointColors ?? this.pointColors
|
|
460
465
|
);
|
|
461
466
|
if (!points) return;
|
|
462
467
|
points.visible = this.#pointsVisible();
|
|
@@ -760,6 +765,7 @@ export class Body {
|
|
|
760
765
|
// first use -- mirrors Terrain.js's per-vertex color update pattern,
|
|
761
766
|
// just targeting THREE.Points/PointsMaterial instead of Mesh/MeshPhongMaterial.
|
|
762
767
|
setPointColors(colorsFlat) {
|
|
768
|
+
this.shownPointColors = colorsFlat;
|
|
763
769
|
for (const points of this.representations.points ?? []) {
|
|
764
770
|
if (!points) continue;
|
|
765
771
|
let attr = points.geometry.getAttribute("color");
|
|
@@ -791,14 +797,23 @@ export class Body {
|
|
|
791
797
|
this.pointCount
|
|
792
798
|
);
|
|
793
799
|
|
|
794
|
-
|
|
800
|
+
// A lookup table, not a colormap call per point (which allocates a
|
|
801
|
+
// THREE.Color each: ~60% of the recolor time at 200k points).
|
|
802
|
+
const lut = colormapLUT(getCallableFromColorMapName(cmapName));
|
|
803
|
+
const last = lut.length / 3 - 1;
|
|
795
804
|
const colors = new Float32Array(this.pointCount * 3);
|
|
796
805
|
for (let i = 0; i < this.pointCount; i++) {
|
|
797
|
-
const
|
|
798
|
-
|
|
799
|
-
|
|
800
|
-
|
|
801
|
-
|
|
806
|
+
const sim = similarities[i];
|
|
807
|
+
if (Number.isFinite(sim)) {
|
|
808
|
+
const k = Math.round((0.5 + 0.5 * Math.max(-1, Math.min(1, sim))) * last) * 3;
|
|
809
|
+
colors[i * 3] = lut[k];
|
|
810
|
+
colors[i * 3 + 1] = lut[k + 1];
|
|
811
|
+
colors[i * 3 + 2] = lut[k + 2];
|
|
812
|
+
} else {
|
|
813
|
+
colors[i * 3] = NO_DATA_COLOR.r;
|
|
814
|
+
colors[i * 3 + 1] = NO_DATA_COLOR.g;
|
|
815
|
+
colors[i * 3 + 2] = NO_DATA_COLOR.b;
|
|
816
|
+
}
|
|
802
817
|
}
|
|
803
818
|
this.setPointColors(colors);
|
|
804
819
|
this.selectedPointIndex = queryIndex;
|
|
@@ -813,6 +828,16 @@ export class Body {
|
|
|
813
828
|
if (this.app.legend) this.app.legend.update();
|
|
814
829
|
}
|
|
815
830
|
|
|
831
|
+
// Shows the named per-point color layer (shape.colorLayers), or the
|
|
832
|
+
// static coloring if this body ships no layer of that name.
|
|
833
|
+
showColorLayer(name) {
|
|
834
|
+
const rgb = this.pointColorLayers.get(name);
|
|
835
|
+
if (!rgb) return this.resetPointColors();
|
|
836
|
+
this.setPointColors(rgb);
|
|
837
|
+
this.selectedPointIndex = null;
|
|
838
|
+
if (this.app.legend) this.app.legend.update();
|
|
839
|
+
}
|
|
840
|
+
|
|
816
841
|
// Restores the static PCA-RGB coloring (or clears to no color data if
|
|
817
842
|
// this body never had any), undoing recolorBySimilarity.
|
|
818
843
|
resetPointColors() {
|
|
@@ -131,6 +131,9 @@ export class BodyStateWindow {
|
|
|
131
131
|
}
|
|
132
132
|
|
|
133
133
|
this.bodyListContainer.appendChild(list);
|
|
134
|
+
// Nothing to read in a scene with no posed bodies (e.g. only static
|
|
135
|
+
// point clouds); the BatchLegend already covers batch switching.
|
|
136
|
+
this.window.style.display = this.bodyListItems.size ? "" : "none";
|
|
134
137
|
}
|
|
135
138
|
|
|
136
139
|
selectBody(name) {
|
|
@@ -4,6 +4,39 @@ import { colorMapOptions } from "../vendor/js-colormaps.js";
|
|
|
4
4
|
import { RENDER_ALL, RENDER_FOCUSED } from "../utils/batchVisibility.js";
|
|
5
5
|
import { serializeViewState } from "../utils/viewState.js";
|
|
6
6
|
|
|
7
|
+
// Hover text per control, keyed by its property.
|
|
8
|
+
const CONTROL_TIPS = {
|
|
9
|
+
bodyVisualizationMode: "How bodies are drawn: mesh, wireframe, primitive shapes, or none to hide them.",
|
|
10
|
+
showPointClouds: "Show or hide the point-cloud bodies.",
|
|
11
|
+
showPolylines: "Show or hide the polylines.",
|
|
12
|
+
showAxes: "Draw each body's local coordinate axes.",
|
|
13
|
+
showTrails: "Draw the path each body has travelled.",
|
|
14
|
+
smoothInterpolation: "Interpolate poses between recorded frames instead of snapping to the nearest one.",
|
|
15
|
+
renderAllBatches: "Draw every batch at once. Off draws only the focused batch (plus any pinned by split screen), which is faster for many batches.",
|
|
16
|
+
pointColorMode: "What colors the points: pca (stored colors), a named color layer, or similarity (click a point to color every point by its similarity to it).",
|
|
17
|
+
linkPointSimilarity: "A similarity click recolors every point cloud with the same point count, not just the clicked one.",
|
|
18
|
+
showContacts: "Show contact points.",
|
|
19
|
+
showVelocity: "Show each body's linear velocity as an arrow.",
|
|
20
|
+
showAngularVelocity: "Show each body's angular velocity as an arrow.",
|
|
21
|
+
showForce: "Show the linear force acting on each body as an arrow.",
|
|
22
|
+
showTorque: "Show the torque acting on each body as an arrow.",
|
|
23
|
+
showSurface: "Show or hide the colored terrain surface (and its legend).",
|
|
24
|
+
showWireframe: "Overlay the terrain's grid lines.",
|
|
25
|
+
showNormals: "Draw the terrain's surface normals as short lines.",
|
|
26
|
+
colorMap: "Colormap used to color the terrain surface.",
|
|
27
|
+
colorMode: "What the terrain color encodes: height, a terrain property, a diff between two batches, or feature similarity.",
|
|
28
|
+
diffLayer: "Terrain layer to compare between the two batches.",
|
|
29
|
+
diffBatchA: "Baseline batch for the diff (the diff is B minus A).",
|
|
30
|
+
diffBatchB: "Batch compared against the baseline (the diff is B minus A).",
|
|
31
|
+
terrainProbe: "Hover the terrain to read its values at the cursor.",
|
|
32
|
+
fov: "Camera field of view in degrees.",
|
|
33
|
+
trackBody: "Keep the camera following the chosen body.",
|
|
34
|
+
splitScreen: "Show two batches side by side.",
|
|
35
|
+
splitBatchA: "Batch shown in the first half of the split screen.",
|
|
36
|
+
splitBatchB: "Batch shown in the second half of the split screen.",
|
|
37
|
+
copyViewLink: "Copy a link that reopens this view: camera, toggles and selections.",
|
|
38
|
+
};
|
|
39
|
+
|
|
7
40
|
// The lil-gui Controls panel (Body/Terrain/Camera Options, Scene Info) and
|
|
8
41
|
// its global keyboard shortcuts.
|
|
9
42
|
export class UIControls {
|
|
@@ -64,6 +97,7 @@ export class UIControls {
|
|
|
64
97
|
const ctrl = old.options(names).onChange((value) => {
|
|
65
98
|
this.app.uiState.trackBody = value;
|
|
66
99
|
});
|
|
100
|
+
ctrl.domElement.title = old.domElement.title;
|
|
67
101
|
parent.insertBefore(ctrl.domElement, next);
|
|
68
102
|
if (!names.includes(ctrl.getValue())) ctrl.setValue("None");
|
|
69
103
|
this.trackBodyCtrl = ctrl;
|
|
@@ -223,26 +257,53 @@ export class UIControls {
|
|
|
223
257
|
}
|
|
224
258
|
|
|
225
259
|
// Only shown when at least one body ships a per-point similarity
|
|
226
|
-
// embedding (see Body.js's pointEmbedding / recolorBySimilarity)
|
|
227
|
-
//
|
|
228
|
-
// "similarity"
|
|
229
|
-
//
|
|
230
|
-
|
|
231
|
-
|
|
260
|
+
// embedding (see Body.js's pointEmbedding / recolorBySimilarity)
|
|
261
|
+
// or named color layers (Body.js's pointColorLayers). Point clicks
|
|
262
|
+
// only recolor by similarity once this is set to "similarity"
|
|
263
|
+
// (InteractionController's #handlePointClick); "pca" restores the
|
|
264
|
+
// static coloring, a layer name shows that layer on every body
|
|
265
|
+
// that has it.
|
|
266
|
+
const pointBodies = [...this.app.bodies.values()].filter(
|
|
267
|
+
(body) => body.pointEmbedding || body.pointColorLayers?.size
|
|
232
268
|
);
|
|
233
|
-
if (
|
|
269
|
+
if (pointBodies.length > 0) {
|
|
270
|
+
const layerNames = [
|
|
271
|
+
...new Set(pointBodies.flatMap((body) => [...body.pointColorLayers.keys()])),
|
|
272
|
+
];
|
|
273
|
+
const hasEmbedding = pointBodies.some((body) => body.pointEmbedding);
|
|
274
|
+
const modes = ["pca", ...layerNames, ...(hasEmbedding ? ["similarity"] : [])];
|
|
275
|
+
if (!modes.includes(this.app.uiState.pointColorMode)) {
|
|
276
|
+
this.app.uiState.pointColorMode = "pca";
|
|
277
|
+
}
|
|
278
|
+
const applyMode = (value) => {
|
|
279
|
+
if (value === "similarity") return; // waits for a click
|
|
280
|
+
pointBodies.forEach((body) =>
|
|
281
|
+
value === "pca" ? body.resetPointColors() : body.showColorLayer(value)
|
|
282
|
+
);
|
|
283
|
+
};
|
|
234
284
|
const pointColorControls = {
|
|
235
285
|
pointColorMode: this.app.uiState.pointColorMode,
|
|
286
|
+
linkPointSimilarity: this.app.uiState.linkPointSimilarity,
|
|
236
287
|
};
|
|
237
288
|
this.bodyFolder
|
|
238
|
-
.add(pointColorControls, "pointColorMode",
|
|
289
|
+
.add(pointColorControls, "pointColorMode", modes)
|
|
239
290
|
.name("Point Color Mode")
|
|
240
291
|
.onChange((value) => {
|
|
241
292
|
this.app.uiState.pointColorMode = value;
|
|
242
|
-
|
|
243
|
-
bodiesWithEmbedding.forEach((body) => body.resetPointColors());
|
|
244
|
-
}
|
|
293
|
+
applyMode(value);
|
|
245
294
|
});
|
|
295
|
+
applyMode(this.app.uiState.pointColorMode);
|
|
296
|
+
if (hasEmbedding) {
|
|
297
|
+
// A click recolors every body with the same point count by
|
|
298
|
+
// the clicked index -- meaningful when bodies share point
|
|
299
|
+
// order (e.g. one cloud's features from several models).
|
|
300
|
+
this.bodyFolder
|
|
301
|
+
.add(pointColorControls, "linkPointSimilarity")
|
|
302
|
+
.name("Link Similarity")
|
|
303
|
+
.onChange((value) => {
|
|
304
|
+
this.app.uiState.linkPointSimilarity = value;
|
|
305
|
+
});
|
|
306
|
+
}
|
|
246
307
|
}
|
|
247
308
|
|
|
248
309
|
// Only create toggles for attributes actually present in the loaded data.
|
|
@@ -469,6 +530,11 @@ export class UIControls {
|
|
|
469
530
|
this.cameraControls = cameraControls;
|
|
470
531
|
cameraFolder.close();
|
|
471
532
|
|
|
533
|
+
// Before Scene Info is added: its keys are free-form metadata.
|
|
534
|
+
for (const c of this.gui.controllersRecursive()) {
|
|
535
|
+
if (CONTROL_TIPS[c.property]) c.domElement.title = CONTROL_TIPS[c.property];
|
|
536
|
+
}
|
|
537
|
+
|
|
472
538
|
if (this.app.metadata && Object.keys(this.app.metadata).length > 0) {
|
|
473
539
|
this.metadataFolder = this.gui.addFolder("Scene Info");
|
|
474
540
|
|
|
@@ -759,6 +825,7 @@ export class UIControls {
|
|
|
759
825
|
this.app.uiState.terrainVisualizationModes = {};
|
|
760
826
|
}
|
|
761
827
|
this.app.uiState.terrainVisualizationModes[type] = visible;
|
|
828
|
+
if (type === "surface" && this.app.legend) this.app.legend.update();
|
|
762
829
|
}
|
|
763
830
|
}
|
|
764
831
|
|
|
@@ -27,7 +27,9 @@ export class Legend {
|
|
|
27
27
|
}
|
|
28
28
|
|
|
29
29
|
#updateTerrainLegend() {
|
|
30
|
-
|
|
30
|
+
// Only the surface is colored by the mode (wireframe/normals aren't).
|
|
31
|
+
const surfaceShown = this.app.uiState.terrainVisualizationModes?.surface ?? true;
|
|
32
|
+
if (!this.app.terrain || !surfaceShown) {
|
|
31
33
|
this.container.style.display = "none";
|
|
32
34
|
return;
|
|
33
35
|
}
|
|
@@ -107,7 +109,7 @@ export class Legend {
|
|
|
107
109
|
}
|
|
108
110
|
this.pointContainer.style.display = "flex";
|
|
109
111
|
// Stack above the terrain legend, or take its slot when there's none.
|
|
110
|
-
this.pointContainer.style.bottom = this.
|
|
112
|
+
this.pointContainer.style.bottom = this.container.style.display !== "none" ? "90px" : "20px";
|
|
111
113
|
// Fixed coolwarm/[-1,1], matching Body.recolorBySimilarity's own
|
|
112
114
|
// hardcoded colormap and cosine-similarity range.
|
|
113
115
|
this.#renderGradient(
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: simview
|
|
3
|
-
Version: 6.
|
|
3
|
+
Version: 6.4.0
|
|
4
4
|
Summary: THREE.js-based simulation visualization tool
|
|
5
5
|
Author-email: Jan Vlk <vlkjan6@fel.cvut.cz>, Ales Kucera <kuceral4@fel.cvut.cz>, David Korcak <david.korcak@gmail.com>
|
|
6
6
|
License-Expression: BSD-3-Clause
|
|
@@ -135,3 +135,18 @@ def test_create_terrain_without_embedding_map_key_is_none():
|
|
|
135
135
|
assert scene.model.terrain is not None
|
|
136
136
|
assert scene.model.terrain.embedding_data is None
|
|
137
137
|
assert scene.model.terrain.to_json()["embeddingData"] is None
|
|
138
|
+
|
|
139
|
+
|
|
140
|
+
def test_create_pointcloud_color_layers_roundtrip_and_validation():
|
|
141
|
+
points = torch.zeros(4, 3)
|
|
142
|
+
cls = torch.rand(4, 3)
|
|
143
|
+
body = SimViewBody.create_pointcloud("pts", points, color_layers={"class": cls})
|
|
144
|
+
assert _flat(body.shape["colorLayers"]["class"]) == pytest.approx(
|
|
145
|
+
cls.flatten().tolist()
|
|
146
|
+
)
|
|
147
|
+
with pytest.raises(ValueError, match="must have shape"):
|
|
148
|
+
SimViewBody.create_pointcloud(
|
|
149
|
+
"pts", points, color_layers={"class": torch.zeros(3, 3)}
|
|
150
|
+
)
|
|
151
|
+
with pytest.raises(ValueError, match="reserved"):
|
|
152
|
+
SimViewBody.create_pointcloud("pts", points, color_layers={"similarity": cls})
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{simview-6.3.1 → simview-6.4.0}/simview/static/lib/three-0.174.0/addons/controls/OrbitControls.js
RENAMED
|
File without changes
|
{simview-6.3.1 → simview-6.4.0}/simview/static/lib/three-0.174.0/addons/libs/lil-gui.module.min.js
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|