Skip to content

Commit c46c842

Browse files
committed
rename copy(),getCopy() to clone()
1 parent d039876 commit c46c842

File tree

9 files changed

+38
-38
lines changed

9 files changed

+38
-38
lines changed

ts/world/Event.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -186,7 +186,7 @@ const EventModule = {
186186
var pIntersect = pickResult[0];
187187
var pCamera = camera.getPosition();
188188
var legnth2Intersect = MathUtils.getLengthFromVerticeToVertice(pCamera, pIntersect);
189-
var mat = camera.matrix.copy();
189+
var mat = camera.matrix.clone();
190190
mat.setColumnTrans(pIntersect.x, pIntersect.y, pIntersect.z);
191191
var DELTA_RADIAN = MathUtils.degreeToRadian(DELTA_PITCH);
192192
mat.localRotateX(DELTA_RADIAN);

ts/world/Line.ts

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -7,23 +7,23 @@ class Line{
77
public vector: Vector;
88

99
constructor(position: Vertice, direction: Vector){
10-
this.vertice = position.getCopy();
11-
this.vector = direction.getCopy();
10+
this.vertice = position.clone();
11+
this.vector = direction.clone();
1212
this.vector.normalize();
1313
}
1414

1515
setVertice(position: Vertice): Line {
16-
this.vertice = position.getCopy();
16+
this.vertice = position.clone();
1717
return this;
1818
}
1919

2020
setVector(direction: Vector): Line {
21-
this.vector = direction.getCopy();
21+
this.vector = direction.clone();
2222
this.vector.normalize();
2323
return this;
2424
}
2525

26-
getCopy(): Line {
26+
clone(): Line {
2727
var lineCopy = new Line(this.vertice, this.vector);
2828
return lineCopy;
2929
}

ts/world/Math.ts

Lines changed: 17 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -80,9 +80,9 @@ const MathUtils = {
8080
* 计算三角形的面积
8181
*/
8282
getTriangleArea(v1: Vertice, v2: Vertice, v3: Vertice){
83-
var v1Copy = v1.getCopy();
84-
var v2Copy = v2.getCopy();
85-
var v3Copy = v3.getCopy();
83+
var v1Copy = v1.clone();
84+
var v2Copy = v2.clone();
85+
var v3Copy = v3.clone();
8686
var direction = Vector.verticeMinusVertice(v3Copy, v2Copy);
8787
var line = new Line(v2Copy,direction);
8888
var h = this.getLengthFromVerticeToLine(v1Copy,line);
@@ -98,8 +98,8 @@ const MathUtils = {
9898
* @return {Number}
9999
*/
100100
getLengthFromVerticeToVertice(vertice1: Vertice, vertice2: Vertice){
101-
var vertice1Copy = vertice1.getCopy();
102-
var vertice2Copy = vertice2.getCopy();
101+
var vertice1Copy = vertice1.clone();
102+
var vertice2Copy = vertice2.clone();
103103
var length2 = Math.pow(vertice1Copy.x-vertice2Copy.x,2) + Math.pow(vertice1Copy.y-vertice2Copy.y,2) + Math.pow(vertice1Copy.z-vertice2Copy.z,2);
104104
var length = Math.sqrt(length2);
105105
return length;
@@ -113,8 +113,8 @@ const MathUtils = {
113113
* @return {Number}
114114
*/
115115
getLengthFromVerticeToLine : function(vertice: Vertice, line: Line){
116-
var verticeCopy = vertice.getCopy();
117-
var lineCopy = line.getCopy();
116+
var verticeCopy = vertice.clone();
117+
var lineCopy = line.clone();
118118
var x0 = verticeCopy.x;
119119
var y0 = verticeCopy.y;
120120
var z0 = verticeCopy.z;
@@ -141,8 +141,8 @@ const MathUtils = {
141141
* @return {Number}
142142
*/
143143
getLengthFromVerticeToPlan(vertice: Vertice, plan: Plan){
144-
var verticeCopy = vertice.getCopy();
145-
var planCopy = plan.getCopy();
144+
var verticeCopy = vertice.clone();
145+
var planCopy = plan.clone();
146146
var x = verticeCopy.x;
147147
var y = verticeCopy.y;
148148
var z = verticeCopy.z;
@@ -164,8 +164,8 @@ const MathUtils = {
164164
* @return {World.Vertice}
165165
*/
166166
getVerticeVerticalIntersectPointWidthPlan(vertice: Vertice, plan: Plan){
167-
var verticeCopy = vertice.getCopy();
168-
var planCopy = plan.getCopy();
167+
var verticeCopy = vertice.clone();
168+
var planCopy = plan.clone();
169169
var x0 = verticeCopy.x;
170170
var y0 = verticeCopy.y;
171171
var z0 = verticeCopy.z;
@@ -184,8 +184,8 @@ const MathUtils = {
184184
},
185185

186186
getIntersectPointByLineAdPlan(line: Line, plan: Plan){
187-
var lineCopy = line.getCopy();
188-
var planCopy = plan.getCopy();
187+
var lineCopy = line.clone();
188+
var planCopy = plan.clone();
189189
lineCopy.vector.normalize();
190190
var A = planCopy.A;
191191
var B = planCopy.B;
@@ -213,7 +213,7 @@ const MathUtils = {
213213
*/
214214
getLineIntersectPointWithEarth(line: Line): Vertice[]{
215215
var result:Vertice[] = [];
216-
var lineCopy = line.getCopy();
216+
var lineCopy = line.clone();
217217
var vertice = lineCopy.vertice;
218218
var direction = lineCopy.vector;
219219
direction.normalize();
@@ -280,8 +280,8 @@ const MathUtils = {
280280
* @return {Object} World.Plan 返回平面表达式中Ax+By+Cz+D=0的A、B、C、D的信息
281281
*/
282282
getCrossPlaneByLine(vertice: Vertice, direction: Vector): Plan{
283-
var verticeCopy = vertice.getCopy();
284-
var directionCopy = direction.getCopy();
283+
var verticeCopy = vertice.clone();
284+
var directionCopy = direction.clone();
285285
directionCopy.normalize();
286286
var a = directionCopy.x;
287287
var b = directionCopy.y;
@@ -361,7 +361,7 @@ const MathUtils = {
361361
* @return {Array}
362362
*/
363363
cartesianCoordToGeographic(vertice: Vertice): number[]{
364-
var verticeCopy = vertice.getCopy();
364+
var verticeCopy = vertice.clone();
365365
var x = verticeCopy.x;
366366
var y = verticeCopy.y;
367367
var z = verticeCopy.z;

ts/world/Matrix.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -226,7 +226,7 @@ class Matrix{
226226
return true;
227227
}
228228

229-
copy(): Matrix {
229+
clone(): Matrix {
230230
return new Matrix(
231231
this.elements[0], this.elements[4], this.elements[8], this.elements[12],
232232
this.elements[1], this.elements[5], this.elements[9], this.elements[13],

ts/world/PerspectiveCamera.ts

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -104,9 +104,9 @@ class PerspectiveCamera extends Object3D{
104104
}
105105

106106
look(cameraPnt: Vertice, targetPnt: Vertice, upDirection: Vector = new Vector(0, 1, 0)): void {
107-
var cameraPntCopy = cameraPnt.getCopy();
108-
var targetPntCopy = targetPnt.getCopy();
109-
var up = upDirection.getCopy();
107+
var cameraPntCopy = cameraPnt.clone();
108+
var targetPntCopy = targetPnt.clone();
109+
var up = upDirection.clone();
110110
var transX = cameraPntCopy.x;
111111
var transY = cameraPntCopy.y;
112112
var transZ = cameraPntCopy.z;
@@ -128,7 +128,7 @@ class PerspectiveCamera extends Object3D{
128128
}
129129

130130
lookAt(targetPnt: Vertice, upDirection?: Vector): void {
131-
var targetPntCopy = targetPnt.getCopy();
131+
var targetPntCopy = targetPnt.clone();
132132
var position = this.getPosition();
133133
this.look(position, targetPntCopy, upDirection);
134134
}
@@ -173,7 +173,7 @@ class PerspectiveCamera extends Object3D{
173173
if (!(viewMatrix instanceof Matrix)) {
174174
viewMatrix = this.getViewMatrix();
175175
}
176-
var verticeInCameraCopy = verticeInCamera.getCopy();
176+
var verticeInCameraCopy = verticeInCamera.clone();
177177
var inverseMatrix = viewMatrix.getInverseMatrix();
178178
var column = [verticeInCameraCopy.x, verticeInCameraCopy.y, verticeInCameraCopy.z, 1];
179179
var column2 = inverseMatrix.multiplyColumn(column);
@@ -189,7 +189,7 @@ class PerspectiveCamera extends Object3D{
189189
if (!(viewMatrix instanceof Matrix)) {
190190
viewMatrix = this.getViewMatrix();
191191
}
192-
var vectorInCameraCopy = vectorInCamera.getCopy();
192+
var vectorInCameraCopy = vectorInCamera.clone();
193193
var verticeInCamera = vectorInCameraCopy.getVertice();
194194
var verticeInWorld = this.convertVerticeFromCameraToWorld(verticeInCamera, viewMatrix);
195195
var originInWorld = this.getPosition();

ts/world/Plan.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ class Plan{
33
constructor(public A: number, public B: number, public C: number, public D: number){
44
}
55

6-
getCopy(): Plan{
6+
clone(): Plan{
77
var planCopy = new Plan(this.A, this.B, this.C, this.D);
88
return planCopy;
99
}

ts/world/Ray.ts

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -12,23 +12,23 @@ class Ray{
1212
* @constructor
1313
*/
1414
constructor(position: Vertice, direction: Vector){
15-
this.vertice = position.getCopy();
16-
this.vector = direction.getCopy();
15+
this.vertice = position.clone();
16+
this.vector = direction.clone();
1717
this.vector.normalize();
1818
}
1919

2020
setVertice(position: Vertice): Ray {
21-
this.vertice = position.getCopy();
21+
this.vertice = position.clone();
2222
return this;
2323
}
2424

2525
setVector(direction: Vector): Ray {
26-
this.vector = direction.getCopy();
26+
this.vector = direction.clone();
2727
this.vector.normalize();
2828
return this;
2929
}
3030

31-
getCopy(): Ray {
31+
clone(): Ray {
3232
var rayCopy = new Ray(this.vertice, this.vector);
3333
return rayCopy;
3434
}

ts/world/Vector.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ class Vector{
2424
return [this.x, this.y, this.z];
2525
}
2626

27-
getCopy(): Vector {
27+
clone(): Vector {
2828
return new Vector(this.x, this.y, this.z);
2929
}
3030

ts/world/Vertice.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ class Vertice{
2525
return [this.x, this.y, this.z];
2626
}
2727

28-
getCopy(): Vertice {
28+
clone(): Vertice {
2929
return new Vertice(this.x, this.y, this.z);
3030
}
3131

0 commit comments

Comments
 (0)