mirror of
https://github.com/overte-org/overte.git
synced 2025-08-08 10:37:35 +02:00
most of a music box
This commit is contained in:
parent
d833c52e4b
commit
e780e46d5f
6 changed files with 266 additions and 242 deletions
|
@ -21,7 +21,6 @@
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
function startUpdate() {
|
function startUpdate() {
|
||||||
print("EBL Start CLOCK Update")
|
print("EBL Start CLOCK Update")
|
||||||
//when the baton is claimed;
|
//when the baton is claimed;
|
||||||
|
@ -101,7 +100,6 @@
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
|
|
||||||
update: function() {
|
update: function() {
|
||||||
|
|
||||||
if (iOwn === false) {
|
if (iOwn === false) {
|
||||||
|
@ -122,20 +120,14 @@
|
||||||
var seconds = date.getSeconds();
|
var seconds = date.getSeconds();
|
||||||
var minutes = date.getMinutes();
|
var minutes = date.getMinutes();
|
||||||
|
|
||||||
if (seconds === 0 && minutes === 0) {
|
if (minutes % 15 === 0 && seconds === 0) {
|
||||||
_this.popCuckooOut();
|
|
||||||
}
|
|
||||||
// if (seconds % 30 === 0) {
|
|
||||||
// _this.popCuckooOut();
|
|
||||||
// }
|
|
||||||
|
|
||||||
if(minutes%15===0){
|
|
||||||
_this.popCuckooOut();
|
_this.popCuckooOut();
|
||||||
}
|
}
|
||||||
|
|
||||||
},
|
},
|
||||||
|
|
||||||
popCuckooOut: function() {
|
popCuckooOut: function() {
|
||||||
|
_this.checkTime = false;
|
||||||
// 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!!!!!!!!!!!");
|
||||||
|
@ -155,7 +147,6 @@
|
||||||
currentFrame: 0
|
currentFrame: 0
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
_this.checkTime = false;
|
|
||||||
Script.setTimeout(function() {
|
Script.setTimeout(function() {
|
||||||
_this.checkTime = true;
|
_this.checkTime = true;
|
||||||
}, _this.TIME_CHECK_REFRACTORY_PERIOD);
|
}, _this.TIME_CHECK_REFRACTORY_PERIOD);
|
||||||
|
|
|
@ -74,7 +74,6 @@ Plant = function(spawnPosition, spawnRotation) {
|
||||||
});
|
});
|
||||||
|
|
||||||
var WATER_CAN_MODEL_URL = "atp:/growingPlant/waterCan.fbx";
|
var WATER_CAN_MODEL_URL = "atp:/growingPlant/waterCan.fbx";
|
||||||
var WATER_CAN_COLLIISION_HULL_URL = "atp:/growingPlant/can.obj";
|
|
||||||
|
|
||||||
var waterCanPosition = Vec3.sum(plantPosition, Vec3.multiply(0.6, Quat.getRight(orientation)));
|
var waterCanPosition = Vec3.sum(plantPosition, Vec3.multiply(0.6, Quat.getRight(orientation)));
|
||||||
var waterCanRotation = orientation;
|
var waterCanRotation = orientation;
|
||||||
|
|
|
@ -10,32 +10,39 @@
|
||||||
}
|
}
|
||||||
|
|
||||||
var MUSIC_URL = Script.resolvePath('http://hifi-content.s3.amazonaws.com/DomainContent/Home/musicBox/music_converted.wav');
|
var MUSIC_URL = Script.resolvePath('http://hifi-content.s3.amazonaws.com/DomainContent/Home/musicBox/music_converted.wav');
|
||||||
var SHUT_SOUND_URL = Script.resolvePath('http://hifi-content.s3.amazonaws.com/DomainContent/Home/Sounds/book_fall.L.wav');
|
// var SHUT_SOUND_URL = Script.resolvePath('http://hifi-content.s3.amazonaws.com/DomainContent/Home/Sounds/book_fall.L.wav');
|
||||||
var OPEN_SOUND_URL = Script.resolvePath('http://public.highfidelity.io/sounds/Switches%20and%20sliders/lamp_switch_2.wav');
|
// var OPEN_SOUND_URL = Script.resolvePath('http://public.highfidelity.io/sounds/Switches%20and%20sliders/lamp_switch_2.wav');
|
||||||
var BASE_ANIMATION_URL = 'http://hifi-content.s3.amazonaws.com/DomainContent/Home/musicBox/MusicBoxAnimated2.fbx';
|
var SHUT_SOUND_URL = Script.resolvePath('atp:/openSound.wav');
|
||||||
|
var OPEN_SOUND_URL = Script.resolvePath('atp:/closeSound.wav');
|
||||||
|
|
||||||
Lid.prototype = {
|
Lid.prototype = {
|
||||||
musicInjector: null,
|
musicInjector: null,
|
||||||
playingByClick: false,
|
|
||||||
preload: function(entityID) {
|
preload: function(entityID) {
|
||||||
_this.entityID = entityID;
|
this.entityID = entityID;
|
||||||
_this.music = SoundCache.getSound(MUSIC_URL);
|
this.music = SoundCache.getSound(MUSIC_URL);
|
||||||
_this.shutSound = SoundCache.getSound(SHUT_SOUND_URL);
|
this.shutSound = SoundCache.getSound(SHUT_SOUND_URL);
|
||||||
_this.openSound = SoundCache.getSound(OPEN_SOUND_URL);
|
this.openSound = SoundCache.getSound(OPEN_SOUND_URL);
|
||||||
_this.musicIsPlaying = false;
|
|
||||||
_this.shut = true;
|
print('OPEN SOUND?? ' + this.openSound)
|
||||||
_this.shutSoundInjector = {
|
this.musicIsPlaying = false;
|
||||||
|
this.shut = true;
|
||||||
|
this.shutSoundInjector = {
|
||||||
isPlaying: false
|
isPlaying: false
|
||||||
};
|
};
|
||||||
_this.musicInjector = null;
|
this.musicInjector = null;
|
||||||
_this.openSoundInjector = {
|
this.openSoundInjector = {
|
||||||
isPlaying: false
|
isPlaying: false
|
||||||
}
|
}
|
||||||
_this.getBase();
|
this.getParts();
|
||||||
|
this.props = Entities.getEntityProperties(this.entityID);
|
||||||
|
},
|
||||||
|
|
||||||
|
updateSoundPositionWhileBaseIsHeld: function() {
|
||||||
|
|
||||||
},
|
},
|
||||||
|
|
||||||
startNearTrigger: function() {
|
startNearTrigger: function() {
|
||||||
this.getBase();
|
this.getParts();
|
||||||
},
|
},
|
||||||
|
|
||||||
continueNearTrigger: function() {
|
continueNearTrigger: function() {
|
||||||
|
@ -59,9 +66,9 @@
|
||||||
},
|
},
|
||||||
|
|
||||||
stopMusic: function() {
|
stopMusic: function() {
|
||||||
|
this.musicIsPlaying = false;
|
||||||
if (this.musicInjector !== null) {
|
if (this.musicInjector !== null) {
|
||||||
this.musicInjector.stop();
|
this.musicInjector.stop();
|
||||||
this.musicIsPlaying = false;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
},
|
},
|
||||||
|
@ -77,10 +84,12 @@
|
||||||
loop: false
|
loop: false
|
||||||
}
|
}
|
||||||
this.openSoundInjector = Audio.playSound(this.openSound, audioOptions);
|
this.openSoundInjector = Audio.playSound(this.openSound, audioOptions);
|
||||||
|
print('this oppen soundinejctopr' + JSON.stringify(this.openSoundInjector))
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
playShutSound: function() {
|
playShutSound: function() {
|
||||||
|
print('shut injector' + JSON.stringify(this.shutSoundInjector));
|
||||||
if (this.shutSoundInjector.isPlaying !== true) {
|
if (this.shutSoundInjector.isPlaying !== true) {
|
||||||
|
|
||||||
var properties = Entities.getEntityProperties(this.entityID);
|
var properties = Entities.getEntityProperties(this.entityID);
|
||||||
|
@ -114,10 +123,10 @@
|
||||||
|
|
||||||
|
|
||||||
//this might be z now that its roll
|
//this might be z now that its roll
|
||||||
var constraint = finalRotation.x
|
var constraint = finalRotation.z
|
||||||
|
|
||||||
var MIN_LID_ROTATION = 0;
|
var MIN_LID_ROTATION = 0;
|
||||||
var MAX_LID_ROTAITON = 75;
|
var MAX_LID_ROTATION = 75;
|
||||||
|
|
||||||
//handle sound on open, close, and actually play the song
|
//handle sound on open, close, and actually play the song
|
||||||
if (constraint > 20 && this.musicIsPlaying === false) {
|
if (constraint > 20 && this.musicIsPlaying === false) {
|
||||||
|
@ -132,10 +141,14 @@
|
||||||
print('play open sound!!')
|
print('play open sound!!')
|
||||||
this.shut = false;
|
this.shut = false;
|
||||||
this.playOpenSound();
|
this.playOpenSound();
|
||||||
|
this.startHat();
|
||||||
|
this.startKey();
|
||||||
} else if (constraint <= 0 && this.shut === false) {
|
} else if (constraint <= 0 && this.shut === false) {
|
||||||
print('play shut sound!!')
|
print('play shut sound!!')
|
||||||
this.shut = true;
|
this.shut = true;
|
||||||
this.playShutSound();
|
this.playShutSound();
|
||||||
|
this.stopKey();
|
||||||
|
this.stopHat();
|
||||||
}
|
}
|
||||||
|
|
||||||
//handle scaling the lid angle to the animation frame
|
//handle scaling the lid angle to the animation frame
|
||||||
|
@ -144,147 +157,88 @@
|
||||||
|
|
||||||
//scale for going up down, and then spin when fully open ;)
|
//scale for going up down, and then spin when fully open ;)
|
||||||
|
|
||||||
var currentFrame = scaleValue(constraint, MIN_LID_ROTATION, MAX_LID_ROTAITON, 0, 30)
|
var hatHeight = scaleValue(constraint, MIN_LID_ROTATION, MAX_LID_ROTATION, 0, 0.04);
|
||||||
|
|
||||||
var animation;
|
|
||||||
|
|
||||||
if (finalRotation.x === 75) {
|
|
||||||
animation = {
|
|
||||||
loop: true,
|
|
||||||
firstFrame: 30,
|
|
||||||
lastFrame: 90,
|
|
||||||
running: true,
|
|
||||||
animationFPS: 30,
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
animation = {
|
|
||||||
url: BASE_ANIMATION_URL,
|
|
||||||
running: false,
|
|
||||||
currentFrame: currentFrame,
|
|
||||||
firstFrame: 0,
|
|
||||||
lastFrame: 30
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
Entities.editEntity(this.entityID, {
|
Entities.editEntity(this.entityID, {
|
||||||
rotation: Quat.fromPitchYawRollDegrees(finalRotation.x, finalRotation.y, finalRotation.z)
|
rotation: Quat.fromPitchYawRollDegrees(finalRotation.x, finalRotation.y, finalRotation.z)
|
||||||
})
|
})
|
||||||
|
|
||||||
Entities.editEntity(this.base, {
|
var VERTICAL_OFFSET = 0.025;
|
||||||
animation: animation
|
var FORWARD_OFFSET = 0.0;
|
||||||
|
var LATERAL_OFFSET = 0.0;
|
||||||
|
|
||||||
|
var hatOffset = getOffsetFromCenter(VERTICAL_OFFSET, FORWARD_OFFSET, LATERAL_OFFSET)
|
||||||
|
var upOffset = Vec3.sum({
|
||||||
|
x: 0,
|
||||||
|
y: hatHeight,
|
||||||
|
z: 0
|
||||||
|
}, hatOffset)
|
||||||
|
Entities.editEntity(this.hat, {
|
||||||
|
position: upOffset
|
||||||
})
|
})
|
||||||
|
|
||||||
},
|
},
|
||||||
|
|
||||||
clickDownOnEntity: function() {
|
getParts: function() {
|
||||||
this.getBase();
|
var properties = Entities.getEntityProperties(this.entityID);
|
||||||
if (this.playingByClick === false) {
|
var results = Entities.findEntities(properties.position, 2);
|
||||||
this.playingByClick = true;
|
results.forEach(function(result) {
|
||||||
this.playByClick();
|
|
||||||
} else {
|
|
||||||
this.playingByClick = false;
|
|
||||||
this.stopByClick();
|
|
||||||
}
|
|
||||||
},
|
|
||||||
|
|
||||||
clickReleaseOnEntity: function() {
|
var props = Entities.getEntityProperties(result);
|
||||||
|
|
||||||
|
if (props.name === 'home_music_box_base') {
|
||||||
},
|
print('FOUND BASE');
|
||||||
|
_this.base = result;
|
||||||
playByClick: function() {
|
_this.baseProps = props;
|
||||||
|
|
||||||
//turn music on
|
|
||||||
this.playMusic();
|
|
||||||
var animation;
|
|
||||||
//play frames 0 to 30 and
|
|
||||||
animation = {
|
|
||||||
url: BASE_ANIMATION_URL,
|
|
||||||
running: true,
|
|
||||||
firstFrame: 0,
|
|
||||||
lastFrame: 30,
|
|
||||||
animationFPS: 30
|
|
||||||
};
|
|
||||||
Entities.editEntity(this.base, {
|
|
||||||
animation: animation
|
|
||||||
});
|
|
||||||
// rotate the lid,
|
|
||||||
|
|
||||||
//then hold at 30-90
|
|
||||||
Script.setTimeout(function() {
|
|
||||||
animation = {
|
|
||||||
running: true,
|
|
||||||
firstFrame: 30,
|
|
||||||
lastFrame: 90,
|
|
||||||
animationFPS: 30,
|
|
||||||
loop: true,
|
|
||||||
}
|
}
|
||||||
Entities.editEntity(_this.base, {
|
|
||||||
animation: animation
|
|
||||||
});
|
|
||||||
}, 1000);
|
|
||||||
|
|
||||||
},
|
if (props.name === 'home_music_box_key') {
|
||||||
|
print('FOUND KEY')
|
||||||
stopByClick: function() {
|
_this.key = result;
|
||||||
|
_this.keyProps = props;
|
||||||
var animation;
|
|
||||||
//play frames 90-120 then stop animating
|
|
||||||
|
|
||||||
animation = {
|
|
||||||
running: true,
|
|
||||||
firstFrame: 90,
|
|
||||||
lastFrame: 120,
|
|
||||||
animationFPS: 30
|
|
||||||
};
|
|
||||||
Entities.editEntity(this.base, {
|
|
||||||
animation: animation
|
|
||||||
});
|
|
||||||
Script.setTimeout(function() {
|
|
||||||
//turn music off
|
|
||||||
_this.stopMusic();
|
|
||||||
animation = {
|
|
||||||
currentFrame: 120,
|
|
||||||
firstFrame: 120,
|
|
||||||
lastFrame: 120,
|
|
||||||
loop: false,
|
|
||||||
animationFPS: 0,
|
|
||||||
running: false
|
|
||||||
}
|
}
|
||||||
Entities.editEntity(_this.base, {
|
|
||||||
animation: animation
|
|
||||||
});
|
|
||||||
print('should stop')
|
|
||||||
}, 1000)
|
|
||||||
|
|
||||||
|
if (props.name === 'home_music_box_hat') {
|
||||||
|
print('FOUND HAT')
|
||||||
|
_this.hat = result;
|
||||||
|
_this.hatProps = props;
|
||||||
|
}
|
||||||
|
|
||||||
|
})
|
||||||
},
|
},
|
||||||
|
|
||||||
playThroughToClose: function() {
|
startHat: function() {
|
||||||
|
Entities.editEntity(this.hat, {
|
||||||
|
angularDamping: 0,
|
||||||
|
angularVelocity: {
|
||||||
|
x: 0,
|
||||||
|
y: 0.785398,
|
||||||
|
z: 0,
|
||||||
|
}
|
||||||
|
})
|
||||||
},
|
},
|
||||||
|
|
||||||
getBase: function() {
|
startKey: function() {
|
||||||
var props = Entities.getEntityProperties(this.entityID);
|
Entities.editEntity(this.key, {
|
||||||
var data = JSON.parse(props.userData);
|
angularDamping: 0,
|
||||||
var base = data["hifiHomeKey"].musicBoxBase;
|
angularVelocity: {
|
||||||
print('base is: ' + base);
|
x: 0,
|
||||||
this.base = base;
|
y: 0,
|
||||||
|
z: 0.785398,
|
||||||
|
}
|
||||||
|
})
|
||||||
},
|
},
|
||||||
|
|
||||||
rotateHat: function() {
|
stopHat: function() {
|
||||||
|
Entities.editEntity(this.hat, {
|
||||||
|
angularDamping: 0.5,
|
||||||
|
});
|
||||||
},
|
},
|
||||||
|
|
||||||
rotateKey: function() {
|
stopKey: function() {
|
||||||
|
Entities.editEntity(this.key, {
|
||||||
},
|
angularDamping: 0.5,
|
||||||
|
});
|
||||||
raiseHat: function() {
|
|
||||||
|
|
||||||
},
|
|
||||||
|
|
||||||
lowerHat: function() {
|
|
||||||
|
|
||||||
},
|
},
|
||||||
|
|
||||||
unload: function() {
|
unload: function() {
|
||||||
|
@ -298,6 +252,26 @@
|
||||||
return min2 + (max2 - min2) * ((value - min1) / (max1 - min1));
|
return min2 + (max2 - min2) * ((value - min1) / (max1 - min1));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function getOffsetFromCenter(VERTICAL_OFFSET, FORWARD_OFFSET, LATERAL_OFFSET) {
|
||||||
|
|
||||||
|
var properties = Entities.getEntityProperties(_this.base);
|
||||||
|
|
||||||
|
var upVector = Quat.getUp(properties.rotation);
|
||||||
|
var frontVector = Quat.getFront(properties.rotation);
|
||||||
|
var rightVector = Quat.getRight(properties.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(properties.position, upOffset);
|
||||||
|
finalOffset = Vec3.sum(finalOffset, frontOffset);
|
||||||
|
finalOffset = Vec3.sum(finalOffset, rightOffset);
|
||||||
|
|
||||||
|
return finalOffset
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
return new Lid();
|
return new Lid();
|
||||||
})
|
})
|
|
@ -60,65 +60,32 @@ HomeMusicBox = function(spawnPosition, spawnRotation) {
|
||||||
|
|
||||||
var LID_SCRIPT_URL = Script.resolvePath('lid.js?' + Math.random());
|
var LID_SCRIPT_URL = Script.resolvePath('lid.js?' + Math.random());
|
||||||
|
|
||||||
var LID_MODEL_URL = 'http://hifi-content.s3.amazonaws.com/DomainContent/Home/musicBox/MusicBoxLid.fbx';
|
|
||||||
var BASE_MODEL_URL = 'http://hifi-content.s3.amazonaws.com/DomainContent/Home/musicBox/MusicBoxAnimated2.fbx';
|
|
||||||
var BASE_ANIMATION_URL = 'http://hifi-content.s3.amazonaws.com/DomainContent/Home/musicBox/MusicBoxAnimated2.fbx';
|
|
||||||
|
|
||||||
var base, lid, hat, key;
|
var base, lid, hat, key;
|
||||||
|
|
||||||
function createBase() {
|
|
||||||
var baseProperties = {
|
|
||||||
name: 'hifi-home-music-box-base',
|
|
||||||
type: 'Model',
|
|
||||||
modelURL: BASE_MODEL_URL,
|
|
||||||
position: BASE_POSITION,
|
|
||||||
dimensions: BASE_DIMENSIONS,
|
|
||||||
animation: {
|
|
||||||
url: BASE_ANIMATION_URL,
|
|
||||||
running: false,
|
|
||||||
currentFrame: 0,
|
|
||||||
firstFrame: 0,
|
|
||||||
lastFrame: 120,
|
|
||||||
loop: false
|
|
||||||
},
|
|
||||||
userData: JSON.stringify({
|
|
||||||
'hifiHomeKey': {
|
|
||||||
'reset': true
|
|
||||||
}
|
|
||||||
}),
|
|
||||||
}
|
|
||||||
|
|
||||||
base = Entities.addEntity(baseProperties);
|
|
||||||
createLid(base);
|
|
||||||
};
|
|
||||||
|
|
||||||
|
|
||||||
function createLid(baseID) {
|
function createLid(baseID) {
|
||||||
|
|
||||||
var baseProps = Entities.getEntityProperties(baseID);
|
var baseProps = Entities.getEntityProperties(baseID);
|
||||||
var frontVector = Quat.getFront(baseProps.rotation);
|
var VERTICAL_OFFSET = 0.05;
|
||||||
var rightVector = Quat.getRight(baseProps.rotation);
|
var FORWARD_OFFSET = 0;
|
||||||
var backVector = Vec3.multiply(-1, frontVector);
|
var LATERAL_OFFSET = -0.070;
|
||||||
var backOffset = 0.0125;
|
|
||||||
var backPosition = baseProps.position;
|
var startPosition = getOffsetFromCenter(VERTICAL_OFFSET, FORWARD_OFFSET, LATERAL_OFFSET);
|
||||||
var backPosition = Vec3.sum(baseProps.position, Vec3.multiply(backOffset, backVector));
|
|
||||||
backPosition.y = backPosition.y += (BASE_DIMENSIONS.y / 2)
|
|
||||||
|
|
||||||
print('backPosition' + JSON.stringify(backPosition));
|
|
||||||
var lidProperties = {
|
var lidProperties = {
|
||||||
name: 'hifi-home-music-box-lid',
|
name: 'home_music_box_lid',
|
||||||
type: 'Model',
|
type: 'Model',
|
||||||
modelURL: LID_MODEL_URL,
|
modelURL: 'atp:/MB_Lid.fbx',
|
||||||
dimensions: LID_DIMENSIONS,
|
dimensions: LID_DIMENSIONS,
|
||||||
position: baseProps.position,
|
position: startPosition,
|
||||||
|
parentID: baseID,
|
||||||
registrationPoint: LID_REGISTRATION_POINT,
|
registrationPoint: LID_REGISTRATION_POINT,
|
||||||
dynamic: false,
|
dynamic: false,
|
||||||
script: LID_SCRIPT_URL,
|
script: LID_SCRIPT_URL,
|
||||||
collidesWith: 'myAvatar,otherAvatar',
|
collidesWith: 'myAvatar,otherAvatar',
|
||||||
userData: JSON.stringify({
|
userData: JSON.stringify({
|
||||||
'hifiHomeKey': {
|
'hifiHomeKey': {
|
||||||
'reset': true,
|
'reset': true
|
||||||
'musicBoxBase': baseID
|
|
||||||
},
|
},
|
||||||
grabConstraintsKey: {
|
grabConstraintsKey: {
|
||||||
callback: 'rotateLid',
|
callback: 'rotateLid',
|
||||||
|
@ -132,8 +99,8 @@ HomeMusicBox = function(spawnPosition, spawnRotation) {
|
||||||
min: 0,
|
min: 0,
|
||||||
max: 75,
|
max: 75,
|
||||||
startingAxis: 'y',
|
startingAxis: 'y',
|
||||||
startingPoint: backPosition.y,
|
startingPoint: startPosition.y,
|
||||||
distanceToMax: backPosition.y + 0.35
|
distanceToMax: startPosition.y + 0.35
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
@ -142,69 +109,134 @@ HomeMusicBox = function(spawnPosition, spawnRotation) {
|
||||||
disableReleaseVelocity: true
|
disableReleaseVelocity: true
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
}
|
};
|
||||||
|
|
||||||
lid = Entities.addEntity(lidProperties);
|
lid = Entities.addEntity(lidProperties);
|
||||||
createKey(baseID)
|
createKey(baseID);
|
||||||
createHat(baseID)
|
createHat(baseID);
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
function createHat(baseID) {
|
function createHat(baseID) {
|
||||||
|
var VERTICAL_OFFSET = 0.025;
|
||||||
|
var FORWARD_OFFSET = 0.0;
|
||||||
|
var LATERAL_OFFSET = 0.0;
|
||||||
|
|
||||||
var properties = {
|
var properties = {
|
||||||
name: 'hifi-home-music-box-hat',
|
modelURL: "atp:/MB_Hat.fbx",
|
||||||
type: 'Box',
|
name: 'home_music_box_hat',
|
||||||
|
type: 'Model',
|
||||||
|
position: getOffsetFromCenter(VERTICAL_OFFSET, FORWARD_OFFSET, LATERAL_OFFSET),
|
||||||
parentID: baseID,
|
parentID: baseID,
|
||||||
dimensions: {
|
dimensions: {
|
||||||
x: 0.1,
|
x: 0.0786,
|
||||||
y: 0.1,
|
y: 0.0549,
|
||||||
z: 0.1
|
z: 0.0810
|
||||||
},
|
},
|
||||||
}
|
dynamic: true,
|
||||||
|
angularDamping: 1,
|
||||||
|
angularVelocity: {
|
||||||
|
x: 0,
|
||||||
|
y: 0.785398,
|
||||||
|
z: 0,
|
||||||
|
},
|
||||||
|
userData: JSON.stringify({
|
||||||
|
'hifiHomeKey': {
|
||||||
|
'reset': true
|
||||||
|
},
|
||||||
|
'musicBoxKey': {
|
||||||
|
'startPosition': getOffsetFromCenter(VERTICAL_OFFSET, FORWARD_OFFSET, LATERAL_OFFSET)
|
||||||
|
}
|
||||||
|
})
|
||||||
|
};
|
||||||
|
|
||||||
hat = Entities.addEntity(properties);
|
hat = Entities.addEntity(properties);
|
||||||
}
|
};
|
||||||
|
|
||||||
function createKey(baseID) {
|
function createKey(baseID) {
|
||||||
var properties = {
|
var VERTICAL_OFFSET = 0.0;
|
||||||
name: 'hifi-home-music-box-key',
|
var FORWARD_OFFSET = 0.11;
|
||||||
type: 'Box',
|
var LATERAL_OFFSET = 0.0;
|
||||||
parentID: baseID,
|
|
||||||
dimensions: {
|
|
||||||
x: 0.1,
|
|
||||||
y: 0.1,
|
|
||||||
z: 0.1
|
|
||||||
},
|
|
||||||
}
|
|
||||||
key = Entities.addEntity(properties);
|
|
||||||
|
|
||||||
}
|
var properties = {
|
||||||
|
modelURL: "atp:/MB_Key.fbx",
|
||||||
|
name: 'home_music_box_key',
|
||||||
|
type: 'Model',
|
||||||
|
parentID: baseID,
|
||||||
|
angularDamping:1,
|
||||||
|
angularVelocity: {
|
||||||
|
x: 0,
|
||||||
|
y: 0,
|
||||||
|
z: 0.785398,
|
||||||
|
},
|
||||||
|
position: getOffsetFromCenter(VERTICAL_OFFSET, FORWARD_OFFSET, LATERAL_OFFSET),
|
||||||
|
dimensions: {
|
||||||
|
x: 0.0057,
|
||||||
|
y: 0.0482,
|
||||||
|
z: 0.0435
|
||||||
|
},
|
||||||
|
userData: JSON.stringify({
|
||||||
|
'hifiHomeKey': {
|
||||||
|
'reset': true
|
||||||
|
}
|
||||||
|
})
|
||||||
|
};
|
||||||
|
|
||||||
|
key = Entities.addEntity(properties);
|
||||||
|
};
|
||||||
|
|
||||||
function createBaseBox() {
|
function createBaseBox() {
|
||||||
var properties = {
|
|
||||||
name: 'hifi-home-music-box-base',
|
|
||||||
type: 'Box',
|
|
||||||
dimensions: {
|
|
||||||
x: 0.1,
|
|
||||||
y: 0.1,
|
|
||||||
z: 0.1
|
|
||||||
},
|
|
||||||
}
|
|
||||||
base = Entities.addEntity(properties);
|
|
||||||
|
|
||||||
}
|
var properties = {
|
||||||
|
modelURL: "atp:/MB_Box.fbx",
|
||||||
|
name: 'home_music_box_base',
|
||||||
|
type: 'Model',
|
||||||
|
position: BASE_POSITION,
|
||||||
|
dimensions: {
|
||||||
|
x: 0.1661,
|
||||||
|
y: 0.0928,
|
||||||
|
z: 0.2022
|
||||||
|
},
|
||||||
|
userData: JSON.stringify({
|
||||||
|
'hifiHomeKey': {
|
||||||
|
'reset': true
|
||||||
|
}
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
base = Entities.addEntity(properties);
|
||||||
|
createLid(base);
|
||||||
|
};
|
||||||
|
|
||||||
function cleanup() {
|
function cleanup() {
|
||||||
Entities.deleteEntity(base);
|
Entities.deleteEntity(base);
|
||||||
Entities.deleteEntity(lid);
|
Entities.deleteEntity(lid);
|
||||||
Entities.deleteEntity(key);
|
Entities.deleteEntity(key);
|
||||||
Entities.deleteEntity(hat);
|
Entities.deleteEntity(hat);
|
||||||
}
|
};
|
||||||
|
|
||||||
|
function getOffsetFromCenter(VERTICAL_OFFSET, FORWARD_OFFSET, LATERAL_OFFSET) {
|
||||||
|
|
||||||
|
var properties = Entities.getEntityProperties(base);
|
||||||
|
|
||||||
|
var upVector = Quat.getUp(properties.rotation);
|
||||||
|
var frontVector = Quat.getFront(properties.rotation);
|
||||||
|
var rightVector = Quat.getRight(properties.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(properties.position, upOffset);
|
||||||
|
finalOffset = Vec3.sum(finalOffset, frontOffset);
|
||||||
|
finalOffset = Vec3.sum(finalOffset, rightOffset);
|
||||||
|
|
||||||
|
return finalOffset
|
||||||
|
};
|
||||||
|
|
||||||
this.cleanup = cleanup;
|
this.cleanup = cleanup;
|
||||||
|
|
||||||
createBase();
|
createBaseBox();
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
|
@ -67,9 +67,24 @@
|
||||||
});
|
});
|
||||||
|
|
||||||
// Once user releases eraser, wait a bit then put marker back to its original position and rotation
|
// Once user releases eraser, wait a bit then put marker back to its original position and rotation
|
||||||
Script.setTimeout(function() {
|
// Script.setTimeout(function() {
|
||||||
|
// var userData = getEntityUserData(_this.entityID);
|
||||||
|
// Entities.editEntity(_this.entityID, {
|
||||||
|
// position: userData.originalPosition,
|
||||||
|
// rotation: userData.originalRotation,
|
||||||
|
// velocity: {
|
||||||
|
// x: 0,
|
||||||
|
// y: -0.01,
|
||||||
|
// z: 0
|
||||||
|
// }
|
||||||
|
// });
|
||||||
|
// }, _this.ERASER_RESET_WAIT_TIME);
|
||||||
|
},
|
||||||
|
collisionWithEntity: function(myID, otherID, collision) {
|
||||||
|
var otherProps = Entities.getEntityProperties(otherID);
|
||||||
|
if (otherProps.name === 'home_model_homeset') {
|
||||||
var userData = getEntityUserData(_this.entityID);
|
var userData = getEntityUserData(_this.entityID);
|
||||||
Entities.editEntity(_this.entityID, {
|
Entities.editEntity(_this.entityID) {
|
||||||
position: userData.originalPosition,
|
position: userData.originalPosition,
|
||||||
rotation: userData.originalRotation,
|
rotation: userData.originalRotation,
|
||||||
velocity: {
|
velocity: {
|
||||||
|
@ -77,12 +92,11 @@
|
||||||
y: -0.01,
|
y: -0.01,
|
||||||
z: 0
|
z: 0
|
||||||
}
|
}
|
||||||
});
|
}
|
||||||
}, _this.ERASER_RESET_WAIT_TIME);
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
preload: function(entityID) {
|
preload: function(entityID) {
|
||||||
_this.entityID = entityID;
|
_this.entityID = entityID;
|
||||||
_this.searchSphere = Overlays.addOverlay('sphere', {
|
_this.searchSphere = Overlays.addOverlay('sphere', {
|
||||||
|
|
|
@ -49,7 +49,7 @@
|
||||||
_this.equipped = true;
|
_this.equipped = true;
|
||||||
_this.hand = params[0] == "left" ? 0 : 1;
|
_this.hand = params[0] == "left" ? 0 : 1;
|
||||||
_this.markerColor = getEntityUserData(_this.entityID).markerColor;
|
_this.markerColor = getEntityUserData(_this.entityID).markerColor;
|
||||||
// search for whiteboards
|
// search for whiteboards
|
||||||
var markerPosition = Entities.getEntityProperties(_this.entityID, "position").position;
|
var markerPosition = Entities.getEntityProperties(_this.entityID, "position").position;
|
||||||
var entities = Entities.findEntities(markerPosition, 10);
|
var entities = Entities.findEntities(markerPosition, 10);
|
||||||
entities.forEach(function(entity) {
|
entities.forEach(function(entity) {
|
||||||
|
@ -68,9 +68,25 @@
|
||||||
});
|
});
|
||||||
|
|
||||||
// Once user releases marker, wait a bit then put marker back to its original position and rotation
|
// Once user releases marker, wait a bit then put marker back to its original position and rotation
|
||||||
Script.setTimeout(function() {
|
// Script.setTimeout(function() {
|
||||||
|
// var userData = getEntityUserData(_this.entityID);
|
||||||
|
// Entities.editEntity(_this.entityID, {
|
||||||
|
// position: userData.originalPosition,
|
||||||
|
// rotation: userData.originalRotation,
|
||||||
|
// velocity: {
|
||||||
|
// x: 0,
|
||||||
|
// y: -0.01,
|
||||||
|
// z: 0
|
||||||
|
// }
|
||||||
|
// });
|
||||||
|
// }, _this.MARKER_RESET_WAIT_TIME);
|
||||||
|
},
|
||||||
|
|
||||||
|
collisionWithEntity: function(myID, otherID, collision) {
|
||||||
|
var otherProps = Entities.getEntityProperties(otherID);
|
||||||
|
if (otherProps.name === 'home_model_homeset') {
|
||||||
var userData = getEntityUserData(_this.entityID);
|
var userData = getEntityUserData(_this.entityID);
|
||||||
Entities.editEntity(_this.entityID, {
|
Entities.editEntity(_this.entityID) {
|
||||||
position: userData.originalPosition,
|
position: userData.originalPosition,
|
||||||
rotation: userData.originalRotation,
|
rotation: userData.originalRotation,
|
||||||
velocity: {
|
velocity: {
|
||||||
|
@ -78,11 +94,9 @@
|
||||||
y: -0.01,
|
y: -0.01,
|
||||||
z: 0
|
z: 0
|
||||||
}
|
}
|
||||||
});
|
}
|
||||||
}, _this.MARKER_RESET_WAIT_TIME);
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
|
|
||||||
continueEquip: function() {
|
continueEquip: function() {
|
||||||
// cast a ray from marker and see if it hits anything
|
// cast a ray from marker and see if it hits anything
|
||||||
var markerProps = Entities.getEntityProperties(_this.entityID, ["position", "rotation"]);
|
var markerProps = Entities.getEntityProperties(_this.entityID, ["position", "rotation"]);
|
||||||
|
|
Loading…
Reference in a new issue