@mulsense/xnew 0.5.4 → 0.6.1
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 +18 -16
- package/dist/addons/xpixi.mjs +18 -16
- package/dist/addons/xrapier2d.js +7 -5
- package/dist/addons/xrapier2d.mjs +7 -5
- 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 +22 -19
- package/dist/addons/xthree.mjs +22 -19
- package/dist/xnew.d.ts +42 -23
- package/dist/xnew.js +351 -161
- package/dist/xnew.mjs +351 -161
- 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,47 +24,49 @@
|
|
|
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
|
-
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 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,47 +2,49 @@ 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
|
-
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 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
|
@@ -6,19 +6,21 @@
|
|
|
6
6
|
|
|
7
7
|
var xrapier2d = {
|
|
8
8
|
initialize({ gravity = { x: 0.0, y: -9.81 } } = {}) {
|
|
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('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;
|
|
@@ -3,19 +3,21 @@ import RAPIER from '@dimforge/rapier2d-compat';
|
|
|
3
3
|
|
|
4
4
|
var xrapier2d = {
|
|
5
5
|
initialize({ gravity = { x: 0.0, y: -9.81 } } = {}) {
|
|
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('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,49 +24,52 @@
|
|
|
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
71
|
return {
|
|
69
|
-
threeObject
|
|
72
|
+
get threeObject() { return object; },
|
|
70
73
|
};
|
|
71
74
|
}
|
|
72
75
|
|
package/dist/addons/xthree.mjs
CHANGED
|
@@ -2,49 +2,52 @@ 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
49
|
return {
|
|
47
|
-
threeObject
|
|
50
|
+
get threeObject() { return object; },
|
|
48
51
|
};
|
|
49
52
|
}
|
|
50
53
|
|
package/dist/xnew.d.ts
CHANGED
|
@@ -34,6 +34,8 @@ declare class Eventor {
|
|
|
34
34
|
remove(type: string, listener: Function): void;
|
|
35
35
|
private basic;
|
|
36
36
|
private resize;
|
|
37
|
+
private change;
|
|
38
|
+
private input;
|
|
37
39
|
private click;
|
|
38
40
|
private click_outside;
|
|
39
41
|
private pointer;
|
|
@@ -45,6 +47,7 @@ declare class Eventor {
|
|
|
45
47
|
private gesture;
|
|
46
48
|
private key;
|
|
47
49
|
private key_arrow;
|
|
50
|
+
private key_wasd;
|
|
48
51
|
}
|
|
49
52
|
|
|
50
53
|
type UnitElement = HTMLElement | SVGElement;
|
|
@@ -73,7 +76,7 @@ declare class UnitTimer {
|
|
|
73
76
|
}
|
|
74
77
|
interface Context {
|
|
75
78
|
stack: Context | null;
|
|
76
|
-
key?:
|
|
79
|
+
key?: any;
|
|
77
80
|
value?: any;
|
|
78
81
|
}
|
|
79
82
|
interface Snapshot {
|
|
@@ -100,10 +103,7 @@ interface Internal {
|
|
|
100
103
|
children: Unit[];
|
|
101
104
|
promises: UnitPromise[];
|
|
102
105
|
elements: UnitElement[];
|
|
103
|
-
|
|
104
|
-
component: Function;
|
|
105
|
-
defines: Record<string, any>;
|
|
106
|
-
}[];
|
|
106
|
+
components: Function[];
|
|
107
107
|
listeners: MapMap<string, Function, {
|
|
108
108
|
element: UnitElement;
|
|
109
109
|
component: Function | null;
|
|
@@ -141,7 +141,7 @@ declare class Unit {
|
|
|
141
141
|
static reset(): void;
|
|
142
142
|
static scope(snapshot: Snapshot, func: Function, ...args: any[]): any;
|
|
143
143
|
static snapshot(unit: Unit): Snapshot;
|
|
144
|
-
static context(unit: Unit, key:
|
|
144
|
+
static context(unit: Unit, key: any, value?: any): any;
|
|
145
145
|
static component2units: MapSet<Function, Unit>;
|
|
146
146
|
static find(component: Function): Unit[];
|
|
147
147
|
static type2units: MapSet<string, Unit>;
|
|
@@ -149,7 +149,7 @@ declare class Unit {
|
|
|
149
149
|
off(type?: string, listener?: Function): void;
|
|
150
150
|
static on(unit: Unit, type: string, listener: Function, options?: boolean | AddEventListenerOptions): void;
|
|
151
151
|
static off(unit: Unit, type: string, listener?: Function): void;
|
|
152
|
-
static emit(type: string,
|
|
152
|
+
static emit(type: string, props?: object): void;
|
|
153
153
|
}
|
|
154
154
|
|
|
155
155
|
interface CreateUnit {
|
|
@@ -175,22 +175,23 @@ interface CreateUnit {
|
|
|
175
175
|
(target: HTMLElement | SVGElement | string, Component?: Function | string, props?: Object): Unit;
|
|
176
176
|
}
|
|
177
177
|
|
|
178
|
-
declare function OpenAndClose(unit: Unit, {
|
|
179
|
-
|
|
178
|
+
declare function OpenAndClose(unit: Unit, { open }?: {
|
|
179
|
+
open?: boolean;
|
|
180
180
|
}): {
|
|
181
181
|
toggle(duration?: number, easing?: string): void;
|
|
182
182
|
open(duration?: number, easing?: string): void;
|
|
183
183
|
close(duration?: number, easing?: string): void;
|
|
184
184
|
};
|
|
185
|
+
declare function Accordion(unit: Unit): void;
|
|
186
|
+
declare function Modal(unit: Unit, { background }?: {
|
|
187
|
+
background?: string;
|
|
188
|
+
}): void;
|
|
185
189
|
|
|
186
|
-
type ScreenFit = 'contain' | 'cover'
|
|
187
|
-
declare function Screen(unit: Unit, {
|
|
188
|
-
|
|
189
|
-
height?: number;
|
|
190
|
+
type ScreenFit = 'contain' | 'cover';
|
|
191
|
+
declare function Screen(unit: Unit, { aspect, fit }?: {
|
|
192
|
+
aspect?: number;
|
|
190
193
|
fit?: ScreenFit;
|
|
191
|
-
}):
|
|
192
|
-
readonly canvas: UnitElement;
|
|
193
|
-
};
|
|
194
|
+
}): void;
|
|
194
195
|
|
|
195
196
|
declare function AnalogStick(unit: Unit, { stroke, strokeOpacity, strokeWidth, strokeLinejoin, fill, fillOpacity }?: {
|
|
196
197
|
stroke?: string;
|
|
@@ -211,6 +212,26 @@ declare function DPad(unit: Unit, { diagonal, stroke, strokeOpacity, strokeWidth
|
|
|
211
212
|
fillOpacity?: number;
|
|
212
213
|
}): void;
|
|
213
214
|
|
|
215
|
+
interface GUIPanelOptions {
|
|
216
|
+
name?: string;
|
|
217
|
+
open?: boolean;
|
|
218
|
+
params?: Record<string, any>;
|
|
219
|
+
}
|
|
220
|
+
declare function GUIPanel(unit: Unit, { name, open, params }: GUIPanelOptions): {
|
|
221
|
+
group({ name, open, params }: GUIPanelOptions, inner: Function): Unit;
|
|
222
|
+
button(key: string): Unit;
|
|
223
|
+
select(key: string, { options }?: {
|
|
224
|
+
options?: string[];
|
|
225
|
+
}): Unit;
|
|
226
|
+
range(key: string, options?: {
|
|
227
|
+
min?: number;
|
|
228
|
+
max?: number;
|
|
229
|
+
step?: number;
|
|
230
|
+
}): Unit;
|
|
231
|
+
checkbox(key: string): Unit;
|
|
232
|
+
separator(): void;
|
|
233
|
+
};
|
|
234
|
+
|
|
214
235
|
type SynthesizerOptions = {
|
|
215
236
|
oscillator: OscillatorOptions;
|
|
216
237
|
amp: AmpOptions;
|
|
@@ -256,14 +277,11 @@ declare namespace xnew {
|
|
|
256
277
|
type UnitTimer = InstanceType<typeof UnitTimer>;
|
|
257
278
|
}
|
|
258
279
|
declare const xnew: CreateUnit & {
|
|
259
|
-
nest(tag: string
|
|
280
|
+
nest(tag: string): HTMLElement | SVGElement;
|
|
260
281
|
extend(component: Function, props?: Object): {
|
|
261
282
|
[key: string]: any;
|
|
262
283
|
};
|
|
263
|
-
|
|
264
|
-
[key: string]: any;
|
|
265
|
-
};
|
|
266
|
-
context(key: string, value?: any): any;
|
|
284
|
+
context(component: Function): any;
|
|
267
285
|
promise(promise: Promise<any>): UnitPromise;
|
|
268
286
|
then(callback: Function): UnitPromise;
|
|
269
287
|
catch(callback: Function): UnitPromise;
|
|
@@ -278,11 +296,12 @@ declare const xnew: CreateUnit & {
|
|
|
278
296
|
} & {
|
|
279
297
|
basics: {
|
|
280
298
|
Screen: typeof Screen;
|
|
281
|
-
Modal: any;
|
|
282
|
-
Accordion: any;
|
|
283
299
|
OpenAndClose: typeof OpenAndClose;
|
|
284
300
|
AnalogStick: typeof AnalogStick;
|
|
285
301
|
DPad: typeof DPad;
|
|
302
|
+
GUIPanel: typeof GUIPanel;
|
|
303
|
+
Accordion: typeof Accordion;
|
|
304
|
+
Modal: typeof Modal;
|
|
286
305
|
};
|
|
287
306
|
audio: {
|
|
288
307
|
load(path: string): UnitPromise;
|