diff --git a/README.md b/README.md index 1410c30..14ec292 100644 --- a/README.md +++ b/README.md @@ -1,82 +1,20 @@ -# [Project2: Toolbox Functions](https://github.com/CIS700-Procedural-Graphics/Project2-Toolbox-Functions) +# [Project2: Toolbox Functions] -## Overview +## Color +interpolate (power 2) color from black to selected color based on which layer the feather belongs to -The objective of this assignment is to procedurally model and animate a bird wing. Let's get creative! +## Orientation +The length of the feathers are calculated by two trig functions to achieve the decrease in length in the middle of the wing. The thickness of the feather is decreased with a small bias to the tip of the wing. -Start by forking and then cloning [this repository](https://github.com/CIS700-Procedural-Graphics/Project2-Toolbox-Functions) +## Scale +The feathers are distributed along the wing with a stronger bias towards the end. The rotation of the feathers are also increased along the curve with a strong bias towards the tip in order to achieve the "flick" at the end. The shorter feathers are thicker (based on layers) -## Modeling +## Distribution +The parameters are the tesselation number, representing the number of feathers along the curve. The number of layers is obvious. -##### Reference images +## Wind +The feathers flutter/rotate based on the angle of the force (cosine) and the magnitude of the force. -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. +## Motion +The wing flaps with a magnitude of the motion parameter and speed. The curvature affects the overall curve of the wing but changing the control points of the curve. -##### Make wing curve - -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. - -##### Distribute feathers - -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. - -Feel free to diversify your wings by using multiple base feather models. - -## Animation - -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. - -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. - -## Interactivity - -Using Dat.GUI and the examples provided in the reference code, allow the user to adjust the following controls: - -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 - -## For the Overachievers - -Suggestions: -- Make a pretty iridescent or otherwise feather appropriate shader. -- Otherwise, going the extra mile for this assignment is really in the polish! - -## Submission - -- 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 diff --git a/geo/feather_new.mtl b/geo/feather_new.mtl new file mode 100644 index 0000000..85ea760 --- /dev/null +++ b/geo/feather_new.mtl @@ -0,0 +1,6 @@ +newmtl feather_new:initialShadingGroup +illum 4 +Kd 0.50 0.50 0.50 +Ka 0.00 0.00 0.00 +Tf 1.00 1.00 1.00 +Ni 1.00 diff --git a/geo/feather_new.obj b/geo/feather_new.obj new file mode 100644 index 0000000..2fcccc2 --- /dev/null +++ b/geo/feather_new.obj @@ -0,0 +1,380 @@ +# This file uses centimeters as units for non-parametric coordinates. + +mtllib feather_new.mtl +g default +v 0.008944 -1.265333 -0.000403 +v -0.001577 -1.265336 0.024164 +v -0.022766 -1.265347 0.005486 +v -0.007131 -1.265346 -0.022364 +v 0.003378 -0.006267 -0.020570 +v 0.030247 -0.007453 0.002724 +v 0.002282 -0.007361 0.025575 +v -0.014445 -0.006470 0.003240 +v -0.006238 -1.852820 -0.012329 +v 0.000577 -1.853547 -0.001528 +v -0.012534 -1.852688 0.000799 +v -0.003873 -1.854606 0.009689 +v 0.075914 -0.025935 0.000000 +v 0.192354 -0.305013 0.000000 +v 0.186993 -0.584400 0.000000 +v 0.159129 -1.456443 0.000000 +v 0.108279 -1.624937 0.000000 +v 0.047627 -1.977286 0.000000 +v 0.001694 -0.012257 -0.014336 +v 0.001694 -0.319788 -0.014336 +v 0.001875 -0.583623 -0.014336 +v 0.001135 -1.493798 -0.014336 +v 0.000985 -1.664036 -0.014336 +v 0.001443 -2.057082 -0.004730 +v -0.052986 -0.013115 0.000000 +v -0.146487 -0.313221 0.000000 +v -0.168498 -0.583794 0.000000 +v -0.138298 -1.520982 0.000000 +v -0.137244 -1.690876 0.000000 +v -0.046702 -2.045595 0.000000 +v 0.152333 -0.747027 0.000000 +v 0.001445 -0.765215 -0.014336 +v -0.158668 -0.786321 0.000000 +v 0.075914 -0.025935 0.003354 +v 0.192354 -0.305013 0.003354 +v 0.001694 -0.319788 0.017690 +v 0.001694 -0.012257 0.017690 +v 0.186993 -0.584400 0.003354 +v 0.001875 -0.583623 0.017690 +v 0.152333 -0.747027 0.003354 +v 0.001445 -0.765215 0.017690 +v 0.159129 -1.456443 0.003354 +v 0.108279 -1.624937 0.003354 +v 0.000985 -1.664036 0.017690 +v 0.001135 -1.493798 0.017690 +v 0.047627 -1.977286 0.003354 +v 0.001443 -2.057082 0.008084 +v -0.146487 -0.313221 0.003354 +v -0.052986 -0.013115 0.003354 +v -0.168498 -0.583794 0.003354 +v -0.158668 -0.786321 0.003354 +v -0.137244 -1.690876 0.003354 +v -0.138298 -1.520982 0.003354 +v -0.046702 -2.045595 0.003354 +vt 0.625000 0.000000 +vt 0.875000 0.000000 +vt 0.875000 0.250000 +vt 0.625000 0.250000 +vt 0.440704 0.750000 +vt 0.625000 0.750000 +vt 0.625000 1.000000 +vt 0.440704 1.000000 +vt 0.440704 0.250000 +vt 0.440704 0.000000 +vt 0.625000 0.000000 +vt 0.625000 0.250000 +vt 0.440704 0.500000 +vt 0.625000 0.500000 +vt 0.875000 0.000000 +vt 0.875000 0.250000 +vt 0.000000 0.000000 +vt 0.200000 0.000000 +vt 0.200000 0.250000 +vt 0.000000 0.250000 +vt 0.400000 0.000000 +vt 0.400000 0.250000 +vt 0.433224 0.000000 +vt 0.433224 0.250000 +vt 0.600000 0.000000 +vt 0.800000 0.000000 +vt 0.800000 0.250000 +vt 0.600000 0.250000 +vt 1.000000 0.000000 +vt 1.000000 0.250000 +vt 0.200000 0.500000 +vt 0.000000 0.500000 +vt 0.400000 0.500000 +vt 0.433224 0.500000 +vt 0.800000 0.500000 +vt 0.600000 0.500000 +vt 1.000000 0.500000 +vt 0.000000 0.000000 +vt 0.000000 0.250000 +vt 0.200000 0.250000 +vt 0.200000 0.000000 +vt 0.400000 0.250000 +vt 0.400000 0.000000 +vt 0.433224 0.250000 +vt 0.433224 0.000000 +vt 0.600000 0.000000 +vt 0.600000 0.250000 +vt 0.800000 0.250000 +vt 0.800000 0.000000 +vt 1.000000 0.250000 +vt 1.000000 0.000000 +vt 0.000000 0.500000 +vt 0.200000 0.500000 +vt 0.400000 0.500000 +vt 0.433224 0.500000 +vt 0.600000 0.500000 +vt 0.800000 0.500000 +vt 1.000000 0.500000 +vt 0.000000 0.000000 +vt 0.200000 0.000000 +vt 0.000000 0.250000 +vt 0.400000 0.000000 +vt 0.433224 0.000000 +vt 0.600000 0.000000 +vt 0.800000 0.000000 +vt 1.000000 0.000000 +vt 1.000000 0.250000 +vt 0.200000 0.500000 +vt 0.000000 0.500000 +vt 0.400000 0.500000 +vt 0.433224 0.500000 +vt 0.800000 0.500000 +vt 0.600000 0.500000 +vt 1.000000 0.500000 +vn -0.077940 -0.994333 -0.072295 +vn -0.077940 -0.994333 -0.072295 +vn -0.077940 -0.994333 -0.072295 +vn -0.077940 -0.994333 -0.072295 +vn 0.606521 0.000101 -0.795068 +vn 0.608461 0.000269 -0.793583 +vn 0.714396 0.001263 -0.699741 +vn 0.715417 0.001167 -0.698697 +vn 0.633629 -0.005231 0.773619 +vn 0.793334 -0.003936 0.608773 +vn 0.794221 -0.003991 0.607615 +vn 0.633303 -0.005248 0.773886 +vn -0.680097 -0.004852 0.733106 +vn -0.675067 -0.008626 0.737706 +vn -0.675038 -0.008567 0.737733 +vn -0.679773 -0.004856 0.733407 +vn -0.758886 0.000230 -0.651224 +vn -0.829313 -0.003633 -0.558773 +vn -0.829053 -0.003601 -0.559158 +vn -0.759349 0.000225 -0.650684 +vn 0.714396 0.001263 -0.699741 +vn 0.819601 -0.009551 -0.572855 +vn 0.819601 -0.009551 -0.572855 +vn 0.715417 0.001167 -0.698697 +vn -0.829313 -0.003633 -0.558773 +vn -0.881643 -0.010497 -0.471800 +vn -0.881643 -0.010497 -0.471800 +vn -0.829053 -0.003601 -0.559158 +vn -0.675067 -0.008626 0.737706 +vn -0.678961 -0.016532 0.733988 +vn -0.678962 -0.016532 0.733988 +vn -0.675038 -0.008567 0.737733 +vn 0.793334 -0.003936 0.608773 +vn 0.922583 -0.013462 0.385565 +vn 0.922583 -0.013462 0.385565 +vn 0.794221 -0.003991 0.607615 +vn 0.107507 0.021340 0.993975 +vn -0.009028 0.021551 0.999727 +vn -0.000556 0.009534 0.999954 +vn 0.088493 0.007968 0.996045 +vn 0.088493 0.007968 0.996045 +vn -0.000556 0.009534 0.999954 +vn -0.001352 -0.001292 0.999998 +vn 0.079171 -0.003338 0.996855 +vn 0.079171 -0.003338 0.996855 +vn -0.001352 -0.001292 0.999998 +vn 0.002737 -0.001375 0.999995 +vn 0.090624 -0.001881 0.995883 +vn 0.094383 -0.001346 0.995535 +vn -0.008868 -0.002077 0.999959 +vn 0.006871 -0.017452 0.999824 +vn 0.123289 -0.019635 0.992177 +vn 0.123289 -0.019635 0.992177 +vn 0.006871 -0.017452 0.999824 +vn -0.043697 -0.024875 0.998735 +vn 0.141683 -0.024195 0.989616 +vn -0.009028 0.021551 0.999727 +vn -0.139326 0.021439 0.990014 +vn -0.108221 0.010314 0.994073 +vn -0.000556 0.009534 0.999954 +vn -0.000556 0.009534 0.999954 +vn -0.108221 0.010314 0.994073 +vn -0.088156 0.001161 0.996106 +vn -0.001352 -0.001292 0.999998 +vn -0.001352 -0.001292 0.999998 +vn -0.088156 0.001161 0.996106 +vn -0.093282 -0.001469 0.995639 +vn 0.002737 -0.001375 0.999995 +vn -0.008868 -0.002077 0.999959 +vn -0.096685 -0.001085 0.995315 +vn -0.100842 -0.015531 0.994781 +vn 0.006871 -0.017452 0.999824 +vn -0.043697 -0.024875 0.998735 +vn 0.006871 -0.017452 0.999824 +vn -0.100842 -0.015531 0.994781 +vn -0.099708 -0.024913 0.994705 +vn 0.090624 -0.001881 0.995883 +vn 0.002737 -0.001375 0.999995 +vn -0.008868 -0.002077 0.999959 +vn 0.094383 -0.001346 0.995535 +vn -0.093282 -0.001469 0.995639 +vn -0.096685 -0.001085 0.995315 +vn -0.008868 -0.002077 0.999959 +vn 0.002737 -0.001375 0.999995 +vn 0.107507 0.021340 -0.993975 +vn 0.088493 0.007968 -0.996045 +vn -0.000556 0.009534 -0.999954 +vn -0.009028 0.021551 -0.999727 +vn 0.088493 0.007968 -0.996045 +vn 0.079171 -0.003338 -0.996855 +vn -0.001352 -0.001292 -0.999998 +vn -0.000556 0.009534 -0.999954 +vn 0.079171 -0.003338 -0.996855 +vn 0.090624 -0.001881 -0.995883 +vn 0.002737 -0.001375 -0.999995 +vn -0.001352 -0.001292 -0.999998 +vn 0.094383 -0.001346 -0.995535 +vn 0.123289 -0.019635 -0.992177 +vn 0.006871 -0.017452 -0.999824 +vn -0.008868 -0.002077 -0.999959 +vn 0.123289 -0.019635 -0.992177 +vn 0.141683 -0.024195 -0.989616 +vn -0.043697 -0.024875 -0.998735 +vn 0.006871 -0.017452 -0.999824 +vn -0.009028 0.021551 -0.999727 +vn -0.000556 0.009534 -0.999954 +vn -0.108221 0.010314 -0.994073 +vn -0.139326 0.021439 -0.990014 +vn -0.000556 0.009534 -0.999954 +vn -0.001352 -0.001292 -0.999998 +vn -0.088156 0.001161 -0.996106 +vn -0.108221 0.010314 -0.994073 +vn -0.001352 -0.001292 -0.999998 +vn 0.002737 -0.001375 -0.999995 +vn -0.093282 -0.001469 -0.995639 +vn -0.088156 0.001161 -0.996106 +vn -0.008868 -0.002077 -0.999959 +vn 0.006871 -0.017452 -0.999824 +vn -0.100842 -0.015531 -0.994781 +vn -0.096685 -0.001085 -0.995315 +vn -0.043697 -0.024875 -0.998735 +vn -0.099708 -0.024913 -0.994705 +vn -0.100842 -0.015531 -0.994781 +vn 0.006871 -0.017452 -0.999824 +vn 0.090624 -0.001881 -0.995883 +vn 0.094383 -0.001346 -0.995535 +vn -0.008868 -0.002077 -0.999959 +vn 0.002737 -0.001375 -0.999995 +vn -0.093282 -0.001469 -0.995639 +vn 0.002737 -0.001375 -0.999995 +vn -0.008868 -0.002077 -0.999959 +vn -0.096685 -0.001085 -0.995315 +vn 0.922892 0.385059 -0.000000 +vn 0.922892 0.385059 -0.000000 +vn 0.980788 0.195078 -0.000000 +vn 0.980788 0.195078 -0.000000 +vn 0.101409 0.994845 0.000000 +vn 0.101409 0.994845 0.000000 +vn 0.181234 0.983440 0.000000 +vn 0.181234 0.983440 0.000000 +vn 0.980788 0.195078 -0.000000 +vn 0.980788 0.195078 -0.000000 +vn 0.995926 -0.090174 -0.000000 +vn 0.995926 -0.090174 -0.000000 +vn 0.995926 -0.090174 -0.000000 +vn 0.995926 -0.090174 -0.000000 +vn 0.999490 -0.031935 -0.000000 +vn 0.999490 -0.031935 -0.000000 +vn 0.998743 -0.050118 -0.000000 +vn 0.998743 -0.050118 -0.000000 +vn 0.977844 -0.209337 -0.000000 +vn 0.977844 -0.209337 -0.000000 +vn 0.977844 -0.209337 -0.000000 +vn 0.977844 -0.209337 -0.000000 +vn 0.952776 -0.303675 -0.000000 +vn 0.952776 -0.303675 -0.000000 +vn 0.952776 -0.303675 -0.000000 +vn 0.952776 -0.303675 -0.000000 +vn 0.865490 -0.500926 -0.000000 +vn 0.865490 -0.500926 -0.000000 +vn -0.980124 0.198387 0.000000 +vn -0.980124 0.198387 0.000000 +vn -0.954735 0.297457 0.000000 +vn -0.954735 0.297457 0.000000 +vn -0.015681 0.999877 0.000000 +vn -0.015681 0.999877 0.000000 +vn 0.101409 0.994845 0.000000 +vn 0.101409 0.994845 0.000000 +vn -0.999669 0.025737 0.000000 +vn -0.999669 0.025737 0.000000 +vn -0.980124 0.198387 0.000000 +vn -0.980124 0.198387 0.000000 +vn -0.999481 -0.032207 0.000000 +vn -0.999481 -0.032207 0.000000 +vn -0.999669 0.025737 0.000000 +vn -0.999669 0.025737 0.000000 +vn -0.985098 -0.171995 0.000000 +vn -0.985098 -0.171995 0.000000 +vn -0.999720 -0.023678 0.000000 +vn -0.999720 -0.023678 0.000000 +vn -0.232074 -0.972698 -0.000000 +vn -0.232074 -0.972698 -0.000000 +vn -0.232074 -0.972698 -0.000000 +vn -0.232074 -0.972698 -0.000000 +vn -0.968934 -0.247319 0.000000 +vn -0.968934 -0.247319 0.000000 +vn -0.985098 -0.171995 0.000000 +vn -0.985098 -0.171995 0.000000 +vn 0.999490 -0.031935 -0.000000 +vn 0.999490 -0.031935 -0.000000 +vn 0.998743 -0.050118 -0.000000 +vn 0.998743 -0.050118 -0.000000 +vn -0.999720 -0.023678 0.000000 +vn -0.999720 -0.023678 0.000000 +vn -0.999481 -0.032207 0.000000 +vn -0.999481 -0.032207 0.000000 +s off +g feather_new:Mesh +usemtl feather_new:initialShadingGroup +f 10/1/1 12/4/2 11/3/3 9/2/4 +f 5/5/5 6/8/6 1/7/7 4/6/8 +f 7/9/9 2/12/10 1/11/11 6/10/12 +f 8/13/13 3/14/14 2/12/15 7/9/16 +f 5/5/17 4/6/18 3/14/19 8/13/20 +f 1/11/21 10/1/22 9/2/23 4/15/24 +f 4/15/25 9/2/26 11/3/27 3/16/28 +f 3/16/29 11/3/30 12/4/31 2/12/32 +f 2/12/33 12/4/34 10/1/35 1/11/36 +f 34/17/37 37/20/38 36/19/39 35/18/40 +f 35/18/41 36/19/42 39/22/43 38/21/44 +f 38/21/45 39/22/46 41/24/47 40/23/48 +f 42/25/49 45/28/50 44/27/51 43/26/52 +f 43/26/53 44/27/54 47/30/55 46/29/56 +f 37/20/57 49/32/58 48/31/59 36/19/60 +f 36/19/61 48/31/62 50/33/63 39/22/64 +f 39/22/65 50/33/66 51/34/67 41/24/68 +f 45/28/69 53/36/70 52/35/71 44/27/72 +f 47/30/73 44/27/74 52/35/75 54/37/76 +f 40/23/77 41/24/78 45/28/79 42/25/80 +f 51/34/81 53/36/82 45/28/83 41/24/84 +f 13/38/85 14/41/86 20/40/87 19/39/88 +f 14/41/89 15/43/90 21/42/91 20/40/92 +f 15/43/93 31/45/94 32/44/95 21/42/96 +f 16/46/97 17/49/98 23/48/99 22/47/100 +f 17/49/101 18/51/102 24/50/103 23/48/104 +f 19/39/105 20/40/106 26/53/107 25/52/108 +f 20/40/109 21/42/110 27/54/111 26/53/112 +f 21/42/113 32/44/114 33/55/115 27/54/116 +f 22/47/117 23/48/118 29/57/119 28/56/120 +f 24/50/121 30/58/122 29/57/123 23/48/124 +f 31/45/125 16/46/126 22/47/127 32/44/128 +f 33/55/129 32/44/130 22/47/131 28/56/132 +f 13/59/133 34/17/134 35/18/135 14/60/136 +f 19/61/137 37/20/138 34/17/139 13/59/140 +f 14/60/141 35/18/142 38/21/143 15/62/144 +f 15/62/145 38/21/146 40/23/147 31/63/148 +f 16/64/149 42/25/150 43/26/151 17/65/152 +f 17/65/153 43/26/154 46/29/155 18/66/156 +f 18/66/157 46/29/158 47/30/159 24/67/160 +f 26/68/161 48/31/162 49/32/163 25/69/164 +f 25/69/165 49/32/166 37/20/167 19/61/168 +f 27/70/169 50/33/170 48/31/171 26/68/172 +f 33/71/173 51/34/174 50/33/175 27/70/176 +f 29/72/177 52/35/178 53/36/179 28/73/180 +f 24/67/181 47/30/182 54/37/183 30/74/184 +f 30/74/185 54/37/186 52/35/187 29/72/188 +f 31/63/189 40/23/190 42/25/191 16/64/192 +f 28/73/193 53/36/194 51/34/195 33/71/196 diff --git a/npm-debug.log b/npm-debug.log new file mode 100644 index 0000000..a2dc310 --- /dev/null +++ b/npm-debug.log @@ -0,0 +1,43 @@ +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 'run', +1 verbose cli 'deploy' ] +2 info using npm@2.15.9 +3 info using node@v4.5.0 +4 verbose run-script [ 'predeploy', 'deploy', 'postdeploy' ] +5 info predeploy @ +6 info deploy @ +7 verbose unsafe-perm in lifecycle true +8 info @ Failed to exec deploy script +9 verbose stack Error: @ deploy: `rm -rf npm-debug.log && git checkout master && git commit -am 'update' && gh-pages-deploy` +9 verbose stack Exit status 1 +9 verbose stack at EventEmitter. (c:\Program Files\nodejs\node_modules\npm\lib\utils\lifecycle.js:217:16) +9 verbose stack at emitTwo (events.js:87:13) +9 verbose stack at EventEmitter.emit (events.js:172:7) +9 verbose stack at ChildProcess. (c:\Program Files\nodejs\node_modules\npm\lib\utils\spawn.js:24:14) +9 verbose stack at emitTwo (events.js:87:13) +9 verbose stack at ChildProcess.emit (events.js:172:7) +9 verbose stack at maybeClose (internal/child_process.js:829:16) +9 verbose stack at Process.ChildProcess._handle.onexit (internal/child_process.js:211:5) +10 verbose pkgid @ +11 verbose cwd c:\Users\Sarah\Documents\UPENN\CIS700\Project2-Toolbox-Functions +12 error Windows_NT 6.1.7601 +13 error argv "c:\\Program Files\\nodejs\\node.exe" "c:\\Program Files\\nodejs\\node_modules\\npm\\bin\\npm-cli.js" "run" "deploy" +14 error node v4.5.0 +15 error npm v2.15.9 +16 error code ELIFECYCLE +17 error @ deploy: `rm -rf npm-debug.log && git checkout master && git commit -am 'update' && gh-pages-deploy` +17 error Exit status 1 +18 error Failed at the @ deploy script 'rm -rf npm-debug.log && git checkout master && git commit -am 'update' && gh-pages-deploy'. +18 error This is most likely a problem with the package, +18 error not with npm itself. +18 error Tell the author that this fails on your system: +18 error rm -rf npm-debug.log && git checkout master && git commit -am 'update' && gh-pages-deploy +18 error You can get information on how to open an issue for this project with: +18 error npm bugs +18 error Or if that isn't available, you can get their info via: +18 error +18 error npm owner ls +18 error There is likely additional logging output above. +19 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/references/images.jpg b/references/images.jpg new file mode 100644 index 0000000..ca8aac3 Binary files /dev/null and b/references/images.jpg differ diff --git a/references/images1.jpg b/references/images1.jpg new file mode 100644 index 0000000..e5c8657 Binary files /dev/null and b/references/images1.jpg differ diff --git a/src/distribution.js b/src/distribution.js new file mode 100644 index 0000000..45887cf --- /dev/null +++ b/src/distribution.js @@ -0,0 +1,47 @@ +function bias(b, t) { + return Math.pow(t, Math.log(b) / Math.log(0.5)); +} + +function gain(g, t) { + if (t < 0.5) return bias(1-g, 2*t)/2; + else return 1 - bias(1-g, 2-2*t)/2; +} + +function parabola(x, k) { + return Math.pow(4*x*(1-x),k); +} + +function cubicPulse(c, w, x) { + var x = Math.abs(x-c); + if (x>w) return 0; + x /=w; + return 1 - x*x*(3-2*x); +} + +function pcurve(x, a, b) { + var k = Math.pow(a+b, a+b) / Math.pow(a,a) / Math.pow(b,b); + return k * Math.pow(x, a) * Math.pow(1-x, b); +} + +export function spread(mesh, curve, params) { + var i = mesh.path/params.tessel/2; + var rot = -(150* bias(params.orientation, mesh.path/params.tessel) - 30); + var dist = parabola(i, 1.5); + var roo = curve.getPointAt(dist); + var Xoutward = (-45 + 8*mesh.layer) * Math.PI/180; + var Yoverlap = -15 * Math.PI/180; + // var Zrightleft = -3 * mesh.path * Math.PI/180; // 20 -> -120 + var Zrightleft = rot * Math.PI / 180; + mesh.position.set(roo.x, roo.y, roo.z-mesh.layer*0.001); + mesh.rotation.set(Xoutward, Yoverlap, Zrightleft); +} + +export function size(mesh, curve, params) { + var oi = mesh.path/ params.tessel; + var l = gain(0.3,(mesh.layer + 1)/params.layers); + var x = 1+Math.sin(3 * Math.PI /2 * oi)* Math.sin(3 * Math.PI /2 * oi)/2; + var y = 1 + Math.cos(Math.PI * oi) * Math.cos(Math.PI * oi); + var sc = params.scale * cubicPulse(0, 2, 1-oi); + var sx = params.scale * Math.min(2*(1-bias(0.6, oi))+1,1.5); + mesh.scale.set(sx, x*y*sc*l, x*y*sc*l); +} \ No newline at end of file diff --git a/src/main.js b/src/main.js index fd8fbd4..444641b 100755 --- a/src/main.js +++ b/src/main.js @@ -4,6 +4,85 @@ const THREE = require('three'); // older modules are imported like this. You shouldn't have to worry about this much import Framework from './framework' +import {spread, size} from './distribution' + +var val = function() { + this.speed = 10; this.curvature = 1; + this.scale = 1; this.orientation = 0.1; this.color = [1.0,0.0,0.0]; + this.motion = 1; + this.layers = 3; this.tessel = 20; + this.direction = Math.PI; this.force = 0.5; +}; + +var feathers = []; +var featherGeo; +var params = new val(); + +var new_mat = function(l) { + var mat = { + uniforms: { + color: {value: params.color}, + light: {value: [1.0, 3.0, 2.0]}, + layer: {value: l}, + total: {value: params.layers} + }, + vertexShader: require('./shaders/feather-vert.glsl'), + fragmentShader: require('./shaders/feather-frag.glsl') + }; + return mat; +} + +var p0 = new THREE.Vector3(2.5,0,0); +var p1_0 = new THREE.Vector3(1.5,-0.5*params.curvature,-0.5*params.motion); +var p1_1 = new THREE.Vector3(1.5,-0.5*params.curvature, 0.5*params.motion); +var p2_0 = new THREE.Vector3(-1.5,0.5*params.curvature,0.75*params.motion); +var p2_1 = new THREE.Vector3(-1,0.5*params.curvature,-0.75*params.motion); +var p3_0 = new THREE.Vector3(-2.5,0.5*params.curvature,1*params.motion) +var p3_1 = new THREE.Vector3(-1.25,0.5*params.curvature,-1*params.motion); +var p1 = new THREE.Vector3(0,0,0); +var p2 = new THREE.Vector3(0,0,0); +var p3 = new THREE.Vector3(0,0,0); + +var curve = new THREE.CatmullRomCurve3( [p0, p1_0, p2_0, p3_0 ]); + +function createWing(scene, geo) { + // remove all feathers + for (var f = 0; f < feathers.length; f ++ ) { + scene.remove(feathers[f]); + } + feathers = []; + + var k; + var material; + + p1_0 = new THREE.Vector3(1.5,-5*params.curvature,-0.5*params.motion); + p1_1 = new THREE.Vector3(1.5,-5*params.curvature, 0.5*params.motion); + p2_0 = new THREE.Vector3(-1.5,0.5*params.curvature,0.75*params.motion); + p2_1 = new THREE.Vector3(-1.5,0.5*params.curvature,-0.75*params.motion); + p3_0 = new THREE.Vector3(-2.5,0.5*params.curvature,1*params.motion) + p3_1 = new THREE.Vector3(-2.5,0.5*params.curvature,-1*params.motion); + curve = new THREE.CatmullRomCurve3( [p0, p1_0, p2_0, p3_0 ]); + // debugger + for (var j = 0; j < params.layers; j++) { + material = new THREE.ShaderMaterial(new_mat(j)); + for (var i = 0; i < params.tessel; i++) { + var k = feathers.length; + var feather = new THREE.Mesh(geo, material); + feathers.push(feather); + feather.name = "feather" + (k).toString(); + feather.path = i; + feather.layer = j; + size(feather, curve, params); + spread(feather, curve, params); + scene.add(feather); + } + } +} + +function moveFeathers(scene) { + +} + // called after the scene loads function onLoad(framework) { var scene = framework.scene; @@ -12,9 +91,6 @@ function onLoad(framework) { var gui = framework.gui; var stats = framework.stats; - // Basic Lambert white - var lambertWhite = new THREE.MeshLambertMaterial({ color: 0xaaaaaa, side: THREE.DoubleSide }); - // Set light var directionalLight = new THREE.DirectionalLight( 0xffffff, 1 ); directionalLight.color.setHSL(0.1, 1, 0.95); @@ -23,7 +99,7 @@ function onLoad(framework) { // set skybox var loader = new THREE.CubeTextureLoader(); - var urlPrefix = '/images/skymap/'; + var urlPrefix = 'images/skymap/'; var skymap = new THREE.CubeTextureLoader().load([ urlPrefix + 'px.jpg', urlPrefix + 'nx.jpg', @@ -35,37 +111,70 @@ function onLoad(framework) { // load a simple obj mesh var objLoader = new THREE.OBJLoader(); - objLoader.load('/geo/feather.obj', function(obj) { - + var obj = objLoader.load('geo/feather_new.obj', function(obj) { // LOOK: This function runs after the obj has finished loading - var featherGeo = obj.children[0].geometry; - - var featherMesh = new THREE.Mesh(featherGeo, lambertWhite); - featherMesh.name = "feather"; - scene.add(featherMesh); + featherGeo = obj.children[0].geometry; + createWing(scene, featherGeo); }); // set camera position - camera.position.set(0, 1, 5); + camera.position.set(-10, 5, 6); camera.lookAt(new THREE.Vector3(0,0,0)); - // scene.add(lambertCube); scene.add(directionalLight); // edit params and listen to changes like this // more information here: https://workshop.chromeexperiments.com/examples/gui/#1--Basic-Usage - gui.add(camera, 'fov', 0, 180).onChange(function(newVal) { - camera.updateProjectionMatrix(); + var f1 = gui.addFolder('Wing'); + var f2 = gui.addFolder('Feathers'); + var f3 = gui.addFolder('Wind'); + + //color + f2.addColor(params, 'color').onChange(function(newVal) { + // params.color = [newVal[0]/255, newVal[1]/255, newVal[2]/255]; + createWing(scene, featherGeo); }); + //scale + f2.add(params, 'scale',0.0, 2.0).onChange(function(newVal) {}); + //orient + f2.add(params, 'orientation',0.0, 1.0).onChange(function(newVal) {}); + // flapping speed + f1.add(params, 'speed', 0, 40).onChange(function(newVal) {}); + // flapping motion + f1.add(params, 'motion', 0, 3).onChange(function(newVal) { + createWing(scene, featherGeo);}); + //curvature + f1.add(params, 'curvature', 0.0, 5).onChange(function(newVal) { + createWing(scene, featherGeo);}); + // distribution + f1.add(params, 'layers', 0, 5).step(1).onChange(function(newVal) { + createWing(scene, featherGeo);}); + f1.add(params, 'tessel', 0, 100).step(1).onChange(function(newVal) { + createWing(scene, featherGeo);}); + // force magnitude + f3.add(params, 'force', 0,1).onChange(function(newVal) {}); + // force direction + f3.add(params, 'direction', 0, 2*Math.PI).onChange(function(newVal) {}); } // called on frame updates function onUpdate(framework) { - var feather = framework.scene.getObjectByName("feather"); - if (feather !== undefined) { - // Simply flap wing - var date = new Date(); - feather.rotateZ(Math.sin(date.getTime() / 100) * 2 * Math.PI / 180); + var date = new Date(); + var t = Math.sin(params.speed * date.getTime()/(4*1000))/2 + 0.5; + curve = new THREE.CatmullRomCurve3( + [p0, p1.lerpVectors(p1_0, p1_1, t), + p1.lerpVectors(p2_0, p2_1, t), + p2.lerpVectors(p3_0, p3_1,t)]); + for (var i = 0; i < feathers.length; i++) { + var feather = framework.scene.getObjectByName("feather" + i.toString()); + if (feather !== undefined) { + size(feather, curve, params); + spread(feather, curve, params); + var flutter = params.force * Math.cos(params.direction)/2; + feather.rotateY(flutter*Math.sin(date.getTime()/(25 + Math.random()))); + //feather.rotateZ(Math.sin(date.getTime())/(100 + Math.random())); + //feather.rotateZ(Math.sin(date.getTime() / 100) * 2 * Math.PI / 180); + } } } diff --git a/src/shaders/feather-frag.glsl b/src/shaders/feather-frag.glsl new file mode 100644 index 0000000..124f09c --- /dev/null +++ b/src/shaders/feather-frag.glsl @@ -0,0 +1,20 @@ +uniform vec3 color; +uniform vec3 light; +uniform float layer; +uniform float total; + +varying vec3 vPosition; +varying vec3 vNormal; + +vec3 lerp(vec3 a, vec3 b, float t) { + return a * (1.0-t) + b * t; +} + +void main() { + vec3 incoming_ray = normalize(light - vPosition); + vec3 black = vec3(1.0,1.0,1.0); + vec3 bcolor = lerp(black, color/255.0, (layer + 1.0)/total ); + float c = dot(vNormal, incoming_ray); + gl_FragColor = vec4(c * bcolor, 1.0 ); + +} \ No newline at end of file diff --git a/src/shaders/feather-vert.glsl b/src/shaders/feather-vert.glsl new file mode 100644 index 0000000..9be614c --- /dev/null +++ b/src/shaders/feather-vert.glsl @@ -0,0 +1,10 @@ +varying vec3 vPosition; +varying vec3 vNormal; + +void main() { + + vNormal = normal; + vPosition = position; + + gl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 ); +} \ No newline at end of file