MCPcopy Index your code
hub / github.com/processing/p5.js / update

Method update

test/types/webgl-pixels.ts:125–158  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

123 }
124
125 update() {
126 Matter.World.remove(engine.world, this.springs)
127 this.springs = []
128 const bins = this.binnedNodes()
129 for (const node of this.nodes) {
130 const binsToCheck = this.adjacentBins(node)
131 for (const bin of binsToCheck) {
132 const key = this.binKey(bin)
133 if (!bins[key]) continue
134 for (const other of bins[key]) {
135 if (other === node) continue
136 this.springs.push(Matter.Constraint.create({
137 bodyA: node,
138 pointA: { x: 0, y: 0 },
139 bodyB: other,
140 pointB: { x: 0, y: 0 },
141 stiffness: map(
142 Math.hypot(node.position.x - other.position.x, node.position.y - other.position.y),
143 0, 12*BLOB_NODE_SIZE,
144 0.02, 0.03,
145 true
146 ),
147 damping: 0.001,
148 // length: 0,
149 length: max(
150 2 * BLOB_NODE_SIZE,
151 Math.hypot(node.position.x - other.position.x, node.position.y - other.position.y) * 0.975
152 ),
153 }))
154 }
155 }
156 }
157 Matter.World.add(engine.world, this.springs)
158 }
159
160 drawBlob() {
161 const minX = Math.min(...this.nodes.map((n) => n.position.x)) - 4 * BLOB_NODE_SIZE

Callers 3

drawFunction · 0.45
p5.Texture.jsFile · 0.45

Calls 7

binnedNodesMethod · 0.95
adjacentBinsMethod · 0.95
binKeyMethod · 0.95
mapFunction · 0.85
removeMethod · 0.45
pushMethod · 0.45
addMethod · 0.45

Tested by

no test coverage detected