Spaces:
Runtime error
Runtime error
Update dna-slot-machine.html
Browse files- dna-slot-machine.html +165 -76
dna-slot-machine.html
CHANGED
|
@@ -13,8 +13,8 @@
|
|
| 13 |
|
| 14 |
body {
|
| 15 |
font-family: Arial, sans-serif;
|
| 16 |
-
background: #
|
| 17 |
-
color: #
|
| 18 |
overflow: hidden;
|
| 19 |
}
|
| 20 |
|
|
@@ -26,7 +26,7 @@
|
|
| 26 |
.viewer {
|
| 27 |
flex: 1;
|
| 28 |
position: relative;
|
| 29 |
-
background:
|
| 30 |
}
|
| 31 |
|
| 32 |
#canvas3d {
|
|
@@ -36,22 +36,26 @@
|
|
| 36 |
|
| 37 |
.controls {
|
| 38 |
width: 350px;
|
| 39 |
-
background:
|
|
|
|
| 40 |
padding: 20px;
|
| 41 |
overflow-y: auto;
|
|
|
|
| 42 |
}
|
| 43 |
|
| 44 |
.control-section {
|
| 45 |
margin-bottom: 25px;
|
| 46 |
padding: 15px;
|
| 47 |
-
background:
|
| 48 |
-
border-radius:
|
|
|
|
| 49 |
}
|
| 50 |
|
| 51 |
.control-section h3 {
|
| 52 |
margin-bottom: 15px;
|
| 53 |
-
color: #
|
| 54 |
font-size: 1.2em;
|
|
|
|
| 55 |
}
|
| 56 |
|
| 57 |
.input-group {
|
|
@@ -61,41 +65,48 @@
|
|
| 61 |
.input-group label {
|
| 62 |
display: block;
|
| 63 |
margin-bottom: 5px;
|
| 64 |
-
color: #
|
| 65 |
font-size: 0.9em;
|
|
|
|
| 66 |
}
|
| 67 |
|
| 68 |
.input-group input,
|
| 69 |
.input-group select,
|
| 70 |
.input-group textarea {
|
| 71 |
width: 100%;
|
| 72 |
-
padding:
|
| 73 |
-
background:
|
| 74 |
-
border:
|
| 75 |
-
border-radius:
|
| 76 |
-
color: #
|
|
|
|
|
|
|
| 77 |
}
|
| 78 |
|
| 79 |
-
.input-group
|
| 80 |
-
|
| 81 |
-
|
|
|
|
|
|
|
|
|
|
| 82 |
}
|
| 83 |
|
| 84 |
button {
|
| 85 |
width: 100%;
|
| 86 |
-
padding:
|
| 87 |
-
background: linear-gradient(135deg, #
|
| 88 |
border: none;
|
| 89 |
-
border-radius:
|
| 90 |
-
color: #
|
| 91 |
-
font-weight:
|
| 92 |
cursor: pointer;
|
| 93 |
transition: all 0.3s;
|
|
|
|
| 94 |
}
|
| 95 |
|
| 96 |
button:hover {
|
| 97 |
transform: translateY(-2px);
|
| 98 |
-
box-shadow: 0
|
| 99 |
}
|
| 100 |
|
| 101 |
.view-buttons {
|
|
@@ -114,37 +125,53 @@
|
|
| 114 |
position: absolute;
|
| 115 |
top: 20px;
|
| 116 |
left: 20px;
|
| 117 |
-
background: rgba(
|
| 118 |
-
|
| 119 |
-
|
| 120 |
-
border:
|
|
|
|
| 121 |
max-width: 300px;
|
| 122 |
}
|
| 123 |
|
| 124 |
.info-panel h4 {
|
| 125 |
-
color: #
|
| 126 |
-
margin-bottom:
|
|
|
|
| 127 |
}
|
| 128 |
|
| 129 |
.info-item {
|
| 130 |
-
margin:
|
| 131 |
-
font-size: 0.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 132 |
}
|
| 133 |
|
| 134 |
.legend {
|
| 135 |
position: absolute;
|
| 136 |
bottom: 20px;
|
| 137 |
right: 20px;
|
| 138 |
-
background: rgba(
|
| 139 |
-
|
| 140 |
-
|
| 141 |
-
border:
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 142 |
}
|
| 143 |
|
| 144 |
.legend-item {
|
| 145 |
display: flex;
|
| 146 |
align-items: center;
|
| 147 |
-
margin:
|
|
|
|
| 148 |
}
|
| 149 |
|
| 150 |
.legend-color {
|
|
@@ -184,11 +211,49 @@
|
|
| 184 |
|
| 185 |
.slider {
|
| 186 |
flex: 1;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 187 |
}
|
| 188 |
|
| 189 |
.slider-value {
|
| 190 |
min-width: 40px;
|
| 191 |
text-align: right;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 192 |
}
|
| 193 |
|
| 194 |
/* Molecule info tooltip */
|
|
@@ -230,7 +295,15 @@
|
|
| 230 |
</div>
|
| 231 |
|
| 232 |
<div class="controls">
|
| 233 |
-
<h2 style="
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 234 |
|
| 235 |
<div class="control-section">
|
| 236 |
<h3>🧬 Input Sequence</h3>
|
|
@@ -338,32 +411,35 @@
|
|
| 338 |
let atoms = [];
|
| 339 |
let bonds = [];
|
| 340 |
|
| 341 |
-
// Color schemes
|
| 342 |
const elementColors = {
|
| 343 |
-
'C':
|
| 344 |
-
'H':
|
| 345 |
-
'N':
|
| 346 |
-
'O':
|
| 347 |
-
'P':
|
| 348 |
-
'S':
|
| 349 |
};
|
| 350 |
|
| 351 |
const residueColors = {
|
| 352 |
-
'A':
|
| 353 |
-
'
|
| 354 |
-
//
|
| 355 |
-
'
|
| 356 |
-
'
|
| 357 |
-
|
| 358 |
-
'
|
| 359 |
-
'
|
|
|
|
|
|
|
|
|
|
| 360 |
};
|
| 361 |
|
| 362 |
function init() {
|
| 363 |
// Scene setup
|
| 364 |
scene = new THREE.Scene();
|
| 365 |
-
scene.background = new THREE.Color(
|
| 366 |
-
scene.fog = new THREE.Fog(
|
| 367 |
|
| 368 |
// Camera
|
| 369 |
camera = new THREE.PerspectiveCamera(75, window.innerWidth / window.innerHeight, 0.1, 1000);
|
|
@@ -372,22 +448,24 @@
|
|
| 372 |
// Renderer
|
| 373 |
renderer = new THREE.WebGLRenderer({
|
| 374 |
canvas: document.getElementById('canvas3d'),
|
| 375 |
-
antialias: true
|
|
|
|
| 376 |
});
|
| 377 |
renderer.setSize(window.innerWidth - 350, window.innerHeight);
|
| 378 |
renderer.shadowMap.enabled = true;
|
| 379 |
renderer.shadowMap.type = THREE.PCFSoftShadowMap;
|
|
|
|
| 380 |
|
| 381 |
// Lights
|
| 382 |
-
const ambientLight = new THREE.AmbientLight(
|
| 383 |
scene.add(ambientLight);
|
| 384 |
|
| 385 |
-
const directionalLight1 = new THREE.DirectionalLight(0xffffff,
|
| 386 |
directionalLight1.position.set(50, 50, 50);
|
| 387 |
directionalLight1.castShadow = true;
|
| 388 |
scene.add(directionalLight1);
|
| 389 |
|
| 390 |
-
const directionalLight2 = new THREE.DirectionalLight(
|
| 391 |
directionalLight2.position.set(-50, 50, -50);
|
| 392 |
scene.add(directionalLight2);
|
| 393 |
|
|
@@ -639,9 +717,11 @@
|
|
| 639 |
|
| 640 |
const tubeGeometry = new THREE.TubeGeometry(curve, 100, 1, 8, false);
|
| 641 |
const tubeMaterial = new THREE.MeshPhongMaterial({
|
| 642 |
-
color:
|
| 643 |
shininess: 100,
|
| 644 |
-
specular:
|
|
|
|
|
|
|
| 645 |
});
|
| 646 |
const tube = new THREE.Mesh(tubeGeometry, tubeMaterial);
|
| 647 |
moleculeGroup.add(tube);
|
|
@@ -650,7 +730,9 @@
|
|
| 650 |
atoms.filter(a => a.type.includes('base')).forEach(atom => {
|
| 651 |
const geometry = new THREE.BoxGeometry(3, 0.5, 1);
|
| 652 |
const material = new THREE.MeshPhongMaterial({
|
| 653 |
-
color: residueColors[atom.element] ||
|
|
|
|
|
|
|
| 654 |
});
|
| 655 |
const base = new THREE.Mesh(geometry, material);
|
| 656 |
base.position.copy(atom.position);
|
|
@@ -676,9 +758,11 @@
|
|
| 676 |
|
| 677 |
// Color by secondary structure prediction (simplified)
|
| 678 |
const tubeMaterial = new THREE.MeshPhongMaterial({
|
| 679 |
-
color:
|
| 680 |
shininess: 100,
|
| 681 |
-
specular:
|
|
|
|
|
|
|
| 682 |
});
|
| 683 |
|
| 684 |
const tube = new THREE.Mesh(tubeGeometry, tubeMaterial);
|
|
@@ -690,7 +774,9 @@
|
|
| 690 |
atoms.forEach((atom, index) => {
|
| 691 |
const geometry = new THREE.SphereGeometry(0.5, 16, 16);
|
| 692 |
const material = new THREE.MeshPhongMaterial({
|
| 693 |
-
color: getAtomColor(atom)
|
|
|
|
|
|
|
| 694 |
});
|
| 695 |
const sphere = new THREE.Mesh(geometry, material);
|
| 696 |
sphere.position.copy(atom.position);
|
|
@@ -709,7 +795,8 @@
|
|
| 709 |
|
| 710 |
const geometry = new THREE.CylinderGeometry(0.2, 0.2, distance, 8);
|
| 711 |
const material = new THREE.MeshPhongMaterial({
|
| 712 |
-
color: bond.type === 'hydrogen' ?
|
|
|
|
| 713 |
});
|
| 714 |
|
| 715 |
const cylinder = new THREE.Mesh(geometry, material);
|
|
@@ -741,10 +828,12 @@
|
|
| 741 |
const points = atoms.map(a => a.position);
|
| 742 |
const geometry = new THREE.ConvexGeometry(points);
|
| 743 |
const material = new THREE.MeshPhongMaterial({
|
| 744 |
-
color:
|
| 745 |
transparent: true,
|
| 746 |
-
opacity: 0.
|
| 747 |
-
side: THREE.DoubleSide
|
|
|
|
|
|
|
| 748 |
});
|
| 749 |
const mesh = new THREE.Mesh(geometry, material);
|
| 750 |
moleculeGroup.add(mesh);
|
|
@@ -754,24 +843,24 @@
|
|
| 754 |
const scheme = document.getElementById('colorScheme').value;
|
| 755 |
|
| 756 |
if (scheme === 'element') {
|
| 757 |
-
return elementColors[atom.element] ||
|
| 758 |
} else if (scheme === 'residue') {
|
| 759 |
-
return residueColors[atom.element] || residueColors[atom.type] ||
|
| 760 |
} else if (scheme === 'chain') {
|
| 761 |
-
return atom.type.includes('strand1') || atom.type === 'backbone' ?
|
| 762 |
} else if (scheme === 'hydrophobicity') {
|
| 763 |
-
// Simplified hydrophobicity scale
|
| 764 |
const hydrophobic = ['A', 'V', 'I', 'L', 'M', 'F', 'W'];
|
| 765 |
-
return hydrophobic.includes(atom.element) ?
|
| 766 |
} else if (scheme === 'charge') {
|
| 767 |
const positive = ['R', 'K', 'H'];
|
| 768 |
const negative = ['D', 'E'];
|
| 769 |
-
if (positive.includes(atom.element)) return
|
| 770 |
-
if (negative.includes(atom.element)) return
|
| 771 |
-
return
|
| 772 |
}
|
| 773 |
|
| 774 |
-
return
|
| 775 |
}
|
| 776 |
|
| 777 |
function getAtomRadius(element) {
|
|
|
|
| 13 |
|
| 14 |
body {
|
| 15 |
font-family: Arial, sans-serif;
|
| 16 |
+
background: linear-gradient(135deg, #ffeaa7 0%, #fab1a0 25%, #a29bfe 50%, #74b9ff 75%, #81ecec 100%);
|
| 17 |
+
color: #2d3436;
|
| 18 |
overflow: hidden;
|
| 19 |
}
|
| 20 |
|
|
|
|
| 26 |
.viewer {
|
| 27 |
flex: 1;
|
| 28 |
position: relative;
|
| 29 |
+
background: linear-gradient(135deg, rgba(255, 255, 255, 0.8), rgba(240, 240, 240, 0.8));
|
| 30 |
}
|
| 31 |
|
| 32 |
#canvas3d {
|
|
|
|
| 36 |
|
| 37 |
.controls {
|
| 38 |
width: 350px;
|
| 39 |
+
background: rgba(255, 255, 255, 0.95);
|
| 40 |
+
backdrop-filter: blur(10px);
|
| 41 |
padding: 20px;
|
| 42 |
overflow-y: auto;
|
| 43 |
+
box-shadow: -5px 0 20px rgba(0, 0, 0, 0.1);
|
| 44 |
}
|
| 45 |
|
| 46 |
.control-section {
|
| 47 |
margin-bottom: 25px;
|
| 48 |
padding: 15px;
|
| 49 |
+
background: linear-gradient(135deg, rgba(162, 155, 254, 0.1), rgba(116, 185, 255, 0.1));
|
| 50 |
+
border-radius: 12px;
|
| 51 |
+
border: 1px solid rgba(162, 155, 254, 0.2);
|
| 52 |
}
|
| 53 |
|
| 54 |
.control-section h3 {
|
| 55 |
margin-bottom: 15px;
|
| 56 |
+
color: #5f3dc4;
|
| 57 |
font-size: 1.2em;
|
| 58 |
+
font-weight: 600;
|
| 59 |
}
|
| 60 |
|
| 61 |
.input-group {
|
|
|
|
| 65 |
.input-group label {
|
| 66 |
display: block;
|
| 67 |
margin-bottom: 5px;
|
| 68 |
+
color: #5f3dc4;
|
| 69 |
font-size: 0.9em;
|
| 70 |
+
font-weight: 500;
|
| 71 |
}
|
| 72 |
|
| 73 |
.input-group input,
|
| 74 |
.input-group select,
|
| 75 |
.input-group textarea {
|
| 76 |
width: 100%;
|
| 77 |
+
padding: 10px;
|
| 78 |
+
background: rgba(255, 255, 255, 0.8);
|
| 79 |
+
border: 2px solid #dfe6e9;
|
| 80 |
+
border-radius: 8px;
|
| 81 |
+
color: #2d3436;
|
| 82 |
+
font-size: 14px;
|
| 83 |
+
transition: all 0.3s ease;
|
| 84 |
}
|
| 85 |
|
| 86 |
+
.input-group input:focus,
|
| 87 |
+
.input-group select:focus,
|
| 88 |
+
.input-group textarea:focus {
|
| 89 |
+
outline: none;
|
| 90 |
+
border-color: #74b9ff;
|
| 91 |
+
box-shadow: 0 0 0 3px rgba(116, 185, 255, 0.2);
|
| 92 |
}
|
| 93 |
|
| 94 |
button {
|
| 95 |
width: 100%;
|
| 96 |
+
padding: 12px;
|
| 97 |
+
background: linear-gradient(135deg, #74b9ff, #a29bfe);
|
| 98 |
border: none;
|
| 99 |
+
border-radius: 8px;
|
| 100 |
+
color: #fff;
|
| 101 |
+
font-weight: 600;
|
| 102 |
cursor: pointer;
|
| 103 |
transition: all 0.3s;
|
| 104 |
+
box-shadow: 0 4px 6px rgba(162, 155, 254, 0.3);
|
| 105 |
}
|
| 106 |
|
| 107 |
button:hover {
|
| 108 |
transform: translateY(-2px);
|
| 109 |
+
box-shadow: 0 6px 12px rgba(162, 155, 254, 0.4);
|
| 110 |
}
|
| 111 |
|
| 112 |
.view-buttons {
|
|
|
|
| 125 |
position: absolute;
|
| 126 |
top: 20px;
|
| 127 |
left: 20px;
|
| 128 |
+
background: rgba(255, 255, 255, 0.9);
|
| 129 |
+
backdrop-filter: blur(10px);
|
| 130 |
+
padding: 20px;
|
| 131 |
+
border-radius: 12px;
|
| 132 |
+
box-shadow: 0 8px 16px rgba(0, 0, 0, 0.1);
|
| 133 |
max-width: 300px;
|
| 134 |
}
|
| 135 |
|
| 136 |
.info-panel h4 {
|
| 137 |
+
color: #5f3dc4;
|
| 138 |
+
margin-bottom: 15px;
|
| 139 |
+
font-weight: 600;
|
| 140 |
}
|
| 141 |
|
| 142 |
.info-item {
|
| 143 |
+
margin: 8px 0;
|
| 144 |
+
font-size: 0.95em;
|
| 145 |
+
color: #2d3436;
|
| 146 |
+
}
|
| 147 |
+
|
| 148 |
+
.info-item span {
|
| 149 |
+
color: #74b9ff;
|
| 150 |
+
font-weight: 500;
|
| 151 |
}
|
| 152 |
|
| 153 |
.legend {
|
| 154 |
position: absolute;
|
| 155 |
bottom: 20px;
|
| 156 |
right: 20px;
|
| 157 |
+
background: rgba(255, 255, 255, 0.9);
|
| 158 |
+
backdrop-filter: blur(10px);
|
| 159 |
+
padding: 20px;
|
| 160 |
+
border-radius: 12px;
|
| 161 |
+
box-shadow: 0 8px 16px rgba(0, 0, 0, 0.1);
|
| 162 |
+
}
|
| 163 |
+
|
| 164 |
+
.legend h4 {
|
| 165 |
+
color: #5f3dc4;
|
| 166 |
+
margin-bottom: 10px;
|
| 167 |
+
font-weight: 600;
|
| 168 |
}
|
| 169 |
|
| 170 |
.legend-item {
|
| 171 |
display: flex;
|
| 172 |
align-items: center;
|
| 173 |
+
margin: 8px 0;
|
| 174 |
+
color: #2d3436;
|
| 175 |
}
|
| 176 |
|
| 177 |
.legend-color {
|
|
|
|
| 211 |
|
| 212 |
.slider {
|
| 213 |
flex: 1;
|
| 214 |
+
-webkit-appearance: none;
|
| 215 |
+
height: 6px;
|
| 216 |
+
border-radius: 3px;
|
| 217 |
+
background: linear-gradient(to right, #dfe6e9 0%, #74b9ff 50%, #a29bfe 100%);
|
| 218 |
+
outline: none;
|
| 219 |
+
}
|
| 220 |
+
|
| 221 |
+
.slider::-webkit-slider-thumb {
|
| 222 |
+
-webkit-appearance: none;
|
| 223 |
+
appearance: none;
|
| 224 |
+
width: 18px;
|
| 225 |
+
height: 18px;
|
| 226 |
+
border-radius: 50%;
|
| 227 |
+
background: #5f3dc4;
|
| 228 |
+
cursor: pointer;
|
| 229 |
+
box-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
|
| 230 |
+
}
|
| 231 |
+
|
| 232 |
+
.slider::-moz-range-thumb {
|
| 233 |
+
width: 18px;
|
| 234 |
+
height: 18px;
|
| 235 |
+
border-radius: 50%;
|
| 236 |
+
background: #5f3dc4;
|
| 237 |
+
cursor: pointer;
|
| 238 |
+
box-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
|
| 239 |
}
|
| 240 |
|
| 241 |
.slider-value {
|
| 242 |
min-width: 40px;
|
| 243 |
text-align: right;
|
| 244 |
+
color: #5f3dc4;
|
| 245 |
+
font-weight: 500;
|
| 246 |
+
}
|
| 247 |
+
|
| 248 |
+
#analysisResults {
|
| 249 |
+
background: rgba(255, 255, 255, 0.6);
|
| 250 |
+
padding: 15px;
|
| 251 |
+
border-radius: 8px;
|
| 252 |
+
color: #2d3436;
|
| 253 |
+
}
|
| 254 |
+
|
| 255 |
+
#analysisResults strong {
|
| 256 |
+
color: #5f3dc4;
|
| 257 |
}
|
| 258 |
|
| 259 |
/* Molecule info tooltip */
|
|
|
|
| 295 |
</div>
|
| 296 |
|
| 297 |
<div class="controls">
|
| 298 |
+
<h2 style="
|
| 299 |
+
margin-bottom: 20px;
|
| 300 |
+
text-align: center;
|
| 301 |
+
background: linear-gradient(135deg, #5f3dc4, #74b9ff, #fd79a8);
|
| 302 |
+
-webkit-background-clip: text;
|
| 303 |
+
-webkit-text-fill-color: transparent;
|
| 304 |
+
background-clip: text;
|
| 305 |
+
font-size: 1.8em;
|
| 306 |
+
">🧬 3D Structure Controls</h2>
|
| 307 |
|
| 308 |
<div class="control-section">
|
| 309 |
<h3>🧬 Input Sequence</h3>
|
|
|
|
| 411 |
let atoms = [];
|
| 412 |
let bonds = [];
|
| 413 |
|
| 414 |
+
// Color schemes - Pastel colors
|
| 415 |
const elementColors = {
|
| 416 |
+
'C': 0x9b9b9b, // Soft gray
|
| 417 |
+
'H': 0xf8f8f8, // Almost white
|
| 418 |
+
'N': 0x74b9ff, // Soft blue
|
| 419 |
+
'O': 0xfd79a8, // Soft pink
|
| 420 |
+
'P': 0xfdcb6e, // Soft orange
|
| 421 |
+
'S': 0xf9ca24 // Soft yellow
|
| 422 |
};
|
| 423 |
|
| 424 |
const residueColors = {
|
| 425 |
+
'A': 0xfd79a8, // Soft pink
|
| 426 |
+
'T': 0x81ecec, // Soft turquoise
|
| 427 |
+
'G': 0xfdcb6e, // Soft yellow
|
| 428 |
+
'C': 0xa29bfe, // Soft purple
|
| 429 |
+
'U': 0xf8b5ff, // Soft magenta
|
| 430 |
+
// Amino acids - all in pastel shades
|
| 431 |
+
'ALA': 0xc7ecee, 'ARG': 0xdfe6e9, 'ASN': 0xfab1a0, 'ASP': 0xfd79a8,
|
| 432 |
+
'CYS': 0xffeaa7, 'GLN': 0xff7675, 'GLU': 0xe17055, 'GLY': 0xffffff,
|
| 433 |
+
'HIS': 0xa29bfe, 'ILE': 0x81ecec, 'LEU': 0x74b9ff, 'LYS': 0x686de0,
|
| 434 |
+
'MET': 0xfdcb6e, 'PHE': 0x6c5ce7, 'PRO': 0xb2bec3, 'SER': 0xff7675,
|
| 435 |
+
'THR': 0xf0932b, 'TRP': 0x5f3dc4, 'TYR': 0xeb4d4b, 'VAL': 0xbadc58
|
| 436 |
};
|
| 437 |
|
| 438 |
function init() {
|
| 439 |
// Scene setup
|
| 440 |
scene = new THREE.Scene();
|
| 441 |
+
scene.background = new THREE.Color(0xffffff);
|
| 442 |
+
scene.fog = new THREE.Fog(0xffffff, 100, 200);
|
| 443 |
|
| 444 |
// Camera
|
| 445 |
camera = new THREE.PerspectiveCamera(75, window.innerWidth / window.innerHeight, 0.1, 1000);
|
|
|
|
| 448 |
// Renderer
|
| 449 |
renderer = new THREE.WebGLRenderer({
|
| 450 |
canvas: document.getElementById('canvas3d'),
|
| 451 |
+
antialias: true,
|
| 452 |
+
alpha: true
|
| 453 |
});
|
| 454 |
renderer.setSize(window.innerWidth - 350, window.innerHeight);
|
| 455 |
renderer.shadowMap.enabled = true;
|
| 456 |
renderer.shadowMap.type = THREE.PCFSoftShadowMap;
|
| 457 |
+
renderer.setClearColor(0xffffff, 0.9);
|
| 458 |
|
| 459 |
// Lights
|
| 460 |
+
const ambientLight = new THREE.AmbientLight(0xffffff, 0.8);
|
| 461 |
scene.add(ambientLight);
|
| 462 |
|
| 463 |
+
const directionalLight1 = new THREE.DirectionalLight(0xffffff, 0.6);
|
| 464 |
directionalLight1.position.set(50, 50, 50);
|
| 465 |
directionalLight1.castShadow = true;
|
| 466 |
scene.add(directionalLight1);
|
| 467 |
|
| 468 |
+
const directionalLight2 = new THREE.DirectionalLight(0xa29bfe, 0.3);
|
| 469 |
directionalLight2.position.set(-50, 50, -50);
|
| 470 |
scene.add(directionalLight2);
|
| 471 |
|
|
|
|
| 717 |
|
| 718 |
const tubeGeometry = new THREE.TubeGeometry(curve, 100, 1, 8, false);
|
| 719 |
const tubeMaterial = new THREE.MeshPhongMaterial({
|
| 720 |
+
color: 0x74b9ff,
|
| 721 |
shininess: 100,
|
| 722 |
+
specular: 0xffffff,
|
| 723 |
+
emissive: 0x74b9ff,
|
| 724 |
+
emissiveIntensity: 0.1
|
| 725 |
});
|
| 726 |
const tube = new THREE.Mesh(tubeGeometry, tubeMaterial);
|
| 727 |
moleculeGroup.add(tube);
|
|
|
|
| 730 |
atoms.filter(a => a.type.includes('base')).forEach(atom => {
|
| 731 |
const geometry = new THREE.BoxGeometry(3, 0.5, 1);
|
| 732 |
const material = new THREE.MeshPhongMaterial({
|
| 733 |
+
color: residueColors[atom.element] || 0xa29bfe,
|
| 734 |
+
shininess: 100,
|
| 735 |
+
specular: 0xffffff
|
| 736 |
});
|
| 737 |
const base = new THREE.Mesh(geometry, material);
|
| 738 |
base.position.copy(atom.position);
|
|
|
|
| 758 |
|
| 759 |
// Color by secondary structure prediction (simplified)
|
| 760 |
const tubeMaterial = new THREE.MeshPhongMaterial({
|
| 761 |
+
color: 0xfd79a8,
|
| 762 |
shininess: 100,
|
| 763 |
+
specular: 0xffffff,
|
| 764 |
+
emissive: 0xfd79a8,
|
| 765 |
+
emissiveIntensity: 0.1
|
| 766 |
});
|
| 767 |
|
| 768 |
const tube = new THREE.Mesh(tubeGeometry, tubeMaterial);
|
|
|
|
| 774 |
atoms.forEach((atom, index) => {
|
| 775 |
const geometry = new THREE.SphereGeometry(0.5, 16, 16);
|
| 776 |
const material = new THREE.MeshPhongMaterial({
|
| 777 |
+
color: getAtomColor(atom),
|
| 778 |
+
shininess: 100,
|
| 779 |
+
specular: 0xffffff
|
| 780 |
});
|
| 781 |
const sphere = new THREE.Mesh(geometry, material);
|
| 782 |
sphere.position.copy(atom.position);
|
|
|
|
| 795 |
|
| 796 |
const geometry = new THREE.CylinderGeometry(0.2, 0.2, distance, 8);
|
| 797 |
const material = new THREE.MeshPhongMaterial({
|
| 798 |
+
color: bond.type === 'hydrogen' ? 0xdfe6e9 : 0xb2bec3,
|
| 799 |
+
shininess: 50
|
| 800 |
});
|
| 801 |
|
| 802 |
const cylinder = new THREE.Mesh(geometry, material);
|
|
|
|
| 828 |
const points = atoms.map(a => a.position);
|
| 829 |
const geometry = new THREE.ConvexGeometry(points);
|
| 830 |
const material = new THREE.MeshPhongMaterial({
|
| 831 |
+
color: 0xa29bfe,
|
| 832 |
transparent: true,
|
| 833 |
+
opacity: 0.6,
|
| 834 |
+
side: THREE.DoubleSide,
|
| 835 |
+
shininess: 100,
|
| 836 |
+
specular: 0xffffff
|
| 837 |
});
|
| 838 |
const mesh = new THREE.Mesh(geometry, material);
|
| 839 |
moleculeGroup.add(mesh);
|
|
|
|
| 843 |
const scheme = document.getElementById('colorScheme').value;
|
| 844 |
|
| 845 |
if (scheme === 'element') {
|
| 846 |
+
return elementColors[atom.element] || 0xb2bec3;
|
| 847 |
} else if (scheme === 'residue') {
|
| 848 |
+
return residueColors[atom.element] || residueColors[atom.type] || 0xb2bec3;
|
| 849 |
} else if (scheme === 'chain') {
|
| 850 |
+
return atom.type.includes('strand1') || atom.type === 'backbone' ? 0xfd79a8 : 0x74b9ff;
|
| 851 |
} else if (scheme === 'hydrophobicity') {
|
| 852 |
+
// Simplified hydrophobicity scale with pastel colors
|
| 853 |
const hydrophobic = ['A', 'V', 'I', 'L', 'M', 'F', 'W'];
|
| 854 |
+
return hydrophobic.includes(atom.element) ? 0xfdcb6e : 0x81ecec;
|
| 855 |
} else if (scheme === 'charge') {
|
| 856 |
const positive = ['R', 'K', 'H'];
|
| 857 |
const negative = ['D', 'E'];
|
| 858 |
+
if (positive.includes(atom.element)) return 0x74b9ff;
|
| 859 |
+
if (negative.includes(atom.element)) return 0xfd79a8;
|
| 860 |
+
return 0xdfe6e9;
|
| 861 |
}
|
| 862 |
|
| 863 |
+
return 0xb2bec3;
|
| 864 |
}
|
| 865 |
|
| 866 |
function getAtomRadius(element) {
|