@urso/core 0.7.95 → 0.7.96

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.
@@ -149,7 +149,7 @@ object-assign
149
149
  */
150
150
 
151
151
  /*!
152
- * GSAP 3.13.0
152
+ * GSAP 3.14.2
153
153
  * https://gsap.com
154
154
  *
155
155
  * @license Copyright 2008-2025, GreenSock. All rights reserved.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@urso/core",
3
- "version": "0.7.95",
3
+ "version": "0.7.96",
4
4
  "description": "HTML5 game engine",
5
5
  "main": "build/js/index.js",
6
6
  "author": "Megbrimef",
@@ -11,7 +11,8 @@ let ConfigMain = {
11
11
  fps: {
12
12
  limit: 60, //max fps limit
13
13
  optimizeLowPerformance: false //down to 30 fps if lower 60
14
- }
14
+ },
15
+ domParentSelector: false //or '#app-container' - div selector, to append canvas
15
16
  };
16
17
 
17
18
  module.exports = ConfigMain;
@@ -12,6 +12,7 @@ class ModulesObserverConfig {
12
12
  EXTRA_BROWSEREVENTS_POINTER_EVENT: 'extra.browserEvents.window.pointer.event',
13
13
  EXTRA_BROWSEREVENTS_WINDOW_PRE_RESIZE: 'extra.browserEvents.window.pre.resize',
14
14
  EXTRA_BROWSEREVENTS_WINDOW_RESIZE: 'extra.browserEvents.window.resize',
15
+ EXTRA_BROWSEREVENTS_PARENT_RESIZE: 'extra.browserEvents.parent.resize',
15
16
  EXTRA_BROWSEREVENTS_WINDOW_VISIBILITYCHANGE: 'extra.browserEvents.window.visibilitychange',
16
17
  MODULES_ASSETS_GROUP_LOADED: 'modules.assets.group.loaded',
17
18
  MODULES_ASSETS_LOAD_PROGRESS: 'modules.assets.load.progress',
@@ -42,9 +42,19 @@ class ModulesScenesPixiWrapper {
42
42
  //this._renderer = new PIXI.Renderer({ preserveDrawingBuffer: true, width: 1, height: 1 });
43
43
  //document.body.appendChild(this._renderer.view);
44
44
  this._renderer = app.renderer;
45
- document.body.appendChild(app.view);
45
+ let parentContainer = document.body;
46
46
 
47
- //debugger
47
+ if (Urso.config.domParentSelector) {
48
+ const container = document.querySelector(Urso.config.domParentSelector);
49
+
50
+ if (container) {
51
+ parentContainer = container;
52
+ } else {
53
+ Urso.logger.warn(`No element found for domParentSelector: ${domParentSelector}`);
54
+ }
55
+ }
56
+
57
+ parentContainer.appendChild(this._renderer.view);
48
58
 
49
59
  //root and world
50
60
  this._root = new PIXI.Container();
@@ -10,6 +10,9 @@ class ModulesScenesResolutions {
10
10
  this.preResize = this.preResize.bind(this);
11
11
  this.refreshSceneSize();
12
12
 
13
+ this._customDomElementlatestWidth = 0;
14
+ this._customDomElementlatestHeight = 0;
15
+
13
16
  //TODO optimization (performance)
14
17
  /*if (devicePixelRatio > 2)
15
18
  devicePixelRatio = 2;*/ // when we are calculating canvas size
@@ -18,7 +21,48 @@ class ModulesScenesResolutions {
18
21
  _subscribeOnce() {
19
22
  this.addListener(Urso.events.EXTRA_BROWSEREVENTS_WINDOW_PRE_RESIZE, this.preResize, true);
20
23
  this.addListener(Urso.events.EXTRA_BROWSEREVENTS_WINDOW_RESIZE, this.refreshSceneSize, true);
24
+ this.addListener(Urso.events.EXTRA_BROWSEREVENTS_PARENT_RESIZE, this.refreshSceneSize, true);
21
25
  this.addListener(Urso.events.MODULES_SCENES_NEW_SCENE_INIT, this.refreshSceneSize, true);
26
+
27
+ if (Urso.config.domParentSelector) { this._observeCustomDomElementResize(); }
28
+ }
29
+
30
+ _observeCustomDomElementResize() {
31
+ const container = document.querySelector(Urso.config.domParentSelector);
32
+
33
+ if (!container) {
34
+ Urso.logger.warn(`No element found for domParentSelector: ${domParentSelector}`);
35
+ return;
36
+ }
37
+
38
+ const ro = new ResizeObserver((entries) => {
39
+ for (const entry of entries) {
40
+ if (entry.target.resizeHandler) {
41
+ entry.target.resizeHandler(entry.target.clientHeight, entry.target.clientWidth);
42
+ }
43
+ }
44
+ });
45
+
46
+ container.resizeHandler = this._customDomElementResizeHandler.bind(this);
47
+ ro.observe(container);
48
+ }
49
+
50
+ _customDomElementResizeHandler(newHeight, newWidth) {
51
+ let needResize = false;
52
+
53
+ if (this._customDomElementlatestWidth !== newWidth) {
54
+ this._customDomElementlatestWidth = newWidth;
55
+ needResize = true;
56
+ }
57
+
58
+ if (this._customDomElementlatestHeight !== newHeight) {
59
+ this._customDomElementlatestHeight = newHeight;
60
+ needResize = true;
61
+ }
62
+
63
+ if (needResize) {
64
+ this.emit(Urso.events.EXTRA_BROWSEREVENTS_PARENT_RESIZE);
65
+ }
22
66
  }
23
67
 
24
68
  getTemplateSize() {
@@ -73,6 +117,17 @@ class ModulesScenesResolutions {
73
117
  height: window.innerHeight
74
118
  };
75
119
 
120
+ if (Urso.config.domParentSelector) {
121
+ const container = document.querySelector(Urso.config.domParentSelector);
122
+
123
+ if (container) {
124
+ windowSize = {
125
+ width: container.offsetWidth,
126
+ height: container.offsetHeight
127
+ };
128
+ }
129
+ }
130
+
76
131
  if (window.devicePixelRatio && window.devicePixelRatio !== 1) {
77
132
  windowSize.width *= window.devicePixelRatio;
78
133
  windowSize.height *= window.devicePixelRatio;