Browse Source

Vector2, Vector3, Quaternion: make the coordinates private

customisations
alemart 10 months ago
parent
commit
ae646530be

+ 6
- 6
docs/api/quaternion.md View File

8
 
8
 
9
 ### x
9
 ### x
10
 
10
 
11
-`quaternion.x: number`
11
+`quaternion.x: number, read-only`
12
 
12
 
13
 The x coordinate of the quaternion (imaginary).
13
 The x coordinate of the quaternion (imaginary).
14
 
14
 
15
 ### y
15
 ### y
16
 
16
 
17
-`quaternion.y: number`
17
+`quaternion.y: number, read-only`
18
 
18
 
19
 The y coordinate of the quaternion (imaginary).
19
 The y coordinate of the quaternion (imaginary).
20
 
20
 
21
 ### z
21
 ### z
22
 
22
 
23
-`quaternion.z: number`
23
+`quaternion.z: number, read-only`
24
 
24
 
25
 The z coordinate of the quaternion (imaginary).
25
 The z coordinate of the quaternion (imaginary).
26
 
26
 
27
 ### w
27
 ### w
28
 
28
 
29
-`quaternion.w: number`
29
+`quaternion.w: number, read-only`
30
 
30
 
31
 The w coordinate of the quaternion (real).
31
 The w coordinate of the quaternion (real).
32
 
32
 
36
 
36
 
37
 `quaternion.length(): number`
37
 `quaternion.length(): number`
38
 
38
 
39
-Compute the length of the quaternion: `sqrt(x^2 + y^2 + z^2 + w^2)`.
39
+Compute the magnitude of the quaternion.
40
 
40
 
41
 **Returns**
41
 **Returns**
42
 
42
 
43
-The length of the quaternion.
43
+The magnitude of the quaternion.
44
 
44
 
45
 ### equals
45
 ### equals
46
 
46
 

+ 4
- 4
docs/api/vector2.md View File

8
 
8
 
9
 ### x
9
 ### x
10
 
10
 
11
-`vector.x: number`
11
+`vector.x: number, read-only`
12
 
12
 
13
 The x coordinate of the vector.
13
 The x coordinate of the vector.
14
 
14
 
15
 ### y
15
 ### y
16
 
16
 
17
-`vector.y: number`
17
+`vector.y: number, read-only`
18
 
18
 
19
 The y coordinate of the vector.
19
 The y coordinate of the vector.
20
 
20
 
24
 
24
 
25
 `vector.length(): number`
25
 `vector.length(): number`
26
 
26
 
27
-Compute the length of the vector: `sqrt(x^2 + y^2)`.
27
+Compute the magnitude of the vector.
28
 
28
 
29
 **Returns**
29
 **Returns**
30
 
30
 
31
-The length of the vector.
31
+The magnitude of the vector.
32
 
32
 
33
 ### dot
33
 ### dot
34
 
34
 

+ 5
- 5
docs/api/vector3.md View File

8
 
8
 
9
 ### x
9
 ### x
10
 
10
 
11
-`vector.x: number`
11
+`vector.x: number, read-only`
12
 
12
 
13
 The x coordinate of the vector.
13
 The x coordinate of the vector.
14
 
14
 
15
 ### y
15
 ### y
16
 
16
 
17
-`vector.y: number`
17
+`vector.y: number, read-only`
18
 
18
 
19
 The y coordinate of the vector.
19
 The y coordinate of the vector.
20
 
20
 
21
 ### z
21
 ### z
22
 
22
 
23
-`vector.z: number`
23
+`vector.z: number, read-only`
24
 
24
 
25
 The z coordinate of the vector.
25
 The z coordinate of the vector.
26
 
26
 
30
 
30
 
31
 `vector.length(): number`
31
 `vector.length(): number`
32
 
32
 
33
-Compute the length of the vector: `sqrt(x^2 + y^2 + z^2)`.
33
+Compute the magnitude of the vector.
34
 
