Home > other >  Javascript implementation of camera roaming function?
Javascript implementation of camera roaming function?

Time:09-26

Copy of the c + + camera roaming algorithm on the net, to the javascript version of the function, is meant to a series of coordinate point div dots within the page [] {x: y:},... Processed into new point set to return to again appear, roaming the point/line effect, but not always, don't know where is wrong, please help to look at, thank you!!!!!!

The function levenshtein distance (dots) {//not to deal with?
Var lastX=400, lastY=300, firstMouse=true, yaw=0, pitch=0;
Var PTS=[];
For (var I=0; iVar pt=dots [I];
If (firstMouse) {
LastX=pt. X;
LastY=pt. Y;
FirstMouse=false;
}
Var xoffset=pt. X-ray lastX;
Var yoffset=lastY - pt. Y;
LastX=pt. X;
LastY=pt. Y;

Var sensitivity=0.05;
Xoffset *=sensitivity;
Yoffset *=sensitivity;
Yaw +=xoffset;
Pitch +=yoffset;

If (pitch & gt; 89.0)
Pitch=89.0;
If (pitch & lt; 89.0)
Pitch=89.0;

Var pt={x x: pt. * (1 + Math. Cos (yaw) * Math. Cos (pitch), y: pt. Y * (1 + Math. Sin (pitch), z: pt. Z * (1 + Math. Sin (yaw) * Math. Cos (pitch)};
PTS. Push (pt);
}
Return the PTS;
}

CodePudding user response:

There is no answer? If I understand it wrong?
Known to have a series of div pixels, I want to look from a different path is the path to the point, how should do?
  • Related