trees
Port of Painted Valley's src/valley/trees.js (blendi/painted-valley, MIT): growTree (with ports of three's CatmullRomCurve3, Frenet frames and IcosahedronGeometry), plant, the near trees, far trees and bushes (createTrees), the leaf-spray texture, and the shade cast onto the grou…
trees
Port of Painted Valley's src/valley/trees.js (blendi/painted-valley, MIT): growTree (with ports of three's CatmullRomCurve3, Frenet frames and IcosahedronGeometry), plant, the near trees, far trees and bushes (createTrees), the leaf-spray texture, and the shade cast onto the ground (tShade).
Interface
What this asset declares: the schema it conforms to, what it exposes, and the rendered structured payload.
conforms to
zero/source-extract/v2native
mulberry(seed: number) → void
| arg | type | description |
|---|---|---|
| seed | number |
f32(v: number) → number
| arg | type | description |
|---|---|---|
| v | number |
hypot3(x: number, y: number, z: number) → number
| arg | type | description |
|---|---|---|
| x | number | |
| y | number | |
| z | number |
smoothstep(x: number, lo: number, hi: number) → number
THREE.MathUtils.smoothstep(x, min, max)
| arg | type | description |
|---|---|---|
| x | number | |
| lo | number | |
| hi | number |
v3(x: number, y: number, z: number) → V
| arg | type | description |
|---|---|---|
| x | number | |
| y | number | |
| z | number |
clone(a: V) → V
| arg | type | description |
|---|---|---|
| a | V |
addScaled(a: V, b: V, s: number) → V
a += b * s (addScaledVector)
| arg | type | description |
|---|---|---|
| a | V | |
| b | V | |
| s | number |
add(a: V, b: V) → V
| arg | type | description |
|---|---|---|
| a | V | |
| b | V |
lerp(a: V, b: V, t: number) → V
| arg | type | description |
|---|---|---|
| a | V | |
| b | V | |
| t | number |
normalize(a: V) → V
| arg | type | description |
|---|---|---|
| a | V |
cross(a: V, b: V) → V
| arg | type | description |
|---|---|---|
| a | V | |
| b | V |
scale(a: V, s: number) → V
| arg | type | description |
|---|---|---|
| a | V | |
| s | number |
initNonuniform(x0: number, x1: number, x2: number, x3: number, dt0: number, dt1: number, dt2: number) → void
| arg | type | description |
|---|---|---|
| x0 | number | |
| x1 | number | |
| x2 | number | |
| x3 | number | |
| dt0 | number | |
| dt1 | number | |
| dt2 | number |
dist2(a: V, b: V) → number
| arg | type | description |
|---|---|---|
| a | V | |
| b | V |
new(points: { V }) → void
| arg | type | description |
|---|---|---|
| points | { V } |
getPoint(t: number) → V
| arg | type | description |
|---|---|---|
| t | number |
getLengths( ) → void
getLength( ) → number
getUtoTmapping(u: number) → number
| arg | type | description |
|---|---|---|
| u | number |
getTangent(t: number) → V
| arg | type | description |
|---|---|---|
| t | number |
rotateAxis(v: V, axis: V, angle: number) → void
applyMatrix4(makeRotationAxis(axis, angle)) on v, in place.
| arg | type | description |
|---|---|---|
| v | V | |
| axis | V | |
| angle | number |
computeFrenetFrames(segments: number) → void
| arg | type | description |
|---|---|---|
| segments | number |
icosahedron( ) → void
vert(i: number) → V
| arg | type | description |
|---|---|---|
| i | number |
push(p: V) → void
| arg | type | description |
|---|---|---|
| p | V |
leafPixels( ) → void
A spray of leaves, white on black, 256 square: red is how light a leaf is painted, green is where there is leaf at all. The original draws it on a canvas (filled quadratic curves, anti-aliased): here each pixel is sampled 4x4 and painted over what is under it by its coverage, as the canvas composites. Returns RGBA bytes, rows bottom to top (three's CanvasTexture flips Y), and the size.
leaf(x: number, y: number, angle: number, len: number) → void
| arg | type | description |
|---|---|---|
| x | number | |
| y | number | |
| angle | number | |
| len | number |
leafTexture( ) → any
The leaf texture on the GPU: mipmapped, trilinear, anisotropy 4, repeating; linear values (a CanvasTexture has no colour space).
growTree(seed: number, o: any) → void
Grows one tree, standing at the origin. Returns its wood, its leaves and its core (the dark balls under the sprays) as geometry, and how big its crown is, for its shadow. o.trunk height of the bole, o.girth its radius, o.crown the crown's radius, o.rise the crown's height, o.limbs how many, o.clump the radius of a clump of leaves, o.fill clumps added to round the crown out, o.cards leaf sprays to a clump, o.spray the size of one
| arg | type | description |
|---|---|---|
| seed | number | |
| o | any |
reach(a: number) → number
| arg | type | description |
|---|---|---|
| a | number |
plant( ) → void
Where the trees stand: { x, z, kind, scale, turn }. Kind 0 is the great tree.
clear(x: number, z: number, gap: number) → boolean
| arg | type | description |
|---|---|---|
| x | number | |
| z | number | |
| gap | number |
copse(u: number, v: number, n: number, spread: number) → void
A copse: n trees packed round (u, v) so their crowns run together into one mass, longer one way than the other, big trees in its middle and small ones at its edge.
| arg | type | description |
|---|---|---|
| u | number | |
| v | number | |
| n | number | |
| spread | number |
lone(u: number, v: number) → void
One big tree standing alone.
| arg | type | description |
|---|---|---|
| u | number | |
| v | number |
grow(cardsShare: number?) → void
The kinds of tree and bush, and every one of them planted: { kinds, trees, BUSH }. options.cards 0 to 1, the share of leaf sprays drawn.
| arg | type | description |
|---|---|---|
| cardsShare | number? |
bush(x: number, z: number, sc: number) → void
| arg | type | description |
|---|---|---|
| x | number | |
| z | number | |
| sc | number |
indices(n: number) → void
| arg | type | description |
|---|---|---|
| n | number |
randColors(r: { number }) → void
| arg | type | description |
|---|---|---|
| r | { number } |
meshes(kind: any) → void
| arg | type | description |
|---|---|---|
| kind | any |
castInto(data: buffer, kinds: { any }, trees: { any }, BUSH: number, sunDir: { number }, extentMin: { number }, extent: number, stride: number?) → void
Lays every crown's shadow on the ground for this sun, into `data` (RES*RES texels of `stride` bytes, the shade in the first, row j at z). The original's trees.cast. Yields now and then where it can, so a cast at sunset (long shadows) does not hold a frame up.
| arg | type | description |
|---|---|---|
| data | buffer | |
| kinds | { any } | |
| trees | { any } | |
| BUSH | number | |
| sunDir | { number } | |
| extentMin | { number } | |
| extent | number | |
| stride | number? |
bindTexture(key: string, slot: string, tex: any) → void
| arg | type | description |
|---|---|---|
| key | string | |
| slot | string | |
| tex | any |
createTrees(core: any, options: any?) → void
The original's createTrees(field, { cards }): every tree and bush drawn, one kind to a draw for each of wood, core and sprays, and their shade cast onto the ground as tShade (core.setTexture). Returns { trees, kinds, BUSH, shade (texture), cast(sunDir), destroy() }. options.cards 0 to 1, the share of leaf sprays.
| arg | type | description |
|---|---|---|
| core | any | |
| options | any? |
bindOwn( ) → void
draw(mesh: any, material: any) → void
| arg | type | description |
|---|---|---|
| mesh | any | |
| material | any |
upload( ) → void
cast(sunDir: any) → void
Lays every crown's shadow on the ground for this sun. Call when the hour changes. sunDir = {x, y, z} (or .x/.y/.z).
| arg | type | description |
|---|---|---|
| sunDir | any |
destroy( ) → void
Sub-parts
Everything contained inside this part. Assets are composite children (clickable cards). Files are leaf payloads. Expand any row to view its source.
Problems
Everything affecting this asset right now: its own problems, anything wrong inside it, and problems on its direct dependencies.
agent_score is exposed.+ quality × 0.35
+ performance × 0.25
± compat factor
Usability ratings
Did the part work as advertised when consumers tried to drop it in. Separate from upvotes: those are taste; this is "did it function".
Scoped to this part · feeds back into the world's score.