Three.js 6.3 KB

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