From 11047f676b0bff4853fae4d3ce77d97ac3c298df Mon Sep 17 00:00:00 2001 From: ericrius1 Date: Fri, 12 Feb 2016 13:58:12 -0800 Subject: [PATCH] stable --- .../plant/growingPlantEntityScript.js | 55 +++++++++++++++++-- .../homeContent/plant/growingPlantSpawner.js | 1 + 2 files changed, 51 insertions(+), 5 deletions(-) diff --git a/examples/homeContent/plant/growingPlantEntityScript.js b/examples/homeContent/plant/growingPlantEntityScript.js index 33ffadbaeb..c0775caaad 100644 --- a/examples/homeContent/plant/growingPlantEntityScript.js +++ b/examples/homeContent/plant/growingPlantEntityScript.js @@ -24,9 +24,51 @@ GrowingPlant.prototype = { createFlowers: function() { - for(var i = 0; i < 3; i++) { - _this.createFlower(); - } + for (var i = 0; i < 3; i++) { + _this.createFlower(); + } + }, + + createCactus: function() { + var MODEL_URL = "file:///C:/Users/Eric/Desktop/cactus.fbx?v1" + Math.random(); + var dimensions = { + x: 0.09, + y: 0.01, + z: 0.09 + }; + _this.cactus = Entities.addEntity({ + type: "Model", + modelURL: MODEL_URL, + position: _this.position, + dimensions: dimensions + }); + + var curProps = { + yDimension: 0.01, + yPosition: _this.position.y + }; + + var endProps = { + yDimension: 0.8, + yPosition: _this.position.y + 0.4 + }; + + var growTween = new TWEEN.Tween(curProps). + to(endProps, 2000). + onUpdate(function() { + Entities.editEntity(_this.cactus, { + dimensions: { + x: dimensions.x, + y: curProps.yDimension, + z: dimensions.z + }, + position: { + x: _this.position.x, + y: curProps.yPosition, + z: _this.position.z + } + }); + }).start(); }, createFlower: function() { @@ -39,7 +81,7 @@ ProceduralEntity: { shaderUrl: "file:///C:/Users/Eric/hifi/examples/homeContent/plant/flower.fs", uniforms: { - iBloomPct: 0.0 + iBloomPct: 0.5 } } }; @@ -64,7 +106,7 @@ var curProps = { yDimension: startingFlowerDimensions.y, yPosition: startingFlowerPosition.y, - bloomPct: flowerUserData.ProceduralEntity.uniforms.iBloomPct + bloomPct: flowerUserData.ProceduralEntity.uniforms.iBloomPct }; var newYDimension = curProps.yDimension + 1; var endProps = { @@ -101,7 +143,9 @@ this.props = Entities.getEntityProperties(this.entityID, ["position", "dimensions"]); this.position = this.props.position; this.dimensions = this.props.dimensions; + this.createCactus(); this.createFlowers(); + // this.createFlower(); Script.update.connect(_this.update); }, @@ -111,6 +155,7 @@ unload: function() { Script.update.disconnect(_this.update); + Entities.deleteEntity(_this.cactus); _this.flowers.forEach(function(flower) { Entities.deleteEntity(flower); }); diff --git a/examples/homeContent/plant/growingPlantSpawner.js b/examples/homeContent/plant/growingPlantSpawner.js index b138d2f894..6f7b7633eb 100644 --- a/examples/homeContent/plant/growingPlantSpawner.js +++ b/examples/homeContent/plant/growingPlantSpawner.js @@ -32,6 +32,7 @@ function initializePlant() { Script.setTimeout(function() { var naturalDimensions = Entities.getEntityProperties(pot, "naturalDimensions").naturalDimensions; Entities.editEntity(pot, {dimensions: naturalDimensions, script: SCRIPT_URL}); + // Entities.editEntity(pot, {dimensions: naturalDimensions}); }, 100); }