diff --git a/assets/stls/parts/edgeVoxPartLowPoly.stl b/assets/stls/parts/edgeVoxPartLowPoly.stl index 42ad99e0e53e5cc1443780d51e551ce4677ce582..efef6ae803fd1e357be42cd9bb331ea7f8b14cee 100644 Binary files a/assets/stls/parts/edgeVoxPartLowPoly.stl and b/assets/stls/parts/edgeVoxPartLowPoly.stl differ diff --git a/js/fea/DmaCell.js b/js/fea/DmaCell.js index e44345cd827d9810ffd3eca7b4dc69b91d4c5fd8..cb00ab3429ed8ce41569b2125bf16bbcbe6bc758 100644 --- a/js/fea/DmaCell.js +++ b/js/fea/DmaCell.js @@ -167,6 +167,9 @@ DMACell.prototype._initParts = function(){ return [];//override in subclasses }; +DMACell.prototype.changePartType = function(){//override in subclasses +}; + DMACell.prototype.removePart = function(index){ this.parts[index].destroy(); this.parts[index] = null; diff --git a/js/fea/DmaCellOcta.js b/js/fea/DmaCellOcta.js index fda02f81954dd5924dc98a9e630b8ef478154140..a0a1afc1fa867b4900cf0f32bbda595dab527d01 100644 --- a/js/fea/DmaCellOcta.js +++ b/js/fea/DmaCellOcta.js @@ -156,7 +156,22 @@ function DMARotatedEdgeCell(indices, scale, cellMode, partType){ DMARotatedEdgeCell.prototype = Object.create(DMACell.prototype); DMARotatedEdgeCell.prototype._initParts = function(){ - return [new DMAEdgeVoxPart(0, this)]; + return this.changePartType(dmaGlobals.lattice.get("partType")); +}; + +DMARotatedEdgeCell.prototype.changePartType = function(type){ + var newParts = []; + if (type == "vox"){ + newParts.push(new DMAEdgeVoxPart(0, this)); + } else if (type == "voxLowPoly"){ + newParts.push(new DMAEdgeVoxPartLowPoly(0, this)); + } else { + console.warn("part type not recognized"); + return; + } + if (!this.parts) return newParts; + this.destroyParts(); + this.parts = newParts; }; DMARotatedEdgeCell.prototype._doMeshTransformations = function(mesh){ diff --git a/js/fea/DmaPart.js b/js/fea/DmaPart.js index 48afeb37705b621bce40a2a32303a5a1c30532d4..804b40e278338275f15c0ca57e86a97e9171ff3a 100644 --- a/js/fea/DmaPart.js +++ b/js/fea/DmaPart.js @@ -180,6 +180,36 @@ var partMaterial = new THREE.MeshLambertMaterial({ color:0xffffff, shading: THRE })(); +(function () { + + var unitPartGeo; + + //import part geometry + var loader = new THREE.STLLoader(); + loader.load("assets/stls/parts/edgeVoxPartLowPoly.stl", function(geometry){ + + unitPartGeo = geometry; + unitPartGeo.computeBoundingBox(); + var unitScale = 0.706/unitPartGeo.boundingBox.max.y; + unitPartGeo.applyMatrix(new THREE.Matrix4().makeScale(unitScale, unitScale, unitScale)); + }); + + function DMAEdgeVoxPartLowPoly(type, parent){ + DMAPart.call(this, type, parent); + } + DMAEdgeVoxPartLowPoly.prototype = Object.create(DMAPart.prototype); + + DMAEdgeVoxPartLowPoly.prototype._makeMeshForType = function(){ + var mesh = new THREE.Mesh(unitPartGeo, partMaterial); + mesh.myPart = this;//need a ref back to this part + return mesh; + }; + + self.DMAEdgeVoxPartLowPoly = DMAEdgeVoxPartLowPoly; + +})(); + + (function () { var unitPartGeo;