mirror of
https://github.com/overte-org/overte.git
synced 2025-08-08 00:10:52 +02:00
fix indent floatingLanternBox
This commit is contained in:
parent
f3d8d1641f
commit
9fc0ad0d28
1 changed files with 75 additions and 75 deletions
|
@ -15,89 +15,89 @@
|
||||||
|
|
||||||
(function() {
|
(function() {
|
||||||
|
|
||||||
var _this;
|
var _this;
|
||||||
var LANTERN_MODEL_URL = "http://hifi-content.s3.amazonaws.com/DomainContent/Welcome%20Area/Models/chinaLantern_capsule.fbx";
|
var LANTERN_MODEL_URL = "http://hifi-content.s3.amazonaws.com/DomainContent/Welcome%20Area/Models/chinaLantern_capsule.fbx";
|
||||||
var LANTERN_SCRIPT_URL = Script.resolvePath("floatingLantern.js?v=" + Date.now());
|
var LANTERN_SCRIPT_URL = Script.resolvePath("floatingLantern.js?v=" + Date.now());
|
||||||
var LIFETIME = 120;
|
var LIFETIME = 120;
|
||||||
var RESPAWN_INTERVAL = 1000;
|
var RESPAWN_INTERVAL = 1000;
|
||||||
var MAX_LANTERNS = 4;
|
var MAX_LANTERNS = 4;
|
||||||
var SCALE_FACTOR = 1;
|
var SCALE_FACTOR = 1;
|
||||||
|
|
||||||
var LANTERN = {
|
var LANTERN = {
|
||||||
type: "Model",
|
type: "Model",
|
||||||
name: "Floating Lantern",
|
name: "Floating Lantern",
|
||||||
description: "Spawns Lanterns that float away when grabbed and released!",
|
description: "Spawns Lanterns that float away when grabbed and released!",
|
||||||
modelURL: LANTERN_MODEL_URL,
|
modelURL: LANTERN_MODEL_URL,
|
||||||
script: LANTERN_SCRIPT_URL,
|
script: LANTERN_SCRIPT_URL,
|
||||||
dimensions: {
|
dimensions: {
|
||||||
x: 0.2049 * SCALE_FACTOR,
|
x: 0.2049 * SCALE_FACTOR,
|
||||||
y: 0.4 * SCALE_FACTOR,
|
y: 0.4 * SCALE_FACTOR,
|
||||||
z: 0.2049 * SCALE_FACTOR
|
z: 0.2049 * SCALE_FACTOR
|
||||||
},
|
},
|
||||||
gravity: {
|
gravity: {
|
||||||
x: 0,
|
x: 0,
|
||||||
y: -1,
|
y: -1,
|
||||||
z: 0
|
z: 0
|
||||||
},
|
},
|
||||||
velocity: {
|
velocity: {
|
||||||
x: 0, y: .01, z: 0
|
x: 0, y: .01, z: 0
|
||||||
},
|
},
|
||||||
linearDampening: 0,
|
linearDampening: 0,
|
||||||
shapeType: 'Box',
|
shapeType: 'Box',
|
||||||
lifetime: LIFETIME,
|
lifetime: LIFETIME,
|
||||||
dynamic: true
|
dynamic: true
|
||||||
};
|
};
|
||||||
|
|
||||||
lanternBox = function() {
|
lanternBox = function() {
|
||||||
_this = this;
|
_this = this;
|
||||||
};
|
};
|
||||||
|
|
||||||
lanternBox.prototype = {
|
lanternBox.prototype = {
|
||||||
|
|
||||||
preload: function(entityID) {
|
preload: function(entityID) {
|
||||||
this.entityID = entityID;
|
this.entityID = entityID;
|
||||||
var props = Entities.getEntityProperties(this.entityID);
|
var props = Entities.getEntityProperties(this.entityID);
|
||||||
|
|
||||||
if (props.owningAvatarID === MyAvatar.sessionUUID) {
|
if (props.owningAvatarID === MyAvatar.sessionUUID) {
|
||||||
this.respawnTimer = Script.setInterval(this.spawnAllLanterns.bind(this), RESPAWN_INTERVAL);
|
this.respawnTimer = Script.setInterval(this.spawnAllLanterns.bind(this), RESPAWN_INTERVAL);
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
unload: function(entityID) {
|
unload: function(entityID) {
|
||||||
if (this.respawnTimer) {
|
if (this.respawnTimer) {
|
||||||
Script.clearInterval(this.respawnTimer);
|
Script.clearInterval(this.respawnTimer);
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
spawnAllLanterns: function() {
|
spawnAllLanterns: function() {
|
||||||
var props = Entities.getEntityProperties(this.entityID);
|
var props = Entities.getEntityProperties(this.entityID);
|
||||||
var lanternCount = 0;
|
var lanternCount = 0;
|
||||||
var nearbyEntities = Entities.findEntities(props.position, props.dimensions.x * 0.75);
|
var nearbyEntities = Entities.findEntities(props.position, props.dimensions.x * 0.75);
|
||||||
|
|
||||||
for (var i = 0; i < nearbyEntities.length; i++) {
|
for (var i = 0; i < nearbyEntities.length; i++) {
|
||||||
var name = Entities.getEntityProperties(nearbyEntities[i], ["name"]).name;
|
var name = Entities.getEntityProperties(nearbyEntities[i], ["name"]).name;
|
||||||
if (name === "Floating Lantern") {
|
if (name === "Floating Lantern") {
|
||||||
lanternCount++;
|
lanternCount++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
while (lanternCount++ < MAX_LANTERNS) {
|
||||||
|
this.spawnLantern();
|
||||||
|
}
|
||||||
|
},
|
||||||
|
|
||||||
|
spawnLantern: function() {
|
||||||
|
var boxProps = Entities.getEntityProperties(this.entityID);
|
||||||
|
|
||||||
|
LANTERN.position = boxProps.position;
|
||||||
|
LANTERN.position.x += Math.random() * .2 - .1;
|
||||||
|
LANTERN.position.y += Math.random() * .2 + .1;
|
||||||
|
LANTERN.position.z += Math.random() * .2 - .1;
|
||||||
|
LANTERN.owningAvatarID = boxProps.owningAvatarID;
|
||||||
|
|
||||||
|
return Entities.addEntity(LANTERN);
|
||||||
}
|
}
|
||||||
}
|
};
|
||||||
|
|
||||||
while (lanternCount++ < MAX_LANTERNS) {
|
return new lanternBox();
|
||||||
this.spawnLantern();
|
|
||||||
}
|
|
||||||
},
|
|
||||||
|
|
||||||
spawnLantern: function() {
|
|
||||||
var boxProps = Entities.getEntityProperties(this.entityID);
|
|
||||||
|
|
||||||
LANTERN.position = boxProps.position;
|
|
||||||
LANTERN.position.x += Math.random() * .2 - .1;
|
|
||||||
LANTERN.position.y += Math.random() * .2 + .1;
|
|
||||||
LANTERN.position.z += Math.random() * .2 - .1;
|
|
||||||
LANTERN.owningAvatarID = boxProps.owningAvatarID;
|
|
||||||
|
|
||||||
return Entities.addEntity(LANTERN);
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
return new lanternBox();
|
|
||||||
});
|
});
|
||||||
|
|
Loading…
Reference in a new issue