Three.js 6.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296
  1. /**
  2. * @author mrdoob / http://mrdoob.com/
  3. */
  4. var THREE = { REVISION: '72dev' };
  5. // browserify support
  6. if ( typeof module === 'object' ) {
  7. module.exports = THREE;
  8. }
  9. // polyfills
  10. ( function () {
  11. var lastTime = 0;
  12. var vendors = [ 'ms', 'moz', 'webkit', 'o' ];
  13. for ( var x = 0; x < vendors.length && ! self.requestAnimationFrame; ++ x ) {
  14. self.requestAnimationFrame = self[ vendors[ x ] + 'RequestAnimationFrame' ];
  15. self.cancelAnimationFrame = self[ vendors[ x ] + 'CancelAnimationFrame' ] || self[ vendors[ x ] + 'CancelRequestAnimationFrame' ];
  16. }
  17. if ( self.requestAnimationFrame === undefined && self.setTimeout !== undefined ) {
  18. self.requestAnimationFrame = function ( callback ) {
  19. var currTime = Date.now(), timeToCall = Math.max( 0, 16 - ( currTime - lastTime ) );
  20. var id = self.setTimeout( function () {
  21. callback( currTime + timeToCall );
  22. }, timeToCall );
  23. lastTime = currTime + timeToCall;
  24. return id;
  25. };
  26. }
  27. if ( self.cancelAnimationFrame === undefined && self.clearTimeout !== undefined ) {
  28. self.cancelAnimationFrame = function ( id ) {
  29. self.clearTimeout( id );
  30. };
  31. }
  32. }() );
  33. if ( Math.sign === undefined ) {
  34. // https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Math/sign
  35. Math.sign = function ( x ) {
  36. return ( x < 0 ) ? - 1 : ( x > 0 ) ? 1 : + x;
  37. };
  38. }
  39. if ( Function.prototype.name === undefined && Object.defineProperty !== undefined ) {
  40. // Missing in IE9-11.
  41. // https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Function/name
  42. Object.defineProperty( Function.prototype, 'name', {
  43. get: function () {
  44. return this.toString().match( /^\s*function\s*(\S*)\s*\(/ )[ 1 ];
  45. }
  46. } );
  47. }
  48. // https://developer.mozilla.org/en-US/docs/Web/API/MouseEvent.button
  49. THREE.MOUSE = { LEFT: 0, MIDDLE: 1, RIGHT: 2 };
  50. // GL STATE CONSTANTS
  51. THREE.CullFaceNone = 0;
  52. THREE.CullFaceBack = 1;
  53. THREE.CullFaceFront = 2;
  54. THREE.CullFaceFrontBack = 3;
  55. THREE.FrontFaceDirectionCW = 0;
  56. THREE.FrontFaceDirectionCCW = 1;
  57. // SHADOWING TYPES
  58. THREE.BasicShadowMap = 0;
  59. THREE.PCFShadowMap = 1;
  60. THREE.PCFSoftShadowMap = 2;
  61. // MATERIAL CONSTANTS
  62. // side
  63. THREE.FrontSide = 0;
  64. THREE.BackSide = 1;
  65. THREE.DoubleSide = 2;
  66. // shading
  67. THREE.NoShading = 0;
  68. THREE.FlatShading = 1;
  69. THREE.SmoothShading = 2;
  70. // colors
  71. THREE.NoColors = 0;
  72. THREE.FaceColors = 1;
  73. THREE.VertexColors = 2;
  74. // blending modes
  75. THREE.NoBlending = 0;
  76. THREE.NormalBlending = 1;
  77. THREE.AdditiveBlending = 2;
  78. THREE.SubtractiveBlending = 3;
  79. THREE.MultiplyBlending = 4;
  80. THREE.CustomBlending = 5;
  81. // custom blending equations
  82. // (numbers start from 100 not to clash with other
  83. // mappings to OpenGL constants defined in Texture.js)
  84. THREE.AddEquation = 100;
  85. THREE.SubtractEquation = 101;
  86. THREE.ReverseSubtractEquation = 102;
  87. THREE.MinEquation = 103;
  88. THREE.MaxEquation = 104;
  89. // custom blending destination factors
  90. THREE.ZeroFactor = 200;
  91. THREE.OneFactor = 201;
  92. THREE.SrcColorFactor = 202;
  93. THREE.OneMinusSrcColorFactor = 203;
  94. THREE.SrcAlphaFactor = 204;
  95. THREE.OneMinusSrcAlphaFactor = 205;
  96. THREE.DstAlphaFactor = 206;
  97. THREE.OneMinusDstAlphaFactor = 207;
  98. // custom blending source factors
  99. //THREE.ZeroFactor = 200;
  100. //THREE.OneFactor = 201;
  101. //THREE.SrcAlphaFactor = 204;
  102. //THREE.OneMinusSrcAlphaFactor = 205;
  103. //THREE.DstAlphaFactor = 206;
  104. //THREE.OneMinusDstAlphaFactor = 207;
  105. THREE.DstColorFactor = 208;
  106. THREE.OneMinusDstColorFactor = 209;
  107. THREE.SrcAlphaSaturateFactor = 210;
  108. // depth modes
  109. THREE.NeverDepth = 0;
  110. THREE.AlwaysDepth = 1;
  111. THREE.LessDepth = 2;
  112. THREE.LessEqualDepth = 3;
  113. THREE.EqualDepth = 4;
  114. THREE.GreaterEqualDepth = 5;
  115. THREE.GreaterDepth = 6;
  116. THREE.NotEqualDepth = 7;
  117. // TEXTURE CONSTANTS
  118. THREE.MultiplyOperation = 0;
  119. THREE.MixOperation = 1;
  120. THREE.AddOperation = 2;
  121. // Mapping modes
  122. THREE.UVMapping = 300;
  123. THREE.CubeReflectionMapping = 301;
  124. THREE.CubeRefractionMapping = 302;
  125. THREE.EquirectangularReflectionMapping = 303;
  126. THREE.EquirectangularRefractionMapping = 304;
  127. THREE.SphericalReflectionMapping = 305;
  128. // Wrapping modes
  129. THREE.RepeatWrapping = 1000;
  130. THREE.ClampToEdgeWrapping = 1001;
  131. THREE.MirroredRepeatWrapping = 1002;
  132. // Filters
  133. THREE.NearestFilter = 1003;
  134. THREE.NearestMipMapNearestFilter = 1004;
  135. THREE.NearestMipMapLinearFilter = 1005;
  136. THREE.LinearFilter = 1006;
  137. THREE.LinearMipMapNearestFilter = 1007;
  138. THREE.LinearMipMapLinearFilter = 1008;
  139. // Data types
  140. THREE.UnsignedByteType = 1009;
  141. THREE.ByteType = 1010;
  142. THREE.ShortType = 1011;
  143. THREE.UnsignedShortType = 1012;
  144. THREE.IntType = 1013;
  145. THREE.UnsignedIntType = 1014;
  146. THREE.FloatType = 1015;
  147. THREE.HalfFloatType = 1025;
  148. // Pixel types
  149. //THREE.UnsignedByteType = 1009;
  150. THREE.UnsignedShort4444Type = 1016;
  151. THREE.UnsignedShort5551Type = 1017;
  152. THREE.UnsignedShort565Type = 1018;
  153. // Pixel formats
  154. THREE.AlphaFormat = 1019;
  155. THREE.RGBFormat = 1020;
  156. THREE.RGBAFormat = 1021;
  157. THREE.LuminanceFormat = 1022;
  158. THREE.LuminanceAlphaFormat = 1023;
  159. // THREE.RGBEFormat handled as THREE.RGBAFormat in shaders
  160. THREE.RGBEFormat = THREE.RGBAFormat; //1024;
  161. // DDS / ST3C Compressed texture formats
  162. THREE.RGB_S3TC_DXT1_Format = 2001;
  163. THREE.RGBA_S3TC_DXT1_Format = 2002;
  164. THREE.RGBA_S3TC_DXT3_Format = 2003;
  165. THREE.RGBA_S3TC_DXT5_Format = 2004;
  166. // PVRTC compressed texture formats
  167. THREE.RGB_PVRTC_4BPPV1_Format = 2100;
  168. THREE.RGB_PVRTC_2BPPV1_Format = 2101;
  169. THREE.RGBA_PVRTC_4BPPV1_Format = 2102;
  170. THREE.RGBA_PVRTC_2BPPV1_Format = 2103;
  171. // DEPRECATED
  172. THREE.Projector = function () {
  173. console.error( 'THREE.Projector has been moved to /examples/js/renderers/Projector.js.' );
  174. this.projectVector = function ( vector, camera ) {
  175. console.warn( 'THREE.Projector: .projectVector() is now vector.project().' );
  176. vector.project( camera );
  177. };
  178. this.unprojectVector = function ( vector, camera ) {
  179. console.warn( 'THREE.Projector: .unprojectVector() is now vector.unproject().' );
  180. vector.unproject( camera );
  181. };
  182. this.pickingRay = function ( vector, camera ) {
  183. console.error( 'THREE.Projector: .pickingRay() is now raycaster.setFromCamera().' );
  184. };
  185. };
  186. THREE.CanvasRenderer = function () {
  187. console.error( 'THREE.CanvasRenderer has been moved to /examples/js/renderers/CanvasRenderer.js' );
  188. this.domElement = document.createElement( 'canvas' );
  189. this.clear = function () {};
  190. this.render = function () {};
  191. this.setClearColor = function () {};
  192. this.setSize = function () {};
  193. };