Spaces:
Running
Running
Download sensor-models.js from polyutaslab/UrbanV2X-Viewer: direct link, hf CLI and curl.
- Browser
- Download file 1.83 kB
-
https://huggingface.co/spaces/polyutaslab/UrbanV2X-Viewer/resolve/main/sensor-models.js
- Command line
-
hf download hf://spaces/polyutaslab/UrbanV2X-Viewer/sensor-models.js
-
curl -L -o sensor-models.js https://huggingface.co/spaces/polyutaslab/UrbanV2X-Viewer/resolve/main/sensor-models.js
1.83 kB
| import * as THREE from 'three'; | |
| const mat=(color,metalness=.15)=>new THREE.MeshStandardMaterial({color,metalness,roughness:.48}); | |
| function box(g,size,position,material){const m=new THREE.Mesh(new THREE.BoxGeometry(...size),material);m.position.set(...position);g.add(m);return m;} | |
| function pole(g,radius,height,z,material){const m=new THREE.Mesh(new THREE.CylinderGeometry(radius,radius,height,16),material);m.rotation.x=Math.PI/2;m.position.z=z;g.add(m);return m;} | |
| export function vehicleModel(){ | |
| const g=new THREE.Group();g.name='Onboard vehicle';g.userData.kind='vehicle';g.renderOrder=2; | |
| const body=mat('#e4eff3'),glass=mat('#284e69',.45),rubber=mat('#18222c'),accent=mat('#35d4bd'); | |
| box(g,[4.6,1.9,.7],[0,0,-1.05],body);box(g,[2.5,1.7,.65],[-.35,0,-.4],glass);box(g,[2.4,1.75,.12],[-.35,0,-.03],body); | |
| box(g,[.9,1.8,.2],[1.65,0,-.62],body);box(g,[.15,1.7,.22],[2.3,0,-.95],accent); | |
| for(const x of [-1.45,1.45])for(const y of [-.98,.98]){const w=new THREE.Mesh(new THREE.CylinderGeometry(.39,.39,.24,20),rubber);w.position.set(x,y,-1.3);g.add(w);} | |
| for(const y of [-.62,.62]){box(g,[.05,.4,.17],[2.33,y,-.75],mat('#fff4c8'));box(g,[.05,.4,.16],[-2.33,y,-.75],mat('#f55e56'));} | |
| pole(g,.27,.3,.18,accent);box(g,[.28,.28,.16],[-.8,0,.1],mat('#56b9ff'));box(g,[.22,.48,.18],[.8,0,.1],mat('#ff7f9e')); | |
| return g; | |
| } | |
| export function roadsideModel(color,name){ | |
| const g=new THREE.Group();g.name=name+' lamp pole';g.userData.kind='lamp-pole';g.renderOrder=2; | |
| const steel=mat('#ccd6de',.65),accent=mat(color),lamp=mat('#fff1c5'); | |
| pole(g,.26,7,-2.5,steel);pole(g,.35,.25,-5.9,steel);box(g,[.65,.65,.18],[0,0,-6.1],mat('#6d8494')); | |
| box(g,[2,.24,.24],[.92,0,.95],steel);box(g,[.85,.38,.15],[1.6,0,.86],steel);box(g,[.7,.3,.035],[1.6,0,.76],lamp); | |
| box(g,[.46,.4,.35],[.3,0,0],accent);pole(g,.18,.25,-.65,accent); | |
| return g; | |
| } | |