first commit

This commit is contained in:
2025-06-10 15:28:23 +05:30
commit e22a2dc275
699 changed files with 100382 additions and 0 deletions

View File

@@ -0,0 +1,35 @@
let url_Backend_dwinzo = `http://${process.env.REACT_APP_SERVER_REST_API_BASE_URL}`;
export const createAisleApi = async (
aisleUuid: string,
points: any,
type: Object,
projectId: string
) => {
try {
const response = await fetch(`${url_Backend_dwinzo}/api/V1/UpsertAisle`, {
method: "POST",
headers: {
Authorization: "Bearer <access_token>", // Replace with actual token
"Content-Type": "application/json",
token: localStorage.getItem("token") || "", // Coerce null to empty string
refresh_token: localStorage.getItem("refreshToken") || "",
},
body: JSON.stringify({ aisleUuid, points, type, projectId }),
});
if (!response.ok) {
throw new Error("Failed to add project");
}
const result = await response.json();
// console.log("result: ", result);
return result;
} catch (error) {
if (error instanceof Error) {
throw new Error(error.message);
} else {
throw new Error("An unknown error occurred");
}
}
};

View File

@@ -0,0 +1,29 @@
let url_Backend_dwinzo = `http://${process.env.REACT_APP_SERVER_REST_API_BASE_URL}`;
export const deleteAisleApi = async (aisleUuid: string, projectId: string) => {
try {
const response = await fetch(`${url_Backend_dwinzo}/api/V1/DeleteAisle`, {
method: "PATCH",
headers: {
Authorization: "Bearer <access_token>", // Replace with actual token
"Content-Type": "application/json",
token: localStorage.getItem("token") || "", // Coerce null to empty string
refresh_token: localStorage.getItem("refreshToken") || "",
},
body: JSON.stringify({ aisleUuid, projectId }),
});
if (!response.ok) {
throw new Error("Failed to clearPanel in the zone");
}
const result = await response.json();
// console.log('result: ', result);
return result;
} catch (error) {
if (error instanceof Error) {
throw new Error(error.message);
} else {
throw new Error("An unknown error occurred");
}
}
};

View File

@@ -0,0 +1,28 @@
let url_Backend_dwinzo = `http://${process.env.REACT_APP_SERVER_REST_API_BASE_URL}`;
export const getAisleApi = async (projectId: string) => {
try {
const response = await fetch(
`${url_Backend_dwinzo}/api/V1/Aisles/${projectId}`,
{
method: "GET",
headers: {
Authorization: "Bearer <access_token>", // Replace with actual token
"Content-Type": "application/json",
token: localStorage.getItem("token") || "", // Coerce null to empty string
refresh_token: localStorage.getItem("refreshToken") || "",
},
}
);
// console.log("response: ", response);
if (!response.ok) {
throw new Error("Failed to fetch");
}
return await response.json();
} catch (error: any) {
console.error("Failed to get asset image:", error);
throw new Error(error.message);
}
};

View File

@@ -0,0 +1,24 @@
let url_Backend_dwinzo = `http://${process.env.REACT_APP_SERVER_MARKETPLACE_URL}`;
export const getAssetImages = async (cursor?: string) => {
try {
const response = await fetch(
`${url_Backend_dwinzo}/api/v3/AssetDatas?limit=10${cursor ? `&cursor=${cursor}` : ""}`,
{
method: "GET",
headers: {
"Content-Type": "application/json",
},
}
);
if (!response.ok) {
throw new Error("Failed to fetch assets");
}
return await response.json();
} catch (error: any) {
echo.error("Failed to get asset image");
throw new Error(error.message);
}
};

View File

@@ -0,0 +1,29 @@
let url_Backend_dwinzo = `http://${process.env.REACT_APP_SERVER_MARKETPLACE_URL}`;
export const getAssetModel = async (modelId: string) => {
try {
const response = await fetch(
`${url_Backend_dwinzo}/api/v2/AssetFile/${modelId}`,
{
method: "GET",
headers: {
"Content-Type": "application/json",
},
}
);
if (!response.ok) {
throw new Error("Failed to fetch model");
}
const result = await response.json();
return result;
} catch (error) {
echo.error("Failed to get asset model");
if (error instanceof Error) {
throw new Error(error.message);
} else {
throw new Error("An unknown error occurred");
}
}
};