34
 
35
 **Returns**
35
 **Returns**
36
 
36
 
37
-The length of the vector.
37
+The magnitude of the vector.
38
 
38
 
39
 ### dot
39
 ### dot
40
 
40
 

+ 17
- 11
src/geometry/pose-filter.ts View File

150
             const w = (T - i) * d;
150
             const w = (T - i) * d;
151
 
151
 
152
             // weighted avg: sum from i=0 to T-1 { (T-i) * t[i] } * (2/(T^2+T))
152
             // weighted avg: sum from i=0 to T-1 { (T-i) * t[i] } * (2/(T^2+T))
153
-            t.x += ti.x * w;
154
-            t.y += ti.y * w;
155
-            t.z += ti.z * w;
153
+            t._set(
154
+                t.x + ti.x * w,
155
+                t.y + ti.y * w,
156
+                t.z + ti.z * w
157
+            );
156
         }
158
         }
157
 
159
 
158
         // average *nearby* rotations
160
         // average *nearby* rotations
169
                 // XXX since Quaternion._fromRotationMatrix() computes w >= 0,
171
                 // XXX since Quaternion._fromRotationMatrix() computes w >= 0,
170
                 // this will never happen. Leave this here for extra safety
172
                 // this will never happen. Leave this here for extra safety
171
                 // in case anything changes?
173
                 // in case anything changes?
172
-                qi.x = -qi.x;
173
-                qi.y = -qi.y;
174
-                qi.z = -qi.z;
175
-                qi.w = -qi.w;
174
+                qi._set(
175
+                    -qi.x,
176
+                    -qi.y,
177
+                    -qi.z,
178
+                    -qi.w
179
+                );
176
             }
180
             }
177
 
181
 
178
-            q.x += qi.x * w;
179
-            q.y += qi.y * w;
180
-            q.z += qi.z * w;
181
-            q.w += qi.w * w;
182
+            q._set(
183
+                q.x + qi.x * w,
184
+                q.y + qi.y * w,
185
+                q.z + qi.z * w,
186
+                q.w + qi.w * w
187
+            );
182
         }
188
         }
183
         //q._normalize();
189
         //q._normalize();
184
 
190
 

+ 87
- 36
src/geometry/quaternion.ts View File

37
 export class Quaternion
37
 export class Quaternion
