@konitif/viewer-3d 0.284.1

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.
Files changed (175) hide show
  1. package/LICENSE.md +21 -0
  2. package/README.md +34 -0
  3. package/dist/balanceFootprintDefinition.d.ts +7 -0
  4. package/dist/balanceFootprintDefinition.d.ts.map +1 -0
  5. package/dist/balanceFootprintDefinition.js +2 -0
  6. package/dist/balanceFootprintDefinition.js.map +1 -0
  7. package/dist/diagnosticContactDefinition.d.ts +7 -0
  8. package/dist/diagnosticContactDefinition.d.ts.map +1 -0
  9. package/dist/diagnosticContactDefinition.js +2 -0
  10. package/dist/diagnosticContactDefinition.js.map +1 -0
  11. package/dist/handTipDefinition.d.ts +13 -0
  12. package/dist/handTipDefinition.d.ts.map +1 -0
  13. package/dist/handTipDefinition.js +2 -0
  14. package/dist/handTipDefinition.js.map +1 -0
  15. package/dist/index.d.ts +41 -0
  16. package/dist/index.d.ts.map +1 -0
  17. package/dist/index.js +19 -0
  18. package/dist/index.js.map +1 -0
  19. package/dist/jointHandleDefinition.d.ts +23 -0
  20. package/dist/jointHandleDefinition.d.ts.map +1 -0
  21. package/dist/jointHandleDefinition.js +2 -0
  22. package/dist/jointHandleDefinition.js.map +1 -0
  23. package/dist/ledPlacementDefinition.d.ts +38 -0
  24. package/dist/ledPlacementDefinition.d.ts.map +1 -0
  25. package/dist/ledPlacementDefinition.js +2 -0
  26. package/dist/ledPlacementDefinition.js.map +1 -0
  27. package/dist/ledReferenceFrame.d.ts +26 -0
  28. package/dist/ledReferenceFrame.d.ts.map +1 -0
  29. package/dist/ledReferenceFrame.js +2 -0
  30. package/dist/ledReferenceFrame.js.map +1 -0
  31. package/dist/ledRingCalibration.d.ts +22 -0
  32. package/dist/ledRingCalibration.d.ts.map +1 -0
  33. package/dist/ledRingCalibration.js +2 -0
  34. package/dist/ledRingCalibration.js.map +1 -0
  35. package/dist/renderer/AnimationLoop.d.ts +18 -0
  36. package/dist/renderer/AnimationLoop.d.ts.map +1 -0
  37. package/dist/renderer/AnimationLoop.js +39 -0
  38. package/dist/renderer/AnimationLoop.js.map +1 -0
  39. package/dist/renderer/CameraController.d.ts +154 -0
  40. package/dist/renderer/CameraController.d.ts.map +1 -0
  41. package/dist/renderer/CameraController.js +469 -0
  42. package/dist/renderer/CameraController.js.map +1 -0
  43. package/dist/renderer/NavigationPhysicsObservation.d.ts +25 -0
  44. package/dist/renderer/NavigationPhysicsObservation.d.ts.map +1 -0
  45. package/dist/renderer/NavigationPhysicsObservation.js +81 -0
  46. package/dist/renderer/NavigationPhysicsObservation.js.map +1 -0
  47. package/dist/renderer/ObservedRobotGroundingProjection.d.ts +206 -0
  48. package/dist/renderer/ObservedRobotGroundingProjection.d.ts.map +1 -0
  49. package/dist/renderer/ObservedRobotGroundingProjection.js +522 -0
  50. package/dist/renderer/ObservedRobotGroundingProjection.js.map +1 -0
  51. package/dist/renderer/ObservedRobotPresentationBuffer.d.ts +71 -0
  52. package/dist/renderer/ObservedRobotPresentationBuffer.d.ts.map +1 -0
  53. package/dist/renderer/ObservedRobotPresentationBuffer.js +226 -0
  54. package/dist/renderer/ObservedRobotPresentationBuffer.js.map +1 -0
  55. package/dist/renderer/PerformanceMonitor.d.ts +38 -0
  56. package/dist/renderer/PerformanceMonitor.d.ts.map +1 -0
  57. package/dist/renderer/PerformanceMonitor.js +84 -0
  58. package/dist/renderer/PerformanceMonitor.js.map +1 -0
  59. package/dist/renderer/ProjectileInteraction.d.ts +57 -0
  60. package/dist/renderer/ProjectileInteraction.d.ts.map +1 -0
  61. package/dist/renderer/ProjectileInteraction.js +152 -0
  62. package/dist/renderer/ProjectileInteraction.js.map +1 -0
  63. package/dist/renderer/RobotComparisonVisibilityTransition.d.ts +12 -0
  64. package/dist/renderer/RobotComparisonVisibilityTransition.d.ts.map +1 -0
  65. package/dist/renderer/RobotComparisonVisibilityTransition.js +23 -0
  66. package/dist/renderer/RobotComparisonVisibilityTransition.js.map +1 -0
  67. package/dist/renderer/RobotPoseTransition.d.ts +34 -0
  68. package/dist/renderer/RobotPoseTransition.d.ts.map +1 -0
  69. package/dist/renderer/RobotPoseTransition.js +66 -0
  70. package/dist/renderer/RobotPoseTransition.js.map +1 -0
  71. package/dist/renderer/RobotPostureCompensation.d.ts +31 -0
  72. package/dist/renderer/RobotPostureCompensation.d.ts.map +1 -0
  73. package/dist/renderer/RobotPostureCompensation.js +60 -0
  74. package/dist/renderer/RobotPostureCompensation.js.map +1 -0
  75. package/dist/renderer/SelectionController.d.ts +24 -0
  76. package/dist/renderer/SelectionController.d.ts.map +1 -0
  77. package/dist/renderer/SelectionController.js +68 -0
  78. package/dist/renderer/SelectionController.js.map +1 -0
  79. package/dist/renderer/TemporalProjectionModel.d.ts +71 -0
  80. package/dist/renderer/TemporalProjectionModel.d.ts.map +1 -0
  81. package/dist/renderer/TemporalProjectionModel.js +363 -0
  82. package/dist/renderer/TemporalProjectionModel.js.map +1 -0
  83. package/dist/renderer/Viewer3DRenderer.d.ts +1137 -0
  84. package/dist/renderer/Viewer3DRenderer.d.ts.map +1 -0
  85. package/dist/renderer/Viewer3DRenderer.js +10655 -0
  86. package/dist/renderer/Viewer3DRenderer.js.map +1 -0
  87. package/dist/renderer/ViewerExperimentCollector.d.ts +27 -0
  88. package/dist/renderer/ViewerExperimentCollector.d.ts.map +1 -0
  89. package/dist/renderer/ViewerExperimentCollector.js +2 -0
  90. package/dist/renderer/ViewerExperimentCollector.js.map +1 -0
  91. package/dist/renderer/ViewerExperimentPort.d.ts +19 -0
  92. package/dist/renderer/ViewerExperimentPort.d.ts.map +1 -0
  93. package/dist/renderer/ViewerExperimentPort.js +2 -0
  94. package/dist/renderer/ViewerExperimentPort.js.map +1 -0
  95. package/dist/renderer/ViewerFrameSignals.d.ts +13 -0
  96. package/dist/renderer/ViewerFrameSignals.d.ts.map +1 -0
  97. package/dist/renderer/ViewerFrameSignals.js +73 -0
  98. package/dist/renderer/ViewerFrameSignals.js.map +1 -0
  99. package/dist/renderer/ViewerHistoryData.d.ts +59 -0
  100. package/dist/renderer/ViewerHistoryData.d.ts.map +1 -0
  101. package/dist/renderer/ViewerHistoryData.js +2 -0
  102. package/dist/renderer/ViewerHistoryData.js.map +1 -0
  103. package/dist/renderer/ViewerHistoryPort.d.ts +15 -0
  104. package/dist/renderer/ViewerHistoryPort.d.ts.map +1 -0
  105. package/dist/renderer/ViewerHistoryPort.js +2 -0
  106. package/dist/renderer/ViewerHistoryPort.js.map +1 -0
  107. package/dist/renderer/ViewerIncarnationHealth.d.ts +14 -0
  108. package/dist/renderer/ViewerIncarnationHealth.d.ts.map +1 -0
  109. package/dist/renderer/ViewerIncarnationHealth.js +13 -0
  110. package/dist/renderer/ViewerIncarnationHealth.js.map +1 -0
  111. package/dist/renderer/ViewerInputBindings.d.ts +19 -0
  112. package/dist/renderer/ViewerInputBindings.d.ts.map +1 -0
  113. package/dist/renderer/ViewerInputBindings.js +44 -0
  114. package/dist/renderer/ViewerInputBindings.js.map +1 -0
  115. package/dist/renderer/ViewerMetadata.d.ts +11 -0
  116. package/dist/renderer/ViewerMetadata.d.ts.map +1 -0
  117. package/dist/renderer/ViewerMetadata.js +8 -0
  118. package/dist/renderer/ViewerMetadata.js.map +1 -0
  119. package/dist/renderer/ViewerPlaybackCompletionPolicy.d.ts +29 -0
  120. package/dist/renderer/ViewerPlaybackCompletionPolicy.d.ts.map +1 -0
  121. package/dist/renderer/ViewerPlaybackCompletionPolicy.js +27 -0
  122. package/dist/renderer/ViewerPlaybackCompletionPolicy.js.map +1 -0
  123. package/dist/renderer/ViewerProjectileParticleRenderer.d.ts +21 -0
  124. package/dist/renderer/ViewerProjectileParticleRenderer.d.ts.map +1 -0
  125. package/dist/renderer/ViewerProjectileParticleRenderer.js +134 -0
  126. package/dist/renderer/ViewerProjectileParticleRenderer.js.map +1 -0
  127. package/dist/renderer/ViewerResizePresentation.d.ts +16 -0
  128. package/dist/renderer/ViewerResizePresentation.d.ts.map +1 -0
  129. package/dist/renderer/ViewerResizePresentation.js +12 -0
  130. package/dist/renderer/ViewerResizePresentation.js.map +1 -0
  131. package/dist/renderer/ViewerTemporalProjectionExperimentAdapter.d.ts +34 -0
  132. package/dist/renderer/ViewerTemporalProjectionExperimentAdapter.d.ts.map +1 -0
  133. package/dist/renderer/ViewerTemporalProjectionExperimentAdapter.js +130 -0
  134. package/dist/renderer/ViewerTemporalProjectionExperimentAdapter.js.map +1 -0
  135. package/dist/renderer/ViewerTemporalScheduler.d.ts +6 -0
  136. package/dist/renderer/ViewerTemporalScheduler.d.ts.map +1 -0
  137. package/dist/renderer/ViewerTemporalScheduler.js +12 -0
  138. package/dist/renderer/ViewerTemporalScheduler.js.map +1 -0
  139. package/dist/renderer/VisualGroundLayer.d.ts +110 -0
  140. package/dist/renderer/VisualGroundLayer.d.ts.map +1 -0
  141. package/dist/renderer/VisualGroundLayer.js +576 -0
  142. package/dist/renderer/VisualGroundLayer.js.map +1 -0
  143. package/dist/renderer/displayFrameRate.d.ts +5 -0
  144. package/dist/renderer/displayFrameRate.d.ts.map +1 -0
  145. package/dist/renderer/displayFrameRate.js +23 -0
  146. package/dist/renderer/displayFrameRate.js.map +1 -0
  147. package/dist/renderer/index.d.ts +20 -0
  148. package/dist/renderer/index.d.ts.map +1 -0
  149. package/dist/renderer/index.js +18 -0
  150. package/dist/renderer/index.js.map +1 -0
  151. package/dist/renderer/physics/ViewerJointResolution.d.ts +19 -0
  152. package/dist/renderer/physics/ViewerJointResolution.d.ts.map +1 -0
  153. package/dist/renderer/physics/ViewerJointResolution.js +24 -0
  154. package/dist/renderer/physics/ViewerJointResolution.js.map +1 -0
  155. package/dist/renderer/physics/ViewerPhysicsFrame.d.ts +9 -0
  156. package/dist/renderer/physics/ViewerPhysicsFrame.d.ts.map +1 -0
  157. package/dist/renderer/physics/ViewerPhysicsFrame.js +26 -0
  158. package/dist/renderer/physics/ViewerPhysicsFrame.js.map +1 -0
  159. package/dist/renderer/physics/ViewerPhysicsJointMapping.d.ts +11 -0
  160. package/dist/renderer/physics/ViewerPhysicsJointMapping.d.ts.map +1 -0
  161. package/dist/renderer/physics/ViewerPhysicsJointMapping.js +20 -0
  162. package/dist/renderer/physics/ViewerPhysicsJointMapping.js.map +1 -0
  163. package/dist/renderer/physics/ViewerPhysicsMetadata.d.ts +20 -0
  164. package/dist/renderer/physics/ViewerPhysicsMetadata.d.ts.map +1 -0
  165. package/dist/renderer/physics/ViewerPhysicsMetadata.js +49 -0
  166. package/dist/renderer/physics/ViewerPhysicsMetadata.js.map +1 -0
  167. package/dist/renderer/robotViewerMotion.d.ts +49 -0
  168. package/dist/renderer/robotViewerMotion.d.ts.map +1 -0
  169. package/dist/renderer/robotViewerMotion.js +253 -0
  170. package/dist/renderer/robotViewerMotion.js.map +1 -0
  171. package/dist/supportDefinition.d.ts +11 -0
  172. package/dist/supportDefinition.d.ts.map +1 -0
  173. package/dist/supportDefinition.js +2 -0
  174. package/dist/supportDefinition.js.map +1 -0
  175. package/package.json +52 -0