View File

@@ -0,0 +1,20 @@
let BackEnd_url = `http://${process.env.REACT_APP_SERVER_MARKETPLACE_URL}`;
export const getCategoryAsset = async (categoryName: any) => {
try {
const response = await fetch(
`${BackEnd_url}/api/v2/getCategoryAssets/${categoryName}`,
{
method: "GET",
headers: {
"Content-Type": "application/json",
},
}
);
const result = await response.json();
return result;
} catch (error: any) {
echo.error("Failed to get category asset");
throw new Error(error.message);
}
};

View File

@@ -0,0 +1,34 @@
let url_Backend_dwinzo = `http://${process.env.REACT_APP_SERVER_REST_API_BASE_URL}`;
export const deleteFloorItem = async (
organization: string,
modelUuid: string,
modelName: string
) => {
try {
const response = await fetch(
`${url_Backend_dwinzo}/api/v1/deletefloorItem`,
{
method: "DELETE",
headers: {
"Content-Type": "application/json",
},
body: JSON.stringify({ organization, modelUuid, modelName }),
}
);
if (!response.ok) {
throw new Error("Failed to delete Floor Item");
}
const result = await response.json();
return result;
} catch (error) {
echo.error("Failed to delete floor item");
if (error instanceof Error) {
throw new Error(error.message);
} else {
throw new Error("An unknown error occurred");
}
}
};

View File

@@ -0,0 +1,35 @@
let url_Backend_dwinzo = `http://${process.env.REACT_APP_SERVER_REST_API_BASE_URL}`;
export const getFloorAssets = async (organization: string,projectId?:string) => {
try {
const response = await fetch(
`${url_Backend_dwinzo}/api/V1/floorAssets/${projectId}`,
{
method: "GET",
headers: {
Authorization: "Bearer <access_token>",
"Content-Type": "application/json",
token: localStorage.getItem("token") || "",
refresh_token: localStorage.getItem("refreshToken") || "",
},
}
);
// console.log('response: ', response);
if (!response.ok) {
throw new Error("Failed to get assets");
}
const result = await response.json();
// console.log('result: ', result);
return result;
} catch (error) {
echo.error("Failed to get floor asset");
if (error instanceof Error) {
throw new Error(error.message);
} else {
throw new Error("An unknown error occurred");
}
}
};

View File

@@ -0,0 +1,49 @@
let url_Backend_dwinzo = `http://${process.env.REACT_APP_SERVER_REST_API_BASE_URL}`;
export const setFloorItemApi = async (
organization: string,
modelUuid?: string,
modelName?: string,
modelfileID?: string,
position?: Object,
rotation?: Object,
isLocked?: boolean,
isVisible?: boolean
) => {
try {
const body: any = {
organization,
modelUuid,
modelName,
position,
rotation,
modelfileID,
isLocked,
isVisible,
};
const response = await fetch(`${url_Backend_dwinzo}/api/V1/setAsset`, {
method: "POST",
headers: {
Authorization: "Bearer <access_token>",
"Content-Type": "application/json",
token: localStorage.getItem("token") || "",
refresh_token: localStorage.getItem("refreshToken") || "",
},
body: JSON.stringify(body),
});
if (!response.ok) {
throw new Error("Failed to set or update Floor Item");
}
const result = await response.json();
return result;
} catch (error) {
echo.error("Failed to set floor items");
if (error instanceof Error) {
throw new Error(error.message);
} else {
throw new Error("An unknown error occurred");
}
}
};

View File

@@ -0,0 +1,34 @@
let url_Backend_dwinzo = `http://${process.env.REACT_APP_SERVER_REST_API_BASE_URL}`;
export const deleteWallItem = async (
organization: string,
modelUuid: string,
modelName: string
) => {
try {
const response = await fetch(
`${url_Backend_dwinzo}/api/v1/deleteWallItem`,
{
method: "DELETE",
headers: {
"Content-Type": "application/json",
},
body: JSON.stringify({ organization, modelUuid, modelName }),
}
);
if (!response.ok) {
throw new Error("Failed to delete Wall Item");
}
const result = await response.json();
return result;
} catch (error) {
echo.error("Failed to delete wall items");
if (error instanceof Error) {
throw new Error(error.message);
} else {
throw new Error("An unknown error occurred");
}
}
};

