mirror of
https://github.com/overte-org/overte.git
synced 2025-04-20 03:44:02 +02:00
start fish fix
This commit is contained in:
parent
855f505ae1
commit
c072cd323e
3 changed files with 59 additions and 60 deletions
|
@ -32,6 +32,22 @@
|
|||
blue: 255
|
||||
}
|
||||
|
||||
var TANK_DIMENSIONS = {
|
||||
x: 0.8212,
|
||||
y: 0.8116,
|
||||
z: 2.1404
|
||||
};
|
||||
|
||||
var LOWER_CORNER_VERTICAL_OFFSET = -TANK_DIMENSIONS.y / 2;
|
||||
var LOWER_CORNER_FORWARD_OFFSET = TANK_DIMENSIONS.x;
|
||||
var LOWER_CORNER_LATERAL_OFFSET = -TANK_DIMENSIONS.z / 8;
|
||||
|
||||
var UPPER_CORNER_VERTICAL_OFFSET = TANK_DIMENSIONS.y / 2;;
|
||||
var UPPER_CORNER_FORWARD_OFFSET = -TANK_DIMENSIONS.x;
|
||||
var UPPER_CORNER_LATERAL_OFFSET = TANK_DIMENSIONS.z / 8;
|
||||
|
||||
|
||||
|
||||
function FishTank() {
|
||||
_this = this;
|
||||
}
|
||||
|
@ -238,11 +254,10 @@
|
|||
_this.overlayLineOn(pickRay.origin, Vec3.sum(pickRay.origin, Vec3.multiply(front, _this.overlayLineDistance)), INTERSECT_COLOR);
|
||||
};
|
||||
|
||||
var brn = _this.userData['hifi-home-fishtank']['corners'].brn;
|
||||
var tfl = _this.userData['hifi-home-fishtank']['corners'].tfl;
|
||||
|
||||
var innerContainer = _this.userData['hifi-home-fishtank'].innerContainer;
|
||||
|
||||
var intersection = Entities.findRayIntersection(pickRay, true, [innerContainer], [_this.entityID, brn, tfl]);
|
||||
var intersection = Entities.findRayIntersection(pickRay, true, [innerContainer], [_this.entityID]);
|
||||
|
||||
if (intersection.intersects && intersection.entityID === innerContainer) {
|
||||
//print('intersecting a tank')
|
||||
|
@ -359,6 +374,8 @@
|
|||
var FISH_MODEL_TWO_URL = "http://hifi-content.s3.amazonaws.com/DomainContent/Home/fishTank/goodfish5.fbx";
|
||||
var fishLoaded = false;
|
||||
|
||||
var lowerCorner, upperCorner;
|
||||
|
||||
function randomVector(scale) {
|
||||
return {
|
||||
x: Math.random() * scale - scale / 2.0,
|
||||
|
@ -377,7 +394,6 @@
|
|||
return;
|
||||
}
|
||||
|
||||
|
||||
if (THROTTLE === true) {
|
||||
sinceLastUpdate = sinceLastUpdate + deltaTime * 100;
|
||||
if (sinceLastUpdate > THROTTLE_RATE) {
|
||||
|
@ -388,7 +404,6 @@
|
|||
}
|
||||
|
||||
|
||||
// print('has userdata fish??' + _this.userData['hifi-home-fishtank'].fishLoaded)
|
||||
|
||||
if (_this.userData['hifi-home-fishtank'].fishLoaded === false) {
|
||||
//no fish in the user data
|
||||
|
@ -399,10 +414,6 @@
|
|||
fishLoaded: true,
|
||||
bubbleSystem: _this.userData['hifi-home-fishtank'].bubbleSystem,
|
||||
bubbleSound: _this.userData['hifi-home-fishtank'].bubbleSound,
|
||||
corners: {
|
||||
brn: _this.userData['hifi-home-fishtank'].lowerCorner,
|
||||
tfl: _this.userData['hifi-home-fishtank'].upperCorner
|
||||
},
|
||||
innerContainer: _this.userData['hifi-home-fishtank'].innerContainer,
|
||||
|
||||
}
|
||||
|
@ -421,7 +432,6 @@
|
|||
|
||||
}
|
||||
|
||||
|
||||
var fish = _this.fish;
|
||||
// print('how many fish do i find?' + fish.length)
|
||||
|
||||
|
@ -442,25 +452,6 @@
|
|||
z: 0
|
||||
};
|
||||
|
||||
|
||||
var userData = JSON.parse(_this.currentProperties.userData);
|
||||
var innerContainer = userData['hifi-home-fishtank']['innerContainer'];
|
||||
var props = Entities.getEntityProperties(innerContainer, "boundingBox");
|
||||
var bounds = null;
|
||||
if (props.hasOwnProperty('boundingBox') === true) {
|
||||
bounds = props.boundingBox;
|
||||
}
|
||||
if (bounds !== null) {
|
||||
lowerCorner = bounds.brn;
|
||||
upperCorner = bounds.tfl;
|
||||
|
||||
print('LOWER CORNER BOUND:: '+ JSON.stringify(lowerCorner))
|
||||
} else {
|
||||
print('NO BOUNDS FOR TANK, returning!!');
|
||||
print('INNER CONTAINER?' + innerContainer);
|
||||
print('INNER PROPS :: ' + JSON.stringify(props));
|
||||
return;
|
||||
}
|
||||
// First pre-load an array with properties on all the other fish so our per-fish loop
|
||||
// isn't doing it.
|
||||
var flockProperties = [];
|
||||
|
@ -531,8 +522,6 @@
|
|||
//attractors
|
||||
//[position, radius, force]
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
if (_this.hasLookAttractor === true) {
|
||||
|
@ -606,20 +595,12 @@
|
|||
var STARTING_FRACTION = 0.25;
|
||||
|
||||
function loadFish(howMany) {
|
||||
// print('LOADING FISH: ' + howMany)
|
||||
print('LOADING FISH: ' + howMany)
|
||||
|
||||
var center = _this.currentProperties.position;
|
||||
|
||||
lowerCorner = {
|
||||
x: center.x - (_this.currentProperties.dimensions.z / 2),
|
||||
y: center.y,
|
||||
z: center.z - (_this.currentProperties.dimensions.z / 2)
|
||||
};
|
||||
upperCorner = {
|
||||
x: center.x + (_this.currentProperties.dimensions.z / 2),
|
||||
y: center.y + _this.currentProperties.dimensions.y,
|
||||
z: center.z + (_this.currentProperties.dimensions.z / 2)
|
||||
};
|
||||
upperCorner = getOffsetFromTankCenter(LOWER_CORNER_VERTICAL_OFFSET, LOWER_CORNER_FORWARD_OFFSET, LOWER_CORNER_LATERAL_OFFSET);
|
||||
lowerCorner = getOffsetFromTankCenter(UPPER_CORNER_VERTICAL_OFFSET, UPPER_CORNER_FORWARD_OFFSET, UPPER_CORNER_LATERAL_OFFSET);
|
||||
|
||||
var fish = [];
|
||||
|
||||
|
@ -674,6 +655,24 @@
|
|||
})
|
||||
|
||||
|
||||
function getOffsetFromTankCenter(VERTICAL_OFFSET, FORWARD_OFFSET, LATERAL_OFFSET) {
|
||||
|
||||
var tankProperties = Entities.getEntityProperties(_this.entityID);
|
||||
|
||||
var upVector = Quat.getUp(tankProperties.rotation);
|
||||
var frontVector = Quat.getFront(tankProperties.rotation);
|
||||
var rightVector = Quat.getRight(tankProperties.rotation);
|
||||
|
||||
var upOffset = Vec3.multiply(upVector, VERTICAL_OFFSET);
|
||||
var frontOffset = Vec3.multiply(frontVector, FORWARD_OFFSET);
|
||||
var rightOffset = Vec3.multiply(rightVector, LATERAL_OFFSET);
|
||||
|
||||
var finalOffset = Vec3.sum(tankProperties.position, upOffset);
|
||||
finalOffset = Vec3.sum(finalOffset, frontOffset);
|
||||
finalOffset = Vec3.sum(finalOffset, rightOffset);
|
||||
return finalOffset
|
||||
}
|
||||
|
||||
function setEntityUserData(id, data) {
|
||||
var json = JSON.stringify(data)
|
||||
Entities.editEntity(id, {
|
||||
|
|
|
@ -105,6 +105,13 @@ FishTank = function(spawnPosition, spawnRotation) {
|
|||
z: 0.1020
|
||||
}
|
||||
|
||||
var LOWER_CORNER_VERTICAL_OFFSET = -TANK_DIMENSIONS.y / 2;
|
||||
var LOWER_CORNER_FORWARD_OFFSET = TANK_DIMENSIONS.x;
|
||||
var LOWER_CORNER_LATERAL_OFFSET = -TANK_DIMENSIONS.z/8;
|
||||
|
||||
var UPPER_CORNER_VERTICAL_OFFSET = TANK_DIMENSIONS.y / 2;;
|
||||
var UPPER_CORNER_FORWARD_OFFSET = -TANK_DIMENSIONS.x;
|
||||
var UPPER_CORNER_LATERAL_OFFSET = TANK_DIMENSIONS.z/8;
|
||||
|
||||
function createFishTank() {
|
||||
var tankProperties = {
|
||||
|
@ -113,7 +120,7 @@ FishTank = function(spawnPosition, spawnRotation) {
|
|||
modelURL: TANK_MODEL_URL,
|
||||
dimensions: TANK_DIMENSIONS,
|
||||
position: TANK_POSITION,
|
||||
rotation:spawnRotation,
|
||||
rotation: spawnRotation,
|
||||
color: DEBUG_COLOR,
|
||||
collisionless: true,
|
||||
script: TANK_SCRIPT,
|
||||
|
@ -121,7 +128,7 @@ FishTank = function(spawnPosition, spawnRotation) {
|
|||
}
|
||||
|
||||
if (spawnRotation !== undefined) {
|
||||
tankProperties.rotation = Quat.fromPitchYawRollDegrees(spawnRotation.x,spawnRotation.y,spawnRotation.z)
|
||||
tankProperties.rotation = Quat.fromPitchYawRollDegrees(spawnRotation.x, spawnRotation.y, spawnRotation.z)
|
||||
}
|
||||
|
||||
fishTank = Entities.addEntity(tankProperties);
|
||||
|
@ -247,7 +254,6 @@ FishTank = function(spawnPosition, spawnRotation) {
|
|||
|
||||
function createEntitiesAtCorners() {
|
||||
|
||||
var bounds = Entities.getEntityProperties(innerContainer, "boundingBox").boundingBox;
|
||||
|
||||
var lowerProps = {
|
||||
name: 'hifi-home-fishtank-lower-corner',
|
||||
|
@ -264,8 +270,8 @@ FishTank = function(spawnPosition, spawnRotation) {
|
|||
blue: 0
|
||||
},
|
||||
collisionless: true,
|
||||
position: bounds.brn,
|
||||
visible: false
|
||||
position: getOffsetFromTankCenter(LOWER_CORNER_VERTICAL_OFFSET, LOWER_CORNER_FORWARD_OFFSET, LOWER_CORNER_LATERAL_OFFSET),
|
||||
visible: true
|
||||
}
|
||||
|
||||
var upperProps = {
|
||||
|
@ -283,8 +289,8 @@ FishTank = function(spawnPosition, spawnRotation) {
|
|||
blue: 0
|
||||
},
|
||||
collisionless: true,
|
||||
position: bounds.tfl,
|
||||
visible: false
|
||||
position: getOffsetFromTankCenter(UPPER_CORNER_VERTICAL_OFFSET, UPPER_CORNER_FORWARD_OFFSET, UPPER_CORNER_LATERAL_OFFSET),
|
||||
visible: true
|
||||
}
|
||||
|
||||
lowerCorner = Entities.addEntity(lowerProps);
|
||||
|
@ -380,13 +386,8 @@ FishTank = function(spawnPosition, spawnRotation) {
|
|||
var data = {
|
||||
fishLoaded: false,
|
||||
bubbleSystem: bubbleSystem,
|
||||
bubbleSound: bubbleSound,
|
||||
corners: {
|
||||
brn: lowerCorner,
|
||||
tfl: upperCorner
|
||||
},
|
||||
// bubbleSound: bubbleSound,
|
||||
innerContainer: innerContainer,
|
||||
|
||||
}
|
||||
|
||||
Script.setTimeout(function() {
|
||||
|
|
|
@ -79,16 +79,17 @@
|
|||
_this.tidying = true;
|
||||
_this.showTidyingButton();
|
||||
_this.playTidyingSound();
|
||||
_this.cleanupDynamicEntities();
|
||||
_this.cleanupKineticEntities();
|
||||
Script.setTimeout(function() {
|
||||
_this.showTidyButton();
|
||||
_this.tidying = false;
|
||||
}, 2500);
|
||||
_this.cleanupDynamicEntities();
|
||||
_this.cleanupKineticEntities();
|
||||
|
||||
Script.setTimeout(function() {
|
||||
_this.createKineticEntities();
|
||||
_this.createDynamicEntities();
|
||||
}, 500)
|
||||
}, 750)
|
||||
|
||||
|
||||
}
|
||||
|
@ -190,8 +191,6 @@
|
|||
|
||||
createKineticEntities: function() {
|
||||
|
||||
|
||||
|
||||
var fruitBowl = new FruitBowl({
|
||||
x: 1105.3185,
|
||||
y: 460.3221,
|
||||
|
|
Loading…
Reference in a new issue