Cylinder frame: scene calculation and near hemisphere
Cylinder frame: scene calculation and near hemisphere
Module cylinderFrameTruth.ts. It defines two critical pieces for consistency between:
- visualizacion en 3D del cilindro (cilindro/cilindro-texturas)
- 3D editor (discs, ellipses, selection, and editing)
The goal is to use the same depth and the same visible hemisphere across the entire Hub app.
1. Problem it solves
When UI calculates:
- where cylinder center is in world space (for meshes and editing)
- which texture portion belongs to near/visible hemisphere (for UV cropping/selection)
it is easy for different components to use different conventions.
cylinderFrameTruth.ts unifies those conventions:
getCylinderFrameAtCaptureCenter(...)-> frame del cilindro en el centro de capturagetNearHemisphereBoundsFromBOHs(...)-> bounds{ uMin, uMax }del hemisferio cercano
2. getCylinderFrameAtCaptureCenter(...)
Signature (current implementation):
plane: GeologicalPlanemeasurement: { device_info?, compositeImageDepth?, boh_lines? } | null | undefinedtrajectory: TrajectoryPoint[]offset: {x,y,z}(offset del contexto de escena)profile: HUB_CYLINDER_DISPLAY_PROFILE.trajectory | HUB_CYLINDER_DISPLAY_PROFILE.editor3dfallbacks?: LiveMeasurementDepthFallbacks
What it does:
- Determines geometry by plane diameter:
diameterType = plane.cylinderDiameter ?? 'H'dims = getCylinderDimensions(diameterType)radiusMyheightMsalen dedims
- Calculates
targetDepthMusing depth truth module:getCylinderTrajectoryAnchorDepthM(plane, heightM, fallbacks)
- Calculates base world position/orientation:
calculateImagePositionOnTrajectory(targetDepthM, trajectory, offset, heightM)
- Canonicalizes BOH angles:
getCanonicalBohAnglesFromPlane(plane, measurement)
- Builds final quaternion:
calculateImageOrientation(axisDirWorld, line1Angle, line2Angle, profile.imageOrientationAxialDeg, result.azimuthAtDepth)
CylinderFrame output:
centerWorld: THREE.Vector3axisDirWorld: THREE.Vector3quaternionWorld: THREE.QuaternionradiusM: numberheightM: numbertargetDepthM: number
3. getNearHemisphereBoundsFromBOHs(...)
Input:
boh1AngleDegboh2AngleDegbohLocalOffsetDeg
Output:
{ uMin, uMax }in canonical U space (0..1) with wrap handling.
Concept:
- BOH angles define a "front" and an interval around center (using angular offset from
BOH_AXIAL_OFFSET_DEG + bohLocalOffsetDeg) - Two points are computed (2D XY) and used to extract a local front vector
- It converts to U (
atan2+ normalization) - It builds a total 0.5-wide window (0.25 each side in U)
In practice:
FieldCylinderWithData/FieldCaptureView3D/FullscreenCylinderEditor3D- used to apply crops or bounds when selection/editing is restricted to near hemisphere
4. Validation checklist
- Select a measurement with visible BOHs:
- verify
uMin/uMaxcovers the same side as camera view
- verify
- Edit discs/ellipses:
- verify editing does not jump to far-side areas when it should not
- Depth fallback cases:
- when
captureDepthCenteris missing, verify cylinder anchor stays stable across views
- when