View File

@@ -0,0 +1,34 @@
let url_Backend_dwinzo = `http://${process.env.REACT_APP_SERVER_REST_API_BASE_URL}`;
export const getWallItems = async (organization: string,projectId?:string) => {
try {
const response = await fetch(
`${url_Backend_dwinzo}/api/V1/walls/${projectId}`,
{
method: "GET",
headers: {
Authorization: "Bearer <access_token>",
"Content-Type": "application/json",
token: localStorage.getItem("token") || "",
refresh_token: localStorage.getItem("refreshToken") || "",
},
}
);
// console.log('response: ', response);
if (!response.ok) {
throw new Error("Failed to get Wall Items");
}
const result = await response.json();
// console.log('result: ', result);
return result;
} catch (error) {
echo.error("Failed to get wall items");
if (error instanceof Error) {
throw new Error(error.message);
} else {
throw new Error("An unknown error occurred");
}
}
};

View File

@@ -0,0 +1,47 @@
let url_Backend_dwinzo = `http://${process.env.REACT_APP_SERVER_REST_API_BASE_URL}`;
export const setWallItem = async (
organization: string,
modelUuid: string,
modelName: string,
type: string,
csgposition: Object,
csgscale: Object,
position: Object,
quaternion: Object,
scale: Object
) => {
try {
const response = await fetch(`${url_Backend_dwinzo}/api/v1/setWallItems`, {
method: "POST",
headers: {
"Content-Type": "application/json",
},
body: JSON.stringify({
organization,
modelUuid,
modelName,
position,
type,
csgposition,
csgscale,
quaternion,
scale,
}),
});
if (!response.ok) {
throw new Error("Failed to set or update Wall Item");
}
const result = await response.json();
return result;
} catch (error) {
echo.error("Failed to set wall items");
if (error instanceof Error) {
throw new Error(error.message);
} else {
throw new Error("An unknown error occurred");
}
}
};

View File

@@ -0,0 +1,36 @@
let url_Backend_dwinzo = `http://${process.env.REACT_APP_SERVER_REST_API_BASE_URL}`;
export const getCamera = async (organization: string, userId: string, projectId?: string) => {
try {
const response = await fetch(
`${url_Backend_dwinzo}/api/V1/cameras/${projectId}`,
{
method: "GET",
headers: {
Authorization: "Bearer <access_token>",
"Content-Type": "application/json",
token: localStorage.getItem("token") || "",
refresh_token: localStorage.getItem("refreshToken") || "",
},
}
);
if (!response.ok) {
throw new Error("Failed to get Camera position and target");
}
const result = await response.json();
if (result === "user not found") {
return null;
} else {
return result;
}
} catch (error) {
echo.error("Failed to get camera");
if (error instanceof Error) {
throw new Error(error.message);
} else {
throw new Error("An unknown error occurred");
}
}
};

View File

@@ -0,0 +1,39 @@
let url_Backend_dwinzo = `http://${process.env.REACT_APP_SERVER_REST_API_BASE_URL}`;
export const setCamera = async (
organization: string,
userId: string,
position: Object,
target: Object,
rotation: Object
) => {
try {
const response = await fetch(`${url_Backend_dwinzo}/api/v1/setCamera`, {
method: "POST",
headers: {
"Content-Type": "application/json",
},
body: JSON.stringify({
organization,
userId,
position,
target,
rotation,
}),
});
if (!response.ok) {
throw new Error("Failed to set Camera Position and Target");
}
const result = await response.json();
return result;
} catch (error) {
echo.error("Failed to set camera");
if (error instanceof Error) {
throw new Error(error.message);
} else {
throw new Error("An unknown error occurred");
}
}
};

View File

