mage-engine 3.23.25 → 3.23.27

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 +135 -88
  2. package/package.json +1 -1
package/dist/mage.js CHANGED
@@ -55428,7 +55428,76 @@ var Universe$1 = new Universe();var generateUUID = function generateUUID() {
55428
55428
  };
55429
55429
  var generateRandomName = function generateRandomName(prefix) {
55430
55430
  return "".concat(prefix, "_").concat(generateUUID());
55431
- };var uuid$1=/*#__PURE__*/Object.freeze({__proto__:null,generateUUID:generateUUID,generateRandomName:generateRandomName});var _MATERIAL_PROPERTIES_, _MATERIAL_PROPERTIES_2, _MATERIAL_TEXTURE_MAP$1;
55431
+ };var uuid$1=/*#__PURE__*/Object.freeze({__proto__:null,generateUUID:generateUUID,generateRandomName:generateRandomName});/**
55432
+ * Environment configuration module for mage-engine.
55433
+ * Centralizes all environment variables and their default values.
55434
+ *
55435
+ * Usage:
55436
+ * import env from './env';
55437
+ * const baseUrl = env.MAGE_ASSETS_BASE_URL;
55438
+ */
55439
+
55440
+ /**
55441
+ * Safe window access - returns undefined in non-browser environments
55442
+ */
55443
+ var getWindow = function getWindow() {
55444
+ return typeof window !== "undefined" ? window : undefined;
55445
+ };
55446
+ /**
55447
+ * Gets an environment variable from the window object with a fallback default.
55448
+ * @param {string} key - The environment variable name
55449
+ * @param {any} defaultValue - Default value if not set
55450
+ * @returns {any} - The environment variable value or default
55451
+ */
55452
+
55453
+
55454
+ var getEnv = function getEnv(key) {
55455
+ var defaultValue = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : undefined;
55456
+ var win = getWindow();
55457
+ return win && win[key] !== undefined ? win[key] : defaultValue;
55458
+ };
55459
+ /**
55460
+ * Environment variables with their default values.
55461
+ * These are accessed as getters so they're evaluated at access time,
55462
+ * not at module load time (important for variables set after page load).
55463
+ */
55464
+
55465
+
55466
+ var env = {
55467
+ /**
55468
+ * Base URL for loading assets (textures, models, audio).
55469
+ * Set by mage-studio editor or deployed builds.
55470
+ * Default: empty string (paths used as-is for backwards compatibility)
55471
+ */
55472
+ get MAGE_ASSETS_BASE_URL() {
55473
+ return getEnv("MAGE_ASSETS_BASE_URL", "");
55474
+ },
55475
+
55476
+ /**
55477
+ * Enable debug mode for verbose logging.
55478
+ * Default: false
55479
+ */
55480
+ get MAGE_DEBUG() {
55481
+ return getEnv("MAGE_DEBUG", false);
55482
+ },
55483
+
55484
+ /**
55485
+ * Current project ID (set by mage-studio).
55486
+ * Default: empty string
55487
+ */
55488
+ get MAGE_PROJECT_ID() {
55489
+ return getEnv("MAGE_PROJECT_ID", "");
55490
+ },
55491
+
55492
+ /**
55493
+ * Current build ID (set by deployed builds).
55494
+ * Default: empty string
55495
+ */
55496
+ get MAGE_BUILD_ID() {
55497
+ return getEnv("MAGE_BUILD_ID", "");
55498
+ }
55499
+
55500
+ };var _MATERIAL_PROPERTIES_, _MATERIAL_PROPERTIES_2, _MATERIAL_TEXTURE_MAP$1;
55432
55501
  var ALMOST_ZERO = 0.00001;
55433
55502
  var UP$1 = "UP";
55434
55503
  var DOWN$1 = "DOWN";
@@ -55722,7 +55791,39 @@ var TAGS = {
55722
55791
  };