38
 {
38
 {
39
     /** x coordinate (imaginary) */
39
     /** x coordinate (imaginary) */
40
-    public x: number;
40
+    private _x: number;
41
 
41
 
42
     /** y coordinate (imaginary) */
42
     /** y coordinate (imaginary) */
43
-    public y: number;
43
+    private _y: number;
44
 
44
 
45
     /** z coordinate (imaginary) */
45
     /** z coordinate (imaginary) */
46
-    public z: number;
46
+    private _z: number;
47
 
47
 
48
     /** w coordinate (real) */
48
     /** w coordinate (real) */
49
-    public w: number;
49
+    private _w: number;
50
 
50
 
51
 
51
 
52
 
52
 
59
      */
59
      */
60
     constructor(x: number = 0, y: number = 0, z: number = 0, w: number = 1)
60
     constructor(x: number = 0, y: number = 0, z: number = 0, w: number = 1)
61
     {
61
     {
62
-        this.x = +x;
63
-        this.y = +y;
64
-        this.z = +z;
65
-        this.w = +w;
62
+        this._x = +x;
63
+        this._y = +y;
64
+        this._z = +z;
65
+        this._w = +w;
66
     }
66
     }
67
 
67
 
68
     /**
68
     /**
75
     }
75
     }
76
 
76
 
77
     /**
77
     /**
78
+     * The x coordinate of the quaternion (imaginary)
79
+     */
80
+    get x(): number
81
+    {
82
+        return this._x;
83
+    }
84
+
85
+    /**
86
+     * The y coordinate of the quaternion (imaginary)
87
+     */
88
+    get y(): number
89
+    {
90
+        return this._y;
91
+    }
92
+
93
+    /**
94
+     * The z coordinate of the quaternion (imaginary)
95
+     */
96
+    get z(): number
97
+    {
98
+        return this._z;
99
+    }
100
+
101
+    /**
102
+     * The w coordinate of the quaternion (real)
103
+     */
104
+    get w(): number
105
+    {
106
+        return this._w;
107
+    }
108
+
109
+    /**
78
      * The length of this quaternion
110
      * The length of this quaternion
79
      * @returns sqrt(x^2 + y^2 + z^2 + w^2)
111
      * @returns sqrt(x^2 + y^2 + z^2 + w^2)
80
      */
112
      */
81
     length(): number
113
     length(): number
82
     {
114
     {
83
-        const x = this.x;
84
-        const y = this.y;
85
-        const z = this.z;
86
-        const w = this.w;
115
+        const x = this._x;
116
+        const y = this._y;
117
+        const z = this._z;
118
+        const w = this._w;
87
 
119
 
88
         return Math.sqrt(x*x + y*y + z*z + w*w);
120
         return Math.sqrt(x*x + y*y + z*z + w*w);
89
     }
121
     }
95
      */
127
      */
96
     equals(q: Quaternion): boolean
128
     equals(q: Quaternion): boolean
97
     {
129
     {
98
-        return this.w === q.w && this.x === q.x && this.y === q.y && this.z === q.z;
130
+        return this._w === q._w && this._x === q._x && this._y === q._y && this._z === q._z;
99
     }
131
     }
100
 
132
 
101
     /**
133
     /**
104
      */
136
      */
105
     toString(): string
137
     toString(): string
106
     {
138
     {
107
-        const x = this.x.toFixed(4);
108
-        const y = this.y.toFixed(4);
109
-        const z = this.z.toFixed(4);
110
-        const w = this.w.toFixed(4);
139
+        const x = this._x.toFixed(4);
140
+        const y = this._y.toFixed(4);
141
+        const z = this._z.toFixed(4);
142
+        const w = this._w.toFixed(4);
111
 
143
 
112
         return `Quaternion(${x},${y},${z},${w})`;
144
         return `Quaternion(${x},${y},${z},${w})`;
113
     }
145
     }
124
         if(length < EPSILON) // zero?
156
         if(length < EPSILON) // zero?
125
             return this;
157
             return this;
126
 
158
 
127
-        this.x /= length;
128
-        this.y /= length;
129
-        this.z /= length;
130
-        this.w /= length;
159
+        this._x /= length;
160
+        this._y /= length;
161
+        this._z /= length;
162
+        this._w /= length;
131
 
163
 
132
         return this;
164
         return this;
133
     }
165
     }
139
      */
171
      */
140
     _conjugate(): Quaternion
172
     _conjugate(): Quaternion
141
     {
173
     {
142
-        this.x = -this.x;
143
-        this.y = -this.y;
144
-        this.z = -this.z;
174
+        this._x = -this._x;
175
+        this._y = -this._y;
176
+        this._z = -this._z;
177
+
178
+        return this;
179
+    }
180
+
181
+    /**
182
+     * Set the coordinates of this quaternion
183
+     * @param x x-coordinate
184
+     * @param y y-coordinate
185
+     * @param z z-coordinate
186
+     * @param w w-coordinate
187
+     * @returns this quaternion
188
+     * @internal
189
+     */
190
+    _set(x: number, y: number, z: number, w: number): Quaternion
191
+    {
192
+        this._x = +x;
193
+        this._y = +y;
194
+        this._z = +z;
195
+        this._w = +w;
145
 
196
 
146
         return this;
197
         return this;
147
     }
198
     }
154
      */
205
      */
155
     _copyFrom(q: Quaternion): Quaternion
