bianjiang 1 year ago
parent
commit
295e8f46d3

+ 2 - 2
src/comm/controllers/deviceCtrl.ts

@@ -94,8 +94,8 @@ export class DeviceController extends Controller {
       appGuid: "",
     };
     this.appDataDir = await this.GetAppDataDir();
-    this.httpServer = await this.StartHttpServer(`${this.appDataDir}/screen`);
-
+    const httpServer = await this.StartHttpServer(`${this.appDataDir}/screen/`);
+    this.httpServer = httpServer.substring(0, httpServer.length - 1);
     console.log("current app profile=>", this.profile);
   }
 

+ 0 - 1
src/modules/list/actions/canvas.ts

@@ -9,7 +9,6 @@ export default ListModule.action({
     const totalLines = this.store.animate.totalLines;
     const scrollType = this.store.animate.scrollType;
     const items = await this.actions.loadData();
-    console.log("items", items);
     if (!items) {
       return;
     }

+ 69 - 4
src/pages/frame3d/routes/frame3d/index.tsx

@@ -1,6 +1,6 @@
 import { css } from "@linaria/core";
 
-import { defineComponent, onMounted, reactive, ref } from "vue";
+import { defineComponent, onMounted, reactive, ref, watch } from "vue";
 
 import { object } from "vue-types";
 
@@ -10,6 +10,8 @@ import { Spin } from "ant-design-vue";
 import { useQueditor } from "@queenjs-modules/queditor";
 
 import { useList } from "@/modules/list";
+import { cloneDeep } from "lodash";
+import { useCtx } from "@/comm/ctx";
 
 function getQuery() {
   const search = location.href.split("?")[1];
@@ -35,9 +37,72 @@ const Canvas3d = defineComponent({
     const state = reactive({ loaded: false });
     const { actions, components, controls, store } = useQueditor();
     store.showLoading = false;
+    const getLocalSource = (asset: any) => {
+      let pack = cloneDeep(asset);
+      let source = pack.source;
+
+      const { deviceCtrl } = useCtx();
+      const httpServer = deviceCtrl.httpServer;
+      let scope = this;
+
+      //模型处理
+      let geom = source.geoms[0];
+      let osgbinUrl = geom.osgjs.url;
+
+      geom.osgjs.url = httpServer + geom.osgjs.url;
+      source.geoms = [geom];
+      if (geom.shadow.url) {
+        geom.shadow.url = httpServer + geom.shadow.url;
+        // files.push(f.promise);
+      }
+
+      //材质处理
+      source.mats.forEach((m: any) => {
+        //base map
+
+        m.albedo.texture.url = httpServer + m.albedo.texture.url;
+
+        //法线
+        if (m.normal?.texture) {
+          m.normal.texture.url = httpServer + m.normal.texture.url;
+        }
+        //粗糙度
+        if (m.roughness.texture) {
+          m.roughness.texture.url = httpServer + m.roughness.texture.url;
+        }
+
+        //金属度
+        if (m.metalness.texture) {
+          m.metalness.texture.url = httpServer + m.metalness.texture.url;
+        }
+
+        //透明度
+        if (m.opacity.texture) {
+          m.opacity.texture.url = httpServer + m.opacity.texture.url;
+        }
+      });
 
-    const initQueen = async () => {
-      actions.initPack(props.pack.source);
+      //环境球
+      source.env3ds.forEach((item: any) => {
+        if (item.background?.image?.url) {
+          item.background.image.url = httpServer + item.background.image.url;
+        }
+      });
+
+      source.scenes.forEach((c: any) => {
+        //@ts-ignore
+        const url = c.background?.image?.url;
+        if (url) {
+          //@ts-ignore
+          c.background.image.url = httpServer + c.background.image.url;
+        }
+      });
+      console.log(httpServer,source);
+      return source;
+    };
+    const initQueen = () => {
+      const source = getLocalSource(props.pack);
+      actions.initPack(source);
       actions.on("initQueen3dScene:success", () => {
         const queen3d = controls.queen3dCtrl.queen3d;
         const app = controls.queen3dCtrl.queen3d.getAppInstance();
@@ -89,7 +154,7 @@ export default defineComponent({
     onMounted(async () => {
       const res = await actions.loadPack3d({ meshId: meshId } as any);
       packRef.value = res?.data;
-
+      state.loaded = true;
       document.addEventListener("mousedown", () => {
         window.parent.postMessage(JSON.stringify({ type: "start", dialogId }));
       });

+ 0 - 1
src/pages/website/routes/list/item.tsx

@@ -13,7 +13,6 @@ export default defineComponent({
   },
   emits: ["close", "move", "touch"],
   setup(props, { emit }) {
-    console.log(props.data);
     // const ctx = useCtx();
     // const state = reactive({
     //   descShow: false,