perf: faster still
This commit is contained in:
parent
ef5029da1d
commit
67cd54fe33
8 changed files with 280 additions and 203 deletions
|
|
@ -1,5 +1,5 @@
|
|||
import type { Vec3 } from "../math/Vec3"
|
||||
import type { Mesh } from "./Mesh"
|
||||
import { STRIDE, type Mesh } from "./Mesh"
|
||||
|
||||
const TAU = Math.PI * 2
|
||||
|
||||
|
|
@ -37,7 +37,7 @@ export namespace Boulder {
|
|||
const cy = boulder.position.y + sy * 0.55
|
||||
|
||||
const jitter = jitterGrid(seg, rings, rand)
|
||||
const start = mesh.vertices.length
|
||||
const start = mesh.verts.length / STRIDE
|
||||
for (let ir = 0; ir <= rings; ir++) {
|
||||
const phi = (ir / rings) * Math.PI
|
||||
const cyv = Math.cos(phi)
|
||||
|
|
@ -45,14 +45,13 @@ export namespace Boulder {
|
|||
for (let is = 0; is <= seg; is++) {
|
||||
const theta = (is / seg) * TAU
|
||||
const j = jitter[ir][is]
|
||||
mesh.vertices.push({
|
||||
pos: {
|
||||
x: cx + crv * Math.cos(theta) * sx * j,
|
||||
y: cy + cyv * sy * j,
|
||||
z: cz + crv * Math.sin(theta) * sz * j,
|
||||
},
|
||||
uv: { x: (is / seg) * 1.5, y: (ir / rings) * 1.5 },
|
||||
})
|
||||
mesh.verts.push(
|
||||
cx + crv * Math.cos(theta) * sx * j,
|
||||
cy + cyv * sy * j,
|
||||
cz + crv * Math.sin(theta) * sz * j,
|
||||
(is / seg) * 1.5,
|
||||
(ir / rings) * 1.5,
|
||||
)
|
||||
}
|
||||
}
|
||||
const row = seg + 1
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue