Skip to content

Commit

Permalink
Fix css, isolate phonon amplitude, and force theme in tag attrs
Browse files Browse the repository at this point in the history
  • Loading branch information
blokhin committed Mar 28, 2024
1 parent a2eacb9 commit f76c381
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 3 deletions.
3 changes: 3 additions & 0 deletions player/player.view.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
[mol_theme="$mol_theme_light"] {
--mol_theme_back: white;
}
6 changes: 5 additions & 1 deletion player/player.view.css.ts
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ namespace $.$$ {
},

Toogle_all: {
boxShadow: `0 0.5rem 0.5rem -0.5rem hsla(0,0%,0%,.5)`,
boxShadow: `0 0.5rem 0.5rem -0.5rem hsla(0,0%,0%,.5)`,
},

Overlays: {
Expand Down Expand Up @@ -114,6 +114,10 @@ namespace $.$$ {
margin: 'auto',
},

Three: {
cursor: 'move',
},

} )

}
10 changes: 8 additions & 2 deletions player/player.view.web.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,14 @@ namespace $.$$ {
const TWEEN = $mpds_cifplayer_lib_tween.TWEEN
type TWEEN = typeof TWEEN

const phonon_amp: number = 6

export class $mpds_cifplayer_player extends $.$mpds_cifplayer_player {

theme() {
return '$mol_theme_' + (this.externals()?.theme || 'dark')
}

@ $mol_mem
available_overlays() {
try {
Expand Down Expand Up @@ -420,12 +426,12 @@ namespace $.$$ {
const labels = this.overlay_box().children

if( phonon.length !== atoms.length) {
this.$.$mol_fail( new $mol_data_error(`Internal error: phonon length does not match number of atoms`) )
this.$.$mol_fail( new $mol_data_error(`Phonon length does not match number of atoms`) )
}

atoms.forEach( ( atom: InstanceType< THREE["Object3D"] >, i: number ) => {
const start = atom.position.toArray()
const [ x, y, z ] = phonon[ i ].map( ( v, i ) => start[ i ] + v * 6 )
const [ x, y, z ] = phonon[ i ].map( ( v, i ) => start[ i ] + v * phonon_amp )

this.tweens.add( new TWEEN.Tween( atom.position ).to( { x, y, z }, 750 )
.easing( TWEEN.Easing.Cubic.InOut ).repeat( Infinity ).yoyo( true ).start()
Expand Down

0 comments on commit f76c381

Please sign in to comment.