@mulsense/xnew 0.1.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.
Files changed (49) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +46 -0
  3. package/dist/addons/xmatter.d.ts +6 -0
  4. package/dist/addons/xmatter.js +45 -0
  5. package/dist/addons/xmatter.mjs +40 -0
  6. package/dist/addons/xpixi.d.ts +10 -0
  7. package/dist/addons/xpixi.js +101 -0
  8. package/dist/addons/xpixi.mjs +77 -0
  9. package/dist/addons/xrapier2d.d.ts +6 -0
  10. package/dist/addons/xrapier2d.js +66 -0
  11. package/dist/addons/xrapier2d.mjs +61 -0
  12. package/dist/addons/xthree.d.ts +9 -0
  13. package/dist/addons/xthree.js +77 -0
  14. package/dist/addons/xthree.mjs +53 -0
  15. package/dist/types/audio/audio.d.ts +13 -0
  16. package/dist/types/audio/loader.d.ts +1 -0
  17. package/dist/types/audio/synthesizer.d.ts +68 -0
  18. package/dist/types/basics/Accordion.d.ts +20 -0
  19. package/dist/types/basics/Block.d.ts +24 -0
  20. package/dist/types/basics/Bullet.d.ts +7 -0
  21. package/dist/types/basics/ControlPanel.d.ts +7 -0
  22. package/dist/types/basics/Controller.d.ts +28 -0
  23. package/dist/types/basics/Event.d.ts +3 -0
  24. package/dist/types/basics/File.d.ts +1 -0
  25. package/dist/types/basics/Input.d.ts +2 -0
  26. package/dist/types/basics/Modal.d.ts +11 -0
  27. package/dist/types/basics/Navigation.d.ts +1 -0
  28. package/dist/types/basics/Panel.d.ts +6 -0
  29. package/dist/types/basics/Popup.d.ts +8 -0
  30. package/dist/types/basics/ResizeEvent.d.ts +1 -0
  31. package/dist/types/basics/Screen.d.ts +13 -0
  32. package/dist/types/basics/SubWIndow.d.ts +6 -0
  33. package/dist/types/basics/Tab.d.ts +12 -0
  34. package/dist/types/basics/TabView.d.ts +18 -0
  35. package/dist/types/basics/Tabs.d.ts +8 -0
  36. package/dist/types/basics/Transition.d.ts +17 -0
  37. package/dist/types/basics/UserEvent.d.ts +2 -0
  38. package/dist/types/basics/WorkSpace.d.ts +16 -0
  39. package/dist/types/core/map.d.ts +34 -0
  40. package/dist/types/core/time.d.ts +27 -0
  41. package/dist/types/core/unit.d.ts +105 -0
  42. package/dist/types/core/util.d.ts +1 -0
  43. package/dist/types/core/xnew.d.ts +9 -0
  44. package/dist/types/index.d.ts +47 -0
  45. package/dist/types/xnew.d.ts +8 -0
  46. package/dist/xnew.d.ts +273 -0
  47. package/dist/xnew.js +2013 -0
  48. package/dist/xnew.mjs +2005 -0
  49. package/package.json +85 -0
package/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2024 - 2025 mulsense
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md ADDED
@@ -0,0 +1,46 @@
1
+ # xnew
2
+ `xnew` is a JavaScript / TypeScript library for component-oriented programming,
3
+ providing a flexible architecture well-suited for applications with dynamic scenes and games.
4
+
5
+ [**Visit the xnew website**](https://mulsense.github.io/xnew)
6
+
7
+ <div>
8
+ <img src="website/static/img/introduction.svg" width="500" alt="xnew introduction" />
9
+ </div>
10
+
11
+ ## Setup
12
+
13
+ ### Via CDN
14
+ Include the following script in your HTML file:
15
+ ```html
16
+ <script src="https://unpkg.com/xnew@5.0.x/dist/xnew.js"></script>
17
+ ```
18
+
19
+ ### Via CDN (ESM)
20
+ Use the ES module version with an import map:
21
+ ```html
22
+ <script type="importmap">
23
+ {
24
+ "imports": {
25
+ "xnew": "https://unpkg.com/xnew@5.0.x/dist/xnew.mjs"
26
+ }
27
+ }
28
+ </script>
29
+
30
+ <script type="module">
31
+ import xnew from 'xnew';
32
+
33
+ // Your code here
34
+ </script>
35
+ ```
36
+
37
+ ### Via npm
38
+ Install `xnew` using npm:
39
+ ```bash
40
+ npm install xnew@5.0.x
41
+ ```
42
+
43
+ Then import it in your JavaScript file:
44
+ ```js
45
+ import xnew from 'xnew';
46
+ ```
@@ -0,0 +1,6 @@
1
+ declare const _default: {
2
+ initialize({ engine }?: any): void;
3
+ nest(object: any): any;
4
+ readonly engine: any;
5
+ };
6
+ export default _default;
@@ -0,0 +1,45 @@
1
+ (function (global, factory) {
2
+ typeof exports === 'object' && typeof module !== 'undefined' ? module.exports = factory(require('xnew'), require('matter-js')) :
3
+ typeof define === 'function' && define.amd ? define(['xnew', 'matter-js'], factory) :
4
+ (global = typeof globalThis !== 'undefined' ? globalThis : global || self, global.xmatter = factory(global.xnew, global.Matter));
5
+ })(this, (function (xnew, Matter) { 'use strict';
6
+
7
+ var xmatter = {
8
+ initialize({ engine = null } = {}) {
9
+ xnew.extend(Root, { engine });
10
+ },
11
+ nest(object) {
12
+ xnew.extend(Nest, object);
13
+ return object;
14
+ },
15
+ get engine() {
16
+ var _a;
17
+ return (_a = xnew.context('xmatter.root')) === null || _a === void 0 ? void 0 : _a.engine;
18
+ },
19
+ };
20
+ function Root(self, { engine }) {
21
+ const root = {};
22
+ xnew.context('xmatter.root', root);
23
+ root.isActive = true;
24
+ root.engine = engine !== null && engine !== void 0 ? engine : Matter.Engine.create();
25
+ xnew.extend(Nest, root.engine.world);
26
+ self.on('update', () => {
27
+ if (root.isActive) {
28
+ Matter.Engine.update(root.engine);
29
+ }
30
+ });
31
+ }
32
+ function Nest(self, object) {
33
+ const parent = xnew.context('xmatter.object');
34
+ xnew.context('xmatter.object', object);
35
+ if (parent) {
36
+ Matter.Composite.add(parent, object);
37
+ self.on('finalize', () => {
38
+ Matter.Composite.remove(parent, object);
39
+ });
40
+ }
41
+ }
42
+
43
+ return xmatter;
44
+
45
+ }));
@@ -0,0 +1,40 @@
1
+ import xnew from 'xnew';
2
+ import Matter from 'matter-js';
3
+
4
+ var xmatter = {
5
+ initialize({ engine = null } = {}) {
6
+ xnew.extend(Root, { engine });
7
+ },
8
+ nest(object) {
9
+ xnew.extend(Nest, object);
10
+ return object;
11
+ },
12
+ get engine() {
13
+ var _a;
14
+ return (_a = xnew.context('xmatter.root')) === null || _a === void 0 ? void 0 : _a.engine;
15
+ },
16
+ };
17
+ function Root(self, { engine }) {
18
+ const root = {};
19
+ xnew.context('xmatter.root', root);
20
+ root.isActive = true;
21
+ root.engine = engine !== null && engine !== void 0 ? engine : Matter.Engine.create();
22
+ xnew.extend(Nest, root.engine.world);
23
+ self.on('update', () => {
24
+ if (root.isActive) {
25
+ Matter.Engine.update(root.engine);
26
+ }
27
+ });
28
+ }
29
+ function Nest(self, object) {
30
+ const parent = xnew.context('xmatter.object');
31
+ xnew.context('xmatter.object', object);
32
+ if (parent) {
33
+ Matter.Composite.add(parent, object);
34
+ self.on('finalize', () => {
35
+ Matter.Composite.remove(parent, object);
36
+ });
37
+ }
38
+ }
39
+
40
+ export { xmatter as default };
@@ -0,0 +1,10 @@
1
+ import * as PIXI from 'pixi.js';
2
+ declare const _default: {
3
+ initialize({ renderer, canvas }?: any): void;
4
+ nest(object: any): any;
5
+ sync(canvas: any): PIXI.Texture<PIXI.TextureSource<any>>;
6
+ readonly renderer: any;
7
+ readonly scene: any;
8
+ readonly canvas: any;
9
+ };
10
+ export default _default;
@@ -0,0 +1,101 @@
1
+ (function (global, factory) {
2
+ typeof exports === 'object' && typeof module !== 'undefined' ? module.exports = factory(require('xnew'), require('pixi.js')) :
3
+ typeof define === 'function' && define.amd ? define(['xnew', 'pixi.js'], factory) :
4
+ (global = typeof globalThis !== 'undefined' ? globalThis : global || self, global.xpixi = factory(global.xnew, global.PIXI));
5
+ })(this, (function (xnew, PIXI) { 'use strict';
6
+
7
+ function _interopNamespaceDefault(e) {
8
+ var n = Object.create(null);
9
+ if (e) {
10
+ Object.keys(e).forEach(function (k) {
11
+ if (k !== 'default') {
12
+ var d = Object.getOwnPropertyDescriptor(e, k);
13
+ Object.defineProperty(n, k, d.get ? d : {
14
+ enumerable: true,
15
+ get: function () { return e[k]; }
16
+ });
17
+ }
18
+ });
19
+ }
20
+ n.default = e;
21
+ return Object.freeze(n);
22
+ }
23
+
24
+ var PIXI__namespace = /*#__PURE__*/_interopNamespaceDefault(PIXI);
25
+
26
+ var xpixi = {
27
+ initialize({ renderer = null, canvas = null } = {}) {
28
+ xnew.extend(Root, { renderer, canvas });
29
+ },
30
+ nest(object) {
31
+ xnew.extend(Nest, object);
32
+ return object;
33
+ },
34
+ sync(canvas) {
35
+ const texture = PIXI__namespace.Texture.from(canvas);
36
+ xnew(PreUpdate, () => {
37
+ texture.source.update();
38
+ });
39
+ return texture;
40
+ },
41
+ get renderer() {
42
+ var _a;
43
+ return (_a = xnew.context('xpixi.root')) === null || _a === void 0 ? void 0 : _a.renderer;
44
+ },
45
+ get scene() {
46
+ var _a;
47
+ return (_a = xnew.context('xpixi.root')) === null || _a === void 0 ? void 0 : _a.scene;
48
+ },
49
+ get canvas() {
50
+ var _a;
51
+ return (_a = xnew.context('xpixi.root')) === null || _a === void 0 ? void 0 : _a.canvas;
52
+ }
53
+ };
54
+ function Root(self, { canvas }) {
55
+ const root = {};
56
+ xnew.context('xpixi.root', root);
57
+ root.canvas = canvas;
58
+ const renderer = PIXI__namespace.autoDetectRenderer({
59
+ width: canvas.width, height: canvas.height, view: canvas,
60
+ antialias: true, backgroundAlpha: 0,
61
+ });
62
+ root.renderer = null;
63
+ if (renderer instanceof Promise) {
64
+ xnew.promise(renderer).then((renderer) => root.renderer = renderer);
65
+ }
66
+ else {
67
+ root.renderer = renderer;
68
+ }
69
+ root.updates = [];
70
+ root.scene = new PIXI__namespace.Container();
71
+ xnew.context('xpixi.object', root.scene);
72
+ self.on('update', () => {
73
+ root.updates.forEach((update) => {
74
+ update();
75
+ });
76
+ if (root.renderer && root.scene) {
77
+ root.renderer.render(root.scene);
78
+ }
79
+ });
80
+ }
81
+ function Nest(self, object) {
82
+ const parent = xnew.context('xpixi.object');
83
+ xnew.context('xpixi.object', object);
84
+ if (parent) {
85
+ parent.addChild(object);
86
+ self.on('finalize', () => {
87
+ parent.removeChild(object);
88
+ });
89
+ }
90
+ }
91
+ function PreUpdate(self, callback) {
92
+ const root = xnew.context('xpixi.root');
93
+ root.updates.push(callback);
94
+ self.on('finalize', () => {
95
+ root.updates = root.updates.filter((update) => update !== callback);
96
+ });
97
+ }
98
+
99
+ return xpixi;
100
+
101
+ }));
@@ -0,0 +1,77 @@
1
+ import xnew from 'xnew';
2
+ import * as PIXI from 'pixi.js';
3
+
4
+ var xpixi = {
5
+ initialize({ renderer = null, canvas = null } = {}) {
6
+ xnew.extend(Root, { renderer, canvas });
7
+ },
8
+ nest(object) {
9
+ xnew.extend(Nest, object);
10
+ return object;
11
+ },
12
+ sync(canvas) {
13
+ const texture = PIXI.Texture.from(canvas);
14
+ xnew(PreUpdate, () => {
15
+ texture.source.update();
16
+ });
17
+ return texture;
18
+ },
19
+ get renderer() {
20
+ var _a;
21
+ return (_a = xnew.context('xpixi.root')) === null || _a === void 0 ? void 0 : _a.renderer;
22
+ },
23
+ get scene() {
24
+ var _a;
25
+ return (_a = xnew.context('xpixi.root')) === null || _a === void 0 ? void 0 : _a.scene;
26
+ },
27
+ get canvas() {
28
+ var _a;
29
+ return (_a = xnew.context('xpixi.root')) === null || _a === void 0 ? void 0 : _a.canvas;
30
+ }
31
+ };
32
+ function Root(self, { canvas }) {
33
+ const root = {};
34
+ xnew.context('xpixi.root', root);
35
+ root.canvas = canvas;
36
+ const renderer = PIXI.autoDetectRenderer({
37
+ width: canvas.width, height: canvas.height, view: canvas,
38
+ antialias: true, backgroundAlpha: 0,
39
+ });
40
+ root.renderer = null;
41
+ if (renderer instanceof Promise) {
42
+ xnew.promise(renderer).then((renderer) => root.renderer = renderer);
43
+ }
44
+ else {
45
+ root.renderer = renderer;
46
+ }
47
+ root.updates = [];
48
+ root.scene = new PIXI.Container();
49
+ xnew.context('xpixi.object', root.scene);
50
+ self.on('update', () => {
51
+ root.updates.forEach((update) => {
52
+ update();
53
+ });
54
+ if (root.renderer && root.scene) {
55
+ root.renderer.render(root.scene);
56
+ }
57
+ });
58
+ }
59
+ function Nest(self, object) {
60
+ const parent = xnew.context('xpixi.object');
61
+ xnew.context('xpixi.object', object);
62
+ if (parent) {
63
+ parent.addChild(object);
64
+ self.on('finalize', () => {
65
+ parent.removeChild(object);
66
+ });
67
+ }
68
+ }
69
+ function PreUpdate(self, callback) {
70
+ const root = xnew.context('xpixi.root');
71
+ root.updates.push(callback);
72
+ self.on('finalize', () => {
73
+ root.updates = root.updates.filter((update) => update !== callback);
74
+ });
75
+ }
76
+
77
+ export { xpixi as default };
@@ -0,0 +1,6 @@
1
+ declare const _default: {
2
+ initialize({ gravity, timestep }?: any): void;
3
+ nest(object: any): any;
4
+ readonly world: any;
5
+ };
6
+ export default _default;
@@ -0,0 +1,66 @@
1
+ (function (global, factory) {
2
+ typeof exports === 'object' && typeof module !== 'undefined' ? module.exports = factory(require('xnew'), require('@dimforge/rapier2d-compat')) :
3
+ typeof define === 'function' && define.amd ? define(['xnew', '@dimforge/rapier2d-compat'], factory) :
4
+ (global = typeof globalThis !== 'undefined' ? globalThis : global || self, global.xrapier2d = factory(global.xnew, global.RAPIER));
5
+ })(this, (function (xnew, RAPIER) { 'use strict';
6
+
7
+ var xrapier2d = {
8
+ initialize({ gravity = { x: 0.0, y: 9.81 }, timestep = null } = {}) {
9
+ xnew.extend(Root, { gravity, timestep });
10
+ },
11
+ nest(object) {
12
+ xnew.extend(Nest, object);
13
+ return object;
14
+ },
15
+ get world() {
16
+ var _a;
17
+ return (_a = xnew.context('xrapier2d.root')) === null || _a === void 0 ? void 0 : _a.world;
18
+ },
19
+ };
20
+ function Root(self, { gravity, timestep }) {
21
+ const root = {};
22
+ xnew.context('xrapier2d.root', root);
23
+ xnew.promise(RAPIER.init()).then(() => {
24
+ root.world = new RAPIER.World(gravity);
25
+ if (timestep !== null) {
26
+ root.world.timestep = timestep;
27
+ }
28
+ xnew.extend(Nest, root.world);
29
+ });
30
+ self.on('update', () => {
31
+ if (root.world) {
32
+ root.world.step();
33
+ }
34
+ });
35
+ }
36
+ function Nest(self, object) {
37
+ const parent = xnew.context('xrapier2d.object');
38
+ xnew.context('xrapier2d.object', object);
39
+ if (parent) {
40
+ // Rapier2D objects (RigidBody, Collider, etc.) are already added to the world
41
+ // when created, so we only need to handle removal on finalize
42
+ self.on('finalize', () => {
43
+ try {
44
+ // Check if object is a RigidBody
45
+ if (object.translation && typeof object.translation === 'function') {
46
+ parent.removeRigidBody(object);
47
+ }
48
+ // Check if object is a Collider
49
+ else if (object.shape && typeof object.shape === 'function') {
50
+ parent.removeCollider(object);
51
+ }
52
+ // Check if object is an ImpulseJoint
53
+ else if (object.impulse !== undefined) {
54
+ parent.removeImpulseJoint(object);
55
+ }
56
+ }
57
+ catch (e) {
58
+ // Object may have already been removed
59
+ }
60
+ });
61
+ }
62
+ }
63
+
64
+ return xrapier2d;
65
+
66
+ }));
@@ -0,0 +1,61 @@
1
+ import xnew from 'xnew';
2
+ import RAPIER from '@dimforge/rapier2d-compat';
3
+
4
+ var xrapier2d = {
5
+ initialize({ gravity = { x: 0.0, y: 9.81 }, timestep = null } = {}) {
6
+ xnew.extend(Root, { gravity, timestep });
7
+ },
8
+ nest(object) {
9
+ xnew.extend(Nest, object);
10
+ return object;
11
+ },
12
+ get world() {
13
+ var _a;
14
+ return (_a = xnew.context('xrapier2d.root')) === null || _a === void 0 ? void 0 : _a.world;
15
+ },
16
+ };
17
+ function Root(self, { gravity, timestep }) {
18
+ const root = {};
19
+ xnew.context('xrapier2d.root', root);
20
+ xnew.promise(RAPIER.init()).then(() => {
21
+ root.world = new RAPIER.World(gravity);
22
+ if (timestep !== null) {
23
+ root.world.timestep = timestep;
24
+ }
25
+ xnew.extend(Nest, root.world);
26
+ });
27
+ self.on('update', () => {
28
+ if (root.world) {
29
+ root.world.step();
30
+ }
31
+ });
32
+ }
33
+ function Nest(self, object) {
34
+ const parent = xnew.context('xrapier2d.object');
35
+ xnew.context('xrapier2d.object', object);
36
+ if (parent) {
37
+ // Rapier2D objects (RigidBody, Collider, etc.) are already added to the world
38
+ // when created, so we only need to handle removal on finalize
39
+ self.on('finalize', () => {
40
+ try {
41
+ // Check if object is a RigidBody
42
+ if (object.translation && typeof object.translation === 'function') {
43
+ parent.removeRigidBody(object);
44
+ }
45
+ // Check if object is a Collider
46
+ else if (object.shape && typeof object.shape === 'function') {
47
+ parent.removeCollider(object);
48
+ }
49
+ // Check if object is an ImpulseJoint
50
+ else if (object.impulse !== undefined) {
51
+ parent.removeImpulseJoint(object);
52
+ }
53
+ }
54
+ catch (e) {
55
+ // Object may have already been removed
56
+ }
57
+ });
58
+ }
59
+ }
60
+
61
+ export { xrapier2d as default };
@@ -0,0 +1,9 @@
1
+ declare const _default: {
2
+ initialize({ renderer, canvas, camera }?: any): void;
3
+ nest(object: any): any;
4
+ readonly renderer: any;
5
+ readonly camera: any;
6
+ readonly scene: any;
7
+ readonly canvas: any;
8
+ };
9
+ export default _default;
@@ -0,0 +1,77 @@
1
+ (function (global, factory) {
2
+ typeof exports === 'object' && typeof module !== 'undefined' ? module.exports = factory(require('xnew'), require('three')) :
3
+ typeof define === 'function' && define.amd ? define(['xnew', 'three'], factory) :
4
+ (global = typeof globalThis !== 'undefined' ? globalThis : global || self, global.xthree = factory(global.xnew, global.THREE));
5
+ })(this, (function (xnew, THREE) { 'use strict';
6
+
7
+ function _interopNamespaceDefault(e) {
8
+ var n = Object.create(null);
9
+ if (e) {
10
+ Object.keys(e).forEach(function (k) {
11
+ if (k !== 'default') {
12
+ var d = Object.getOwnPropertyDescriptor(e, k);
13
+ Object.defineProperty(n, k, d.get ? d : {
14
+ enumerable: true,
15
+ get: function () { return e[k]; }
16
+ });
17
+ }
18
+ });
19
+ }
20
+ n.default = e;
21
+ return Object.freeze(n);
22
+ }
23
+
24
+ var THREE__namespace = /*#__PURE__*/_interopNamespaceDefault(THREE);
25
+
26
+ var xthree = {
27
+ initialize({ renderer = null, canvas = null, camera = null } = {}) {
28
+ xnew.extend(Root, { renderer, canvas, camera });
29
+ },
30
+ nest(object) {
31
+ xnew.extend(Nest, object);
32
+ return object;
33
+ },
34
+ get renderer() {
35
+ var _a;
36
+ return (_a = xnew.context('xthree.root')) === null || _a === void 0 ? void 0 : _a.renderer;
37
+ },
38
+ get camera() {
39
+ var _a;
40
+ return (_a = xnew.context('xthree.root')) === null || _a === void 0 ? void 0 : _a.camera;
41
+ },
42
+ get scene() {
43
+ var _a;
44
+ return (_a = xnew.context('xthree.root')) === null || _a === void 0 ? void 0 : _a.scene;
45
+ },
46
+ get canvas() {
47
+ var _a;
48
+ return (_a = xnew.context('xthree.root')) === null || _a === void 0 ? void 0 : _a.canvas;
49
+ }
50
+ };
51
+ function Root(self, { canvas, camera }) {
52
+ const root = {};
53
+ xnew.context('xthree.root', root);
54
+ root.canvas = canvas;
55
+ root.renderer = new THREE__namespace.WebGLRenderer({ canvas, alpha: true });
56
+ root.renderer.setClearColor(0x000000, 0);
57
+ root.camera = camera !== null && camera !== void 0 ? camera : new THREE__namespace.PerspectiveCamera(45, root.renderer.domElement.width / root.renderer.domElement.height);
58
+ root.scene = new THREE__namespace.Scene();
59
+ xnew.extend(Nest, root.scene);
60
+ self.on('update', () => {
61
+ root.renderer.render(root.scene, root.camera);
62
+ });
63
+ }
64
+ function Nest(self, object) {
65
+ const parent = xnew.context('xthree.object');
66
+ xnew.context('xthree.object', object);
67
+ if (parent) {
68
+ parent === null || parent === void 0 ? void 0 : parent.add(object);
69
+ self.on('finalize', () => {
70
+ parent === null || parent === void 0 ? void 0 : parent.remove(object);
71
+ });
72
+ }
73
+ }
74
+
75
+ return xthree;
76
+
77
+ }));
@@ -0,0 +1,53 @@
1
+ import xnew from 'xnew';
2
+ import * as THREE from 'three';
3
+
4
+ var xthree = {
5
+ initialize({ renderer = null, canvas = null, camera = null } = {}) {
6
+ xnew.extend(Root, { renderer, canvas, camera });
7
+ },
8
+ nest(object) {
9
+ xnew.extend(Nest, object);
10
+ return object;
11
+ },
12
+ get renderer() {
13
+ var _a;
14
+ return (_a = xnew.context('xthree.root')) === null || _a === void 0 ? void 0 : _a.renderer;
15
+ },
16
+ get camera() {
17
+ var _a;
18
+ return (_a = xnew.context('xthree.root')) === null || _a === void 0 ? void 0 : _a.camera;
19
+ },
20
+ get scene() {
21
+ var _a;
22
+ return (_a = xnew.context('xthree.root')) === null || _a === void 0 ? void 0 : _a.scene;
23
+ },
24
+ get canvas() {
25
+ var _a;
26
+ return (_a = xnew.context('xthree.root')) === null || _a === void 0 ? void 0 : _a.canvas;
27
+ }
28
+ };
29
+ function Root(self, { canvas, camera }) {
30
+ const root = {};
31
+ xnew.context('xthree.root', root);
32
+ root.canvas = canvas;
33
+ root.renderer = new THREE.WebGLRenderer({ canvas, alpha: true });
34
+ root.renderer.setClearColor(0x000000, 0);
35
+ root.camera = camera !== null && camera !== void 0 ? camera : new THREE.PerspectiveCamera(45, root.renderer.domElement.width / root.renderer.domElement.height);
36
+ root.scene = new THREE.Scene();
37
+ xnew.extend(Nest, root.scene);
38
+ self.on('update', () => {
39
+ root.renderer.render(root.scene, root.camera);
40
+ });
41
+ }
42
+ function Nest(self, object) {
43
+ const parent = xnew.context('xthree.object');
44
+ xnew.context('xthree.object', object);
45
+ if (parent) {
46
+ parent === null || parent === void 0 ? void 0 : parent.add(object);
47
+ self.on('finalize', () => {
48
+ parent === null || parent === void 0 ? void 0 : parent.remove(object);
49
+ });
50
+ }
51
+ }
52
+
53
+ export { xthree as default };
@@ -0,0 +1,13 @@
1
+ export type AudioNodeMap = {
2
+ [key: string]: AudioNode & {
3
+ [key: string]: any;
4
+ };
5
+ };
6
+ export declare class Audio {
7
+ static context: AudioContext | null;
8
+ static master: GainNode | null;
9
+ static initialize(): void;
10
+ static connect(params: {
11
+ [key: string]: any[];
12
+ }): AudioNodeMap;
13
+ }
@@ -0,0 +1 @@
1
+ export {};