(now)
| 1180 | let leftGamepadTrigger, rightGamepadTrigger; |
| 1181 | |
| 1182 | const frame = (now) => { |
| 1183 | let inv = invert4(viewMatrix); |
| 1184 | let shiftKey = |
| 1185 | activeKeys.includes("Shift") || |
| 1186 | activeKeys.includes("ShiftLeft") || |
| 1187 | activeKeys.includes("ShiftRight"); |
| 1188 | |
| 1189 | if (activeKeys.includes("ArrowUp")) { |
| 1190 | if (shiftKey) { |
| 1191 | inv = translate4(inv, 0, -0.03, 0); |
| 1192 | } else { |
| 1193 | inv = translate4(inv, 0, 0, 0.1); |
| 1194 | } |
| 1195 | } |
| 1196 | if (activeKeys.includes("ArrowDown")) { |
| 1197 | if (shiftKey) { |
| 1198 | inv = translate4(inv, 0, 0.03, 0); |
| 1199 | } else { |
| 1200 | inv = translate4(inv, 0, 0, -0.1); |
| 1201 | } |
| 1202 | } |
| 1203 | if (activeKeys.includes("ArrowLeft")) |
| 1204 | inv = translate4(inv, -0.03, 0, 0); |
| 1205 | // |
| 1206 | if (activeKeys.includes("ArrowRight")) |
| 1207 | inv = translate4(inv, 0.03, 0, 0); |
| 1208 | // inv = rotate4(inv, 0.01, 0, 1, 0); |
| 1209 | if (activeKeys.includes("KeyA")) inv = rotate4(inv, -0.01, 0, 1, 0); |
| 1210 | if (activeKeys.includes("KeyD")) inv = rotate4(inv, 0.01, 0, 1, 0); |
| 1211 | if (activeKeys.includes("KeyQ")) inv = rotate4(inv, 0.01, 0, 0, 1); |
| 1212 | if (activeKeys.includes("KeyE")) inv = rotate4(inv, -0.01, 0, 0, 1); |
| 1213 | if (activeKeys.includes("KeyW")) inv = rotate4(inv, 0.005, 1, 0, 0); |
| 1214 | if (activeKeys.includes("KeyS")) inv = rotate4(inv, -0.005, 1, 0, 0); |
| 1215 | |
| 1216 | const gamepads = navigator.getGamepads ? navigator.getGamepads() : []; |
| 1217 | let isJumping = activeKeys.includes("Space"); |
| 1218 | for (let gamepad of gamepads) { |
| 1219 | if (!gamepad) continue; |
| 1220 | |
| 1221 | const axisThreshold = 0.1; // Threshold to detect when the axis is intentionally moved |
| 1222 | const moveSpeed = 0.06; |
| 1223 | const rotateSpeed = 0.02; |
| 1224 | |
| 1225 | // Assuming the left stick controls translation (axes 0 and 1) |
| 1226 | if (Math.abs(gamepad.axes[0]) > axisThreshold) { |
| 1227 | inv = translate4(inv, moveSpeed * gamepad.axes[0], 0, 0); |
| 1228 | carousel = false; |
| 1229 | } |
| 1230 | if (Math.abs(gamepad.axes[1]) > axisThreshold) { |
| 1231 | inv = translate4(inv, 0, 0, -moveSpeed * gamepad.axes[1]); |
| 1232 | carousel = false; |
| 1233 | } |
| 1234 | if (gamepad.buttons[12].pressed || gamepad.buttons[13].pressed) { |
| 1235 | inv = translate4( |
| 1236 | inv, |
| 1237 | 0, |
| 1238 | -moveSpeed * |
| 1239 | (gamepad.buttons[12].pressed - |
no test coverage detected