roamwright 0.2.0 → 0.20.1
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 +3 -1
- package/README.md +19 -21
- package/geometry/bedding.js +141 -0
- package/geometry/builder-cells.js +42 -0
- package/geometry/builder-frame.js +47 -0
- package/geometry/builder.js +189 -177
- package/geometry/cell-mask.js +25 -0
- package/geometry/creased-sheet.js +34 -34
- package/geometry/ear.js +36 -36
- package/geometry/erosion.js +65 -42
- package/geometry/face-grid.js +65 -65
- package/geometry/foliage.js +47 -0
- package/geometry/hair-gathers.js +41 -41
- package/geometry/hair-locks.js +41 -41
- package/geometry/hair-patch.js +18 -18
- package/geometry/hair-shell.js +31 -31
- package/geometry/head-profile.js +15 -15
- package/geometry/head-shape.js +77 -77
- package/geometry/heightfield.js +27 -18
- package/geometry/index-parts.js +60 -0
- package/geometry/instance-visibility.js +41 -0
- package/geometry/instances.js +35 -12
- package/geometry/outline-grid.js +7 -7
- package/geometry/part-ranges.js +18 -0
- package/geometry/path-field.js +63 -33
- package/geometry/placement.js +52 -52
- package/geometry/point-buckets.js +50 -0
- package/geometry/primitives.js +63 -47
- package/geometry/sagging-tube.js +27 -27
- package/geometry/sampled-surface.js +109 -77
- package/geometry/scatter-grid.js +46 -6
- package/geometry/sculpt.js +93 -93
- package/geometry/shore-grid.js +77 -34
- package/geometry/strata-field.js +92 -92
- package/geometry/strata-tiles.js +91 -91
- package/geometry/stream.js +70 -48
- package/geometry/terrain-chunks.js +101 -92
- package/geometry/terrain-extension.js +6 -6
- package/index.js +5 -0
- package/math/cell-edge.js +16 -16
- package/math/cell-key.js +6 -0
- package/math/circle-clearances.js +19 -0
- package/math/cloth-textures.js +6 -6
- package/math/cloud-textures.js +20 -20
- package/math/color.js +14 -14
- package/math/curve.js +22 -22
- package/math/mountain-ranges.js +216 -165
- package/math/noise.js +101 -49
- package/math/particle-noise.js +28 -28
- package/math/periodic.js +5 -5
- package/math/random.js +24 -15
- package/math/rectangles.js +52 -0
- package/math/rock-texture.js +7 -7
- package/math/scalar.js +5 -5
- package/math/surface-textures.js +54 -54
- package/motion/arm-reach.js +24 -24
- package/motion/ballistic-arc.js +11 -0
- package/motion/biped-cycle.js +44 -0
- package/motion/biped-leg.js +37 -0
- package/motion/biped-stride.js +98 -122
- package/motion/contact-transition.js +33 -0
- package/motion/crowd-alarms.js +39 -39
- package/motion/crowd-routine.js +94 -65
- package/motion/daily-clock.js +9 -9
- package/motion/deck-surface.js +38 -0
- package/motion/ground-lookahead.js +29 -0
- package/motion/instance-sight.js +8 -8
- package/motion/player.js +36 -28
- package/motion/quadruped.js +155 -155
- package/motion/spaces.js +32 -32
- package/motion/weather.js +73 -24
- package/motion/wind.js +32 -13
- package/package.json +8 -4
- package/rendering/caster-motion.js +5 -5
- package/rendering/cell-lod.js +147 -82
- package/rendering/cloud-dome.js +28 -28
- package/rendering/cloud-field.js +2 -2
- package/rendering/compilation-schedule.js +68 -11
- package/rendering/contact-shadows.js +2 -2
- package/rendering/context.js +12 -0
- package/rendering/crowd-skinning.js +13 -13
- package/rendering/crust.js +18 -12
- package/rendering/daylight.js +3 -3
- package/rendering/detail-range.js +28 -0
- package/rendering/dispose-meshes.js +18 -0
- package/rendering/dof.js +9 -9
- package/rendering/eye-adapt.js +14 -14
- package/rendering/far-shadow.js +8 -8
- package/rendering/flocks.js +78 -78
- package/rendering/garment-material.js +17 -17
- package/rendering/glow-lines.js +13 -13
- package/rendering/hair-strands.js +20 -20
- package/rendering/height-probe.js +149 -19
- package/rendering/label-layout.js +46 -0
- package/rendering/label-range.js +38 -0
- package/rendering/light-budget.js +52 -52
- package/rendering/light-shafts.js +23 -23
- package/rendering/local-lights.js +15 -4
- package/rendering/material-lod.js +49 -49
- package/rendering/particle-emitters.js +90 -90
- package/rendering/particles.js +78 -67
- package/rendering/piece-batch.js +91 -26
- package/rendering/planar-reflection.js +38 -38
- package/rendering/post-shaders.js +17 -13
- package/rendering/post.js +71 -71
- package/rendering/rain-streaks.js +67 -0
- package/rendering/road-surface.js +11 -11
- package/rendering/sea-shaders.js +11 -11
- package/rendering/shader-warmup.js +29 -16
- package/rendering/shadow-alignment.js +4 -4
- package/rendering/shadow-depth.js +7 -7
- package/rendering/sky-occlusion.js +16 -16
- package/rendering/sky.js +16 -6
- package/rendering/stage-lights.js +6 -6
- package/rendering/static-point-shadow.js +3 -3
- package/rendering/still-casters.js +1 -1
- package/rendering/strata-material.js +10 -10
- package/rendering/stream-flow.js +10 -10
- package/rendering/taa.js +26 -26
- package/rendering/talus.js +15 -15
- package/rendering/terrain-rock.js +7 -7
- package/rendering/texture-fills.js +8 -8
- package/rendering/textures.js +28 -28
- package/rendering/wakes.js +24 -24
- package/rendering/water-material.js +36 -23
- package/rendering/world-matrices.js +38 -38
- package/runtime/diagnostic-log.js +2 -2
- package/runtime/first-use.js +33 -28
- package/runtime/frame-budget.js +49 -0
- package/runtime/frame-pacing.js +33 -0
- package/runtime/gpu-timing.js +13 -10
- package/runtime/grid-cache.js +1 -1
- package/runtime/grid-rows.js +44 -5
- package/runtime/hand-over.js +41 -23
- package/runtime/pool.js +58 -16
- package/runtime/quality-fit.js +1 -1
- package/runtime/search.js +22 -22
- package/runtime/spatial-audio.js +13 -13
- package/runtime/withdrawable-task.js +35 -0
- package/runtime/worker.js +7 -0
package/math/curve.js
CHANGED
|
@@ -17,12 +17,12 @@ function cubic(x0, x1, x2, x3, dt0, dt1, dt2, t) {
|
|
|
17
17
|
tt = t * t;
|
|
18
18
|
return x1 + t1 * t + c2 * tt + c3 * (tt * t);
|
|
19
19
|
}
|
|
20
|
-
const knot = (
|
|
20
|
+
const knot = (startPoint, endPoint) => Math.pow((startPoint[0] - endPoint[0]) * (startPoint[0] - endPoint[0]) + (startPoint[1] - endPoint[1]) * (startPoint[1] - endPoint[1]), 0.25);
|
|
21
21
|
const _before = [0, 0],
|
|
22
22
|
_after = [0, 0];
|
|
23
|
-
// The point of the curve through
|
|
24
|
-
function curvePoint(
|
|
25
|
-
const count =
|
|
23
|
+
// The point of the curve through the control points at t in 0..1, where t runs evenly from point to point.
|
|
24
|
+
function curvePoint(controlPoints, t) {
|
|
25
|
+
const count = controlPoints.length,
|
|
26
26
|
at = (count - 1) * t;
|
|
27
27
|
let i = Math.floor(at),
|
|
28
28
|
weight = at - i;
|
|
@@ -31,17 +31,17 @@ function curvePoint(pts, t) {
|
|
|
31
31
|
weight = 1;
|
|
32
32
|
}
|
|
33
33
|
// past either end the line is carried on by its last step
|
|
34
|
-
const first =
|
|
35
|
-
last =
|
|
36
|
-
_after[0] = last[0] -
|
|
37
|
-
_after[1] = last[1] -
|
|
38
|
-
_before[0] = first[0] -
|
|
39
|
-
_before[1] = first[1] -
|
|
34
|
+
const first = controlPoints[0],
|
|
35
|
+
last = controlPoints[count - 1];
|
|
36
|
+
_after[0] = last[0] - controlPoints[count - 2][0] + last[0];
|
|
37
|
+
_after[1] = last[1] - controlPoints[count - 2][1] + last[1];
|
|
38
|
+
_before[0] = first[0] - controlPoints[1][0] + first[0];
|
|
39
|
+
_before[1] = first[1] - controlPoints[1][1] + first[1];
|
|
40
40
|
const atEnd = i + 2 >= count,
|
|
41
|
-
p0 = i > 0 ?
|
|
42
|
-
p1 =
|
|
43
|
-
p2 =
|
|
44
|
-
p3 = atEnd ? _after :
|
|
41
|
+
p0 = i > 0 ? controlPoints[i - 1] : atEnd ? _after : _before,
|
|
42
|
+
p1 = controlPoints[i],
|
|
43
|
+
p2 = controlPoints[i + 1],
|
|
44
|
+
p3 = atEnd ? _after : controlPoints[i + 2];
|
|
45
45
|
let dt0 = knot(p0, p1),
|
|
46
46
|
dt1 = knot(p1, p2),
|
|
47
47
|
dt2 = knot(p2, p3);
|
|
@@ -51,12 +51,12 @@ function curvePoint(pts, t) {
|
|
|
51
51
|
return [cubic(p0[0], p1[0], p2[0], p3[0], dt0, dt1, dt2, weight), cubic(p0[1], p1[1], p2[1], p3[1], dt0, dt1, dt2, weight)];
|
|
52
52
|
}
|
|
53
53
|
// The curve's length from its start to each of ARC_STEPS + 1 points along it.
|
|
54
|
-
function arcLengths(
|
|
54
|
+
function arcLengths(controlPoints) {
|
|
55
55
|
const lengths = [0];
|
|
56
|
-
let last = curvePoint(
|
|
56
|
+
let last = curvePoint(controlPoints, 0),
|
|
57
57
|
sum = 0;
|
|
58
|
-
for (let
|
|
59
|
-
const point = curvePoint(
|
|
58
|
+
for (let stepIndex = 1; stepIndex <= ARC_STEPS; stepIndex++) {
|
|
59
|
+
const point = curvePoint(controlPoints, stepIndex / ARC_STEPS);
|
|
60
60
|
sum += Math.sqrt((point[0] - last[0]) * (point[0] - last[0]) + (point[1] - last[1]) * (point[1] - last[1]));
|
|
61
61
|
lengths.push(sum);
|
|
62
62
|
last = point;
|
|
@@ -81,12 +81,12 @@ function shareToT(lengths, u) {
|
|
|
81
81
|
if (lengths[high] === target) return high / ARC_STEPS;
|
|
82
82
|
return (high + (target - lengths[high]) / (lengths[high + 1] - lengths[high])) / ARC_STEPS;
|
|
83
83
|
}
|
|
84
|
-
// The line through
|
|
85
|
-
function spacedCurve(
|
|
86
|
-
const lengths = arcLengths(
|
|
84
|
+
// The line through the control points as a smooth curve of evenly spaced points, about `spacing` apart.
|
|
85
|
+
function spacedCurve(controlPoints, spacing) {
|
|
86
|
+
const lengths = arcLengths(controlPoints),
|
|
87
87
|
steps = Math.max(2, Math.round(lengths[ARC_STEPS] / spacing)),
|
|
88
88
|
points = [];
|
|
89
|
-
for (let
|
|
89
|
+
for (let stepIndex = 0; stepIndex <= steps; stepIndex++) points.push(curvePoint(controlPoints, shareToT(lengths, stepIndex / steps)));
|
|
90
90
|
return points;
|
|
91
91
|
}
|
|
92
92
|
|