@mulsense/xnew 0.3.5 → 0.3.6
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/addons/xmatter.js +1 -1
- package/dist/addons/xmatter.mjs +1 -1
- package/dist/addons/xpixi.js +6 -6
- package/dist/addons/xpixi.mjs +6 -6
- package/dist/addons/xrapier2d.js +1 -1
- package/dist/addons/xrapier2d.mjs +1 -1
- package/dist/addons/xrapier3d.js +5 -10
- package/dist/addons/xrapier3d.mjs +5 -10
- package/dist/addons/xthree.js +4 -6
- package/dist/addons/xthree.mjs +4 -6
- package/dist/xnew.d.ts +1 -0
- package/dist/xnew.js +9 -2
- package/dist/xnew.mjs +9 -2
- package/package.json +1 -1
package/dist/addons/xmatter.js
CHANGED
|
@@ -21,7 +21,7 @@
|
|
|
21
21
|
const root = {};
|
|
22
22
|
xnew.context('xmatter.root', root);
|
|
23
23
|
root.engine = engine !== null && engine !== void 0 ? engine : Matter.Engine.create();
|
|
24
|
-
unit.on('
|
|
24
|
+
unit.on('logicupdate', () => {
|
|
25
25
|
Matter.Engine.update(root.engine);
|
|
26
26
|
});
|
|
27
27
|
}
|
package/dist/addons/xmatter.mjs
CHANGED
|
@@ -18,7 +18,7 @@ function Root(unit, { engine }) {
|
|
|
18
18
|
const root = {};
|
|
19
19
|
xnew.context('xmatter.root', root);
|
|
20
20
|
root.engine = engine !== null && engine !== void 0 ? engine : Matter.Engine.create();
|
|
21
|
-
unit.on('
|
|
21
|
+
unit.on('logicupdate', () => {
|
|
22
22
|
Matter.Engine.update(root.engine);
|
|
23
23
|
});
|
|
24
24
|
}
|
package/dist/addons/xpixi.js
CHANGED
|
@@ -51,7 +51,7 @@
|
|
|
51
51
|
return (_a = xnew.context('xpixi.root')) === null || _a === void 0 ? void 0 : _a.canvas;
|
|
52
52
|
},
|
|
53
53
|
};
|
|
54
|
-
function Root(
|
|
54
|
+
function Root(unit, { canvas }) {
|
|
55
55
|
const root = {};
|
|
56
56
|
xnew.context('xpixi.root', root);
|
|
57
57
|
root.canvas = canvas;
|
|
@@ -63,7 +63,7 @@
|
|
|
63
63
|
root.updates = [];
|
|
64
64
|
root.scene = new PIXI__namespace.Container();
|
|
65
65
|
xnew.context('xpixi.object', root.scene);
|
|
66
|
-
|
|
66
|
+
unit.on('update', () => {
|
|
67
67
|
root.updates.forEach((update) => {
|
|
68
68
|
update();
|
|
69
69
|
});
|
|
@@ -72,18 +72,18 @@
|
|
|
72
72
|
}
|
|
73
73
|
});
|
|
74
74
|
}
|
|
75
|
-
function Nest(
|
|
75
|
+
function Nest(unit, { object }) {
|
|
76
76
|
const parent = xnew.context('xpixi.object');
|
|
77
77
|
xnew.context('xpixi.object', object);
|
|
78
78
|
parent.addChild(object);
|
|
79
|
-
|
|
79
|
+
unit.on('finalize', () => {
|
|
80
80
|
parent.removeChild(object);
|
|
81
81
|
});
|
|
82
82
|
}
|
|
83
|
-
function PreUpdate(
|
|
83
|
+
function PreUpdate(unit, callback) {
|
|
84
84
|
const root = xnew.context('xpixi.root');
|
|
85
85
|
root.updates.push(callback);
|
|
86
|
-
|
|
86
|
+
unit.on('finalize', () => {
|
|
87
87
|
root.updates = root.updates.filter((update) => update !== callback);
|
|
88
88
|
});
|
|
89
89
|
}
|
package/dist/addons/xpixi.mjs
CHANGED
|
@@ -29,7 +29,7 @@ var xpixi = {
|
|
|
29
29
|
return (_a = xnew.context('xpixi.root')) === null || _a === void 0 ? void 0 : _a.canvas;
|
|
30
30
|
},
|
|
31
31
|
};
|
|
32
|
-
function Root(
|
|
32
|
+
function Root(unit, { canvas }) {
|
|
33
33
|
const root = {};
|
|
34
34
|
xnew.context('xpixi.root', root);
|
|
35
35
|
root.canvas = canvas;
|
|
@@ -41,7 +41,7 @@ function Root(self, { canvas }) {
|
|
|
41
41
|
root.updates = [];
|
|
42
42
|
root.scene = new PIXI.Container();
|
|
43
43
|
xnew.context('xpixi.object', root.scene);
|
|
44
|
-
|
|
44
|
+
unit.on('update', () => {
|
|
45
45
|
root.updates.forEach((update) => {
|
|
46
46
|
update();
|
|
47
47
|
});
|
|
@@ -50,18 +50,18 @@ function Root(self, { canvas }) {
|
|
|
50
50
|
}
|
|
51
51
|
});
|
|
52
52
|
}
|
|
53
|
-
function Nest(
|
|
53
|
+
function Nest(unit, { object }) {
|
|
54
54
|
const parent = xnew.context('xpixi.object');
|
|
55
55
|
xnew.context('xpixi.object', object);
|
|
56
56
|
parent.addChild(object);
|
|
57
|
-
|
|
57
|
+
unit.on('finalize', () => {
|
|
58
58
|
parent.removeChild(object);
|
|
59
59
|
});
|
|
60
60
|
}
|
|
61
|
-
function PreUpdate(
|
|
61
|
+
function PreUpdate(unit, callback) {
|
|
62
62
|
const root = xnew.context('xpixi.root');
|
|
63
63
|
root.updates.push(callback);
|
|
64
|
-
|
|
64
|
+
unit.on('finalize', () => {
|
|
65
65
|
root.updates = root.updates.filter((update) => update !== callback);
|
|
66
66
|
});
|
|
67
67
|
}
|
package/dist/addons/xrapier2d.js
CHANGED
package/dist/addons/xrapier3d.js
CHANGED
|
@@ -5,27 +5,22 @@
|
|
|
5
5
|
})(this, (function (xnew, RAPIER) { 'use strict';
|
|
6
6
|
|
|
7
7
|
var xrapier3d = {
|
|
8
|
-
initialize({ gravity = { x: 0.0, y: 9.81, z: 0.0 }
|
|
9
|
-
xnew.extend(Root, { gravity
|
|
8
|
+
initialize({ gravity = { x: 0.0, y: 9.81, z: 0.0 } } = {}) {
|
|
9
|
+
xnew.extend(Root, { gravity });
|
|
10
10
|
},
|
|
11
11
|
get world() {
|
|
12
12
|
var _a;
|
|
13
13
|
return (_a = xnew.context('xrapier3d.root')) === null || _a === void 0 ? void 0 : _a.world;
|
|
14
14
|
},
|
|
15
15
|
};
|
|
16
|
-
function Root(self, { gravity
|
|
16
|
+
function Root(self, { gravity }) {
|
|
17
17
|
const root = {};
|
|
18
18
|
xnew.context('xrapier3d.root', root);
|
|
19
19
|
xnew.promise(RAPIER.init()).then(() => {
|
|
20
20
|
root.world = new RAPIER.World(gravity);
|
|
21
|
-
if (timestep !== null) {
|
|
22
|
-
root.world.timestep = timestep;
|
|
23
|
-
}
|
|
24
21
|
});
|
|
25
|
-
self.on('
|
|
26
|
-
|
|
27
|
-
root.world.step();
|
|
28
|
-
}
|
|
22
|
+
self.on('logicupdate', () => {
|
|
23
|
+
root.world.step();
|
|
29
24
|
});
|
|
30
25
|
}
|
|
31
26
|
|
|
@@ -2,27 +2,22 @@ import xnew from '@mulsense/xnew';
|
|
|
2
2
|
import RAPIER from '@dimforge/rapier3d-compat';
|
|
3
3
|
|
|
4
4
|
var xrapier3d = {
|
|
5
|
-
initialize({ gravity = { x: 0.0, y: 9.81, z: 0.0 }
|
|
6
|
-
xnew.extend(Root, { gravity
|
|
5
|
+
initialize({ gravity = { x: 0.0, y: 9.81, z: 0.0 } } = {}) {
|
|
6
|
+
xnew.extend(Root, { gravity });
|
|
7
7
|
},
|
|
8
8
|
get world() {
|
|
9
9
|
var _a;
|
|
10
10
|
return (_a = xnew.context('xrapier3d.root')) === null || _a === void 0 ? void 0 : _a.world;
|
|
11
11
|
},
|
|
12
12
|
};
|
|
13
|
-
function Root(self, { gravity
|
|
13
|
+
function Root(self, { gravity }) {
|
|
14
14
|
const root = {};
|
|
15
15
|
xnew.context('xrapier3d.root', root);
|
|
16
16
|
xnew.promise(RAPIER.init()).then(() => {
|
|
17
17
|
root.world = new RAPIER.World(gravity);
|
|
18
|
-
if (timestep !== null) {
|
|
19
|
-
root.world.timestep = timestep;
|
|
20
|
-
}
|
|
21
18
|
});
|
|
22
|
-
self.on('
|
|
23
|
-
|
|
24
|
-
root.world.step();
|
|
25
|
-
}
|
|
19
|
+
self.on('logicupdate', () => {
|
|
20
|
+
root.world.step();
|
|
26
21
|
});
|
|
27
22
|
}
|
|
28
23
|
|
package/dist/addons/xthree.js
CHANGED
|
@@ -64,12 +64,10 @@
|
|
|
64
64
|
function Nest(unit, { object }) {
|
|
65
65
|
const parent = xnew.context('xthree.object');
|
|
66
66
|
xnew.context('xthree.object', object);
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
});
|
|
72
|
-
}
|
|
67
|
+
parent.add(object);
|
|
68
|
+
unit.on('finalize', () => {
|
|
69
|
+
parent.remove(object);
|
|
70
|
+
});
|
|
73
71
|
}
|
|
74
72
|
|
|
75
73
|
return xthree;
|
package/dist/addons/xthree.mjs
CHANGED
|
@@ -42,12 +42,10 @@ function Root(unit, { canvas, camera }) {
|
|
|
42
42
|
function Nest(unit, { object }) {
|
|
43
43
|
const parent = xnew.context('xthree.object');
|
|
44
44
|
xnew.context('xthree.object', object);
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
});
|
|
50
|
-
}
|
|
45
|
+
parent.add(object);
|
|
46
|
+
unit.on('finalize', () => {
|
|
47
|
+
parent.remove(object);
|
|
48
|
+
});
|
|
51
49
|
}
|
|
52
50
|
|
|
53
51
|
export { xthree as default };
|
package/dist/xnew.d.ts
CHANGED
package/dist/xnew.js
CHANGED
|
@@ -209,7 +209,7 @@
|
|
|
209
209
|
//----------------------------------------------------------------------------------------------------
|
|
210
210
|
// utils
|
|
211
211
|
//----------------------------------------------------------------------------------------------------
|
|
212
|
-
const SYSTEM_EVENTS = ['start', 'update', 'stop', 'finalize'];
|
|
212
|
+
const SYSTEM_EVENTS = ['start', 'logicupdate', 'update', 'stop', 'finalize'];
|
|
213
213
|
//----------------------------------------------------------------------------------------------------
|
|
214
214
|
// unit
|
|
215
215
|
//----------------------------------------------------------------------------------------------------
|
|
@@ -302,7 +302,7 @@
|
|
|
302
302
|
components: [],
|
|
303
303
|
listeners: new MapMap(),
|
|
304
304
|
defines: {},
|
|
305
|
-
systems: { start: [], update: [], stop: [], finalize: [] },
|
|
305
|
+
systems: { start: [], logicupdate: [], update: [], stop: [], finalize: [] },
|
|
306
306
|
});
|
|
307
307
|
// nest html element
|
|
308
308
|
if (typeof unit._.target === 'string') {
|
|
@@ -417,6 +417,12 @@
|
|
|
417
417
|
unit._.systems.update.forEach((listener) => Unit.scope(Unit.snapshot(unit), listener));
|
|
418
418
|
}
|
|
419
419
|
}
|
|
420
|
+
static logicupdate(unit) {
|
|
421
|
+
if (unit._.state === 'started') {
|
|
422
|
+
unit._.children.forEach((child) => Unit.logicupdate(child));
|
|
423
|
+
unit._.systems.logicupdate.forEach((listener) => Unit.scope(Unit.snapshot(unit), listener));
|
|
424
|
+
}
|
|
425
|
+
}
|
|
420
426
|
static reset() {
|
|
421
427
|
var _a, _b;
|
|
422
428
|
(_a = Unit.root) === null || _a === void 0 ? void 0 : _a.finalize();
|
|
@@ -424,6 +430,7 @@
|
|
|
424
430
|
(_b = Unit.ticker) === null || _b === void 0 ? void 0 : _b.clear();
|
|
425
431
|
Unit.ticker = new Ticker(() => {
|
|
426
432
|
Unit.start(Unit.root);
|
|
433
|
+
Unit.logicupdate(Unit.root);
|
|
427
434
|
Unit.update(Unit.root);
|
|
428
435
|
});
|
|
429
436
|
}
|
package/dist/xnew.mjs
CHANGED
|
@@ -203,7 +203,7 @@ class Timer {
|
|
|
203
203
|
//----------------------------------------------------------------------------------------------------
|
|
204
204
|
// utils
|
|
205
205
|
//----------------------------------------------------------------------------------------------------
|
|
206
|
-
const SYSTEM_EVENTS = ['start', 'update', 'stop', 'finalize'];
|
|
206
|
+
const SYSTEM_EVENTS = ['start', 'logicupdate', 'update', 'stop', 'finalize'];
|
|
207
207
|
//----------------------------------------------------------------------------------------------------
|
|
208
208
|
// unit
|
|
209
209
|
//----------------------------------------------------------------------------------------------------
|
|
@@ -296,7 +296,7 @@ class Unit {
|
|
|
296
296
|
components: [],
|
|
297
297
|
listeners: new MapMap(),
|
|
298
298
|
defines: {},
|
|
299
|
-
systems: { start: [], update: [], stop: [], finalize: [] },
|
|
299
|
+
systems: { start: [], logicupdate: [], update: [], stop: [], finalize: [] },
|
|
300
300
|
});
|
|
301
301
|
// nest html element
|
|
302
302
|
if (typeof unit._.target === 'string') {
|
|
@@ -411,6 +411,12 @@ class Unit {
|
|
|
411
411
|
unit._.systems.update.forEach((listener) => Unit.scope(Unit.snapshot(unit), listener));
|
|
412
412
|
}
|
|
413
413
|
}
|
|
414
|
+
static logicupdate(unit) {
|
|
415
|
+
if (unit._.state === 'started') {
|
|
416
|
+
unit._.children.forEach((child) => Unit.logicupdate(child));
|
|
417
|
+
unit._.systems.logicupdate.forEach((listener) => Unit.scope(Unit.snapshot(unit), listener));
|
|
418
|
+
}
|
|
419
|
+
}
|
|
414
420
|
static reset() {
|
|
415
421
|
var _a, _b;
|
|
416
422
|
(_a = Unit.root) === null || _a === void 0 ? void 0 : _a.finalize();
|
|
@@ -418,6 +424,7 @@ class Unit {
|
|
|
418
424
|
(_b = Unit.ticker) === null || _b === void 0 ? void 0 : _b.clear();
|
|
419
425
|
Unit.ticker = new Ticker(() => {
|
|
420
426
|
Unit.start(Unit.root);
|
|
427
|
+
Unit.logicupdate(Unit.root);
|
|
421
428
|
Unit.update(Unit.root);
|
|
422
429
|
});
|
|
423
430
|
}
|