From 4cf7f78332a49df9832384e1a73e2ed6bb1b78fd Mon Sep 17 00:00:00 2001 From: Rudraksha20 Date: Tue, 31 Jan 2017 15:57:51 -0500 Subject: [PATCH 1/5] commit_1 basic feathers layout --- src/main.js | 190 ++++++++++++++++++++++++++++++++++++++++++++++++++-- 1 file changed, 183 insertions(+), 7 deletions(-) diff --git a/src/main.js b/src/main.js index fd8fbd4..a5288ae 100755 --- a/src/main.js +++ b/src/main.js @@ -13,7 +13,11 @@ function onLoad(framework) { var stats = framework.stats; // Basic Lambert white - var lambertWhite = new THREE.MeshLambertMaterial({ color: 0xaaaaaa, side: THREE.DoubleSide }); + var lambertWhite = new THREE.MeshLambertMaterial({ color: 0x4F2B08, side: THREE.DoubleSide }); + + //lambert light blue and green + var lambertLB = new THREE.MeshLambertMaterial({ color: 0x7A430C, side: THREE.DoubleSide }); + var lambertG = new THREE.MeshLambertMaterial({ color: 0xA6703A, side: THREE.DoubleSide }); // Set light var directionalLight = new THREE.DirectionalLight( 0xffffff, 1 ); @@ -40,11 +44,137 @@ function onLoad(framework) { // 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); - }); - +// var featherMesh = new THREE.Mesh(featherGeo, lambertWhite); +// featherMesh.name = "feather"; +// scene.add(featherMesh); +// + //base curve + var curve = new THREE.CatmullRomCurve3( [ + new THREE.Vector3( 0, 0, 0 ), + new THREE.Vector3( 0.25, 0, 0.8), + new THREE.Vector3( 0.1, 0, 2), + new THREE.Vector3( 0, 0, 3), + new THREE.Vector3( 0.3, 0, 3.8), + new THREE.Vector3( 0, 0, 4.5) + ] ); + + //base feathers + var no_of_feathers_base = 31; + for(var i =1; i < no_of_feathers_base; i++) + { + var new_fm = new THREE.Mesh(featherGeo, lambertWhite); + new_fm.name = "feather" + i; + var f_pos = curve.getPoint(i / (no_of_feathers_base - 1)); + + + //setting up the feather pos on the curve points + new_fm.position.x = f_pos.x; + new_fm.position.y = f_pos.y; + new_fm.position.z = f_pos.z; + + //scaling the feathers + new_fm.scale.set(f_pos.x + 1,1,1); + + if(i == no_of_feathers_base - 11) + { + new_fm.rotateY( (no_of_feathers_base - 11 - i - 1) * 1.5 * 2 * Math.PI / 180); + } + + //rotating the feathers towards the end + if(i >= no_of_feathers_base - 10) + { + //console.log(new_fm.position.z); + //new_fm.position.z = 3.65; + new_fm.rotateY( (no_of_feathers_base - 10 - i - 1) * 5 * 2 * Math.PI / 180); + } + + //rotating the feathers by a slight value + new_fm.rotateY(-8 * Math.PI / 180); + + //adding the feathures to the scene + scene.add(new_fm); + } + + + //feathers on top1 + var no_of_feathers_top1 = 31; + for(var i =1; i < no_of_feathers_top1; i++) + { + var new_fm = new THREE.Mesh(featherGeo, lambertLB); + new_fm.name = "feather" + i + 30; + var f_pos = curve.getPoint(i / (no_of_feathers_top1 - 1)); + + + //setting up the feather pos on the curve points + new_fm.position.x = f_pos.x; + new_fm.position.y = f_pos.y + 0.065; + new_fm.position.z = f_pos.z + 0.1; + + //scaling the feathers + new_fm.scale.set(f_pos.x + 0.6,1,1); + + if(i == no_of_feathers_top1 - 11) + { + new_fm.rotateY( (no_of_feathers_top1 - 11 - i - 1) * 1.5 * 2 * Math.PI / 180); + } + + //rotating the feathers towards the end + if(i >= no_of_feathers_top1 - 10) + { + //console.log(new_fm.position.z); + //new_fm.position.z = 3.65; + new_fm.rotateY( (no_of_feathers_top1 - 10 - i - 1) * 5 * 2 * Math.PI / 180); + } + + + //rotating the feathers by a slight value + new_fm.rotateY(-10 * Math.PI / 180); + + //adding the feathures to the scene + scene.add(new_fm); + } + + + //feathers on top2 + var no_of_feathers_top2 = 31; + for(var i =1; i < no_of_feathers_top2; i++) + { + var new_fm = new THREE.Mesh(featherGeo, lambertG); + new_fm.name = "feather" + i + 60; + var f_pos = curve.getPoint(i / (no_of_feathers_top2 - 1)); + + + //setting up the feather pos on the curve points + new_fm.position.x = f_pos.x; + new_fm.position.y = f_pos.y + 0.15; + new_fm.position.z = f_pos.z + 0.15; + + //scaling the feathers + new_fm.scale.set(f_pos.x + 0.3,1,1); + + if(i == no_of_feathers_top2 - 11) + { + new_fm.scale.set(0.35,1,1); + new_fm.rotateY( (no_of_feathers_top2 - 11 - i - 1) * 1.5 * 2 * Math.PI / 180); + } + + //rotating the feathers towards the end + if(i >= no_of_feathers_top2 - 10) + { + new_fm.scale.set(0.4,1,1); + //console.log(new_fm.position.z); + //new_fm.position.z = 3.65; + new_fm.rotateY( (no_of_feathers_top2 - 10 - i - 1) * 5 * 2 * Math.PI / 180); + } + + + //adding the feathures to the scene + scene.add(new_fm); + } + + }); + + // set camera position camera.position.set(0, 1, 5); camera.lookAt(new THREE.Vector3(0,0,0)); @@ -65,8 +195,54 @@ function onUpdate(framework) { if (feather !== undefined) { // Simply flap wing var date = new Date(); - feather.rotateZ(Math.sin(date.getTime() / 100) * 2 * Math.PI / 180); + //feather.rotateZ(Math.sin(date.getTime() / 100) * 2 * Math.PI / 180); } + + //flapping wings!!! + for(var i = 1 ;i < 31; i++) + { + var base_feather = framework.scene.getObjectByName("feather" + i); + if(base_feather !== undefined){ + var date = new Date(); + //base_feather.position.y = Math.sin(date.getTime() * base_feather.position.z * Math.PI / 180); + //base_feather.position.y = base_feather.position.y + (Math.sin(date.getTime() / 100)); //good + //top2_feather.position.y = Math.sin(date.getTime() * top2_feather.position.z * Math.PI / 180); + + //base_feather.rotateX(Math.sin(date.getTime() / 1000 * base_feather.position.z) * 10 * Math.PI / 180); +// base_feather.position.y = (base_feather.position.y + Math.sin(base_feather.position.z)) + Math.sin(date.getTime() / 10); + + //base_feather.rotateX(60*Math.sin(10*date.getTime())); + + base_feather.position.y = Math.sin(date.getTime() / 800 * base_feather.position.z) / 10; + } + + + var top1_feather = framework.scene.getObjectByName("feather" + i + 30); + if(top1_feather !== undefined){ + var date = new Date(); + //base_feather.position.y = Math.sin(date.getTime() * base_feather.position.z * Math.PI / 180); + //top1_feather.position.y = top1_feather.position.y + (Math.sin(date.getTime() / 100)); //good + //top2_feather.position.y = Math.sin(date.getTime() * top2_feather.position.z * Math.PI / 180); + + //top1_feather.rotateX(Math.sin(date.getTime() / 1000 * top1_feather.position.z) * 10 * Math.PI / 180); + + top1_feather.position.y = Math.sin(date.getTime() / 800 * top1_feather.position.z) / 10; + } + + var top2_feather = framework.scene.getObjectByName("feather" + i + 60); + if(top2_feather !== undefined){ + var date = new Date(); + //base_feather.position.y = Math.sin(date.getTime() * base_feather.position.z * Math.PI / 180); + //top2_feather.position.y = top2_feather.position.y + (Math.sin(date.getTime() / 100)); //good + //top2_feather.position.y = Math.sin(date.getTime() * top2_feather.position.z * Math.PI / 180); + + //top2_feather.rotateX(Math.sin(date.getTime() / 1000 * top2_feather.position.z) * 10 * Math.PI / 180); + + top2_feather.position.y = Math.sin(date.getTime() / 800 * top2_feather.position.z) / 10; + } + + } + } // when the scene is done initializing, it will call onLoad, then on frame updates, call onUpdate From 30d8ad590adee090ddb900a27b62e158d7ef16f0 Mon Sep 17 00:00:00 2001 From: Rudraksha20 Date: Tue, 31 Jan 2017 23:57:22 -0500 Subject: [PATCH 2/5] Commit --- README.md | 62 +--------- src/main.js | 349 +++++++++++++++++++++++++++++++++++++++++++++++----- 2 files changed, 321 insertions(+), 90 deletions(-) diff --git a/README.md b/README.md index 1410c30..832b8bf 100644 --- a/README.md +++ b/README.md @@ -8,75 +8,21 @@ Start by forking and then cloning [this repository](https://github.com/CIS700-Pr ## Modeling -##### Reference images +Modelling the Shape of a wing procedurally using mathametical equations. First modeling the curve of the wing using Catmull Rom spline. Then instancing a feather geometry across the spline creatinging the basic structure of the wing, many different types of feather geometry can be instanced to sample multiple types of feathers. -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. - -##### 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. +The wind force is reflected as the jittering motion of the wings, the speed of the wind determines the jitter rate. Wing flapping is achived by applying a basic sin function to the Y component of the feathers position. ## 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 +2. Feather distribution - In Later Implementations 3. Feather size -4. Feather color +4. Feather color - In Later Implementations 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/src/main.js b/src/main.js index a5288ae..2a63f6e 100755 --- a/src/main.js +++ b/src/main.js @@ -4,6 +4,33 @@ const THREE = require('three'); // older modules are imported like this. You shouldn't have to worry about this much import Framework from './framework' +var freq = { + Frequency: 600 +} +var amp = { + Amplitude: 7 +} + +var d = { + Dance: 56 +} + +var o ={ + Orient: 0 +} + +var toggle = false; + +var windspeed = { + WindSpeed: 0 + } + +var scale = { + ScaleFeathers: 1 +} + +var toggle1 = false; + // called after the scene loads function onLoad(framework) { var scene = framework.scene; @@ -36,7 +63,7 @@ function onLoad(framework) { ] ); scene.background = skymap; - + // load a simple obj mesh var objLoader = new THREE.OBJLoader(); objLoader.load('/geo/feather.obj', function(obj) { @@ -44,10 +71,7 @@ function onLoad(framework) { // 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); -// + //base curve var curve = new THREE.CatmullRomCurve3( [ new THREE.Vector3( 0, 0, 0 ), @@ -93,6 +117,40 @@ function onLoad(framework) { //adding the feathures to the scene scene.add(new_fm); + + //------------------------------------------------------------------- + //second feather + var new_fm = new THREE.Mesh(featherGeo, lambertWhite); + new_fm.name = "feather" + i + 30; + var f_pos = curve.getPoint(i / (no_of_feathers_base - 1)); + + + //setting up the feather pos on the curve points + new_fm.position.x = f_pos.x; + new_fm.position.y = f_pos.y; + new_fm.position.z = -f_pos.z; + + //scaling the feathers + new_fm.scale.set(f_pos.x + 1,1,1); + + if(i == no_of_feathers_base - 11) + { + new_fm.rotateY( -(no_of_feathers_base - 11 - i - 1) * 1.5 * 2 * Math.PI / 180); + } + + //rotating the feathers towards the end + if(i >= no_of_feathers_base - 10) + { + //console.log(new_fm.position.z); + //new_fm.position.z = 3.65; + new_fm.rotateY( -(no_of_feathers_base - 10 - i - 1) * 5 * 2 * Math.PI / 180); + } + + //rotating the feathers by a slight value + new_fm.rotateY(8 * Math.PI / 180); + + //adding the feathures to the scene + scene.add(new_fm); } @@ -101,13 +159,13 @@ function onLoad(framework) { for(var i =1; i < no_of_feathers_top1; i++) { var new_fm = new THREE.Mesh(featherGeo, lambertLB); - new_fm.name = "feather" + i + 30; + new_fm.name = "feather" + i + 60; var f_pos = curve.getPoint(i / (no_of_feathers_top1 - 1)); //setting up the feather pos on the curve points new_fm.position.x = f_pos.x; - new_fm.position.y = f_pos.y + 0.065; + new_fm.position.y = f_pos.y + 0.07; new_fm.position.z = f_pos.z + 0.1; //scaling the feathers @@ -132,6 +190,40 @@ function onLoad(framework) { //adding the feathures to the scene scene.add(new_fm); + + //------------------------------------------------------------------- + var new_fm = new THREE.Mesh(featherGeo, lambertLB); + new_fm.name = "feather" + i + 90; + var f_pos = curve.getPoint(i / (no_of_feathers_top1 - 1)); + + + //setting up the feather pos on the curve points + new_fm.position.x = f_pos.x; + new_fm.position.y = f_pos.y + 0.07; + new_fm.position.z = -(f_pos.z + 0.1); + + //scaling the feathers + new_fm.scale.set(f_pos.x + 0.6,1,1); + + if(i == no_of_feathers_top1 - 11) + { + new_fm.rotateY( -(no_of_feathers_top1 - 11 - i - 1) * 1.5 * 2 * Math.PI / 180); + } + + //rotating the feathers towards the end + if(i >= no_of_feathers_top1 - 10) + { + //console.log(new_fm.position.z); + //new_fm.position.z = 3.65; + new_fm.rotateY( -(no_of_feathers_top1 - 10 - i - 1) * 5 * 2 * Math.PI / 180); + } + + + //rotating the feathers by a slight value + new_fm.rotateY(10 * Math.PI / 180); + + //adding the feathures to the scene + scene.add(new_fm); } @@ -140,7 +232,7 @@ function onLoad(framework) { for(var i =1; i < no_of_feathers_top2; i++) { var new_fm = new THREE.Mesh(featherGeo, lambertG); - new_fm.name = "feather" + i + 60; + new_fm.name = "feather" + i + 120; var f_pos = curve.getPoint(i / (no_of_feathers_top2 - 1)); @@ -170,6 +262,41 @@ function onLoad(framework) { //adding the feathures to the scene scene.add(new_fm); + + //------------------------------------------------------------------- + var new_fm = new THREE.Mesh(featherGeo, lambertG); + new_fm.name = "feather" + i + 150; + var f_pos = curve.getPoint(i / (no_of_feathers_top2 - 1)); + + + //setting up the feather pos on the curve points + new_fm.position.x = f_pos.x; + new_fm.position.y = f_pos.y + 0.15; + new_fm.position.z = -(f_pos.z + 0.15); + + //scaling the feathers + new_fm.scale.set(f_pos.x + 0.3,1,1); + + if(i == no_of_feathers_top2 - 11) + { + new_fm.scale.set(0.35,1,1); + new_fm.rotateY( -(no_of_feathers_top2 - 11 - i - 1) * 1.5 * 2 * Math.PI / 180); + } + + //rotating the feathers towards the end + if(i >= no_of_feathers_top2 - 10) + { + new_fm.scale.set(0.4,1,1); + //console.log(new_fm.position.z); + //new_fm.position.z = 3.65; + new_fm.rotateY( -(no_of_feathers_top2 - 10 - i - 1) * 5 * 2 * Math.PI / 180); + } + + + //adding the feathures to the scene + scene.add(new_fm); + + } }); @@ -187,6 +314,34 @@ function onLoad(framework) { gui.add(camera, 'fov', 0, 180).onChange(function(newVal) { camera.updateProjectionMatrix(); }); + + //gui for changing falpping attributes + gui.add(freq, 'Frequency', 10, 1000).onChange(function(newVal1) { + flapping.Frequency = newVal1; + }); + + gui.add(amp, 'Amplitude', 0.001, 10).onChange(function(newVal2) { + flapping.Amplitude = newVal2; + }); + + gui.add(d, 'Dance', 0.01, 200).onChange(function(newVal3) { + d.Dance = newVal3; + }); + + gui.add(o, 'Orient', 0, 360, 1).onChange(function(newVal4) { + o.Orient = newVal4; + toggle = true; + }); + + gui.add(windspeed, 'WindSpeed', 0, 25, 1).onChange(function(newVal5) { + windspeed.WindSpeed = newVal5; + }); + + gui.add(scale, 'ScaleFeathers', 1, 10, 0.5).onChange(function(newVal6) { + scale.ScaleFeathers = newVal6; + toggle1 = true; + }); + } // called on frame updates @@ -198,51 +353,181 @@ function onUpdate(framework) { //feather.rotateZ(Math.sin(date.getTime() / 100) * 2 * Math.PI / 180); } + var frequency = (1000-freq.Frequency); + var amplitude = (10 - amp.Amplitude); + var dance = d.Dance; + var orient = o.Orient; + var windsp = windspeed.WindSpeed; + var scaleF = scale.ScaleFeathers; + //flapping wings!!! for(var i = 1 ;i < 31; i++) { - var base_feather = framework.scene.getObjectByName("feather" + i); - if(base_feather !== undefined){ var date = new Date(); - //base_feather.position.y = Math.sin(date.getTime() * base_feather.position.z * Math.PI / 180); - //base_feather.position.y = base_feather.position.y + (Math.sin(date.getTime() / 100)); //good - //top2_feather.position.y = Math.sin(date.getTime() * top2_feather.position.z * Math.PI / 180); + var val_date = date.getTime(); + + var base_f_ypos = 0; + var top1_f_ypos = 0; + var top2_f_ypos = 0; + + //base feathers---------------------------------------------------------- + //base feather + var base_feather = framework.scene.getObjectByName("feather" + i); + if(base_feather !== undefined){ + + base_feather.position.y = base_feather.position.z * Math.sin(((base_feather.position.z * dance +val_date)/frequency) % 360) / amplitude; + + base_f_ypos = base_feather.position.y; + //X orientation + if(toggle === true){ + base_feather.rotateX(orient); + } - //base_feather.rotateX(Math.sin(date.getTime() / 1000 * base_feather.position.z) * 10 * Math.PI / 180); -// base_feather.position.y = (base_feather.position.y + Math.sin(base_feather.position.z)) + Math.sin(date.getTime() / 10); + //wind effects + //base_feather.rotateX(math.sin(val_date)); + base_feather.position.x = Math.sin( (base_feather.position.x * base_feather.position.z * val_date / 100) % 360) / (30-windsp); + + //feather size + if(toggle1 === true){ + base_feather.scale.set(scaleF, 1, 1); + //base_feather.scale.addScalar(scaleF); + } - //base_feather.rotateX(60*Math.sin(10*date.getTime())); - base_feather.position.y = Math.sin(date.getTime() / 800 * base_feather.position.z) / 10; } + //base feather1 + var base_feather1 = framework.scene.getObjectByName("feather" + i + 30); + if(base_feather1 !== undefined){ + +// base_feather1.position.y = -(base_feather1.position.z * Math.sin(((base_feather1.position.z * dance +val_date)/frequency) % 360) / amplitude); + base_feather1.position.y = base_f_ypos; + + //X orientation + if(toggle === true){ + base_feather1.rotateX(orient); + } + + //wind effects + //base_feather.rotateX(math.sin(val_date)); + base_feather1.position.x = Math.sin( (base_feather1.position.x * base_feather1.position.z * val_date / 100) % 360) / (30-windsp); + + //feather size + if(toggle1 === true){ + base_feather1.scale.set(scaleF, 1, 1); + } + + } - var top1_feather = framework.scene.getObjectByName("feather" + i + 30); + + + //top1 feathers------------------------------------------------------------ + //top1 feathers + var top1_feather = framework.scene.getObjectByName("feather" + i + 60); if(top1_feather !== undefined){ var date = new Date(); - //base_feather.position.y = Math.sin(date.getTime() * base_feather.position.z * Math.PI / 180); - //top1_feather.position.y = top1_feather.position.y + (Math.sin(date.getTime() / 100)); //good - //top2_feather.position.y = Math.sin(date.getTime() * top2_feather.position.z * Math.PI / 180); - - //top1_feather.rotateX(Math.sin(date.getTime() / 1000 * top1_feather.position.z) * 10 * Math.PI / 180); + + top1_feather.position.y = top1_feather.position.z * Math.sin(((top1_feather.position.z * dance +val_date)/frequency) % 360) / amplitude; + + + top1_f_ypos = top1_feather.position.y; + //X orientation + if(toggle === true){ + top1_feather.rotateX(orient); + } + + //wind effects + //base_feather.rotateX(math.sin(val_date)); + top1_feather.position.x = Math.sin( (top1_feather.position.x * top1_feather.position.z * val_date / 100) % 360) / (30 - windsp); + + //feather size + if(toggle1 === true){ + top1_feather.scale.set(scaleF, 1, 1); + } + + } - top1_feather.position.y = Math.sin(date.getTime() / 800 * top1_feather.position.z) / 10; + //top1 feathers1 + var top1_feather1 = framework.scene.getObjectByName("feather" + i + 90); + if(top1_feather1 !== undefined){ + var date = new Date(); + +// top1_feather1.position.y = -(top1_feather1.position.z * Math.sin(((top1_feather1.position.z * dance +val_date)/frequency) % 360) / amplitude); + + top1_feather1.position.y = top1_f_ypos; + + //X orientation + if(toggle === true){ + top1_feather1.rotateX(orient); + } + + //wind effects + //base_feather.rotateX(math.sin(val_date)); + top1_feather1.position.x = Math.sin( (top1_feather1.position.x * top1_feather1.position.z * val_date / 100) % 360) / (30 - windsp); + + //feather size + if(toggle1 === true){ + top1_feather1.scale.set(scaleF, 1, 1); + } + } - var top2_feather = framework.scene.getObjectByName("feather" + i + 60); + + //top2 feathers-------------------------------------------------------------------------- + //top2 feather + var top2_feather = framework.scene.getObjectByName("feather" + i + 120); if(top2_feather !== undefined){ var date = new Date(); - //base_feather.position.y = Math.sin(date.getTime() * base_feather.position.z * Math.PI / 180); - //top2_feather.position.y = top2_feather.position.y + (Math.sin(date.getTime() / 100)); //good - //top2_feather.position.y = Math.sin(date.getTime() * top2_feather.position.z * Math.PI / 180); - - //top2_feather.rotateX(Math.sin(date.getTime() / 1000 * top2_feather.position.z) * 10 * Math.PI / 180); + + top2_feather.position.y = top2_feather.position.z * Math.sin(((top2_feather.position.z * dance +val_date)/frequency) % 360) / amplitude; + + top2_f_ypos = top2_feather.position.y; + + //X orientation + if(toggle === true){ + top2_feather.rotateX(orient); + } + + //wind effects + //base_feather.rotateX(math.sin(val_date)); + top2_feather.position.x = Math.sin( (top2_feather.position.x * top2_feather.position.z * val_date / 100) % 360) / (30 - windsp); + + //feather size + if(toggle1 === true){ + top2_feather.scale.set(scaleF, 1, 1); + } + + } - top2_feather.position.y = Math.sin(date.getTime() / 800 * top2_feather.position.z) / 10; + //top2 feather1 + var top2_feather1 = framework.scene.getObjectByName("feather" + i + 150); + if(top2_feather1 !== undefined){ + var date = new Date(); + +// top2_feather1.position.y = -(top2_feather1.position.z * Math.sin(((top2_feather1.position.z * dance +val_date)/frequency) % 360) / amplitude); + + top2_feather1.position.y = top2_f_ypos; + + //X orientation + if(toggle === true){ + top2_feather1.rotateX(orient); + } + + //wind effects + //base_feather.rotateX(math.sin(val_date)); + top2_feather1.position.x = Math.sin( (top2_feather1.position.x * top2_feather1.position.z * val_date / 100) % 360) / (30 - windsp); + + //feather size + if(toggle1 === true){ + top2_feather1.scale.set(scaleF, 1, 1); + } + } + } - + toggle = false; + toggle1 = false; } // when the scene is done initializing, it will call onLoad, then on frame updates, call onUpdate From ce1a6e220c7c0b104b4ec10bd64e842a129bfec8 Mon Sep 17 00:00:00 2001 From: Rudraksha20 Date: Wed, 1 Feb 2017 00:14:05 -0500 Subject: [PATCH 3/5] commit1 --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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": [ From 5dd9874103502401a0911c30d898f2566670fa1a Mon Sep 17 00:00:00 2001 From: Rudraksha20 Date: Wed, 1 Feb 2017 00:20:21 -0500 Subject: [PATCH 4/5] commit2 --- src/main.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/main.js b/src/main.js index 2a63f6e..b55e974 100755 --- a/src/main.js +++ b/src/main.js @@ -317,11 +317,11 @@ function onLoad(framework) { //gui for changing falpping attributes gui.add(freq, 'Frequency', 10, 1000).onChange(function(newVal1) { - flapping.Frequency = newVal1; + freq.Frequency = newVal1; }); gui.add(amp, 'Amplitude', 0.001, 10).onChange(function(newVal2) { - flapping.Amplitude = newVal2; + amp.Amplitude = newVal2; }); gui.add(d, 'Dance', 0.01, 200).onChange(function(newVal3) { From 8b38de2de8ec6adf0753cdc7d4c9d8d8928e694a Mon Sep 17 00:00:00 2001 From: Rudraksha20 Date: Tue, 7 Feb 2017 18:30:00 -0500 Subject: [PATCH 5/5] commit_for_deploy --- src/main.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/main.js b/src/main.js index b55e974..3c7879e 100755 --- a/src/main.js +++ b/src/main.js @@ -54,7 +54,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', @@ -66,7 +66,7 @@ function onLoad(framework) { // load a simple obj mesh var objLoader = new THREE.OBJLoader(); - objLoader.load('/geo/feather.obj', function(obj) { + objLoader.load('geo/feather.obj', function(obj) { // LOOK: This function runs after the obj has finished loading var featherGeo = obj.children[0].geometry;