update assetID
This commit is contained in:
@@ -40,16 +40,11 @@ export default function SocketResponses({
|
||||
floorPlanGroup,
|
||||
lines,
|
||||
floorGroup,
|
||||
floorGroupAisle,
|
||||
scene,
|
||||
onlyFloorlines,
|
||||
itemsGroup,
|
||||
isTempLoader,
|
||||
tempLoader,
|
||||
currentLayerPoint,
|
||||
floorPlanGroupPoint,
|
||||
floorPlanGroupLine,
|
||||
zoneGroup,
|
||||
dragPointControls,
|
||||
}: any) {
|
||||
const { socket } = useSocketStore();
|
||||
@@ -104,7 +99,7 @@ export default function SocketResponses({
|
||||
const asset: Asset = {
|
||||
modelUuid: data.data.modelUuid,
|
||||
modelName: data.data.modelName,
|
||||
assetId: data.data.modelfileID,
|
||||
assetId: data.data.assetId,
|
||||
position: data.data.position,
|
||||
rotation: [data.data.rotation.x, data.data.rotation.y, data.data.rotation.z],
|
||||
isLocked: data.data.isLocked,
|
||||
@@ -125,7 +120,7 @@ export default function SocketResponses({
|
||||
const asset: Asset = {
|
||||
modelUuid: data.data.modelUuid,
|
||||
modelName: data.data.modelName,
|
||||
assetId: data.data.modelfileID,
|
||||
assetId: data.data.assetId,
|
||||
position: data.data.position,
|
||||
rotation: [data.data.rotation.x, data.data.rotation.y, data.data.rotation.z],
|
||||
isLocked: data.data.isLocked,
|
||||
@@ -474,13 +469,14 @@ export default function SocketResponses({
|
||||
let url_Backend_dwinzo = `http://${process.env.REACT_APP_SERVER_MARKETPLACE_URL}`;
|
||||
|
||||
socket.on("v1:wallItem:Response:Delete", (data: any) => {
|
||||
// console.log('data: ', data);
|
||||
if (socket.id === data.socketId) {
|
||||
return;
|
||||
}
|
||||
if (organization !== data.organization) {
|
||||
return;
|
||||
}
|
||||
if (data.message === "wallitem deleted") {
|
||||
if (data.message === "wall Item deleted successfully") {
|
||||
const deletedUUID = data.data.modelUuid;
|
||||
let WallItemsRef = wallItems;
|
||||
const Items = WallItemsRef.filter((item: any) => item.model?.uuid !== deletedUUID);
|
||||
@@ -504,6 +500,7 @@ export default function SocketResponses({
|
||||
});
|
||||
|
||||
socket.on("v1:wallItems:Response:Update", (data: any) => {
|
||||
// console.log('data: ', data);
|
||||
//
|
||||
if (socket.id === data.socketId) {
|
||||
return;
|
||||
@@ -511,7 +508,7 @@ export default function SocketResponses({
|
||||
if (organization !== data.organization) {
|
||||
return;
|
||||
}
|
||||
if (data.message === "wallIitem created") {
|
||||
if (data.message === "wall Item created successfully") {
|
||||
const loader = new GLTFLoader();
|
||||
const dracoLoader = new DRACOLoader();
|
||||
|
||||
@@ -519,20 +516,20 @@ export default function SocketResponses({
|
||||
loader.setDRACOLoader(dracoLoader);
|
||||
|
||||
// Check THREE.js cache first
|
||||
const cachedModel = THREE.Cache.get(data.data.modelfileID);
|
||||
const cachedModel = THREE.Cache.get(data.data.assetId);
|
||||
if (cachedModel) {
|
||||
handleModelLoad(cachedModel);
|
||||
return;
|
||||
}
|
||||
|
||||
// Check IndexedDB cache
|
||||
retrieveGLTF(data.data.modelfileID).then((cachedModelBlob) => {
|
||||
retrieveGLTF(data.data.assetId).then((cachedModelBlob) => {
|
||||
if (cachedModelBlob) {
|
||||
const blobUrl = URL.createObjectURL(cachedModelBlob);
|
||||
loader.load(blobUrl, (gltf) => {
|
||||
URL.revokeObjectURL(blobUrl);
|
||||
THREE.Cache.remove(blobUrl);
|
||||
THREE.Cache.add(data.data.modelfileID, gltf);
|
||||
THREE.Cache.add(data.data.assetId, gltf);
|
||||
handleModelLoad(gltf);
|
||||
});
|
||||
return;
|
||||
@@ -540,11 +537,11 @@ export default function SocketResponses({
|
||||
})
|
||||
|
||||
// Load from backend if not in any cache
|
||||
loader.load(`${url_Backend_dwinzo}/api/v2/AssetFile/${data.data.modelfileID}`, async (gltf) => {
|
||||
loader.load(`${url_Backend_dwinzo}/api/v2/AssetFile/${data.data.assetId}`, async (gltf) => {
|
||||
try {
|
||||
const modelBlob = await fetch(`${url_Backend_dwinzo}/api/v2/AssetFile/${data.data.modelfileID}`).then((res) => res.blob());
|
||||
await storeGLTF(data.data.modelfileID, modelBlob);
|
||||
THREE.Cache.add(data.data.modelfileID, gltf);
|
||||
const modelBlob = await fetch(`${url_Backend_dwinzo}/api/v2/AssetFile/${data.data.assetId}`).then((res) => res.blob());
|
||||
await storeGLTF(data.data.assetId, modelBlob);
|
||||
THREE.Cache.add(data.data.assetId, gltf);
|
||||
await handleModelLoad(gltf);
|
||||
} catch (error) {
|
||||
|
||||
@@ -567,7 +564,7 @@ export default function SocketResponses({
|
||||
type: data.data.type,
|
||||
model: model,
|
||||
modelName: data.data.modelName,
|
||||
modelfileID: data.data.modelfileID,
|
||||
assetId: data.data.assetId,
|
||||
scale: data.data.scale,
|
||||
csgscale: data.data.csgscale,
|
||||
csgposition: data.data.csgposition,
|
||||
@@ -592,7 +589,7 @@ export default function SocketResponses({
|
||||
});
|
||||
}
|
||||
|
||||
} else if (data.message === "wallIitem updated") {
|
||||
} else if (data.message === "Updated successfully") {
|
||||
const updatedUUID = data.data.modelUuid;
|
||||
|
||||
setWallItems((prevItems: any) => {
|
||||
|
||||
Reference in New Issue
Block a user