@@ -0,0 +1,32 @@
let url_Backend_dwinzo = `http://${process.env.REACT_APP_SERVER_REST_API_BASE_URL}`;
export default async function getActiveUsersData(organization: string) {
const apiUrl = `${url_Backend_dwinzo}/api/v1/activeCameras/${organization}`;
try {
const response = await fetch(apiUrl, {
method: "GET",
headers: {
"Content-Type": "application/json",
},
});
if (!response.ok) {
throw new Error(`Error: ${response.status} - ${response.statusText}`);
}
if (!response.ok) {
throw new Error("Failed to get active cameras ");
}
const result = await response.json();
return result;
} catch (error) {
echo.error("Failed to get active users");
if (error instanceof Error) {
throw new Error(error.message);
} else {
throw new Error("An unknown error occurred");
}
}
}

View File

@@ -0,0 +1,32 @@
let url_Backend_dwinzo = `http://${process.env.REACT_APP_SERVER_REST_API_BASE_URL}`;
export default async function fetchShareUsers(organization: string) {
const apiUrl = `${url_Backend_dwinzo}/api/v1/findshareUsers?organization=${organization}`;
try {
const response = await fetch(apiUrl, {
method: "GET",
headers: {
"Content-Type": "application/json",
},
});
if (!response.ok) {
throw new Error(`Error: ${response.status} - ${response.statusText}`);
}
if (!response.ok) {
throw new Error("Failed to get users ");
}
const result = await response.json();
return result;
} catch (error) {
echo.error("Failed to get user API");
if (error instanceof Error) {
throw new Error(error.message);
} else {
throw new Error("An unknown error occurred");
}
}
}

View File

@@ -0,0 +1,31 @@
let url_Backend_dwinzo = `http://${process.env.REACT_APP_SERVER_REST_API_BASE_URL}`;
export default async function giveCollabAccess(
email: string,
isShare: boolean,
organization: string
) {
try {
const response = await fetch(`${url_Backend_dwinzo}/api/v1/shareUser`, {
method: "POST",
headers: {
"Content-Type": "application/json",
},
body: JSON.stringify({ email, isShare, organization }),
});
if (!response.ok) {
throw new Error("Failed to set Camera Position and Target");
}
const result = await response.json();
return result;
} catch (error) {
echo.error("Failed to give collab access");
if (error instanceof Error) {
throw new Error(error.message);
} else {
throw new Error("An unknown error occurred");
}
}
}

View File

@@ -0,0 +1,34 @@
let url_Backend_dwinzo = `http://${process.env.REACT_APP_SERVER_REST_API_BASE_URL}`;
export const findEnvironment = async (organization: string, userId: string, projectId?: string) => {
try {
const response = await fetch(
`${url_Backend_dwinzo}/api/V1/Environments/${projectId}`,
{
method: "GET",
headers: {
Authorization: "Bearer <access_token>",
"Content-Type": "application/json",
token: localStorage.getItem("token") || "",
refresh_token: localStorage.getItem("refreshToken") || "",
},
}
);
if (!response.ok) {
throw new Error("Failed to get wall and roof visibility");
}
const result = await response.json();
return result;
} catch (error) {
echo.error("Failed to find env");
if (error instanceof Error) {
throw new Error(error.message);
} else {
throw new Error("An unknown error occurred");
}
}
};

View File

@@ -0,0 +1,54 @@
let url_Backend_dwinzo = `http://${process.env.REACT_APP_SERVER_REST_API_BASE_URL}`;
export const setEnvironment = async (
organization: string,
userId: string,
wallVisibility: boolean,
roofVisibility: boolean,
shadowVisibility: boolean,
renderDistance: number,
limitDistance: boolean,
projectId?: string
) => {
try {
const response = await fetch(
`${url_Backend_dwinzo}/api/V1/SetEnvironments`,
{
method: "POST",
headers: {
Authorization: "Bearer <access_token>",
"Content-Type": "application/json",
token: localStorage.getItem("token") || "",
refresh_token: localStorage.getItem("refreshToken") || "",
},
body: JSON.stringify({
organization,
userId,
wallVisibility,
roofVisibility,
shadowVisibility,
renderDistance,
limitDistance,
projectId
}),
}
);
// console.log('responseenv: ', response);
if (!response.ok) {
throw new Error("Failed to set wall and roof visibility");
}
const result = await response.json();
// console.log('resultsetenv: ', result);
return result;
} catch (error) {
echo.error("Failed to set env");
if (error instanceof Error) {
throw new Error(error.message);
} else {
throw new Error("An unknown error occurred");
}
}
};

