Skip to content

Commit

Permalink
rename copy(),getCopy() to clone()
Browse files Browse the repository at this point in the history
  • Loading branch information
iSpring committed Oct 18, 2016
1 parent d039876 commit c46c842
Show file tree
Hide file tree
Showing 9 changed files with 38 additions and 38 deletions.
2 changes: 1 addition & 1 deletion ts/world/Event.ts
Expand Up @@ -186,7 +186,7 @@ const EventModule = {
var pIntersect = pickResult[0];
var pCamera = camera.getPosition();
var legnth2Intersect = MathUtils.getLengthFromVerticeToVertice(pCamera, pIntersect);
var mat = camera.matrix.copy();
var mat = camera.matrix.clone();
mat.setColumnTrans(pIntersect.x, pIntersect.y, pIntersect.z);
var DELTA_RADIAN = MathUtils.degreeToRadian(DELTA_PITCH);
mat.localRotateX(DELTA_RADIAN);
Expand Down
10 changes: 5 additions & 5 deletions ts/world/Line.ts
Expand Up @@ -7,23 +7,23 @@ class Line{
public vector: Vector;

constructor(position: Vertice, direction: Vector){
this.vertice = position.getCopy();
this.vector = direction.getCopy();
this.vertice = position.clone();
this.vector = direction.clone();
this.vector.normalize();
}

setVertice(position: Vertice): Line {
this.vertice = position.getCopy();
this.vertice = position.clone();
return this;
}

setVector(direction: Vector): Line {
this.vector = direction.getCopy();
this.vector = direction.clone();
this.vector.normalize();
return this;
}

getCopy(): Line {
clone(): Line {
var lineCopy = new Line(this.vertice, this.vector);
return lineCopy;
}
Expand Down
34 changes: 17 additions & 17 deletions ts/world/Math.ts
Expand Up @@ -80,9 +80,9 @@ const MathUtils = {
* 计算三角形的面积
*/
getTriangleArea(v1: Vertice, v2: Vertice, v3: Vertice){
var v1Copy = v1.getCopy();
var v2Copy = v2.getCopy();
var v3Copy = v3.getCopy();
var v1Copy = v1.clone();
var v2Copy = v2.clone();
var v3Copy = v3.clone();
var direction = Vector.verticeMinusVertice(v3Copy, v2Copy);
var line = new Line(v2Copy,direction);
var h = this.getLengthFromVerticeToLine(v1Copy,line);
Expand All @@ -98,8 +98,8 @@ const MathUtils = {
* @return {Number}
*/
getLengthFromVerticeToVertice(vertice1: Vertice, vertice2: Vertice){
var vertice1Copy = vertice1.getCopy();
var vertice2Copy = vertice2.getCopy();
var vertice1Copy = vertice1.clone();
var vertice2Copy = vertice2.clone();
var length2 = Math.pow(vertice1Copy.x-vertice2Copy.x,2) + Math.pow(vertice1Copy.y-vertice2Copy.y,2) + Math.pow(vertice1Copy.z-vertice2Copy.z,2);
var length = Math.sqrt(length2);
return length;
Expand All @@ -113,8 +113,8 @@ const MathUtils = {
* @return {Number}
*/
getLengthFromVerticeToLine : function(vertice: Vertice, line: Line){
var verticeCopy = vertice.getCopy();
var lineCopy = line.getCopy();
var verticeCopy = vertice.clone();
var lineCopy = line.clone();
var x0 = verticeCopy.x;
var y0 = verticeCopy.y;
var z0 = verticeCopy.z;
Expand All @@ -141,8 +141,8 @@ const MathUtils = {
* @return {Number}
*/
getLengthFromVerticeToPlan(vertice: Vertice, plan: Plan){
var verticeCopy = vertice.getCopy();
var planCopy = plan.getCopy();
var verticeCopy = vertice.clone();
var planCopy = plan.clone();
var x = verticeCopy.x;
var y = verticeCopy.y;
var z = verticeCopy.z;
Expand All @@ -164,8 +164,8 @@ const MathUtils = {
* @return {World.Vertice}
*/
getVerticeVerticalIntersectPointWidthPlan(vertice: Vertice, plan: Plan){
var verticeCopy = vertice.getCopy();
var planCopy = plan.getCopy();
var verticeCopy = vertice.clone();
var planCopy = plan.clone();
var x0 = verticeCopy.x;
var y0 = verticeCopy.y;
var z0 = verticeCopy.z;
Expand All @@ -184,8 +184,8 @@ const MathUtils = {
},

getIntersectPointByLineAdPlan(line: Line, plan: Plan){
var lineCopy = line.getCopy();
var planCopy = plan.getCopy();
var lineCopy = line.clone();
var planCopy = plan.clone();
lineCopy.vector.normalize();
var A = planCopy.A;
var B = planCopy.B;
Expand Down Expand Up @@ -213,7 +213,7 @@ const MathUtils = {
*/
getLineIntersectPointWithEarth(line: Line): Vertice[]{
var result:Vertice[] = [];
var lineCopy = line.getCopy();
var lineCopy = line.clone();
var vertice = lineCopy.vertice;
var direction = lineCopy.vector;
direction.normalize();
Expand Down Expand Up @@ -280,8 +280,8 @@ const MathUtils = {
* @return {Object} World.Plan 返回平面表达式中Ax+By+Cz+D=0的A、B、C、D的信息
*/
getCrossPlaneByLine(vertice: Vertice, direction: Vector): Plan{
var verticeCopy = vertice.getCopy();
var directionCopy = direction.getCopy();
var verticeCopy = vertice.clone();
var directionCopy = direction.clone();
directionCopy.normalize();
var a = directionCopy.x;
var b = directionCopy.y;
Expand Down Expand Up @@ -361,7 +361,7 @@ const MathUtils = {
* @return {Array}
*/
cartesianCoordToGeographic(vertice: Vertice): number[]{
var verticeCopy = vertice.getCopy();
var verticeCopy = vertice.clone();
var x = verticeCopy.x;
var y = verticeCopy.y;
var z = verticeCopy.z;
Expand Down
2 changes: 1 addition & 1 deletion ts/world/Matrix.ts
Expand Up @@ -226,7 +226,7 @@ class Matrix{
return true;
}

copy(): Matrix {
clone(): Matrix {
return new Matrix(
this.elements[0], this.elements[4], this.elements[8], this.elements[12],
this.elements[1], this.elements[5], this.elements[9], this.elements[13],
Expand Down
12 changes: 6 additions & 6 deletions ts/world/PerspectiveCamera.ts
Expand Up @@ -104,9 +104,9 @@ class PerspectiveCamera extends Object3D{
}

look(cameraPnt: Vertice, targetPnt: Vertice, upDirection: Vector = new Vector(0, 1, 0)): void {
var cameraPntCopy = cameraPnt.getCopy();
var targetPntCopy = targetPnt.getCopy();
var up = upDirection.getCopy();
var cameraPntCopy = cameraPnt.clone();
var targetPntCopy = targetPnt.clone();
var up = upDirection.clone();
var transX = cameraPntCopy.x;
var transY = cameraPntCopy.y;
var transZ = cameraPntCopy.z;
Expand All @@ -128,7 +128,7 @@ class PerspectiveCamera extends Object3D{
}

lookAt(targetPnt: Vertice, upDirection?: Vector): void {
var targetPntCopy = targetPnt.getCopy();
var targetPntCopy = targetPnt.clone();
var position = this.getPosition();
this.look(position, targetPntCopy, upDirection);
}
Expand Down Expand Up @@ -173,7 +173,7 @@ class PerspectiveCamera extends Object3D{
if (!(viewMatrix instanceof Matrix)) {
viewMatrix = this.getViewMatrix();
}
var verticeInCameraCopy = verticeInCamera.getCopy();
var verticeInCameraCopy = verticeInCamera.clone();
var inverseMatrix = viewMatrix.getInverseMatrix();
var column = [verticeInCameraCopy.x, verticeInCameraCopy.y, verticeInCameraCopy.z, 1];
var column2 = inverseMatrix.multiplyColumn(column);
Expand All @@ -189,7 +189,7 @@ class PerspectiveCamera extends Object3D{
if (!(viewMatrix instanceof Matrix)) {
viewMatrix = this.getViewMatrix();
}
var vectorInCameraCopy = vectorInCamera.getCopy();
var vectorInCameraCopy = vectorInCamera.clone();
var verticeInCamera = vectorInCameraCopy.getVertice();
var verticeInWorld = this.convertVerticeFromCameraToWorld(verticeInCamera, viewMatrix);
var originInWorld = this.getPosition();
Expand Down
2 changes: 1 addition & 1 deletion ts/world/Plan.ts
Expand Up @@ -3,7 +3,7 @@ class Plan{
constructor(public A: number, public B: number, public C: number, public D: number){
}

getCopy(): Plan{
clone(): Plan{
var planCopy = new Plan(this.A, this.B, this.C, this.D);
return planCopy;
}
Expand Down
10 changes: 5 additions & 5 deletions ts/world/Ray.ts
Expand Up @@ -12,23 +12,23 @@ class Ray{
* @constructor
*/
constructor(position: Vertice, direction: Vector){
this.vertice = position.getCopy();
this.vector = direction.getCopy();
this.vertice = position.clone();
this.vector = direction.clone();
this.vector.normalize();
}

setVertice(position: Vertice): Ray {
this.vertice = position.getCopy();
this.vertice = position.clone();
return this;
}

setVector(direction: Vector): Ray {
this.vector = direction.getCopy();
this.vector = direction.clone();
this.vector.normalize();
return this;
}

getCopy(): Ray {
clone(): Ray {
var rayCopy = new Ray(this.vertice, this.vector);
return rayCopy;
}
Expand Down
2 changes: 1 addition & 1 deletion ts/world/Vector.ts
Expand Up @@ -24,7 +24,7 @@ class Vector{
return [this.x, this.y, this.z];
}

getCopy(): Vector {
clone(): Vector {
return new Vector(this.x, this.y, this.z);
}

Expand Down
2 changes: 1 addition & 1 deletion ts/world/Vertice.ts
Expand Up @@ -25,7 +25,7 @@ class Vertice{
return [this.x, this.y, this.z];
}

getCopy(): Vertice {
clone(): Vertice {
return new Vertice(this.x, this.y, this.z);
}

Expand Down

0 comments on commit c46c842

Please sign in to comment.