Skip to content

Implement camera state persistence#392

Closed
seonglae wants to merge 2 commits intomainfrom
codex/로컬스토리지에-위치-저장-후-글로-이동

Hidden character warning

The head ref may contain hidden characters: "codex/\ub85c\uceec\uc2a4\ud1a0\ub9ac\uc9c0\uc5d0-\uc704\uce58-\uc800\uc7a5-\ud6c4-\uae00\ub85c-\uc774\ub3d9"
Closed

Implement camera state persistence#392
seonglae wants to merge 2 commits intomainfrom
codex/로컬스토리지에-위치-저장-후-글로-이동

Conversation

@seonglae
Copy link
Member

@seonglae seonglae commented Jun 8, 2025

Summary

  • remember camera position and target in a localstorage-backed vuex module
  • restore camera location on load and keep it updated as user moves

Testing

  • npm run lint (fails: Parsing error: Unexpected token <)

https://chatgpt.com/codex/tasks/task_e_6844d54ed6b883279a4a925700324fa8

@vercel
Copy link

vercel bot commented Jun 8, 2025

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
pointland ✅ Ready (Inspect) Visit Preview 💬 Add feedback Jun 8, 2025 1:47pm

Copy link

@cursor cursor bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Bug: Camera Positioning and Event Listener Issues

The camera handling introduces several issues:
The saved camera position is restored twice, with the second restoration overriding the first, making it redundant. Additionally, the space.controls 'update' event listener is attached prematurely and never removed. This causes it to trigger during initial camera setup, saving incorrect intermediate states that overwrite the user's saved position. Furthermore, its continuous firing during camera movement leads to frequent, expensive localStorage writes, degrading performance and potentially causing memory leaks.

src/composables/usePointland.js#L26-L87

.then((pco) => loadPCO(pco, space))
.then(() => {
const saved = store.state.ls.camera
if (saved && saved.position && saved.target) {
space.controls.setLookAt(
saved.position[0],
saved.position[1],
saved.position[2],
saved.target[0],
saved.target[1],
saved.target[2],
false
)
}
})
space.controls.addEventListener('update', () => {
const pos = space.controls.getPosition()
const target = space.controls.getTarget()
store.commit('ls/setCamera', {
position: [pos.x, pos.y, pos.z],
target: [target.x, target.y, target.z],
})
})
return layerspace
}
function loadPCO(pco, space) {
store.commit('setLoading', false)
space.offset = [pco.position.x, pco.position.y, pco.position.z]
pco.translateX(-pco.position.x)
pco.translateY(-pco.position.y)
pco.translateZ(-pco.position.z)
const initialPosition = [8700, 3900, 255]
pco.translateX(-initialPosition[0])
pco.translateY(-initialPosition[1])
pco.translateZ(-initialPosition[2])
const initialRotation = [3, 1.178]
space.controls.rotateTo(initialRotation[0], initialRotation[1], true)
space.pointclouds.push(pco)
space.scene.add(pco)
pco.material.intensityRange = [0, 255]
pco.material.maxSize = 40
pco.material.minSize = 4
pco.material.size = 1
pco.material.shape = 1
pco.material.rgbBrightness = 0.05
pco.material.rgbContrast = 0.25
space.controls.setTarget(POSITION[0] + 7 * EPS, POSITION[1] - 1 * EPS, POSITION[2] - EPS, true)
const saved = store.state.ls.camera
if (saved && saved.position && saved.target) {
space.controls.setLookAt(
saved.position[0],
saved.position[1],
saved.position[2],
saved.target[0],
saved.target[1],
saved.target[2],
false
)
}

Fix in Cursor


BugBot free trial expires on June 13, 2025
You have used $0.00 of your $0.00 spend limit so far. Manage your spend limit in the Cursor dashboard.

Was this report helpful? Give feedback by reacting with 👍 or 👎

Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR implements camera state persistence by storing and restoring the camera's position and target using a localStorage-backed Vuex module. Key changes include:

  • Introducing a new Vuex state for camera data and a mutation to update it.
  • Restoring the camera state after the point cloud loads.
  • Continuously updating camera state on control events.

Reviewed Changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.

File Description
src/store/ls.js Added camera state structure and setCamera mutation.
src/composables/usePointland.js Integrated camera state restoration and update logic.

@seonglae seonglae self-assigned this Jun 9, 2025
@seonglae
Copy link
Member Author

Closing in favor of #514 which implements camera persistence for the updated React codebase. This PR was created for the old Nuxt2/Vue2 architecture.

@seonglae seonglae closed this Dec 31, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants