|
@@ -4,9 +4,22 @@
|
|
|
<HomeFadeIn
|
|
|
v-if="isShowFadeInMask"
|
|
|
class="fade-in-mask"
|
|
|
- @loading-end="onLoadingEnd"
|
|
|
+ :progress="progress"
|
|
|
/>
|
|
|
</transition>
|
|
|
+
|
|
|
+ <div
|
|
|
+ v-show="$route.meta.isShow3DMap"
|
|
|
+ id="unity-container"
|
|
|
+ >
|
|
|
+ <canvas
|
|
|
+ id="unity-canvas"
|
|
|
+ width="960"
|
|
|
+ height="600"
|
|
|
+ tabindex="-1"
|
|
|
+ />
|
|
|
+ </div>
|
|
|
+
|
|
|
<router-view />
|
|
|
|
|
|
<nav
|
|
@@ -99,26 +112,88 @@ export default {
|
|
|
HomeFadeIn,
|
|
|
},
|
|
|
setup () {
|
|
|
- const isShowFadeInMask = ref(false)
|
|
|
- function onLoadingEnd() {
|
|
|
- isShowFadeInMask.value = false
|
|
|
- }
|
|
|
+ const isShowFadeInMask = ref(true)
|
|
|
+ const progress = ref(0)
|
|
|
+ onMounted(() => {
|
|
|
+ // this.$mitt.on('test', e => {
|
|
|
+ // console.log('test', e)
|
|
|
+ // })
|
|
|
+
|
|
|
+ window.addEventListener("load", function () {
|
|
|
+ if ("serviceWorker" in navigator) {
|
|
|
+ navigator.serviceWorker.register("ServiceWorker.js")
|
|
|
+ }
|
|
|
+ })
|
|
|
+
|
|
|
+ var canvas = document.querySelector("#unity-canvas")
|
|
|
+
|
|
|
+ var buildUrl = "unity/Build"
|
|
|
+ var loaderUrl = buildUrl + "/SHIndustryMuseum_1.6.loader.js"
|
|
|
+ var config = {
|
|
|
+ dataUrl: buildUrl + "/SHIndustryMuseum_1.6.data.unityweb",
|
|
|
+ frameworkUrl: buildUrl + "/SHIndustryMuseum_1.6.framework.js.unityweb",
|
|
|
+ codeUrl: buildUrl + "/SHIndustryMuseum_1.6.wasm.unityweb",
|
|
|
+ streamingAssetsUrl: "StreamingAssets",
|
|
|
+ companyName: "DefaultCompany",
|
|
|
+ productName: "SHIndustryMuseum",
|
|
|
+ productVersion: "0.1",
|
|
|
+ }
|
|
|
+
|
|
|
+ // By default Unity keeps WebGL canvas render target size matched with
|
|
|
+ // the DOM size of the canvas element (scaled by window.devicePixelRatio)
|
|
|
+ // Set this to false if you want to decouple this synchronization from
|
|
|
+ // happening inside the engine, and you would instead like to size up
|
|
|
+ // the canvas DOM size and WebGL render target sizes yourself.
|
|
|
+ // config.matchWebGLToCanvasSize = false;
|
|
|
+ if (/iPhone|iPad|iPod|Android/i.test(navigator.userAgent)) {
|
|
|
+ // Mobile device style: fill the whole browser client area with the game canvas:
|
|
|
+ var meta = document.createElement('meta')
|
|
|
+ meta.name = 'viewport'
|
|
|
+ meta.content = 'width=device-width, height=device-height, initial-scale=1.0, user-scalable=no, shrink-to-fit=yes'
|
|
|
+ document.getElementsByTagName('head')[0].appendChild(meta)
|
|
|
+ }
|
|
|
+
|
|
|
+ var script = document.createElement("script")
|
|
|
+ script.src = loaderUrl
|
|
|
+ script.onload = () => {
|
|
|
+ createUnityInstance(canvas, config, (paramProgress) => {
|
|
|
+ progress.value = Math.round(paramProgress * 100)
|
|
|
+ if (paramProgress > 0.95) {
|
|
|
+ setTimeout(() => {
|
|
|
+ isShowFadeInMask.value = false
|
|
|
+ }, 1000)
|
|
|
+ }
|
|
|
+ }).then((unityInstance) => {
|
|
|
+ window.gUnityInst = unityInstance
|
|
|
+
|
|
|
+ for (let index = 1; index <= 36; index++) {
|
|
|
+ unityInstance.SendMessage('Panel1', 'ShowEnterprise', index) //显示id为index的企业
|
|
|
+ // unityInstance.SendMessage('Panel1', 'HideEnterprise', index); //隐藏id为index的企业
|
|
|
+ }
|
|
|
+
|
|
|
+ }).catch((message) => {
|
|
|
+ alert(message)
|
|
|
+ })
|
|
|
+ }
|
|
|
+ window.onClickEnterprise = function (id) {
|
|
|
+ if (window.onCorpOnMapClicked) {
|
|
|
+ window.onCorpOnMapClicked(id)
|
|
|
+ }
|
|
|
+ }
|
|
|
+ document.body.appendChild(script)
|
|
|
+ })
|
|
|
|
|
|
const isShowNavBar = ref(true)
|
|
|
const activeNavItemIdx = ref(0)
|
|
|
+
|
|
|
return {
|
|
|
isShowFadeInMask,
|
|
|
- onLoadingEnd,
|
|
|
+ progress,
|
|
|
|
|
|
isShowNavBar,
|
|
|
activeNavItemIdx,
|
|
|
}
|
|
|
},
|
|
|
- mounted() {
|
|
|
- this.$mitt.on('test', e => {
|
|
|
- console.log('test', e)
|
|
|
- })
|
|
|
- }
|
|
|
}
|
|
|
</script>
|
|
|
|