@mulsense/xnew 0.3.3 → 0.3.5

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.
@@ -1,7 +1,9 @@
1
+ import * as PIXI from 'pixi.js';
2
+
1
3
  declare const _default: {
2
4
  initialize({ renderer, canvas }?: any): void;
3
5
  nest(object: any): any;
4
- sync(canvas: any): any;
6
+ sync(canvas: any): PIXI.Texture<PIXI.TextureSource<any>>;
5
7
  readonly renderer: any;
6
8
  readonly scene: any;
7
9
  readonly canvas: any;
@@ -55,12 +55,11 @@
55
55
  const root = {};
56
56
  xnew.context('xpixi.root', root);
57
57
  root.canvas = canvas;
58
- const renderer = PIXI__namespace.autoDetectRenderer({
58
+ root.renderer = null;
59
+ xnew.promise(PIXI__namespace.autoDetectRenderer({
59
60
  width: canvas.width, height: canvas.height, view: canvas,
60
61
  antialias: true, backgroundAlpha: 0,
61
- });
62
- root.renderer = null;
63
- xnew.promise(renderer, false).then((renderer) => root.renderer = renderer);
62
+ })).then((renderer) => root.renderer = renderer);
64
63
  root.updates = [];
65
64
  root.scene = new PIXI__namespace.Container();
66
65
  xnew.context('xpixi.object', root.scene);
@@ -33,12 +33,11 @@ function Root(self, { canvas }) {
33
33
  const root = {};
34
34
  xnew.context('xpixi.root', root);
35
35
  root.canvas = canvas;
36
- const renderer = PIXI.autoDetectRenderer({
36
+ root.renderer = null;
37
+ xnew.promise(PIXI.autoDetectRenderer({
37
38
  width: canvas.width, height: canvas.height, view: canvas,
38
39
  antialias: true, backgroundAlpha: 0,
39
- });
40
- root.renderer = null;
41
- xnew.promise(renderer, false).then((renderer) => root.renderer = renderer);
40
+ })).then((renderer) => root.renderer = renderer);
42
41
  root.updates = [];
43
42
  root.scene = new PIXI.Container();
44
43
  xnew.context('xpixi.object', root.scene);
@@ -1,6 +1,5 @@
1
1
  declare const _default: {
2
- initialize({ gravity, timestep }?: any): void;
3
- connect(type: any, object: any): any;
2
+ initialize({ gravity }?: any): void;
4
3
  readonly world: any;
5
4
  };
6
5
 
@@ -5,62 +5,22 @@
5
5
  })(this, (function (xnew, RAPIER) { 'use strict';
6
6
 
7
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;
8
+ initialize({ gravity = { x: 0.0, y: 9.81 } } = {}) {
9
+ xnew.extend(Root, { gravity });
14
10
  },
15
11
  get world() {
16
12
  var _a;
17
13
  return (_a = xnew.context('xrapier2d.root')) === null || _a === void 0 ? void 0 : _a.world;
18
14
  },
19
15
  };
20
- function Root(self, { gravity, timestep }) {
16
+ function Root(self, { gravity }) {
21
17
  const root = {};
22
18
  xnew.context('xrapier2d.root', root);
23
- xnew.promise(RAPIER.init(), false).then(() => {
19
+ xnew.promise(RAPIER.init()).then(() => {
24
20
  root.world = new RAPIER.World(gravity);
25
- if (timestep !== null) {
26
- root.world.timestep = timestep;
27
- }
28
- // xnew.extend(Nest, root.world);
29
21
  });
30
22
  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
- }
23
+ root.world.step();
64
24
  });
65
25
  }
66
26
 
@@ -2,62 +2,22 @@ import xnew from '@mulsense/xnew';
2
2
  import RAPIER from '@dimforge/rapier2d-compat';
3
3
 
4
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;
5
+ initialize({ gravity = { x: 0.0, y: 9.81 } } = {}) {
6
+ xnew.extend(Root, { gravity });
11
7
  },
12
8
  get world() {
13
9
  var _a;
14
10
  return (_a = xnew.context('xrapier2d.root')) === null || _a === void 0 ? void 0 : _a.world;
15
11
  },
16
12
  };
17
- function Root(self, { gravity, timestep }) {
13
+ function Root(self, { gravity }) {
18
14
  const root = {};
19
15
  xnew.context('xrapier2d.root', root);
20
- xnew.promise(RAPIER.init(), false).then(() => {
16
+ xnew.promise(RAPIER.init()).then(() => {
21
17
  root.world = new RAPIER.World(gravity);
22
- if (timestep !== null) {
23
- root.world.timestep = timestep;
24
- }
25
- // xnew.extend(Nest, root.world);
26
18
  });
27
19
  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
- }
20
+ root.world.step();
61
21
  });
62
22
  }
63
23
 
@@ -0,0 +1,6 @@
1
+ declare const _default: {
2
+ initialize({ gravity }?: any): void;
3
+ readonly world: any;
4
+ };
5
+
6
+ export { _default as default };
@@ -0,0 +1,34 @@
1
+ (function (global, factory) {
2
+ typeof exports === 'object' && typeof module !== 'undefined' ? module.exports = factory(require('@mulsense/xnew'), require('@dimforge/rapier3d-compat')) :
3
+ typeof define === 'function' && define.amd ? define(['@mulsense/xnew', '@dimforge/rapier3d-compat'], factory) :
4
+ (global = typeof globalThis !== 'undefined' ? globalThis : global || self, global.xrapier3d = factory(global.xnew, global.RAPIER));
5
+ })(this, (function (xnew, RAPIER) { 'use strict';
6
+
7
+ var xrapier3d = {
8
+ initialize({ gravity = { x: 0.0, y: 9.81, z: 0.0 }, timestep = null } = {}) {
9
+ xnew.extend(Root, { gravity, timestep });
10
+ },
11
+ get world() {
12
+ var _a;
13
+ return (_a = xnew.context('xrapier3d.root')) === null || _a === void 0 ? void 0 : _a.world;
14
+ },
15
+ };
16
+ function Root(self, { gravity, timestep }) {
17
+ const root = {};
18
+ xnew.context('xrapier3d.root', root);
19
+ xnew.promise(RAPIER.init()).then(() => {
20
+ root.world = new RAPIER.World(gravity);
21
+ if (timestep !== null) {
22
+ root.world.timestep = timestep;
23
+ }
24
+ });
25
+ self.on('update', () => {
26
+ if (root.world) {
27
+ root.world.step();
28
+ }
29
+ });
30
+ }
31
+
32
+ return xrapier3d;
33
+
34
+ }));
@@ -0,0 +1,29 @@
1
+ import xnew from '@mulsense/xnew';
2
+ import RAPIER from '@dimforge/rapier3d-compat';
3
+
4
+ var xrapier3d = {
5
+ initialize({ gravity = { x: 0.0, y: 9.81, z: 0.0 }, timestep = null } = {}) {
6
+ xnew.extend(Root, { gravity, timestep });
7
+ },
8
+ get world() {
9
+ var _a;
10
+ return (_a = xnew.context('xrapier3d.root')) === null || _a === void 0 ? void 0 : _a.world;
11
+ },
12
+ };
13
+ function Root(self, { gravity, timestep }) {
14
+ const root = {};
15
+ xnew.context('xrapier3d.root', root);
16
+ xnew.promise(RAPIER.init()).then(() => {
17
+ root.world = new RAPIER.World(gravity);
18
+ if (timestep !== null) {
19
+ root.world.timestep = timestep;
20
+ }
21
+ });
22
+ self.on('update', () => {
23
+ if (root.world) {
24
+ root.world.step();
25
+ }
26
+ });
27
+ }
28
+
29
+ export { xrapier3d as default };
package/dist/xnew.d.ts CHANGED
@@ -46,6 +46,7 @@ interface UnitInternal {
46
46
  baseComponent: Function;
47
47
  currentElement: UnitElement;
48
48
  currentContext: Context;
49
+ currentComponent: Function | null;
49
50
  anchor: UnitElement | null;
50
51
  state: string;
51
52
  tostart: boolean;
@@ -97,8 +98,8 @@ declare class Unit {
97
98
  }
98
99
  declare class UnitPromise {
99
100
  promise: Promise<any>;
100
- useResult: Boolean;
101
- constructor(promise: Promise<any>, useResult: Boolean);
101
+ component: Function | null;
102
+ constructor(promise: Promise<any>, component: Function | null);
102
103
  then(callback: Function): UnitPromise;
103
104
  catch(callback: Function): UnitPromise;
104
105
  finally(callback: Function): UnitPromise;
@@ -170,7 +171,7 @@ declare const xnew$1: CreateUnit & {
170
171
  * @example
171
172
  * xnew.promise(fetchData()).then(data => console.log(data))
172
173
  */
173
- promise(promise: Promise<any>, useResult?: Boolean): UnitPromise;
174
+ promise(promise: Promise<any>): UnitPromise;
174
175
  /**
175
176
  * Handles successful resolution of all registered promises in the current component
176
177
  * @param callback - Function to call when all promises resolve
@@ -274,6 +275,7 @@ declare function AccordionContent(content: Unit, {}?: {}): {
274
275
  };
275
276
 
276
277
  declare function ResizeEvent(resize: Unit): void;
278
+ declare function DirectEvent(unit: Unit): void;
277
279
  declare function KeyboardEvent(keyboard: Unit): void;
278
280
  declare function PointerEvent(unit: Unit): void;
279
281
 
@@ -728,6 +730,7 @@ declare class Synthesizer {
728
730
  declare const basics: {
729
731
  Screen: typeof Screen;
730
732
  PointerEvent: typeof PointerEvent;
733
+ DirectEvent: typeof DirectEvent;
731
734
  ResizeEvent: typeof ResizeEvent;
732
735
  KeyboardEvent: typeof KeyboardEvent;
733
736
  ModalFrame: typeof ModalFrame;