前端小玩意兒:用three.js開發的手機太空穿越VR游戲,特效非常猛

来源:https://www.cnblogs.com/coderhf/archive/2020/05/19/12917297.html
-Advertisement-
Play Games

hello,今天給大家用three.js開發了一個手機太空穿越VR游戲,確實不容易,小編的頭髮又少了一大截。Ok,廢話少說,先看效果。 效果圖 首頁index.html <!DOCTYPE html> <html lang="en" > <head> <meta charset="UTF-8"> < ...


hello,今天給大家用three.js開發了一個手機太空穿越VR游戲,確實不容易,小編的頭髮又少了一大截。Ok,廢話少說,先看效果。

效果圖

首頁index.html

<!DOCTYPE html>
<html lang="en" >

<head>
<meta charset="UTF-8">
<title>Three.js Mobile VR Sonic</title>



<link rel="stylesheet" href="css/style.css">


</head>

<body>

<script src="js/jquery-1.12.4.min.js"></script>
<script src="js/d3.v4.min.js"></script>
<script src="js/three.min.js"></script>
<script src="js/GLTFLoader.js"></script>


<script src="js/TweenMax.min.js"></script>
<script src="js/CSSPlugin.min.js"></script>
<script src="js/EasePack.min.js"></script>



<script src='js/AssimpJSONLoader.js'></script>
<script src="js/DeviceOrientationControls.js"></script>
<script src="js/OrbitControls.js"></script>
<script src="js/StereoEffect.js"></script>
<script src="js/tween.min.js"></script>
<script src="js/dat.gui.min.js"></script>
<!-- glowing effect scripts -->
<script src="js/EffectComposer.js"></script>
<script src="js/RenderPass.js"></script>
<script src="js/MaskPass.js"></script>
<script src="js/ShaderPass.js"></script>
<script src="js/CopyShader.js"></script>
<script src="js/FXAAShader.js"></script>
<script src="js/ConvolutionShader.js"></script>
<script src="js/LuminosityHighPassShader.js"></script>
<!-- unreal bloom -->
<script src="js/UnrealBloomPass.js"></script>


    <!-- VR Button -->
    <button id='VR' class='button toggleVR' onclick='toggleVR()' title='Toggle VR Mode for Mobile Devices Only'>
      <svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" version="1.1" x="0px" y="0px" viewBox="0 0 62.7 52.375" enable-background="new 0 0 62.7 41.9" xml:space="preserve"><path d="M53.4,5.5h-44c-2.1,0-3.7,1.7-3.7,3.7v22.6c0,2.1,1.7,3.7,3.7,3.7h13.4c1.1,0,2.1-0.6,2.5-1.6l3-7.5c1.2-2.6,4.9-2.5,6,0.1  l2.6,7.3c0.4,1,1.4,1.7,2.5,1.7h13.9c2.1,0,3.7-1.7,3.7-3.7V9.3C57.2,7.2,55.5,5.5,53.4,5.5z M20.4,27c-3.2,0-5.7-2.6-5.7-5.7  s2.6-5.7,5.7-5.7s5.7,2.6,5.7,5.7S23.6,27,20.4,27z M42.4,27c-3.2,0-5.7-2.6-5.7-5.7s2.6-5.7,5.7-5.7s5.7,2.6,5.7,5.7  S45.6,27,42.4,27z"/><text x="0" y="56.9" fill="#000000" font-size="5px" font-weight="bold" font-family="'Helvetica Neue', Helvetica, Arial-Unicode, Arial, Sans-serif">Created by Nick Bluth</text><text x="0" y="61.9" fill="#000000" font-size="5px" font-weight="bold" font-family="'Helvetica Neue', Helvetica, Arial-Unicode, Arial, Sans-serif">from the Noun Project</text></svg>
    </button>

    <div id="info">SUPER!</div>
    <audio id="bflat" src="sonic_ring_sound.mp3"></audio>
  
  

    <script  src="js/index.js"></script>




</body>

</html>

 

核心代碼js

