This commit is contained in:
ericrius1 2016-02-12 13:58:12 -08:00
parent 4c3e3538e8
commit 11047f676b
2 changed files with 51 additions and 5 deletions

View file

@ -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);
});

View file

@ -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);
}