3DStreet/3dstreet

street segments with negative elevation results in NaN `x` position raising console errors

Opened this issue · 2 comments

https://3dstreet.app/#/scenes/d1f54dc8-2aa1-4de9-8349-677d67b334ee.json

This street has an invalid value for position that includes NaN for x value:

...
{
                    "components": {
                      "geometry": "height: 0.2; depth: 120; width: 2.4",
                      "material": "offset: 0.415 0; repeat: 1 150; roughness: 0.8; src: #grass-texture",
                      "position": "NaN -0.1 0"
                    },
                    "element": "a-entity",
                    "mixin": "grass",
                    "primitive": "box"
                  },
...

When using transform controls this raises an error repeatedly when dragging:
image

I also found a case where an unsupported streetmix segment will result in an entity that has NaN for height.

How does this happen?

(1) Example1: https://3dstreet.app/#/scenes/0aeddcc9-f207-492b-9671-93334e07a61c.json

For drainage channel, the elevation is set to -2. JSON code from streetmix:

        {
          "id": "dF30-wNArqiOxXyqvXlYF",
          "type": "drainage-channel",
          "variantString": "slanted",
          "width": 1,
          "elevation": -2
        },

This results in NaN for height value in the function createSegmentElement: https://github.com/3DStreet/3dstreet/blob/main/src/aframe-streetmix-parsers.js#L916

(2) Example2: x position for ground lot is NaN

How does this happen? If there is incorrect value length, streetWidth or sideMultiplier here:
const groundPositionX = (length / 4 + streetWidth / 2) * sideMultiplier;
in https://github.com/3DStreet/3dstreet/blob/main/src/aframe-streetmix-parsers.js#L916

Related:

doing "elevation: 1" on a drive-lane with pedestrians in it doesn't elevate the peds to go with the elevated drive lane, causing the peds to look like they're doing a bit of wading through the asphalt