1 | /**
|
---|
2 | * @author mrdoob / http://mrdoob.com/
|
---|
3 | * @author Larry Battle / http://bateru.com/news
|
---|
4 | * @author bhouston / http://exocortex.com
|
---|
5 | */
|
---|
6 |
|
---|
7 | var THREE = { REVISION: '65' };
|
---|
8 |
|
---|
9 | self.console = self.console || {
|
---|
10 |
|
---|
11 | info: function () {},
|
---|
12 | log: function () {},
|
---|
13 | debug: function () {},
|
---|
14 | warn: function () {},
|
---|
15 | error: function () {}
|
---|
16 |
|
---|
17 | };
|
---|
18 |
|
---|
19 | String.prototype.trim = String.prototype.trim || function () {
|
---|
20 |
|
---|
21 | return this.replace( /^\s+|\s+$/g, '' );
|
---|
22 |
|
---|
23 | };
|
---|
24 |
|
---|
25 | // based on https://github.com/documentcloud/underscore/blob/bf657be243a075b5e72acc8a83e6f12a564d8f55/underscore.js#L767
|
---|
26 | THREE.extend = function ( obj, source ) {
|
---|
27 |
|
---|
28 | // ECMAScript5 compatibility based on: http://www.nczonline.net/blog/2012/12/11/are-your-mixins-ecmascript-5-compatible/
|
---|
29 | if ( Object.keys ) {
|
---|
30 |
|
---|
31 | var keys = Object.keys( source );
|
---|
32 |
|
---|
33 | for (var i = 0, il = keys.length; i < il; i++) {
|
---|
34 |
|
---|
35 | var prop = keys[i];
|
---|
36 | Object.defineProperty( obj, prop, Object.getOwnPropertyDescriptor( source, prop ) );
|
---|
37 |
|
---|
38 | }
|
---|
39 |
|
---|
40 | } else {
|
---|
41 |
|
---|
42 | var safeHasOwnProperty = {}.hasOwnProperty;
|
---|
43 |
|
---|
44 | for ( var prop in source ) {
|
---|
45 |
|
---|
46 | if ( safeHasOwnProperty.call( source, prop ) ) {
|
---|
47 |
|
---|
48 | obj[prop] = source[prop];
|
---|
49 |
|
---|
50 | }
|
---|
51 |
|
---|
52 | }
|
---|
53 |
|
---|
54 | }
|
---|
55 |
|
---|
56 | return obj;
|
---|
57 |
|
---|
58 | };
|
---|
59 |
|
---|
60 | // http://paulirish.com/2011/requestanimationframe-for-smart-animating/
|
---|
61 | // http://my.opera.com/emoller/blog/2011/12/20/requestanimationframe-for-smart-er-animating
|
---|
62 |
|
---|
63 | // requestAnimationFrame polyfill by Erik Möller
|
---|
64 | // fixes from Paul Irish and Tino Zijdel
|
---|
65 | // using 'self' instead of 'window' for compatibility with both NodeJS and IE10.
|
---|
66 | ( function () {
|
---|
67 |
|
---|
68 | var lastTime = 0;
|
---|
69 | var vendors = [ 'ms', 'moz', 'webkit', 'o' ];
|
---|
70 |
|
---|
71 | for ( var x = 0; x < vendors.length && !self.requestAnimationFrame; ++ x ) {
|
---|
72 |
|
---|
73 | self.requestAnimationFrame = self[ vendors[ x ] + 'RequestAnimationFrame' ];
|
---|
74 | self.cancelAnimationFrame = self[ vendors[ x ] + 'CancelAnimationFrame' ] || self[ vendors[ x ] + 'CancelRequestAnimationFrame' ];
|
---|
75 |
|
---|
76 | }
|
---|
77 |
|
---|
78 | if ( self.requestAnimationFrame === undefined && self['setTimeout'] !== undefined ) {
|
---|
79 |
|
---|
80 | self.requestAnimationFrame = function ( callback ) {
|
---|
81 |
|
---|
82 | var currTime = Date.now(), timeToCall = Math.max( 0, 16 - ( currTime - lastTime ) );
|
---|
83 | var id = self.setTimeout( function() { callback( currTime + timeToCall ); }, timeToCall );
|
---|
84 | lastTime = currTime + timeToCall;
|
---|
85 | return id;
|
---|
86 |
|
---|
87 | };
|
---|
88 |
|
---|
89 | }
|
---|
90 |
|
---|
91 | if( self.cancelAnimationFrame === undefined && self['clearTimeout'] !== undefined ) {
|
---|
92 |
|
---|
93 | self.cancelAnimationFrame = function ( id ) { self.clearTimeout( id ) };
|
---|
94 |
|
---|
95 | }
|
---|
96 |
|
---|
97 | }() );
|
---|
98 |
|
---|
99 | // GL STATE CONSTANTS
|
---|
100 |
|
---|
101 | THREE.CullFaceNone = 0;
|
---|
102 | THREE.CullFaceBack = 1;
|
---|
103 | THREE.CullFaceFront = 2;
|
---|
104 | THREE.CullFaceFrontBack = 3;
|
---|
105 |
|
---|
106 | THREE.FrontFaceDirectionCW = 0;
|
---|
107 | THREE.FrontFaceDirectionCCW = 1;
|
---|
108 |
|
---|
109 | // SHADOWING TYPES
|
---|
110 |
|
---|
111 | THREE.BasicShadowMap = 0;
|
---|
112 | THREE.PCFShadowMap = 1;
|
---|
113 | THREE.PCFSoftShadowMap = 2;
|
---|
114 |
|
---|
115 | // MATERIAL CONSTANTS
|
---|
116 |
|
---|
117 | // side
|
---|
118 |
|
---|
119 | THREE.FrontSide = 0;
|
---|
120 | THREE.BackSide = 1;
|
---|
121 | THREE.DoubleSide = 2;
|
---|
122 |
|
---|
123 | // shading
|
---|
124 |
|
---|
125 | THREE.NoShading = 0;
|
---|
126 | THREE.FlatShading = 1;
|
---|
127 | THREE.SmoothShading = 2;
|
---|
128 |
|
---|
129 | // colors
|
---|
130 |
|
---|
131 | THREE.NoColors = 0;
|
---|
132 | THREE.FaceColors = 1;
|
---|
133 | THREE.VertexColors = 2;
|
---|
134 |
|
---|
135 | // blending modes
|
---|
136 |
|
---|
137 | THREE.NoBlending = 0;
|
---|
138 | THREE.NormalBlending = 1;
|
---|
139 | THREE.AdditiveBlending = 2;
|
---|
140 | THREE.SubtractiveBlending = 3;
|
---|
141 | THREE.MultiplyBlending = 4;
|
---|
142 | THREE.CustomBlending = 5;
|
---|
143 |
|
---|
144 | // custom blending equations
|
---|
145 | // (numbers start from 100 not to clash with other
|
---|
146 | // mappings to OpenGL constants defined in Texture.js)
|
---|
147 |
|
---|
148 | THREE.AddEquation = 100;
|
---|
149 | THREE.SubtractEquation = 101;
|
---|
150 | THREE.ReverseSubtractEquation = 102;
|
---|
151 |
|
---|
152 | // custom blending destination factors
|
---|
153 |
|
---|
154 | THREE.ZeroFactor = 200;
|
---|
155 | THREE.OneFactor = 201;
|
---|
156 | THREE.SrcColorFactor = 202;
|
---|
157 | THREE.OneMinusSrcColorFactor = 203;
|
---|
158 | THREE.SrcAlphaFactor = 204;
|
---|
159 | THREE.OneMinusSrcAlphaFactor = 205;
|
---|
160 | THREE.DstAlphaFactor = 206;
|
---|
161 | THREE.OneMinusDstAlphaFactor = 207;
|
---|
162 |
|
---|
163 | // custom blending source factors
|
---|
164 |
|
---|
165 | //THREE.ZeroFactor = 200;
|
---|
166 | //THREE.OneFactor = 201;
|
---|
167 | //THREE.SrcAlphaFactor = 204;
|
---|
168 | //THREE.OneMinusSrcAlphaFactor = 205;
|
---|
169 | //THREE.DstAlphaFactor = 206;
|
---|
170 | //THREE.OneMinusDstAlphaFactor = 207;
|
---|
171 | THREE.DstColorFactor = 208;
|
---|
172 | THREE.OneMinusDstColorFactor = 209;
|
---|
173 | THREE.SrcAlphaSaturateFactor = 210;
|
---|
174 |
|
---|
175 |
|
---|
176 | // TEXTURE CONSTANTS
|
---|
177 |
|
---|
178 | THREE.MultiplyOperation = 0;
|
---|
179 | THREE.MixOperation = 1;
|
---|
180 | THREE.AddOperation = 2;
|
---|
181 |
|
---|
182 | // Mapping modes
|
---|
183 |
|
---|
184 | THREE.UVMapping = function () {};
|
---|
185 |
|
---|
186 | THREE.CubeReflectionMapping = function () {};
|
---|
187 | THREE.CubeRefractionMapping = function () {};
|
---|
188 |
|
---|
189 | THREE.SphericalReflectionMapping = function () {};
|
---|
190 | THREE.SphericalRefractionMapping = function () {};
|
---|
191 |
|
---|
192 | // Wrapping modes
|
---|
193 |
|
---|
194 | THREE.RepeatWrapping = 1000;
|
---|
195 | THREE.ClampToEdgeWrapping = 1001;
|
---|
196 | THREE.MirroredRepeatWrapping = 1002;
|
---|
197 |
|
---|
198 | // Filters
|
---|
199 |
|
---|
200 | THREE.NearestFilter = 1003;
|
---|
201 | THREE.NearestMipMapNearestFilter = 1004;
|
---|
202 | THREE.NearestMipMapLinearFilter = 1005;
|
---|
203 | THREE.LinearFilter = 1006;
|
---|
204 | THREE.LinearMipMapNearestFilter = 1007;
|
---|
205 | THREE.LinearMipMapLinearFilter = 1008;
|
---|
206 |
|
---|
207 | // Data types
|
---|
208 |
|
---|
209 | THREE.UnsignedByteType = 1009;
|
---|
210 | THREE.ByteType = 1010;
|
---|
211 | THREE.ShortType = 1011;
|
---|
212 | THREE.UnsignedShortType = 1012;
|
---|
213 | THREE.IntType = 1013;
|
---|
214 | THREE.UnsignedIntType = 1014;
|
---|
215 | THREE.FloatType = 1015;
|
---|
216 |
|
---|
217 | // Pixel types
|
---|
218 |
|
---|
219 | //THREE.UnsignedByteType = 1009;
|
---|
220 | THREE.UnsignedShort4444Type = 1016;
|
---|
221 | THREE.UnsignedShort5551Type = 1017;
|
---|
222 | THREE.UnsignedShort565Type = 1018;
|
---|
223 |
|
---|
224 | // Pixel formats
|
---|
225 |
|
---|
226 | THREE.AlphaFormat = 1019;
|
---|
227 | THREE.RGBFormat = 1020;
|
---|
228 | THREE.RGBAFormat = 1021;
|
---|
229 | THREE.LuminanceFormat = 1022;
|
---|
230 | THREE.LuminanceAlphaFormat = 1023;
|
---|
231 |
|
---|
232 | // Compressed texture formats
|
---|
233 |
|
---|
234 | THREE.RGB_S3TC_DXT1_Format = 2001;
|
---|
235 | THREE.RGBA_S3TC_DXT1_Format = 2002;
|
---|
236 | THREE.RGBA_S3TC_DXT3_Format = 2003;
|
---|
237 | THREE.RGBA_S3TC_DXT5_Format = 2004;
|
---|
238 |
|
---|
239 | /*
|
---|
240 | // Potential future PVRTC compressed texture formats
|
---|
241 | THREE.RGB_PVRTC_4BPPV1_Format = 2100;
|
---|
242 | THREE.RGB_PVRTC_2BPPV1_Format = 2101;
|
---|
243 | THREE.RGBA_PVRTC_4BPPV1_Format = 2102;
|
---|
244 | THREE.RGBA_PVRTC_2BPPV1_Format = 2103;
|
---|
245 | */
|
---|