View File

@@ -0,0 +1,27 @@
let url_Backend_dwinzo = `http://${process.env.REACT_APP_SERVER_REST_API_BASE_URL}`;
export const deleteLayer = async (organization: string, layer: number) => {
try {
const response = await fetch(`${url_Backend_dwinzo}/api/v1/deleteLayer`, {
method: "POST",
headers: {
"Content-Type": "application/json",
},
body: JSON.stringify({ organization, layer }),
});
if (!response.ok) {
throw new Error("Failed to delete line");
}
const result = await response.json();
return result;
} catch (error) {
echo.error("Failed to delete line");
if (error instanceof Error) {
throw new Error(error.message);
} else {
throw new Error("An unknown error occurred");
}
}
};

View File

@@ -0,0 +1,27 @@
let url_Backend_dwinzo = `http://${process.env.REACT_APP_SERVER_REST_API_BASE_URL}`;
export const deleteLineApi = async (organization: string, line: Object) => {
try {
const response = await fetch(`${url_Backend_dwinzo}/api/v1/deleteLine`, {
method: "DELETE",
headers: {
"Content-Type": "application/json",
},
body: JSON.stringify({ organization, line }),
});
if (!response.ok) {
throw new Error("Failed to delete line");
}
const result = await response.json();
return result;
} catch (error) {
echo.error("Failed to delete line");
if (error instanceof Error) {
throw new Error(error.message);
} else {
throw new Error("An unknown error occurred");
}
}
};

View File

@@ -0,0 +1,27 @@
let url_Backend_dwinzo = `http://${process.env.REACT_APP_SERVER_REST_API_BASE_URL}`;
export const deletePointApi = async (organization: string, uuid: string) => {
try {
const response = await fetch(`${url_Backend_dwinzo}/api/v1/deletePoint`, {
method: "DELETE",
headers: {
"Content-Type": "application/json",
},
body: JSON.stringify({ organization, uuid }),
});
if (!response.ok) {
throw new Error("Failed to delete point");
}
const result = await response.json();
return result;
} catch (error) {
echo.error("Failed to delete point");
if (error instanceof Error) {
throw new Error(error.message);
} else {
throw new Error("An unknown error occurred");
}
}
};

View File

@@ -0,0 +1,33 @@
let url_Backend_dwinzo = `http://${process.env.REACT_APP_SERVER_REST_API_BASE_URL}`;
export const getLines = async (organization: string,projectId?:string) => {
try {
const response = await fetch(
`${url_Backend_dwinzo}/api/V1/lines/${projectId}`,
{
method: "GET",
headers: {
Authorization: "Bearer <access_token>",
"Content-Type": "application/json",
token: localStorage.getItem("token") || "",
refresh_token: localStorage.getItem("refreshToken") || "",
},
}
);
if (!response.ok) {
throw new Error("Failed to get Lines");
}
const result = await response.json();
// console.log('result: ', result);
return result;
} catch (error) {
echo.error("Failed to get Lines");
if (error instanceof Error) {
throw new Error(error.message);
} else {
throw new Error("An unknown error occurred");
}
}
};

View File

@@ -0,0 +1,32 @@
let url_Backend_dwinzo = `http://${process.env.REACT_APP_SERVER_REST_API_BASE_URL}`;
export const setLine = async (
organization: string,
layer: number,
line: Object,
type: string
) => {
try {
const response = await fetch(`${url_Backend_dwinzo}/api/v1/setLine`, {
method: "POST",
headers: {
"Content-Type": "application/json",
},
body: JSON.stringify({ organization, layer, line, type }),
});
if (!response.ok) {
throw new Error("Failed to set line");
}
const result = await response.json();
return result;
} catch (error) {
echo.error("Failed to set line");
if (error instanceof Error) {
throw new Error(error.message);
} else {
throw new Error("An unknown error occurred");
}
}
};