//===================================================== full screen
var requestFullscreen = function(ele) {
  if (ele.requestFullscreen) {
    ele.requestFullscreen();
  } else if (ele.webkitRequestFullscreen) {
    ele.webkitRequestFullscreen();
  } else if (ele.mozRequestFullScreen) {
    ele.mozRequestFullScreen();
  } else if (ele.msRequestFullscreen) {
    ele.msRequestFullscreen();
  } else {
    console.log("Fullscreen API is not supported.");
  }
};
var exitFullscreen = function(ele) {
  if (ele.exitFullscreen) {
    ele.exitFullscreen();
  } else if (ele.webkitExitFullscreen) {
    ele.webkitExitFullscreen();
  } else if (ele.mozCancelFullScreen) {
    ele.mozCancelFullScreen();
  } else if (ele.msExitFullscreen) {
    ele.msExitFullscreen();
  } else {
    console.log("Fullscreen API is not supported.");
  }
};
//===================================================== add canvas
let renderer = new THREE.WebGLRenderer({ antialias: true, alpha: true });
renderer.setSize(window.innerWidth, window.innerHeight);
renderer.setClearColor(0xd8e7ff, 0);
document.body.appendChild(renderer.domElement);
//===================================================== resize
window.addEventListener("resize", function() {
  let width = window.innerWidth;
  let height = window.innerHeight;
  renderer.setSize(width, height);
  camera.aspect = width / height;
  camera.updateProjectionMatrix();
});
//===================================================== add Scene
let scene = new THREE.Scene();
//===================================================== add Camera
let camera = new THREE.PerspectiveCamera(
  45,
  window.innerWidth / window.innerHeight,
  1,
  10000
);
let cameraTarget = new THREE.Vector3(0, 0, 0);
//===================================================== add Group
group = new THREE.Group();
scene.add(group);
//===================================================== add Controls
var controls = new THREE.OrbitControls(camera, renderer.domElement);
controls.enableDamping = true;
controls.dampingFactor = 0.25;
controls.enableZoom = true;
//How far you can orbit vertically, upper and lower limits. The maximum is Pi / 2 (90deg). You wont see below the below the line of the horizon
controls.maxPolarAngle = Math.PI / 2.1;
//===================================================== add VR
renderer.setPixelRatio(window.devicePixelRatio); //VR
effect = new THREE.StereoEffect(renderer); //VR
effect.setSize(window.innerWidth, window.innerHeight); //VR

var VR = false;
function toggleVR() {
  if (VR) {
    VR = false;
    controls = new THREE.OrbitControls(camera, renderer.domElement);
  } else {
    VR = true;
    controls = new THREE.DeviceOrientationControls(camera);
    requestFullscreen(document.documentElement);
  }
  renderer.setSize(window.innerWidth, window.innerHeight);
}
//===================================================== curve points exported from blender using python
var points = [
  /*[2.873088836669922, 1.886053442955017, 2.807666063308716] ,
[2.8677191734313965, 1.901498556137085, 0.9702248573303223] ,
[4.261392116546631, 1.1370995044708252, 2.199495315551758] ,
[5.4436726570129395, -0.46564579010009766, 1.1223225593566895] ,
[4.683673858642578, -5.823459148406982, 0.29172343015670776] ,
[4.683673858642578, -5.823459148406982, 0.29172343015670776] ,
[1.0320820808410645, -8.896514892578125, -0.25123584270477295] ,
[-6.009271621704102, -5.854086875915527, -1.619685411453247] ,
[-5.8719940185546875, 1.664353609085083, 1.4598760604858398] ,
[-3.664644718170166, 5.1350908279418945, 0.8891280889511108] ,
[0.3946661949157715, 9.023353576660156, 2.472759246826172] ,
[6.545413017272949, 7.975126266479492, 4.807941913604736] ,
[9.380702018737793, 3.8875434398651123, -1.2000198364257812] ,
[3.980130672454834, -3.3519601821899414, -1.5907882452011108] ,
[0.10054226964712143, -4.0724077224731445, -2.6255977153778076] ,
[0.11306309700012207, -4.062130451202393, -2.625786781311035] ,
[-1.5915921926498413, 2.2223830223083496, 1.9054492712020874] ,
[-0.7800552845001221, 2.729933738708496, 2.711679458618164] ,
[2.2788195610046387, 1.5061609745025635, 3.6167585849761963] ,
[3.330962896347046, -1.753382682800293, 3.5841569900512695] ,
[3.3268532752990723, -1.7394065856933594, 3.584031343460083] ,
[1.8003381490707397, -2.6099541187286377, 4.496334552764893] ,
[1.809736728668213, -2.6042258739471436, 4.490817546844482] ,
[-1.5139055252075195, -2.2446377277374268, 3.513293743133545] ,
[-1.5139055252075195, -2.2446377277374268, 3.513293743133545] ,
[-1.5139055252075195, -2.2446377277374268, 1.7960444688796997] ,
[-1.9393141269683838, -0.623103678226471, 1.3167498111724854] ,
[-1.5, 0.0, 0.0] ,
[-1.0, 1.0, 0.0] ,
[1.0, 1.0, 0.0] ,
[1.5, 0.0, 0.0] ,*/

  [1.8117204904556274, 5.987488269805908, 0.29106736183166504],
  [6.005367279052734, 1.7647128105163574, -1.5591322183609009],
  [1.435487985610962, -6.016839504241943, 2.1336286067962646],
  [-4.118395805358887, -6.886471271514893, -0.7294682264328003],
  [-4.732693195343018, 3.405961036682129, 3.1304938793182373],
  [8.304193496704102, 7.593861103057861, 0.3412821292877197],
  [8.038525581359863, -4.391696453094482, 2.687108278274536],
  [1.488401174545288, -9.993440628051758, -2.2956111431121826],
  [-5.277090549468994, -8.481210708618164, -0.719127893447876],
  [-7.250330448150635, -0.9653520584106445, -0.3089699447154999],
  [-6.526705741882324, 5.678538799285889, 0.15560221672058105],
  [-0.885545015335083, 6.678538799285889, 1.5724562406539917],
  [1.614454984664917, 5.678538799285889, 0.24559785425662994],
  [1.8117204904556274, 5.987488269805908, 0.29106736183166504]
];

