master
howard 2021-03-31 17:11:42 -07:00
parent fb17612e2a
commit 351b794719
5 changed files with 16 additions and 16 deletions

View File

@ -5,7 +5,7 @@
import * as THREE from '../node_modules/three/src/Three'; import * as THREE from '../node_modules/three/src/Three';
// import { OrbitControls } from './utils/OrbitControls' // import { OrbitControls } from './utils/OrbitControls'
import { TrackballControls } from './utils/trackball' import { TrackballControls } from './utils/trackball'
import { Sketcher } from './sketcher/Sketcher' import { TwoDEnv } from './sketcher/TwoDEnv'
import Stats from './utils/stats.module.js'; import Stats from './utils/stats.module.js';
import { add3DPoint } from './datums' import { add3DPoint } from './datums'
@ -201,7 +201,7 @@ async function addSketch() {
} }
} }
const sketcher = new Sketcher(this.camera, this.canvas, this.store) const sketcher = new TwoDEnv(this.camera, this.canvas, this.store)
if (references.length == 1 && references[0].name[0] == 'd') { if (references.length == 1 && references[0].name[0] == 'd') {
this.sketch.add(sketcher.sketch) this.sketch.add(sketcher.sketch)

View File

@ -5,14 +5,14 @@ import * as THREE from '../../node_modules/three/src/Three';
import { drawOnClick1, drawOnClick2, drawPreClick2, drawClear } from './drawEvents' import { drawOnClick1, drawOnClick2, drawPreClick2, drawClear } from './drawEvents'
import { onHover, onDrag, onPick, onRelease } from '../utils/mouseEvents' import { onHover, onDrag, onPick, onRelease } from '../utils/mouseEvents'
import { addDimension, setCoincident } from './constraintEvents' import { addDimension, setCoincident } from './constraintEvents'
import { get3PtArc } from './sketchArc' import { get3PtArc } from './drawArc'
import { _vec2, _vec3, raycaster } from '../utils/static' import { _vec2, _vec3, raycaster } from '../utils/static'
import { replacer, reviver } from '../utils/mapJSONReplacer' import { replacer, reviver } from '../utils/mapJSONReplacer'
class Sketcher { class TwoDEnv {
constructor(camera, canvas, store, sketch) { constructor(camera, canvas, store, sketch) {
@ -352,7 +352,7 @@ const _y = new THREE.Vector3();
const _z = new THREE.Vector3(); const _z = new THREE.Vector3();
Object.assign(Sketcher.prototype, Object.assign(TwoDEnv.prototype,
{ {
linkNum: { linkNum: {
'line': 0, 'line': 0,
@ -370,4 +370,4 @@ Object.assign(Sketcher.prototype,
export { Sketcher } export { TwoDEnv }

View File

@ -6,7 +6,7 @@ import {ptObj, lineObj} from '../utils/static'
const n = 30 const n = 30
export function sketchArc(mouseLoc) { export function drawArc(mouseLoc) {
const p1 = ptObj(mouseLoc) const p1 = ptObj(mouseLoc)
p1.matrixAutoUpdate = false; p1.matrixAutoUpdate = false;
@ -26,7 +26,7 @@ export function sketchArc(mouseLoc) {
return [p1, p2, p3, arc] return [p1, p2, p3, arc]
} }
export function sketchArc2(mouseLoc, toPush) { export function drawArc2(mouseLoc, toPush) {
const [p1, p2, p3, arc] = toPush const [p1, p2, p3, arc] = toPush
p2.geometry.attributes.position.set(mouseLoc); p2.geometry.attributes.position.set(mouseLoc);

View File

@ -1,6 +1,6 @@
import { sketchArc, sketchArc2 } from './sketchArc' import { drawArc, drawArc2 } from './drawArc'
import { sketchLine, sketchLine2 } from './sketchLine' import { drawLine, drawLine2 } from './drawLine'
export function drawOnClick1(e) { export function drawOnClick1(e) {
if (e.buttons !== 1) return if (e.buttons !== 1) return
@ -8,9 +8,9 @@ export function drawOnClick1(e) {
const mouseLoc = this.getLocation(e); const mouseLoc = this.getLocation(e);
if (this.mode == "line") { if (this.mode == "line") {
this.toPush = sketchLine.call(this, mouseLoc) this.toPush = drawLine.call(this, mouseLoc)
} else if (this.mode == "arc") { } else if (this.mode == "arc") {
this.toPush = sketchArc(mouseLoc) this.toPush = drawArc(mouseLoc)
} }
this.updatePoint = this.sketch.children.length this.updatePoint = this.sketch.children.length
@ -31,9 +31,9 @@ export function drawPreClick2(e) {
const mouseLoc = this.getLocation(e); const mouseLoc = this.getLocation(e);
if (this.mode == "line") { if (this.mode == "line") {
sketchLine2(mouseLoc, this.toPush) drawLine2(mouseLoc, this.toPush)
} else if (this.mode == 'arc') { } else if (this.mode == 'arc') {
sketchArc2(mouseLoc, this.toPush) drawArc2(mouseLoc, this.toPush)
} }
this.sketch.dispatchEvent({ type: 'change' }) this.sketch.dispatchEvent({ type: 'change' })

View File

@ -1,7 +1,7 @@
import * as THREE from '../../node_modules/three/src/Three'; import * as THREE from '../../node_modules/three/src/Three';
import {ptObj, lineObj} from '../utils/static' import {ptObj, lineObj} from '../utils/static'
export function sketchLine(mouseLoc) { export function drawLine(mouseLoc) {
const p1 = ptObj() const p1 = ptObj()
@ -40,7 +40,7 @@ export function sketchLine(mouseLoc) {
return [p1, p2, line]; return [p1, p2, line];
} }
export function sketchLine2(mouseLoc, toPush) { export function drawLine2(mouseLoc, toPush) {
const [p1, p2, line] = toPush const [p1, p2, line] = toPush