plant stuffs

This commit is contained in:
James B. Pollack 2016-03-30 13:02:46 -07:00
parent b15e182e80
commit 12f8d83a6f
2 changed files with 23 additions and 16 deletions

View file

@ -18,7 +18,7 @@
function WaterSpout() { function WaterSpout() {
_this = this; _this = this;
_this.waterSound = SoundCache.getSound("atp:/sounds/watering_can_pour.L.wav"); _this.waterSound = SoundCache.getSound("atp:/growingPlant/watering_can_pour.L.wav");
_this.POUR_ANGLE_THRESHOLD = 0; _this.POUR_ANGLE_THRESHOLD = 0;
_this.waterPouring = false; _this.waterPouring = false;
_this.WATER_SPOUT_NAME = "hifi-water-spout"; _this.WATER_SPOUT_NAME = "hifi-water-spout";
@ -37,17 +37,21 @@
}, },
startHold: function() { startHold: function() {
if (_this.waterSpout) { var entities = Entities.findEntities(_this.position, 2);
_this.waterSpoutPosition = Entities.getEntityProperties(_this.waterSpout, "position").position; print("EBL SEARCHING FOR SPOUT");
_this.waterSpoutRotation = Entities.getEntityProperties(_this.waterSpout, "rotation").rotation; entities.forEach(function(entity) {
_this.createWaterEffect(); var name = Entities.getEntityProperties(entity, "name").name;
} else { if (name === _this.WATER_SPOUT_NAME) {
print("EBL NO WATER SPOUT FOUND RETURNING"); print("EBL FOUND SPOUT");
return; _this.waterSpout = entity;
} _this.waterSpoutPosition = Entities.getEntityProperties(_this.waterSpout, "position").position;
_this.waterSpoutRotation = Entities.getEntityProperties(_this.waterSpout, "rotation").rotation;
_this.createWaterEffect();
}
});
_this.findGrowableEntities(); _this.findGrowableEntities();
}, },
releaseEquip: function() { releaseEquip: function() {
_this.releaseHold(); _this.releaseHold();
}, },
@ -220,14 +224,17 @@
}, },
preload: function(entityID) { preload: function(entityID) {
print("EBL PRELOADING WATER CAN")
_this.entityID = entityID; _this.entityID = entityID;
_this.position = Entities.getEntityProperties(_this.entityID, "position").position; _this.position = Entities.getEntityProperties(_this.entityID, "position").position;
// Wait a a bit for spout to spawn for case where preload is initial spawn, then save it // Wait a a bit for spout to spawn for case where preload is initial spawn, then save it
Script.setTimeout(function() { Script.setTimeout(function() {
var entities = Entities.findEntities(_this.position, 2); var entities = Entities.findEntities(_this.position, 2);
print("EBL SEARCHING FOR SPOUT");
entities.forEach(function(entity) { entities.forEach(function(entity) {
var name = Entities.getEntityProperties(entity, "name").name; var name = Entities.getEntityProperties(entity, "name").name;
if (name === _this.WATER_SPOUT_NAME) { if (name === _this.WATER_SPOUT_NAME) {
print("EBL FOUND SPOUT");
_this.waterSpout = entity; _this.waterSpout = entity;
} }
}); });

View file

@ -9,8 +9,8 @@
// 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:/scripts/growingPlantEntityScript.js"); var PLANT_SCRIPT_URL = Script.resolvePath("atp:/growingPlant/growingPlantEntityScript.js");
var WATER_CAN_SCRIPT_URL = Script.resolvePath("atp:/scripts/waterCanEntityScript.js"); var WATER_CAN_SCRIPT_URL = Script.resolvePath("atp:/growingPlant/waterCanEntityScript.js");
Plant = function(spawnPosition, spawnRotation) { Plant = function(spawnPosition, spawnRotation) {
var orientation; var orientation;
if (spawnRotation !== undefined) { if (spawnRotation !== undefined) {
@ -20,7 +20,7 @@ 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:/models/Flowers-Bowl.fbx"; var BOWL_MODEL_URL = "atp:/growingPlant/Flowers-Bowl.fbx";
var bowlDimensions = { var bowlDimensions = {
x: 0.518, x: 0.518,
y: 0.1938, y: 0.1938,
@ -40,7 +40,7 @@ Plant = function(spawnPosition, spawnRotation) {
}); });
var PLANT_MODEL_URL = "atp:/models/Flowers-Rock.fbx"; var PLANT_MODEL_URL = "atp:/growingPlant/Flowers-Rock.fbx";
var plantDimensions = { var plantDimensions = {
x: 0.52, x: 0.52,
@ -68,7 +68,7 @@ Plant = function(spawnPosition, spawnRotation) {
}); });
var WATER_CAN_MODEL_URL = "atp:/models/waterCan.fbx"; var WATER_CAN_MODEL_URL = "atp:/growingPlant/waterCan.fbx";
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;
@ -84,7 +84,7 @@ Plant = function(spawnPosition, spawnRotation) {
z: 0.4115 z: 0.4115
}, },
position: waterCanPosition, position: waterCanPosition,
collisionSoundURL: "atp:/sounds/watering_can_drop.L.wav", collisionSoundURL: "atp:/growingPlant/watering_can_drop.L.wav",
angularDamping: 1, angularDamping: 1,
dynamic: true, dynamic: true,
gravity: { gravity: {