@konitif/viewer-3d 0.285.7 → 0.285.8
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.
- package/dist/renderer/CameraController.d.ts +3 -0
- package/dist/renderer/CameraController.d.ts.map +1 -1
- package/dist/renderer/CameraController.js +36 -24
- package/dist/renderer/CameraController.js.map +1 -1
- package/dist/renderer/CardinalGridLayer.d.ts +22 -0
- package/dist/renderer/CardinalGridLayer.d.ts.map +1 -0
- package/dist/renderer/CardinalGridLayer.js +127 -0
- package/dist/renderer/CardinalGridLayer.js.map +1 -0
- package/dist/renderer/OrthographicGroundReflection.d.ts +5 -0
- package/dist/renderer/OrthographicGroundReflection.d.ts.map +1 -0
- package/dist/renderer/OrthographicGroundReflection.js +58 -0
- package/dist/renderer/OrthographicGroundReflection.js.map +1 -0
- package/dist/renderer/SceneAstronomy.d.ts +34 -0
- package/dist/renderer/SceneAstronomy.d.ts.map +1 -0
- package/dist/renderer/SceneAstronomy.js +96 -0
- package/dist/renderer/SceneAstronomy.js.map +1 -0
- package/dist/renderer/SceneDayCycle.d.ts +21 -0
- package/dist/renderer/SceneDayCycle.d.ts.map +1 -0
- package/dist/renderer/SceneDayCycle.js +27 -0
- package/dist/renderer/SceneDayCycle.js.map +1 -0
- package/dist/renderer/SceneEnvironmentLayer.d.ts +26 -0
- package/dist/renderer/SceneEnvironmentLayer.d.ts.map +1 -0
- package/dist/renderer/SceneEnvironmentLayer.js +89 -0
- package/dist/renderer/SceneEnvironmentLayer.js.map +1 -0
- package/dist/renderer/Viewer3DRenderer.d.ts +24 -1
- package/dist/renderer/Viewer3DRenderer.d.ts.map +1 -1
- package/dist/renderer/Viewer3DRenderer.js +59 -9
- package/dist/renderer/Viewer3DRenderer.js.map +1 -1
- package/dist/renderer/VisualGroundLayer.d.ts.map +1 -1
- package/dist/renderer/VisualGroundLayer.js +37 -5
- package/dist/renderer/VisualGroundLayer.js.map +1 -1
- package/dist/renderer/index.d.ts +1 -0
- package/dist/renderer/index.d.ts.map +1 -1
- package/dist/renderer/index.js +1 -0
- package/dist/renderer/index.js.map +1 -1
- package/package.json +1 -1
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
import { ViewerCardinalGridLayer } from './CardinalGridLayer.js';
|
|
2
|
+
import { ViewerSceneEnvironmentLayer } from './SceneEnvironmentLayer.js';
|
|
1
3
|
import { measureViewerOperation } from './PerformanceObservation.js';
|
|
2
4
|
import { createViewerPhysicsFrameQuaternion, resolveViewerSceneYaw, projectViewerImpulseByFrame, projectViewerPointByFrame } from './physics/ViewerPhysicsFrame.js';
|
|
3
5
|
import { resolveViewerJointMapping, selectDirectViewerJointMappings } from './physics/ViewerJointResolution.js';
|
|
@@ -258,6 +260,9 @@ export class Viewer3D {
|
|
|
258
260
|
gridHelper = null;
|
|
259
261
|
visualGroundLayer = null;
|
|
260
262
|
keyLight = null;
|
|
263
|
+
cardinalGrid = null;
|
|
264
|
+
sceneDayCycle = null;
|
|
265
|
+
sceneFog = null;
|
|
261
266
|
trajectoryGroup = null;
|
|
262
267
|
contactPointGroup = null;
|
|
263
268
|
physicsDebugGroup = null;
|
|
@@ -701,6 +706,12 @@ export class Viewer3D {
|
|
|
701
706
|
}
|
|
702
707
|
this.scheduleLoop();
|
|
703
708
|
}
|
|
709
|
+
/** Signal a projection-only change made to caller-owned scene contributions.
|
|
710
|
+
* Uses the viewer's existing coalesced frame loop; does not advance simulation or transport.
|
|
711
|
+
*/
|
|
712
|
+
requestPresentationFrame() {
|
|
713
|
+
this.requestRender();
|
|
714
|
+
}
|
|
704
715
|
setStatsVisible(showStats) {
|
|
705
716
|
if (this.options.showStats === showStats) {
|
|
706
717
|
return;
|
|
@@ -730,6 +741,31 @@ export class Viewer3D {
|
|
|
730
741
|
this.globalRafProbeFrame = 0;
|
|
731
742
|
}
|
|
732
743
|
}
|
|
744
|
+
/** Set a static local solar time; the caller owns persistence and playback. */
|
|
745
|
+
setSceneTimeHours(timeHours) {
|
|
746
|
+
this.sceneDayCycle ??= new ViewerSceneEnvironmentLayer(this.scene, this.renderer, this.keyLight, () => this.requestRender(), this.options.transparent);
|
|
747
|
+
this.sceneDayCycle.setFog(this.sceneFog);
|
|
748
|
+
this.sceneDayCycle.setTime(timeHours);
|
|
749
|
+
}
|
|
750
|
+
/** A null density delegates to the environment. Manual density survives day/night and theme changes. */
|
|
751
|
+
setSceneFog(settings) {
|
|
752
|
+
this.sceneFog = settings ? { enabled: settings.enabled, density: typeof settings.density === 'number' && Number.isFinite(settings.density) ? Math.max(0, Math.min(.5, settings.density)) : null } : null;
|
|
753
|
+
if (this.sceneDayCycle)
|
|
754
|
+
this.sceneDayCycle.setFog(this.sceneFog);
|
|
755
|
+
else
|
|
756
|
+
this.updateVisualGroundEnvironment();
|
|
757
|
+
this.requestRender();
|
|
758
|
+
}
|
|
759
|
+
setCardinalGridVisible(visible) {
|
|
760
|
+
if (visible)
|
|
761
|
+
this.cardinalGrid ??= new ViewerCardinalGridLayer(this.scene, () => this.controls.target, this.renderer.domElement.parentElement ?? undefined);
|
|
762
|
+
else {
|
|
763
|
+
this.cardinalGrid?.dispose();
|
|
764
|
+
this.cardinalGrid = null;
|
|
765
|
+
}
|
|
766
|
+
this.requestRender();
|
|
767
|
+
}
|
|
768
|
+
clearSceneTimeHours() { this.sceneDayCycle?.dispose(); this.sceneDayCycle = null; this.applyTheme(); }
|
|
733
769
|
setGridVisible(showGrid) {
|
|
734
770
|
if (this.options.showGrid === showGrid) {
|
|
735
771
|
return;
|
|
@@ -3150,6 +3186,10 @@ export class Viewer3D {
|
|
|
3150
3186
|
this.requestRender();
|
|
3151
3187
|
}
|
|
3152
3188
|
destroy(options = {}) {
|
|
3189
|
+
this.cardinalGrid?.dispose();
|
|
3190
|
+
this.cardinalGrid = null;
|
|
3191
|
+
this.sceneDayCycle?.dispose();
|
|
3192
|
+
this.sceneDayCycle = null;
|
|
3153
3193
|
this.performanceObserver = null;
|
|
3154
3194
|
if (this.destroyed) {
|
|
3155
3195
|
return;
|
|
@@ -3316,14 +3356,14 @@ export class Viewer3D {
|
|
|
3316
3356
|
}
|
|
3317
3357
|
this.updateVisualGroundShadowCasters();
|
|
3318
3358
|
this.updateVisualGroundFocusTiltPasses();
|
|
3319
|
-
const fogEnabled = this.options.showVisualGround && (config?.components.fogFade ?? true);
|
|
3359
|
+
const fogEnabled = this.sceneFog?.enabled ?? (this.options.showVisualGround && (config?.components.fogFade ?? true));
|
|
3320
3360
|
if (!fogEnabled || this.options.transparent) {
|
|
3321
3361
|
this.scene.fog = null;
|
|
3322
3362
|
return;
|
|
3323
3363
|
}
|
|
3324
3364
|
const themeBackgroundColor = this.resolveThemeColor('--color-background-canvas', '#111722');
|
|
3325
3365
|
const fogColor = this.resolveVisualGroundSkyColor(themeBackgroundColor);
|
|
3326
|
-
const fogDensity = config?.fogDensity ?? DEFAULT_VIEWER_VISUAL_GROUND_CONFIG.fogDensity;
|
|
3366
|
+
const fogDensity = this.sceneFog?.density ?? config?.fogDensity ?? DEFAULT_VIEWER_VISUAL_GROUND_CONFIG.fogDensity;
|
|
3327
3367
|
if (this.scene.fog instanceof FogExp2) {
|
|
3328
3368
|
// Preserve the same fog authority while Viewer settings react. Replacing
|
|
3329
3369
|
// the object on every layer update invalidated material state and could
|
|
@@ -3445,6 +3485,7 @@ export class Viewer3D {
|
|
|
3445
3485
|
if (this.scene.fog instanceof FogExp2) {
|
|
3446
3486
|
this.scene.fog.color.copy(backgroundColor);
|
|
3447
3487
|
}
|
|
3488
|
+
this.sceneDayCycle?.apply();
|
|
3448
3489
|
if (!this.gridHelper) {
|
|
3449
3490
|
this.requestRender();
|
|
3450
3491
|
return;
|
|
@@ -3675,7 +3716,10 @@ export class Viewer3D {
|
|
|
3675
3716
|
this.perspectiveCamera.near = planes.near;
|
|
3676
3717
|
this.perspectiveCamera.far = planes.far;
|
|
3677
3718
|
this.perspectiveCamera.updateProjectionMatrix();
|
|
3678
|
-
|
|
3719
|
+
// Orthographic projection has no perspective eye plane. Include geometry
|
|
3720
|
+
// on both sides of the camera plane, especially the foreground floor
|
|
3721
|
+
// at grazing angles; otherwise it is sliced by a positive near plane.
|
|
3722
|
+
this.orthographicCamera.near = -planes.far;
|
|
3679
3723
|
this.orthographicCamera.far = planes.far;
|
|
3680
3724
|
this.orthographicCamera.updateProjectionMatrix();
|
|
3681
3725
|
}
|
|
@@ -4112,6 +4156,7 @@ export class Viewer3D {
|
|
|
4112
4156
|
measureViewerOperation(this.performanceObserver, 'viewer.draw.cpu', () => this.renderScene());
|
|
4113
4157
|
}
|
|
4114
4158
|
renderScene() {
|
|
4159
|
+
this.cardinalGrid?.update(this.camera);
|
|
4115
4160
|
this.projectComparisonSimulation();
|
|
4116
4161
|
if (this.observedRobotGhostMirrorsSimulatedRobot) {
|
|
4117
4162
|
this.syncObservedRobotGhostFromSimulatedRobot();
|
|
@@ -4827,6 +4872,11 @@ export class Viewer3D {
|
|
|
4827
4872
|
: undefined
|
|
4828
4873
|
};
|
|
4829
4874
|
}
|
|
4875
|
+
/** Invalidate the on-demand projection after caller-owned scene changes. */
|
|
4876
|
+
notifySceneChanged() {
|
|
4877
|
+
if (!this.destroyed)
|
|
4878
|
+
this.requestRender();
|
|
4879
|
+
}
|
|
4830
4880
|
requestRender() {
|
|
4831
4881
|
this.animationLoop.requestRender();
|
|
4832
4882
|
}
|
|
@@ -11076,8 +11126,8 @@ export class Viewer3D {
|
|
|
11076
11126
|
this.updateViewerDebugLayers({ poseHandles: true });
|
|
11077
11127
|
}
|
|
11078
11128
|
setCameraPose(position, target = this.options.cameraTarget, up) {
|
|
11079
|
-
if (this.options.cameraControlMode === 'orbit') {
|
|
11080
|
-
const worldUpPose = resolveWorldUpCameraPose(new Vector3(position.x, position.y, position.z), new Vector3(target.x, target.y, target.z),
|
|
11129
|
+
if (this.options.cameraControlMode === 'orbit' && !up) {
|
|
11130
|
+
const worldUpPose = resolveWorldUpCameraPose(new Vector3(position.x, position.y, position.z), new Vector3(target.x, target.y, target.z), this.camera.up);
|
|
11081
11131
|
this.cameraController.setCameraPose(this.serializeCameraVector(worldUpPose.position), target, this.serializeCameraVector(worldUpPose.up));
|
|
11082
11132
|
return;
|
|
11083
11133
|
}
|
|
@@ -11121,13 +11171,13 @@ export class Viewer3D {
|
|
|
11121
11171
|
z: Number(vector.z.toFixed(4))
|
|
11122
11172
|
};
|
|
11123
11173
|
}
|
|
11124
|
-
transitionCameraPose(position, target = this.options.cameraTarget, durationMs = 420, up) {
|
|
11125
|
-
if (this.options.cameraControlMode === 'orbit') {
|
|
11174
|
+
transitionCameraPose(position, target = this.options.cameraTarget, durationMs = 420, up, transition = {}) {
|
|
11175
|
+
if (this.options.cameraControlMode === 'orbit' && !transition.orbit) {
|
|
11126
11176
|
const worldUpPose = resolveWorldUpCameraPose(new Vector3(position.x, position.y, position.z), new Vector3(target.x, target.y, target.z), up ? new Vector3(up.x, up.y, up.z) : this.camera.up);
|
|
11127
|
-
this.cameraController.transitionCameraPose(this.serializeCameraVector(worldUpPose.position), target, durationMs, this.serializeCameraVector(worldUpPose.up));
|
|
11177
|
+
this.cameraController.transitionCameraPose(this.serializeCameraVector(worldUpPose.position), target, durationMs, this.serializeCameraVector(worldUpPose.up), transition);
|
|
11128
11178
|
return;
|
|
11129
11179
|
}
|
|
11130
|
-
this.cameraController.transitionCameraPose(position, target, durationMs, up);
|
|
11180
|
+
this.cameraController.transitionCameraPose(position, target, durationMs, up, transition);
|
|
11131
11181
|
}
|
|
11132
11182
|
resetCameraView(durationMs = 520) {
|
|
11133
11183
|
this.transitionCameraPose(VIEWER3D_DEFAULT_CAMERA_POSITION, VIEWER3D_DEFAULT_CAMERA_TARGET, durationMs, {
|