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