mirror of
https://github.com/xibyte/jsketcher
synced 2026-02-17 21:01:36 +01:00
grouping to curved surface
This commit is contained in:
parent
2f40461c78
commit
e97a7ba206
2 changed files with 33 additions and 4 deletions
|
|
@ -117,7 +117,7 @@ TCAD.Viewer = function(bus) {
|
|||
**/
|
||||
|
||||
|
||||
this.selectionMgr = new TCAD.FaceSelectionManager( 0xFAFAD2, null);
|
||||
this.selectionMgr = new TCAD.FaceSelectionManager( 0xFAFAD2, 0xFF0000, null);
|
||||
|
||||
var raycaster = new THREE.Raycaster();
|
||||
|
||||
|
|
@ -198,16 +198,26 @@ TCAD.Viewer.prototype.select = function(polyFace) {
|
|||
this.bus.notify('selection', polyFace);
|
||||
};
|
||||
|
||||
TCAD.FaceSelectionManager = function(selectionColor, defaultColor) {
|
||||
TCAD.FaceSelectionManager = function(selectionColor, readOnlyColor, defaultColor) {
|
||||
this.selectionColor = selectionColor;
|
||||
this.readOnlyColor = readOnlyColor;
|
||||
this.defaultColor = defaultColor;
|
||||
this.selection = [];
|
||||
};
|
||||
|
||||
TCAD.FaceSelectionManager.prototype.select = function(polyFace) {
|
||||
this.clear();
|
||||
this.selection.push(polyFace);
|
||||
TCAD.view.setFaceColor(polyFace, this.selectionColor);
|
||||
if (polyFace.curvedSurfaces !== null) {
|
||||
for (var i = 0; i < polyFace.curvedSurfaces.length; i++) {
|
||||
var face = polyFace.curvedSurfaces[i];
|
||||
this.selection.push(face);
|
||||
TCAD.view.setFaceColor(face, this.readOnlyColor);
|
||||
}
|
||||
} else {
|
||||
this.selection.push(polyFace);
|
||||
TCAD.view.setFaceColor(polyFace, this.selectionColor);
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
TCAD.FaceSelectionManager.prototype.contains = function(polyFace) {
|
||||
|
|
|
|||
|
|
@ -502,6 +502,10 @@ TCAD.utils.getDerivedID = function(shared) {
|
|||
return shared.__tcad && !!shared.__tcad.csgInfo && !!shared.__tcad.csgInfo.derivedFrom ? shared.__tcad.csgInfo.derivedFrom.id : null;
|
||||
};
|
||||
|
||||
TCAD.utils.getDerivedFrom = function(shared) {
|
||||
return shared.__tcad && !!shared.__tcad.csgInfo && !!shared.__tcad.csgInfo.derivedFrom ? shared.__tcad.csgInfo.derivedFrom : null;
|
||||
};
|
||||
|
||||
/** @constructor */
|
||||
TCAD.Solid = function(csg, material) {
|
||||
THREE.Geometry.call( this );
|
||||
|
|
@ -518,6 +522,7 @@ TCAD.Solid = function(csg, material) {
|
|||
|
||||
this.polyFaces = [];
|
||||
this.wires = TCAD.struct.hashTable.forEdge();
|
||||
this.curvedSurfaces = {};
|
||||
var scope = this;
|
||||
function threeV(v) {return new THREE.Vector3( v.x, v.y, v.z )}
|
||||
|
||||
|
|
@ -553,6 +558,7 @@ TCAD.Solid = function(csg, material) {
|
|||
//TCAD.view.setFaceColor(polyFace, TCAD.utils.isSmoothPiece(group.shared) ? 0xFF0000 : null);
|
||||
off = this.vertices.length;
|
||||
}
|
||||
this.collectCurvedSurface(polyFace);
|
||||
this.collectWires(polyFace);
|
||||
}
|
||||
|
||||
|
|
@ -565,6 +571,18 @@ if (typeof THREE !== "undefined") {
|
|||
TCAD.Solid.prototype = Object.create( THREE.Geometry.prototype );
|
||||
}
|
||||
|
||||
TCAD.Solid.prototype.collectCurvedSurface = function(face) {
|
||||
var derivedFrom = TCAD.utils.getDerivedFrom(face.csgGroup.shared);
|
||||
if (derivedFrom === null || derivedFrom._class !== "TCAD.TWO.Arc" && derivedFrom._class !== "TCAD.TWO.Circle" ) return;
|
||||
var surfaces = this.curvedSurfaces[derivedFrom.id];
|
||||
if (surfaces === undefined) {
|
||||
surfaces = [];
|
||||
this.curvedSurfaces[derivedFrom.id] = surfaces;
|
||||
}
|
||||
surfaces.push(face);
|
||||
face.curvedSurfaces = surfaces;
|
||||
};
|
||||
|
||||
TCAD.Solid.prototype.collectWires = function(face) {
|
||||
|
||||
function contains(planes, plane) {
|
||||
|
|
@ -649,6 +667,7 @@ TCAD.SketchFace = function(solid, csgGroup) {
|
|||
this.csgGroup = csgGroup;
|
||||
this.faces = [];
|
||||
this.sketch3DGroup = null;
|
||||
this.curvedSurfaces = null;
|
||||
};
|
||||
|
||||
if (typeof THREE !== "undefined") {
|
||||
|
|
|
|||
Loading…
Reference in a new issue