Skip to content

Commit

Permalink
types: remove implicit any
Browse files Browse the repository at this point in the history
  • Loading branch information
IsaacThoman committed Jan 28, 2025
1 parent e4f5ed1 commit afc6957
Show file tree
Hide file tree
Showing 11 changed files with 28 additions and 28 deletions.
2 changes: 1 addition & 1 deletion deno.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"nodeModulesDir": "manual",
"nodeModulesDir": "auto",
"tasks": {
"dev": "deno run -A --node-modules-dir npm:vite",
"build": "deno run -A --node-modules-dir npm:vite build",
Expand Down
10 changes: 5 additions & 5 deletions src/client/core/AssetManager.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { GLTFLoader } from 'three/examples/jsm/loaders/GLTFLoader.js';
import { GLTF, GLTFLoader } from 'three/examples/jsm/loaders/GLTFLoader.js';
import { DRACOLoader } from 'three/examples/jsm/loaders/DRACOLoader.js';
import * as THREE from 'three';

Expand Down Expand Up @@ -31,11 +31,11 @@ export class AssetManager {
private cloneWithNewMaterials(scene: THREE.Group): THREE.Group {
const clonedScene = scene.clone();

clonedScene.traverse((node) => {
clonedScene.traverse((node: THREE.Object3D) => {
if ((node as THREE.Mesh).isMesh) {
const mesh = node as THREE.Mesh;
if (Array.isArray(mesh.material)) {
mesh.material = mesh.material.map((mat) => mat.clone());
mesh.material = mesh.material.map((mat: THREE.Material) => mat.clone());
} else {
mesh.material = mesh.material.clone();
}
Expand All @@ -60,7 +60,7 @@ export class AssetManager {
this.assets.set(url, { scene: new THREE.Group(), isLoaded: false, callbacks: [callback] });
this.gltfLoader.load(
url,
(gltf) => {
(gltf: GLTF) => {
const assetEntry = this.assets.get(url)!;
assetEntry.scene = gltf.scene;
assetEntry.isLoaded = true;
Expand All @@ -72,7 +72,7 @@ export class AssetManager {
assetEntry.callbacks = [];
},
undefined,
(error) => {
(error: Error) => {
console.error(`Error loading asset ${url}:`, error);
},
);
Expand Down
14 changes: 7 additions & 7 deletions src/client/core/RemotePlayerRenderer.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import * as THREE from 'three';
import { Networking } from './Networking.ts';
import { GLTFLoader } from 'three/examples/jsm/loaders/GLTFLoader.js';
import { GLTF, GLTFLoader } from 'three/examples/jsm/loaders/GLTFLoader.js';
import { DRACOLoader } from 'three/examples/jsm/loaders/DRACOLoader.js';
import { acceleratedRaycast, computeBoundsTree, disposeBoundsTree } from 'three-mesh-bvh';
import { Player, PlayerData } from '../../shared/Player.ts';
Expand Down Expand Up @@ -74,7 +74,7 @@ export class RemotePlayerRenderer {
this.possumMesh = undefined;
this.loader.load(
'models/simplified_possum.glb',
(gltf) => {
(gltf: GLTF) => {
console.time('Computing possum BVH');
(<THREE.Mesh> gltf.scene.children[0]).geometry.computeBoundsTree();
console.timeEnd('Computing possum BVH');
Expand Down Expand Up @@ -412,7 +412,7 @@ export class RemotePlayerRenderer {
const wallIntersects = this.raycaster.intersectObjects([RemotePlayerRenderer.map]);
this.raycaster.firstHitOnly = false;

const filteredIntersects = playerIntersects.filter((playerIntersect) => {
const filteredIntersects = playerIntersects.filter((playerIntersect: THREE.Intersection) => {
for (const wallIntersect of wallIntersects) {
if (wallIntersect.distance < playerIntersect.distance) {
return false;
Expand All @@ -424,7 +424,7 @@ export class RemotePlayerRenderer {
return true;
});

return filteredIntersects.map((intersect) => intersect.object);
return filteredIntersects.map((intersect: THREE.Intersection) => intersect.object);
}

public getPlayerSpheresInCrosshairWithWalls(): THREE.Object3D[] {
Expand All @@ -437,7 +437,7 @@ export class RemotePlayerRenderer {
const wallIntersects = this.raycaster.intersectObjects([RemotePlayerRenderer.map]);
this.raycaster.firstHitOnly = false;

const filteredIntersects = playerIntersects.filter((playerIntersect) => {
const filteredIntersects = playerIntersects.filter((playerIntersect: THREE.Intersection) => {
for (const wallIntersect of wallIntersects) {
if (wallIntersect.distance < playerIntersect.distance) {
return false;
Expand All @@ -446,7 +446,7 @@ export class RemotePlayerRenderer {
return true;
});

return filteredIntersects.map((intersect) => intersect.object);
return filteredIntersects.map((intersect: THREE.Intersection) => intersect.object);
}

public getShotVectorsToPlayersWithOffset(
Expand All @@ -467,7 +467,7 @@ export class RemotePlayerRenderer {
this.raycaster.firstHitOnly = false;

// Filter player intersections based on wall intersections
const filteredPlayerIntersects = playerIntersects.filter((playerIntersect) => {
const filteredPlayerIntersects = playerIntersects.filter((playerIntersect: THREE.Intersection) => {
for (const wallIntersect of wallIntersects) {
if (wallIntersect.distance < playerIntersect.distance) {
return false; // A wall is blocking the player
Expand Down
4 changes: 2 additions & 2 deletions src/client/items/BananaGun.ts
Original file line number Diff line number Diff line change
Expand Up @@ -38,12 +38,12 @@ export class BananaGun extends ItemBase {
AssetManager.getInstance().loadAsset('models/simplified_banana_1.glb', (scene) => {
this.object = scene;
if (this.itemType === ItemType.InventoryItem) {
this.object.traverse((child) => {
this.object.traverse((child: THREE.Object3D) => {
if ((child as THREE.Mesh).isMesh) {
child.renderOrder = 999;
const mesh = child as THREE.Mesh;
if (Array.isArray(mesh.material)) {
mesh.material.forEach((mat) => mat.depthTest = false);
mesh.material.forEach((mat: THREE.Material) => mat.depthTest = false);
} else {
mesh.material.depthTest = false;
}
Expand Down
4 changes: 2 additions & 2 deletions src/client/items/FishGun.ts
Original file line number Diff line number Diff line change
Expand Up @@ -39,12 +39,12 @@ export class FishGun extends ItemBase {
AssetManager.getInstance().loadAsset('models/simplified_fish.glb', (scene) => {
this.object = scene;
if (this.itemType === ItemType.InventoryItem) {
this.object.traverse((child) => {
this.object.traverse((child: THREE.Object3D) => {
if ((child as THREE.Mesh).isMesh) {
child.renderOrder = 999;
const mesh = child as THREE.Mesh;
if (Array.isArray(mesh.material)) {
mesh.material.forEach((mat) => mat.depthTest = false);
mesh.material.forEach((mat: THREE.Material) => mat.depthTest = false);
} else {
mesh.material.depthTest = false;
}
Expand Down
4 changes: 2 additions & 2 deletions src/client/items/FlagItem.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,12 +31,12 @@ export class FlagItem extends ItemBase {
AssetManager.getInstance().loadAsset('models/simplified_pizza.glb', (scene) => {
this.object = scene;
if (this.itemType === ItemType.InventoryItem) {
this.object.traverse((child) => {
this.object.traverse((child: THREE.Object3D) => {
if ((child as THREE.Mesh).isMesh) {
child.renderOrder = 999;
const mesh = child as THREE.Mesh;
if (Array.isArray(mesh.material)) {
mesh.material.forEach((mat) => mat.depthTest = false);
mesh.material.forEach((mat: THREE.Material) => mat.depthTest = false);
} else {
mesh.material.depthTest = false;
}
Expand Down
4 changes: 2 additions & 2 deletions src/client/items/ItemBase.ts
Original file line number Diff line number Diff line change
Expand Up @@ -38,10 +38,10 @@ export class ItemBase {
this.inventoryMenuObject = this.object.clone();

if (this.itemType === ItemType.InventoryItem) {
this.object.traverse((child) => {
this.object.traverse((child: THREE.Object3D) => {
if ((child as THREE.Mesh).isMesh) {
child.renderOrder = 999;
const applyDepthTest = (material: THREE.Material | THREE.Material[]) => {
const applyDepthTest = (material: THREE.Material | THREE.Material[]): void => {
if (Array.isArray(material)) {
material.forEach((mat) => applyDepthTest(mat)); // Recursively handle array elements
} else {
Expand Down
4 changes: 2 additions & 2 deletions src/client/items/Pipe.ts
Original file line number Diff line number Diff line change
Expand Up @@ -40,12 +40,12 @@ export class Pipe extends ItemBase {
AssetManager.getInstance().loadAsset('models/simplified_rusty_pipe.glb', (scene) => {
this.object = scene;
if (this.itemType === ItemType.InventoryItem) {
this.object.traverse((child) => {
this.object.traverse((child: THREE.Object3D) => {
if ((child as THREE.Mesh).isMesh) {
child.renderOrder = 999;
const mesh = child as THREE.Mesh;
if (Array.isArray(mesh.material)) {
mesh.material.forEach((mat) => mat.depthTest = false);
mesh.material.forEach((mat: THREE.Material) => mat.depthTest = false);
} else {
mesh.material.depthTest = false;
}
Expand Down
2 changes: 1 addition & 1 deletion src/client/ui/DirectionIndicator.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ export class DirectionIndicator extends IndicatorBase {
this.loadModel('models/arrow.glb')
.then((model) => {
this.directionObject = model;
this.directionObject.traverse((child) => {
this.directionObject.traverse((child: THREE.Object3D) => {
if ((child as THREE.Mesh).isMesh) {
(child as THREE.Mesh).renderOrder = 999;
this.applyDepthTestToMesh(child as THREE.Mesh);
Expand Down
2 changes: 1 addition & 1 deletion src/client/ui/HealthIndicator.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ export class HealthIndicator extends IndicatorBase {
this.loadModel('models/simplified_possum.glb')
.then((model) => {
this.possumObject = model;
this.possumObject.traverse((child) => {
this.possumObject.traverse((child: THREE.Object3D) => {
if ((child as THREE.Mesh).isMesh) {
(child as THREE.Mesh).renderOrder = 999;
this.applyDepthTest(child as THREE.Mesh);
Expand Down
6 changes: 3 additions & 3 deletions src/client/ui/IndicatorBase.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import * as THREE from 'three';
import { GLTFLoader } from 'three/examples/jsm/loaders/GLTFLoader.js';
import { GLTF, GLTFLoader } from 'three/examples/jsm/loaders/GLTFLoader.js';
import { DRACOLoader } from 'three/examples/jsm/loaders/DRACOLoader.js';
import { Player } from '../../shared/Player.ts';
import { Networking } from '../core/Networking.ts';
Expand Down Expand Up @@ -87,9 +87,9 @@ export abstract class IndicatorBase {
return new Promise((resolve, reject) => {
loader.load(
modelPath,
(gltf) => {
(gltf: GLTF) => {
const object = gltf.scene;
object.traverse((child) => {
object.traverse((child: THREE.Object3D) => {
if ((child as THREE.Mesh).isMesh) {
(child as THREE.Mesh).renderOrder = 999;
this.applyDepthTest(child as THREE.Mesh);
Expand Down

0 comments on commit afc6957

Please sign in to comment.