Skip to content

Commit 4ed5fd6

Browse files
author
Raymond Hulha
committed
added Vector.useList and Vector.copy, changed Vector.fromList
1 parent 4d35e41 commit 4ed5fd6

1 file changed

Lines changed: 14 additions & 4 deletions

File tree

lib/src/vector.dart

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,17 +3,23 @@ part of chronos_gl;
33
class Vector {
44

55
Float32List array = new Float32List(3);
6-
7-
6+
87
double get x => array[0];
98
double get y => array[1];
109
double get z => array[2];
11-
10+
1211
set x(double v) => array[0] = v;
1312
set y(double v) => array[1] = v;
1413
set z(double v) => array[2] = v;
1514

16-
Vector.fromList( this.array);
15+
// Careful, this shares the data...
16+
Vector.useList( this.array);
17+
18+
Vector.fromList( Float32List array) {
19+
this.array[0] = array[0];
20+
this.array[1] = array[1];
21+
this.array[2] = array[2];
22+
}
1723

1824
Vector( [double x=0.0, double y=0.0, double z=0.0])
1925
{
@@ -38,6 +44,10 @@ class Vector {
3844
return this;
3945
}
4046

47+
Vector copy() {
48+
return new Vector.fromList(this.array);
49+
}
50+
4151
Vector add( Vector v) {
4252
array[0] += v[0];
4353
array[1] += v[1];

0 commit comments

Comments
 (0)