mirror of
https://github.com/xibyte/jsketcher
synced 2025-12-07 08:53:25 +01:00
clean up unused code
This commit is contained in:
parent
68fe161e30
commit
0926d2082d
6 changed files with 0 additions and 172 deletions
|
|
@ -1,56 +0,0 @@
|
||||||
import {findDiff} from 'gems/iterables';
|
|
||||||
import {entitySelectionToken} from '../controls/pickControlPlugin';
|
|
||||||
|
|
||||||
export class AbstractSelectionMarker {
|
|
||||||
|
|
||||||
constructor(context, entity) {
|
|
||||||
this.context = context;
|
|
||||||
this.entity = entity;
|
|
||||||
this.selection = [];
|
|
||||||
this.context.streams.selection[entity].attach(this.update);
|
|
||||||
}
|
|
||||||
|
|
||||||
update = () => {
|
|
||||||
let selection = this.context.services.selection[this.entity].objects;
|
|
||||||
if (!selection) {
|
|
||||||
if (this.selection.length !== 0) {
|
|
||||||
for (let obj of this.selection) {
|
|
||||||
this.unMark(obj);
|
|
||||||
}
|
|
||||||
this.selection = [];
|
|
||||||
}
|
|
||||||
this.context.services.viewer.render();
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
let [, toMark, toWithdraw] = findDiff(selection, this.selection);
|
|
||||||
for (let obj of toMark) {
|
|
||||||
this.selection.push(obj);
|
|
||||||
this.mark(obj);
|
|
||||||
}
|
|
||||||
|
|
||||||
for (let obj of toWithdraw) {
|
|
||||||
this.selection.splice(this.selection.indexOf(obj), 1);
|
|
||||||
this.unMark(obj);
|
|
||||||
}
|
|
||||||
this.context.services.viewer.render();
|
|
||||||
};
|
|
||||||
|
|
||||||
mark(obj) {
|
|
||||||
throw 'abstract';
|
|
||||||
}
|
|
||||||
|
|
||||||
unMark(obj) {
|
|
||||||
throw 'abstract';
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
export function setFacesColor(faces, color) {
|
|
||||||
for (let face of faces) {
|
|
||||||
if (color === null) {
|
|
||||||
face.color.set(new THREE.Color());
|
|
||||||
} else {
|
|
||||||
face.color.set( color );
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
@ -1,16 +0,0 @@
|
||||||
import {AbstractSelectionMarker} from './abstractSelectionMarker';
|
|
||||||
|
|
||||||
export class EdgeSelectionMarker extends AbstractSelectionMarker {
|
|
||||||
|
|
||||||
constructor (context) {
|
|
||||||
super(context, 'edge');
|
|
||||||
}
|
|
||||||
|
|
||||||
mark(obj) {
|
|
||||||
obj.marker.material.visible = true;
|
|
||||||
}
|
|
||||||
|
|
||||||
unMark(obj) {
|
|
||||||
obj.marker.material.visible = false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
@ -1,24 +0,0 @@
|
||||||
import {AbstractSelectionMarker} from "./abstractSelectionMarker";
|
|
||||||
import {setAttribute, getAttribute} from 'scene/objectData';
|
|
||||||
|
|
||||||
export class LineMarker extends AbstractSelectionMarker {
|
|
||||||
|
|
||||||
constructor(context, entity, selectionMaterial) {
|
|
||||||
super(context, entity);
|
|
||||||
this.selectionMaterial = selectionMaterial;
|
|
||||||
}
|
|
||||||
|
|
||||||
mark(obj) {
|
|
||||||
let line = this.getLine(obj);
|
|
||||||
setAttribute(line, 'selection_defaultMaterial', line.material);
|
|
||||||
line.material = this.selectionMaterial;
|
|
||||||
}
|
|
||||||
|
|
||||||
unMark(obj) {
|
|
||||||
let line = this.getLine(obj);
|
|
||||||
line.material = getAttribute(line, 'selection_defaultMaterial');
|
|
||||||
line.material = this.selectionMaterial;
|
|
||||||
}
|
|
||||||
|
|
||||||
getLine() {throw 'abstract'}
|
|
||||||
}
|
|
||||||
|
|
@ -1,47 +0,0 @@
|
||||||
import * as stitching from 'brep/operations/stitching'
|
|
||||||
import {AbstractSelectionMarker, setFacesColor} from "./abstractSelectionMarker";
|
|
||||||
|
|
||||||
export class SelectionMarker extends AbstractSelectionMarker {
|
|
||||||
|
|
||||||
constructor(context, markColor, readOnlyColor, defaultColor) {
|
|
||||||
super(context, 'face');
|
|
||||||
this.markColor = markColor;
|
|
||||||
this.defaultColor = defaultColor;
|
|
||||||
this.readOnlyColor = readOnlyColor;
|
|
||||||
}
|
|
||||||
|
|
||||||
mark(sceneFace) {
|
|
||||||
this.setColor(sceneFace, this.markColor, this.readOnlyColor);
|
|
||||||
}
|
|
||||||
|
|
||||||
unMark(sceneFace) {
|
|
||||||
this.setColor(sceneFace, this.defaultColor, this.defaultColor);
|
|
||||||
}
|
|
||||||
|
|
||||||
setColor(sceneFace, color, groupColor) {
|
|
||||||
const group = this.findGroup(sceneFace);
|
|
||||||
if (group) {
|
|
||||||
for (let i = 0; i < group.length; i++) {
|
|
||||||
let face = group[i];
|
|
||||||
setFacesColor(face.meshFaces, groupColor);
|
|
||||||
face.solid.mesh.geometry.colorsNeedUpdate = true;
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
setFacesColor(sceneFace.meshFaces, color);
|
|
||||||
sceneFace.solid.mesh.geometry.colorsNeedUpdate = true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
findGroup(sceneFace) {
|
|
||||||
if (sceneFace.curvedSurfaces) {
|
|
||||||
return sceneFace.curvedSurfaces;
|
|
||||||
}
|
|
||||||
if (sceneFace.brepFace) {
|
|
||||||
const stitchedFace = sceneFace.brepFace.data[stitching.FACE_CHUNK];
|
|
||||||
if (stitchedFace) {
|
|
||||||
return stitchedFace.faces.map(f => f.data['scene.face']);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return undefined;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
@ -1,17 +0,0 @@
|
||||||
import {findDiff} from 'gems/iterables';
|
|
||||||
|
|
||||||
export const selectionSynchronizer = (entity, findEntity, color) => ([old, curr]) => {
|
|
||||||
let [, toWithdraw, toMark] = findDiff(old, curr);
|
|
||||||
toWithdraw.forEach(id => {
|
|
||||||
let model = findEntity(entity, id);
|
|
||||||
if (model) {
|
|
||||||
model.ext.view.withdraw();
|
|
||||||
}
|
|
||||||
});
|
|
||||||
toMark.forEach(id => {
|
|
||||||
let model = findEntity(entity, id);
|
|
||||||
if (model) {
|
|
||||||
model.ext.view.mark(id, color);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
};
|
|
||||||
|
|
@ -1,12 +0,0 @@
|
||||||
import {LineMarker} from './lineMarker';
|
|
||||||
|
|
||||||
export class SketchSelectionMarker extends LineMarker {
|
|
||||||
|
|
||||||
constructor(context, selectionMaterial) {
|
|
||||||
super(context, 'sketchObject', selectionMaterial);
|
|
||||||
}
|
|
||||||
|
|
||||||
getLine(obj) {
|
|
||||||
return obj.viewObject;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
Loading…
Reference in a new issue