Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

MeshPhysicalMaterial attenuationDistance is null when exporting to JSON #24797

Closed
davcri opened this issue Oct 14, 2022 · 0 comments · Fixed by #24798
Closed

MeshPhysicalMaterial attenuationDistance is null when exporting to JSON #24797

davcri opened this issue Oct 14, 2022 · 0 comments · Fixed by #24798

Comments

@davcri
Copy link
Contributor

davcri commented Oct 14, 2022

Describe the bug

const mesh = new THREE.Mesh(new THREE.BoxGeometry(), new THREE.MeshPhysicalMaterial())
console.log(mesh.material.attenuationDistance); // Infinity (correct)
const json = JSON.stringify(mesh.toJSON())
const x = new THREE.ObjectLoader().parse(JSON.parse(json))
console.log(x.material.attenuationDistance); // null, but it should be Infinity

Live example

Expected behavior

Serializing and deserializing should preserve the material appearance.

Probably we should avoid exporting attenuationDistance when it's equal to Infinity (the default value).

Related issue: #24622

Screenshots

I noticed this issue by exporting and re-importing a MeshPhysicalMaterial from the editor.

Attenuation distance is NaN after importing model.json with MeshPhysicalMaterial (with transmission = 1, roughness ~=0)

Platform:

  • Device: Desktop, Mobile
  • OS: Windows, MacOS, Linux, Android, iOS
  • Browser: Chrome, Firefox, Safari, Edge
  • Three.js version: dev
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants