shaogen1995 1 месяц назад
Родитель
Сommit
de8765fc60

BIN
public/Chenzhebei-ShanxiMuseum/Build/Build.data.unityweb


BIN
public/Chenzhebei-ShanxiMuseum/Build/Build.framework.js.unityweb


BIN
public/Chenzhebei-ShanxiMuseum/Build/Build.wasm.unityweb


+ 314 - 0
public/Chenzhebei-ShanxiMuseum/StreamingAssets/Settings.json

@@ -0,0 +1,314 @@
+{
+  "panels": [
+    {
+      "name": "DefaultVirtualCamera",
+      "cameraOrthographicSize": 9,
+      "viewportX": 0,
+      "offset": -10,
+      "model": {
+        "rotation": {
+          "x": 0,
+          "y": -180,
+          "z": 0
+        }
+      }
+    },
+    {
+      "name": "Panel1Camera",
+      "cameraOrthographicSize": 9,
+      "viewportX": 0,
+      "offset": -10,
+      "model": {
+        "rotation": {
+          "x": 0,
+          "y": -180,
+          "z": 0
+        }
+      }
+    },
+    {
+      "name": "Panel2Camera",
+      "cameraOrthographicSize": 9,
+      "viewportX": 0,
+      "offset": -10,
+      "model": {
+        "rotation": {
+          "x": 0,
+          "y": -180,
+          "z": 0
+        }
+      }
+    },
+    {
+      "name": "Panel3Camera",
+      "cameraOrthographicSize": 9,
+      "viewportX": 0,
+      "offset": -10,
+      "model": {
+        "rotation": {
+          "x": 0,
+          "y": -180,
+          "z": 0
+        }
+      }
+    },
+    {
+      "name": "Panel4Camera",
+      "cameraOrthographicSize": 9,
+      "viewportX": 0,
+      "offset": -10,
+      "model": {
+        "rotation": {
+          "x": 0,
+          "y": 0,
+          "z": 0
+        }
+      }
+    },
+    {
+      "name": "Panel5Camera",
+      "cameraOrthographicSize": 9,
+      "viewportX": 0.5,
+      "offset": 0,
+      "model": {
+        "rotation": {
+          "x": 0,
+          "y": -180,
+          "z": 0
+        }
+      },
+      "rotationNotAllowed": true
+    }
+  ],
+  "hotspots": [
+    {
+      "name": "佛龛",
+      "camera": {
+        "cameraOrthographicSize": 5,
+        "viewportX": 0.5,
+        "offset": 0,
+        "position": {
+          "y": 1.1,
+          "z": -50
+        }
+      },
+      "model": {
+        "rotation": {
+          "x": 0,
+          "y": -180,
+          "z": 0
+        }
+      }
+    },
+    {
+      "name": "佛像",
+      "camera": {
+        "cameraOrthographicSize": 5,
+        "viewportX": 0.5,
+        "offset": 0,
+        "position": {
+          "y": 0,
+          "z": -50
+        }
+      },
+      "model": {
+        "rotation": {
+          "x": 0,
+          "y": -180,
+          "z": 0
+        }
+      }
+    },
+    {
+      "name": "佛龛两侧",
+      "camera": {
+        "cameraOrthographicSize": 5,
+        "viewportX": 0.5,
+        "offset": 0,
+        "position": {
+          "y": 0,
+          "z": -50
+        }
+      },
+      "model": {
+        "rotation": {
+          "x": 0,
+          "y": -180,
+          "z": 0
+        }
+      }
+    },
+    {
+      "name": "佛龛上部",
+      "camera": {
+        "cameraOrthographicSize": 5,
+        "viewportX": 0.5,
+        "offset": 0,
+        "position": {
+          "y": 2,
+          "z": -50
+        }
+      },
+      "model": {
+        "rotation": {
+          "x": 0,
+          "y": -180,
+          "z": 0
+        }
+      }
+    },
+    {
+      "name": "佛龛下部",
+      "camera": {
+        "cameraOrthographicSize": 5,
+        "viewportX": 0.5,
+        "offset": 0,
+        "position": {
+          "y": -1,
+          "z": -50
+        }
+      },
+      "model": {
+        "rotation": {
+          "x": 0,
+          "y": -180,
+          "z": 0
+        }
+      }
+    },
+    {
+      "name": "畏兽",
+      "camera": {
+        "cameraOrthographicSize": 5,
+        "viewportX": 0.5,
+        "offset": 0,
+        "position": {
+          "y": 2,
+          "z": -50
+        }
+      },
+      "model": {
+        "rotation": {
+          "x": 0,
+          "y": -90,
+          "z": 0
+        }
+      }
+    },
+    {
+      "name": "飞天",
+      "camera": {
+        "cameraOrthographicSize": 5,
+        "viewportX": 0.5,
+        "offset": 0,
+        "position": {
+          "y": 0,
+          "z": -50
+        }
+      },
+      "model": {
+        "rotation": {
+          "x": 0,
+          "y": -90,
+          "z": 0
+        }
+      }
+    },
+    {
+      "name": "摩尼宝珠",
+      "camera": {
+        "cameraOrthographicSize": 5,
+        "viewportX": 0.5,
+        "offset": 0,
+        "position": {
+          "y": -1,
+          "z": -50
+        }
+      },
+      "model": {
+        "rotation": {
+          "x": 0,
+          "y": -90,
+          "z": 0
+        }
+      }
+    }
+  ],
+  "inscriptions": [
+    {
+      "name": "碑额",
+      "camera": {
+        "cameraOrthographicSize": 2,
+        "viewportX": 0,
+        "offset": 0,
+        "position": {
+          "y": 4.4,
+          "z": -50
+        }
+      },
+      "model": {
+        "rotation": {
+          "x": 0,
+          "y": 0,
+          "z": 0
+        }
+      }
+    },
+    {
+      "name": "碑文1",
+      "camera": {
+        "cameraOrthographicSize": 2,
+        "viewportX": 0,
+        "offset": 0,
+        "position": {
+          "y": 3.6,
+          "z": -50
+        }
+      },
+      "model": {
+        "rotation": {
+          "x": 0,
+          "y": 0,
+          "z": 0
+        }
+      }
+    },{
+      "name": "碑文2",
+      "camera": {
+        "cameraOrthographicSize": 9,
+        "viewportX": 0,
+        "offset": -10,
+        "position": {
+          "y": 0,
+          "z": -50
+        }
+      },
+      "model": {
+        "rotation": {
+          "x": 0,
+          "y": 0,
+          "z": 0
+        }
+      }
+    },
+    {
+      "name": "碑文3",
+      "camera": {
+        "cameraOrthographicSize": 9,
+        "viewportX": 0,
+        "offset": -10,
+        "position": {
+          "y": 0,
+          "z": -50
+        }
+      },
+      "model": {
+        "rotation": {
+          "x": 0,
+          "y": 0,
+          "z": 0
+        }
+      }
+    }
+  ]
+}

+ 7 - 0
public/Chenzhebei-ShanxiMuseum/unityExport.js

@@ -66,3 +66,10 @@ window.addModelScale = function (value) {
 window.resetModel = function () {
     window.unityInstance.SendMessage('MainCanvas', 'ResetModel')
 }
+
+// 调整模型大小和位置
+window.refreshAppSettings = function (json) {
+    console.log('xxxxxxxx',typeof(json));
+    
+    window.unityInstance.SendMessage('MainCanvas', 'RefreshAppSettings', json)
+}

BIN
public/myData/home.ts


+ 343 - 19
src/App.tsx

@@ -7,13 +7,11 @@ import SpinLoding from './components/SpinLoding'
 import store, { RootState } from './store'
 import { useSelector } from 'react-redux'
 import NotFound from '@/components/NotFound'
-import { baseURL, isLoc, myData } from './utils/http'
+import { baseURL, envFlag, isLoc, myData } from './utils/http'
 import AsyncSpinLoding from './components/AsyncSpinLoding'
 import { Image } from 'antd'
 import MessageCom from '@/components/Message'
 
-
-
 // import Vconsole from 'vconsole'
 // new Vconsole()
 
@@ -29,7 +27,6 @@ const A7Wjwj = React.lazy(() => import('./pages/A7wjwj'))
 const A6_1_zxys = React.lazy(() => import('./pages/A6ybwx/A6_1_zxys'))
 const A6_2_zxzgh = React.lazy(() => import('./pages/A6ybwx/A6_2_zxzgh'))
 
-
 declare global {
   //设置全局属性
   interface Window {
@@ -40,8 +37,6 @@ declare global {
   }
 }
 
-
-
 let tempW = document.documentElement.clientWidth
 let tempH = document.documentElement.clientHeight
 
@@ -68,7 +63,6 @@ export default function App() {
 
   const lookBigImg = useSelector((state: RootState) => state.A0Layout.lookBigImg)
 
-
   // 根元素
   const rootRef = useRef<any>(null)
 
@@ -173,34 +167,365 @@ export default function App() {
 
   // 动态根据路由更改背景图
   const handleHashChange = () => {
-
     if (window.location.hash === '#/base') {
       callIframeFu('changePanel', 0)
       callIframeFu('showInscription', -1)
       callIframeFu('showHotspot', -1)
-    };
+    }
     if (window.location.hash === '#/yblm') {
       callIframeFu('changePanel', 1)
       callIframeFu('showInscription', -1)
       callIframeFu('showHotspot', -1)
-    };
-    if (window.location.hash === '#/beie') { callIframeFu('changePanel', 3); callIframeFu('showInscription', 0) }
+    }
+    if (window.location.hash === '#/beie') {
+      callIframeFu('changePanel', 3)
+      callIframeFu('showInscription', 0)
+    }
     if (window.location.hash === '#/quanwen') {
-      callIframeFu('changePanel', 3);
+      callIframeFu('changePanel', 3)
       callIframeFu('showInscription', -1)
     }
     if (window.location.hash === '#/wenwu') {
       callIframeFu('changePanel', 4)
       callIframeFu('showInscription', -1)
       callIframeFu('showHotspot', -1)
-    };
-  };
+    }
+  }
   useEffect(() => {
-    window.addEventListener('hashchange', handleHashChange);
+    window.addEventListener('hashchange', handleHashChange)
     return () => {
-      window.removeEventListener('hashchange', handleHashChange);
-    };
-  }, []);
+      window.removeEventListener('hashchange', handleHashChange)
+    }
+  }, [])
+
+  // 更新unity页面
+  useEffect(() => {
+    if (envFlag) {
+      window.addEventListener('keyup', e => {
+        if (e.code === 'Enter') {
+          callIframeFu(
+            'refreshAppSettings',
+            JSON.stringify(
+              {
+              panels: [
+                {
+                  name: 'DefaultVirtualCamera',
+                  cameraOrthographicSize: 9,
+                  viewportX: 0,
+                  offset: -10,
+                  model: {
+                    rotation: {
+                      x: 0,
+                      y: -180,
+                      z: 0
+                    }
+                  }
+                },
+                {
+                  name: 'Panel1Camera',
+                  cameraOrthographicSize: 4,
+                  viewportX: 0.5,
+                  offset: -10,
+                  model: {
+                    rotation: {
+                      x: 0,
+                      y: -180,
+                      z: 0
+                    }
+                  }
+                },
+                {
+                  name: 'Panel2Camera',
+                  cameraOrthographicSize: 9,
+                  viewportX: 0,
+                  offset: -10,
+                  model: {
+                    rotation: {
+                      x: 0,
+                      y: -180,
+                      z: 0
+                    }
+                  }
+                },
+                {
+                  name: 'Panel3Camera',
+                  cameraOrthographicSize: 9,
+                  viewportX: 0,
+                  offset: -10,
+                  model: {
+                    rotation: {
+                      x: 0,
+                      y: -180,
+                      z: 0
+                    }
+                  }
+                },
+                {
+                  name: 'Panel4Camera',
+                  cameraOrthographicSize: 9,
+                  viewportX: 0,
+                  offset: -10,
+                  model: {
+                    rotation: {
+                      x: 0,
+                      y: 0,
+                      z: 0
+                    }
+                  }
+                },
+                {
+                  name: 'Panel5Camera',
+                  cameraOrthographicSize: 9,
+                  viewportX: 0.5,
+                  offset: 0,
+                  model: {
+                    rotation: {
+                      x: 0,
+                      y: -180,
+                      z: 0
+                    }
+                  },
+                  rotationNotAllowed: true
+                }
+              ],
+              hotspots: [
+                {
+                  name: '佛龛',
+                  camera: {
+                    cameraOrthographicSize: 5,
+                    viewportX: 0.5,
+                    offset: 0,
+                    position: {
+                      y: 1.1,
+                      z: -50
+                    }
+                  },
+                  model: {
+                    rotation: {
+                      x: 0,
+                      y: -180,
+                      z: 0
+                    }
+                  }
+                },
+                {
+                  name: '佛像',
+                  camera: {
+                    cameraOrthographicSize: 5,
+                    viewportX: 0.5,
+                    offset: 0,
+                    position: {
+                      y: 0,
+                      z: -50
+                    }
+                  },
+                  model: {
+                    rotation: {
+                      x: 0,
+                      y: -180,
+                      z: 0
+                    }
+                  }
+                },
+                {
+                  name: '佛龛两侧',
+                  camera: {
+                    cameraOrthographicSize: 5,
+                    viewportX: 0.5,
+                    offset: 0,
+                    position: {
+                      y: 0,
+                      z: -50
+                    }
+                  },
+                  model: {
+                    rotation: {
+                      x: 0,
+                      y: -180,
+                      z: 0
+                    }
+                  }
+                },
+                {
+                  name: '佛龛上部',
+                  camera: {
+                    cameraOrthographicSize: 5,
+                    viewportX: 0.5,
+                    offset: 0,
+                    position: {
+                      y: 2,
+                      z: -50
+                    }
+                  },
+                  model: {
+                    rotation: {
+                      x: 0,
+                      y: -180,
+                      z: 0
+                    }
+                  }
+                },
+                {
+                  name: '佛龛下部',
+                  camera: {
+                    cameraOrthographicSize: 5,
+                    viewportX: 0.5,
+                    offset: 0,
+                    position: {
+                      y: -1,
+                      z: -50
+                    }
+                  },
+                  model: {
+                    rotation: {
+                      x: 0,
+                      y: -180,
+                      z: 0
+                    }
+                  }
+                },
+                {
+                  name: '畏兽',
+                  camera: {
+                    cameraOrthographicSize: 5,
+                    viewportX: 0.5,
+                    offset: 0,
+                    position: {
+                      y: 2,
+                      z: -50
+                    }
+                  },
+                  model: {
+                    rotation: {
+                      x: 0,
+                      y: -90,
+                      z: 0
+                    }
+                  }
+                },
+                {
+                  name: '飞天',
+                  camera: {
+                    cameraOrthographicSize: 5,
+                    viewportX: 0.5,
+                    offset: 0,
+                    position: {
+                      y: 0,
+                      z: -50
+                    }
+                  },
+                  model: {
+                    rotation: {
+                      x: 0,
+                      y: -90,
+                      z: 0
+                    }
+                  }
+                },
+                {
+                  name: '摩尼宝珠',
+                  camera: {
+                    cameraOrthographicSize: 5,
+                    viewportX: 0.5,
+                    offset: 0,
+                    position: {
+                      y: -1,
+                      z: -50
+                    }
+                  },
+                  model: {
+                    rotation: {
+                      x: 0,
+                      y: -90,
+                      z: 0
+                    }
+                  }
+                }
+              ],
+              inscriptions: [
+                {
+                  name: '碑额',
+                  camera: {
+                    cameraOrthographicSize: 2,
+                    viewportX: 0,
+                    offset: 0,
+                    position: {
+                      y: 4.4,
+                      z: -50
+                    }
+                  },
+                  model: {
+                    rotation: {
+                      x: 0,
+                      y: 0,
+                      z: 0
+                    }
+                  }
+                },
+                {
+                  name: '碑文1',
+                  camera: {
+                    cameraOrthographicSize: 2,
+                    viewportX: 0,
+                    offset: 0,
+                    position: {
+                      y: 3.6,
+                      z: -50
+                    }
+                  },
+                  model: {
+                    rotation: {
+                      x: 0,
+                      y: 0,
+                      z: 0
+                    }
+                  }
+                },
+                {
+                  name: '碑文2',
+                  camera: {
+                    cameraOrthographicSize: 9,
+                    viewportX: 0,
+                    offset: -10,
+                    position: {
+                      y: 0,
+                      z: -50
+                    }
+                  },
+                  model: {
+                    rotation: {
+                      x: 0,
+                      y: 0,
+                      z: 0
+                    }
+                  }
+                },
+                {
+                  name: '碑文3',
+                  camera: {
+                    cameraOrthographicSize: 9,
+                    viewportX: 0,
+                    offset: -10,
+                    position: {
+                      y: 0,
+                      z: -50
+                    }
+                  },
+                  model: {
+                    rotation: {
+                      x: 0,
+                      y: 0,
+                      z: 0
+                    }
+                  }
+                }
+              ]
+            }),'json'
+          )
+        }
+      })
+    }
+  }, [])
 
   return (
     <>
@@ -249,7 +574,6 @@ export default function App() {
       ) : null}
 
       <MessageCom />
