mage-engine 3.25.2 → 3.25.3
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.
- package/dist/mage.js +39 -11
- package/package.json +1 -1
package/dist/mage.js
CHANGED
|
@@ -53720,7 +53720,8 @@ const LIGHT_NOT_FOUND = `${PREFIX} This light was not created properly.`;
|
|
|
53720
53720
|
const LIGHT_HOLDER_MODEL_NOT_FOUND = `${PREFIX} This light holder model can't be found.`;
|
|
53721
53721
|
const SOUND_HOLDER_MODEL_NOT_FOUND = `${PREFIX} This sound holder model can't be found.`;
|
|
53722
53722
|
const LABEL_DOMELEMENT_MISSING = `${PREFIX} Could not create Label, domElement is missing. Did you forget to set the this.element ref on your component?`;
|
|
53723
|
-
const NO_VALID_LEVEL_DATA_PROVIDED = `${PREFIX} No valid level data (json or url) provided
|
|
53723
|
+
const NO_VALID_LEVEL_DATA_PROVIDED = `${PREFIX} No valid level data (json or url) provided`;
|
|
53724
|
+
const THIRD_PERSON_CONTROL_TARGET_MISSING = `${PREFIX} ThirdPersonControl requires a target element. Please provide a valid target.`;/**!
|
|
53724
53725
|
* hotkeys-js v3.13.7
|
|
53725
53726
|
* A simple micro-library for defining and dispatching keyboard shortcuts. It has no dependencies.
|
|
53726
53727
|
*
|
|
@@ -56475,10 +56476,16 @@ let Physics = /*#__PURE__*/function (_EventDispatcher) {
|
|
|
56475
56476
|
value: function init() {
|
|
56476
56477
|
if (Config$1.physics().enabled) {
|
|
56477
56478
|
this.createWorker();
|
|
56479
|
+
|
|
56480
|
+
// Resolve ammo.js using MAGE_ASSETS_BASE_URL (same as models,
|
|
56481
|
+
// images, and audio) so the path works identically in local
|
|
56482
|
+
// preview and production.
|
|
56483
|
+
const baseUrl = env.MAGE_ASSETS_BASE_URL;
|
|
56484
|
+
const host = baseUrl ? `${getHostURL()}/${baseUrl}` : getHostURL();
|
|
56478
56485
|
this.worker.postMessage({
|
|
56479
56486
|
event: PHYSICS_EVENTS.LOAD.AMMO,
|
|
56480
56487
|
...Config$1.physics(),
|
|
56481
|
-
host
|
|
56488
|
+
host
|
|
56482
56489
|
});
|
|
56483
56490
|
return new Promise(resolve => {
|
|
56484
56491
|
const isWorkerReady = () => this.workerReady;
|
|
@@ -59038,6 +59045,10 @@ let ThirdPersonControl = /*#__PURE__*/function (_EventDispatcher) {
|
|
|
59038
59045
|
return _createClass(ThirdPersonControl, [{
|
|
59039
59046
|
key: "init",
|
|
59040
59047
|
value: function init() {
|
|
59048
|
+
if (!this.character) {
|
|
59049
|
+
console.error(THIRD_PERSON_CONTROL_TARGET_MISSING);
|
|
59050
|
+
return;
|
|
59051
|
+
}
|
|
59041
59052
|
this._onClick = this.onClick.bind(this);
|
|
59042
59053
|
this._onMouseMove = this.onMouseMove.bind(this);
|
|
59043
59054
|
this._onKeyDown = this.onKeyDown.bind(this);
|
|
@@ -59053,7 +59064,7 @@ let ThirdPersonControl = /*#__PURE__*/function (_EventDispatcher) {
|
|
|
59053
59064
|
|
|
59054
59065
|
// In non-physics mode, use the character's starting Y as ground level
|
|
59055
59066
|
// when no explicit value was provided, so it doesn't free-fall on start.
|
|
59056
|
-
if (!this.hasPhysicsEnabled()
|
|
59067
|
+
if (!this.hasPhysicsEnabled()) {
|
|
59057
59068
|
const startY = this.character.getPosition().y;
|
|
59058
59069
|
if (this.options.groundLevel === 0.5 && startY > 1) {
|
|
59059
59070
|
this.options.groundLevel = startY;
|
|
@@ -59061,7 +59072,7 @@ let ThirdPersonControl = /*#__PURE__*/function (_EventDispatcher) {
|
|
|
59061
59072
|
// Start grounded so the first jump works
|
|
59062
59073
|
this.canJump = true;
|
|
59063
59074
|
}
|
|
59064
|
-
if (this.hasPhysicsEnabled()
|
|
59075
|
+
if (this.hasPhysicsEnabled()) {
|
|
59065
59076
|
this.addCharacterToPhysics();
|
|
59066
59077
|
}
|
|
59067
59078
|
}
|
|
@@ -59090,7 +59101,7 @@ let ThirdPersonControl = /*#__PURE__*/function (_EventDispatcher) {
|
|
|
59090
59101
|
}, {
|
|
59091
59102
|
key: "getCharacter",
|
|
59092
59103
|
value: function getCharacter() {
|
|
59093
|
-
return this.character
|
|
59104
|
+
return this.character;
|
|
59094
59105
|
}
|
|
59095
59106
|
|
|
59096
59107
|
// --- Pointer Lock ---
|
|
@@ -59410,7 +59421,7 @@ let ThirdPersonControl = /*#__PURE__*/function (_EventDispatcher) {
|
|
|
59410
59421
|
}, {
|
|
59411
59422
|
key: "physicsUpdate",
|
|
59412
59423
|
value: function physicsUpdate() {
|
|
59413
|
-
if (this.hasPhysicsEnabled()
|
|
59424
|
+
if (this.hasPhysicsEnabled()) {
|
|
59414
59425
|
// Re-enable jumping when grounded AND space is released
|
|
59415
59426
|
const grounded = this.character.getPhysicsState("grounded");
|
|
59416
59427
|
if (grounded && !this.spaceHeld) {
|
|
@@ -59440,9 +59451,7 @@ let ThirdPersonControl = /*#__PURE__*/function (_EventDispatcher) {
|
|
|
59440
59451
|
}
|
|
59441
59452
|
|
|
59442
59453
|
// Always position camera relative to character
|
|
59443
|
-
|
|
59444
|
-
this.updateCameraPosition();
|
|
59445
|
-
}
|
|
59454
|
+
this.updateCameraPosition();
|
|
59446
59455
|
}
|
|
59447
59456
|
}]);
|
|
59448
59457
|
}(EventDispatcher);let FlyControl = /*#__PURE__*/function (_EventDispatcher) {
|
|
@@ -59837,8 +59846,26 @@ let Controls = /*#__PURE__*/function (_EventDispatcher) {
|
|
|
59837
59846
|
}
|
|
59838
59847
|
}, {
|
|
59839
59848
|
key: "setThirdPersonControls",
|
|
59840
|
-
value: function setThirdPersonControls(options) {
|
|
59849
|
+
value: async function setThirdPersonControls(options) {
|
|
59841
59850
|
this.disposePreviousControls([CONTROLS.FPS, CONTROLS.FLY, CONTROLS.ORBIT]);
|
|
59851
|
+
|
|
59852
|
+
// Ensure the global physics system is initialised when the control
|
|
59853
|
+
// requests physics. The builder/preview config may not have enabled
|
|
59854
|
+
// physics explicitly, so we enable it on-demand here.
|
|
59855
|
+
if (options.physicsEnabled && !Config$1.physics().enabled) {
|
|
59856
|
+
Config$1.physics().enabled = true;
|
|
59857
|
+
await Physics$1.init();
|
|
59858
|
+
|
|
59859
|
+
// Entities loaded before physics was enabled had their
|
|
59860
|
+
// enablePhysics() calls silently skipped. Now that the
|
|
59861
|
+
// worker is ready, add every entity that has pending
|
|
59862
|
+
// physics options to the world.
|
|
59863
|
+
Universe$1.forEach(element => {
|
|
59864
|
+
if (element._physicsEnabled && !Physics$1.hasElement(element)) {
|
|
59865
|
+
Physics$1.add(element, element.getPhysicsOptions());
|
|
59866
|
+
}
|
|
59867
|
+
});
|
|
59868
|
+
}
|
|
59842
59869
|
this.controls[CONTROLS.TPS] = new ThirdPersonControl(Scene$1.getCamera(), Scene$1.getDOMElement(), options);
|
|
59843
59870
|
this.controls[CONTROLS.TPS].init();
|
|
59844
59871
|
return this.controls[CONTROLS.TPS];
|
|
@@ -61268,7 +61295,7 @@ function applyMiddleware() {
|
|
|
61268
61295
|
|
|
61269
61296
|
var thunk = createThunkMiddleware();
|
|
61270
61297
|
thunk.withExtraArgument = createThunkMiddleware;var name = "mage-engine";
|
|
61271
|
-
var version$1 = "3.25.
|
|
61298
|
+
var version$1 = "3.25.3";
|
|
61272
61299
|
var description = "A WebGL Javascript Game Engine, built on top of THREE.js and many other libraries.";
|
|
61273
61300
|
var main = "dist/mage.js";
|
|
61274
61301
|
var author$1 = {
|
|
@@ -64986,6 +65013,7 @@ let Element$1 = /*#__PURE__*/function (_Entity) {
|
|
|
64986
65013
|
key: "enablePhysics",
|
|
64987
65014
|
value: function enablePhysics(options = {}) {
|
|
64988
65015
|
this.setPhysicsOptions(options);
|
|
65016
|
+
this._physicsEnabled = true;
|
|
64989
65017
|
if (Config$1.physics().enabled) {
|
|
64990
65018
|
Physics$1.add(this, options);
|
|
64991
65019
|
}
|