diff --git a/rollup.config.js b/rollup.config.js index 6f9786e4039ff3..6be0f3879e09c8 100644 --- a/rollup.config.js +++ b/rollup.config.js @@ -7,8 +7,6 @@ Object.defineProperty( exports, 'AudioContext', { } });`; -var footer = fs.readFileSync( 'src/Three.Legacy.js', 'utf-8' ); - function glsl () { return { transform ( code, id ) { @@ -33,6 +31,5 @@ export default { glsl() ], - outro: outro, - footer: footer + outro: outro }; diff --git a/src/Three.Legacy.js b/src/Three.Legacy.js index 5bbed7d4f65338..8759c4ed410db2 100644 --- a/src/Three.Legacy.js +++ b/src/Three.Legacy.js @@ -2,44 +2,86 @@ * @author mrdoob / http://mrdoob.com/ */ -Object.assign( THREE, { - Face4: function ( a, b, c, d, normal, color, materialIndex ) { - console.warn( 'THREE.Face4 has been removed. A THREE.Face3 will be created instead.' ); - return new THREE.Face3( a, b, c, normal, color, materialIndex ); - }, - LineStrip: 0, - LinePieces: 1, - MeshFaceMaterial: THREE.MultiMaterial, - PointCloud: function ( geometry, material ) { - console.warn( 'THREE.PointCloud has been renamed to THREE.Points.' ); - return new THREE.Points( geometry, material ); - }, - Particle: THREE.Sprite, - ParticleSystem: function ( geometry, material ) { - console.warn( 'THREE.ParticleSystem has been renamed to THREE.Points.' ); - return new THREE.Points( geometry, material ); - }, - PointCloudMaterial: function ( parameters ) { - console.warn( 'THREE.PointCloudMaterial has been renamed to THREE.PointsMaterial.' ); - return new THREE.PointsMaterial( parameters ); - }, - ParticleBasicMaterial: function ( parameters ) { - console.warn( 'THREE.ParticleBasicMaterial has been renamed to THREE.PointsMaterial.' ); - return new THREE.PointsMaterial( parameters ); - }, - ParticleSystemMaterial: function ( parameters ) { - console.warn( 'THREE.ParticleSystemMaterial has been renamed to THREE.PointsMaterial.' ); - return new THREE.PointsMaterial( parameters ); - }, - Vertex: function ( x, y, z ) { - console.warn( 'THREE.Vertex has been removed. Use THREE.Vector3 instead.' ); - return new THREE.Vector3( x, y, z ); - } -} ); +import { Audio } from './audio/Audio.js'; +import { AudioAnalyser } from './audio/AudioAnalyser.js'; +import { PerspectiveCamera } from './cameras/PerspectiveCamera.js'; +import { CullFaceFront, CullFaceBack } from './constants.js'; +import { BufferAttribute } from './core/BufferAttribute.js'; +import { BufferGeometry } from './core/BufferGeometry.js'; +import { EventDispatcher } from './core/EventDispatcher.js'; +import { Face3 } from './core/Face3.js'; +import { Object3D } from './core/Object3D.js'; +import { Light } from './lights/Light.js'; +import { AudioLoader } from './loaders/AudioLoader.js'; +import { CubeTextureLoader } from './loaders/CubeTextureLoader.js'; +import { TextureLoader } from './loaders/TextureLoader.js'; +import { Material } from './materials/Material.js'; +import { MeshPhongMaterial } from './materials/MeshPhongMaterial.js'; +import { MultiMaterial } from './materials/MultiMaterial.js'; +import { PointsMaterial } from './materials/PointsMaterial.js'; +import { ShaderMaterial } from './materials/ShaderMaterial.js'; +import { Box2 } from './math/Box2.js'; +import { Box3 } from './math/Box3.js'; +import { Color } from './math/Color.js'; +import { Matrix3 } from './math/Matrix3.js'; +import { Matrix4 } from './math/Matrix4.js'; +import { Plane } from './math/Plane.js'; +import { Quaternion } from './math/Quaternion.js'; +import { Ray } from './math/Ray.js'; +import { Vector3 } from './math/Vector3.js'; +import { LOD } from './objects/LOD.js'; +import { Points } from './objects/Points.js'; +import { Sprite } from './objects/Sprite.js'; +import { WebGLRenderer } from './renderers/WebGLRenderer.js'; +import { WebGLRenderTarget } from './renderers/WebGLRenderTarget.js'; +import { WebGLShadowMap } from './renderers/webgl/WebGLShadowMap.js'; + +export function Face4 ( a, b, c, d, normal, color, materialIndex ) { + console.warn( 'THREE.Face4 has been removed. A THREE.Face3 will be created instead.' ); + return new Face3( a, b, c, normal, color, materialIndex ); +} + +export const LineStrip = 0; + +export const LinePieces = 1; + +export { MultiMaterial as MeshFaceMaterial }; + +export function PointCloud ( geometry, material ) { + console.warn( 'THREE.PointCloud has been renamed to THREE.Points.' ); + return new Points( geometry, material ); +} + +export { Sprite as Particle }; + +export function ParticleSystem ( geometry, material ) { + console.warn( 'THREE.ParticleSystem has been renamed to THREE.Points.' ); + return new Points( geometry, material ); +} + +export function PointCloudMaterial ( parameters ) { + console.warn( 'THREE.PointCloudMaterial has been renamed to THREE.PointsMaterial.' ); + return new PointsMaterial( parameters ); +} + +export function ParticleBasicMaterial ( parameters ) { + console.warn( 'THREE.ParticleBasicMaterial has been renamed to THREE.PointsMaterial.' ); + return new PointsMaterial( parameters ); +} + +export function ParticleSystemMaterial ( parameters ) { + console.warn( 'THREE.ParticleSystemMaterial has been renamed to THREE.PointsMaterial.' ); + return new PointsMaterial( parameters ); +} + +export function Vertex ( x, y, z ) { + console.warn( 'THREE.Vertex has been removed. Use THREE.Vector3 instead.' ); + return new Vector3( x, y, z ); +} // -Object.assign( THREE.Box2.prototype, { +Object.assign( Box2.prototype, { empty: function () { console.warn( 'THREE.Box2: .empty() has been renamed to .isEmpty().' ); return this.isEmpty(); @@ -50,7 +92,7 @@ Object.assign( THREE.Box2.prototype, { } } ); -Object.assign( THREE.Box3.prototype, { +Object.assign( Box3.prototype, { empty: function () { console.warn( 'THREE.Box3: .empty() has been renamed to .isEmpty().' ); return this.isEmpty(); @@ -65,7 +107,7 @@ Object.assign( THREE.Box3.prototype, { } } ); -Object.assign( THREE.Matrix3.prototype, { +Object.assign( Matrix3.prototype, { multiplyVector3: function ( vector ) { console.warn( 'THREE.Matrix3: .multiplyVector3() has been removed. Use vector.applyMatrix3( matrix ) instead.' ); return vector.applyMatrix3( this ); @@ -76,7 +118,7 @@ Object.assign( THREE.Matrix3.prototype, { } } ); -Object.assign( THREE.Matrix4.prototype, { +Object.assign( Matrix4.prototype, { extractPosition: function ( m ) { console.warn( 'THREE.Matrix4: .extractPosition() has been renamed to .copyPosition().' ); return this.copyPosition( m ); @@ -122,21 +164,21 @@ Object.assign( THREE.Matrix4.prototype, { } } ); -Object.assign( THREE.Plane.prototype, { +Object.assign( Plane.prototype, { isIntersectionLine: function ( line ) { console.warn( 'THREE.Plane: .isIntersectionLine() has been renamed to .intersectsLine().' ); return this.intersectsLine( line ); } } ); -Object.assign( THREE.Quaternion.prototype, { +Object.assign( Quaternion.prototype, { multiplyVector3: function ( vector ) { console.warn( 'THREE.Quaternion: .multiplyVector3() has been removed. Use is now vector.applyQuaternion( quaternion ) instead.' ); return vector.applyQuaternion( this ); } } ); -Object.assign( THREE.Ray.prototype, { +Object.assign( Ray.prototype, { isIntersectionBox: function ( box ) { console.warn( 'THREE.Ray: .isIntersectionBox() has been renamed to .intersectsBox().' ); return this.intersectsBox( box ); @@ -151,7 +193,7 @@ Object.assign( THREE.Ray.prototype, { } } ); -Object.assign( THREE.Vector3.prototype, { +Object.assign( Vector3.prototype, { setEulerFromRotationMatrix: function () { console.error( 'THREE.Vector3: .setEulerFromRotationMatrix() has been removed. Use Euler.setFromRotationMatrix() instead.' ); }, @@ -174,7 +216,7 @@ Object.assign( THREE.Vector3.prototype, { // -Object.assign( THREE.Object3D.prototype, { +Object.assign( Object3D.prototype, { getChildByName: function ( name ) { console.warn( 'THREE.Object3D: .getChildByName() has been renamed to .getObjectByName().' ); return this.getObjectByName( name ); @@ -188,7 +230,7 @@ Object.assign( THREE.Object3D.prototype, { } } ); -Object.defineProperties( THREE.Object3D.prototype, { +Object.defineProperties( Object3D.prototype, { eulerOrder: { get: function () { console.warn( 'THREE.Object3D: .eulerOrder is now .rotation.order.' ); @@ -209,7 +251,7 @@ Object.defineProperties( THREE.Object3D.prototype, { } } ); -Object.defineProperties( THREE.LOD.prototype, { +Object.defineProperties( LOD.prototype, { objects: { get: function () { console.warn( 'THREE.LOD: .objects has been renamed to .levels.' ); @@ -220,7 +262,7 @@ Object.defineProperties( THREE.LOD.prototype, { // -THREE.PerspectiveCamera.prototype.setLens = function ( focalLength, filmGauge ) { +PerspectiveCamera.prototype.setLens = function ( focalLength, filmGauge ) { console.warn( "THREE.PerspectiveCamera.setLens is deprecated. " + "Use .setFocalLength and .filmGauge for a photographic setup." ); @@ -232,7 +274,7 @@ THREE.PerspectiveCamera.prototype.setLens = function ( focalLength, filmGauge ) // -Object.defineProperties( THREE.Light.prototype, { +Object.defineProperties( Light.prototype, { onlyShadow: { set: function ( value ) { console.warn( 'THREE.Light: .onlyShadow has been removed.' ); @@ -312,7 +354,7 @@ Object.defineProperties( THREE.Light.prototype, { // -Object.defineProperties( THREE.BufferAttribute.prototype, { +Object.defineProperties( BufferAttribute.prototype, { length: { get: function () { console.warn( 'THREE.BufferAttribute: .length has been deprecated. Please use .count.' ); @@ -321,7 +363,7 @@ Object.defineProperties( THREE.BufferAttribute.prototype, { } } ); -Object.assign( THREE.BufferGeometry.prototype, { +Object.assign( BufferGeometry.prototype, { addIndex: function ( index ) { console.warn( 'THREE.BufferGeometry: .addIndex() has been renamed to .setIndex().' ); this.setIndex( index ); @@ -345,7 +387,7 @@ Object.assign( THREE.BufferGeometry.prototype, { } } ); -Object.defineProperties( THREE.BufferGeometry.prototype, { +Object.defineProperties( BufferGeometry.prototype, { drawcalls: { get: function () { console.error( 'THREE.BufferGeometry: .drawcalls has been renamed to .groups.' ); @@ -362,7 +404,7 @@ Object.defineProperties( THREE.BufferGeometry.prototype, { // -Object.defineProperties( THREE.Material.prototype, { +Object.defineProperties( Material.prototype, { wrapAround: { get: function () { console.warn( 'THREE.' + this.type + ': .wrapAround has been removed.' ); @@ -374,12 +416,12 @@ Object.defineProperties( THREE.Material.prototype, { wrapRGB: { get: function () { console.warn( 'THREE.' + this.type + ': .wrapRGB has been removed.' ); - return new THREE.Color(); + return new Color(); } } } ); -Object.defineProperties( THREE.MeshPhongMaterial.prototype, { +Object.defineProperties( MeshPhongMaterial.prototype, { metal: { get: function () { console.warn( 'THREE.MeshPhongMaterial: .metal has been removed. Use THREE.MeshStandardMaterial instead.' ); @@ -391,7 +433,7 @@ Object.defineProperties( THREE.MeshPhongMaterial.prototype, { } } ); -Object.defineProperties( THREE.ShaderMaterial.prototype, { +Object.defineProperties( ShaderMaterial.prototype, { derivatives: { get: function () { console.warn( 'THREE.ShaderMaterial: .derivatives has been moved to .extensions.derivatives.' ); @@ -406,11 +448,11 @@ Object.defineProperties( THREE.ShaderMaterial.prototype, { // -THREE.EventDispatcher.prototype = Object.assign( Object.create( { +EventDispatcher.prototype = Object.assign( Object.create( { // Note: Extra base ensures these properties are not 'assign'ed. - constructor: THREE.EventDispatcher, + constructor: EventDispatcher, apply: function ( target ) { @@ -421,11 +463,11 @@ THREE.EventDispatcher.prototype = Object.assign( Object.create( { } -} ), THREE.EventDispatcher.prototype ); +} ), EventDispatcher.prototype ); // -Object.assign( THREE.WebGLRenderer.prototype, { +Object.assign( WebGLRenderer.prototype, { supportsFloatTextures: function () { console.warn( 'THREE.WebGLRenderer: .supportsFloatTextures() is now .extensions.get( \'OES_texture_float\' ).' ); return this.extensions.get( 'OES_texture_float' ); @@ -475,7 +517,7 @@ Object.assign( THREE.WebGLRenderer.prototype, { } } ); -Object.defineProperties( THREE.WebGLRenderer.prototype, { +Object.defineProperties( WebGLRenderer.prototype, { shadowMapEnabled: { get: function () { return this.shadowMap.enabled; @@ -505,13 +547,13 @@ Object.defineProperties( THREE.WebGLRenderer.prototype, { } } ); -Object.defineProperties( THREE.WebGLShadowMap.prototype, { +Object.defineProperties( WebGLShadowMap.prototype, { cullFace: { get: function () { - return this.renderReverseSided ? THREE.CullFaceFront : THREE.CullFaceBack; + return this.renderReverseSided ? CullFaceFront : CullFaceBack; }, set: function ( cullFace ) { - var value = ( cullFace !== THREE.CullFaceBack ); + var value = ( cullFace !== CullFaceBack ); console.warn( "WebGLRenderer: .shadowMap.cullFace is deprecated. Set .shadowMap.renderReverseSided to " + value + "." ); this.renderReverseSided = value; } @@ -520,7 +562,7 @@ Object.defineProperties( THREE.WebGLShadowMap.prototype, { // -Object.defineProperties( THREE.WebGLRenderTarget.prototype, { +Object.defineProperties( WebGLRenderTarget.prototype, { wrapS: { get: function () { console.warn( 'THREE.WebGLRenderTarget: .wrapS is now .texture.wrapS.' ); @@ -625,11 +667,11 @@ Object.defineProperties( THREE.WebGLRenderTarget.prototype, { // -Object.assign( THREE.Audio.prototype, { +Object.assign( Audio.prototype, { load: function ( file ) { console.warn( 'THREE.Audio: .load has been deprecated. Please use THREE.AudioLoader.' ); var scope = this; - var audioLoader = new THREE.AudioLoader(); + var audioLoader = new AudioLoader(); audioLoader.load( file, function ( buffer ) { scope.setBuffer( buffer ); } ); @@ -637,7 +679,7 @@ Object.assign( THREE.Audio.prototype, { } } ); -Object.assign( THREE.AudioAnalyser.prototype, { +Object.assign( AudioAnalyser.prototype, { getData: function ( file ) { console.warn( 'THREE.AudioAnalyser: .getData() is now .getFrequencyData().' ); return this.getFrequencyData(); @@ -646,7 +688,7 @@ Object.assign( THREE.AudioAnalyser.prototype, { // -THREE.GeometryUtils = { +export const GeometryUtils = { merge: function ( geometry1, geometry2, materialIndexOffset ) { @@ -654,7 +696,7 @@ THREE.GeometryUtils = { var matrix; - if ( geometry2 instanceof THREE.Mesh ) { + if ( geometry2.isMesh ) { geometry2.matrixAutoUpdate && geometry2.updateMatrix(); @@ -676,7 +718,7 @@ THREE.GeometryUtils = { }; -THREE.ImageUtils = { +export const ImageUtils = { crossOrigin: undefined, @@ -684,7 +726,7 @@ THREE.ImageUtils = { console.warn( 'THREE.ImageUtils.loadTexture has been deprecated. Use THREE.TextureLoader() instead.' ); - var loader = new THREE.TextureLoader(); + var loader = new TextureLoader(); loader.setCrossOrigin( this.crossOrigin ); var texture = loader.load( url, onLoad, undefined, onError ); @@ -699,7 +741,7 @@ THREE.ImageUtils = { console.warn( 'THREE.ImageUtils.loadTextureCube has been deprecated. Use THREE.CubeTextureLoader() instead.' ); - var loader = new THREE.CubeTextureLoader(); + var loader = new CubeTextureLoader(); loader.setCrossOrigin( this.crossOrigin ); var texture = loader.load( urls, onLoad, undefined, onError ); @@ -726,7 +768,7 @@ THREE.ImageUtils = { // -THREE.Projector = function () { +export function Projector () { console.error( 'THREE.Projector has been moved to /examples/js/renderers/Projector.js.' ); @@ -750,11 +792,11 @@ THREE.Projector = function () { }; -}; +} // -THREE.CanvasRenderer = function () { +export function CanvasRenderer () { console.error( 'THREE.CanvasRenderer has been moved to /examples/js/renderers/CanvasRenderer.js' ); @@ -764,4 +806,4 @@ THREE.CanvasRenderer = function () { this.setClearColor = function () {}; this.setSize = function () {}; -}; +} diff --git a/src/Three.js b/src/Three.js index e76012b86998e9..5d63971db4e70d 100644 --- a/src/Three.js +++ b/src/Three.js @@ -237,3 +237,4 @@ export { ShapeUtils } from './extras/ShapeUtils.js'; export { SceneUtils } from './extras/SceneUtils.js'; export { CurveUtils } from './extras/CurveUtils.js'; export * from './constants.js'; +export * from './Three.Legacy.js';