@asymmetric-effort/specifyjs 0.2.128 → 0.2.132
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/dist/types/components/viz/3d-force-graph/src/force-sim.d.ts +6 -0
- package/dist/types/components/viz/3d-force-graph/src/types.d.ts +14 -3
- package/dist/types/components/viz/3dSpace/src/pipeline-factory.d.ts +22 -0
- package/dist/types/components/viz/3dSpace/src/raycast.d.ts +56 -0
- package/dist/types/components/viz/3dSpace/src/render-pipeline.d.ts +2 -0
- package/dist/types/components/viz/3dSpace/src/scene-object.d.ts +7 -0
- package/dist/types/components/viz/3dSpace/src/webgpu-pipeline.d.ts +29 -0
- package/package.json +1 -1
|
@@ -12,6 +12,8 @@ export interface SimNode {
|
|
|
12
12
|
velocity: Vec3;
|
|
13
13
|
mass: number;
|
|
14
14
|
fixed: boolean;
|
|
15
|
+
/** Radius for sphere-sphere collision detection. Default: 1. */
|
|
16
|
+
collisionRadius?: number;
|
|
15
17
|
}
|
|
16
18
|
/** A simulation edge. */
|
|
17
19
|
export interface SimEdge {
|
|
@@ -31,6 +33,10 @@ export interface SimConfig {
|
|
|
31
33
|
min: Vec3;
|
|
32
34
|
max: Vec3;
|
|
33
35
|
};
|
|
36
|
+
/** Enable sphere-sphere collision detection and response. Default: false. */
|
|
37
|
+
collisionEnabled?: boolean;
|
|
38
|
+
/** Coefficient of restitution (bounciness) 0-1. 1 = perfectly elastic. Default: 0.8. */
|
|
39
|
+
restitution?: number;
|
|
34
40
|
}
|
|
35
41
|
/**
|
|
36
42
|
* Run one step of the 3D force simulation.
|
|
@@ -18,6 +18,8 @@ export interface ForceGraph3DNode {
|
|
|
18
18
|
fixed?: boolean;
|
|
19
19
|
/** Affects force response. Default: 1.0. */
|
|
20
20
|
mass?: number;
|
|
21
|
+
/** Collision sphere radius. Defaults to size. */
|
|
22
|
+
collisionRadius?: number;
|
|
21
23
|
}
|
|
22
24
|
/** An edge in the 3D force graph. */
|
|
23
25
|
export interface ForceGraph3DEdge {
|
|
@@ -60,9 +62,18 @@ export interface ForceGraph3DProps {
|
|
|
60
62
|
cameraDistance?: number;
|
|
61
63
|
/** Default: true. */
|
|
62
64
|
orbitControls?: boolean;
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
65
|
+
/** Enable sphere-sphere collision detection. Default: true. */
|
|
66
|
+
collisionEnabled?: boolean;
|
|
67
|
+
/** Coefficient of restitution (bounciness) 0-1. Default: 0.8. */
|
|
68
|
+
restitution?: number;
|
|
69
|
+
onNodeClick?: (nodeId: string, node: ForceGraph3DNode, event: MouseEvent) => void;
|
|
70
|
+
onNodeDoubleClick?: (nodeId: string, node: ForceGraph3DNode, event: MouseEvent) => void;
|
|
71
|
+
onNodeRightClick?: (nodeId: string, node: ForceGraph3DNode, event: MouseEvent) => void;
|
|
72
|
+
onNodeMouseDown?: (nodeId: string, node: ForceGraph3DNode, event: MouseEvent) => void;
|
|
73
|
+
onNodeMouseUp?: (nodeId: string, node: ForceGraph3DNode, event: MouseEvent) => void;
|
|
74
|
+
onNodeHover?: (nodeId: string | null, node: ForceGraph3DNode | null, event: MouseEvent) => void;
|
|
75
|
+
onEdgeClick?: (edge: ForceGraph3DEdge, event: MouseEvent) => void;
|
|
76
|
+
onEdgeHover?: (edge: ForceGraph3DEdge | null, event: MouseEvent) => void;
|
|
66
77
|
/** Dynamic API ref. */
|
|
67
78
|
apiRef?: (api: ForceGraph3DAPI) => void;
|
|
68
79
|
lightingModel?: LightingModel;
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Auto-select the best available render pipeline for the client hardware.
|
|
3
|
+
*
|
|
4
|
+
* Detection order:
|
|
5
|
+
* 1. WebGPU (navigator.gpu available + adapter + device)
|
|
6
|
+
* 2. WebGL (canvas.getContext('webgl2') or 'webgl')
|
|
7
|
+
* 3. CPU (canvas.getContext('2d'))
|
|
8
|
+
*/
|
|
9
|
+
import type { RenderPipeline } from './render-pipeline';
|
|
10
|
+
/**
|
|
11
|
+
* Create the best available render pipeline for the given canvas.
|
|
12
|
+
* Tries WebGPU first, then WebGL, then falls back to CPU.
|
|
13
|
+
*
|
|
14
|
+
* @param canvas - The target canvas element.
|
|
15
|
+
* @returns The initialized pipeline (ready to call render()).
|
|
16
|
+
*/
|
|
17
|
+
export declare function createPipeline(canvas: HTMLCanvasElement): Promise<RenderPipeline>;
|
|
18
|
+
/**
|
|
19
|
+
* Synchronous pipeline creation — always returns CpuPipeline.
|
|
20
|
+
* Use this when async initialization is not feasible.
|
|
21
|
+
*/
|
|
22
|
+
export declare function createPipelineSync(canvas: HTMLCanvasElement): RenderPipeline;
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Raycasting utilities for 3D object picking and hit testing.
|
|
3
|
+
*/
|
|
4
|
+
import type { Vec3 } from '../../../math/src/vec';
|
|
5
|
+
import type { Mat4 } from '../../../math/src/mat4';
|
|
6
|
+
import type { SceneObject } from './scene-object';
|
|
7
|
+
import type { ObjectPicker } from './types';
|
|
8
|
+
/** A ray defined by an origin point and a normalized direction. */
|
|
9
|
+
export interface Ray {
|
|
10
|
+
origin: Vec3;
|
|
11
|
+
direction: Vec3;
|
|
12
|
+
}
|
|
13
|
+
/**
|
|
14
|
+
* Ray-sphere intersection test.
|
|
15
|
+
* @returns Distance along the ray to the nearest intersection, or null if no hit.
|
|
16
|
+
*/
|
|
17
|
+
export declare function raySphereIntersect(ray: Ray, center: Vec3, radius: number): number | null;
|
|
18
|
+
/**
|
|
19
|
+
* Ray-AABB (axis-aligned bounding box) intersection test.
|
|
20
|
+
* @returns Distance along the ray to the nearest intersection, or null if no hit.
|
|
21
|
+
*/
|
|
22
|
+
export declare function rayAABBIntersect(ray: Ray, min: Vec3, max: Vec3): number | null;
|
|
23
|
+
/**
|
|
24
|
+
* Ray-cylinder intersection test (finite cylinder along an axis).
|
|
25
|
+
* @param ray - The ray to test.
|
|
26
|
+
* @param start - One endpoint of the cylinder axis.
|
|
27
|
+
* @param end - Other endpoint of the cylinder axis.
|
|
28
|
+
* @param radius - Cylinder radius.
|
|
29
|
+
* @returns Distance along the ray to the nearest intersection, or null if no hit.
|
|
30
|
+
*/
|
|
31
|
+
export declare function rayCylinderIntersect(ray: Ray, start: Vec3, end: Vec3, radius: number): number | null;
|
|
32
|
+
/**
|
|
33
|
+
* Convert screen coordinates to a world-space ray.
|
|
34
|
+
* @param screenX - Screen x position (pixels).
|
|
35
|
+
* @param screenY - Screen y position (pixels).
|
|
36
|
+
* @param viewportW - Viewport width (pixels).
|
|
37
|
+
* @param viewportH - Viewport height (pixels).
|
|
38
|
+
* @param viewProj - The combined view * projection matrix.
|
|
39
|
+
* @returns A ray in world space from the camera through the screen point.
|
|
40
|
+
*/
|
|
41
|
+
export declare function screenToRay(screenX: number, screenY: number, viewportW: number, viewportH: number, viewProj: Mat4): Ray;
|
|
42
|
+
/**
|
|
43
|
+
* Pick the closest visible object intersected by a ray.
|
|
44
|
+
* Uses bounding sphere for each object.
|
|
45
|
+
* @returns The closest hit, or null if nothing was hit.
|
|
46
|
+
*/
|
|
47
|
+
export declare function pickObjects(ray: Ray, objects: SceneObject[]): {
|
|
48
|
+
object: SceneObject;
|
|
49
|
+
distance: number;
|
|
50
|
+
} | null;
|
|
51
|
+
/**
|
|
52
|
+
* RaycastPicker — implements the ObjectPicker interface using ray-sphere intersection.
|
|
53
|
+
*/
|
|
54
|
+
export declare class RaycastPicker implements ObjectPicker {
|
|
55
|
+
pick(origin: Vec3, direction: Vec3, objects: SceneObject[]): SceneObject | null;
|
|
56
|
+
}
|
|
@@ -7,6 +7,8 @@ import type { Light } from './light';
|
|
|
7
7
|
export interface RenderPipeline {
|
|
8
8
|
name: string;
|
|
9
9
|
initialize(canvas: HTMLCanvasElement): void;
|
|
10
|
+
/** Async initialization for pipelines that need it (e.g., WebGPU). */
|
|
11
|
+
initializeAsync?(canvas: HTMLCanvasElement): Promise<void>;
|
|
10
12
|
dispose(): void;
|
|
11
13
|
render(scene: SceneGraph, camera: Camera, viewport: Viewport, lighting: LightingModel, lights?: Light[]): void;
|
|
12
14
|
}
|
|
@@ -17,6 +17,8 @@ export declare class SceneObject {
|
|
|
17
17
|
material?: Material;
|
|
18
18
|
/** Billboard text label rendered at this object's world position. */
|
|
19
19
|
label?: string;
|
|
20
|
+
/** Bounding sphere radius for hit testing. Set manually or via computeBoundingRadius(). */
|
|
21
|
+
boundingRadius?: number;
|
|
20
22
|
children: SceneObject[];
|
|
21
23
|
parent: SceneObject | null;
|
|
22
24
|
visible: boolean;
|
|
@@ -34,4 +36,9 @@ export declare class SceneObject {
|
|
|
34
36
|
* Uses iterative traversal up the parent chain.
|
|
35
37
|
*/
|
|
36
38
|
getWorldMatrix(): Mat4;
|
|
39
|
+
/**
|
|
40
|
+
* Compute bounding sphere radius from mesh vertices (max distance from local origin).
|
|
41
|
+
* Accounts for scale. Sets and returns boundingRadius.
|
|
42
|
+
*/
|
|
43
|
+
computeBoundingRadius(): number;
|
|
37
44
|
}
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* WebGPU-based render pipeline.
|
|
3
|
+
* Uses hardware-accelerated GPU rendering with WGSL shaders.
|
|
4
|
+
* Provides depth buffer via GPUTexture for correct occlusion.
|
|
5
|
+
*/
|
|
6
|
+
import type { RenderPipeline } from './render-pipeline';
|
|
7
|
+
import type { SceneGraph } from './scene-graph';
|
|
8
|
+
import type { Camera } from './camera';
|
|
9
|
+
import type { Viewport } from './viewport';
|
|
10
|
+
import type { LightingModel } from './lighting-model';
|
|
11
|
+
import type { Light } from './light';
|
|
12
|
+
export declare class WebGPUPipeline implements RenderPipeline {
|
|
13
|
+
readonly name = "webgpu";
|
|
14
|
+
private device;
|
|
15
|
+
private context;
|
|
16
|
+
private pipeline;
|
|
17
|
+
private depthTexture;
|
|
18
|
+
private uniformBuffer;
|
|
19
|
+
private uniformData;
|
|
20
|
+
private _canvas;
|
|
21
|
+
private overlayCanvas;
|
|
22
|
+
private overlayCtx;
|
|
23
|
+
initialize(canvas: HTMLCanvasElement): void;
|
|
24
|
+
initializeAsync(canvas: HTMLCanvasElement): Promise<void>;
|
|
25
|
+
dispose(): void;
|
|
26
|
+
render(scene: SceneGraph, camera: Camera, viewport: Viewport, lighting: LightingModel, lights?: Light[]): void;
|
|
27
|
+
/** Project a label SceneObject to screen and draw as 2D text on the overlay. */
|
|
28
|
+
private renderLabel;
|
|
29
|
+
}
|