Files
Dwinzo_Demo/app/src/modules/scene/camera/updateCameraPosition.ts

27 lines
762 B
TypeScript
Raw Normal View History

2025-06-10 15:28:23 +05:30
import { Socket } from "socket.io-client";
2025-06-23 09:37:53 +05:30
import * as THREE from "three";
import { getUserData } from "../../../functions/getUserData";
2025-06-10 15:28:23 +05:30
export default function updateCamPosition(
2025-06-23 09:37:53 +05:30
controls: any,
socket: Socket,
position: THREE.Vector3,
rotation: THREE.Euler,
projectId?: string
2025-06-10 15:28:23 +05:30
) {
2025-06-23 09:37:53 +05:30
const { userId, organization } = getUserData();
if (!controls.current) return;
const target = controls.current.getTarget(new THREE.Vector3());
2025-06-10 15:28:23 +05:30
2025-06-23 09:37:53 +05:30
const camData = {
organization,
userId: userId,
position: position,
target: new THREE.Vector3(target.x, 0, target.z),
rotation: new THREE.Vector3(rotation.x, rotation.y, rotation.z),
socketId: socket.id,
projectId,
};
socket.emit("v1:Camera:set", camData);
}