From fd86396cada2794a6d7bd9beb132c845e8735b84 Mon Sep 17 00:00:00 2001 From: Florian Fechner Date: Sat, 24 Feb 2018 23:49:09 +0100 Subject: [PATCH] Zoom fix --- voxel-visualization.js | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/voxel-visualization.js b/voxel-visualization.js index bc5342f..d8bc116 100644 --- a/voxel-visualization.js +++ b/voxel-visualization.js @@ -56,7 +56,8 @@ class VoxelVisualization extends Polymer.mixinBehaviors([Polymer.IronResizableBe '_onSchematicJsonPathChanged(schematicJsonPath)', '_onSchematicPathChanged(schematicPath)', '_onAmbientLightIntensityChanged(ambientLightIntensity)', - '_onDirectionalLightIntensityChanged(directionalLightIntensity)' + '_onDirectionalLightIntensityChanged(directionalLightIntensity)', + '_onZoomChanged(zoom)' ] } @@ -131,6 +132,15 @@ class VoxelVisualization extends Polymer.mixinBehaviors([Polymer.IronResizableBe if(this.directionalLight) this.directionalLight.color.set(directionalLightColor); } + _onZoomChanged() + { + if(this.group) + { + let base = -2; + this.group.position.set(0, 0, base / this.zoom); + } + } + _onSchematicPathChanged(schematicPath) { let file = schematicPath; @@ -246,8 +256,9 @@ class VoxelVisualization extends Polymer.mixinBehaviors([Polymer.IronResizableBe let normals = new Float32Array(this.calculateNormals(faces, expandedWidth, expandedHeight, expandedDepth)); let uvs = new Float32Array(this.calculateUVs(faces, blockIdList)); + let base = -2; this.group = new THREE.Group(); - this.group.position.set(0, 0, -3); + this.group.position.set(0, 0, base / this.zoom); for(let i=0; i