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

Class WebGLManager

components/liquid-ether.tsx:1085–1173  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1083 }
1084
1085 class WebGLManager implements LiquidEtherWebGL {
1086 props: any;
1087 output!: Output;
1088 autoDriver?: AutoDriver;
1089 lastUserInteraction = performance.now();
1090 running = false;
1091 private _loop = this.loop.bind(this);
1092 private _resize = this.resize.bind(this);
1093 private _onVisibility?: () => void;
1094 constructor(props: any) {
1095 this.props = props;
1096 Common.init(props.$wrapper);
1097 Mouse.init(props.$wrapper);
1098 Mouse.autoIntensity = props.autoIntensity;
1099 Mouse.takeoverDuration = props.takeoverDuration;
1100 Mouse.onInteract = () => {
1101 this.lastUserInteraction = performance.now();
1102 if (this.autoDriver) this.autoDriver.forceStop();
1103 };
1104 this.autoDriver = new AutoDriver(Mouse, this as any, {
1105 enabled: props.autoDemo,
1106 speed: props.autoSpeed,
1107 resumeDelay: props.autoResumeDelay,
1108 rampDuration: props.autoRampDuration,
1109 });
1110 this.init();
1111 window.addEventListener("resize", this._resize);
1112 this._onVisibility = () => {
1113 const hidden = document.hidden;
1114 if (hidden) {
1115 this.pause();
1116 } else if (isVisibleRef.current) {
1117 this.start();
1118 }
1119 };
1120 document.addEventListener("visibilitychange", this._onVisibility);
1121 }
1122 init() {
1123 if (!Common.renderer) return;
1124 this.props.$wrapper.prepend(Common.renderer.domElement);
1125 this.output = new Output();
1126 }
1127 resize() {
1128 Common.resize();
1129 this.output.resize();
1130 }
1131 render() {
1132 if (this.autoDriver) this.autoDriver.update();
1133 Mouse.update();
1134 Common.update();
1135 this.output.update();
1136 }
1137 loop() {
1138 if (!this.running) return;
1139 this.render();
1140 rafRef.current = requestAnimationFrame(this._loop);
1141 }
1142 start() {

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected