diff --git a/README.md b/README.md index 1410c30..be068a2 100644 --- a/README.md +++ b/README.md @@ -1,82 +1,46 @@ -# [Project2: Toolbox Functions](https://github.com/CIS700-Procedural-Graphics/Project2-Toolbox-Functions) +# Procedural Wing -## Overview +## Project Description -The objective of this assignment is to procedurally model and animate a bird wing. Let's get creative! +### Overall description -Start by forking and then cloning [this repository](https://github.com/CIS700-Procedural-Graphics/Project2-Toolbox-Functions) +The project goes about creating the wing of a bird, albeit perhaps not the most detailed model. +Various GUI controls were added to give the project more life. -## Modeling +GUI controls let you: -##### Reference images +1. Change the colors of the feathers of the wing -Search for three or more images of a bird wing (or any flying creature, really) in order to provide yourself reference material, as you're going to base your modeling and animation from these images. For the more artistic minds, feel free to sketch your own concept. +2. Change the strength and direction of wind, which is seen as a small perturbarance -##### Make wing curve +3. Change the flapping speed of the wing -Begin with a 3D curve for your basic wing shape. Three.js provides classes to create many different types of curves, so you may use whatever type of curve you prefer. +4. Change the control points of the spline that determines the wing shape -##### Distribute feathers +5. Change various aspects of the feathers on the wing: the number of feathers, how they're distributed, +their orientation, and their size -We have provided a simple feather model from which to begin. You are not required to use this model if you have others that you prefer. From this base, you must duplicate the feather to model a complete wing, and your wing should consist of at least thirty feathers. Distribute points along the curve you created previously; you will append the feather primitives to the curve at these points. Make sure that you modify the size, orientation, and color of your feathers depending on their location on the wing. +6. Change the field of view of the camera -Feel free to diversify your wings by using multiple base feather models. +The UVs are updated constantly to make the surface of the sphere seem animated. -## Animation +### Things Done: -Add a wind force to your scene, and parameterize its direction and speed. You will use this wind force to animate the feathers of your wing by vibrating them slightly. Using Dat.GUI, allow the user to modify these wind parameters. Please note that we don't care about your feather motion being physically accurate, as long as it looks nice. +#### main.js description -Additionally, animate the control points of your wing curve to make the wing flap, and allow the user to control the speed of the wing flapping. +1. Created a spline curve using four control points, which defines the high level look of a birds wing. -## Interactivity +2. I then generated a bunch of feathers at various points along the curve. -Using Dat.GUI and the examples provided in the reference code, allow the user to adjust the following controls: +3. The feather_Material shader contains a uniform that allows us to dynamically change the color of the feathers. -1. The curvature of the wing's basic shape -2. Feather distribution -3. Feather size -4. Feather color -5. Feather orientation -6. Flapping speed -7. Flapping motion +4. The GUI parameters are all applied to control aspects of feather generation and wing shape determination. This necessitates +that atleast a few, such as number of feahers, result in the removal of all objects from the scene and overall feather group, to be added again with new properties. -## For the Overachievers +5. All the GUI parameters updated to create a dynamic looking scene in 'function onUpdate(framework)' -Suggestions: -- Make a pretty iridescent or otherwise feather appropriate shader. -- Otherwise, going the extra mile for this assignment is really in the polish! +#### Shaders -## Submission +##### Fragment Shader -- Create a folder called `references` to include your reference images. - -- Update `README.md` to contain a solid description of your project - -- Publish your project to gh-pages. `npm run deploy`. It should now be visible at http://username.github.io/repo-name - -- Create a [pull request](https://help.github.com/articles/creating-a-pull-request/) to this repository, and in the comment, include a link to your published project. - -- Submit the link to your pull request on Canvas. - -## Getting Started - -1. [Install Node.js](https://nodejs.org/en/download/). Node.js is a JavaScript runtime. It basically allows you to run JavaScript when not in a browser. For our purposes, this is not necessary. The important part is that with it comes `npm`, the Node Package Manager. This allows us to easily declare and install external dependencies such as [three.js](https://threejs.org/), [dat.GUI](https://workshop.chromeexperiments.com/examples/gui/#1--Basic-Usage), and [glMatrix](http://glmatrix.net/). Some other packages we'll be using make it significantly easier to develop your code and create modules for better code reuse and clarity. These tools make it _signficantly_ easier to write code in multiple `.js` files without globally defining everything. - -2. Fork and clone your repository. - -3. In the root directory of your project, run `npm install`. This will download all of those dependencies. - -4. Do either of the following (but I highly recommend the first one for reasons I will explain later). - - a. Run `npm start` and then go to `localhost:7000` in your web browser - - b. Run `npm run build` and then go open `index.html` in your web browser - - You should hopefully see the framework code with a 3D cube at the center of the screen! - - -## Developing Your Code -All of the JavaScript code is living inside the `src` directory. The main file that gets executed when you load the page as you may have guessed is `main.js`. Here, you can make any changes you want, import functions from other files, etc. The reason that I highly suggest you build your project with `npm start` is that doing so will start a process that watches for any changes you make to your code. If it detects anything, it'll automagically rebuild your project and then refresh your browser window for you. Wow. That's cool. If you do it the other way, you'll need to run `npm build` and then refresh your page every time you want to test something. - -## Publishing Your Code -We highly suggest that you put your code on GitHub. One of the reasons we chose to make this course using JavaScript is that the Web is highly accessible and making your awesome work public and visible can be a huge benefit when you're looking to score a job or internship. To aid you in this process, running `npm run deploy` will automatically build your project and push it to `gh-pages` where it will be visible at `username.github.io/repo-name`. \ No newline at end of file +1. The fragment shader utilizes the uniform color passed in to color in fragments diff --git a/npm-debug.log b/npm-debug.log new file mode 100644 index 0000000..7da10c5 --- /dev/null +++ b/npm-debug.log @@ -0,0 +1,47 @@ +0 info it worked if it ends with ok +1 verbose cli [ 'C:\\Program Files\\nodejs\\node.exe', +1 verbose cli 'C:\\Program Files\\nodejs\\node_modules\\npm\\bin\\npm-cli.js', +1 verbose cli 'start' ] +2 info using npm@3.10.10 +3 info using node@v6.9.4 +4 verbose run-script [ 'prestart', 'start', 'poststart' ] +5 info lifecycle @~prestart: @ +6 silly lifecycle @~prestart: no script for prestart, continuing +7 info lifecycle @~start: @ +8 verbose lifecycle @~start: unsafe-perm in lifecycle true +9 verbose lifecycle @~start: PATH: C:\Program Files\nodejs\node_modules\npm\bin\node-gyp-bin;C:\Users\Aman\Documents\GitHub\CIS 700 (Procedural Graphics)\Project2-Toolbox-Functions\node_modules\.bin;C:\SPB_Data\bin;C:\Program Files\Git\mingw64\bin;C:\Program Files\Git\usr\local\bin;C:\Program Files\Git\usr\bin;C:\Program Files\Git\usr\bin;C:\Program Files\Git\mingw64\bin;C:\Program Files\Git\usr\bin;C:\SPB_Data\bin;C:\Program Files\ImageMagick-7.0.2-Q16;C:\Program Files (x86)\NVIDIA Corporation\PhysX\Common;C:\Python27\Lib\site-packages\PyQt4;C:\ProgramData\Oracle\Java\javapath;C:\Program Files (x86)\Intel\iCLS Client;C:\Program Files\Intel\iCLS Client;C:\windows\system32;C:\windows;C:\windows\System32\Wbem;C:\windows\System32\WindowsPowerShell\v1.0;C:\Program Files\Intel\Intel(R) Management Engine Components\DAL;C:\Program Files\Intel\Intel(R) Management Engine Components\IPT;C:\Program Files (x86)\Intel\Intel(R) Management Engine Components\DAL;C:\Program Files (x86)\Intel\Intel(R) Management Engine Components\IPT;C:\Program Files\Microsoft SQL Server\110\Tools\Binn;C:\adb;C:\Python27;C:\Python27\DLLs;C:\Python27\Scripts;C:\Python27\gnuplot\binary;C:\Program Files (x86)\pythonxy\SciTE-3.5.1-4;C:\Program Files (x86)\pythonxy\console;C:\Program Files (x86)\Microsoft SQL Server\110\Tools\Binn;C:\Program Files\Microsoft SQL Server\110\DTS\Binn;C:\WINDOWS\system32;C:\WINDOWS;C:\WINDOWS\System32\Wbem;C:\WINDOWS\System32\WindowsPowerShell\v1.0;C:\Program Files (x86)\Skype\Phone;C:\Program Files (x86)\Microsoft SDKs\TypeScript\1.0;C:\Program Files\Microsoft SQL Server\120\Tools\Binn;C:\Program Files\Microsoft SQL Server\130\Tools\Binn;C:\WINDOWS\system32\config\systemprofile\.dnx\bin;C:\Program Files\Microsoft DNX\Dnvm;C:\Program Files (x86)\Windows Kits\8.1\Windows Performance Toolkit;C:\Program Files (x86)\QuickTime\QTSystem;C:\Program Files\nodejs;C:\Users\Aman\AppData\Local\Programs\Python\Python36\Scripts;C:\Users\Aman\AppData\Local\Programs\Python\Python36;C:\Users\Aman\AppData\Local\Microsoft\WindowsApps;C:\Users\Aman\AppData\Roaming\npm;C:\Users\Aman\AppData\Local\atom\bin;C:\Program Files\Git\usr\bin\vendor_perl;C:\Program Files\Git\usr\bin\core_perl +10 verbose lifecycle @~start: CWD: C:\Users\Aman\Documents\GitHub\CIS 700 (Procedural Graphics)\Project2-Toolbox-Functions +11 silly lifecycle @~start: Args: [ '/d /s /c', 'webpack-dev-server --hot --inline' ] +12 silly lifecycle @~start: Returned: code: 3221225786 signal: null +13 info lifecycle @~start: Failed to exec start script +14 verbose stack Error: @ start: `webpack-dev-server --hot --inline` +14 verbose stack Exit status 3221225786 +14 verbose stack at EventEmitter. (C:\Program Files\nodejs\node_modules\npm\lib\utils\lifecycle.js:255:16) +14 verbose stack at emitTwo (events.js:106:13) +14 verbose stack at EventEmitter.emit (events.js:191:7) +14 verbose stack at ChildProcess. (C:\Program Files\nodejs\node_modules\npm\lib\utils\spawn.js:40:14) +14 verbose stack at emitTwo (events.js:106:13) +14 verbose stack at ChildProcess.emit (events.js:191:7) +14 verbose stack at maybeClose (internal/child_process.js:877:16) +14 verbose stack at Process.ChildProcess._handle.onexit (internal/child_process.js:226:5) +15 verbose pkgid @ +16 verbose cwd C:\Users\Aman\Documents\GitHub\CIS 700 (Procedural Graphics)\Project2-Toolbox-Functions +17 error Windows_NT 10.0.14393 +18 error argv "C:\\Program Files\\nodejs\\node.exe" "C:\\Program Files\\nodejs\\node_modules\\npm\\bin\\npm-cli.js" "start" +19 error node v6.9.4 +20 error npm v3.10.10 +21 error code ELIFECYCLE +22 error @ start: `webpack-dev-server --hot --inline` +22 error Exit status 3221225786 +23 error Failed at the @ start script 'webpack-dev-server --hot --inline'. +23 error Make sure you have the latest version of node.js and npm installed. +23 error If you do, this is most likely a problem with the package, +23 error not with npm itself. +23 error Tell the author that this fails on your system: +23 error webpack-dev-server --hot --inline +23 error You can get information on how to open an issue for this project with: +23 error npm bugs +23 error Or if that isn't available, you can get their info via: +23 error npm owner ls +23 error There is likely additional logging output above. +24 verbose exit [ 1, true ] diff --git a/package.json b/package.json index c80e8a3..cde25c8 100644 --- a/package.json +++ b/package.json @@ -2,7 +2,7 @@ "scripts": { "start": "webpack-dev-server --hot --inline", "build": "webpack", - "deploy": "rm -rf npm-debug.log && git checkout master && git commit -am 'update' && gh-pages-deploy" + "deploy": "gh-pages-deploy" }, "gh-pages-deploy": { "prep": [ diff --git a/references/1_5015007473_48b3eea88d_o.jpg b/references/1_5015007473_48b3eea88d_o.jpg new file mode 100644 index 0000000..746f5f5 Binary files /dev/null and b/references/1_5015007473_48b3eea88d_o.jpg differ diff --git a/src/main.js b/src/main.js index fd8fbd4..2739a64 100755 --- a/src/main.js +++ b/src/main.js @@ -1,73 +1,666 @@ - // Skybox texture from: https://github.com/mrdoob/three.js/tree/master/examples/textures/cube/skybox const THREE = require('three'); // older modules are imported like this. You shouldn't have to worry about this much import Framework from './framework' +//var levelOfDetail = 50; +var feathers = new THREE.Object3D(); +var feathersLayer2 = new THREE.Object3D(); +var feathersLayer3 = new THREE.Object3D(); +var splineObject = new THREE.Line(); +var curve = new THREE.SplineCurve( [ + new THREE.Vector2( 1, 0 ), + new THREE.Vector2( -0.5, -0.6 ), + new THREE.Vector2( -2, 0 ), + new THREE.Vector2( -2.5, 0 ) + ] ); +var PathLayer1 = new THREE.Path(curve.getPoints(50)); //50 is the numberOfFeathers initially +var splineGeom = PathLayer1.createPointsGeometry(50); +var featherMesh = new THREE.Mesh(); +var featherGeo = new THREE.Geometry(); +var oldNum = 50; +var featherOriginalX = []; +var featherOriginalY = []; +var featherOriginalZ = []; + +var guiParameters = { + windStrength: 3.0, //0 to 10 + windDirectionX: 0.1, //0 to 1 + windDirectionY: 0.1, //0 to 1 + windDirectionZ: 0.0, //0 to 1 + controlPoint2x: 0.0, //increase curvature of spline + controlPoint2y: 0.0, //increase curvature of spline + controlPoint3x: 0.0, //increase curvature of spline + controlPoint3y: 0.0, //increase curvature of spline + // Layer1ColorR: 0.0902, + // Layer1ColorG: 0.1961, + // Layer1ColorB: 0.5411, + // Layer2ColorR: 0.8471, + // Layer2ColorG: 0.1647, + // Layer2ColorB: 0.1647, + // Layer3ColorR: 0.0667, + // Layer3ColorG: 0.749, + // Layer3ColorB: 0.2039, + Layer1Color: new THREE.Color(0x17328A),// [23,50,138], + Layer2Color: [216,42,42], + Layer3Color: [17,191,52], + numberOfFeathers: 50, + featherDistribution: 1.0, //clumping factor from 0 to 1 + featherSize: 1.0, // + featherOrientation: 0.0, //increase curvature of individual feathers 1 to 10 + flappingSpeed: 1.0, //0 to 10 + flappingMotion: 2.7 //change orientation of entire wing 0 to 1 +} + +var feather_Material = new THREE.ShaderMaterial({ + uniforms: + { + feathercolor: + { + type: "v3", + value: new THREE.Vector3( 0.0902, 0.1961, 0.5411 ) + // value: new THREE.Color(0x17328A) + } + }, + vertexShader: require('./shaders/feather-vert.glsl'), + fragmentShader: require('./shaders/feather-frag.glsl') +}); + +var feather_Material2 = new THREE.ShaderMaterial({ + uniforms: + { + feathercolor: + { + type: "v3", + value: new THREE.Vector3( 0.0902, 0.1961, 0.5411 ) + } + }, + vertexShader: require('./shaders/feather-vert.glsl'), + fragmentShader: require('./shaders/feather-frag.glsl') +}); + +var feather_Material3 = new THREE.ShaderMaterial({ + uniforms: + { + feathercolor: + { + type: "v3", + value: new THREE.Vector3( 0.0902, 0.1961, 0.5411 ) + } + }, + vertexShader: require('./shaders/feather-vert.glsl'), + fragmentShader: require('./shaders/feather-frag.glsl') +}); + +function dynamicLayers(scene) +{ + /* + // //remove old feathers + // // for(var i=0; i +23 verbose exit [ 1, true ] diff --git a/src/shaders/feather-frag.glsl b/src/shaders/feather-frag.glsl new file mode 100644 index 0000000..b280661 --- /dev/null +++ b/src/shaders/feather-frag.glsl @@ -0,0 +1,7 @@ +uniform vec3 feathercolor; + +void main() +{ + //vec4 color = feathercolor; + gl_FragColor = vec4( feathercolor, 1.0 ); +} diff --git a/src/shaders/feather-vert.glsl b/src/shaders/feather-vert.glsl new file mode 100644 index 0000000..3c72359 --- /dev/null +++ b/src/shaders/feather-vert.glsl @@ -0,0 +1,5 @@ + +void main() +{ + gl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 ); +} diff --git a/webpack.config.js b/webpack.config.js index 57dce48..bf2a406 100644 --- a/webpack.config.js +++ b/webpack.config.js @@ -1,4 +1,5 @@ const path = require('path'); +const webpack = require('webpack'); module.exports = { entry: path.join(__dirname, "src/main"), @@ -24,5 +25,8 @@ module.exports = { devtool: 'source-map', devServer: { port: 7000 - } -} \ No newline at end of file + }, + plugins: [ + new webpack.OldWatchingPlugin() + ] +}