lingo3d
Version:
Lingo3D is a React/Vue 3d game development framework that ships with a complete visual editor
21 lines • 1.01 kB
JavaScript
import { vertexAngle, Point, rotatePoint } from "@lincode/math";
import { fpsRatioPtr } from "../pointers/fpsRatioPtr";
import createInternalSystem from "./utils/createInternalSystem";
import { configPhysicsSystem } from "./configLoadedSystems/configPhysicsSystem";
export const moveToSystem = createInternalSystem("moveToSystem", {
data: {},
update: (self, data) => {
self.x += data.sx * fpsRatioPtr[0];
if (data.y !== undefined)
self.y += data.sy * fpsRatioPtr[0];
self.z += data.sz * fpsRatioPtr[0];
const angle = vertexAngle(new Point(self.x, self.z), new Point(data.x, data.z), new Point(self.x, data.z));
const rotated = rotatePoint(new Point(data.x, data.z), new Point(self.x, self.z), data.quad === 1 || data.quad === 4 ? angle : -angle);
if (data.z > rotated.y) {
moveToSystem.delete(self);
self.onMoveToEnd?.();
}
configPhysicsSystem.add(self);
}
});
//# sourceMappingURL=moveToSystem.js.map