{ 3 var obj = arr_webplayers[key2]; 4 switch(obj.methodofmove) 5 { 6 case "controlwitha": 7 { 8 obj.lab.rotation.y=(-1.55 - cameraArcRotative[0].alpha)-obj.mesh.rotation.y; 9 if(obj.countstop<=4) 10 { 11 if ((obj.vmove.x != 0 || obj.vmove.y != 0 || obj.vmove.z != 0 || obj.rychange != 0)&& obj.PlayAnnimation == false) { 12 obj.PlayAnnimation = true; 13 obj.beginSP(0); 14 obj.mesh.moveWithCollisions(obj.vmove); 15 } (obj.vmove.x == 0 && obj.vmove.y == 0 && obj.vmove.z == 0 && obj.rychange == 0 && obj.PlayAnnimation == true) { 17 obj.countstop++; { 20 obj.PlayAnnimation = false; 21 obj.stopSP(0); 22 } 23 } 24 } 25 break; 26 } 27 default : 28 { 29 break; 30 } 31 } 32 }
c¡¢×îºóÊǶÔNPCÎïÌåÔ˶¯Í¬²½µÄ´¦Àí£º
1 case "[admins]": 2 { 3 if(username=="admin") } { 9 if(!scene.isReady() || !arr_myplayers) 10 { 11 return; 12 } 13 var arr_rabbitmove=JSON.parse(str_data.substr(8)); 14 var len=arr_rabbitmove.length; 15 for(var i=0;i<len;i++) 16 { 17 var arr=arr_rabbitmove[i]; 18 var rabbit=arr_animals[arr[0]]; 19 var rabbitmesh=rabbit.mesh; 20 rabbitmesh.position=arr[1]; 21 rabbitmesh.rotation=arr[2]; 22 rabbit.vmove=arr[3]; 23 rabbit.rychange=arr[4]; (arr[5]=="run"&&rabbit.state=="eat") 26 { 27 rabbit.state="run"; 28 rabbit.powerofmove=3; 29 scene.beginAnimation(rabbitmesh.skeleton, 0, 72, true, 2.4); 30 } (arr[5]=="eat"&&rabbit.state=="run") 32 { 33 rabbit.state="eat"; 34 rabbit.powerofmove=1; 35 scene.beginAnimation(rabbitmesh.skeleton, 0, 72, true, 0.8); 36 } 37 } 38 } 39 break; 40 }
½â¿ªJSON£¬¶Ôÿһ¸öNPCÎïÌå·Ö±ð´¦Àí¡£
Îå¡¢²¿ÊðºÍʹÓãº
³ÌÐòÍêÕû´úÂëÔÚ¿ÉÒÔÔÚhttps://github.com/ljzc002/WebGL2ÏÂÔØ£¬ÎÒ±àдµÄ´úÂë»ùÓÚMITÐÒé·¢²¼£¬Ê¹ÓõĵÚÈý·½¿âÎļþ°´ÆäÔÓеķ¢²¼ÐÒé·¢²¼¡£
²¿Ê𣺰ÑPRACTICE/WebRoot/ϵÄËùÓÐÎļþ¸´ÖƵ½PRACTICE3/Ŀ¼Ï£¬½«PRACTICE3/¸´ÖƵ½TomcatµÄWebApps/Ŀ¼Ï£¬°ÑPRACTICE3/¸ÄÃûΪPRACTICE/£¬Æô¶¯Tomcat£¬·ÃÎÊscene_link.htmlÒ³Ãæ¡£
ʹÓ㺵ÚÒ»¸öinputÊäÈëWebsocketËùÔÚIP£¬µÚ¶þ¸öinputÊäÈëÓû§Ãû£¨ÊäÈëadmin±íʾÉêÇë×÷ΪÖ÷»ú£©£¬µã»÷¡°websocketÁ¬½Ó¡±½¨Á¢Á¬½Ó£¬µã»÷¡°Æô¶¯³¡¾°¡±Æô¶¯WebGL³¡¾°¡£
Áù¡¢Ð´ÔÚºóÃæµÄ»°£º
ÏÞÓÚʱ¼äºÍ±à³Ìˮƽ£¬³ÌÐòÖл¹ÓкܶàbugºÍȱÏÝ£¬»¶Ó´ó¼ÒÅúÆÀÖ¸Õý¡£
¡¡