Hello,
I saw this code :three.js webgl - IFCLoader but what is the way to do the same with fiber ? Thank you.
you would do the same. everything you see in threejs works in fiber, you can use the loader code 1:1.
that example seems outdated btw, looks like IFCLoader was deprecated for this GitHub - ThatOpen/engine_components the new api looks very confusing, downright puzzling but thatâs a different matter.
I actually did that:
import {useLoader} from â@react-three/fiberâ;
import { IFCLoader } from âweb-ifc-threeâ;
import { IFCSPACE } from âweb-ifcâ;import {useEffect,Suspense} from âreactâ
const Model = () => {
useEffect( ()=>{
async function Kaka(){
const ifcLoader = new IFCLoader();
await ifcLoader.ifcManager.setWasmPath( âweb-ifc CDN by jsDelivr - A free, fast, and reliable Open Source CDNâ, true );await ifcLoader.ifcManager.parser.setupOptionalCategories( {
[ IFCSPACE ]: false,
} );await ifcLoader.ifcManager.applyWebIfcConfig( {
USE_FAST_BOOLS: true
} );ifcLoader.load( â./src/assets/rac_advanced_sample_project.ifcâ, function ( ) {
// scene.add( model.mesh );
// render();} );
}Kaka()},)
return (
<div>AA</div> </Suspense>);
};export default Model
I have this error :
RuntimeError: Aborted(LinkError: WebAssembly.instantiate(): Import #49 module=âaâ function=âXâ: function import requires a callable). Build with -sASSERTIONS for more info.
Do you know whatâs wrong ? Thanks a lot.
this is not about fiber in that case, the browser refuses to load their wasm.
other than that, when you get the wasm fixed, you canât return a div, which would be the same as new THREE.Div() but such a thing does not exist. if you want to put a pre-existing object3d into the scene you would typically use primitive.
if you donât want to use useLoader and suspense, then itâs just
const [scene, setScene] = useState()
useEffect(() => {
...
setScene(scene)
}, [])
return scene && <primitive object={scene} />