Browse Source

Make _clone() internal

customisations
alemart 10 months ago
parent
commit
08ee564dd3

+ 0
- 10
docs/api/quaternion.md View File

42
 
42
 
43
 The magnitude of the quaternion.
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
 ### equals
45
 ### equals
56
 
46
 
57
 `quaternion.equals(q: Quaternion): boolean`
47
 `quaternion.equals(q: Quaternion): boolean`

+ 0
- 10
docs/api/vector2.md View File

95
 
95
 
96
 A new unit vector pointing to `v` from `this`.
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
 ### equals
98
 ### equals
109
 
99
 
110
 `vector.equals(v: Vector2): boolean`
100
 `vector.equals(v: Vector2): boolean`

+ 0
- 10
docs/api/vector3.md View File

102
 
102
 
103
 A new unit vector pointing to `v` from `this`.
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
 ### cross
105
 ### cross
116
 
106
 
117
 `vector.cross(v: Vector3): Vector3`
107
 `vector.cross(v: Vector3): Vector3`

+ 10
- 9
src/geometry/quaternion.ts View File

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
      * Check if this and q have the same coordinates
124
      * Check if this and q have the same coordinates
134
      * @param q a quaternion
125
      * @param q a quaternion
135
      * @returns true if this and q have the same coordinates
126
      * @returns true if this and q have the same coordinates
401
 
392
 
402
         return this;
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 View File

132
      */
132
      */
133
     directionTo(v: Vector2): Vector2
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
 
245
 
255
         return this;
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 View File

145
      */
145
      */
146
     directionTo(v: Vector3): Vector3
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
     }
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
      * Check if this and v have the same coordinates
166
      * Check if this and v have the same coordinates
176
      * @param v a vector
167
      * @param v a vector
177
      * @returns true if this and v have the same coordinates
168
      * @returns true if this and v have the same coordinates
313
 
304
 
314
         return this;
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 View File

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

Loading…
Cancel
Save