@mulsense/xnew 0.1.10 → 0.1.12

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 CHANGED
@@ -1,46 +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/@mulsense/xnew@0.1.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
- "@mulsense/xnew": "https://unpkg.com/@mulsense/xnew@0.1.x/dist/xnew.mjs"
26
- }
27
- }
28
- </script>
29
-
30
- <script type="module">
31
- import xnew from '@mulsense/xnew';
32
-
33
- // Your code here
34
- </script>
35
- ```
36
-
37
- ### Via npm
38
- Install `xnew` using npm:
39
- ```bash
40
- npm install @mulsense/xnew@0.1.x
41
- ```
42
-
43
- Then import it in your JavaScript file:
44
- ```js
45
- import xnew from '@mulsense/xnew';
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/@mulsense/xnew@0.1.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
+ "@mulsense/xnew": "https://unpkg.com/@mulsense/xnew@0.1.x/dist/xnew.mjs"
26
+ }
27
+ }
28
+ </script>
29
+
30
+ <script type="module">
31
+ import xnew from '@mulsense/xnew';
32
+
33
+ // Your code here
34
+ </script>
35
+ ```
36
+
37
+ ### Via npm
38
+ Install `xnew` using npm:
39
+ ```bash
40
+ npm install @mulsense/xnew@0.1.x
41
+ ```
42
+
43
+ Then import it in your JavaScript file:
44
+ ```js
45
+ import xnew from '@mulsense/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,43 @@
1
+ (function (global, factory) {
2
+ typeof exports === 'object' && typeof module !== 'undefined' ? module.exports = factory(require('@mulsense/xnew'), require('matter-js')) :
3
+ typeof define === 'function' && define.amd ? define(['@mulsense/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.context('xmatter.object', 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
+ Matter.Composite.add(parent, object);
36
+ self.on('finalize', () => {
37
+ Matter.Composite.remove(parent, object);
38
+ });
39
+ }
40
+
41
+ return xmatter;
42
+
43
+ }));
@@ -0,0 +1,38 @@
1
+ import xnew from '@mulsense/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.context('xmatter.object', 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
+ Matter.Composite.add(parent, object);
33
+ self.on('finalize', () => {
34
+ Matter.Composite.remove(parent, object);
35
+ });
36
+ }
37
+
38
+ 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,106 @@
1
+ (function (global, factory) {
2
+ typeof exports === 'object' && typeof module !== 'undefined' ? module.exports = factory(require('@mulsense/xnew'), require('pixi.js')) :
3
+ typeof define === 'function' && define.amd ? define(['@mulsense/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
+ capture() {
54
+ var _a, _b;
55
+ const render = (_a = xnew.context('xpixi.root')) === null || _a === void 0 ? void 0 : _a.renderer;
56
+ const scene = (_b = xnew.context('xpixi.root')) === null || _b === void 0 ? void 0 : _b.scene;
57
+ const canvas = render.extract.canvas(scene);
58
+ return canvas.toDataURL('image/png', 1.0);
59
+ }
60
+ };
61
+ function Root(self, { canvas }) {
62
+ const root = {};
63
+ xnew.context('xpixi.root', root);
64
+ root.canvas = canvas;
65
+ const renderer = PIXI__namespace.autoDetectRenderer({
66
+ width: canvas.width, height: canvas.height, view: canvas,
67
+ antialias: true, backgroundAlpha: 0,
68
+ });
69
+ root.renderer = null;
70
+ if (renderer instanceof Promise) {
71
+ xnew.promise(renderer).then((renderer) => root.renderer = renderer);
72
+ }
73
+ else {
74
+ root.renderer = renderer;
75
+ }
76
+ root.updates = [];
77
+ root.scene = new PIXI__namespace.Container();
78
+ xnew.context('xpixi.object', root.scene);
79
+ self.on('update', () => {
80
+ root.updates.forEach((update) => {
81
+ update();
82
+ });
83
+ if (root.renderer && root.scene) {
84
+ root.renderer.render(root.scene);
85
+ }
86
+ });
87
+ }
88
+ function Nest(self, { object }) {
89
+ const parent = xnew.context('xpixi.object');
90
+ xnew.context('xpixi.object', object);
91
+ parent.addChild(object);
92
+ self.on('finalize', () => {
93
+ parent.removeChild(object);
94
+ });
95
+ }
96
+ function PreUpdate(self, callback) {
97
+ const root = xnew.context('xpixi.root');
98
+ root.updates.push(callback);
99
+ self.on('finalize', () => {
100
+ root.updates = root.updates.filter((update) => update !== callback);
101
+ });
102
+ }
103
+
104
+ return xpixi;
105
+
106
+ }));
@@ -0,0 +1,82 @@
1
+ import xnew from '@mulsense/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
+ capture() {
32
+ var _a, _b;
33
+ const render = (_a = xnew.context('xpixi.root')) === null || _a === void 0 ? void 0 : _a.renderer;
34
+ const scene = (_b = xnew.context('xpixi.root')) === null || _b === void 0 ? void 0 : _b.scene;
35
+ const canvas = render.extract.canvas(scene);
36
+ return canvas.toDataURL('image/png', 1.0);
37
+ }
38
+ };
39
+ function Root(self, { canvas }) {
40
+ const root = {};
41
+ xnew.context('xpixi.root', root);
42
+ root.canvas = canvas;
43
+ const renderer = PIXI.autoDetectRenderer({
44
+ width: canvas.width, height: canvas.height, view: canvas,
45
+ antialias: true, backgroundAlpha: 0,
46
+ });
47
+ root.renderer = null;
48
+ if (renderer instanceof Promise) {
49
+ xnew.promise(renderer).then((renderer) => root.renderer = renderer);
50
+ }
51
+ else {
52
+ root.renderer = renderer;
53
+ }
54
+ root.updates = [];
55
+ root.scene = new PIXI.Container();
56
+ xnew.context('xpixi.object', root.scene);
57
+ self.on('update', () => {
58
+ root.updates.forEach((update) => {
59
+ update();
60
+ });
61
+ if (root.renderer && root.scene) {
62
+ root.renderer.render(root.scene);
63
+ }
64
+ });
65
+ }
66
+ function Nest(self, { object }) {
67
+ const parent = xnew.context('xpixi.object');
68
+ xnew.context('xpixi.object', object);
69
+ parent.addChild(object);
70
+ self.on('finalize', () => {
71
+ parent.removeChild(object);
72
+ });
73
+ }
74
+ function PreUpdate(self, callback) {
75
+ const root = xnew.context('xpixi.root');
76
+ root.updates.push(callback);
77
+ self.on('finalize', () => {
78
+ root.updates = root.updates.filter((update) => update !== callback);
79
+ });
80
+ }
81
+
82
+ export { xpixi as default };
@@ -0,0 +1,6 @@
1
+ declare const _default: {
2
+ initialize({ gravity, timestep }?: any): void;
3
+ connect(type: any, object: any): any;
4
+ readonly world: any;
5
+ };
6
+ export default _default;
@@ -0,0 +1,69 @@
1
+ (function (global, factory) {
2
+ typeof exports === 'object' && typeof module !== 'undefined' ? module.exports = factory(require('@mulsense/xnew'), require('@dimforge/rapier2d-compat')) :
3
+ typeof define === 'function' && define.amd ? define(['@mulsense/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
+ connect(type, object) {
12
+ xnew.extend(Connect, { type, 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
+ let count = 0;
37
+ function Connect(self, { type, object }) {
38
+ const root = xnew.context('xrapier2d.root');
39
+ let temp = count++;
40
+ console.log(temp, type, object);
41
+ // Rapier2D objects (RigidBody, Collider, etc.) are already added to the world
42
+ // when created, so we only need to handle removal on finalize
43
+ self.on('finalize', () => {
44
+ try {
45
+ // Check if object is a RigidBody
46
+ if (type === 'rigidBody') {
47
+ console.log('Removing RigidBody');
48
+ root.world.removeRigidBody(object);
49
+ }
50
+ // Check if object is a Collider
51
+ else if (type === 'collider') {
52
+ console.log('Removing Collider');
53
+ root.world.removeCollider(object);
54
+ }
55
+ // Check if object is an ImpulseJoint
56
+ else if (type === 'impulseJoint') {
57
+ console.log('Removing ImpulseJoint');
58
+ root.world.removeImpulseJoint(object);
59
+ }
60
+ }
61
+ catch (e) {
62
+ // Object may have already been removed
63
+ }
64
+ });
65
+ }
66
+
67
+ return xrapier2d;
68
+
69
+ }));
@@ -0,0 +1,64 @@
1
+ import xnew from '@mulsense/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
+ connect(type, object) {
9
+ xnew.extend(Connect, { type, 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
+ let count = 0;
34
+ function Connect(self, { type, object }) {
35
+ const root = xnew.context('xrapier2d.root');
36
+ let temp = count++;
37
+ console.log(temp, type, object);
38
+ // Rapier2D objects (RigidBody, Collider, etc.) are already added to the world
39
+ // when created, so we only need to handle removal on finalize
40
+ self.on('finalize', () => {
41
+ try {
42
+ // Check if object is a RigidBody
43
+ if (type === 'rigidBody') {
44
+ console.log('Removing RigidBody');
45
+ root.world.removeRigidBody(object);
46
+ }
47
+ // Check if object is a Collider
48
+ else if (type === 'collider') {
49
+ console.log('Removing Collider');
50
+ root.world.removeCollider(object);
51
+ }
52
+ // Check if object is an ImpulseJoint
53
+ else if (type === 'impulseJoint') {
54
+ console.log('Removing ImpulseJoint');
55
+ root.world.removeImpulseJoint(object);
56
+ }
57
+ }
58
+ catch (e) {
59
+ // Object may have already been removed
60
+ }
61
+ });
62
+ }
63
+
64
+ 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('@mulsense/xnew'), require('three')) :
3
+ typeof define === 'function' && define.amd ? define(['@mulsense/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.context('xthree.object', 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 '@mulsense/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.context('xthree.object', 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 };