Commit 29d65126 authored by Amanda Ghassaei's avatar Amanda Ghassaei

starting to add nucleotides

parent d11ee567
......@@ -41,8 +41,14 @@ define(['underscore', 'three', 'threeModel', 'lattice', 'appState', 'cubeCell'],
callback(parts);
});
} else if (lattice.get("partType") == "dnaStraight") {
require(['gikPartLowPoly'], function(PartSubclass){
parts.push(new PartSubclass(self.index.x, self));
require(['dnaStraightPart'], function(PartSubclass){
for (var i=0;i<16;i++){
parts.push(new PartSubclass(self.index.x, self, {
vertIndex: i,
isBridge: false
}));
}
parts.push(new PartSubclass(self.index.x, self, {isBridge: true}));
callback(parts);
});
}
......
......@@ -108,6 +108,7 @@ require.config({
kennyTeqHighResPart: 'parts/KennyTeqHighResPart',
samTeqPart: 'parts/SamTeqPart',
legoPart: 'parts/LegoPart',
dnaStraightPart: 'parts/DNAStraightPart',
//materials
materials: 'materials/DMAMaterials',
......@@ -212,7 +213,8 @@ require.config({
gikEndPartLowPolySTL: 'assets/stls/parts/GIKEndPartLowPoly.stl',
kennyTeqPartSTL: 'assets/stls/parts/KennyTeqPart.stl',
kennyTeqPartHighResSTL: 'assets/stls/parts/KennyTeqPartHighRes.stl',
samTeqPartSTL: 'assets/stls/parts/SamTeqPart.stl'
samTeqPartSTL: 'assets/stls/parts/SamTeqPart.stl',
legoBrickSTL: 'assets/stls/parts/legoBrick1x1.stl'
},
......
......@@ -6,7 +6,7 @@
define(['underscore', 'three'], function(_, THREE){
function DMAPart(index, parent) {
function DMAPart(index, parent, options) {
this.parentCell = parent;
this.index = index;
this.mesh = this._buildMesh();
......
/**
* Created by aghassaei on 9/14/15.
*/
define(['underscore', 'stlLoader', 'gikPart'], function(_, THREE, GIKPart){
var zScale = 1/8;
var unitGeo = new THREE.BoxGeometry(0.2, 0.2, zScale);
var bridgeGeo = new THREE.BoxGeometry(0.3, 0.4, zScale);
var bridgeMaterial = new THREE.MeshLambertMaterial({color:'#000000'});
var nuclMaterials = {
a: new THREE.MeshLambertMaterial({color:"#cc00cc"}),
t: new THREE.MeshLambertMaterial({color:"#ff6600"}),
c: new THREE.MeshLambertMaterial({color:"#66ffff"}),
g: new THREE.MeshLambertMaterial({color:"#00ff33"})
};
function DNAStraightPart(index, parent, options){
this._isBridge = options.isBridge;
if (!this._isBridge){
this._vertIndex = options.vertIndex;
if (!options.nuclType) this._nuclType = this._randomNucleotide();
else this._nuclType = options.nuclType;
}
GIKPart.call(this, index, parent, options);
}
DNAStraightPart.prototype = Object.create(GIKPart.prototype);
DNAStraightPart.prototype._randomNucleotide = function(){
var rand = Math.random();
if (rand < 0.25) return 'a';
if (rand < 0.5) return 't';
if (rand < 0.75) return 'c';
return 'g';
};
DNAStraightPart.prototype._getGeometry = function(){
if (this._isBridge) return bridgeGeo;
return unitGeo;
};
DNAStraightPart.prototype.getMaterial = function(returnTHREEObject){
if (returnTHREEObject) {
if (this._isBridge) return bridgeMaterial;
return nuclMaterials[this._nuclType];
}
return GIKPart.prototype.getMaterial.call(this, returnTHREEObject);
};
DNAStraightPart.prototype._translatePart = function(mesh){
if (this._isBridge){
mesh.translateX(0.15+0.2);
mesh.translateZ(this.parentCell.zScale()/2-zScale/2);
return mesh;
}
var xOffset = 0.1;
var yOffset = -0.1;
if (this.index == 1) {
xOffset = -0.1;
yOffset = 0.1;
}
mesh.position.set(xOffset, yOffset, this.parentCell.zScale()/2-zScale/2-this._vertIndex*zScale);
return mesh;
};
return DNAStraightPart;
});
\ No newline at end of file
......@@ -3,7 +3,7 @@
*/
define(['underscore', 'stlLoader', 'gikPart', 'bin!../assets/stls/parts/legoBrick1x1.stl'], function(_, THREE, GIKPart, stl){
define(['underscore', 'stlLoader', 'gikPart', 'bin!legoBrickSTL'], function(_, THREE, GIKPart, stl){
var loader = new THREE.STLLoader();
var unitGeo = preProcessGeo(loader.parse(stl));
......
......@@ -254,11 +254,11 @@ define(['three'], function(THREE){
dnaBricks: {
name: "DNA Bricks",
parts: {
dnaLego: {
name: "Lego Blocks"
},
dnaStraight: {
name: "DNA (straight chains)"
},
dnaLego: {
name: "Lego Blocks"
}
},
aspectRatio: new THREE.Vector3(1,1,1),
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment