Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Release/Fix] Replay sample mutation in interpolation fix #194

Merged
merged 3 commits into from
Dec 19, 2022
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
5 changes: 2 additions & 3 deletions app/components/viewer/ReplayCars.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -40,8 +40,7 @@ const ReplayCar = ({

const timeLineGlobal = GlobalTimeLineInfos.getInstance();

let curSample = replay.samples[0];
const smoothSample: ReplayDataPoint = { ...replay.samples[0] };
const smoothSample: ReplayDataPoint = replay.samples[0].clone();

// Get own material from loaded car model
const carMesh: THREE.Mesh = fbx.children[0] as THREE.Mesh;
Expand Down Expand Up @@ -71,7 +70,7 @@ const ReplayCar = ({
const hovered = timeLineGlobal.hoveredReplay != null && timeLineGlobal.hoveredReplay._id === replay._id;

// Get closest sample to TimeLine.currentRaceTime
curSample = getSampleNearTime(replay, timeLineGlobal.currentRaceTime);
const curSample = getSampleNearTime(replay, timeLineGlobal.currentRaceTime);

currentSampleRef.current = curSample;
prevSampleRef.current = replay.samples[replay.samples.indexOf(curSample) - 1];
Expand Down
10 changes: 10 additions & 0 deletions app/lib/replays/replayData.ts
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,16 @@ export class ReplayDataPoint {
const z = this.readFloat(dataView);
return new THREE.Vector3(x, y, z);
};

clone(): ReplayDataPoint {
return {
...this,
position: this.position.clone(),
velocity: this.velocity.clone(),
up: this.up.clone(),
dir: this.dir.clone(),
};
}
}

export interface DataViewResult {
Expand Down