mage-engine 3.23.26 → 3.23.28

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 +179 -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,64 @@ 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 (with protocol).
55796
+ */
55797
+
55798
+ var isAbsoluteURL$3 = function isAbsoluteURL(path) {
55799
+ try {
55800
+ new URL(path);
55801
+ return true;
55802
+ } catch (_) {
55803
+ return false;
55804
+ }
55805
+ };
55806
+ /**
55807
+ * Checks if a path already contains the assets API path.
55808
+ * This prevents double-prepending when a full path is passed.
55809
+ */
55810
+
55811
+
55812
+ var isAlreadyResolved$2 = function isAlreadyResolved(path) {
55813
+ return path && (isAbsoluteURL$3(path) || path.includes("/api/assets/"));
55814
+ };
55815
+ /**
55816
+ * Resolves a single asset path to a full URL using MAGE_ASSETS_BASE_URL.
55817
+ */
55818
+
55819
+
55820
+ var resolveSinglePath = function resolveSinglePath(path) {
55821
+ // If already a full URL or already contains the API path, return as-is
55822
+ if (isAlreadyResolved$2(path)) {
55823
+ return path;
55824
+ }
55825
+
55826
+ var baseUrl = env.MAGE_ASSETS_BASE_URL;
55827
+
55828
+ if (baseUrl) {
55829
+ var cleanPath = path.startsWith("/") ? path.slice(1) : path;
55830
+ return "".concat(baseUrl, "/").concat(cleanPath);
55831
+ }
55832
+
55833
+ return path;
55834
+ };
55835
+ /**
55836
+ * Resolves asset path(s) to full URL(s) using MAGE_ASSETS_BASE_URL.
55837
+ * Handles both single paths (string) and arrays of paths (for cube textures).
55838
+ */
55839
+
55840
+
55841
+ var resolveAssetPath$2 = function resolveAssetPath(pathOrPaths) {
55842
+ if (Array.isArray(pathOrPaths)) {
55843
+ return pathOrPaths.map(function (p) {
55844
+ return resolveSinglePath(p);
55845
+ });
55846
+ }
55847
+
55848
+ return resolveSinglePath(pathOrPaths);
55849
+ };
55850
+
55851
+ var Images = /*#__PURE__*/function () {
55726
55852
  function Images() {
55727
55853
  var _this = this;
55728
55854
 
@@ -55801,11 +55927,13 @@ var isLevelName = function isLevelName(level) {
55801
55927
  var loaderType = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : _this.LOADERS.TEXTURE;
55802
55928
  var id = buildAssetId(name, level);
55803
55929
 
55804
- var loader = _this.getLoaderByType(loaderType);
55930
+ var loader = _this.getLoaderByType(loaderType); // Resolve the path using MAGE_ASSETS_BASE_URL if available
55805
55931
 
55932
+
55933
+ var resolvedPath = resolveAssetPath$2(path);
55806
55934
  return new Promise(function (resolve) {
55807
55935
  try {
55808
- loader.load(path, function (asset) {
55936
+ loader.load(resolvedPath, function (asset) {
55809
55937
  _this.add(id, asset);
55810
55938
 
55811
55939
  resolve(asset);
@@ -58297,7 +58425,7 @@ function applyMiddleware() {
58297
58425
 
58298
58426
  var thunk = createThunkMiddleware();
58299
58427
  thunk.withExtraArgument = createThunkMiddleware;var name = "mage-engine";
58300
- var version$1 = "3.23.26";
58428
+ var version$1 = "3.23.28";
58301
58429
  var description = "A WebGL Javascript Game Engine, built on top of THREE.js and many other libraries.";
58302
58430
  var main = "dist/mage.js";
58303
58431
  var author$1 = {
@@ -70214,75 +70342,6 @@ var createConnect = function (ref) {
70214
70342
  };
70215
70343
  var connect = createConnect();var BaseUI = function BaseUI() {
70216
70344
  return null;
70217
- };/**
70218
- * Environment configuration module for mage-engine.
70219
- * Centralizes all environment variables and their default values.
70220
- *
70221
- * Usage:
70222
- * import env from './env';
70223
- * const baseUrl = env.MAGE_ASSETS_BASE_URL;
70224
- */
70225
-
70226
- /**
70227
- * Safe window access - returns undefined in non-browser environments
70228
- */
70229
- var getWindow = function getWindow() {
70230
- return typeof window !== "undefined" ? window : undefined;
70231
- };
70232
- /**
70233
- * Gets an environment variable from the window object with a fallback default.
70234
- * @param {string} key - The environment variable name
70235
- * @param {any} defaultValue - Default value if not set
70236
- * @returns {any} - The environment variable value or default
70237
- */
70238
-
70239
-
70240
- var getEnv = function getEnv(key) {
70241
- var defaultValue = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : undefined;
70242
- var win = getWindow();
70243
- return win && win[key] !== undefined ? win[key] : defaultValue;
70244
- };
70245
- /**
70246
- * Environment variables with their default values.
70247
- * These are accessed as getters so they're evaluated at access time,
70248
- * not at module load time (important for variables set after page load).
70249
- */
70250
-
70251
-
70252
- var env = {
70253
- /**
70254
- * Base URL for loading assets (textures, models, audio).
70255
- * Set by mage-studio editor or deployed builds.
70256
- * Default: empty string (paths used as-is for backwards compatibility)
70257
- */
70258
- get MAGE_ASSETS_BASE_URL() {
70259
- return getEnv("MAGE_ASSETS_BASE_URL", "");
70260
- },
70261
-
70262
- /**
70263
- * Enable debug mode for verbose logging.
70264
- * Default: false
70265
- */
70266
- get MAGE_DEBUG() {
70267
- return getEnv("MAGE_DEBUG", false);
70268
- },
70269
-
70270
- /**
70271
- * Current project ID (set by mage-studio).
70272
- * Default: empty string
70273
- */
70274
- get MAGE_PROJECT_ID() {
70275
- return getEnv("MAGE_PROJECT_ID", "");
70276
- },
70277
-
70278
- /**
70279
- * Current build ID (set by deployed builds).
70280
- * Default: empty string
70281
- */
70282
- get MAGE_BUILD_ID() {
70283
- return getEnv("MAGE_BUILD_ID", "");
70284
- }
70285
-
70286
70345
  };var TIME_FOR_UPDATE = 5;
70287
70346
  var VOLUME = 2;
70288
70347
  var DEFAULT_AUDIO_NODE_VOLUME = 5;
@@ -70293,12 +70352,10 @@ var AUDIO_RAMPS = {
70293
70352
  EXPONENTIAL: "EXPONENTIAL"
70294
70353
  };
70295
70354
  /**
70296
- * Checks if a path is an absolute URL.
70297
- * @param {string} path - The path to check
70298
- * @returns {boolean} - True if path is an absolute URL
70355
+ * Checks if a path is an absolute URL (with protocol).
70299
70356
  */
70300
70357
 
70301
- var isURL$1 = function isURL(path) {
70358
+ var isAbsoluteURL$2 = function isAbsoluteURL(path) {
70302
70359
  try {
70303
70360
  new URL(path);
70304
70361
  return true;
@@ -70306,9 +70363,18 @@ var isURL$1 = function isURL(path) {
70306
70363
  return false;
70307
70364
  }
70308
70365
  };
70366
+ /**
70367
+ * Checks if a path already contains the assets API path.
70368
+ * This prevents double-prepending when a full path is passed.
70369
+ */
70370
+
70371
+
70372
+ var isAlreadyResolved$1 = function isAlreadyResolved(path) {
70373
+ return path && (isAbsoluteURL$2(path) || path.includes("/api/assets/"));
70374
+ };
70309
70375
  /**
70310
70376
  * Resolves an asset path to a full URL.
70311
- * If path is already an absolute URL, returns it as-is.
70377
+ * If path is already an absolute URL or contains the API path, returns it as-is.
70312
70378
  * If path is relative and MAGE_ASSETS_BASE_URL is set, prepends the base URL.
70313
70379
  * @param {string} path - The asset path (relative or absolute)
70314
70380
  * @returns {string} - The resolved full URL
@@ -70316,8 +70382,8 @@ var isURL$1 = function isURL(path) {
70316
70382
 
70317
70383
 
70318
70384
  var resolveAssetPath$1 = function resolveAssetPath(path) {
70319
- // If it's already an absolute URL, use it as-is
70320
- if (isURL$1(path)) {
70385
+ // If already a full URL or already contains the API path, return as-is
70386
+ if (isAlreadyResolved$1(path)) {
70321
70387
  return path;
70322
70388
  } // If MAGE_ASSETS_BASE_URL is set, prepend it to the relative path
70323
70389
 
@@ -76231,7 +76297,7 @@ var NURBSCurve = /*#__PURE__*/function (_Curve) {
76231
76297
  }]);
76232
76298
 
76233
76299
  return NURBSCurve;
76234
- }(Curve);var isAbsoluteURL = function isAbsoluteURL(url) {
76300
+ }(Curve);var isAbsoluteURL$1 = function isAbsoluteURL(url) {
76235
76301
  return /^(?:\w+:)\/\//.test(url);
76236
76302
  };/**
76237
76303
  * Loader loads FBX file and generates Group representing FBX scene.
@@ -76327,7 +76393,7 @@ var buildFBXLoader = function buildFBXLoader() {
76327
76393
  var texturePath = LoaderUtils.extractUrlBase(texture);
76328
76394
  var textureLoader = new TextureLoader(this.manager).setCrossOrigin(this.crossOrigin);
76329
76395
 
76330
- if (!isAbsoluteURL(texture)) {
76396
+ if (!isAbsoluteURL$1(texture)) {
76331
76397
  textureLoader.setPath(this.resourcePath || texturePath || path);
76332
76398
  }
76333
76399
 
@@ -80868,18 +80934,43 @@ var DEFAULTbuildObjectLoader = function DEFAULTbuildObjectLoader() {
80868
80934
  };
80869
80935
 
80870
80936
  var loaders = (_loaders = {}, _defineProperty$1(_loaders, EXTENSIONS.JSON, DEFAULTbuildObjectLoader), _defineProperty$1(_loaders, EXTENSIONS.GLB, buildGLTFLoader), _defineProperty$1(_loaders, EXTENSIONS.GLTF, buildGLTFLoader), _defineProperty$1(_loaders, EXTENSIONS.FBX, buildFBXLoader), _defineProperty$1(_loaders, EXTENSIONS.OBJ, buildOBJMTLLoader), _loaders);
80937
+ /**
80938
+ * Checks if a path is an absolute URL (with protocol).
80939
+ */
80940
+
80941
+ var isAbsoluteURL = function isAbsoluteURL(path) {
80942
+ try {
80943
+ new URL(path);
80944
+ return true;
80945
+ } catch (_) {
80946
+ return false;
80947
+ }
80948
+ };
80949
+ /**
80950
+ * Parses a URL and returns the URL object, or false if not a valid URL.
80951
+ * Used by extractExtension to get the pathname.
80952
+ */
80953
+
80871
80954
 
80872
80955
  var isURL = function isURL(path) {
80873
80956
  try {
80874
- var url = new URL(path);
80875
- return url;
80957
+ return new URL(path);
80876
80958
  } catch (_) {
80877
80959
  return false;
80878
80960
  }
80879
80961
  };
80962
+ /**
80963
+ * Checks if a path already contains the assets API path.
80964
+ * This prevents double-prepending when a full path is passed.
80965
+ */
80966
+
80967
+
80968
+ var isAlreadyResolved = function isAlreadyResolved(path) {
80969
+ return path && (isAbsoluteURL(path) || path.includes("/api/assets/"));
80970
+ };
80880
80971
  /**
80881
80972
  * Resolves an asset path to a full URL.
80882
- * If path is already an absolute URL, returns it as-is.
80973
+ * If path is already an absolute URL or contains the API path, returns it as-is.
80883
80974
  * If path is relative and MAGE_ASSETS_BASE_URL is set, prepends the base URL.
80884
80975
  * @param {string} path - The asset path (relative or absolute)
80885
80976
  * @returns {string} - The resolved full URL
@@ -80887,8 +80978,8 @@ var isURL = function isURL(path) {
80887
80978
 
80888
80979
 
80889
80980
  var resolveAssetPath = function resolveAssetPath(path) {
80890
- // If it's already an absolute URL, use it as-is
80891
- if (isURL(path)) {
80981
+ // If already a full URL or already contains the API path, return as-is
80982
+ if (isAlreadyResolved(path)) {
80892
80983
  return path;
80893
80984
  } // If MAGE_ASSETS_BASE_URL is set, prepend it to the relative path
80894
80985
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "mage-engine",
3
- "version": "3.23.26",
3
+ "version": "3.23.28",
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": {