roamwright 0.1.0 → 0.2.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/CONTRIBUTING.md +39 -8
- package/README.md +53 -24
- package/examples/viaduct-camera.js +40 -0
- package/examples/viaduct-landscape.js +81 -0
- package/examples/viaduct.css +75 -0
- package/examples/viaduct.html +47 -0
- package/examples/viaduct.js +332 -0
- package/geometry/builder.js +11 -14
- package/geometry/creased-sheet.js +127 -0
- package/geometry/ear.js +97 -0
- package/geometry/erosion.js +106 -0
- package/geometry/face-grid.js +143 -0
- package/geometry/garment-tags.js +11 -0
- package/geometry/hair-gathers.js +174 -0
- package/geometry/hair-locks.js +156 -0
- package/geometry/hair-patch.js +42 -0
- package/geometry/hair-shell.js +186 -0
- package/geometry/hair-tags.js +6 -0
- package/geometry/head-profile.js +138 -0
- package/geometry/head-shape.js +499 -0
- package/geometry/heightfield.js +68 -0
- package/geometry/outline-grid.js +46 -0
- package/geometry/path-field.js +65 -0
- package/geometry/sagging-tube.js +58 -0
- package/geometry/sampled-surface.js +101 -0
- package/geometry/scatter-grid.js +32 -0
- package/geometry/sculpt.js +263 -0
- package/geometry/shore-grid.js +67 -0
- package/geometry/strata-field.js +339 -0
- package/geometry/strata-tiles.js +215 -0
- package/geometry/stream.js +94 -0
- package/geometry/terrain-chunks.js +300 -0
- package/geometry/terrain-extension.js +44 -0
- package/math/cell-edge.js +44 -0
- package/math/cloth-textures.js +83 -0
- package/math/cloud-textures.js +112 -0
- package/math/color.js +29 -0
- package/math/curve.js +3 -4
- package/math/mountain-ranges.js +463 -0
- package/math/particle-noise.js +48 -0
- package/math/periodic.js +20 -0
- package/math/rock-texture.js +56 -0
- package/math/surface-textures.js +241 -0
- package/motion/arm-reach.js +74 -0
- package/motion/biped-stride.js +276 -0
- package/motion/crowd-alarms.js +127 -0
- package/motion/crowd-routine.js +183 -0
- package/motion/daily-clock.js +59 -0
- package/motion/instance-sight.js +84 -0
- package/motion/quadruped.js +332 -0
- package/motion/weather.js +59 -0
- package/motion/wind.js +27 -0
- package/package.json +6 -4
- package/rendering/caster-motion.js +79 -0
- package/rendering/cell-lod.js +175 -0
- package/rendering/cloud-dome.js +371 -0
- package/rendering/cloud-field.js +83 -0
- package/rendering/compilation-schedule.js +34 -0
- package/rendering/contact-shadows.js +79 -0
- package/rendering/crowd-skinning.js +133 -0
- package/rendering/crust.js +28 -0
- package/rendering/daylight.js +50 -0
- package/rendering/far-shadow.js +186 -0
- package/rendering/flocks.js +323 -0
- package/rendering/garment-material.js +110 -0
- package/rendering/glow-lines.js +74 -0
- package/rendering/glow-shell.js +90 -0
- package/rendering/hair-strands.js +67 -0
- package/rendering/height-haze.js +129 -0
- package/rendering/height-probe.js +91 -0
- package/rendering/interior-mapping.js +19 -0
- package/rendering/light-budget.js +222 -0
- package/rendering/light-points.js +51 -0
- package/rendering/light-shafts.js +131 -0
- package/rendering/local-lights.js +28 -0
- package/rendering/low-light.js +13 -0
- package/rendering/material-lod.js +110 -0
- package/rendering/particle-emitters.js +223 -0
- package/rendering/particles.js +297 -0
- package/rendering/planar-reflection.js +175 -0
- package/rendering/post-shaders.js +21 -1
- package/rendering/post.js +8 -5
- package/rendering/rain-rings.js +22 -0
- package/rendering/road-surface.js +63 -0
- package/rendering/sea-shaders.js +230 -0
- package/rendering/shader-warmup.js +197 -0
- package/rendering/shadow-alignment.js +28 -0
- package/rendering/shadow-depth.js +129 -0
- package/rendering/sky-occlusion.js +187 -0
- package/rendering/sky.js +169 -0
- package/rendering/stage-lights.js +209 -0
- package/rendering/static-point-shadow.js +119 -0
- package/rendering/still-casters.js +6 -11
- package/rendering/strata-material.js +93 -0
- package/rendering/stream-flow.js +36 -0
- package/rendering/surface-light.js +22 -0
- package/rendering/surface-projection.js +69 -0
- package/rendering/talus.js +26 -0
- package/rendering/terrain-rock.js +48 -0
- package/rendering/texture-fills.js +68 -0
- package/rendering/viewport.js +9 -0
- package/rendering/wakes.js +99 -0
- package/rendering/water-material.js +288 -0
- package/rendering/world-matrices.js +4 -6
- package/runtime/device-quality.js +27 -0
- package/runtime/diagnostic-log.js +80 -0
- package/runtime/events.js +14 -0
- package/runtime/first-use.js +3 -1
- package/runtime/frame-yield.js +14 -0
- package/runtime/grid-cache.js +88 -0
- package/runtime/grid-rows.js +9 -0
- package/runtime/module-preload.js +15 -0
- package/runtime/quality-fit.js +5 -9
- package/runtime/search.js +69 -0
- package/runtime/spatial-audio.js +57 -0
- package/scripts/serve.py +26 -0
|
@@ -0,0 +1,106 @@
|
|
|
1
|
+
import { lerp, sstep } from '../math/scalar.js';
|
|
2
|
+
|
|
3
|
+
// Weights in a circular erosion brush sum to one, including a fractional radius.
|
|
4
|
+
function erosionBrush(radius) {
|
|
5
|
+
const cells = [],
|
|
6
|
+
r = Math.ceil(radius);
|
|
7
|
+
let sum = 0;
|
|
8
|
+
for (let dj = -r; dj <= r; dj++)
|
|
9
|
+
for (let di = -r; di <= r; di++) {
|
|
10
|
+
const w = Math.max(0, radius - Math.hypot(di, dj));
|
|
11
|
+
if (w > 0) {
|
|
12
|
+
cells.push(di, dj, w);
|
|
13
|
+
sum += w;
|
|
14
|
+
}
|
|
15
|
+
}
|
|
16
|
+
for (let c = 2; c < cells.length; c += 3) cells[c] /= sum;
|
|
17
|
+
return cells;
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
// Erode a square vertex grid in place, using a per-vertex influence mask in [0,1].
|
|
21
|
+
// rng supplies reproducible samples in [0,1); all distances are in grid cells.
|
|
22
|
+
export function erodeHeightfield(heights, width, mask, rng, options) {
|
|
23
|
+
const { drops, lifetime, inertia, capacityFactor, minCapacity, erosionRate,
|
|
24
|
+
depositRate, evaporation, gravity, radius, maxChange } = options;
|
|
25
|
+
if (!Number.isInteger(width) || width < 4 || heights.length !== width * width || mask.length !== heights.length) {
|
|
26
|
+
throw new RangeError('height and mask grids must match the square width');
|
|
27
|
+
}
|
|
28
|
+
if (!(radius > 0)) throw new RangeError('radius must be positive');
|
|
29
|
+
const last = width - 1, start = heights.slice(), brush = erosionBrush(radius);
|
|
30
|
+
const hg = [0, 0, 0]; // height and its slope across and along at a point, worked out by heightGrad
|
|
31
|
+
// the height at (px, py) in cells, and its gradient, from the four cells round it
|
|
32
|
+
const heightGrad = (px, py) => {
|
|
33
|
+
const i = px | 0,
|
|
34
|
+
j = py | 0,
|
|
35
|
+
u = px - i,
|
|
36
|
+
v = py - j,
|
|
37
|
+
k = j * width + i,
|
|
38
|
+
a = heights[k],
|
|
39
|
+
b = heights[k + 1],
|
|
40
|
+
c = heights[k + width],
|
|
41
|
+
d = heights[k + width + 1];
|
|
42
|
+
hg[0] = a * (1 - u) * (1 - v) + b * u * (1 - v) + c * (1 - u) * v + d * u * v;
|
|
43
|
+
hg[1] = (b - a) * (1 - v) + (d - c) * v;
|
|
44
|
+
hg[2] = (c - a) * (1 - u) + (d - b) * u;
|
|
45
|
+
};
|
|
46
|
+
const change = (k, amount) => {
|
|
47
|
+
const h = heights[k] + amount * mask[k];
|
|
48
|
+
heights[k] = Math.min(Math.max(h, start[k] - maxChange), start[k] + maxChange);
|
|
49
|
+
};
|
|
50
|
+
for (let n = 0; n < drops; n++) {
|
|
51
|
+
let px = 1 + rng() * (last - 2),
|
|
52
|
+
py = 1 + rng() * (last - 2);
|
|
53
|
+
if (mask[(py | 0) * width + (px | 0)] <= 0) continue;
|
|
54
|
+
let dx = 0,
|
|
55
|
+
dy = 0,
|
|
56
|
+
speed = 1,
|
|
57
|
+
water = 1,
|
|
58
|
+
carried = 0;
|
|
59
|
+
for (let life = 0; life < lifetime; life++) {
|
|
60
|
+
const i = px | 0,
|
|
61
|
+
j = py | 0,
|
|
62
|
+
u = px - i,
|
|
63
|
+
v = py - j,
|
|
64
|
+
k = j * width + i;
|
|
65
|
+
heightGrad(px, py);
|
|
66
|
+
const h = hg[0];
|
|
67
|
+
dx = dx * inertia - hg[1] * (1 - inertia);
|
|
68
|
+
dy = dy * inertia - hg[2] * (1 - inertia);
|
|
69
|
+
const len = Math.hypot(dx, dy);
|
|
70
|
+
if (len < 1e-6) break; // a hollow: the drop stands and soaks away
|
|
71
|
+
dx /= len;
|
|
72
|
+
dy /= len;
|
|
73
|
+
px += dx;
|
|
74
|
+
py += dy;
|
|
75
|
+
if (px < 1 || py < 1 || px >= last - 1 || py >= last - 1) break;
|
|
76
|
+
heightGrad(px, py);
|
|
77
|
+
const fall = h - hg[0], // positive downhill
|
|
78
|
+
capacity = Math.max(fall * speed * water * capacityFactor, minCapacity);
|
|
79
|
+
if (fall < 0 || carried > capacity) {
|
|
80
|
+
// uphill it fills the hollow it came out of; over its capacity it lays some down: both at the cell it left, by its corners
|
|
81
|
+
const laid = fall < 0 ? Math.min(-fall, carried) : (carried - capacity) * depositRate;
|
|
82
|
+
carried -= laid;
|
|
83
|
+
change(k, laid * (1 - u) * (1 - v));
|
|
84
|
+
change(k + 1, laid * u * (1 - v));
|
|
85
|
+
change(k + width, laid * (1 - u) * v);
|
|
86
|
+
change(k + width + 1, laid * u * v);
|
|
87
|
+
} else {
|
|
88
|
+
// under its capacity it wears the ground round the cell it left, never deeper than its own fall
|
|
89
|
+
const worn = Math.min((capacity - carried) * erosionRate, fall);
|
|
90
|
+
for (let c = 0; c < brush.length; c += 3) {
|
|
91
|
+
const bi = i + brush[c],
|
|
92
|
+
bj = j + brush[c + 1];
|
|
93
|
+
if (bi < 0 || bj < 0 || bi > last || bj > last) continue;
|
|
94
|
+
const bk = bj * width + bi,
|
|
95
|
+
take = worn * brush[c + 2] * mask[bk];
|
|
96
|
+
change(bk, -worn * brush[c + 2]);
|
|
97
|
+
carried += take;
|
|
98
|
+
}
|
|
99
|
+
}
|
|
100
|
+
speed = Math.sqrt(Math.max(speed * speed + fall * gravity, 0));
|
|
101
|
+
water *= 1 - evaporation;
|
|
102
|
+
}
|
|
103
|
+
}
|
|
104
|
+
// the worn ground is eased into the laid-out ground at the edge of the wild, so nothing steps where the mask fades
|
|
105
|
+
for (let k = 0; k < heights.length; k++) heights[k] = lerp(start[k], heights[k], sstep(0, 0.35, mask[k]));
|
|
106
|
+
}
|
|
@@ -0,0 +1,143 @@
|
|
|
1
|
+
import { Vector3 } from 'three';
|
|
2
|
+
|
|
3
|
+
// ════════════════════════════════════════════════════════════════════════
|
|
4
|
+
// The grid a head is sculpted on: rows by height and columns by angle round from the front, crowded where a face needs them
|
|
5
|
+
// (the lids, the nose, the lips). Behind the face only some of the rows go on, joined to the rest without a gap.
|
|
6
|
+
// ════════════════════════════════════════════════════════════════════════
|
|
7
|
+
const HALF = 118, // millimetres from the head's middle to its crown: the rows are given in millimetres
|
|
8
|
+
CHANNELS = 8,
|
|
9
|
+
EYE_WIDTH = 74.5, // half the head's width at the eyes and how square its outline is there: columns are given by how far
|
|
10
|
+
EYE_SQUARE = 2.15; // across the face they cross that level
|
|
11
|
+
|
|
12
|
+
// The angle round from the front at which the outline at the eyes' level is that far across.
|
|
13
|
+
function angleAcross(across) {
|
|
14
|
+
let low = 0,
|
|
15
|
+
high = Math.PI / 2;
|
|
16
|
+
for (let i = 0; i < 30; i++) {
|
|
17
|
+
const a = (low + high) / 2,
|
|
18
|
+
s = Math.sin(a),
|
|
19
|
+
c = Math.cos(a);
|
|
20
|
+
if (EYE_WIDTH * s * Math.pow(Math.pow(s, EYE_SQUARE) + Math.pow(c, EYE_SQUARE), -1 / EYE_SQUARE) < across) low = a;
|
|
21
|
+
else high = a;
|
|
22
|
+
}
|
|
23
|
+
return (low + high) / 2;
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
// rows: heights from the chin up; across: columns over the face (millimetres at the eyes' level); behind: columns round the back
|
|
27
|
+
// (degrees); backRows: the rows that go on behind the face (all of them if none are named); closed: whether the grid closes
|
|
28
|
+
// over the crown and under the chin.
|
|
29
|
+
function faceGrid(rows, across, behind, backRows, closed = true) {
|
|
30
|
+
const half = [...across.map(angleAcross), ...behind.map(deg => (deg * Math.PI) / 180)],
|
|
31
|
+
angles = [
|
|
32
|
+
...half
|
|
33
|
+
.slice(1)
|
|
34
|
+
.reverse()
|
|
35
|
+
.map(a => -a),
|
|
36
|
+
...half,
|
|
37
|
+
],
|
|
38
|
+
nr = rows.length,
|
|
39
|
+
nc = angles.length,
|
|
40
|
+
faceEdge = half[across.length - 1] + 1e-6,
|
|
41
|
+
whole = angles.map(a => Math.abs(a) <= faceEdge), // the columns that carry every row
|
|
42
|
+
kept = rows.map((y, i) => (!backRows || i === 0 || i === nr - 1 || backRows.includes(y) ? i : -1)).filter(i => i >= 0),
|
|
43
|
+
used = new Uint8Array(nr * nc),
|
|
44
|
+
idx = [];
|
|
45
|
+
for (let j = 0; j < nc; j++) for (let i = 0; i < nr; i++) used[i * nc + j] = whole[j] || kept.includes(i) ? 1 : 0;
|
|
46
|
+
for (let j = 0; j < nc - 1; j++) {
|
|
47
|
+
const left = (i, c = j) => i * nc + c,
|
|
48
|
+
right = i => i * nc + j + 1;
|
|
49
|
+
if (whole[j] && whole[j + 1])
|
|
50
|
+
for (let i = 0; i < nr - 1; i++) idx.push(left(i), right(i), right(i + 1), left(i), right(i + 1), left(i + 1));
|
|
51
|
+
else
|
|
52
|
+
for (let k = 0; k < kept.length - 1; k++) {
|
|
53
|
+
const a = kept[k],
|
|
54
|
+
b = kept[k + 1],
|
|
55
|
+
mid = (a + b + 1) >> 1;
|
|
56
|
+
if (!whole[j] && !whole[j + 1]) idx.push(left(a), right(a), right(b), left(a), right(b), left(b));
|
|
57
|
+
else if (whole[j]) {
|
|
58
|
+
// every row on the left, the kept ones on the right: a fan from each end of the right-hand edge
|
|
59
|
+
for (let i = a; i < b; i++) idx.push(left(i), right(i < mid ? a : b), left(i + 1));
|
|
60
|
+
idx.push(left(mid), right(a), right(b));
|
|
61
|
+
} else {
|
|
62
|
+
for (let i = a; i < b; i++) idx.push(left(i < mid ? a : b), right(i), right(i + 1));
|
|
63
|
+
idx.push(left(a), right(mid), left(b));
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
if (closed) for (let j = 0; j < nc - 1; j++) idx.push((nr - 1) * nc + j, (nr - 1) * nc + j + 1, nr * nc, j + 1, j, nr * nc + 1);
|
|
68
|
+
return { rows, angles, nr, nc, used, idx };
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
const _o = new Vector3(),
|
|
72
|
+
_a = new Vector3(),
|
|
73
|
+
_b = new Vector3(),
|
|
74
|
+
_ch = [0, 1, 0, 0, 0, 0, 0, 0];
|
|
75
|
+
|
|
76
|
+
// A head function sampled on a grid: positions, normals, the channels of each point, and the grid's triangles.
|
|
77
|
+
function faceSculpt(fn, grid) {
|
|
78
|
+
const { rows, angles, nr, nc, used, idx } = grid,
|
|
79
|
+
n = nr * nc + 2,
|
|
80
|
+
P = new Float32Array(n * 3),
|
|
81
|
+
N = new Float32Array(n * 3),
|
|
82
|
+
CH = new Float32Array(n * CHANNELS);
|
|
83
|
+
const put = (i, row, angle) => {
|
|
84
|
+
fn.point(row, angle, _o, _ch);
|
|
85
|
+
P[i * 3] = _o.x;
|
|
86
|
+
P[i * 3 + 1] = _o.y;
|
|
87
|
+
P[i * 3 + 2] = _o.z;
|
|
88
|
+
for (let k = 0; k < CHANNELS; k++) CH[i * CHANNELS + k] = _ch[k];
|
|
89
|
+
};
|
|
90
|
+
for (let i = 0; i < nr; i++) for (let j = 0; j < nc; j++) if (used[i * nc + j]) put(i * nc + j, rows[i], angles[j]);
|
|
91
|
+
put(nr * nc, HALF, 0);
|
|
92
|
+
put(nr * nc + 1, -HALF, 0);
|
|
93
|
+
// each point's normal is the sum of its triangles', so a row pinched shut at the corner of an eye does no harm
|
|
94
|
+
for (let t = 0; t < idx.length; t += 3) {
|
|
95
|
+
const a = idx[t] * 3,
|
|
96
|
+
b = idx[t + 1] * 3,
|
|
97
|
+
c = idx[t + 2] * 3;
|
|
98
|
+
_a.set(P[b] - P[a], P[b + 1] - P[a + 1], P[b + 2] - P[a + 2]);
|
|
99
|
+
_b.set(P[c] - P[a], P[c + 1] - P[a + 1], P[c + 2] - P[a + 2]);
|
|
100
|
+
_a.cross(_b);
|
|
101
|
+
for (const q of [a, b, c]) {
|
|
102
|
+
N[q] += _a.x;
|
|
103
|
+
N[q + 1] += _a.y;
|
|
104
|
+
N[q + 2] += _a.z;
|
|
105
|
+
}
|
|
106
|
+
}
|
|
107
|
+
for (let i = 0; i < nr; i++) {
|
|
108
|
+
// the first and last columns are one line down the back of the head
|
|
109
|
+
const a = i * nc * 3,
|
|
110
|
+
b = (i * nc + nc - 1) * 3;
|
|
111
|
+
for (let k = 0; k < 3; k++) N[a + k] = N[b + k] = N[a + k] + N[b + k];
|
|
112
|
+
}
|
|
113
|
+
for (let i = 0; i < n; i++) {
|
|
114
|
+
const q = i * 3,
|
|
115
|
+
l = Math.hypot(N[q], N[q + 1], N[q + 2]);
|
|
116
|
+
if (l > 0) {
|
|
117
|
+
N[q] /= l;
|
|
118
|
+
N[q + 1] /= l;
|
|
119
|
+
N[q + 2] /= l;
|
|
120
|
+
} else N[q + 1] = 1;
|
|
121
|
+
}
|
|
122
|
+
return { P, N, CH, idx };
|
|
123
|
+
}
|
|
124
|
+
|
|
125
|
+
// The point of the face that lies at x across and y up from the head's middle (metres), as [x, y, z, and the normal there],
|
|
126
|
+
// raised off the skin by lift.
|
|
127
|
+
function faceAt(fn, x, y, lift = 0) {
|
|
128
|
+
let row = y * 1000,
|
|
129
|
+
angle = Math.asin(Math.max(-0.99, Math.min(0.99, (x * 1000) / EYE_WIDTH)));
|
|
130
|
+
for (let i = 0; i < 5; i++) {
|
|
131
|
+
fn.point(row, angle, _o, null);
|
|
132
|
+
row += (y - _o.y) * 1000;
|
|
133
|
+
angle += ((x - _o.x) * 1000) / 70;
|
|
134
|
+
}
|
|
135
|
+
fn.point(row + 0.6, angle, _a, null);
|
|
136
|
+
fn.point(row, angle + 0.012, _b, null);
|
|
137
|
+
_a.sub(_o);
|
|
138
|
+
_b.sub(_o);
|
|
139
|
+
_b.cross(_a).normalize();
|
|
140
|
+
return [_o.x + _b.x * lift, _o.y + _b.y * lift, _o.z + _b.z * lift, _b.x, _b.y, _b.z];
|
|
141
|
+
}
|
|
142
|
+
|
|
143
|
+
export { CHANNELS, faceAt, faceGrid, faceSculpt };
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
// A negative tag selects a garment type and interpolates between smooth and gathered cloth.
|
|
2
|
+
const PLAIN = 0.1,
|
|
3
|
+
CREASED = 0.9,
|
|
4
|
+
HANGS = 0.5, // how creased cloth is that hangs in folds, uncrumpled
|
|
5
|
+
KIND = { wool: 0, linen: 1, silk: 2, leather: 3, mail: 4, plate: 5 };
|
|
6
|
+
// Optional integer attributes store this many steps per unit.
|
|
7
|
+
const TAG_STEPS = 16;
|
|
8
|
+
// The tag of a garment of a kind, creased by so much (0 to 1).
|
|
9
|
+
const garmentTag = (crease, kind = KIND.wool) => -(kind + PLAIN + (CREASED - PLAIN) * Math.min(1, Math.max(0, crease)));
|
|
10
|
+
|
|
11
|
+
export { CREASED, HANGS, KIND, PLAIN, TAG_STEPS, garmentTag };
|
|
@@ -0,0 +1,174 @@
|
|
|
1
|
+
import { lerp, sstep, TAU } from '../math/scalar.js';
|
|
2
|
+
import { STRANDS } from './hair-tags.js';
|
|
3
|
+
import { POINT } from './hair-patch.js';
|
|
4
|
+
|
|
5
|
+
const ROOT_SHADE = 0.72, // hair is darker where it is gathered or leaves the head than at its ends
|
|
6
|
+
PLAIT_LEAN = 0.7, // how far a plait's strands slant from its length (the tangent of the angle)
|
|
7
|
+
PLAIT_SWELL = 0.26, // how far each turn of a plait stands out of it, a share of its thickness
|
|
8
|
+
PLAIT_ROWS = 4, // rows of points to a turn of a plait: fewer, and its outline is a saw's
|
|
9
|
+
SHUT = 0.12; // a rope or a plait begins this much of its first ring's size, so that no open end shows
|
|
10
|
+
|
|
11
|
+
// A value at t along a row of spans' values (one for each ring), bent smoothly through them.
|
|
12
|
+
function through(rings, k, t) {
|
|
13
|
+
const last = rings.length - 1,
|
|
14
|
+
i = Math.min(last - 1, Math.floor(t)),
|
|
15
|
+
f = t - i,
|
|
16
|
+
a = rings[Math.max(0, i - 1)][k],
|
|
17
|
+
b = rings[i][k],
|
|
18
|
+
c = rings[i + 1][k],
|
|
19
|
+
d = rings[Math.min(last, i + 2)][k];
|
|
20
|
+
return b + 0.5 * f * (c - a + f * (2 * a - 5 * b + 4 * c - d + f * (3 * (b - c) + d - a)));
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
// The ring a rope begins with, above its first: drawn in to a point.
|
|
24
|
+
const shut = ring => [ring[0] + ring[1] * 0.8, ring[1] * SHUT, ring[2] * SHUT, ring[3], ring[4]];
|
|
25
|
+
|
|
26
|
+
// Adds a surface that hangs, lofted down through rings [height, half-width, half-depth, middle across, middle fore and aft]:
|
|
27
|
+
// a rope where it goes all the way round, a sheet from o.a0 to o.a1 (angles as a loft counts them: 3/2 pi is straight behind).
|
|
28
|
+
// o: rows and sides (how finely it is cut), colour and tone(v, a) (how bright a point a share v of the way down is), swell(v, a,
|
|
29
|
+
// y) (its thickness there, of the rings'), hem(a) (how much lower its end hangs there, metres), lean (how far its strands slant:
|
|
30
|
+
// the way across them goes so much round for each metre down), from (the strand its first side lies at), root (how dark it is
|
|
31
|
+
// where it begins, if not as dark as hair that is gathered).
|
|
32
|
+
function hang(patch, rings, o) {
|
|
33
|
+
const open = o.a1 !== undefined;
|
|
34
|
+
if (!open) rings = [shut(rings[0]), ...rings];
|
|
35
|
+
const { rows, sides, colour } = o,
|
|
36
|
+
a0 = o.a0 ?? 0,
|
|
37
|
+
a1 = o.a1 ?? TAU,
|
|
38
|
+
first = patch.points.length / POINT,
|
|
39
|
+
spans = rings.length - 1,
|
|
40
|
+
at = (i, j) => first + i * (sides + 1) + j,
|
|
41
|
+
place = [],
|
|
42
|
+
mean = rings.reduce((sum, r) => sum + (r[1] + r[2]) / 2, 0) / rings.length,
|
|
43
|
+
// a rope's strands meet themselves again once round it: a whole number of periods to the turn
|
|
44
|
+
round = open
|
|
45
|
+
? (mean * (a1 - a0)) / STRANDS.span
|
|
46
|
+
: Math.max(1, Math.round((mean * TAU) / STRANDS.span / STRANDS.period)) * STRANDS.period;
|
|
47
|
+
for (let i = 0; i <= rows; i++) {
|
|
48
|
+
const v = i / rows,
|
|
49
|
+
t = v * spans;
|
|
50
|
+
for (let j = 0; j <= sides; j++) {
|
|
51
|
+
const a = a0 + ((a1 - a0) * j) / sides,
|
|
52
|
+
y = through(rings, 0, t) - (o.hem ? o.hem(a) * v * v : 0),
|
|
53
|
+
k = o.swell ? o.swell(v, a, y) : 1;
|
|
54
|
+
place.push(
|
|
55
|
+
through(rings, 3, t) + Math.cos(a) * through(rings, 1, t) * k,
|
|
56
|
+
y,
|
|
57
|
+
through(rings, 4, t) + Math.sin(a) * through(rings, 2, t) * k,
|
|
58
|
+
);
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
for (let i = 0; i <= rows; i++)
|
|
62
|
+
for (let j = 0; j <= sides; j++) {
|
|
63
|
+
// the normal from the points round about (a rope's first and last sides are one line)
|
|
64
|
+
const wrap = j2 => (open ? Math.min(sides, Math.max(0, j2)) : (j2 + sides) % sides),
|
|
65
|
+
l = (i * (sides + 1) + wrap(j - 1)) * 3,
|
|
66
|
+
r = (i * (sides + 1) + wrap(j + 1)) * 3,
|
|
67
|
+
up = (Math.max(0, i - 1) * (sides + 1) + j) * 3,
|
|
68
|
+
down = (Math.min(rows, i + 1) * (sides + 1) + j) * 3,
|
|
69
|
+
p = (i * (sides + 1) + j) * 3,
|
|
70
|
+
a = a0 + ((a1 - a0) * j) / sides,
|
|
71
|
+
v = i / rows,
|
|
72
|
+
tx = place[r] - place[l],
|
|
73
|
+
ty = place[r + 1] - place[l + 1],
|
|
74
|
+
tz = place[r + 2] - place[l + 2],
|
|
75
|
+
ux = place[down] - place[up],
|
|
76
|
+
uy = place[down + 1] - place[up + 1],
|
|
77
|
+
uz = place[down + 2] - place[up + 2];
|
|
78
|
+
let nx = ty * uz - tz * uy,
|
|
79
|
+
ny = tz * ux - tx * uz,
|
|
80
|
+
nz = tx * uy - ty * ux;
|
|
81
|
+
const length = Math.hypot(nx, ny, nz) || 1,
|
|
82
|
+
out = nx * Math.cos(a) + nz * Math.sin(a) < 0 ? -1 : 1,
|
|
83
|
+
tone = (o.tone ? o.tone(v, a) : 1) * lerp(o.root ?? ROOT_SHADE, 1, sstep(0, 0.35, v));
|
|
84
|
+
nx *= out / length;
|
|
85
|
+
ny *= out / length;
|
|
86
|
+
nz *= out / length;
|
|
87
|
+
patch.points.push(
|
|
88
|
+
place[p],
|
|
89
|
+
place[p + 1],
|
|
90
|
+
place[p + 2],
|
|
91
|
+
nx,
|
|
92
|
+
ny,
|
|
93
|
+
nz,
|
|
94
|
+
colour[0] * tone,
|
|
95
|
+
colour[1] * tone,
|
|
96
|
+
colour[2] * tone,
|
|
97
|
+
(o.from || 0) + (round * j) / sides + (o.lean || 0) * (rings[0][0] - place[p + 1]),
|
|
98
|
+
);
|
|
99
|
+
if (i < rows && j < sides) patch.triangles.push(at(i, j), at(i + 1, j), at(i + 1, j + 1), at(i, j), at(i + 1, j + 1), at(i, j + 1));
|
|
100
|
+
}
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
// A plait hanging: two halves side by side, their strands slanting in to the line between them, each turn of the plait
|
|
104
|
+
// standing out on one side and then the other. turn: the height of one turn (metres); side: which way it faces (the angle of
|
|
105
|
+
// the line between its halves, as a loft counts angles).
|
|
106
|
+
function plait(patch, rings, o) {
|
|
107
|
+
rings = [shut(rings[0]), ...rings];
|
|
108
|
+
const turns = Math.max(1, Math.round((rings[0][0] - rings[rings.length - 1][0]) / o.turn)),
|
|
109
|
+
rows = turns * PLAIT_ROWS;
|
|
110
|
+
for (const half of [-1, 1])
|
|
111
|
+
hang(patch, rings, {
|
|
112
|
+
...o,
|
|
113
|
+
rows,
|
|
114
|
+
sides: o.sides >> 1,
|
|
115
|
+
a0: o.side + (half < 0 ? -Math.PI : 0),
|
|
116
|
+
a1: o.side + (half < 0 ? 0 : Math.PI),
|
|
117
|
+
lean: (half * PLAIT_LEAN) / STRANDS.span,
|
|
118
|
+
from: (o.from || 0) + half,
|
|
119
|
+
swell: (v, a) => 1 + PLAIT_SWELL * half * Math.cos(v * turns * TAU) * Math.sin(Math.abs(a - o.side)) * sstep(0, 0.06, v),
|
|
120
|
+
tone: (v, a) => 0.72 + 0.28 * Math.sin(Math.abs(a - o.side)),
|
|
121
|
+
});
|
|
122
|
+
}
|
|
123
|
+
|
|
124
|
+
// A knot of hair on the head: a ball at `at` with half-sizes `size` (from the head's middle), its strands wound round its
|
|
125
|
+
// upright axis and climbing a little as they go.
|
|
126
|
+
function knot(patch, place, at, size, colour, rows, sides) {
|
|
127
|
+
const first = patch.points.length / POINT,
|
|
128
|
+
round = Math.max(1, Math.round((((size[0] + size[2]) / 2) * TAU) / STRANDS.span / STRANDS.period)) * STRANDS.period;
|
|
129
|
+
for (let i = 0; i <= rows; i++)
|
|
130
|
+
for (let j = 0; j <= sides; j++) {
|
|
131
|
+
const polar = (i / rows) * Math.PI,
|
|
132
|
+
a = (j / sides) * TAU,
|
|
133
|
+
nx = Math.sin(polar) * Math.cos(a),
|
|
134
|
+
ny = Math.cos(polar),
|
|
135
|
+
nz = Math.sin(polar) * Math.sin(a),
|
|
136
|
+
tone = 0.8 + 0.2 * ny,
|
|
137
|
+
v = place([at[0] + nx * size[0], at[1] + ny * size[1], at[2] + nz * size[2], nx / size[0], ny / size[1], nz / size[2]]);
|
|
138
|
+
patch.points.push(
|
|
139
|
+
v[0],
|
|
140
|
+
v[1],
|
|
141
|
+
v[2],
|
|
142
|
+
v[3],
|
|
143
|
+
v[4],
|
|
144
|
+
v[5],
|
|
145
|
+
colour[0] * tone,
|
|
146
|
+
colour[1] * tone,
|
|
147
|
+
colour[2] * tone,
|
|
148
|
+
(round * j) / sides + 0.35 * (i / rows),
|
|
149
|
+
);
|
|
150
|
+
if (i < rows && j < sides) {
|
|
151
|
+
const p = first + i * (sides + 1) + j;
|
|
152
|
+
patch.triangles.push(p, p + sides + 1, p + sides + 2, p, p + sides + 2, p + 1);
|
|
153
|
+
}
|
|
154
|
+
}
|
|
155
|
+
}
|
|
156
|
+
|
|
157
|
+
// The fall of long hair down the back as a near head wears it: the far fall's rings (hair-far.js, fallShape: [height, half-
|
|
158
|
+
// width, half-depth, middle]), but beginning on the mass of the hair itself, where the long locks leave the head, instead of
|
|
159
|
+
// standing off it. crown: the ring of the mass there. Returns the rings, and at(y): the fall's half-width, half-depth and
|
|
160
|
+
// middle at a height.
|
|
161
|
+
function nearFallRings(rings, crown) {
|
|
162
|
+
const fallen = [crown, ...rings.slice(1)],
|
|
163
|
+
at = y => {
|
|
164
|
+
let i = 0;
|
|
165
|
+
while (i < fallen.length - 2 && y < fallen[i + 1][0]) i++;
|
|
166
|
+
const a = fallen[i],
|
|
167
|
+
b = fallen[i + 1],
|
|
168
|
+
t = Math.min(1, Math.max(0, (y - a[0]) / (b[0] - a[0])));
|
|
169
|
+
return [lerp(a[1], b[1], t), lerp(a[2], b[2], t), lerp(a[3], b[3], t)];
|
|
170
|
+
};
|
|
171
|
+
return { rings: fallen, at };
|
|
172
|
+
}
|
|
173
|
+
|
|
174
|
+
export { hang, knot, nearFallRings, plait };
|
|
@@ -0,0 +1,156 @@
|
|
|
1
|
+
import * as THREE from 'three';
|
|
2
|
+
import { lerp, sstep } from '../math/scalar.js';
|
|
3
|
+
import { STRANDS } from './hair-tags.js';
|
|
4
|
+
import { POINT } from './hair-patch.js';
|
|
5
|
+
|
|
6
|
+
// ════════════════════════════════════════════════════════════════════════
|
|
7
|
+
// Locks of a near head's hair. A lock is a narrow strip that lies on the mass of the hair (hair-mass.js) along the lie of the
|
|
8
|
+
// cut and curves with it, each a little over the one below as hair lies in layers, lifting only toward its tip; a lock of
|
|
9
|
+
// long hair is combed over the head and hangs over the fall behind. It is drawn as a ribbon that comes to a point, rounded by
|
|
10
|
+
// its normals, its strands running on to its edge. Lengths are metres from the head's middle.
|
|
11
|
+
// ════════════════════════════════════════════════════════════════════════
|
|
12
|
+
const FACE_EDGE = 0.028, // below the hairline no hair lies further forward than this: it lies beside the face, not over it
|
|
13
|
+
HAIRLINE = 0.035,
|
|
14
|
+
SHOULDER_DEEP = 0.13, // half the depth of the shoulders, fore and aft
|
|
15
|
+
ROOT_SHADE = 0.94, // a lock is darker at its root than at its tip
|
|
16
|
+
TIP_SHADE = 1.02,
|
|
17
|
+
EDGE_SHADE = 0.95, // and darker down one edge, as strands lie over one another
|
|
18
|
+
ROUND = 0.08, // how far a ribbon's normals lean out over its edges (radians): it is lit as a round lock
|
|
19
|
+
TIP = 0.1, // a ribbon's width at its tip, of its fullest
|
|
20
|
+
FREE = -1; // the lift of a point that hangs clear of the head
|
|
21
|
+
|
|
22
|
+
const _p = new THREE.Vector3(),
|
|
23
|
+
_q = new THREE.Vector3(),
|
|
24
|
+
_d = new THREE.Vector3(),
|
|
25
|
+
_f = new THREE.Vector3(),
|
|
26
|
+
_n = new THREE.Vector3(),
|
|
27
|
+
_s = new THREE.Vector3(),
|
|
28
|
+
_dir = new THREE.Vector3();
|
|
29
|
+
|
|
30
|
+
// Moves a point off the neck and the shoulders (o.neck: how far from the neck's axis; o.shoulder: half the shoulders' breadth).
|
|
31
|
+
function clearNeck(p, o) {
|
|
32
|
+
if (p.y < HAIRLINE && p.z > FACE_EDGE) p.z = FACE_EDGE;
|
|
33
|
+
if (p.y >= -0.075) return;
|
|
34
|
+
const low = sstep(-0.14, -0.215, p.y),
|
|
35
|
+
rx = lerp(o.neck, o.shoulder + 0.035, low),
|
|
36
|
+
rz = lerp(o.neck, SHOULDER_DEEP, low),
|
|
37
|
+
z = p.z + 0.012,
|
|
38
|
+
q = Math.hypot(p.x / rx, z / rz);
|
|
39
|
+
if (q < 1) {
|
|
40
|
+
p.x /= q;
|
|
41
|
+
p.z = z / q - 0.012;
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
// The path of a lock that lies on the mass: points [x, y, z, the way out, its lift]. root: a direction from the head's middle
|
|
46
|
+
// to where it grows; o: flow(d, out) (the lie of the cut at a direction), aside (how far this lock leans from it), length,
|
|
47
|
+
// segs, base, rise and tip (its lift off the mass at the root, how much more by its end, and how far its tip stands up besides,
|
|
48
|
+
// metres), wave and coil (how far it winds from side to side and how fast), curl (how far it turns at each step, one way),
|
|
49
|
+
// phase, neck and shoulder.
|
|
50
|
+
function layLock(mass, root, o) {
|
|
51
|
+
const points = [],
|
|
52
|
+
step = o.length / o.segs;
|
|
53
|
+
_dir.copy(root);
|
|
54
|
+
for (let i = 0; i <= o.segs; i++) {
|
|
55
|
+
const u = i / o.segs,
|
|
56
|
+
lift = o.base + o.rise * u + o.tip * u * u * u;
|
|
57
|
+
mass.at(_dir, lift, _p, _n);
|
|
58
|
+
clearNeck(_p, o);
|
|
59
|
+
points.push([_p.x, _p.y, _p.z, _n.x, _n.y, _n.z, lift]);
|
|
60
|
+
if (i === o.segs) break;
|
|
61
|
+
o.flow(_dir, _f);
|
|
62
|
+
_f.x += o.aside[0];
|
|
63
|
+
_f.z += o.aside[1];
|
|
64
|
+
_f.addScaledVector(_n, -_f.dot(_n)).normalize();
|
|
65
|
+
const turn = (o.wave || 0) * Math.sin(o.phase + i * o.coil) + (o.curl || 0) * (i + 0.5);
|
|
66
|
+
if (turn) _f.applyAxisAngle(_n, turn);
|
|
67
|
+
mass.at(_dir, 0, _q).addScaledVector(_f, step);
|
|
68
|
+
mass.skull.under(_q.x, _q.y, _q.z, _dir);
|
|
69
|
+
}
|
|
70
|
+
return points;
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
// The path of a lock of long hair: combed over the mass from its root to where it leaves the head, behind the ear or at the
|
|
74
|
+
// nape, then hanging over the fall of hair down the back. o: round (where round the fall it hangs, as the fall counts angles),
|
|
75
|
+
// shape(y) (the fall's half-width, half-depth and middle at a height), from (the height at which it leaves the head, as a
|
|
76
|
+
// share of the head's), end (how low it hangs), combed and segs (its lengths over the head and hanging), lift (metres off the mass), sway and phase (how it wavers as it hangs).
|
|
77
|
+
function hangLock(mass, root, o) {
|
|
78
|
+
const points = [];
|
|
79
|
+
_d.set(Math.cos(o.round), 0, Math.sin(o.round)).multiplyScalar(Math.sqrt(1 - o.from * o.from));
|
|
80
|
+
_d.y = o.from;
|
|
81
|
+
for (let i = 0; i <= o.combed; i++) {
|
|
82
|
+
const lift = 0.001 + o.lift * Math.sin((i / o.combed) * Math.PI * 0.5);
|
|
83
|
+
mass.at(
|
|
84
|
+
_s
|
|
85
|
+
.copy(root)
|
|
86
|
+
.lerp(_d, i / o.combed)
|
|
87
|
+
.normalize(),
|
|
88
|
+
lift,
|
|
89
|
+
_p,
|
|
90
|
+
_n,
|
|
91
|
+
);
|
|
92
|
+
points.push([_p.x, _p.y, _p.z, _n.x, _n.y, _n.z, lift]);
|
|
93
|
+
}
|
|
94
|
+
const top = _p.y;
|
|
95
|
+
for (let j = 1; j <= o.segs; j++) {
|
|
96
|
+
const t = j / o.segs,
|
|
97
|
+
y = lerp(top, o.end, t),
|
|
98
|
+
[rx, rz, cz] = o.shape(y),
|
|
99
|
+
a = o.round + o.sway * Math.sin(o.phase + j * 1.3) * t,
|
|
100
|
+
out = 0.004 + 0.006 * t;
|
|
101
|
+
_n.set(Math.cos(a) / rx, 0.6, Math.sin(a) / rz).normalize();
|
|
102
|
+
points.push([Math.cos(a) * (rx + out), y, cz + Math.sin(a) * (rz + out), _n.x, _n.y, _n.z, FREE]);
|
|
103
|
+
}
|
|
104
|
+
return points;
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
// Adds a lock's path to a patch ({ points, triangles }: hair-patch.js) as a ribbon of that half-width, fullest a third of the
|
|
108
|
+
// way along and drawn to a point. place sets a point of the head in the figure; mass: what its edges lie on, where the path
|
|
109
|
+
// does; strand: where across the strands of the head its middle lies (any number: each lock has its own strands).
|
|
110
|
+
function drawLock(patch, place, mass, points, half, colour, tone, strand) {
|
|
111
|
+
const last = points.length - 1,
|
|
112
|
+
first = patch.points.length / POINT;
|
|
113
|
+
for (let i = 0; i <= last; i++) {
|
|
114
|
+
const p = points[i],
|
|
115
|
+
a = points[Math.max(0, i - 1)],
|
|
116
|
+
b = points[Math.min(last, i + 1)],
|
|
117
|
+
u = i / last,
|
|
118
|
+
wide = half * (0.4 + 0.6 * Math.sin(Math.min(1, u * 3) * Math.PI * 0.5)) * lerp(1, TIP, Math.pow(u, 1.4)),
|
|
119
|
+
shade = tone * lerp(ROOT_SHADE, TIP_SHADE, u);
|
|
120
|
+
_d.set(b[0] - a[0], b[1] - a[1], b[2] - a[2]);
|
|
121
|
+
_n.set(p[3], p[4], p[5]);
|
|
122
|
+
_s.crossVectors(_d, _n).normalize();
|
|
123
|
+
for (const k of [-1, 1]) {
|
|
124
|
+
_p.set(p[0] + _s.x * wide * k, p[1] + _s.y * wide * k, p[2] + _s.z * wide * k);
|
|
125
|
+
if (p[6] !== FREE) mass.at(mass.skull.under(_p.x, _p.y, _p.z, _dir), p[6], _p, _q);
|
|
126
|
+
else _q.copy(_n);
|
|
127
|
+
const v = place([
|
|
128
|
+
_p.x,
|
|
129
|
+
_p.y,
|
|
130
|
+
_p.z,
|
|
131
|
+
_q.x * Math.cos(ROUND) + _s.x * Math.sin(ROUND) * k,
|
|
132
|
+
_q.y * Math.cos(ROUND) + _s.y * Math.sin(ROUND) * k,
|
|
133
|
+
_q.z * Math.cos(ROUND) + _s.z * Math.sin(ROUND) * k,
|
|
134
|
+
]),
|
|
135
|
+
dark = shade * (k < 0 ? EDGE_SHADE : 1);
|
|
136
|
+
patch.points.push(
|
|
137
|
+
v[0],
|
|
138
|
+
v[1],
|
|
139
|
+
v[2],
|
|
140
|
+
v[3],
|
|
141
|
+
v[4],
|
|
142
|
+
v[5],
|
|
143
|
+
colour[0] * dark,
|
|
144
|
+
colour[1] * dark,
|
|
145
|
+
colour[2] * dark,
|
|
146
|
+
strand + (wide / STRANDS.span) * k,
|
|
147
|
+
);
|
|
148
|
+
}
|
|
149
|
+
if (i < last) {
|
|
150
|
+
const at = first + i * 2;
|
|
151
|
+
patch.triangles.push(at, at + 1, at + 3, at, at + 3, at + 2);
|
|
152
|
+
}
|
|
153
|
+
}
|
|
154
|
+
}
|
|
155
|
+
|
|
156
|
+
export { drawLock, hangLock, layLock };
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
import { HAIR_NEAR, STRANDS } from './hair-tags.js';
|
|
2
|
+
|
|
3
|
+
const POINT = 10, // numbers to a point: its place, its normal, its colour, and how far across the strands it lies
|
|
4
|
+
BAND = 2 * STRANDS.period,
|
|
5
|
+
MARGIN = 0.2, // where a band's middle lies within the tag's fraction: a triangle may reach this far out of its band
|
|
6
|
+
MOST = 0.97; // the most of the fraction a tag carries
|
|
7
|
+
|
|
8
|
+
// Emit each shared vertex once per strand band, correcting the winding from the supplied normals.
|
|
9
|
+
function packHairPatch(points, triangles, emitVertex) {
|
|
10
|
+
const bands = new Map(), corners = [];
|
|
11
|
+
let vertexCount = 0;
|
|
12
|
+
for (let t = 0; t < triangles.length; t += 3) {
|
|
13
|
+
const a = triangles[t] * POINT,
|
|
14
|
+
b = triangles[t + 1] * POINT,
|
|
15
|
+
c = triangles[t + 2] * POINT,
|
|
16
|
+
band = Math.floor((points[a + 9] + points[b + 9] + points[c + 9]) / 3 / BAND),
|
|
17
|
+
ux = points[b] - points[a],
|
|
18
|
+
uy = points[b + 1] - points[a + 1],
|
|
19
|
+
uz = points[b + 2] - points[a + 2],
|
|
20
|
+
vx = points[c] - points[a],
|
|
21
|
+
vy = points[c + 1] - points[a + 1],
|
|
22
|
+
vz = points[c + 2] - points[a + 2],
|
|
23
|
+
faces =
|
|
24
|
+
(uy * vz - uz * vy) * (points[a + 3] + points[b + 3] + points[c + 3]) +
|
|
25
|
+
(uz * vx - ux * vz) * (points[a + 4] + points[b + 4] + points[c + 4]) +
|
|
26
|
+
(ux * vy - uy * vx) * (points[a + 5] + points[b + 5] + points[c + 5]);
|
|
27
|
+
let put = bands.get(band);
|
|
28
|
+
if (!put) { put = new Map(); bands.set(band, put); }
|
|
29
|
+
for (const p of faces < 0 ? [a, c, b] : [a, b, c]) {
|
|
30
|
+
let v = put.get(p);
|
|
31
|
+
if (v === undefined) {
|
|
32
|
+
v = vertexCount++;
|
|
33
|
+
put.set(p, v);
|
|
34
|
+
const tag = HAIR_NEAR + Math.min(MOST, Math.max(0, points[p + 9] - band * BAND + MARGIN));
|
|
35
|
+
emitVertex(p, tag);
|
|
36
|
+
}
|
|
37
|
+
corners.push(v);
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
return corners;
|
|
41
|
+
}
|
|
42
|
+
export { POINT, packHairPatch };
|