Skip to content

Commit

Permalink
Update latk.js
Browse files Browse the repository at this point in the history
  • Loading branch information
n1ckfg committed Nov 15, 2023
1 parent 7c4e390 commit 231cd70
Showing 1 changed file with 10 additions and 6 deletions.
16 changes: 10 additions & 6 deletions latk.js
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,8 @@ Dual licenced under the MIT license or GPLv3. See https://raw.github.com/Stuk/js
!function(a){"object"==typeof exports?module.exports=a():"function"==typeof define&&define.amd?define(a):"undefined"!=typeof window?window.JSZipUtils=a():"undefined"!=typeof global?global.JSZipUtils=a():"undefined"!=typeof self&&(self.JSZipUtils=a())}(function(){return function a(b,c,d){function e(g,h){if(!c[g]){if(!b[g]){var i="function"==typeof require&&require;if(!h&&i)return i(g,!0);if(f)return f(g,!0);throw new Error("Cannot find module '"+g+"'")}var j=c[g]={exports:{}};b[g][0].call(j.exports,function(a){var c=b[g][1][a];return e(c?c:a)},j,j.exports,a,b,c,d)}return c[g].exports}for(var f="function"==typeof require&&require,g=0;g<d.length;g++)e(d[g]);return e}({1:[function(a,b){"use strict";function c(){try{return new window.XMLHttpRequest}catch(a){}}function d(){try{return new window.ActiveXObject("Microsoft.XMLHTTP")}catch(a){}}var e={};e._getBinaryFromXHR=function(a){return a.response||a.responseText};var f=window.ActiveXObject?function(){return c()||d()}:c;e.getBinaryContent=function(a,b){try{var c=f();c.open("GET",a,!0),"responseType"in c&&(c.responseType="arraybuffer"),c.overrideMimeType&&c.overrideMimeType("text/plain; charset=x-user-defined"),c.onreadystatechange=function(){var d,f;if(4===c.readyState)if(200===c.status||0===c.status){d=null,f=null;try{d=e._getBinaryFromXHR(c)}catch(g){f=new Error(g)}b(f,d)}else b(new Error("Ajax error for "+a+" : "+this.status+" "+this.statusText),null)},c.send()}catch(d){b(new Error(d),null)}},b.exports=e},{}]},{},[1])(1)});
// ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~

// Adapted from three.js TiltLoader.

class TiltLoader {

constructor() {
Expand Down Expand Up @@ -169,6 +171,8 @@ class TiltStroke {

// ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~

// Adapted from SharpQuill by @JoanCharmant

class QuillLoader {

constructor() {
Expand Down Expand Up @@ -420,7 +424,7 @@ class LatkLayer {
}


// ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ;
// ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~

class Latk {

Expand All @@ -447,15 +451,15 @@ class Latk {
}
}

static read(animationPath) {
static read(url) {
let latk = new Latk();

let extension = animationPath.split(".")[animationPath.split(".").length-1].toLowerCase();
let extension = url.split(".")[url.split(".").length-1].toLowerCase();

if (extension === "json") {
let xobj = new XMLHttpRequest();
xobj.overrideMimeType("application/json");
xobj.open('GET', animationPath, true);
xobj.open('GET', url, true);
xobj.onreadystatechange = function() {
if (xobj.readyState == 4 && xobj.status == "200") {
// Required use of an anonymous callback as .open will NOT return a value but simply returns undefined in asynchronous mode
Expand All @@ -464,9 +468,9 @@ class Latk {
latk.ready = true;
}
};
xobj.send(null);
xobj.send(null);
} else {
JSZipUtils.getBinaryContent(animationPath, function(err, data) {
JSZipUtils.getBinaryContent(url, function(err, data) {
if (err) {
throw err; // or handle err
}
Expand Down

0 comments on commit 231cd70

Please sign in to comment.