[SOLVED] Setting camera near clip to 0.001 in UI causes an issue

In the editor, setting the camera near clip to 0.001 ends up setting the value to 0, and blanks the camera out.

Seems reasonable to want to set the near clip to 0.001 (1mm). At least, for very small scenes. Hey @vaios, it is easy to increase the decimal precision on that number field? Or would such a change have to apply to all number fields?

By the way, you can get around this for the time being with a script of course:

var NearClip = pc.createScript('nearClip');

NearClip.attributes.add('nearClip', { type: 'number', precision: 5, default: 0.001 });

// initialize code called once per entity
NearClip.prototype.initialize = function() {
    this.entity.camera.nearClip = this.nearClip;
};

It is easy, in file:
editor/attributes/components/attributes-components-camera.js
Find this piece of code:

var fieldNearClip = editor.call('attributes:addField', {
    parent: panel,
    name: 'Clip',
    placeholder: 'Near',
    type: 'number',
    precision: 2,
    step: .1,
    min: 0,
    link: entities,
    path: 'components.camera.nearClip'
});

And here you can change precision to some larger number, like 4, that will allow as low 0.0001 values.
Probably sensible to apply same precision to fieldFarClip as well.

1 Like

Hey @Mal_Duffin. We’ve updated the precision of nearClip and farClip to 4 to allow for values as low as 0.001. Hopefully this helps! (and thanks to @moka saving me time finding the lines/files!)

2 Likes

Cheers @halvves - it’s great to see the UI getting some updates!