|
@@ -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 }));
|
|
|
});
|