mirror of
https://github.com/overte-org/overte.git
synced 2025-08-09 10:47:11 +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
|
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() {
|
function FishTank() {
|
||||||
_this = this;
|
_this = this;
|
||||||
}
|
}
|
||||||
|
@ -238,11 +254,10 @@
|
||||||
_this.overlayLineOn(pickRay.origin, Vec3.sum(pickRay.origin, Vec3.multiply(front, _this.overlayLineDistance)), INTERSECT_COLOR);
|
_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 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) {
|
if (intersection.intersects && intersection.entityID === innerContainer) {
|
||||||
//print('intersecting a tank')
|
//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 FISH_MODEL_TWO_URL = "http://hifi-content.s3.amazonaws.com/DomainContent/Home/fishTank/goodfish5.fbx";
|
||||||
var fishLoaded = false;
|
var fishLoaded = false;
|
||||||
|
|
||||||
|
var lowerCorner, upperCorner;
|
||||||
|
|
||||||
function randomVector(scale) {
|
function randomVector(scale) {
|
||||||
return {
|
return {
|
||||||
x: Math.random() * scale - scale / 2.0,
|
x: Math.random() * scale - scale / 2.0,
|
||||||
|
@ -377,7 +394,6 @@
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
if (THROTTLE === true) {
|
if (THROTTLE === true) {
|
||||||
sinceLastUpdate = sinceLastUpdate + deltaTime * 100;
|
sinceLastUpdate = sinceLastUpdate + deltaTime * 100;
|
||||||
if (sinceLastUpdate > THROTTLE_RATE) {
|
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) {
|
if (_this.userData['hifi-home-fishtank'].fishLoaded === false) {
|
||||||
//no fish in the user data
|
//no fish in the user data
|
||||||
|
@ -399,10 +414,6 @@
|
||||||
fishLoaded: true,
|
fishLoaded: true,
|
||||||
bubbleSystem: _this.userData['hifi-home-fishtank'].bubbleSystem,
|
bubbleSystem: _this.userData['hifi-home-fishtank'].bubbleSystem,
|
||||||
bubbleSound: _this.userData['hifi-home-fishtank'].bubbleSound,
|
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,
|
innerContainer: _this.userData['hifi-home-fishtank'].innerContainer,
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -421,7 +432,6 @@
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
var fish = _this.fish;
|
var fish = _this.fish;
|
||||||
// print('how many fish do i find?' + fish.length)
|
// print('how many fish do i find?' + fish.length)
|
||||||
|
|
||||||
|
@ -442,25 +452,6 @@
|
||||||
z: 0
|
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
|
// First pre-load an array with properties on all the other fish so our per-fish loop
|
||||||
// isn't doing it.
|
// isn't doing it.
|
||||||
var flockProperties = [];
|
var flockProperties = [];
|
||||||
|
@ -531,8 +522,6 @@
|
||||||
//attractors
|
//attractors
|
||||||
//[position, radius, force]
|
//[position, radius, force]
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (_this.hasLookAttractor === true) {
|
if (_this.hasLookAttractor === true) {
|
||||||
|
@ -606,20 +595,12 @@
|
||||||
var STARTING_FRACTION = 0.25;
|
var STARTING_FRACTION = 0.25;
|
||||||
|
|
||||||
function loadFish(howMany) {
|
function loadFish(howMany) {
|
||||||
// print('LOADING FISH: ' + howMany)
|
print('LOADING FISH: ' + howMany)
|
||||||
|
|
||||||
var center = _this.currentProperties.position;
|
var center = _this.currentProperties.position;
|
||||||
|
|
||||||
lowerCorner = {
|
upperCorner = getOffsetFromTankCenter(LOWER_CORNER_VERTICAL_OFFSET, LOWER_CORNER_FORWARD_OFFSET, LOWER_CORNER_LATERAL_OFFSET);
|
||||||
x: center.x - (_this.currentProperties.dimensions.z / 2),
|
lowerCorner = getOffsetFromTankCenter(UPPER_CORNER_VERTICAL_OFFSET, UPPER_CORNER_FORWARD_OFFSET, UPPER_CORNER_LATERAL_OFFSET);
|
||||||
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)
|
|
||||||
};
|
|
||||||
|
|
||||||
var fish = [];
|
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) {
|
function setEntityUserData(id, data) {
|
||||||
var json = JSON.stringify(data)
|
var json = JSON.stringify(data)
|
||||||
Entities.editEntity(id, {
|
Entities.editEntity(id, {
|
||||||
|
|
|
@ -105,6 +105,13 @@ FishTank = function(spawnPosition, spawnRotation) {
|
||||||
z: 0.1020
|
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() {
|
function createFishTank() {
|
||||||
var tankProperties = {
|
var tankProperties = {
|
||||||
|
@ -113,7 +120,7 @@ FishTank = function(spawnPosition, spawnRotation) {
|
||||||
modelURL: TANK_MODEL_URL,
|
modelURL: TANK_MODEL_URL,
|
||||||
dimensions: TANK_DIMENSIONS,
|
dimensions: TANK_DIMENSIONS,
|
||||||
position: TANK_POSITION,
|
position: TANK_POSITION,
|
||||||
rotation:spawnRotation,
|
rotation: spawnRotation,
|
||||||
color: DEBUG_COLOR,
|
color: DEBUG_COLOR,
|
||||||
collisionless: true,
|
collisionless: true,
|
||||||
script: TANK_SCRIPT,
|
script: TANK_SCRIPT,
|
||||||
|
@ -121,7 +128,7 @@ FishTank = function(spawnPosition, spawnRotation) {
|
||||||
}
|
}
|
||||||
|
|
||||||
if (spawnRotation !== undefined) {
|
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);
|
fishTank = Entities.addEntity(tankProperties);
|
||||||
|
@ -247,7 +254,6 @@ FishTank = function(spawnPosition, spawnRotation) {
|
||||||
|
|
||||||
function createEntitiesAtCorners() {
|
function createEntitiesAtCorners() {
|
||||||
|
|
||||||
var bounds = Entities.getEntityProperties(innerContainer, "boundingBox").boundingBox;
|
|
||||||
|
|
||||||
var lowerProps = {
|
var lowerProps = {
|
||||||
name: 'hifi-home-fishtank-lower-corner',
|
name: 'hifi-home-fishtank-lower-corner',
|
||||||
|
@ -264,8 +270,8 @@ FishTank = function(spawnPosition, spawnRotation) {
|
||||||
blue: 0
|
blue: 0
|
||||||
},
|
},
|
||||||
collisionless: true,
|
collisionless: true,
|
||||||
position: bounds.brn,
|
position: getOffsetFromTankCenter(LOWER_CORNER_VERTICAL_OFFSET, LOWER_CORNER_FORWARD_OFFSET, LOWER_CORNER_LATERAL_OFFSET),
|
||||||
visible: false
|
visible: true
|
||||||
}
|
}
|
||||||
|
|
||||||
var upperProps = {
|
var upperProps = {
|
||||||
|
@ -283,8 +289,8 @@ FishTank = function(spawnPosition, spawnRotation) {
|
||||||
blue: 0
|
blue: 0
|
||||||
},
|
},
|
||||||
collisionless: true,
|
collisionless: true,
|
||||||
position: bounds.tfl,
|
position: getOffsetFromTankCenter(UPPER_CORNER_VERTICAL_OFFSET, UPPER_CORNER_FORWARD_OFFSET, UPPER_CORNER_LATERAL_OFFSET),
|
||||||
visible: false
|
visible: true
|
||||||
}
|
}
|
||||||
|
|
||||||
lowerCorner = Entities.addEntity(lowerProps);
|
lowerCorner = Entities.addEntity(lowerProps);
|
||||||
|
@ -380,13 +386,8 @@ FishTank = function(spawnPosition, spawnRotation) {
|
||||||
var data = {
|
var data = {
|
||||||
fishLoaded: false,
|
fishLoaded: false,
|
||||||
bubbleSystem: bubbleSystem,
|
bubbleSystem: bubbleSystem,
|
||||||
bubbleSound: bubbleSound,
|
// bubbleSound: bubbleSound,
|
||||||
corners: {
|
|
||||||
brn: lowerCorner,
|
|
||||||
tfl: upperCorner
|
|
||||||
},
|
|
||||||
innerContainer: innerContainer,
|
innerContainer: innerContainer,
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
Script.setTimeout(function() {
|
Script.setTimeout(function() {
|
||||||
|
|
|
@ -79,16 +79,17 @@
|
||||||
_this.tidying = true;
|
_this.tidying = true;
|
||||||
_this.showTidyingButton();
|
_this.showTidyingButton();
|
||||||
_this.playTidyingSound();
|
_this.playTidyingSound();
|
||||||
|
_this.cleanupDynamicEntities();
|
||||||
|
_this.cleanupKineticEntities();
|
||||||
Script.setTimeout(function() {
|
Script.setTimeout(function() {
|
||||||
_this.showTidyButton();
|
_this.showTidyButton();
|
||||||
_this.tidying = false;
|
_this.tidying = false;
|
||||||
}, 2500);
|
}, 2500);
|
||||||
_this.cleanupDynamicEntities();
|
|
||||||
_this.cleanupKineticEntities();
|
|
||||||
Script.setTimeout(function() {
|
Script.setTimeout(function() {
|
||||||
_this.createKineticEntities();
|
_this.createKineticEntities();
|
||||||
_this.createDynamicEntities();
|
_this.createDynamicEntities();
|
||||||
}, 500)
|
}, 750)
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -190,8 +191,6 @@
|
||||||
|
|
||||||
createKineticEntities: function() {
|
createKineticEntities: function() {
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
var fruitBowl = new FruitBowl({
|
var fruitBowl = new FruitBowl({
|
||||||
x: 1105.3185,
|
x: 1105.3185,
|
||||||
y: 460.3221,
|
y: 460.3221,
|
||||||
|
|
Loading…
Reference in a new issue