OLD | NEW |
1 <!DOCTYPE html> | 1 <!DOCTYPE html> |
2 <!-- | 2 <!-- |
3 Copyright (c) 2014 The Chromium Authors. All rights reserved. | 3 Copyright (c) 2014 The Chromium Authors. All rights reserved. |
4 Use of this source code is governed by a BSD-style license that can be | 4 Use of this source code is governed by a BSD-style license that can be |
5 found in the LICENSE file. | 5 found in the LICENSE file. |
6 --> | 6 --> |
7 <link rel="import" href="/tracing/base/base.html"> | 7 <link rel="import" href="/tracing/base/base.html"> |
8 <script src="/gl-matrix-min.js"></script> | 8 <script src="/gl-matrix-min.js"></script> |
9 | 9 |
10 <script> | 10 <script> |
(...skipping 13 matching lines...) Expand all Loading... |
24 global[exportName] = glMatrixModule[exportName]; | 24 global[exportName] = glMatrixModule[exportName]; |
25 } | 25 } |
26 } | 26 } |
27 })(this); | 27 })(this); |
28 </script> | 28 </script> |
29 | 29 |
30 <script> | 30 <script> |
31 'use strict'; | 31 'use strict'; |
32 | 32 |
33 tr.exportTo('tr.b', function() { | 33 tr.exportTo('tr.b', function() { |
| 34 /* Returns true when x and y are within delta of each other. */ |
| 35 function approximately(x, y, delta) { |
| 36 if (delta === undefined) |
| 37 delta = 1e-9; |
| 38 return Math.abs(x - y) < delta; |
| 39 } |
| 40 |
34 function clamp(x, lo, hi) { | 41 function clamp(x, lo, hi) { |
35 return Math.min(Math.max(x, lo), hi); | 42 return Math.min(Math.max(x, lo), hi); |
36 } | 43 } |
37 | 44 |
38 function lerp(percentage, lo, hi) { | 45 function lerp(percentage, lo, hi) { |
39 var range = hi - lo; | 46 var range = hi - lo; |
40 return lo + percentage * range; | 47 return lo + percentage * range; |
41 } | 48 } |
42 | 49 |
43 function normalize(value, lo, hi) { | 50 function normalize(value, lo, hi) { |
(...skipping 105 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
149 out[3] = 1; | 156 out[3] = 1; |
150 return out; | 157 return out; |
151 }; | 158 }; |
152 | 159 |
153 vec2.copyFromVec4 = function(out, a) { | 160 vec2.copyFromVec4 = function(out, a) { |
154 vec4.unitize(tmp_vec4, a); | 161 vec4.unitize(tmp_vec4, a); |
155 vec2.copy(out, tmp_vec4); | 162 vec2.copy(out, tmp_vec4); |
156 }; | 163 }; |
157 | 164 |
158 return { | 165 return { |
| 166 approximately: approximately, |
159 clamp: clamp, | 167 clamp: clamp, |
160 lerp: lerp, | 168 lerp: lerp, |
161 normalize: normalize, | 169 normalize: normalize, |
162 deg2rad: deg2rad, | 170 deg2rad: deg2rad, |
163 erf: erf | 171 erf: erf |
164 }; | 172 }; |
165 }); | 173 }); |
166 </script> | 174 </script> |
OLD | NEW |