Three.js: โ€œ0โ€ width for box renders as โ€œ1โ€ width

Created on 3 Jul 2019  ยท  7Comments  ยท  Source: mrdoob/three.js

Description of the problem

โ€œ0โ€ width for box renders as โ€œ1โ€ width

Describe the bug or feature request in detail.

When creating a box

new THREE.BoxGeometry(opening.geometry.xLength, opening.geometry.yLength, opening.geometry.zLength)

when you make a 0 width box.

new THREE.BoxGeometry(0, 1, 1)

It renders on the screen with 1 as width. I think it should not render anything. Is this a bug of three.js?.

Three.js version

r106

Browser
  • [X ] Chrome
OS
  • [X ] Windows
  • [ ] macOS
  • [ ] Linux
  • [ ] Android
  • [ ] iOS

Most helpful comment

Use a rectangle instead.

In our case THREE.PlaneBufferGeometry.

All 7 comments

The dimensions passed to the constructor of BoxGeometry or BoxBufferGeometry must be non-negative (EDIT) positive.

three.js does not validate function, or constructor, arguments.

function BoxBufferGeometry( width, height, depth, widthSegments, heightSegments, depthSegments ) {

  ...

  width = width || 1;
  height = height || 1;
  depth = depth || 1;
}

Seems intentional to me

@WestLangley 0 is a non-negative value. However, my question is as @samipe says. Is it really intentional?. Who can confirm that?.

@sebasecheverry Oops. Sorry, I meant _positive_.

If zeros are allowed as a dimension, the normals will be incorrect. So, additional changes would be required.

Degenerate triangles would also occur, unless there were further modifications to the code.

Cube with 0 width makes no sense. Use a rectangle instead.

Use a rectangle instead.

In our case THREE.PlaneBufferGeometry.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

boyravikumar picture boyravikumar  ยท  3Comments

donmccurdy picture donmccurdy  ยท  3Comments

jens-duttke picture jens-duttke  ยท  3Comments

fuzihaofzh picture fuzihaofzh  ยท  3Comments

ghost picture ghost  ยท  3Comments