Skip to content

Commit

Permalink
refactor(#4): remove camera pivot coordinates
Browse files Browse the repository at this point in the history
  • Loading branch information
franmagn committed Oct 15, 2025
1 parent 8b701d3 commit 7d804b7
Showing 1 changed file with 6 additions and 25 deletions.
31 changes: 6 additions & 25 deletions src/AnnotationControl/annotationPanel.js
Original file line number Diff line number Diff line change
Expand Up @@ -260,11 +260,8 @@ export function initAnnotationsPanel(viewer) {
viewer.scene.view &&
typeof viewer.scene.view.setView === 'function'
) {
const target =
annPos ||
vecToArray(ann.cameraTarget) ||
viewer.scene.view.getPivot()
viewer.scene.view.setView(camPos, target, 1000) //animation duration in ms
const target = annPos || null
viewer.scene.view.setView(camPos, target, 1000) // animation duration in ms
}
}
row.appendChild(jumpBtn)
Expand Down Expand Up @@ -360,9 +357,6 @@ export function initAnnotationsPanel(viewer) {
const cam = vecToArray(
ann.cameraPosition || ann.camera_position || ann.cameraPos
)
const camTarget = vecToArray(
ann.cameraTarget || ann.camera_target || ann.cameraPivot
)

// Start with serialized position, then prefer the live object's current position
let pointPos = vecToArray(
Expand All @@ -385,13 +379,13 @@ export function initAnnotationsPanel(viewer) {
const PLACEHOLDER_POS = [589748.27, 231444.54, 753.675]
if (pointPos && approxEqual(pointPos, PLACEHOLDER_POS)) pointPos = null

if (cam || camTarget || pointPos) {
if (cam || pointPos) {
const info = document.createElement('div')
info.className = 'annotation-info'
info.style.fontSize = '0.8em'
info.style.marginLeft = '8px'
const fmt = (v) => (v ? v.map((c) => Number(c).toFixed(3)).join(', ') : '—')
info.innerHTML = `Camera coordinates: ${fmt(cam)}<br/>Pivot coordinates: ${fmt(camTarget)}<br/>Saved Point coordinates: ${fmt(pointPos)}`
info.innerHTML = `Camera coordinates: ${fmt(cam)}<br/>Saved Point coordinates: ${fmt(pointPos)}`
row.appendChild(info)
}
} catch (e) {
Expand Down Expand Up @@ -616,9 +610,8 @@ export function initAnnotationsPanel(viewer) {
if (annotationHeader && annotationHeader.nextElementSibling) {
$(annotationHeader.nextElementSibling).slideDown()
}
// Capture current camera view (position + pivot) at the moment the user clicks Add
let camPos = null
let camTarget = null
// Capture current camera view (position) at the moment the user clicks Add
let camPos = null
try {
if (viewer && viewer.scene && viewer.scene.view) {
camPos =
Expand All @@ -632,17 +625,6 @@ export function initAnnotationsPanel(viewer) {
viewer.scene.view.position.z
]
: null
camTarget =
viewer.scene.view.getPivot &&
typeof viewer.scene.view.getPivot === 'function'
? viewer.scene.view.getPivot().toArray
? viewer.scene.view.getPivot().toArray()
: [
viewer.scene.view.getPivot().x,
viewer.scene.view.getPivot().y,
viewer.scene.view.getPivot().z
]
: null
}
} catch (e) {
console.warn('Could not read current view for annotation', e)
Expand Down Expand Up @@ -677,7 +659,6 @@ export function initAnnotationsPanel(viewer) {
// Persist captured camera info on the annotation object so it will be available in the jsTree node data
try {
if (camPos) annotation.cameraPosition = camPos
if (camTarget) annotation.cameraTarget = camTarget
} catch (e) {
console.warn('Could not attach camera info to annotation', e)
}
Expand Down

0 comments on commit 7d804b7

Please sign in to comment.