touch rotate

master
howard 2021-04-22 01:30:03 -07:00
parent bc6cd77592
commit df049a31cc
2 changed files with 27 additions and 60 deletions

View File

@ -678,7 +678,7 @@ var TrackballControls = function ( object, domElement ) {
break; break;
} }
scope.update()
} }
function touchend( event ) { function touchend( event ) {

View File

@ -16,7 +16,6 @@ export function drawOnClick1(e) {
// this.mode allow alow following modes to create new obj3ds // this.mode allow alow following modes to create new obj3ds
if (this.mode == "line") { if (this.mode == "line") {
this.toPush = drawLine(mouseLoc) this.toPush = drawLine(mouseLoc)
if (this.subsequent) { if (this.subsequent) {
// we pre-increment because we need to push the same c_id to the constraints // we pre-increment because we need to push the same c_id to the constraints
// map. we push into constraints map second because it makes more semantic sense // map. we push into constraints map second because it makes more semantic sense
@ -30,27 +29,12 @@ export function drawOnClick1(e) {
this.obj3d.children[this.obj3d.children.length - 2].userData.constraints.push(this.c_id) this.obj3d.children[this.obj3d.children.length - 2].userData.constraints.push(this.c_id)
this.toPush[0].userData.constraints.push(this.c_id) this.toPush[0].userData.constraints.push(this.c_id)
} else if (this.hovered.length) {
this.constraints.set(++this.c_id,
[
'points_coincident', -1,
[this.hovered[this.hovered.length - 1].name, this.toPush[0].name, -1, -1]
]
)
this.hovered[this.hovered.length - 1].userData.constraints.push(this.c_id)
this.toPush[0].userData.constraints.push(this.c_id)
this.updateOtherBuffers()
} }
} else if (this.mode == "arc") { } else if (this.mode == "arc") {
this.toPush = drawArc(mouseLoc) this.toPush = drawArc(mouseLoc)
}
if (this.hovered.length) { if (this.hovered.length && !this.subsequent) {
this.constraints.set(++this.c_id, this.constraints.set(++this.c_id,
[ [
'points_coincident', -1, 'points_coincident', -1,
@ -60,13 +44,8 @@ export function drawOnClick1(e) {
this.hovered[this.hovered.length - 1].userData.constraints.push(this.c_id) this.hovered[this.hovered.length - 1].userData.constraints.push(this.c_id)
this.toPush[0].userData.constraints.push(this.c_id) this.toPush[0].userData.constraints.push(this.c_id)
this.updateOtherBuffers() this.updateOtherBuffers()
} }
}
this.updatePoint = this.obj3d.children.length this.updatePoint = this.obj3d.children.length
this.obj3d.add(...this.toPush) this.obj3d.add(...this.toPush)
this.linkedObjs.set(this.l_id, [this.mode, this.toPush.map(e => e.name)]) this.linkedObjs.set(this.l_id, [this.mode, this.toPush.map(e => e.name)])
@ -98,13 +77,12 @@ export function drawOnClick2(e) {
this.updatePointsBuffer(this.updatePoint) this.updatePointsBuffer(this.updatePoint)
this.updateOtherBuffers() this.updateOtherBuffers()
// a this.mode == "" here will prevent event chain from persisisting // a this.mode == "" (set with esc) here will prevent event chain from persisisting
this.toPush.forEach(element => { this.toPush.forEach(element => { // make sure elements are selectable by sketch raycaster
element.layers.enable(2) element.layers.enable(2)
}); });
if (this.mode == "line") {
if (this.hovered.length) { if (this.hovered.length) {
this.constraints.set(++this.c_id, this.constraints.set(++this.c_id,
[ [
@ -118,24 +96,13 @@ export function drawOnClick2(e) {
} }
if (this.mode == "line") {
this.subsequent = true this.subsequent = true
this.drawOnClick1(e) this.drawOnClick1(e)
} else if (this.mode == "arc") { } else if (this.mode == "arc") {
if (this.hovered.length) {
this.constraints.set(++this.c_id,
[
'points_coincident', -1,
[this.hovered[this.hovered.length - 1].name, this.toPush[1].name, -1, -1]
]
)
this.hovered[this.hovered.length - 1].userData.constraints.push(this.c_id)
this.toPush[1].userData.constraints.push(this.c_id)
this.updateOtherBuffers()
}
drawArc3(this.toPush[0], this.toPush[1]) drawArc3(this.toPush[0], this.toPush[1])
this.canvas.addEventListener('pointermove', this.drawPreClick3) this.canvas.addEventListener('pointermove', this.drawPreClick3)