@thi.ng/scenegraph 0.6.31 → 1.0.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/CHANGELOG.md +16 -1
- package/README.md +1 -1
- package/anode.d.ts +1 -2
- package/anode.js +19 -11
- package/api.d.ts +3 -0
- package/node2.d.ts +0 -1
- package/node2.js +3 -3
- package/node3.d.ts +0 -1
- package/node3.js +3 -3
- package/package.json +12 -13
package/CHANGELOG.md
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
# Change Log
|
|
2
2
|
|
|
3
|
-
- **Last updated**: 2023-
|
|
3
|
+
- **Last updated**: 2023-11-12T16:43:31Z
|
|
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,21 @@ 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
|
+
|
|
21
|
+
### [0.6.32](https://github.com/thi-ng/umbrella/tree/@thi.ng/scenegraph@0.6.32) (2023-11-09)
|
|
22
|
+
|
|
23
|
+
#### ♻️ Refactoring
|
|
24
|
+
|
|
25
|
+
- update all tests (packages A-S) ([e3085e4](https://github.com/thi-ng/umbrella/commit/e3085e4))
|
|
26
|
+
|
|
12
27
|
## [0.6.0](https://github.com/thi-ng/umbrella/tree/@thi.ng/scenegraph@0.6.0) (2023-04-19)
|
|
13
28
|
|
|
14
29
|
#### 🚀 Features
|
package/README.md
CHANGED
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
|
-
|
|
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,11 +1,20 @@
|
|
|
1
|
+
import { isNumber } from "@thi.ng/checks/is-number";
|
|
1
2
|
import { assert } from "@thi.ng/errors/assert";
|
|
2
3
|
export class ANode {
|
|
4
|
+
id;
|
|
5
|
+
parent;
|
|
6
|
+
children;
|
|
7
|
+
body;
|
|
8
|
+
mat;
|
|
9
|
+
invMat;
|
|
10
|
+
enabled;
|
|
11
|
+
display;
|
|
3
12
|
constructor(id, parent, body) {
|
|
4
13
|
this.id = id;
|
|
5
14
|
this.parent = parent;
|
|
6
15
|
this.children = [];
|
|
7
16
|
if (parent) {
|
|
8
|
-
parent.
|
|
17
|
+
parent.appendChild(this);
|
|
9
18
|
}
|
|
10
19
|
this.body = body;
|
|
11
20
|
this.mat = [];
|
|
@@ -26,6 +35,15 @@ export class ANode {
|
|
|
26
35
|
node.update();
|
|
27
36
|
return this;
|
|
28
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
|
+
}
|
|
29
47
|
draw(ctx) {
|
|
30
48
|
if (this.display) {
|
|
31
49
|
for (let c of this.children) {
|
|
@@ -71,14 +89,4 @@ export class ANode {
|
|
|
71
89
|
containsLocalPoint(_) {
|
|
72
90
|
return false;
|
|
73
91
|
}
|
|
74
|
-
_deleteChild(node, clazz) {
|
|
75
|
-
const i = node instanceof clazz
|
|
76
|
-
? this.children.indexOf(node)
|
|
77
|
-
: node;
|
|
78
|
-
if (i !== -1) {
|
|
79
|
-
this.children.splice(i, 1);
|
|
80
|
-
return true;
|
|
81
|
-
}
|
|
82
|
-
return false;
|
|
83
|
-
}
|
|
84
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
|
@@ -7,6 +7,9 @@ import { set2 } from "@thi.ng/vectors/set";
|
|
|
7
7
|
import { ANode } from "./anode.js";
|
|
8
8
|
import { toHiccup } from "./hiccup.js";
|
|
9
9
|
export class Node2D extends ANode {
|
|
10
|
+
translate;
|
|
11
|
+
rotate;
|
|
12
|
+
scale;
|
|
10
13
|
constructor(id, parent, translate = [0, 0], rotate = 0, scale = 1, body) {
|
|
11
14
|
super(id, parent, body);
|
|
12
15
|
this.translate = translate;
|
|
@@ -17,9 +20,6 @@ export class Node2D extends ANode {
|
|
|
17
20
|
copy() {
|
|
18
21
|
return new Node2D(this.id, this.parent, set2([], this.translate), this.rotate, set2([], this.scale), this.body);
|
|
19
22
|
}
|
|
20
|
-
deleteChild(node) {
|
|
21
|
-
return this._deleteChild(node, Node2D);
|
|
22
|
-
}
|
|
23
23
|
update() {
|
|
24
24
|
if (this.enabled) {
|
|
25
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
|
@@ -7,6 +7,9 @@ import { set3 } from "@thi.ng/vectors/set";
|
|
|
7
7
|
import { ANode } from "./anode.js";
|
|
8
8
|
import { toHiccup } from "./hiccup.js";
|
|
9
9
|
export class Node3D extends ANode {
|
|
10
|
+
translate;
|
|
11
|
+
rotate;
|
|
12
|
+
scale;
|
|
10
13
|
constructor(id, parent, translate = [0, 0, 0], rotate = [0, 0, 0], scale = 1, body) {
|
|
11
14
|
super(id, parent, body);
|
|
12
15
|
this.translate = translate;
|
|
@@ -17,9 +20,6 @@ export class Node3D extends ANode {
|
|
|
17
20
|
copy() {
|
|
18
21
|
return new Node3D(this.id, this.parent, set3([], this.translate), set3([], this.rotate), set3([], this.scale), this.body);
|
|
19
22
|
}
|
|
20
|
-
deleteChild(node) {
|
|
21
|
-
return this._deleteChild(node, Node3D);
|
|
22
|
-
}
|
|
23
23
|
update() {
|
|
24
24
|
if (this.enabled) {
|
|
25
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.
|
|
3
|
+
"version": "1.0.0",
|
|
4
4
|
"description": "Extensible 2D/3D scene graph with @thi.ng/hiccup-canvas support",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"module": "./index.js",
|
|
@@ -28,24 +28,23 @@
|
|
|
28
28
|
"clean": "rimraf --glob '*.js' '*.d.ts' '*.map' doc",
|
|
29
29
|
"doc": "typedoc --excludePrivate --excludeInternal --out doc src/index.ts",
|
|
30
30
|
"doc:ae": "mkdir -p .ae/doc .ae/temp && api-extractor run --local --verbose",
|
|
31
|
-
"doc:readme": "
|
|
32
|
-
"doc:stats": "tools:module-stats",
|
|
31
|
+
"doc:readme": "bun ../../tools/src/module-stats.ts && bun ../../tools/src/readme.ts",
|
|
33
32
|
"pub": "yarn npm publish --access public",
|
|
34
|
-
"test": "
|
|
33
|
+
"test": "bun test"
|
|
35
34
|
},
|
|
36
35
|
"dependencies": {
|
|
37
|
-
"@thi.ng/api": "^8.9.
|
|
38
|
-
"@thi.ng/checks": "^3.4.
|
|
39
|
-
"@thi.ng/errors": "^2.4.
|
|
40
|
-
"@thi.ng/matrices": "^2.2.
|
|
41
|
-
"@thi.ng/vectors": "^7.8.
|
|
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.9",
|
|
40
|
+
"@thi.ng/vectors": "^7.8.5"
|
|
42
41
|
},
|
|
43
42
|
"devDependencies": {
|
|
44
|
-
"@microsoft/api-extractor": "^7.38.
|
|
45
|
-
"@thi.ng/testament": "^0.
|
|
43
|
+
"@microsoft/api-extractor": "^7.38.2",
|
|
44
|
+
"@thi.ng/testament": "^0.4.1",
|
|
46
45
|
"rimraf": "^5.0.5",
|
|
47
46
|
"tools": "^0.0.1",
|
|
48
|
-
"typedoc": "^0.25.
|
|
47
|
+
"typedoc": "^0.25.3",
|
|
49
48
|
"typescript": "^5.2.2"
|
|
50
49
|
},
|
|
51
50
|
"keywords": [
|
|
@@ -98,5 +97,5 @@
|
|
|
98
97
|
],
|
|
99
98
|
"status": "alpha"
|
|
100
99
|
},
|
|
101
|
-
"gitHead": "
|
|
100
|
+
"gitHead": "2be4c38c9680da929339bd164acfb69ebb1fd3d0\n"
|
|
102
101
|
}
|