From d7455adbd1beacac092af1edc05cf3a915d4757b Mon Sep 17 00:00:00 2001 From: Mario Voigt Date: Fri, 21 Aug 2020 18:02:13 +0200 Subject: [PATCH] Removed unnecessary things --- src/Madeleine.js | 151 ++--------------------------------------------- 1 file changed, 6 insertions(+), 145 deletions(-) diff --git a/src/Madeleine.js b/src/Madeleine.js index 5526637..86b74a0 100644 --- a/src/Madeleine.js +++ b/src/Madeleine.js @@ -170,48 +170,6 @@ scope.__rotating = true; e.preventDefault(); }; - this.touchStartHandler = function(e) { - if (e.changedTouches.length == 1) { - scope.trackMouse = true; - scope.__rotating = false; - scope.mouseY = e.changedTouches[0].clientY; - scope.mouseX = e.changedTouches[0].clientX; - } - }; - this.touchMoveHandler = function(e) { - if (scope.trackMouse) { - // Top-left corner is (0, 0) - // e.clientX grows as touch goes down - // e.clientY grows as touch goes right - scope.rotateObjectZ(scope.mouseX - e.clientX); - scope.rotateObjectX(scope.mouseY - e.clientY); - scope.mouseY = e.clientY; - scope.mouseX = e.clientX; - } - e.preventDefault(); - }; - this.touchEndHandler = function(e) { - scope.trackMouse = false; - scope.__rotating = true; - e.preventDefault(); - }; - this.rightClickHandler = function(e) { - e.preventDefault(); - }; - this.viewModeHandler = function(e) { - if (scope.__firstPerson) { - e.target.className = e.target.className.replace(" focused", ""); - scope.__firstPerson = false; - scope.disableFirstPersonViewerMode(); - } else { - e.target.className += " focused"; - scope.__firstPerson = true; - scope.enableFirstPersonViewerMode(); - } - }; - this.captureHandler = function(e) { - // TODO capture the model - }; // Check if option values are correct this.adjustUserConfiguration(); @@ -504,10 +462,6 @@ // renderer configuration this.__renderer.setSize(this.__width, this.__height); this.__renderer.setClearColor(0x000000, 0); - // this.__renderer.shadowMapCullFace = THREE.CullFaceBack; - // this.__renderer.shadowMapEnabled = true; - // this.__renderer.gammaOutput = true; - // this.__renderer.gammaInput = true; }; // Generate Madeleine Viewer @@ -519,13 +473,7 @@ this.__viewer.id = this.options.viewer.prefix + this.__uniqueID; // Force viewer size - //this.container.style["max-height"] = this.__height+"px"; - //this.container.style["min-height"] = this.__height+"px"; - //this.__viewer.style["max-height"] = this.__height+"px"; - //this.__viewer.style["min-height"] = this.__height+"px"; - //this.__viewer.style["max-width"] = this.__width+"px"; this.__viewer.style["max-width"] = "100%"; - //this.__viewer.style["min-width"] = this.__width+"px"; this.__viewer.style["min-width"] = "50%"; this.__viewer.style.height = this.__height; this.__viewer.style.width = this.__width; @@ -554,16 +502,12 @@ // Viewer iconGrid var iconGrid = document.createElement("div"); iconGrid.style.cssText += "background:transparent;position:absolute;padding:15px 10px;"; - //iconGrid.style.cssText += "height:50px;width:"+this.__width+"px;top:0;overflow:hidden;"; iconGrid.style.cssText += "height:50px;width:100%;top:0;overflow:hidden;"; iconGrid.className += "box"; var logo = document.createElement("div"); var info = document.createElement("div"); var view = document.createElement("div"); - var capture = document.createElement("div"); - //var download = document.createElement("div"); - var fullscreen = document.createElement("div"); info.id = "model-info-" + this.__uniqueID; info.className += "model-info noselect"; @@ -571,45 +515,17 @@ logo.className += "clickable pull-left madeleine-logo"; view.className += "clickable pull-right icon-mad-view"; - capture.className += "clickable pull-right icon-mad-capture"; - //download.className += "clickable pull-right icon-mad-download"; - fullscreen.className += "clickable pull-right icon-mad-screen-full"; - - Lily.bind(view, "click", this.viewModeHandler); - Lily.bind(capture, "click", this.captureHandler); var rotator = document.createElement("div"); - var faster = document.createElement("div"); - var slower = document.createElement("div"); - var player = document.createElement("div"); rotator.style.cssText += "background:transparent;position:absolute;padding:15px 10px;right:0;"; - //rotator.style.cssText += "height:50px;width:"+this.__width+"px;top:0;overflow:hidden;"; rotator.style.cssText += "height:50px;width:100%;top:0;overflow:hidden;"; rotator.style.cssText += "margin-top:"+(this.__height-30)+"px;"; - player.className += "icon-clickable pull-right icon-mad-stop"; - slower.className += "icon-clickable pull-right icon-mad-slower"; - faster.className += "icon-clickable pull-right icon-mad-faster"; - - rotator.appendChild(faster); - rotator.appendChild(player); - rotator.appendChild(slower); - - var controller = document.createElement("div"); - var trackball = document.createElement("div"); - var right = document.createElement("div"); - var left = document.createElement("div"); - var down = document.createElement("div"); - var up = document.createElement("div"); - - iconGrid.appendChild(fullscreen); - //iconGrid.appendChild(download); - iconGrid.appendChild(capture); iconGrid.appendChild(view); - iconGrid.appendChild(logo); - iconGrid.appendChild(info); - iconGrid.appendChild(rotator); + iconGrid.appendChild(logo); //the madeleine.js logo + iconGrid.appendChild(info); //the file name + iconGrid.appendChild(rotator); //the invisible thing to allow rotating the model by mouse // Append to container if (this.options.viewer.notappend) {//IMPROVED not append a new canvas put in same @@ -621,58 +537,12 @@ this.__viewer.appendChild(iconGrid); this.__viewer.appendChild(progress); } - this.adaptViewerTheme(); + this.__viewer.style.background = this.makeHexString(options.backgroundColor || OBJECT_BACKGROUND); + this.options.objectColor = options.objectColor || OBJECT_COLOR; + this.__object && this.setObjectColor(); } }; - // Set viewer theme - Madeleine.prototype.adaptViewerTheme = function() { - var theme = arguments.length == 0 ? this.options.viewer.theme : arguments[0]; - - // Adapt theme - switch (theme) { - case "dark": - this.__viewer.style.background = "#000000"; - this.options.objectColor = "FFD300"; - break; - case "lime": - this.__viewer.style.cssText += this.generateGradation({dark: "2B2B2B"}); - this.options.objectColor = "D4FF00"; // [212, 255, 0]; - break; - case "rose": - this.__viewer.style.cssText += this.generateGradation({bright: "369075"}); - this.options.objectColor = "C94C66"; // [201, 76, 102]; - break; - case "lego": - this.__viewer.style.cssText += this.generateGradation({bright: "FFA400"}); - this.options.objectColor = "00A08C"; // [0, 160, 140]; - break; - case "toxic": - this.__viewer.style.cssText += this.generateGradation({bright: "FFEE4D"}); - this.options.objectColor = "5254CB"; // [82, 84, 203]; - break; - case "cobalt": - this.__viewer.style.cssText += this.generateGradation({bright: "FFC200"}); - this.options.objectColor = "0C6BC0"; // [12, 107, 192]; - break; - case "light": - this.__viewer.style.cssText += this.generateGradation({bright: "FFFFFF"}); - this.options.objectColor = "F00842"; - break; - case "soft": - this.__viewer.style.cssText += this.generateGradation({dark: "0F0F0F", bright: "4D4D4D", pos1: "0", pos2: "60"}); - this.options.objectColor = OBJECT_COLOR; - break; - default: - this.__viewer.style.background = this.makeHexString(options.backgroundColor || OBJECT_BACKGROUND); - this.options.objectColor = options.objectColor || OBJECT_COLOR; - break; - } - - // If object exists, paint color on it. - this.__object && this.setObjectColor(); - }; - // Set canvas background color Madeleine.prototype.setBackgroundColor = function(code) { var code = arguments.length == 3 ? [arguments[0], arguments[1], arguments[2]] : code; @@ -950,16 +820,11 @@ // Enable Madeline Viewer to be controlled by mouse movement Madeleine.prototype.enableUserInteraction = function() { // block right click action - Lily.bind(this.container, "contextmenu", this.rightClickHandler); if (!this.__movable) return; // attach event handler Lily.bind(this.container, "mousedown", this.mouseDownHandler); Lily.bind(this.container, "mousemove", this.mouseMoveHandler); Lily.bind(this.container, "mouseup", this.mouseUpHandler); - // mobile support - Lily.bind(this.container, "touchstart", this.touchStartHandler); - Lily.bind(this.container, "touchmove", this.touchMoveHandler); - Lily.bind(this.container, "touchend", this.touchEndHandler); }; // Disable Madeline Viewer to be controlled by mouse movement @@ -969,10 +834,6 @@ Lily.remove(this.container, "mousedown", this.mouseDownHandler); Lily.remove(this.container, "mousemove", this.mouseMoveHandler); Lily.remove(this.container, "mouseup", this.mouseUpHandler); - // mobile support - Lily.remove(this.container, "touchstart", this.touchStartHandler); - Lily.remove(this.container, "touchmove", this.touchMoveHandler); - Lily.remove(this.container, "touchend", this.touchEndHandler); }; // Enable first-person viewer mode