diff --git a/app/Resources/assets/javascripts/ModelViewer.js b/app/Resources/assets/javascripts/ModelViewer.js index a201365..fcae063 100644 --- a/app/Resources/assets/javascripts/ModelViewer.js +++ b/app/Resources/assets/javascripts/ModelViewer.js @@ -1,19 +1,11 @@ ModelViewer = function() { var container; - var camera, scene, cameraTarget, renderer, controls, object; + var camera, cameraTarget, scene, renderer, controls, object; var width, height; - this.init = function(containerId) { - container = document.getElementById(containerId); - - if (document.defaultView && document.defaultView.getComputedStyle) { - width = parseFloat(document.defaultView.getComputedStyle(container,null).getPropertyValue('width')); - height = parseFloat(document.defaultView.getComputedStyle(container,null).getPropertyValue('height')); - } else { - width = parseFloat(container.currentStyle.width); - height = parseFloat(container.currentStyle.height); - } - + this.initScene = function($container) { + width = parseFloat($container.width()); + height = parseFloat($container.height()); camera = new THREE.PerspectiveCamera(45, width/height, 0.1, 1000); camera.position.set(-2, 2, 0.8); @@ -22,7 +14,6 @@ ModelViewer = function() { scene = new THREE.Scene(); scene.fog = new THREE.FogExp2(0x000000, 0.001); - var grid = new THREE.GridHelper( 30, 70 ); grid.position.set(30/70,-0.5,30/70); scene.add( grid ); @@ -51,14 +42,13 @@ ModelViewer = function() { renderer.shadowMap.enabled = true; renderer.shadowMap.renderReverseSided = false; - container.appendChild(renderer.domElement); + $container.append(renderer.domElement); controls = new THREE.OrbitControls( camera, renderer.domElement ); controls.addEventListener( 'change', this.render ); // add this only if there is no animation loop (requestAnimationFrame) // controls.enableDamping = true; // controls.dampingFactor = 0.25; controls.enableZoom = true; - }; this.loadStl = function(model) { @@ -80,13 +70,12 @@ ModelViewer = function() { this.animate = function() { requestAnimationFrame( this.animate ); - - controls.update(); // required if controls.enableDamping = true, or if controls.autoRotate = true - this.render(); }; this.render = function() { + renderer.render(scene, camera); + }; }; \ No newline at end of file diff --git a/app/Resources/views/part/detail.html.twig b/app/Resources/views/part/detail.html.twig index c3a5f29..dc7d024 100644 --- a/app/Resources/views/part/detail.html.twig +++ b/app/Resources/views/part/detail.html.twig @@ -4,10 +4,7 @@ {{ dump(part) }} - {{ dump(localPart) }} -
- {% endblock %} @@ -23,9 +20,9 @@