206
     _copyFrom(q: Quaternion): Quaternion
156
     {
207
     {
157
-        this.x = q.x;
158
-        this.y = q.y;
159
-        this.z = q.z;
160
-        this.w = q.w;
208
+        this._x = q._x;
209
+        this._y = q._y;
210
+        this._z = q._z;
211
+        this._w = q._w;
161
 
212
 
162
         return this;
213
         return this;
163
     }
214
     }
176
             return Speedy.Matrix.Eye(3);
227
             return Speedy.Matrix.Eye(3);
177
 
228
 
178
         // let q = (x,y,z,w) be a unit quaternion
229
         // let q = (x,y,z,w) be a unit quaternion
179
-        const x = this.x / length;
180
-        const y = this.y / length;
181
-        const z = this.z / length;
182
-        const w = this.w / length;
230
+        const x = this._x / length;
231
+        const y = this._y / length;
232
+        const z = this._z / length;
233
+        const w = this._w / length;
183
 
234
 
184
         /*
235
         /*
185
 
236
 
334
         const z = 0.5 * Math.sqrt(Math.max(0, tr - 2 * (m11 + m22))); // |z|
385
         const z = 0.5 * Math.sqrt(Math.max(0, tr - 2 * (m11 + m22))); // |z|
335
 
386
 
336
         const length = Math.sqrt(x*x + y*y + z*z + w*w); // should be ~ 1
387
         const length = Math.sqrt(x*x + y*y + z*z + w*w); // should be ~ 1
337
-        this.x = (x * sx) / length;
338
-        this.y = (y * sy) / length;
339
-        this.z = (z * sz) / length;
340
-        this.w = w / length;
388
+        this._x = (x * sx) / length;
389
+        this._y = (y * sy) / length;
390
+        this._z = (z * sz) / length;
391
+        this._w = w / length;
341
 
392
 
342
         return this;
393
         return this;
343
     }
394
     }

+ 42
- 26
src/geometry/vector2.ts View File

38
 export class Vector2
38
 export class Vector2
39
 {
39
 {
40
     /** x coordinate */
40
     /** x coordinate */
41
-    public x: number;
41
+    private _x: number;
42
 
42
 
43
     /** y coordinate */
43
     /** y coordinate */
44
-    public y: number;
44
+    private _y: number;
45
 
45
 
46
 
46
 
47
 
47
 
52
      */
52
      */
53
     constructor(x: number = 0, y: number = 0)
53
     constructor(x: number = 0, y: number = 0)
54
     {
54
     {
55
-        this.x = +x;
56
-        this.y = +y;
55
+        this._x = +x;
56
+        this._y = +y;
57
     }
57
     }
58
 
58
 
59
     /**
59
     /**
71
      */
71
      */
72
     static get ZERO(): Vector2
72
     static get ZERO(): Vector2
73
     {
73
     {
74
-        return ZERO || (ZERO = Object.freeze(Vector2.Zero()));
74
+        return ZERO || (ZERO = Object.freeze(Vector2.Zero()) as Vector2);
75
+    }
76
+
77
+    /**
78
+     * The x coordinate of the vector
79
+     */
80
+    get x(): number
81
+    {
82
+        return this._x;
83
+    }
84
+
85
+    /**
86
+     * The y coordinate of the vector
87
+     */
88
+    get y(): number
89
+    {
90
+        return this._y;
75
     }
91
     }
76
 
92
 
77
     /**
93
     /**
80
      */
96
      */
81
     length(): number
97
     length(): number
82
     {
98
     {
83
-        const x = this.x;
84
-        const y = this.y;
99
+        const x = this._x;
100
+        const y = this._y;
85
 
101
 
86
         return Math.sqrt(x*x + y*y);
102
         return Math.sqrt(x*x + y*y);
87
     }
103
     }
93
      */
109
      */
94
     dot(v: Vector2): number
