vanishing
require
opacity()parameters
| Parameter | Default Value | Type | Description |
|---|---|---|---|
invisibleDistance | number | 240 | |
visibleDistance | number | 60 | |
tag | string | "alive" |
example
vanishing({ invisibleDistance: 240, visibleDistance: 60, tag: "alive"}),function vanishing(p) { const param = { invisibleDistance: 240, visibleDistance: 60, tag: "alive", ...p } return { require: ["opacity"], id: "invisible", update() { let op = 1 for (const e of get(param.tag, { recursive: true })) { const d = (e.pos.dist(this.pos) - param.invisibleDistance) const calcul = 1 - clamp(0, 1, d / param.visibleDistance) op = Math.min(op, calcul) } this.opacity = op } }}