Merge branch 'newfishes' of https://github.com/imgntn/hifi into newfishes

This commit is contained in:
James B. Pollack 2016-03-09 09:14:56 -08:00
commit de45fef3fc
3 changed files with 76 additions and 107 deletions

View file

@ -1,47 +0,0 @@
{
"color": {},
"isEmitting": 1,
"maxParticles": 1880,
"lifespan": 1.6,
"emitRate": 10,
"emitSpeed": 0.025,
"speedSpread": 0.025,
"emitOrientation": {
"x": 0,
"y": 0.5,
"z": 0.5,
"w": 0
},
"emitDimensions": {
"x": -0.2,
"y": 1.2000000000000002,
"z": 0
},
"polarStart": 0,
"polarFinish": 0,
"azimuthStart": 0.2,
"azimuthFinish": 0.1,
"emitAcceleration": {
"x": 0,
"y": 0.4,
"z": 0
},
"accelerationSpread": {
"x": 0.1,
"y": 0.1,
"z": 0.1
},
"particleRadius": 0.02,
"radiusSpread": 0,
"radiusStart": 0.043,
"radiusFinish": 0.02,
"colorSpread": {},
"colorStart": {},
"colorFinish": {},
"alpha": 0.2,
"alphaSpread": 0,
"alphaStart": 0.3,
"alphaFinish": 0,
"emitterShouldTrail": 0,
"textures": "http://hifi-content.s3.amazonaws.com/DomainContent/Home/fishTank/bubble-white.png"
}

View file

