lightning strikes

This commit is contained in:
ericrius1 2016-01-19 16:02:41 -08:00
parent 5245bdc96e
commit 713496a8a0

View file

@ -7,10 +7,16 @@
var center = Vec3.sum(MyAvatar.position, Vec3.multiply(3, Quat.getFront(orientation)));
var emitters = [];
var spheres = []
var spheres = [];
var bolt;
var raveRoomModelURL = "https://s3-us-west-1.amazonaws.com/hifi-content/eric/models/RaveRoom.fbx";
var roomDimensions = {x: 30.58, y: 15.29, z: 30.58};
var roomDimensions = {
x: 30.58,
y: 15.29,
z: 30.58
};
var raveRoom = Entities.addEntity({
type: "Model",
@ -26,26 +32,69 @@ var weatherZone = Entities.addEntity({
type: "Zone",
name: "Weather Zone",
shapeType: 'box',
keyLightIntensity: 0.01,
keyLightIntensity: 1,
keyLightColor: {
red: 50,
green: 0,
blue: 50
},
keyLightAmbientIntensity: .01,
keyLightAmbientIntensity: 1,
position: MyAvatar.position,
dimensions: {
x: 100,
y: 100,
z: 100
}
});
createWeatherBox(center);
center.y += boxDimensions.y/2;
createCloud(center);
createLightningStrike(center)
function createLightningStrike(position) {
var normal = Vec3.subtract(position, MyAvatar.position);
normal.y = 0;
var textureURL = "file:///C:/Users/Eric/Desktop/lightning.png"
var linePoints = [];
var normals = [];
var strokeWidths = [];
linePoints.push({
x: 0,
y: 0,
z: 0
});
linePoints.push({
x: 0,
y: -1,
z: 0
});
normals.push(normal);
normals.push(normal);
strokeWidths.push(0.01);
strokeWidths.push(0.01);
bolt = Entities.addEntity({
type: "PolyLine",
textures: textureURL,
position: position,
dimensions: {
x: 10,
y: 10,
z: 10
}
},
linePoints: linePoints,
normals: normals,
strokeWidths: strokeWidths
});
createWeatherBox(center);
createNodes();
}
function createWeatherBox(position) {
var naturalDimensions = {x: 1.11, y: 1.3, z: 1.11};
var naturalDimensions = {
x: 1.11,
y: 1.3,
z: 1.11
};
boxDimensions = Vec3.multiply(naturalDimensions, 0.7);
var modelURL = "file:///C:/Users/Eric/Desktop/weatherBox.fbx?v1" + Math.random();
// var modelURL = "https://s3-us-west-1.amazonaws.com/hifi-content/eric/models/raveStick.fbx";
@ -58,17 +107,7 @@ function createWeatherBox(position) {
}
function createNodes() {
var numNodes = 1;
for (var i = 0; i < numNodes; i++) {
var position = center;
position.y += boxDimensions.y/2;
createNode(position)
}
}
function createNode(position) {
function createCloud(position) {
var props = {
"type": "ParticleEffect",
"position": position,
@ -78,7 +117,11 @@ function createNode(position) {
"emitRate": 1000,
"emitSpeed": 0.025,
"speedSpread": 0,
"emitDimensions": {x: 1, y: 1, z: 0.1},
"emitDimensions": {
x: 1,
y: 1,
z: 0.1
},
"emitRadiusStart": 1,
"polarStart": 0,
"polarFinish": 1.570796012878418,
@ -99,7 +142,9 @@ function createNode(position) {
"blue": 255
},
color: {
red: 100, green: 100, blue: 200
red: 100,
green: 100,
blue: 200
},
"colorFinish": {
"red": 200,
@ -120,17 +165,18 @@ function createNode(position) {
function cleanup() {
emitters.forEach(function(emitter) {
Entities.deleteEntity(emitter);
})
});
spheres.forEach(function(sphere) {
Entities.deleteEntity(sphere);
})
});
Entities.deleteEntity(weatherBox);
Entities.deleteEntity(weatherZone);
Entities.deleteEntity(bolt);
Entities.deleteEntity(raveRoom);
}
Script.scriptEnding.connect(cleanup);