Three.js 3.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183
  1. /**
  2. * @author mr.doob / http://mrdoob.com/
  3. */
  4. var THREE = THREE || { REVISION: '50dev' };
  5. if ( ! self.console ) {
  6. self.console = {
  7. info: function () {},
  8. log: function () {},
  9. debug: function () {},
  10. warn: function () {},
  11. error: function () {}
  12. };
  13. }
  14. if ( ! self.Int32Array ) {
  15. self.Int32Array = Array;
  16. self.Float32Array = Array;
  17. }
  18. // http://paulirish.com/2011/requestanimationframe-for-smart-animating/
  19. // http://my.opera.com/emoller/blog/2011/12/20/requestanimationframe-for-smart-er-animating
  20. // requestAnimationFrame polyfill by Erik Möller
  21. // fixes from Paul Irish and Tino Zijdel
  22. ( function () {
  23. var lastTime = 0;
  24. var vendors = [ 'ms', 'moz', 'webkit', 'o' ];
  25. for ( var x = 0; x < vendors.length && !window.requestAnimationFrame; ++ x ) {
  26. window.requestAnimationFrame = window[ vendors[ x ] + 'RequestAnimationFrame' ];
  27. window.cancelAnimationFrame = window[ vendors[ x ] + 'CancelAnimationFrame' ] || window[ vendors[ x ] + 'CancelRequestAnimationFrame' ];
  28. }
  29. if ( !window.requestAnimationFrame ) {
  30. window.requestAnimationFrame = function ( callback, element ) {
  31. var currTime = Date.now(), timeToCall = Math.max( 0, 16 - ( currTime - lastTime ) );
  32. var id = window.setTimeout( function() { callback( currTime + timeToCall ); }, timeToCall );
  33. lastTime = currTime + timeToCall;
  34. return id;
  35. };
  36. }
  37. if ( !window.cancelAnimationFrame ) {
  38. window.cancelAnimationFrame = function ( id ) { clearTimeout( id ); };
  39. }
  40. }() );
  41. // MATERIAL CONSTANTS
  42. // side
  43. THREE.FrontSide = 0;
  44. THREE.BackSide = 1;
  45. THREE.DoubleSide = 2;
  46. // shading
  47. THREE.NoShading = 0;
  48. THREE.FlatShading = 1;
  49. THREE.SmoothShading = 2;
  50. // colors
  51. THREE.NoColors = 0;
  52. THREE.FaceColors = 1;
  53. THREE.VertexColors = 2;
  54. // blending modes
  55. THREE.NoBlending = 0;
  56. THREE.NormalBlending = 1;
  57. THREE.AdditiveBlending = 2;
  58. THREE.SubtractiveBlending = 3;
  59. THREE.MultiplyBlending = 4;
  60. THREE.CustomBlending = 5;
  61. // custom blending equations
  62. // (numbers start from 100 not to clash with other
  63. // mappings to OpenGL constants defined in Texture.js)
  64. THREE.AddEquation = 100;
  65. THREE.SubtractEquation = 101;
  66. THREE.ReverseSubtractEquation = 102;
  67. // custom blending destination factors
  68. THREE.ZeroFactor = 200;
  69. THREE.OneFactor = 201;
  70. THREE.SrcColorFactor = 202;
  71. THREE.OneMinusSrcColorFactor = 203;
  72. THREE.SrcAlphaFactor = 204;
  73. THREE.OneMinusSrcAlphaFactor = 205;
  74. THREE.DstAlphaFactor = 206;
  75. THREE.OneMinusDstAlphaFactor = 207;
  76. // custom blending source factors
  77. //THREE.ZeroFactor = 200;
  78. //THREE.OneFactor = 201;
  79. //THREE.SrcAlphaFactor = 204;
  80. //THREE.OneMinusSrcAlphaFactor = 205;
  81. //THREE.DstAlphaFactor = 206;
  82. //THREE.OneMinusDstAlphaFactor = 207;
  83. THREE.DstColorFactor = 208;
  84. THREE.OneMinusDstColorFactor = 209;
  85. THREE.SrcAlphaSaturateFactor = 210;
  86. // TEXTURE CONSTANTS
  87. THREE.MultiplyOperation = 0;
  88. THREE.MixOperation = 1;
  89. // Mapping modes
  90. THREE.UVMapping = function () {};
  91. THREE.CubeReflectionMapping = function () {};
  92. THREE.CubeRefractionMapping = function () {};
  93. THREE.SphericalReflectionMapping = function () {};
  94. THREE.SphericalRefractionMapping = function () {};
  95. // Wrapping modes
  96. THREE.RepeatWrapping = 1000;
  97. THREE.ClampToEdgeWrapping = 1001;
  98. THREE.MirroredRepeatWrapping = 1002;
  99. // Filters
  100. THREE.NearestFilter = 1003;
  101. THREE.NearestMipMapNearestFilter = 1004;
  102. THREE.NearestMipMapLinearFilter = 1005;
  103. THREE.LinearFilter = 1006;
  104. THREE.LinearMipMapNearestFilter = 1007;
  105. THREE.LinearMipMapLinearFilter = 1008;
  106. // Data types
  107. THREE.UnsignedByteType = 1009;
  108. THREE.ByteType = 1010;
  109. THREE.ShortType = 1011;
  110. THREE.UnsignedShortType = 1012;
  111. THREE.IntType = 1013;
  112. THREE.UnsignedIntType = 1014;
  113. THREE.FloatType = 1015;
  114. // Pixel types
  115. //THREE.UnsignedByteType = 1009;
  116. THREE.UnsignedShort4444Type = 1016;
  117. THREE.UnsignedShort5551Type = 1017;
  118. THREE.UnsignedShort565Type = 1018;
  119. // Pixel formats
  120. THREE.AlphaFormat = 1019;
  121. THREE.RGBFormat = 1020;
  122. THREE.RGBAFormat = 1021;
  123. THREE.LuminanceFormat = 1022;
  124. THREE.LuminanceAlphaFormat = 1023;