import{REQUEST_TYPE}from"../../../unity/model-api";import{merge}from"lodash";const defaultHeatMapSetting={radius:5,intensity:.2,height:20,alpha:.5,mode:0,renderType:0,colorLerpValue:.2};export const createHeatMap=async(a,b)=>{let c=merge(defaultHeatMapSetting,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{HeatMapID:e}=await b.unity.invoke(REQUEST_TYPE.CreatHeatMap,{Name:a.name,Visible:a.visible||!0,PosData:{SpaceRefernce:"World",Data:d},Setting:{Radius:c.radius,Intensity:c.intensity,Height:c.height,Alpha:c.alpha,Mode:c.mode,RenderType:c.renderType,ColorLerpValue:c.colorLerpValue}});return{id:e,remove:()=>{b.unity.invoke(REQUEST_TYPE.RemoveHeatMap,{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.UpdateHeatMapData,{Id:e,PosData:{SpaceRefernce:"World",Data:c}})},updateSetting:a=>{let c=merge(defaultHeatMapSetting,a);b.unity.invoke(REQUEST_TYPE.UpdateHeatMapSetting,{Id:e,Setting:{Radius:c.radius,Intensity:c.intensity,Height:c.height,Alpha:c.alpha,Mode:c.mode,RenderType:c.renderType,ColorLerpValue:c.colorLerpValue}})},setVisiblity:a=>{b.unity.invoke(REQUEST_TYPE.SetHeatMapVisiblity,{Ids:[e],Visible:a})}}};