// create all of the zone attenuation objects let za_offset = 1; let zone_attenuation_data = []; for (const [room, roomData] of Object.entries(MAP.rooms)) { zones = new Set(); for (const [room, roomData] of Object.entries(MAP.rooms)) { zones.add(room); } for (const [zone, coefficient] of Object.entries(roomData.attenuation_coefficients)) { zone_attenuation_data.push({ 'source-zone-id': zone_to_id[room], 'listener-zone-id': zone_to_id[zone], 'za-offset': za_offset++, 'attenuation': coefficient }); zones.delete(zone); } // all 'self' zones and zones not specified. for (const zone of zones) { zone_attenuation_data.push({ 'source-zone-id': zone_to_id[room], 'listener-zone-id': zone_to_id[zone], 'za-offset': za_offset++, 'attenuation': (room !== zone) ? 1.0 : 0.5 }); } } await fetch(space_url('/zone_attenuations'), { method: 'POST', headers: { 'Content-type': 'application/json; charset=UTF-8' // Indicates the content }, body: JSON.stringify(zone_attenuation_data) });
Preview:
downloadDownload PNG
downloadDownload JPEG
downloadDownload SVG
Tip: You can change the style, width & colours of the snippet with the inspect tool before clicking Download!
Click to optimize width for Twitter