var scale = 5;

//Convert the array of points into vertices
for (var i = 0; i < points.length; i++) {
  var x = points[i][0] * scale;
  var y = points[i][1] * scale;
  var z = points[i][2] * scale;
  points[i] = new THREE.Vector3(x, z, -y);
}

//Create a path from the points
var carPath = new THREE.CatmullRomCurve3(points);
var radius = 0.25;

var geometry = new THREE.TubeGeometry(carPath, 600, radius, 10, false);

//Set a different color on each face
for (var i = 0, j = geometry.faces.length; i < j; i++) {
  geometry.faces[i].color = new THREE.Color(
    "hsl(" + Math.floor(Math.random() * 290) + ",50%,50%)"
  );
}

var material = new THREE.MeshBasicMaterial({
  side: THREE.BackSide,
  vertexColors: THREE.FaceColors,
  side: THREE.DoubleSide,
  transparent: true,
  opacity: 1
});
var tube = new THREE.Mesh(geometry, material);
scene.add(tube);

//===================================================== add lighta
var light = new THREE.DirectionalLight(0xefefff, 1.25);
light.position.set(1, 1, 1).normalize();
scene.add(light);
var light = new THREE.DirectionalLight(0xffefef, 1.25);
light.position.set(-1, -1, -1).normalize();
scene.add(light);

//Create a point light in our scene. Makes everything gloomy
var light = new THREE.PointLight(0xffffff, 1, 100);
scene.add(light);

//===================================================== particles
var mergedGeometry = new THREE.Geometry();

var boxGeometry = new THREE.TetrahedronGeometry(0.25, 0);

var material = new THREE.MeshNormalMaterial({
  color: new THREE.Color("white")
});

for (var i = 0; i < 1000; i++) {
  var x = Math.random() * 125 - 75;
  var y = Math.random() * 125 - 75;
  var z = Math.random() * 125 - 75;

  boxGeometry.translate(x, y, z);

  mergedGeometry.merge(boxGeometry);

  boxGeometry.translate(-x, -y, -z);
}

var cubes = new THREE.Mesh(mergedGeometry, material);
scene.add(cubes);

//===================================================== Loader
//3d model from
var loader = new THREE.GLTFLoader();
var model;
loader.load(
  "sky-island.glb",
  function(gltf) {
    gltf.scene.traverse(function(node) {
      if (node instanceof THREE.Mesh) {
        node.castShadow = true;
        node.material.side = THREE.DoubleSide;
      }
    });

    model = gltf.scene;
    model.scale.set(3, 3, 3);
    model.position.set(0, -20, -10);
    //model.rotateY(Math.PI);
    scene.add(model);
  }
);

//===================================================== Loader
//3d model from https://3dwarehouse.sketchup.com/user/0438052632930067253040161/wingedkoopa67?nav=models
var clock = new THREE.Clock();
var mixer = null;
var firstObject;
var loader = new THREE.GLTFLoader();
loader.load(
  "sonic.glb",
  function(gltf) {
    gltf.scene.traverse(function(node) {
      if (node instanceof THREE.Mesh) {
        node.castShadow = true;
        node.material.side = THREE.DoubleSide;
      }
    });

    firstObject = gltf.scene;
    firstObject.scale.set(0.65, 0.65, 0.65);
    group.add(firstObject);

    console.log(gltf.animations); //shows all animations imported into the dopesheet in blender

    mixer = new THREE.AnimationMixer(firstObject);
    mixer.clipAction(gltf.animations[0]).play();

    document.body.addEventListener("click", jump);
    function jump() {
      mixer.clipAction(gltf.animations[0]).stop();
      mixer.clipAction(gltf.animations[1]).play();
      setTimeout(function() {
        mixer.clipAction(gltf.animations[1]).stop();
        mixer.clipAction(gltf.animations[0]).play();
      }, 900);
    }
  }
);

//===================================================== add model
var size = 0.05;
var meshList = [];

for (var i = 0; i < carPath.points.length; i++) {
  var x = carPath.points[i].x;
  var y = carPath.points[i].y;
  var z = carPath.points[i].z;

  var geometry = new THREE.TorusGeometry(3, 0.5, 8, 50);
  var material = new THREE.MeshBasicMaterial({
    color: new THREE.Color("yellow")
  });
  var secondObject = new THREE.Mesh(geometry, material);
  secondObject.position.set(x, y + 0.75, z);
  secondObject.scale.set(size, size, size);
  meshList.push(secondObject);
  scene.add(secondObject);
}

//===================================================== Collision Detection
function PlaySound() {
  bflat.play();
}

//calculate distance of the main object
firstBB = new THREE.Box3().setFromObject(group);

//calculate distance for all other objects
for (var i = 0; i < meshList.length; i++) {
  secondBB = new THREE.Box3().setFromObject(meshList[i]);
}

var count = 0;
function hit() {
  //recalculate distance for the main object
  firstBB = new THREE.Box3().setFromObject(group);
  //recalcuate distance for all the other objects
  for (var i = 0; i < meshList.length; i++) {
    secondBB = new THREE.Box3().setFromObject(meshList[i]);

    if (firstBB.isIntersectionBox(secondBB)) {
      PlaySound();
      info.style.color = "hsl(" + Math.floor(Math.random() * 290) + ",50%,50%)";
      info.innerHTML =
        Math.random() > 0.25
          ? "Superb!"
          : Math.random() > 0.25 ? "Oustanding!" : "Awesome!";

      TweenLite.to(info, 0.75, {
        css: { fontSize: "50px", opacity: 1 },
        ease: Power4.easeOut,
        onComplete: function() {
          TweenLite.to(info, 0.75, {
            css: { fontSize: "14px", opacity: 0 },
            ease: Power4.easeOut
          }); //end tween
        } //end onComplete
      }); //end tween
    } //end if
  } //end for
} //end hit

//===================================================== bloom
var renderScene = new THREE.RenderPass(scene, camera);
var shaderActive = "none";
var gui = new dat.GUI();
dat.GUI.toggleHide();
var composer;

var parameters = {
  x: 0,
  y: 30,
  z: 0,
  bloomStrength: 1.0,
  bloomRadius: 1.0,
  bloomThreshold: 0.45,
  useShaderNone: function() {
    setupShaderNone();
  },
  useShaderBloom: function() {
    setupShaderBloom();
  }
};

gui.add(parameters, "useShaderNone").name("Display Original Scene");

var folderBloom = gui.addFolder("Bloom");
var bloomStrengthGUI = folderBloom
  .add(parameters, "bloomStrength")
  .min(0.0)
  .max(2.0)
  .step(0.01)
  .name("Strength")
  .listen();
bloomStrengthGUI.onChange(function(value) {
  setupShaderBloom();
});
var bloomRadiusGUI = folderBloom
  .add(parameters, "bloomRadius")
  .min(0.0)
  .max(5.0)
  .step(0.01)
  .name("Radius")
  .listen();
bloomRadiusGUI.onChange(function(value) {
  setupShaderBloom();
});
var bloomThresholdGUI = folderBloom
  .add(parameters, "bloomThreshold")
  .min(0)
  .max(0.99)
  .step(0.01)
  .name("Threshold")
  .listen();
bloomThresholdGUI.onChange(function(value) {
  setupShaderBloom();
});
folderBloom.add(parameters, "useShaderBloom").name("Use Bloom Shader");
folderBloom.open();

//===================================================== functions

function setupShaderNone() {
  shaderActive = "none";
}

