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
ed75fe54
Commit
ed75fe54
authored
6 years ago
by
Alexander Rose
Browse files
Options
Downloads
Patches
Plain Diff
structure animation tweaks
parent
8c0a3a4a
Branches
Branches containing commit
Tags
Tags containing commit
No related merge requests found
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
package-lock.json
+0
-0
0 additions, 0 deletions
package-lock.json
src/mol-plugin/behavior/dynamic/animation.ts
+45
-26
45 additions, 26 deletions
src/mol-plugin/behavior/dynamic/animation.ts
src/mol-plugin/index.ts
+1
-1
1 addition, 1 deletion
src/mol-plugin/index.ts
with
46 additions
and
27 deletions
package-lock.json
-6 B (0%)
View file @
ed75fe54
File suppressed by a .gitattributes entry or the file's encoding is unsupported.
This diff is collapsed.
Click to expand it.
src/mol-plugin/behavior/dynamic/animation.ts
+
45
−
26
View file @
ed75fe54
...
@@ -11,74 +11,93 @@ import { degToRad } from 'mol-math/misc';
...
@@ -11,74 +11,93 @@ import { degToRad } from 'mol-math/misc';
import
{
Mat4
,
Vec3
}
from
'
mol-math/linear-algebra
'
;
import
{
Mat4
,
Vec3
}
from
'
mol-math/linear-algebra
'
;
import
{
PluginStateObject
as
SO
,
PluginStateObject
}
from
'
../../state/objects
'
;
import
{
PluginStateObject
as
SO
,
PluginStateObject
}
from
'
../../state/objects
'
;
import
{
StateSelection
}
from
'
mol-state/state/selection
'
;
import
{
StateSelection
}
from
'
mol-state/state/selection
'
;
import
{
StateObjectCell
,
State
}
from
'
mol-state
'
;
const
StructureAnimationParams
=
{
rotate
:
PD
.
Boolean
(
false
)
}
type
StructureAnimationProps
=
PD
.
Values
<
typeof
StructureAnimationParams
>
function
getRootStructure
(
root
:
StateObjectCell
,
state
:
State
)
{
let
parent
:
StateObjectCell
|
undefined
while
(
true
)
{
const
_parent
=
StateSelection
.
findAncestorOfType
(
state
.
tree
,
state
.
cells
,
root
.
transform
.
ref
,
[
PluginStateObject
.
Molecule
.
Structure
])
if
(
_parent
)
{
parent
=
_parent
root
=
_parent
}
else
{
break
}
}
if
(
!
parent
||
!
parent
.
obj
)
return
return
parent
.
obj
as
PluginStateObject
.
Molecule
.
Structure
}
// TODO this is just for testing purposes
// TODO this is just for testing purposes
export
const
Animation
=
PluginBehavior
.
create
<
{
play
:
boolean
}
>
({
export
const
Structure
Animation
=
PluginBehavior
.
create
<
StructureAnimationProps
>
({
name
:
'
animation
'
,
name
:
'
structure-
animation
'
,
display
:
{
name
:
'
Animation
'
,
group
:
'
Animation
'
},
display
:
{
name
:
'
Structure
Animation
'
,
group
:
'
Animation
'
},
ctor
:
class
extends
PluginBehavior
.
Handler
<
{
play
:
boolean
}
>
{
ctor
:
class
extends
PluginBehavior
.
Handler
<
StructureAnimationProps
>
{
private
tmpMat
=
Mat4
.
identity
()
private
tmpMat
=
Mat4
.
identity
()
private
rotMat
=
Mat4
.
identity
()
private
rotMat
=
Mat4
.
identity
()
private
transMat
=
Mat4
.
identity
()
private
transMat
=
Mat4
.
identity
()
private
a
nimMat
=
Mat4
.
identity
()
private
rotA
nimMat
=
Mat4
.
identity
()
private
transVec
=
Vec3
.
zero
()
private
transVec
=
Vec3
.
zero
()
private
rotVec
=
Vec3
.
create
(
0
,
1
,
0
)
private
rotVec
=
Vec3
.
create
(
0
,
1
,
0
)
private
animHandle
=
-
1
constructor
(
protected
ctx
:
PluginContext
,
protected
params
:
{
play
:
boolean
})
{
private
rotateAnimHandle
=
-
1
constructor
(
protected
ctx
:
PluginContext
,
protected
params
:
StructureAnimationProps
)
{
super
(
ctx
,
params
)
super
(
ctx
,
params
)
this
.
update
(
params
)
this
.
update
(
params
)
}
}
anim
ate
(
play
:
boolean
)
{
rot
ate
(
play
:
boolean
)
{
if
(
play
)
{
if
(
play
)
{
const
state
=
this
.
ctx
.
state
.
dataState
const
state
=
this
.
ctx
.
state
.
dataState
const
reprs
=
state
.
select
(
q
=>
q
.
rootsOfType
(
PluginStateObject
.
Molecule
.
Representation3D
));
const
reprs
=
state
.
select
(
q
=>
q
.
rootsOfType
(
PluginStateObject
.
Molecule
.
Representation3D
));
const
anim
=
(
t
:
number
)
=>
{
const
rotate
=
(
t
:
number
)
=>
{
const
rad
=
degToRad
((
t
/
10
)
%
360
)
const
rad
=
degToRad
((
t
/
10
)
%
360
)
Mat4
.
rotate
(
this
.
rotMat
,
this
.
tmpMat
,
rad
,
this
.
rotVec
)
Mat4
.
rotate
(
this
.
rotMat
,
this
.
tmpMat
,
rad
,
this
.
rotVec
)
for
(
const
r
of
reprs
)
{
for
(
const
r
of
reprs
)
{
if
(
!
SO
.
isRepresentation3D
(
r
.
obj
))
return
if
(
!
SO
.
isRepresentation3D
(
r
.
obj
))
return
const
parent
=
StateSelection
.
findAncestorOfType
(
state
.
tree
,
state
.
cells
,
r
.
transform
.
ref
,
[
PluginStateObject
.
Molecule
.
Structure
])
const
structure
=
getRootStructure
(
r
,
state
)
if
(
!
parent
||
!
parent
.
obj
)
continue
if
(
!
structure
)
continue
const
structure
=
parent
.
obj
as
PluginStateObject
.
Molecule
.
Structure
Vec3
.
negate
(
this
.
transVec
,
Vec3
.
copy
(
this
.
transVec
,
structure
.
data
.
boundary
.
sphere
.
center
))
Vec3
.
negate
(
this
.
transVec
,
Vec3
.
copy
(
this
.
transVec
,
structure
.
data
.
boundary
.
sphere
.
center
))
Mat4
.
fromTranslation
(
this
.
transMat
,
this
.
transVec
)
Mat4
.
fromTranslation
(
this
.
transMat
,
this
.
transVec
)
Mat4
.
mul
(
this
.
a
nimMat
,
this
.
rotMat
,
this
.
transMat
)
Mat4
.
mul
(
this
.
rotA
nimMat
,
this
.
rotMat
,
this
.
transMat
)
Vec3
.
copy
(
this
.
transVec
,
structure
.
data
.
boundary
.
sphere
.
center
)
Vec3
.
copy
(
this
.
transVec
,
structure
.
data
.
boundary
.
sphere
.
center
)
Mat4
.
fromTranslation
(
this
.
transMat
,
this
.
transVec
)
Mat4
.
fromTranslation
(
this
.
transMat
,
this
.
transVec
)
Mat4
.
mul
(
this
.
a
nimMat
,
this
.
transMat
,
this
.
a
nimMat
)
Mat4
.
mul
(
this
.
rotA
nimMat
,
this
.
transMat
,
this
.
rotA
nimMat
)
r
.
obj
.
data
.
setState
({
transform
:
this
.
a
nimMat
})
r
.
obj
.
data
.
setState
({
transform
:
this
.
rotA
nimMat
})
this
.
ctx
.
canvas3d
.
add
(
r
.
obj
.
data
)
this
.
ctx
.
canvas3d
.
add
(
r
.
obj
.
data
)
this
.
ctx
.
canvas3d
.
requestDraw
(
true
)
this
.
ctx
.
canvas3d
.
requestDraw
(
true
)
}
}
this
.
a
nimHandle
=
requestAnimationFrame
(
anim
)
this
.
rotateA
nimHandle
=
requestAnimationFrame
(
rotate
)
}
}
this
.
a
nimHandle
=
requestAnimationFrame
(
anim
)
this
.
rotateA
nimHandle
=
requestAnimationFrame
(
rotate
)
}
else
{
}
else
{
cancelAnimationFrame
(
this
.
a
nimHandle
)
cancelAnimationFrame
(
this
.
rotateA
nimHandle
)
}
}
}
}
register
():
void
{
}
register
():
void
{
}
update
(
p
:
{
play
:
boolean
}
)
{
update
(
p
:
StructureAnimationProps
)
{
let
updated
=
this
.
params
.
play
!==
p
.
play
let
updated
=
this
.
params
.
rotate
!==
p
.
rotate
this
.
params
.
play
=
p
.
play
this
.
params
.
rotate
=
p
.
rotate
if
(
updated
)
{
if
(
updated
)
{
this
.
anim
ate
(
this
.
params
.
play
)
this
.
rot
ate
(
this
.
params
.
rotate
)
}
}
return
updated
;
return
updated
;
}
}
unregister
()
{
unregister
()
{
cancelAnimationFrame
(
this
.
a
nimHandle
)
cancelAnimationFrame
(
this
.
rotateA
nimHandle
)
}
}
},
},
params
:
()
=>
({
params
:
()
=>
StructureAnimationParams
play
:
PD
.
Boolean
(
false
)
})
});
});
\ No newline at end of file
This diff is collapsed.
Click to expand it.
src/mol-plugin/index.ts
+
1
−
1
View file @
ed75fe54
...
@@ -37,7 +37,7 @@ const DefaultSpec: PluginSpec = {
...
@@ -37,7 +37,7 @@ const DefaultSpec: PluginSpec = {
PluginSpec
.
Behavior
(
PluginBehaviors
.
Representation
.
SelectLoci
),
PluginSpec
.
Behavior
(
PluginBehaviors
.
Representation
.
SelectLoci
),
PluginSpec
.
Behavior
(
PluginBehaviors
.
Representation
.
DefaultLociLabelProvider
),
PluginSpec
.
Behavior
(
PluginBehaviors
.
Representation
.
DefaultLociLabelProvider
),
PluginSpec
.
Behavior
(
PluginBehaviors
.
Camera
.
FocusLociOnSelect
,
{
minRadius
:
20
,
extraRadius
:
4
}),
PluginSpec
.
Behavior
(
PluginBehaviors
.
Camera
.
FocusLociOnSelect
,
{
minRadius
:
20
,
extraRadius
:
4
}),
PluginSpec
.
Behavior
(
PluginBehaviors
.
Animation
.
Animation
,
{
play
:
false
}),
PluginSpec
.
Behavior
(
PluginBehaviors
.
Animation
.
Structure
Animation
,
{
rotate
:
false
}),
PluginSpec
.
Behavior
(
PluginBehaviors
.
CustomProps
.
PDBeStructureQualityReport
,
{
autoAttach
:
true
}),
PluginSpec
.
Behavior
(
PluginBehaviors
.
CustomProps
.
PDBeStructureQualityReport
,
{
autoAttach
:
true
}),
PluginSpec
.
Behavior
(
PluginBehaviors
.
CustomProps
.
RCSBAssemblySymmetry
,
{
autoAttach
:
true
}),
PluginSpec
.
Behavior
(
PluginBehaviors
.
CustomProps
.
RCSBAssemblySymmetry
,
{
autoAttach
:
true
}),
]
]
...
...
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