110
     dot(v: Vector2): number
95
     {
111
     {
96
-        return this.x * v.x + this.y * v.y;
112
+        return this._x * v._x + this._y * v._y;
97
     }
113
     }
98
 
114
 
99
     /**
115
     /**
103
      */
119
      */
104
     distanceTo(v: Vector2): number
120
     distanceTo(v: Vector2): number
105
     {
121
     {
106
-        const dx = this.x - v.x;
107
-        const dy = this.y - v.y;
122
+        const dx = this._x - v._x;
123
+        const dy = this._y - v._y;
108
 
124
 
109
         return Math.sqrt(dx*dx + dy*dy);
125
         return Math.sqrt(dx*dx + dy*dy);
110
     }
126
     }
126
      */
142
      */
127
     equals(v: Vector2): boolean
143
     equals(v: Vector2): boolean
128
     {
144
     {
129
-        return this.x === v.x && this.y === v.y;
145
+        return this._x === v._x && this._y === v._y;
130
     }
146
     }
131
 
147
 
132
     /**
148
     /**
135
      */
151
      */
136
     toString(): string
152
     toString(): string
137
     {
153
     {
138
-        const x = this.x.toFixed(5);
139
-        const y = this.y.toFixed(5);
154
+        const x = this._x.toFixed(5);
155
+        const y = this._y.toFixed(5);
140
 
156
 
141
         return `Vector2(${x},${y})`;
157
         return `Vector2(${x},${y})`;
142
     }
158
     }
148
      */
164
      */
149
     _clone(): Vector2
165
     _clone(): Vector2
150
     {
166
     {
151
-        return new Vector2(this.x, this.y);
167
+        return new Vector2(this._x, this._y);
152
     }
168
     }
153
 
169
 
154
     /**
170
     /**
160
      */
176
      */
161
     _set(x: number, y: number): Vector2
177
     _set(x: number, y: number): Vector2
162
     {
178
     {
163
-        this.x = +x;
164
-        this.y = +y;
179
+        this._x = +x;
180
+        this._y = +y;
165
 
181
 
166
         return this;
182
         return this;
167
     }
183
     }
174
      */
190
      */
175
     _copyFrom(v: Vector2): Vector2
191
     _copyFrom(v: Vector2): Vector2
176
     {
192
     {
177
-        this.x = v.x;
178
-        this.y = v.y;
193
+        this._x = v._x;
194
+        this._y = v._y;
179
 
195
 
180
         return this;
196
         return this;
181
     }
197
     }
192
         if(length < EPSILON) // zero?
208
         if(length < EPSILON) // zero?
193
             return this;
209
             return this;
194
 
210
 
195
-        this.x /= length;
196
-        this.y /= length;
211
+        this._x /= length;
212
+        this._y /= length;
197
 
213
 
198
         return this;
214
         return this;
199
     }
215
     }
206
      */
222
      */
207
     _add(v: Vector2): Vector2
223
     _add(v: Vector2): Vector2
208
     {
224
     {
209
-        this.x += v.x;
210
-        this.y += v.y;
225
+        this._x += v._x;
226
+        this._y += v._y;
211
 
227
 
212
         return this;
228
         return this;
213
     }
229
     }
220
      */
236
      */
221
     _subtract(v: Vector2): Vector2
237
     _subtract(v: Vector2): Vector2
222
     {
238
     {
223
-        this.x -= v.x;
224
-        this.y -= v.y;
239
+        this._x -= v._x;
240
+        this._y -= v._y;
225
 
241
 
226
         return this;
242
         return this;
227
     }
243
     }
234
      */
250
      */
235
     _scale(s: number): Vector2
251
     _scale(s: number): Vector2
236
     {
252
     {
237
-        this.x *= s;
238
-        this.y *= s;
253
+        this._x *= s;
254
+        this._y *= s;
239
 
255
 
240
         return this;
256
         return this;
241
     }
257
     }

