feat: add decal library URL and update related components for decal handling
This commit is contained in:
3
app/.env
3
app/.env
@@ -13,6 +13,9 @@ REACT_APP_SERVER_MARKETPLACE_URL=185.100.212.76:50011
|
||||
# Base URL for the asset library server, used for asset library images and model blob id.
|
||||
REACT_APP_SERVER_ASSET_LIBRARY_URL=185.100.212.76:50011
|
||||
|
||||
# Base URL for the decal library server, used for decal library images and model blob id.
|
||||
REACT_APP_SERVER_DECAL_LIBRARY_URL=185.100.212.76:9998
|
||||
|
||||
# base url for IoT socket server
|
||||
REACT_APP_IOT_SOCKET_SERVER_URL =185.100.212.76:5010
|
||||
|
||||
|
||||
@@ -111,6 +111,7 @@ const Assets: React.FC = () => {
|
||||
onClick={async () => {
|
||||
setIsLoading(true);
|
||||
const res = await fetchCategoryDecals(cat.name);
|
||||
console.log('res: ', res);
|
||||
setAssets(res);
|
||||
setSelectedDecalCategory(cat.name);
|
||||
setIsLoading(false);
|
||||
|
||||
@@ -10,15 +10,15 @@ export const RenderAsset: React.FC<{ asset: AssetProp | DecalProp; index: number
|
||||
return (
|
||||
<div key={`${index}-${asset.decalName}`} className="assets" id={asset.decalName} title={asset.decalName}>
|
||||
<img
|
||||
src={asset.decalImage}
|
||||
src={asset.decalImage || `http://${process.env.REACT_APP_SERVER_DECAL_LIBRARY_URL}/${asset.decalUrl}`}
|
||||
alt={asset.decalName}
|
||||
className="asset-image"
|
||||
onPointerDown={() => {
|
||||
setDroppedDecal({
|
||||
category: asset.category,
|
||||
decalName: asset.decalName,
|
||||
decalImage: asset.decalImage,
|
||||
decalId: asset.id,
|
||||
decalImage: asset.decalImage || "",
|
||||
decalId: asset.decalUrl || "",
|
||||
})
|
||||
}}
|
||||
/>
|
||||
|
||||
@@ -18,7 +18,7 @@ function DecalInstance({
|
||||
zPosition = decal.decalPosition[2],
|
||||
overWritePosition = null,
|
||||
}: Readonly<{ parent: Wall | Floor; visible?: boolean; decal: Decal; zPosition?: number; overWritePosition?: [number, number, number] | null }>) {
|
||||
const url_Backend_dwinzo = `http://${process.env.REACT_APP_SERVER_MARKETPLACE_URL}`;
|
||||
const url_Backend_dwinzo = `http://${process.env.REACT_APP_SERVER_DECAL_LIBRARY_URL}`;
|
||||
const { selectedDecal, deletableDecal, setSelectedDecal, setDeletableDecal } = useBuilderStore();
|
||||
const { toolMode } = useToolMode();
|
||||
const { toggleView } = useToggleView();
|
||||
@@ -108,7 +108,7 @@ function DecalInstance({
|
||||
};
|
||||
|
||||
const loadFromBackend = (decalId: string) => {
|
||||
const textureUrl = `${url_Backend_dwinzo}/api/v1/DecalImage/${decalId}`;
|
||||
const textureUrl = `${url_Backend_dwinzo}/${decalId}`;
|
||||
const textureLoader = new THREE.TextureLoader();
|
||||
|
||||
textureLoader.load(
|
||||
@@ -161,7 +161,7 @@ function DecalInstance({
|
||||
|
||||
return (
|
||||
<Decal
|
||||
debug
|
||||
debug={false}
|
||||
visible={visible}
|
||||
ref={decalRef}
|
||||
position={overWritePosition ? [overWritePosition[0], overWritePosition[1], zPosition] : [decal.decalPosition[0], decal.decalPosition[1], zPosition]}
|
||||
|
||||
@@ -3,7 +3,7 @@ let BackEnd_url = `http://${process.env.REACT_APP_SERVER_MARKETPLACE_URL}`;
|
||||
export const getCategoryDecals = async (category: string) => {
|
||||
try {
|
||||
const response = await fetch(
|
||||
`${BackEnd_url}/api/v1/categoryDecalDatas/${category}`,
|
||||
`${BackEnd_url}/api/v2/categoryDecalDatas/${category}`,
|
||||
{
|
||||
method: "GET",
|
||||
headers: {
|
||||
|
||||
3
app/src/types/uiTypes.d.ts
vendored
3
app/src/types/uiTypes.d.ts
vendored
@@ -18,7 +18,8 @@ interface AssetProp {
|
||||
interface DecalProp {
|
||||
id: string;
|
||||
decalName: string;
|
||||
decalImage: string;
|
||||
decalImage?: string;
|
||||
decalUrl?: string;
|
||||
category: string;
|
||||
type?: string;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user