When i was loading a Revit model, the model in three.js was all BLACK

Description of the problem

The model is from Revit, I tried to export its model info to a .json file.
When I was loading the JSON file, there’s no error in the Chrome console, but my model was all black.
I’ve changed parameters about “materials”, but it didn’t work.
I also changed the three.js’s version, it still didn’t work.
I think the key is “materials”'s type, “MeshPhongMaterial”
Because when I use “MeshStandardMaterial”, and the parameters are default, the model in three.js is winking continuously, changing color from BLACK to correct color, I’m confused…

This is my .json file:
https://paste.ubuntu.com/p/J8sYXbvxYf/

And this is my .html file:
https://paste.ubuntu.com/p/bgHmHPppGc/


Three.js version
  • [x] r95
  • [x] r103
  • [x] r106
  • [x] r107
  • [x] r108
Browser
  • [ ] All of them
  • [x] Chrome
  • [ ] Firefox
  • [ ] Internet Explorer
OS
  • [ ] All of them
  • [x] Windows
  • [ ] macOS
  • [ ] Linux
  • [ ] Android
  • [ ] iOS
Hardware Requirements (graphics card, VR Device, …)

graphics card: NVIDIA GeForce GTX 1650

There might be an issue with your lights. Can you please add an ambient light to your scene and see if it improves rendering?

var ambientLight = new THREE.AmbientLight( 0xffffff, 0.4 );
scene.add( ambientLight );
2 Likes

Oh, I really appreciate it.

I have added the code fragment to my code. Although now the model in three.js is showing the correct color, it still is winking continuously, from the correct color to black.
If the model can keep the correct color, my problem will be solved.

Thank you again.

Try to avoid code like this:

spotLight.position.copy(camera.position);

Instead, add the light as a child to the camera and then add the camera to the scene:

camera.add( spotLight );
scene.add( camera );

BTW: A point light might be better for this use case than a spot light.

1 Like

Thank you for your reply.

I forgot to paste my fresh code, so there’s a misunderstanding.
I have deleted all the code about spotLight, and this is the latest code:
https://paste.ubuntu.com/p/gRQGD7NtSY/

I have concerned about whether is Z-Fighting causes winking and I tried to fix it. It still doesn’t work.
I will continue to look for solutions. And if I solve this problem, I will show it by replying to this topic.

Really thanks for your help.

How did you export revit to json, did you use any add-ons or from dynamo, could you give me a little more information about the export?