mirror of
https://github.com/lubosz/overte.git
synced 2025-08-07 16:41:02 +02:00
fixed bugs
This commit is contained in:
parent
257424ae61
commit
156f186e49
3 changed files with 99 additions and 65 deletions
|
@ -24,13 +24,19 @@
|
||||||
|
|
||||||
function startUpdate() {
|
function startUpdate() {
|
||||||
print("EBL Start CLOCK Update")
|
print("EBL Start CLOCK Update")
|
||||||
//when the baton is claimed;
|
//when the baton is claimed;
|
||||||
// print('trying to claim the object' + _entityID)
|
// print('trying to claim the object' + _entityID)
|
||||||
iOwn = true;
|
iOwn = true;
|
||||||
connected = true;
|
connected = true;
|
||||||
|
|
||||||
|
|
||||||
|
_this.updateSecondHandForOwnersLocalTime();
|
||||||
|
|
||||||
Script.update.connect(_this.update);
|
Script.update.connect(_this.update);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
function stopUpdateAndReclaim() {
|
function stopUpdateAndReclaim() {
|
||||||
//when the baton is released;
|
//when the baton is released;
|
||||||
print('EBL I released the object ' + _this.entityID)
|
print('EBL I released the object ' + _this.entityID)
|
||||||
|
@ -55,16 +61,32 @@
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
_this.clockBody = _this.userData.clockBody;
|
_this.clockBody = _this.userData.clockBody;
|
||||||
|
_this.secondHand = _this.userData.secondHand;
|
||||||
// One winner for each entity
|
// One winner for each entity
|
||||||
|
|
||||||
if(Entities.canRez() && Entities.canAdjustLocks){
|
if (Entities.canRez() && Entities.canAdjustLocks) {
|
||||||
print("EBL I HAVE EDIT RIGHTS, SO SET UP BATON!");
|
print("EBL I HAVE EDIT RIGHTS, SO SET UP BATON!");
|
||||||
baton = virtualBaton({
|
baton = virtualBaton({
|
||||||
batonName: "io.highfidelity.cuckooClock:" + _this.entityID
|
batonName: "io.highfidelity.cuckooClock:" + _this.entityID
|
||||||
});
|
});
|
||||||
stopUpdateAndReclaim();
|
stopUpdateAndReclaim();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
},
|
||||||
|
|
||||||
|
updateSecondHandForOwnersLocalTime: function() {
|
||||||
|
// We are taking over so make sure to update our second hand to reflect local time
|
||||||
|
if (!_this.secondHand) {
|
||||||
|
print("WE DONT HAVE A SECOND HAND! RETURNING");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
var DEGREES_FOR_SECOND = 6;
|
||||||
|
var myDate = new Date();
|
||||||
|
var seconds = myDate.getSeconds();
|
||||||
|
secondRollDegrees = -seconds * DEGREES_FOR_SECOND;
|
||||||
|
Entities.editEntity(_this.secondHand, {rotation: Quat.fromPitchYawRollDegrees(0, 0, secondRollDegrees)});
|
||||||
|
|
||||||
},
|
},
|
||||||
|
|
||||||
unload: function() {
|
unload: function() {
|
||||||
|
@ -90,7 +112,7 @@
|
||||||
// if (seconds === 0 && minutes === 0) {
|
// if (seconds === 0 && minutes === 0) {
|
||||||
// _this.popCuckooOut();
|
// _this.popCuckooOut();
|
||||||
// }
|
// }
|
||||||
if (seconds % 15 === 0) {
|
if (seconds % 15 === 0) {
|
||||||
_this.popCuckooOut();
|
_this.popCuckooOut();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -100,8 +122,11 @@
|
||||||
// We are at the top of the hour!
|
// We are at the top of the hour!
|
||||||
_this.position = Entities.getEntityProperties(_this.entityID, "position").position;
|
_this.position = Entities.getEntityProperties(_this.entityID, "position").position;
|
||||||
print("EBL POP CUCKOO CLOCK!!!!!!!!!!!");
|
print("EBL POP CUCKOO CLOCK!!!!!!!!!!!");
|
||||||
if(!_this.cuckooSoundInjector) {
|
if (!_this.cuckooSoundInjector) {
|
||||||
_this.cuckooSoundInjector = Audio.playSound(_this.cuckooSound, {position: _this.position, volume: _this.CUCKOO_SOUND_VOLUME});
|
_this.cuckooSoundInjector = Audio.playSound(_this.cuckooSound, {
|
||||||
|
position: _this.position,
|
||||||
|
volume: _this.CUCKOO_SOUND_VOLUME
|
||||||
|
});
|
||||||
} else {
|
} else {
|
||||||
_this.cuckooSoundInjector.stop();
|
_this.cuckooSoundInjector.stop();
|
||||||
_this.cuckooSoundInjector.restart();
|
_this.cuckooSoundInjector.restart();
|
||||||
|
|
|
@ -38,6 +38,11 @@ MyCuckooClock = function(spawnPosition, spawnRotation) {
|
||||||
y: 1.3662,
|
y: 1.3662,
|
||||||
z: 0.8181
|
z: 0.8181
|
||||||
},
|
},
|
||||||
|
userData: JSON.stringify({
|
||||||
|
hifiHomeKey: {
|
||||||
|
reset: true
|
||||||
|
}
|
||||||
|
})
|
||||||
})
|
})
|
||||||
|
|
||||||
var clockFaceOffset = {
|
var clockFaceOffset = {
|
||||||
|
@ -56,7 +61,13 @@ MyCuckooClock = function(spawnPosition, spawnRotation) {
|
||||||
x: 0.2397,
|
x: 0.2397,
|
||||||
y: 0.2402,
|
y: 0.2402,
|
||||||
z: 0.0212
|
z: 0.0212
|
||||||
}
|
},
|
||||||
|
userData: JSON.stringify({
|
||||||
|
hifiHomeKey: {
|
||||||
|
reset: true
|
||||||
|
}
|
||||||
|
})
|
||||||
|
|
||||||
});
|
});
|
||||||
|
|
||||||
// CLOCK HANDS
|
// CLOCK HANDS
|
||||||
|
@ -100,7 +111,52 @@ MyCuckooClock = function(spawnPosition, spawnRotation) {
|
||||||
y: 0.0982,
|
y: 0.0982,
|
||||||
z: 0.0024
|
z: 0.0024
|
||||||
},
|
},
|
||||||
// script: SCRIPT_URL
|
userData: JSON.stringify({
|
||||||
|
hifiHomeKey: {
|
||||||
|
reset: true
|
||||||
|
}
|
||||||
|
})
|
||||||
|
});
|
||||||
|
|
||||||
|
|
||||||
|
// **************** SECOND HAND *********************
|
||||||
|
var DEGREES_FOR_SECOND = 6;
|
||||||
|
var seconds = myDate.getSeconds();
|
||||||
|
secondRollDegrees = -seconds * DEGREES_FOR_SECOND;
|
||||||
|
var ANGULAR_ROLL_SPEED_SECOND_RADIANS = 0.10472
|
||||||
|
clockSecondHand = Entities.addEntity({
|
||||||
|
type: "Box",
|
||||||
|
parentID: clockBody,
|
||||||
|
// modelURL: CLOCK_SECOND_HAND_URL,
|
||||||
|
name: "home_model_clockSecondHand",
|
||||||
|
position: Vec3.sum(clockFacePosition, clockHandOffset),
|
||||||
|
dimensions: {
|
||||||
|
x: 0.00263,
|
||||||
|
y: 0.0982,
|
||||||
|
z: 0.0024
|
||||||
|
},
|
||||||
|
color: {
|
||||||
|
red: 200,
|
||||||
|
green: 10,
|
||||||
|
blue: 200
|
||||||
|
},
|
||||||
|
registrationPoint: {
|
||||||
|
x: 0.5,
|
||||||
|
y: 0.05,
|
||||||
|
z: 0.5
|
||||||
|
},
|
||||||
|
rotation: Quat.fromPitchYawRollDegrees(0, 0, secondRollDegrees),
|
||||||
|
angularDamping: 0,
|
||||||
|
angularVelocity: {
|
||||||
|
x: 0,
|
||||||
|
y: 0,
|
||||||
|
z: -ANGULAR_ROLL_SPEED_SECOND_RADIANS
|
||||||
|
},
|
||||||
|
userData: JSON.stringify({
|
||||||
|
hifiHomeKey: {
|
||||||
|
reset: true
|
||||||
|
}
|
||||||
|
})
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
||||||
|
@ -133,44 +189,14 @@ MyCuckooClock = function(spawnPosition, spawnRotation) {
|
||||||
z: 0.0032
|
z: 0.0032
|
||||||
},
|
},
|
||||||
script: MINUTE_HAND_CLOCK_SCRIPT_URL,
|
script: MINUTE_HAND_CLOCK_SCRIPT_URL,
|
||||||
userData: JSON.stringify({clockBody: clockBody})
|
userData: JSON.stringify({
|
||||||
|
clockBody: clockBody,
|
||||||
|
secondHand: clockSecondHand,
|
||||||
|
hifiHomeKey: {
|
||||||
|
reset: true
|
||||||
|
}
|
||||||
|
})
|
||||||
});
|
});
|
||||||
// *******************************************
|
|
||||||
|
|
||||||
var DEGREES_FOR_SECOND = 6;
|
|
||||||
var seconds = myDate.getSeconds();
|
|
||||||
secondRollDegrees = -seconds * DEGREES_FOR_SECOND;
|
|
||||||
var ANGULAR_ROLL_SPEED_SECOND_RADIANS = 0.10472
|
|
||||||
clockSecondHand = Entities.addEntity({
|
|
||||||
type: "Box",
|
|
||||||
parentID: clockBody,
|
|
||||||
// modelURL: CLOCK_SECOND_HAND_URL,
|
|
||||||
name: "home_model_clockSecondHand",
|
|
||||||
position: Vec3.sum(clockFacePosition, clockHandOffset),
|
|
||||||
dimensions: {
|
|
||||||
x: 0.00263,
|
|
||||||
y: 0.0982,
|
|
||||||
z: 0.0024
|
|
||||||
},
|
|
||||||
color: {
|
|
||||||
red: 200,
|
|
||||||
green: 10,
|
|
||||||
blue: 200
|
|
||||||
},
|
|
||||||
registrationPoint: {
|
|
||||||
x: 0.5,
|
|
||||||
y: 0.05,
|
|
||||||
z: 0.5
|
|
||||||
},
|
|
||||||
rotation: Quat.fromPitchYawRollDegrees(0, 0, secondRollDegrees),
|
|
||||||
angularDamping: 0,
|
|
||||||
angularVelocity: {
|
|
||||||
x: 0,
|
|
||||||
y: 0,
|
|
||||||
z: -ANGULAR_ROLL_SPEED_SECOND_RADIANS
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
createClock();
|
createClock();
|
||||||
|
|
|
@ -96,7 +96,7 @@
|
||||||
}, 2500);
|
}, 2500);
|
||||||
|
|
||||||
Script.setTimeout(function() {
|
Script.setTimeout(function() {
|
||||||
_this.createKineticEntities();
|
// _this.createKineticEntities();
|
||||||
_this.createDynamicEntities();
|
_this.createDynamicEntities();
|
||||||
}, 750)
|
}, 750)
|
||||||
|
|
||||||
|
@ -169,26 +169,9 @@
|
||||||
var cuckooClock = new MyCuckooClock(center);
|
var cuckooClock = new MyCuckooClock(center);
|
||||||
// var doppelganger = new Doppelganger();
|
// var doppelganger = new Doppelganger();
|
||||||
|
|
||||||
dynamicEntities.push(cuckooClock);
|
|
||||||
|
|
||||||
// dynamicEntities.push(fishTank);
|
|
||||||
// dynamicEntities.push(tiltMaze);
|
|
||||||
// dynamicEntities.push(whiteboard);
|
|
||||||
// dynamicEntities.push(myPlant);
|
|
||||||
|
|
||||||
},
|
|
||||||
|
|
||||||
cleanupDynamicEntities: function() {
|
|
||||||
if (dynamicEntities.length === 0) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
dynamicEntities.forEach(function(dynamicEntity) {
|
|
||||||
print('dynamicEntity is:: '+JSON.stringify(dynamicEntity))
|
|
||||||
dynamicEntity.cleanup();
|
|
||||||
});
|
|
||||||
|
|
||||||
},
|
},
|
||||||
|
|
||||||
|
|
||||||
createKineticEntities: function() {
|
createKineticEntities: function() {
|
||||||
|
|
||||||
var fruitBowl = new FruitBowl({
|
var fruitBowl = new FruitBowl({
|
||||||
|
|
Loading…
Reference in a new issue