function setupShaderBloom() {
  composer = new THREE.EffectComposer(renderer);
  composer.addPass(new THREE.RenderPass(scene, camera));

  /*unreal bloom*/
  var effectFXAA = new THREE.ShaderPass(THREE.FXAAShader);
  effectFXAA.uniforms["resolution"].value.set(
    1 / window.innerWidth,
    1 / window.innerHeight
  );

  var copyShader = new THREE.ShaderPass(THREE.CopyShader);
  copyShader.renderToScreen = true;

  var bloomPass = new THREE.UnrealBloomPass(
    new THREE.Vector2(window.innerWidth, window.innerHeight),
    parameters.bloomStrength,
    parameters.bloomRadius,
    parameters.bloomThreshold
  );

  composer = new THREE.EffectComposer(renderer);
  composer.setSize(window.innerWidth, window.innerHeight);
  composer.addPass(renderScene);
  composer.addPass(effectFXAA);
  composer.addPass(bloomPass);
  composer.addPass(copyShader);
  shaderActive = "bloom";
}

function isShaderActive() {
  if (shaderActive == "none") {
    renderer.render(scene, camera);
  } else {
    composer.render();
  }
}

//active bloom on load
setupShaderBloom();

//===================================================== Animate
var percentage = 0;
var prevTime = Date.now();
function POV() {
  percentage += 0.00045;
  var p1 = carPath.getPointAt(percentage % 1);
  var p2 = carPath.getPointAt((percentage + 0.01) % 1);
  var p3 = carPath.getPointAt((percentage + 0.01 / 2) % 1);
  var p4 = carPath.getPointAt((percentage + 0.01 / 4) % 1);

  camera.lookAt(p2);
 

  group.position.set(p3.x, p3.y + 0.25, p3.z);
  group.lookAt(p2);
  camera.position.x = p4.x + 2;
  camera.position.y = p4.y + 1;
  camera.position.z = p4.z + 2;
  camera.lookAt(group.position);
}

function animate() {
  POV();
  hit();
  var delta = clock.getDelta();
  if (mixer != null) mixer.update(delta);

  //VR
  if (VR) {
    effect.render(scene, camera);
  } else {
    //renderer.render( scene, camera );
    isShaderActive();
  }

  requestAnimationFrame(animate);
  controls.update();
}
animate();

//set camera position
camera.position.x = 40;
camera.position.y = 50;
camera.position.z = 50;

更多學習內容:請關註我的知乎專欄    高級前端工程師前端學習教程,從基礎到進階,看完保證讓你的薪資上升一個臺階,你也能成為阿裡人(持續更新)

 


您的分享是我們最大的動力!

-Advertisement-
Play Games
更多相關文章
  • 1. SELinux 背景知識 1.1 DAC 與 MAC 在 SELinux 出現之前,Linux 上的安全模型叫 DAC,全稱是 Discretionary Access Control,翻譯為自主訪問控制。 DAC 的核心思想很簡單,就是:進程理論上所擁有的許可權與執行它的用戶的許可權相同。比如, ...
  • 一、Swich語句 1.switch語句格式 swich(條件表達式){ case 表達式: 語句1; break; case 表示式: 語句2; break; case 表達式: 語句3: break; default: 語句n+1; break; } 註意點: (1)JS中判斷是否相等時是全等於 ...
  • 寫在前面 書籍介紹:《React進階之路》詳細介紹了React技術棧涉及的主要技術。本書分為基礎篇、進階篇和實戰篇三部分。基礎篇主要介紹React的基本用法,包括React 16的新特性;進階篇深入講解組件state、虛擬DOM、高階組件等React中的重要概念,同時對初學者容易困惑的知識點做了介紹 ...
  • 【目錄】 一、jQuery 簡介 二、jQuery 的基本使用 一、jQuery 簡介 1、介紹 jQuery內部封裝了原生的js代碼(還額外添加了很多的功能)能夠讓你通過書寫更少的代碼 完成js操作 類似於python裡面的模塊 在前端模塊不叫模塊 叫 “類庫” 相容多個瀏覽器的 你在使用jQue ...
  • 如何學好Web前端開發技術?前端學習路線是什麼?如今,移動開發的發展依舊如火如荼,企業對於Web前端人才需求產生了巨大的缺口,從事Web前端開發的程式員們則是其中較大的獲益者。Web前端的廣泛運用,造就了本身的優勢。現在學習Web前端是絕佳時期,抓住機會,拿高薪進名企就不再是問題。那麼想學好這門技術 ...
  • # 什麼是Hexo? Hexo 是一個快速、簡潔且高效的博客框架。Hexo 使用 Markdown(或其他渲染引擎)解析文章,在幾秒內,即可利用靚麗的主題生成靜態網頁。 # 優勢 1. Node.js 所帶來的超快生成速度,讓上百個頁面在幾秒內瞬間完成渲染。 2. Hexo 支持 GitHub Fl... ...
  • function isInArray(arr, val) { let testStr = ',' + arr.join(",") + ","; return testStr.indexOf("," + val + ",") -1 } ...
  • let markPointData = op.series[params.seriesIndex].markPoint.data; let newMarkPointData = markPointData.filter(({ name }) => name !== params.name); d1 ...