-
     </>
   )
 }

+ 0 - 1
src/pages/A0base/index.tsx

@@ -23,7 +23,6 @@ function A0base() {
     }, 2000)
   }, [showIsDev])
 
-
   return (
     <div className={classNames(isPc ? '' : styles.A0baseMo, styles.A0base)}>
       <div className='A0baseContainner'>

+ 4 - 0
src/pages/A1home/index.module.scss

@@ -92,6 +92,10 @@
       opacity: 0;
       pointer-events: none;
       transition: all 0.3s;
+      .A1videoBox{
+        width: 100%;
+        height: 100%;
+      }
 
       .A1videoBtn {
         position: absolute;

+ 4 - 2
src/utils/history.ts

@@ -30,7 +30,7 @@ export const backPageFu = (path: string) => {
 }
 
 // 调用iframe方法
-export const callIframeFu = (fuName: string, params: any) => {
+export const callIframeFu = (fuName: string, params: any,type?:string) => {
   const dom = document.getElementById('modalIframe') as HTMLIFrameElement | null;
   const iframeWindow = dom?.contentWindow as Window & { [key: string]: (...args: any[]) => void } | undefined;
   if (iframeWindow && typeof iframeWindow[fuName] === 'function') {
@@ -45,7 +45,9 @@ export const callIframeFu = (fuName: string, params: any) => {
       iframeWindow[fuName](params);
     }
     // 修复日志显示:直接打印 params,避免 0 被 || '' 转换为空字符串
-    console.log(`执行了方法: ${fuName}(${params})`);
+    if(type) console.log(`执行了方法: ${fuName}`,type);
+    else console.log(`执行了方法: ${fuName}(${params})`);
+    
   } else {
     console.warn(`iframe 方法调用失败: 方法不存在或 iframe 未加载`);
   }

+ 2 - 0
src/utils/http.ts

@@ -15,3 +15,5 @@ export const otherUrl = otherUrlTemp
 
 // 发送请求基地址
 export const apiUrl: string = apiUrlTemp
+
+export const envFlag = process.env.NODE_ENV === 'development'