View File

@@ -0,0 +1,31 @@
let url_Backend_dwinzo = `http://${process.env.REACT_APP_SERVER_REST_API_BASE_URL}`;
export const updatePoint = async (
organization: string,
position: Object,
uuid: string
) => {
try {
const response = await fetch(`${url_Backend_dwinzo}/api/v1/updatePoint`, {
method: "POST",
headers: {
"Content-Type": "application/json",
},
body: JSON.stringify({ organization, position, uuid }),
});
if (!response.ok) {
throw new Error("Failed to update point");
}
const result = await response.json();
return result;
} catch (error) {
echo.error("Failed to update point");
if (error instanceof Error) {
throw new Error(error.message);
} else {
throw new Error("An unknown error occurred");
}
}
};

View File

@@ -0,0 +1,45 @@
import React, { useEffect } from "react";
import mqtt from "mqtt";
import { useDrieUIValue } from "../../../store/builder/store";
const MqttEvents = () => {
const { setTouch, setTemperature, setHumidity } = useDrieUIValue();
useEffect(() => {
// const client = mqtt.connect(`ws://${process.env.REACT_APP_SERVER_MQTT_URL}`);
// client.subscribe("touch");
// client.subscribe("temperature");
// client.subscribe("humidity");
// const handleMessage = (topic: string, message: any) => {
// const value = message.toString();
// if (topic === "touch") {
// setTouch(value);
// } else if (topic === "temperature") {
// setTemperature(parseFloat(value));
// } else if (topic === "humidity") {
// setHumidity(parseFloat(value));
// }
// };
// client.on("message", handleMessage);
// client.on("error", (err) => {
// console.error("MQTT Connection Error:", err);
// });
// client.on("close", () => {
// console.log("MQTT Connection Closed");
// });
// return () => {
// client.end();
// };
}, [setTouch, setTemperature, setHumidity]);
return null;
};
export default MqttEvents;

View File

@@ -0,0 +1,22 @@
let url_Backend_dwinzo = `http://${process.env.REACT_APP_SERVER_REST_API_BASE_URL}`;
export const signInApi = async (Email: string, Password: Object, organization: Object, fingerprint: any) => {
try {
const response = await fetch(`${url_Backend_dwinzo}/api/V1/Auth/login`, {
method: "POST",
headers: { "Content-Type": "application/json", },
body: JSON.stringify({ Email, Password, organization, fingerprint }),
});
const result = await response.json();
return result;
} catch (error) {
echo.error("Failed to sign-in");
if (error instanceof Error) {
return { error: error.message };
} else {
return { error: "An unknown error occurred" };
}
}
};

View File

@@ -0,0 +1,30 @@
let url_Backend_dwinzo = `http://${process.env.REACT_APP_SERVER_REST_API_BASE_URL}`;
export const signUpApi = async (
userName: string,
Email: string,
Password: Object,
organization: Object
) => {
try {
const response = await fetch(`${url_Backend_dwinzo}/api/V1/Auth/signup`, {
method: "POST",
headers: { "Content-Type": "application/json", },
body: JSON.stringify({ userName, Email, Password, organization }),
});
if (!response.ok) {
throw new Error("Failed to signUpApi");
}
const result = await response.json();
return result;
} catch (error) {
echo.error("Failed to sign-up");
if (error instanceof Error) {
throw new Error(error.message);
} else {
throw new Error("An unknown error occurred");
}
}
};

View File

