From 1359ecb3cc5b6813ae22b1d7c3ed9e178fc3752f Mon Sep 17 00:00:00 2001 From: Peter Abbondanzo Date: Wed, 4 Dec 2019 13:39:13 -0500 Subject: [PATCH] Fix linting warnings (#75) --- src/builders/SceneBuilder.ts | 32 +++++++++--------- .../player/buildRocketLoadoutScene.ts | 18 ++++++---- src/loaders/operators/loadObject.ts | 4 +-- src/loaders/storage/loadRlLoadout.ts | 33 ++++++++++++++----- src/viewer/clients/loadBuilderFromReplay.ts | 9 +++-- 5 files changed, 61 insertions(+), 35 deletions(-) diff --git a/src/builders/SceneBuilder.ts b/src/builders/SceneBuilder.ts index b5e9d50..aaec05c 100644 --- a/src/builders/SceneBuilder.ts +++ b/src/builders/SceneBuilder.ts @@ -1,16 +1,16 @@ -import { Cache, LoadingManager, Scene } from 'three' +import { RocketAssetManager, RocketConfig, TextureFormat } from "rl-loadout-lib" +import { Cache, LoadingManager, Scene } from "three" +import { DRACOLoader } from "three/examples/jsm/loaders/DRACOLoader" +import { GLTFLoader } from "three/examples/jsm/loaders/GLTFLoader" -import GameFieldAssets from '../loaders/scenes/GameFieldAssets' -import SceneManager from '../managers/SceneManager' -import { buildBall } from './ball/buildBall' -import { buildPlayfield } from './field/buildPlayfield' -import { addLighting } from './scene/addLighting' -import { ExtendedPlayer } from '../models/ReplayMetadata'; -import { loadRlLoadout } from '../loaders/storage/loadRlLoadout'; -import { RocketAssetManager, RocketConfig, TextureFormat } from 'rl-loadout-lib'; -import { buildRocketLoadoutGroup } from './player/buildRocketLoadoutScene'; -import { GLTFLoader } from 'three/examples/jsm/loaders/GLTFLoader'; -import { DRACOLoader } from 'three/examples/jsm/loaders/DRACOLoader'; +import GameFieldAssets from "../loaders/scenes/GameFieldAssets" +import { loadRlLoadout } from "../loaders/storage/loadRlLoadout" +import SceneManager from "../managers/SceneManager" +import { ExtendedPlayer } from "../models/ReplayMetadata" +import { buildBall } from "./ball/buildBall" +import { buildPlayfield } from "./field/buildPlayfield" +import { buildRocketLoadoutGroup } from "./player/buildRocketLoadoutScene" +import { addLighting } from "./scene/addLighting" /** * @description The sole purpose of this function is to initialize and tie together all of the @@ -34,17 +34,19 @@ const defaultSceneBuilder = async ( const gltfLoader = new GLTFLoader() const dracoLoader = new DRACOLoader() - dracoLoader.setDecoderPath('/draco/') + dracoLoader.setDecoderPath("/draco/") gltfLoader.setDRACOLoader(dracoLoader) const config = new RocketConfig({ gltfLoader, loadingManager, textureFormat: TextureFormat.PNG, - useCompressedModels: true + useCompressedModels: true, }) const manager = new RocketAssetManager(config) - const bodyPromises = playerInfo.map(player => loadRlLoadout(manager, player, defaultLoadouts)) + const bodyPromises = playerInfo.map(player => + loadRlLoadout(manager, player, defaultLoadouts) + ) await GameFieldAssets.load() const bodies = await Promise.all(bodyPromises) diff --git a/src/builders/player/buildRocketLoadoutScene.ts b/src/builders/player/buildRocketLoadoutScene.ts index 3096f87..420a694 100644 --- a/src/builders/player/buildRocketLoadoutScene.ts +++ b/src/builders/player/buildRocketLoadoutScene.ts @@ -1,11 +1,15 @@ -import { BodyModel } from 'rl-loadout-lib'; -import { ExtendedPlayer } from '../../models/ReplayMetadata'; -import { getCarName, getGroupName } from '../utils/playerNameGetters'; -import { Group, Scene } from 'three'; -import { generateSprite } from './generateSprite'; -import PlayerManager from '../../managers/models/PlayerManager'; +import { BodyModel } from "rl-loadout-lib" +import { Group, Scene } from "three" -export function buildRocketLoadoutGroup(scene: Scene, {body, player}: { body: BodyModel; player: ExtendedPlayer }) { +import PlayerManager from "../../managers/models/PlayerManager" +import { ExtendedPlayer } from "../../models/ReplayMetadata" +import { getCarName, getGroupName } from "../utils/playerNameGetters" +import { generateSprite } from "./generateSprite" + +export const buildRocketLoadoutGroup = ( + scene: Scene, + { body, player }: { body: BodyModel; player: ExtendedPlayer } +) => { body.scene.name = getCarName(player.name) // Build sprite and camera container (for position) diff --git a/src/loaders/operators/loadObject.ts b/src/loaders/operators/loadObject.ts index 6914561..0de5efa 100644 --- a/src/loaders/operators/loadObject.ts +++ b/src/loaders/operators/loadObject.ts @@ -1,6 +1,6 @@ import { LoadingManager } from "three" -import { GLTF, GLTFLoader } from "three/examples/jsm/loaders/GLTFLoader" import { DRACOLoader } from "three/examples/jsm/loaders/DRACOLoader" +import { GLTF, GLTFLoader } from "three/examples/jsm/loaders/GLTFLoader" export const loadObject = (path: string, loadingManager?: LoadingManager) => { return new Promise( @@ -10,7 +10,7 @@ export const loadObject = (path: string, loadingManager?: LoadingManager) => { ) => { const gltfLoader = new GLTFLoader(loadingManager) const dracoLoader = new DRACOLoader() - dracoLoader.setDecoderPath('/draco/') + dracoLoader.setDecoderPath("/draco/") gltfLoader.setDRACOLoader(dracoLoader) gltfLoader.load( path, diff --git a/src/loaders/storage/loadRlLoadout.ts b/src/loaders/storage/loadRlLoadout.ts index d26a3b9..3c118d9 100644 --- a/src/loaders/storage/loadRlLoadout.ts +++ b/src/loaders/storage/loadRlLoadout.ts @@ -1,9 +1,21 @@ -import { createPaintConfig, RocketAssetManager, BodyModel, WheelsModel, Body, Wheel, Decal } from 'rl-loadout-lib' -import { ExtendedPlayer } from '../../models/ReplayMetadata' -import { Mesh, MeshPhongMaterial, MeshStandardMaterial } from 'three' +import { + Body, + BodyModel, + createPaintConfig, + Decal, + RocketAssetManager, + Wheel, + WheelsModel, +} from "rl-loadout-lib" +import { Mesh, MeshPhongMaterial, MeshStandardMaterial } from "three" -export async function loadRlLoadout(manager: RocketAssetManager, player: ExtendedPlayer, defaultLoadout?: boolean): - Promise<{ body: BodyModel; player: ExtendedPlayer }> { +import { ExtendedPlayer } from "../../models/ReplayMetadata" + +export const loadRlLoadout = async ( + manager: RocketAssetManager, + player: ExtendedPlayer, + defaultLoadout?: boolean +): Promise<{ body: BodyModel; player: ExtendedPlayer }> => { let body: BodyModel let wheels: WheelsModel @@ -24,9 +36,14 @@ export async function loadRlLoadout(manager: RocketAssetManager, player: Extende player.loadout.antennaPaint ) - const bodyTask = manager.loadBody(player.loadout.car, paintConfig, Body.DEFAULT) + const bodyTask = manager.loadBody( + player.loadout.car, + paintConfig, + Body.DEFAULT + ) - // TODO use the default wheel for now, there aren't a lot of wheels in rocket-loadout yet, and not yet fully supported + // TODO use the default wheel for now, there aren't a lot of wheels in rocket-loadout yet, + // and not yet fully supported wheels = new WheelsModel(Wheel.DEFAULT, paintConfig, manager.config) await wheels.load() @@ -59,5 +76,5 @@ export async function loadRlLoadout(manager: RocketAssetManager, player: Extende } }) - return {player, body} + return { player, body } } diff --git a/src/viewer/clients/loadBuilderFromReplay.ts b/src/viewer/clients/loadBuilderFromReplay.ts index 8ad3eea..41152a8 100644 --- a/src/viewer/clients/loadBuilderFromReplay.ts +++ b/src/viewer/clients/loadBuilderFromReplay.ts @@ -1,14 +1,17 @@ -import { loadReplay } from "./loadReplay" import { GameManager } from "../../managers/GameManager" import FPSClock from "../../utils/FPSClock" +import { loadReplay } from "./loadReplay" -export const loadBuilderFromReplay = async (replayId: string, defaultLoadouts: boolean = false) => { +export const loadBuilderFromReplay = async ( + replayId: string, + defaultLoadouts: boolean = false +) => { return loadReplay(replayId).then(([replayData, replayMetadata]) => { return GameManager.builder({ replayData, replayMetadata, clock: FPSClock.convertReplayToClock(replayData), - defaultLoadouts + defaultLoadouts, }) }) }