Three.Legacy.js 33 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353
  1. /**
  2. * @author mrdoob / http://mrdoob.com/
  3. */
  4. import { Audio } from './audio/Audio.js';
  5. import { AudioAnalyser } from './audio/AudioAnalyser.js';
  6. import { PerspectiveCamera } from './cameras/PerspectiveCamera.js';
  7. import { CullFaceFront, CullFaceBack } from './constants.js';
  8. import {
  9. Float64BufferAttribute,
  10. Float32BufferAttribute,
  11. Uint32BufferAttribute,
  12. Int32BufferAttribute,
  13. Uint16BufferAttribute,
  14. Int16BufferAttribute,
  15. Uint8ClampedBufferAttribute,
  16. Uint8BufferAttribute,
  17. Int8BufferAttribute,
  18. BufferAttribute
  19. } from './core/BufferAttribute.js';
  20. import { BufferGeometry } from './core/BufferGeometry.js';
  21. import { EventDispatcher } from './core/EventDispatcher.js';
  22. import { Face3 } from './core/Face3.js';
  23. import { Geometry } from './core/Geometry';
  24. import { Object3D } from './core/Object3D.js';
  25. import { Uniform } from './core/Uniform';
  26. import { CatmullRomCurve3 } from './extras/curves/CatmullRomCurve3.js';
  27. import { BoxHelper } from './extras/helpers/BoxHelper';
  28. import { GridHelper } from './extras/helpers/GridHelper.js';
  29. import { BoxGeometry } from './geometries/BoxGeometry.js';
  30. import { EdgesGeometry } from './geometries/EdgesGeometry.js';
  31. import { ExtrudeGeometry } from './geometries/ExtrudeGeometry.js';
  32. import { ShapeGeometry } from './geometries/ShapeGeometry.js';
  33. import { WireframeGeometry } from './geometries/WireframeGeometry.js';
  34. import { Light } from './lights/Light.js';
  35. import { FileLoader } from './loaders/FileLoader.js';
  36. import { AudioLoader } from './loaders/AudioLoader.js';
  37. import { CubeTextureLoader } from './loaders/CubeTextureLoader.js';
  38. import { TextureLoader } from './loaders/TextureLoader.js';
  39. import { Material } from './materials/Material.js';
  40. import { LineBasicMaterial } from './materials/LineBasicMaterial.js';
  41. import { MeshPhongMaterial } from './materials/MeshPhongMaterial.js';
  42. import { MultiMaterial } from './materials/MultiMaterial.js';
  43. import { PointsMaterial } from './materials/PointsMaterial.js';
  44. import { ShaderMaterial } from './materials/ShaderMaterial.js';
  45. import { Box2 } from './math/Box2.js';
  46. import { Box3 } from './math/Box3.js';
  47. import { Color } from './math/Color.js';
  48. import { Line3 } from './math/Line3.js';
  49. import { _Math } from './math/Math.js';
  50. import { Matrix3 } from './math/Matrix3.js';
  51. import { Matrix4 } from './math/Matrix4.js';
  52. import { Plane } from './math/Plane.js';
  53. import { Quaternion } from './math/Quaternion.js';
  54. import { Ray } from './math/Ray.js';
  55. import { Vector3 } from './math/Vector3.js';
  56. import { LineSegments } from './objects/LineSegments.js';
  57. import { LOD } from './objects/LOD.js';
  58. import { Points } from './objects/Points.js';
  59. import { Sprite } from './objects/Sprite.js';
  60. import { WebGLRenderer } from './renderers/WebGLRenderer.js';
  61. import { WebGLRenderTarget } from './renderers/WebGLRenderTarget.js';
  62. import { WebGLShadowMap } from './renderers/webgl/WebGLShadowMap.js';
  63. import { Shape } from './extras/core/Shape.js';
  64. export { BoxGeometry as CubeGeometry };
  65. export function Face4( a, b, c, d, normal, color, materialIndex ) {
  66. console.warn( 'THREE.Face4 has been removed. A THREE.Face3 will be created instead.' );
  67. return new Face3( a, b, c, normal, color, materialIndex );
  68. }
  69. export var LineStrip = 0;
  70. export var LinePieces = 1;
  71. export function MeshFaceMaterial( materials ) {
  72. console.warn( 'THREE.MeshFaceMaterial has been renamed to THREE.MultiMaterial.' );
  73. return new MultiMaterial( materials );
  74. }
  75. export function PointCloud( geometry, material ) {
  76. console.warn( 'THREE.PointCloud has been renamed to THREE.Points.' );
  77. return new Points( geometry, material );
  78. }
  79. export function Particle( material ) {
  80. console.warn( 'THREE.Particle has been renamed to THREE.Sprite.' );
  81. return new Sprite( material );
  82. }
  83. export function ParticleSystem( geometry, material ) {
  84. console.warn( 'THREE.ParticleSystem has been renamed to THREE.Points.' );
  85. return new Points( geometry, material );
  86. }
  87. export function PointCloudMaterial( parameters ) {
  88. console.warn( 'THREE.PointCloudMaterial has been renamed to THREE.PointsMaterial.' );
  89. return new PointsMaterial( parameters );
  90. }
  91. export function ParticleBasicMaterial( parameters ) {
  92. console.warn( 'THREE.ParticleBasicMaterial has been renamed to THREE.PointsMaterial.' );
  93. return new PointsMaterial( parameters );
  94. }
  95. export function ParticleSystemMaterial( parameters ) {
  96. console.warn( 'THREE.ParticleSystemMaterial has been renamed to THREE.PointsMaterial.' );
  97. return new PointsMaterial( parameters );
  98. }
  99. export function Vertex( x, y, z ) {
  100. console.warn( 'THREE.Vertex has been removed. Use THREE.Vector3 instead.' );
  101. return new Vector3( x, y, z );
  102. }
  103. //
  104. export function DynamicBufferAttribute( array, itemSize ) {
  105. console.warn( 'THREE.DynamicBufferAttribute has been removed. Use new THREE.BufferAttribute().setDynamic( true ) instead.' );
  106. return new BufferAttribute( array, itemSize ).setDynamic( true );
  107. }
  108. export function Int8Attribute( array, itemSize ) {
  109. console.warn( 'THREE.Int8Attribute has been removed. Use new THREE.Int8BufferAttribute() instead.' );
  110. return new Int8BufferAttribute( array, itemSize );
  111. }
  112. export function Uint8Attribute( array, itemSize ) {
  113. console.warn( 'THREE.Uint8Attribute has been removed. Use new THREE.Uint8BufferAttribute() instead.' );
  114. return new Uint8BufferAttribute( array, itemSize );
  115. }
  116. export function Uint8ClampedAttribute( array, itemSize ) {
  117. console.warn( 'THREE.Uint8ClampedAttribute has been removed. Use new THREE.Uint8ClampedBufferAttribute() instead.' );
  118. return new Uint8ClampedBufferAttribute( array, itemSize );
  119. }
  120. export function Int16Attribute( array, itemSize ) {
  121. console.warn( 'THREE.Int16Attribute has been removed. Use new THREE.Int16BufferAttribute() instead.' );
  122. return new Int16BufferAttribute( array, itemSize );
  123. }
  124. export function Uint16Attribute( array, itemSize ) {
  125. console.warn( 'THREE.Uint16Attribute has been removed. Use new THREE.Uint16BufferAttribute() instead.' );
  126. return new Uint16BufferAttribute( array, itemSize );
  127. }
  128. export function Int32Attribute( array, itemSize ) {
  129. console.warn( 'THREE.Int32Attribute has been removed. Use new THREE.Int32BufferAttribute() instead.' );
  130. return new Int32BufferAttribute( array, itemSize );
  131. }
  132. export function Uint32Attribute( array, itemSize ) {
  133. console.warn( 'THREE.Uint32Attribute has been removed. Use new THREE.Uint32BufferAttribute() instead.' );
  134. return new Uint32BufferAttribute( array, itemSize );
  135. }
  136. export function Float32Attribute( array, itemSize ) {
  137. console.warn( 'THREE.Float32Attribute has been removed. Use new THREE.Float32BufferAttribute() instead.' );
  138. return new Float32BufferAttribute( array, itemSize );
  139. }
  140. export function Float64Attribute( array, itemSize ) {
  141. console.warn( 'THREE.Float64Attribute has been removed. Use new THREE.Float64BufferAttribute() instead.' );
  142. return new Float64BufferAttribute( array, itemSize );
  143. }
  144. //
  145. export function ClosedSplineCurve3( points ) {
  146. console.warn( 'THREE.ClosedSplineCurve3 has been deprecated. Use THREE.CatmullRomCurve3 instead.' );
  147. CatmullRomCurve3.call( this, points );
  148. this.type = 'catmullrom';
  149. this.closed = true;
  150. }
  151. ClosedSplineCurve3.prototype = Object.create( CatmullRomCurve3.prototype );
  152. //
  153. export function BoundingBoxHelper( object, color ) {
  154. console.warn( 'THREE.BoundingBoxHelper has been deprecated. Creating a THREE.BoxHelper instead.' );
  155. return new BoxHelper( object, color );
  156. }
  157. export function EdgesHelper( object, hex ) {
  158. console.warn( 'THREE.EdgesHelper has been removed. Use THREE.EdgesGeometry instead.' );
  159. return new LineSegments( new EdgesGeometry( object.geometry ), new LineBasicMaterial( { color: hex !== undefined ? hex : 0xffffff } ) );
  160. }
  161. GridHelper.prototype.setColors = function () {
  162. console.error( 'THREE.GridHelper: setColors() has been deprecated, pass them in the constructor instead.' );
  163. };
  164. export function WireframeHelper( object, hex ) {
  165. console.warn( 'THREE.WireframeHelper has been removed. Use THREE.WireframeGeometry instead.' );
  166. return new LineSegments( new WireframeGeometry( object.geometry ), new LineBasicMaterial( { color: hex !== undefined ? hex : 0xffffff } ) );
  167. }
  168. //
  169. export function XHRLoader( manager ) {
  170. console.warn( 'THREE.XHRLoader has been renamed to THREE.FileLoader.' );
  171. return new FileLoader( manager );
  172. }
  173. //
  174. Object.assign( Box2.prototype, {
  175. center: function ( optionalTarget ) {
  176. console.warn( 'THREE.Box2: .center() has been renamed to .getCenter().' );
  177. return this.getCenter( optionalTarget );
  178. },
  179. empty: function () {
  180. console.warn( 'THREE.Box2: .empty() has been renamed to .isEmpty().' );
  181. return this.isEmpty();
  182. },
  183. isIntersectionBox: function ( box ) {
  184. console.warn( 'THREE.Box2: .isIntersectionBox() has been renamed to .intersectsBox().' );
  185. return this.intersectsBox( box );
  186. },
  187. size: function ( optionalTarget ) {
  188. console.warn( 'THREE.Box2: .size() has been renamed to .getSize().' );
  189. return this.getSize( optionalTarget );
  190. }
  191. } );
  192. Object.assign( Box3.prototype, {
  193. center: function ( optionalTarget ) {
  194. console.warn( 'THREE.Box3: .center() has been renamed to .getCenter().' );
  195. return this.getCenter( optionalTarget );
  196. },
  197. empty: function () {
  198. console.warn( 'THREE.Box3: .empty() has been renamed to .isEmpty().' );
  199. return this.isEmpty();
  200. },
  201. isIntersectionBox: function ( box ) {
  202. console.warn( 'THREE.Box3: .isIntersectionBox() has been renamed to .intersectsBox().' );
  203. return this.intersectsBox( box );
  204. },
  205. isIntersectionSphere: function ( sphere ) {
  206. console.warn( 'THREE.Box3: .isIntersectionSphere() has been renamed to .intersectsSphere().' );
  207. return this.intersectsSphere( sphere );
  208. },
  209. size: function ( optionalTarget ) {
  210. console.warn( 'THREE.Box3: .size() has been renamed to .getSize().' );
  211. return this.getSize( optionalTarget );
  212. }
  213. } );
  214. Line3.prototype.center = function ( optionalTarget ) {
  215. console.warn( 'THREE.Line3: .center() has been renamed to .getCenter().' );
  216. return this.getCenter( optionalTarget );
  217. };
  218. _Math.random16 = function () {
  219. console.warn( 'THREE.Math.random16() has been deprecated. Use Math.random() instead.' );
  220. return Math.random();
  221. };
  222. Object.assign( Matrix3.prototype, {
  223. flattenToArrayOffset: function ( array, offset ) {
  224. console.warn( "THREE.Matrix3: .flattenToArrayOffset() has been deprecated. Use .toArray() instead." );
  225. return this.toArray( array, offset );
  226. },
  227. multiplyVector3: function ( vector ) {
  228. console.warn( 'THREE.Matrix3: .multiplyVector3() has been removed. Use vector.applyMatrix3( matrix ) instead.' );
  229. return vector.applyMatrix3( this );
  230. },
  231. multiplyVector3Array: function ( a ) {
  232. console.warn( 'THREE.Matrix3: .multiplyVector3Array() has been renamed. Use matrix.applyToVector3Array( array ) instead.' );
  233. return this.applyToVector3Array( a );
  234. },
  235. applyToBuffer: function( buffer, offset, length ) {
  236. console.warn( 'THREE.Matrix3: .applyToBuffer() has been removed. Use matrix.applyToBufferAttribute( attribute ) instead.' );
  237. return this.applyToBufferAttribute( buffer );
  238. }
  239. } );
  240. Object.assign( Matrix4.prototype, {
  241. extractPosition: function ( m ) {
  242. console.warn( 'THREE.Matrix4: .extractPosition() has been renamed to .copyPosition().' );
  243. return this.copyPosition( m );
  244. },
  245. flattenToArrayOffset: function ( array, offset ) {
  246. console.warn( "THREE.Matrix4: .flattenToArrayOffset() has been deprecated. Use .toArray() instead." );
  247. return this.toArray( array, offset );
  248. },
  249. getPosition: function () {
  250. var v1;
  251. return function getPosition() {
  252. if ( v1 === undefined ) v1 = new Vector3();
  253. console.warn( 'THREE.Matrix4: .getPosition() has been removed. Use Vector3.setFromMatrixPosition( matrix ) instead.' );
  254. return v1.setFromMatrixColumn( this, 3 );
  255. };
  256. }(),
  257. setRotationFromQuaternion: function ( q ) {
  258. console.warn( 'THREE.Matrix4: .setRotationFromQuaternion() has been renamed to .makeRotationFromQuaternion().' );
  259. return this.makeRotationFromQuaternion( q );
  260. },
  261. multiplyVector3: function ( vector ) {
  262. console.warn( 'THREE.Matrix4: .multiplyVector3() has been removed. Use vector.applyMatrix4( matrix ) or vector.applyProjection( matrix ) instead.' );
  263. return vector.applyProjection( this );
  264. },
  265. multiplyVector4: function ( vector ) {
  266. console.warn( 'THREE.Matrix4: .multiplyVector4() has been removed. Use vector.applyMatrix4( matrix ) instead.' );
  267. return vector.applyMatrix4( this );
  268. },
  269. multiplyVector3Array: function ( a ) {
  270. console.warn( 'THREE.Matrix4: .multiplyVector3Array() has been renamed. Use matrix.applyToVector3Array( array ) instead.' );
  271. return this.applyToVector3Array( a );
  272. },
  273. rotateAxis: function ( v ) {
  274. console.warn( 'THREE.Matrix4: .rotateAxis() has been removed. Use Vector3.transformDirection( matrix ) instead.' );
  275. v.transformDirection( this );
  276. },
  277. crossVector: function ( vector ) {
  278. console.warn( 'THREE.Matrix4: .crossVector() has been removed. Use vector.applyMatrix4( matrix ) instead.' );
  279. return vector.applyMatrix4( this );
  280. },
  281. translate: function () {
  282. console.error( 'THREE.Matrix4: .translate() has been removed.' );
  283. },
  284. rotateX: function () {
  285. console.error( 'THREE.Matrix4: .rotateX() has been removed.' );
  286. },
  287. rotateY: function () {
  288. console.error( 'THREE.Matrix4: .rotateY() has been removed.' );
  289. },
  290. rotateZ: function () {
  291. console.error( 'THREE.Matrix4: .rotateZ() has been removed.' );
  292. },
  293. rotateByAxis: function () {
  294. console.error( 'THREE.Matrix4: .rotateByAxis() has been removed.' );
  295. },
  296. applyToBuffer: function( buffer, offset, length ) {
  297. console.warn( 'THREE.Matrix4: .applyToBuffer() has been removed. Use matrix.applyToBufferAttribute( attribute ) instead.' );
  298. return this.applyToBufferAttribute( buffer );
  299. }
  300. } );
  301. Plane.prototype.isIntersectionLine = function ( line ) {
  302. console.warn( 'THREE.Plane: .isIntersectionLine() has been renamed to .intersectsLine().' );
  303. return this.intersectsLine( line );
  304. };
  305. Quaternion.prototype.multiplyVector3 = function ( vector ) {
  306. console.warn( 'THREE.Quaternion: .multiplyVector3() has been removed. Use is now vector.applyQuaternion( quaternion ) instead.' );
  307. return vector.applyQuaternion( this );
  308. };
  309. Object.assign( Ray.prototype, {
  310. isIntersectionBox: function ( box ) {
  311. console.warn( 'THREE.Ray: .isIntersectionBox() has been renamed to .intersectsBox().' );
  312. return this.intersectsBox( box );
  313. },
  314. isIntersectionPlane: function ( plane ) {
  315. console.warn( 'THREE.Ray: .isIntersectionPlane() has been renamed to .intersectsPlane().' );
  316. return this.intersectsPlane( plane );
  317. },
  318. isIntersectionSphere: function ( sphere ) {
  319. console.warn( 'THREE.Ray: .isIntersectionSphere() has been renamed to .intersectsSphere().' );
  320. return this.intersectsSphere( sphere );
  321. }
  322. } );
  323. Object.assign( Shape.prototype, {
  324. extrude: function ( options ) {
  325. console.warn( 'THREE.Shape: .extrude() has been removed. Use ExtrudeGeometry() instead.' );
  326. return new ExtrudeGeometry( this, options );
  327. },
  328. makeGeometry: function ( options ) {
  329. console.warn( 'THREE.Shape: .makeGeometry() has been removed. Use ShapeGeometry() instead.' );
  330. return new ShapeGeometry( this, options );
  331. }
  332. } );
  333. Object.assign( Vector3.prototype, {
  334. setEulerFromRotationMatrix: function () {
  335. console.error( 'THREE.Vector3: .setEulerFromRotationMatrix() has been removed. Use Euler.setFromRotationMatrix() instead.' );
  336. },
  337. setEulerFromQuaternion: function () {
  338. console.error( 'THREE.Vector3: .setEulerFromQuaternion() has been removed. Use Euler.setFromQuaternion() instead.' );
  339. },
  340. getPositionFromMatrix: function ( m ) {
  341. console.warn( 'THREE.Vector3: .getPositionFromMatrix() has been renamed to .setFromMatrixPosition().' );
  342. return this.setFromMatrixPosition( m );
  343. },
  344. getScaleFromMatrix: function ( m ) {
  345. console.warn( 'THREE.Vector3: .getScaleFromMatrix() has been renamed to .setFromMatrixScale().' );
  346. return this.setFromMatrixScale( m );
  347. },
  348. getColumnFromMatrix: function ( index, matrix ) {
  349. console.warn( 'THREE.Vector3: .getColumnFromMatrix() has been renamed to .setFromMatrixColumn().' );
  350. return this.setFromMatrixColumn( matrix, index );
  351. }
  352. } );
  353. //
  354. Geometry.prototype.computeTangents = function () {
  355. console.warn( 'THREE.Geometry: .computeTangents() has been removed.' );
  356. };
  357. Object.assign( Object3D.prototype, {
  358. getChildByName: function ( name ) {
  359. console.warn( 'THREE.Object3D: .getChildByName() has been renamed to .getObjectByName().' );
  360. return this.getObjectByName( name );
  361. },
  362. renderDepth: function () {
  363. console.warn( 'THREE.Object3D: .renderDepth has been removed. Use .renderOrder, instead.' );
  364. },
  365. translate: function ( distance, axis ) {
  366. console.warn( 'THREE.Object3D: .translate() has been removed. Use .translateOnAxis( axis, distance ) instead.' );
  367. return this.translateOnAxis( axis, distance );
  368. }
  369. } );
  370. Object.defineProperties( Object3D.prototype, {
  371. eulerOrder: {
  372. get: function () {
  373. console.warn( 'THREE.Object3D: .eulerOrder is now .rotation.order.' );
  374. return this.rotation.order;
  375. },
  376. set: function ( value ) {
  377. console.warn( 'THREE.Object3D: .eulerOrder is now .rotation.order.' );
  378. this.rotation.order = value;
  379. }
  380. },
  381. useQuaternion: {
  382. get: function () {
  383. console.warn( 'THREE.Object3D: .useQuaternion has been removed. The library now uses quaternions by default.' );
  384. },
  385. set: function () {
  386. console.warn( 'THREE.Object3D: .useQuaternion has been removed. The library now uses quaternions by default.' );
  387. }
  388. }
  389. } );
  390. Object.defineProperties( LOD.prototype, {
  391. objects: {
  392. get: function () {
  393. console.warn( 'THREE.LOD: .objects has been renamed to .levels.' );
  394. return this.levels;
  395. }
  396. }
  397. } );
  398. //
  399. PerspectiveCamera.prototype.setLens = function ( focalLength, filmGauge ) {
  400. console.warn( "THREE.PerspectiveCamera.setLens is deprecated. " +
  401. "Use .setFocalLength and .filmGauge for a photographic setup." );
  402. if ( filmGauge !== undefined ) this.filmGauge = filmGauge;
  403. this.setFocalLength( focalLength );
  404. };
  405. //
  406. Object.defineProperties( Light.prototype, {
  407. onlyShadow: {
  408. set: function () {
  409. console.warn( 'THREE.Light: .onlyShadow has been removed.' );
  410. }
  411. },
  412. shadowCameraFov: {
  413. set: function ( value ) {
  414. console.warn( 'THREE.Light: .shadowCameraFov is now .shadow.camera.fov.' );
  415. this.shadow.camera.fov = value;
  416. }
  417. },
  418. shadowCameraLeft: {
  419. set: function ( value ) {
  420. console.warn( 'THREE.Light: .shadowCameraLeft is now .shadow.camera.left.' );
  421. this.shadow.camera.left = value;
  422. }
  423. },
  424. shadowCameraRight: {
  425. set: function ( value ) {
  426. console.warn( 'THREE.Light: .shadowCameraRight is now .shadow.camera.right.' );
  427. this.shadow.camera.right = value;
  428. }
  429. },
  430. shadowCameraTop: {
  431. set: function ( value ) {
  432. console.warn( 'THREE.Light: .shadowCameraTop is now .shadow.camera.top.' );
  433. this.shadow.camera.top = value;
  434. }
  435. },
  436. shadowCameraBottom: {
  437. set: function ( value ) {
  438. console.warn( 'THREE.Light: .shadowCameraBottom is now .shadow.camera.bottom.' );
  439. this.shadow.camera.bottom = value;
  440. }
  441. },
  442. shadowCameraNear: {
  443. set: function ( value ) {
  444. console.warn( 'THREE.Light: .shadowCameraNear is now .shadow.camera.near.' );
  445. this.shadow.camera.near = value;
  446. }
  447. },
  448. shadowCameraFar: {
  449. set: function ( value ) {
  450. console.warn( 'THREE.Light: .shadowCameraFar is now .shadow.camera.far.' );
  451. this.shadow.camera.far = value;
  452. }
  453. },
  454. shadowCameraVisible: {
  455. set: function () {
  456. console.warn( 'THREE.Light: .shadowCameraVisible has been removed. Use new THREE.CameraHelper( light.shadow.camera ) instead.' );
  457. }
  458. },
  459. shadowBias: {
  460. set: function ( value ) {
  461. console.warn( 'THREE.Light: .shadowBias is now .shadow.bias.' );
  462. this.shadow.bias = value;
  463. }
  464. },
  465. shadowDarkness: {
  466. set: function () {
  467. console.warn( 'THREE.Light: .shadowDarkness has been removed.' );
  468. }
  469. },
  470. shadowMapWidth: {
  471. set: function ( value ) {
  472. console.warn( 'THREE.Light: .shadowMapWidth is now .shadow.mapSize.width.' );
  473. this.shadow.mapSize.width = value;
  474. }
  475. },
  476. shadowMapHeight: {
  477. set: function ( value ) {
  478. console.warn( 'THREE.Light: .shadowMapHeight is now .shadow.mapSize.height.' );
  479. this.shadow.mapSize.height = value;
  480. }
  481. }
  482. } );
  483. //
  484. Object.defineProperties( BufferAttribute.prototype, {
  485. length: {
  486. get: function () {
  487. console.warn( 'THREE.BufferAttribute: .length has been deprecated. Use .count instead.' );
  488. return this.array.length;
  489. }
  490. }
  491. } );
  492. Object.assign( BufferGeometry.prototype, {
  493. addIndex: function ( index ) {
  494. console.warn( 'THREE.BufferGeometry: .addIndex() has been renamed to .setIndex().' );
  495. this.setIndex( index );
  496. },
  497. addDrawCall: function ( start, count, indexOffset ) {
  498. if ( indexOffset !== undefined ) {
  499. console.warn( 'THREE.BufferGeometry: .addDrawCall() no longer supports indexOffset.' );
  500. }
  501. console.warn( 'THREE.BufferGeometry: .addDrawCall() is now .addGroup().' );
  502. this.addGroup( start, count );
  503. },
  504. clearDrawCalls: function () {
  505. console.warn( 'THREE.BufferGeometry: .clearDrawCalls() is now .clearGroups().' );
  506. this.clearGroups();
  507. },
  508. computeTangents: function () {
  509. console.warn( 'THREE.BufferGeometry: .computeTangents() has been removed.' );
  510. },
  511. computeOffsets: function () {
  512. console.warn( 'THREE.BufferGeometry: .computeOffsets() has been removed.' );
  513. }
  514. } );
  515. Object.defineProperties( BufferGeometry.prototype, {
  516. drawcalls: {
  517. get: function () {
  518. console.error( 'THREE.BufferGeometry: .drawcalls has been renamed to .groups.' );
  519. return this.groups;
  520. }
  521. },
  522. offsets: {
  523. get: function () {
  524. console.warn( 'THREE.BufferGeometry: .offsets has been renamed to .groups.' );
  525. return this.groups;
  526. }
  527. }
  528. } );
  529. //
  530. Object.defineProperties( Uniform.prototype, {
  531. dynamic: {
  532. set: function () {
  533. console.warn( 'THREE.Uniform: .dynamic has been removed. Use object.onBeforeRender() instead.' );
  534. }
  535. },
  536. onUpdate: {
  537. value: function () {
  538. console.warn( 'THREE.Uniform: .onUpdate() has been removed. Use object.onBeforeRender() instead.' );
  539. return this;
  540. }
  541. }
  542. } );
  543. //
  544. Object.defineProperties( Material.prototype, {
  545. wrapAround: {
  546. get: function () {
  547. console.warn( 'THREE.' + this.type + ': .wrapAround has been removed.' );
  548. },
  549. set: function () {
  550. console.warn( 'THREE.' + this.type + ': .wrapAround has been removed.' );
  551. }
  552. },
  553. wrapRGB: {
  554. get: function () {
  555. console.warn( 'THREE.' + this.type + ': .wrapRGB has been removed.' );
  556. return new Color();
  557. }
  558. }
  559. } );
  560. Object.defineProperties( MeshPhongMaterial.prototype, {
  561. metal: {
  562. get: function () {
  563. console.warn( 'THREE.MeshPhongMaterial: .metal has been removed. Use THREE.MeshStandardMaterial instead.' );
  564. return false;
  565. },
  566. set: function () {
  567. console.warn( 'THREE.MeshPhongMaterial: .metal has been removed. Use THREE.MeshStandardMaterial instead' );
  568. }
  569. }
  570. } );
  571. Object.defineProperties( ShaderMaterial.prototype, {
  572. derivatives: {
  573. get: function () {
  574. console.warn( 'THREE.ShaderMaterial: .derivatives has been moved to .extensions.derivatives.' );
  575. return this.extensions.derivatives;
  576. },
  577. set: function ( value ) {
  578. console.warn( 'THREE. ShaderMaterial: .derivatives has been moved to .extensions.derivatives.' );
  579. this.extensions.derivatives = value;
  580. }
  581. }
  582. } );
  583. //
  584. EventDispatcher.prototype = Object.assign( Object.create( {
  585. // Note: Extra base ensures these properties are not 'assign'ed.
  586. constructor: EventDispatcher,
  587. apply: function ( target ) {
  588. console.warn( "THREE.EventDispatcher: .apply is deprecated, " +
  589. "just inherit or Object.assign the prototype to mix-in." );
  590. Object.assign( target, this );
  591. }
  592. } ), EventDispatcher.prototype );
  593. //
  594. Object.assign( WebGLRenderer.prototype, {
  595. supportsFloatTextures: function () {
  596. console.warn( 'THREE.WebGLRenderer: .supportsFloatTextures() is now .extensions.get( \'OES_texture_float\' ).' );
  597. return this.extensions.get( 'OES_texture_float' );
  598. },
  599. supportsHalfFloatTextures: function () {
  600. console.warn( 'THREE.WebGLRenderer: .supportsHalfFloatTextures() is now .extensions.get( \'OES_texture_half_float\' ).' );
  601. return this.extensions.get( 'OES_texture_half_float' );
  602. },
  603. supportsStandardDerivatives: function () {
  604. console.warn( 'THREE.WebGLRenderer: .supportsStandardDerivatives() is now .extensions.get( \'OES_standard_derivatives\' ).' );
  605. return this.extensions.get( 'OES_standard_derivatives' );
  606. },
  607. supportsCompressedTextureS3TC: function () {
  608. console.warn( 'THREE.WebGLRenderer: .supportsCompressedTextureS3TC() is now .extensions.get( \'WEBGL_compressed_texture_s3tc\' ).' );
  609. return this.extensions.get( 'WEBGL_compressed_texture_s3tc' );
  610. },
  611. supportsCompressedTexturePVRTC: function () {
  612. console.warn( 'THREE.WebGLRenderer: .supportsCompressedTexturePVRTC() is now .extensions.get( \'WEBGL_compressed_texture_pvrtc\' ).' );
  613. return this.extensions.get( 'WEBGL_compressed_texture_pvrtc' );
  614. },
  615. supportsBlendMinMax: function () {
  616. console.warn( 'THREE.WebGLRenderer: .supportsBlendMinMax() is now .extensions.get( \'EXT_blend_minmax\' ).' );
  617. return this.extensions.get( 'EXT_blend_minmax' );
  618. },
  619. supportsVertexTextures: function () {
  620. console.warn( 'THREE.WebGLRenderer: .supportsVertexTextures() is now .capabilities.vertexTextures.' );
  621. return this.capabilities.vertexTextures;
  622. },
  623. supportsInstancedArrays: function () {
  624. console.warn( 'THREE.WebGLRenderer: .supportsInstancedArrays() is now .extensions.get( \'ANGLE_instanced_arrays\' ).' );
  625. return this.extensions.get( 'ANGLE_instanced_arrays' );
  626. },
  627. enableScissorTest: function ( boolean ) {
  628. console.warn( 'THREE.WebGLRenderer: .enableScissorTest() is now .setScissorTest().' );
  629. this.setScissorTest( boolean );
  630. },
  631. initMaterial: function () {
  632. console.warn( 'THREE.WebGLRenderer: .initMaterial() has been removed.' );
  633. },
  634. addPrePlugin: function () {
  635. console.warn( 'THREE.WebGLRenderer: .addPrePlugin() has been removed.' );
  636. },
  637. addPostPlugin: function () {
  638. console.warn( 'THREE.WebGLRenderer: .addPostPlugin() has been removed.' );
  639. },
  640. updateShadowMap: function () {
  641. console.warn( 'THREE.WebGLRenderer: .updateShadowMap() has been removed.' );
  642. }
  643. } );
  644. Object.defineProperties( WebGLRenderer.prototype, {
  645. shadowMapEnabled: {
  646. get: function () {
  647. return this.shadowMap.enabled;
  648. },
  649. set: function ( value ) {
  650. console.warn( 'THREE.WebGLRenderer: .shadowMapEnabled is now .shadowMap.enabled.' );
  651. this.shadowMap.enabled = value;
  652. }
  653. },
  654. shadowMapType: {
  655. get: function () {
  656. return this.shadowMap.type;
  657. },
  658. set: function ( value ) {
  659. console.warn( 'THREE.WebGLRenderer: .shadowMapType is now .shadowMap.type.' );
  660. this.shadowMap.type = value;
  661. }
  662. },
  663. shadowMapCullFace: {
  664. get: function () {
  665. return this.shadowMap.cullFace;
  666. },
  667. set: function ( value ) {
  668. console.warn( 'THREE.WebGLRenderer: .shadowMapCullFace is now .shadowMap.cullFace.' );
  669. this.shadowMap.cullFace = value;
  670. }
  671. }
  672. } );
  673. Object.defineProperties( WebGLShadowMap.prototype, {
  674. cullFace: {
  675. get: function () {
  676. return this.renderReverseSided ? CullFaceFront : CullFaceBack;
  677. },
  678. set: function ( cullFace ) {
  679. var value = ( cullFace !== CullFaceBack );
  680. console.warn( "WebGLRenderer: .shadowMap.cullFace is deprecated. Set .shadowMap.renderReverseSided to " + value + "." );
  681. this.renderReverseSided = value;
  682. }
  683. }
  684. } );
  685. //
  686. Object.defineProperties( WebGLRenderTarget.prototype, {
  687. wrapS: {
  688. get: function () {
  689. console.warn( 'THREE.WebGLRenderTarget: .wrapS is now .texture.wrapS.' );
  690. return this.texture.wrapS;
  691. },
  692. set: function ( value ) {
  693. console.warn( 'THREE.WebGLRenderTarget: .wrapS is now .texture.wrapS.' );
  694. this.texture.wrapS = value;
  695. }
  696. },
  697. wrapT: {
  698. get: function () {
  699. console.warn( 'THREE.WebGLRenderTarget: .wrapT is now .texture.wrapT.' );
  700. return this.texture.wrapT;
  701. },
  702. set: function ( value ) {
  703. console.warn( 'THREE.WebGLRenderTarget: .wrapT is now .texture.wrapT.' );
  704. this.texture.wrapT = value;
  705. }
  706. },
  707. magFilter: {
  708. get: function () {
  709. console.warn( 'THREE.WebGLRenderTarget: .magFilter is now .texture.magFilter.' );
  710. return this.texture.magFilter;
  711. },
  712. set: function ( value ) {
  713. console.warn( 'THREE.WebGLRenderTarget: .magFilter is now .texture.magFilter.' );
  714. this.texture.magFilter = value;
  715. }
  716. },
  717. minFilter: {
  718. get: function () {
  719. console.warn( 'THREE.WebGLRenderTarget: .minFilter is now .texture.minFilter.' );
  720. return this.texture.minFilter;
  721. },
  722. set: function ( value ) {
  723. console.warn( 'THREE.WebGLRenderTarget: .minFilter is now .texture.minFilter.' );
  724. this.texture.minFilter = value;
  725. }
  726. },
  727. anisotropy: {
  728. get: function () {
  729. console.warn( 'THREE.WebGLRenderTarget: .anisotropy is now .texture.anisotropy.' );
  730. return this.texture.anisotropy;
  731. },
  732. set: function ( value ) {
  733. console.warn( 'THREE.WebGLRenderTarget: .anisotropy is now .texture.anisotropy.' );
  734. this.texture.anisotropy = value;
  735. }
  736. },
  737. offset: {
  738. get: function () {
  739. console.warn( 'THREE.WebGLRenderTarget: .offset is now .texture.offset.' );
  740. return this.texture.offset;
  741. },
  742. set: function ( value ) {
  743. console.warn( 'THREE.WebGLRenderTarget: .offset is now .texture.offset.' );
  744. this.texture.offset = value;
  745. }
  746. },
  747. repeat: {
  748. get: function () {
  749. console.warn( 'THREE.WebGLRenderTarget: .repeat is now .texture.repeat.' );
  750. return this.texture.repeat;
  751. },
  752. set: function ( value ) {
  753. console.warn( 'THREE.WebGLRenderTarget: .repeat is now .texture.repeat.' );
  754. this.texture.repeat = value;
  755. }
  756. },
  757. format: {
  758. get: function () {
  759. console.warn( 'THREE.WebGLRenderTarget: .format is now .texture.format.' );
  760. return this.texture.format;
  761. },
  762. set: function ( value ) {
  763. console.warn( 'THREE.WebGLRenderTarget: .format is now .texture.format.' );
  764. this.texture.format = value;
  765. }
  766. },
  767. type: {
  768. get: function () {
  769. console.warn( 'THREE.WebGLRenderTarget: .type is now .texture.type.' );
  770. return this.texture.type;
  771. },
  772. set: function ( value ) {
  773. console.warn( 'THREE.WebGLRenderTarget: .type is now .texture.type.' );
  774. this.texture.type = value;
  775. }
  776. },
  777. generateMipmaps: {
  778. get: function () {
  779. console.warn( 'THREE.WebGLRenderTarget: .generateMipmaps is now .texture.generateMipmaps.' );
  780. return this.texture.generateMipmaps;
  781. },
  782. set: function ( value ) {
  783. console.warn( 'THREE.WebGLRenderTarget: .generateMipmaps is now .texture.generateMipmaps.' );
  784. this.texture.generateMipmaps = value;
  785. }
  786. }
  787. } );
  788. //
  789. Audio.prototype.load = function ( file ) {
  790. console.warn( 'THREE.Audio: .load has been deprecated. Use THREE.AudioLoader instead.' );
  791. var scope = this;
  792. var audioLoader = new AudioLoader();
  793. audioLoader.load( file, function ( buffer ) {
  794. scope.setBuffer( buffer );
  795. } );
  796. return this;
  797. };
  798. AudioAnalyser.prototype.getData = function () {
  799. console.warn( 'THREE.AudioAnalyser: .getData() is now .getFrequencyData().' );
  800. return this.getFrequencyData();
  801. };
  802. //
  803. export var GeometryUtils = {
  804. merge: function ( geometry1, geometry2, materialIndexOffset ) {
  805. console.warn( 'THREE.GeometryUtils: .merge() has been moved to Geometry. Use geometry.merge( geometry2, matrix, materialIndexOffset ) instead.' );
  806. var matrix;
  807. if ( geometry2.isMesh ) {
  808. geometry2.matrixAutoUpdate && geometry2.updateMatrix();
  809. matrix = geometry2.matrix;
  810. geometry2 = geometry2.geometry;
  811. }
  812. geometry1.merge( geometry2, matrix, materialIndexOffset );
  813. },
  814. center: function ( geometry ) {
  815. console.warn( 'THREE.GeometryUtils: .center() has been moved to Geometry. Use geometry.center() instead.' );
  816. return geometry.center();
  817. }
  818. };
  819. export var ImageUtils = {
  820. crossOrigin: undefined,
  821. loadTexture: function ( url, mapping, onLoad, onError ) {
  822. console.warn( 'THREE.ImageUtils.loadTexture has been deprecated. Use THREE.TextureLoader() instead.' );
  823. var loader = new TextureLoader();
  824. loader.setCrossOrigin( this.crossOrigin );
  825. var texture = loader.load( url, onLoad, undefined, onError );
  826. if ( mapping ) texture.mapping = mapping;
  827. return texture;
  828. },
  829. loadTextureCube: function ( urls, mapping, onLoad, onError ) {
  830. console.warn( 'THREE.ImageUtils.loadTextureCube has been deprecated. Use THREE.CubeTextureLoader() instead.' );
  831. var loader = new CubeTextureLoader();
  832. loader.setCrossOrigin( this.crossOrigin );
  833. var texture = loader.load( urls, onLoad, undefined, onError );
  834. if ( mapping ) texture.mapping = mapping;
  835. return texture;
  836. },
  837. loadCompressedTexture: function () {
  838. console.error( 'THREE.ImageUtils.loadCompressedTexture has been removed. Use THREE.DDSLoader instead.' );
  839. },
  840. loadCompressedTextureCube: function () {
  841. console.error( 'THREE.ImageUtils.loadCompressedTextureCube has been removed. Use THREE.DDSLoader instead.' );
  842. }
  843. };
  844. //
  845. export function Projector() {
  846. console.error( 'THREE.Projector has been moved to /examples/js/renderers/Projector.js.' );
  847. this.projectVector = function ( vector, camera ) {
  848. console.warn( 'THREE.Projector: .projectVector() is now vector.project().' );
  849. vector.project( camera );
  850. };
  851. this.unprojectVector = function ( vector, camera ) {
  852. console.warn( 'THREE.Projector: .unprojectVector() is now vector.unproject().' );
  853. vector.unproject( camera );
  854. };
  855. this.pickingRay = function () {
  856. console.error( 'THREE.Projector: .pickingRay() is now raycaster.setFromCamera().' );
  857. };
  858. }
  859. //
  860. export function CanvasRenderer() {
  861. console.error( 'THREE.CanvasRenderer has been moved to /examples/js/renderers/CanvasRenderer.js' );
  862. this.domElement = document.createElementNS( 'http://www.w3.org/1999/xhtml', 'canvas' );
  863. this.clear = function () {};
  864. this.render = function () {};
  865. this.setClearColor = function () {};
  866. this.setSize = function () {};
  867. }
粤ICP备19079148号