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
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Michal Malý
Molstar
Commits
8c0a3a4a
Commit
8c0a3a4a
authored
6 years ago
by
Alexander Rose
Browse files
Options
Downloads
Patches
Plain Diff
animate behavior for testing
parent
5f51f41e
No related branches found
No related tags found
No related merge requests found
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
src/mol-plugin/behavior.ts
+3
-1
3 additions, 1 deletion
src/mol-plugin/behavior.ts
src/mol-plugin/behavior/dynamic/animation.ts
+84
-0
84 additions, 0 deletions
src/mol-plugin/behavior/dynamic/animation.ts
src/mol-plugin/index.ts
+2
-0
2 additions, 0 deletions
src/mol-plugin/index.ts
with
89 additions
and
1 deletion
src/mol-plugin/behavior.ts
+
3
−
1
View file @
8c0a3a4a
...
...
@@ -14,6 +14,7 @@ import * as StaticMisc from './behavior/static/misc'
import
*
as
DynamicRepresentation
from
'
./behavior/dynamic/representation
'
import
*
as
DynamicCamera
from
'
./behavior/dynamic/camera
'
import
*
as
DynamicCustomProps
from
'
./behavior/dynamic/custom-props
'
import
*
as
DynamicAnimation
from
'
./behavior/dynamic/animation
'
export
const
BuiltInPluginBehaviors
=
{
State
:
StaticState
,
...
...
@@ -25,5 +26,6 @@ export const BuiltInPluginBehaviors = {
export
const
PluginBehaviors
=
{
Representation
:
DynamicRepresentation
,
Camera
:
DynamicCamera
,
CustomProps
:
DynamicCustomProps
CustomProps
:
DynamicCustomProps
,
Animation
:
DynamicAnimation
}
\ No newline at end of file
This diff is collapsed.
Click to expand it.
src/mol-plugin/behavior/dynamic/animation.ts
0 → 100644
+
84
−
0
View file @
8c0a3a4a
/**
* Copyright (c) 2018 mol* contributors, licensed under MIT, See LICENSE file for more info.
*
* @author Alexander Rose <alexander.rose@weirdbyte.de>
*/
import
{
PluginContext
}
from
'
mol-plugin/context
'
;
import
{
PluginBehavior
}
from
'
../behavior
'
;
import
{
ParamDefinition
as
PD
}
from
'
mol-util/param-definition
'
import
{
degToRad
}
from
'
mol-math/misc
'
;
import
{
Mat4
,
Vec3
}
from
'
mol-math/linear-algebra
'
;
import
{
PluginStateObject
as
SO
,
PluginStateObject
}
from
'
../../state/objects
'
;
import
{
StateSelection
}
from
'
mol-state/state/selection
'
;
// TODO this is just for testing purposes
export
const
Animation
=
PluginBehavior
.
create
<
{
play
:
boolean
}
>
({
name
:
'
animation
'
,
display
:
{
name
:
'
Animation
'
,
group
:
'
Animation
'
},
ctor
:
class
extends
PluginBehavior
.
Handler
<
{
play
:
boolean
}
>
{
private
tmpMat
=
Mat4
.
identity
()
private
rotMat
=
Mat4
.
identity
()
private
transMat
=
Mat4
.
identity
()
private
animMat
=
Mat4
.
identity
()
private
transVec
=
Vec3
.
zero
()
private
rotVec
=
Vec3
.
create
(
0
,
1
,
0
)
private
animHandle
=
-
1
constructor
(
protected
ctx
:
PluginContext
,
protected
params
:
{
play
:
boolean
})
{
super
(
ctx
,
params
)
this
.
update
(
params
)
}
animate
(
play
:
boolean
)
{
if
(
play
)
{
const
state
=
this
.
ctx
.
state
.
dataState
const
reprs
=
state
.
select
(
q
=>
q
.
rootsOfType
(
PluginStateObject
.
Molecule
.
Representation3D
));
const
anim
=
(
t
:
number
)
=>
{
const
rad
=
degToRad
((
t
/
10
)
%
360
)
Mat4
.
rotate
(
this
.
rotMat
,
this
.
tmpMat
,
rad
,
this
.
rotVec
)
for
(
const
r
of
reprs
)
{
if
(
!
SO
.
isRepresentation3D
(
r
.
obj
))
return
const
parent
=
StateSelection
.
findAncestorOfType
(
state
.
tree
,
state
.
cells
,
r
.
transform
.
ref
,
[
PluginStateObject
.
Molecule
.
Structure
])
if
(
!
parent
||
!
parent
.
obj
)
continue
const
structure
=
parent
.
obj
as
PluginStateObject
.
Molecule
.
Structure
Vec3
.
negate
(
this
.
transVec
,
Vec3
.
copy
(
this
.
transVec
,
structure
.
data
.
boundary
.
sphere
.
center
))
Mat4
.
fromTranslation
(
this
.
transMat
,
this
.
transVec
)
Mat4
.
mul
(
this
.
animMat
,
this
.
rotMat
,
this
.
transMat
)
Vec3
.
copy
(
this
.
transVec
,
structure
.
data
.
boundary
.
sphere
.
center
)
Mat4
.
fromTranslation
(
this
.
transMat
,
this
.
transVec
)
Mat4
.
mul
(
this
.
animMat
,
this
.
transMat
,
this
.
animMat
)
r
.
obj
.
data
.
setState
({
transform
:
this
.
animMat
})
this
.
ctx
.
canvas3d
.
add
(
r
.
obj
.
data
)
this
.
ctx
.
canvas3d
.
requestDraw
(
true
)
}
this
.
animHandle
=
requestAnimationFrame
(
anim
)
}
this
.
animHandle
=
requestAnimationFrame
(
anim
)
}
else
{
cancelAnimationFrame
(
this
.
animHandle
)
}
}
register
():
void
{
}
update
(
p
:
{
play
:
boolean
})
{
let
updated
=
this
.
params
.
play
!==
p
.
play
this
.
params
.
play
=
p
.
play
if
(
updated
)
{
this
.
animate
(
this
.
params
.
play
)
}
return
updated
;
}
unregister
()
{
cancelAnimationFrame
(
this
.
animHandle
)
}
},
params
:
()
=>
({
play
:
PD
.
Boolean
(
false
)
})
});
\ No newline at end of file
This diff is collapsed.
Click to expand it.
src/mol-plugin/index.ts
+
2
−
0
View file @
8c0a3a4a
...
...
@@ -2,6 +2,7 @@
* Copyright (c) 2018 mol* contributors, licensed under MIT, See LICENSE file for more info.
*
* @author David Sehnal <david.sehnal@gmail.com>
* @author Alexander Rose <alexander.rose@weirdbyte.de>
*/
import
{
PluginContext
}
from
'
./context
'
;
...
...
@@ -36,6 +37,7 @@ const DefaultSpec: PluginSpec = {
PluginSpec
.
Behavior
(
PluginBehaviors
.
Representation
.
SelectLoci
),
PluginSpec
.
Behavior
(
PluginBehaviors
.
Representation
.
DefaultLociLabelProvider
),
PluginSpec
.
Behavior
(
PluginBehaviors
.
Camera
.
FocusLociOnSelect
,
{
minRadius
:
20
,
extraRadius
:
4
}),
PluginSpec
.
Behavior
(
PluginBehaviors
.
Animation
.
Animation
,
{
play
:
false
}),
PluginSpec
.
Behavior
(
PluginBehaviors
.
CustomProps
.
PDBeStructureQualityReport
,
{
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