28 lines
1016 B
TypeScript
28 lines
1016 B
TypeScript
import { Socket } from "socket.io-client";
|
|
import * as THREE from 'three';
|
|
|
|
export default function updateCamPosition(
|
|
controls: any,
|
|
socket: Socket,
|
|
position: THREE.Vector3,
|
|
rotation: THREE.Euler,
|
|
projectId?:string
|
|
) {
|
|
if (!controls.current) return;
|
|
const target = controls.current.getTarget(new THREE.Vector3());
|
|
const email = localStorage.getItem("email");
|
|
const organization = email!.split("@")[1].split(".")[0];
|
|
|
|
const camData = {
|
|
organization: organization,
|
|
userId: localStorage.getItem("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);
|
|
localStorage.setItem("cameraPosition", JSON.stringify(position));
|
|
localStorage.setItem("controlTarget", JSON.stringify(new THREE.Vector3(target.x, 0, target.z)));
|
|
} |