@mulsense/xnew 0.5.4 → 0.6.0
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/README.md +3 -3
- package/dist/addons/xmatter.d.ts +1 -1
- package/dist/addons/xmatter.js +9 -8
- package/dist/addons/xmatter.mjs +9 -8
- package/dist/addons/xpixi.d.ts +1 -2
- package/dist/addons/xpixi.js +17 -15
- package/dist/addons/xpixi.mjs +17 -15
- package/dist/addons/xrapier2d.js +6 -4
- package/dist/addons/xrapier2d.mjs +6 -4
- package/dist/addons/xrapier3d.js +7 -5
- package/dist/addons/xrapier3d.mjs +7 -5
- package/dist/addons/xthree.d.ts +1 -3
- package/dist/addons/xthree.js +21 -21
- package/dist/addons/xthree.mjs +21 -21
- package/dist/xnew.d.ts +10 -20
- package/dist/xnew.js +116 -103
- package/dist/xnew.mjs +116 -103
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -13,7 +13,7 @@ providing a flexible architecture well-suited for applications with dynamic scen
|
|
|
13
13
|
### Via CDN
|
|
14
14
|
Include the following script in your HTML file:
|
|
15
15
|
```html
|
|
16
|
-
<script src="https://unpkg.com/@mulsense/xnew@0.
|
|
16
|
+
<script src="https://unpkg.com/@mulsense/xnew@0.6.x/dist/xnew.js"></script>
|
|
17
17
|
```
|
|
18
18
|
|
|
19
19
|
### Via CDN (ESM)
|
|
@@ -22,7 +22,7 @@ Use the ES module version with an import map:
|
|
|
22
22
|
<script type="importmap">
|
|
23
23
|
{
|
|
24
24
|
"imports": {
|
|
25
|
-
"@mulsense/xnew": "https://unpkg.com/@mulsense/xnew@0.
|
|
25
|
+
"@mulsense/xnew": "https://unpkg.com/@mulsense/xnew@0.6.x/dist/xnew.mjs"
|
|
26
26
|
}
|
|
27
27
|
}
|
|
28
28
|
</script>
|
|
@@ -37,7 +37,7 @@ import xnew from '@mulsense/xnew';
|
|
|
37
37
|
### Via npm
|
|
38
38
|
Install `xnew` using npm:
|
|
39
39
|
```bash
|
|
40
|
-
npm install @mulsense/xnew@0.
|
|
40
|
+
npm install @mulsense/xnew@0.6.x
|
|
41
41
|
```
|
|
42
42
|
|
|
43
43
|
Then import it in your JavaScript file:
|
package/dist/addons/xmatter.d.ts
CHANGED
package/dist/addons/xmatter.js
CHANGED
|
@@ -5,22 +5,23 @@
|
|
|
5
5
|
})(this, (function (xnew, Matter) { 'use strict';
|
|
6
6
|
|
|
7
7
|
var xmatter = {
|
|
8
|
-
initialize({
|
|
9
|
-
xnew
|
|
8
|
+
initialize({} = {}) {
|
|
9
|
+
xnew(Root, {});
|
|
10
10
|
},
|
|
11
11
|
get engine() {
|
|
12
12
|
var _a;
|
|
13
|
-
return (_a = xnew.context(
|
|
13
|
+
return (_a = xnew.context(Root)) === null || _a === void 0 ? void 0 : _a.engine;
|
|
14
14
|
},
|
|
15
15
|
get world() {
|
|
16
16
|
var _a;
|
|
17
|
-
return (_a = xnew.context(
|
|
17
|
+
return (_a = xnew.context(Root)) === null || _a === void 0 ? void 0 : _a.engine.world;
|
|
18
18
|
},
|
|
19
19
|
};
|
|
20
|
-
function Root(unit, {
|
|
21
|
-
const
|
|
22
|
-
|
|
23
|
-
|
|
20
|
+
function Root(unit, {}) {
|
|
21
|
+
const engine = Matter.Engine.create();
|
|
22
|
+
return {
|
|
23
|
+
get engine() { return engine; },
|
|
24
|
+
};
|
|
24
25
|
}
|
|
25
26
|
|
|
26
27
|
return xmatter;
|
package/dist/addons/xmatter.mjs
CHANGED
|
@@ -2,22 +2,23 @@ import xnew from '@mulsense/xnew';
|
|
|
2
2
|
import Matter from 'matter-js';
|
|
3
3
|
|
|
4
4
|
var xmatter = {
|
|
5
|
-
initialize({
|
|
6
|
-
xnew
|
|
5
|
+
initialize({} = {}) {
|
|
6
|
+
xnew(Root, {});
|
|
7
7
|
},
|
|
8
8
|
get engine() {
|
|
9
9
|
var _a;
|
|
10
|
-
return (_a = xnew.context(
|
|
10
|
+
return (_a = xnew.context(Root)) === null || _a === void 0 ? void 0 : _a.engine;
|
|
11
11
|
},
|
|
12
12
|
get world() {
|
|
13
13
|
var _a;
|
|
14
|
-
return (_a = xnew.context(
|
|
14
|
+
return (_a = xnew.context(Root)) === null || _a === void 0 ? void 0 : _a.engine.world;
|
|
15
15
|
},
|
|
16
16
|
};
|
|
17
|
-
function Root(unit, {
|
|
18
|
-
const
|
|
19
|
-
|
|
20
|
-
|
|
17
|
+
function Root(unit, {}) {
|
|
18
|
+
const engine = Matter.Engine.create();
|
|
19
|
+
return {
|
|
20
|
+
get engine() { return engine; },
|
|
21
|
+
};
|
|
21
22
|
}
|
|
22
23
|
|
|
23
24
|
export { xmatter as default };
|
package/dist/addons/xpixi.d.ts
CHANGED
package/dist/addons/xpixi.js
CHANGED
|
@@ -24,8 +24,8 @@
|
|
|
24
24
|
var PIXI__namespace = /*#__PURE__*/_interopNamespaceDefault(PIXI);
|
|
25
25
|
|
|
26
26
|
var xpixi = {
|
|
27
|
-
initialize({
|
|
28
|
-
xnew
|
|
27
|
+
initialize({ canvas = null } = {}) {
|
|
28
|
+
xnew(Root, { canvas });
|
|
29
29
|
},
|
|
30
30
|
nest(object) {
|
|
31
31
|
xnew.extend(Nest, { object });
|
|
@@ -33,38 +33,40 @@
|
|
|
33
33
|
},
|
|
34
34
|
get renderer() {
|
|
35
35
|
var _a;
|
|
36
|
-
return (_a = xnew.context(
|
|
36
|
+
return (_a = xnew.context(Root)) === null || _a === void 0 ? void 0 : _a.renderer;
|
|
37
37
|
},
|
|
38
38
|
get scene() {
|
|
39
39
|
var _a;
|
|
40
|
-
return (_a = xnew.context(
|
|
40
|
+
return (_a = xnew.context(Root)) === null || _a === void 0 ? void 0 : _a.scene;
|
|
41
41
|
},
|
|
42
42
|
get canvas() {
|
|
43
43
|
var _a;
|
|
44
|
-
return (_a = xnew.context(
|
|
44
|
+
return (_a = xnew.context(Root)) === null || _a === void 0 ? void 0 : _a.canvas;
|
|
45
45
|
},
|
|
46
46
|
};
|
|
47
47
|
function Root(unit, { canvas }) {
|
|
48
|
-
|
|
49
|
-
xnew.context('xpixi.root', root);
|
|
50
|
-
root.canvas = canvas;
|
|
51
|
-
root.renderer = null;
|
|
48
|
+
let renderer = null;
|
|
52
49
|
xnew.promise(PIXI__namespace.autoDetectRenderer({
|
|
53
50
|
width: canvas.width, height: canvas.height, view: canvas,
|
|
54
51
|
antialias: true, backgroundAlpha: 0,
|
|
55
|
-
})).then((
|
|
56
|
-
|
|
57
|
-
|
|
52
|
+
})).then((value) => renderer = value);
|
|
53
|
+
let scene = new PIXI__namespace.Container();
|
|
54
|
+
return {
|
|
55
|
+
get renderer() { return renderer; },
|
|
56
|
+
get scene() { return scene; },
|
|
57
|
+
get canvas() { return canvas; },
|
|
58
|
+
};
|
|
58
59
|
}
|
|
59
60
|
function Nest(unit, { object }) {
|
|
60
|
-
|
|
61
|
-
xnew.context(
|
|
61
|
+
var _a, _b;
|
|
62
|
+
const root = xnew.context(Root);
|
|
63
|
+
const parent = (_b = (_a = xnew.context(Nest)) === null || _a === void 0 ? void 0 : _a.pixiObject) !== null && _b !== void 0 ? _b : root.scene;
|
|
62
64
|
parent.addChild(object);
|
|
63
65
|
unit.on('finalize', () => {
|
|
64
66
|
parent.removeChild(object);
|
|
65
67
|
});
|
|
66
68
|
return {
|
|
67
|
-
pixiObject
|
|
69
|
+
get pixiObject() { return object; },
|
|
68
70
|
};
|
|
69
71
|
}
|
|
70
72
|
|
package/dist/addons/xpixi.mjs
CHANGED
|
@@ -2,8 +2,8 @@ import xnew from '@mulsense/xnew';
|
|
|
2
2
|
import * as PIXI from 'pixi.js';
|
|
3
3
|
|
|
4
4
|
var xpixi = {
|
|
5
|
-
initialize({
|
|
6
|
-
xnew
|
|
5
|
+
initialize({ canvas = null } = {}) {
|
|
6
|
+
xnew(Root, { canvas });
|
|
7
7
|
},
|
|
8
8
|
nest(object) {
|
|
9
9
|
xnew.extend(Nest, { object });
|
|
@@ -11,38 +11,40 @@ var xpixi = {
|
|
|
11
11
|
},
|
|
12
12
|
get renderer() {
|
|
13
13
|
var _a;
|
|
14
|
-
return (_a = xnew.context(
|
|
14
|
+
return (_a = xnew.context(Root)) === null || _a === void 0 ? void 0 : _a.renderer;
|
|
15
15
|
},
|
|
16
16
|
get scene() {
|
|
17
17
|
var _a;
|
|
18
|
-
return (_a = xnew.context(
|
|
18
|
+
return (_a = xnew.context(Root)) === null || _a === void 0 ? void 0 : _a.scene;
|
|
19
19
|
},
|
|
20
20
|
get canvas() {
|
|
21
21
|
var _a;
|
|
22
|
-
return (_a = xnew.context(
|
|
22
|
+
return (_a = xnew.context(Root)) === null || _a === void 0 ? void 0 : _a.canvas;
|
|
23
23
|
},
|
|
24
24
|
};
|
|
25
25
|
function Root(unit, { canvas }) {
|
|
26
|
-
|
|
27
|
-
xnew.context('xpixi.root', root);
|
|
28
|
-
root.canvas = canvas;
|
|
29
|
-
root.renderer = null;
|
|
26
|
+
let renderer = null;
|
|
30
27
|
xnew.promise(PIXI.autoDetectRenderer({
|
|
31
28
|
width: canvas.width, height: canvas.height, view: canvas,
|
|
32
29
|
antialias: true, backgroundAlpha: 0,
|
|
33
|
-
})).then((
|
|
34
|
-
|
|
35
|
-
|
|
30
|
+
})).then((value) => renderer = value);
|
|
31
|
+
let scene = new PIXI.Container();
|
|
32
|
+
return {
|
|
33
|
+
get renderer() { return renderer; },
|
|
34
|
+
get scene() { return scene; },
|
|
35
|
+
get canvas() { return canvas; },
|
|
36
|
+
};
|
|
36
37
|
}
|
|
37
38
|
function Nest(unit, { object }) {
|
|
38
|
-
|
|
39
|
-
xnew.context(
|
|
39
|
+
var _a, _b;
|
|
40
|
+
const root = xnew.context(Root);
|
|
41
|
+
const parent = (_b = (_a = xnew.context(Nest)) === null || _a === void 0 ? void 0 : _a.pixiObject) !== null && _b !== void 0 ? _b : root.scene;
|
|
40
42
|
parent.addChild(object);
|
|
41
43
|
unit.on('finalize', () => {
|
|
42
44
|
parent.removeChild(object);
|
|
43
45
|
});
|
|
44
46
|
return {
|
|
45
|
-
pixiObject
|
|
47
|
+
get pixiObject() { return object; },
|
|
46
48
|
};
|
|
47
49
|
}
|
|
48
50
|
|
package/dist/addons/xrapier2d.js
CHANGED
|
@@ -10,15 +10,17 @@
|
|
|
10
10
|
},
|
|
11
11
|
get world() {
|
|
12
12
|
var _a;
|
|
13
|
-
return (_a = xnew.context(
|
|
13
|
+
return (_a = xnew.context(Root)) === null || _a === void 0 ? void 0 : _a.world;
|
|
14
14
|
},
|
|
15
15
|
};
|
|
16
16
|
function Root(unit, { gravity }) {
|
|
17
|
-
|
|
18
|
-
xnew.context('xrapier2d.root', root);
|
|
17
|
+
let world = null;
|
|
19
18
|
xnew.promise(RAPIER.init()).then(() => {
|
|
20
|
-
|
|
19
|
+
world = new RAPIER.World(gravity);
|
|
21
20
|
});
|
|
21
|
+
return {
|
|
22
|
+
get world() { return world; },
|
|
23
|
+
};
|
|
22
24
|
}
|
|
23
25
|
|
|
24
26
|
return xrapier2d;
|
|
@@ -7,15 +7,17 @@ var xrapier2d = {
|
|
|
7
7
|
},
|
|
8
8
|
get world() {
|
|
9
9
|
var _a;
|
|
10
|
-
return (_a = xnew.context(
|
|
10
|
+
return (_a = xnew.context(Root)) === null || _a === void 0 ? void 0 : _a.world;
|
|
11
11
|
},
|
|
12
12
|
};
|
|
13
13
|
function Root(unit, { gravity }) {
|
|
14
|
-
|
|
15
|
-
xnew.context('xrapier2d.root', root);
|
|
14
|
+
let world = null;
|
|
16
15
|
xnew.promise(RAPIER.init()).then(() => {
|
|
17
|
-
|
|
16
|
+
world = new RAPIER.World(gravity);
|
|
18
17
|
});
|
|
18
|
+
return {
|
|
19
|
+
get world() { return world; },
|
|
20
|
+
};
|
|
19
21
|
}
|
|
20
22
|
|
|
21
23
|
export { xrapier2d as default };
|
package/dist/addons/xrapier3d.js
CHANGED
|
@@ -6,19 +6,21 @@
|
|
|
6
6
|
|
|
7
7
|
var xrapier3d = {
|
|
8
8
|
initialize({ gravity = { x: 0.0, y: -9.81, z: 0.0 } } = {}) {
|
|
9
|
-
xnew
|
|
9
|
+
xnew(Root, { gravity });
|
|
10
10
|
},
|
|
11
11
|
get world() {
|
|
12
12
|
var _a;
|
|
13
|
-
return (_a = xnew.context(
|
|
13
|
+
return (_a = xnew.context(Root)) === null || _a === void 0 ? void 0 : _a.world;
|
|
14
14
|
},
|
|
15
15
|
};
|
|
16
16
|
function Root(unit, { gravity }) {
|
|
17
|
-
|
|
18
|
-
xnew.context('xrapier3d.root', root);
|
|
17
|
+
let world = null;
|
|
19
18
|
xnew.promise(RAPIER.init()).then(() => {
|
|
20
|
-
|
|
19
|
+
world = new RAPIER.World(gravity);
|
|
21
20
|
});
|
|
21
|
+
return {
|
|
22
|
+
get world() { return world; },
|
|
23
|
+
};
|
|
22
24
|
}
|
|
23
25
|
|
|
24
26
|
return xrapier3d;
|
|
@@ -3,19 +3,21 @@ import RAPIER from '@dimforge/rapier3d-compat';
|
|
|
3
3
|
|
|
4
4
|
var xrapier3d = {
|
|
5
5
|
initialize({ gravity = { x: 0.0, y: -9.81, z: 0.0 } } = {}) {
|
|
6
|
-
xnew
|
|
6
|
+
xnew(Root, { gravity });
|
|
7
7
|
},
|
|
8
8
|
get world() {
|
|
9
9
|
var _a;
|
|
10
|
-
return (_a = xnew.context(
|
|
10
|
+
return (_a = xnew.context(Root)) === null || _a === void 0 ? void 0 : _a.world;
|
|
11
11
|
},
|
|
12
12
|
};
|
|
13
13
|
function Root(unit, { gravity }) {
|
|
14
|
-
|
|
15
|
-
xnew.context('xrapier3d.root', root);
|
|
14
|
+
let world = null;
|
|
16
15
|
xnew.promise(RAPIER.init()).then(() => {
|
|
17
|
-
|
|
16
|
+
world = new RAPIER.World(gravity);
|
|
18
17
|
});
|
|
18
|
+
return {
|
|
19
|
+
get world() { return world; },
|
|
20
|
+
};
|
|
19
21
|
}
|
|
20
22
|
|
|
21
23
|
export { xrapier3d as default };
|
package/dist/addons/xthree.d.ts
CHANGED
|
@@ -1,11 +1,9 @@
|
|
|
1
1
|
import * as THREE from 'three';
|
|
2
2
|
|
|
3
3
|
declare const _default: {
|
|
4
|
-
initialize({
|
|
5
|
-
renderer?: any;
|
|
4
|
+
initialize({ canvas, camera }?: {
|
|
6
5
|
canvas?: HTMLCanvasElement | null;
|
|
7
6
|
camera?: THREE.Camera | null;
|
|
8
|
-
update?: boolean;
|
|
9
7
|
}): void;
|
|
10
8
|
nest(object: any): any;
|
|
11
9
|
readonly renderer: any;
|
package/dist/addons/xthree.js
CHANGED
|
@@ -24,50 +24,50 @@
|
|
|
24
24
|
var THREE__namespace = /*#__PURE__*/_interopNamespaceDefault(THREE);
|
|
25
25
|
|
|
26
26
|
var xthree = {
|
|
27
|
-
initialize({
|
|
28
|
-
xnew
|
|
27
|
+
initialize({ canvas = null, camera = null } = {}) {
|
|
28
|
+
xnew(Root, { canvas, camera });
|
|
29
29
|
},
|
|
30
30
|
nest(object) {
|
|
31
|
-
xnew
|
|
31
|
+
xnew(Nest, { object });
|
|
32
32
|
return object;
|
|
33
33
|
},
|
|
34
34
|
get renderer() {
|
|
35
35
|
var _a;
|
|
36
|
-
return (_a = xnew.context(
|
|
36
|
+
return (_a = xnew.context(Root)) === null || _a === void 0 ? void 0 : _a.renderer;
|
|
37
37
|
},
|
|
38
38
|
get camera() {
|
|
39
39
|
var _a;
|
|
40
|
-
return (_a = xnew.context(
|
|
40
|
+
return (_a = xnew.context(Root)) === null || _a === void 0 ? void 0 : _a.camera;
|
|
41
41
|
},
|
|
42
42
|
get scene() {
|
|
43
43
|
var _a;
|
|
44
|
-
return (_a = xnew.context(
|
|
44
|
+
return (_a = xnew.context(Root)) === null || _a === void 0 ? void 0 : _a.scene;
|
|
45
45
|
},
|
|
46
46
|
get canvas() {
|
|
47
47
|
var _a;
|
|
48
|
-
return (_a = xnew.context(
|
|
48
|
+
return (_a = xnew.context(Root)) === null || _a === void 0 ? void 0 : _a.canvas;
|
|
49
49
|
},
|
|
50
50
|
};
|
|
51
|
-
function Root(unit, { canvas, camera
|
|
52
|
-
const
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
51
|
+
function Root(unit, { canvas, camera }) {
|
|
52
|
+
const renderer = new THREE__namespace.WebGLRenderer({ canvas, alpha: true });
|
|
53
|
+
renderer.setClearColor(0x000000, 0);
|
|
54
|
+
camera = camera !== null && camera !== void 0 ? camera : new THREE__namespace.PerspectiveCamera(45, renderer.domElement.width / renderer.domElement.height);
|
|
55
|
+
const scene = new THREE__namespace.Scene();
|
|
56
|
+
return {
|
|
57
|
+
get canvas() { return canvas; },
|
|
58
|
+
get camera() { return camera; },
|
|
59
|
+
get renderer() { return renderer; },
|
|
60
|
+
get scene() { return scene; },
|
|
61
|
+
};
|
|
60
62
|
}
|
|
61
63
|
function Nest(unit, { object }) {
|
|
62
|
-
|
|
63
|
-
xnew.context(
|
|
64
|
+
var _a, _b;
|
|
65
|
+
const root = xnew.context(Root);
|
|
66
|
+
const parent = (_b = (_a = xnew.context(Nest)) === null || _a === void 0 ? void 0 : _a.threeObject) !== null && _b !== void 0 ? _b : root.scene;
|
|
64
67
|
parent.add(object);
|
|
65
68
|
unit.on('finalize', () => {
|
|
66
69
|
parent.remove(object);
|
|
67
70
|
});
|
|
68
|
-
return {
|
|
69
|
-
threeObject: object,
|
|
70
|
-
};
|
|
71
71
|
}
|
|
72
72
|
|
|
73
73
|
return xthree;
|
package/dist/addons/xthree.mjs
CHANGED
|
@@ -2,50 +2,50 @@ import xnew from '@mulsense/xnew';
|
|
|
2
2
|
import * as THREE from 'three';
|
|
3
3
|
|
|
4
4
|
var xthree = {
|
|
5
|
-
initialize({
|
|
6
|
-
xnew
|
|
5
|
+
initialize({ canvas = null, camera = null } = {}) {
|
|
6
|
+
xnew(Root, { canvas, camera });
|
|
7
7
|
},
|
|
8
8
|
nest(object) {
|
|
9
|
-
xnew
|
|
9
|
+
xnew(Nest, { object });
|
|
10
10
|
return object;
|
|
11
11
|
},
|
|
12
12
|
get renderer() {
|
|
13
13
|
var _a;
|
|
14
|
-
return (_a = xnew.context(
|
|
14
|
+
return (_a = xnew.context(Root)) === null || _a === void 0 ? void 0 : _a.renderer;
|
|
15
15
|
},
|
|
16
16
|
get camera() {
|
|
17
17
|
var _a;
|
|
18
|
-
return (_a = xnew.context(
|
|
18
|
+
return (_a = xnew.context(Root)) === null || _a === void 0 ? void 0 : _a.camera;
|
|
19
19
|
},
|
|
20
20
|
get scene() {
|
|
21
21
|
var _a;
|
|
22
|
-
return (_a = xnew.context(
|
|
22
|
+
return (_a = xnew.context(Root)) === null || _a === void 0 ? void 0 : _a.scene;
|
|
23
23
|
},
|
|
24
24
|
get canvas() {
|
|
25
25
|
var _a;
|
|
26
|
-
return (_a = xnew.context(
|
|
26
|
+
return (_a = xnew.context(Root)) === null || _a === void 0 ? void 0 : _a.canvas;
|
|
27
27
|
},
|
|
28
28
|
};
|
|
29
|
-
function Root(unit, { canvas, camera
|
|
30
|
-
const
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
29
|
+
function Root(unit, { canvas, camera }) {
|
|
30
|
+
const renderer = new THREE.WebGLRenderer({ canvas, alpha: true });
|
|
31
|
+
renderer.setClearColor(0x000000, 0);
|
|
32
|
+
camera = camera !== null && camera !== void 0 ? camera : new THREE.PerspectiveCamera(45, renderer.domElement.width / renderer.domElement.height);
|
|
33
|
+
const scene = new THREE.Scene();
|
|
34
|
+
return {
|
|
35
|
+
get canvas() { return canvas; },
|
|
36
|
+
get camera() { return camera; },
|
|
37
|
+
get renderer() { return renderer; },
|
|
38
|
+
get scene() { return scene; },
|
|
39
|
+
};
|
|
38
40
|
}
|
|
39
41
|
function Nest(unit, { object }) {
|
|
40
|
-
|
|
41
|
-
xnew.context(
|
|
42
|
+
var _a, _b;
|
|
43
|
+
const root = xnew.context(Root);
|
|
44
|
+
const parent = (_b = (_a = xnew.context(Nest)) === null || _a === void 0 ? void 0 : _a.threeObject) !== null && _b !== void 0 ? _b : root.scene;
|
|
42
45
|
parent.add(object);
|
|
43
46
|
unit.on('finalize', () => {
|
|
44
47
|
parent.remove(object);
|
|
45
48
|
});
|
|
46
|
-
return {
|
|
47
|
-
threeObject: object,
|
|
48
|
-
};
|
|
49
49
|
}
|
|
50
50
|
|
|
51
51
|
export { xthree as default };
|
package/dist/xnew.d.ts
CHANGED
|
@@ -45,6 +45,7 @@ declare class Eventor {
|
|
|
45
45
|
private gesture;
|
|
46
46
|
private key;
|
|
47
47
|
private key_arrow;
|
|
48
|
+
private key_wasd;
|
|
48
49
|
}
|
|
49
50
|
|
|
50
51
|
type UnitElement = HTMLElement | SVGElement;
|
|
@@ -73,7 +74,7 @@ declare class UnitTimer {
|
|
|
73
74
|
}
|
|
74
75
|
interface Context {
|
|
75
76
|
stack: Context | null;
|
|
76
|
-
key?:
|
|
77
|
+
key?: any;
|
|
77
78
|
value?: any;
|
|
78
79
|
}
|
|
79
80
|
interface Snapshot {
|
|
@@ -100,10 +101,7 @@ interface Internal {
|
|
|
100
101
|
children: Unit[];
|
|
101
102
|
promises: UnitPromise[];
|
|
102
103
|
elements: UnitElement[];
|
|
103
|
-
|
|
104
|
-
component: Function;
|
|
105
|
-
defines: Record<string, any>;
|
|
106
|
-
}[];
|
|
104
|
+
components: Function[];
|
|
107
105
|
listeners: MapMap<string, Function, {
|
|
108
106
|
element: UnitElement;
|
|
109
107
|
component: Function | null;
|
|
@@ -141,7 +139,7 @@ declare class Unit {
|
|
|
141
139
|
static reset(): void;
|
|
142
140
|
static scope(snapshot: Snapshot, func: Function, ...args: any[]): any;
|
|
143
141
|
static snapshot(unit: Unit): Snapshot;
|
|
144
|
-
static context(unit: Unit, key:
|
|
142
|
+
static context(unit: Unit, key: any, value?: any): any;
|
|
145
143
|
static component2units: MapSet<Function, Unit>;
|
|
146
144
|
static find(component: Function): Unit[];
|
|
147
145
|
static type2units: MapSet<string, Unit>;
|
|
@@ -183,14 +181,11 @@ declare function OpenAndClose(unit: Unit, { state: initialState }?: {
|
|
|
183
181
|
close(duration?: number, easing?: string): void;
|
|
184
182
|
};
|
|
185
183
|
|
|
186
|
-
type ScreenFit = 'contain' | 'cover'
|
|
187
|
-
declare function Screen(unit: Unit, {
|
|
188
|
-
|
|
189
|
-
height?: number;
|
|
184
|
+
type ScreenFit = 'contain' | 'cover';
|
|
185
|
+
declare function Screen(unit: Unit, { aspect, fit }?: {
|
|
186
|
+
aspect?: number;
|
|
190
187
|
fit?: ScreenFit;
|
|
191
|
-
}):
|
|
192
|
-
readonly canvas: UnitElement;
|
|
193
|
-
};
|
|
188
|
+
}): void;
|
|
194
189
|
|
|
195
190
|
declare function AnalogStick(unit: Unit, { stroke, strokeOpacity, strokeWidth, strokeLinejoin, fill, fillOpacity }?: {
|
|
196
191
|
stroke?: string;
|
|
@@ -256,14 +251,11 @@ declare namespace xnew {
|
|
|
256
251
|
type UnitTimer = InstanceType<typeof UnitTimer>;
|
|
257
252
|
}
|
|
258
253
|
declare const xnew: CreateUnit & {
|
|
259
|
-
nest(tag: string
|
|
254
|
+
nest(tag: string): HTMLElement | SVGElement;
|
|
260
255
|
extend(component: Function, props?: Object): {
|
|
261
256
|
[key: string]: any;
|
|
262
257
|
};
|
|
263
|
-
|
|
264
|
-
[key: string]: any;
|
|
265
|
-
};
|
|
266
|
-
context(key: string, value?: any): any;
|
|
258
|
+
context(key: any, value?: any): any;
|
|
267
259
|
promise(promise: Promise<any>): UnitPromise;
|
|
268
260
|
then(callback: Function): UnitPromise;
|
|
269
261
|
catch(callback: Function): UnitPromise;
|
|
@@ -278,8 +270,6 @@ declare const xnew: CreateUnit & {
|
|
|
278
270
|
} & {
|
|
279
271
|
basics: {
|
|
280
272
|
Screen: typeof Screen;
|
|
281
|
-
Modal: any;
|
|
282
|
-
Accordion: any;
|
|
283
273
|
OpenAndClose: typeof OpenAndClose;
|
|
284
274
|
AnalogStick: typeof AnalogStick;
|
|
285
275
|
DPad: typeof DPad;
|