Three.js 7.4 KB

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