Three.js 6.5 KB

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