Three.js 5.4 KB

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