1
1
import { Box3 , Vector3 } from "three" ;
2
- import type { Node } from "./Node" ;
2
+ import type { Node , NodeType } from "./Node" ;
3
3
import type { Area } from "./areas" ;
4
- import type { Primitive } from "./Primitive" ;
4
+ import type { Primitive , PrimitiveType } from "./Primitive" ;
5
5
import type { Material } from "./Material" ;
6
+ import type { SDFPrimitiveType } from "./sdf/SDFPrimitive" ;
6
7
/**
7
8
* 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 ?
13
14
*/
14
15
export type ValueResultType = {
15
16
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 ;
20
21
} ;
22
+ type ElementType = "Element" | NodeType | PrimitiveType | SDFPrimitiveType ;
21
23
export type ElementJSON = {
22
24
type : string ;
23
25
} ;
@@ -26,12 +28,9 @@ export type ElementJSON = {
26
28
* @class
27
29
* @constructor
28
30
*/
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 ;
35
34
id : number ;
36
35
aabb : Box3 ;
37
36
valid_aabb : boolean ;
@@ -53,7 +52,7 @@ export declare class Element {
53
52
/**
54
53
* @return Type of the element
55
54
*/
56
- getType ( ) : string ;
55
+ getType ( ) : ElementType ;
57
56
/**
58
57
* Perform precomputation that will help to reduce future processing time,
59
58
* especially on calls to value.
@@ -66,9 +65,9 @@ export declare class Element {
66
65
* By default, the AABB returned is the unionns of all vertices AABB (This is
67
66
* good for almost all basic primitives).
68
67
*/
69
- computeAABB ( ) : void ;
68
+ abstract computeAABB ( ) : void ;
70
69
/**
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
72
71
* isValidAABB before to ensure the current AABB does correspond to the primitive
73
72
* settings.
74
73
*/
@@ -93,20 +92,19 @@ export declare class Element {
93
92
* Important note: For now, a primitive is considered prepared for eval if and only
94
93
* if its bounding box is valid (valid_aabb is true).
95
94
*/
96
- prepareForEval ( ) : void ;
95
+ abstract prepareForEval ( ) : void ;
97
96
/**
98
97
* @abstract
99
98
* Compute the value and/or gradient and/or material
100
99
* of the element at position p in space. return computations in res (see below)
101
100
*
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
104
102
*/
105
- value ( _p : Vector3 , _res : ValueResultType ) : void ;
103
+ abstract value ( p : Vector3 , res : ValueResultType ) : void ;
106
104
/**
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
110
108
*/
111
109
numericalGradient : ( this : Element , p : Vector3 , res : Vector3 , epsilon : number ) => void ;
112
110
/**
@@ -132,9 +130,9 @@ export declare class Element {
132
130
/**
133
131
* @abstract
134
132
* 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.
136
134
*/
137
- heuristicStepWithin ( ) : void ;
135
+ abstract heuristicStepWithin ( ) : number ;
138
136
/**
139
137
* Trim the tree to keep only nodes influencing a given bounding box.
140
138
* The tree must be prepared for eval for this process to be working.
@@ -152,6 +150,7 @@ export declare class Element {
152
150
* @return The number of element of class cls
153
151
*/
154
152
count ( _cls : Function ) : number ;
155
- destroy ( ) : void ;
153
+ abstract destroy ( ) : void ;
156
154
}
155
+ export { } ;
157
156
//# sourceMappingURL=Element.d.ts.map
0 commit comments