@ -1,12 +1,14 @@
var fishTank, bubbleSystem, innerContainer, bubbleInjector, lowerCorner, upperCorner, urchin, rocks;
var fishTank, tankBase, bubbleSystem, secondBubbleSystem, innerContainer, bubbleInjector, lowerCorner, upperCorner, urchin, rocks;
var CLEANUP = true;
var TANK_DIMENSIONS = {
x: 1.3393,
y: 1.3515,
z: 3.5914
x: 0.8212,
y: 0.8116,
z: 2.1404
};
var INNER_TANK_SCALE = 0.7;
var INNER_TANK_DIMENSIONS = Vec3.multiply(INNER_TANK_SCALE, TANK_DIMENSIONS);
INNER_TANK_DIMENSIONS.y = INNER_TANK_DIMENSIONS.y - 0.4;
@ -25,12 +27,24 @@ var TANK_POSITION = center;
var TANK_SCRIPT = Script.resolvePath('tank.js?' + Math.random())
var TANK_MODEL_URL = "http://hifi-content.s3.amazonaws.com/DomainContent/Home/fishTank/aquarium-6.fbx";
var TANK_MODEL_URL = "http://hifi-content.s3.amazonaws.com/DomainContent/Home/fishTank/aquariumTank.fbx";
var BUBBLE_SYSTEM_FORWARD_OFFSET = TANK_DIMENSIONS.x;
var TANK_BASE_MODEL_URL = 'http://hifi-content.s3.amazonaws.com/DomainContent/Home/fishTank/aquariumBase.fbx';
var TANK_BASE_COLLISION_HULL = 'http://hifi-content.s3.amazonaws.com/DomainContent/Home/fishTank/aquariumBase.obj'
var TANK_BASE_DIMENSIONS = {
x: 0.8599,
y: 1.8450,
z: 2.1936
};
var BASE_VERTICAL_OFFSET = 0.42;
var BUBBLE_SYSTEM_FORWARD_OFFSET = TANK_DIMENSIONS.x + 0.06;
//depth of tank
var BUBBLE_SYSTEM_LATERAL_OFFSET = 0.15;
var BUBBLE_SYSTEM_VERTICAL_OFFSET = -0.5;
var BUBBLE_SYSTEM_LATERAL_OFFSET = 0.025;
var BUBBLE_SYSTEM_VERTICAL_OFFSET = -0.25;
var BUBBLE_SYSTEM_DIMENSIONS = {
x: TANK_DIMENSIONS.x / 8,
@ -44,7 +58,7 @@ var bubbleSound = SoundCache.getSound(BUBBLE_SOUND_URL);
var URCHIN_FORWARD_OFFSET = -TANK_DIMENSIONS.x;
//depth of tank
var URCHIN_LATERAL_OFFSET = -0.15;
var URCHIN_VERTICAL_OFFSET = -0.37;
var URCHIN_VERTICAL_OFFSET = -0.17;
var URCHIN_MODEL_URL = 'http://hifi-content.s3.amazonaws.com/DomainContent/Home/fishTank/Urchin.fbx';
@ -54,7 +68,7 @@ var URCHIN_DIMENSIONS = {
z: 0.35
}
var ROCKS_FORWARD_OFFSET = (TANK_DIMENSIONS.x / 2) - 0.75;
var ROCKS_FORWARD_OFFSET = 0;
//depth of tank
var ROCKS_LATERAL_OFFSET = 0.0;
var ROCKS_VERTICAL_OFFSET = (-TANK_DIMENSIONS.y / 2) + 0.25;
@ -62,9 +76,9 @@ var ROCKS_VERTICAL_OFFSET = (-TANK_DIMENSIONS.y / 2) + 0.25;
var ROCK_MODEL_URL = 'http://hifi-content.s3.amazonaws.com/DomainContent/Home/fishTank/Aquarium-Rocks-2.fbx';
var ROCK_DIMENSIONS = {
x: 0.88,
x: 0.707,
y: 0.33,
z: 2.9
z: 1.64
}
function createFishTank() {
@ -83,12 +97,11 @@ function createFishTank() {
fishTank = Entities.addEntity(tankProperties);
}
function createBubbleSystem() {
function createBubbleSystems() {
var tankProperties = Entities.getEntityProperties(fishTank);
var bubbleProperties = {
"name": 'hifi-home-fishtank-bubbles',
"color": {},
"isEmitting": 1,
"maxParticles": 1880,
"lifespan": 1.6,
@ -103,7 +116,7 @@ function createBubbleSystem() {
},
"emitDimensions": {
"x": -0.2,
"y": 1.6000000000000002,
"y": TANK_DIMENSIONS.y,
"z": 0
},
"polarStart": 0,
@ -124,9 +137,6 @@ function createBubbleSystem() {
"radiusSpread": 0,
"radiusStart": 0.043,
"radiusFinish": 0.02,
"colorSpread": {},
"colorStart": {},
"colorFinish": {},
"alpha": 0.2,
"alphaSpread": 0,
"alphaStart": 0.3,
@ -142,12 +152,16 @@ function createBubbleSystem() {
var finalOffset = getOffsetFromTankCenter(BUBBLE_SYSTEM_VERTICAL_OFFSET, BUBBLE_SYSTEM_FORWARD_OFFSET, BUBBLE_SYSTEM_LATERAL_OFFSET);
bubbleProperties.position = finalOffset;
bubbleSystem = Entities.addEntity(bubbleProperties);
bubbleProperties.position.z += -0.076;
secondBubbleSystem = Entities.addEntity(bubbleProperties)
createBubbleSound(finalOffset);
}
function getOffsetFromTankCenter(VERTICAL_OFFSET, FORWARD_OFFSET, LATERAL_OFFSET) {
var tankProperties = Entities.getEntityProperties(fishTank);
@ -163,13 +177,12 @@ function getOffsetFromTankCenter(VERTICAL_OFFSET, FORWARD_OFFSET, LATERAL_OFFSET
var finalOffset = Vec3.sum(tankProperties.position, upOffset);
finalOffset = Vec3.sum(finalOffset, frontOffset);
finalOffset = Vec3.sum(finalOffset, rightOffset);
print('final offset is: ' + finalOffset)
return finalOffset
}
function createBubbleSound(position) {
var audioProperties = {
volume: 1,
volume: 0.05,
position: position,
loop: true
};
@ -245,8 +258,7 @@ function createEntitiesAtCorners() {
lowerCorner = Entities.addEntity(lowerProps);
upperCorner = Entities.addEntity(upperProps);
print('CORNERS :::' + JSON.stringify(upperCorner))
print('CORNERS :::' + JSON.stringify(lowerCorner))
}
function createRocks() {
@ -281,21 +293,37 @@ function createUrchin() {
}
function createTankBase() {
var properties = {
name: 'hifi-home-fishtank-base',
type: 'Model',
modelURL: TANK_BASE_MODEL_URL,
parentID: fishTank,
shapeType: 'compound',
compoundShapeURL: TANK_BASE_COLLISION_HULL,
position: {
x: TANK_POSITION.x,
y: TANK_POSITION.y - BASE_VERTICAL_OFFSET,
z: TANK_POSITION.z
},
dimensions: TANK_BASE_DIMENSIONS
}
tankBase = Entities.addEntity(properties);
}
createFishTank();
createInnerContainer();
createBubbleSystem();
createBubbleSystems();
createEntitiesAtCorners();
createBubbleSound();
createUrchin();
createRocks();
createTankBase();
var customKey = 'hifi-home-fishtank';
@ -326,7 +354,9 @@ Script.setTimeout(function() {
function cleanup() {
Entities.deleteEntity(fishTank);
Entities.deleteEntity(tankBase);
Entities.deleteEntity(bubbleSystem);
Entities.deleteEntity(secondBubbleSystem);
Entities.deleteEntity(innerContainer);
Entities.deleteEntity(lowerCorner);
Entities.deleteEntity(upperCorner);

View file

@ -1,6 +1,6 @@
(function() {
Script.include('../../../../examples/libraries/virtualBaton.js?' + Math.random());
Script.include('../../../../examples/libraries/virtualBaton.js');
//only one person should simulate the tank at a time -- we pass around a virtual baton
var baton;
@ -25,7 +25,7 @@
function startUpdate() {
//when the baton is claimed;
print('trying to claim the object' + _entityID)
// print('trying to claim the object' + _entityID)
iOwn = true;
connected = true;
Script.update.connect(_this.update);
@ -33,7 +33,7 @@
function stopUpdateAndReclaim() {
//when the baton is released;
print('i released the object ' + _entityID)
// print('i released the object ' + _entityID)
iOwn = false;
if (connected === true) {
connected = false;
@ -54,7 +54,7 @@
overlayLineDistance: 3,
debugSphere: null,
findFishInTank: function() {
print('looking for a fish in the tank')
// print('looking for a fish in the tank')
var results = Entities.findEntities(_this.currentProperties.position, TANK_SEARCH_RADIUS);
var fishList = [];
@ -65,7 +65,7 @@
}
})
print('fish? ' + fishList.length)
// print('fish? ' + fishList.length)
return fishList;
},
@ -75,27 +75,27 @@
if (properties.hasOwnProperty('userData') === false || properties.userData.length === 0) {
_this.initTimeout = Script.setTimeout(function() {
if (properties.hasOwnProperty('userData')) {
print('JBP has user data property')
// print('has user data property')
}
if (properties.userData.length === 0) {
print('JBP user data length is zero')
// print('user data length is zero')
}
print('JBP try again in one second')
// print('try again in one second')
_this.initialize(entityID);
}, 1000)
} else {
print('JBP userdata before parse attempt' + properties.userData)
// print('userdata before parse attempt' + properties.userData)
_this.userData = null;
try {
_this.userData = JSON.parse(properties.userData);
} catch (err) {
print('JBP error parsing json');
print('JBP properties are:' + properties.userData);
// print('error parsing json');
// print('properties are:' + properties.userData);
return;
}
print('after parse')
// print('after parse')
_this.currentProperties = Entities.getEntityProperties(entityID);
baton = virtualBaton({
batonName: 'io.highfidelity.fishtank:' + entityID, // One winner for each entity
@ -107,19 +107,16 @@
},
preload: function(entityID) {
print("preload");
// print("preload");
this.entityID = entityID;
_entityID = entityID;
this.initialize(entityID);
// if(_this.initTimeout!==null){
// Script.clearTimeout(_this.initTimeout)
// }
this.initTimeout = null;
},
unload: function() {
print(' UNLOAD')
// print(' UNLOAD')
if (connected === true) {
Script.update.disconnect(_this.update);
}
@ -127,7 +124,7 @@
_this.overlayLineOff();
}
if (baton) {
print('BATON RELEASE ')
// print('BATON RELEASE ')
baton.release(function() {});
}
@ -135,8 +132,8 @@
update: function(deltaTime) {
if (iOwn === false) {
print('i dont own')
//exit if we're not supposed to be simulating the fish
// print('i dont own')
//exit if we're not supposed to be simulating the fish
return
}
// print('i am the owner!')
@ -214,8 +211,6 @@
_this.overlayLine = null;
},
seeIfOwnerIsLookingAtTheTank: function() {
var cameraPosition = Camera.getPosition();
var cameraOrientation = Camera.getOrientation();
@ -228,7 +223,6 @@
if (WANT_LOOK_DEBUG_LINE === true) {
_this.overlayLineOn(pickRay.origin, Vec3.sum(pickRay.origin, Vec3.multiply(front, _this.overlayLineDistance)), INTERSECT_COLOR);
};
var brn = _this.userData['hifi-home-fishtank']['corners'].brn;
@ -264,7 +258,6 @@
}
}
},
//look attractors could be private to the tank...
createLookAttractor: function(position, distance) {
_this.lookAttractor = {
position: position,
@ -296,13 +289,6 @@
// check for intersection
// add attractor for closest person (?)
var intersection = Entities.findRayIntersection(pickRay, true, [_this.entityID]);
if (intersection.intersects && intersection.entityID === _this.entityID) {
print('intersecting a tank')
print('intersection:: ' + JSON.stringify(intersection));
}
}
};
@ -595,7 +581,7 @@
var STARTING_FRACTION = 0.25;
function loadFish(howMany) {
print('LOADING FISH: ' + howMany)
// print('LOADING FISH: ' + howMany)
var center = _this.currentProperties.position;
@ -654,7 +640,7 @@
}
print('initial fish::' + fish.length)
// print('initial fish::' + fish.length)
_this.tankLocked = false;
}
@ -707,4 +693,4 @@
}
return new FishTank();
});
});