mirror of
https://github.com/overte-org/overte.git
synced 2025-06-05 18:51:13 +02:00
Moved entity reset switch, fixed some style issues
This commit is contained in:
parent
9f0721c08b
commit
b7f52ea542
2 changed files with 15 additions and 30 deletions
|
@ -10,7 +10,7 @@
|
||||||
//
|
//
|
||||||
|
|
||||||
|
|
||||||
(function () {
|
(function() {
|
||||||
|
|
||||||
var _this;
|
var _this;
|
||||||
|
|
||||||
|
@ -22,13 +22,13 @@
|
||||||
var dollScriptURL = Script.resolvePath("../examples/toys/doll/doll.js");
|
var dollScriptURL = Script.resolvePath("../examples/toys/doll/doll.js");
|
||||||
var lightsScriptURL = Script.resolvePath("../examples/toys/lightSwitch.js");
|
var lightsScriptURL = Script.resolvePath("../examples/toys/lightSwitch.js");
|
||||||
|
|
||||||
ResetSwitch = function () {
|
ResetSwitch = function() {
|
||||||
_this = this;
|
_this = this;
|
||||||
};
|
};
|
||||||
|
|
||||||
ResetSwitch.prototype = {
|
ResetSwitch.prototype = {
|
||||||
|
|
||||||
clickReleaseOnEntity: function (entityId, mouseEvent) {
|
clickReleaseOnEntity: function(entityId, mouseEvent) {
|
||||||
if (!mouseEvent.isLeftButton) {
|
if (!mouseEvent.isLeftButton) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -36,26 +36,22 @@
|
||||||
|
|
||||||
},
|
},
|
||||||
|
|
||||||
startNearGrabNonColliding: function () {
|
startNearGrabNonColliding: function() {
|
||||||
this.triggerReset();
|
this.triggerReset();
|
||||||
},
|
},
|
||||||
|
|
||||||
startFarGrabNonColliding: function () {
|
triggerReset: function() {
|
||||||
this.triggerReset();
|
|
||||||
},
|
|
||||||
|
|
||||||
triggerReset: function () {
|
|
||||||
MasterReset();
|
MasterReset();
|
||||||
},
|
},
|
||||||
|
|
||||||
preload: function (entityID) {
|
preload: function(entityID) {
|
||||||
this.entityID = entityID;
|
this.entityID = entityID;
|
||||||
}
|
}
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
MasterReset = function () {
|
MasterReset = function() {
|
||||||
var resetKey = "resetMe";
|
var resetKey = "resetMe";
|
||||||
var GRABBABLE_DATA_KEY = "grabbableKey";
|
var GRABBABLE_DATA_KEY = "grabbableKey";
|
||||||
|
|
||||||
|
@ -145,7 +141,7 @@
|
||||||
function deleteAllToys() {
|
function deleteAllToys() {
|
||||||
var entities = Entities.findEntities(MyAvatar.position, 100);
|
var entities = Entities.findEntities(MyAvatar.position, 100);
|
||||||
|
|
||||||
entities.forEach(function (entity) {
|
entities.forEach(function(entity) {
|
||||||
//params: customKey, id, defaultValue
|
//params: customKey, id, defaultValue
|
||||||
var shouldReset = getEntityCustomData(resetKey, entity, {}).resetMe;
|
var shouldReset = getEntityCustomData(resetKey, entity, {}).resetMe;
|
||||||
if (shouldReset === true) {
|
if (shouldReset === true) {
|
||||||
|
@ -330,14 +326,14 @@
|
||||||
function testBallDistanceFromStart() {
|
function testBallDistanceFromStart() {
|
||||||
var resetCount = 0;
|
var resetCount = 0;
|
||||||
|
|
||||||
collidingBalls.forEach(function (ball, index) {
|
collidingBalls.forEach(function(ball, index) {
|
||||||
var currentPosition = Entities.getEntityProperties(ball, "position").position;
|
var currentPosition = Entities.getEntityProperties(ball, "position").position;
|
||||||
var originalPosition = originalBallPositions[index];
|
var originalPosition = originalBallPositions[index];
|
||||||
var distance = Vec3.subtract(originalPosition, currentPosition);
|
var distance = Vec3.subtract(originalPosition, currentPosition);
|
||||||
var length = Vec3.length(distance);
|
var length = Vec3.length(distance);
|
||||||
|
|
||||||
if (length > RESET_DISTANCE) {
|
if (length > RESET_DISTANCE) {
|
||||||
Script.setTimeout(function () {
|
Script.setTimeout(function() {
|
||||||
var newPosition = Entities.getEntityProperties(ball, "position").position;
|
var newPosition = Entities.getEntityProperties(ball, "position").position;
|
||||||
var moving = Vec3.length(Vec3.subtract(currentPosition, newPosition));
|
var moving = Vec3.length(Vec3.subtract(currentPosition, newPosition));
|
||||||
if (moving < MINIMUM_MOVE_LENGTH) {
|
if (moving < MINIMUM_MOVE_LENGTH) {
|
||||||
|
|
|
@ -24,28 +24,17 @@ function createHiddenMasterSwitch() {
|
||||||
type: "Box",
|
type: "Box",
|
||||||
name: "Master Switch",
|
name: "Master Switch",
|
||||||
script: hiddenEntityScriptURL,
|
script: hiddenEntityScriptURL,
|
||||||
dimensions: {
|
dimensions: {x: 0.7, y: 0.2, z: 0.1},
|
||||||
x: 0.2,
|
position: {x: 543.9, y: 496.05, z: 502.43},
|
||||||
y: 0.2,
|
rotation: Quat.fromPitchYawRollDegrees(0, 33, 0),
|
||||||
z: 0.2
|
visible: false
|
||||||
},
|
|
||||||
color: {
|
|
||||||
red: 42,
|
|
||||||
green: 36,
|
|
||||||
blue: 30
|
|
||||||
},
|
|
||||||
position: {
|
|
||||||
x: 554,
|
|
||||||
y: 495.5,
|
|
||||||
z: 503.2
|
|
||||||
}
|
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
var entities = Entities.findEntities(MyAvatar.position, 100);
|
var entities = Entities.findEntities(MyAvatar.position, 100);
|
||||||
|
|
||||||
entities.forEach(function (entity) {
|
entities.forEach(function(entity) {
|
||||||
//params: customKey, id, defaultValue
|
//params: customKey, id, defaultValue
|
||||||
var name = Entities.getEntityProperties(entity, "name").name
|
var name = Entities.getEntityProperties(entity, "name").name
|
||||||
if (name === "Master Switch") {
|
if (name === "Master Switch") {
|
||||||
|
|
Loading…
Reference in a new issue