h
This commit is contained in:
parent
2cc2f003df
commit
61718e2981
18 changed files with 572 additions and 190 deletions
|
|
@ -2016,6 +2016,15 @@ const vm = require('vm');
|
|||
const context = {{
|
||||
console, globalThis: null, window: null,
|
||||
clamp: (v, lo, hi) => Math.max(lo, Math.min(hi, Number(v) || 0)),
|
||||
TarinaiGeometry: {{
|
||||
pointSegmentDistance(px, py, ax, ay, bx, by) {{
|
||||
const sx = bx - ax, sy = by - ay;
|
||||
const len2 = sx * sx + sy * sy;
|
||||
if (len2 <= 1e-12) return Math.hypot(px - ax, py - ay);
|
||||
const t = Math.max(0, Math.min(1, ((px - ax) * sx + (py - ay) * sy) / len2));
|
||||
return Math.hypot(px - (ax + sx * t), py - (ay + sy * t));
|
||||
}},
|
||||
}},
|
||||
audio: {{ damage() {{}}, play() {{}}, death() {{}} }},
|
||||
}};
|
||||
context.globalThis = context;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue