From 56bc4d15479e63ab57ff01e2a33c250567d8acb4 Mon Sep 17 00:00:00 2001 From: Richard Davey Date: Wed, 13 Sep 2017 17:09:16 +0100 Subject: [PATCH] Using MATH_CONST properly to avoid entire library import. Swapping to removing all index.js listings to avoid globbing. --- v3/src/boot/Config.js | 2 +- v3/src/math/const.js | 7 +++- v3/src/math/index.js | 46 +++++++++++++++++++++++++ v3/src/phaser.js | 8 +++++ v3/src/utils/object/GetAdvancedValue.js | 2 +- v3/webpack.dist.config.js | 17 ++++----- 6 files changed, 69 insertions(+), 13 deletions(-) diff --git a/v3/src/boot/Config.js b/v3/src/boot/Config.js index 50a60a76c..deb7f04aa 100644 --- a/v3/src/boot/Config.js +++ b/v3/src/boot/Config.js @@ -1,7 +1,7 @@ var Class = require('../utils/Class'); var CONST = require('../const'); var GetValue = require('../utils/object/GetValue'); -var MATH = require('../math'); +var MATH = require('../math/const'); var NOOP = require('../utils/NOOP'); var ValueToColor = require('../graphics/color/ValueToColor'); diff --git a/v3/src/math/const.js b/v3/src/math/const.js index 6f06737dc..85d0fb59a 100644 --- a/v3/src/math/const.js +++ b/v3/src/math/const.js @@ -1,10 +1,15 @@ +var RND = require('./random-data-generator/RandomDataGenerator'); + var MATH_CONST = { PI2: Math.PI * 2, TAU: Math.PI * 0.5, EPSILON: 1.0e-6, DEG_TO_RAD: Math.PI / 180, - RAD_TO_DEG: 180 / Math.PI + RAD_TO_DEG: 180 / Math.PI, + + // Random Data Generator + RND: new RND() }; diff --git a/v3/src/math/index.js b/v3/src/math/index.js index 8c54b009c..068e3f75e 100644 --- a/v3/src/math/index.js +++ b/v3/src/math/index.js @@ -1,3 +1,4 @@ +/* var RND = require('./random-data-generator/RandomDataGenerator'); module.exports = { @@ -53,3 +54,48 @@ module.exports = { Wrap: require('./Wrap') }; +*/ + +module.exports = { + + // Collections of functions + Angle: require('./angle/'), + Distance: require('./distance/'), + Easing: require('./easing/'), + Fuzzy: require('./fuzzy/'), + Interpolation: require('./interpolation/'), + Pow2: require('./pow2/'), + Snap: require('./snap/'), + + // Single functions + Average: require('./Average'), + Bernstein: require('./Bernstein'), + Between: require('./Between'), + CatmullRom: require('./CatmullRom'), + CeilTo: require('./CeilTo'), + Clamp: require('./Clamp'), + DegToRad: require('./DegToRad'), + Difference: require('./Difference'), + Factorial: require('./Factorial'), + FloatBetween: require('./FloatBetween'), + FloorTo: require('./FloorTo'), + GetSpeed: require('./GetSpeed'), + IsEven: require('./IsEven'), + IsEvenStrict: require('./IsEvenStrict'), + Linear: require('./Linear'), + MaxAdd: require('./MaxAdd'), + MinSub: require('./MinSub'), + Percent: require('./Percent'), + RadToDeg: require('./RadToDeg'), + Rotate: require('./Rotate'), + RotateAround: require('./RotateAround'), + RotateAroundDistance: require('./RotateAroundDistance'), + RoundAwayFromZero: require('./RoundAwayFromZero'), + RoundTo: require('./RoundTo'), + SinCosTableGenerator: require('./SinCosTableGenerator'), + SmootherStep: require('./SmootherStep'), + SmoothStep: require('./SmoothStep'), + Within: require('./Within'), + Wrap: require('./Wrap') + +}; diff --git a/v3/src/phaser.js b/v3/src/phaser.js index da3594f35..94ca48d60 100644 --- a/v3/src/phaser.js +++ b/v3/src/phaser.js @@ -5,6 +5,14 @@ var Extend = require('./utils/object/Extend'); // This object is exported globally +/* +var Phaser = { + + Game: require('./boot/Game') + +}; +*/ + var Phaser = { Actions: require('./actions/'), diff --git a/v3/src/utils/object/GetAdvancedValue.js b/v3/src/utils/object/GetAdvancedValue.js index f824e6714..fbb019c8c 100644 --- a/v3/src/utils/object/GetAdvancedValue.js +++ b/v3/src/utils/object/GetAdvancedValue.js @@ -1,4 +1,4 @@ -var MATH = require('../../math'); +var MATH = require('../../math/const'); var GetValue = require('./GetValue'); // Allowed types: diff --git a/v3/webpack.dist.config.js b/v3/webpack.dist.config.js index 9a5450442..a6c7e47b8 100644 --- a/v3/webpack.dist.config.js +++ b/v3/webpack.dist.config.js @@ -2,7 +2,7 @@ const webpack = require('webpack'); const WebpackShellPlugin = require('webpack-shell-plugin'); -const UglifyJSPlugin = require('uglifyjs-webpack-plugin') +const UglifyJSPlugin = require('uglifyjs-webpack-plugin'); module.exports = { @@ -23,10 +23,15 @@ module.exports = { plugins: [ + new webpack.DefinePlugin({ + 'CANVAS_RENDERER': JSON.stringify(true), + 'WEBGL_RENDERER': JSON.stringify(true) + }), + new UglifyJSPlugin({ include: /\.min\.js$/, parallel: true, - sourceMap: true, + sourceMap: false, compress: true, comments: false, uglifyOptions: { @@ -43,12 +48,4 @@ module.exports = { ] -// new webpack.DefinePlugin({ -// PRODUCTION: JSON.stringify(true), -// VERSION: JSON.stringify("5fa3b9"), -// BROWSER_SUPPORTS_HTML5: true, -// TWO: "1+1", -// "typeof window": JSON.stringify("object") -// }) - };