ThreeJS render objects reverse lighting those have scale(-1,-1,-1).
Object A has scale(1,1,1)
Object B has scale(-1,-1,-1)
the Model was exported with Sketchup as GLB format.
The images are too bloated and even with the help of the arrows it is unclear what exactly is wrong and how it should look like. Try with two boxes, one normal and one flipped. If you still get wrong light, then share it via CodePen.io (or similar tool) so that others could debug it live.
BTW I tried with two GLB models, one scaled (-1,-1,-1) and did not see any inconsistency. They look just as I’d expect. Of course, it is possible that I have misunderstood the issue.
Glb file became very large, because I had to explode every components/symbols in the sketchup file; which is not a good thing to do… And I will be have to do this again every model revision over Sketchup…
Something into your mesh, maybe in up, scale, matrix, parents deep in childrens.
Because if apply negative scale to box it looks ok.
Your mesh have reacting to scale.z=-1.
No reactions to scale.x=-1, scale.x=1, scale.y=-1, scale.y=1, or its ok i dont know.
If change Y position, then mesh go forward insted up
It looks like the model data are wrongly defined. Even in Blender the model shows up wrongly. I made a quick patch that may or may not work in the general case. The patch flips the normals of all geometries, which are buried under odd number of negatively scaled objects, because even number of negative scales cancel each other. The first snapshot is without the patch, the second is with the patch.
Thank you very much for your effort; I was doing very same hack in the first place -you can see it in question post, somes are ok but some objects never appeared in correct position.
Maybe Sketchup uses some custom (or very new (or very rare)) GLTF/GLB feature not supported by others? Maybe it related to reversed winding order? Maybe you could try to export in different format?
The GLB model shows wrongly in Blender, so I’d assume it is not a Three.js issue.
How is the model created? If you have made it, could you remake the second object by rotating the first object, instead of by scaling it negatively?
Just to clarify, if the original is not GLB/GLTF, Sketchfab converts anything that’s not in the original format through its own pipeline, designers don’t upload multiple exported formats. That’s why I always do the glTF export myself, because a lot of things from the data structure to the materials end up incorrect otherwise.
Well it was an architectural model, and exported from Sketchup. The model created by architects and engineers for the construction. My sketchup skills was low, and not neccessary, I am on the Threejs side.
~Yeah, but if you export it yourself with the correct structure from the original format like USDZ or OBJ, you won’t see this problem as @PavelBoytchev fixed.~
Sorry, I’ve tried, it doesn’t always fix it. Even GLTF/GLB exports of custom meshes don’t work correctly, alpha and shadows look wrong as your issue…
There have been a number of fixes in three.js over the years intended to support lighting on negatively-scaled objects correctly. It looks to me like either (a) there has been a regression, or (b) this model requires some additional workarounds in three.js to handle. In either case — please feel free to open an issue with the .glb model on the github repository, perhaps that can be fixed.
That said, handling negative scaling in three.js is a bit tricky, and I’d (personally) be hesitant to rely heavily on that method in production applications, at least if you care about physically-based lighting. I suspect Sketchup has a specialized renderer for CAD models, and just handles this data very differently. If size of the model is the main concern, otherwise, there are many ways to reduce that. Exports directly from a DCC tool like Sketchup or Blender are not usually particularly optimized, so extra optimization steps with tools like gltfpack or glTF-Transform will help.
The glTF file itself contains nothing particularly unusual except the negatively-scaled nodes, and the KHR_materials_pbrSpecularGlossiness extension (which is now unsupported, but doesn’t seem to affect this issue).