OLD | NEW |
1 // Copyright (c) 2011, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2011, the Dart project authors. Please see the AUTHORS file |
2 // for details. All rights reserved. Use of this source code is governed by a | 2 // for details. All rights reserved. Use of this source code is governed by a |
3 // BSD-style license that can be found in the LICENSE file. | 3 // BSD-style license that can be found in the LICENSE file. |
4 | 4 |
5 /** | 5 /** |
6 * Emulates the browser's Float32Array (so Matrix4 can be used outside | 6 * Emulates the browser's Float32Array (so Matrix4 can be used outside |
7 * the browser. | 7 * the browser. |
8 * (Note this stores entries as 64-bit doubles, since there is no | 8 * (Note this stores entries as 64-bit doubles, since there is no |
9 * 32-bit float type on the vm.) | 9 * 32-bit float type on the vm.) |
10 */ | 10 */ |
11 class Float32Array { | 11 class Float32Array { |
12 final List<double> buf; | 12 final List<double> buf; |
13 | 13 |
14 Float32Array(int size) : buf = new List<double>(size) { | 14 Float32Array(int size) : buf = new List<double>(size) { |
15 for (int i = 0; i < size; i++) { | 15 for (int i = 0; i < size; i++) { |
16 buf[i] = 0.0; | 16 buf[i] = 0.0; |
17 } | 17 } |
18 } | 18 } |
19 | 19 |
20 double operator [](int i) { | 20 double operator [](int i) { |
21 return buf[i]; | 21 return buf[i]; |
22 } | 22 } |
23 | 23 |
24 void operator []=(int i, num value) { | 24 void operator []=(int i, num value) { |
25 buf[i] = (value != null) ? value.toDouble() : 0.0; | 25 buf[i] = (value != null) ? value.toDouble() : 0.0; |
26 } | 26 } |
27 } | 27 } |
OLD | NEW |