mage-engine 3.22.3 → 3.22.4

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 +378 -125
  2. package/package.json +1 -1
package/dist/mage.js CHANGED
@@ -57763,7 +57763,7 @@ function applyMiddleware() {
57763
57763
 
57764
57764
  var thunk = createThunkMiddleware();
57765
57765
  thunk.withExtraArgument = createThunkMiddleware;var name = "mage-engine";
57766
- var version$1 = "3.22.3";
57766
+ var version$1 = "3.22.4";
57767
57767
  var description = "A WebGL Javascript Game Engine, built on top of THREE.js and many other libraries.";
57768
57768
  var main = "dist/mage.js";
57769
57769
  var author$1 = {
@@ -60945,7 +60945,11 @@ var tweenTo = function tweenTo(origin, target) {
60945
60945
  tags: this.getTags(),
60946
60946
  name: this.getName(),
60947
60947
  uuid: this.uuid(),
60948
- data: this.getData()
60948
+ data: this.getData(),
60949
+ shadow: {
60950
+ cast: this.getBody().castShadow,
60951
+ receive: this.getBody().receiveShadow
60952
+ }
60949
60953
  };
60950
60954
  }
60951
60955
  }
@@ -82994,7 +82998,7 @@ var MeshLoader$1 = new MeshLoader();var Light = /*#__PURE__*/function (_Entity)
82994
82998
  targetSprite.setDepthTest(false);
82995
82999
  targetSprite.setDepthWrite(false);
82996
83000
  targetSprite.setSerializable(false);
82997
- targetSprite.setPosition(_this.getTargetPosition());
83001
+ targetSprite.setPosition(_this.getTarget().getPosition());
82998
83002
  targetSprite.addTags([TAGS.LIGHTS.HELPER, TAGS.LIGHTS.TARGET, name]);
82999
83003
  targetSprite.setHelperTarget(_assertThisInitialized(_this));
83000
83004
  targetSprite.getBody().add(_this.getBody().target);
@@ -83111,6 +83115,17 @@ var MeshLoader$1 = new MeshLoader();var Light = /*#__PURE__*/function (_Entity)
83111
83115
  value: function getColor() {
83112
83116
  return this.body.color;
83113
83117
  }
83118
+ }, {
83119
+ key: "setCastShadow",
83120
+ value: function setCastShadow(castShadow) {
83121
+ this.castShadow = castShadow;
83122
+ this.getBody().castShadow = castShadow;
83123
+ }
83124
+ }, {
83125
+ key: "getCastShadow",
83126
+ value: function getCastShadow() {
83127
+ return this.castShadow;
83128
+ }
83114
83129
  }, {
83115
83130
  key: "dim",
83116
83131
  value: function dim() {
@@ -83166,7 +83181,8 @@ var MeshLoader$1 = new MeshLoader();var Light = /*#__PURE__*/function (_Entity)
83166
83181
  type: this.getEntityType(),
83167
83182
  color: this.getColor(),
83168
83183
  intensity: this.getIntensity(),
83169
- name: this.getName()
83184
+ name: this.getName(),
83185
+ castShadow: this.getCastShadow()
83170
83186
  });
83171
83187
  }
83172
83188
  }]);
@@ -83208,7 +83224,29 @@ var SunLight = /*#__PURE__*/function (_Light) {
83208
83224
  intensity: intensity,
83209
83225
  name: name
83210
83226
  });
83227
+
83228
+ _defineProperty$1(_assertThisInitialized(_this), "setShadowCameraNearFar", function () {
83229
+ var near = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : DEFAULT_NEAR$2;
83230
+ var far = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : DEFAULT_FAR$2;
83231
+ _this.near = near;
83232
+ _this.far = far;
83233
+ var d = _this.far / 2;
83234
+ _this.getBody().shadow.camera.left = -d;
83235
+ _this.getBody().shadow.camera.right = d;
83236
+ _this.getBody().shadow.camera.top = d;
83237
+ _this.getBody().shadow.camera.bottom = -d;
83238
+ _this.getBody().shadow.camera.near = near;
83239
+ _this.getBody().shadow.camera.far = far;
83240
+ });
83241
+
83242
+ _defineProperty$1(_assertThisInitialized(_this), "setBias", function () {
83243
+ var bias = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : DEFAULT_BIAS$2;
83244
+ _this.bias = bias;
83245
+ _this.getBody().shadow.bias = bias;
83246
+ });
83247
+
83211
83248
  _this.options = options;
