import{REQUEST_TYPE}from"../../../unity/model-api";import{merge}from"lodash";const defaultTemperatureMapSetting={globleRadius:5,height:.2,transparent:.2,temperatureColors:[{color:{R:1,G:.1,B:0,A:1},temperatureRange:40},{color:{R:1,G:.9,B:.1,A:1},temperatureRange:30},{color:{R:.36,G:1,B:.21,A:1},temperatureRange:20},{color:{R:.16,G:.24,B:1,A:0},temperatureRange:10}]};export const createTemperatureMap=async(a,b)=>{let c=merge(defaultTemperatureMapSetting,a.setting?a.setting:{}),d=a.posData.map(a=>({X:a.x,Y:a.y,Z:a.z,W:a.w}));if(0===d.length)throw new Error("posData \u4E3A\u7A7A");const{TemperatureMapID:e}=await b.unity.invoke(REQUEST_TYPE.CreatTemperatureMap,{Name:a.name,PosData:{SpaceRefernce:"World",Data:d},Setting:{GlobleRadius:c.globleRadius,Height:c.height,Transparent:c.transparent,TemperatureColors:c.temperatureColors.map(a=>({Color:a.color,TemperatureRange:a.temperatureRange}))}});return{id:e,remove:()=>{b.unity.invoke(REQUEST_TYPE.RemoveTemperatureMap,{Ids:[e]})},update:a=>{let c=a.map(a=>({X:a.x,Y:a.y,Z:a.z,W:a.w}));if(0===c.length)throw new Error("posData \u4E3A\u7A7A");b.unity.invoke(REQUEST_TYPE.UpdateTemperatureData,{Id:e,PosData:{SpaceRefernce:"World",Data:c}})},setVisiblity:a=>{b.unity.invoke(REQUEST_TYPE.SetTemperatureMapVisiblity,{Ids:[e],Visible:a})}}};