mirror of
https://github.com/overte-org/overte.git
synced 2025-04-08 07:12:40 +02:00
add fire remove plant
This commit is contained in:
parent
91a5d82af5
commit
af8a827c83
3 changed files with 202 additions and 17 deletions
151
unpublishedScripts/DomainContent/Home/firePit/fire.js
Normal file
151
unpublishedScripts/DomainContent/Home/firePit/fire.js
Normal file
|
@ -0,0 +1,151 @@
|
|||
// 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;
|
||||
},
|
||||
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.explodeWithColor();
|
||||
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)
|
||||
}
|
||||
}
|
||||
|
||||
return new Fire();
|
||||
});
|
51
unpublishedScripts/DomainContent/Home/firePit/flicker.js
Normal file
51
unpublishedScripts/DomainContent/Home/firePit/flicker.js
Normal 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
|
||||
|
||||
|
||||
});
|
|
@ -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';
|
||||
|
@ -213,16 +207,6 @@
|
|||
z: 0
|
||||
});
|
||||
|
||||
var myPlant = new Plant({
|
||||
x: 1099.8785,
|
||||
y: 460.3115,
|
||||
z: -84.7736
|
||||
}, {
|
||||
x: 0,
|
||||
y: 0,
|
||||
z: 0
|
||||
});
|
||||
|
||||
var pingPongGun = new HomePingPongGun({
|
||||
x: 1101.2123,
|
||||
y: 460.2328,
|
||||
|
@ -243,7 +227,6 @@
|
|||
z: 0
|
||||
});
|
||||
|
||||
// var musicBox = new MusicBox();
|
||||
print('HOME after creating scripted entities')
|
||||
|
||||
},
|
||||
|
|
Loading…
Reference in a new issue