83249
+ _this.target = ORIGIN;
83212
83250
 
83213
83251
  _this.setLight({
83214
83252
  color: color,
@@ -83248,51 +83286,77 @@ var SunLight = /*#__PURE__*/function (_Light) {
83248
83286
  }, {
83249
83287
  key: "postLightCreation",
83250
83288
  value: function postLightCreation() {
83251
- var _this$options = this.options,
83252
- _this$options$positio = _this$options.position,
83253
- position = _this$options$positio === void 0 ? DEFAULT_POSITION$3 : _this$options$positio,
83254
- target = _this$options.target;
83289
+ var _this$options$positio = this.options.position,
83290
+ position = _this$options$positio === void 0 ? DEFAULT_POSITION$3 : _this$options$positio;
83291
+ var emptyTarget = new Element$1({
83292
+ body: new Object3D()
83293
+ });
83255
83294
  this.setPosition(position);
83256
-
83257
- if (target) {
83258
- this.setTarget(target);
83259
- }
83260
-
83295
+ this.setTarget(emptyTarget);
83261
83296
  this.setLightShadows();
83262
83297
  this.addToScene();
83263
83298
  }
83264
83299
  }, {
83265
83300
  key: "setLightShadows",
83266
83301
  value: function setLightShadows() {
83267
- var _this$options2 = this.options,
83268
- _this$options2$near = _this$options2.near,
83269
- near = _this$options2$near === void 0 ? DEFAULT_NEAR$2 : _this$options2$near,
83270
- _this$options2$far = _this$options2.far,
83271
- far = _this$options2$far === void 0 ? DEFAULT_FAR$2 : _this$options2$far,
83272
- _this$options2$mapSiz = _this$options2.mapSize,
83273
- mapSize = _this$options2$mapSiz === void 0 ? DEFAULT_MAP_SIZE$2 : _this$options2$mapSiz,
83274
- _this$options2$bias = _this$options2.bias,
83275
- bias = _this$options2$bias === void 0 ? DEFAULT_BIAS$2 : _this$options2$bias,
83276
- _this$options2$fov = _this$options2.fov,
83277
- fov = _this$options2$fov === void 0 ? DEFAULT_FOV : _this$options2$fov,
83278
- _this$options2$castSh = _this$options2.castShadow,
83279
- castShadow = _this$options2$castSh === void 0 ? true : _this$options2$castSh;
83280
-
83281
- if (Config$1.lights().shadows && castShadow) {
83282
- this.body.castShadow = true;
83283
- var d = far / 1.5;
83284
- this.body.shadow.mapSize.height = mapSize;
83285
- this.body.shadow.mapSize.width = mapSize;
83286
- this.body.shadow.camera.left = -d;
83287
- this.body.shadow.camera.right = d;
83288
- this.body.shadow.camera.top = d;
83289
- this.body.shadow.camera.bottom = -d;
83290
- this.body.shadow.camera.near = near;
83291
- this.body.shadow.camera.far = far;
83292
- this.body.shadow.camera.fov = fov;
83293
- this.body.shadow.bias = bias;
83302
+ var _this$options = this.options,
83303
+ _this$options$near = _this$options.near,
83304
+ near = _this$options$near === void 0 ? DEFAULT_NEAR$2 : _this$options$near,
83305
+ _this$options$far = _this$options.far,
83306
+ far = _this$options$far === void 0 ? DEFAULT_FAR$2 : _this$options$far,
83307
+ _this$options$mapSize = _this$options.mapSize,
83308
+ mapSize = _this$options$mapSize === void 0 ? DEFAULT_MAP_SIZE$2 : _this$options$mapSize,
83309
+ _this$options$bias = _this$options.bias,
83310
+ bias = _this$options$bias === void 0 ? DEFAULT_BIAS$2 : _this$options$bias,
83311
+ _this$options$fov = _this$options.fov,
83312
+ fov = _this$options$fov === void 0 ? DEFAULT_FOV : _this$options$fov;
83313
+
83314
+ if (Config$1.lights().shadows) {
83315
+ this.setCastShadow(true);
83316
+ this.setMapSize(mapSize);
83317
+ this.setShadowCameraNearFar(near, far);
83318
+ this.setBias(bias);
83319
+ this.setShadowCameraFov(fov);
83294
83320
  }
83295
83321
  }
83322
+ }, {
83323
+ key: "getShadowCameraNearFar",
83324
+ value: function getShadowCameraNearFar() {
83325
+ return {
83326
+ near: this.near,
83327
+ far: this.far
83328
+ };
83329
+ }
83330
+ }, {
83331
+ key: "setShadowCameraFov",
83332
+ value: function setShadowCameraFov() {
83333
+ var fov = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : DEFAULT_FOV;
83334
+ this.fov = fov;
83335
+ this.getBody().shadow.camera.fov = fov;
83336
+ }
83337
+ }, {
83338
+ key: "getShadowCameraFov",
83339
+ value: function getShadowCameraFov() {
83340
+ return this.fov;
83341
+ }
83342
+ }, {
83343
+ key: "setMapSize",
83344
+ value: function setMapSize() {
83345
+ var mapSize = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : DEFAULT_MAP_SIZE$2;
83346
+ this.mapSize = mapSize;
83347
+ this.getBody().shadow.mapSize.height = mapSize;
83348
+ this.getBody().shadow.mapSize.width = mapSize;
83349
+ }
83350
+ }, {
83351
+ key: "getMapSize",
83352
+ value: function getMapSize() {
83353
+ return this.mapSize;
83354
+ }
83355
+ }, {
83356
+ key: "getBias",
83357
+ value: function getBias() {
83358
+ return this.bias;
83359
+ }
83296
83360
  }, {
83297
83361
  key: "hasTarget",
83298
83362
  value: function hasTarget() {
@@ -83301,14 +83365,13 @@ var SunLight = /*#__PURE__*/function (_Light) {
83301
83365
  }, {
83302
83366
  key: "setTarget",
83303
83367
  value: function setTarget(target) {
83304
- if (target.position) {
83305
- this.body.target = target;
83306
- Scene$1.add(this.body.target, null, false);
83307
- }
83368
+ this.target = target;
83369
+ this.getBody().target = target.getBody();
83370
+ Scene$1.add(this.getBody().target, null, false);
83308
83371
  }
83309
83372
  }, {
83310
- key: "getTargetPosition",
83311
- value: function getTargetPosition() {
83373
+ key: "getTarget",
83374
+ value: function getTarget() {
83312
83375
  return this.target;
83313
83376
  }
83314
83377
  }, {
@@ -83316,7 +83379,7 @@ var SunLight = /*#__PURE__*/function (_Light) {
83316
83379
  value: function addHelpers() {
83317
83380
  var _ref2 = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {},
83318
83381
  _ref2$holderName = _ref2.holderName,
83319
- holderName = _ref2$holderName === void 0 ? "sunlightHelper" : _ref2$holderName,
83382
+ holderName = _ref2$holderName === void 0 ? "sunlightholder" : _ref2$holderName,
83320
83383
  _ref2$holderSize = _ref2.holderSize,
83321
83384
  holderSize = _ref2$holderSize === void 0 ? 0.05 : _ref2$holderSize,
83322
83385
  _ref2$targetHolderNam = _ref2.targetHolderName,
@@ -83352,7 +83415,16 @@ var SunLight = /*#__PURE__*/function (_Light) {
83352
83415
  key: "toJSON",
83353
83416
  value: function toJSON() {
83354
83417
  return _objectSpread2$1(_objectSpread2$1({}, _get(_getPrototypeOf(SunLight.prototype), "toJSON", this).call(this)), {}, {
83355
- target: this.getTargetPosition()
83418
+ target: this.getTarget(),
83419
+ distance: this.getDistance(),
83420
+ decay: this.getDecay(),
83421
+ bias: this.getBias(),
83422
+ mapSize: this.getMapSize(),
83423
+ shadowCamera: _objectSpread2$1(_objectSpread2$1({}, this.getShadowCameraNearFar()), {}, {
83424
+ fov: this.setShadowCameraFov()
83425
+ }),
83426
+ penumbra: this.getPenumbra(),
83427
+ angle: this.getAngle()
83356
83428
  });
83357
83429
  }
83358
83430
  }]);
@@ -83500,6 +83572,27 @@ var PointLight = /*#__PURE__*/function (_Light) {
83500
83572
  intensity: intensity,
83501
83573
  name: name
83502
83574
  });
83575
+
83576
+ _defineProperty$1(_assertThisInitialized(_this), "setShadowCameraNearFar", function () {
83577
+ var near = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : DEFAULT_NEAR$1;
83578
+ var far = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : DEFAULT_FAR$1;
83579
+ _this.near = near;
83580
+ _this.far = far;
83581
+ var d = _this.far / 2;
83582
+ _this.getBody().shadow.camera.left = -d;
83583
+ _this.getBody().shadow.camera.right = d;
83584
+ _this.getBody().shadow.camera.top = d;
83585
+ _this.getBody().shadow.camera.bottom = -d;
83586
+ _this.getBody().shadow.camera.near = near;
83587
+ _this.getBody().shadow.camera.far = far;
83588
+ });
83589
+
83590
+ _defineProperty$1(_assertThisInitialized(_this), "setBias", function () {
83591
+ var bias = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : DEFAULT_BIAS$1;
83592
+ _this.bias = bias;
83593
+ _this.getBody().shadow.bias = bias;
83594
+ });
83595
+
83503
83596
  _this.options = options;
83504
83597
 
83505
83598
  _this.setLight({
@@ -83535,8 +83628,10 @@ var PointLight = /*#__PURE__*/function (_Light) {
83535
83628
  });
83536
83629
  } else {
83537
83630
  this.setBody({
83538
- body: new PointLight$1(color, intensity, distance, decay)
83631
+ body: new PointLight$1(color, intensity)
83539
83632
  });
83633
+ this.setDistance(distance);
83634
+ this.setDecay(decay);
83540
83635
  }
83541
83636
 
83542
83637
  if (this.hasBody()) {
@@ -83566,19 +83661,62 @@ var PointLight = /*#__PURE__*/function (_Light) {
83566
83661
  bias = _this$options$bias === void 0 ? DEFAULT_BIAS$1 : _this$options$bias;
83567
83662
 
83568
83663
  if (Config$1.lights().shadows) {
83569
- this.body.castShadow = true;
83570
- var d = far / 2;
83571
- this.body.shadow.mapSize.height = mapSize;
83572
- this.body.shadow.mapSize.width = mapSize;
83573
- this.body.shadow.camera.left = -d;
83574
- this.body.shadow.camera.right = d;
83575
- this.body.shadow.camera.top = d;
83576
- this.body.shadow.camera.bottom = -d;
83577
- this.body.shadow.camera.near = near;
83578
- this.body.shadow.camera.far = far;
83579
- this.body.shadow.bias = bias;
83664
+ this.setCastShadow(true);
83665
+ this.setMapSize(mapSize);
83666
+ this.setShadowCameraNearFar(near, far);
83667
+ this.setBias(bias);
83580
83668
  }
83581
83669
  }
83670
+ }, {
83671
+ key: "setDistance",
83672
+ value: function setDistance() {
83673
+ var distance = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : DEFAULT_DISTANCE;
83674
+ this.distance = distance;
83675
+ this.getBody().distance = distance;
83676
+ }
83677
+ }, {
83678
+ key: "getDistance",
83679
+ value: function getDistance() {
83680
+ return this.distance;
83681
+ }
83682
+ }, {
83683
+ key: "setDecay",
83684
+ value: function setDecay() {
83685
+ var decay = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : DEFAULT_DECAY;
83686
+ this.decay = decay;
83687
+ this.getBody().decay = decay;
83688
+ }
83689
+ }, {
83690
+ key: "getDecay",
83691
+ value: function getDecay() {
83692
+ return this.decay;
83693
+ }
83694
+ }, {
83695
+ key: "getShadowCameraNearFar",
83696
+ value: function getShadowCameraNearFar() {
83697
+ return {
83698
+ near: this.near,
83699
+ far: this.far
83700
+ };
83701
+ }
83702
+ }, {
83703
+ key: "setMapSize",
83704
+ value: function setMapSize() {
83705
+ var mapSize = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : DEFAULT_MAP_SIZE$1;
83706
+ this.mapSize = mapSize;
83707
+ this.getBody().shadow.mapSize.height = mapSize;
83708
+ this.getBody().shadow.mapSize.width = mapSize;
83709
+ }
83710
+ }, {
83711
+ key: "getMapSize",
83712
+ value: function getMapSize() {
83713
+ return this.mapSize;
83714
+ }
83715
+ }, {
83716
+ key: "getBias",
83717
+ value: function getBias() {
83718
+ return this.bias;
83719
+ }
83582
83720
  }, {
83583
83721
  key: "addHelpers",
83584
83722
  value: function addHelpers() {
@@ -83615,7 +83753,11 @@ var PointLight = /*#__PURE__*/function (_Light) {
83615
83753
  key: "toJSON",
83616
83754
  value: function toJSON() {
83617
83755
  return _objectSpread2$1(_objectSpread2$1({}, _get(_getPrototypeOf(PointLight.prototype), "toJSON", this).call(this)), {}, {
83618
- distance: this.distance
83756
+ distance: this.getDistance(),
83757
+ decay: this.getDecay(),
83758
+ bias: this.getBias(),
83759
+ mapSize: this.getMapSize(),
83760
+ shadowCamera: this.getShadowCameraNearFar()
83619
83761
  });
83620
83762
  }
83621
83763
  }]);
@@ -91430,11 +91572,6 @@ var DEFAULT_POSITION = {
91430
91572
  y: 0,
91431
91573
  z: 0
91432
91574
  };
91433
- var DEFAULT_TARGET_POSITION = {
91434
- x: 0,
91435
- y: 0,
91436
- z: 0
91437
- };
91438
91575
  var DEFAULT_INTENSITY$1 = 0.5;
91439
91576
  var DEFAULT_MAP_SIZE = 2048;
91440
91577
  var DEFAULT_BIAS = -0.0001;
@@ -91475,6 +91612,27 @@ var SpotLight = /*#__PURE__*/function (_Light) {
91475
91612
  intensity: intensity,
91476
91613
  name: name
91477
91614
  });
91615
+
91616
+ _defineProperty$1(_assertThisInitialized(_this), "setShadowCameraNearFar", function () {
91617
+ var near = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : DEFAULT_NEAR;
91618
+ var far = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : DEFAULT_FAR;
91619
+ _this.near = near;
91620
+ _this.far = far;
91621
+ var d = _this.far / 2;
91622
+ _this.getBody().shadow.camera.left = -d;
91623
+ _this.getBody().shadow.camera.right = d;
91624
+ _this.getBody().shadow.camera.top = d;
91625
+ _this.getBody().shadow.camera.bottom = -d;
91626
+ _this.getBody().shadow.camera.near = near;
91627
+ _this.getBody().shadow.camera.far = far;
91628
+ });
91629
+
91630
+ _defineProperty$1(_assertThisInitialized(_this), "setBias", function () {
91631
+ var bias = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : DEFAULT_BIAS;
91632
+ _this.bias = bias;
91633
+ _this.getBody().shadow.bias = bias;
91634
+ });
91635
+
91478
91636
  _this.options = options;
91479
91637
 
91480
91638
  _this.setLight({
@@ -91517,8 +91675,12 @@ var SpotLight = /*#__PURE__*/function (_Light) {
91517
91675
  });
91518
91676
  } else {
91519
91677
  this.setBody({
91520
- body: new SpotLight$1(color, intensity, distance, angle, penumbra, decay)
91678
+ body: new SpotLight$1(color, intensity)
91521
91679
  });
91680
+ this.setDistance(distance);
91681
+ this.setAngle(angle);
91682
+ this.setPenumbra(penumbra);
91683
+ this.setDecay(decay);
91522
91684
  }
91523
91685
 
91524
91686
  if (this.hasBody()) {
@@ -91528,60 +91690,120 @@ var SpotLight = /*#__PURE__*/function (_Light) {
91528
91690
  }, {
91529
91691
  key: "postLightCreation",
91530
91692
  value: function postLightCreation() {
91531
- var _this$options = this.options,
91532
- _this$options$positio = _this$options.position,
91533
- position = _this$options$positio === void 0 ? DEFAULT_POSITION : _this$options$positio,
91534
- _this$options$target = _this$options.target,
91535
- target = _this$options$target === void 0 ? DEFAULT_TARGET_POSITION : _this$options$target;
91693
+ var _this$options$positio = this.options.position,
91694
+ position = _this$options$positio === void 0 ? DEFAULT_POSITION : _this$options$positio;
91695
+ var emptyTarget = new Element$1({
91696
+ body: new Object3D()
91697
+ });
91536
91698
  this.setPosition(position);
91537
- this.setTargetPosition(target);
91699
+ this.setTarget(emptyTarget);
91538
91700
  this.setLightShadows();
91539
91701
  this.addToScene();
91540
91702
  }
91541
91703
  }, {
91542
91704
  key: "setLightShadows",
91543
91705
  value: function setLightShadows() {
91544
- var _this$options2 = this.options,
91545
- _this$options2$near = _this$options2.near,
91546
- near = _this$options2$near === void 0 ? DEFAULT_NEAR : _this$options2$near,
91547
- _this$options2$far = _this$options2.far,
91548
- far = _this$options2$far === void 0 ? DEFAULT_FAR : _this$options2$far,
91549
- _this$options2$mapSiz = _this$options2.mapSize,
91550
- mapSize = _this$options2$mapSiz === void 0 ? DEFAULT_MAP_SIZE : _this$options2$mapSiz,
91551
- _this$options2$bias = _this$options2.bias,
91552
- bias = _this$options2$bias === void 0 ? DEFAULT_BIAS : _this$options2$bias;
91706
+ var _this$options = this.options,
91707
+ _this$options$near = _this$options.near,
91708
+ near = _this$options$near === void 0 ? DEFAULT_NEAR : _this$options$near,
91709
+ _this$options$far = _this$options.far,
91710
+ far = _this$options$far === void 0 ? DEFAULT_FAR : _this$options$far,
91711
+ _this$options$mapSize = _this$options.mapSize,
91712
+ mapSize = _this$options$mapSize === void 0 ? DEFAULT_MAP_SIZE : _this$options$mapSize,
91713
+ _this$options$bias = _this$options.bias,
91714
+ bias = _this$options$bias === void 0 ? DEFAULT_BIAS : _this$options$bias;
91553
91715
 
91554
91716
  if (Config$1.lights().shadows) {
91555
- this.body.castShadow = true;
91556
- var d = far / 2;
91557
- this.body.shadow.mapSize.height = mapSize;
91558
- this.body.shadow.mapSize.width = mapSize;
91559
- this.body.shadow.camera.left = -d;
91560
- this.body.shadow.camera.right = d;
91561
- this.body.shadow.camera.top = d;
91562
- this.body.shadow.camera.bottom = -d;
91563
- this.body.shadow.camera.near = near;
91564
- this.body.shadow.camera.far = far;
91565
- this.body.shadow.bias = bias;
91566
- }
91567
- }
91568
- }, {
91569
- key: "setTargetPosition",
91570
- value: function setTargetPosition() {
91571
- var position = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
91572
- this.target = _objectSpread2$1(_objectSpread2$1({}, this.target), position);
91573
- var _this$target = this.target,
91574
- _this$target$x = _this$target.x,
91575
- x = _this$target$x === void 0 ? 0 : _this$target$x,
91576
- _this$target$y = _this$target.y,
91577
- y = _this$target$y === void 0 ? 0 : _this$target$y,
91578
- _this$target$z = _this$target.z,
91579
- z = _this$target$z === void 0 ? 0 : _this$target$z;
91580
- this.body.target.position.set(x, y, z);
91581
- }
91582
- }, {
91583
- key: "getTargetPosition",
91584
- value: function getTargetPosition() {
91717
+ this.setCastShadow(true);
91718
+ this.setMapSize(mapSize);
91719
+ this.setShadowCameraNearFar(near, far);
91720
+ this.setBias(bias);
91721
+ }
91722
+ }
91723
+ }, {
91724
+ key: "setDistance",
91725
+ value: function setDistance() {
91726
+ var distance = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : DEFAULT_FAR;
91727
+ this.distance = distance;
91728
+ this.getBody().distance = distance;
91729
+ }
91730
+ }, {
91731
+ key: "getDistance",
91732
+ value: function getDistance() {
91733
+ return this.distance;
91734
+ }
91735
+ }, {
91736
+ key: "setAngle",
91737
+ value: function setAngle() {
91738
+ var angle = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : DEFAULT_SPOTLIGHT_ANGLE;
91739
+ this.angle = angle;
91740
+ this.getBody().angle = angle;
91741
+ }
91742
+ }, {
91743
+ key: "getAngle",
91744
+ value: function getAngle() {
91745
+ return this.angle;
91746
+ }
91747
+ }, {
91748
+ key: "setPenumbra",
91749
+ value: function setPenumbra() {
91750
+ var penumbra = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : DEFAULT_SPOTLIGHT_PENUMBRA;
91751
+ this.penumbra = penumbra;
91752
+ this.getBody().penumbra = penumbra;
91753
+ }
91754
+ }, {
91755
+ key: "getPenumbra",
91756
+ value: function getPenumbra() {
91757
+ return this.penumbra;
91758
+ }
91759
+ }, {
91760
+ key: "setDecay",
91761
+ value: function setDecay() {
91762
+ var decay = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : DEFAULT_SPOTLIGHT_DECAY;
91763
+ this.decay = decay;
91764
+ this.getBody().decay = decay;
91765
+ }
91766
+ }, {
91767
+ key: "getDecay",
91768
+ value: function getDecay() {
91769
+ return this.decay;
91770
+ }
91771
+ }, {
91772
+ key: "getShadowCameraNearFar",
91773
+ value: function getShadowCameraNearFar() {
91774
+ return {
91775
+ near: this.near,
91776
+ far: this.far
91777
+ };
91778
+ }
91779
+ }, {
91780
+ key: "setMapSize",
91781
+ value: function setMapSize() {
91782
+ var mapSize = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : DEFAULT_MAP_SIZE;
91783
+ this.mapSize = mapSize;
91784
+ this.getBody().shadow.mapSize.height = mapSize;
91785
+ this.getBody().shadow.mapSize.width = mapSize;
91786
+ }
91787
+ }, {
91788
+ key: "getMapSize",
91789
+ value: function getMapSize() {
91790
+ return this.mapSize;
91791
+ }
91792
+ }, {
91793
+ key: "getBias",
91794
+ value: function getBias() {
91795
+ return this.bias;
91796
+ }
91797
+ }, {
91798
+ key: "setTarget",
91799
+ value: function setTarget(target) {
91800
+ this.target = target;
91801
+ this.getBody().target = target.getBody();
91802
+ Scene$1.add(this.getBody().target, null, false);
91803
+ }
91804
+ }, {
91805
+ key: "getTarget",
91806
+ value: function getTarget() {
91585
91807
  return this.target;
91586
91808
  }
91587
91809
  }, {
@@ -91630,7 +91852,14 @@ var SpotLight = /*#__PURE__*/function (_Light) {
91630
91852
  key: "toJSON",
91631
91853
  value: function toJSON() {
91632
91854
  return _objectSpread2$1(_objectSpread2$1({}, _get(_getPrototypeOf(SpotLight.prototype), "toJSON", this).call(this)), {}, {
91633
- target: this.getTargetPosition()
91855
+ target: this.getTarget(),
91856
+ distance: this.getDistance(),
91857
+ decay: this.getDecay(),
91858
+ bias: this.getBias(),
91859
+ mapSize: this.getMapSize(),
91860
+ shadowCamera: this.getShadowCameraNearFar(),
91861
+ penumbra: this.getPenumbra(),
91862
+ angle: this.getAngle()
91634
91863
  });
91635
91864
  }
91636
91865
  }]);
@@ -91667,6 +91896,23 @@ var HemisphereLight = /*#__PURE__*/function (_Light) {
91667
91896
  intensity: intensity,
91668
91897
  name: name
91669
91898
  });
91899
+
91900
+ _defineProperty$1(_assertThisInitialized(_this), "setColor", function () {
91901
+ var _ref = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {},
91902
+ sky = _ref.sky,
91903
+ ground = _ref.ground;
91904
+
91905
+ _this.getBody().color = sky;
91906
+ _this.getBody().groundColor = ground;
91907
+ });
91908
+
91909
+ _defineProperty$1(_assertThisInitialized(_this), "getColor", function () {
91910
+ return {
91911
+ sky: _this.getBody().color,
91912
+ ground: _this.getBody().groundColor
91913
+ };
91914
+ });
91915
+
91670
91916
  _this.options = options;
91671
91917
 
91672
91918
  _this.setLight({
@@ -91683,15 +91929,15 @@ var HemisphereLight = /*#__PURE__*/function (_Light) {
91683
91929
 
91684
91930
  _createClass(HemisphereLight, [{
91685
91931
  key: "setLight",
91686
- value: function setLight(_ref) {
91687
- var light = _ref.light,
91688
- _ref$color = _ref.color,
91689
- color = _ref$color === void 0 ? {
91932
+ value: function setLight(_ref2) {
91933
+ var light = _ref2.light,
91934
+ _ref2$color = _ref2.color,
91935
+ color = _ref2$color === void 0 ? {
91690
91936
  sky: DEFAULT_SKY_COLOR,
91691
91937
  ground: DEFAULT_GROUND_COLOR
91692
- } : _ref$color,
91693
- _ref$intensity = _ref.intensity,
91694
- intensity = _ref$intensity === void 0 ? DEFAULT_INTENSITY : _ref$intensity;
91938
+ } : _ref2$color,
91939
+ _ref2$intensity = _ref2.intensity,
91940
+ intensity = _ref2$intensity === void 0 ? DEFAULT_INTENSITY : _ref2$intensity;
91695
91941
 
91696
91942
  if (light) {
91697
91943
  this.setBody({
@@ -91714,11 +91960,11 @@ var HemisphereLight = /*#__PURE__*/function (_Light) {
91714
91960
  }, {
91715
91961
  key: "addHelpers",
91716
91962
  value: function addHelpers() {
91717
- var _ref2 = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {},
91718
- _ref2$holderName = _ref2.holderName,
91719
- holderName = _ref2$holderName === void 0 ? "hemispherelightholder" : _ref2$holderName,
91720
- _ref2$holderSize = _ref2.holderSize,
91721
- holderSize = _ref2$holderSize === void 0 ? 0.05 : _ref2$holderSize;
91963
+ var _ref3 = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {},
91964
+ _ref3$holderName = _ref3.holderName,
91965
+ holderName = _ref3$holderName === void 0 ? "hemispherelightholder" : _ref3$holderName,
91966
+ _ref3$holderSize = _ref3.holderSize,
91967
+ holderSize = _ref3$holderSize === void 0 ? 0.05 : _ref3$holderSize;
91722
91968
 
91723
91969
  this.helper = new HemisphereLightHelper(this.getBody(), 2, GREEN);
91724
91970
  this.addHolder(holderName, holderSize);
@@ -91736,6 +91982,13 @@ var HemisphereLight = /*#__PURE__*/function (_Light) {
91736
91982
  });
91737
91983
  }
91738
91984
  }
91985
+ }, {
91986
+ key: "toJSON",
91987
+ value: function toJSON() {
91988
+ return _objectSpread2$1(_objectSpread2$1({}, _get(_getPrototypeOf(HemisphereLight.prototype), "toJSON", this).call(this)), {}, {
91989
+ color: this.getColor()
91990
+ });
91991
+ }
91739
91992
  }]);
91740
91993
 
91741
91994
  return HemisphereLight;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "mage-engine",
3
- "version": "3.22.3",
3
+ "version": "3.22.4",
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": {