@equinor/videx-3d 1.1.1 → 3.0.0
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/README.md +120 -120
- package/dist/chunk-DKAquGKk.js +2820 -0
- package/dist/chunk-DsUZyEG_.js +16 -0
- package/dist/generators.js +512 -716
- package/dist/main.js +6909 -8947
- package/dist/sdk.js +2 -785
- package/dist/src/sdk/materials/shaderLib/oit.glsl +106 -0
- package/dist/types/components/Annotations/AutoUpdate.d.ts +1 -1
- package/dist/types/components/Annotations/index.d.ts +2 -2
- package/dist/types/components/Annotations/types.d.ts +3 -1
- package/dist/types/components/Annotations/update-annotations.d.ts +10 -0
- package/dist/types/components/EventEmitter/picking-helper.d.ts +23 -1
- package/dist/types/components/Ocean/Ocean.d.ts +333 -0
- package/dist/types/components/Ocean/index.d.ts +6 -0
- package/dist/types/components/Ocean/ocean-bed-material.d.ts +60 -0
- package/dist/types/components/Ocean/ocean-contact.d.ts +39 -0
- package/dist/types/components/Ocean/ocean-material.d.ts +145 -0
- package/dist/types/components/Ocean/ocean-sampler.d.ts +93 -0
- package/dist/types/components/Ocean/ocean-volume-material.d.ts +54 -0
- package/dist/types/components/Surfaces/Surface.d.ts +8 -1
- package/dist/types/components/Surfaces/SurfaceMaterial.d.ts +3 -0
- package/dist/types/components/Surfaces/surface-defs.d.ts +1 -0
- package/dist/types/components/Tanker/Tanker.d.ts +47 -0
- package/dist/types/components/Tanker/TankerSuperstructure.d.ts +23 -0
- package/dist/types/components/Tanker/tanker-geometry-builder.d.ts +21 -0
- package/dist/types/generators/surface-generator.d.ts +1 -1
- package/dist/types/layers/layers.d.ts +4 -0
- package/dist/types/main.d.ts +1 -0
- package/dist/types/rendering/OitMaterial.d.ts +59 -0
- package/dist/types/rendering/Pass.d.ts +16 -0
- package/dist/types/rendering/RenderingPipeline.d.ts +46 -0
- package/dist/types/rendering/debug/DebugBoxOutputPass.d.ts +22 -0
- package/dist/types/rendering/debug/DebugPatternPass.d.ts +30 -0
- package/dist/types/rendering/fullscreen-renderer.d.ts +1 -0
- package/dist/types/rendering/fxaa-resolver.d.ts +25 -0
- package/dist/types/rendering/gpu-timer.d.ts +46 -0
- package/dist/types/rendering/index.d.ts +8 -1
- package/dist/types/rendering/oit-material.d.ts +122 -0
- package/dist/types/{components/Annotations/annotations-renderer.d.ts → rendering/passes/AnnotationsPass.d.ts} +14 -4
- package/dist/types/rendering/passes/FXAAPass.d.ts +17 -0
- package/dist/types/rendering/passes/OITRenderPass.d.ts +429 -0
- package/dist/types/rendering/passes/OutputPass.d.ts +19 -0
- package/dist/types/rendering/passes/RenderPass.d.ts +10 -0
- package/dist/types/rendering/passes/index.d.ts +4 -0
- package/dist/types/rendering/rendering-state.d.ts +59 -0
- package/dist/types/rendering/smaa-resolver.d.ts +58 -0
- package/dist/types/rendering/taa-resolver.d.ts +161 -0
- package/dist/types/rendering/temporal-resolver.d.ts +152 -0
- package/dist/types/sdk/geometries/boundary-loops.d.ts +38 -0
- package/dist/types/sdk/geometries/geometry-attributes.d.ts +37 -0
- package/dist/types/sdk/geometries/grid-sampling.d.ts +50 -0
- package/dist/types/sdk/geometries/ocean-geometry.d.ts +288 -0
- package/dist/types/sdk/geometries/packing.d.ts +1 -1
- package/dist/types/sdk/geometries/tessellation.d.ts +25 -0
- package/dist/types/sdk/index.d.ts +5 -0
- package/dist/types/sdk/utils/elevation-map.d.ts +23 -0
- package/dist/types/sdk/utils/trigonometry.d.ts +4 -1
- package/dist/types/sdk/utils/vector-operations.d.ts +7 -0
- package/package.json +9 -10
- package/dist/chunk-BlPg4RjP.js +0 -689
- package/dist/chunk-CnY6Tmof.js +0 -358
- package/dist/chunk-DuRASjkF.js +0 -17
- package/dist/chunk-iY0wQ9Z6.js +0 -887
- package/dist/types/rendering/render-passes.d.ts +0 -16
- /package/dist/{shaderLib → src/sdk/materials/shaderLib}/color-conversion.glsl +0 -0
- /package/dist/{shaderLib → src/sdk/materials/shaderLib}/colors.glsl +0 -0
- /package/dist/{shaderLib → src/sdk/materials/shaderLib}/glyphs.glsl +0 -0
- /package/dist/{shaderLib → src/sdk/materials/shaderLib}/random.glsl +0 -0
- /package/dist/{shaderLib → src/sdk/materials/shaderLib}/remap.glsl +0 -0
- /package/dist/{shaderLib → src/sdk/materials/shaderLib}/render-number.glsl +0 -0
- /package/dist/{shaderLib → src/sdk/materials/shaderLib}/render-text.glsl +0 -0
- /package/dist/{shaderLib → src/sdk/materials/shaderLib}/rotation.glsl +0 -0
- /package/dist/{shaderLib → src/sdk/materials/shaderLib}/sdf-functions.glsl +0 -0
- /package/dist/textures/{normal_map.jpg → public/normal_map.jpg} +0 -0
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import { WebGLRenderer, WebGLRenderTarget } from 'three';
|
|
2
|
+
/**
|
|
3
|
+
* Fast Approximate Anti-Aliasing (FXAA) resolver. A single-pass, purely spatial
|
|
4
|
+
* morphological technique: it estimates edge direction from local luma and blends
|
|
5
|
+
* along it. Very cheap, but softer than SMAA and — like all spatial techniques —
|
|
6
|
+
* unable to recover sub-pixel features (thin lines/tubes that fall between
|
|
7
|
+
* samples); those need supersampling or the temporal mode.
|
|
8
|
+
*
|
|
9
|
+
* It operates entirely in the pipeline's linear FP16 space: the shader detects
|
|
10
|
+
* edges with a cheap perceptual luma but blends the linear texels, so brightness
|
|
11
|
+
* is untouched, flat regions are an exact passthrough, and HDR values above 1 are
|
|
12
|
+
* preserved (no LDR clamp). Because the neighbourhood taps cannot read the same
|
|
13
|
+
* target being written, it resolves into a scratch target and blits the result
|
|
14
|
+
* back into the buffer in place.
|
|
15
|
+
*/
|
|
16
|
+
export declare class FxaaResolver {
|
|
17
|
+
private scratch;
|
|
18
|
+
private fxaaMaterial;
|
|
19
|
+
private blitMaterial;
|
|
20
|
+
private fullscreenRenderer;
|
|
21
|
+
constructor();
|
|
22
|
+
setSize(width: number, height: number): void;
|
|
23
|
+
dispose(): void;
|
|
24
|
+
render(renderer: WebGLRenderer, buffer: WebGLRenderTarget): void;
|
|
25
|
+
}
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
import { WebGLRenderer } from 'three';
|
|
2
|
+
/**
|
|
3
|
+
* Tiny GPU timer for WebGL2 built on `EXT_disjoint_timer_query_webgl2`.
|
|
4
|
+
*
|
|
5
|
+
* DEBUG-ONLY instrumentation: it brackets named, non-overlapping segments with
|
|
6
|
+
* `TIME_ELAPSED` queries and reads the results back asynchronously (a few frames
|
|
7
|
+
* later), reporting a smoothed millisecond figure per segment. Because the GPU runs
|
|
8
|
+
* behind the CPU, results are never available the same frame they are issued, so a
|
|
9
|
+
* small ring of queries per segment is kept in flight.
|
|
10
|
+
*
|
|
11
|
+
* Only one timer query can be active at a time per spec, so {@link begin}/{@link end}
|
|
12
|
+
* calls must be strictly sequential (never nested). All methods are no-ops when the
|
|
13
|
+
* extension is unavailable (older browsers, or the WebGPU renderer), so call sites
|
|
14
|
+
* can leave instrumentation in place unconditionally.
|
|
15
|
+
*
|
|
16
|
+
* This is measurement only — it issues no draws and mutates no render state — so it
|
|
17
|
+
* does not affect the rendered result and is safe to leave compiled in behind a flag.
|
|
18
|
+
*
|
|
19
|
+
* @group Rendering
|
|
20
|
+
*/
|
|
21
|
+
export declare class GpuTimer {
|
|
22
|
+
private gl;
|
|
23
|
+
private ext;
|
|
24
|
+
private segments;
|
|
25
|
+
private pool;
|
|
26
|
+
private active;
|
|
27
|
+
private activeSeg;
|
|
28
|
+
/** Whether GPU timing is available in this context. */
|
|
29
|
+
get supported(): boolean;
|
|
30
|
+
constructor(renderer: WebGLRenderer);
|
|
31
|
+
/** Begin timing a segment. No-op if unsupported or another segment is active. */
|
|
32
|
+
begin(label: string): void;
|
|
33
|
+
/** End timing the current segment. */
|
|
34
|
+
end(): void;
|
|
35
|
+
/**
|
|
36
|
+
* Harvest finished queries and update the smoothed timings. Call once per frame
|
|
37
|
+
* (e.g. at the top of the host pass's render). Disjoint frames (GPU context
|
|
38
|
+
* disruption) are discarded.
|
|
39
|
+
*/
|
|
40
|
+
poll(): void;
|
|
41
|
+
/** Smoothed elapsed milliseconds for a segment, or -1 if no result yet. */
|
|
42
|
+
get(label: string): number;
|
|
43
|
+
/** Snapshot of every segment's smoothed timing in milliseconds. */
|
|
44
|
+
snapshot(): Record<string, number>;
|
|
45
|
+
dispose(): void;
|
|
46
|
+
}
|
|
@@ -1,2 +1,9 @@
|
|
|
1
1
|
export * from './fullscreen-renderer';
|
|
2
|
-
export * from './
|
|
2
|
+
export * from './gpu-timer';
|
|
3
|
+
export * from './oit-material';
|
|
4
|
+
export * from './OitMaterial';
|
|
5
|
+
export * from './Pass';
|
|
6
|
+
export * from './passes';
|
|
7
|
+
export * from './rendering-state';
|
|
8
|
+
export * from './RenderingPipeline';
|
|
9
|
+
export type { SMAAQuality } from './smaa-resolver';
|
|
@@ -0,0 +1,122 @@
|
|
|
1
|
+
import { IUniform, Material, ShaderMaterial, Side, Texture, Vector2 } from 'three';
|
|
2
|
+
/**
|
|
3
|
+
* The OIT render passes a material provides a variant for.
|
|
4
|
+
* - `depthMin`: min view-space linear depth pre-pass (front-layer detection)
|
|
5
|
+
* - `accum`: single-buffer weighted-blended OIT tail (b-weighted, carries coverage)
|
|
6
|
+
* - `front`: exact depth-peeled front layer (alpha-over)
|
|
7
|
+
* - `occlusion`: optional depth-only stamp that writes depth where the surface's own
|
|
8
|
+
* alpha clears `oitOcclusionThreshold` (used to occlude annotation labels). Off by
|
|
9
|
+
* default; its program is only compiled by Three when the pass actually renders it.
|
|
10
|
+
*/
|
|
11
|
+
export type OitPass = 'depthMin' | 'accum' | 'front' | 'occlusion';
|
|
12
|
+
/** The set of per-pass variant materials used by the OITRenderPass. */
|
|
13
|
+
export type OitVariants = Record<OitPass, Material>;
|
|
14
|
+
/** The OIT uniforms shared across a material's variants and set by the pass. */
|
|
15
|
+
export type OitUniforms = {
|
|
16
|
+
oitDepthFar: IUniform<number>;
|
|
17
|
+
oitScreenSize: IUniform<Vector2>;
|
|
18
|
+
oitMinDepthTexture: IUniform<Texture | null>;
|
|
19
|
+
oitSkipFront: IUniform<number>;
|
|
20
|
+
oitOcclusionThreshold: IUniform<number>;
|
|
21
|
+
};
|
|
22
|
+
/**
|
|
23
|
+
* A material that can participate in the {@link OITRenderPass} hybrid pipeline.
|
|
24
|
+
* Implemented by library materials (via {@link attachOitVariants}) and by patched
|
|
25
|
+
* stock / user materials (via {@link makeOitCompatible}).
|
|
26
|
+
*/
|
|
27
|
+
export interface OitCapableMaterial {
|
|
28
|
+
/** Returns the lazily-built per-pass variant materials (shared uniforms). */
|
|
29
|
+
getOitVariants(): OitVariants;
|
|
30
|
+
/** Returns the OIT uniforms object the pass updates each frame. */
|
|
31
|
+
getOitUniforms(): OitUniforms;
|
|
32
|
+
}
|
|
33
|
+
/** Options for making a material OIT-compatible. */
|
|
34
|
+
export type OitMaterialOptions = {
|
|
35
|
+
/**
|
|
36
|
+
* Force a specific `side` on all variants (e.g. `DoubleSide` for surfaces so back
|
|
37
|
+
* faces contribute to the tail). Defaults to the base material's side.
|
|
38
|
+
*/
|
|
39
|
+
side?: Side;
|
|
40
|
+
/**
|
|
41
|
+
* Names of properties on the material that hold uniform containers (objects of
|
|
42
|
+
* `IUniform`) which should be shared *by reference* with each per-pass variant.
|
|
43
|
+
* `ShaderMaterial` variants already share `uniforms`, but non-`ShaderMaterial`
|
|
44
|
+
* materials are cloned, so any custom uniform object they read in
|
|
45
|
+
* `onBeforeCompile` (e.g. a `uniforms` field used for slicing) must be listed
|
|
46
|
+
* here for live per-frame updates to reach the variants.
|
|
47
|
+
*/
|
|
48
|
+
shareUniforms?: string[];
|
|
49
|
+
/**
|
|
50
|
+
* Names of **value** properties to keep in sync from the base material onto the
|
|
51
|
+
* per-pass variants every frame. Only relevant for stock/built-in materials, whose
|
|
52
|
+
* variants are *cloned* and would otherwise snapshot their appearance at build time
|
|
53
|
+
* (`ShaderMaterial` variants share `uniforms` and are always live, so this is
|
|
54
|
+
* ignored for them).
|
|
55
|
+
*
|
|
56
|
+
* Restricted to value properties that do **not** affect the compiled program:
|
|
57
|
+
* - primitives (e.g. `metalness`, `roughness`, `emissiveIntensity`), and
|
|
58
|
+
* - copyable value objects with a `.copy()` method (e.g. `color`, `emissive` —
|
|
59
|
+
* `Color`; or `Vector2/3/4`), which are copied in place (no allocation, no
|
|
60
|
+
* recompile).
|
|
61
|
+
*
|
|
62
|
+
* Do **not** list program-affecting properties here (textures such as `map`,
|
|
63
|
+
* `vertexColors`, anything that toggles a shader `#define`) — changing those needs
|
|
64
|
+
* a recompile and is intentionally unsupported through this fast path. `opacity` is
|
|
65
|
+
* always kept live and need not be listed. Use {@link COMMON_OIT_SYNC_PROPS} for a
|
|
66
|
+
* sensible default set.
|
|
67
|
+
*
|
|
68
|
+
* @example
|
|
69
|
+
* ```ts
|
|
70
|
+
* makeOitCompatible(material, { syncProperties: ['color', 'metalness'] });
|
|
71
|
+
* // or spread the common set:
|
|
72
|
+
* makeOitCompatible(material, { syncProperties: [...COMMON_OIT_SYNC_PROPS] });
|
|
73
|
+
* ```
|
|
74
|
+
*/
|
|
75
|
+
syncProperties?: string[];
|
|
76
|
+
};
|
|
77
|
+
/**
|
|
78
|
+
* A convenient default set of common appearance properties to pass as
|
|
79
|
+
* {@link OitMaterialOptions.syncProperties} so runtime changes (e.g. recoloring) are
|
|
80
|
+
* reflected through the OIT passes for cloned built-in materials. Properties not
|
|
81
|
+
* present on a given material are ignored.
|
|
82
|
+
*
|
|
83
|
+
* @group Rendering
|
|
84
|
+
*/
|
|
85
|
+
export declare const COMMON_OIT_SYNC_PROPS: readonly ["color", "emissive", "emissiveIntensity", "metalness", "roughness"];
|
|
86
|
+
/** Type guard for {@link OitCapableMaterial}. */
|
|
87
|
+
export declare function isOitCapable(material: Material | null | undefined): material is Material & OitCapableMaterial;
|
|
88
|
+
/**
|
|
89
|
+
* Make a library `ShaderMaterial` OIT-capable. The material's fragment shader is
|
|
90
|
+
* expected to already `#include` `oit.glsl` and call `oitProcess(gl_FragColor)`
|
|
91
|
+
* guarded by `#ifdef USE_OIT` (a no-op in the default pipeline). This adds the OIT
|
|
92
|
+
* uniforms to the material and attaches the per-pass variant machinery.
|
|
93
|
+
*
|
|
94
|
+
* @param material - the library ShaderMaterial to extend
|
|
95
|
+
* @param options - optional overrides (e.g. `side`)
|
|
96
|
+
* @returns the same material, typed as {@link OitCapableMaterial}
|
|
97
|
+
*
|
|
98
|
+
* @group Rendering
|
|
99
|
+
* @see {@link makeOitCompatible}
|
|
100
|
+
*/
|
|
101
|
+
export declare function attachOitVariants<T extends ShaderMaterial>(material: T, options?: OitMaterialOptions): T & OitCapableMaterial;
|
|
102
|
+
/**
|
|
103
|
+
* Make any stock Three.js material or user-authored material OIT-compatible by
|
|
104
|
+
* patching its shaders at compile time (via `onBeforeCompile`) to include the OIT
|
|
105
|
+
* logic, and attaching the per-pass variant machinery.
|
|
106
|
+
*
|
|
107
|
+
* Works with lit built-in materials (which provide `vViewPosition`) and with
|
|
108
|
+
* materials lacking it (e.g. `LineBasicMaterial`), in which case `vViewPosition` is
|
|
109
|
+
* injected automatically. All injected code is guarded by `#ifdef USE_OIT`, so the
|
|
110
|
+
* base program is unchanged outside the OIT pipeline.
|
|
111
|
+
*
|
|
112
|
+
* Note: targets materials compiled by Three.js (built-ins, `ShaderMaterial`). Raw
|
|
113
|
+
* `RawShaderMaterial` (no Three.js shader prelude) is not auto-patched.
|
|
114
|
+
*
|
|
115
|
+
* @param material - the material to patch
|
|
116
|
+
* @param options - optional overrides (e.g. `side`)
|
|
117
|
+
* @returns the same material, typed as {@link OitCapableMaterial}
|
|
118
|
+
*
|
|
119
|
+
* @group Rendering
|
|
120
|
+
* @see {@link attachOitVariants}
|
|
121
|
+
*/
|
|
122
|
+
export declare function makeOitCompatible<T extends Material>(material: T, options?: OitMaterialOptions): T & OitCapableMaterial;
|
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
import { Camera, CanvasTexture, Clock, PerspectiveCamera, ShaderMaterial, Vector2, WebGLRenderer, WebGLRenderTarget } from 'three';
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
|
|
2
|
+
import { AnnotationInstance } from '../../components/Annotations/types';
|
|
3
|
+
import { FullscreenRenderer } from '../fullscreen-renderer';
|
|
4
|
+
import { Pass } from '../Pass';
|
|
5
|
+
export declare class AnnotationsPass extends Pass {
|
|
5
6
|
maxVisible: number;
|
|
6
7
|
camera: PerspectiveCamera;
|
|
7
8
|
clock: Clock;
|
|
@@ -12,11 +13,20 @@ export declare class AnnotationsRenderer {
|
|
|
12
13
|
annotationsRenderTarget: WebGLRenderTarget;
|
|
13
14
|
annotationsBuffer: Uint8Array;
|
|
14
15
|
annotationsMaterial: ShaderMaterial;
|
|
15
|
-
fullscreenRenderer: FullscreenRenderer;
|
|
16
16
|
annotationsData: AnnotationInstance[];
|
|
17
17
|
isBusy: boolean;
|
|
18
18
|
dataTextureNeedsUpdate: boolean;
|
|
19
|
+
fullscreenRenderer: FullscreenRenderer;
|
|
19
20
|
unsubscribeListeners: () => void;
|
|
21
|
+
private prevCameraMatrix;
|
|
22
|
+
private prevPointerX;
|
|
23
|
+
private prevPointerY;
|
|
24
|
+
private prevSizeX;
|
|
25
|
+
private prevSizeY;
|
|
26
|
+
private occlusionChanged;
|
|
27
|
+
connectorTargetFrameTime: number;
|
|
28
|
+
connectorStretchSlack: number;
|
|
29
|
+
connectorRestStretch: number;
|
|
20
30
|
constructor(camera: Camera, clock: Clock, pointer: Vector2, maxVisible?: number);
|
|
21
31
|
updateAnnotationsData(buffer: Uint8Array): void;
|
|
22
32
|
updateOverlayTexture(inViewSpace: AnnotationInstance[]): void;
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { WebGLRenderer, WebGLRenderTarget } from 'three';
|
|
2
|
+
import { Pass } from '../Pass';
|
|
3
|
+
/**
|
|
4
|
+
* Standalone FXAA post pass. Wraps a {@link FxaaResolver} and composites it in
|
|
5
|
+
* place into the shared pipeline buffer, so it works after any base pass
|
|
6
|
+
* ({@link RenderPass} or {@link OITRenderPass}) — unlike the OIT-internal SMAA /
|
|
7
|
+
* temporal modes it does not require order-independent transparency.
|
|
8
|
+
*
|
|
9
|
+
* Insert it between the base pass and the {@link OutputPass}:
|
|
10
|
+
* `[base, new FXAAPass(), new OutputPass()]`.
|
|
11
|
+
*/
|
|
12
|
+
export declare class FXAAPass extends Pass {
|
|
13
|
+
private resolver;
|
|
14
|
+
setSize(width: number, height: number): void;
|
|
15
|
+
dispose(): void;
|
|
16
|
+
render(renderer: WebGLRenderer, buffer: WebGLRenderTarget): void;
|
|
17
|
+
}
|