diff --git a/src/components/InteractiveObjects/MazeQuizGame/MazeQuizGame.js b/src/components/InteractiveObjects/MazeQuizGame/MazeQuizGame.js index 7d0e056..b501762 100644 --- a/src/components/InteractiveObjects/MazeQuizGame/MazeQuizGame.js +++ b/src/components/InteractiveObjects/MazeQuizGame/MazeQuizGame.js @@ -36,6 +36,7 @@ const tl = 4; class MazeQuizGame { constructor(engine, data) { + data.noPhysics = true; return new Promise(async (resolve, reject)=>{ let questions = data.shuffle ? Utils.shuffleArray(data.questions) : data.questions; let def = this.generate(questions); diff --git a/src/components/InteractiveObjects/MazeQuizGame/MazeQuizGame.vue b/src/components/InteractiveObjects/MazeQuizGame/MazeQuizGame.vue index f08b629..7fd1305 100644 --- a/src/components/InteractiveObjects/MazeQuizGame/MazeQuizGame.vue +++ b/src/components/InteractiveObjects/MazeQuizGame/MazeQuizGame.vue @@ -41,7 +41,6 @@ export default { props:['modelValue'], mounted(){ this.modelValue.questions ??= []; - this.modelValue.noPhysics = true; }, methods:{ addQuestion(){ diff --git a/src/components/InteractiveObjects/Particles.js b/src/components/InteractiveObjects/Particles.js index 88ade67..6d9c794 100644 --- a/src/components/InteractiveObjects/Particles.js +++ b/src/components/InteractiveObjects/Particles.js @@ -10,6 +10,7 @@ import * as BufferGeometryUtils from 'three/addons/utils/BufferGeometryUtils.js' class Particles { constructor(engine, data) { + data.noPhysics = true; const { x, y, count, w, h } = data; let positions = Particles.positions(count, w, h); return new Promise(async (resolve, reject) => { diff --git a/src/components/InteractiveObjects/Particles.vue b/src/components/InteractiveObjects/Particles.vue index 7692bea..3112fd5 100644 --- a/src/components/InteractiveObjects/Particles.vue +++ b/src/components/InteractiveObjects/Particles.vue @@ -43,7 +43,6 @@ export default { this.modelValue.count = 1000; this.modelValue.w = 50; this.modelValue.h = 50; - this.modelValue.noPhysics = true; } } } diff --git a/src/lib/Utils.js b/src/lib/Utils.js index f063aa4..99659ba 100644 --- a/src/lib/Utils.js +++ b/src/lib/Utils.js @@ -60,6 +60,20 @@ export default { .sort((a, b) => a.sort - b.sort).map(({ value }) => value) }, + deepMerge(target, source, transformFn) { + Object.entries(source).forEach(([key, value]) => { + if (transformFn){ + value = transformFn(key, value) + } + if (value && typeof value === 'object' && !Array.isArray(value)) { + this.deepMerge(target[key] = target[key] || {}, value, transformFn); + return; + } + target[key] = value; + }); + return target; + }, + drawOnCanvas(svg, width, height){ return new Promise((resolve, reject)=>{ let url = URL.createObjectURL(new Blob([svg],{ type:"image/svg+xml;charset=utf-8" })); diff --git a/src/pages/games/[[id]].vue b/src/pages/games/[[id]].vue index 0a44439..6cf50f6 100644 --- a/src/pages/games/[[id]].vue +++ b/src/pages/games/[[id]].vue @@ -62,6 +62,7 @@ export default { async save(params) { this.loading = true; try { + console.log('saving', this.object) let result = await this.$api.game.save(this.object); //Object.assign(this.object, result.data.object); this.object.id = result.data.object.id; diff --git a/src/plugins/api.js b/src/plugins/api.js index ce3fd6b..bd82b4f 100644 --- a/src/plugins/api.js +++ b/src/plugins/api.js @@ -1,13 +1,15 @@ import axios from 'axios'; +import Utils from '@/lib/Utils'; const $ax = axios.create({ baseURL: '/api/', transformRequest: [ (data, headers)=>{ if (data && !(data instanceof FormData)){ - data = JSON.stringify(data, (k, v)=>{ + data = Utils.deepMerge({}, data, (k, v)=>{ return k.startsWith('__') ? undefined : v; - }); + }) + data = JSON.stringify(data); headers['Content-Type'] = 'application/json;charset=utf-8'; } return data;