@thi.ng/scenegraph 0.6.33 → 1.0.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/CHANGELOG.md CHANGED
@@ -1,6 +1,6 @@
1
1
  # Change Log
2
2
 
3
- - **Last updated**: 2023-11-09T10:28:19Z
3
+ - **Last updated**: 2023-11-24T09:35:46Z
4
4
  - **Generator**: [thi.ng/monopub](https://thi.ng/monopub)
5
5
 
6
6
  All notable changes to this project will be documented in this file.
@@ -9,6 +9,15 @@ See [Conventional Commits](https://conventionalcommits.org/) for commit guidelin
9
9
  **Note:** Unlisted _patch_ versions only involve non-code or otherwise excluded changes
10
10
  and/or version bumps of transitive dependencies.
11
11
 
12
+ # [1.0.0](https://github.com/thi-ng/umbrella/tree/@thi.ng/scenegraph@1.0.0) (2023-11-12)
13
+
14
+ #### 🛑 Breaking changes
15
+
16
+ - update ISceneNode, ANode ([a2a2694](https://github.com/thi-ng/umbrella/commit/a2a2694))
17
+ - BREAKING CHANGE: add child ops to ISceneNode interface
18
+ - update ANode.deleteChild()
19
+ - simplify Node2/3 impls
20
+
12
21
  ### [0.6.32](https://github.com/thi-ng/umbrella/tree/@thi.ng/scenegraph@0.6.32) (2023-11-09)
13
22
 
14
23
  #### ♻️ Refactoring
package/README.md CHANGED
@@ -58,7 +58,7 @@ For Node.js REPL:
58
58
  const scenegraph = await import("@thi.ng/scenegraph");
59
59
  ```
60
60
 
61
- Package sizes (brotli'd, pre-treeshake): ESM: 989 bytes
61
+ Package sizes (brotli'd, pre-treeshake): ESM: 982 bytes
62
62
 
63
63
  ## Dependencies
64
64
 
package/anode.d.ts CHANGED
@@ -14,7 +14,7 @@ export declare abstract class ANode<T extends ISceneNode<any>> {
14
14
  constructor(id: string, parent?: Nullable<T>, body?: any);
15
15
  appendChild(node: T): this;
16
16
  insertChild(i: number, node: T): this;
17
- abstract deleteChild(node: number | T): boolean;
17
+ deleteChild(node: number | T): boolean;
18
18
  abstract update(): void;
19
19
  draw<T>(ctx: T): void;
20
20
  /**
@@ -61,6 +61,5 @@ export declare abstract class ANode<T extends ISceneNode<any>> {
61
61
  * @param p -
62
62
  */
63
63
  containsLocalPoint(_: ReadonlyVec): boolean;
64
- protected _deleteChild(node: number | T, clazz: any): boolean;
65
64
  }
66
65
  //# sourceMappingURL=anode.d.ts.map
package/anode.js CHANGED
@@ -1,3 +1,4 @@
1
+ import { isNumber } from "@thi.ng/checks/is-number";
1
2
  import { assert } from "@thi.ng/errors/assert";
2
3
  export class ANode {
3
4
  id;
@@ -13,7 +14,7 @@ export class ANode {
13
14
  this.parent = parent;
14
15
  this.children = [];
15
16
  if (parent) {
16
- parent.children.push(this);
17
+ parent.appendChild(this);
17
18
  }
18
19
  this.body = body;
19
20
  this.mat = [];
@@ -34,6 +35,15 @@ export class ANode {
34
35
  node.update();
35
36
  return this;
36
37
  }
38
+ deleteChild(node) {
39
+ const { children } = this;
40
+ const i = isNumber(node) ? node : children.indexOf(node);
41
+ if (i >= 0 && i < children.length) {
42
+ children.splice(i, 1);
43
+ return true;
44
+ }
45
+ return false;
46
+ }
37
47
  draw(ctx) {
38
48
  if (this.display) {
39
49
  for (let c of this.children) {
@@ -79,14 +89,4 @@ export class ANode {
79
89
  containsLocalPoint(_) {
80
90
  return false;
81
91
  }
82
- _deleteChild(node, clazz) {
83
- const i = node instanceof clazz
84
- ? this.children.indexOf(node)
85
- : node;
86
- if (i !== -1) {
87
- this.children.splice(i, 1);
88
- return true;
89
- }
90
- return false;
91
- }
92
92
  }
package/api.d.ts CHANGED
@@ -6,6 +6,9 @@ export interface ISceneNode<T extends ISceneNode<T>> extends IID<string> {
6
6
  children: T[];
7
7
  mat: Mat;
8
8
  invMat: Mat;
9
+ appendChild(node: T): this;
10
+ insertChild(i: number, node: T): this;
11
+ deleteChild(node: number | T): boolean;
9
12
  update(): void;
10
13
  draw<D>(ctx: D): void;
11
14
  mapGlobalPoint(p: ReadonlyVec): Vec | undefined;
package/node2.d.ts CHANGED
@@ -8,7 +8,6 @@ export declare class Node2D extends ANode<Node2D> implements ICopy<Node2D>, ISce
8
8
  scale: Vec | number;
9
9
  constructor(id: string, parent?: Nullable<Node2D>, translate?: Vec, rotate?: number, scale?: Vec | number, body?: any);
10
10
  copy(): Node2D;
11
- deleteChild(node: number | Node2D): boolean;
12
11
  update(): void;
13
12
  mapGlobalPoint(p: ReadonlyVec): Vec;
14
13
  mapLocalPointToGlobal(p: ReadonlyVec): Vec;
package/node2.js CHANGED
@@ -20,9 +20,6 @@ export class Node2D extends ANode {
20
20
  copy() {
21
21
  return new Node2D(this.id, this.parent, set2([], this.translate), this.rotate, set2([], this.scale), this.body);
22
22
  }
23
- deleteChild(node) {
24
- return this._deleteChild(node, Node2D);
25
- }
26
23
  update() {
27
24
  if (this.enabled) {
28
25
  this.mat = transform23([], this.translate, this.rotate, this.scale);
package/node3.d.ts CHANGED
@@ -8,7 +8,6 @@ export declare class Node3D extends ANode<Node3D> implements ICopy<Node3D>, ISce
8
8
  scale: Vec | number;
9
9
  constructor(id: string, parent?: Nullable<Node3D>, translate?: Vec, rotate?: Vec, scale?: Vec | number, body?: any);
10
10
  copy(): Node3D;
11
- deleteChild(node: number | Node3D): boolean;
12
11
  update(): void;
13
12
  mapGlobalPoint(p: ReadonlyVec): Vec | undefined;
14
13
  mapLocalPointToGlobal(p: ReadonlyVec): Vec | undefined;
package/node3.js CHANGED
@@ -20,9 +20,6 @@ export class Node3D extends ANode {
20
20
  copy() {
21
21
  return new Node3D(this.id, this.parent, set3([], this.translate), set3([], this.rotate), set3([], this.scale), this.body);
22
22
  }
23
- deleteChild(node) {
24
- return this._deleteChild(node, Node3D);
25
- }
26
23
  update() {
27
24
  if (this.enabled) {
28
25
  this.mat = transform44([], this.translate, this.rotate, this.scale);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@thi.ng/scenegraph",
3
- "version": "0.6.33",
3
+ "version": "1.0.1",
4
4
  "description": "Extensible 2D/3D scene graph with @thi.ng/hiccup-canvas support",
5
5
  "type": "module",
6
6
  "module": "./index.js",
@@ -33,19 +33,19 @@
33
33
  "test": "bun test"
34
34
  },
35
35
  "dependencies": {
36
- "@thi.ng/api": "^8.9.8",
37
- "@thi.ng/checks": "^3.4.8",
38
- "@thi.ng/errors": "^2.4.2",
39
- "@thi.ng/matrices": "^2.2.8",
40
- "@thi.ng/vectors": "^7.8.4"
36
+ "@thi.ng/api": "^8.9.9",
37
+ "@thi.ng/checks": "^3.4.9",
38
+ "@thi.ng/errors": "^2.4.3",
39
+ "@thi.ng/matrices": "^2.2.10",
40
+ "@thi.ng/vectors": "^7.8.6"
41
41
  },
42
42
  "devDependencies": {
43
- "@microsoft/api-extractor": "^7.38.2",
44
- "@thi.ng/testament": "^0.4.1",
43
+ "@microsoft/api-extractor": "^7.38.3",
44
+ "@thi.ng/testament": "^0.4.2",
45
45
  "rimraf": "^5.0.5",
46
46
  "tools": "^0.0.1",
47
47
  "typedoc": "^0.25.3",
48
- "typescript": "^5.2.2"
48
+ "typescript": "^5.3.2"
49
49
  },
50
50
  "keywords": [
51
51
  "2d",
@@ -97,5 +97,5 @@
97
97
  ],
98
98
  "status": "alpha"
99
99
  },
100
- "gitHead": "669a3151e4302480244fe3e60eff5e732ea5b7a7\n"
100
+ "gitHead": "f6de41f4991704fdbbb2899bb430ed4f4f6efab0\n"
101
101
  }