mirror of
https://github.com/lubosz/overte.git
synced 2025-08-07 16:41:02 +02:00
dont set at begin for tank
This commit is contained in:
parent
a52926c4af
commit
f7b1129152
3 changed files with 47 additions and 14 deletions
|
@ -42,6 +42,7 @@
|
||||||
iOwn = true;
|
iOwn = true;
|
||||||
connected = true;
|
connected = true;
|
||||||
Script.update.connect(_this.update);
|
Script.update.connect(_this.update);
|
||||||
|
print('JBP connecting in startupdate')
|
||||||
}
|
}
|
||||||
|
|
||||||
function stopUpdateAndReclaim() {
|
function stopUpdateAndReclaim() {
|
||||||
|
@ -107,10 +108,13 @@
|
||||||
if (properties.hasOwnProperty('userData') === false || properties.userData.length === 0) {
|
if (properties.hasOwnProperty('userData') === false || properties.userData.length === 0) {
|
||||||
_this.initTimeout = Script.setTimeout(function() {
|
_this.initTimeout = Script.setTimeout(function() {
|
||||||
if (properties.hasOwnProperty('userData')) {
|
if (properties.hasOwnProperty('userData')) {
|
||||||
// print('has user data property')
|
print('JBP has user data property')
|
||||||
}
|
}
|
||||||
if (properties.userData.length === 0) {
|
if (properties.userData.length === 0) {
|
||||||
// print('user data length is zero')
|
print('JBP user data length is zero')
|
||||||
|
}
|
||||||
|
if(properties.userData===""){
|
||||||
|
print('JBP user data is empty')
|
||||||
}
|
}
|
||||||
|
|
||||||
// print('try again in one second')
|
// print('try again in one second')
|
||||||
|
@ -122,9 +126,10 @@
|
||||||
_this.userData = null;
|
_this.userData = null;
|
||||||
try {
|
try {
|
||||||
_this.userData = JSON.parse(properties.userData);
|
_this.userData = JSON.parse(properties.userData);
|
||||||
|
print('JBP set userdata to parsed json')
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
// print('error parsing json');
|
print('JBP error parsing json');
|
||||||
// print('properties are:' + properties.userData);
|
print('JBP properties are:' + properties.userData);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
// print('after parse')
|
// print('after parse')
|
||||||
|
@ -171,7 +176,7 @@
|
||||||
// print('i am the owner!')
|
// print('i am the owner!')
|
||||||
//do stuff
|
//do stuff
|
||||||
updateFish(deltaTime);
|
updateFish(deltaTime);
|
||||||
_this.seeIfOwnerIsLookingAtTheTank();
|
// _this.seeIfOwnerIsLookingAtTheTank();
|
||||||
},
|
},
|
||||||
|
|
||||||
debugSphereOn: function(position) {
|
debugSphereOn: function(position) {
|
||||||
|
@ -339,7 +344,7 @@
|
||||||
var FISHTANK_USERDATA_KEY = 'hifi-home-fishtank'
|
var FISHTANK_USERDATA_KEY = 'hifi-home-fishtank'
|
||||||
|
|
||||||
var LIFETIME = 300; // Fish live for 5 minutes
|
var LIFETIME = 300; // Fish live for 5 minutes
|
||||||
var NUM_FISH = 8;
|
var NUM_FISH = 2;
|
||||||
var TANK_DIMENSIONS = {
|
var TANK_DIMENSIONS = {
|
||||||
x: 0.8212,
|
x: 0.8212,
|
||||||
y: 0.8116,
|
y: 0.8116,
|
||||||
|
@ -416,8 +421,7 @@
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
print('jbp has userdata fish??' + JSON.stringify(_this.userData))
|
||||||
// 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
|
||||||
|
@ -699,6 +703,31 @@
|
||||||
Script.update.disconnect(_this.update);
|
Script.update.disconnect(_this.update);
|
||||||
})
|
})
|
||||||
|
|
||||||
|
function keepFishInTank(fish,position,rotation){
|
||||||
|
|
||||||
|
// cast a ray from the fish
|
||||||
|
// see if it hits the tank wall
|
||||||
|
// see how far it is from the tank wall
|
||||||
|
// if less than a certain distance, then apply opposite vector
|
||||||
|
var keepAwayDistance = 0.15;
|
||||||
|
|
||||||
|
|
||||||
|
var pickRay = {
|
||||||
|
origin: position,
|
||||||
|
direction: rotation
|
||||||
|
};
|
||||||
|
|
||||||
|
var innerContainer = _this.userData['hifi-home-fishtank'].innerContainer;
|
||||||
|
|
||||||
|
var intersection = Entities.findRayIntersection(pickRay, true, [innerContainer], [_this.entityID]);
|
||||||
|
|
||||||
|
if (intersection.intersects && intersection.entityID === innerContainer) {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
return newVector
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
function setEntityUserData(id, data) {
|
function setEntityUserData(id, data) {
|
||||||
var json = JSON.stringify(data)
|
var json = JSON.stringify(data)
|
||||||
|
|
|
@ -122,11 +122,11 @@ FishTank = function(spawnPosition, spawnRotation) {
|
||||||
collisionless: true,
|
collisionless: true,
|
||||||
script: TANK_SCRIPT,
|
script: TANK_SCRIPT,
|
||||||
visible: true,
|
visible: true,
|
||||||
userData: JSON.stringify({
|
// userData: JSON.stringify({
|
||||||
'hifiHomeKey': {
|
// 'hifiHomeKey': {
|
||||||
'reset': true
|
// 'reset': true
|
||||||
}
|
// }
|
||||||
}),
|
// }),
|
||||||
}
|
}
|
||||||
|
|
||||||
fishTank = Entities.addEntity(tankProperties);
|
fishTank = Entities.addEntity(tankProperties);
|
||||||
|
|
|
@ -128,6 +128,9 @@
|
||||||
z: 0
|
z: 0
|
||||||
});
|
});
|
||||||
|
|
||||||
|
//REMOVE BEFORE MERGE
|
||||||
|
return;
|
||||||
|
|
||||||
var tiltMaze = new TiltMaze({
|
var tiltMaze = new TiltMaze({
|
||||||
x: 1105.5768,
|
x: 1105.5768,
|
||||||
y: 460.3298,
|
y: 460.3298,
|
||||||
|
@ -181,7 +184,8 @@
|
||||||
|
|
||||||
|
|
||||||
createKineticEntities: function() {
|
createKineticEntities: function() {
|
||||||
|
//REMOVE BEFORE MERGE
|
||||||
|
return;
|
||||||
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