Skip to content

Commit ca282e9

Browse files
authored
Merge pull request #11 from maximeq/jeulin/migration-ts
TS Migration
2 parents 89cd723 + 89e81f6 commit ca282e9

File tree

120 files changed

+9447
-8710
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

120 files changed

+9447
-8710
lines changed

dist/three-js-blobtree.module.d.ts

Lines changed: 2146 additions & 2021 deletions
Large diffs are not rendered by default.

dist/three-js-blobtree.module.js

Lines changed: 3364 additions & 2960 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/three-js-blobtree.module.js.map

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Lines changed: 36 additions & 48 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,10 @@
1-
import { Node } from "./Node";
2-
/**
3-
* @typedef {import('./Element.js')} Element
4-
* @typedef {import('./Element.js').Json} Json
5-
* @typedef {import('./Node.js').NodeJSON} NodeJSON
6-
*/
7-
/**
8-
* @typedef {{alpha:number} & NodeJSON} DifferenceNodeJSON
9-
*/
1+
import { Vector3, Box3 } from "three";
2+
import { Node, type NodeJSON, type DifferenceNodeType } from "./Node";
3+
import { Material } from "./Material";
4+
import { Element, type ValueResultType } from './Element';
5+
type DifferenceNodeJSON = {
6+
alpha: number;
7+
} & NodeJSON;
108
/**
119
* This class implement a difference blending node.
1210
* The scalar field of the second child of this node will be substracted to the first node field.
@@ -15,35 +13,28 @@ import { Node } from "./Node";
1513
* @extends Node
1614
*/
1715
export declare class DifferenceNode extends Node {
18-
static type: string;
19-
/**
20-
* @param {DifferenceNodeJSON} json
21-
* @returns {DifferenceNode}
22-
*/
23-
static fromJSON(json: any): DifferenceNode;
16+
alpha: number;
17+
clamped: number;
18+
tmp_res0: ValueResultType;
19+
tmp_res1: ValueResultType;
20+
g0: Vector3;
21+
m0: Material;
22+
g1: Vector3;
23+
m1: Material;
24+
tmp_v_arr: Float32Array;
25+
tmp_m_arr: [Material | null, Material | null];
26+
static type: DifferenceNodeType;
27+
static fromJSON(json: DifferenceNodeJSON): DifferenceNode;
2428
/**
2529
*
26-
* @param {!Node} node0 The first node
27-
* @param {!Node} node1 The second node, its value will be substracted to the node 0 value.
28-
* @param {number} alpha Power of the second field : the greater alpha the sharper the difference. Default is 1, must be > 1.
30+
* @param node0 The first node
31+
* @param node1 The second node, its value will be substracted to the node 0 value.
32+
* @param alpha Power of the second field : the greater alpha the sharper the difference. Default is 1, must be > 1.
2933
*/
30-
constructor(node0: any, node1: any, alpha: any);
31-
/**
32-
* @returns {number}
33-
*/
34-
getAlpha(): any;
35-
/**
36-
* @param {number} alpha
37-
*/
38-
setAlpha(alpha: any): void;
39-
/**
40-
* @returns {DifferenceNodeJSON}
41-
*/
42-
toJSON(): {
43-
alpha: any;
44-
children: never[];
45-
type: string;
46-
};
34+
constructor(node0: Node, node1: Node, alpha: number);
35+
getAlpha(): number;
36+
setAlpha(alpha: number): void;
37+
toJSON(): DifferenceNodeJSON;
4738
/**
4839
* @link Node.prepareForEval for a complete description
4940
**/
@@ -52,25 +43,22 @@ export declare class DifferenceNode extends Node {
5243
* Compute the value and/or gradient and/or material
5344
* of the element at position p in space. return computations in res (see below)
5445
*
55-
* @param {Vector3} p Point where we want to evaluate the primitive field
56-
* @param {Object} res Computed values will be stored here. Each values should exist and
46+
* @param p Point where we want to evaluate the primitive field
47+
* @param res Computed values will be stored here. Each values should exist and
5748
* be allocated already.
58-
* @param {number} res.v Value, must be defined
59-
* @param {Material} res.m Material, must be allocated and defined if wanted
60-
* @param {Vector3} res.g Gradient, must be allocated and defined if wanted
61-
* @param {number=} res.step The next step we can safely walk without missing the iso (0). Mostly used for convergence function or ray marching.
62-
* @param {number=} res.stepOrtho
49+
* @param res.v Value, must be defined
50+
* @param res.m Material, must be allocated and defined if wanted
51+
* @param res.g Gradient, must be allocated and defined if wanted
52+
* @param res.step The next step we can safely walk without missing the iso (0). Mostly used for convergence function or ray marching.
53+
* @param res.stepOrtho
6354
*/
64-
value(p: any, res: any): void;
55+
value(p: Vector3, res: ValueResultType): void;
6556
/**
6657
* @link Element.trim for a complete description.
6758
*
6859
* Trim must be redefined for DifferenceNode since in this node we cannot trim one of the 2 nodes without trimming the other.
69-
*
70-
* @param {Box3} aabb
71-
* @param {Array.<Element>} trimmed
72-
* @param {Array.<Node>} parents
7360
*/
74-
trim(aabb: any, trimmed: any, parents: any): void;
61+
trim(aabb: Box3, trimmed: Element[], parents: Node[]): void;
7562
}
63+
export {};
7664
//# sourceMappingURL=DifferenceNode.d.ts.map

dist/types/blobtree/DifferenceNode.d.ts.map

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/types/blobtree/Element.d.ts

Lines changed: 29 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,25 @@
11
import { Box3, Vector3 } from "three";
2-
import type { Node } from "./Node";
2+
import type { Node, NodeType } from "./Node";
33
import type { Area } from "./areas";
4-
import type { Primitive } from "./Primitive";
4+
import type { Primitive, PrimitiveType } from "./Primitive";
55
import type { Material } from "./Material";
6+
import type { SDFPrimitiveType } from "./sdf/SDFPrimitive";
67
/**
78
* Computed values will be stored here. Each values should exist and be allocated already.
8-
* @property {number} v Value, must be defined
9-
* @property {Material=} m Material, must be allocated and defined if wanted
10-
* @property {Vector3=} g Gradient, must be allocated and defined if wanted
11-
* @property {number=} step ??? Not sure, probably a "safe" step for raymarching
12-
* @property {number=} stepOrtho ??? Same as step but in orthogonal direction ?
9+
* @property v Value, must be defined
10+
* @property m Material, must be allocated and defined if wanted
11+
* @property g Gradient, must be allocated and defined if wanted
12+
* @property step ??? Not sure, probably a "safe" step for raymarching
13+
* @property stepOrtho ??? Same as step but in orthogonal direction ?
1314
*/
1415
export type ValueResultType = {
1516
v: number;
16-
m: Material;
17-
g: Vector3;
18-
step: number;
19-
stepOrtho: number;
17+
m?: Material | null;
18+
g?: Vector3 | null;
19+
step?: number;
20+
stepOrtho?: number;
2021
};
22+
type ElementType = "Element" | NodeType | PrimitiveType | SDFPrimitiveType;
2123
export type ElementJSON = {
2224
type: string;
2325
};
@@ -26,12 +28,9 @@ export type ElementJSON = {
2628
* @class
2729
* @constructor
2830
*/
29-
export declare class Element {
30-
static type: string;
31-
/**
32-
* @param {ElementJSON} _json
33-
*/
34-
static fromJSON(_json: any): void;
31+
export declare abstract class Element {
32+
static type: ElementType;
33+
static fromJSON(_json: ElementJSON): void;
3534
id: number;
3635
aabb: Box3;
3736
valid_aabb: boolean;
@@ -53,7 +52,7 @@ export declare class Element {
5352
/**
5453
* @return Type of the element
5554
*/
56-
getType(): string;
55+
getType(): ElementType;
5756
/**
5857
* Perform precomputation that will help to reduce future processing time,
5958
* especially on calls to value.
@@ -66,9 +65,9 @@ export declare class Element {
6665
* By default, the AABB returned is the unionns of all vertices AABB (This is
6766
* good for almost all basic primitives).
6867
*/
69-
computeAABB(): void;
68+
abstract computeAABB(): void;
7069
/**
71-
* @return {Box3} The AABB of this Element (primitive or node). WARNING : call
70+
* @return The AABB of this Element (primitive or node). WARNING : call
7271
* isValidAABB before to ensure the current AABB does correspond to the primitive
7372
* settings.
7473
*/
@@ -93,20 +92,19 @@ export declare class Element {
9392
* Important note: For now, a primitive is considered prepared for eval if and only
9493
* if its bounding box is valid (valid_aabb is true).
9594
*/
96-
prepareForEval(): void;
95+
abstract prepareForEval(): void;
9796
/**
9897
* @abstract
9998
* Compute the value and/or gradient and/or material
10099
* of the element at position p in space. return computations in res (see below)
101100
*
102-
* @param {Vector3} _p Point where we want to evaluate the primitive field
103-
* @param {ValueResultType} _res
101+
* @param p Point where we want to evaluate the primitive field
104102
*/
105-
value(_p: Vector3, _res: ValueResultType): void;
103+
abstract value(p: Vector3, res: ValueResultType): void;
106104
/**
107-
* @param {Vector3} p The point where we want the numerical gradient
108-
* @param {Vector3} res The resulting gradient
109-
* @param {number} epsilon The step value for the numerical evaluation
105+
* @param p The point where we want the numerical gradient
106+
* @param res The resulting gradient
107+
* @param epsilon The step value for the numerical evaluation
110108
*/
111109
numericalGradient: (this: Element, p: Vector3, res: Vector3, epsilon: number) => void;
112110
/**
@@ -132,9 +130,9 @@ export declare class Element {
132130
/**
133131
* @abstract
134132
* This function is called when a point is within the potential influence of a primitive/node.
135-
* @return {number} The next step length to do with respect to this primitive/node.
133+
* @return The next step length to do with respect to this primitive/node.
136134
*/
137-
heuristicStepWithin(): void;
135+
abstract heuristicStepWithin(): number;
138136
/**
139137
* Trim the tree to keep only nodes influencing a given bounding box.
140138
* The tree must be prepared for eval for this process to be working.
@@ -152,6 +150,7 @@ export declare class Element {
152150
* @return The number of element of class cls
153151
*/
154152
count(_cls: Function): number;
155-
destroy(): void;
153+
abstract destroy(): void;
156154
}
155+
export {};
157156
//# sourceMappingURL=Element.d.ts.map

dist/types/blobtree/Element.d.ts.map

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)