3DStreet / 3dstreet

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

simple method for consistent texture scaling #407

Open kfarr opened 10 months ago

kfarr commented 10 months ago

Issue: Textures appear too large, too small or squished in some cases for ground in building lots or ground for street segments.

Cause: When applying textures to ground box or segment box the repeat values are dependent upon the user supplied length, width, depth, etc. of the underlying geometry (plane or box)

Workaround: A user can manually modify assets.js material code to change texture repeat values.

Instead: we should have a mechanism for a-frame to define a texture for a geometry such that the material automatically sets a repeat value as to maintain the original aspect ratio and resolution of an image. (perhaps there is a new property that can be passed to specify the relative scaling from the original resolution as a number)

How would this be applied?

Current: <a-mixin shadow id="ground-parking-lot-material" material="src:#parking-lot-texture;repeat:.5 2;roughness:${surfacesRoughness}"></a-mixin>

Instead, example syntax: <a-mixin shadow id="ground-parking-lot-material" fixed-repeat material="src:#parking-lot-texture;roughness:${surfacesRoughness}"></a-mixin>

and the fixed-repeat component automatically calculates material repeat value based on dimensions of box or plane (no other geometry primitive value supported?)

kfarr commented 10 months ago

Here is an existing method that does this for separator type segments: https://github.com/3DStreet/3dstreet/blob/main/src/aframe-streetmix-parsers.js#L688

If done correctly the new component proposed in this ticket should be able to replace the use of repeat: ${repeatCount[0]} ${repeatCount[1]} within the streetmix json parsing function

Algorush commented 10 months ago

I did this option with repeat last year. So it will be easier for me to implement this method