We are using Needle and react to create a visualization tool.
During dev things are looking nice and everything works, but when we a prod build we get weird errors.
One such example is a reference to a post processing volume, established in Unity, no longer refers to the active post processing profile.
We can log the value of the post processing profile, and it will show our assigned values. However if we log them before assigning to them we get undefined.
updateFocusDistance(distance: number) {
this.focusDistance = distance;
const profile = this.post?.sharedProfile;
if (!profile) return;
for (const ef of profile!.components!) {
if (ef instanceof DepthOfField) {
ef.focusDistance.value = distance;
}
}
}
@SteffenMFureli updating the focus distance works for me. All i did was applying a sin function to the value (and uncommenting the line that wrote to value) - so the effect is updated when you change it - I didnt change anything else ef.focusDistance.value = Math.sin(this.context.time.time * 3) * 3 + 3;
Well, to be more precise:
Everything works when deployed in our development environment, but when running a prod build it somehow fails. Could there be specifics in how we have set up our dev env that could cause the issue?
Is it possible to perhaps have a one to one someday where I can show you how it is setup?
Hi @SteffenMFureli - the issue seems to be caused by webpack’s chunking which causes issues where types existing multiple times in production builds. Until there’s a better solution one way to make nextjs builds work again right now is by adding these two lines to the webpack config:
My “FireplaceController” reference made in Unity still gets broken and returns undefined.
And when using “FindObjectOfType” I get one of my cameras in return.
Can you also try removing needle engine from the transpiled packages list? After nextconfig.transpilePackages.splice(nextconfig.transpilePackages.indexOf('@needle-tools/engine'), 1);