Note: The default ITS GitLab runner is a shared resource and is subject to slowdowns during heavy usage.
You can run your own GitLab runner that is dedicated just to your group if you need to avoid processing delays.

Commit 6a79021e authored by Songan Zhang's avatar Songan Zhang
Browse files

fix bug of 3D Coordinate translate

parent 0e0db9d9
......@@ -139,30 +139,22 @@ function Box(anchor, cursor, angle, boundingBox, boxHelper, data) {
}
// method to reheight the 3D bounding box manually, only under 3D mode
this.reheight = function (mouse) {
this.reheight = function (mouse, originalVertices) {
if (mouse.z != this.anchor.y) {
// console.log(mouse.z);
// var v1 = cursor.clone();
// var v2 = this.anchor.clone();
//
// v1.y = 0;
// v2.y = 0;
//
// // rotate cursor and anchor
// rotate(v1, v2, this.angle);
console.log("this.angle",this.angle)
// calculating corner points and rotating point
var maxVector = this.geometry.vertices[0].clone();
console.log(originalVertices.vertices[0]);
var maxVector = originalVertices.vertices[0].clone();
maxVector.y = 0;
var minVector = this.geometry.vertices[1].clone();
var minVector = originalVertices.vertices[1].clone();
minVector.y = 0;
var topLeft = this.geometry.vertices[2].clone();
var topLeft = originalVertices.vertices[2].clone();
topLeft.y = 0;
var bottomRight = this.geometry.vertices[3].clone();
var bottomRight = originalVertices.vertices[3].clone();
bottomRight.y = 0;
var topCenter = getCenter(maxVector, topLeft);
var bottomCenter = this.geometry.vertices[4].clone();
var bottomCenter = originalVertices.vertices[4].clone();
bottomCenter.y = 0;
var bottom = this.centerZ - this.heightCar/2;
......@@ -182,20 +174,6 @@ function Box(anchor, cursor, angle, boundingBox, boxHelper, data) {
// need to do this to make matrix invertible
maxVector.y += 0.00001;
// setting bounding box limits
this.boundingBox.set(minVector.clone(), maxVector.clone());
// rotate BoxHelper back
this.boxHelper.rotation.y = this.angle;
// setting y coordinate back to zero since we are done with drawing
// maxVector.y = 0;
// rotate back the corner points
rotate(minVector, maxVector, -this.angle);
rotate(topLeft, bottomRight, -this.angle);
rotate(topCenter, bottomCenter, -this.angle);
// set updated corner points used to resize box
this.geometry.vertices[0] = maxVector.clone();
this.geometry.vertices[1] = minVector.clone();
......@@ -205,8 +183,21 @@ function Box(anchor, cursor, angle, boundingBox, boxHelper, data) {
// this.geometry.vertices[5] = lowCenter.clone();
this.geometry.vertices[5] = highCenter.clone();
// rotate back the corner points
rotate(minVector, maxVector, this.angle);
rotate(topLeft, bottomRight, this.angle);
rotate(topCenter, bottomCenter, this.angle);
this.boxHelper.rotation.y = this.angle;
// setting bounding box limits
this.boundingBox.set(minVector.clone(), maxVector.clone());
this.boundingBox.max.y = this.centerZ + this.heightCar/2;
this.boundingBox.min.y = this.centerZ - this.heightCar/2;
console.log("Boundingbox min",boundingBox.min);
console.log("Boundingbox max",boundingBox.max);
// rotate BoxHelper back
this.boxHelper.rotation.y = this.angle;
// tell scene to update corner points
this.geometry.verticesNeedUpdate = true;
......
......@@ -29,6 +29,7 @@ var angle;
var hoverIdx, hoverBox;
var resizeBox, rotatingBox, reheightBox;
var dispPlane;
var temp_anchor;
var isResizing = false;
var isMoving = false;
var isRotating = false;
......@@ -398,8 +399,9 @@ function onDocumentMouseMove( event ) {
else if (mode3D) {
if (isReHeighting) {
var mouse = get3DIntersectPlane();
// console.log(cursor);
reheightBox.reheight(mouse);
console.log("mouse",mouse);
console.log("mouse_move temp anchor",temp_anchor[0]);
reheightBox.reheight(mouse, temp_anchor);
}
}
......@@ -510,6 +512,7 @@ function onDocumentMouseUp( event ) {
predictBox = reheightBox;
scene.remove(dispPlane);
dispPlane = null;
temp_anchor = null;
}
if (predictBox) {
predictLabel(predictBox);
......@@ -558,7 +561,9 @@ function onDocumentMouseDown( event ) {
isReHeighting = true;
reheightBox = box;
reheightBox.anchor = reheightBox.geometry.vertices[getOppositeCorner(closestIdx)].clone();
temp_anchor = reheightBox.geometry.clone();
console.log("reheightBox.anchor",reheightBox.anchor);
console.log("temp_anchor",temp_anchor);
dispPlane = get3DVerticalCoord(reheightBox);
}
}
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment