mirror of
https://github.com/overte-org/overte.git
synced 2025-06-05 12:21:05 +02:00
cast ray from spout in its direction
This commit is contained in:
parent
03ae48d465
commit
b301b71c7d
2 changed files with 42 additions and 15 deletions
|
@ -60,12 +60,14 @@ var waterCan = Entities.addEntity({
|
|||
|
||||
|
||||
var waterSpoutPosition = Vec3.sum(waterCanPosition, Vec3.multiply(0.2, Quat.getFront(orientation)))
|
||||
var waterSpoutRotation = Quat.multiply(waterCanRotation, Quat.fromPitchYawRollDegrees(30, 0, 0));
|
||||
var waterSpout = Entities.addEntity({
|
||||
type: "Box",
|
||||
name: "hifi-water-spout",
|
||||
dimensions: {x: 0.02, y: 0.02, z: 0.07},
|
||||
color: {red: 200, green: 10, blue: 200},
|
||||
position: waterSpoutPosition,
|
||||
rotation: waterCanRotation,
|
||||
rotation: waterSpoutRotation,
|
||||
parentID: waterCan
|
||||
});
|
||||
|
||||
|
|
|
@ -20,6 +20,7 @@
|
|||
_this.waterSound = SoundCache.getSound("https://s3-us-west-1.amazonaws.com/hifi-content/eric/Sounds/shower.wav");
|
||||
_this.POUR_ANGLE_THRESHOLD = -30;
|
||||
_this.waterPouring = false;
|
||||
_this.WATER_SPOUT_NAME = "hifi-water-spout";
|
||||
|
||||
};
|
||||
|
||||
|
@ -33,6 +34,9 @@
|
|||
},
|
||||
|
||||
continueHolding: function() {
|
||||
if (!_this.waterSpout) {
|
||||
return;
|
||||
}
|
||||
// Check rotation of water can along it's z axis. If it's beyond a threshold, then start spraying water
|
||||
var rotation = Entities.getEntityProperties(_this.entityID, "rotation").rotation;
|
||||
var pitch = Quat.safeEulerAngles(rotation).x;
|
||||
|
@ -43,7 +47,7 @@
|
|||
Entities.editEntity(_this.waterEffect, {isEmitting: false});
|
||||
_this.waterPouring = false;
|
||||
}
|
||||
print("PITCH " + pitch);
|
||||
// print("PITCH " + pitch);
|
||||
},
|
||||
|
||||
|
||||
|
@ -52,8 +56,9 @@
|
|||
_this.waterEffect = Entities.addEntity({
|
||||
type: "ParticleEffect",
|
||||
name: "water particle effect",
|
||||
position: _this.waterSpoutPosition,
|
||||
isEmitting: false,
|
||||
position: _this.position,
|
||||
parentID: _this.waterSpout,
|
||||
colorStart: {
|
||||
red: 50,
|
||||
green: 50,
|
||||
|
@ -70,27 +75,28 @@
|
|||
blue: 60
|
||||
},
|
||||
maxParticles: 20000,
|
||||
lifespan: 10,
|
||||
emitRate: 10000,
|
||||
emitSpeed: .1,
|
||||
lifespan: 2,
|
||||
emitRate: 1000,
|
||||
emitSpeed: .2,
|
||||
speedSpread: 0.0,
|
||||
emitDimensions: {
|
||||
x: 0.1,
|
||||
y: 0.01,
|
||||
z: 0.1
|
||||
x: 0,
|
||||
y: 0,
|
||||
z: 0
|
||||
},
|
||||
emitAcceleration: {
|
||||
x: 0.0,
|
||||
y: -1.0,
|
||||
y: 0,
|
||||
z: 0
|
||||
},
|
||||
polarStart: 0,
|
||||
polarFinish: Math.PI,
|
||||
polarFinish: .2,
|
||||
accelerationSpread: {
|
||||
x: 0.1,
|
||||
x: 0.01,
|
||||
y: 0.0,
|
||||
z: 0.1
|
||||
z: 0.01
|
||||
},
|
||||
emitOrientation: _this.waterSpoutRotation,
|
||||
particleRadius: 0.04,
|
||||
radiusSpread: 0.01,
|
||||
radiusStart: 0.03,
|
||||
|
@ -98,7 +104,8 @@
|
|||
alphaSpread: .1,
|
||||
alphaStart: 0.7,
|
||||
alphaFinish: 0.5,
|
||||
textures: "https://s3-us-west-1.amazonaws.com/hifi-content/eric/images/raindrop.png",
|
||||
emitterShouldTrail: true,
|
||||
textures: "https://s3-us-west-1.amazonaws.com/hifi-content/eric/images/raindrop.png?v2",
|
||||
});
|
||||
|
||||
},
|
||||
|
@ -106,7 +113,25 @@
|
|||
preload: function(entityID) {
|
||||
_this.entityID = entityID;
|
||||
_this.position = Entities.getEntityProperties(_this.entityID, "position").position;
|
||||
_this.createWaterEffect();
|
||||
|
||||
// Wait a a bit for spout to spawn for case where preload is initial spawn, then save it
|
||||
Script.setTimeout(function() {
|
||||
var entities = Entities.findEntities(_this.position, 1);
|
||||
entities.forEach (function(entity) {
|
||||
var name = Entities.getEntityProperties(entity, "name").name;
|
||||
if (name === _this.WATER_SPOUT_NAME) {
|
||||
_this.waterSpout = entity;
|
||||
|
||||
}
|
||||
});
|
||||
|
||||
if (_this.waterSpout) {
|
||||
_this.waterSpoutPosition = Entities.getEntityProperties(_this.waterSpout, "position").position;
|
||||
_this.waterSpoutRotation = Entities.getEntityProperties(_this.waterSpout, "rotation").rotation;
|
||||
_this.createWaterEffect();
|
||||
}
|
||||
|
||||
}, 3000);
|
||||
|
||||
},
|
||||
|
||||
|
|
Loading…
Reference in a new issue