@@ -0,0 +1,576 @@
1
+ import { Color, DoubleSide, FrontSide, Group, MathUtils, Mesh, MeshStandardMaterial, PlaneGeometry, ShaderMaterial, Vector2, Vector3 } from 'three';
2
+ import { Reflector } from 'three/examples/jsm/objects/Reflector.js';
3
+ /**
4
+ * Decides whether the planar reflection needs a new scene projection.
5
+ * The previously rendered texture remains valid between refreshes, so camera
6
+ * and timeline interactions do not need a second full scene render at 120 Hz.
7
+ */
8
+ export function shouldRefreshViewerGroundReflection({ forced, lastRefreshAt, minimumIntervalMs, now }) {
9
+ return forced || minimumIntervalMs <= 0 || now - lastRefreshAt >= minimumIntervalMs;
10
+ }
11
+ export const DEFAULT_VIEWER_VISUAL_GROUND_CONFIG = {
12
+ // Orthographic/isometric projections preserve their footprint with depth.
13
+ // The visual plane must therefore extend beyond the distance at which the
14
+ // exponential fog becomes opaque, otherwise its near edge remains visible.
15
+ size: 160,
16
+ tileSize: 0.5,
17
+ jointWidth: 0,
18
+ majorJointWidth: 0.003,
19
+ majorJointOpacity: 0.55,
20
+ variationStrength: 0.11,
21
+ surfaceOpacity: 1,
22
+ roughness: 0.58,
23
+ metalness: 0.04,
24
+ reflectionOpacity: 0.14,
25
+ reflectionResolution: 1024,
26
+ reflectionBlurRadius: 1.2,
27
+ // Keep the robot readable at working distance while absorbing the tile
28
+ // pattern before it reaches the horizon. The previous 0.068 density left a
29
+ // visible checker band between the ground and the sky on wide viewports.
30
+ fogDensity: 0.095,
31
+ components: {
32
+ tilePattern: true,
33
+ surfaceVariation: true,
34
+ fogFade: true,
35
+ receiveShadows: true,
36
+ reflection: true,
37
+ focusTilt: true
38
+ }
39
+ };
40
+ export const DEFAULT_VIEWER_VISUAL_GROUND_PALETTE = {
41
+ base: '#172c40',
42
+ alternate: '#203a50',
43
+ joint: '#102235',
44
+ majorJoint: '#afc7d5',
45
+ reflection: '#b6d1e2'
46
+ };
47
+ const VIEWER_GROUND_REFLECTION_GRAZING_FADE_OUT = 0.035;
48
+ const VIEWER_GROUND_REFLECTION_GRAZING_FADE_IN = 0.13;
49
+ /**
50
+ * Removes the planar mirror before its oblique clip plane becomes unstable at
51
+ * grazing incidence. The opaque visual ground remains continuous underneath.
52
+ */
53
+ export function resolveViewerGroundReflectionIncidenceOpacity(incidence) {
54
+ if (!Number.isFinite(incidence))
55
+ return 0;
56
+ return MathUtils.smoothstep(Math.abs(incidence), VIEWER_GROUND_REFLECTION_GRAZING_FADE_OUT, VIEWER_GROUND_REFLECTION_GRAZING_FADE_IN);
57
+ }
58
+ /**
59
+ * Pure visual projection of the viewer support plane.
60
+ *
61
+ * The layer owns no raycast, target, navigation, or command behavior. Its
62
+ * components can be disabled independently without changing scene authority.
63
+ */
64
+ export class VisualGroundLayer {
65
+ group = new Group();
66
+ config;
67
+ palette;
68
+ geometry;
69
+ reflectionGeometry;
70
+ surfaceMaterial;
71
+ surfaceMesh;
72
+ reflectionMesh;
73
+ reflectionMaterial;
74
+ reflectionMaterialVariants = new Map();
75
+ compiledUniforms = null;
76
+ reflectionMinimumRefreshIntervalMs = 0;
77
+ reflectionRefreshForced = true;
78
+ lastReflectionRefreshAt = Number.NEGATIVE_INFINITY;
79
+ constructor(config = {}, palette = {}) {
80
+ this.config = normalizeViewerVisualGroundConfig(config);
81
+ this.palette = normalizeViewerVisualGroundPalette(palette);
82
+ this.group.name = 'viewer-visual-ground-layer';
83
+ this.geometry = new PlaneGeometry(this.config.size, this.config.size, 1, 1);
84
+ this.geometry.rotateX(-Math.PI / 2);
85
+ this.surfaceMaterial = new MeshStandardMaterial({
86
+ color: '#ffffff',
87
+ opacity: this.config.surfaceOpacity,
88
+ transparent: this.config.surfaceOpacity < 1,
89
+ metalness: this.config.metalness,
90
+ roughness: this.config.roughness,
91
+ // The mirror camera lives below the support plane. Keeping the visual
92
+ // surface front-sided prevents it from occluding the reflected robot.
93
+ side: FrontSide
94
+ });
95
+ this.surfaceMaterial.name = 'viewer-visual-ground-surface';
96
+ this.surfaceMaterial.fog = this.config.components.fogFade;
97
+ // The decorative surface and the transparent reflection plane occupy the
98
+ // same visual support plane. A sub-millimetre world-space offset alone is
99
+ // not stable at grazing angles: depth quantization makes both fragments
100
+ // alternate while the camera moves. Push the opaque surface back in depth
101
+ // space and pull the reflection forward instead of increasing the visible
102
+ // gap below the robot feet.
103
+ this.surfaceMaterial.polygonOffset = true;
104
+ this.surfaceMaterial.polygonOffsetFactor = 1;
105
+ this.surfaceMaterial.polygonOffsetUnits = 1;
106
+ this.surfaceMaterial.onBeforeCompile = (shader) => {
107
+ const uniforms = createGroundUniforms(this.config, this.palette);
108
+ Object.assign(shader.uniforms, uniforms);
109
+ this.compiledUniforms = uniforms;
110
+ shader.vertexShader = injectGroundVertexShader(shader.vertexShader);
111
+ shader.fragmentShader = injectGroundFragmentShader(shader.fragmentShader);
112
+ };
113
+ this.surfaceMaterial.customProgramCacheKey = () => 'konitif-visual-ground-v3';
114
+ this.surfaceMesh = new Mesh(this.geometry, this.surfaceMaterial);
115
+ this.surfaceMesh.name = 'viewer-visual-ground-surface';
116
+ // Keep the visual surface immediately below the shared support plane.
117
+ // The previous 3 mm offset was visible in close/side views and made a
118
+ // correctly grounded robot appear to float before physics started.
119
+ this.surfaceMesh.position.y = -0.0004;
120
+ this.surfaceMesh.receiveShadow = this.config.components.receiveShadows;
121
+ this.surfaceMesh.renderOrder = 1;
122
+ this.group.add(this.surfaceMesh);
123
+ this.reflectionGeometry = new PlaneGeometry(this.config.size, this.config.size, 1, 1);
124
+ this.reflectionMesh = new Reflector(this.reflectionGeometry, {
125
+ clipBias: 0.002,
126
+ color: this.palette.reflection,
127
+ // Keep the reflection target bounded while antialiasing the reflected
128
+ // silhouette before the final Viewer post-processing pass.
129
+ multisample: 4,
130
+ textureHeight: this.config.reflectionResolution,
131
+ textureWidth: this.config.reflectionResolution
132
+ });
133
+ this.reflectionMesh.rotateX(-Math.PI / 2);
134
+ this.reflectionMaterial = this.reflectionMesh.material;
135
+ this.prepareReflectionMaterial();
136
+ this.prepareReflectionFacingPass();
137
+ this.reflectionMaterial.name = 'viewer-visual-ground-reflection';
138
+ this.reflectionMesh.name = 'viewer-visual-ground-reflection';
139
+ // Reflection remains above the decorative surface but below the physical
140
+ // support plane, avoiding both z-fighting and intersections with soles.
141
+ this.reflectionMesh.position.y = -0.0001;
142
+ this.reflectionMesh.renderOrder = 2;
143
+ this.reflectionMesh.visible = this.config.components.reflection;
144
+ this.group.add(this.reflectionMesh);
145
+ }
146
+ setVisible(visible) {
147
+ this.group.visible = visible;
148
+ if (visible) {
149
+ this.requestReflectionRefresh();
150
+ }
151
+ }
152
+ setReflectionMinimumRefreshInterval(minimumIntervalMs) {
153
+ this.reflectionMinimumRefreshIntervalMs = Number.isFinite(minimumIntervalMs)
154
+ ? Math.max(0, minimumIntervalMs)
155
+ : 0;
156
+ }
157
+ requestReflectionRefresh() {
158
+ this.reflectionRefreshForced = true;
159
+ }
160
+ setComponentVisible(componentId, visible) {
161
+ if (this.config.components[componentId] === visible) {
162
+ return;
163
+ }
164
+ this.config = {
165
+ ...this.config,
166
+ components: {
167
+ ...this.config.components,
168
+ [componentId]: visible
169
+ }
170
+ };
171
+ if (componentId === 'reflection') {
172
+ this.reflectionMesh.visible = visible;
173
+ if (visible) {
174
+ this.requestReflectionRefresh();
175
+ }
176
+ }
177
+ else if (componentId === 'receiveShadows') {
178
+ this.surfaceMesh.receiveShadow = visible;
179
+ }
180
+ else if (componentId === 'fogFade') {
181
+ this.surfaceMaterial.fog = visible;
182
+ this.surfaceMaterial.needsUpdate = true;
183
+ }
184
+ this.synchronizeUniforms();
185
+ this.requestReflectionRefresh();
186
+ }
187
+ configure(config) {
188
+ const previousFogFade = this.config.components.fogFade;
189
+ const nextConfig = normalizeViewerVisualGroundConfig({
190
+ ...this.config,
191
+ ...config,
192
+ components: {
193
+ ...this.config.components,
194
+ ...config.components
195
+ }
196
+ });
197
+ const sizeChanged = nextConfig.size !== this.config.size;
198
+ const reflectionResolutionChanged = nextConfig.reflectionResolution !== this.config.reflectionResolution;
199
+ this.config = nextConfig;
200
+ if (sizeChanged) {
201
+ const nextGeometry = new PlaneGeometry(this.config.size, this.config.size, 1, 1);
202
+ nextGeometry.rotateX(-Math.PI / 2);
203
+ this.surfaceMesh.geometry = nextGeometry;
204
+ this.geometry.dispose();
205
+ this.geometry = nextGeometry;
206
+ const nextReflectionGeometry = new PlaneGeometry(this.config.size, this.config.size, 1, 1);
207
+ this.reflectionMesh.geometry = nextReflectionGeometry;
208
+ this.reflectionGeometry.dispose();
209
+ this.reflectionGeometry = nextReflectionGeometry;
210
+ }
211
+ if (reflectionResolutionChanged) {
212
+ this.reflectionMesh
213
+ .getRenderTarget()
214
+ .setSize(this.config.reflectionResolution, this.config.reflectionResolution);
215
+ }
216
+ const surfaceTransparencyChanged = this.surfaceMaterial.transparent !== (this.config.surfaceOpacity < 1);
217
+ this.surfaceMaterial.opacity = this.config.surfaceOpacity;
218
+ this.surfaceMaterial.transparent = this.config.surfaceOpacity < 1;
219
+ this.surfaceMaterial.roughness = this.config.roughness;
220
+ this.surfaceMaterial.metalness = this.config.metalness;
221
+ this.reflectionMaterial.uniforms.konitifReflectionOpacity.value = this.config.reflectionOpacity;
222
+ this.reflectionMaterial.uniforms.konitifReflectionBlurRadius.value =
223
+ this.config.reflectionBlurRadius;
224
+ this.reflectionMaterial.uniforms.konitifReflectionTexelSize.value.setScalar(1 / this.config.reflectionResolution);
225
+ this.reflectionMesh.visible = this.config.components.reflection;
226
+ this.surfaceMesh.receiveShadow = this.config.components.receiveShadows;
227
+ this.surfaceMaterial.fog = this.config.components.fogFade;
228
+ if (previousFogFade !== this.config.components.fogFade) {
229
+ this.surfaceMaterial.needsUpdate = true;
230
+ }
231
+ if (surfaceTransparencyChanged) {
232
+ this.surfaceMaterial.needsUpdate = true;
233
+ }
234
+ this.synchronizeUniforms();
235
+ this.requestReflectionRefresh();
236
+ }
237
+ applyPalette(palette) {
238
+ this.palette = normalizeViewerVisualGroundPalette({ ...this.palette, ...palette });
239
+ this.reflectionMaterial.uniforms.color.value.copy(this.palette.reflection);
240
+ this.synchronizeUniforms();
241
+ this.requestReflectionRefresh();
242
+ }
243
+ getConfig() {
244
+ return {
245
+ ...this.config,
246
+ components: { ...this.config.components }
247
+ };
248
+ }
249
+ dispose() {
250
+ this.group.remove(this.surfaceMesh, this.reflectionMesh);
251
+ this.geometry.dispose();
252
+ this.reflectionGeometry.dispose();
253
+ this.surfaceMaterial.dispose();
254
+ this.reflectionMesh.dispose();
255
+ for (const variant of this.reflectionMaterialVariants.values()) {
256
+ variant.material.dispose();
257
+ }
258
+ this.reflectionMaterialVariants.clear();
259
+ this.compiledUniforms = null;
260
+ }
261
+ synchronizeUniforms() {
262
+ if (!this.compiledUniforms) {
263
+ this.surfaceMaterial.needsUpdate = true;
264
+ return;
265
+ }
266
+ const nextUniforms = createGroundUniforms(this.config, this.palette);
267
+ for (const key of Object.keys(nextUniforms)) {
268
+ const nextValue = nextUniforms[key].value;
269
+ const currentValue = this.compiledUniforms[key].value;
270
+ if (currentValue instanceof Color && nextValue instanceof Color) {
271
+ currentValue.copy(nextValue);
272
+ }
273
+ else {
274
+ this.compiledUniforms[key].value = nextValue;
275
+ }
276
+ }
277
+ }
278
+ prepareReflectionMaterial() {
279
+ this.reflectionMaterial.uniforms.konitifReflectionOpacity = {
280
+ value: this.config.reflectionOpacity
281
+ };
282
+ this.reflectionMaterial.uniforms.konitifReflectionTexelSize = {
283
+ value: new Vector2(1 / this.config.reflectionResolution, 1 / this.config.reflectionResolution)
284
+ };
285
+ this.reflectionMaterial.uniforms.konitifReflectionBlurRadius = {
286
+ value: this.config.reflectionBlurRadius
287
+ };
288
+ this.reflectionMaterial.fragmentShader = this.reflectionMaterial.fragmentShader
289
+ .replace('uniform sampler2D tDiffuse;', `uniform sampler2D tDiffuse;
290
+ uniform float konitifReflectionOpacity;
291
+ uniform vec2 konitifReflectionTexelSize;
292
+ uniform float konitifReflectionBlurRadius;`)
293
+ .replace('vec4 base = texture2DProj( tDiffuse, vUv );', `vec2 konitifReflectionSampleOffset =
294
+ konitifReflectionTexelSize * konitifReflectionBlurRadius * vUv.w;
295
+ vec4 base = texture2DProj( tDiffuse, vUv ) * 0.52;
296
+ base += texture2DProj(
297
+ tDiffuse,
298
+ vUv + vec4(konitifReflectionSampleOffset, 0.0, 0.0)
299
+ ) * 0.12;
300
+ base += texture2DProj(
301
+ tDiffuse,
302
+ vUv - vec4(konitifReflectionSampleOffset, 0.0, 0.0)
303
+ ) * 0.12;
304
+ base += texture2DProj(
305
+ tDiffuse,
306
+ vUv + vec4(konitifReflectionSampleOffset.x, -konitifReflectionSampleOffset.y, 0.0, 0.0)
307
+ ) * 0.12;
308
+ base += texture2DProj(
309
+ tDiffuse,
310
+ vUv + vec4(-konitifReflectionSampleOffset.x, konitifReflectionSampleOffset.y, 0.0, 0.0)
311
+ ) * 0.12;`)
312
+ .replace('gl_FragColor = vec4( blendOverlay( base.rgb, color ), 1.0 );', `gl_FragColor = vec4(
313
+ \t\tblendOverlay( base.rgb, color ),
314
+ \t\tkonitifReflectionOpacity
315
+ \t);`);
316
+ this.reflectionMaterial.transparent = true;
317
+ this.reflectionMaterial.depthWrite = false;
318
+ this.reflectionMaterial.polygonOffset = true;
319
+ this.reflectionMaterial.polygonOffsetFactor = -1;
320
+ this.reflectionMaterial.polygonOffsetUnits = -1;
321
+ this.reflectionMaterial.side = FrontSide;
322
+ this.reflectionMaterial.needsUpdate = true;
323
+ }
324
+ /**
325
+ * A planar mirror observes the scene from the opposite side of the support
326
+ * plane. Some robot assets contain mixed triangle winding, which is harmless
327
+ * from the authored camera but exposes missing or inside-out faces from the
328
+ * reflected camera. The reflection therefore receives cached, double-sided
329
+ * material variants while the primary scene keeps its original materials.
330
+ */
331
+ prepareReflectionFacingPass() {
332
+ const renderReflection = this.reflectionMesh.onBeforeRender;
333
+ const reflectorWorldPosition = new Vector3();
334
+ const cameraWorldPosition = new Vector3();
335
+ const reflectorNormal = new Vector3();
336
+ const cameraDirection = new Vector3();
337
+ this.reflectionMesh.onBeforeRender = (...args) => {
338
+ const camera = args[2];
339
+ this.reflectionMesh.getWorldPosition(reflectorWorldPosition);
340
+ camera.getWorldPosition(cameraWorldPosition);
341
+ reflectorNormal.set(0, 0, 1).transformDirection(this.reflectionMesh.matrixWorld);
342
+ cameraDirection.subVectors(cameraWorldPosition, reflectorWorldPosition).normalize();
343
+ const incidenceOpacity = resolveViewerGroundReflectionIncidenceOpacity(cameraDirection.dot(reflectorNormal));
344
+ this.reflectionMaterial.uniforms.konitifReflectionOpacity.value =
345
+ this.config.reflectionOpacity * incidenceOpacity;
346
+ if (incidenceOpacity <= 0) {
347
+ // Refresh once the mirror becomes stable again; never reuse a texture
348
+ // matrix captured on the opposite side of the grazing boundary.
349
+ this.reflectionRefreshForced = true;
350
+ return;
351
+ }
352
+ const now = performance.now();
353
+ if (!shouldRefreshViewerGroundReflection({
354
+ forced: this.reflectionRefreshForced,
355
+ lastRefreshAt: this.lastReflectionRefreshAt,
356
+ minimumIntervalMs: this.reflectionMinimumRefreshIntervalMs,
357
+ now
358
+ })) {
359
+ return;
360
+ }
361
+ const scene = args[1];
362
+ const assignments = [];
363
+ // Match the renderer's visibility traversal: hidden subtrees cannot
364
+ // contribute to this pass. Resolve their variants only when shown.
365
+ scene.traverseVisible((object) => {
366
+ if (object === this.surfaceMesh || object === this.reflectionMesh) {
367
+ return;
368
+ }
369
+ const mesh = object;
370
+ if (!mesh.isMesh || !mesh.material)
371
+ return;
372
+ const sourceMaterial = mesh.material;
373
+ const reflectionMaterial = Array.isArray(sourceMaterial)
374
+ ? sourceMaterial.map((material) => this.resolveReflectionMaterialVariant(material))
375
+ : this.resolveReflectionMaterialVariant(sourceMaterial);
376
+ if (reflectionMaterial === sourceMaterial) {
377
+ return;
378
+ }
379
+ assignments.push({ mesh, material: sourceMaterial });
380
+ mesh.material = reflectionMaterial;
381
+ });
382
+ try {
383
+ renderReflection.apply(this.reflectionMesh, args);
384
+ this.lastReflectionRefreshAt = now;
385
+ this.reflectionRefreshForced = false;
386
+ }
387
+ finally {
388
+ for (const assignment of assignments) {
389
+ assignment.mesh.material = assignment.material;
390
+ }
391
+ }
392
+ };
393
+ }
394
+ resolveReflectionMaterialVariant(source) {
395
+ if (source.side === DoubleSide) {
396
+ return source;
397
+ }
398
+ const current = this.reflectionMaterialVariants.get(source);
399
+ if (current?.sourceVersion === source.version) {
400
+ return current.material;
401
+ }
402
+ current?.material.dispose();
403
+ const material = source.clone();
404
+ material.name = source.name ? `${source.name}-reflection-facing` : 'reflection-facing';
405
+ material.side = DoubleSide;
406
+ material.needsUpdate = true;
407
+ this.reflectionMaterialVariants.set(source, {
408
+ material,
409
+ sourceVersion: source.version
410
+ });
411
+ return material;
412
+ }
413
+ }
414
+ export function normalizeViewerVisualGroundConfig(config = {}) {
415
+ const components = config.components ?? {};
416
+ return {
417
+ size: clampFinite(config.size, DEFAULT_VIEWER_VISUAL_GROUND_CONFIG.size, 2, 320),
418
+ tileSize: clampFinite(config.tileSize, DEFAULT_VIEWER_VISUAL_GROUND_CONFIG.tileSize, 0.05, 4),
419
+ jointWidth: clampFinite(config.jointWidth, DEFAULT_VIEWER_VISUAL_GROUND_CONFIG.jointWidth, 0, 0.2),
420
+ majorJointWidth: clampFinite(config.majorJointWidth, DEFAULT_VIEWER_VISUAL_GROUND_CONFIG.majorJointWidth, 0.001, 0.1),
421
+ majorJointOpacity: clampFinite(config.majorJointOpacity, DEFAULT_VIEWER_VISUAL_GROUND_CONFIG.majorJointOpacity, 0, 1),
422
+ variationStrength: clampFinite(config.variationStrength, DEFAULT_VIEWER_VISUAL_GROUND_CONFIG.variationStrength, 0, 0.5),
423
+ surfaceOpacity: clampFinite(config.surfaceOpacity, DEFAULT_VIEWER_VISUAL_GROUND_CONFIG.surfaceOpacity, 0, 1),
424
+ roughness: clampFinite(config.roughness, DEFAULT_VIEWER_VISUAL_GROUND_CONFIG.roughness, 0, 1),
425
+ metalness: clampFinite(config.metalness, DEFAULT_VIEWER_VISUAL_GROUND_CONFIG.metalness, 0, 1),
426
+ reflectionOpacity: clampFinite(config.reflectionOpacity, DEFAULT_VIEWER_VISUAL_GROUND_CONFIG.reflectionOpacity, 0, 0.5),
427
+ reflectionResolution: Math.round(clampFinite(config.reflectionResolution, DEFAULT_VIEWER_VISUAL_GROUND_CONFIG.reflectionResolution, 128, 2048)),
428
+ reflectionBlurRadius: clampFinite(config.reflectionBlurRadius, DEFAULT_VIEWER_VISUAL_GROUND_CONFIG.reflectionBlurRadius, 0, 2.5),
429
+ fogDensity: clampFinite(config.fogDensity, DEFAULT_VIEWER_VISUAL_GROUND_CONFIG.fogDensity, 0.001, 0.5),
430
+ components: {
431
+ tilePattern: components.tilePattern ?? DEFAULT_VIEWER_VISUAL_GROUND_CONFIG.components.tilePattern,
432
+ surfaceVariation: components.surfaceVariation ?? DEFAULT_VIEWER_VISUAL_GROUND_CONFIG.components.surfaceVariation,
433
+ fogFade: components.fogFade ?? DEFAULT_VIEWER_VISUAL_GROUND_CONFIG.components.fogFade,
434
+ receiveShadows: components.receiveShadows ?? DEFAULT_VIEWER_VISUAL_GROUND_CONFIG.components.receiveShadows,
435
+ reflection: components.reflection ?? DEFAULT_VIEWER_VISUAL_GROUND_CONFIG.components.reflection,
436
+ focusTilt: components.focusTilt ?? DEFAULT_VIEWER_VISUAL_GROUND_CONFIG.components.focusTilt
437
+ }
438
+ };
439
+ }
440
+ export function injectGroundVertexShader(source) {
441
+ return source
442
+ .replace('void main() {', 'varying vec2 vKonitifGroundPosition;\nvoid main() {')
443
+ .replace('#include <begin_vertex>', '#include <begin_vertex>\n\tvKonitifGroundPosition = position.xz;');
444
+ }
445
+ export function injectGroundFragmentShader(source) {
446
+ const declarations = `
447
+ varying vec2 vKonitifGroundPosition;
448
+ uniform float konitifGroundTilePatternEnabled;
449
+ uniform float konitifGroundSurfaceVariationEnabled;
450
+ uniform float konitifGroundSize;
451
+ uniform float konitifGroundTileSize;
452
+ uniform float konitifGroundJointWidth;
453
+ uniform float konitifGroundMajorJointWidth;
454
+ uniform float konitifGroundMajorJointOpacity;
455
+ uniform float konitifGroundVariationStrength;
456
+ uniform vec3 konitifGroundBaseColor;
457
+ uniform vec3 konitifGroundAlternateColor;
458
+ uniform vec3 konitifGroundJointColor;
459
+ uniform vec3 konitifGroundMajorJointColor;
460
+
461
+ float konitifGroundHash(vec2 cell) {
462
+ return fract(sin(dot(cell, vec2(127.1, 311.7))) * 43758.5453123);
463
+ }
464
+ `;
465
+ const diffuseProjection = `
466
+ vec2 konitifGroundTiles = (vKonitifGroundPosition + vec2(konitifGroundSize * 0.5)) / konitifGroundTileSize;
467
+ vec2 konitifGroundCell = floor(konitifGroundTiles);
468
+ float konitifGroundChecker = mod(konitifGroundCell.x + konitifGroundCell.y, 2.0);
469
+ float konitifGroundMicroVariation = (konitifGroundHash(konitifGroundCell) - 0.5) * 0.18;
470
+ float konitifGroundVariation = mix(0.0, 1.0, konitifGroundChecker);
471
+ konitifGroundVariation += konitifGroundMicroVariation * konitifGroundVariationStrength;
472
+ konitifGroundVariation = mix(0.5, konitifGroundVariation, konitifGroundSurfaceVariationEnabled);
473
+ vec3 konitifGroundTileColor = mix(
474
+ konitifGroundBaseColor,
475
+ konitifGroundAlternateColor,
476
+ clamp(konitifGroundVariation, 0.0, 1.0)
477
+ );
478
+ // Adjacent 50 cm tiles meet directly. Their checker tint retains the inner
479
+ // subdivision without cutting a dark gap through each one-metre group.
480
+ vec3 konitifGroundColor = konitifGroundTileColor;
481
+ // Shift the one-metre white frame by one tile on both axes.
482
+ vec2 konitifGroundMajorTiles = (
483
+ vKonitifGroundPosition + vec2(konitifGroundSize * 0.5 - konitifGroundTileSize)
484
+ ) / (konitifGroundTileSize * 2.0);
485
+ vec2 konitifGroundMajorLocal = fract(konitifGroundMajorTiles);
486
+ vec2 konitifGroundMajorEdgeDistance = min(
487
+ konitifGroundMajorLocal,
488
+ 1.0 - konitifGroundMajorLocal
489
+ );
490
+ float konitifGroundMajorJointRatio = konitifGroundMajorJointWidth / (konitifGroundTileSize * 2.0);
491
+ // Preserve each directional derivative until after antialiasing. Taking
492
+ // fwidth(min(x, y)) makes the gradient unstable where both line families
493
+ // cross and produces bright point-like coverage spikes at grazing angles.
494
+ vec2 konitifGroundMajorPixelFootprint = max(
495
+ fwidth(konitifGroundMajorEdgeDistance),
496
+ vec2(0.0001)
497
+ );
498
+ // Analytic one-pixel coverage. The transition width is derived exclusively
499
+ // from screen-space derivatives, so a near diagonal line cannot inherit a
500
+ // widening/stepping threshold from its authored world-space thickness.
501
+ vec2 konitifGroundMajorEdgeCoverage = clamp(
502
+ (
503
+ vec2(konitifGroundMajorJointRatio) - konitifGroundMajorEdgeDistance
504
+ ) / konitifGroundMajorPixelFootprint + vec2(0.5),
505
+ vec2(0.0),
506
+ vec2(1.0)
507
+ );
508
+ vec2 konitifGroundMajorAxisJoint =
509
+ konitifGroundMajorEdgeCoverage * konitifGroundMajorEdgeCoverage *
510
+ (vec2(3.0) - 2.0 * konitifGroundMajorEdgeCoverage);
511
+ // Once a metric line becomes sub-pixel, sampling the periodic pattern would
512
+ // create distant moire. Fade its coverage before that threshold; the fog then
513
+ // absorbs it instead of leaving a noisy horizon.
514
+ vec2 konitifGroundMajorPixelCoverage = clamp(
515
+ vec2(konitifGroundMajorJointRatio) / konitifGroundMajorPixelFootprint,
516
+ vec2(0.0),
517
+ vec2(1.0)
518
+ );
519
+ konitifGroundMajorAxisJoint *= smoothstep(
520
+ vec2(0.1),
521
+ vec2(0.8),
522
+ konitifGroundMajorPixelCoverage
523
+ );
524
+ // max() is an intensity-bounded union: a crossing is never brighter than
525
+ // either individual line.
526
+ float konitifGroundMajorJoint = max(
527
+ konitifGroundMajorAxisJoint.x,
528
+ konitifGroundMajorAxisJoint.y
529
+ );
530
+ konitifGroundMajorJoint *= konitifGroundTilePatternEnabled;
531
+ konitifGroundColor = mix(
532
+ konitifGroundColor,
533
+ konitifGroundMajorJointColor,
534
+ konitifGroundMajorJoint * konitifGroundMajorJointOpacity
535
+ );
536
+ vec4 diffuseColor = vec4(konitifGroundColor, opacity);
537
+ `;
538
+ return source
539
+ .replace('void main() {', `${declarations}\nvoid main() {`)
540
+ .replace('vec4 diffuseColor = vec4( diffuse, opacity );', diffuseProjection);
541
+ }
542
+ function createGroundUniforms(config, palette) {
543
+ return {
544
+ konitifGroundTilePatternEnabled: { value: config.components.tilePattern ? 1 : 0 },
545
+ konitifGroundSurfaceVariationEnabled: { value: config.components.surfaceVariation ? 1 : 0 },
546
+ konitifGroundSize: { value: config.size },
547
+ konitifGroundTileSize: { value: config.tileSize },
548
+ konitifGroundJointWidth: { value: config.jointWidth },
549
+ konitifGroundMajorJointWidth: { value: config.majorJointWidth },
550
+ konitifGroundMajorJointOpacity: { value: config.majorJointOpacity },
551
+ konitifGroundVariationStrength: { value: config.variationStrength },
552
+ konitifGroundBaseColor: { value: palette.base.clone() },
553
+ konitifGroundAlternateColor: { value: palette.alternate.clone() },
554
+ konitifGroundJointColor: { value: palette.joint.clone() },
555
+ konitifGroundMajorJointColor: { value: palette.majorJoint.clone() }
556
+ };
557
+ }
558
+ function normalizeViewerVisualGroundPalette(palette) {
559
+ return {
560
+ base: normalizePaletteColor(palette.base, DEFAULT_VIEWER_VISUAL_GROUND_PALETTE.base),
561
+ alternate: normalizePaletteColor(palette.alternate, DEFAULT_VIEWER_VISUAL_GROUND_PALETTE.alternate),
562
+ joint: normalizePaletteColor(palette.joint, DEFAULT_VIEWER_VISUAL_GROUND_PALETTE.joint),
563
+ majorJoint: normalizePaletteColor(palette.majorJoint, DEFAULT_VIEWER_VISUAL_GROUND_PALETTE.majorJoint),
564
+ reflection: normalizePaletteColor(palette.reflection, DEFAULT_VIEWER_VISUAL_GROUND_PALETTE.reflection)
565
+ };
566
+ }
567
+ function normalizePaletteColor(value, fallback) {
568
+ return value instanceof Color ? value.clone() : new Color(value ?? fallback);
569
+ }
570
+ function clampFinite(value, fallback, minimum, maximum) {
571
+ if (!Number.isFinite(value)) {
572
+ return fallback;
573
+ }
574
+ return Math.min(maximum, Math.max(minimum, value));
575
+ }
576
+ //# sourceMappingURL=VisualGroundLayer.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"VisualGroundLayer.js","sourceRoot":"","sources":["../../src/renderer/VisualGroundLayer.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,KAAK,EACL,UAAU,EACV,SAAS,EACT,KAAK,EACL,SAAS,EACT,IAAI,EACJ,oBAAoB,EACpB,aAAa,EACb,cAAc,EACd,OAAO,EACP,OAAO,EAKR,MAAM,OAAO,CAAC;AACf,OAAO,EAAE,SAAS,EAAE,MAAM,yCAAyC,CAAC;AA2DpE;;;;GAIG;AACH,MAAM,UAAU,mCAAmC,CAAC,EAClD,MAAM,EACN,aAAa,EACb,iBAAiB,EACjB,GAAG,EACmC;IACtC,OAAO,MAAM,IAAI,iBAAiB,IAAI,CAAC,IAAI,GAAG,GAAG,aAAa,IAAI,iBAAiB,CAAC;AACtF,CAAC;AAED,MAAM,CAAC,MAAM,mCAAmC,GAA6B;IAC3E,0EAA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AAK,CAAC,KAAK,EAAE,CAAC,CAAC,CAAC,IAAI,KAAK,CAAC,KAAK,IAAI,QAAQ,CAAC,CAAC;AAC/E,CAAC;AAED,SAAS,WAAW,CAAC,KAAyB,EAAE,QAAgB,EAAE,OAAe,EAAE,OAAe;IAChG,IAAI,CAAC,MAAM,CAAC,QAAQ,CAAC,KAAK,CAAC,EAAE,CAAC;QAC5B,OAAO,QAAQ,CAAC;IAClB,CAAC;IAED,OAAO,IAAI,CAAC,GAAG,CAAC,OAAO,EAAE,IAAI,CAAC,GAAG,CAAC,OAAO,EAAE,KAAe,CAAC,CAAC,CAAC;AAC/D,CAAC"}
@@ -0,0 +1,5 @@
1
+ export declare const DEFAULT_DISPLAY_FRAME_RATE_HZ = 60;
2
+ export declare function normalizeConfiguredDisplayFrameRate(value: number | undefined): number | null;
3
+ export declare function observeDisplayFrameRateCeiling(currentCeilingHz: number, observedFrameDurationMs: number): number;
4
+ export declare function resolveDisplayFrameRateTarget(configuredFrameRateHz: number | null, observedCeilingHz: number): number;
5
+ //# sourceMappingURL=displayFrameRate.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"displayFrameRate.d.ts","sourceRoot":"","sources":["../../src/renderer/displayFrameRate.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,6BAA6B,KAAK,CAAC;AAKhD,wBAAgB,mCAAmC,CAAC,KAAK,EAAE,MAAM,GAAG,SAAS,GAAG,MAAM,GAAG,IAAI,CAM5F;AAED,wBAAgB,8BAA8B,CAC5C,gBAAgB,EAAE,MAAM,EACxB,uBAAuB,EAAE,MAAM,GAC9B,MAAM,CAeR;AAED,wBAAgB,6BAA6B,CAC3C,qBAAqB,EAAE,MAAM,GAAG,IAAI,EACpC,iBAAiB,EAAE,MAAM,GACxB,MAAM,CAKR"}
@@ -0,0 +1,23 @@
1
+ export const DEFAULT_DISPLAY_FRAME_RATE_HZ = 60;
2
+ const MIN_DISPLAY_FRAME_RATE_HZ = 30;
3
+ const MAX_DISPLAY_FRAME_RATE_HZ = 240;
4
+ export function normalizeConfiguredDisplayFrameRate(value) {
5
+ if (typeof value !== 'number' || !Number.isFinite(value)) {
6
+ return null;
7
+ }
8
+ return Math.max(MIN_DISPLAY_FRAME_RATE_HZ, Math.min(MAX_DISPLAY_FRAME_RATE_HZ, value));
9
+ }
10
+ export function observeDisplayFrameRateCeiling(currentCeilingHz, observedFrameDurationMs) {
11
+ if (!Number.isFinite(observedFrameDurationMs) || observedFrameDurationMs < 1000 / MAX_DISPLAY_FRAME_RATE_HZ) {
12
+ return currentCeilingHz;
13
+ }
14
+ const observedFrameRateHz = 1000 / observedFrameDurationMs;
15
+ if (observedFrameRateHz < MIN_DISPLAY_FRAME_RATE_HZ) {
16
+ return currentCeilingHz;
17
+ }
18
+ return Math.max(currentCeilingHz, Math.min(MAX_DISPLAY_FRAME_RATE_HZ, Math.round(observedFrameRateHz)));
19
+ }
20
+ export function resolveDisplayFrameRateTarget(configuredFrameRateHz, observedCeilingHz) {
21
+ return configuredFrameRateHz ?? Math.max(MIN_DISPLAY_FRAME_RATE_HZ, Math.min(MAX_DISPLAY_FRAME_RATE_HZ, observedCeilingHz));
22
+ }
23
+ //# sourceMappingURL=displayFrameRate.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"displayFrameRate.js","sourceRoot":"","sources":["../../src/renderer/displayFrameRate.ts"],"names":[],"mappings":"AAAA,MAAM,CAAC,MAAM,6BAA6B,GAAG,EAAE,CAAC;AAEhD,MAAM,yBAAyB,GAAG,EAAE,CAAC;AACrC,MAAM,yBAAyB,GAAG,GAAG,CAAC;AAEtC,MAAM,UAAU,mCAAmC,CAAC,KAAyB;IAC3E,IAAI,OAAO,KAAK,KAAK,QAAQ,IAAI,CAAC,MAAM,CAAC,QAAQ,CAAC,KAAK,CAAC,EAAE,CAAC;QACzD,OAAO,IAAI,CAAC;IACd,CAAC;IAED,OAAO,IAAI,CAAC,GAAG,CAAC,yBAAyB,EAAE,IAAI,CAAC,GAAG,CAAC,y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