mage-engine 3.23.9 → 3.23.11

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (2) hide show
  1. package/dist/mage.js +92 -54
  2. package/package.json +1 -1
package/dist/mage.js CHANGED
@@ -57798,7 +57798,7 @@ function applyMiddleware() {
57798
57798
 
57799
57799
  var thunk = createThunkMiddleware();
57800
57800
  thunk.withExtraArgument = createThunkMiddleware;var name$1 = "mage-engine";
57801
- var version$1 = "3.23.9";
57801
+ var version$1 = "3.23.11";
57802
57802
  var description = "A WebGL Javascript Game Engine, built on top of THREE.js and many other libraries.";
57803
57803
  var main = "dist/mage.js";
57804
57804
  var author$1 = {
@@ -60038,14 +60038,14 @@ var prepareModel = function prepareModel(model) {
60038
60038
  return model;
60039
60039
  };
60040
60040
  var serializeVector = function serializeVector(vector) {
60041
- return {
60041
+ return vector && {
60042
60042
  x: vector.x,
60043
60043
  y: vector.y,
60044
60044
  z: vector.z
60045
60045
  };
60046
60046
  };
60047
60047
  var serializeQuaternion = function serializeQuaternion(quaternion) {
60048
- return {
60048
+ return quaternion && {
60049
60049
  x: quaternion.x,
60050
60050
  y: quaternion.y,
60051
60051
  z: quaternion.z,
@@ -60053,7 +60053,7 @@ var serializeQuaternion = function serializeQuaternion(quaternion) {
60053
60053
  };
60054
60054
  };
60055
60055
  var serializeColor = function serializeColor(color) {
60056
- return {
60056
+ return color && {
60057
60057
  r: color.r,
60058
60058
  g: color.g,
60059
60059
  b: color.b
@@ -89372,24 +89372,37 @@ var FirstPersonControl = /*#__PURE__*/function (_EventDispatcher) {
89372
89372
 
89373
89373
  return FlyControl;
89374
89374
  }(EventDispatcher);var CONTROLS = {
89375
- ORBIT: "orbit",
89376
- TRANSFORM: "transform",
89377
- FPS: "fps",
89378
- FLY: "fly"
89375
+ ORBIT: "CONTROLS:ORBIT",
89376
+ TRANSFORM: "CONTROLS:TRANSFORM",
89377
+ FPS: "CONTROLS:FPS",
89378
+ FLY: "CONTROLS:FLY"
89379
89379
  };
89380
- var AVAILABLE_CONTROLS = Object.keys(CONTROLS);
89381
- var EVENTS = {
89380
+ var AVAILABLE_CONTROLS = Object.keys(CONTROLS);var controls_contants=/*#__PURE__*/Object.freeze({__proto__:null,CONTROLS:CONTROLS,AVAILABLE_CONTROLS:AVAILABLE_CONTROLS});var THREEJS_CONTROL_EVENTS = {
89382
89381
  CHANGE: "change",
89382
+ OBJECT_CHANGE: "objectChange",
89383
89383
  DRAGGING_CHANGE: "dragging-changed"
89384
89384
  };
89385
- var Controls = /*#__PURE__*/function () {
89385
+ var CONTROL_EVENTS = {
89386
+ TRANSFORM: {
89387
+ CHANGE: "".concat(CONTROLS.TRANSFORM, ":CHANGE"),
89388
+ DRAGGING_CHANGE: "".concat(CONTROLS.TRANSFORM, ":DRAGGING_CHANGE")
89389
+ }
89390
+ };
89391
+ var Controls = /*#__PURE__*/function (_EventDispatcher) {
89392
+ _inherits(Controls, _EventDispatcher);
89393
+
89394
+ var _super = _createSuper(Controls);
89395
+
89386
89396
  function Controls() {
89387
- var _this = this,
89388
- _this$controls;
89397
+ var _this$controls;
89398
+
89399
+ var _this;
89389
89400
 
89390
89401
  _classCallCheck(this, Controls);
89391
89402
 
89392
- _defineProperty$1(this, "disposeSingleControls", function (control) {
89403
+ _this = _super.call(this);
89404
+
89405
+ _defineProperty$1(_assertThisInitialized(_this), "disposeSingleControls", function (control) {
89393
89406
  if (_this.controls[control] && _this.controls[control].dispose) {
89394
89407
  _this.controls[control].dispose();
89395
89408
 
@@ -89397,7 +89410,8 @@ var Controls = /*#__PURE__*/function () {
89397
89410
  }
89398
89411
  });
89399
89412
 
89400
- this.controls = (_this$controls = {}, _defineProperty$1(_this$controls, CONTROLS.ORBIT, undefined), _defineProperty$1(_this$controls, CONTROLS.TRANSFORM, undefined), _defineProperty$1(_this$controls, CONTROLS.FPS, undefined), _defineProperty$1(_this$controls, CONTROLS.FLY, undefined), _this$controls);
89413
+ _this.controls = (_this$controls = {}, _defineProperty$1(_this$controls, CONTROLS.ORBIT, undefined), _defineProperty$1(_this$controls, CONTROLS.TRANSFORM, undefined), _defineProperty$1(_this$controls, CONTROLS.FPS, undefined), _defineProperty$1(_this$controls, CONTROLS.FLY, undefined), _this$controls);
89414
+ return _this;
89401
89415
  }
89402
89416
 
89403
89417
  _createClass(Controls, [{
@@ -89466,15 +89480,36 @@ var Controls = /*#__PURE__*/function () {
89466
89480
  value: function setTransformControls() {
89467
89481
  var _this4 = this;
89468
89482
 
89469
- this.controls[CONTROLS.TRANSFORM] = new TransformControls(Scene$1.getCameraBody(), Scene$1.getDOMElement());
89470
- this.controls[CONTROLS.TRANSFORM].init();
89471
- this.controls[CONTROLS.TRANSFORM].addEventListener(EVENTS.CHANGE, Scene$1.render.bind(Scene$1));
89472
- this.controls[CONTROLS.TRANSFORM].addEventListener(EVENTS.DRAGGING_CHANGE, function (event) {
89483
+ var control = new TransformControls(Scene$1.getCameraBody(), Scene$1.getDOMElement());
89484
+ control.init();
89485
+ control.addEventListener(THREEJS_CONTROL_EVENTS.CHANGE, function () {
89486
+ _this4.dispatchEvent({
89487
+ type: CONTROL_EVENTS.TRANSFORM.CHANGE,
89488
+ element: Universe$1.find(control.object)
89489
+ });
89490
+
89491
+ Scene$1.render.call(Scene$1);
89492
+ });
89493
+ control.addEventListener(THREEJS_CONTROL_EVENTS.OBJECT_CHANGE, function () {
89494
+ _this4.dispatchEvent({
89495
+ type: CONTROL_EVENTS.TRANSFORM.CHANGE,
89496
+ element: Universe$1.find(control.object)
89497
+ });
89498
+
89499
+ Scene$1.render.call(Scene$1);
89500
+ });
89501
+ control.addEventListener(THREEJS_CONTROL_EVENTS.DRAGGING_CHANGE, function (event) {
89502
+ _this4.dispatchEvent({
89503
+ type: CONTROL_EVENTS.TRANSFORM.DRAGGING_CHANGE,
89504
+ element: Universe$1.find(control.object)
89505
+ });
89506
+
89473
89507
  if (_this4.controls[CONTROLS.ORBIT]) {
89474
89508
  _this4.controls[CONTROLS.ORBIT].enabled = !event.value;
89475
89509
  }
89476
89510
  });
89477
- return this.controls.transform;
89511
+ this.controls[CONTROLS.TRANSFORM] = control;
89512
+ return this.controls[CONTROLS.TRANSFORM];
89478
89513
  }
89479
89514
  }, {
89480
89515
  key: "setFirstPersonControl",
@@ -89505,7 +89540,7 @@ var Controls = /*#__PURE__*/function () {
89505
89540
  }]);
89506
89541
 
89507
89542
  return Controls;
89508
- }();
89543
+ }(EventDispatcher);
89509
89544
  var Controls$1 = new Controls();var author = {
89510
89545
  name: "Marco Stagni",
89511
89546
  email: "mrc.stagni@gmail.com",
@@ -91631,9 +91666,10 @@ var addHitBox = function addHitBox(element) {
91631
91666
  key: "toJSON",
91632
91667
  value: function toJSON() {
91633
91668
  var parseJSON = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : false;
91669
+ var color = this.getColor();
91634
91670
  return _objectSpread2$1(_objectSpread2$1({}, _get(_getPrototypeOf(Light.prototype), "toJSON", this).call(this, parseJSON)), {}, {
91635
91671
  type: this.getEntityType(),
91636
- color: this.getColor(),
91672
+ color: parseJSON ? serializeColor(color) : color,
91637
91673
  intensity: this.getIntensity(),
91638
91674
  name: this.getName(),
91639
91675
  castShadow: this.getCastShadow()
@@ -91972,7 +92008,7 @@ var SunLight = /*#__PURE__*/function (_Light) {
91972
92008
  value: function toJSON() {
91973
92009
  var parseJSON = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : false;
91974
92010
  return _objectSpread2$1(_objectSpread2$1({}, _get(_getPrototypeOf(SunLight.prototype), "toJSON", this).call(this, parseJSON)), {}, {
91975
- target: this.getTarget(),
92011
+ target: parseJSON ? this.getTarget().toJSON(parseJSON) : this.getTarget(),
91976
92012
  bias: this.getBias(),
91977
92013
  mapSize: this.getMapSize(),
91978
92014
  shadowCamera: _objectSpread2$1(_objectSpread2$1({}, this.getShadowCameraNearFar()), {}, {
@@ -92502,7 +92538,7 @@ var SpotLight = /*#__PURE__*/function (_Light) {
92502
92538
  value: function toJSON() {
92503
92539
  var parseJSON = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : false;
92504
92540
  return _objectSpread2$1(_objectSpread2$1({}, _get(_getPrototypeOf(SpotLight.prototype), "toJSON", this).call(this, parseJSON)), {}, {
92505
- target: this.getTarget(),
92541
+ target: parseJSON ? this.getTarget().toJSON(parseJSON) : this.getTarget(),
92506
92542
  distance: this.getDistance(),
92507
92543
  decay: this.getDecay(),
92508
92544
  bias: this.getBias(),
@@ -92748,9 +92784,10 @@ var SpotLight = /*#__PURE__*/function (_Light) {
92748
92784
  key: "toJSON",
92749
92785
  value: function toJSON() {
92750
92786
  var parseJSON = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : false;
92787
+ var color = this.getColor();
92751
92788
  return _objectSpread2$1(_objectSpread2$1({}, _get(_getPrototypeOf(Light.prototype), "toJSON", this).call(this, parseJSON)), {}, {
92752
92789
  type: this.getEntityType(),
92753
- color: this.getColor(),
92790
+ color: parseJSON ? serializeColor(color) : color,
92754
92791
  intensity: this.getIntensity(),
92755
92792
  name: this.getName(),
92756
92793
  castShadow: this.getCastShadow()
@@ -92880,8 +92917,9 @@ var HemisphereLight = /*#__PURE__*/function (_Light) {
92880
92917
  key: "toJSON",
92881
92918
  value: function toJSON() {
92882
92919
  var parseJSON = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : false;
92920
+ var color = this.getColor();
92883
92921
  return _objectSpread2$1(_objectSpread2$1({}, _get(_getPrototypeOf(HemisphereLight.prototype), "toJSON", this).call(this, parseJSON)), {}, {
92884
- color: this.getColor()
92922
+ color: parseJSON ? serializeColor(color) : color
92885
92923
  });
92886
92924
  }
92887
92925
  }]);
@@ -94198,41 +94236,41 @@ var Water = /*#__PURE__*/function (_Element) {
94198
94236
  }, {
94199
94237
  key: "vertexShader",
94200
94238
  value: function vertexShader() {
94201
- return ['uniform vec3 sunPosition;', 'uniform float rayleigh;', 'uniform float turbidity;', 'uniform float mieCoefficient;', 'varying vec3 vWorldPosition;', 'varying vec3 vSunDirection;', 'varying float vSunfade;', 'varying vec3 vBetaR;', 'varying vec3 vBetaM;', 'varying float vSunE;', 'const vec3 up = vec3( 0.0, 1.0, 0.0 );', // constants for atmospheric scattering
94202
- 'const float e = 2.71828182845904523536028747135266249775724709369995957;', 'const float pi = 3.141592653589793238462643383279502884197169;', // wavelength of used primaries, according to preetham
94203
- 'const vec3 lambda = vec3( 680E-9, 550E-9, 450E-9 );', // this pre-calcuation replaces older TotalRayleigh(vec3 lambda) function:
94239
+ return ["uniform vec3 sunPosition;", "uniform float rayleigh;", "uniform float turbidity;", "uniform float mieCoefficient;", "varying vec3 vWorldPosition;", "varying vec3 vSunDirection;", "varying float vSunfade;", "varying vec3 vBetaR;", "varying vec3 vBetaM;", "varying float vSunE;", "const vec3 up = vec3( 0.0, 1.0, 0.0 );", // constants for atmospheric scattering
94240
+ "const float e = 2.71828182845904523536028747135266249775724709369995957;", "const float pi = 3.141592653589793238462643383279502884197169;", // wavelength of used primaries, according to preetham
94241
+ "const vec3 lambda = vec3( 680E-9, 550E-9, 450E-9 );", // this pre-calcuation replaces older TotalRayleigh(vec3 lambda) function:
94204
94242
  // (8.0 * pow(pi, 3.0) * pow(pow(n, 2.0) - 1.0, 2.0) * (6.0 + 3.0 * pn)) / (3.0 * N * pow(lambda, vec3(4.0)) * (6.0 - 7.0 * pn))
94205
- 'const vec3 totalRayleigh = vec3( 5.804542996261093E-6, 1.3562911419845635E-5, 3.0265902468824876E-5 );', // mie stuff
94243
+ "const vec3 totalRayleigh = vec3( 5.804542996261093E-6, 1.3562911419845635E-5, 3.0265902468824876E-5 );", // mie stuff
94206
94244
  // K coefficient for the primaries
94207
- 'const float v = 4.0;', 'const vec3 K = vec3( 0.686, 0.678, 0.666 );', // MieConst = pi * pow( ( 2.0 * pi ) / lambda, vec3( v - 2.0 ) ) * K
94208
- 'const vec3 MieConst = vec3( 1.8399918514433978E14, 2.7798023919660528E14, 4.0790479543861094E14 );', // earth shadow hack
94245
+ "const float v = 4.0;", "const vec3 K = vec3( 0.686, 0.678, 0.666 );", // MieConst = pi * pow( ( 2.0 * pi ) / lambda, vec3( v - 2.0 ) ) * K
94246
+ "const vec3 MieConst = vec3( 1.8399918514433978E14, 2.7798023919660528E14, 4.0790479543861094E14 );", // earth shadow hack
94209
94247
  // cutoffAngle = pi / 1.95;
94210
- 'const float cutoffAngle = 1.6110731556870734;', 'const float steepness = 1.5;', 'const float EE = 1000.0;', 'float sunIntensity( float zenithAngleCos ) {', ' zenithAngleCos = clamp( zenithAngleCos, -1.0, 1.0 );', ' return EE * max( 0.0, 1.0 - pow( e, -( ( cutoffAngle - acos( zenithAngleCos ) ) / steepness ) ) );', '}', 'vec3 totalMie( float T ) {', ' float c = ( 0.2 * T ) * 10E-18;', ' return 0.434 * c * MieConst;', '}', 'void main() {', ' vec4 worldPosition = modelMatrix * vec4( position, 1.0 );', ' vWorldPosition = worldPosition.xyz;', ' gl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );', ' gl_Position.z = gl_Position.w;', // set z to camera.far
94211
- ' vSunDirection = normalize( sunPosition );', ' vSunE = sunIntensity( dot( vSunDirection, up ) );', ' vSunfade = 1.0 - clamp( 1.0 - exp( ( sunPosition.y / 450000.0 ) ), 0.0, 1.0 );', ' float rayleighCoefficient = rayleigh - ( 1.0 * ( 1.0 - vSunfade ) );', // extinction (absorbtion + out scattering)
94248
+ "const float cutoffAngle = 1.6110731556870734;", "const float steepness = 1.5;", "const float EE = 1000.0;", "float sunIntensity( float zenithAngleCos ) {", " zenithAngleCos = clamp( zenithAngleCos, -1.0, 1.0 );", " return EE * max( 0.0, 1.0 - pow( e, -( ( cutoffAngle - acos( zenithAngleCos ) ) / steepness ) ) );", "}", "vec3 totalMie( float T ) {", " float c = ( 0.2 * T ) * 10E-18;", " return 0.434 * c * MieConst;", "}", "void main() {", " vec4 worldPosition = modelMatrix * vec4( position, 1.0 );", " vWorldPosition = worldPosition.xyz;", " gl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );", " gl_Position.z = gl_Position.w;", // set z to camera.far
94249
+ " vSunDirection = normalize( sunPosition );", " vSunE = sunIntensity( dot( vSunDirection, up ) );", " vSunfade = 1.0 - clamp( 1.0 - exp( ( sunPosition.y / 450000.0 ) ), 0.0, 1.0 );", " float rayleighCoefficient = rayleigh - ( 1.0 * ( 1.0 - vSunfade ) );", // extinction (absorbtion + out scattering)
94212
94250
  // rayleigh coefficients
94213
- ' vBetaR = totalRayleigh * rayleighCoefficient;', // mie coefficients
94214
- ' vBetaM = totalMie( turbidity ) * mieCoefficient;', '}'].join('\n');
94251
+ " vBetaR = totalRayleigh * rayleighCoefficient;", // mie coefficients
94252
+ " vBetaM = totalMie( turbidity ) * mieCoefficient;", "}"].join("\n");
94215
94253
  }
94216
94254
  }, {
94217
94255
  key: "fragmentShader",
94218
94256
  value: function fragmentShader() {
94219
- return ['varying vec3 vWorldPosition;', 'varying vec3 vSunDirection;', 'varying float vSunfade;', 'varying vec3 vBetaR;', 'varying vec3 vBetaM;', 'varying float vSunE;', 'uniform float luminance;', 'uniform float mieDirectionalG;', 'const vec3 cameraPos = vec3( 0.0, 0.0, 0.0 );', // constants for atmospheric scattering
94220
- 'const float pi = 3.141592653589793238462643383279502884197169;', 'const float n = 1.0003;', // refractive index of air
94221
- 'const float N = 2.545E25;', // number of molecules per unit volume for air at
94257
+ return ["varying vec3 vWorldPosition;", "varying vec3 vSunDirection;", "varying float vSunfade;", "varying vec3 vBetaR;", "varying vec3 vBetaM;", "varying float vSunE;", "uniform float luminance;", "uniform float mieDirectionalG;", "const vec3 cameraPos = vec3( 0.0, 0.0, 0.0 );", // constants for atmospheric scattering
94258
+ "const float pi = 3.141592653589793238462643383279502884197169;", "const float n = 1.0003;", // refractive index of air
94259
+ "const float N = 2.545E25;", // number of molecules per unit volume for air at
94222
94260
  // 288.15K and 1013mb (sea level -45 celsius)
94223
94261
  // optical length at zenith for molecules
94224
- 'const float rayleighZenithLength = 8.4E3;', 'const float mieZenithLength = 1.25E3;', 'const vec3 up = vec3( 0.0, 1.0, 0.0 );', // 66 arc seconds -> degrees, and the cosine of that
94225
- 'const float sunAngularDiameterCos = 0.999956676946448443553574619906976478926848692873900859324;', // 3.0 / ( 16.0 * pi )
94226
- 'const float THREE_OVER_SIXTEENPI = 0.05968310365946075;', // 1.0 / ( 4.0 * pi )
94227
- 'const float ONE_OVER_FOURPI = 0.07957747154594767;', 'float rayleighPhase( float cosTheta ) {', ' return THREE_OVER_SIXTEENPI * ( 1.0 + pow( cosTheta, 2.0 ) );', '}', 'float hgPhase( float cosTheta, float g ) {', ' float g2 = pow( g, 2.0 );', ' float inverse = 1.0 / pow( 1.0 - 2.0 * g * cosTheta + g2, 1.5 );', ' return ONE_OVER_FOURPI * ( ( 1.0 - g2 ) * inverse );', '}', // Filmic ToneMapping http://filmicgames.com/archives/75
94228
- 'const float A = 0.15;', 'const float B = 0.50;', 'const float C = 0.10;', 'const float D = 0.20;', 'const float E = 0.02;', 'const float F = 0.30;', 'const float whiteScale = 1.0748724675633854;', // 1.0 / Uncharted2Tonemap(1000.0)
94229
- 'vec3 Uncharted2Tonemap( vec3 x ) {', ' return ( ( x * ( A * x + C * B ) + D * E ) / ( x * ( A * x + B ) + D * F ) ) - E / F;', '}', 'void main() {', // optical length
94262
+ "const float rayleighZenithLength = 8.4E3;", "const float mieZenithLength = 1.25E3;", "const vec3 up = vec3( 0.0, 1.0, 0.0 );", // 66 arc seconds -> degrees, and the cosine of that
94263
+ "const float sunAngularDiameterCos = 0.999956676946448443553574619906976478926848692873900859324;", // 3.0 / ( 16.0 * pi )
94264
+ "const float THREE_OVER_SIXTEENPI = 0.05968310365946075;", // 1.0 / ( 4.0 * pi )
94265
+ "const float ONE_OVER_FOURPI = 0.07957747154594767;", "float rayleighPhase( float cosTheta ) {", " return THREE_OVER_SIXTEENPI * ( 1.0 + pow( cosTheta, 2.0 ) );", "}", "float hgPhase( float cosTheta, float g ) {", " float g2 = pow( g, 2.0 );", " float inverse = 1.0 / pow( 1.0 - 2.0 * g * cosTheta + g2, 1.5 );", " return ONE_OVER_FOURPI * ( ( 1.0 - g2 ) * inverse );", "}", // Filmic ToneMapping http://filmicgames.com/archives/75
94266
+ "const float A = 0.15;", "const float B = 0.50;", "const float C = 0.10;", "const float D = 0.20;", "const float E = 0.02;", "const float F = 0.30;", "const float whiteScale = 1.0748724675633854;", // 1.0 / Uncharted2Tonemap(1000.0)
94267
+ "vec3 Uncharted2Tonemap( vec3 x ) {", " return ( ( x * ( A * x + C * B ) + D * E ) / ( x * ( A * x + B ) + D * F ) ) - E / F;", "}", "void main() {", // optical length
94230
94268
  // cutoff angle at 90 to avoid singularity in next formula.
94231
- ' float zenithAngle = acos( max( 0.0, dot( up, normalize( vWorldPosition - cameraPos ) ) ) );', ' float inverse = 1.0 / ( cos( zenithAngle ) + 0.15 * pow( 93.885 - ( ( zenithAngle * 180.0 ) / pi ), -1.253 ) );', ' float sR = rayleighZenithLength * inverse;', ' float sM = mieZenithLength * inverse;', // combined extinction factor
94232
- ' vec3 Fex = exp( -( vBetaR * sR + vBetaM * sM ) );', // in scattering
94233
- ' float cosTheta = dot( normalize( vWorldPosition - cameraPos ), vSunDirection );', ' float rPhase = rayleighPhase( cosTheta * 0.5 + 0.5 );', ' vec3 betaRTheta = vBetaR * rPhase;', ' float mPhase = hgPhase( cosTheta, mieDirectionalG );', ' vec3 betaMTheta = vBetaM * mPhase;', ' vec3 Lin = pow( vSunE * ( ( betaRTheta + betaMTheta ) / ( vBetaR + vBetaM ) ) * ( 1.0 - Fex ), vec3( 1.5 ) );', ' Lin *= mix( vec3( 1.0 ), pow( vSunE * ( ( betaRTheta + betaMTheta ) / ( vBetaR + vBetaM ) ) * Fex, vec3( 1.0 / 2.0 ) ), clamp( pow( 1.0 - dot( up, vSunDirection ), 5.0 ), 0.0, 1.0 ) );', // nightsky
94234
- ' vec3 direction = normalize( vWorldPosition - cameraPos );', ' float theta = acos( direction.y ); // elevation --> y-axis, [-pi/2, pi/2]', ' float phi = atan( direction.z, direction.x ); // azimuth --> x-axis [-pi/2, pi/2]', ' vec2 uv = vec2( phi, theta ) / vec2( 2.0 * pi, pi ) + vec2( 0.5, 0.0 );', ' vec3 L0 = vec3( 0.1 ) * Fex;', // composition + solar disc
94235
- ' float sundisk = smoothstep( sunAngularDiameterCos, sunAngularDiameterCos + 0.00002, cosTheta );', ' L0 += ( vSunE * 19000.0 * Fex ) * sundisk;', ' vec3 texColor = ( Lin + L0 ) * 0.04 + vec3( 0.0, 0.0003, 0.00075 );', ' vec3 curr = Uncharted2Tonemap( ( log2( 2.0 / pow( luminance, 4.0 ) ) ) * texColor );', ' vec3 color = curr * whiteScale;', ' vec3 retColor = pow( color, vec3( 1.0 / ( 1.2 + ( 1.2 * vSunfade ) ) ) );', ' gl_FragColor = vec4( retColor, 1.0 );', '}'].join('\n');
94269
+ " float zenithAngle = acos( max( 0.0, dot( up, normalize( vWorldPosition - cameraPos ) ) ) );", " float inverse = 1.0 / ( cos( zenithAngle ) + 0.15 * pow( 93.885 - ( ( zenithAngle * 180.0 ) / pi ), -1.253 ) );", " float sR = rayleighZenithLength * inverse;", " float sM = mieZenithLength * inverse;", // combined extinction factor
94270
+ " vec3 Fex = exp( -( vBetaR * sR + vBetaM * sM ) );", // in scattering
94271
+ " float cosTheta = dot( normalize( vWorldPosition - cameraPos ), vSunDirection );", " float rPhase = rayleighPhase( cosTheta * 0.5 + 0.5 );", " vec3 betaRTheta = vBetaR * rPhase;", " float mPhase = hgPhase( cosTheta, mieDirectionalG );", " vec3 betaMTheta = vBetaM * mPhase;", " vec3 Lin = pow( vSunE * ( ( betaRTheta + betaMTheta ) / ( vBetaR + vBetaM ) ) * ( 1.0 - Fex ), vec3( 1.5 ) );", " Lin *= mix( vec3( 1.0 ), pow( vSunE * ( ( betaRTheta + betaMTheta ) / ( vBetaR + vBetaM ) ) * Fex, vec3( 1.0 / 2.0 ) ), clamp( pow( 1.0 - dot( up, vSunDirection ), 5.0 ), 0.0, 1.0 ) );", // nightsky
94272
+ " vec3 direction = normalize( vWorldPosition - cameraPos );", " float theta = acos( direction.y ); // elevation --> y-axis, [-pi/2, pi/2]", " float phi = atan( direction.z, direction.x ); // azimuth --> x-axis [-pi/2, pi/2]", " vec2 uv = vec2( phi, theta ) / vec2( 2.0 * pi, pi ) + vec2( 0.5, 0.0 );", " vec3 L0 = vec3( 0.1 ) * Fex;", // composition + solar disc
94273
+ " float sundisk = smoothstep( sunAngularDiameterCos, sunAngularDiameterCos + 0.00002, cosTheta );", " L0 += ( vSunE * 19000.0 * Fex ) * sundisk;", " vec3 texColor = ( Lin + L0 ) * 0.04 + vec3( 0.0, 0.0003, 0.00075 );", " vec3 curr = Uncharted2Tonemap( ( log2( 2.0 / pow( luminance, 4.0 ) ) ) * texColor );", " vec3 color = curr * whiteScale;", " vec3 retColor = pow( color, vec3( 1.0 / ( 1.2 + ( 1.2 * vSunfade ) ) ) );", " gl_FragColor = vec4( retColor, 1.0 );", "}"].join("\n");
94236
94274
  }
94237
94275
  }]);
94238
94276
 
@@ -94240,10 +94278,10 @@ var Water = /*#__PURE__*/function (_Element) {
94240
94278
  }();
94241
94279
  var DEFAULT_SCALE = 10000;
94242
94280
  var DEFAULT_TURBIDITY = 10;
94243
- var DEFAULT_RALEIGH = .8;
94281
+ var DEFAULT_RALEIGH = 0.8;
94244
94282
  var DEFAULT_MIE_COEFFICIENT = 0.005;
94245
- var DEFAULT_MIE_DIRECTIONAL_G = .8;
94246
- var DEFAULT_SUN_INCLINATION = .49;
94283
+ var DEFAULT_MIE_DIRECTIONAL_G = 0.8;
94284
+ var DEFAULT_SUN_INCLINATION = 0.49;
94247
94285
  var DEFAULT_SUN_AZIMUTH = 0.205;
94248
94286
  var DEFAULT_SUN_DISTANCE = 100;
94249
94287
 
@@ -94463,4 +94501,4 @@ var Shaders$1 = new Shaders();var Shader = function Shader(name, attributes, uni
94463
94501
  } else {
94464
94502
  this.instance = this.shader.instance;
94465
94503
  }
94466
- };var constants = _objectSpread2$1(_objectSpread2$1(_objectSpread2$1({}, lib_constants), light_contants), material_constants);export{AUDIO_RAMPS,AmbientLight,AmbientSound,Atmosphere,Audio$1 as Audio,Axes,BUILTIN,BaseScript,Box,Camera,Color,Cone,Config$1 as Config,Controls$1 as Controls,Cube,CurveLine,Cylinder,DirectionalSound,ENTITY_EVENTS,ENTITY_TYPES,Element$1 as Element,Entity,EventDispatcher,FEATURES,Features$1 as Features,GameRunner$1 as GameRunner,Grid,HelperSprite,HemisphereLight,INPUT_EVENTS,Images$1 as Images,Input$1 as Input,Label,LabelComponent,Level,Lights$1 as Lights,Line,Mirror,Models$1 as Models,Ocean,PALETTES,PARTICLES,constants$1 as PHYSICS_CONSTANTS,PHYSICS_EVENTS,ParticleEmitter,ParticleEmitterGroup,Particles$1 as Particles,index$1 as Partykals,Physics$1 as Physics,Plane,PointLight,PostProcessing$1 as PostProcessing,Proton,ProtonParticleEmitter,Provider,Router$1 as Router,Scene$1 as Scene,Scripts$1 as Scripts,Shader,Sky,Skybox,Sound,Sphere,SpotLight,Sprite,Stats$1 as Stats,SunLight,three_module as THREE,Universe$1 as Universe,Vector3$1 as Vector3,Water,author,connect,constants,createElement,easing,functions,hitbox as hitboxUtils,index_esm as inferno,math,utils as physicsUtils,index$2 as rxjs,index as store,strings,uuid$1 as uuid,workers,index$3 as xstate};
94504
+ };var constants = _objectSpread2$1(_objectSpread2$1(_objectSpread2$1(_objectSpread2$1({}, lib_constants), light_contants), material_constants), controls_contants);export{AUDIO_RAMPS,AmbientLight,AmbientSound,Atmosphere,Audio$1 as Audio,Axes,BUILTIN,BaseScript,Box,CONTROL_EVENTS,Camera,Color,Cone,Config$1 as Config,Controls$1 as Controls,Cube,CurveLine,Cylinder,DirectionalSound,ENTITY_EVENTS,ENTITY_TYPES,Element$1 as Element,Entity,EventDispatcher,FEATURES,Features$1 as Features,GameRunner$1 as GameRunner,Grid,HelperSprite,HemisphereLight,INPUT_EVENTS,Images$1 as Images,Input$1 as Input,Label,LabelComponent,Level,Lights$1 as Lights,Line,Mirror,Models$1 as Models,Ocean,PALETTES,PARTICLES,constants$1 as PHYSICS_CONSTANTS,PHYSICS_EVENTS,ParticleEmitter,ParticleEmitterGroup,Particles$1 as Particles,index$1 as Partykals,Physics$1 as Physics,Plane,PointLight,PostProcessing$1 as PostProcessing,Proton,ProtonParticleEmitter,Provider,Router$1 as Router,Scene$1 as Scene,Scripts$1 as Scripts,Shader,Sky,Skybox,Sound,Sphere,SpotLight,Sprite,Stats$1 as Stats,SunLight,three_module as THREE,THREEJS_CONTROL_EVENTS,Universe$1 as Universe,Vector3$1 as Vector3,Water,author,connect,constants,createElement,easing,functions,hitbox as hitboxUtils,index_esm as inferno,math,utils as physicsUtils,index$2 as rxjs,index as store,strings,uuid$1 as uuid,workers,index$3 as xstate};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "mage-engine",
3
- "version": "3.23.9",
3
+ "version": "3.23.11",
4
4
  "description": "A WebGL Javascript Game Engine, built on top of THREE.js and many other libraries.",
5
5
  "main": "dist/mage.js",
6
6
  "author": {