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,7 +18,7 @@
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 ||
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 Expand Up @@ -1340,7 +1340,7 @@
if (!animName || !scene)
return { name: null, isLooping: false, isPlaying: false };

// Your groups are named like `${mesh.name}.${animName}`
// groups are named like `${mesh.name}.${animName}`
const expectedGroupName = `${mesh.name}.${animName}`;

const group =
Expand Down
8 changes: 3 additions & 5 deletions api/camera.js
Original file line number Diff line number Diff line change
Expand Up @@ -199,12 +199,12 @@ export const flockCamera = {
}
}

// position the anchor under the mesh so it doesn’t introduce sideways torque
// position the anchor under the mesh out of the way
const meshWorldPos = mesh.getAbsolutePosition
? mesh.getAbsolutePosition()
: mesh.position.clone();
constraintBox.position.copyFrom(meshWorldPos);
constraintBox.position.y += -4; // keep your original -4 offset
constraintBox.position.y += -4; // keep original -4 offset
constraintBox.computeWorldMatrix(true);

if (constraintBox.physics) {
Expand Down Expand Up @@ -261,14 +261,12 @@ export const flockCamera = {
)
return;
try {
// preserve Y motion; zero X/Z linear velocity *only if you really want to block sliding*.
// If sideways walking causes spin, comment the next two lines so movement isn't fighting physics.
// preserve Y motion; zero X/Z linear velocity
const v = mesh.physics.getLinearVelocity();
mesh.physics.setLinearVelocity(
new flock.BABYLON.Vector3(0, v.y, 0),
);

// keep yaw free; kill roll/pitch
mesh.physics.setAngularVelocity(new flock.BABYLON.Vector3(0, 0, 0));
} catch (err) {
console.warn("Physics body became invalid:", err);
Expand Down
2 changes: 1 addition & 1 deletion api/csg.js
Original file line number Diff line number Diff line change
Expand Up @@ -640,7 +640,7 @@ export const flockCSG = {
return resolve(null);
}

// Align pivot and position (Maintain your original behavior)
// Align pivot and position
const localCenter = resultMesh
.getBoundingInfo()
.boundingBox.center.clone();
Expand Down
4 changes: 1 addition & 3 deletions api/material.js
Original file line number Diff line number Diff line change
Expand Up @@ -354,7 +354,7 @@ export const flockMaterial = {

// Helper function to copy color properties from PBR to Standard material
const copyColorProperties = (pbrMaterial, standardMaterial) => {
// Check for albedoColor first (as seen in your debug output)
// Check for albedoColor first
if (pbrMaterial.albedoColor) {
standardMaterial.diffuseColor = pbrMaterial.albedoColor.clone();
}
Expand Down Expand Up @@ -1561,8 +1561,6 @@ export const flockMaterial = {
const texName = String(getTexName(v));
const alpha = getAlpha(v);

// This matches your existing cache key convention closely while also
// respecting alpha when it’s provided via descriptor or opts.
return `mat_${resolvedHex.toLowerCase()}_${alpha}_${texName}`.toLowerCase();
};

Expand Down
1 change: 0 additions & 1 deletion api/mesh.js
Original file line number Diff line number Diff line change
Expand Up @@ -164,7 +164,6 @@ export const flockMesh = {
return shape;
},
// backRatio: signed fraction of mesh size along the chosen axis (e.g., 0.25 = 25% back; -0.25 = 25% forward)
// axis: "z" (default) if your rig faces ±Z; use "x" if it faces ±X
createSittingCapsuleFromBoundingBox(
mesh,
scene,
Expand Down
8 changes: 4 additions & 4 deletions api/physics.js
Original file line number Diff line number Diff line change
Expand Up @@ -216,6 +216,7 @@ export const flockPhysics = {
mesh.computeWorldMatrix(true);
});
});
return beforePhysicsObserver;
},
up(meshName, upForce = 10) {
const mesh = flock.scene.getMeshByName(meshName);
Expand Down Expand Up @@ -346,7 +347,7 @@ export const flockPhysics = {
const applyMeshPhysicsShape = (targetMesh) => {
const { motionType, disablePreStep } =
capturePhysicsState(targetMesh);
// Keep your original material gate

if (!targetMesh.material) {
disposePhysics(targetMesh);
return;
Expand Down Expand Up @@ -549,7 +550,7 @@ export const flockPhysics = {
await executeAction(meshId);
});

// 👓 Re-integrating your XR Logic
// XR case
if (flock.xrHelper && flock.xrHelper.baseExperience) {
flock.xrHelper.baseExperience.onStateChangedObservable.add(
(state) => {
Expand Down Expand Up @@ -805,9 +806,8 @@ export const flockPhysics = {
} catch (_) {}
});

// If the caller asked for a specific trigger callback semantics (e.g. Exit),
// If the caller asks for a specific trigger callback semantics (e.g. Exit),
// also register their requested trigger to invoke the callback directly.
// This preserves your original API behavior.
if (
trigger &&
B.ActionManager[trigger] &&
Expand Down
1 change: 0 additions & 1 deletion api/sensing.js
Original file line number Diff line number Diff line change
Expand Up @@ -169,7 +169,6 @@ export const flockSensing = {
propertyValue = mesh.isEnabled() && mesh.isVisible;
break;

// Leaving colour-related logic as-is for now, per your request.
case "ALPHA":
allMeshes = [mesh].concat(mesh.getDescendants?.() ?? []);
materialNode = allMeshes.find((node) => node.material);
Expand Down
1 change: 0 additions & 1 deletion api/transform.js
Original file line number Diff line number Diff line change
Expand Up @@ -866,7 +866,6 @@ export const flockTransform = {
wmBefore,
);

// Apply new pivot to mesh (and children, per your existing behavior)
mesh.setPivotPoint(newPivotLocal);
mesh
.getChildMeshes()
Expand Down
Loading