Three.js 6.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345
  1. /**
  2. * @author mrdoob / http://mrdoob.com/
  3. */
  4. var THREE = { REVISION: '73' };
  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. // https://developer.mozilla.org/en-US/docs/Web/API/MouseEvent.button
  71. THREE.MOUSE = { LEFT: 0, MIDDLE: 1, RIGHT: 2 };
  72. // GL STATE CONSTANTS
  73. THREE.CullFaceNone = 0;
  74. THREE.CullFaceBack = 1;
  75. THREE.CullFaceFront = 2;
  76. THREE.CullFaceFrontBack = 3;
  77. THREE.FrontFaceDirectionCW = 0;
  78. THREE.FrontFaceDirectionCCW = 1;
  79. // SHADOWING TYPES
  80. THREE.BasicShadowMap = 0;
  81. THREE.PCFShadowMap = 1;
  82. THREE.PCFSoftShadowMap = 2;
  83. // MATERIAL CONSTANTS
  84. // side
  85. THREE.FrontSide = 0;
  86. THREE.BackSide = 1;
  87. THREE.DoubleSide = 2;
  88. // shading
  89. THREE.FlatShading = 1;
  90. THREE.SmoothShading = 2;
  91. // colors
  92. THREE.NoColors = 0;
  93. THREE.FaceColors = 1;
  94. THREE.VertexColors = 2;
  95. // blending modes
  96. THREE.NoBlending = 0;
  97. THREE.NormalBlending = 1;
  98. THREE.AdditiveBlending = 2;
  99. THREE.SubtractiveBlending = 3;
  100. THREE.MultiplyBlending = 4;
  101. THREE.CustomBlending = 5;
  102. // custom blending equations
  103. // (numbers start from 100 not to clash with other
  104. // mappings to OpenGL constants defined in Texture.js)
  105. THREE.AddEquation = 100;
  106. THREE.SubtractEquation = 101;
  107. THREE.ReverseSubtractEquation = 102;
  108. THREE.MinEquation = 103;
  109. THREE.MaxEquation = 104;
  110. // custom blending destination factors
  111. THREE.ZeroFactor = 200;
  112. THREE.OneFactor = 201;
  113. THREE.SrcColorFactor = 202;
  114. THREE.OneMinusSrcColorFactor = 203;
  115. THREE.SrcAlphaFactor = 204;
  116. THREE.OneMinusSrcAlphaFactor = 205;
  117. THREE.DstAlphaFactor = 206;
  118. THREE.OneMinusDstAlphaFactor = 207;
  119. // custom blending source factors
  120. //THREE.ZeroFactor = 200;
  121. //THREE.OneFactor = 201;
  122. //THREE.SrcAlphaFactor = 204;
  123. //THREE.OneMinusSrcAlphaFactor = 205;
  124. //THREE.DstAlphaFactor = 206;
  125. //THREE.OneMinusDstAlphaFactor = 207;
  126. THREE.DstColorFactor = 208;
  127. THREE.OneMinusDstColorFactor = 209;
  128. THREE.SrcAlphaSaturateFactor = 210;
  129. // depth modes
  130. THREE.NeverDepth = 0;
  131. THREE.AlwaysDepth = 1;
  132. THREE.LessDepth = 2;
  133. THREE.LessEqualDepth = 3;
  134. THREE.EqualDepth = 4;
  135. THREE.GreaterEqualDepth = 5;
  136. THREE.GreaterDepth = 6;
  137. THREE.NotEqualDepth = 7;
  138. // TEXTURE CONSTANTS
  139. THREE.MultiplyOperation = 0;
  140. THREE.MixOperation = 1;
  141. THREE.AddOperation = 2;
  142. // Mapping modes
  143. THREE.UVMapping = 300;
  144. THREE.CubeReflectionMapping = 301;
  145. THREE.CubeRefractionMapping = 302;
  146. THREE.EquirectangularReflectionMapping = 303;
  147. THREE.EquirectangularRefractionMapping = 304;
  148. THREE.SphericalReflectionMapping = 305;
  149. // Wrapping modes
  150. THREE.RepeatWrapping = 1000;
  151. THREE.ClampToEdgeWrapping = 1001;
  152. THREE.MirroredRepeatWrapping = 1002;
  153. // Filters
  154. THREE.NearestFilter = 1003;
  155. THREE.NearestMipMapNearestFilter = 1004;
  156. THREE.NearestMipMapLinearFilter = 1005;
  157. THREE.LinearFilter = 1006;
  158. THREE.LinearMipMapNearestFilter = 1007;
  159. THREE.LinearMipMapLinearFilter = 1008;
  160. // Data types
  161. THREE.UnsignedByteType = 1009;
  162. THREE.ByteType = 1010;
  163. THREE.ShortType = 1011;
  164. THREE.UnsignedShortType = 1012;
  165. THREE.IntType = 1013;
  166. THREE.UnsignedIntType = 1014;
  167. THREE.FloatType = 1015;
  168. THREE.HalfFloatType = 1025;
  169. // Pixel types
  170. //THREE.UnsignedByteType = 1009;
  171. THREE.UnsignedShort4444Type = 1016;
  172. THREE.UnsignedShort5551Type = 1017;
  173. THREE.UnsignedShort565Type = 1018;
  174. // Pixel formats
  175. THREE.AlphaFormat = 1019;
  176. THREE.RGBFormat = 1020;
  177. THREE.RGBAFormat = 1021;
  178. THREE.LuminanceFormat = 1022;
  179. THREE.LuminanceAlphaFormat = 1023;
  180. // THREE.RGBEFormat handled as THREE.RGBAFormat in shaders
  181. THREE.RGBEFormat = THREE.RGBAFormat; //1024;
  182. // DDS / ST3C Compressed texture formats
  183. THREE.RGB_S3TC_DXT1_Format = 2001;
  184. THREE.RGBA_S3TC_DXT1_Format = 2002;
  185. THREE.RGBA_S3TC_DXT3_Format = 2003;
  186. THREE.RGBA_S3TC_DXT5_Format = 2004;
  187. // PVRTC compressed texture formats
  188. THREE.RGB_PVRTC_4BPPV1_Format = 2100;
  189. THREE.RGB_PVRTC_2BPPV1_Format = 2101;
  190. THREE.RGBA_PVRTC_4BPPV1_Format = 2102;
  191. THREE.RGBA_PVRTC_2BPPV1_Format = 2103;
  192. // Loop styles for AnimationAction
  193. THREE.LoopOnce = 2200;
  194. THREE.LoopRepeat = 2201;
  195. THREE.LoopPingPong = 2202;
  196. // DEPRECATED
  197. THREE.Projector = function () {
  198. console.error( 'THREE.Projector has been moved to /examples/js/renderers/Projector.js.' );
  199. this.projectVector = function ( vector, camera ) {
  200. console.warn( 'THREE.Projector: .projectVector() is now vector.project().' );
  201. vector.project( camera );
  202. };
  203. this.unprojectVector = function ( vector, camera ) {
  204. console.warn( 'THREE.Projector: .unprojectVector() is now vector.unproject().' );
  205. vector.unproject( camera );
  206. };
  207. this.pickingRay = function ( vector, camera ) {
  208. console.error( 'THREE.Projector: .pickingRay() is now raycaster.setFromCamera().' );
  209. };
  210. };
  211. THREE.CanvasRenderer = function () {
  212. console.error( 'THREE.CanvasRenderer has been moved to /examples/js/renderers/CanvasRenderer.js' );
  213. this.domElement = document.createElement( 'canvas' );
  214. this.clear = function () {};
  215. this.render = function () {};
  216. this.setClearColor = function () {};
  217. this.setSize = function () {};
  218. };