import{createUnityColor}from"../../../unity/tool";import{REQUEST_TYPE}from"../../../unity/model-api";import{merge}from"lodash";const defaultLightFlowSetting={tilling:1,smooth:1,intensity:1,width:1,speed:1,lineType:0,reverseDirection:!0,autoClosed:!0,color:createUnityColor("#ff0000ff")},defaultArrowFlowSetting={smooth:1,intensity:1,width:1,speed:1,lineType:0,reverseDirection:!0,autoClosed:!0,color:createUnityColor("#ff0000ff")};export let LineEffectType=function(a){return a.LineLightFlow="LineLightFlow",a.LineArrowFlow="LineArrowFlow",a}({});export const createLine=async(a,b)=>{var c,d;let e;if(a.effectType===LineEffectType.LineLightFlow)e=merge(defaultLightFlowSetting,a.setting?a.setting:{});else if(a.effectType===LineEffectType.LineArrowFlow)e=merge(defaultArrowFlowSetting,a.setting?a.setting:{});else throw new Error("\u672A\u77E5 `\u7EBF\u7279\u6548` \u7C7B\u578B\uFF1A"+a.effectType);let f=a.positions.map(a=>({X:a.x,Y:a.y,Z:a.z}));if(0===f.length)throw new Error("Positions \u4E3A\u7A7A");const{ID:g}=await b.unity.invoke(REQUEST_TYPE.CreatLineEffect,{EffectType:a.effectType,SpaceID:a.spaceID,Positions:f,Setting:{Tilling:e.tilling,Smooth:e.smooth,Intensity:e.intensity,Width:e.width,Speed:e.speed,LineType:e.lineType,ReverseDirection:e.reverseDirection,AutoClosed:e.autoClosed,Color:null!==(c=a.setting)&&void 0!==c&&c.color?createUnityColor(null===(d=a.setting)||void 0===d?void 0:d.color):e.color}});return{id:g,remove:()=>{b.unity.invoke(REQUEST_TYPE.RemoveLineEffect,{Ids:[g]})}}};