-
-
Notifications
You must be signed in to change notification settings - Fork 136
Open
Description
I may be missing something but for the life of me I'm unable to assign the url property at runtime. I mean there are no errors thrown, but the url property remains null . The only time it works is when I assign a default value to the ref.
Do you have an example where the url property is assigned through a prop or queried at run time and the assigned to the Cesium3DTileset component?
here is an example that works only when the ref has an initial value (and that only value ever used even if I update the ref:
interface IModelProps {
token: string;
imodelId: string;
position: Cartesian3;
name: string;
description: string;
}
export default function CADModel(props: IModelProps) {
const refUrl = useRef(STATION_URI);
useEffect(() => {
const fetchUrl = async () => {
try {
console.log(`Token: ${props.token}`);
ITwinPlatform.defaultAccessToken = props.token;
const mytiles = await ITwinData.createTilesetFromIModelId(props.imodelId);
refUrl.current = mytiles!.resource!.url! as string;
console.log(`URL to the tileset: ${refUrl.current}`);
} catch (e) {
console.log(`Error reported while processing iModel ${props.imodelId} from Components/CADModel Component: ${e}`);
}
};
fetchUrl();
}, []);
return (
<>
<Entity point={{ pixelSize: 20 }} name={props.name} description={props.description} position={props.position} />
<Cesium3DTileset
url={refUrl.current}
></Cesium3DTileset>
</>
);
}
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels