Fixed the 3d preview on Safari
This commit is contained in:
@@ -125,7 +125,7 @@ module.exports = {
|
|||||||
|
|
||||||
|
|
||||||
methods: {
|
methods: {
|
||||||
update: function () {
|
update: async function () {
|
||||||
if (!this.webglAvailable) {
|
if (!this.webglAvailable) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@@ -142,38 +142,28 @@ module.exports = {
|
|||||||
|
|
||||||
if (!this.enabled || !this.toolpath.filename) return;
|
if (!this.enabled || !this.toolpath.filename) return;
|
||||||
|
|
||||||
function get(url) {
|
async function get(url) {
|
||||||
var d = $.Deferred();
|
const response = await fetch(`${url}?${Math.random()}`);
|
||||||
var xhr = new XMLHttpRequest();
|
const arrayBuffer = await response.arrayBuffer();
|
||||||
|
|
||||||
xhr.open('GET', url + '?' + Math.random(), true);
|
return new Float32Array(arrayBuffer);
|
||||||
xhr.responseType = 'arraybuffer';
|
|
||||||
|
|
||||||
xhr.onload = function (e) {
|
|
||||||
if (xhr.response) d.resolve(new Float32Array(xhr.response));
|
|
||||||
else d.reject();
|
|
||||||
};
|
|
||||||
|
|
||||||
xhr.send();
|
|
||||||
|
|
||||||
return d.promise();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
var d1 = get('/api/path/' + this.toolpath.filename + '/positions');
|
const [positions, speeds] = await Promise.all([
|
||||||
var d2 = get('/api/path/' + this.toolpath.filename + '/speeds');
|
get('/api/path/' + this.toolpath.filename + '/positions'),
|
||||||
|
get('/api/path/' + this.toolpath.filename + '/speeds')
|
||||||
|
]);
|
||||||
|
|
||||||
$.when(d1, d2).done(function (positions, speeds) {
|
this.positions = positions
|
||||||
this.positions = positions
|
this.speeds = speeds;
|
||||||
this.speeds = speeds;
|
this.loading = false;
|
||||||
this.loading = false;
|
|
||||||
|
|
||||||
// Update scene
|
// Update scene
|
||||||
this.scene = new THREE.Scene();
|
this.scene = new THREE.Scene();
|
||||||
this.draw(this.scene);
|
this.draw(this.scene);
|
||||||
this.snap(this.snapView);
|
this.snap(this.snapView);
|
||||||
|
|
||||||
this.update_view();
|
this.update_view();
|
||||||
}.bind(this))
|
|
||||||
},
|
},
|
||||||
|
|
||||||
|
|
||||||
@@ -264,8 +254,12 @@ module.exports = {
|
|||||||
}
|
}
|
||||||
|
|
||||||
var bounds = new THREE.Box3(min, max);
|
var bounds = new THREE.Box3(min, max);
|
||||||
if (bounds.isEmpty()) envelope.geometry = this.create_empty_geom();
|
if (bounds.isEmpty()) {
|
||||||
else envelope.geometry = this.create_bbox_geom(bounds);
|
envelope.geometry = this.create_empty_geom();
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
envelope.geometry = this.create_bbox_geom(bounds);
|
||||||
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -312,7 +312,7 @@ class PathHandler(bbctrl.APIHandler):
|
|||||||
self.write_json(meta)
|
self.write_json(meta)
|
||||||
return
|
return
|
||||||
|
|
||||||
filename = filename + '-' + dataType[1:] + '.gz'
|
filename = filename + '-' + dataType[1:]
|
||||||
self.set_header('Content-Disposition', 'filename="%s"' % filename)
|
self.set_header('Content-Disposition', 'filename="%s"' % filename)
|
||||||
self.set_header('Content-Type', 'application/octet-stream')
|
self.set_header('Content-Type', 'application/octet-stream')
|
||||||
self.set_header('Content-Encoding', 'gzip')
|
self.set_header('Content-Encoding', 'gzip')
|
||||||
|
|||||||
Reference in New Issue
Block a user