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

Class CommonClass

components/liquid-ether.tsx:123–171  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

121 const bgVec4 = new THREE.Vector4(0, 0, 0, 0);
122
123 class CommonClass {
124 width = 0;
125 height = 0;
126 aspect = 1;
127 pixelRatio = 1;
128 isMobile = false;
129 breakpoint = 768;
130 fboWidth: number | null = null;
131 fboHeight: number | null = null;
132 time = 0;
133 delta = 0;
134 container: HTMLElement | null = null;
135 renderer: THREE.WebGLRenderer | null = null;
136 clock: THREE.Clock | null = null;
137 init(container: HTMLElement) {
138 this.container = container;
139 this.pixelRatio = Math.min(window.devicePixelRatio || 1, 2);
140 this.resize();
141 this.renderer = new THREE.WebGLRenderer({
142 antialias: true,
143 alpha: true,
144 preserveDrawingBuffer: true,
145 });
146 this.renderer.autoClear = false;
147 this.renderer.setClearColor(new THREE.Color(0x000000), 0);
148 this.renderer.setPixelRatio(this.pixelRatio);
149 this.renderer.setSize(this.width, this.height);
150 const el = this.renderer.domElement;
151 el.style.width = "100%";
152 el.style.height = "100%";
153 el.style.display = "block";
154 this.clock = new THREE.Clock();
155 this.clock.start();
156 }
157 resize() {
158 if (!this.container) return;
159 const rect = this.container.getBoundingClientRect();
160 this.width = Math.max(1, Math.floor(rect.width));
161 this.height = Math.max(1, Math.floor(rect.height));
162 this.aspect = this.width / this.height;
163 if (this.renderer)
164 this.renderer.setSize(this.width, this.height, false);
165 }
166 update() {
167 if (!this.clock) return;
168 this.delta = this.clock.getDelta();
169 this.time += this.delta;
170 }
171 }
172 const Common = new CommonClass();
173
174 class MouseClass {

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected