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
8b274c10
Commit
8b274c10
authored
6 years ago
by
David Sehnal
Browse files
Options
Downloads
Patches
Plain Diff
mol-plugin: targetted unwind, ability to auto start animation
parent
ca4a6337
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/state.ts
+7
-2
7 additions, 2 deletions
src/mol-plugin/state.ts
src/mol-plugin/state/animation/built-in.ts
+21
-8
21 additions, 8 deletions
src/mol-plugin/state/animation/built-in.ts
src/mol-plugin/state/animation/model.ts
+1
-1
1 addition, 1 deletion
src/mol-plugin/state/animation/model.ts
with
29 additions
and
11 deletions
src/mol-plugin/state.ts
+
7
−
2
View file @
8b274c10
...
...
@@ -44,12 +44,12 @@ class PluginState {
getSnapshot
(
params
?:
PluginState
.
GetSnapshotParams
):
PluginState
.
Snapshot
{
const
p
=
{
...
PluginState
.
DefaultGetSnapshotParams
,
...
params
};
console
.
log
(
p
.
animation
,
this
.
animation
.
getSnapshot
());
return
{
id
:
UUID
.
create22
(),
data
:
p
.
data
?
this
.
dataState
.
getSnapshot
()
:
void
0
,
behaviour
:
p
.
behavior
?
this
.
behaviorState
.
getSnapshot
()
:
void
0
,
animation
:
p
.
animation
?
this
.
animation
.
getSnapshot
()
:
void
0
,
startAnimation
:
p
.
startAnimation
?
!!
p
.
startAnimation
:
void
0
,
camera
:
p
.
camera
?
{
current
:
this
.
plugin
.
canvas3d
.
camera
.
getSnapshot
(),
transitionStyle
:
p
.
cameraTranstion
.
name
,
...
...
@@ -76,13 +76,16 @@ class PluginState {
this
.
animation
.
setSnapshot
(
snapshot
.
animation
);
}
if
(
snapshot
.
camera
)
{
await
PluginCommands
.
Camera
.
SetSnapshot
.
dispatch
(
this
.
plugin
,
{
PluginCommands
.
Camera
.
SetSnapshot
.
dispatch
(
this
.
plugin
,
{
snapshot
:
snapshot
.
camera
.
current
,
durationMs
:
snapshot
.
camera
.
transitionStyle
===
'
animate
'
?
snapshot
.
camera
.
transitionDurationInMs
:
void
0
});
}
if
(
snapshot
.
startAnimation
)
{
this
.
animation
.
start
();
}
}
dispose
()
{
...
...
@@ -120,6 +123,7 @@ namespace PluginState {
data
:
PD
.
Boolean
(
true
),
behavior
:
PD
.
Boolean
(
false
),
animation
:
PD
.
Boolean
(
true
),
startAnimation
:
PD
.
Boolean
(
false
),
canvas3d
:
PD
.
Boolean
(
true
),
camera
:
PD
.
Boolean
(
true
),
// TODO: make camera snapshots same as the StateSnapshots with "child states?"
...
...
@@ -139,6 +143,7 @@ namespace PluginState {
data
?:
State
.
Snapshot
,
behaviour
?:
State
.
Snapshot
,
animation
?:
PluginAnimationManager
.
Snapshot
,
startAnimation
?:
boolean
,
camera
?:
{
current
:
Camera
.
Snapshot
,
transitionStyle
:
CameraTransitionStyle
,
...
...
This diff is collapsed.
Click to expand it.
src/mol-plugin/state/animation/built-in.ts
+
21
−
8
View file @
8b274c10
...
...
@@ -7,9 +7,10 @@
import
{
PluginStateAnimation
}
from
'
./model
'
;
import
{
PluginStateObject
}
from
'
../objects
'
;
import
{
StateTransforms
}
from
'
../transforms
'
;
import
{
StateSelection
}
from
'
mol-state
'
;
import
{
StateSelection
,
StateTransform
}
from
'
mol-state
'
;
import
{
PluginCommands
}
from
'
mol-plugin/command
'
;
import
{
ParamDefinition
as
PD
}
from
'
mol-util/param-definition
'
;
import
{
PluginContext
}
from
'
mol-plugin/context
'
;
export
const
AnimateModelIndex
=
PluginStateAnimation
.
create
({
name
:
'
built-in.animate-model-index
'
,
...
...
@@ -89,14 +90,25 @@ export const AnimateModelIndex = PluginStateAnimation.create({
export
const
AnimateAssemblyUnwind
=
PluginStateAnimation
.
create
({
name
:
'
built-in.animate-assembly-unwind
'
,
display
:
{
name
:
'
Unwind Assembly
'
},
params
:
()
=>
({
durationInMs
:
PD
.
Numeric
(
3000
,
{
min
:
100
,
max
:
10000
,
step
:
100
}),
playOnce
:
PD
.
Boolean
(
false
)
}),
params
:
(
plugin
:
PluginContext
)
=>
{
const
targets
:
[
string
,
string
][]
=
[[
'
all
'
,
'
All
'
]];
const
structures
=
plugin
.
state
.
dataState
.
select
(
StateSelection
.
Generators
.
rootsOfType
(
PluginStateObject
.
Molecule
.
Structure
));
for
(
const
s
of
structures
)
{
targets
.
push
([
s
.
transform
.
ref
,
s
.
obj
!
.
data
.
models
[
0
].
label
]);
}
return
{
durationInMs
:
PD
.
Numeric
(
3000
,
{
min
:
100
,
max
:
10000
,
step
:
100
}),
playOnce
:
PD
.
Boolean
(
false
),
target
:
PD
.
Select
(
targets
[
0
][
0
],
targets
)
};
},
initialState
:
()
=>
({
t
:
0
}),
async
setup
(
_
,
plugin
)
{
async
setup
(
params
,
plugin
)
{
const
state
=
plugin
.
state
.
dataState
;
const
reprs
=
state
.
select
(
StateSelection
.
Generators
.
ofType
(
PluginStateObject
.
Molecule
.
Structure
.
Representation3D
));
const
root
=
!
params
.
target
||
params
.
target
===
'
all
'
?
StateTransform
.
RootRef
:
params
.
target
;
const
reprs
=
state
.
select
(
StateSelection
.
Generators
.
ofType
(
PluginStateObject
.
Molecule
.
Structure
.
Representation3D
,
root
));
const
update
=
state
.
build
();
let
changed
=
false
;
...
...
@@ -125,7 +137,8 @@ export const AnimateAssemblyUnwind = PluginStateAnimation.create({
},
async
apply
(
animState
,
t
,
ctx
)
{
const
state
=
ctx
.
plugin
.
state
.
dataState
;
const
anims
=
state
.
select
(
StateSelection
.
Generators
.
ofTransformer
(
StateTransforms
.
Representation
.
UnwindStructureAssemblyRepresentation3D
));
const
root
=
!
ctx
.
params
.
target
||
ctx
.
params
.
target
===
'
all
'
?
StateTransform
.
RootRef
:
ctx
.
params
.
target
;
const
anims
=
state
.
select
(
StateSelection
.
Generators
.
ofTransformer
(
StateTransforms
.
Representation
.
UnwindStructureAssemblyRepresentation3D
,
root
));
if
(
anims
.
length
===
0
)
{
return
{
kind
:
'
finished
'
};
...
...
This diff is collapsed.
Click to expand it.
src/mol-plugin/state/animation/model.ts
+
1
−
1
View file @
8b274c10
...
...
@@ -15,7 +15,7 @@ export { PluginStateAnimation }
interface
PluginStateAnimation
<
P
=
any
,
S
=
any
>
{
name
:
string
,
readonly
display
:
{
readonly
name
:
string
,
readonly
description
?:
string
},
params
:
(
ctx
:
PluginContext
)
=>
PD
.
For
<
P
>
,
params
(
ctx
:
PluginContext
)
:
PD
.
For
<
P
>
,
initialState
(
params
:
P
,
ctx
:
PluginContext
):
S
,
// TODO: support state in setup/teardown?
...
...
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