Skip to content

Commit

Permalink
MathUtils: convert to esmodules to allow for tree-shaking (mrdoob#21651)
Browse files Browse the repository at this point in the history
* MathUtils: convert to es-modules

* MathUtils: remove deprecated methods
  • Loading branch information
marcofugaro authored Apr 14, 2021
1 parent 952441f commit 354f955
Show file tree
Hide file tree
Showing 29 changed files with 178 additions and 191 deletions.
25 changes: 1 addition & 24 deletions src/Three.Legacy.js
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ import { Sphere } from './math/Sphere.js';
import { Color } from './math/Color.js';
import { Frustum } from './math/Frustum.js';
import { Line3 } from './math/Line3.js';
import { MathUtils } from './math/MathUtils.js';
import * as MathUtils from './math/MathUtils.js';
import { Matrix3 } from './math/Matrix3.js';
import { Matrix4 } from './math/Matrix4.js';
import { Plane } from './math/Plane.js';
Expand Down Expand Up @@ -428,29 +428,6 @@ Line3.prototype.center = function ( optionalTarget ) {

//

MathUtils.random16 = function () {

console.warn( 'THREE.Math: .random16() has been deprecated. Use Math.random() instead.' );
return Math.random();

};

MathUtils.nearestPowerOfTwo = function ( value ) {

console.warn( 'THREE.Math: .nearestPowerOfTwo() has been renamed to .floorPowerOfTwo().' );
return MathUtils.floorPowerOfTwo( value );

};

MathUtils.nextPowerOfTwo = function ( value ) {

console.warn( 'THREE.Math: .nextPowerOfTwo() has been renamed to .ceilPowerOfTwo().' );
return MathUtils.ceilPowerOfTwo( value );

};

//

Matrix3.prototype.flattenToArrayOffset = function ( array, offset ) {

console.warn( 'THREE.Matrix3: .flattenToArrayOffset() has been deprecated. Use .toArray() instead.' );
Expand Down
2 changes: 1 addition & 1 deletion src/Three.js
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ export { DiscreteInterpolant } from './math/interpolants/DiscreteInterpolant.js'
export { CubicInterpolant } from './math/interpolants/CubicInterpolant.js';
export { Interpolant } from './math/Interpolant.js';
export { Triangle } from './math/Triangle.js';
export { MathUtils } from './math/MathUtils.js';
export * as MathUtils from './math/MathUtils.js';
export { Spherical } from './math/Spherical.js';
export { Cylindrical } from './math/Cylindrical.js';
export { Plane } from './math/Plane.js';
Expand Down
2 changes: 1 addition & 1 deletion src/animation/AnimationClip.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import { NumberKeyframeTrack } from './tracks/NumberKeyframeTrack.js';
import { QuaternionKeyframeTrack } from './tracks/QuaternionKeyframeTrack.js';
import { StringKeyframeTrack } from './tracks/StringKeyframeTrack.js';
import { VectorKeyframeTrack } from './tracks/VectorKeyframeTrack.js';
import { MathUtils } from '../math/MathUtils.js';
import * as MathUtils from '../math/MathUtils.js';
import { NormalAnimationBlendMode } from '../constants.js';

class AnimationClip {
Expand Down
2 changes: 1 addition & 1 deletion src/animation/AnimationObjectGroup.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { PropertyBinding } from './PropertyBinding.js';
import { MathUtils } from '../math/MathUtils.js';
import * as MathUtils from '../math/MathUtils.js';

/**
*
Expand Down
2 changes: 1 addition & 1 deletion src/cameras/PerspectiveCamera.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { Camera } from './Camera.js';
import { MathUtils } from '../math/MathUtils.js';
import * as MathUtils from '../math/MathUtils.js';

class PerspectiveCamera extends Camera {

Expand Down
2 changes: 1 addition & 1 deletion src/cameras/StereoCamera.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { Matrix4 } from '../math/Matrix4.js';
import { MathUtils } from '../math/MathUtils.js';
import * as MathUtils from '../math/MathUtils.js';
import { PerspectiveCamera } from './PerspectiveCamera.js';

const _eyeRight = /*@__PURE__*/ new Matrix4();
Expand Down
2 changes: 1 addition & 1 deletion src/core/BufferGeometry.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import { Sphere } from '../math/Sphere.js';
import { Object3D } from './Object3D.js';
import { Matrix4 } from '../math/Matrix4.js';
import { Matrix3 } from '../math/Matrix3.js';
import { MathUtils } from '../math/MathUtils.js';
import * as MathUtils from '../math/MathUtils.js';
import { arrayMax } from '../utils.js';

let _id = 0;
Expand Down
2 changes: 1 addition & 1 deletion src/core/InterleavedBuffer.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { MathUtils } from '../math/MathUtils.js';
import * as MathUtils from '../math/MathUtils.js';
import { StaticDrawUsage } from '../constants.js';

class InterleavedBuffer {
Expand Down
2 changes: 1 addition & 1 deletion src/core/Object3D.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import { EventDispatcher } from './EventDispatcher.js';
import { Euler } from '../math/Euler.js';
import { Layers } from './Layers.js';
import { Matrix3 } from '../math/Matrix3.js';
import { MathUtils } from '../math/MathUtils.js';
import * as MathUtils from '../math/MathUtils.js';

let _object3DId = 0;

Expand Down
2 changes: 1 addition & 1 deletion src/extras/core/Curve.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { MathUtils } from '../../math/MathUtils.js';
import * as MathUtils from '../../math/MathUtils.js';
import { Vector2 } from '../../math/Vector2.js';
import { Vector3 } from '../../math/Vector3.js';
import { Matrix4 } from '../../math/Matrix4.js';
Expand Down
2 changes: 1 addition & 1 deletion src/extras/core/Shape.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { Path } from './Path.js';
import { MathUtils } from '../../math/MathUtils.js';
import * as MathUtils from '../../math/MathUtils.js';

class Shape extends Path {

Expand Down
2 changes: 1 addition & 1 deletion src/geometries/EdgesGeometry.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { BufferGeometry } from '../core/BufferGeometry.js';
import { Float32BufferAttribute } from '../core/BufferAttribute.js';
import { MathUtils } from '../math/MathUtils.js';
import * as MathUtils from '../math/MathUtils.js';
import { Triangle } from '../math/Triangle.js';
import { Vector3 } from '../math/Vector3.js';

Expand Down
2 changes: 1 addition & 1 deletion src/geometries/LatheGeometry.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { Float32BufferAttribute } from '../core/BufferAttribute.js';
import { BufferGeometry } from '../core/BufferGeometry.js';
import { Vector3 } from '../math/Vector3.js';
import { Vector2 } from '../math/Vector2.js';
import { MathUtils } from '../math/MathUtils.js';
import * as MathUtils from '../math/MathUtils.js';

class LatheGeometry extends BufferGeometry {

Expand Down
2 changes: 1 addition & 1 deletion src/lights/SpotLightShadow.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { LightShadow } from './LightShadow.js';
import { MathUtils } from '../math/MathUtils.js';
import * as MathUtils from '../math/MathUtils.js';
import { PerspectiveCamera } from '../cameras/PerspectiveCamera.js';

class SpotLightShadow extends LightShadow {
Expand Down
2 changes: 1 addition & 1 deletion src/materials/Material.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { EventDispatcher } from '../core/EventDispatcher.js';
import { FrontSide, FlatShading, NormalBlending, LessEqualDepth, AddEquation, OneMinusSrcAlphaFactor, SrcAlphaFactor, AlwaysStencilFunc, KeepStencilOp } from '../constants.js';
import { MathUtils } from '../math/MathUtils.js';
import * as MathUtils from '../math/MathUtils.js';

let materialId = 0;

Expand Down
2 changes: 1 addition & 1 deletion src/materials/MeshPhysicalMaterial.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { Vector2 } from '../math/Vector2.js';
import { MeshStandardMaterial } from './MeshStandardMaterial.js';
import { Color } from '../math/Color.js';
import { MathUtils } from '../math/MathUtils.js';
import * as MathUtils from '../math/MathUtils.js';

/**
* parameters = {
Expand Down
2 changes: 1 addition & 1 deletion src/math/Color.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { MathUtils } from './MathUtils.js';
import * as MathUtils from './MathUtils.js';

const _colorKeywords = { 'aliceblue': 0xF0F8FF, 'antiquewhite': 0xFAEBD7, 'aqua': 0x00FFFF, 'aquamarine': 0x7FFFD4, 'azure': 0xF0FFFF,
'beige': 0xF5F5DC, 'bisque': 0xFFE4C4, 'black': 0x000000, 'blanchedalmond': 0xFFEBCD, 'blue': 0x0000FF, 'blueviolet': 0x8A2BE2,
Expand Down
2 changes: 1 addition & 1 deletion src/math/Euler.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { Quaternion } from './Quaternion.js';
import { Vector3 } from './Vector3.js';
import { Matrix4 } from './Matrix4.js';
import { MathUtils } from './MathUtils.js';
import * as MathUtils from './MathUtils.js';

const _matrix = /*@__PURE__*/ new Matrix4();
const _quaternion = /*@__PURE__*/ new Quaternion();
Expand Down
2 changes: 1 addition & 1 deletion src/math/Line3.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { Vector3 } from './Vector3.js';
import { MathUtils } from './MathUtils.js';
import * as MathUtils from './MathUtils.js';

const _startP = /*@__PURE__*/ new Vector3();
const _startEnd = /*@__PURE__*/ new Vector3();
Expand Down
Loading

0 comments on commit 354f955

Please sign in to comment.