Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Orbit Around Cursor #3796

Closed
wants to merge 25 commits into from
Closed
Changes from 1 commit
Commits
Show all changes
25 commits
Select commit Hold shift + click to select a range
d012877
Updated the fly controller to use the z up basis
AlexandruPopovici Nov 21, 2024
e3a20bd
Fixed very important compiler error
AlexandruPopovici Nov 21, 2024
83063b0
Removed the annoying delay when first holding down WASD keys before m…
AlexandruPopovici Nov 21, 2024
59ae40d
Updated LegacyViewer to use the hybrid camera controls
AlexandruPopovici Nov 22, 2024
0b0cb8b
Merge branch 'main' into alex/advanced-camera-controls
AlexandruPopovici Nov 22, 2024
d1da6a7
Added big baker
AlexandruPopovici Nov 26, 2024
86d9d92
Merge branch 'main' into alex/advanced-camera-controls
AlexandruPopovici Nov 27, 2024
0ad6c44
Trying to figure out the essence of this
AlexandruPopovici Dec 11, 2024
d3d6d52
Partly works
AlexandruPopovici Dec 11, 2024
dabeefc
Pivotal coordinates now work
AlexandruPopovici Dec 18, 2024
fbab733
Smoothened out the math abit
AlexandruPopovici Dec 19, 2024
339cc79
Merged and removed debug spheres
AlexandruPopovici Dec 19, 2024
8fab92e
Fixed sandbox error
AlexandruPopovici Dec 19, 2024
28fff50
Enabled the pivot sphere
AlexandruPopovici Dec 20, 2024
688bb53
chore(viewer-lib): Merged with main
AlexandruPopovici Jan 9, 2025
8d6c043
Merge branch 'main' into alex/advanced-camera-controls
AlexandruPopovici Jan 9, 2025
3ded61f
feat(viewer-lib): Fixed some issues with orbiting around cursor
AlexandruPopovici Jan 9, 2025
a4dbf46
feat(viewer-lib): Updates to WEB-2313, orbiting around mouse cursor
AlexandruPopovici Jan 10, 2025
fc1cf44
feat(viewer-lib): Mouse orbiting now takes clipping planes into consi…
AlexandruPopovici Jan 10, 2025
8720874
chore(viewer-lib): Fixed sandbox build error
AlexandruPopovici Jan 10, 2025
b40e99e
fix(viewer-lib): Handled WEB-2449 and WEB-2450
AlexandruPopovici Jan 13, 2025
5de1bc5
fix(viewer-lib): Fixed the issue with focusing and other camera anima…
AlexandruPopovici Jan 13, 2025
cf0c1e8
Merge branch 'main' into alex/advanced-camera-controls
AlexandruPopovici Jan 14, 2025
572ae38
feat(viewer-lib): Updates on mouse orbiting:
AlexandruPopovici Jan 14, 2025
decb3d5
Merge branch 'main' into alex/advanced-camera-controls
AlexandruPopovici Jan 14, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Partly works
  • Loading branch information
AlexandruPopovici committed Dec 11, 2024
commit d3d6d5205b0018f340a2136d78da0a517e3b30fd
Original file line number Diff line number Diff line change
@@ -650,6 +650,9 @@ export class SmoothOrbitControls extends SpeckleControls {
protected hereToThereMat = new Matrix4()
protected lastPivot = new Vector3()
protected relativeCamPos = new Vector3()
protected lastInitialPosition = new Vector3()
protected lastQuat = new Quaternion()
protected lastDelta = new Vector3()

protected getPivotTransform(pivot: Vector3, quaternion: Quaternion) {
const translateToOrigin = new Matrix4().makeTranslation(
@@ -759,60 +762,36 @@ export class SmoothOrbitControls extends SpeckleControls {
const tPivot = this.getPivotTransform(pivotPoint, quaternion)
const invTPivot = new Matrix4().copy(tPivot).invert()

const deltaPivot = new Vector3().copy(pivotPoint).sub(prevPivotPoint)

const deltaPivot = new Vector3().copy(prevPivotPoint).sub(pivotPoint)
// console.log('Pivot -> ', pivotPoint)
// const tPrevPivot = this.getPivotTransform(prevPivotPoint, quaternion)
// const tPrevPointInv = new Matrix4().copy(tPrevPivot).invert()
// const objectToPrevPiot = new Vector3().copy(camPos).sub(prevPivotPoint)
// const objectToNewPivot = new Vector3().copy(camPos).sub(pivotPoint)
// const offset = new Vector3().copy(objectToPrevPiot).sub(objectToNewPivot)
const delta = new Vector3()
const dir = new Vector3().setFromMatrixColumn(
new Matrix4().makeRotationFromQuaternion(quaternion),
2
)
dir.multiplyScalar(this.spherical.radius)

if (deltaPivot.length() > 0) {
/** New pos */
const newPos = new Vector3()
newPos.sub(pivotPoint)
newPos.applyQuaternion(quaternion)
newPos.add(pivotPoint)

const dir = new Vector3().setFromMatrixColumn(
new Matrix4().makeRotationFromQuaternion(quaternion),
2
this.lastDelta.copy(pivotPoint)
this.lastDelta.add(
new Vector3()
.copy(pivotPoint)
.negate()
.applyQuaternion(new Quaternion().copy(quaternion).invert())
)
dir.multiplyScalar(this.spherical.radius)
newPos.add(dir)

/** Old Pos */
const oldPos = new Vector3()
oldPos.sub(prevPivotPoint)
oldPos.applyQuaternion(quaternion)
oldPos.add(prevPivotPoint)

const dir2 = new Vector3().setFromMatrixColumn(
new Matrix4().makeRotationFromQuaternion(quaternion),
2
)
dir2.multiplyScalar(this.spherical.radius)
oldPos.add(dir2)
delta.copy(oldPos.sub(newPos))
console.warn('Delta -> ', delta)
console.warn('Delta pivot -> ', deltaPivot)
this.lastInitialPosition.copy(this.lastDelta)
}
position.copy(new Vector3(0, 0, 0))

console.warn(this.lastInitialPosition)
position.copy(this.lastInitialPosition)
position.sub(pivotPoint)
position.applyQuaternion(quaternion)
position.add(pivotPoint)

const dir = new Vector3().setFromMatrixColumn(
new Matrix4().makeRotationFromQuaternion(quaternion),
2
)
dir.multiplyScalar(this.spherical.radius)
position.add(dir)
position.sub(delta)

// } else {
// position.copy(this.positionFromSpherical(this.spherical, this.origin))
// }

position.applyQuaternion(
new Quaternion().setFromRotationMatrix(this._basisTransform)
@@ -834,6 +813,7 @@ export class SmoothOrbitControls extends SpeckleControls {
}
this._targetCamera.position.copy(position)
this._targetCamera.quaternion.copy(quaternion)
this._targetCamera.updateMatrixWorld(true)
if (this._targetCamera instanceof PerspectiveCamera)
if (this._targetCamera.fov !== Math.exp(this.logFov)) {
this._targetCamera.fov = Math.exp(this.logFov)