一周排行
    -Advertisement-
    Play Games
  • 移動開發(一):使用.NET MAUI開發第一個安卓APP 對於工作多年的C#程式員來說,近來想嘗試開發一款安卓APP,考慮了很久最終選擇使用.NET MAUI這個微軟官方的框架來嘗試體驗開發安卓APP,畢竟是使用Visual Studio開發工具,使用起來也比較的順手,結合微軟官方的教程進行了安卓 ...
  • 前言 QuestPDF 是一個開源 .NET 庫,用於生成 PDF 文檔。使用了C# Fluent API方式可簡化開發、減少錯誤並提高工作效率。利用它可以輕鬆生成 PDF 報告、發票、導出文件等。 項目介紹 QuestPDF 是一個革命性的開源 .NET 庫,它徹底改變了我們生成 PDF 文檔的方 ...
  • 項目地址 項目後端地址: https://github.com/ZyPLJ/ZYTteeHole 項目前端頁面地址: ZyPLJ/TreeHoleVue (github.com) https://github.com/ZyPLJ/TreeHoleVue 目前項目測試訪問地址: http://tree ...
  • 話不多說,直接開乾 一.下載 1.官方鏈接下載: https://www.microsoft.com/zh-cn/sql-server/sql-server-downloads 2.在下載目錄中找到下麵這個小的安裝包 SQL2022-SSEI-Dev.exe,運行開始下載SQL server; 二. ...
  • 前言 隨著物聯網(IoT)技術的迅猛發展,MQTT(消息隊列遙測傳輸)協議憑藉其輕量級和高效性,已成為眾多物聯網應用的首選通信標準。 MQTTnet 作為一個高性能的 .NET 開源庫,為 .NET 平臺上的 MQTT 客戶端與伺服器開發提供了強大的支持。 本文將全面介紹 MQTTnet 的核心功能 ...
  • Serilog支持多種接收器用於日誌存儲,增強器用於添加屬性,LogContext管理動態屬性,支持多種輸出格式包括純文本、JSON及ExpressionTemplate。還提供了自定義格式化選項,適用於不同需求。 ...
  • 目錄簡介獲取 HTML 文檔解析 HTML 文檔測試參考文章 簡介 動態內容網站使用 JavaScript 腳本動態檢索和渲染數據,爬取信息時需要模擬瀏覽器行為,否則獲取到的源碼基本是空的。 本文使用的爬取步驟如下: 使用 Selenium 獲取渲染後的 HTML 文檔 使用 HtmlAgility ...
  • 1.前言 什麼是熱更新 游戲或者軟體更新時,無需重新下載客戶端進行安裝,而是在應用程式啟動的情況下,在內部進行資源或者代碼更新 Unity目前常用熱更新解決方案 HybridCLR,Xlua,ILRuntime等 Unity目前常用資源管理解決方案 AssetBundles,Addressable, ...
  • 本文章主要是在C# ASP.NET Core Web API框架實現向手機發送驗證碼簡訊功能。這裡我選擇是一個互億無線簡訊驗證碼平臺,其實像阿裡雲,騰訊雲上面也可以。 首先我們先去 互億無線 https://www.ihuyi.com/api/sms.html 去註冊一個賬號 註冊完成賬號後,它會送 ...
  • 通過以下方式可以高效,並保證數據同步的可靠性 1.API設計 使用RESTful設計,確保API端點明確,並使用適當的HTTP方法(如POST用於創建,PUT用於更新)。 設計清晰的請求和響應模型,以確保客戶端能夠理解預期格式。 2.數據驗證 在伺服器端進行嚴格的數據驗證,確保接收到的數據符合預期格 ...