3DStreet / 3dstreet

🚲🚢🚌 Web-based 3D visualization of streets using A-Frame
https://3dstreet.app
Other
256 stars 33 forks source link

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

Open kfarr opened 1 month ago

kfarr commented 1 month ago

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

kfarr commented 1 month ago

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