mirror of
https://github.com/JulianGro/overte.git
synced 2025-04-08 03:42:27 +02:00
working opening lid for music box
This commit is contained in:
parent
30b32f27f8
commit
2667f827cf
3 changed files with 73 additions and 2 deletions
34
unpublishedScripts/DomainContent/Home/musicBox/baseBox.js
Normal file
34
unpublishedScripts/DomainContent/Home/musicBox/baseBox.js
Normal file
|
@ -0,0 +1,34 @@
|
|||
(function() {
|
||||
|
||||
var _this;
|
||||
|
||||
function BaseBox() {
|
||||
_this = this;
|
||||
return this;
|
||||
}
|
||||
|
||||
BaseBox.prototype = {
|
||||
preload: function(entityID) {
|
||||
this.entityID = entityID;
|
||||
},
|
||||
continueNearGrab: function() {
|
||||
var myProps = Entities.getEntityProperties(_this.entityID)
|
||||
var results = Entities.findEntities(myProps.position, 2);
|
||||
var lid = null;
|
||||
results.forEach(function(result) {
|
||||
var resultProps = Entities.getEntityProperties(result);
|
||||
if (resultProps.name.indexOf('music_box_lid') > -1) {
|
||||
lid = result;
|
||||
}
|
||||
});
|
||||
if (lid === null) {
|
||||
return;
|
||||
} else {
|
||||
Entities.callEntityMethod(lid, 'updateHatRotation');
|
||||
Entities.callEntityMethod(lid, 'updateKeyRotation');
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return new BaseBox
|
||||
})
|
|
@ -131,6 +131,8 @@
|
|||
|
||||
var hatHeight = scaleValue(constraint, 0, 75, 0, 0.04);
|
||||
|
||||
this.updateHatRotation();
|
||||
this.updateKeyRotation();
|
||||
Entities.editEntity(this.entityID, {
|
||||
localRotation: Quat.fromPitchYawRollDegrees(finalRotation.x, finalRotation.y, finalRotation.z)
|
||||
})
|
||||
|
@ -152,6 +154,40 @@
|
|||
|
||||
},
|
||||
|
||||
updateHatRotation: function() {
|
||||
var baseProps = Entities.getEntityProperties(_this.base);
|
||||
var localAngularVelocity = {
|
||||
x: 0,
|
||||
y: 0.785398,
|
||||
z: 0,
|
||||
};
|
||||
|
||||
var worldAngularVelocity = Vec3.multiplyQbyV(baseProps.rotation, localAngularVelocity);
|
||||
Entities.editEntity(_this.hat, {
|
||||
angularVelocity: worldAngularVelocity
|
||||
})
|
||||
|
||||
print('UPDATE HAT ANGULAR VELOCITY!' + JSON.stringify(worldAngularVelocity));
|
||||
|
||||
},
|
||||
|
||||
updateKeyRotation: function() {
|
||||
var baseProps = Entities.getEntityProperties(_this.base);
|
||||
var localAngularVelocity = {
|
||||
x: 0,
|
||||
y: 0,
|
||||
z: 0.785398,
|
||||
};
|
||||
|
||||
var worldAngularVelocity = Vec3.multiplyQbyV(baseProps.rotation, localAngularVelocity);
|
||||
Entities.editEntity(this.key, {
|
||||
angularVelocity: worldAngularVelocity
|
||||
})
|
||||
|
||||
print('UPDATE KEY ANGULAR VELOCITY!' + JSON.stringify(worldAngularVelocity));
|
||||
|
||||
},
|
||||
|
||||
playMusic: function() {
|
||||
if (this.musicIsPlaying !== true) {
|
||||
var properties = Entities.getEntityProperties(this.entityID);
|
||||
|
|
|
@ -60,7 +60,7 @@ HomeMusicBox = function(spawnPosition, spawnRotation) {
|
|||
|
||||
var LID_SCRIPT_URL = Script.resolvePath('lid.js?' + Math.random());
|
||||
|
||||
|
||||
var BASE_SCRIPT_URL = Script.resolvePath('baseBox.js?' + Math.random());
|
||||
var base, lid, hat, key;
|
||||
|
||||
function createLid(baseID) {
|
||||
|
@ -173,12 +173,13 @@ HomeMusicBox = function(spawnPosition, spawnRotation) {
|
|||
position: BASE_POSITION,
|
||||
dynamic: true,
|
||||
shapeType: 'compound',
|
||||
compoundShapeURL: 'atp:/boxHull2.obj',
|
||||
compoundShapeURL: 'atp:/boxHull3.obj',
|
||||
dimensions: {
|
||||
x: 0.1661,
|
||||
y: 0.0928,
|
||||
z: 0.2022
|
||||
},
|
||||
script: BASE_SCRIPT_URL,
|
||||
userData: JSON.stringify({
|
||||
'hifiHomeKey': {
|
||||
'reset': true
|
||||
|
|
Loading…
Reference in a new issue