model.html 4.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132
  1. <!DOCTYPE html>
  2. <html lang="en-us">
  3. <head>
  4. <meta charset="utf-8">
  5. <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
  6. <title>常中e大观园</title>
  7. <link rel="shortcut icon" href="TemplateData/favicon.ico">
  8. <link rel="stylesheet" href="TemplateData/style.css">
  9. <link rel="manifest" href="manifest.webmanifest">
  10. <!-- 引用自己的样式 -->
  11. <link rel="stylesheet" href="./myCode/style.css">
  12. </head>
  13. <body>
  14. <div id="unity-container">
  15. <canvas id="unity-canvas" tabindex="-1"></canvas>
  16. <div id="unity-loading-bar">
  17. <div id="unity-logo"></div>
  18. <div id="unity-progress-bar-empty">
  19. <div id="unity-progress-bar-full"></div>
  20. </div>
  21. </div>
  22. <div id="unity-warning"> </div>
  23. </div>
  24. <!-- 加载中文字 -->
  25. <div id="lodingTxt">加载中...</div>
  26. <!-- 分享海报 -->
  27. <div class="shareBox">
  28. <img src="./StreamingAssets/share.png" alt="">
  29. <div class="shareTit">长按图片保存</div>
  30. <div class="shareBtn">关闭</div>
  31. </div>
  32. <script>
  33. let unityExamples = null
  34. window.addEventListener("load", function () {
  35. if ("serviceWorker" in navigator) {
  36. navigator.serviceWorker.register("ServiceWorker.js");
  37. }
  38. });
  39. var container = document.querySelector("#unity-container");
  40. var canvas = document.querySelector("#unity-canvas");
  41. var loadingBar = document.querySelector("#unity-loading-bar");
  42. var progressBarFull = document.querySelector("#unity-progress-bar-full");
  43. var warningBanner = document.querySelector("#unity-warning");
  44. // Shows a temporary message banner/ribbon for a few seconds, or
  45. // a permanent error message on top of the canvas if type=='error'.
  46. // If type=='warning', a yellow highlight color is used.
  47. // Modify or remove this function to customize the visually presented
  48. // way that non-critical warnings and error messages are presented to the
  49. // user.
  50. function unityShowBanner(msg, type) {
  51. function updateBannerVisibility() {
  52. warningBanner.style.display = warningBanner.children.length ? 'block' : 'none';
  53. }
  54. var div = document.createElement('div');
  55. div.innerHTML = msg;
  56. warningBanner.appendChild(div);
  57. if (type == 'error') div.style = 'background: red; padding: 10px;';
  58. else {
  59. if (type == 'warning') div.style = 'background: yellow; padding: 10px;';
  60. setTimeout(function () {
  61. warningBanner.removeChild(div);
  62. updateBannerVisibility();
  63. }, 5000);
  64. }
  65. updateBannerVisibility();
  66. }
  67. var buildUrl = "Build";
  68. var loaderUrl = buildUrl + "/ChangZhouHospital_2.3.loader.js";
  69. var config = {
  70. dataUrl: buildUrl + "/ChangZhouHospital_2.3.data.unityweb",
  71. frameworkUrl: buildUrl + "/ChangZhouHospital_2.3.framework.js.unityweb",
  72. codeUrl: buildUrl + "/ChangZhouHospital_2.3.wasm.unityweb",
  73. streamingAssetsUrl: "StreamingAssets",
  74. companyName: "DefaultCompany",
  75. productName: "ChangZhouHospital",
  76. productVersion: "1.1",
  77. showBanner: unityShowBanner,
  78. };
  79. // By default Unity keeps WebGL canvas render target size matched with
  80. // the DOM size of the canvas element (scaled by window.devicePixelRatio)
  81. // Set this to false if you want to decouple this synchronization from
  82. // happening inside the engine, and you would instead like to size up
  83. // the canvas DOM size and WebGL render target sizes yourself.
  84. // config.matchWebGLToCanvasSize = false;
  85. if (/iPhone|iPad|iPod|Android/i.test(navigator.userAgent)) {
  86. // Mobile device style: fill the whole browser client area with the game canvas:
  87. var meta = document.createElement('meta');
  88. meta.name = 'viewport';
  89. meta.content = 'width=device-width, height=device-height, initial-scale=1.0, user-scalable=no, shrink-to-fit=yes';
  90. document.getElementsByTagName('head')[0].appendChild(meta);
  91. }
  92. loadingBar.style.display = "block";
  93. var script = document.createElement("script");
  94. script.src = loaderUrl;
  95. script.onload = () => {
  96. createUnityInstance(canvas, config, (progress) => {
  97. progressBarFull.style.width = 100 * progress + "%";
  98. }).then((unityInstance) => {
  99. loadingBar.style.display = "none";
  100. // 把unity的实例保存起来
  101. unityExamples = unityInstance
  102. // 隐藏加载中文字
  103. document.querySelector('#lodingTxt').style.display = 'none'
  104. }).catch((message) => {
  105. alert(message);
  106. });
  107. };
  108. document.body.appendChild(script);
  109. </script>
  110. <!-- 引入自己的js -->
  111. <script src="./myCode/index.js"></script>
  112. </body>
  113. </html>