mage-engine 3.20.0 → 3.20.1

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 +82 -69
  2. package/package.json +1 -1
package/dist/mage.js CHANGED
@@ -57411,7 +57411,7 @@ function applyMiddleware() {
57411
57411
 
57412
57412
  var thunk = createThunkMiddleware();
57413
57413
  thunk.withExtraArgument = createThunkMiddleware;var name = "mage-engine";
57414
- var version$1 = "3.20.0";
57414
+ var version$1 = "3.20.1";
57415
57415
  var description = "A WebGL Javascript Game Engine, built on top of THREE.js and many other libraries.";
57416
57416
  var main = "dist/mage.js";
57417
57417
  var author$1 = {
@@ -59638,7 +59638,44 @@ var prepareModel = function prepareModel(model) {
59638
59638
  REPEAT: 'repeat',
59639
59639
  NONE: false
59640
59640
  };
59641
- var FUNCTIONS = _objectSpread2$1({}, Between.Easing);var easing=/*#__PURE__*/Object.freeze({__proto__:null,LOOPING:LOOPING,FUNCTIONS:FUNCTIONS});var Entity = /*#__PURE__*/function (_EventDispatcher) {
59641
+ var EASING_EVENTS = {
59642
+ UPDATE: 'update',
59643
+ COMPLETE: 'complete'
59644
+ };
59645
+ var FUNCTIONS = _objectSpread2$1({}, Between.Easing);
59646
+ var tweenTo = function tweenTo(origin, target) {
59647
+ var options = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};
59648
+ return new Promise(function (resolve) {
59649
+ var time = options.time,
59650
+ _options$easing = options.easing,
59651
+ easing = _options$easing === void 0 ? FUNCTIONS.Linear.None : _options$easing,
59652
+ _options$loop = options.loop,
59653
+ loop = _options$loop === void 0 ? LOOPING.NONE : _options$loop,
59654
+ _options$onUpdate = options.onUpdate,
59655
+ onUpdate = _options$onUpdate === void 0 ? function (f) {
59656
+ return f;
59657
+ } : _options$onUpdate,
59658
+ _options$repeat = options.repeat,
59659
+ repeat = _options$repeat === void 0 ? undefined : _options$repeat;
59660
+ var tween = new Between(origin, target).time(time).easing(easing).on(EASING_EVENTS.UPDATE, onUpdate);
59661
+ var infinite = loop && !repeat;
59662
+
59663
+ var onComplete = function onComplete() {
59664
+ return resolve(tween, infinite);
59665
+ };
59666
+
59667
+ if (loop) {
59668
+ tween.loop(loop, repeat);
59669
+ }
59670
+
59671
+ if (infinite) {
59672
+ var timeToCompleteLoop = time * 2;
59673
+ setTimeout(onComplete, timeToCompleteLoop);
59674
+ } else {
59675
+ tween.on(EASING_EVENTS.COMPLETE, onComplete);
59676
+ }
59677
+ });
59678
+ };var easing=/*#__PURE__*/Object.freeze({__proto__:null,LOOPING:LOOPING,EASING_EVENTS:EASING_EVENTS,FUNCTIONS:FUNCTIONS,tweenTo:tweenTo});var Entity = /*#__PURE__*/function (_EventDispatcher) {
59642
59679
  _inherits(Entity, _EventDispatcher);
59643
59680
 
59644
59681
  var _super = _createSuper(Entity);
@@ -60292,39 +60329,31 @@ var FUNCTIONS = _objectSpread2$1({}, Between.Easing);var easing=/*#__PURE__*/Obj
60292
60329
 
60293
60330
  var scale = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : this.getScale();
60294
60331
  var time = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 250;
60295
-
60296
- var _ref9 = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {},
60297
- _ref9$easing = _ref9.easing,
60298
- easing = _ref9$easing === void 0 ? FUNCTIONS.Linear.None : _ref9$easing,
60299
- _ref9$loop = _ref9.loop,
60300
- loop = _ref9$loop === void 0 ? LOOPING.NONE : _ref9$loop;
60332
+ var options = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};
60301
60333
 
60302
60334
  var _this$getScale = this.getScale(),
60303
60335
  x = _this$getScale.x,
60304
60336
  y = _this$getScale.y,
60305
60337
  z = _this$getScale.z;
60306
60338
 
60307
- var targetScale = _objectSpread2$1({
60339
+ var target = _objectSpread2$1({
60308
60340
  x: x,
60309
60341
  y: y,
60310
60342
  z: z
60311
60343
  }, scale);
60312
60344
 
60313
- return new Promise(function (resolve) {
60314
- var between = new Between({
60315
- x: x,
60316
- y: y,
60317
- z: z
60318
- }, targetScale).time(time).easing(easing);
60319
-
60320
- if (loop) {
60321
- between.loop(loop);
60322
- }
60345
+ var onUpdate = function onUpdate(value) {
60346
+ return !_this7.isDisposed() && _this7.setScale(value);
60347
+ };
60323
60348
 
60324
- between.on('update', function (value) {
60325
- return !_this7.isDisposed() && _this7.setScale(value);
60326
- }).on('complete', resolve);
60327
- });
60349
+ return tweenTo({
60350
+ x: x,
60351
+ y: y,
60352
+ z: z
60353
+ }, target, _objectSpread2$1(_objectSpread2$1({}, options), {}, {
60354
+ time: time,
60355
+ onUpdate: onUpdate
60356
+ }));
60328
60357
  }
60329
60358
  }, {
60330
60359
  key: "rotateTo",
@@ -60333,39 +60362,31 @@ var FUNCTIONS = _objectSpread2$1({}, Between.Easing);var easing=/*#__PURE__*/Obj
60333
60362
 
60334
60363
  var rotation = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : this.getRotation();
60335
60364
  var time = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 250;
60336
-
60337
- var _ref10 = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {},
60338
- _ref10$easing = _ref10.easing,
60339
- easing = _ref10$easing === void 0 ? FUNCTIONS.Linear.None : _ref10$easing,
60340
- _ref10$loop = _ref10.loop,
60341
- loop = _ref10$loop === void 0 ? LOOPING.NONE : _ref10$loop;
60365
+ var options = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};
60342
60366
 
60343
60367
  var _this$getRotation2 = this.getRotation(),
60344
60368
  x = _this$getRotation2.x,
60345
60369
  y = _this$getRotation2.y,
60346
60370
  z = _this$getRotation2.z;
60347
60371
 
60348
- var targetRotation = _objectSpread2$1({
60372
+ var target = _objectSpread2$1({
60349
60373
  x: x,
60350
60374
  y: y,
60351
60375
  z: z
60352
60376
  }, rotation);
60353
60377
 
60354
- return new Promise(function (resolve) {
60355
- var between = new Between({
60356
- x: x,
60357
- y: y,
60358
- z: z
60359
- }, targetRotation).time(time).easing(easing);
60360
-
60361
- if (loop) {
60362
- between.loop(loop);
60363
- }
60378
+ var onUpdate = function onUpdate(value) {
60379
+ return !_this8.isDisposed() && _this8.setRotation(value);
60380
+ };
60364
60381
 
60365
- between.on('update', function (value) {
60366
- return !_this8.isDisposed() && _this8.setRotation(value);
60367
- }).on('complete', resolve);
60368
- });
60382
+ return tweenTo({
60383
+ x: x,
60384
+ y: y,
60385
+ z: z
60386
+ }, target, _objectSpread2$1(_objectSpread2$1({}, options), {}, {
60387
+ time: time,
60388
+ onUpdate: onUpdate
60389
+ }));
60369
60390
  }
60370
60391
  }, {
60371
60392
  key: "goTo",
@@ -60374,39 +60395,31 @@ var FUNCTIONS = _objectSpread2$1({}, Between.Easing);var easing=/*#__PURE__*/Obj
60374
60395
 
60375
60396
  var position = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : this.getPosition();
60376
60397
  var time = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 250;
60377
-
60378
- var _ref11 = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {},
60379
- _ref11$easing = _ref11.easing,
60380
- easing = _ref11$easing === void 0 ? FUNCTIONS.Linear.None : _ref11$easing,
60381
- _ref11$loop = _ref11.loop,
60382
- loop = _ref11$loop === void 0 ? LOOPING.NONE : _ref11$loop;
60398
+ var options = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};
60383
60399
 
60384
60400
  var _this$getPosition2 = this.getPosition(),
60385
60401
  x = _this$getPosition2.x,
60386
60402
  y = _this$getPosition2.y,
60387
60403
  z = _this$getPosition2.z;
60388
60404
 
60389
- var targetPosition = _objectSpread2$1({
60405
+ var target = _objectSpread2$1({
60390
60406
  x: x,
60391
60407
  y: y,
60392
60408
  z: z
60393
60409
  }, position);
60394
60410
 
60395
- return new Promise(function (resolve) {
60396
- var between = new Between({
60397
- x: x,
60398
- y: y,
60399
- z: z
60400
- }, targetPosition).time(time).easing(easing);
60401
-
60402
- if (loop) {
60403
- between.loop(loop);
60404
- }
60411
+ var onUpdate = function onUpdate(value) {
60412
+ return !_this9.isDisposed() && _this9.setPosition(value);
60413
+ };
60405
60414
 
60406
- between.on('update', function (value) {
60407
- return !_this9.isDisposed() && _this9.setPosition(value);
60408
- }).on('complete', resolve);
60409
- });
60415
+ return tweenTo({
60416
+ x: x,
60417
+ y: y,
60418
+ z: z
60419
+ }, target, _objectSpread2$1(_objectSpread2$1({}, options), {}, {
60420
+ time: time,
60421
+ onUpdate: onUpdate
60422
+ }));
60410
60423
  }
60411
60424
  }, {
60412
60425
  key: "uuid",
@@ -60477,10 +60490,10 @@ var FUNCTIONS = _objectSpread2$1({}, Between.Easing);var easing=/*#__PURE__*/Obj
60477
60490
  }, {
60478
60491
  key: "mapScriptsToJSON",
60479
60492
  value: function mapScriptsToJSON() {
60480
- this.scripts.reduce(function (acc, _ref12) {
60481
- var name = _ref12.name,
60482
- _ref12$options = _ref12.options,
60483
- options = _ref12$options === void 0 ? {} : _ref12$options;
60493
+ this.scripts.reduce(function (acc, _ref9) {
60494
+ var name = _ref9.name,
60495
+ _ref9$options = _ref9.options,
60496
+ options = _ref9$options === void 0 ? {} : _ref9$options;
60484
60497
  acc.names.push(name);
60485
60498
  acc.options.push(options);
60486
60499
  return acc;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "mage-engine",
3
- "version": "3.20.0",
3
+ "version": "3.20.1",
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": {