Hi there, i am struggling to find the reason why i am seeing the model loaded by assetManager for a splitsecond when loading the scene. Strangely it does not happen everytime, but ~75% of the loads.
the mesh which should be loaded appears on the screen for a frame or two, then disappears.
i have no idea how to further debug it, if you have any idea where my the problem could lie, please let me know. this a part of the code i use:
const CustomObjectAsset = (props: Props) => {
const [CustomObjectMesh, setMesh] = useState<Mesh>()
const assetManagerResult = useAssetManager(
[
{
taskType: TaskType.Mesh,
rootUrl: props.rootUrl ?? '',
sceneFilename: props.filename,
name: 'CustomObject',
},
],
{ useDefaultLoadingScreen: false, reportProgress: true }
)
const CustomObjectTask = assetManagerResult.taskNameMap['CustomObject'] as MeshAssetTask
useLayoutEffect(() => {
if (CustomObjectTask.isCompleted) {
const rootMesh = CustomObjectTask.loadedMeshes.find((m) => m.name === '__root__')
const mesh = rootMesh?.getChildren()[0]
setMesh(mesh as Mesh)
/** dispose original meshes */
rootMesh?.dispose(true)
if (props.onCreated !== undefined) {
props.onCreated([mesh] as Mesh[])
}
}
}, [CustomObjectTask.isCompleted])
/**
* Create for each CustomObject mesh a React Mesh node and for its LOD meshes.
*/
return (
<transformNode name={'CustomObjects'}>
{CustomObjectMesh && (
<>
<mesh
name={CustomObjectMesh.name}
key={'CustomObject' + CustomObjectMesh.id}
fromInstance={CustomObjectMesh}
isPickable={props.isPickable}
receiveShadows={props.receiveShadows}
setEnabled={false}
/>
</>
)}
</transformNode>
)
}
export default CustomObjectAsset
thank you so much for help!