Closed
Description
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
- https://jsfiddle.net/we3c562t/5/ (open the console)
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