Comments (6)
Sounds like it would be very possible, it should be fast enough.
You would need to create a selection based on the mousemove event, such as
var rect = pv_viewer.boundingClientRect();
var picked = pv_viewer.pick({ x : event.clientX - rect.left, y : event.clientY - rect.top });
And then selectWithin a PV structure (eg protein = pv_viewer.get('model01').structure() )
protein.selectWithin( picked.target(),
{
radius: 4,
matchResidues:true
});
matchResidues extends the atoms found in the radius to be a complete residue.
from pv.
Hi Awaterho
Thanks! I gave the above code a try but I ran into an error.
my code
<html>
<head>
<title>Dengue Virus Methyl Transferase</title>
<meta name="viewport" content="width=device-width, user-scalable=no, minimum-scale=1.0, maximum-scale=1.0">
</head>
<body>
<div id=viewer></div>
</body>
<div id='picked-atom-name' style='text-align:center;'> </div>
<script type='text/javascript' src='pv.min.js'></script>
<script>
var parent = document.getElementById('viewer');
var viewer = pv.Viewer(parent,{ width : 600, height : 600, antialias : true });
parent.addEventListener('mousemove', function(event) {
var rect = viewer.boundingClientRect();
var picked = viewer.pick({ x : event.clientX - rect.left,
y : event.clientY - rect.top });
var protein = viewer.get('protein').structure()
protein.selectWithin(picked.target(), {radius: 4, matchResidues: true});
viewer.requestRedraw();
});
pv.io.fetchPdb('6umt.pdb', function(structure) {
viewer.on('viewerReady', function() {
viewer.cartoon('protein', structure);
viewer.centerOn(structure);
});
});
</script>
the error
Uncaught TypeError: b.eachAtom is not a function
at j.selectWithin (pv.min.js:12:13235)
at HTMLDivElement.<anonymous> (index.html:59:13)
(anonymous) @ pv.min.js:12
(anonymous) @ index.html:59
Do you know what might be causing the issue?
from pv.
Also when I am not hovering directly over an atom, I get this error.
Uncaught TypeError: Cannot read properties of null (reading 'target')
at HTMLDivElement.<anonymous> (index.html:58:24)
(anonymous) @ index.html:58
I want to pick up atoms within a given radius of my mouse even if my mouse if not on top of an atom. Is this possible?
from pv.
You have to check that picked is not null, it will only exist if the mouse is directly over an atom.
from pv.
I see the selectWithin only works on residues, not atoms. So Some minor changes -
<script>
var parent = document.getElementById('viewer');
var viewer = pv.Viewer(parent,{ width : 600, height : 600, antialias : true });
var protein = null;
parent.addEventListener('mousemove', function(event) {
var rect = viewer.boundingClientRect();
var picked = viewer.pick({ x : event.clientX - rect.left,
y : event.clientY - rect.top });
if(!picked)
return;
viewer.rm('surrounding')
var surrounding = protein.selectWithin(picked.target().residue(), {radius: 4, matchResidues: true});
viewer.lines('surrounding', surrounding);
viewer.requestRedraw();
});
pv.io.fetchPdb('6umt.pdb', function(structure) {
viewer.on('viewerReady', function() {
viewer.cartoon('protein', structure);
viewer.centerOn(structure);
protein = viewer.get('protein').structure();
});
});
</script>
from pv.
That worked quite nicely. Thanks! :)
from pv.
Related Issues (20)
- Any way to visually make certain bonds stronger? HOT 2
- Dead contribution guidelines link in readme.md HOT 1
- Uncaught TypeError: Cannot read property 'centralAtom' of undefined
- Disabling zoom on scroll
- Support MMTF format
- HETATM and Organic sticks HOT 1
- If a trace has a length of 1, it may not render properly
- atom has no _residue
- package.json main points to non-existent file
- Partial coloring of structure HOT 3
- CIAO MARCO!!! PROBLEMI CON APERTURA PDB FILES
- Structure creation by hand HOT 1
- project still alive? HOT 3
- Coloring each residue by a hex code color HOT 1
- Suggestion: Make bio-pv a web component HOT 2
- I AM NEW
- Display problem of structure of alphafold2 HOT 6
- Inquiry support drawing a path from one residue to another residue HOT 9
- Using Python CGI to create PV instances on the fly HOT 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from pv.