#Duplicate Needle Engine generate Bug
1 messages · Page 1 of 1 (latest)
Mh, I haven't seen that issue before.
Does that only happen in a production build? Not sure what "_a3" is
Needle Engine is designed to work with multiple instances per page, however I'm not sure if the react template is set up in a way that this works out of the box
Do you have an idea of how could I fix this issue ?
It seems to be a problem with Volume.ts error with postProcessing, in this part :
awake() {
// ensure the profile is initialized
this.sharedProfile?.init();
if (debug) {
console.log(this);
console.log("Press P to toggle post processing");
window.addEventListener("keydown", (e) => {
if (e.key === "p") {
console.log("Toggle volume: " + this.name, !this.enabled);
this.enabled = !this.enabled;
}
});
}
}
Here the log from the canvas :
Hi, can you explain what you do here? Do you mean you have a webpage with multiple <needle-engine> components ?
Yes, that's it
Here my React component :
const NeedleContainer = ({getNeedle, resetKey}) => {
return (
<div id="needleContainer">
{resetKey ? <NeedleEngine key={resetKey} getNeedle={getNeedle} /> : ""}
</div>
);
};
const ResetNeedle = ({ handleReset }) => {
return (
<button style={{transform: "translateY(-50px) translateX(80px)", zIndex: "100"}} onClick={handleReset}>
Réinitialiser la scène 3D
</button>
);
};
function NeedleEngine(props) {
const needleRef = useRef()
const files = JSON.stringify(globalThis["needle:codegen_files"])
useEffect(() => {
// console.log("Needle => ", needleRef)
if(props.getNeedle) props.getNeedle(needleRef)
}, [])
return <needle-engine ref={needleRef} src={"assets/sceneRoot.glb"}>
{/* @ts-ignore */}
{/* <div className="loading"></div> */}
{/* @ts-ignore */}
{/* <div className="desktop ar"> {props.children}</div> */}
</needle-engine>;
}
And I got this error when I duplicate my component like it :
<NeedleContainer getNeedle={getNeedle} handleReset={handleReset} resetKey={resetKey}/>
<NeedleContainer getNeedle={getNeedle} handleReset={handleReset} resetKey={resetKey}/>
I tried like it too :
<NeedleContainer getNeedle={getNeedle} handleReset={handleReset} resetKey={resetKey}/>
<needle-engine src={"assets/sceneRoot.glb"}></needle-engine>
Ah I see and then the exported scene contains PostProcessing and fails then? Does it work without the Volume component?
I will try
Thanks
The error disappear, and it seems that I can get different canvas
I need to verify if the canvas works well
Ok - so the problem is caused by the Volume component 🤔
Ok it works correctly, the others errors come from my scripts
You mean with the Volume component it also works now?