Преглед на файлове

Make _clone() internal

customisations
alemart преди 10 месеца
родител
ревизия
08ee564dd3
променени са 7 файла, в които са добавени 35 реда и са изтрити 62 реда
  1. 0
    10
      docs/api/quaternion.md
  2. 0
    10
      docs/api/vector2.md
  3. 0
    10
      docs/api/vector3.md
  4. 10
    9
      src/geometry/quaternion.ts
  5. 11
    10
      src/geometry/vector2.ts
  6. 11
    10
      src/geometry/vector3.ts
  7. 3
    3
      src/trackers/pointer-tracker/pointer-tracker.ts

+ 0
- 10
docs/api/quaternion.md Целия файл

@@ -42,16 +42,6 @@ Compute the magnitude of the quaternion.
42 42
 
43 43
 The magnitude of the quaternion.
44 44
 
45
-### clone
46
-
47
-`quaternion.clone(): Quaternion`
48
-
49
-Clone the quaternion.
50
-
51
-**Returns**
52
-
53
-A new quaternion object with the same coordinates as `this`.
54
-
55 45
 ### equals
56 46
 
57 47
 `quaternion.equals(q: Quaternion): boolean`

+ 0
- 10
docs/api/vector2.md Целия файл

@@ -95,16 +95,6 @@ Compute a unit vector pointing to `v` from `this`.
95 95
 
96 96
 A new unit vector pointing to `v` from `this`.
97 97
 
98
-### clone
99
-
100
-`vector.clone(): Vector2`
101
-
102
-Clone the vector.
103
-
104
-**Returns**
105
-
106
-A new vector object with the same coordinates as `this`.
107
-
108 98
 ### equals
109 99
 
110 100
 `vector.equals(v: Vector2): boolean`

+ 0
- 10
docs/api/vector3.md Целия файл

@@ -102,16 +102,6 @@ Compute a unit vector pointing to `v` from `this`.
102 102
 
103 103
 A new unit vector pointing to `v` from `this`.
104 104
 
105
-### clone
106
-
107
-`vector.clone(): Vector3`
108
-
109
-Clone the vector.
110
-
111
-**Returns**
112
-
113
-A new vector object with the same coordinates as `this`.
114
-
115 105
 ### cross
116 106
 
117 107
 `vector.cross(v: Vector3): Vector3`

+ 10
- 9
src/geometry/quaternion.ts Целия файл

@@ -121,15 +121,6 @@ export class Quaternion
121 121
     }
122 122
 
123 123
     /**
124
-     * Clone this quaternion
125
-     * @returns a clone of this quaternion
126
-     */
127
-    clone(): Quaternion
128
-    {
129
-        return new Quaternion(this._x, this._y, this._z, this._w);
130
-    }
131
-
132
-    /**
133 124
      * Check if this and q have the same coordinates
134 125
      * @param q a quaternion
135 126
      * @returns true if this and q have the same coordinates
@@ -401,4 +392,14 @@ export class Quaternion
401 392
 
402 393
         return this;
403 394
     }
395
+
396
+    /**
397
+     * Clone this quaternion
398
+     * @returns a clone of this quaternion
399
+     * @internal
400
+     */
401
+    _clone(): Quaternion
402
+    {
403
+        return new Quaternion(this._x, this._y, this._z, this._w);
404
+    }
404 405
 }

+ 11
- 10
src/geometry/vector2.ts Целия файл

@@ -132,16 +132,7 @@ export class Vector2
132 132
      */
133 133
     directionTo(v: Vector2): Vector2
134 134
     {
135
-        return v.clone()._subtract(this)._normalize();
136
-    }
137
-
138
-    /**
139
-     * Clone this vector
140
-     * @returns a clone of this vector
141
-     */
142
-    clone(): Vector2
143
-    {
144
-        return new Vector2(this._x, this._y);
135
+        return v._clone()._subtract(this)._normalize();
145 136
     }
146 137
 
147 138
     /**
@@ -254,4 +245,14 @@ export class Vector2
254 245
 
255 246
         return this;
256 247
     }
248
+
249
+    /**
250
+     * Clone this vector
251
+     * @returns a clone of this vector
252
+     * @internal
253
+     */
254
+    _clone(): Vector2
255
+    {
256
+        return new Vector2(this._x, this._y);
257
+    }
257 258
 }

+ 11
- 10
src/geometry/vector3.ts Целия файл

@@ -145,7 +145,7 @@ export class Vector3
145 145
      */
146 146
     directionTo(v: Vector3): Vector3
147 147
     {
148
-        return v.clone()._subtract(this)._normalize();
148
+        return v._clone()._subtract(this)._normalize();
149 149
     }
150 150
 
151 151
     /**
@@ -163,15 +163,6 @@ export class Vector3
163 163
     }
164 164
 
165 165
     /**
166
-     * Clone this vector
167
-     * @returns a clone of this vector
168
-     */
169
-    clone(): Vector3
170
-    {
171
-        return new Vector3(this._x, this._y, this._z);
172
-    }
173
-
174
-    /**
175 166
      * Check if this and v have the same coordinates
176 167
      * @param v a vector
177 168
      * @returns true if this and v have the same coordinates
@@ -313,4 +304,14 @@ export class Vector3
313 304
 
314 305
         return this;
315 306
     }
307
+
308
+    /**
309
+     * Clone this vector
310
+     * @returns a clone of this vector
311
+     * @internal
312
+     */
313
+    _clone(): Vector3
314
+    {
315
+        return new Vector3(this._x, this._y, this._z);
316
+    }
316 317
 }

+ 3
- 3
src/trackers/pointer-tracker/pointer-tracker.ts Целия файл

@@ -285,14 +285,14 @@ export class PointerTracker implements Tracker
285 285
 
286 286
             // determine the position delta
287 287
             const deltaPosition = !previous ? Vector2.ZERO :
288
-                                  position.clone()._subtract(previous.position);
288
+                                  position._clone()._subtract(previous.position);
289 289
 
290 290
             // determine the initial position
291 291
             const initialPosition = previous ? previous.initialPosition :
292
-                                    Object.freeze(position.clone());
292
+                                    Object.freeze(position._clone());
293 293
 
294 294
             // determine the velocity
295
-            const velocity = deltaPosition.clone()._scale(inverseDeltaTime);
295
+            const velocity = deltaPosition._clone()._scale(inverseDeltaTime);
296 296
 
297 297
             // determine the elapsed time since the tracking began
298 298
             const elapsedTime = previous ? previous.elapsedTime + deltaTime : 0;

Loading…
Отказ
Запис