I’m creating a sort of product configurator using React where I utilize CSG (Chandler Prall) to do some edits to 3D objects. This is pretty performant in development, almost no delays in rendering objects with multiple CSG operations.
When I build this React project for production everything goes well performance wise, until I introduce some CSG operations on a 3D object. Suddenly the render of the object takes several seconds for 1 operation, and even a minute when there are 5 or something similar.
I can’t find anything on this subject, especially because in development everything flies in comparison to when it is built for production.
Has anyone encountered a problem like this, or knows what the problem could be?
Both actually, this problem surfaces when deployed on a shared server but after this I tested the production build on a locally hosted webserver and the performance was the same.
For anyone searching for a solution in the future:
I backtracked in my git to pinpoint the moment where this went wrong, as it worked fine when I deployed the application a while ago. I found that at one point I updated the “react-scripts” dependency from 3.3.0 to 3.4.1 and when I change the version back to 3.3.0 the performance of the CSG is as fast as it should be. No idea what is causing this so far.
What I find so far is that the clone function is much slower in production. But also the performance tools in Chrome don’t work because I think something very expensive or memory intensive is happening.
Are you also using react-three-fiber?
Maybe there are two renderers or something?
I think the cause is webpack / babel three shaking or removing important things from the class
UPDATE 25 march 2021
Use the code from Seanwasere!
After that is was still much (10 times) slower for me in production right now than in development somehow…
It also still freezes my application for a while but I finally found why it is still slow somehow.
You also have to copy the file at
three/examples/jsm/deprecated/Geometry’
to your local project and import in CSGMesh.js like
import { Geometry, Face3 } from ‘./Geometry’
I only now had the chance to check this out. This indeed helps a ton as the application doesn’t freeze anymore, although I notice a small delay in rendering. But that is a small price to pay for getting an actual response from the application when rendering.