Skip to content

TS Migration #11

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 15 commits into from
Jul 25, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4,167 changes: 2,146 additions & 2,021 deletions dist/three-js-blobtree.module.d.ts

Large diffs are not rendered by default.

6,324 changes: 3,364 additions & 2,960 deletions dist/three-js-blobtree.module.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion dist/three-js-blobtree.module.js.map

Large diffs are not rendered by default.

84 changes: 36 additions & 48 deletions dist/types/blobtree/DifferenceNode.d.ts
Original file line number Diff line number Diff line change
@@ -1,12 +1,10 @@
import { Node } from "./Node";
/**
* @typedef {import('./Element.js')} Element
* @typedef {import('./Element.js').Json} Json
* @typedef {import('./Node.js').NodeJSON} NodeJSON
*/
/**
* @typedef {{alpha:number} & NodeJSON} DifferenceNodeJSON
*/
import { Vector3, Box3 } from "three";
import { Node, type NodeJSON, type DifferenceNodeType } from "./Node";
import { Material } from "./Material";
import { Element, type ValueResultType } from './Element';
type DifferenceNodeJSON = {
alpha: number;
} & NodeJSON;
/**
* This class implement a difference blending node.
* The scalar field of the second child of this node will be substracted to the first node field.
Expand All @@ -15,35 +13,28 @@ import { Node } from "./Node";
* @extends Node
*/
export declare class DifferenceNode extends Node {
static type: string;
/**
* @param {DifferenceNodeJSON} json
* @returns {DifferenceNode}
*/
static fromJSON(json: any): DifferenceNode;
alpha: number;
clamped: number;
tmp_res0: ValueResultType;
tmp_res1: ValueResultType;
g0: Vector3;
m0: Material;
g1: Vector3;
m1: Material;
tmp_v_arr: Float32Array;
tmp_m_arr: [Material | null, Material | null];
static type: DifferenceNodeType;
static fromJSON(json: DifferenceNodeJSON): DifferenceNode;
/**
*
* @param {!Node} node0 The first node
* @param {!Node} node1 The second node, its value will be substracted to the node 0 value.
* @param {number} alpha Power of the second field : the greater alpha the sharper the difference. Default is 1, must be > 1.
* @param node0 The first node
* @param node1 The second node, its value will be substracted to the node 0 value.
* @param alpha Power of the second field : the greater alpha the sharper the difference. Default is 1, must be > 1.
*/
constructor(node0: any, node1: any, alpha: any);
/**
* @returns {number}
*/
getAlpha(): any;
/**
* @param {number} alpha
*/
setAlpha(alpha: any): void;
/**
* @returns {DifferenceNodeJSON}
*/
toJSON(): {
alpha: any;
children: never[];
type: string;
};
constructor(node0: Node, node1: Node, alpha: number);
getAlpha(): number;
setAlpha(alpha: number): void;
toJSON(): DifferenceNodeJSON;
/**
* @link Node.prepareForEval for a complete description
**/
Expand All @@ -52,25 +43,22 @@ export declare class DifferenceNode extends Node {
* Compute the value and/or gradient and/or material
* of the element at position p in space. return computations in res (see below)
*
* @param {Vector3} p Point where we want to evaluate the primitive field
* @param {Object} res Computed values will be stored here. Each values should exist and
* @param p Point where we want to evaluate the primitive field
* @param res Computed values will be stored here. Each values should exist and
* be allocated already.
* @param {number} res.v Value, must be defined
* @param {Material} res.m Material, must be allocated and defined if wanted
* @param {Vector3} res.g Gradient, must be allocated and defined if wanted
* @param {number=} res.step The next step we can safely walk without missing the iso (0). Mostly used for convergence function or ray marching.
* @param {number=} res.stepOrtho
* @param res.v Value, must be defined
* @param res.m Material, must be allocated and defined if wanted
* @param res.g Gradient, must be allocated and defined if wanted
* @param res.step The next step we can safely walk without missing the iso (0). Mostly used for convergence function or ray marching.
* @param res.stepOrtho
*/
value(p: any, res: any): void;
value(p: Vector3, res: ValueResultType): void;
/**
* @link Element.trim for a complete description.
*
* Trim must be redefined for DifferenceNode since in this node we cannot trim one of the 2 nodes without trimming the other.
*
* @param {Box3} aabb
* @param {Array.<Element>} trimmed
* @param {Array.<Node>} parents
*/
trim(aabb: any, trimmed: any, parents: any): void;
trim(aabb: Box3, trimmed: Element[], parents: Node[]): void;
}
export {};
//# sourceMappingURL=DifferenceNode.d.ts.map
2 changes: 1 addition & 1 deletion dist/types/blobtree/DifferenceNode.d.ts.map

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

59 changes: 29 additions & 30 deletions dist/types/blobtree/Element.d.ts
Original file line number Diff line number Diff line change
@@ -1,23 +1,25 @@
import { Box3, Vector3 } from "three";
import type { Node } from "./Node";
import type { Node, NodeType } from "./Node";
import type { Area } from "./areas";
import type { Primitive } from "./Primitive";
import type { Primitive, PrimitiveType } from "./Primitive";
import type { Material } from "./Material";
import type { SDFPrimitiveType } from "./sdf/SDFPrimitive";
/**
* Computed values will be stored here. Each values should exist and be allocated already.
* @property {number} v Value, must be defined
* @property {Material=} m Material, must be allocated and defined if wanted
* @property {Vector3=} g Gradient, must be allocated and defined if wanted
* @property {number=} step ??? Not sure, probably a "safe" step for raymarching
* @property {number=} stepOrtho ??? Same as step but in orthogonal direction ?
* @property v Value, must be defined
* @property m Material, must be allocated and defined if wanted
* @property g Gradient, must be allocated and defined if wanted
* @property step ??? Not sure, probably a "safe" step for raymarching
* @property stepOrtho ??? Same as step but in orthogonal direction ?
*/
export type ValueResultType = {
v: number;
m: Material;
g: Vector3;
step: number;
stepOrtho: number;
m?: Material | null;
g?: Vector3 | null;
step?: number;
stepOrtho?: number;
};
type ElementType = "Element" | NodeType | PrimitiveType | SDFPrimitiveType;
export type ElementJSON = {
type: string;
};
Expand All @@ -26,12 +28,9 @@ export type ElementJSON = {
* @class
* @constructor
*/
export declare class Element {
static type: string;
/**
* @param {ElementJSON} _json
*/
static fromJSON(_json: any): void;
export declare abstract class Element {
static type: ElementType;
static fromJSON(_json: ElementJSON): void;
id: number;
aabb: Box3;
valid_aabb: boolean;
Expand All @@ -53,7 +52,7 @@ export declare class Element {
/**
* @return Type of the element
*/
getType(): string;
getType(): ElementType;
/**
* Perform precomputation that will help to reduce future processing time,
* especially on calls to value.
Expand All @@ -66,9 +65,9 @@ export declare class Element {
* By default, the AABB returned is the unionns of all vertices AABB (This is
* good for almost all basic primitives).
*/
computeAABB(): void;
abstract computeAABB(): void;
/**
* @return {Box3} The AABB of this Element (primitive or node). WARNING : call
* @return The AABB of this Element (primitive or node). WARNING : call
* isValidAABB before to ensure the current AABB does correspond to the primitive
* settings.
*/
Expand All @@ -93,20 +92,19 @@ export declare class Element {
* Important note: For now, a primitive is considered prepared for eval if and only
* if its bounding box is valid (valid_aabb is true).
*/
prepareForEval(): void;
abstract prepareForEval(): void;
/**
* @abstract
* Compute the value and/or gradient and/or material
* of the element at position p in space. return computations in res (see below)
*
* @param {Vector3} _p Point where we want to evaluate the primitive field
* @param {ValueResultType} _res
* @param p Point where we want to evaluate the primitive field
*/
value(_p: Vector3, _res: ValueResultType): void;
abstract value(p: Vector3, res: ValueResultType): void;
/**
* @param {Vector3} p The point where we want the numerical gradient
* @param {Vector3} res The resulting gradient
* @param {number} epsilon The step value for the numerical evaluation
* @param p The point where we want the numerical gradient
* @param res The resulting gradient
* @param epsilon The step value for the numerical evaluation
*/
numericalGradient: (this: Element, p: Vector3, res: Vector3, epsilon: number) => void;
/**
Expand All @@ -132,9 +130,9 @@ export declare class Element {
/**
* @abstract
* This function is called when a point is within the potential influence of a primitive/node.
* @return {number} The next step length to do with respect to this primitive/node.
* @return The next step length to do with respect to this primitive/node.
*/
heuristicStepWithin(): void;
abstract heuristicStepWithin(): number;
/**
* Trim the tree to keep only nodes influencing a given bounding box.
* The tree must be prepared for eval for this process to be working.
Expand All @@ -152,6 +150,7 @@ export declare class Element {
* @return The number of element of class cls
*/
count(_cls: Function): number;
destroy(): void;
abstract destroy(): void;
}
export {};
//# sourceMappingURL=Element.d.ts.map
2 changes: 1 addition & 1 deletion dist/types/blobtree/Element.d.ts.map

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading