mirror of
https://github.com/xibyte/jsketcher
synced 2026-02-10 17:34:14 +01:00
visualizing points
This commit is contained in:
parent
e7c2ac0058
commit
6cb9cf8a72
8 changed files with 87 additions and 19 deletions
|
|
@ -94,9 +94,9 @@ export const HoleOperation: OperationDescriptor<HoleParams> = {
|
|||
holeSolids.push(makeHoleSolid(
|
||||
{
|
||||
id: "holeP" + holeSourceElement.id,
|
||||
x: holeSourceElement.point.x,
|
||||
y: holeSourceElement.point.y,
|
||||
z: holeSourceElement.point.z,
|
||||
x: holeSourceElement.pt.x,
|
||||
y: holeSourceElement.pt.y,
|
||||
z: holeSourceElement.pt.z,
|
||||
csys,
|
||||
invert: params.invertDirection
|
||||
}, ctx));
|
||||
|
|
|
|||
|
|
@ -4,6 +4,7 @@ export enum EntityKind {
|
|||
FACE = 'face',
|
||||
EDGE = 'edge',
|
||||
VERTEX = 'vertex',
|
||||
POINT = 'point',
|
||||
SKETCH_OBJECT = 'sketchObject',
|
||||
DATUM = 'datum',
|
||||
DATUM_AXIS = 'datumAxis',
|
||||
|
|
@ -15,6 +16,7 @@ export const SHELL = EntityKind.SHELL;
|
|||
export const FACE = EntityKind.FACE;
|
||||
export const EDGE = EntityKind.EDGE;
|
||||
export const VERTEX = EntityKind.VERTEX;
|
||||
export const POINT = EntityKind.POINT;
|
||||
export const SKETCH_OBJECT = EntityKind.SKETCH_OBJECT;
|
||||
export const DATUM = EntityKind.DATUM;
|
||||
export const DATUM_AXIS = EntityKind.DATUM_AXIS;
|
||||
|
|
|
|||
|
|
@ -119,6 +119,7 @@ export class MFace extends MObject {
|
|||
};
|
||||
addSketchObjects(sketch.connections);
|
||||
addSketchObjects(sketch.loops);
|
||||
addSketchObjects(sketch.points);
|
||||
|
||||
|
||||
const index = new Map();
|
||||
|
|
|
|||
|
|
@ -8,6 +8,8 @@ import {SketchMesh} from "cad/scene/views/shellView";
|
|||
import {FACE} from "cad/model/entities";
|
||||
import {setAttribute} from "scene/objectData";
|
||||
import {ViewMode} from "cad/scene/viewer";
|
||||
import {SketchPoint} from "cad/sketch/sketchModel";
|
||||
import {SketchPointView} from "cad/scene/views/sketchPointView";
|
||||
|
||||
export class SketchingView extends View {
|
||||
|
||||
|
|
@ -35,7 +37,13 @@ export class SketchingView extends View {
|
|||
|
||||
const sketchTr = this.model.sketchToWorldTransformation;
|
||||
for (const sketchObject of this.model.sketchObjects) {
|
||||
const sov = new SketchObjectView(this.ctx, sketchObject, sketchTr);
|
||||
let sov;
|
||||
if (sketchObject.sketchPrimitive instanceof SketchPoint) {
|
||||
sov = new SketchPointView(this.ctx, sketchObject, sketchTr);
|
||||
} else {
|
||||
sov = new SketchObjectView(this.ctx, sketchObject, sketchTr);
|
||||
}
|
||||
|
||||
SceneGraph.addToGroup(this.sketchGroup, sov.rootGroup);
|
||||
this.sketchObjectViews.push(sov);
|
||||
}
|
||||
|
|
|
|||
20
web/app/cad/scene/views/sketchPointView.js
Normal file
20
web/app/cad/scene/views/sketchPointView.js
Normal file
|
|
@ -0,0 +1,20 @@
|
|||
import {View} from "cad/scene/views/view";
|
||||
import {VertexObject} from "cad/scene/views/vertexView";
|
||||
|
||||
export class SketchPointView extends View {
|
||||
|
||||
constructor(ctx, sketchPoint) {
|
||||
super(ctx, sketchPoint);
|
||||
this.rootGroup = new VertexObject(ctx.viewer, 15, 100, () => this.rootGroup.position, true, 0x0000FF);
|
||||
|
||||
this.rootGroup.position.x = sketchPoint.sketchPrimitive.pt.x;
|
||||
this.rootGroup.position.y = sketchPoint.sketchPrimitive.pt.y;
|
||||
this.rootGroup.position.z = sketchPoint.sketchPrimitive.pt.z;
|
||||
}
|
||||
|
||||
dispose() {
|
||||
this.rootGroup.dispose();
|
||||
super.dispose();
|
||||
// this.rootGroup.dispose();
|
||||
}
|
||||
}
|
||||
|
|
@ -26,11 +26,11 @@ export class VertexView extends View {
|
|||
}
|
||||
}
|
||||
|
||||
class VertexObject extends ConstantScaleGroup {
|
||||
export class VertexObject extends ConstantScaleGroup {
|
||||
|
||||
constructor(viewer, sizePx, sizeModel, getOrigin) {
|
||||
constructor(viewer, sizePx, sizeModel, getOrigin, visibleByDefault, defaultColor) {
|
||||
super(viewer.sceneSetup, sizePx, sizeModel, getOrigin);
|
||||
this.sphere = new VertexSphere(viewer);
|
||||
this.sphere = new VertexSphere(viewer, visibleByDefault, defaultColor);
|
||||
this.add(this.sphere);
|
||||
}
|
||||
|
||||
|
|
@ -42,14 +42,17 @@ class VertexObject extends ConstantScaleGroup {
|
|||
class VertexSphere extends Mesh {
|
||||
|
||||
mouseInside;
|
||||
visibleByDefault;
|
||||
|
||||
constructor(viewer) {
|
||||
constructor(viewer, visibleByDefault = false, defaultColor = 0xFFFFFF) {
|
||||
super(new SphereGeometry( 1 ), new MeshBasicMaterial({
|
||||
transparent: true,
|
||||
opacity: 0.5,
|
||||
color: 0xFFFFFF,
|
||||
visible: false
|
||||
color: defaultColor,
|
||||
visible: visibleByDefault
|
||||
}));
|
||||
this.visibleByDefault = visibleByDefault;
|
||||
this.defaultColor = defaultColor;
|
||||
this.viewer = viewer;
|
||||
this.scale.multiplyScalar(CSYS_SIZE_MODEL * 0.2);
|
||||
}
|
||||
|
|
@ -69,7 +72,7 @@ class VertexSphere extends Mesh {
|
|||
onMouseLeave(e) {
|
||||
this.mouseInside = false;
|
||||
this.updateVisibility();
|
||||
this.material.color.setHex(0xFFFFFF);
|
||||
this.material.color.setHex(this.defaultColor);
|
||||
this.viewer.requestRender();
|
||||
}
|
||||
|
||||
|
|
@ -90,7 +93,6 @@ class VertexSphere extends Mesh {
|
|||
}
|
||||
|
||||
updateVisibility() {
|
||||
const datum3D = this.parent.parent;
|
||||
this.viewer.setVisualProp(this.material, 'visible', this.mouseInside);
|
||||
this.viewer.setVisualProp(this.material, 'visible', this.visibleByDefault || this.mouseInside);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -125,6 +125,45 @@ export class Segment extends SketchPrimitive {
|
|||
}
|
||||
}
|
||||
|
||||
export class SketchPoint extends SketchPrimitive {
|
||||
|
||||
pt: Vector;
|
||||
|
||||
constructor(id, pt) {
|
||||
super(id);
|
||||
this.pt = pt;
|
||||
}
|
||||
|
||||
tessellate(resolution) {
|
||||
return [];
|
||||
}
|
||||
|
||||
toVerbNurbs(tr) {
|
||||
const a = tr(this.pt).data();
|
||||
return new verb.geom.Line(a, a);
|
||||
}
|
||||
|
||||
toGenericForm() {
|
||||
return [this.pt];
|
||||
}
|
||||
|
||||
toOCCGeometry(oci: OCCCommandInterface, underName: string, csys: CSys) {
|
||||
throw 'unsupported';
|
||||
}
|
||||
|
||||
tangentAtStart(): Vector {
|
||||
throw 'unsupported';
|
||||
}
|
||||
|
||||
tangentAtEnd(): Vector {
|
||||
throw 'unsupported';
|
||||
}
|
||||
|
||||
massiveness() {
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
export class Arc extends SketchPrimitive {
|
||||
|
||||
a: Vector;
|
||||
|
|
|
|||
|
|
@ -121,12 +121,8 @@ export function ReadSketch(sketch, sketchId) {
|
|||
const x = readSketchFloat(data.x);
|
||||
const y = readSketchFloat(data.y);
|
||||
const z = 0;
|
||||
|
||||
//out.points.push(ReadSketchPoint(data));
|
||||
createdObj = {
|
||||
id:getID(obj),
|
||||
point:{x,y,z}
|
||||
} as any;
|
||||
|
||||
createdObj = new sm.SketchPoint(getID(obj), new Vector(x,y,z));
|
||||
out.points.push(createdObj);
|
||||
}
|
||||
createdObj.construction = isConstructionObject;
|
||||
|
|
|
|||
Loading…
Reference in a new issue