MCPcopy Create free account
hub / github.com/TheOrcDev/github-creature / update

Method update

components/liquid-ether.tsx:382–424  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

380 this.mouse.isAutoActive = false;
381 }
382 update() {
383 if (!this.enabled) return;
384 const now = performance.now();
385 const idle = now - this.manager.lastUserInteraction;
386 if (idle < this.resumeDelay) {
387 if (this.active) this.forceStop();
388 return;
389 }
390 if (this.mouse.isHoverInside) {
391 if (this.active) this.forceStop();
392 return;
393 }
394 if (!this.active) {
395 this.active = true;
396 this.current.copy(this.mouse.coords);
397 this.lastTime = now;
398 this.activationTime = now;
399 }
400 if (!this.active) return;
401 this.mouse.isAutoActive = true;
402 let dtSec = (now - this.lastTime) / 1000;
403 this.lastTime = now;
404 if (dtSec > 0.2) dtSec = 0.016;
405 const dir = this._tmpDir.subVectors(this.target, this.current);
406 const dist = dir.length();
407 if (dist < 0.01) {
408 this.pickNewTarget();
409 return;
410 }
411 dir.normalize();
412 let ramp = 1;
413 if (this.rampDurationMs > 0) {
414 const t = Math.min(
415 1,
416 (now - this.activationTime) / this.rampDurationMs
417 );
418 ramp = t * t * (3 - 2 * t);
419 }
420 const step = this.speed * dtSec * ramp;
421 const move = Math.min(step, dist);
422 this.current.addScaledVector(dir, move);
423 this.mouse.setNormalized(this.current.x, this.current.y);
424 }
425 }
426
427 const face_vert = `

Callers

nothing calls this directly

Calls 3

forceStopMethod · 0.95
pickNewTargetMethod · 0.95
setNormalizedMethod · 0.80

Tested by

no test coverage detected