Merge pull request #7866 from imgntn/firePit

[Home] Updates to content
This commit is contained in:
James B. Pollack 2016-05-12 13:48:40 -07:00
commit e92b4029b2
4 changed files with 244 additions and 45 deletions

View file

@ -9,7 +9,7 @@
// Distributed under the Apache License, Version 2.0.
// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html
var MINUTE_HAND_CLOCK_SCRIPT_URL = Script.resolvePath("cuckooClockMinuteHandEntityScript.js" )
var MINUTE_HAND_CLOCK_SCRIPT_URL = Script.resolvePath("cuckooClockMinuteHandEntityScript.js")
var CLOCK_BODY_URL = "atp:/cuckooClock/cuckoo2_BODY.fbx";
var CLOCK_BODY_COLLISION_HULL_URL = "atp:/cuckooClock/clockHull.obj";
var CLOCK_FACE_URL = "atp:/cuckooClock/cuckooClock2_FACE.fbx";
@ -38,11 +38,11 @@ MyCuckooClock = function(spawnPosition, spawnRotation) {
},
position: spawnPosition,
rotation: clockRotation,
dimensions: {
dimensions: Vec3.multiply(0.5, {
x: 0.8181,
y: 1.3662,
z: 0.8181
},
}),
userData: JSON.stringify({
hifiHomeKey: {
reset: true
@ -50,9 +50,9 @@ MyCuckooClock = function(spawnPosition, spawnRotation) {
})
})
var forwardOffset = -0.13
var upOffset = 0.255;
var sideOffset = -0.03;
var forwardOffset = 0.5 * -0.13;
var upOffset = 0.5 * 0.255;
var sideOffset = 0.5 * -0.03;
var clockFacePosition = spawnPosition;
clockFacePosition = Vec3.sum(clockFacePosition, Vec3.multiply(Quat.getFront(clockRotation), forwardOffset));
clockFacePosition = Vec3.sum(clockFacePosition, Vec3.multiply(Quat.getUp(clockRotation), upOffset));
@ -65,11 +65,11 @@ MyCuckooClock = function(spawnPosition, spawnRotation) {
name: "home_model_clockFace",
modelURL: CLOCK_FACE_URL,
position: clockFacePosition,
dimensions: {
dimensions: Vec3.multiply(0.5, {
x: 0.2397,
y: 0.2402,
z: 0.0212
},
}),
userData: JSON.stringify({
hifiHomeKey: {
reset: true
@ -86,7 +86,7 @@ MyCuckooClock = function(spawnPosition, spawnRotation) {
var myDate = new Date()
// HOUR HAND *************************
var clockHandForwardOffset = -0.017;
var clockHandForwardOffset = (0.5 * -0.017);
var hourHandPosition = Vec3.sum(clockFacePosition, Vec3.multiply(Quat.getFront(clockRotation), clockHandForwardOffset));
@ -118,11 +118,11 @@ MyCuckooClock = function(spawnPosition, spawnRotation) {
rotation: worldClockHandRotation,
angularDamping: 0,
angularVelocity: worldAngularVelocity,
dimensions: {
dimensions: Vec3.multiply(0.5, {
x: 0.0263,
y: 0.0982,
z: 0.0024
},
}),
userData: JSON.stringify({
hifiHomeKey: {
reset: true
@ -150,11 +150,11 @@ MyCuckooClock = function(spawnPosition, spawnRotation) {
modelURL: CLOCK_SECOND_HAND_URL,
name: "home_model_clockSecondHand",
position: hourHandPosition,
dimensions: {
dimensions: Vec3.multiply(0.5, {
x: 0.0043,
y: 0.1117,
z: 0.0008
},
}),
color: {
red: 200,
green: 10,
@ -202,14 +202,14 @@ MyCuckooClock = function(spawnPosition, spawnRotation) {
y: 0.05,
z: 0.5
},
rotation:worldClockHandRotation,
rotation: worldClockHandRotation,
angularDamping: 0,
angularVelocity: worldAngularVelocity,
dimensions: {
dimensions: Vec3.multiply(0.5, {
x: 0.0251,
y: 0.1179,
z: 0.0032
},
}),
script: MINUTE_HAND_CLOCK_SCRIPT_URL,
userData: JSON.stringify({
clockBody: clockBody,

View file

@ -0,0 +1,165 @@
// this script turns an entity into an exploder -- anything that collides with it will be vaporized!
//
//
(function() {
var _this = this;
function Fire() {
_this = this;
}
var RED = {
red: 255,
green: 0,
blue: 0
};
var ORANGE = {
red: 255,
green: 165,
blue: 0
};
var YELLOW = {
red: 255,
green: 255,
blue: 0
};
var GREEN = {
red: 0,
green: 255,
blue: 0
};
var BLUE = {
red: 0,
green: 0,
blue: 255
};
var INDIGO = {
red: 128,
green: 0,
blue: 128
};
var VIOLET = {
red: 75,
green: 0,
blue: 130
};
var colors = [RED, ORANGE, YELLOW, GREEN, BLUE, INDIGO, VIOLET];
Fire.prototype = {
preload: function(entityID) {
this.entityID = entityID;
this.EXPLOSION_SOUND = SoundCache.getSound("atp:/firepit/fire_burst.wav");
},
collisionWithEntity: function(myID, otherID, collisionInfo) {
var otherProps = Entities.getEntityProperties(otherID);
var data = null;
try {
data = JSON.parse(otherProps.userData)
} catch (err) {
print('ERROR GETTING USERDATA!');
}
if (data === null || "") {
return;
} else {
if (data.hasOwnProperty('hifiHomeKey')) {
if (data.hifiHomeKey.reset === true) {
print('FLAMMABLE THING, EXPLODE IT!');
_this.playSoundAtCurrentPosition();
_this.explodeWithColor();
_this.smokePuff();
Entities.deleteEntity(otherID)
}
}
}
},
explodeWithColor: function() {
print('EXPLODE!')
var myProps = Entities.getEntityProperties(this.entityID);
var color = colors[Math.floor(Math.random() * colors.length)];
var explosionParticleProperties = {
"color": color,
"isEmitting": 1,
"maxParticles": 1000,
"lifespan": 0.25,
"emitRate": 1,
"emitSpeed": 0.1,
"speedSpread": 1,
"emitOrientation": Quat.getUp(myProps.rotation),
"emitDimensions": {
"x": 0,
"y": 0,
"z": 0
},
"polarStart": 0,
"polarFinish": 0,
"azimuthStart": 0,
"azimuthFinish": 0,
"emitAcceleration": {
"x": 0,
"y": 0,
"z": 0
},
"accelerationSpread": {
"x": 0,
"y": 0,
"z": 0
},
"particleRadius": 0.829,
"radiusSpread": 0,
"radiusStart": 0.361,
"radiusFinish": 0.294,
"colorSpread": {
"red": 0,
"green": 0,
"blue": 0
},
"colorStart": {
"red": 255,
"green": 255,
"blue": 255
},
"colorFinish": {
"red": 255,
"green": 255,
"blue": 255
},
"alpha": 1,
"alphaSpread": 0,
"alphaStart": -0.2,
"alphaFinish": 0.5,
"emitterShouldTrail": 0,
"textures": "atp:/firepit/explode.png",
"type": "ParticleEffect",
lifetime: 1,
position: myProps.position
};
var explosion = Entities.addEntity(explosionParticleProperties);
print('explosion is: ' + explosion)
},
smokePuff: function() {
//smoke puff here
},
playSoundAtCurrentPosition: function() {
var audioProperties = {
volume: 0.5,
position: Entities.getEntityProperties(this.entityID).position
};
Audio.playSound(this.EXPLOSION_SOUND, audioProperties);
},
}
return new Fire();
});

View file

@ -0,0 +1,51 @@
(function() {
var MINIMUM_LIGHT_INTENSITY = 50.0;
var MAXIMUM_LIGHT_INTENSITY = 200.0;
var LIGHT_FALLOFF_RADIUS = 0.1;
var LIGHT_INTENSITY_RANDOMNESS = 0.1;
function randFloat(low, high) {
return low + Math.random() * (high - low);
}
var _this;
function FlickeringFlame() {
_this = this;
}
var totalTime = 0;
var spacer = 2;
FlickeringFlame.prototype = {
preload: function(entityID) {
this.entityID = entityID;
Script.update.connect(this.update);
},
update: function(deltaTime) {
totalTime += deltaTime;
if (totalTime > spacer) {
var howManyAvatars = AvatarList.getAvatarIdentifiers().length;
var intensity = (MINIMUM_LIGHT_INTENSITY + (MAXIMUM_LIGHT_INTENSITY + (Math.sin(totalTime) * MAXIMUM_LIGHT_INTENSITY)));
intensity += randFloat(-LIGHT_INTENSITY_RANDOMNESS, LIGHT_INTENSITY_RANDOMNESS);
Entities.editEntity(_this.entityID, {
intensity: intensity
});
spacer = Math.random(0, 100) * (2 / howManyAvatars);
totalTime = 0;
} else {
//just keep counting
}
},
unload: function() {
Script.update.disconnect(this.update)
}
}
return new FlickeringFlame
});

View file

@ -37,14 +37,10 @@
var whiteboardPath = Script.resolvePath("atp:/whiteboard/wrapper.js");
var plantPath = Script.resolvePath("atp:/growingPlant/wrapper.js");
var cuckooClockPath = Script.resolvePath("atp:/cuckooClock/wrapper.js");
var pingPongGunPath = Script.resolvePath("atp:/pingPongGun/wrapper.js");
var musicBoxPath = Script.resolvePath("musicBox/wrapper.js?" + Math.random());
var transformerPath = Script.resolvePath("atp:/dressingRoom/wrapper.js");
Script.include(utilsPath);
@ -54,10 +50,8 @@
Script.include(fishTankPath);
Script.include(tiltMazePath);
Script.include(whiteboardPath);
Script.include(plantPath);
Script.include(cuckooClockPath);
Script.include(pingPongGunPath);
// Script.include(musicBoxPath);
Script.include(transformerPath);
var TRANSFORMER_URL_ROBOT = 'atp:/dressingRoom/simple_robot.fbx';
@ -204,23 +198,13 @@
});
var whiteboard = new Whiteboard({
x: 1104,
y: 460.5,
z: -77
x: 1105.0955,
y: 460.5000,
z: -77.4409
}, {
x: 0,
y: -133,
z: 0
});
var myPlant = new Plant({
x: 1099.8785,
y: 460.3115,
z: -84.7736
}, {
x: 0,
y: 0,
z: 0
x: -0.0013,
y: -133.0056,
z: -0.0013
});
var pingPongGun = new HomePingPongGun({
@ -234,16 +218,15 @@
});
var cuckooClock = new MyCuckooClock({
x: 1105.267,
y: 461.44,
z: -81.9495
x: 1105.5237,
y: 461.4826,
z: -81.7524
}, {
x: 0,
y: -57,
z: 0
x: -0.0013,
y: -57.0089,
z: -0.0013
});
// var musicBox = new MusicBox();
print('HOME after creating scripted entities')
},