mirror of
https://github.com/HifiExperiments/overte.git
synced 2025-08-09 10:19:06 +02:00
cleanup and bug fixes
This commit is contained in:
parent
3dc39600cd
commit
d4bc83f408
4 changed files with 96 additions and 22 deletions
|
@ -1,3 +1,13 @@
|
||||||
|
//
|
||||||
|
// flowers.fs
|
||||||
|
// examples/homeContent/plant
|
||||||
|
//
|
||||||
|
// Created by Eric Levin on 3/7/16.
|
||||||
|
// Copyright 2016 High Fidelity, Inc.
|
||||||
|
//
|
||||||
|
// This fragment shader is designed to shader a sphere to create the effect of a blooming flower
|
||||||
|
// Distributed under the Apache License, Version 2.0.
|
||||||
|
// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html
|
||||||
|
|
||||||
|
|
||||||
#define TWO_PI 6.28318530718
|
#define TWO_PI 6.28318530718
|
||||||
|
|
|
@ -33,6 +33,9 @@
|
||||||
max: 1000
|
max: 1000
|
||||||
};
|
};
|
||||||
_this.canCreateFlower = true;
|
_this.canCreateFlower = true;
|
||||||
|
_this.flowersBloomingSound = SoundCache.getSound("https://s3-us-west-1.amazonaws.com/hifi-content/eric/Sounds/flowersBlooming.wav");
|
||||||
|
_this.soundPlaying = false;
|
||||||
|
_this.BLOOM_VOLUME = 0.4;
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -57,8 +60,16 @@
|
||||||
flower.grow();
|
flower.grow();
|
||||||
});
|
});
|
||||||
|
|
||||||
|
if (!_this.soundPlaying) {
|
||||||
|
_this.position = Entities.getEntityProperties(_this.entityID, "position").position;
|
||||||
|
_this.soundPlaying = true;
|
||||||
|
_this.bloomSoundInjector = Audio.playSound(_this.flowersBloomingSound, {position: _this.position, volume: _this.BLOOM_VOLUME});
|
||||||
|
}
|
||||||
|
},
|
||||||
|
|
||||||
|
stopWatering: function() {
|
||||||
|
_this.bloomSoundInjector.stop();
|
||||||
|
_this.soundPlaying = false;
|
||||||
},
|
},
|
||||||
|
|
||||||
createFlower: function(position, surfaceNormal) {
|
createFlower: function(position, surfaceNormal) {
|
||||||
|
@ -114,8 +125,7 @@
|
||||||
|
|
||||||
preload: function(entityID) {
|
preload: function(entityID) {
|
||||||
_this.entityID = entityID;
|
_this.entityID = entityID;
|
||||||
var SHADER_URL = "file:///C:/Users/Eric/hifi/examples/homeContent/plant/flower.fs"
|
var SHADER_URL = "https://s3-us-west-1.amazonaws.com/hifi-content/eric/shaders/flower.fs?v1";
|
||||||
// var SHADER_URL = "https://s3-us-west-1.amazonaws.com/hifi-content/eric/shaders/flower.fs";
|
|
||||||
_this.flowerUserData = {
|
_this.flowerUserData = {
|
||||||
ProceduralEntity: {
|
ProceduralEntity: {
|
||||||
shaderUrl: SHADER_URL,
|
shaderUrl: SHADER_URL,
|
||||||
|
@ -128,12 +138,10 @@
|
||||||
},
|
},
|
||||||
|
|
||||||
unload: function() {
|
unload: function() {
|
||||||
print("EBL UNLOAD GROWING PLANT SCRIPT");
|
if (_this.bloomSoundInjector) {
|
||||||
// _this.flowers.forEach(function(flower) {
|
_this.bloomSoundInjector.stop();
|
||||||
// Entities.deleteEntity(flower.id);
|
delete _this.bloomSoundInjector;
|
||||||
// })
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
|
@ -18,8 +18,12 @@ orientation = Quat.fromVec3Degrees(orientation);
|
||||||
|
|
||||||
var bowlPosition = Vec3.sum(MyAvatar.position, Vec3.multiply(2, Quat.getFront(orientation)));
|
var bowlPosition = Vec3.sum(MyAvatar.position, Vec3.multiply(2, Quat.getFront(orientation)));
|
||||||
var BOWL_MODEL_URL = "http://hifi-content.s3.amazonaws.com/alan/dev/Flowers--Bowl.fbx";
|
var BOWL_MODEL_URL = "http://hifi-content.s3.amazonaws.com/alan/dev/Flowers--Bowl.fbx";
|
||||||
var bowlDimensions = {x: 0.518, y: 0.1938, z: 0.5518};
|
var bowlDimensions = {
|
||||||
var bowl= Entities.addEntity({
|
x: 0.518,
|
||||||
|
y: 0.1938,
|
||||||
|
z: 0.5518
|
||||||
|
};
|
||||||
|
var bowl = Entities.addEntity({
|
||||||
type: "Model",
|
type: "Model",
|
||||||
modelURL: BOWL_MODEL_URL,
|
modelURL: BOWL_MODEL_URL,
|
||||||
dimensions: bowlDimensions,
|
dimensions: bowlDimensions,
|
||||||
|
@ -30,8 +34,16 @@ var bowl= Entities.addEntity({
|
||||||
|
|
||||||
var PLANT_MODEL_URL = "http://hifi-content.s3.amazonaws.com/alan/dev/Flowers--Moss-Rock.fbx";
|
var PLANT_MODEL_URL = "http://hifi-content.s3.amazonaws.com/alan/dev/Flowers--Moss-Rock.fbx";
|
||||||
var PLANT_SCRIPT_URL = Script.resolvePath("growingPlantEntityScript.js?v1" + Math.random().toFixed(2));
|
var PLANT_SCRIPT_URL = Script.resolvePath("growingPlantEntityScript.js?v1" + Math.random().toFixed(2));
|
||||||
var plantDimensions = {x: 0.52, y: 0.2600, z: 0.52};
|
var plantDimensions = {
|
||||||
var plantPosition = Vec3.sum(bowlPosition, {x: 0, y: plantDimensions.y/2, z: 0});
|
x: 0.52,
|
||||||
|
y: 0.2600,
|
||||||
|
z: 0.52
|
||||||
|
};
|
||||||
|
var plantPosition = Vec3.sum(bowlPosition, {
|
||||||
|
x: 0,
|
||||||
|
y: plantDimensions.y / 2,
|
||||||
|
z: 0
|
||||||
|
});
|
||||||
var plant = Entities.addEntity({
|
var plant = Entities.addEntity({
|
||||||
type: "Model",
|
type: "Model",
|
||||||
modelURL: PLANT_MODEL_URL,
|
modelURL: PLANT_MODEL_URL,
|
||||||
|
@ -52,12 +64,46 @@ var waterCan = Entities.addEntity({
|
||||||
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,
|
||||||
dimensions: {x: 0.1859, y: 0.2762, z: 0.4115},
|
dimensions: {
|
||||||
|
x: 0.1859,
|
||||||
|
y: 0.2762,
|
||||||
|
z: 0.4115
|
||||||
|
},
|
||||||
position: waterCanPosition,
|
position: waterCanPosition,
|
||||||
angularDamping: 1,
|
angularDamping: 1,
|
||||||
dynamic: true,
|
dynamic: true,
|
||||||
gravity: { x: 0.0, y: -2.0, z: 0},
|
gravity: {
|
||||||
rotation: waterCanRotation
|
x: 0.0,
|
||||||
|
y: -2.0,
|
||||||
|
z: 0
|
||||||
|
},
|
||||||
|
rotation: waterCanRotation,
|
||||||
|
userData: JSON.stringify({
|
||||||
|
wearable: {
|
||||||
|
joints: {
|
||||||
|
RightHand: [{
|
||||||
|
x: 0.024,
|
||||||
|
y: 0.173,
|
||||||
|
z: 0.152
|
||||||
|
}, {
|
||||||
|
x: 0.374,
|
||||||
|
y: 0.636,
|
||||||
|
z: -0.638,
|
||||||
|
w: -0.215
|
||||||
|
}],
|
||||||
|
LeftHand: [{
|
||||||
|
x: -0.0348,
|
||||||
|
y: 0.201,
|
||||||
|
z: 0.166
|
||||||
|
}, {
|
||||||
|
x: 0.4095,
|
||||||
|
y: -0.625,
|
||||||
|
z: 0.616,
|
||||||
|
w: -0.247
|
||||||
|
}]
|
||||||
|
}
|
||||||
|
}
|
||||||
|
})
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
||||||
|
@ -66,8 +112,16 @@ var waterSpoutRotation = Quat.multiply(waterCanRotation, Quat.fromPitchYawRollDe
|
||||||
var waterSpout = Entities.addEntity({
|
var waterSpout = Entities.addEntity({
|
||||||
type: "Box",
|
type: "Box",
|
||||||
name: "hifi-water-spout",
|
name: "hifi-water-spout",
|
||||||
dimensions: {x: 0.02, y: 0.02, z: 0.07},
|
dimensions: {
|
||||||
color: {red: 200, green: 10, blue: 200},
|
x: 0.02,
|
||||||
|
y: 0.02,
|
||||||
|
z: 0.07
|
||||||
|
},
|
||||||
|
color: {
|
||||||
|
red: 200,
|
||||||
|
green: 10,
|
||||||
|
blue: 200
|
||||||
|
},
|
||||||
position: waterSpoutPosition,
|
position: waterSpoutPosition,
|
||||||
rotation: waterSpoutRotation,
|
rotation: waterSpoutRotation,
|
||||||
parentID: waterCan,
|
parentID: waterCan,
|
||||||
|
|
|
@ -37,7 +37,6 @@
|
||||||
|
|
||||||
startHold: function() {
|
startHold: function() {
|
||||||
_this.findGrowableEntities();
|
_this.findGrowableEntities();
|
||||||
print("EB: GROWABLE ENTITIES length " + _this.growableEntities.length)
|
|
||||||
},
|
},
|
||||||
|
|
||||||
releaseEquip: function() {
|
releaseEquip: function() {
|
||||||
|
@ -58,7 +57,10 @@
|
||||||
});
|
});
|
||||||
_this.waterPouring = false;
|
_this.waterPouring = false;
|
||||||
//water no longer pouring...
|
//water no longer pouring...
|
||||||
_this.waterInjector.stop();
|
if (_this.waterInjector) {
|
||||||
|
_this.waterInjector.stop();
|
||||||
|
}
|
||||||
|
Entities.callEntityMethod(_this.mostRecentIntersectedGrowableEntity, 'stopWatering');
|
||||||
},
|
},
|
||||||
continueEquip: function() {
|
continueEquip: function() {
|
||||||
_this.continueHolding();
|
_this.continueHolding();
|
||||||
|
@ -85,7 +87,6 @@
|
||||||
});
|
});
|
||||||
_this.waterPouring = true;
|
_this.waterPouring = true;
|
||||||
if (!_this.waterInjector) {
|
if (!_this.waterInjector) {
|
||||||
print("PLAY SOUND")
|
|
||||||
_this.waterInjector = Audio.playSound(_this.waterSound, {
|
_this.waterInjector = Audio.playSound(_this.waterSound, {
|
||||||
position: spoutProps.position,
|
position: spoutProps.position,
|
||||||
loop: true
|
loop: true
|
||||||
|
@ -122,6 +123,7 @@
|
||||||
position: intersection.intersection,
|
position: intersection.intersection,
|
||||||
surfaceNormal: intersection.surfaceNormal
|
surfaceNormal: intersection.surfaceNormal
|
||||||
});
|
});
|
||||||
|
_this.mostRecentIntersectedGrowableEntity = intersection.entityID;
|
||||||
Entities.callEntityMethod(intersection.entityID, 'continueWatering', [data]);
|
Entities.callEntityMethod(intersection.entityID, 'continueWatering', [data]);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -184,7 +186,7 @@
|
||||||
alpha: 1.0,
|
alpha: 1.0,
|
||||||
alphaFinish: 1.0,
|
alphaFinish: 1.0,
|
||||||
emitterShouldTrail: true,
|
emitterShouldTrail: true,
|
||||||
textures: "https://s3-us-west-1.amazonaws.com/hifi-content/eric/images/raindrop.png?v2",
|
textures: "https://s3-us-west-1.amazonaws.com/hifi-content/eric/images/raindrop.png",
|
||||||
});
|
});
|
||||||
|
|
||||||
},
|
},
|
||||||
|
|
Loading…
Reference in a new issue