@@ -0,0 +1,41 @@
import * as THREE from 'three';
import { GLTFLoader } from 'three/examples/jsm/loaders/GLTFLoader';
import { DRACOLoader } from 'three/examples/jsm/loaders/DRACOLoader';
import { retrieveGLTF, storeGLTF } from '../../../utils/indexDB/idbUtils';
const loader = new GLTFLoader();
const dracoLoader = new DRACOLoader();
dracoLoader.setDecoderPath('https://cdn.jsdelivr.net/npm/three@0.160.0/examples/jsm/libs/draco/gltf/');
loader.setDRACOLoader(dracoLoader);
let url_Backend_dwinzo = `http://${process.env.REACT_APP_SERVER_MARKETPLACE_URL}`;
onmessage = async (event) => {
const { floorItems } = event.data;
const uniqueItems = floorItems.filter((item, index, self) =>
index === self.findIndex((t) => t.modelfileID === item.modelfileID)
);
for (const item of uniqueItems) {
if(item.modelfileID === null || item.modelfileID === undefined) {
continue; // Skip items without a valid modelfileID
}
const modelID = item.modelfileID;
const indexedDBModel = await retrieveGLTF(modelID);
let modelBlob;
if (indexedDBModel) {
modelBlob = indexedDBModel;
const message = "gltfLoaded";
postMessage({ message, modelID, modelBlob });
} else {
const modelUrl = `${url_Backend_dwinzo}/api/v2/AssetFile/${modelID}`;
const modelBlob = await fetch(modelUrl).then((res) => res.blob());
await storeGLTF(modelID, modelBlob);
const message = "gltfLoaded";
postMessage({ message, modelID, modelBlob });
}
}
postMessage({ message: 'done' })
};

View File

@@ -0,0 +1,11 @@
import * as THREE from 'three';
onmessage = (event) => {
const { controlsTarget, sunPosition, offsetDistance } = event.data;
const lightPosition = new THREE.Vector3()
.copy(controlsTarget)
.addScaledVector(new THREE.Vector3().copy(sunPosition).normalize(), offsetDistance);
postMessage({ lightPosition, controlsTarget });
};

View File

@@ -0,0 +1,32 @@
let url_Backend_dwinzo = `http://${process.env.REACT_APP_SERVER_REST_API_BASE_URL}`;
export const deleteZonesApi = async (
userId: string,
organization: string,
zoneUuid: string
) => {
try {
const response = await fetch(`${url_Backend_dwinzo}/api/v1/setLine`, {
method: "POST",
headers: {
"Content-Type": "application/json",
},
body: JSON.stringify({ userId, organization, zoneUuid }),
});
if (!response.ok) {
throw new Error("Failed to delete zone");
}
const result = await response.json();
return result;
} catch (error) {
echo.error("Failed to delete zone");
if (error instanceof Error) {
throw new Error(error.message);
} else {
throw new Error("An unknown error occurred");
}
}
};

View File

@@ -0,0 +1,35 @@
let url_Backend_dwinzo = `http://${process.env.REACT_APP_SERVER_REST_API_BASE_URL}`;
// let url_Backend_dwinzo = `http://192.168.0.102:5000`;
export const getZonesApi = async (organization: string, projectId?: string) => {
try {
const response = await fetch(
`${url_Backend_dwinzo}/api/V1/zones/${projectId}`,
{
method: "GET",
headers: {
Authorization: "Bearer <access_token>",
"Content-Type": "application/json",
token: localStorage.getItem("token") || "",
refresh_token: localStorage.getItem("refreshToken") || "",
},
}
);
if (!response.ok) {
throw new Error("Failed to get Zones");
}
const result = await response.json();
// console.log('result:zone ', result);
return result;
} catch (error) {
echo.error("Failed to get zone data");
if (error instanceof Error) {
throw new Error(error.message);
} else {
throw new Error("An unknown error occurred");
}
}
};

View File

@@ -0,0 +1,31 @@
let url_Backend_dwinzo = `http://${process.env.REACT_APP_SERVER_REST_API_BASE_URL}`;
export const setZonesApi = async (
userId: string,
organization: string,
zoneData: any
) => {
try {
const response = await fetch(`${url_Backend_dwinzo}/api/v1/setLine`, {
method: "POST",
headers: {
"Content-Type": "application/json",
},
body: JSON.stringify({ userId, organization, zoneData }),
});
if (!response.ok) {
throw new Error("Failed to set zone");
}
const result = await response.json();
return result;
} catch (error) {
echo.error("Failed to zone data");
if (error instanceof Error) {
throw new Error(error.message);
} else {
throw new Error("An unknown error occurred");
}
}
};