@equinor/videx-3d 1.1.1 → 2.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-61X6qE5N.js +981 -0
- package/dist/chunk-ChG5d4HC.js +675 -0
- package/dist/{chunk-BlPg4RjP.js → chunk-M-Pcc_Yg.js} +19 -19
- package/dist/generators.js +271 -260
- package/dist/main.js +4919 -3344
- package/dist/sdk.js +92 -90
- package/dist/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/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/generators/surface-generator.d.ts +1 -1
- package/dist/types/layers/layers.d.ts +4 -0
- package/dist/types/rendering/OitMaterial.d.ts +59 -0
- package/dist/types/rendering/Pass.d.ts +7 -0
- package/dist/types/rendering/RenderingPipeline.d.ts +37 -0
- package/dist/types/rendering/fullscreen-renderer.d.ts +1 -0
- package/dist/types/rendering/gpu-timer.d.ts +46 -0
- package/dist/types/rendering/index.d.ts +7 -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} +13 -4
- package/dist/types/rendering/passes/FXAAPass.d.ts +12 -0
- package/dist/types/rendering/passes/OITRenderPass.d.ts +282 -0
- package/dist/types/rendering/passes/OutputPass.d.ts +10 -0
- package/dist/types/rendering/passes/RenderPass.d.ts +8 -0
- package/dist/types/rendering/passes/SMAAPass.d.ts +40 -0
- package/dist/types/rendering/passes/TAAPass.d.ts +94 -0
- package/dist/types/rendering/passes/index.d.ts +6 -0
- package/dist/types/rendering/rendering-state.d.ts +59 -0
- package/dist/types/sdk/utils/elevation-map.d.ts +23 -0
- package/dist/types/sdk/utils/trigonometry.d.ts +4 -1
- package/package.json +1 -1
- package/dist/chunk-CnY6Tmof.js +0 -358
- package/dist/chunk-iY0wQ9Z6.js +0 -887
- package/dist/types/rendering/render-passes.d.ts +0 -16
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
import { Object3D } from 'three';
|
|
2
|
+
import { StoreApi } from 'zustand/vanilla';
|
|
3
|
+
/**
|
|
4
|
+
* Transparency rendering mode currently active for a given scene/canvas.
|
|
5
|
+
*
|
|
6
|
+
* - `'standard'`: default rendering, as if no custom rendering pipeline is used.
|
|
7
|
+
* Components apply their default self-transparency workarounds.
|
|
8
|
+
* - `'oit'`: an order-independent-transparency pipeline (e.g. {@link OITRenderPass})
|
|
9
|
+
* is active. Components should disable workarounds that conflict with OIT (such as
|
|
10
|
+
* depth-only mask passes) and let the pipeline resolve transparency.
|
|
11
|
+
*/
|
|
12
|
+
export type TransparencyMode = 'standard' | 'oit';
|
|
13
|
+
/**
|
|
14
|
+
* Per-canvas rendering pipeline state.
|
|
15
|
+
*
|
|
16
|
+
* Lets components react to which rendering pipeline (if any) is active without the
|
|
17
|
+
* user having to manually configure each component. The defaults match the behavior
|
|
18
|
+
* of default rendering with no custom pipeline.
|
|
19
|
+
*
|
|
20
|
+
* @group Rendering
|
|
21
|
+
*/
|
|
22
|
+
export type RenderingState = {
|
|
23
|
+
/** The active transparency mode. Defaults to `'standard'`. */
|
|
24
|
+
transparencyMode: TransparencyMode;
|
|
25
|
+
/** @internal reference count of active OIT pipelines. */
|
|
26
|
+
_oitCount: number;
|
|
27
|
+
/**
|
|
28
|
+
* Register an active OIT pipeline. Sets {@link RenderingState.transparencyMode}
|
|
29
|
+
* to `'oit'`. Returns a release function that must be called when the pipeline is
|
|
30
|
+
* disposed; the mode reverts to `'standard'` once all registrations are released.
|
|
31
|
+
* Reference counted so multiple/short-lived passes behave correctly.
|
|
32
|
+
*/
|
|
33
|
+
acquireOit: () => () => void;
|
|
34
|
+
};
|
|
35
|
+
/**
|
|
36
|
+
* Get (or lazily create) the {@link RenderingState} store for a given scene.
|
|
37
|
+
*
|
|
38
|
+
* Both the rendering passes (which hold a reference to the scene) and the hooks used
|
|
39
|
+
* by components (which resolve the scene via R3F) call this with the same scene, so
|
|
40
|
+
* they share a single store instance per canvas. No provider is required — the store
|
|
41
|
+
* is created on first access, so components used without any pipeline still work and
|
|
42
|
+
* simply observe the `'standard'` default.
|
|
43
|
+
*
|
|
44
|
+
* @group Rendering
|
|
45
|
+
*/
|
|
46
|
+
export declare function getRenderingState(scene: Object3D): StoreApi<RenderingState>;
|
|
47
|
+
/**
|
|
48
|
+
* Hook to read the per-canvas {@link RenderingState}. Resolves the store from the
|
|
49
|
+
* current R3F scene, so it must be used inside a `Canvas`.
|
|
50
|
+
*
|
|
51
|
+
* @example
|
|
52
|
+
* ```tsx
|
|
53
|
+
* const isOit = useRenderingState(state => state.transparencyMode === 'oit');
|
|
54
|
+
* ```
|
|
55
|
+
*
|
|
56
|
+
* @group Hooks
|
|
57
|
+
* @category Rendering
|
|
58
|
+
*/
|
|
59
|
+
export declare function useRenderingState<T>(selector: (state: RenderingState) => T): T;
|
|
@@ -13,3 +13,26 @@ export declare function createNormalTexture(buffer: Uint8Array, width: number, h
|
|
|
13
13
|
* Create a data texture from RGBA encoded depth values
|
|
14
14
|
*/
|
|
15
15
|
export declare function createElevationTexture(buffer: Float32Array, width: number, height: number): DataTexture;
|
|
16
|
+
/**
|
|
17
|
+
* Compute geometric surface normals from an elevation grid, encoded as a compact
|
|
18
|
+
* RG8 buffer (2 bytes/texel) using a hemisphere encoding: only the grid-local
|
|
19
|
+
* `x` and `z` components are stored (mapped to [0, 1]); the consumer reconstructs
|
|
20
|
+
* `y = sqrt(1 - x^2 - z^2)`.
|
|
21
|
+
*
|
|
22
|
+
* This replicates the per-fragment normal that `SurfaceMaterial`'s shader derives
|
|
23
|
+
* from the elevation texture (same four diagonal neighbours, cross products and
|
|
24
|
+
* hole handling), but pays the cost once on the CPU instead of in every OIT pass.
|
|
25
|
+
* The result is laid out to match the elevation buffer (row-major, intended for a
|
|
26
|
+
* `flipY = true` texture), so it samples 1:1 with the same grid UVs.
|
|
27
|
+
*
|
|
28
|
+
* @param data elevation values (row-major, holes < 0)
|
|
29
|
+
* @param columns number of columns (nx)
|
|
30
|
+
* @param rows number of rows (ny)
|
|
31
|
+
* @param xScale column spacing (xinc)
|
|
32
|
+
* @param yScale row spacing (yinc)
|
|
33
|
+
*/
|
|
34
|
+
export declare function computeSurfaceNormalsRG(data: Float32Array, columns: number, rows: number, xScale: number, yScale: number): Uint8Array<ArrayBuffer>;
|
|
35
|
+
/**
|
|
36
|
+
* Create an RG8 data texture from a buffer produced by {@link computeSurfaceNormalsRG}.
|
|
37
|
+
*/
|
|
38
|
+
export declare function createPackedNormalTexture(buffer: Uint8Array, width: number, height: number): DataTexture;
|
|
@@ -8,5 +8,8 @@ export declare const PI8: number;
|
|
|
8
8
|
* Given a 2D rectangle and an angle off the center, find the point
|
|
9
9
|
* of the closest corner. Used for anchoring connector lines
|
|
10
10
|
* to annotation labels.
|
|
11
|
+
*
|
|
12
|
+
* Pass an optional `target` array to write the result into, avoiding
|
|
13
|
+
* an allocation in hot paths.
|
|
11
14
|
*/
|
|
12
|
-
export declare function edgeOfRectangle(rect: Vec2, theta: number): Vec2;
|
|
15
|
+
export declare function edgeOfRectangle(rect: Vec2, theta: number, target?: Vec2): Vec2;
|
package/package.json
CHANGED
package/dist/chunk-CnY6Tmof.js
DELETED
|
@@ -1,358 +0,0 @@
|
|
|
1
|
-
import Q from "proj4";
|
|
2
|
-
import { DataTexture as z, RedFormat as $, FloatType as I, LinearFilter as T, UniformsGroup as O, Uniform as h, Vector4 as Y, Vector3 as Z, Vector2 as J, RedIntegerFormat as j, UnsignedShortType as q, ShaderMaterial as K, UniformsUtils as X, ShaderLib as ee } from "three";
|
|
3
|
-
import "comlink";
|
|
4
|
-
import "p-limit";
|
|
5
|
-
import "curve-interpolator";
|
|
6
|
-
import { a3 as B, aa as ne, ah as A, F as te } from "./chunk-iY0wQ9Z6.js";
|
|
7
|
-
import "three/src/math/MathUtils.js";
|
|
8
|
-
function ge(e, n, r) {
|
|
9
|
-
const t = /* @__PURE__ */ new Map(), l = {};
|
|
10
|
-
n.sort((o, s) => o.id === r ? -1 : s.id === r ? 1 : o.drilled && s.drilled ? s.drilled.getTime() - o.drilled.getTime() : o.name.localeCompare(s.name));
|
|
11
|
-
for (let o = 0; o < n.length; o++) {
|
|
12
|
-
const s = n[o];
|
|
13
|
-
if (!s) continue;
|
|
14
|
-
let u = s.parent && s.kickoffDepthMsl !== null ? s.kickoffDepthMsl : -s.depthReferenceElevation;
|
|
15
|
-
if (t.has(s.id))
|
|
16
|
-
u = t.get(s.id);
|
|
17
|
-
else {
|
|
18
|
-
let m = s.parent;
|
|
19
|
-
for (; m; ) {
|
|
20
|
-
const a = e[m];
|
|
21
|
-
if (!a) break;
|
|
22
|
-
if (t.has(a.id)) {
|
|
23
|
-
const i = t.get(a.id);
|
|
24
|
-
u >= i && (t.set(a.id, u), u = i);
|
|
25
|
-
break;
|
|
26
|
-
} else
|
|
27
|
-
t.set(a.id, u), u = a.parent && a.kickoffDepthMsl !== null ? a.kickoffDepthMsl : -a.depthReferenceElevation;
|
|
28
|
-
m = a.parent;
|
|
29
|
-
}
|
|
30
|
-
}
|
|
31
|
-
l[s.id] = [u, o], t.set(s.id, s.depthMdMsl);
|
|
32
|
-
}
|
|
33
|
-
return l;
|
|
34
|
-
}
|
|
35
|
-
const re = "+proj=longlat +ellps=WGS84 +datum=WGS84 +no_defs";
|
|
36
|
-
class me {
|
|
37
|
-
utmDef;
|
|
38
|
-
originWgs84;
|
|
39
|
-
originUtm;
|
|
40
|
-
_projection;
|
|
41
|
-
constructor(n, r, t = "lnglat") {
|
|
42
|
-
this.utmDef = n, this._projection = Q(re, n), t === "lnglat" ? (this.originWgs84 = r, this.originUtm = this.wgs84ToUtm(r)) : (this.originWgs84 = this.utmToWgs84(r), this.originUtm = r);
|
|
43
|
-
}
|
|
44
|
-
utmToWgs84(n) {
|
|
45
|
-
return this._projection.inverse(n);
|
|
46
|
-
}
|
|
47
|
-
wgs84ToUtm(n) {
|
|
48
|
-
return this._projection.forward(n);
|
|
49
|
-
}
|
|
50
|
-
utmToWorld(n, r, t) {
|
|
51
|
-
return {
|
|
52
|
-
x: n - this.originUtm[0],
|
|
53
|
-
y: t,
|
|
54
|
-
z: this.originUtm[1] - r
|
|
55
|
-
};
|
|
56
|
-
}
|
|
57
|
-
worldToUtm(n, r, t) {
|
|
58
|
-
return {
|
|
59
|
-
easting: n + this.originUtm[0],
|
|
60
|
-
altitude: r,
|
|
61
|
-
northing: this.originUtm[1] - t
|
|
62
|
-
};
|
|
63
|
-
}
|
|
64
|
-
wgs84ToWorld(n, r, t = 0) {
|
|
65
|
-
const l = this.wgs84ToUtm([n, r]);
|
|
66
|
-
return this.utmToWorld(l[0], l[1], t);
|
|
67
|
-
}
|
|
68
|
-
worldToWgs84(n, r, t) {
|
|
69
|
-
const l = this.worldToUtm(n, r, t), o = this.utmToWgs84([l.easting, l.northing]);
|
|
70
|
-
return {
|
|
71
|
-
lng: o[0],
|
|
72
|
-
lat: o[1],
|
|
73
|
-
alt: r
|
|
74
|
-
};
|
|
75
|
-
}
|
|
76
|
-
}
|
|
77
|
-
function pe(e) {
|
|
78
|
-
const [, n, r] = new RegExp(/^([0-9]{2})([N|S]?)$/).exec(e) || [];
|
|
79
|
-
return `+proj=utm +zone=${n}${r === "S" ? " +south" : ""} +ellps=intl +towgs84=-87,-98,-121,0,0,0,0 +units=m +no_defs`;
|
|
80
|
-
}
|
|
81
|
-
function he([e, n]) {
|
|
82
|
-
if (n > 55 && n < 64 && e > 2 && e < 6)
|
|
83
|
-
return "32N";
|
|
84
|
-
if (n > 71 && e >= 6 && e < 9)
|
|
85
|
-
return "31N";
|
|
86
|
-
if (n > 71 && (e >= 9 && e < 12 || e >= 18 && e < 21))
|
|
87
|
-
return "33N";
|
|
88
|
-
if (n > 71 && (e >= 21 && e < 24 || e >= 30 && e < 33))
|
|
89
|
-
return "35N";
|
|
90
|
-
if (e >= -180 && e <= 180) {
|
|
91
|
-
const r = Math.floor((e + 180) / 6) % 60 + 1;
|
|
92
|
-
return n < 0 ? `${r}S` : `${r}N`;
|
|
93
|
-
}
|
|
94
|
-
throw new Error(
|
|
95
|
-
`getUtmZoneFromLatLng: Cannot figure out UTM zone from give Lat: ${n}, Lng: ${e}`
|
|
96
|
-
);
|
|
97
|
-
}
|
|
98
|
-
function b(e, n, r) {
|
|
99
|
-
const t = A(e, n), l = A(e, r);
|
|
100
|
-
return B(te(t, l));
|
|
101
|
-
}
|
|
102
|
-
function ve(e, n, r, t, l = 0, o = -1) {
|
|
103
|
-
const s = e.length / n, u = n - 1, m = s - 1, a = new Uint8Array(u * m * 4);
|
|
104
|
-
let i = 0;
|
|
105
|
-
const d = (c, g) => e[g * n + c];
|
|
106
|
-
for (let c = 0; c < m; c++) {
|
|
107
|
-
const g = c + 1, p = c + 0.5;
|
|
108
|
-
for (let f = 0; f < u; f++) {
|
|
109
|
-
const v = f + 1, w = f + 0.5, _ = d(f, c);
|
|
110
|
-
if (_ !== o) {
|
|
111
|
-
const V = d(f, g), F = d(v, c), M = d(v, g), D = (_ + V + F + M) / 4, G = [f * r, c * t, _], L = [f * r, g * t, V], P = [v * r, c * t, F], E = [v * r, g * t, M], x = [w * r, p * t, D], C = b(x, G, P), R = b(x, P, E), H = b(x, E, L), U = b(x, L, G), S = B([
|
|
112
|
-
C[0] + R[0] + H[0] + U[0],
|
|
113
|
-
C[2] + R[2] + H[2] + U[2],
|
|
114
|
-
C[1] + R[1] + H[1] + U[1]
|
|
115
|
-
]), y = ne(S, [0, 1, 0], l * (Math.PI / 180)), W = Math.floor((y[0] + 1) / 2 * 255), N = Math.floor((y[1] + 1) / 2 * 255), k = Math.floor((y[2] + 1) / 2 * 255);
|
|
116
|
-
a[i] = W, a[i + 1] = N, a[i + 2] = k, a[i + 3] = 255;
|
|
117
|
-
} else
|
|
118
|
-
a[i] = 0, a[i + 1] = 0, a[i + 2] = 0, a[i + 3] = 0;
|
|
119
|
-
i += 4;
|
|
120
|
-
}
|
|
121
|
-
}
|
|
122
|
-
return a;
|
|
123
|
-
}
|
|
124
|
-
function _e(e, n, r) {
|
|
125
|
-
const t = new z(e, n, r);
|
|
126
|
-
return t.minFilter = T, t.magFilter = T, t.flipY = !0, t.anisotropy = 4, t.needsUpdate = !0, t;
|
|
127
|
-
}
|
|
128
|
-
function we(e, n, r) {
|
|
129
|
-
const t = new z(
|
|
130
|
-
e,
|
|
131
|
-
n,
|
|
132
|
-
r,
|
|
133
|
-
$,
|
|
134
|
-
I
|
|
135
|
-
);
|
|
136
|
-
return t.minFilter = T, t.magFilter = T, t.needsUpdate = !0, t.flipY = !0, t;
|
|
137
|
-
}
|
|
138
|
-
function xe(e) {
|
|
139
|
-
const n = new Map(
|
|
140
|
-
e.chars.map((i, d) => [i.id, { index: d, spacing: i.xadvance }])
|
|
141
|
-
), r = 32, t = (i) => {
|
|
142
|
-
const d = [];
|
|
143
|
-
let c = 0;
|
|
144
|
-
for (let g = 0; g < i.length; g++) {
|
|
145
|
-
let p = i.charCodeAt(g);
|
|
146
|
-
n.has(p) || (p = r);
|
|
147
|
-
const f = n.get(p);
|
|
148
|
-
f && (d.push(f.index), c += f.spacing);
|
|
149
|
-
}
|
|
150
|
-
return {
|
|
151
|
-
indices: d,
|
|
152
|
-
width: c
|
|
153
|
-
};
|
|
154
|
-
}, l = (i) => {
|
|
155
|
-
i = Array.isArray(i) ? i : [i];
|
|
156
|
-
const d = [], c = [];
|
|
157
|
-
for (let f = 0; f < i.length; f++) {
|
|
158
|
-
const v = i[f], w = t(v), _ = c.length;
|
|
159
|
-
c.push(...w.indices), d.push([_, c.length, w.width]);
|
|
160
|
-
}
|
|
161
|
-
c.length || c.push(0);
|
|
162
|
-
const g = c.length;
|
|
163
|
-
d.forEach((f) => c.push(...f));
|
|
164
|
-
const p = new z(
|
|
165
|
-
new Uint16Array(c),
|
|
166
|
-
c.length,
|
|
167
|
-
1,
|
|
168
|
-
j,
|
|
169
|
-
q
|
|
170
|
-
);
|
|
171
|
-
return p.needsUpdate = !0, { texture: p, textPointersOffset: g, textPointersCount: d.length };
|
|
172
|
-
}, o = new O();
|
|
173
|
-
o.setName("GlyphData");
|
|
174
|
-
const s = [], u = [];
|
|
175
|
-
e.chars.forEach((i) => {
|
|
176
|
-
s.push(
|
|
177
|
-
new h(new Y(i.x, i.y, i.width, i.height))
|
|
178
|
-
), u.push(
|
|
179
|
-
new h(new Z(i.xoffset, i.yoffset, i.xadvance))
|
|
180
|
-
);
|
|
181
|
-
}), o.add(s), o.add(u), o.add(
|
|
182
|
-
new h(new J(e.common.scaleW, e.common.scaleH))
|
|
183
|
-
), o.add(new h(e.info.size)), o.add(new h(e.distanceField.distanceRange)), o.add(new h(e.common.lineHeight)), o.add(new h(e.common.base));
|
|
184
|
-
const m = () => {
|
|
185
|
-
o.dispose();
|
|
186
|
-
};
|
|
187
|
-
return {
|
|
188
|
-
glyphsCount: e.chars.length,
|
|
189
|
-
glyphData: o,
|
|
190
|
-
encodeText: t,
|
|
191
|
-
encodeTextTexture: l,
|
|
192
|
-
dispose: m
|
|
193
|
-
};
|
|
194
|
-
}
|
|
195
|
-
function be(e, n, r) {
|
|
196
|
-
if (e.length === 0) return [];
|
|
197
|
-
e.sort((o, s) => n(o) - n(s));
|
|
198
|
-
const t = [];
|
|
199
|
-
let l = { start: n(e[0]), end: r(e[0]) };
|
|
200
|
-
for (let o = 1; o < e.length; o += 1)
|
|
201
|
-
n(e[o]) === l.end ? l.end = r(e[o]) : (t.push(l), l = { start: n(e[o]), end: r(e[o]) });
|
|
202
|
-
return t.push(l), t;
|
|
203
|
-
}
|
|
204
|
-
var oe = `#define TRAJECTORY_MATERIAL
|
|
205
|
-
|
|
206
|
-
uniform vec3 diffuse;
|
|
207
|
-
uniform float opacity;
|
|
208
|
-
|
|
209
|
-
#ifndef FLAT_SHADED
|
|
210
|
-
varying vec3 vNormal;
|
|
211
|
-
#endif
|
|
212
|
-
varying vec3 vViewPosition;
|
|
213
|
-
#include <common>
|
|
214
|
-
#include <color_pars_fragment>
|
|
215
|
-
#include <uv_pars_fragment>
|
|
216
|
-
#include <map_pars_fragment>
|
|
217
|
-
#include <fog_pars_fragment>
|
|
218
|
-
#include <logdepthbuf_pars_fragment>
|
|
219
|
-
#include <clipping_planes_pars_fragment>
|
|
220
|
-
|
|
221
|
-
vec3 hue2rgb(in float H) {
|
|
222
|
-
float R = abs(H * 6. - 3.) - 1.;
|
|
223
|
-
float G = 2. - abs(H * 6. - 2.);
|
|
224
|
-
float B = 2. - abs(H * 6. - 4.);
|
|
225
|
-
return saturate(vec3(R, G, B));
|
|
226
|
-
}
|
|
227
|
-
|
|
228
|
-
vec3 hsl2rgb(in vec3 HSL) {
|
|
229
|
-
vec3 RGB = hue2rgb(HSL.x);
|
|
230
|
-
float C = (1. - abs(2. * HSL.z - 1.)) * HSL.y;
|
|
231
|
-
return (RGB - 0.5) * C + HSL.z;
|
|
232
|
-
}
|
|
233
|
-
|
|
234
|
-
vec3 rgb2hsv(in vec3 RGB) {
|
|
235
|
-
|
|
236
|
-
vec4 P = (RGB.g < RGB.b) ? vec4(RGB.bg, -1.0, 2.0 / 3.0) : vec4(RGB.gb, 0.0, -1.0 / 3.0);
|
|
237
|
-
vec4 Q = (RGB.r < P.x) ? vec4(P.xyw, RGB.r) : vec4(RGB.r, P.yzx);
|
|
238
|
-
float C = Q.x - min(Q.w, Q.y);
|
|
239
|
-
float H = abs((Q.w - Q.y) / (6. * C + EPSILON) + Q.z);
|
|
240
|
-
return vec3(H, C, Q.x);
|
|
241
|
-
}
|
|
242
|
-
|
|
243
|
-
vec3 rgb2hsl(in vec3 RGB) {
|
|
244
|
-
vec3 HCV = rgb2hsv(RGB);
|
|
245
|
-
float L = HCV.z - HCV.y * 0.5;
|
|
246
|
-
float S = HCV.y / (1. - abs(L * 2. - 1.) + EPSILON);
|
|
247
|
-
return vec3(HCV.x, S, L);
|
|
248
|
-
}
|
|
249
|
-
|
|
250
|
-
vec3 hsv2rgb(in vec3 HSV) {
|
|
251
|
-
vec3 RGB = hue2rgb(HSV.x);
|
|
252
|
-
return ((RGB - 1.) * HSV.y + 1.) * HSV.z;
|
|
253
|
-
}
|
|
254
|
-
|
|
255
|
-
void main() {
|
|
256
|
-
#include <clipping_planes_fragment>
|
|
257
|
-
|
|
258
|
-
vec3 color = diffuse.rgb;
|
|
259
|
-
|
|
260
|
-
vec4 diffuseColor = vec4(color.rgb, opacity);
|
|
261
|
-
|
|
262
|
-
#include <logdepthbuf_fragment>
|
|
263
|
-
#include <map_fragment>
|
|
264
|
-
#include <color_fragment>
|
|
265
|
-
#include <normal_fragment_begin>
|
|
266
|
-
|
|
267
|
-
#ifdef DEPTH_SHADE
|
|
268
|
-
float depthFactor = clamp(dot(normalize(vNormal), normalize(vViewPosition)), 0.0, 1.0);
|
|
269
|
-
float darkenFactor = clamp(vViewPosition.z / 5000.0, 0.1, 0.8);
|
|
270
|
-
vec3 hsv = rgb2hsv(diffuseColor.rgb);
|
|
271
|
-
hsv.z = hsv.z * darkenFactor;
|
|
272
|
-
vec3 mixColor = hsv2rgb(hsv);
|
|
273
|
-
diffuseColor.rgb = mix(mixColor, diffuseColor.rgb, pow(depthFactor, 0.8));
|
|
274
|
-
#else
|
|
275
|
-
float alphaFactor = clamp(vViewPosition.z / 100000.0, 0.0, 0.9);
|
|
276
|
-
|
|
277
|
-
diffuseColor.a = 1.0 - alphaFactor;
|
|
278
|
-
#endif
|
|
279
|
-
|
|
280
|
-
gl_FragColor = diffuseColor.rgba;
|
|
281
|
-
|
|
282
|
-
#include <tonemapping_fragment>
|
|
283
|
-
#include <colorspace_fragment>
|
|
284
|
-
#include <fog_fragment>
|
|
285
|
-
|
|
286
|
-
#ifdef OPAQUE
|
|
287
|
-
|
|
288
|
-
gl_FragColor.a = 1.0;
|
|
289
|
-
|
|
290
|
-
#endif
|
|
291
|
-
}`, ie = `#define TRAJECTORY_MATERIAL
|
|
292
|
-
|
|
293
|
-
varying vec3 vViewPosition;
|
|
294
|
-
|
|
295
|
-
#include <common>
|
|
296
|
-
#include <batching_pars_vertex>
|
|
297
|
-
#include <uv_pars_vertex>
|
|
298
|
-
#include <envmap_pars_vertex>
|
|
299
|
-
#include <color_pars_vertex>
|
|
300
|
-
#include <fog_pars_vertex>
|
|
301
|
-
#include <normal_pars_fragment>
|
|
302
|
-
#include <logdepthbuf_pars_vertex>
|
|
303
|
-
#include <clipping_planes_pars_vertex>
|
|
304
|
-
|
|
305
|
-
void main() {
|
|
306
|
-
|
|
307
|
-
#include <uv_vertex>
|
|
308
|
-
#include <color_vertex>
|
|
309
|
-
#include <batching_vertex>
|
|
310
|
-
#include <beginnormal_vertex>
|
|
311
|
-
#include <defaultnormal_vertex>
|
|
312
|
-
#include <normal_vertex>
|
|
313
|
-
|
|
314
|
-
#include <begin_vertex>
|
|
315
|
-
#include <project_vertex>
|
|
316
|
-
#include <logdepthbuf_vertex>
|
|
317
|
-
#include <clipping_planes_vertex>
|
|
318
|
-
|
|
319
|
-
vViewPosition = - mvPosition.xyz;
|
|
320
|
-
|
|
321
|
-
#include <worldpos_vertex>
|
|
322
|
-
#include <fog_vertex>
|
|
323
|
-
}`;
|
|
324
|
-
class Te extends K {
|
|
325
|
-
isTubeMaterial = !0;
|
|
326
|
-
constructor(n) {
|
|
327
|
-
super({
|
|
328
|
-
vertexShader: ie,
|
|
329
|
-
fragmentShader: oe,
|
|
330
|
-
uniforms: X.clone(ee.basic.uniforms),
|
|
331
|
-
defines: {
|
|
332
|
-
DEPTH_SHADE: !0
|
|
333
|
-
},
|
|
334
|
-
clipping: !0,
|
|
335
|
-
fog: !0
|
|
336
|
-
}), n && this.setValues(n);
|
|
337
|
-
}
|
|
338
|
-
get color() {
|
|
339
|
-
return this.uniforms.diffuse.value;
|
|
340
|
-
}
|
|
341
|
-
set color(n) {
|
|
342
|
-
this.uniforms.diffuse.value.set(n);
|
|
343
|
-
}
|
|
344
|
-
}
|
|
345
|
-
export {
|
|
346
|
-
me as C,
|
|
347
|
-
Te as T,
|
|
348
|
-
we as a,
|
|
349
|
-
xe as b,
|
|
350
|
-
ge as c,
|
|
351
|
-
_e as d,
|
|
352
|
-
ve as e,
|
|
353
|
-
he as f,
|
|
354
|
-
pe as g,
|
|
355
|
-
b as h,
|
|
356
|
-
be as t,
|
|
357
|
-
re as w
|
|
358
|
-
};
|