Three.js 7.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377
  1. /**
  2. * @author mrdoob / http://mrdoob.com/
  3. */
  4. var THREE = { REVISION: '74dev' };
  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. //
  39. if ( self.performance === undefined ) {
  40. self.performance = {};
  41. }
  42. if ( self.performance.now === undefined ) {
  43. ( function () {
  44. var start = Date.now();
  45. self.performance.now = function () {
  46. return Date.now() - start;
  47. }
  48. } )();
  49. }
  50. //
  51. if ( Number.EPSILON === undefined ) {
  52. Number.EPSILON = Math.pow( 2, - 52 );
  53. }
  54. //
  55. if ( Math.sign === undefined ) {
  56. // https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Math/sign
  57. Math.sign = function ( x ) {
  58. return ( x < 0 ) ? - 1 : ( x > 0 ) ? 1 : + x;
  59. };
  60. }
  61. if ( Function.prototype.name === undefined && Object.defineProperty !== undefined ) {
  62. // Missing in IE9-11.
  63. // https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Function/name
  64. Object.defineProperty( Function.prototype, 'name', {
  65. get: function () {
  66. return this.toString().match( /^\s*function\s*(\S*)\s*\(/ )[ 1 ];
  67. }
  68. } );
  69. }
  70. if ( Object.assign === undefined ) {
  71. // https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/assign
  72. Object.defineProperty( Object, 'assign', {
  73. writable: true,
  74. configurable: true,
  75. value: function ( target ) {
  76. 'use strict';
  77. if ( target === undefined || target === null ) {
  78. throw new TypeError( "Cannot convert first argument to object" );
  79. }
  80. var to = Object( target );
  81. for ( var i = 1, n = arguments.length; i !== n; ++ i ) {
  82. var nextSource = arguments[ i ];
  83. if ( nextSource === undefined || nextSource === null ) continue;
  84. nextSource = Object( nextSource );
  85. var keysArray = Object.keys( nextSource );
  86. for ( var nextIndex = 0, len = keysArray.length; nextIndex !== len; ++ nextIndex ) {
  87. var nextKey = keysArray[ nextIndex ];
  88. var desc = Object.getOwnPropertyDescriptor( nextSource, nextKey );
  89. if ( desc !== undefined && desc.enumerable ) {
  90. to[ nextKey ] = nextSource[ nextKey ];
  91. }
  92. }
  93. }
  94. return to;
  95. }
  96. } );
  97. }
  98. // https://developer.mozilla.org/en-US/docs/Web/API/MouseEvent.button
  99. THREE.MOUSE = { LEFT: 0, MIDDLE: 1, RIGHT: 2 };
  100. // GL STATE CONSTANTS
  101. THREE.CullFaceNone = 0;
  102. THREE.CullFaceBack = 1;
  103. THREE.CullFaceFront = 2;
  104. THREE.CullFaceFrontBack = 3;
  105. THREE.FrontFaceDirectionCW = 0;
  106. THREE.FrontFaceDirectionCCW = 1;
  107. // SHADOWING TYPES
  108. THREE.BasicShadowMap = 0;
  109. THREE.PCFShadowMap = 1;
  110. THREE.PCFSoftShadowMap = 2;
  111. // MATERIAL CONSTANTS
  112. // side
  113. THREE.FrontSide = 0;
  114. THREE.BackSide = 1;
  115. THREE.DoubleSide = 2;
  116. // shading
  117. THREE.FlatShading = 1;
  118. THREE.SmoothShading = 2;
  119. // colors
  120. THREE.NoColors = 0;
  121. THREE.FaceColors = 1;
  122. THREE.VertexColors = 2;
  123. // blending modes
  124. THREE.NoBlending = 0;
  125. THREE.NormalBlending = 1;
  126. THREE.AdditiveBlending = 2;
  127. THREE.SubtractiveBlending = 3;
  128. THREE.MultiplyBlending = 4;
  129. THREE.CustomBlending = 5;
  130. // custom blending equations
  131. // (numbers start from 100 not to clash with other
  132. // mappings to OpenGL constants defined in Texture.js)
  133. THREE.AddEquation = 100;
  134. THREE.SubtractEquation = 101;
  135. THREE.ReverseSubtractEquation = 102;
  136. THREE.MinEquation = 103;
  137. THREE.MaxEquation = 104;
  138. // custom blending destination factors
  139. THREE.ZeroFactor = 200;
  140. THREE.OneFactor = 201;
  141. THREE.SrcColorFactor = 202;
  142. THREE.OneMinusSrcColorFactor = 203;
  143. THREE.SrcAlphaFactor = 204;
  144. THREE.OneMinusSrcAlphaFactor = 205;
  145. THREE.DstAlphaFactor = 206;
  146. THREE.OneMinusDstAlphaFactor = 207;
  147. // custom blending source factors
  148. //THREE.ZeroFactor = 200;
  149. //THREE.OneFactor = 201;
  150. //THREE.SrcAlphaFactor = 204;
  151. //THREE.OneMinusSrcAlphaFactor = 205;
  152. //THREE.DstAlphaFactor = 206;
  153. //THREE.OneMinusDstAlphaFactor = 207;
  154. THREE.DstColorFactor = 208;
  155. THREE.OneMinusDstColorFactor = 209;
  156. THREE.SrcAlphaSaturateFactor = 210;
  157. // depth modes
  158. THREE.NeverDepth = 0;
  159. THREE.AlwaysDepth = 1;
  160. THREE.LessDepth = 2;
  161. THREE.LessEqualDepth = 3;
  162. THREE.EqualDepth = 4;
  163. THREE.GreaterEqualDepth = 5;
  164. THREE.GreaterDepth = 6;
  165. THREE.NotEqualDepth = 7;
  166. // TEXTURE CONSTANTS
  167. THREE.MultiplyOperation = 0;
  168. THREE.MixOperation = 1;
  169. THREE.AddOperation = 2;
  170. // Mapping modes
  171. THREE.UVMapping = 300;
  172. THREE.CubeReflectionMapping = 301;
  173. THREE.CubeRefractionMapping = 302;
  174. THREE.EquirectangularReflectionMapping = 303;
  175. THREE.EquirectangularRefractionMapping = 304;
  176. THREE.SphericalReflectionMapping = 305;
  177. // Wrapping modes
  178. THREE.RepeatWrapping = 1000;
  179. THREE.ClampToEdgeWrapping = 1001;
  180. THREE.MirroredRepeatWrapping = 1002;
  181. // Filters
  182. THREE.NearestFilter = 1003;
  183. THREE.NearestMipMapNearestFilter = 1004;
  184. THREE.NearestMipMapLinearFilter = 1005;
  185. THREE.LinearFilter = 1006;
  186. THREE.LinearMipMapNearestFilter = 1007;
  187. THREE.LinearMipMapLinearFilter = 1008;
  188. // Data types
  189. THREE.UnsignedByteType = 1009;
  190. THREE.ByteType = 1010;
  191. THREE.ShortType = 1011;
  192. THREE.UnsignedShortType = 1012;
  193. THREE.IntType = 1013;
  194. THREE.UnsignedIntType = 1014;
  195. THREE.FloatType = 1015;
  196. THREE.HalfFloatType = 1025;
  197. // Pixel types
  198. //THREE.UnsignedByteType = 1009;
  199. THREE.UnsignedShort4444Type = 1016;
  200. THREE.UnsignedShort5551Type = 1017;
  201. THREE.UnsignedShort565Type = 1018;
  202. // Pixel formats
  203. THREE.AlphaFormat = 1019;
  204. THREE.RGBFormat = 1020;
  205. THREE.RGBAFormat = 1021;
  206. THREE.LuminanceFormat = 1022;
  207. THREE.LuminanceAlphaFormat = 1023;
  208. // THREE.RGBEFormat handled as THREE.RGBAFormat in shaders
  209. THREE.RGBEFormat = THREE.RGBAFormat; //1024;
  210. // DDS / ST3C Compressed texture formats
  211. THREE.RGB_S3TC_DXT1_Format = 2001;
  212. THREE.RGBA_S3TC_DXT1_Format = 2002;
  213. THREE.RGBA_S3TC_DXT3_Format = 2003;
  214. THREE.RGBA_S3TC_DXT5_Format = 2004;
  215. // PVRTC compressed texture formats
  216. THREE.RGB_PVRTC_4BPPV1_Format = 2100;
  217. THREE.RGB_PVRTC_2BPPV1_Format = 2101;
  218. THREE.RGBA_PVRTC_4BPPV1_Format = 2102;
  219. THREE.RGBA_PVRTC_2BPPV1_Format = 2103;
  220. // Loop styles for AnimationAction
  221. THREE.LoopOnce = 2200;
  222. THREE.LoopRepeat = 2201;
  223. THREE.LoopPingPong = 2202;
  224. // Interpolation
  225. THREE.InterpolateDiscrete = 2300;
  226. THREE.InterpolateLinear = 2301;
  227. THREE.InterpolateSmooth = 2302;
  228. // Interpolant ending modes
  229. THREE.ZeroCurvatureEnding = 2400;
  230. THREE.ZeroSlopeEnding = 2401;
  231. THREE.WrapAroundEnding = 2402;
  232. // Triangle Draw modes
  233. THREE.TrianglesDrawMode = 0;
  234. THREE.TriangleStripDrawMode = 1;
  235. THREE.TriangleFanDrawMode = 2;
粤ICP备19079148号