55723
55792
  var isLevelName = function isLevelName(level) {
55724
55793
  return level.startsWith(DIVIDER);
55725
- };var Images = /*#__PURE__*/function () {
55794
+ };/**
55795
+ * Checks if a path is an absolute URL.
55796
+ */
55797
+
55798
+ var isURL$2 = function isURL(path) {
55799
+ try {
55800
+ new URL(path);
55801
+ return true;
55802
+ } catch (_) {
55803
+ return false;
55804
+ }
55805
+ };
55806
+ /**
55807
+ * Resolves an asset path to a full URL using MAGE_ASSETS_BASE_URL.
55808
+ */
55809
+
55810
+
55811
+ var resolveAssetPath$2 = function resolveAssetPath(path) {
55812
+ if (isURL$2(path)) {
55813
+ return path;
55814
+ }
55815
+
55816
+ var baseUrl = env.MAGE_ASSETS_BASE_URL;
55817
+
55818
+ if (baseUrl) {
55819
+ var cleanPath = path.startsWith("/") ? path.slice(1) : path;
55820
+ return "".concat(baseUrl, "/").concat(cleanPath);
55821
+ }
55822
+
55823
+ return path;
55824
+ };
55825
+
55826
+ var Images = /*#__PURE__*/function () {
55726
55827
  function Images() {
55727
55828
  var _this = this;
55728
55829
 
@@ -55801,21 +55902,25 @@ var isLevelName = function isLevelName(level) {
55801
55902
  var loaderType = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : _this.LOADERS.TEXTURE;
55802
55903
  var id = buildAssetId(name, level);
55803
55904
 
55804
- var loader = _this.getLoaderByType(loaderType);
55905
+ var loader = _this.getLoaderByType(loaderType); // Resolve the path using MAGE_ASSETS_BASE_URL if available
55805
55906
 
55806
- return new Promise(function (resolve, reject) {
55907
+
55908
+ var resolvedPath = resolveAssetPath$2(path);
55909
+ return new Promise(function (resolve) {
55807
55910
  try {
55808
- loader.load(path, function (asset) {
55911
+ loader.load(resolvedPath, function (asset) {
55809
55912
  _this.add(id, asset);
55810
55913
 
55811
55914
  resolve(asset);
55812
- }, function () {}, function () {
55813
- console.log(ERROR_LOADING_TEXTURE, name, path);
55814
- resolve();
55915
+ }, function () {}, function (error) {
55916
+ // Log warning but resolve anyway to allow other assets to continue loading
55917
+ console.warn("[Mage] ".concat(ERROR_LOADING_TEXTURE), name, path, (error === null || error === void 0 ? void 0 : error.message) || "");
55918
+ resolve(null);
55815
55919
  });
55816
55920
  } catch (e) {
55817
- console.log(ERROR_LOADING_TEXTURE, name, path);
55818
- reject();
55921
+ // Log warning but resolve anyway to allow other assets to continue loading
55922
+ console.warn("[Mage] ".concat(ERROR_LOADING_TEXTURE), name, path, (e === null || e === void 0 ? void 0 : e.message) || "");
55923
+ resolve(null);
55819
55924
  }
55820
55925
  });
55821
55926
  });
@@ -58295,7 +58400,7 @@ function applyMiddleware() {
58295
58400
 
58296
58401
  var thunk = createThunkMiddleware();
58297
58402
  thunk.withExtraArgument = createThunkMiddleware;var name = "mage-engine";
58298
- var version$1 = "3.23.25";
58403
+ var version$1 = "3.23.27";
58299
58404
  var description = "A WebGL Javascript Game Engine, built on top of THREE.js and many other libraries.";
58300
58405
  var main = "dist/mage.js";
58301
58406
  var author$1 = {
@@ -70212,75 +70317,6 @@ var createConnect = function (ref) {
70212
70317
  };
70213
70318
  var connect = createConnect();var BaseUI = function BaseUI() {
70214
70319
  return null;
70215
- };/**
70216
- * Environment configuration module for mage-engine.
70217
- * Centralizes all environment variables and their default values.
70218
- *
70219
- * Usage:
70220
- * import env from './env';
70221
- * const baseUrl = env.MAGE_ASSETS_BASE_URL;
70222
- */
70223
-
70224
- /**
70225
- * Safe window access - returns undefined in non-browser environments
70226
- */
70227
- var getWindow = function getWindow() {
70228
- return typeof window !== "undefined" ? window : undefined;
70229
- };
70230
- /**
70231
- * Gets an environment variable from the window object with a fallback default.
70232
- * @param {string} key - The environment variable name
70233
- * @param {any} defaultValue - Default value if not set
70234
- * @returns {any} - The environment variable value or default
70235
- */
70236
-
70237
-
70238
- var getEnv = function getEnv(key) {
70239
- var defaultValue = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : undefined;
70240
- var win = getWindow();
70241
- return win && win[key] !== undefined ? win[key] : defaultValue;
70242
- };
70243
- /**
70244
- * Environment variables with their default values.
70245
- * These are accessed as getters so they're evaluated at access time,
70246
- * not at module load time (important for variables set after page load).
70247
- */
70248
-
70249
-
70250
- var env = {
70251
- /**
70252
- * Base URL for loading assets (textures, models, audio).
70253
- * Set by mage-studio editor or deployed builds.
70254
- * Default: empty string (paths used as-is for backwards compatibility)
70255
- */
70256
- get MAGE_ASSETS_BASE_URL() {
70257
- return getEnv("MAGE_ASSETS_BASE_URL", "");
70258
- },
70259
-
70260
- /**
70261
- * Enable debug mode for verbose logging.
70262
- * Default: false
70263
- */
70264
- get MAGE_DEBUG() {
70265
- return getEnv("MAGE_DEBUG", false);
70266
- },
70267
-
70268
- /**
70269
- * Current project ID (set by mage-studio).
70270
- * Default: empty string
70271
- */
70272
- get MAGE_PROJECT_ID() {
70273
- return getEnv("MAGE_PROJECT_ID", "");
70274
- },
70275
-
70276
- /**
70277
- * Current build ID (set by deployed builds).
70278
- * Default: empty string
70279
- */
70280
- get MAGE_BUILD_ID() {
70281
- return getEnv("MAGE_BUILD_ID", "");
70282
- }
70283
-
70284
70320
  };var TIME_FOR_UPDATE = 5;
70285
70321
  var VOLUME = 2;
70286
70322
  var DEFAULT_AUDIO_NODE_VOLUME = 5;
@@ -70377,15 +70413,22 @@ var Audio = /*#__PURE__*/function () {
70377
70413
  request.responseType = "arraybuffer";
70378
70414
 
70379
70415
  request.onreadystatechange = function (e) {
70380
- if (request.readyState === 4 && request.status === 200) {
70381
- _this.context.decodeAudioData(request.response, function (buffer) {
70382
- _this.buffersMap[id] = buffer;
70383
- resolve();
70384
- }, function () {
70416
+ if (request.readyState === 4) {
70417
+ if (request.status === 200) {
70418
+ _this.context.decodeAudioData(request.response, function (buffer) {
70419
+ _this.buffersMap[id] = buffer;
70420
+ resolve();
70421
+ }, function () {
70422
+ _this.buffersMap[id] = null;
70423
+ console.error(ASSETS_AUDIO_FILE_LOAD_FAIL);
70424
+ resolve();
70425
+ });
70426
+ } else {
70427
+ // Handle HTTP errors (404, etc.) - log warning and continue
70428
+ console.warn("[Mage] Failed to load audio \"".concat(id, "\" from ").concat(resolvedPath, ": HTTP ").concat(request.status));
70385
70429
  _this.buffersMap[id] = null;
70386
- console.error(ASSETS_AUDIO_FILE_LOAD_FAIL);
70387
70430
  resolve();
70388
- });
70431
+ }
70389
70432
  }
70390
70433
  };
70391
70434
 
@@ -81128,7 +81171,11 @@ var Models = /*#__PURE__*/function (_EventDispatcher) {
81128
81171
  }
81129
81172
 
81130
81173
  resolve(parsedModel);
81131
- }, NOOP, NOOP);
81174
+ }, NOOP, function (error) {
81175
+ // Log error but resolve anyway to allow other assets to continue loading
81176
+ console.warn("[Mage] Failed to load model \"".concat(name, "\" from ").concat(resolvedPath, ":"), (error === null || error === void 0 ? void 0 : error.message) || error);
81177
+ resolve(null);
81178
+ });
81132
81179
  });
81133
81180
  });
81134
81181
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "mage-engine",
3
- "version": "3.23.25",
3
+ "version": "3.23.27",
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": {