Permalink
Browse files

Fix : mirror output

Image files in the ZIP was not mirrored.
  • Loading branch information...
1 parent 047b4d2 commit c8139b08f07c2690873626dd85effa23c757d77f @lautr3k committed Jul 26, 2016
Showing with 6 additions and 13 deletions.
  1. +6 −3 js/main.js
  2. +0 −10 viewer2d.html
View
@@ -117,9 +117,8 @@ function hexToDec(hex) {
return parseInt(hex.toString().replace('#', ''), 16);
}
-function sliceImage(dataURL, mirror) {
+function sliceImage(dataURL) {
settings.set('slice.dataURL', dataURL || 'none');
- settings.set('slice.mirror' , mirror ? 'mirror' : '');
}
function getSlice(layerNumber) {
@@ -164,6 +163,10 @@ function getSlice(layerNumber) {
shape = shapes[i];
slice = shape.clone();
+ if (settings.get('slicer.mirror')) {
+ slice.applyMatrix(new THREE.Matrix4().makeScale(-1, 1, 1));
+ }
+
slice.material = slice.material.clone();
slice.material.color.setHex(0xffffff);
viewer2d.addObject(slice);
@@ -180,7 +183,7 @@ function getSlice(layerNumber) {
// render 2D view
viewer2d.screenshot(function(dataURL) {
- sliceImage(dataURL, settings.get('slicer.mirror'));
+ sliceImage(dataURL);
if (zipFolder) {
var fileName = layerNumber + '.png';
View
@@ -21,14 +21,6 @@
background-position: center;
background-repeat: no-repeat;
}
- .mirror {
- -moz-transform: scaleX(-1);
- -o-transform: scaleX(-1);
- -webkit-transform: scaleX(-1);
- transform: scaleX(-1);
- filter: FlipH;
- -ms-filter: "FlipH";
- }
</style>
</head>
<body>
@@ -38,13 +30,11 @@
<script>
function storageListener() {
var settings = new SLAcer.Settings();
- var mirror = settings.get('slice.mirror', false);
var dataURL = settings.get('slice.dataURL', 'none');
var image = dataURL !== 'none' ? 'url(' + dataURL + ')' : 'none';
var slice = document.getElementById('slice');
slice.style.backgroundImage = image;
- slice.className = mirror ? 'mirror' : '';
}
window.addEventListener('storage', storageListener, false);

0 comments on commit c8139b0

Please sign in to comment.