Skip to content

Commit

Permalink
Clean up utils functions #262
Browse files Browse the repository at this point in the history
  • Loading branch information
neu5 committed Jan 19, 2024
1 parent e1b8424 commit c2730b3
Show file tree
Hide file tree
Showing 2 changed files with 1 addition and 97 deletions.
3 changes: 1 addition & 2 deletions packages/client/src/scene/scene.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import {
} from "@babylonjs/core";
import HavokPhysics from "@babylonjs/havok";

import { addBox, addColors, addVehicle } from "../utils";
import { addColors, addVehicle } from "../utils";

import type { Engine } from "@babylonjs/core";
import type { GameConfig, GameObject } from "@neu5/types/src";
Expand Down Expand Up @@ -165,7 +165,6 @@ const startRace = async ({
scene
);

// const sphere = addSphere({ diameter: 2, shadowGenerator });
const sphere = MeshBuilder.CreateSphere(
"sphere",
{ diameter: 4, segments: 32 },
Expand Down
95 changes: 0 additions & 95 deletions packages/client/src/utils/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -70,32 +70,6 @@ const getName = (name: string) => {
return `${name}_${meshCounter}`;
};

const addPlane = ({
name = "plane",
width = 100,
height = 100,
scene,
}: {
name?: string;
width?: number;
height?: number;
scene: Scene;
}) => {
// Graphics
const plane = MeshBuilder.CreatePlane(
getName(name),
{
width,
height,
},
scene
);
plane.rotation = new Vector3(Math.PI / 2, 0, 0);
plane.receiveShadows = true;

return plane;
};

const addBox = ({
width,
height,
Expand Down Expand Up @@ -145,24 +119,6 @@ const addBox = ({
return box;
};

const addSphere = ({
diameter,
name = "sphere",
shadowGenerator,
}: {
name?: string;
diameter: number;
shadowGenerator: ShadowGenerator;
}) => {
// Graphics
const sphere = MeshBuilder.CreateSphere(getName(name));
sphere.scalingDeterminant = diameter * 2;
sphere.rotationQuaternion = sphere.rotationQuaternion || new Quaternion();
shadowGenerator.addShadowCaster(sphere, true);

return sphere;
};

const addVehicle = ({
// colorName,
scene,
Expand All @@ -172,11 +128,6 @@ const addVehicle = ({
scene: Scene;
shadowGenerator: ShadowGenerator;
}) => {
// const car = addSphere({
// diameter: 2,
// shadowGenerator,
// });

// car.material = scene.getMaterialByName(colorName);

const chassisMesh = MeshBuilder.CreateBox("Chassis", {
Expand Down Expand Up @@ -317,49 +268,6 @@ const addVehicle = ({
return vehicle;
};

const addRigidVehicle = ({
colorName,
scene,
shadowGenerator,
}: {
colorName: string;
scene: Scene;
shadowGenerator: ShadowGenerator;
}) => {
const carChassisSize = {
width: 4,
height: 0.5,
depth: 2,
};
const carWheelSize = 0.8;

const carBody = addBox({
width: carChassisSize.width,
height: carChassisSize.height,
depth: carChassisSize.depth,
shadowGenerator,
});

carBody.material = scene.getMaterialByName(colorName);

let wheels = [];

// wheels
for (let idx = 0; idx < 4; idx++) {
const wheel = addSphere({
diameter: carWheelSize,
shadowGenerator,
});
wheel.material = scene.getMaterialByName(COLOR_NAMES.BLACK);
wheels.push(wheel);
}

return {
body: carBody,
wheels,
};
};

const TOAST_COLORS = {
RED: "linear-gradient(to right, rgb(255, 95, 109), rgb(255, 195, 113))",
};
Expand Down Expand Up @@ -409,9 +317,6 @@ const toggleStartRaceBtns = (
export {
addBox,
addColors,
addPlane,
addSphere,
addRigidVehicle,
addVehicle,
debounce,
log,
Expand Down

0 comments on commit c2730b3

Please sign in to comment.