diff --git a/public/js/annotation.js b/public/js/annotation.js index cd2c944..ac67149 100644 --- a/public/js/annotation.js +++ b/public/js/annotation.js @@ -2,6 +2,7 @@ import * as THREE from "./lib/three.module.js"; import { globalObjectCategory } from "./obj_cfg.js"; import { saveWorldList } from "./save.js"; import { intersect } from "./util.js"; +import request from "./request.js"; function Annotation(sceneMeta, world, frameInfo) { this.world = world; @@ -514,7 +515,7 @@ function Annotation(sceneMeta, world, frameInfo) { xhr.open( "GET", - "/load_annotation" + + request + "/load_annotation" + "?scene=" + this.frameInfo.scene + "&frame=" + diff --git a/public/js/auto_annotate.js b/public/js/auto_annotate.js index a8cc208..e3ff5ea 100644 --- a/public/js/auto_annotate.js +++ b/public/js/auto_annotate.js @@ -1,4 +1,5 @@ import { globalObjectCategory } from "./obj_cfg.js"; +import request from "./request.js"; function autoAnnotate(world, done, alg) { var xhr = new XMLHttpRequest(); @@ -25,7 +26,7 @@ function autoAnnotate(world, done, alg) { xhr.open( "GET", - "/auto_annotate?" + + request + "/auto_annotate?" + "scene=" + world.frameInfo.scene + "&frame=" + diff --git a/public/js/crop_scene.js b/public/js/crop_scene.js index 6b3d737..b86ac19 100644 --- a/public/js/crop_scene.js +++ b/public/js/crop_scene.js @@ -1,4 +1,5 @@ import { PopupDialog } from "./popup_dialog.js"; +import request from "./request.js"; class CropScene extends PopupDialog { constructor(ui, editor) { @@ -27,7 +28,7 @@ class CropScene extends PopupDialog { } }; - xhr.open("POST", "/cropscene", true); + xhr.open("POST", request + "/cropscene", true); let para = { rawSceneId: this.editor.data.world.frameInfo.scene, diff --git a/public/js/data.js b/public/js/data.js index aefedea..f7cc7ff 100644 --- a/public/js/data.js +++ b/public/js/data.js @@ -1,6 +1,7 @@ import { World } from "./world.js"; import { Debug } from "./debug.js"; import { logger } from "./log.js"; +import request from "./request.js"; // 请求数据集合 class Data { @@ -428,7 +429,7 @@ class Data { } }; - xhr.open("GET", `/scenemeta?scene=${sceneName}`, true); + xhr.open("GET", `${request}/scenemeta?scene=${sceneName}`, true); xhr.send(); }); } diff --git a/public/js/ego_pose.js b/public/js/ego_pose.js index a12f953..d95281e 100644 --- a/public/js/ego_pose.js +++ b/public/js/ego_pose.js @@ -1,3 +1,4 @@ +import request from "./request.js"; class EgoPose { constructor(sceneMeta, world, frameInfo) { this.world = world; @@ -37,7 +38,7 @@ class EgoPose { xhr.open( "GET", - "/load_ego_pose" + + request + "/load_ego_pose" + "?scene=" + this.world.frameInfo.scene + "&frame=" + diff --git a/public/js/lib/ml/lalolib.js b/public/js/lib/ml/lalolib.js index a392383..8a4fcc0 100644 --- a/public/js/lib/ml/lalolib.js +++ b/public/js/lib/ml/lalolib.js @@ -1,3 +1,4 @@ +import request from "../../request.js"; ///////////////////////////////////// /// Stand alone lalolib base functions //////////////////////////////////// @@ -1404,7 +1405,7 @@ Lalolab.prototype.import = function ( script, callback ) { function importLaloScript ( script ) { // load a script in lalolib language in the current Lab worker var xhr = new XMLHttpRequest(); - xhr.open('GET', script, false); + xhr.open('GET', request + script, false); xhr.send(); var cmd = xhr.responseText; return lalo(cmd); diff --git a/public/js/lib/ml/ml.js b/public/js/lib/ml/ml.js index 215d0a7..98a6567 100644 --- a/public/js/lib/ml/ml.js +++ b/public/js/lib/ml/ml.js @@ -1,3 +1,4 @@ +import request from "../../request.js"; ///////////////////////////////////// /// Stand alone lalolib base functions //////////////////////////////////// @@ -1404,7 +1405,7 @@ Lalolab.prototype.import = function ( script, callback ) { function importLaloScript ( script ) { // load a script in lalolib language in the current Lab worker var xhr = new XMLHttpRequest(); - xhr.open('GET', script, false); + xhr.open('GET', request + script, false); xhr.send(); var cmd = xhr.responseText; return lalo(cmd); @@ -26392,7 +26393,7 @@ function loadmodel ( url, format ) { // load a remote file (from same web server only...) var xhr = new XMLHttpRequest(); - xhr.open('GET', url, false); // false = synchronous + xhr.open('GET', request + url, false); // false = synchronous xhr.responseType = 'blob'; xhr.send(null); @@ -26418,7 +26419,7 @@ function loaddata ( url, format ) { // load a remote file (from same web server only...) var xhr = new XMLHttpRequest(); - xhr.open('GET', url, false); // false = synchronous + xhr.open('GET', request + url, false); // false = synchronous xhr.responseType = 'blob'; xhr.send(null); diff --git a/public/js/obj_id_list.js b/public/js/obj_id_list.js index 079dcea..5e17c1f 100644 --- a/public/js/obj_id_list.js +++ b/public/js/obj_id_list.js @@ -1,4 +1,5 @@ import { categoryZh } from "./obj_cfg.js"; +import request from "./request.js"; class ObjectIdManager { maxId = 1; @@ -107,7 +108,7 @@ class ObjectIdManager { } }; - xhr.open("GET", "/objs_of_scene?scene=" + scene, true); + xhr.open("GET", request + "/objs_of_scene?scene=" + scene, true); xhr.send(); } diff --git a/public/js/request.js b/public/js/request.js new file mode 100644 index 0000000..d605ce3 --- /dev/null +++ b/public/js/request.js @@ -0,0 +1,2 @@ +const request = location.host.indexOf('localhost')!=-1 ? '' : '/3Dpoints' +export default request \ No newline at end of file diff --git a/public/js/save.js b/public/js/save.js index d063965..ca03855 100644 --- a/public/js/save.js +++ b/public/js/save.js @@ -1,6 +1,7 @@ import { Editor } from "./editor.js"; import { checkScene } from "./error_check.js"; import { logger } from "./log.js"; +import request from "./request.js"; function reloadWorldList(worldList, done) { var xhr = new XMLHttpRequest(); @@ -27,7 +28,7 @@ function reloadWorldList(worldList, done) { } }; - xhr.open("POST", "/loadworldlist", true); + xhr.open("POST", request + "/loadworldlist", true); let para = worldList.map((w) => { return { @@ -95,7 +96,7 @@ function doSaveWorldList(worldList, done) { }); var xhr = new XMLHttpRequest(); - xhr.open("POST", "/saveworldlist", true); + xhr.open("POST", request + "/saveworldlist", true); xhr.setRequestHeader("Content-Type", "application/json"); xhr.onreadystatechange = function () {