Three.js 6.3 KB

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