growing flowers faster

This commit is contained in:
ericrius1 2016-03-31 15:10:43 -07:00
parent 4cf5f41eed
commit aead16da89
5 changed files with 94 additions and 84 deletions

View file

@ -32,5 +32,5 @@ function createTidyGuy() {
var tidyGuy = createTidyGuy(); var tidyGuy = createTidyGuy();
Script.scriptEnding.connect(function() { Script.scriptEnding.connect(function() {
// Entities.deleteEntity(tidyGuy); Entities.deleteEntity(tidyGuy);
}) })

View file

@ -19,7 +19,6 @@
function GrowingPlant() { function GrowingPlant() {
_this = this; _this = this;
_this.flowers = []; _this.flowers = [];
// _this.STARTING_FLOWER_DIMENSIONS = {x: 0.1, y: 0.001, z: 0.1}
_this.STARTING_FLOWER_DIMENSIONS = { _this.STARTING_FLOWER_DIMENSIONS = {
x: 0.001, x: 0.001,
y: 0.001, y: 0.001,
@ -34,9 +33,9 @@
max: 1000 max: 1000
}; };
_this.canCreateFlower = true; _this.canCreateFlower = true;
// _this.SHADER_URL = "https://s3-us-west-1.amazonaws.com/hifi-content/eric/shaders/flower.fs"; // _this.SHADER_URL = "atp:/shaders/flower.fs";
_this.SHADER_URL = "atp:/shaders/flower.fs"; // EBL REMOVE ME
// _this.SHADER_URL = "file:///C:/Users/Eric/hifi/unpublishedScripts/DomainContent/Home/plant/flower.fs"; _this.SHADER_URL = Script.resolvePath("flower.fs");
_this.flowerHSLColors = [{ _this.flowerHSLColors = [{
hue: 19 / 360, hue: 19 / 360,
@ -77,10 +76,10 @@
// Reduces flower overlap // Reduces flower overlap
return; return;
} }
var xzGrowthRate = randFloat(0.00006, 0.00016); var xzGrowthRate = randFloat(0.0009, 0.0026);
var growthRate = { var growthRate = {
x: xzGrowthRate, x: xzGrowthRate,
y: randFloat(0.001, 0.003), y: randFloat(0.01, 0.03),
z: xzGrowthRate z: xzGrowthRate
}; };
@ -92,17 +91,7 @@
}, },
startingPosition: position, startingPosition: position,
rotation: Quat.rotationBetween(Vec3.UNIT_Y, surfaceNormal), rotation: Quat.rotationBetween(Vec3.UNIT_Y, surfaceNormal),
maxYDimension: randFloat(0.4, 1.1), maxYDimension: randFloat(0.8, 1.7),
// startingHSLColor: {
// hue: 80 / 360,
// saturation: 0.47,
// light: 0.48
// },
// endingHSLColor: {
// hue: 19 / 260,
// saturation: 0.92,
// light: 0.41
// },
hslColor: Math.random() < 0.5 ? _this.flowerHSLColors[0] : _this.flowerHSLColors[1], hslColor: Math.random() < 0.5 ? _this.flowerHSLColors[0] : _this.flowerHSLColors[1],
growthRate: growthRate growthRate: growthRate
}; };
@ -121,7 +110,7 @@
}; };
flower.id = Entities.addEntity({ flower.id = Entities.addEntity({
type: "Sphere", type: "Sphere",
name: "flower", name: "home-sphere-flower",
lifetime: 3600, lifetime: 3600,
position: position, position: position,
collisionless: true, collisionless: true,
@ -136,12 +125,6 @@
} }
flower.dimensions = Vec3.sum(flower.dimensions, flower.growthRate); flower.dimensions = Vec3.sum(flower.dimensions, flower.growthRate);
flower.position = Vec3.sum(flower.startingPosition, Vec3.multiply(Quat.getUp(flower.rotation), flower.dimensions.y / 2)); flower.position = Vec3.sum(flower.startingPosition, Vec3.multiply(Quat.getUp(flower.rotation), flower.dimensions.y / 2));
//As we grow we must also move ourselves in direction we grow!
//TODO: Add this color changing back once we fix bug https://app.asana.com/0/inbox/31759584831096/96943843100173/98022172055918
// var newHue = map(flower.dimensions.y, _this.STARTING_FLOWER_DIMENSIONS.y, flower.maxYDimension, flower.startingHSLColor.hue, flower.endingHSLColor.hue);
// var newSaturation = map(flower.dimensions.y, _this.STARTING_FLOWER_DIMENSIONS.y, flower.maxYDimension, flower.startingHSLColor.saturation, flower.endingHSLColor.saturation);
// var newLight = map(flower.dimensions.y, _this.STARTING_FLOWER_DIMENSIONS.y, flower.maxYDimension, flower.startingHSLColor.light, flower.endingHSLColor.light);
// flower.userData.PrsoceduralEntity.uniforms.iHSLColor = [newHue, newSaturation, newLight];
Entities.editEntity(flower.id, { Entities.editEntity(flower.id, {
dimensions: flower.dimensions, dimensions: flower.dimensions,
position: flower.position, position: flower.position,
@ -155,6 +138,12 @@
_this.entityID = entityID; _this.entityID = entityID;
}, },
unload: function() {
_this.flowers.forEach(function(flower) {
Entities.deleteEntity(flower.id);
});
}
}; };
// entity scripts always need to return a newly constructed object of our type // entity scripts always need to return a newly constructed object of our type

View file

@ -91,12 +91,12 @@
return; return;
} }
// Check rotation of water can along it's z axis. If it's beyond a threshold, then start spraying water // Check rotation of water can along it's z axis. If it's beyond a threshold, then start spraying water
_this.castRay();
var rotation = Entities.getEntityProperties(_this.entityID, "rotation").rotation; var rotation = Entities.getEntityProperties(_this.entityID, "rotation").rotation;
var pitch = Quat.safeEulerAngles(rotation).x; var pitch = Quat.safeEulerAngles(rotation).x;
if (pitch < _this.POUR_ANGLE_THRESHOLD) { if (pitch < _this.POUR_ANGLE_THRESHOLD) {
// Water is pouring // Water is pouring
var spoutProps = Entities.getEntityProperties(_this.waterSpout, ["rotation", "position"]); var spoutProps = Entities.getEntityProperties(_this.waterSpout, ["rotation", "position"]);
_this.castRay();
if (!_this.waterPouring) { if (!_this.waterPouring) {
Entities.editEntity(_this.waterEffect, { Entities.editEntity(_this.waterEffect, {
isEmitting: true isEmitting: true
@ -201,7 +201,9 @@
alpha: 1.0, alpha: 1.0,
alphaFinish: 1.0, alphaFinish: 1.0,
emitterShouldTrail: true, emitterShouldTrail: true,
textures: "atp:/growingPlant/raindrop.png", // textures: "atp:/growingPlant/raindrop.png",
//EBL REMOVE ME
textures: "https://s3-us-west-1.amazonaws.com/hifi-content/eric/images/raindrop.png",
userData: JSON.stringify({ userData: JSON.stringify({
'hifiHomeKey': { 'hifiHomeKey': {
'reset': true 'reset': true

View file

@ -9,8 +9,14 @@
// Distributed under the Apache License, Version 2.0. // Distributed under the Apache License, Version 2.0.
// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html // See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html
// //
var PLANT_SCRIPT_URL = Script.resolvePath("atp:/growingPlant/growingPlantEntityScript.js");
var WATER_CAN_SCRIPT_URL = Script.resolvePath("atp:/growingPlant/waterCanEntityScript.js"); //
// var PLANT_SCRIPT_URL = Script.resolvePath("atp:/growingPlant/growingPlantEntityScript.js");
// var WATER_CAN_SCRIPT_URL = Script.resolvePath("atp:/growingPlant/waterCanEntityScript.js");
//EBL REMOVE ME
var PLANT_SCRIPT_URL = Script.resolvePath("growingPlantEntityScript.js");
var WATER_CAN_SCRIPT_URL = Script.resolvePath("waterCanEntityScript.js");
Plant = function(spawnPosition, spawnRotation) { Plant = function(spawnPosition, spawnRotation) {
print("EBL PLANT CONSTRUCTOR!") print("EBL PLANT CONSTRUCTOR!")
var orientation; var orientation;
@ -21,8 +27,11 @@ Plant = function(spawnPosition, spawnRotation) {
} }
print("EBL ORIENTATION " + JSON.stringify(orientation)); print("EBL ORIENTATION " + JSON.stringify(orientation));
var bowlPosition = spawnPosition; var bowlPosition = spawnPosition;
var BOWL_MODEL_URL = "atp:/growingPlant/Flowers-Bowl.fbx"; // var BOWL_MODEL_URL = "atp:/growingPlant/Flowers-Bowl.fbx";
var BOWL_COLLISION_HULL_URL = "atp:/growingPlant/bowl.obj"; var BOWL_COLLISION_HULL_URL = "atp:/growingPlant/bowl.obj";
//EBL REMOVE ME
var BOWL_MODEL_URL = "http://hifi-content.s3.amazonaws.com/alan/dev/Flowers--Bowl.fbx";
var bowlDimensions = { var bowlDimensions = {
x: 0.518, x: 0.518,
y: 0.1938, y: 0.1938,
@ -32,9 +41,9 @@ Plant = function(spawnPosition, spawnRotation) {
type: "Model", type: "Model",
modelURL: BOWL_MODEL_URL, modelURL: BOWL_MODEL_URL,
dimensions: bowlDimensions, dimensions: bowlDimensions,
dynamic: true, // dynamic: true,
shapeType: 'compound', shapeType: 'box',
compundShapeURL: BOWL_COLLISION_HULL_URL, // compoundShapeURL: BOWL_COLLISION_HULL_URL,
name: "plant bowl", name: "plant bowl",
position: bowlPosition, position: bowlPosition,
userData: JSON.stringify({ userData: JSON.stringify({
@ -46,8 +55,9 @@ Plant = function(spawnPosition, spawnRotation) {
var PLANT_MODEL_URL = "atp:/growingPlant/Flowers-Rock.fbx"; //var PLANT_MODEL_URL = "atp:/growingPlant/Flowers-Rock.fbx";
//EBL REMOVE ME
var PLANT_MODEL_URL = "http://hifi-content.s3.amazonaws.com/alan/dev/Flowers--Moss-Rock.fbx";
var plantDimensions = { var plantDimensions = {
x: 0.52, x: 0.52,
y: 0.2600, y: 0.2600,
@ -74,14 +84,16 @@ Plant = function(spawnPosition, spawnRotation) {
}); });
var WATER_CAN_MODEL_URL = "atp:/growingPlant/waterCan.fbx"; // var WATER_CAN_MODEL_URL = "atp:/growingPlant/waterCan.fbx";
// EBL REMOVE ME
var WATER_CAN_MODEL_URL = "https://s3-us-west-1.amazonaws.com/hifi-content/eric/models/waterCan.fbx?v1" + Math.random();
var WATER_CAN_COLLIISION_HULL_URL = "atp:/growingPlant/can.obj"; var WATER_CAN_COLLIISION_HULL_URL = "atp:/growingPlant/can.obj";
var waterCanPosition = Vec3.sum(plantPosition, Vec3.multiply(0.6, Quat.getRight(orientation))); var waterCanPosition = Vec3.sum(plantPosition, Vec3.multiply(0.6, Quat.getRight(orientation)));
var waterCanRotation = orientation; var waterCanRotation = orientation;
var waterCan = Entities.addEntity({ var waterCan = Entities.addEntity({
type: "Model", type: "Model",
shapeType: 'compound', shapeType: 'box',
compundShapeURL: WATER_CAN_COLLIISION_HULL_URL, // compoundShapeURL: WATER_CAN_COLLIISION_HULL_URL,
name: "hifi-water-can", name: "hifi-water-can",
modelURL: WATER_CAN_MODEL_URL, modelURL: WATER_CAN_MODEL_URL,
script: WATER_CAN_SCRIPT_URL, script: WATER_CAN_SCRIPT_URL,

View file

@ -28,7 +28,11 @@
var whiteboardPath = Script.resolvePath("atp:/whiteboard/wrapper.js"); var whiteboardPath = Script.resolvePath("atp:/whiteboard/wrapper.js");
var plantPath = Script.resolvePath("atp:/growingPlant/wrapper.js"); // var plantPath = Script.resolvePath("atp:/growingPlant/wrapper.js");
//EBL REMOVE ME
var myPlant;
var plantPath = Script.resolvePath("growingPlant/wrapper.js?v1" + Math.random());
var cuckooClockPath = Script.resolvePath("atp:/cuckooClock/wrapper.js"); var cuckooClockPath = Script.resolvePath("atp:/cuckooClock/wrapper.js");
@ -109,16 +113,16 @@
_this.showTidyingButton(); _this.showTidyingButton();
_this.playTidyingSound(); _this.playTidyingSound();
_this.findAndDeleteHomeEntities(); // _this.findAndDeleteHomeEntities();
Script.setTimeout(function() { Script.setTimeout(function() {
_this.showTidyButton(); _this.showTidyButton();
_this.tidying = false; _this.tidying = false;
}, 2500); }, 2500);
Script.setTimeout(function() { Script.setTimeout(function() {
_this.createKineticEntities(); // _this.createKineticEntities();
_this.createDynamicEntities(); _this.createDynamicEntities();
_this.setupDressingRoom(); // _this.setupDressingRoom();
}, 750) }, 750)
@ -138,33 +142,33 @@
}, },
createDynamicEntities: function() { createDynamicEntities: function() {
var fishTank = new FishTank({ // var fishTank = new FishTank({
x: 1099.2200, // x: 1099.2200,
y: 460.5460, // y: 460.5460,
z: -78.2363 // z: -78.2363
}, { // }, {
x: 0, // x: 0,
y: 0, // y: 0,
z: 0 // z: 0
}); // });
var tiltMaze = new TiltMaze({ // var tiltMaze = new TiltMaze({
x: 1105.5768, // x: 1105.5768,
y: 460.3298, // y: 460.3298,
z: -80.4891 // z: -80.4891
}); // });
var whiteboard = new Whiteboard({ // var whiteboard = new Whiteboard({
x: 1104, // x: 1104,
y: 460.5, // y: 460.5,
z: -77 // z: -77
}, { // }, {
x: 0, // x: 0,
y: -133, // y: -133,
z: 0 // z: 0
}); // });
var myPlant = new Plant({ myPlant = new Plant({
x: 1099.8785, x: 1099.8785,
y: 460.3115, y: 460.3115,
z: -84.7736 z: -84.7736
@ -174,24 +178,24 @@
z: 0 z: 0
}); });
var pingPongGun = new HomePingPongGun({ // var pingPongGun = new HomePingPongGun({
x: 1101.2123, // x: 1101.2123,
y: 460.2328, // y: 460.2328,
z: -65.8513 // z: -65.8513
}, { // }, {
x: 97.3683, // x: 97.3683,
y: 179.0293, // y: 179.0293,
z: 89.9698 // z: 89.9698
}); // });
var cuckooClock = new MyCuckooClock({ // var cuckooClock = new MyCuckooClock({
x: 1105.267, // x: 1105.267,
y: 461.44, // y: 461.44,
z: -81.9495 // z: -81.9495
}, { // }, {
x: 0, // x: 0,
y: -57, // y: -57,
z: 0 // z: 0
}); // });
//v2.0 //v2.0
// var musicBox = new MusicBox(); // var musicBox = new MusicBox();
@ -457,6 +461,9 @@
unload: function() { unload: function() {
// this.findAndDeleteHomeEntities(); // this.findAndDeleteHomeEntities();
//REMOVE ME
myPlant.cleanup();
} }
} }