Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion api/animate.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,13 +18,13 @@
const updateCapsuleShapeForAnimation = (
physicsMesh,
animationName,
{ fallYOffset = -0.4 } = {},

Check failure on line 21 in api/animate.js

View workflow job for this annotation

GitHub Actions / eslint

'fallYOffset' is assigned a value but never used
) => {
if (
!physicsMesh ||
!physicsMesh.physics ||
!physicsMesh.physics.shape ||
physicsMesh.physics.shape.constructor.name !== "_PhysicsShapeCapsule"
!(flock?.BABYLON?.PhysicsShapeCapsule && physicsMesh.physics.shape instanceof flock.BABYLON.PhysicsShapeCapsule)
) {
return;
}
Expand Down Expand Up @@ -253,7 +253,7 @@
y = Number.isFinite(Number(y)) ? Number(y) : 0;
}

return new Promise(async (resolve) => {

Check failure on line 256 in api/animate.js

View workflow job for this annotation

GitHub Actions / eslint

Promise executor functions should not be async
await flock.whenModelReady(meshName, async function (mesh) {
if (mesh) {
const groundLevelSentinel = -999999;
Expand Down Expand Up @@ -375,7 +375,7 @@
easing = "Linear",
} = {},
) {
return new Promise(async (resolve) => {

Check failure on line 378 in api/animate.js

View workflow job for this annotation

GitHub Actions / eslint

Promise executor functions should not be async
await flock.whenModelReady(meshName1, async function (mesh1) {
if (!mesh1) {
resolve();
Expand Down Expand Up @@ -447,7 +447,7 @@
easing = "Linear",
} = {},
) {
return new Promise(async (resolve) => {

Check failure on line 450 in api/animate.js

View workflow job for this annotation

GitHub Actions / eslint

Promise executor functions should not be async
await flock.whenModelReady(meshName1, async function (mesh1) {
if (!mesh1) {
resolve();
Expand Down
2 changes: 1 addition & 1 deletion api/mesh.js
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ export const flockMesh = {
: null;

if (
physicsMesh?.physics?.shape?.constructor.name === "_PhysicsShapeCapsule"
physicsMesh?.physics?.shape instanceof flock.BABYLON.PhysicsShapeCapsule
) {
const currentShape = physicsMesh.physics.shape;
if (
Expand Down
28 changes: 18 additions & 10 deletions api/physics.js
Original file line number Diff line number Diff line change
@@ -1,15 +1,13 @@
let flock;
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🟡 Minor

Address the Prettier formatting warning.

The CI pipeline reports a Prettier formatting issue for this file. Run prettier --write api/physics.js to fix the formatting before merging.

🧰 Tools
🪛 GitHub Actions: Prettier

[warning] 1-1: Prettier reported formatting is not compliant (file listed under checks).

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@api/physics.js` at line 1, The file has a Prettier formatting violation; run
Prettier to reformat api/physics.js (e.g., run prettier --write on that file)
and commit the updated formatting; ensure the top-level declaration (let flock;)
and surrounding whitespace/line endings are normalized by Prettier so the CI
formatting check passes.


const getShapeTypeFromPhysics = (physics) => {
const shapeName = physics?.shape?.constructor?.name;
switch (shapeName) {
case "_PhysicsShapeCapsule":
return "CAPSULE";
case "_PhysicsShapeMesh":
return "MESH";
default:
return null;
}
if (!physics?.shape) return null;
const shape = physics.shape;
if (flock?.BABYLON?.PhysicsShapeCapsule && shape instanceof flock.BABYLON.PhysicsShapeCapsule)
return "CAPSULE";
if (flock?.BABYLON?.PhysicsShapeMesh && shape instanceof flock.BABYLON.PhysicsShapeMesh)
return "MESH";
return null;
};

const capturePhysicsState = (targetMesh) => ({
Expand Down Expand Up @@ -168,8 +166,18 @@ export const flockPhysics = {
Math.max(width, depth) / 2,
flock.scene,
);
} else if (flock?.BABYLON?.PhysicsShapeCapsule && physicsShape instanceof flock.BABYLON.PhysicsShapeCapsule) {
detectedShapeType = "CAPSULE";
newShape = createPhysicsShape(mesh, "CAPSULE");
if (!newShape) return;
} else if (flock?.BABYLON?.PhysicsShapeMesh && physicsShape instanceof flock.BABYLON.PhysicsShapeMesh) {
detectedShapeType = "MESH";
newShape = createPhysicsShape(mesh, "MESH");
if (!newShape) return;
} else {
detectedShapeType = getShapeTypeFromPhysics(parent.physics);
detectedShapeType =
getShapeTypeFromPhysics(parent.physics) ||
parent.metadata?.physicsShapeType;
if (!detectedShapeType) return;
newShape = createPhysicsShape(mesh, detectedShapeType);
if (!newShape) return;
Expand Down
Loading