Removed unnecessary things
This commit is contained in:
parent
159553c025
commit
d7455adbd1
147
src/Madeleine.js
147
src/Madeleine.js
@ -170,48 +170,6 @@
|
|||||||
scope.__rotating = true;
|
scope.__rotating = true;
|
||||||
e.preventDefault();
|
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
|
// Check if option values are correct
|
||||||
this.adjustUserConfiguration();
|
this.adjustUserConfiguration();
|
||||||
@ -504,10 +462,6 @@
|
|||||||
// renderer configuration
|
// renderer configuration
|
||||||
this.__renderer.setSize(this.__width, this.__height);
|
this.__renderer.setSize(this.__width, this.__height);
|
||||||
this.__renderer.setClearColor(0x000000, 0);
|
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
|
// Generate Madeleine Viewer
|
||||||
@ -519,13 +473,7 @@
|
|||||||
this.__viewer.id = this.options.viewer.prefix + this.__uniqueID;
|
this.__viewer.id = this.options.viewer.prefix + this.__uniqueID;
|
||||||
|
|
||||||
// Force viewer size
|
// 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["max-width"] = "100%";
|
||||||
//this.__viewer.style["min-width"] = this.__width+"px";
|
|
||||||
this.__viewer.style["min-width"] = "50%";
|
this.__viewer.style["min-width"] = "50%";
|
||||||
this.__viewer.style.height = this.__height;
|
this.__viewer.style.height = this.__height;
|
||||||
this.__viewer.style.width = this.__width;
|
this.__viewer.style.width = this.__width;
|
||||||
@ -554,16 +502,12 @@
|
|||||||
// Viewer iconGrid
|
// Viewer iconGrid
|
||||||
var iconGrid = document.createElement("div");
|
var iconGrid = document.createElement("div");
|
||||||
iconGrid.style.cssText += "background:transparent;position:absolute;padding:15px 10px;";
|
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.style.cssText += "height:50px;width:100%;top:0;overflow:hidden;";
|
||||||
iconGrid.className += "box";
|
iconGrid.className += "box";
|
||||||
|
|
||||||
var logo = document.createElement("div");
|
var logo = document.createElement("div");
|
||||||
var info = document.createElement("div");
|
var info = document.createElement("div");
|
||||||
var view = 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.id = "model-info-" + this.__uniqueID;
|
||||||
info.className += "model-info noselect";
|
info.className += "model-info noselect";
|
||||||
@ -571,45 +515,17 @@
|
|||||||
|
|
||||||
logo.className += "clickable pull-left madeleine-logo";
|
logo.className += "clickable pull-left madeleine-logo";
|
||||||
view.className += "clickable pull-right icon-mad-view";
|
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 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 += "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 += "height:50px;width:100%;top:0;overflow:hidden;";
|
||||||
rotator.style.cssText += "margin-top:"+(this.__height-30)+"px;";
|
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(view);
|
||||||
iconGrid.appendChild(logo);
|
iconGrid.appendChild(logo); //the madeleine.js logo
|
||||||
iconGrid.appendChild(info);
|
iconGrid.appendChild(info); //the file name
|
||||||
iconGrid.appendChild(rotator);
|
iconGrid.appendChild(rotator); //the invisible thing to allow rotating the model by mouse
|
||||||
|
|
||||||
// Append to container
|
// Append to container
|
||||||
if (this.options.viewer.notappend) {//IMPROVED not append a new canvas put in same
|
if (this.options.viewer.notappend) {//IMPROVED not append a new canvas put in same
|
||||||
@ -621,56 +537,10 @@
|
|||||||
this.__viewer.appendChild(iconGrid);
|
this.__viewer.appendChild(iconGrid);
|
||||||
this.__viewer.appendChild(progress);
|
this.__viewer.appendChild(progress);
|
||||||
}
|
}
|
||||||
this.adaptViewerTheme();
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
// 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.__viewer.style.background = this.makeHexString(options.backgroundColor || OBJECT_BACKGROUND);
|
||||||
this.options.objectColor = options.objectColor || OBJECT_COLOR;
|
this.options.objectColor = options.objectColor || OBJECT_COLOR;
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
// If object exists, paint color on it.
|
|
||||||
this.__object && this.setObjectColor();
|
this.__object && this.setObjectColor();
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
// Set canvas background color
|
// Set canvas background color
|
||||||
@ -950,16 +820,11 @@
|
|||||||
// Enable Madeline Viewer to be controlled by mouse movement
|
// Enable Madeline Viewer to be controlled by mouse movement
|
||||||
Madeleine.prototype.enableUserInteraction = function() {
|
Madeleine.prototype.enableUserInteraction = function() {
|
||||||
// block right click action
|
// block right click action
|
||||||
Lily.bind(this.container, "contextmenu", this.rightClickHandler);
|
|
||||||
if (!this.__movable) return;
|
if (!this.__movable) return;
|
||||||
// attach event handler
|
// attach event handler
|
||||||
Lily.bind(this.container, "mousedown", this.mouseDownHandler);
|
Lily.bind(this.container, "mousedown", this.mouseDownHandler);
|
||||||
Lily.bind(this.container, "mousemove", this.mouseMoveHandler);
|
Lily.bind(this.container, "mousemove", this.mouseMoveHandler);
|
||||||
Lily.bind(this.container, "mouseup", this.mouseUpHandler);
|
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
|
// Disable Madeline Viewer to be controlled by mouse movement
|
||||||
@ -969,10 +834,6 @@
|
|||||||
Lily.remove(this.container, "mousedown", this.mouseDownHandler);
|
Lily.remove(this.container, "mousedown", this.mouseDownHandler);
|
||||||
Lily.remove(this.container, "mousemove", this.mouseMoveHandler);
|
Lily.remove(this.container, "mousemove", this.mouseMoveHandler);
|
||||||
Lily.remove(this.container, "mouseup", this.mouseUpHandler);
|
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
|
// Enable first-person viewer mode
|
||||||
|
Loading…
Reference in New Issue
Block a user