@mulsense/xnew 0.5.3 → 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 +42 -29
- package/dist/xnew.js +184 -169
- package/dist/xnew.mjs +184 -169
- 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
|
@@ -20,6 +20,14 @@ declare class MapMap<Key1, Key2, Value> extends Map<Key1, Map<Key2, Value>> {
|
|
|
20
20
|
delete(key1: Key1, key2: Key2): boolean;
|
|
21
21
|
}
|
|
22
22
|
|
|
23
|
+
interface TimerOptions {
|
|
24
|
+
transition?: Function;
|
|
25
|
+
timeout?: Function;
|
|
26
|
+
duration: number;
|
|
27
|
+
iterations: number;
|
|
28
|
+
easing?: string;
|
|
29
|
+
}
|
|
30
|
+
|
|
23
31
|
declare class Eventor {
|
|
24
32
|
private map;
|
|
25
33
|
add(element: HTMLElement | SVGElement, type: string, listener: Function, options?: boolean | AddEventListenerOptions): void;
|
|
@@ -37,6 +45,7 @@ declare class Eventor {
|
|
|
37
45
|
private gesture;
|
|
38
46
|
private key;
|
|
39
47
|
private key_arrow;
|
|
48
|
+
private key_wasd;
|
|
40
49
|
}
|
|
41
50
|
|
|
42
51
|
type UnitElement = HTMLElement | SVGElement;
|
|
@@ -48,9 +57,24 @@ declare class UnitPromise {
|
|
|
48
57
|
catch(callback: Function): UnitPromise;
|
|
49
58
|
finally(callback: Function): UnitPromise;
|
|
50
59
|
}
|
|
60
|
+
declare class UnitTimer {
|
|
61
|
+
private unit;
|
|
62
|
+
private stack;
|
|
63
|
+
constructor(options: TimerOptions);
|
|
64
|
+
clear(): void;
|
|
65
|
+
timeout(timeout: Function, duration?: number): this;
|
|
66
|
+
iteration(timeout: Function, duration?: number, iterations?: number): this;
|
|
67
|
+
transition(transition: Function, duration?: number, easing?: string): this;
|
|
68
|
+
static execute(timer: UnitTimer, options: TimerOptions): void;
|
|
69
|
+
static next(timer: UnitTimer): void;
|
|
70
|
+
static Component(unit: Unit, { options, snapshot }: {
|
|
71
|
+
options: TimerOptions;
|
|
72
|
+
snapshot: Snapshot;
|
|
73
|
+
}): void;
|
|
74
|
+
}
|
|
51
75
|
interface Context {
|
|
52
76
|
stack: Context | null;
|
|
53
|
-
key?:
|
|
77
|
+
key?: any;
|
|
54
78
|
value?: any;
|
|
55
79
|
}
|
|
56
80
|
interface Snapshot {
|
|
@@ -115,7 +139,7 @@ declare class Unit {
|
|
|
115
139
|
static reset(): void;
|
|
116
140
|
static scope(snapshot: Snapshot, func: Function, ...args: any[]): any;
|
|
117
141
|
static snapshot(unit: Unit): Snapshot;
|
|
118
|
-
static context(unit: Unit, key:
|
|
142
|
+
static context(unit: Unit, key: any, value?: any): any;
|
|
119
143
|
static component2units: MapSet<Function, Unit>;
|
|
120
144
|
static find(component: Function): Unit[];
|
|
121
145
|
static type2units: MapSet<string, Unit>;
|
|
@@ -149,30 +173,19 @@ interface CreateUnit {
|
|
|
149
173
|
(target: HTMLElement | SVGElement | string, Component?: Function | string, props?: Object): Unit;
|
|
150
174
|
}
|
|
151
175
|
|
|
152
|
-
declare function
|
|
153
|
-
|
|
154
|
-
duration?: number;
|
|
155
|
-
easing?: string;
|
|
176
|
+
declare function OpenAndClose(unit: Unit, { state: initialState }?: {
|
|
177
|
+
state?: number;
|
|
156
178
|
}): {
|
|
157
|
-
toggle(): void;
|
|
158
|
-
open(): void;
|
|
159
|
-
close(): void;
|
|
160
|
-
};
|
|
161
|
-
declare function Modal(unit: Unit, { duration, easing }?: {
|
|
162
|
-
duration?: number;
|
|
163
|
-
easing?: string;
|
|
164
|
-
}): {
|
|
165
|
-
close(): void;
|
|
179
|
+
toggle(duration?: number, easing?: string): void;
|
|
180
|
+
open(duration?: number, easing?: string): void;
|
|
181
|
+
close(duration?: number, easing?: string): void;
|
|
166
182
|
};
|
|
167
183
|
|
|
168
|
-
type ScreenFit = 'contain' | 'cover'
|
|
169
|
-
declare function Screen(unit: Unit, {
|
|
170
|
-
|
|
171
|
-
height?: number;
|
|
184
|
+
type ScreenFit = 'contain' | 'cover';
|
|
185
|
+
declare function Screen(unit: Unit, { aspect, fit }?: {
|
|
186
|
+
aspect?: number;
|
|
172
187
|
fit?: ScreenFit;
|
|
173
|
-
}):
|
|
174
|
-
readonly canvas: UnitElement;
|
|
175
|
-
};
|
|
188
|
+
}): void;
|
|
176
189
|
|
|
177
190
|
declare function AnalogStick(unit: Unit, { stroke, strokeOpacity, strokeWidth, strokeLinejoin, fill, fillOpacity }?: {
|
|
178
191
|
stroke?: string;
|
|
@@ -235,13 +248,14 @@ declare class Synthesizer {
|
|
|
235
248
|
|
|
236
249
|
declare namespace xnew {
|
|
237
250
|
type Unit = InstanceType<typeof Unit>;
|
|
251
|
+
type UnitTimer = InstanceType<typeof UnitTimer>;
|
|
238
252
|
}
|
|
239
253
|
declare const xnew: CreateUnit & {
|
|
240
|
-
nest(tag: string
|
|
254
|
+
nest(tag: string): HTMLElement | SVGElement;
|
|
241
255
|
extend(component: Function, props?: Object): {
|
|
242
256
|
[key: string]: any;
|
|
243
257
|
};
|
|
244
|
-
context(key:
|
|
258
|
+
context(key: any, value?: any): any;
|
|
245
259
|
promise(promise: Promise<any>): UnitPromise;
|
|
246
260
|
then(callback: Function): UnitPromise;
|
|
247
261
|
catch(callback: Function): UnitPromise;
|
|
@@ -249,15 +263,14 @@ declare const xnew: CreateUnit & {
|
|
|
249
263
|
scope(callback: any): any;
|
|
250
264
|
find(component: Function): Unit[];
|
|
251
265
|
emit(type: string, ...args: any[]): void;
|
|
252
|
-
timeout(timeout: Function, duration?: number):
|
|
253
|
-
interval(timeout: Function, duration: number, iterations?: number):
|
|
254
|
-
transition(transition: Function, duration?: number, easing?: string):
|
|
266
|
+
timeout(timeout: Function, duration?: number): UnitTimer;
|
|
267
|
+
interval(timeout: Function, duration: number, iterations?: number): UnitTimer;
|
|
268
|
+
transition(transition: Function, duration?: number, easing?: string): UnitTimer;
|
|
255
269
|
protect(): void;
|
|
256
270
|
} & {
|
|
257
271
|
basics: {
|
|
258
272
|
Screen: typeof Screen;
|
|
259
|
-
|
|
260
|
-
Accordion: typeof Accordion;
|
|
273
|
+
OpenAndClose: typeof OpenAndClose;
|
|
261
274
|
AnalogStick: typeof AnalogStick;
|
|
262
275
|
DPad: typeof DPad;
|
|
263
276
|
};
|