mage-engine 3.23.39 → 3.23.41

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 +432 -238
  2. package/package.json +1 -1
package/dist/mage.js CHANGED
@@ -54995,7 +54995,7 @@ var Config$1 = new Config();let Universe = /*#__PURE__*/function () {
54995
54995
 
54996
54996
  _defineProperty$1(this, "reset", () => {
54997
54997
  this.reality = {};
54998
- this.realityUUID = {};
54998
+ this.nameIndex = {};
54999
54999
  });
55000
55000
 
55001
55001
  _defineProperty$1(this, "forEach", callback => {
@@ -55016,15 +55016,37 @@ var Config$1 = new Config();let Universe = /*#__PURE__*/function () {
55016
55016
  this.reset();
55017
55017
  });
55018
55018
 
55019
- this.reality = {};
55020
- this.realityUUID = {};
55019
+ this.reality = {}; // uuid -> element (primary storage)
55020
+
55021
+ this.nameIndex = {}; // name -> uuid[] (reverse index for name lookups)
55022
+
55021
55023
  this.worker = undefined;
55022
55024
  }
55023
55025
 
55024
55026
  _createClass(Universe, [{
55025
55027
  key: "get",
55026
55028
  value: function get(id) {
55027
- return this.reality[id];
55029
+ // Primary: lookup by UUID
55030
+ if (this.reality[id]) {
55031
+ return this.reality[id];
55032
+ } // Fallback: lookup by name (backward compat for user scripts)
55033
+
55034
+
55035
+ return this.getByName(id);
55036
+ }
55037
+ }, {
55038
+ key: "getByName",
55039
+ value: function getByName(name) {
55040
+ const uuids = this.nameIndex[name];
55041
+
55042
+ if (uuids && uuids.length > 0) {
55043
+ return this.reality[uuids[0]];
55044
+ }
55045
+ }
55046
+ }, {
55047
+ key: "getByUUID",
55048
+ value: function getByUUID(uuid) {
55049
+ return this.reality[uuid];
55028
55050
  }
55029
55051
  }, {
55030
55052
  key: "find",
@@ -55038,15 +55060,6 @@ var Config$1 = new Config();let Universe = /*#__PURE__*/function () {
55038
55060
  });
55039
55061
  return found;
55040
55062
  }
55041
- }, {
55042
- key: "getByUUID",
55043
- value: function getByUUID(uuid) {
55044
- const id = this.realityUUID[uuid.toString()];
55045
-
55046
- if (id) {
55047
- return this.get(id);
55048
- }
55049
- }
55050
55063
  }, {
55051
55064
  key: "getByTag",
55052
55065
  value: function getByTag(tagName) {
@@ -55060,24 +55073,72 @@ var Config$1 = new Config();let Universe = /*#__PURE__*/function () {
55060
55073
  }
55061
55074
  }, {
55062
55075
  key: "set",
55063
- value: function set(id, value) {
55064
- this.reality[id] = value;
55076
+ value: function set(uuid, element) {
55077
+ this.reality[uuid] = element; // Maintain name index
55078
+
55079
+ const name = element.getName ? element.getName() : undefined;
55080
+
55081
+ if (name) {
55082
+ if (!this.nameIndex[name]) {
55083
+ this.nameIndex[name] = [];
55084
+ }
55085
+
55086
+ if (!this.nameIndex[name].includes(uuid)) {
55087
+ this.nameIndex[name].push(uuid);
55088
+ }
55089
+ }
55065
55090
  }
55091
+ }, {
55092
+ key: "updateNameIndex",
55093
+ value: function updateNameIndex(uuid, oldName, newName) {
55094
+ // Remove from old name's list
55095
+ if (oldName && this.nameIndex[oldName]) {
55096
+ this.nameIndex[oldName] = this.nameIndex[oldName].filter(u => u !== uuid);
55097
+
55098
+ if (this.nameIndex[oldName].length === 0) {
55099
+ delete this.nameIndex[oldName];
55100
+ }
55101
+ } // Add to new name's list
55102
+
55103
+
55104
+ if (newName) {
55105
+ if (!this.nameIndex[newName]) {
55106
+ this.nameIndex[newName] = [];
55107
+ }
55108
+
55109
+ if (!this.nameIndex[newName].includes(uuid)) {
55110
+ this.nameIndex[newName].push(uuid);
55111
+ }
55112
+ }
55113
+ } // @deprecated - indexing is now handled inside set()
55114
+
55066
55115
  }, {
55067
55116
  key: "storeUUIDToElementNameReference",
55068
- value: function storeUUIDToElementNameReference(uuid, name) {
55069
- this.realityUUID[uuid] = name;
55070
- }
55117
+ value: function storeUUIDToElementNameReference(uuid, name) {// no-op: set() handles name indexing
55118
+ } // @deprecated - use updateNameIndex() instead
55119
+
55071
55120
  }, {
55072
55121
  key: "replaceUUIDToElementNameReference",
55073
- value: function replaceUUIDToElementNameReference(uuid, newName) {
55074
- delete this.realityUUID[uuid];
55075
- this.realityUUID[uuid] = newName;
55122
+ value: function replaceUUIDToElementNameReference(uuid, newName) {// no-op: use updateNameIndex() instead
55076
55123
  }
55077
55124
  }, {
55078
55125
  key: "remove",
55079
- value: function remove(id) {
55080
- delete this.reality[id];
55126
+ value: function remove(uuid) {
55127
+ const element = this.reality[uuid];
55128
+
55129
+ if (element) {
55130
+ const name = element.getName ? element.getName() : undefined;
55131
+
55132
+ if (name && this.nameIndex[name]) {
55133
+ this.nameIndex[name] = this.nameIndex[name].filter(u => u !== uuid);
55134
+
55135
+ if (this.nameIndex[name].length === 0) {
55136
+ delete this.nameIndex[name];
55137
+ }
55138
+ }
55139
+ }
55140
+
55141
+ delete this.reality[uuid];
55081
55142
  }
55082
55143
  }, {
55083
55144
  key: "update",
@@ -55522,6 +55583,7 @@ const BEFORE_UNLOAD = "beforeunload";
55522
55583
  const HASH_CHANGE = "hashchange";
55523
55584
  const TAGS = {
55524
55585
  HELPER: "TAGS.HELPER",
55586
+ CAMERA_HELPER: "TAGS.CAMERA_HELPER",
55525
55587
  LIGHTS: {
55526
55588
  HOLDER: "TAGS.LIGHTS.HOLDER",
55527
55589
  HELPER: "TAGS.LIGHTS.HELPER",
@@ -55563,13 +55625,18 @@ const resolveSinglePath = path => {
55563
55625
  // If already a full URL or already contains the API path, return as-is
55564
55626
  if (isAlreadyResolved$2(path)) {
55565
55627
  return path;
55628
+ } // Root-relative paths (starting with /) are served from the public folder
55629
+ // and should not be modified with base URL
55630
+
55631
+
55632
+ if (path && path.startsWith("/")) {
55633
+ return path;
55566
55634
  }
55567
55635
 
55568
55636
  const baseUrl = env.MAGE_ASSETS_BASE_URL;
55569
55637
 
55570
55638
  if (baseUrl) {
55571
- const cleanPath = path.startsWith("/") ? path.slice(1) : path;
55572
- return `${baseUrl}/${cleanPath}`;
55639
+ return `${baseUrl}/${path}`;
55573
55640
  } // Warn if path contains colon (could be mistaken for protocol) and no base URL is set
55574
55641
 
55575
55642
 
@@ -56785,9 +56852,7 @@ var Physics$1 = new Physics();let Scene = /*#__PURE__*/function () {
56785
56852
  }
56786
56853
 
56787
56854
  if (addUniverse) {
56788
- const name = element.getName();
56789
- Universe$1.set(name, element);
56790
- Universe$1.storeUUIDToElementNameReference(body.uuid, name);
56855
+ Universe$1.set(body.uuid, element);
56791
56856
  }
56792
56857
  }
56793
56858
  }, {
@@ -56806,7 +56871,7 @@ var Physics$1 = new Physics();let Scene = /*#__PURE__*/function () {
56806
56871
  key: "remove",
56807
56872
  value: function remove(body) {
56808
56873
  this.scene.remove(body);
56809
- Universe$1.remove(body.name);
56874
+ Universe$1.remove(body.uuid);
56810
56875
  }
56811
56876
  }, {
56812
56877
  key: "setClearColor",
@@ -58139,7 +58204,7 @@ function applyMiddleware() {
58139
58204
 
58140
58205
  var thunk = createThunkMiddleware();
58141
58206
  thunk.withExtraArgument = createThunkMiddleware;var name = "mage-engine";
58142
- var version$1 = "3.23.39";
58207
+ var version$1 = "3.23.41";
58143
58208
  var description = "A WebGL Javascript Game Engine, built on top of THREE.js and many other libraries.";
58144
58209
  var main = "dist/mage.js";
58145
58210
  var author$1 = {
@@ -62119,13 +62184,14 @@ let Element$1 = /*#__PURE__*/function (_Entity) {
62119
62184
  let {
62120
62185
  replace = false
62121
62186
  } = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
62187
+ const oldName = this.name;
62122
62188
 
62123
62189
  _get(_getPrototypeOf(Element.prototype), "setName", this).call(this, name);
62124
62190
 
62125
62191
  if (this.hasBody()) {
62126
62192
  if (replace) this.dispose();
62127
62193
  this.body.name = name;
62128
- Universe$1.replaceUUIDToElementNameReference(this.uuid(), name);
62194
+ Universe$1.updateNameIndex(this.uuid(), oldName, name);
62129
62195
  if (replace) this.addToScene();
62130
62196
  }
62131
62197
  }
@@ -62993,7 +63059,203 @@ let Element$1 = /*#__PURE__*/function (_Entity) {
62993
63059
  }]);
62994
63060
 
62995
63061
  return Element;
62996
- }(Entity);let Camera = /*#__PURE__*/function (_Entity) {
63062
+ }(Entity);const validateAnisotropy = anisotropy => {
63063
+ const max = Scene$1.getRenderer().capabilities.getMaxAnisotropy();
63064
+ return cap(anisotropy, max);
63065
+ };
63066
+
63067
+ let Sprite = /*#__PURE__*/function (_Element) {
63068
+ _inherits(Sprite, _Element);
63069
+
63070
+ var _super = _createSuper(Sprite);
63071
+
63072
+ function Sprite() {
63073
+ var _this;
63074
+
63075
+ let width = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 20;
63076
+ let height = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 20;
63077
+ let spriteTexture = arguments.length > 2 ? arguments[2] : undefined;
63078
+ let options = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : {};
63079
+
63080
+ _classCallCheck(this, Sprite);
63081
+
63082
+ _this = _super.call(this, {
63083
+ width,
63084
+ height,
63085
+ spriteTexture,
63086
+ ...options
63087
+ });
63088
+ const {
63089
+ anisotropy = 1,
63090
+ sizeAttenuation = true,
63091
+ depthTest = true,
63092
+ depthWrite = true,
63093
+ ...rest
63094
+ } = options;
63095
+ const texture = Images$1.get(spriteTexture);
63096
+
63097
+ _this.recordTexture(spriteTexture, TEXTURES.MAP);
63098
+
63099
+ _this.width = width;
63100
+ _this.height = height;
63101
+ _this.spriteTexture = spriteTexture;
63102
+ const material = new SpriteMaterial({
63103
+ map: texture,
63104
+ ...rest
63105
+ });
63106
+ const body = new Sprite$1(material);
63107
+
63108
+ _this.setBody({
63109
+ body
63110
+ });
63111
+
63112
+ _this.setAnisotropy(anisotropy);
63113
+
63114
+ _this.setWidth(width);
63115
+
63116
+ _this.setHeight(height);
63117
+
63118
+ _this.setSizeAttenuation(sizeAttenuation);
63119
+
63120
+ _this.setDepthTest(depthTest);
63121
+
63122
+ _this.setDepthWrite(depthWrite);
63123
+
63124
+ _this.setEntityType(ENTITY_TYPES.SPRITE.TYPE);
63125
+
63126
+ _this.setEntitySubtype(ENTITY_TYPES.SPRITE.SUBTYPES.DEFAULT);
63127
+
63128
+ return _this;
63129
+ }
63130
+
63131
+ _createClass(Sprite, [{
63132
+ key: "getRotation",
63133
+ value: function getRotation() {
63134
+ return this.getBody().material.rotation;
63135
+ }
63136
+ }, {
63137
+ key: "setRotation",
63138
+ value: function setRotation() {
63139
+ let rotation = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : this.getRotation();
63140
+ const numericRotation = Number(rotation) || 0;
63141
+ this.setData("rotation", numericRotation);
63142
+ this.getBody().material.rotation = numericRotation;
63143
+ }
63144
+ }, {
63145
+ key: "setWidth",
63146
+ value: function setWidth() {
63147
+ let width = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : this.width;
63148
+ const numericWidth = Number(width) || 1;
63149
+ this.setData("width", numericWidth);
63150
+ this.getBody().scale.x = numericWidth;
63151
+ }
63152
+ }, {
63153
+ key: "setHeight",
63154
+ value: function setHeight() {
63155
+ let height = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : this.height;
63156
+ const numericHeight = Number(height) || 1;
63157
+ this.setData("height", numericHeight);
63158
+ this.getBody().scale.y = numericHeight;
63159
+ }
63160
+ }, {
63161
+ key: "setAnisotropy",
63162
+ value: function setAnisotropy() {
63163
+ let anisotropy = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 1;
63164
+ const numericAnisotropy = Number(anisotropy) || 1;
63165
+ this.setData("anisotropy", numericAnisotropy);
63166
+ this.getTexture(TEXTURES.MAP).anisotropy = validateAnisotropy(numericAnisotropy);
63167
+ }
63168
+ }, {
63169
+ key: "setSizeAttenuation",
63170
+ value: function setSizeAttenuation() {
63171
+ let attenuation = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : true;
63172
+ this.setData("sizeAttenuation", attenuation);
63173
+ this.getBody().material.sizeAttenuation = attenuation;
63174
+ }
63175
+ }, {
63176
+ key: "setDepthTest",
63177
+ value: function setDepthTest() {
63178
+ let depthTest = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : true;
63179
+ this.setData("depthTest", depthTest);
63180
+ this.getBody().material.depthTest = depthTest;
63181
+ }
63182
+ }, {
63183
+ key: "setDepthWrite",
63184
+ value: function setDepthWrite() {
63185
+ let depthWrite = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : true;
63186
+ this.setData("depthWrite", depthWrite);
63187
+ this.getBody().material.depthWrite = depthWrite;
63188
+ }
63189
+ }, {
63190
+ key: "toJSON",
63191
+ value: function toJSON() {
63192
+ let parseJSON = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : false;
63193
+
63194
+ if (this.isSerializable()) {
63195
+ return { ..._get(_getPrototypeOf(Sprite.prototype), "toJSON", this).call(this, parseJSON),
63196
+ width: this.width,
63197
+ height: this.height,
63198
+ spriteTexture: this.spriteTexture,
63199
+ anisotropy: this.getBody().material.anisotropy,
63200
+ sizeAttenuation: this.getBody().material.sizeAttenuation,
63201
+ depthTest: this.getBody().material.depthTest,
63202
+ depthWrite: this.getBody().material.depthWrite
63203
+ };
63204
+ }
63205
+ }
63206
+ }], [{
63207
+ key: "create",
63208
+ value: function create() {
63209
+ let data = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
63210
+ const {
63211
+ width,
63212
+ height,
63213
+ spriteTexture,
63214
+ options
63215
+ } = data;
63216
+ return new Sprite(width, height, spriteTexture, options);
63217
+ }
63218
+ }]);
63219
+
63220
+ return Sprite;
63221
+ }(Element$1);let HelperSprite = /*#__PURE__*/function (_Sprite) {
63222
+ _inherits(HelperSprite, _Sprite);
63223
+
63224
+ var _super = _createSuper(HelperSprite);
63225
+
63226
+ function HelperSprite() {
63227
+ var _this;
63228
+
63229
+ _classCallCheck(this, HelperSprite);
63230
+
63231
+ for (var _len = arguments.length, options = new Array(_len), _key = 0; _key < _len; _key++) {
63232
+ options[_key] = arguments[_key];
63233
+ }
63234
+
63235
+ _this = _super.call(this, ...options);
63236
+ _this.helperTarget = undefined;
63237
+
63238
+ _this.setEntityType(ENTITY_TYPES.HELPER.TYPE);
63239
+
63240
+ _this.setEntitySubtype(ENTITY_TYPES.HELPER.SUBTYPES.HELPER_SPRITE);
63241
+
63242
+ return _this;
63243
+ }
63244
+
63245
+ _createClass(HelperSprite, [{
63246
+ key: "setHelperTarget",
63247
+ value: function setHelperTarget(element) {
63248
+ this.helperTarget = element;
63249
+ }
63250
+ }, {
63251
+ key: "getHelperTarget",
63252
+ value: function getHelperTarget() {
63253
+ return this.helperTarget;
63254
+ }
63255
+ }]);
63256
+
63257
+ return HelperSprite;
63258
+ }(Sprite);let Camera = /*#__PURE__*/function (_Entity) {
62997
63259
  _inherits(Camera, _Entity);
62998
63260
 
62999
63261
  var _super = _createSuper(Camera);
@@ -63030,15 +63292,73 @@ let Element$1 = /*#__PURE__*/function (_Entity) {
63030
63292
 
63031
63293
  _this.setEntitySubtype(ENTITY_TYPES.CAMERA.SUBTYPES.MAIN);
63032
63294
 
63033
- _this.setName(name);
63295
+ _this.setName(name); // Helper body for this camera
63034
63296
 
63297
+
63298
+ _this.isUsingHelper = false; // Holder body representing the camera (for selection in editor)
63299
+
63300
+ _this.holder = null; // THREE.js CameraHelper for visual feedback
63301
+
63302
+ _this.helper = null;
63035
63303
  return _this;
63036
63304
  }
63037
63305
 
63038
- _createClass(Camera, [{
63306
+ _createClass(Camera, [{
63307
+ key: "hasHolder",
63308
+ value: function hasHolder() {
63309
+ return !!this.holder;
63310
+ }
63311
+ }, {
63312
+ key: "usingHelper",
63313
+ value: function usingHelper() {
63314
+ return this.isUsingHelper;
63315
+ }
63316
+ }, {
63317
+ key: "addHolder",
63318
+ value: function addHolder() {
63319
+ let name = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : "cameraholder";
63320
+ let size = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 0.05;
63321
+ const holderSprite = new HelperSprite(size, size, name, {
63322
+ name
63323
+ });
63324
+
63325
+ if (holderSprite) {
63326
+ holderSprite.setSizeAttenuation(false);
63327
+ holderSprite.setDepthTest(false);
63328
+ holderSprite.setDepthWrite(false);
63329
+ holderSprite.setSerializable(false);
63330
+ holderSprite.setPosition(this.getPosition());
63331
+ holderSprite.addTags([TAGS.HELPER, TAGS.CAMERA_HELPER, name]);
63332
+ holderSprite.setHelperTarget(this);
63333
+ this.holder = holderSprite;
63334
+ return true;
63335
+ }
63336
+
63337
+ console.warn("[Mage] Camera holder texture not found");
63338
+ return false;
63339
+ }
63340
+ }, {
63341
+ key: "addHelpers",
63342
+ value: function addHelpers() {
63343
+ let {
63344
+ holderName = "cameraholder",
63345
+ holderSize = 0.05
63346
+ } = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
63347
+ // Add THREE.js CameraHelper for visual feedback
63348
+ this.helper = new CameraHelper(this.getBody());
63349
+ Scene$1.add(this.helper, null, false); // Add holder sprite for selection
63350
+
63351
+ this.addHolder(holderName, holderSize);
63352
+ this.isUsingHelper = true;
63353
+ }
63354
+ }, {
63039
63355
  key: "getPosition",
63040
63356
  value: function getPosition() {
63041
- return this.body.position;
63357
+ return {
63358
+ x: this.body.position.x,
63359
+ y: this.body.position.y,
63360
+ z: this.body.position.z
63361
+ };
63042
63362
  }
63043
63363
  }, {
63044
63364
  key: "getDirection",
@@ -63066,6 +63386,66 @@ let Element$1 = /*#__PURE__*/function (_Entity) {
63066
63386
  } = position;
63067
63387
  this.body.lookAt(x, y, z);
63068
63388
  }
63389
+ }, {
63390
+ key: "setPosition",
63391
+ value: function setPosition(where) {
63392
+ let {
63393
+ updateHolder = true
63394
+ } = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
63395
+ const currentPos = this.getPosition();
63396
+ const position = {
63397
+ x: currentPos.x,
63398
+ y: currentPos.y,
63399
+ z: currentPos.z,
63400
+ ...where
63401
+ };
63402
+ const {
63403
+ x,
63404
+ y,
63405
+ z
63406
+ } = position;
63407
+
63408
+ if (this.hasBody()) {
63409
+ this.body.position.set(x, y, z);
63410
+ }
63411
+
63412
+ if (this.hasHolder() && updateHolder) {
63413
+ this.holder.setPosition({
63414
+ x,
63415
+ y,
63416
+ z
63417
+ });
63418
+ }
63419
+ }
63420
+ }, {
63421
+ key: "update",
63422
+ value: function update(dt) {
63423
+ _get(_getPrototypeOf(Camera.prototype), "update", this) && _get(_getPrototypeOf(Camera.prototype), "update", this).call(this, dt); // Update the THREE.js CameraHelper
63424
+
63425
+ if (this.usingHelper() && this.helper) {
63426
+ this.helper.update();
63427
+ } // Sync camera position from holder (when user drags the holder)
63428
+
63429
+
63430
+ if (this.hasHolder()) {
63431
+ // Read directly from the holder's THREE.js body position
63432
+ const holderBody = this.holder.getBody();
63433
+ const holderPos = {
63434
+ x: holderBody.position.x,
63435
+ y: holderBody.position.y,
63436
+ z: holderBody.position.z
63437
+ };
63438
+ const cameraPos = this.getPosition(); // Only update if positions differ significantly
63439
+
63440
+ const threshold = 0.001;
63441
+
63442
+ if (Math.abs(holderPos.x - cameraPos.x) > threshold || Math.abs(holderPos.y - cameraPos.y) > threshold || Math.abs(holderPos.z - cameraPos.z) > threshold) {
63443
+ this.setPosition(holderPos, {
63444
+ updateHolder: false
63445
+ });
63446
+ }
63447
+ }
63448
+ }
63069
63449
  }, {
63070
63450
  key: "getFov",
63071
63451
  value: function getFov() {
@@ -63838,203 +64218,7 @@ let Plane = /*#__PURE__*/function (_Element) {
63838
64218
  }]);
63839
64219
 
63840
64220
  return Box;
63841
- }(Element$1);const validateAnisotropy = anisotropy => {
63842
- const max = Scene$1.getRenderer().capabilities.getMaxAnisotropy();
63843
- return cap(anisotropy, max);
63844
- };
63845
-
63846
- let Sprite = /*#__PURE__*/function (_Element) {
63847
- _inherits(Sprite, _Element);
63848
-
63849
- var _super = _createSuper(Sprite);
63850
-
63851
- function Sprite() {
63852
- var _this;
63853
-
63854
- let width = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 20;
63855
- let height = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 20;
63856
- let spriteTexture = arguments.length > 2 ? arguments[2] : undefined;
63857
- let options = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : {};
63858
-
63859
- _classCallCheck(this, Sprite);
63860
-
63861
- _this = _super.call(this, {
63862
- width,
63863
- height,
63864
- spriteTexture,
63865
- ...options
63866
- });
63867
- const {
63868
- anisotropy = 1,
63869
- sizeAttenuation = true,
63870
- depthTest = true,
63871
- depthWrite = true,
63872
- ...rest
63873
- } = options;
63874
- const texture = Images$1.get(spriteTexture);
63875
-
63876
- _this.recordTexture(spriteTexture, TEXTURES.MAP);
63877
-
63878
- _this.width = width;
63879
- _this.height = height;
63880
- _this.spriteTexture = spriteTexture;
63881
- const material = new SpriteMaterial({
63882
- map: texture,
63883
- ...rest
63884
- });
63885
- const body = new Sprite$1(material);
63886
-
63887
- _this.setBody({
63888
- body
63889
- });
63890
-
63891
- _this.setAnisotropy(anisotropy);
63892
-
63893
- _this.setWidth(width);
63894
-
63895
- _this.setHeight(height);
63896
-
63897
- _this.setSizeAttenuation(sizeAttenuation);
63898
-
63899
- _this.setDepthTest(depthTest);
63900
-
63901
- _this.setDepthWrite(depthWrite);
63902
-
63903
- _this.setEntityType(ENTITY_TYPES.SPRITE.TYPE);
63904
-
63905
- _this.setEntitySubtype(ENTITY_TYPES.SPRITE.SUBTYPES.DEFAULT);
63906
-
63907
- return _this;
63908
- }
63909
-
63910
- _createClass(Sprite, [{
63911
- key: "getRotation",
63912
- value: function getRotation() {
63913
- return this.getBody().material.rotation;
63914
- }
63915
- }, {
63916
- key: "setRotation",
63917
- value: function setRotation() {
63918
- let rotation = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : this.getRotation();
63919
- const numericRotation = Number(rotation) || 0;
63920
- this.setData("rotation", numericRotation);
63921
- this.getBody().material.rotation = numericRotation;
63922
- }
63923
- }, {
63924
- key: "setWidth",
63925
- value: function setWidth() {
63926
- let width = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : this.width;
63927
- const numericWidth = Number(width) || 1;
63928
- this.setData("width", numericWidth);
63929
- this.getBody().scale.x = numericWidth;
63930
- }
63931
- }, {
63932
- key: "setHeight",
63933
- value: function setHeight() {
63934
- let height = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : this.height;
63935
- const numericHeight = Number(height) || 1;
63936
- this.setData("height", numericHeight);
63937
- this.getBody().scale.y = numericHeight;
63938
- }
63939
- }, {
63940
- key: "setAnisotropy",
63941
- value: function setAnisotropy() {
63942
- let anisotropy = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 1;
63943
- const numericAnisotropy = Number(anisotropy) || 1;
63944
- this.setData("anisotropy", numericAnisotropy);
63945
- this.getTexture(TEXTURES.MAP).anisotropy = validateAnisotropy(numericAnisotropy);
63946
- }
63947
- }, {
63948
- key: "setSizeAttenuation",
63949
- value: function setSizeAttenuation() {
63950
- let attenuation = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : true;
63951
- this.setData("sizeAttenuation", attenuation);
63952
- this.getBody().material.sizeAttenuation = attenuation;
63953
- }
63954
- }, {
63955
- key: "setDepthTest",
63956
- value: function setDepthTest() {
63957
- let depthTest = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : true;
63958
- this.setData("depthTest", depthTest);
63959
- this.getBody().material.depthTest = depthTest;
63960
- }
63961
- }, {
63962
- key: "setDepthWrite",
63963
- value: function setDepthWrite() {
63964
- let depthWrite = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : true;
63965
- this.setData("depthWrite", depthWrite);
63966
- this.getBody().material.depthWrite = depthWrite;
63967
- }
63968
- }, {
63969
- key: "toJSON",
63970
- value: function toJSON() {
63971
- let parseJSON = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : false;
63972
-
63973
- if (this.isSerializable()) {
63974
- return { ..._get(_getPrototypeOf(Sprite.prototype), "toJSON", this).call(this, parseJSON),
63975
- width: this.width,
63976
- height: this.height,
63977
- spriteTexture: this.spriteTexture,
63978
- anisotropy: this.getBody().material.anisotropy,
63979
- sizeAttenuation: this.getBody().material.sizeAttenuation,
63980
- depthTest: this.getBody().material.depthTest,
63981
- depthWrite: this.getBody().material.depthWrite
63982
- };
63983
- }
63984
- }
63985
- }], [{
63986
- key: "create",
63987
- value: function create() {
63988
- let data = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
63989
- const {
63990
- width,
63991
- height,
63992
- spriteTexture,
63993
- options
63994
- } = data;
63995
- return new Sprite(width, height, spriteTexture, options);
63996
- }
63997
- }]);
63998
-
63999
- return Sprite;
64000
- }(Element$1);let HelperSprite = /*#__PURE__*/function (_Sprite) {
64001
- _inherits(HelperSprite, _Sprite);
64002
-
64003
- var _super = _createSuper(HelperSprite);
64004
-
64005
- function HelperSprite() {
64006
- var _this;
64007
-
64008
- _classCallCheck(this, HelperSprite);
64009
-
64010
- for (var _len = arguments.length, options = new Array(_len), _key = 0; _key < _len; _key++) {
64011
- options[_key] = arguments[_key];
64012
- }
64013
-
64014
- _this = _super.call(this, ...options);
64015
- _this.helperTarget = undefined;
64016
-
64017
- _this.setEntityType(ENTITY_TYPES.HELPER.TYPE);
64018
-
64019
- _this.setEntitySubtype(ENTITY_TYPES.HELPER.SUBTYPES.HELPER_SPRITE);
64020
-
64021
- return _this;
64022
- }
64023
-
64024
- _createClass(HelperSprite, [{
64025
- key: "setHelperTarget",
64026
- value: function setHelperTarget(element) {
64027
- this.helperTarget = element;
64028
- }
64029
- }, {
64030
- key: "getHelperTarget",
64031
- value: function getHelperTarget() {
64032
- return this.helperTarget;
64033
- }
64034
- }]);
64035
-
64036
- return HelperSprite;
64037
- }(Sprite);var __awaiter$5 = (undefined && undefined.__awaiter) || function (thisArg, _arguments, P, generator) {
64221
+ }(Element$1);var __awaiter$5 = (undefined && undefined.__awaiter) || function (thisArg, _arguments, P, generator) {
64038
64222
  function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
64039
64223
  return new (P || (P = Promise))(function (resolve, reject) {
64040
64224
  function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
@@ -70294,6 +70478,7 @@ const isAlreadyResolved$1 = path => {
70294
70478
  /**
70295
70479
  * Resolves an asset path to a full URL.
70296
70480
  * If path is already an absolute URL or contains the API path, returns it as-is.
70481
+ * If path is root-relative (starts with /), returns it as-is (served from public folder).
70297
70482
  * If path is relative and MAGE_ASSETS_BASE_URL is set, prepends the base URL.
70298
70483
  * @param {string} path - The asset path (relative or absolute)
70299
70484
  * @returns {string} - The resolved full URL
@@ -70304,15 +70489,19 @@ const resolveAssetPath$1 = path => {
70304
70489
  // If already a full URL or already contains the API path, return as-is
70305
70490
  if (isAlreadyResolved$1(path)) {
70306
70491
  return path;
70492
+ } // Root-relative paths (starting with /) are served from the public folder
70493
+ // and should not be modified with base URL
70494
+
70495
+
70496
+ if (path && path.startsWith("/")) {
70497
+ return path;
70307
70498
  } // If MAGE_ASSETS_BASE_URL is set, prepend it to the relative path
70308
70499
 
70309
70500
 
70310
70501
  const baseUrl = env.MAGE_ASSETS_BASE_URL;
70311
70502
 
70312
70503
  if (baseUrl) {
70313
- // Remove leading slash from path if present to avoid double slashes
70314
- const cleanPath = path.startsWith("/") ? path.slice(1) : path;
70315
- return `${baseUrl}/${cleanPath}`;
70504
+ return `${baseUrl}/${path}`;
70316
70505
  } // Warn if path contains colon (could be mistaken for protocol) and no base URL is set
70317
70506
 
70318
70507
 
@@ -80811,6 +81000,7 @@ const isAlreadyResolved = path => {
80811
81000
  /**
80812
81001
  * Resolves an asset path to a full URL.
80813
81002
  * If path is already an absolute URL or contains the API path, returns it as-is.
81003
+ * If path is root-relative (starts with /), returns it as-is (served from public folder).
80814
81004
  * If path is relative and MAGE_ASSETS_BASE_URL is set, prepends the base URL.
80815
81005
  * @param {string} path - The asset path (relative or absolute)
80816
81006
  * @returns {string} - The resolved full URL
@@ -80821,15 +81011,19 @@ const resolveAssetPath = path => {
80821
81011
  // If already a full URL or already contains the API path, return as-is
80822
81012
  if (isAlreadyResolved(path)) {
80823
81013
  return path;
81014
+ } // Root-relative paths (starting with /) are served from the public folder
81015
+ // and should not be modified with base URL
81016
+
81017
+
81018
+ if (path && path.startsWith("/")) {
81019
+ return path;
80824
81020
  } // If MAGE_ASSETS_BASE_URL is set, prepend it to the relative path
80825
81021
 
80826
81022
 
80827
81023
  const baseUrl = env.MAGE_ASSETS_BASE_URL;
80828
81024
 
80829
81025
  if (baseUrl) {
80830
- // Remove leading slash from path if present to avoid double slashes
80831
- const cleanPath = path.startsWith("/") ? path.slice(1) : path;
80832
- return `${baseUrl}/${cleanPath}`;
81026
+ return `${baseUrl}/${path}`;
80833
81027
  } // Warn if path contains colon (could be mistaken for protocol) and no base URL is set
80834
81028
 
80835
81029
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "mage-engine",
3
- "version": "3.23.39",
3
+ "version": "3.23.41",
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": {