Three.js 7.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337
  1. /**
  2. * @author mrdoob / http://mrdoob.com/
  3. */
  4. var THREE = { REVISION: '77dev' };
  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. //
  12. if ( Number.EPSILON === undefined ) {
  13. Number.EPSILON = Math.pow( 2, - 52 );
  14. }
  15. //
  16. if ( Math.sign === undefined ) {
  17. // https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Math/sign
  18. Math.sign = function ( x ) {
  19. return ( x < 0 ) ? - 1 : ( x > 0 ) ? 1 : + x;
  20. };
  21. }
  22. if ( Function.prototype.name === undefined && Object.defineProperty !== undefined ) {
  23. // Missing in IE9-11.
  24. // https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Function/name
  25. Object.defineProperty( Function.prototype, 'name', {
  26. get: function () {
  27. return this.toString().match( /^\s*function\s*(\S*)\s*\(/ )[ 1 ];
  28. }
  29. } );
  30. }
  31. if ( Object.assign === undefined ) {
  32. // https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/assign
  33. Object.defineProperty( Object, 'assign', {
  34. writable: true,
  35. configurable: true,
  36. value: function ( target ) {
  37. 'use strict';
  38. if ( target === undefined || target === null ) {
  39. throw new TypeError( "Cannot convert first argument to object" );
  40. }
  41. var to = Object( target );
  42. for ( var i = 1, n = arguments.length; i !== n; ++ i ) {
  43. var nextSource = arguments[ i ];
  44. if ( nextSource === undefined || nextSource === null ) continue;
  45. nextSource = Object( nextSource );
  46. var keysArray = Object.keys( nextSource );
  47. for ( var nextIndex = 0, len = keysArray.length; nextIndex !== len; ++ nextIndex ) {
  48. var nextKey = keysArray[ nextIndex ];
  49. var desc = Object.getOwnPropertyDescriptor( nextSource, nextKey );
  50. if ( desc !== undefined && desc.enumerable ) {
  51. to[ nextKey ] = nextSource[ nextKey ];
  52. }
  53. }
  54. }
  55. return to;
  56. }
  57. } );
  58. }
  59. // https://developer.mozilla.org/en-US/docs/Web/API/MouseEvent.button
  60. THREE.MOUSE = { LEFT: 0, MIDDLE: 1, RIGHT: 2 };
  61. // GL STATE CONSTANTS
  62. THREE.CullFaceNone = 0;
  63. THREE.CullFaceBack = 1;
  64. THREE.CullFaceFront = 2;
  65. THREE.CullFaceFrontBack = 3;
  66. THREE.FrontFaceDirectionCW = 0;
  67. THREE.FrontFaceDirectionCCW = 1;
  68. // SHADOWING TYPES
  69. THREE.BasicShadowMap = 0;
  70. THREE.PCFShadowMap = 1;
  71. THREE.PCFSoftShadowMap = 2;
  72. // MATERIAL CONSTANTS
  73. // side
  74. THREE.FrontSide = 0;
  75. THREE.BackSide = 1;
  76. THREE.DoubleSide = 2;
  77. // shading
  78. THREE.FlatShading = 1;
  79. THREE.SmoothShading = 2;
  80. // colors
  81. THREE.NoColors = 0;
  82. THREE.FaceColors = 1;
  83. THREE.VertexColors = 2;
  84. // blending modes
  85. THREE.NoBlending = 0;
  86. THREE.NormalBlending = 1;
  87. THREE.AdditiveBlending = 2;
  88. THREE.SubtractiveBlending = 3;
  89. THREE.MultiplyBlending = 4;
  90. THREE.CustomBlending = 5;
  91. // custom blending equations
  92. // (numbers start from 100 not to clash with other
  93. // mappings to OpenGL constants defined in Texture.js)
  94. THREE.AddEquation = 100;
  95. THREE.SubtractEquation = 101;
  96. THREE.ReverseSubtractEquation = 102;
  97. THREE.MinEquation = 103;
  98. THREE.MaxEquation = 104;
  99. // custom blending destination factors
  100. THREE.ZeroFactor = 200;
  101. THREE.OneFactor = 201;
  102. THREE.SrcColorFactor = 202;
  103. THREE.OneMinusSrcColorFactor = 203;
  104. THREE.SrcAlphaFactor = 204;
  105. THREE.OneMinusSrcAlphaFactor = 205;
  106. THREE.DstAlphaFactor = 206;
  107. THREE.OneMinusDstAlphaFactor = 207;
  108. // custom blending source factors
  109. //THREE.ZeroFactor = 200;
  110. //THREE.OneFactor = 201;
  111. //THREE.SrcAlphaFactor = 204;
  112. //THREE.OneMinusSrcAlphaFactor = 205;
  113. //THREE.DstAlphaFactor = 206;
  114. //THREE.OneMinusDstAlphaFactor = 207;
  115. THREE.DstColorFactor = 208;
  116. THREE.OneMinusDstColorFactor = 209;
  117. THREE.SrcAlphaSaturateFactor = 210;
  118. // depth modes
  119. THREE.NeverDepth = 0;
  120. THREE.AlwaysDepth = 1;
  121. THREE.LessDepth = 2;
  122. THREE.LessEqualDepth = 3;
  123. THREE.EqualDepth = 4;
  124. THREE.GreaterEqualDepth = 5;
  125. THREE.GreaterDepth = 6;
  126. THREE.NotEqualDepth = 7;
  127. // TEXTURE CONSTANTS
  128. THREE.MultiplyOperation = 0;
  129. THREE.MixOperation = 1;
  130. THREE.AddOperation = 2;
  131. // Tone Mapping modes
  132. THREE.NoToneMapping = 0; // do not do any tone mapping, not even exposure (required for special purpose passes.)
  133. THREE.LinearToneMapping = 1; // only apply exposure.
  134. THREE.ReinhardToneMapping = 2;
  135. THREE.Uncharted2ToneMapping = 3; // John Hable
  136. THREE.CineonToneMapping = 4; // optimized filmic operator by Jim Hejl and Richard Burgess-Dawson
  137. // Mapping modes
  138. THREE.UVMapping = 300;
  139. THREE.CubeReflectionMapping = 301;
  140. THREE.CubeRefractionMapping = 302;
  141. THREE.EquirectangularReflectionMapping = 303;
  142. THREE.EquirectangularRefractionMapping = 304;
  143. THREE.SphericalReflectionMapping = 305;
  144. THREE.CubeUVReflectionMapping = 306;
  145. THREE.CubeUVRefractionMapping = 307;
  146. // Wrapping modes
  147. THREE.RepeatWrapping = 1000;
  148. THREE.ClampToEdgeWrapping = 1001;
  149. THREE.MirroredRepeatWrapping = 1002;
  150. // Filters
  151. THREE.NearestFilter = 1003;
  152. THREE.NearestMipMapNearestFilter = 1004;
  153. THREE.NearestMipMapLinearFilter = 1005;
  154. THREE.LinearFilter = 1006;
  155. THREE.LinearMipMapNearestFilter = 1007;
  156. THREE.LinearMipMapLinearFilter = 1008;
  157. // Data types
  158. THREE.UnsignedByteType = 1009;
  159. THREE.ByteType = 1010;
  160. THREE.ShortType = 1011;
  161. THREE.UnsignedShortType = 1012;
  162. THREE.IntType = 1013;
  163. THREE.UnsignedIntType = 1014;
  164. THREE.FloatType = 1015;
  165. THREE.HalfFloatType = 1025;
  166. // Pixel types
  167. //THREE.UnsignedByteType = 1009;
  168. THREE.UnsignedShort4444Type = 1016;
  169. THREE.UnsignedShort5551Type = 1017;
  170. THREE.UnsignedShort565Type = 1018;
  171. // Pixel formats
  172. THREE.AlphaFormat = 1019;
  173. THREE.RGBFormat = 1020;
  174. THREE.RGBAFormat = 1021;
  175. THREE.LuminanceFormat = 1022;
  176. THREE.LuminanceAlphaFormat = 1023;
  177. // THREE.RGBEFormat handled as THREE.RGBAFormat in shaders
  178. THREE.RGBEFormat = THREE.RGBAFormat; //1024;
  179. THREE.DepthFormat = 1026;
  180. // DDS / ST3C Compressed texture formats
  181. THREE.RGB_S3TC_DXT1_Format = 2001;
  182. THREE.RGBA_S3TC_DXT1_Format = 2002;
  183. THREE.RGBA_S3TC_DXT3_Format = 2003;
  184. THREE.RGBA_S3TC_DXT5_Format = 2004;
  185. // PVRTC compressed texture formats
  186. THREE.RGB_PVRTC_4BPPV1_Format = 2100;
  187. THREE.RGB_PVRTC_2BPPV1_Format = 2101;
  188. THREE.RGBA_PVRTC_4BPPV1_Format = 2102;
  189. THREE.RGBA_PVRTC_2BPPV1_Format = 2103;
  190. // ETC compressed texture formats
  191. THREE.RGB_ETC1_Format = 2151;
  192. // Loop styles for AnimationAction
  193. THREE.LoopOnce = 2200;
  194. THREE.LoopRepeat = 2201;
  195. THREE.LoopPingPong = 2202;
  196. // Interpolation
  197. THREE.InterpolateDiscrete = 2300;
  198. THREE.InterpolateLinear = 2301;
  199. THREE.InterpolateSmooth = 2302;
  200. // Interpolant ending modes
  201. THREE.ZeroCurvatureEnding = 2400;
  202. THREE.ZeroSlopeEnding = 2401;
  203. THREE.WrapAroundEnding = 2402;
  204. // Triangle Draw modes
  205. THREE.TrianglesDrawMode = 0;
  206. THREE.TriangleStripDrawMode = 1;
  207. THREE.TriangleFanDrawMode = 2;
  208. // Texture Encodings
  209. THREE.LinearEncoding = 3000; // No encoding at all.
  210. THREE.sRGBEncoding = 3001;
  211. THREE.GammaEncoding = 3007; // uses GAMMA_FACTOR, for backwards compatibility with WebGLRenderer.gammaInput/gammaOutput
  212. // The following Texture Encodings are for RGB-only (no alpha) HDR light emission sources.
  213. // These encodings should not specified as output encodings except in rare situations.
  214. THREE.RGBEEncoding = 3002; // AKA Radiance.
  215. THREE.LogLuvEncoding = 3003;
  216. THREE.RGBM7Encoding = 3004;
  217. THREE.RGBM16Encoding = 3005;
  218. THREE.RGBDEncoding = 3006; // MaxRange is 256.
  219. // Depth packing strategies
  220. THREE.BasicDepthPacking = 3200; // for writing to float textures for high precision or for visualizing results in RGB buffers
  221. THREE.RGBADepthPacking = 3201; // for packing into RGBA buffers.