11import { Box3 , Vector3 } from "three" ;
2- import type { Node } from "./Node" ;
2+ import type { Node , NodeType } from "./Node" ;
33import type { Area } from "./areas" ;
4- import type { Primitive } from "./Primitive" ;
4+ import type { Primitive , PrimitiveType } from "./Primitive" ;
55import 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 */
1415export 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 ;
2123export 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
0 commit comments