diff --git a/.gitignore b/.gitignore index 640116f..ad6ac8c 100644 --- a/.gitignore +++ b/.gitignore @@ -18,4 +18,5 @@ /node_modules/ /app/Resources/libs/semantic/dist /web/resources/ +/web/media/ .php_cs.cache \ No newline at end of file diff --git a/README.md b/README.md index fb24ea2..67d510c 100644 --- a/README.md +++ b/README.md @@ -29,7 +29,8 @@ For full requirements see Symfony 3.2 [docs](http://symfony.com/doc/3.2/referenc #### Database 1. Set application parameters in *app/config/parameters.yml* -2. Generate empty database by running command `$ php bin/console doctrine:database:create` -3. Load LDraw models into database by running commad `$ php bin/console app:load:ldraw [ldraw_dir_path]` +2. Generate empty database by running command `$ php bin/console doctrine:database:create` +3. Create database tables by running command `$ bin/console doctrine:schema:create` +3. Load LDraw models into database by running commad `$ php bin/console app:load:models [--all] [--file=FILE] [--update]` 4. Load Rebrickable data into database by running command `$ php bin/console app:load:rebrickable` 5. Load relations between LDraw models and Rebrickable parts by running command `$ php bin/console app:load:relation` \ No newline at end of file diff --git a/app/AppKernel.php b/app/AppKernel.php index 0718d4f..302254e 100644 --- a/app/AppKernel.php +++ b/app/AppKernel.php @@ -20,6 +20,7 @@ class AppKernel extends Kernel new Oneup\FlysystemBundle\OneupFlysystemBundle(), new Knp\Bundle\PaginatorBundle\KnpPaginatorBundle(), new Lexik\Bundle\FormFilterBundle\LexikFormFilterBundle(), + new Liip\ImagineBundle\LiipImagineBundle(), ]; if (in_array($this->getEnvironment(), ['dev', 'test'], true)) { diff --git a/app/Resources/assets/images/brickset_logo.png b/app/Resources/assets/images/brickset_logo.png new file mode 100644 index 0000000..f1eee4d Binary files /dev/null and b/app/Resources/assets/images/brickset_logo.png differ diff --git a/app/Resources/assets/images/rebrickable_logo.png b/app/Resources/assets/images/rebrickable_logo.png new file mode 100644 index 0000000..4651fd8 Binary files /dev/null and b/app/Resources/assets/images/rebrickable_logo.png differ diff --git a/app/Resources/assets/js/ModelViewer.js b/app/Resources/assets/js/ModelViewer.js index 09bc7cc..7423b8f 100644 --- a/app/Resources/assets/js/ModelViewer.js +++ b/app/Resources/assets/js/ModelViewer.js @@ -1,85 +1,277 @@ -ModelViewer = function() { - var container; - var camera, cameraTarget, scene, renderer, controls, object; - var width, height; +var ModelViewer = function($dom_element, model_url) { + var $this = this; + this.container = document.createElement('div'); + this.container.setAttribute('class','model-view'); + this.dom_element = $dom_element; + $dom_element.append(this.container); - this.initScene = function($container) { - width = parseFloat($container.width()); - height = parseFloat($container.height()); + this.camera = null; + this.scene = null; + this.renderer = null; + this.controls = null; + this.width = parseFloat($dom_element.width()); + this.height = parseFloat($dom_element.height()); + this.scale = 1; + this.wireframe = false; + this.rendering = false; + this.container.style.display = "none"; + this.toggleButton = null; + this.background = 0xffffff; + this.model_url = model_url; + this.loaded = false; - camera = new THREE.PerspectiveCamera(45, width/height, 0.1, 1000); - camera.position.set(-2, 2, 0.8); - camera.lookAt(new THREE.Vector3(0, 3, 0)); + this.object = null; - 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 ); - - // Lights - - light = new THREE.DirectionalLight( 0xffffff ); - light.position.set( 1, 1, 1 ); - scene.add( light ); - - light = new THREE.DirectionalLight( 0x002288 ); - light.position.set( -1, -1, -1 ); - scene.add( light ); + this.initHtml(); + this.initScene(); - scene.add( new THREE.AmbientLight( 0xf0f0f0 )); - scene.background = new THREE.Color( 0x000000 ); + // this.stats = new Stats(); + // this.stats.dom.style.position = 'absolute'; + // this.container.append(this.stats.dom); - // renderer - renderer = new THREE.WebGLRenderer(); - renderer.setClearColor( scene.fog.color ); - renderer.setPixelRatio( window.devicePixelRatio ); - renderer.setSize( width, height ); - renderer.gammaInput = true; - renderer.gammaOutput = true; - renderer.shadowMap.enabled = true; - renderer.shadowMap.renderReverseSided = false; - $container.append(renderer.domElement); + function renderLoop() { + requestAnimationFrame(renderLoop); + if($this.rendering) { + if(!$this.loaded) { + $this.loadStl($this.model_url); + $this.loaded = true; + } - 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; - }; + if($this.stats) { + $this.stats.update(); + } + $this.render(); + } + + $this.resize(parseInt($this.dom_element.width()), parseInt($this.dom_element.height())); + } + + + renderLoop(); +}; + +ModelViewer.prototype.initHtml = function () { + $this = this; + + var buttons = document.createElement("div"); + buttons.setAttribute("class", "modelviewer-buttons"); + + this.wireframeButton = $('