Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
M
Molstar
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Container registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
GitLab community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Michal Malý
Molstar
Commits
cfe56709
Commit
cfe56709
authored
Mar 6, 2019
by
Alexander Rose
Browse files
Options
Downloads
Patches
Plain Diff
pinch input improvements and fixes
parent
76c9f6c2
Branches
Branches containing commit
Tags
Tags containing commit
No related merge requests found
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
src/mol-canvas3d/controls/trackball.ts
+4
-15
4 additions, 15 deletions
src/mol-canvas3d/controls/trackball.ts
src/mol-util/input/input-observer.ts
+9
-4
9 additions, 4 deletions
src/mol-util/input/input-observer.ts
with
13 additions
and
19 deletions
src/mol-canvas3d/controls/trackball.ts
+
4
−
15
View file @
cfe56709
/**
/**
* Copyright (c) 2018 mol* contributors, licensed under MIT, See LICENSE file for more info.
* Copyright (c) 2018
-2019
mol* contributors, licensed under MIT, See LICENSE file for more info.
*
*
* @author Alexander Rose <alexander.rose@weirdbyte.de>
* @author Alexander Rose <alexander.rose@weirdbyte.de>
* @author David Sehnal <david.sehnal@gmail.com>
* @author David Sehnal <david.sehnal@gmail.com>
...
@@ -73,9 +73,6 @@ namespace TrackballControls {
...
@@ -73,9 +73,6 @@ namespace TrackballControls {
const
_zoomStart
=
Vec2
.
zero
()
const
_zoomStart
=
Vec2
.
zero
()
const
_zoomEnd
=
Vec2
.
zero
()
const
_zoomEnd
=
Vec2
.
zero
()
let
_touchZoomDistanceStart
=
0
let
_touchZoomDistanceEnd
=
0
const
_panStart
=
Vec2
.
zero
()
const
_panStart
=
Vec2
.
zero
()
const
_panEnd
=
Vec2
.
zero
()
const
_panEnd
=
Vec2
.
zero
()
...
@@ -245,7 +242,7 @@ namespace TrackballControls {
...
@@ -245,7 +242,7 @@ namespace TrackballControls {
// listeners
// listeners
function
onDrag
({
pageX
,
pageY
,
buttons
,
modifiers
,
isStart
}:
DragInput
)
{
function
onDrag
({
pageX
,
pageY
,
buttons
,
isStart
}:
DragInput
)
{
_isInteracting
=
true
;
_isInteracting
=
true
;
if
(
isStart
)
{
if
(
isStart
)
{
...
@@ -279,17 +276,9 @@ namespace TrackballControls {
...
@@ -279,17 +276,9 @@ namespace TrackballControls {
_zoomStart
[
1
]
-=
dy
*
0.0001
_zoomStart
[
1
]
-=
dy
*
0.0001
}
}
function
onPinch
({
distance
,
isStart
}:
PinchInput
)
{
function
onPinch
({
fraction
}:
PinchInput
)
{
_isInteracting
=
true
;
_isInteracting
=
true
;
_zoomStart
[
1
]
-=
(
fraction
-
1
)
*
0.1
if
(
isStart
)
{
_touchZoomDistanceStart
=
distance
}
_touchZoomDistanceEnd
=
distance
const
factor
=
(
_touchZoomDistanceStart
/
_touchZoomDistanceEnd
)
*
p
.
zoomSpeed
_touchZoomDistanceStart
=
_touchZoomDistanceEnd
;
Vec3
.
scale
(
_eye
,
_eye
,
factor
)
}
}
function
dispose
()
{
function
dispose
()
{
...
...
This diff is collapsed.
Click to expand it.
src/mol-util/input/input-observer.ts
+
9
−
4
View file @
cfe56709
/**
/**
* Copyright (c) 2018 mol* contributors, licensed under MIT, See LICENSE file for more info.
* Copyright (c) 2018
-2019
mol* contributors, licensed under MIT, See LICENSE file for more info.
*
*
* @author Alexander Rose <alexander.rose@weirdbyte.de>
* @author Alexander Rose <alexander.rose@weirdbyte.de>
*/
*/
...
@@ -117,6 +117,7 @@ export type MoveInput = {
...
@@ -117,6 +117,7 @@ export type MoveInput = {
export
type
PinchInput
=
{
export
type
PinchInput
=
{
delta
:
number
,
delta
:
number
,
fraction
:
number
,
distance
:
number
,
distance
:
number
,
isStart
:
boolean
isStart
:
boolean
}
}
...
@@ -324,7 +325,9 @@ namespace InputObserver {
...
@@ -324,7 +325,9 @@ namespace InputObserver {
buttons
=
ButtonsType
.
Flag
.
Secondary
buttons
=
ButtonsType
.
Flag
.
Secondary
onPointerDown
(
getCenterTouch
(
ev
))
onPointerDown
(
getCenterTouch
(
ev
))
pinch
.
next
({
distance
:
lastTouchDistance
,
delta
:
0
,
isStart
:
true
})
const
touchDistance
=
getTouchDistance
(
ev
)
lastTouchDistance
=
touchDistance
pinch
.
next
({
distance
:
touchDistance
,
fraction
:
1
,
delta
:
0
,
isStart
:
true
})
}
}
}
}
...
@@ -338,12 +341,14 @@ namespace InputObserver {
...
@@ -338,12 +341,14 @@ namespace InputObserver {
onPointerMove
(
ev
.
touches
[
0
])
onPointerMove
(
ev
.
touches
[
0
])
}
else
if
(
ev
.
touches
.
length
>=
2
)
{
}
else
if
(
ev
.
touches
.
length
>=
2
)
{
const
touchDistance
=
getTouchDistance
(
ev
)
const
touchDistance
=
getTouchDistance
(
ev
)
if
(
lastTouchDistance
-
touchDistance
<
4
)
{
const
touchDelta
=
lastTouchDistance
-
touchDistance
if
(
Math
.
abs
(
touchDelta
)
<
4
)
{
buttons
=
ButtonsType
.
Flag
.
Secondary
buttons
=
ButtonsType
.
Flag
.
Secondary
onPointerMove
(
getCenterTouch
(
ev
))
onPointerMove
(
getCenterTouch
(
ev
))
}
else
{
}
else
{
pinch
.
next
({
pinch
.
next
({
delta
:
lastTouchDistance
-
touchDistance
,
delta
:
touchDelta
,
fraction
:
lastTouchDistance
/
touchDistance
,
distance
:
touchDistance
,
distance
:
touchDistance
,
isStart
:
false
isStart
:
false
})
})
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment