CourseChapter3d.vue 100 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102210321042105210621072108210921102111211221132114211521162117211821192120212121222123212421252126212721282129213021312132213321342135213621372138213921402141214221432144214521462147214821492150215121522153215421552156215721582159216021612162216321642165216621672168216921702171217221732174217521762177217821792180218121822183218421852186218721882189219021912192219321942195219621972198219922002201220222032204220522062207220822092210221122122213221422152216221722182219222022212222222322242225222622272228222922302231223222332234223522362237223822392240224122422243224422452246224722482249225022512252225322542255225622572258225922602261226222632264226522662267226822692270227122722273227422752276227722782279228022812282228322842285228622872288228922902291229222932294229522962297229822992300230123022303230423052306230723082309231023112312231323142315231623172318231923202321232223232324232523262327232823292330233123322333233423352336233723382339234023412342234323442345234623472348234923502351235223532354235523562357235823592360236123622363236423652366236723682369237023712372237323742375237623772378237923802381238223832384238523862387238823892390239123922393239423952396239723982399240024012402240324042405240624072408240924102411241224132414241524162417241824192420242124222423242424252426242724282429243024312432243324342435243624372438243924402441244224432444244524462447244824492450245124522453245424552456245724582459246024612462246324642465246624672468246924702471247224732474247524762477247824792480248124822483248424852486248724882489249024912492249324942495249624972498249925002501250225032504250525062507250825092510251125122513251425152516251725182519252025212522252325242525252625272528252925302531253225332534253525362537253825392540254125422543254425452546254725482549255025512552255325542555255625572558255925602561256225632564256525662567256825692570257125722573257425752576257725782579258025812582258325842585258625872588258925902591259225932594259525962597259825992600260126022603260426052606260726082609261026112612261326142615261626172618261926202621262226232624262526262627262826292630263126322633263426352636263726382639264026412642264326442645264626472648264926502651265226532654265526562657265826592660266126622663266426652666266726682669267026712672267326742675267626772678267926802681268226832684268526862687268826892690269126922693269426952696269726982699270027012702270327042705270627072708270927102711271227132714271527162717271827192720272127222723272427252726272727282729273027312732273327342735273627372738273927402741274227432744274527462747274827492750275127522753275427552756275727582759276027612762276327642765276627672768276927702771277227732774277527762777277827792780278127822783278427852786278727882789279027912792279327942795279627972798279928002801280228032804280528062807280828092810281128122813281428152816281728182819282028212822282328242825282628272828282928302831283228332834283528362837283828392840284128422843284428452846284728482849285028512852285328542855285628572858285928602861286228632864286528662867286828692870287128722873287428752876287728782879288028812882288328842885288628872888
  1. <!-- 实现具体3d逻辑使用 -->
  2. <script setup lang="ts">
  3. import CourseChapter3dMain from '@/components/student/CourseChapter3dMain.vue';
  4. import { threeWorld } from "@/stores/threeWorld.ts";
  5. import { courseChapter3dShow } from "@/stores/courseChapter3dShow.ts";
  6. import { HighlightLayerEvent } from "@/components/student/event/HighlightLayerEvent.ts";
  7. import { DragAndDropEvent } from "@/components/student/event/DragAndDropEvent.ts";
  8. import { TypeViewEvent } from "@/components/student/event/TypeViewEvent.ts";
  9. import { RenderEvent } from "@/components/student/event/RenderEvent.ts";
  10. import { ref, watch } from "vue";
  11. const props = defineProps({
  12. config : {
  13. type: Object
  14. },
  15. // 获取当前学生任务ID缺陷列表
  16. studentTaskIdList : {
  17. type: Object
  18. },
  19. });
  20. // 定义发射给父组件的方法
  21. const emits = defineEmits([
  22. // 上一步是否显示
  23. 'tipsBtnsUpOpen',
  24. // 下一步是否显示
  25. 'tipsBtnsDownOpen',
  26. ]);
  27. // setInterval(function() {
  28. // console.log(
  29. // "3d场景参数", props.config
  30. // );
  31. // }, 1000);
  32. // 处理哪些物体显示高光效果
  33. let objHighlightLayerEvent = new HighlightLayerEvent();
  34. // 处理指定物体拖拽逻辑
  35. let objDragAndDropEvent = new DragAndDropEvent();
  36. // 根据配置的流程切换对应的3d界面逻辑
  37. let objTypeViewEvent = new TypeViewEvent();
  38. // 3d渲染帧事件处理
  39. let objRenderEvent = new RenderEvent();
  40. // // 【开发的时候】3d场景,iframe地址
  41. // let threeWorldUrl = "3dMain/index.html#/main?id=zidingyi";
  42. // babylon 对象
  43. let BABYLON : any = null;
  44. // let commonconfig = "http://localhost:5173/3dMain/model2/";
  45. // let commonmodel = "http://localhost:5173/3dMain/model2/";
  46. // let threeWorldUrl = "3dMain/index.html#/main?id=zidingyi_lu_cun&user=zidingyi"
  47. // + '&commonconfig=' + commonconfig
  48. // + '&commonmodel=' + commonmodel;
  49. // // 【发布的时候】3d场景,iframe地址
  50. // // 配置文件地址
  51. // // let commonconfig = "https://www.3dyzt.com/eduTrain/3dMain/model/";
  52. // let commonconfig = "https://www.3dyzt.com/ShiZhengGuanWangZhiNengJianCeYuWeiHu/user_web/3dMain/model2/";// 正式
  53. // // let commonconfig = "https://www.3dyzt.com/eduTrain/3dMain/model3/";// 临时测试
  54. // // 模型地址
  55. // // let commonmodel = "https://www.3dyzt.com/eduTrain/3dMain/model/";
  56. // let commonmodel = "https://www.3dyzt.com/ShiZhengGuanWangZhiNengJianCeYuWeiHu/user_web/3dMain/model2/";// 正式
  57. // // let commonmodel = "https://www.3dyzt.com/eduTrain/3dMain/model3/";// 临时测试
  58. // // 发布后的地址
  59. // let threeWorldUrl = "https://www.3dyzt.com/main/index.html#/main?id=zidingyi&user=zidingyi&commonconfig=" + commonconfig + "&commonmodel=" + commonmodel;
  60. let threeWorldHost = import.meta.env.VITE_APP_THREE_WORLD_URL;
  61. // let commonconfig = threeWorldHost + "3dMain/model2/";
  62. // let commonmodel = threeWorldHost + "3dMain/model2/";
  63. let commonconfig = threeWorldHost + "3dMain/model_cctv/";
  64. let commonmodel = threeWorldHost + "3dMain/model_cctv/";
  65. let threeWorldUrl = "3dMain/index.html#/main?id=zidingyi_lu_cun&user=zidingyi"
  66. + '&commonconfig=' + commonconfig
  67. + '&commonmodel=' + commonmodel;
  68. /**
  69. * 上一步是否显示
  70. * open true - 显示, false - 隐藏
  71. */
  72. const tipsBtnsUpOpenEvent = (open : Boolean) => {
  73. emits('tipsBtnsUpOpen', open);
  74. }
  75. /**
  76. * 下一步是否显示
  77. * open true - 显示, false - 隐藏
  78. */
  79. const tipsBtnsDownOpenEvent = (open : Boolean) => {
  80. emits('tipsBtnsDownOpen', open);
  81. }
  82. // 记录当前的流程
  83. let thisFlowPath : any = null;
  84. // 记录最后一次播放完成的状态
  85. let thisFlowPathEnd : any = null;
  86. /**
  87. * 监听发送参数变化,流程完成的时候
  88. */
  89. watch(
  90. () => courseChapter3dShow().show.showEndViewBool,
  91. (newVal, oldVal) => {
  92. // console.log(
  93. // newVal, oldVal,
  94. // props.config
  95. // );
  96. // 如果没有加载完成,则不触发后面的逻辑
  97. if (courseChapter3dShow().show.showEndViewBool == false) {
  98. return;
  99. }
  100. if (thisFlowPathEnd != thisFlowPath) {
  101. thisFlowPathEnd = thisFlowPath;
  102. // 启动播放声音
  103. objTypeViewEvent.musicConfigPlay(
  104. thisFlowPath, "end"
  105. );
  106. }
  107. }
  108. );
  109. /**
  110. * 监听发送参数变化,来控制切换3d的逻辑
  111. */
  112. watch(
  113. () => props.config,
  114. (newVal, oldVal) => {
  115. // console.log(
  116. // newVal, oldVal,
  117. // props.config
  118. // );
  119. // 如果没有加载完成,则不触发后面的逻辑
  120. if (threeWorld().loadSuccess == false) {
  121. return;
  122. }
  123. typeEvent(props.config?.threeDimensionalConfig);
  124. }
  125. );
  126. /**
  127. * 监听弹出提示隐藏后来触发不同的逻辑
  128. */
  129. watch(
  130. () => courseChapter3dShow().show.showToastViewBool,
  131. (newVal, oldVal) => {
  132. if (courseChapter3dShow().show.showToastViewBool == true) {
  133. return;
  134. }
  135. console.log(
  136. " () => courseChapter3dShow().show.showToastState 2222222222 ",
  137. courseChapter3dShow().show.showToastState
  138. );
  139. switch (courseChapter3dShow().show.showToastState) {
  140. case '立即穿戴':
  141. objTypeViewEvent.workRoleClothingUpdate("yes", false);
  142. break;
  143. case '去摆放':
  144. console.log(
  145. "去摆放触发了 animationSecurityZoneStart(安全桩001|西区实训基地-烘|BaseLayer)",
  146. courseChapter3dShow().show.showToastViewBool
  147. );
  148. objTypeViewEvent.animationSecurityZoneStart("安全桩001|西区实训基地-烘|BaseLayer");
  149. break;
  150. case '将抬升支架降至最低':
  151. // @ts-ignore
  152. threeWorld().obj.newIframe.cameraVisualAngleGetListNameGpsTo("相机上升");
  153. // @ts-ignore
  154. threeWorld().obj.newIframe.roleShow(false);
  155. // @ts-ignore
  156. threeWorld().obj.newIframe.objIframe.ChengGuangYuanJing.CommonVal.find().animationGroupsEventCallback(
  157. "主机升降", 'start', 1, null, null, false, null, function(state : any, objAnimation : any) {
  158. if (state == "播放完成") {
  159. }
  160. }
  161. );
  162. break;
  163. case '镜头旋转至正上方':
  164. // @ts-ignore
  165. threeWorld().obj.newIframe.cameraVisualAngleGetListNameGpsTo("镜头归位");
  166. // @ts-ignore
  167. threeWorld().obj.newIframe.roleShow(false);
  168. // @ts-ignore
  169. threeWorld().obj.newIframe.objIframe.ChengGuangYuanJing.CommonVal.find().animationGroupsEventCallback(
  170. "相机", 'start', 1, 0, 60, false, null, function(state : any, objAnimation : any) {
  171. if (state == "播放完成") {
  172. }
  173. }
  174. );
  175. break;
  176. case '摆放线缆盘线缆盘方向与爬行器爬行的方向一致':
  177. // @ts-ignore
  178. threeWorld().obj.newIframe.cameraVisualAngleGetListNameGpsTo("连接电缆");
  179. // @ts-ignore
  180. threeWorld().obj.newIframe.roleShow(false);
  181. // @ts-ignore
  182. threeWorld().obj.newIframe.objIframe.ChengGuangYuanJing.CommonVal.find().animationGroupsEventCallback(
  183. "电缆拔出", 'start', 1, null, null, false, null, function(state : any, objAnimation : any) {
  184. if (state == "播放完成") {
  185. }
  186. }
  187. );
  188. break;
  189. case '镜头归位':
  190. // @ts-ignore
  191. threeWorld().obj.newIframe.cameraVisualAngleGetListNameGpsTo("镜头归位");
  192. // @ts-ignore
  193. threeWorld().obj.newIframe.roleShow(false);
  194. // @ts-ignore
  195. threeWorld().obj.newIframe.objIframe.ChengGuangYuanJing.CommonVal.find().animationGroupsEventCallback(
  196. "相机", 'start', 1, 60, 240, false, null, function(state : any, objAnimation : any) {
  197. if (state == "播放完成") {
  198. }
  199. }
  200. );
  201. break;
  202. case '调节行驶方向正确放置过线滑轮':
  203. // @ts-ignore
  204. threeWorld().obj.newIframe.cameraVisualAngleGetListNameGpsTo("相机上升");
  205. // @ts-ignore
  206. threeWorld().obj.newIframe.roleShow(false);
  207. // @ts-ignore
  208. threeWorld().obj.newIframe.objIframe.ChengGuangYuanJing.CommonVal.find().animationGroupsEventCallback(
  209. "轮子滚动", 'start', 1, null, null, false, null, function(state : any, objAnimation : any) {
  210. if (state == "播放完成") {
  211. }
  212. }
  213. );
  214. break;
  215. }
  216. }
  217. );
  218. /**
  219. * 监听发送参数变化
  220. * 控制主光强度
  221. */
  222. watch(
  223. () => courseChapter3dShow().show.lightMain,
  224. (newVal, oldVal) => {
  225. // 如果没有加载完成,则不触发后面的逻辑
  226. if (threeWorld().loadSuccess == false) {
  227. return;
  228. }
  229. // 最大强度值
  230. // let intensityMax = 99999 * 2;
  231. // let intensityMax = 200 * 2;
  232. // let intensityMax = 100 * 2;
  233. let intensityMax = 100;
  234. let newIntensity = courseChapter3dShow().show.lightMain / 100 * intensityMax;
  235. objTypeViewEvent.spotLightCameraUpdateConfig(newIntensity);
  236. }
  237. );
  238. /**
  239. * 监听发送参数变化
  240. * 控制辅光强度
  241. */
  242. watch(
  243. () => courseChapter3dShow().show.lightAssist,
  244. (newVal, oldVal) => {
  245. // 如果没有加载完成,则不触发后面的逻辑
  246. if (threeWorld().loadSuccess == false) {
  247. return;
  248. }
  249. // 最大强度值
  250. // let intensityMax = 999 * 1;
  251. // let intensityMax = 800 * 1;
  252. // let intensityMax = 10;
  253. let intensityMax = 8;
  254. let newIntensity = courseChapter3dShow().show.lightAssist / 100 * intensityMax;
  255. objTypeViewEvent.pointLightCameraUpdateConfig(newIntensity);
  256. }
  257. );
  258. /**
  259. * 回调加载百分比
  260. */
  261. const callbackLoadPercentageEvent = (json: { loadPercentage: any; }) => {
  262. // console.log("回调加载百分比", json)
  263. const loadPercentage = parseFloat(json["loadPercentage"]);
  264. // 加载小于百分比
  265. if (loadPercentage < 100) {
  266. // ##############################【这里只做控制】隐藏其他按钮界面等
  267. threeWorld().loadSuccess = false;
  268. goPlayCallbackEventMain();
  269. return
  270. }
  271. }
  272. /**
  273. * 回调加载完成
  274. */
  275. const callbackLoadEndEvent = (json : { 'roleChoiceOpenBool' : true }) => {
  276. // console.log("回调加载完成", json)
  277. // 此时是显示角色的界面
  278. if (json["roleChoiceOpenBool"] === true) {
  279. // ############################## 隐藏其他按钮界面等
  280. threeWorld().loadSuccess = false;
  281. return;
  282. }
  283. // ############################## 这个时候,是真正的进入3d画面了,才显示其他按钮界面等
  284. threeWorld().loadSuccess = true;
  285. // @ts-ignore
  286. BABYLON = threeWorld().obj.newIframe.objIframe.BABYLON;
  287. objHighlightLayerEventInit();
  288. objDragAndDropEventInit();
  289. objTypeViewEventInit();
  290. objRenderEventInit();
  291. threeEvent();
  292. animationAllFpsToZero();
  293. pipelineProblemsJsonInitEvent();
  294. birthPointInit();
  295. carMoveSpeedInitEvent();
  296. // @ts-ignore 设置鼠标右键平移
  297. threeWorld().obj.newIframe.objIframe.ChengGuangYuanJing.CameraArray.find().jsonCamera.panningSensibility = 8;
  298. // @ts-ignore
  299. threeWorld().obj.newIframe.objIframe.ChengGuangYuanJing.CameraArray.find().activeCameraConfigUpdate();
  300. try {
  301. // 更新角色的固定皮肤
  302. // @ts-ignore
  303. let roleCode = threeWorld().obj.newIframe.objIframe.ChengGuangYuanJing.Role.find().roleCode;
  304. // @ts-ignore
  305. threeWorld().obj.newIframe.objIframe.ChengGuangYuanJing.Role.find().roleCodeAllConfig[roleCode]["skinUpdate"] = "exhibition_html_1709861931375_";
  306. } catch (e) {
  307. }
  308. // @ts-ignore
  309. threeWorld().obj.newIframe.roleShow(true);
  310. // @ts-ignore 解决角色有时候出现不了的问题
  311. threeWorld().obj.newIframe.objIframe.ChengGuangYuanJing.EventMoveRole.find().roleRotationYMove(180);
  312. setTimeout(function() {
  313. initScene();
  314. getRndArrayDemoEvent();
  315. workRoleTexture();
  316. }, 3000);
  317. }
  318. /**
  319. * 回调距离范围内
  320. */
  321. const callbackDistanceYesEvent = (json : any) => {
  322. // console.log("回调距离范围内", json);
  323. }
  324. /**
  325. * 回调距离范围外
  326. */
  327. const callbackDistanceNoEvent = (json : any) => {
  328. // console.log("回调距离范围外", json);
  329. }
  330. /**
  331. * 回调视角切换完成
  332. */
  333. const callbackCameraVisualAngleJsonToLookEvent = (json : any) => {
  334. // console.log("视角触发完成", json);
  335. }
  336. /**
  337. * 记录出生点
  338. */
  339. const birthPointInit = () => {
  340. courseChapter3dShow().show.birthPoint = {};
  341. // @ts-ignore
  342. for (let i = 0; i < threeWorld().obj.newIframe.objIframe.ChengGuangYuanJing.CommonBirthplace.find().list.length; i++) {
  343. // @ts-ignore
  344. let json = threeWorld().obj.newIframe.objIframe.ChengGuangYuanJing.CommonBirthplace.find().list[i];
  345. // console.log(
  346. // "json", json
  347. // );
  348. // @ts-ignore
  349. courseChapter3dShow().show.birthPoint[json.name] = json;
  350. }
  351. // console.log(
  352. // "courseChapter3dShow().show.birthPoint = {};",
  353. // courseChapter3dShow().show.birthPoint
  354. // );
  355. }
  356. /**
  357. * 记录3d里配置的移动速度
  358. */
  359. const carMoveSpeedInitEvent = () => {
  360. // // @ts-ignore
  361. // let objRoleConfig = threeWorld().obj.newIframe.objIframe.ChengGuangYuanJing.Role.find().roleCodeAllConfig[
  362. // // @ts-ignore
  363. // threeWorld().obj.newIframe.objIframe.ChengGuangYuanJing.Role.find().roleCode
  364. // ];
  365. // @ts-ignore
  366. let roleConfig = threeWorld().obj.newIframe.objIframe.ChengGuangYuanJing.CommonVal.find().roleConfig;
  367. courseChapter3dShow().show.carMoveSpeed = parseFloat("" + roleConfig.speedMove);
  368. // console.log(
  369. // "roleConfig",
  370. // roleConfig,
  371. // "courseChapter3dShow().show.carMoveSpeed",
  372. // courseChapter3dShow().show.carMoveSpeed
  373. // );
  374. }
  375. /**
  376. * 初始化 处理高光效果的对象
  377. */
  378. const objHighlightLayerEventInit = () => {
  379. // @ts-ignore
  380. objHighlightLayerEvent.BABYLON = threeWorld().obj.newIframe.objIframe.BABYLON;
  381. // @ts-ignore
  382. objHighlightLayerEvent.ChengGuangYuanJing = threeWorld().obj.newIframe.objIframe.ChengGuangYuanJing;
  383. // @ts-ignore
  384. objHighlightLayerEvent.objIframe = threeWorld().obj.newIframe.objIframe;
  385. // 设置回调方法
  386. objHighlightLayerEvent.tipsBtnsUpOpenEventCallback = function(open : Boolean) {
  387. tipsBtnsUpOpenEvent(open);
  388. }
  389. objHighlightLayerEvent.tipsBtnsDownOpenEventCallback = function(open : Boolean) {
  390. tipsBtnsDownOpenEvent(open);
  391. }
  392. }
  393. /**
  394. * 初始化 处理指定物体拖拽逻辑
  395. */
  396. const objDragAndDropEventInit = () => {
  397. // @ts-ignore
  398. objDragAndDropEvent.BABYLON = threeWorld().obj.newIframe.objIframe.BABYLON;
  399. // @ts-ignore
  400. objDragAndDropEvent.ChengGuangYuanJing = threeWorld().obj.newIframe.objIframe.ChengGuangYuanJing;
  401. // @ts-ignore
  402. objDragAndDropEvent.objIframe = threeWorld().obj.newIframe.objIframe;
  403. objDragAndDropEvent.objHighlightLayerEvent = objHighlightLayerEvent;
  404. // 设置回调方法
  405. objDragAndDropEvent.tipsBtnsUpOpenEventCallback = function(open : Boolean) {
  406. tipsBtnsUpOpenEvent(open);
  407. }
  408. objDragAndDropEvent.tipsBtnsDownOpenEventCallback = function(open : Boolean) {
  409. tipsBtnsDownOpenEvent(open);
  410. }
  411. }
  412. /**
  413. * 初始化 根据配置的流程切换对应的3d界面逻辑
  414. */
  415. const objTypeViewEventInit = () => {
  416. // @ts-ignore 记录该对象,全局使用
  417. courseChapter3dShow().show.objTypeViewEvent = objTypeViewEvent;
  418. // @ts-ignore
  419. objTypeViewEvent.BABYLON = threeWorld().obj.newIframe.objIframe.BABYLON;
  420. // @ts-ignore
  421. objTypeViewEvent.ChengGuangYuanJing = threeWorld().obj.newIframe.objIframe.ChengGuangYuanJing;
  422. // @ts-ignore
  423. objTypeViewEvent.objIframe = threeWorld().obj.newIframe.objIframe;
  424. objTypeViewEvent.objHighlightLayerEvent = objHighlightLayerEvent;
  425. // 设置回调方法
  426. objTypeViewEvent.tipsBtnsUpOpenEventCallback = function(open : Boolean) {
  427. tipsBtnsUpOpenEvent(open);
  428. }
  429. objTypeViewEvent.tipsBtnsDownOpenEventCallback = function(open : Boolean) {
  430. tipsBtnsDownOpenEvent(open);
  431. }
  432. objTypeViewEvent.musicConfig = {
  433. "请走到工作区域" : {
  434. // 进入流程播放如何完成任务的声音
  435. // "start" : new URL("./../../assets/music/demo.mp3", import.meta.url).href,
  436. // "start" : new URL("./../../assets/music/threeWorld/tts_audio/startgongzuoquyu.mp3", import.meta.url).href,
  437. "start" : new URL("./../../assets/music/threeWorld/tts_audio_04_09/startgongzuoquyu.mp3", import.meta.url).href,
  438. // 完成任务播放的声音
  439. // "end" : new URL("./../../assets/music/demo2.mp3", import.meta.url).href,
  440. // "end" : new URL("./../../assets/music/threeWorld/tts_audio/endgongzuoquyu.mp3", import.meta.url).href,
  441. "end" : new URL("./../../assets/music/threeWorld/tts_audio_04_09/endgongzuoquyu.mp3", import.meta.url).href,
  442. },
  443. "请点击人物进行穿搭衣服" : {
  444. // "start" : new URL("./../../assets/music/threeWorld/tts_audio/startgongzuofu.mp3", import.meta.url).href,
  445. // "end" : new URL("./../../assets/music/threeWorld/tts_audio/endgongzuofu.mp3", import.meta.url).href,
  446. "start" : new URL("./../../assets/music/threeWorld/tts_audio_04_09/startgongzuofu.mp3", import.meta.url).href,
  447. "end" : new URL("./../../assets/music/threeWorld/tts_audio_04_09/endgongzuofu.mp3", import.meta.url).href,
  448. },
  449. "将四个安全桩放置到正确的位置" : {
  450. // "start" : new URL("./../../assets/music/threeWorld/tts_audio/startanquanzhuang.mp3", import.meta.url).href,
  451. // "end" : new URL("./../../assets/music/threeWorld/tts_audio/endanquanzhuang.mp3", import.meta.url).href,
  452. "start" : new URL("./../../assets/music/threeWorld/tts_audio_04_09/startanquanzhuang.mp3", import.meta.url).href,
  453. "end" : new URL("./../../assets/music/threeWorld/tts_audio_04_09/endanquanzhuang.mp3", import.meta.url).href,
  454. },
  455. "将盒子拆开把设备拿出来" : {
  456. // "start" : new URL("./../../assets/music/threeWorld/tts_audio/startxiangzi.mp3", import.meta.url).href,
  457. // "end" : new URL("./../../assets/music/threeWorld/tts_audio/endxiangzi.mp3", import.meta.url).href,
  458. "start" : new URL("./../../assets/music/threeWorld/tts_audio_04_09/startxiangzi.mp3", import.meta.url).href,
  459. "end" : new URL("./../../assets/music/threeWorld/tts_audio_04_09/endxiangzi.mp3", import.meta.url).href,
  460. },
  461. "将盒子拆开把设备放置在安全的位置" : {
  462. // "start" : new URL("./../../assets/music/threeWorld/tts_audio/startxiangzi.mp3", import.meta.url).href,
  463. // "end" : new URL("./../../assets/music/threeWorld/tts_audio/endxiangzi.mp3", import.meta.url).href,
  464. "start" : new URL("./../../assets/music/threeWorld/tts_audio_04_09/startxiangzi.mp3", import.meta.url).href,
  465. "end" : new URL("./../../assets/music/threeWorld/tts_audio_04_09/endxiangzi.mp3", import.meta.url).href,
  466. },
  467. "将检测机器人6寸轮子安装到正确位置" : {
  468. // "start" : new URL("./../../assets/music/threeWorld/tts_audio/startsixlunzi.mp3", import.meta.url).href,
  469. // "end" : new URL("./../../assets/music/threeWorld/tts_audio/endsixlunzi.mp3.mp3", import.meta.url).href,
  470. "start" : new URL("./../../assets/music/threeWorld/tts_audio_04_09/startsixlunzi.mp3", import.meta.url).href,
  471. "end" : new URL("./../../assets/music/threeWorld/tts_audio_04_09/endsixlunzi.mp3", import.meta.url).href,
  472. },
  473. "将检测机器人的轮子安装到正确的位置" : {
  474. // "start" : new URL("./../../assets/music/threeWorld/tts_audio/starttenlunzi.mp3", import.meta.url).href,
  475. // "end" : new URL("./../../assets/music/threeWorld/tts_audio/enttenlunzi.mp3.mp3", import.meta.url).href,
  476. "start" : new URL("./../../assets/music/threeWorld/tts_audio_04_09/starttenlunzi.mp3", import.meta.url).href,
  477. "end" : new URL("./../../assets/music/threeWorld/tts_audio_04_09/enttenlunzi.mp3", import.meta.url).href,
  478. },
  479. "将检测机器人6寸右侧轮子安装到正确位置" : {
  480. // "start" : new URL("./../../assets/music/threeWorld/tts_audio_1/startSixChunLunZiYouChe.mp3", import.meta.url).href,
  481. // "end" : new URL("./../../assets/music/threeWorld/tts_audio_1/endSixChunLunZiYouChe.mp3", import.meta.url).href,
  482. "start" : new URL("./../../assets/music/threeWorld/tts_audio_04_09/startSixChunLunZiYouChe.mp3", import.meta.url).href,
  483. "end" : new URL("./../../assets/music/threeWorld/tts_audio_04_09/endSixChunLunZiYouChe.mp3", import.meta.url).href,
  484. },
  485. "将检测机器人6寸左侧轮子安装到正确位置" : {
  486. // "start" : new URL("./../../assets/music/threeWorld/tts_audio_1/startSixChunLunZiZuoChe.mp3", import.meta.url).href,
  487. // "end" : new URL("./../../assets/music/threeWorld/tts_audio_1/endSixChunLunZiZuoChe.mp3", import.meta.url).href,
  488. "start" : new URL("./../../assets/music/threeWorld/tts_audio_04_09/startSixChunLunZiZuoChe.mp3", import.meta.url).href,
  489. "end" : new URL("./../../assets/music/threeWorld/tts_audio_04_09/endSixChunLunZiZuoChe.mp3", import.meta.url).href,
  490. },
  491. "将检测机器人10寸右侧轮子安装到正确位置" : {
  492. // "start" : new URL("./../../assets/music/threeWorld/tts_audio_1/startTenChunLunZiYouChe.mp3", import.meta.url).href,
  493. // "end" : new URL("./../../assets/music/threeWorld/tts_audio_1/endTenChunLunZiYouChe.mp3", import.meta.url).href,
  494. "start" : new URL("./../../assets/music/threeWorld/tts_audio_04_09/startTenChunLunZiYouChe.mp3", import.meta.url).href,
  495. "end" : new URL("./../../assets/music/threeWorld/tts_audio_04_09/endTenChunLunZiYouChe.mp3", import.meta.url).href,
  496. },
  497. "将检测机器人10寸左侧轮子安装到正确位置" : {
  498. // "start" : new URL("./../../assets/music/threeWorld/tts_audio_1/startTenChunLunZiZuoChe.mp3", import.meta.url).href,
  499. // "end" : new URL("./../../assets/music/threeWorld/tts_audio_1/endTenChunLunZiZuoChe.mp3", import.meta.url).href,
  500. "start" : new URL("./../../assets/music/threeWorld/tts_audio_04_09/startTenChunLunZiZuoChe.mp3", import.meta.url).href,
  501. "end" : new URL("./../../assets/music/threeWorld/tts_audio_04_09/endTenChunLunZiZuoChe.mp3", import.meta.url).href,
  502. },
  503. "将检测机器人的防撞杆安装到正确的位置" : {
  504. // "start" : new URL("./../../assets/music/threeWorld/tts_audio/startfangzhuanggan.mp3", import.meta.url).href,
  505. // "end" : new URL("./../../assets/music/threeWorld/tts_audio/endfangzhuanggan.mp3", import.meta.url).href,
  506. "start" : new URL("./../../assets/music/threeWorld/tts_audio_04_09/startfangzhuanggan.mp3", import.meta.url).href,
  507. "end" : new URL("./../../assets/music/threeWorld/tts_audio_04_09/endfangzhuanggan.mp3", import.meta.url).href,
  508. },
  509. "将检测机器人的防撞杆锁安装到正确的位置" : {
  510. // "start" : new URL("./../../assets/music/threeWorld/tts_audio/startfangzhuanggansuo.mp3", import.meta.url).href,
  511. // "end" : new URL("./../../assets/music/threeWorld/tts_audio/endfangzhuanggansuo.mp3", import.meta.url).href,
  512. "start" : new URL("./../../assets/music/threeWorld/tts_audio_04_09/startfangzhuanggansuo.mp3", import.meta.url).href,
  513. "end" : new URL("./../../assets/music/threeWorld/tts_audio_04_09/endfangzhuanggansuo.mp3", import.meta.url).href,
  514. },
  515. "将检测机器人的镜头架安装到正确的位置" : {
  516. // "start" : new URL("./../../assets/music/threeWorld/tts_audio/startxiangji.mp3", import.meta.url).href,
  517. // "end" : new URL("./../../assets/music/threeWorld/tts_audio/endxiangji.mp3", import.meta.url).href,
  518. "start" : new URL("./../../assets/music/threeWorld/tts_audio_04_09/startxiangji.mp3", import.meta.url).href,
  519. "end" : new URL("./../../assets/music/threeWorld/tts_audio_04_09/endxiangji.mp3", import.meta.url).href,
  520. },
  521. "将检测机器人的相机安装到正确的位置" : {
  522. // "start" : new URL("./../../assets/music/threeWorld/tts_audio/startxiangji.mp3", import.meta.url).href,
  523. // "end" : new URL("./../../assets/music/threeWorld/tts_audio/endxiangji.mp3", import.meta.url).href,
  524. "start" : new URL("./../../assets/music/threeWorld/tts_audio_04_09/startxiangji.mp3", import.meta.url).href,
  525. "end" : new URL("./../../assets/music/threeWorld/tts_audio_04_09/endxiangji.mp3", import.meta.url).href,
  526. },
  527. "将绕线车的电源线安装到正确的位置" : {
  528. // "start" : new URL("./../../assets/music/threeWorld/tts_audio/startdianyuanxian.mp3", import.meta.url).href,
  529. // "end" : new URL("./../../assets/music/threeWorld/tts_audio/enddianyuanxian.mp3", import.meta.url).href,
  530. "start" : new URL("./../../assets/music/threeWorld/tts_audio_04_09/startdianyuanxian.mp3", import.meta.url).href,
  531. "end" : new URL("./../../assets/music/threeWorld/tts_audio_04_09/enddianyuanxian.mp3", import.meta.url).href,
  532. },
  533. "将绕线车的纠偏轮安装到正确的位置" : {
  534. // "start" : new URL("./../../assets/music/threeWorld/tts_audio/startjiupianlun.mp3", import.meta.url).href,
  535. // "end" : new URL("./../../assets/music/threeWorld/tts_audio/endjiupianlun.mp3", import.meta.url).href,
  536. "start" : new URL("./../../assets/music/threeWorld/tts_audio_04_09/startjiupianlun.mp3", import.meta.url).href,
  537. "end" : new URL("./../../assets/music/threeWorld/tts_audio_04_09/endjiupianlun.mp3", import.meta.url).href,
  538. },
  539. "将绕线车的锂电池安装到正确的位置" : {
  540. // "start" : new URL("./../../assets/music/threeWorld/tts_audio/startlidianchi.mp3", import.meta.url).href,
  541. // "end" : new URL("./../../assets/music/threeWorld/tts_audio/endlidianchi.mp3", import.meta.url).href,
  542. "start" : new URL("./../../assets/music/threeWorld/tts_audio_04_09/startlidianchi.mp3", import.meta.url).href,
  543. "end" : new URL("./../../assets/music/threeWorld/tts_audio_04_09/endlidianchi.mp3", import.meta.url).href,
  544. },
  545. "将绕线车的电脑主机放置到正确的位置" : {
  546. // "start" : new URL("./../../assets/music/threeWorld/tts_audio/startdiannaozhuji.mp3", import.meta.url).href,
  547. // "end" : new URL("./../../assets/music/threeWorld/tts_audio/enddiannaozhuji.mp3", import.meta.url).href,
  548. "start" : new URL("./../../assets/music/threeWorld/tts_audio_04_09/startdiannaozhuji.mp3", import.meta.url).href,
  549. "end" : new URL("./../../assets/music/threeWorld/tts_audio_04_09/enddiannaozhuji.mp3", import.meta.url).href,
  550. },
  551. "将绕线车的手柄安装到正确的位置" : {
  552. // "start" : new URL("./../../assets/music/threeWorld/tts_audio/startCaoZuoShouBin.mp3", import.meta.url).href,
  553. // "end" : new URL("./../../assets/music/threeWorld/tts_audio/endCaoZuoShouBin.mp3", import.meta.url).href,
  554. "start" : new URL("./../../assets/music/threeWorld/tts_audio_04_09/startCaoZuoShouBin.mp3", import.meta.url).href,
  555. "end" : new URL("./../../assets/music/threeWorld/tts_audio_04_09/endCaoZuoShouBin.mp3", import.meta.url).href,
  556. },
  557. "将绕线车的电缆安装到正确的位置" : {
  558. // "start" : new URL("./../../assets/music/threeWorld/tts_audio/startDianLan.mp3", import.meta.url).href,
  559. // "end" : new URL("./../../assets/music/threeWorld/tts_audio/endDianLan.mp3", import.meta.url).href,
  560. "start" : new URL("./../../assets/music/threeWorld/tts_audio_04_09/startDianLan.mp3", import.meta.url).href,
  561. "end" : new URL("./../../assets/music/threeWorld/tts_audio_04_09/endDianLan.mp3", import.meta.url).href,
  562. },
  563. "抬升支架降至最低" : {
  564. // "start" : new URL("./../../assets/music/threeWorld/tts_audio/startZhiJia.mp3", import.meta.url).href,
  565. // "end" : new URL("./../../assets/music/threeWorld/tts_audio/endZhiJia.mp3", import.meta.url).href,
  566. "start" : new URL("./../../assets/music/threeWorld/tts_audio_04_09/startZhiJia.mp3", import.meta.url).href,
  567. "end" : new URL("./../../assets/music/threeWorld/tts_audio_04_09/endZhiJia.mp3", import.meta.url).href,
  568. },
  569. "镜头旋转至正上方" : {
  570. // "start" : new URL("./../../assets/music/threeWorld/tts_audio/startXiangJiShang.mp3", import.meta.url).href,
  571. // "end" : new URL("./../../assets/music/threeWorld/tts_audio/endXiangJiShang.mp3", import.meta.url).href,
  572. "start" : new URL("./../../assets/music/threeWorld/tts_audio_04_09/startXiangJiShang.mp3", import.meta.url).href,
  573. "end" : new URL("./../../assets/music/threeWorld/tts_audio_04_09/endXiangJiShang.mp3", import.meta.url).href,
  574. },
  575. "镜头归位" : {
  576. // "start" : new URL("./../../assets/music/threeWorld/tts_audio/startXiangJiGuiWei.mp3", import.meta.url).href,
  577. // "end" : new URL("./../../assets/music/threeWorld/tts_audio/endXiangJiGuiWei.mp3", import.meta.url).href,
  578. "start" : new URL("./../../assets/music/threeWorld/tts_audio_04_09/startXiangJiGuiWei.mp3", import.meta.url).href,
  579. "end" : new URL("./../../assets/music/threeWorld/tts_audio_04_09/endXiangJiGuiWei.mp3", import.meta.url).href,
  580. },
  581. "调节行驶方向正确放置过线滑轮" : {
  582. // "start" : new URL("./../../assets/music/threeWorld/tts_audio/startXingShiFangXiang.mp3", import.meta.url).href,
  583. // "end" : new URL("./../../assets/music/threeWorld/tts_audio/endXingShiFangXiang.mp3", import.meta.url).href,
  584. "start" : new URL("./../../assets/music/threeWorld/tts_audio_04_09/startXingShiFangXiang.mp3", import.meta.url).href,
  585. "end" : new URL("./../../assets/music/threeWorld/tts_audio_04_09/endXingShiFangXiang.mp3", import.meta.url).href,
  586. },
  587. "打开井盖" : {
  588. // "start" : new URL("./../../assets/music/threeWorld/tts_audio/startJingGai.mp3", import.meta.url).href,
  589. // "end" : new URL("./../../assets/music/threeWorld/tts_audio/endJingGai.mp3", import.meta.url).href,
  590. "start" : new URL("./../../assets/music/threeWorld/tts_audio_04_09/startJingGai.mp3", import.meta.url).href,
  591. "end" : new URL("./../../assets/music/threeWorld/tts_audio_04_09/endJingGai.mp3", import.meta.url).href,
  592. },
  593. "车辆超速" : {
  594. // "carSpeeding" : new URL("./../../assets/music/threeWorld/tts_audio_1/chaoSuTiXing.mp3", import.meta.url).href,
  595. "carSpeeding" : new URL("./../../assets/music/threeWorld/tts_audio_04_09/chaoSuTiXing.mp3", import.meta.url).href,
  596. },
  597. "爬行器" : {
  598. "introduce" : new URL("./../../assets/music/audio/paXingQi.mp3", import.meta.url).href,
  599. },
  600. "爬行器_LED前灯" : {
  601. "introduce" : new URL("./../../assets/music/audio/paXingQiLedQianDeng.mp3", import.meta.url).href,
  602. },
  603. "爬行器_防撞杆" : {
  604. "introduce" : new URL("./../../assets/music/audio/paXingQiFangZhuangGan.mp3", import.meta.url).href,
  605. },
  606. "爬行器_后置相机" : {
  607. "introduce" : new URL("./../../assets/music/audio/paXingQiHouZhiXiangJi.mp3", import.meta.url).href,
  608. },
  609. "爬行器_检测车身" : {
  610. "introduce" : new URL("./../../assets/music/audio/paXingQiJianCheCheShen.mp3", import.meta.url).href,
  611. },
  612. "爬行器_连接线缆" : {
  613. "introduce" : new URL("./../../assets/music/audio/paXingQiLianJieXianLan.mp3", import.meta.url).href,
  614. },
  615. "爬行器_轮子" : {
  616. "introduce" : new URL("./../../assets/music/audio/paXingQiLunZi.mp3", import.meta.url).href,
  617. },
  618. "爬行器_前置相机" : {
  619. "introduce" : new URL("./../../assets/music/audio/paXingQiQianZhiXiangJi.mp3", import.meta.url).href,
  620. },
  621. "爬行器_升降支架" : {
  622. "introduce" : new URL("./../../assets/music/audio/paXingQiShengJiangZhiJia.mp3", import.meta.url).href,
  623. },
  624. "线缆卷盘" : {
  625. "introduce" : new URL("./../../assets/music/audio/xianLanJuanPan.mp3", import.meta.url).href,
  626. },
  627. "线缆卷盘_电源连线" : {
  628. "introduce" : new URL("./../../assets/music/audio/xianLanJuanPanDianYuanLianXian.mp3", import.meta.url).href,
  629. },
  630. "线缆卷盘_控制手柄" : {
  631. "introduce" : new URL("./../../assets/music/audio/xianLanJuanPanKongZhiShouBing.mp3", import.meta.url).href,
  632. },
  633. "线缆卷盘_控制终端" : {
  634. "introduce" : new URL("./../../assets/music/audio/xianLanJuanPanKongZhiZhongDuan.mp3", import.meta.url).href,
  635. },
  636. "线缆卷盘_锂电池" : {
  637. "introduce" : new URL("./../../assets/music/audio/xianLanJuanPanLiDianChi.mp3", import.meta.url).href,
  638. },
  639. "线缆卷盘_连接线缆" : {
  640. "introduce" : new URL("./../../assets/music/audio/xianLanJuanPanLianJieXianLan.mp3", import.meta.url).href,
  641. },
  642. }
  643. }
  644. /**
  645. * 初始化 3d渲染帧事件处理
  646. */
  647. const objRenderEventInit = () => {
  648. // @ts-ignore
  649. objRenderEvent.BABYLON = threeWorld().obj.newIframe.objIframe.BABYLON;
  650. // @ts-ignore
  651. objRenderEvent.ChengGuangYuanJing = threeWorld().obj.newIframe.objIframe.ChengGuangYuanJing;
  652. // @ts-ignore
  653. objRenderEvent.objIframe = threeWorld().obj.newIframe.objIframe;
  654. // 设置回调方法
  655. objRenderEvent.tipsBtnsUpOpenEventCallback = function(open : Boolean) {
  656. tipsBtnsUpOpenEvent(open);
  657. }
  658. objRenderEvent.tipsBtnsDownOpenEventCallback = function(open : Boolean) {
  659. tipsBtnsDownOpenEvent(open);
  660. }
  661. }
  662. setInterval(function() {
  663. // 如果没有加载完成,则不触发后面的逻辑
  664. if (threeWorld().loadSuccess == false) {
  665. return;
  666. }
  667. // 更新时间
  668. var cur = new Date(); // 创建当前日期对象 cur
  669. var years = cur.getFullYear(); // 从日期对象cur中取得年数
  670. var months = cur.getMonth() + 1; // 取得月数
  671. var days = cur.getDate(); // 取得天数
  672. var hours = cur.getHours(); // 取得小时数
  673. var minutes = cur.getMinutes(); // 取得分钟数
  674. courseChapter3dShow().show.showCarEyeYears = years;
  675. courseChapter3dShow().show.showCarEyeMonths = months;
  676. courseChapter3dShow().show.showCarEyeDays = days;
  677. courseChapter3dShow().show.showCarEyeHours = hours;
  678. courseChapter3dShow().show.showCarEyeMinutes = minutes;
  679. }, 1000);
  680. /**
  681. * 监听是否点击 进入活动,或者是点击屏幕进入3d场景回调
  682. */
  683. const goPlayCallbackEventMain = () => {
  684. if (
  685. // @ts-ignore
  686. threeWorld().obj.newIframe.objIframe.window["goPlayCallbackEvent"] != null
  687. // @ts-ignore
  688. && threeWorld().obj.newIframe.objIframe.window["goPlayCallbackEvent"] != undefined
  689. ) {
  690. return;
  691. }
  692. // @ts-ignore
  693. threeWorld().obj.newIframe.objIframe.window["goPlayCallbackEvent"] = function(res : any) {
  694. // console.log(
  695. // " ========== 监听是否点击 进入活动,或者是点击屏幕进入3d场景 ========== ",
  696. // res
  697. // );
  698. setTimeout(function() {
  699. initScene();
  700. }, 200);
  701. }
  702. }
  703. /**
  704. * 记录点击的时候最后的时间戳
  705. * 用于后续,点击放开后,是否触发增加点击的值的逻辑
  706. */
  707. let clickTime = ref(0);
  708. /**
  709. * 控制多少毫秒触发一次逻辑
  710. */
  711. let threeEventRenderTime = 0;
  712. /**
  713. * 控制多少毫秒触发一次逻辑
  714. */
  715. let threeEventRenderTimeTwo = 0;
  716. /**
  717. * 控制多少毫秒触发一次逻辑
  718. */
  719. let threeEventRenderTimeThree = 0;
  720. /**
  721. * 符合条件下,判断鼠标移动到执行的物体后,更换样式
  722. * 控制多少毫秒执行一次,不要过于频繁,影响性能
  723. */
  724. const moveUpdateMouseStyle = () => {
  725. if (courseChapter3dShow().show.pickResultMoveBool == true) {
  726. courseChapter3dShow().show.showTxtViewBool = false;
  727. return;
  728. }
  729. // 当前的步骤状态
  730. let statue = props.config?.threeDimensionalConfig;
  731. if (
  732. statue == "将四个安全桩放置到正确的位置"
  733. || statue == "将检测机器人6寸轮子安装到正确位置"
  734. || statue == "将检测机器人的轮子安装到正确的位置"
  735. || statue == "将检测机器人6寸右侧轮子安装到正确位置"
  736. || statue == "将检测机器人6寸左侧轮子安装到正确位置"
  737. || statue == "将检测机器人10寸右侧轮子安装到正确位置"
  738. || statue == "将检测机器人10寸左侧轮子安装到正确位置"
  739. || statue == "将检测机器人的防撞杆安装到正确的位置"
  740. || statue == "将检测机器人的防撞杆锁安装到正确的位置"
  741. || statue == "将检测机器人的镜头架安装到正确的位置"
  742. || statue == "将检测机器人的相机安装到正确的位置"
  743. || statue == "将绕线车的电源线安装到正确的位置"
  744. || statue == "将绕线车的纠偏轮安装到正确的位置"
  745. || statue == "将绕线车的锂电池安装到正确的位置"
  746. || statue == "将绕线车的电脑主机放置到正确的位置"
  747. || statue == "将绕线车的手柄安装到正确的位置"
  748. || statue == "将绕线车的电缆安装到正确的位置"
  749. || statue == "抬升支架降至最低"
  750. || statue == "镜头旋转至正上方"
  751. || statue == "镜头归位"
  752. || statue == "打开井盖"
  753. ) {
  754. // @ts-ignore
  755. let objScene = threeWorld().obj.newIframe.objIframe.ChengGuangYuanJing.CommonVal.find().objScene;
  756. // 获取选择的对象, 通过测试 scene.pick() 方法是非常消耗性能的
  757. let pickResultMove = objScene.pick(
  758. objScene.pointerX,
  759. objScene.pointerY
  760. );
  761. // console.log(
  762. // " 鼠标移动的坐标位置 moveUpdateMouseStyle = () => { ",
  763. // objScene.pointerX,
  764. // objScene.pointerY
  765. // );
  766. if (pickResultMove.hit) {
  767. let objMesh = pickResultMove.pickedMesh;
  768. let thisClickPosition = pickResultMove.pickedPoint;
  769. // console.log(
  770. // "符合条件判断是否更新鼠标样式",
  771. // objMesh.id,
  772. // thisClickPosition
  773. // );
  774. // 符合手势的列表
  775. let meshList = [
  776. "model_1709892139359安全桩001",
  777. "model_1709892139359安全桩004",
  778. "model_1709892139359安全桩003",
  779. "model_1709892139359安全桩002",
  780. "exhibition_html_1710385814466_10”后轮左_primitive0",
  781. "exhibition_html_1710385814466_10”后轮左_primitive1",
  782. "exhibition_html_1710385814466_10”后轮左_primitive2",
  783. "exhibition_html_1710385814466_10”前轮左_primitive0",
  784. "exhibition_html_1710385814466_10”前轮左_primitive1",
  785. "exhibition_html_1710385814466_10”前轮左_primitive2",
  786. "exhibition_html_1710385814466_10”后轮右_primitive0",
  787. "exhibition_html_1710385814466_10”后轮右_primitive1",
  788. "exhibition_html_1710385814466_10”后轮右_primitive2",
  789. "exhibition_html_1710385814466_10”前轮右_primitive0",
  790. "exhibition_html_1710385814466_10”前轮右_primitive1",
  791. "exhibition_html_1710385814466_10”前轮右_primitive2",
  792. "exhibition_html_1710385814466_6”后轮左_primitive0",
  793. "exhibition_html_1710385814466_6”后轮左_primitive1",
  794. "exhibition_html_1710385814466_6”中轮左_primitive0",
  795. "exhibition_html_1710385814466_6”中轮左_primitive1",
  796. "exhibition_html_1710385814466_6”前轮左_primitive0",
  797. "exhibition_html_1710385814466_6”前轮左_primitive0",
  798. "exhibition_html_1710385814466_6”后轮右_primitive0",
  799. "exhibition_html_1710385814466_6”后轮右_primitive0",
  800. "exhibition_html_1710385814466_6”中轮右_primitive0",
  801. "exhibition_html_1710385814466_6”中轮右_primitive1",
  802. "exhibition_html_1710385814466_6”前轮右_primitive0",
  803. "exhibition_html_1710385814466_6”前轮右_primitive1",
  804. "exhibition_html_1710385814466_防撞杆_primitive0",
  805. "exhibition_html_1710385814466_防撞杆_primitive1",
  806. "exhibition_html_1710385814466_防撞杆锁_primitive0",
  807. "exhibition_html_1710385814466_防撞杆锁_primitive1",
  808. "exhibition_html_1710385814466_镜头架_primitive0",
  809. "exhibition_html_1710385814466_镜头架_primitive1",
  810. "exhibition_html_1710385814466_镜头架_primitive2",
  811. "exhibition_html_1710385814466_镜头架_primitive3",
  812. "exhibition_html_1710385814466_相机_primitive0",
  813. "exhibition_html_1710385814466_相机_primitive1",
  814. "exhibition_html_1710385814466_相机_primitive2",
  815. "exhibition_html_1710385814466_相机_primitive3",
  816. "exhibition_html_1757573408562_绕线车-电源线",
  817. "exhibition_html_1710385814466_绕线车-纠偏轮_primitive0",
  818. "exhibition_html_1710385814466_绕线车-纠偏轮_primitive1",
  819. "exhibition_html_1710385814466_锂电池_primitive0",
  820. "exhibition_html_1710385814466_锂电池_primitive1",
  821. "exhibition_html_1710385814466_锂电池_primitive2",
  822. "exhibition_html_1710385814466_电脑屏幕_primitive0",
  823. "exhibition_html_1710385814466_电脑屏幕_primitive1",
  824. "exhibition_html_1710385814466_电脑屏幕_primitive2",
  825. "exhibition_html_1710385814466_电脑主机_primitive0",
  826. "exhibition_html_1710385814466_电脑主机_primitive1",
  827. "exhibition_html_1710385814466_电脑主机_primitive2",
  828. "exhibition_html_1710385814466_电脑主机_primitive3",
  829. "exhibition_html_1710385814466_手柄_primitive0",
  830. "exhibition_html_1710385814466_手柄_primitive1",
  831. "exhibition_html_1710385814466_手柄_primitive2",
  832. "exhibition_html_1710385814466_手柄_primitive3",
  833. "exhibition_html_1710385814466_电缆01_primitive0",
  834. "exhibition_html_1710385814466_电缆01_primitive1",
  835. "exhibition_html_1710385814466_绕线车-电缆",
  836. "model_1712911455459井盖002",
  837. "exhibition_html_1710385814466_上机_primitive0",
  838. "exhibition_html_1710385814466_上机_primitive1",
  839. "exhibition_html_1710385814466_上机_primitive2",
  840. "exhibition_html_1710385814466_上机_primitive3",
  841. "exhibition_html_1710385814466_上机_primitive4",
  842. "exhibition_html_1710385814466_上机_primitive5",
  843. ];
  844. for (let i = 0; i < meshList.length; i++) {
  845. let thisMeshList = meshList[i];
  846. if (thisMeshList == objMesh.id) {
  847. objDragAndDropEvent.iframeCanvasStyle("pointer");
  848. if (
  849. // @ts-ignore
  850. threeWorld().obj.meshEvent[objMesh.id] != null
  851. // @ts-ignore
  852. && threeWorld().obj.meshEvent[objMesh.id] != undefined
  853. ) {
  854. // @ts-ignore
  855. let thisMeshEvent = threeWorld().obj.meshEvent[objMesh.id];
  856. courseChapter3dShow().show.showTxtViewBool = true;
  857. courseChapter3dShow().show.showTxtContent = thisMeshEvent.txt;
  858. courseChapter3dShow().show.showTxtViewX = objScene.pointerX + 20;
  859. courseChapter3dShow().show.showTxtViewY = objScene.pointerY - 20;
  860. }
  861. return;
  862. }
  863. }
  864. objDragAndDropEvent.iframeCanvasStyle("normal");
  865. courseChapter3dShow().show.showTxtViewBool = false;
  866. }
  867. }
  868. }
  869. /**
  870. * 设置3d事件
  871. */
  872. const threeEvent = () => {
  873. // @ts-ignore
  874. let objScene = threeWorld().obj.newIframe.objIframe.ChengGuangYuanJing.CommonVal.find().objScene;
  875. /**
  876. * 可以被追加事件的API【 可以不断追加进来 】
  877. */
  878. // @ts-ignore
  879. threeWorld().obj.newIframe.objIframe.ChengGuangYuanJing.CommonVal.find().objScene.onPointerObservable.add(
  880. (pointerInfo : any) => {
  881. // console.log(
  882. // " ============================== 鼠标事件触发了 ============================== ",
  883. // pointerInfo.pickInfo,
  884. // pointerInfo.pickInfo.hit
  885. // );
  886. // 当前的步骤状态
  887. let statue = props.config?.threeDimensionalConfig;
  888. if (courseChapter3dShow().show.pickResultMoveBool == true) {
  889. courseChapter3dShow().show.showDirectionViewBool = false;
  890. courseChapter3dShow().show.showClickRotationViewBool = false;
  891. // 获取选择的对象, 通过测试 scene.pick() 方法是非常消耗性能的
  892. let pickResultMove = objScene.pick(
  893. objScene.pointerX,
  894. objScene.pointerY
  895. );
  896. if (pickResultMove.hit) {
  897. // console.log(
  898. // "鼠标移动触发逻辑",
  899. // "pickResultMove", pickResultMove
  900. // );
  901. objDragAndDropEvent.threeWorldPointerMove(pickResultMove, statue);
  902. objDragAndDropEvent.dragAndDropMove(pickResultMove, statue);
  903. }
  904. }
  905. // 如果点击到3d世界里的物体的时候
  906. if (pointerInfo.pickInfo.hit) {
  907. var pickResult = pointerInfo.pickInfo;
  908. // console.log(
  909. // " threeEvent = () => { 鼠标事件 》》》》》》》》》》 ", pickResult
  910. // );
  911. // // 获取点击对象的方向【 一定要加上 true,否则载入的获取模型的方向,会有问题 】
  912. // var getNormal = pickResult.getNormal(true);
  913. // console.log({
  914. // '事件' : 'lickType 鼠标事件点击到物体了',
  915. // '被点击到的物体' : pickResult,
  916. // '坐标' : pickResult.pickedPoint,
  917. // '被点击的物体的名字' : pickResult.pickedMesh.name,
  918. // '被点击物体的材质' : pickResult.pickedMesh.material,
  919. // '获取点击对象的方向' : getNormal,
  920. // '得到点击物体的所有点位集合[ 物体都是通过很多点为链接而形成的,可以通过这个方法知道物体的最大尺寸,或者最小尺寸等 ]' : pickResult.pickedMesh._geometry._positions,
  921. // '得到被点击物体的绝对坐标,后续该坐标例如取中心点垂直就很有用处【3d模型如果错位,说明是3d建模把模型给合并导致的,需要跟对方沟通,让模型单独】' : pickResult.pickedMesh._absolutePosition
  922. // });
  923. switch (pointerInfo.type) {
  924. case BABYLON.PointerEventTypes.POINTERDOWN:
  925. // console.log("clickType 鼠标按下");
  926. courseChapter3dShow().show.showDirectionViewBool = false;
  927. courseChapter3dShow().show.showClickRotationViewBool = false;
  928. clickTime.value = new Date().getTime();
  929. objDragAndDropEvent.dragAndDropClick( pickResult, statue );
  930. break;
  931. case BABYLON.PointerEventTypes.POINTERUP:
  932. // console.log("clickType 鼠标弹起");
  933. let thisTime = new Date().getTime();
  934. // 距离点击的时间
  935. let distanceTime = thisTime - clickTime.value;
  936. // console.log(
  937. // "distanceTime", distanceTime
  938. // );
  939. objDragAndDropEvent.dragAndDropPointerup(pickResult, statue);
  940. /**
  941. * 低于200毫秒,则为触发增加值的逻辑
  942. * 否则,就是用户平时旋转3d场景的逻辑
  943. */
  944. if (distanceTime <= 200) {
  945. // console.log(
  946. // " 鼠标点击弹起了 threeEvent = () => { ", pickResult.pickedMesh
  947. // );
  948. objDragAndDropEvent.threeWorldPointerupEvent(pickResult, statue);
  949. // // 这里的拖拽逻辑,暂时取消
  950. // gizmoManagerEvent(pickResult.pickedMesh);
  951. objTypeViewEvent.wearingClothes(pickResult.pickedMesh, statue);
  952. objTypeViewEvent.openBox(pickResult.pickedMesh, statue);
  953. objTypeViewEvent.openCable(pickResult.pickedMesh, statue);
  954. objTypeViewEvent.openSupport(pickResult.pickedMesh, statue);
  955. objTypeViewEvent.openShotUp(pickResult.pickedMesh, statue);
  956. objTypeViewEvent.openShotRet(pickResult.pickedMesh, statue);
  957. objTypeViewEvent.openManholeCover(pickResult.pickedMesh, statue);
  958. }
  959. break;
  960. case BABYLON.PointerEventTypes.POINTERMOVE:
  961. // console.log("clickType 鼠标移动中");
  962. break;
  963. case BABYLON.PointerEventTypes.POINTERWHEEL:
  964. // console.log("clickType 鼠标滚轮滚动中");
  965. break;
  966. case BABYLON.PointerEventTypes.POINTERPICK:
  967. // console.log("clickType 鼠标指针选中事件");
  968. break;
  969. case BABYLON.PointerEventTypes.POINTERTAP:
  970. // console.log("clickType 当对象被触摸并在没有拖动的情况下释放时,触发指针触发事件。");
  971. break;
  972. case BABYLON.PointerEventTypes.POINTERDOUBLETAP:
  973. // console.log("clickType 鼠标双击");
  974. break;
  975. }
  976. }
  977. });
  978. // @ts-ignore 添加帧事件
  979. threeWorld().obj.newIframe.objIframe.ChengGuangYuanJing.CommonVal.find().objScene.onBeforeRenderObservable.add(function() {
  980. // 当前的步骤状态
  981. let statue = props.config?.threeDimensionalConfig;
  982. let thisTime = new Date().getTime();
  983. if (thisTime - threeEventRenderTime >= 1000) {
  984. threeEventRenderTime = thisTime;
  985. objRenderEvent.updateCarDb();
  986. objTypeViewEvent.arcRotateCameraCarPushEvent();
  987. carStatusEvent();
  988. objRenderEvent.workEvent(statue);
  989. }
  990. if (thisTime - threeEventRenderTimeTwo >= 3000) {
  991. threeEventRenderTimeTwo = thisTime;
  992. // 自动降挡
  993. objRenderEvent.carMoveLvEvent('moderate');
  994. }
  995. if (thisTime - threeEventRenderTimeThree >= 300) {
  996. threeEventRenderTimeThree = thisTime;
  997. moveUpdateMouseStyle();
  998. }
  999. carCameraAlphaAndBetaNew();
  1000. objTypeViewEvent.arcRotateCameraCarEvent();
  1001. objTypeViewEvent.spotLightCameraEvent();
  1002. objDragAndDropEvent.cameraVisualAngleUpdate();
  1003. objHighlightLayerEvent.updateSize();
  1004. // console.log(
  1005. // " 每帧在执行 threeWorld().obj.newIframe.objIframe.ChengGuangYuanJing.CommonVal.find().objScene.onBeforeRenderObservable.add(function() { "
  1006. // );
  1007. });
  1008. }
  1009. // 是否因为,移动后停止了
  1010. let moveToStop = true;
  1011. // 控制播放超速声音的时间戳,不需要太频繁播放声音
  1012. let speedingMusicPlayTime = 0;
  1013. /**
  1014. * 通过车的不同状态,控制前进还是倒退的逻辑
  1015. */
  1016. const carStatusEvent = () => {
  1017. // console.log(
  1018. // "carStatusEvent = () => {",
  1019. // courseChapter3dShow().show.carStatus,
  1020. // courseChapter3dShow().show.carMoveLv,
  1021. // courseChapter3dShow().show.carMoveSpeed,
  1022. // );
  1023. // 超速提示
  1024. courseChapter3dShow().show.showCarEyeViewBoolSpeeding = courseChapter3dShow().show.carMoveLv >= 8 ? true : false;
  1025. var thisTime = new Date().getTime();
  1026. if (
  1027. // 如果超速
  1028. courseChapter3dShow().show.showCarEyeViewBoolSpeeding == true
  1029. && (thisTime - speedingMusicPlayTime) >= 3500
  1030. ) {
  1031. speedingMusicPlayTime = thisTime;
  1032. objTypeViewEvent.musicConfigPlay(
  1033. "车辆超速", "carSpeeding"
  1034. );
  1035. }
  1036. // 得到最顶部距离的值
  1037. let showCarEyeDistanceMax = (pipelineProblemsArrayEventList.length - 2 - distanceXBoolSum) * 29.94;
  1038. showCarEyeDistanceMax -= (29.94 / 2);
  1039. // 由于多出了个出生点与坐标点的距离差
  1040. showCarEyeDistanceMax += courseChapter3dShow().show.lineDistance;
  1041. // console.log(
  1042. // " 得到最顶部距离的值 showCarEyeDistanceMax ",
  1043. // showCarEyeDistanceMax
  1044. // );
  1045. // console.log(
  1046. // "距离判断是否到最顶位置",
  1047. // // pipelineProblemsArrayEventList.length,
  1048. // // showCarEyeDistanceMax,
  1049. // // courseChapter3dShow().show.showCarEyeDistance,
  1050. // // courseChapter3dShow().show.birthPointRecord,
  1051. // // courseChapter3dShow().show.carPointRecord,
  1052. // // courseChapter3dShow().show.birthPointRecord.x,
  1053. // // courseChapter3dShow().show.carPointRecord.x,
  1054. // );
  1055. if (
  1056. // 前视
  1057. courseChapter3dShow().show.lookAfterOrFront == "front"
  1058. // && courseChapter3dShow().show.showCarEyeDistance >= 476
  1059. && courseChapter3dShow().show.showCarEyeDistance >= showCarEyeDistanceMax
  1060. ) {
  1061. courseChapter3dShow().show.showCarEyeViewBoolSpeeding2 = true;
  1062. } else if (
  1063. // 后视
  1064. courseChapter3dShow().show.lookAfterOrFront == "after"
  1065. // && courseChapter3dShow().show.showCarEyeDistance <= 7.3
  1066. && courseChapter3dShow().show.showCarEyeDistance <= 1
  1067. ) {
  1068. courseChapter3dShow().show.showCarEyeViewBoolSpeeding2 = true;
  1069. } else {
  1070. courseChapter3dShow().show.showCarEyeViewBoolSpeeding2 = false;
  1071. }
  1072. // 如果是停止移动了
  1073. if (courseChapter3dShow().show.carStatus == "stopMove") {
  1074. // 此时说明要停止移动了
  1075. if (moveToStop == false) {
  1076. // 触发键盘的停止逻辑
  1077. // @ts-ignore
  1078. threeWorld().obj.newIframe.objIframe.ChengGuangYuanJing.EventMoveRole.find().moveState = 0;
  1079. // @ts-ignore
  1080. threeWorld().obj.newIframe.objIframe.ChengGuangYuanJing.CommonEvent.find().boolW = false;
  1081. // @ts-ignore
  1082. threeWorld().obj.newIframe.objIframe.ChengGuangYuanJing.CommonEvent.find().boolA = false;
  1083. // @ts-ignore
  1084. threeWorld().obj.newIframe.objIframe.ChengGuangYuanJing.CommonEvent.find().boolS = false;
  1085. // @ts-ignore
  1086. threeWorld().obj.newIframe.objIframe.ChengGuangYuanJing.CommonEvent.find().boolD = false;
  1087. // @ts-ignore 恢复初始的移动速度
  1088. threeWorld().obj.newIframe.objIframe.ChengGuangYuanJing.Role.find().speed = courseChapter3dShow().show.carMoveSpeed;
  1089. moveToStop = true;
  1090. }
  1091. return;
  1092. }
  1093. moveToStop = false;
  1094. // 根据不同的挡位,控制合理的移动速度
  1095. let speed = courseChapter3dShow().show.carMoveSpeed
  1096. * (courseChapter3dShow().show.carMoveLv / courseChapter3dShow().show.carMoveSpeedMultipleMax * 1);
  1097. // // @ts-ignore 更新目标角色的参数
  1098. // threeWorld().obj.newIframe.objIframe.ChengGuangYuanJing.Role.find().modelRoleCreateOrUpdate(
  1099. // // @ts-ignore
  1100. // threeWorld().obj.newIframe.objIframe.ChengGuangYuanJing.Role.find().roleCode,
  1101. // {
  1102. // "addMoveSpeed" : courseChapter3dShow().show.carMoveSpeed - speed,
  1103. // "addMoveSpeedSecond" : 3,
  1104. // "addMoveSpeedSecondTimeUpdate" : new Date().getTime()
  1105. // }
  1106. // );
  1107. // @ts-ignore
  1108. threeWorld().obj.newIframe.objIframe.ChengGuangYuanJing.Role.find().speed = speed;
  1109. // 前进
  1110. if (courseChapter3dShow().show.carStatus == "forwardMove") {
  1111. // @ts-ignore
  1112. threeWorld().obj.newIframe.objIframe.ChengGuangYuanJing.EventMoveRole.find().moveState = 1;
  1113. // @ts-ignore
  1114. threeWorld().obj.newIframe.objIframe.ChengGuangYuanJing.CommonEvent.find().boolW = true;
  1115. // @ts-ignore
  1116. threeWorld().obj.newIframe.objIframe.ChengGuangYuanJing.CommonEvent.find().boolA = false;
  1117. // @ts-ignore
  1118. threeWorld().obj.newIframe.objIframe.ChengGuangYuanJing.CommonEvent.find().boolS = false;
  1119. // @ts-ignore
  1120. threeWorld().obj.newIframe.objIframe.ChengGuangYuanJing.CommonEvent.find().boolD = false;
  1121. }
  1122. // 后退
  1123. if (courseChapter3dShow().show.carStatus == "retreatMove") {
  1124. // @ts-ignore
  1125. threeWorld().obj.newIframe.objIframe.ChengGuangYuanJing.EventMoveRole.find().moveState = 1;
  1126. // @ts-ignore
  1127. threeWorld().obj.newIframe.objIframe.ChengGuangYuanJing.CommonEvent.find().boolS = true;
  1128. // @ts-ignore
  1129. threeWorld().obj.newIframe.objIframe.ChengGuangYuanJing.CommonEvent.find().boolA = false;
  1130. // @ts-ignore
  1131. threeWorld().obj.newIframe.objIframe.ChengGuangYuanJing.CommonEvent.find().boolW = false;
  1132. // @ts-ignore
  1133. threeWorld().obj.newIframe.objIframe.ChengGuangYuanJing.CommonEvent.find().boolD = false;
  1134. }
  1135. // console.log(
  1136. // " carStatusEvent = () => { 移动速度 ",
  1137. // speed
  1138. // );
  1139. }
  1140. /**
  1141. * 通过每帧的方式来控制变化的
  1142. * courseChapter3dShow().show.carCameraAlphaNew
  1143. * courseChapter3dShow().show.carCameraBetaNew
  1144. * …… 左右旋转,上下旋转,镜头放大缩小
  1145. * 等逻辑
  1146. * 跟 车机器人相关的逻辑
  1147. *
  1148. */
  1149. const carCameraAlphaAndBetaNew = () => {
  1150. // 可旋转角度
  1151. let mathPiMax = Math.PI / 2;
  1152. let mathPiMax2 = Math.PI / 10;
  1153. // fov每次变化参数
  1154. let fovUpdate = 0.2;
  1155. // fov最大值
  1156. let fovMax = 1.6;
  1157. // fov最小值
  1158. let fovMin = 0.4;
  1159. // 帧数
  1160. let fps = 75;
  1161. // 完成秒数
  1162. let secondFps = fps * 1.5;
  1163. let secondFps2 = fps * 1.5;
  1164. let secondFps3 = fps * 3;
  1165. // y轴支架每次变化的参数
  1166. let yUpdate = 1 / 2;
  1167. // let yUpdate = 1;
  1168. // y轴支架最大值
  1169. let yMax = 1.5;
  1170. // y轴支架最小值
  1171. let yMin = 0;
  1172. // 车速
  1173. // let carMoveLvProportionMax = 100 * 50;
  1174. let carMoveLvProportionMax = 100;
  1175. // 车相机左右旋转
  1176. if (courseChapter3dShow().show.carCameraAlpha != courseChapter3dShow().show.carCameraAlphaNew) {
  1177. let distance = courseChapter3dShow().show.carCameraAlpha - courseChapter3dShow().show.carCameraAlphaNew;
  1178. if (distance > 0) {
  1179. courseChapter3dShow().show.carCameraAlphaNew += mathPiMax / secondFps3;
  1180. if (courseChapter3dShow().show.carCameraAlphaNew >= courseChapter3dShow().show.carCameraAlpha) {
  1181. courseChapter3dShow().show.carCameraAlphaNew = courseChapter3dShow().show.carCameraAlpha;
  1182. }
  1183. } else {
  1184. courseChapter3dShow().show.carCameraAlphaNew -= mathPiMax / secondFps3;
  1185. if (courseChapter3dShow().show.carCameraAlphaNew <= courseChapter3dShow().show.carCameraAlpha) {
  1186. courseChapter3dShow().show.carCameraAlphaNew = courseChapter3dShow().show.carCameraAlpha;
  1187. }
  1188. }
  1189. if (courseChapter3dShow().show.carCameraAlphaNew >= mathPiMax) {
  1190. courseChapter3dShow().show.carCameraAlphaNew = mathPiMax;
  1191. }
  1192. if (courseChapter3dShow().show.carCameraAlphaNew <= -mathPiMax) {
  1193. courseChapter3dShow().show.carCameraAlphaNew = -mathPiMax;
  1194. }
  1195. }
  1196. // 车相机上下旋转
  1197. if (courseChapter3dShow().show.carCameraBeta != courseChapter3dShow().show.carCameraBetaNew) {
  1198. let distance = courseChapter3dShow().show.carCameraBeta - courseChapter3dShow().show.carCameraBetaNew;
  1199. if (distance > 0) {
  1200. courseChapter3dShow().show.carCameraBetaNew += mathPiMax / secondFps3;
  1201. if (courseChapter3dShow().show.carCameraBetaNew >= courseChapter3dShow().show.carCameraBeta) {
  1202. courseChapter3dShow().show.carCameraBetaNew = courseChapter3dShow().show.carCameraBeta;
  1203. }
  1204. } else {
  1205. courseChapter3dShow().show.carCameraBetaNew -= mathPiMax / secondFps3;
  1206. if (courseChapter3dShow().show.carCameraBetaNew <= courseChapter3dShow().show.carCameraBeta) {
  1207. courseChapter3dShow().show.carCameraBetaNew = courseChapter3dShow().show.carCameraBeta;
  1208. }
  1209. }
  1210. if (courseChapter3dShow().show.carCameraBetaNew >= mathPiMax) {
  1211. courseChapter3dShow().show.carCameraBetaNew = mathPiMax;
  1212. }
  1213. if (courseChapter3dShow().show.carCameraBetaNew <= -mathPiMax) {
  1214. courseChapter3dShow().show.carCameraBetaNew = -mathPiMax;
  1215. }
  1216. }
  1217. // 车左右转弯
  1218. if (courseChapter3dShow().show.carCameraAlphaWheel != courseChapter3dShow().show.carCameraAlphaWheelNew) {
  1219. let distance = courseChapter3dShow().show.carCameraAlphaWheel - courseChapter3dShow().show.carCameraAlphaWheelNew;
  1220. if (distance > 0) {
  1221. courseChapter3dShow().show.carCameraAlphaWheelNew += mathPiMax2 / secondFps2;
  1222. if (courseChapter3dShow().show.carCameraAlphaWheelNew >= courseChapter3dShow().show.carCameraAlphaWheel) {
  1223. courseChapter3dShow().show.carCameraAlphaWheelNew = courseChapter3dShow().show.carCameraAlphaWheel;
  1224. }
  1225. } else {
  1226. courseChapter3dShow().show.carCameraAlphaWheelNew -= mathPiMax2 / secondFps2;
  1227. if (courseChapter3dShow().show.carCameraAlphaWheelNew <= courseChapter3dShow().show.carCameraAlphaWheel) {
  1228. courseChapter3dShow().show.carCameraAlphaWheelNew = courseChapter3dShow().show.carCameraAlphaWheel;
  1229. }
  1230. }
  1231. if (courseChapter3dShow().show.carCameraAlphaWheelNew >= mathPiMax2) {
  1232. courseChapter3dShow().show.carCameraAlphaWheelNew = mathPiMax2;
  1233. }
  1234. if (courseChapter3dShow().show.carCameraAlphaWheelNew <= -mathPiMax2) {
  1235. courseChapter3dShow().show.carCameraAlphaWheelNew = -mathPiMax2;
  1236. }
  1237. }
  1238. // 车相机是否放大
  1239. if (courseChapter3dShow().show.carCameraFov != courseChapter3dShow().show.carCameraFovNew) {
  1240. let distance = courseChapter3dShow().show.carCameraFov - courseChapter3dShow().show.carCameraFovNew;
  1241. if (distance > 0) {
  1242. courseChapter3dShow().show.carCameraFovNew += fovUpdate / secondFps;
  1243. if (courseChapter3dShow().show.carCameraFovNew >= courseChapter3dShow().show.carCameraFov) {
  1244. courseChapter3dShow().show.carCameraFovNew = courseChapter3dShow().show.carCameraFov;
  1245. }
  1246. } else {
  1247. courseChapter3dShow().show.carCameraFovNew -= fovUpdate / secondFps;
  1248. if (courseChapter3dShow().show.carCameraFovNew <= courseChapter3dShow().show.carCameraFov) {
  1249. courseChapter3dShow().show.carCameraFovNew = courseChapter3dShow().show.carCameraFov;
  1250. }
  1251. }
  1252. if (courseChapter3dShow().show.carCameraFovNew >= fovMax) {
  1253. courseChapter3dShow().show.carCameraFovNew = fovMax;
  1254. }
  1255. if (courseChapter3dShow().show.carCameraFovNew <= fovMin) {
  1256. courseChapter3dShow().show.carCameraFovNew = fovMin;
  1257. }
  1258. }
  1259. // 支架上升还是下降
  1260. if (courseChapter3dShow().show.carCameraPositionY != courseChapter3dShow().show.carCameraPositionYNew) {
  1261. let distance = courseChapter3dShow().show.carCameraPositionY - courseChapter3dShow().show.carCameraPositionYNew;
  1262. if (distance > 0) {
  1263. courseChapter3dShow().show.carCameraPositionYNew += yUpdate / secondFps;
  1264. if (courseChapter3dShow().show.carCameraPositionYNew >= courseChapter3dShow().show.carCameraPositionY) {
  1265. courseChapter3dShow().show.carCameraPositionYNew = courseChapter3dShow().show.carCameraPositionY;
  1266. }
  1267. } else {
  1268. courseChapter3dShow().show.carCameraPositionYNew -= yUpdate / secondFps;
  1269. if (courseChapter3dShow().show.carCameraPositionYNew <= courseChapter3dShow().show.carCameraPositionY) {
  1270. courseChapter3dShow().show.carCameraPositionYNew = courseChapter3dShow().show.carCameraPositionY;
  1271. }
  1272. }
  1273. if (courseChapter3dShow().show.carCameraPositionYNew >= yMax) {
  1274. courseChapter3dShow().show.carCameraPositionYNew = yMax;
  1275. }
  1276. if (courseChapter3dShow().show.carCameraPositionYNew <= yMin) {
  1277. courseChapter3dShow().show.carCameraPositionYNew = yMin;
  1278. }
  1279. }
  1280. // 车速变动百分比
  1281. if (courseChapter3dShow().show.carMoveLvProportion != courseChapter3dShow().show.carMoveLvProportionNew) {
  1282. let distance = courseChapter3dShow().show.carMoveLvProportion - courseChapter3dShow().show.carMoveLvProportionNew;
  1283. if (distance > 0) {
  1284. courseChapter3dShow().show.carMoveLvProportionNew += carMoveLvProportionMax / secondFps;
  1285. if (courseChapter3dShow().show.carMoveLvProportionNew >= courseChapter3dShow().show.carMoveLvProportion) {
  1286. courseChapter3dShow().show.carMoveLvProportionNew = courseChapter3dShow().show.carMoveLvProportion;
  1287. }
  1288. } else {
  1289. courseChapter3dShow().show.carMoveLvProportionNew -= carMoveLvProportionMax / secondFps;
  1290. if (courseChapter3dShow().show.carMoveLvProportionNew <= courseChapter3dShow().show.carMoveLvProportion) {
  1291. courseChapter3dShow().show.carMoveLvProportionNew = courseChapter3dShow().show.carMoveLvProportion;
  1292. }
  1293. }
  1294. // if (courseChapter3dShow().show.carMoveLvProportionNew >= 100) {
  1295. // courseChapter3dShow().show.carMoveLvProportionNew = 100;
  1296. // }
  1297. // if (courseChapter3dShow().show.carMoveLvProportionNew <= 0) {
  1298. // courseChapter3dShow().show.carMoveLvProportionNew = 0;
  1299. // }
  1300. if (courseChapter3dShow().show.carMoveLvProportionNew >= 96) {
  1301. courseChapter3dShow().show.carMoveLvProportionNew = 96;
  1302. }
  1303. if (courseChapter3dShow().show.carMoveLvProportionNew <= 3) {
  1304. courseChapter3dShow().show.carMoveLvProportionNew = 3;
  1305. courseChapter3dShow().show.bottomSpeedImgTopSptWidth = '0rem';
  1306. } else {
  1307. // courseChapter3dShow().show.bottomSpeedImgTopSptWidth = '2.6rem';
  1308. courseChapter3dShow().show.bottomSpeedImgTopSptWidth = '2rem';
  1309. }
  1310. // 最大的例子所在位置
  1311. let topRemMax = 6;
  1312. // let topRemMax = 8;
  1313. if (courseChapter3dShow().show.carMoveLvProportionNew <= 50) {
  1314. courseChapter3dShow().show.carMoveLvProportionTopNew = -(topRemMax * courseChapter3dShow().show.carMoveLvProportionNew / 100);
  1315. } else {
  1316. courseChapter3dShow().show.carMoveLvProportionTopNew = -(topRemMax * ( 100 - courseChapter3dShow().show.carMoveLvProportionNew) / 100);
  1317. }
  1318. }
  1319. }
  1320. /**
  1321. * 3d加载完成优先切换到默认的视角
  1322. */
  1323. const initScene = () => {
  1324. // console.log(
  1325. // "initScene = () => {",
  1326. // threeWorld().obj.newIframe,
  1327. // threeWorld().obj.newIframe.getCameraVisualAngleGetList()
  1328. // );
  1329. // @ts-ignore
  1330. threeWorld().obj.newIframe.cameraVisualAngleGetListNameGpsTo("检测车");
  1331. // @ts-ignore
  1332. threeWorld().obj.newIframe.roleShow(false);
  1333. // 清空3d背景
  1334. // @ts-ignore
  1335. threeWorld().obj.newIframe.objIframe.ChengGuangYuanJing.CommonVal.find().objScene.clearColor = {
  1336. "r" : 0, "g" : 0, "b" : 0, "a" : 0
  1337. };
  1338. groundNoRemove();
  1339. typeEvent(props.config?.threeDimensionalConfig);
  1340. // 触发自动点击逻辑
  1341. // @ts-ignore
  1342. threeWorld().obj.newIframe.objIframe.ChengGuangYuanJing.CommonVal.find().screenClickNumEvent();
  1343. // 默认装的盒子是可以看到的
  1344. objTypeViewEvent.boxLook(true);
  1345. }
  1346. /**
  1347. * 将所有设置为地面的,改为不设置为地面
  1348. */
  1349. const groundNoRemove = () => {
  1350. // // 临时测试用的,后续正式,在注释掉
  1351. // return;
  1352. // console.log(
  1353. // "groundNoRemove = () => {",
  1354. // threeWorld().obj.newIframe.objIframe.ChengGuangYuanJing.ModelObjEdit.find().meshListIdToJson
  1355. // );
  1356. // @ts-ignore
  1357. for (const key in threeWorld().obj.newIframe.objIframe.ChengGuangYuanJing.ModelObjEdit.find().meshListIdToJson) {
  1358. if (
  1359. // @ts-ignore
  1360. threeWorld().obj.newIframe.objIframe.ChengGuangYuanJing.ModelObjEdit.find().meshListIdToJson[key]['isGround'] == true
  1361. ) {
  1362. // 通过更新材质的参数,来更新
  1363. // @ts-ignore
  1364. threeWorld().obj.newIframe.objIframe.ChengGuangYuanJing.ModelObjEdit.find().objOneMeshListIdToJsonUpdate(
  1365. key,
  1366. {
  1367. "isGround" : false,
  1368. }
  1369. );
  1370. }
  1371. }
  1372. // @ts-ignore
  1373. for (let i = 0; i < threeWorld().obj.newIframe.objIframe.ChengGuangYuanJing.CommonVal.find().objScene.meshes.length; i++) {
  1374. // @ts-ignore
  1375. let objMesh = threeWorld().obj.newIframe.objIframe.ChengGuangYuanJing.CommonVal.find().objScene.meshes[i];
  1376. // console.log(
  1377. // "myIsGround",
  1378. // objMesh["myIsGround"]
  1379. // );
  1380. // if (objMesh["myIsGround"] == true) {
  1381. // delete objMesh["myIsGround"];
  1382. // }
  1383. delete objMesh["myIsGround"];
  1384. }
  1385. // @ts-ignore
  1386. threeWorld().obj.newIframe.objIframe.ChengGuangYuanJing.Role.find().isGroundList = {};
  1387. // @ts-ignore
  1388. threeWorld().obj.newIframe.objIframe.ChengGuangYuanJing.ModelObjEdit.find().myIsGroundConfigNum = 0;
  1389. }
  1390. /**
  1391. * 停止所有动画
  1392. */
  1393. const animationAllFpsToZero = () => {
  1394. objTypeViewEvent.animationAllTypeUpdate("stopAll");
  1395. };
  1396. /**
  1397. * 根据不同的类型,切换对应的3d逻辑
  1398. */
  1399. const typeEvent = (type : any) => {
  1400. console.log(
  1401. "根据不同的类型,切换对应的3d逻辑",
  1402. type
  1403. );
  1404. courseChapter3dShow().show.viewType = type;
  1405. thisFlowPath = type;
  1406. objDragAndDropEvent.txtBool = false;
  1407. courseChapter3dShow().show.showDirectionViewBool = false;
  1408. // @ts-ignore
  1409. if (threeWorld().obj.showCongratulationsTxtJson[type] != null && threeWorld().obj.showCongratulationsTxtJson[type] != undefined) {
  1410. // @ts-ignore
  1411. let showCongratulationsTxtJson = threeWorld().obj.showCongratulationsTxtJson[type];
  1412. courseChapter3dShow().show.showCongratulationsTxt = showCongratulationsTxtJson.txt;
  1413. courseChapter3dShow().show.showEndTxt = showCongratulationsTxtJson.txtEnd;
  1414. if (
  1415. showCongratulationsTxtJson.showDirectionX != null && showCongratulationsTxtJson.showDirectionX != undefined
  1416. && showCongratulationsTxtJson.showDirectionY != null && showCongratulationsTxtJson.showDirectionY != undefined
  1417. ) {
  1418. let tips = props.config?.tips;
  1419. if (tips != null && tips != undefined) {
  1420. // 由于新增了切换视角逻辑,延迟弹出
  1421. setTimeout(function() {
  1422. // @ts-ignore
  1423. courseChapter3dShow().show.showDirectionEvent(
  1424. tips,
  1425. null,
  1426. showCongratulationsTxtJson.showDirectionX,
  1427. showCongratulationsTxtJson.showDirectionY,
  1428. function() {}
  1429. );
  1430. }, 1500);
  1431. }
  1432. }
  1433. } else {
  1434. courseChapter3dShow().show.showCongratulationsTxt = "";
  1435. }
  1436. setTimeout(function() {
  1437. // 启动播放声音
  1438. objTypeViewEvent.musicConfigPlay(
  1439. type, "start"
  1440. );
  1441. }, 1500);
  1442. // 控制物体的显示和隐藏以及高亮
  1443. objHighlightLayerEvent.statueMeshLookOrHighlight(type);
  1444. // 重置为空数组
  1445. objDragAndDropEvent.highlightLayerMeshListClick = [];
  1446. objDragAndDropEvent.retVisibility(0, "restore", {});
  1447. objDragAndDropEvent.retVisibility(1, "restore", {});
  1448. switch(type) {
  1449. // 操作帮助
  1450. case 'operationHelp':
  1451. objTypeViewEvent.operationHelpEvent();
  1452. break;
  1453. // 设备拆解
  1454. case 'equipmentDisassembly':
  1455. objTypeViewEvent.equipmentDisassemblyEvent();
  1456. // 切换动画
  1457. objTypeViewEvent.animationAllTypeUpdate("stopAll");
  1458. break;
  1459. // 爬行器模块
  1460. case 'crawlerModule':
  1461. objTypeViewEvent.crawlerModuleEvent();
  1462. // 切换动画
  1463. objTypeViewEvent.animationAllTypeUpdate("stopAll");
  1464. objDragAndDropEvent.txtBool = true;
  1465. break;
  1466. // 线缆卷盘
  1467. case 'cableReel':
  1468. objTypeViewEvent.cableReelEvent();
  1469. // 切换动画
  1470. objTypeViewEvent.animationAllTypeUpdate("stopAll");
  1471. objDragAndDropEvent.txtBool = true;
  1472. break;
  1473. // 检测实训注意事项
  1474. case 'precautionsForTestingTraining':
  1475. objTypeViewEvent.precautionsForTestingTrainingEvent(props.config?.durationStudyMin);
  1476. // 切换动画
  1477. objTypeViewEvent.animationAllTypeUpdate("stopAll");
  1478. break;
  1479. // 设备下井实验视频
  1480. case 'equipmentDownHoleExperimentVideo':
  1481. objTypeViewEvent.equipmentDownHoleExperimentVideoEvent();
  1482. // 切换动画
  1483. objTypeViewEvent.animationAllTypeUpdate("stopAll");
  1484. break;
  1485. case '请走到工作区域':
  1486. objTypeViewEvent.work_1();
  1487. // 切换动画
  1488. objTypeViewEvent.animationAllTypeUpdate("beforeUnboxing");
  1489. break;
  1490. case '请点击人物进行穿搭衣服':
  1491. objTypeViewEvent.work_2();
  1492. // 切换动画
  1493. objTypeViewEvent.animationAllTypeUpdate("beforeUnboxing");
  1494. break;
  1495. case '将四个安全桩放置到正确的位置':
  1496. objTypeViewEvent.work_3();
  1497. // 切换动画
  1498. objTypeViewEvent.animationAllTypeUpdate("beforeUnboxing");
  1499. break;
  1500. case '将盒子拆开把设备拿出来':
  1501. objTypeViewEvent.work_4();
  1502. break;
  1503. case '将盒子拆开把设备放置在安全的位置':
  1504. objTypeViewEvent.work_5();
  1505. break;
  1506. // 已经不会用到的逻辑了
  1507. case '将检测机器人6寸轮子安装到正确位置':
  1508. objTypeViewEvent.work_6_0();
  1509. break;
  1510. // 已经不会用到的逻辑了
  1511. case '将检测机器人的轮子安装到正确的位置':
  1512. objTypeViewEvent.work_6();
  1513. break;
  1514. case '将检测机器人6寸右侧轮子安装到正确位置':
  1515. objTypeViewEvent.work_6_right();
  1516. break;
  1517. case '将检测机器人6寸左侧轮子安装到正确位置':
  1518. objTypeViewEvent.work_6_left();
  1519. break;
  1520. case '将检测机器人10寸右侧轮子安装到正确位置':
  1521. objTypeViewEvent.work_10_right();
  1522. break;
  1523. case '将检测机器人10寸左侧轮子安装到正确位置':
  1524. objTypeViewEvent.work_10_left();
  1525. break;
  1526. case '将检测机器人的防撞杆安装到正确的位置':
  1527. objTypeViewEvent.work_7();
  1528. break;
  1529. case '将检测机器人的防撞杆锁安装到正确的位置':
  1530. objTypeViewEvent.work_8();
  1531. break;
  1532. case '将检测机器人的镜头架安装到正确的位置':
  1533. objTypeViewEvent.work_9();
  1534. break;
  1535. case '将检测机器人的相机安装到正确的位置':
  1536. objTypeViewEvent.work_10();
  1537. break;
  1538. case '将绕线车的电源线安装到正确的位置':
  1539. objTypeViewEvent.work_11();
  1540. break;
  1541. case '将绕线车的纠偏轮安装到正确的位置':
  1542. objTypeViewEvent.work_12();
  1543. break;
  1544. case '将绕线车的锂电池安装到正确的位置':
  1545. objTypeViewEvent.work_13();
  1546. break;
  1547. case '将绕线车的电脑主机放置到正确的位置':
  1548. objTypeViewEvent.work_14();
  1549. break;
  1550. case '将绕线车的手柄安装到正确的位置':
  1551. objTypeViewEvent.work_15();
  1552. break;
  1553. case '将绕线车的电缆安装到正确的位置':
  1554. objTypeViewEvent.work_16();
  1555. break;
  1556. case '抬升支架降至最低':
  1557. objTypeViewEvent.work_17();
  1558. break;
  1559. case '镜头旋转至正上方':
  1560. objTypeViewEvent.work_18();
  1561. break;
  1562. case '镜头归位':
  1563. objTypeViewEvent.work_19();
  1564. break;
  1565. case '调节行驶方向正确放置过线滑轮':
  1566. objTypeViewEvent.work_20();
  1567. break;
  1568. case '打开井盖':
  1569. objTypeViewEvent.work_21();
  1570. break;
  1571. case '下井视频':
  1572. objTypeViewEvent.work_22();
  1573. break;
  1574. case '设备回收视频':
  1575. objTypeViewEvent.work_23();
  1576. break;
  1577. // 作业前准备工作1
  1578. case 'preparationWorkBeforeHomework1':
  1579. objTypeViewEvent.preparationWorkBeforeHomework1Event();
  1580. break;
  1581. // 作业前准备工作2
  1582. case 'preparationWorkBeforeHomework2':
  1583. objTypeViewEvent.preparationWorkBeforeHomework2Event();
  1584. break;
  1585. // 作业前准备工作3
  1586. case 'preparationWorkBeforeHomework3':
  1587. objTypeViewEvent.preparationWorkBeforeHomework3Event();
  1588. break;
  1589. // 作业前准备工作4
  1590. case 'preparationWorkBeforeHomework4':
  1591. objTypeViewEvent.preparationWorkBeforeHomework4Event();
  1592. break;
  1593. // 设备连接工作1
  1594. case 'deviceConnectionWork1':
  1595. objTypeViewEvent.deviceConnectionWork1Event();
  1596. break;
  1597. // 设备连接工作2
  1598. case 'deviceConnectionWork2':
  1599. objTypeViewEvent.deviceConnectionWork2Event();
  1600. break;
  1601. // 设备调试工作
  1602. case 'equipmentDebuggingWork':
  1603. objTypeViewEvent.equipmentDebuggingWorkEvent();
  1604. break;
  1605. // 录制准备视频
  1606. case 'recordPreparationVideo':
  1607. objTypeViewEvent.recordPreparationVideoEvent();
  1608. break;
  1609. // 设备下井工作1
  1610. case 'equipmentDownHoleWork1':
  1611. objTypeViewEvent.equipmentDownHoleWork1Event();
  1612. break;
  1613. // 设备下井工作2
  1614. case 'equipmentDownHoleWork2':
  1615. objTypeViewEvent.equipmentDownHoleWork2Event();
  1616. break;
  1617. // 设备下井工作3
  1618. case 'equipmentDownHoleWork3':
  1619. objTypeViewEvent.equipmentDownHoleWork3Event();
  1620. break;
  1621. // 设备下井工作4
  1622. case 'equipmentDownHoleWork4':
  1623. objTypeViewEvent.equipmentDownHoleWork4Event();
  1624. break;
  1625. // 设备下井工作5
  1626. case 'equipmentDownHoleWork5':
  1627. objTypeViewEvent.equipmentDownHoleWork5Event();
  1628. break;
  1629. // 设备下井工作6
  1630. case 'equipmentDownHoleWork6':
  1631. objTypeViewEvent.equipmentDownHoleWork6Event();
  1632. break;
  1633. // 设备下井工作7
  1634. case 'equipmentDownHoleWork7':
  1635. objTypeViewEvent.equipmentDownHoleWork7Event();
  1636. break;
  1637. // 下井检测
  1638. case 'downHoleInspection':
  1639. objTypeViewEvent.downHoleInspectionEvent();
  1640. break;
  1641. // 设备归位工作
  1642. case 'equipmentRepositioningWork':
  1643. objTypeViewEvent.equipmentRepositioningWorkEvent();
  1644. break;
  1645. default:
  1646. objTypeViewEvent.viewHide();
  1647. break;
  1648. }
  1649. let tips = props.config?.tips;
  1650. if (tips != null && tips != undefined) {
  1651. courseChapter3dShow().show.showTitleTxt = tips;
  1652. }
  1653. }
  1654. // let wearYes = new URL("./../../assets/3dMain/body.webp", import.meta.url).href;
  1655. let wearYes = new URL("./../../assets/3dMain/04_M_Construction_d_2.webp", import.meta.url).href;
  1656. let wearNo = new URL("./../../assets/3dMain/04_M_Construction_d_1.webp", import.meta.url).href;
  1657. let wearTextureNo:any = null;
  1658. let wearTextureYes:any = null;
  1659. // 优先记录好工作人员进行替换的贴图对象
  1660. const workRoleTexture = () => {
  1661. let list = [
  1662. "exhibition_html_1709861931375_M_SML_Construction_01_primitive0",
  1663. // "exhibition_html_1709861931375_M_SML_Construction_01_primitive1",
  1664. // "exhibition_html_1709861931375_M_SML_Construction_01_primitive2",
  1665. // "exhibition_html_1709861931375_M_SML_Construction_01_primitive3",
  1666. ];
  1667. for (let i = 0; i < list.length; i++) {
  1668. let objMeshId = list[i];
  1669. // @ts-ignore
  1670. let objMesh = threeWorld().obj.newIframe.objIframe.ChengGuangYuanJing.CommonVal.find().objScene.getMeshById(objMeshId);
  1671. if (objMesh != null && objMesh != undefined && objMesh.material != null && objMesh.material != undefined) {
  1672. // console.log(
  1673. // "objMesh.material",
  1674. // objMesh.material
  1675. // );
  1676. if (wearTextureNo == null) {
  1677. if (objMesh.material.albedoTexture != null && objMesh.material.albedoTexture != undefined) {
  1678. wearTextureNo = objMesh.material.albedoTexture.clone();
  1679. }
  1680. }
  1681. }
  1682. }
  1683. wearTextureYes = new BABYLON.Texture(
  1684. wearYes,
  1685. // @ts-ignore
  1686. threeWorld().obj.newIframe.objIframe.ChengGuangYuanJing.CommonVal.find().objScene,
  1687. null, false
  1688. );
  1689. objTypeViewEvent.wearTextureNo = wearTextureNo;
  1690. objTypeViewEvent.wearTextureYes = wearTextureYes;
  1691. }
  1692. /**
  1693. * 设备连接工作,右侧菜单点击回调
  1694. */
  1695. courseChapter3dShow().show.showToolMenuRightClickCallback = function(res : any) {
  1696. console.log(
  1697. "设备连接工作,右侧菜单点击回调", res
  1698. );
  1699. switch (res.name) {
  1700. case "旋转镜头":
  1701. // @ts-ignore
  1702. threeWorld().obj.newIframe.cameraVisualAngleGetListNameGpsTo("镜头归位");
  1703. // @ts-ignore
  1704. threeWorld().obj.newIframe.roleShow(false);
  1705. // @ts-ignore
  1706. threeWorld().obj.newIframe.objIframe.ChengGuangYuanJing.CommonVal.find().animationGroupsEventCallback(
  1707. "镜头架", 'start', 1, null, null, false, null, function(state : any, objAnimation : any) {
  1708. if (state == "播放完成") {
  1709. }
  1710. }
  1711. );
  1712. // @ts-ignore
  1713. threeWorld().obj.newIframe.objIframe.ChengGuangYuanJing.CommonVal.find().animationGroupsEventCallback(
  1714. "相机", 'start', 1, null, null, false, null, function(state : any, objAnimation : any) {
  1715. if (state == "播放完成") {
  1716. }
  1717. }
  1718. );
  1719. break;
  1720. case "移动电源":
  1721. // @ts-ignore
  1722. threeWorld().obj.newIframe.cameraVisualAngleGetListNameGpsTo("电池");
  1723. // @ts-ignore
  1724. threeWorld().obj.newIframe.roleShow(false);
  1725. // @ts-ignore
  1726. threeWorld().obj.newIframe.objIframe.ChengGuangYuanJing.CommonVal.find().animationGroupsEventCallback(
  1727. "电池", 'start', 1, null, null, false, null, function(state : any, objAnimation : any) {
  1728. if (state == "播放完成") {
  1729. }
  1730. }
  1731. );
  1732. break;
  1733. case "主机终端":
  1734. // @ts-ignore
  1735. threeWorld().obj.newIframe.cameraVisualAngleGetListNameGpsTo("检测车组电脑");
  1736. // @ts-ignore
  1737. threeWorld().obj.newIframe.roleShow(false);
  1738. break;
  1739. case "手柄":
  1740. // @ts-ignore
  1741. threeWorld().obj.newIframe.cameraVisualAngleGetListNameGpsTo("手柄");
  1742. // @ts-ignore
  1743. threeWorld().obj.newIframe.roleShow(false);
  1744. break;
  1745. case "绕线车":
  1746. // @ts-ignore
  1747. threeWorld().obj.newIframe.cameraVisualAngleGetListNameGpsTo("绕线车");
  1748. // @ts-ignore
  1749. threeWorld().obj.newIframe.roleShow(false);
  1750. break;
  1751. case "爬行器":
  1752. // @ts-ignore
  1753. threeWorld().obj.newIframe.cameraVisualAngleGetListNameGpsTo("检测车组");
  1754. // @ts-ignore
  1755. threeWorld().obj.newIframe.roleShow(false);
  1756. break;
  1757. }
  1758. }
  1759. // 管道问题点类型对应布展的物体名字, 每个管段 相差 x = 29.94 的距离,起始坐标 x = -260 [ 端头1 -289.94 ] , y = -13 , z = -30
  1760. let pipelineProblemsJson : any = {
  1761. "管道问题点-支管段" : {
  1762. "exhibitionCode" : "",
  1763. },
  1764. "管道问题点-异物穿入段" : {
  1765. "exhibitionCode" : "",
  1766. },
  1767. "管道问题点-脱节段" : {
  1768. "exhibitionCode" : "",
  1769. },
  1770. "管道问题点-树根段" : {
  1771. "exhibitionCode" : "",
  1772. },
  1773. "管道问题点-起伏段" : {
  1774. "exhibitionCode" : "",
  1775. },
  1776. "管道问题点-破裂段" : {
  1777. "exhibitionCode" : "",
  1778. },
  1779. "管道问题点-密封圈脱落段" : {
  1780. "exhibitionCode" : "",
  1781. },
  1782. "管道问题点-漏水段" : {
  1783. "exhibitionCode" : "",
  1784. },
  1785. "管道问题点-结诟段" : {
  1786. "exhibitionCode" : "",
  1787. },
  1788. "管道问题点-腐蚀段" : {
  1789. "exhibitionCode" : "",
  1790. },
  1791. "管道问题点-浮渣段" : {
  1792. "exhibitionCode" : "",
  1793. },
  1794. "管道问题点-错位段" : {
  1795. "exhibitionCode" : "",
  1796. },
  1797. "管道问题点-残墙段" : {
  1798. "exhibitionCode" : "",
  1799. },
  1800. "管道问题点-障碍物段" : {
  1801. "exhibitionCode" : "",
  1802. },
  1803. "管道问题点-变形段" : {
  1804. "exhibitionCode" : "",
  1805. },
  1806. "管道问题点-端头1" : {
  1807. "exhibitionCode" : "",
  1808. },
  1809. "管道问题点-端头2" : {
  1810. "exhibitionCode" : "",
  1811. },
  1812. "管道问题点-标准管段1" : {
  1813. "exhibitionCode" : "",
  1814. },
  1815. "管道问题点-标准管段2" : {
  1816. "exhibitionCode" : "",
  1817. },
  1818. "管道问题点-标准管段3" : {
  1819. "exhibitionCode" : "",
  1820. },
  1821. "管道问题点-标准管段4" : {
  1822. "exhibitionCode" : "",
  1823. },
  1824. "管道问题点-标准管段5" : {
  1825. "exhibitionCode" : "",
  1826. },
  1827. "管道问题点-标准管段6" : {
  1828. "exhibitionCode" : "",
  1829. },
  1830. "管道问题点-标准管段7" : {
  1831. "exhibitionCode" : "",
  1832. },
  1833. "管道问题点-标准管段8" : {
  1834. "exhibitionCode" : "",
  1835. },
  1836. "管道问题点-标准管段9" : {
  1837. "exhibitionCode" : "",
  1838. },
  1839. "管道问题点-标准管段10" : {
  1840. "exhibitionCode" : "",
  1841. },
  1842. "管道问题点-标准管段11" : {
  1843. "exhibitionCode" : "",
  1844. },
  1845. "管道问题点-标准管段12" : {
  1846. "exhibitionCode" : "",
  1847. },
  1848. "管道问题点-标准管段13" : {
  1849. "exhibitionCode" : "",
  1850. },
  1851. "管道问题点-标准管段14" : {
  1852. "exhibitionCode" : "",
  1853. },
  1854. "管道问题点-标准管段15" : {
  1855. "exhibitionCode" : "",
  1856. },
  1857. };
  1858. /**
  1859. * 记录管道问题点对应的布展的物体
  1860. */
  1861. const pipelineProblemsJsonInitEvent = () => {
  1862. // @ts-ignore
  1863. for (let key in threeWorld().obj.newIframe.objIframe.ChengGuangYuanJing.CommonVal.find().exhibitionJson) {
  1864. // @ts-ignore
  1865. let thisExhibitionJson = threeWorld().obj.newIframe.objIframe.ChengGuangYuanJing.CommonVal.find().exhibitionJson[key];
  1866. let specialCode = thisExhibitionJson.specialCode;
  1867. let codeId = thisExhibitionJson.codeId;
  1868. if (pipelineProblemsJson[specialCode] != null && pipelineProblemsJson[specialCode] != undefined) {
  1869. pipelineProblemsJson[specialCode]["exhibitionCode"] = codeId;
  1870. }
  1871. // console.log(
  1872. // "thisExhibitionJson", thisExhibitionJson,
  1873. // "specialCode", specialCode,
  1874. // "codeId", codeId
  1875. // );
  1876. }
  1877. // console.log(
  1878. // "pipelineProblemsJson", pipelineProblemsJson
  1879. // );
  1880. }
  1881. /**
  1882. * 取随机数
  1883. * min 最小值
  1884. * max 最大值
  1885. */
  1886. const rnd = (min : any, max : any) => {
  1887. return Math.floor(Math.random() * (max - min + 1) + min);
  1888. }
  1889. /**
  1890. * 根据数组demo,来控制管道问题点的排序逻辑
  1891. */
  1892. let pipelineProblemsArrayDemo : any = [
  1893. // { "name" : "管道问题点-标准管段" },
  1894. ];
  1895. /**
  1896. * 随机数组demo
  1897. */
  1898. const getRndArray = () => {
  1899. // 获取可随机定义的数组
  1900. let array = [];
  1901. for (let key in pipelineProblemsJson) {
  1902. array.push({
  1903. "name" : key,
  1904. });
  1905. }
  1906. // 返回得到的随机数组结果
  1907. let arrayNew : any = [];
  1908. // 随机多少个管道问题点
  1909. let runSum = 12;
  1910. for (var i = 0; i < runSum; i++) {
  1911. let rndIndex = rnd(1, array.length) - 1;
  1912. arrayNew.push(array[rndIndex]);
  1913. // 删除数组下标
  1914. array.splice(rndIndex, 1);
  1915. }
  1916. return arrayNew;
  1917. }
  1918. /**
  1919. * 随机个数组案例,来控制管道问题点的排序逻辑
  1920. */
  1921. const getRndArrayDemoEvent = () => {
  1922. // let array = getRndArray();
  1923. let array : any = [];
  1924. // 记录当前新增的【 管道问题点-标准管段 】数量
  1925. let addStandardSum = 1;
  1926. /**
  1927. * 临时记录已经出现过的管段
  1928. * 如果已经重复,则不添加
  1929. */
  1930. let addOldNameJson : any = {};
  1931. // 固定有个最开始封闭的管道
  1932. array.push({
  1933. "name" : "管道问题点-端头1"
  1934. });
  1935. // // 固定有个最开始封闭的管道
  1936. // array.push({
  1937. // "name" : "管道问题点-标准管段1"
  1938. // });
  1939. // if (
  1940. // props.studentTaskIdList != null
  1941. // && props.studentTaskIdList != undefined
  1942. // && typeof props.studentTaskIdList == 'object'
  1943. // ) {
  1944. // for (var i = 0; i < props.studentTaskIdList.length; i++) {
  1945. // let thisStudentTaskIdList = props.studentTaskIdList[i];
  1946. // console.log(
  1947. // "thisStudentTaskIdList",
  1948. // thisStudentTaskIdList
  1949. // );
  1950. // let addJson = {
  1951. // "name" : thisStudentTaskIdList?.pipDefect?.name
  1952. // }
  1953. // if (addJson["name"] == null || addJson["name"] == undefined || addJson["name"] == '') {
  1954. // addJson["name"] = '管道问题点-标准管段' + addStandardSum;
  1955. // addStandardSum += 1;
  1956. // }
  1957. // // // // 调试用的,过滤掉一些,来知道哪些管段有问题
  1958. // // // // if (addJson.name == "管道问题点-变形段") {
  1959. // // if (addJson.name !== "管道问题点-变形段") {
  1960. // // continue;
  1961. // // }
  1962. // if (
  1963. // addOldNameJson[addJson["name"]] == null && addOldNameJson[addJson["name"]] == undefined
  1964. // ) {
  1965. // addOldNameJson[addJson["name"]] = addJson["name"];
  1966. // array.push(addJson);
  1967. // }
  1968. // }
  1969. // }
  1970. // // 本次要继续随机生成的标准管段数量
  1971. // let standardCreateSum = 15 - (array.length - 2);
  1972. // if (standardCreateSum >= 1) {
  1973. // for (var i = 0; i < standardCreateSum; i++) {
  1974. // let addJson = {
  1975. // "name" : '管道问题点-标准管段' + addStandardSum
  1976. // }
  1977. // addStandardSum += 1;
  1978. // // 随机数
  1979. // let rndIndex = rnd(2, array.length - 2);
  1980. // array.splice(rndIndex, 0, addJson);
  1981. // }
  1982. // }
  1983. // console.log(
  1984. // "const getRndArrayDemoEvent = () => {",
  1985. // array,
  1986. // standardCreateSum
  1987. // );
  1988. // ########## 现在修改为根据后端返回的数组下标的点位,进行排序,不在进行随机生成标准管段
  1989. // 优先记录对应数组下标的管段json
  1990. let addIndexJson : any = {};
  1991. if (
  1992. props.studentTaskIdList != null
  1993. && props.studentTaskIdList != undefined
  1994. && typeof props.studentTaskIdList == 'object'
  1995. ) {
  1996. for (var i = 0; i < props.studentTaskIdList.length; i++) {
  1997. let thisStudentTaskIdList = props.studentTaskIdList[i];
  1998. let pipIndex = thisStudentTaskIdList.pipIndex;
  1999. let name = thisStudentTaskIdList?.pipDefect?.name;
  2000. // console.log(
  2001. // "thisStudentTaskIdList",
  2002. // thisStudentTaskIdList
  2003. // );
  2004. let addJson = {
  2005. "name" : name
  2006. }
  2007. if (addJson["name"] == null || addJson["name"] == undefined || addJson["name"] == '') {
  2008. addJson["name"] = '管道问题点-标准管段' + addStandardSum;
  2009. addStandardSum += 1;
  2010. }
  2011. if (
  2012. addOldNameJson[addJson["name"]] == null && addOldNameJson[addJson["name"]] == undefined
  2013. ) {
  2014. addOldNameJson[addJson["name"]] = addJson["name"];
  2015. addIndexJson[pipIndex] = addJson;
  2016. }
  2017. }
  2018. }
  2019. // 总共是15个管段,15个管段内,根据 addIndexJson 数组下标,替换问题管段
  2020. for (var i = 1; i <= 15; i++) {
  2021. // 如果存在问题管段数据
  2022. if (addIndexJson[i] != null && addIndexJson[i] != undefined) {
  2023. array.push(addIndexJson[i]);
  2024. } else {
  2025. var addJson = {
  2026. "name" : '管道问题点-标准管段' + addStandardSum,
  2027. };
  2028. // 增加为标准管段
  2029. array.push(addJson);
  2030. addStandardSum += 1;
  2031. }
  2032. }
  2033. // 固定有个最尾巴封闭的管道
  2034. array.push({
  2035. "name" : "管道问题点-端头2"
  2036. });
  2037. console.log(
  2038. " 【管道问题点】 const getRndArrayDemoEvent = () => {",
  2039. array,
  2040. pipelineProblemsJson
  2041. );
  2042. pipelineProblemsArrayEvent(array);
  2043. }
  2044. /**
  2045. * 优先将所有的管道移动到看不到的地方
  2046. */
  2047. const pipelineProblemsJsonMoveEvent = () => {
  2048. for (let key in pipelineProblemsJson) {
  2049. let objPipelineProblemsJson = pipelineProblemsJson[key];
  2050. let exhibitionCode = objPipelineProblemsJson.exhibitionCode;
  2051. // @ts-ignore
  2052. let objMesh = threeWorld().obj.newIframe.objIframe.ChengGuangYuanJing.CommonVal.find().objScene.getMeshById(exhibitionCode);
  2053. if (objMesh != null && objMesh != undefined) {
  2054. let thisMesh = objMesh;
  2055. // 确认当前可进行移动的主物体
  2056. if (objMesh._parentContainer != null && objMesh._parentContainer != undefined) {
  2057. let _parentContainer = objMesh._parentContainer;
  2058. if (_parentContainer.meshes != null && _parentContainer.meshes != undefined) {
  2059. thisMesh = _parentContainer.meshes[0];
  2060. }
  2061. }
  2062. thisMesh.position.x = 1000;
  2063. }
  2064. }
  2065. }
  2066. /**
  2067. * 记录 pipelineProblemsArrayEvent 方法,本次安装的管道列表数据
  2068. */
  2069. let pipelineProblemsArrayEventList : any = [];
  2070. /**
  2071. * 由于一些管段会出现错位的问题,所以要进行,坐标偏移特殊处理
  2072. * 出现的次数
  2073. */
  2074. let distanceXBoolSum = 0;
  2075. /**
  2076. * 根据数组,来控制管道问题点的排序逻辑
  2077. * array 数组
  2078. */
  2079. const pipelineProblemsArrayEvent = (array : any) => {
  2080. pipelineProblemsJsonMoveEvent();
  2081. pipelineProblemsArrayEventList = array;
  2082. // console.log(
  2083. // "pipelineProblemsArrayEvent = (array : any) => {",
  2084. // "pipelineProblemsArrayEventList",
  2085. // pipelineProblemsArrayEventList
  2086. // );
  2087. // 每个管段 相差 x = 29.94 的距离,起始坐标 x = -260 [ 端头1 -289.94 ] , y = -13 , z = -30
  2088. // let startX = -260;
  2089. // let startX = -289.94;
  2090. let startX = -319.88;
  2091. let distanceX = 29.94;
  2092. /**
  2093. * 由于一些管段会出现错位的问题,所以要进行,坐标偏移特殊处理
  2094. * 出现的次数
  2095. */
  2096. distanceXBoolSum = 0;
  2097. // 开始根据数组的排序,来移动对应的管道到合适的位置
  2098. for (let i = 0; i < array.length; i++) {
  2099. let thisArray = array[i];
  2100. let name = thisArray.name;
  2101. if (pipelineProblemsJson[name] != null && pipelineProblemsJson[name] != undefined) {
  2102. let objPipelineProblemsJson = pipelineProblemsJson[name];
  2103. let exhibitionCode = objPipelineProblemsJson.exhibitionCode;
  2104. // @ts-ignore
  2105. let objMesh = threeWorld().obj.newIframe.objIframe.ChengGuangYuanJing.CommonVal.find().objScene.getMeshById(exhibitionCode);
  2106. if (objMesh != null && objMesh != undefined) {
  2107. let thisMesh = objMesh;
  2108. // 确认当前可进行移动的主物体
  2109. if (objMesh._parentContainer != null && objMesh._parentContainer != undefined) {
  2110. let _parentContainer = objMesh._parentContainer;
  2111. if (_parentContainer.meshes != null && _parentContainer.meshes != undefined) {
  2112. thisMesh = _parentContainer.meshes[0];
  2113. }
  2114. }
  2115. let newX = startX + distanceX * i;
  2116. // // 一些管段特殊处理
  2117. // if (name == "管道问题点-变形段") {
  2118. // // distanceXBoolSum += 1;
  2119. // console.log(
  2120. // name,
  2121. // thisMesh.id
  2122. // );
  2123. // }
  2124. // 触发整体偏移逻辑
  2125. newX = newX - (distanceX * distanceXBoolSum);
  2126. thisMesh.position.x = newX;
  2127. }
  2128. }
  2129. }
  2130. }
  2131. </script>
  2132. <template>
  2133. <!-- 3d课程配置:{{ props.config }} -->
  2134. <img v-if="courseChapter3dShow().show.threeWorldMask == true" class="threeWorldMask" src="../../assets/student/mask.webp" />
  2135. <CourseChapter3dMain
  2136. :iframeId="'newIframe'"
  2137. :url="threeWorldUrl"
  2138. @callbackLoadPercentage="callbackLoadPercentageEvent"
  2139. @callbackLoadEnd="callbackLoadEndEvent"
  2140. @callbackDistanceYes="callbackDistanceYesEvent"
  2141. @callbackDistanceNo="callbackDistanceNoEvent"
  2142. @callbackCameraVisualAngleJsonToLook="callbackCameraVisualAngleJsonToLookEvent"
  2143. ></CourseChapter3dMain>
  2144. </template>
  2145. <style scoped>
  2146. .threeWorldMask {
  2147. position: fixed;
  2148. z-index: 1;
  2149. width: 100%;
  2150. height: 100%;
  2151. top: 0px;
  2152. left: 0px;
  2153. pointer-events: none;
  2154. }
  2155. </style>