+ 64
- 40
src/geometry/vector3.ts View File

38
 export class Vector3
38
 export class Vector3
39
 {
39
 {
40
     /** x coordinate */
40
     /** x coordinate */
41
-    public x: number;
41
+    private _x: number;
42
 
42
 
43
     /** y coordinate */
43
     /** y coordinate */
44
-    public y: number;
44
+    private _y: number;
45
 
45
 
46
     /** z coordinate */
46
     /** z coordinate */
47
-    public z: number;
47
+    private _z: number;
48
 
48
 
49
 
49
 
50
 
50
 
53
      */
53
      */
54
     constructor(x: number = 0, y: number = 0, z: number = 0)
54
     constructor(x: number = 0, y: number = 0, z: number = 0)
55
     {
55
     {
56
-        this.x = +x;
57
-        this.y = +y;
58
-        this.z = +z;
56
+        this._x = +x;
57
+        this._y = +y;
58
+        this._z = +z;
59
     }
59
     }
60
 
60
 
61
     /**
61
     /**
73
      */
73
      */
74
     static get ZERO(): Vector3
74
     static get ZERO(): Vector3
75
     {
75
     {
76
-        return ZERO || (ZERO = Object.freeze(Vector3.Zero()));
76
+        return ZERO || (ZERO = Object.freeze(Vector3.Zero()) as Vector3);
77
+    }
78
+
79
+    /**
80
+     * The x coordinate of the vector
81
+     */
82
+    get x(): number
83
+    {
84
+        return this._x;
85
+    }
86
+
87
+    /**
88
+     * The y coordinate of the vector
89
+     */
90
+    get y(): number
91
+    {
92
+        return this._y;
93
+    }
94
+
95
+    /**
96
+     * The z coordinate of the vector
97
+     */
98
+    get z(): number
99
+    {
100
+        return this._z;
77
     }
101
     }
78
 
102
 
79
     /**
103
     /**
82
      */
106
      */
83
     length(): number
107
     length(): number
84
     {
108
     {
85
-        const x = this.x;
86
-        const y = this.y;
87
-        const z = this.z;
109
+        const x = this._x;
110
+        const y = this._y;
111
+        const z = this._z;
88
 
112
 
89
         return Math.sqrt(x*x + y*y + z*z);
113
         return Math.sqrt(x*x + y*y + z*z);
90
     }
114
     }
96
      */
120
      */
97
     dot(v: Vector3): number
121
     dot(v: Vector3): number
98
     {
122
     {
99
-        return this.x * v.x + this.y * v.y + this.z * v.z;
123
+        return this._x * v._x + this._y * v._y + this._z * v._z;
100
     }
124
     }
101
 
125
 
102
     /**
126
     /**
106
      */
130
      */
107
     distanceTo(v: Vector3): number
131
     distanceTo(v: Vector3): number
108
     {
132
     {
109
-        const dx = this.x - v.x;
110
-        const dy = this.y - v.y;
111
-        const dz = this.z - v.z;
133
+        const dx = this._x - v._x;
134
+        const dy = this._y - v._y;
135
+        const dz = this._z - v._z;
112
 
136
 
113
         return Math.sqrt(dx*dx + dy*dy + dz*dz);
137
         return Math.sqrt(dx*dx + dy*dy + dz*dz);
114
     }
138
     }
130
      */
154
      */
131
     cross(v: Vector3): Vector3
155
     cross(v: Vector3): Vector3
132
     {
156
     {
133
-        const x = this.y * v.z - this.z * v.y;
134
-        const y = this.z * v.x - this.x * v.z;
135
-        const z = this.x * v.y - this.y * v.x;
157
+        const x = this._y * v._z - this._z * v._y;
158
+        const y = this._z * v._x - this._x * v._z;
159
+        const z = this._x * v._y - this._y * v._x;
136
 
160
 
137
         return new Vector3(x, y, z);
161
         return new Vector3(x, y, z);
138
     }
162
     }
144
      */
168
      */
145
     equals(v: Vector3): boolean
169
     equals(v: Vector3): boolean
146
     {
170
     {
147
-        return this.x === v.x && this.y === v.y && this.z === v.z;
171
+        return this._x === v._x && this._y === v._y && this._z === v._z;
148
     }
172
     }
149
 
173
 
150
     /**
174
     /**
153
      */
177
      */
154
     toString(): string
178
     toString(): string
155
     {
179
     {
156
-        const x = this.x.toFixed(5);
157
-        const y = this.y.toFixed(5);
158
-        const z = this.z.toFixed(5);
180
+        const x = this._x.toFixed(5);
181
+        const y = this._y.toFixed(5);
182
+        const z = this._z.toFixed(5);
159
 
183
 
160
         return `Vector3(${x},${y},${z})`;
184
         return `Vector3(${x},${y},${z})`;
161
     }
185
     }
167
      */
191
      */
168
     _clone(): Vector3
192
     _clone(): Vector3
169
     {
193
     {
170
-        return new Vector3(this.x, this.y, this.z);
194
+        return new Vector3(this._x, this._y, this._z);
171
     }
195
     }
172
 
196
 
173
     /**
197
     /**
180
      */
204
      */
181
     _set(x: number, y: number, z: number): Vector3
205
     _set(x: number, y: number, z: number): Vector3
182
     {
206
     {
183
-        this.x = +x;
184
-        this.y = +y;
185
-        this.z = +z;
207
+        this._x = +x;
208
+        this._y = +y;
209
+        this._z = +z;
186
 
210
 
187
         return this;
211
         return this;
188
     }
212
     }
195
      */
219
      */
196
     _copyFrom(v: Vector3): Vector3
220
     _copyFrom(v: Vector3): Vector3
197
     {
221
     {
198
-        this.x = v.x;
199
-        this.y = v.y;
200
-        this.z = v.z;
222
+        this._x = v._x;
223
+        this._y = v._y;
224
+        this._z = v._z;
201
 
225
 
202
         return this;
226
         return this;
203
     }
227
     }
214
         if(length < EPSILON) // zero?
238
         if(length < EPSILON) // zero?
215
             return this;
239
             return this;
216
 
240
 
217
-        this.x /= length;
218
-        this.y /= length;
219
-        this.z /= length;
241
+        this._x /= length;
242
+        this._y /= length;
243
+        this._z /= length;
220
 
244
 
221
         return this;
245
         return this;
222
     }
246
     }
229
      */
253
      */
230
     _add(v: Vector3): Vector3
254
     _add(v: Vector3): Vector3
231
     {
255
     {
232
-        this.x += v.x;
233
-        this.y += v.y;
234
-        this.z += v.z;
256
+        this._x += v._x;
257
+        this._y += v._y;
258
+        this._z += v._z;
235
 
259
 
236
         return this;
260
         return this;
237
     }
261
     }
244
      */
268
      */
245
     _subtract(v: Vector3): Vector3
269
     _subtract(v: Vector3): Vector3
246
     {
270
     {
247
-        this.x -= v.x;
248
-        this.y -= v.y;
249
-        this.z -= v.z;
271
+        this._x -= v._x;
272
+        this._y -= v._y;
273
+        this._z -= v._z;
250
 
274
 
251
         return this;
275
         return this;
252
     }
276
     }
259
      */
283
      */
260
     _scale(s: number): Vector3
284
     _scale(s: number): Vector3
261
     {
285
     {
262
-        this.x *= s;
263
-        this.y *= s;
264
-        this.z *= s;
286
+        this._x *= s;
287
+        this._y *= s;
288
+        this._z *= s;
265
 
289
 
266
         return this;
290
         return this;
267
     }
291
     }

Loading…
Cancel
Save