mage-engine 3.23.10 → 3.23.12

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 +61 -20
  2. package/package.json +1 -1
package/dist/mage.js CHANGED
@@ -55039,6 +55039,7 @@ var Config$1 = new Config();var Universe = /*#__PURE__*/function () {
55039
55039
  }, {
55040
55040
  key: "find",
55041
55041
  value: function find(element) {
55042
+ if (!element) return;
55042
55043
  var found;
55043
55044
  this.forEach(function (el) {
55044
55045
  if (el.has(element) && !found) {
@@ -57798,7 +57799,7 @@ function applyMiddleware() {
57798
57799
 
57799
57800
  var thunk = createThunkMiddleware();
57800
57801
  thunk.withExtraArgument = createThunkMiddleware;var name$1 = "mage-engine";
57801
- var version$1 = "3.23.10";
57802
+ var version$1 = "3.23.12";
57802
57803
  var description = "A WebGL Javascript Game Engine, built on top of THREE.js and many other libraries.";
57803
57804
  var main = "dist/mage.js";
57804
57805
  var author$1 = {
@@ -60267,7 +60268,8 @@ var tweenTo = function tweenTo(origin, target) {
60267
60268
  this.isMage = true;
60268
60269
  this.parent = false;
60269
60270
  this.tags = [DEFAULT_TAG];
60270
- }
60271
+ } // TODO: this is ridiculous, it's introducing a 200ms delay for no reason if delay is missing.
60272
+
60271
60273
  }, {
60272
60274
  key: "waitForBody",
60273
60275
  value: function waitForBody() {
@@ -60366,6 +60368,8 @@ var tweenTo = function tweenTo(origin, target) {
60366
60368
  }, {
60367
60369
  key: "isParentOf",
60368
60370
  value: function isParentOf(child) {
60371
+ if (!child) return false;
60372
+
60369
60373
  var comparator = function comparator(child) {
60370
60374
  return !!child.getBody().getObjectById(child.id);
60371
60375
  };
@@ -60381,6 +60385,8 @@ var tweenTo = function tweenTo(origin, target) {
60381
60385
  }, {
60382
60386
  key: "has",
60383
60387
  value: function has(child) {
60388
+ if (!child) return false;
60389
+
60384
60390
  if (child.isMage) {
60385
60391
  return this.equals(child) || this.isParentOf(child);
60386
60392
  } else {
@@ -89372,24 +89378,37 @@ var FirstPersonControl = /*#__PURE__*/function (_EventDispatcher) {
89372
89378
 
89373
89379
  return FlyControl;
89374
89380
  }(EventDispatcher);var CONTROLS = {
89375
- ORBIT: "orbit",
89376
- TRANSFORM: "transform",
89377
- FPS: "fps",
89378
- FLY: "fly"
89381
+ ORBIT: "CONTROLS:ORBIT",
89382
+ TRANSFORM: "CONTROLS:TRANSFORM",
89383
+ FPS: "CONTROLS:FPS",
89384
+ FLY: "CONTROLS:FLY"
89379
89385
  };
89380
- var AVAILABLE_CONTROLS = Object.keys(CONTROLS);
89381
- var EVENTS = {
89386
+ 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
89387
  CHANGE: "change",
89388
+ OBJECT_CHANGE: "objectChange",
89383
89389
  DRAGGING_CHANGE: "dragging-changed"
89384
89390
  };
89385
- var Controls = /*#__PURE__*/function () {
89391
+ var CONTROL_EVENTS = {
89392
+ TRANSFORM: {
89393
+ CHANGE: "".concat(CONTROLS.TRANSFORM, ":CHANGE"),
89394
+ DRAGGING_CHANGE: "".concat(CONTROLS.TRANSFORM, ":DRAGGING_CHANGE")
89395
+ }
89396
+ };
89397
+ var Controls = /*#__PURE__*/function (_EventDispatcher) {
89398
+ _inherits(Controls, _EventDispatcher);
89399
+
89400
+ var _super = _createSuper(Controls);
89401
+
89386
89402
  function Controls() {
89387
- var _this = this,
89388
- _this$controls;
89403
+ var _this$controls;
89404
+
89405
+ var _this;
89389
89406
 
89390
89407
  _classCallCheck(this, Controls);
89391
89408
 
89392
- _defineProperty$1(this, "disposeSingleControls", function (control) {
89409
+ _this = _super.call(this);
89410
+
89411
+ _defineProperty$1(_assertThisInitialized(_this), "disposeSingleControls", function (control) {
89393
89412
  if (_this.controls[control] && _this.controls[control].dispose) {
89394
89413
  _this.controls[control].dispose();
89395
89414
 
@@ -89397,7 +89416,8 @@ var Controls = /*#__PURE__*/function () {
89397
89416
  }
89398
89417
  });
89399
89418
 
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);
89419
+ _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);
89420
+ return _this;
89401
89421
  }
89402
89422
 
89403
89423
  _createClass(Controls, [{
@@ -89466,15 +89486,36 @@ var Controls = /*#__PURE__*/function () {
89466
89486
  value: function setTransformControls() {
89467
89487
  var _this4 = this;
89468
89488
 
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) {
89489
+ var control = new TransformControls(Scene$1.getCameraBody(), Scene$1.getDOMElement());
89490
+ control.init();
89491
+ control.addEventListener(THREEJS_CONTROL_EVENTS.CHANGE, function () {
89492
+ _this4.dispatchEvent({
89493
+ type: CONTROL_EVENTS.TRANSFORM.CHANGE,
89494
+ element: Universe$1.find(control.object)
89495
+ });
89496
+
89497
+ Scene$1.render.call(Scene$1);
89498
+ });
89499
+ control.addEventListener(THREEJS_CONTROL_EVENTS.OBJECT_CHANGE, function () {
89500
+ _this4.dispatchEvent({
89501
+ type: CONTROL_EVENTS.TRANSFORM.CHANGE,
89502
+ element: Universe$1.find(control.object)
89503
+ });
89504
+
89505
+ Scene$1.render.call(Scene$1);
89506
+ });
89507
+ control.addEventListener(THREEJS_CONTROL_EVENTS.DRAGGING_CHANGE, function (event) {
89508
+ _this4.dispatchEvent({
89509
+ type: CONTROL_EVENTS.TRANSFORM.DRAGGING_CHANGE,
89510
+ element: Universe$1.find(control.object)
89511
+ });
89512
+
89473
89513
  if (_this4.controls[CONTROLS.ORBIT]) {
89474
89514
  _this4.controls[CONTROLS.ORBIT].enabled = !event.value;
89475
89515
  }
89476
89516
  });
89477
- return this.controls.transform;
89517
+ this.controls[CONTROLS.TRANSFORM] = control;
89518
+ return this.controls[CONTROLS.TRANSFORM];
89478
89519
  }
89479
89520
  }, {
89480
89521
  key: "setFirstPersonControl",
@@ -89505,7 +89546,7 @@ var Controls = /*#__PURE__*/function () {
89505
89546
  }]);
89506
89547
 
89507
89548
  return Controls;
89508
- }();
89549
+ }(EventDispatcher);
89509
89550
  var Controls$1 = new Controls();var author = {
89510
89551
  name: "Marco Stagni",
89511
89552
  email: "mrc.stagni@gmail.com",
@@ -94466,4 +94507,4 @@ var Shaders$1 = new Shaders();var Shader = function Shader(name, attributes, uni
94466
94507
  } else {
94467
94508
  this.instance = this.shader.instance;
94468
94509
  }
94469
- };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};
94510
+ };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.10",
3
+ "version": "3.23.12",
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": {