48 lines
No EOL
1.5 KiB
JavaScript
48 lines
No EOL
1.5 KiB
JavaScript
//
|
|
// mirrorButton.js
|
|
//
|
|
// Edited 11/2/18 by Liv Erickson
|
|
// Created by Rebecca Stankus on 8/30/17.
|
|
// Copyright 2018 High Fidelity, Inc.
|
|
//
|
|
// Distributed under the Apache License, Version 2.0.
|
|
// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html
|
|
//
|
|
// This script acts on the reflection box in front of the mirror so that when and avatar
|
|
// enters the area, the mirror will reflect an image via the spectator camera
|
|
|
|
(function () {
|
|
var mirrorID, selfID;
|
|
var mirrorOn = false;
|
|
|
|
var toggleMirrorMode = function() {
|
|
if (!mirrorOn) {
|
|
print("Turning mirror on");
|
|
Entities.callEntityMethod(mirrorID, 'mirrorOverlayOn');
|
|
mirrorOn = true;
|
|
} else {
|
|
print("Turning mirror off");
|
|
Entities.callEntityMethod(mirrorID, 'mirrorOverlayOff');
|
|
mirrorOn = false;
|
|
}
|
|
};
|
|
|
|
// get id of reflection area and mirror
|
|
this.preload = function(entityID) {
|
|
selfID = entityID;
|
|
mirrorID = Entities.getEntityProperties(entityID, 'parentID').parentID;
|
|
print("Loaded, mirrorID: " + mirrorID);
|
|
};
|
|
|
|
// when avatar triggers reflection area, begin reflecting
|
|
this.mousePressOnEntity = function(entityID, event) {
|
|
if (!HMD.active) {
|
|
toggleMirrorMode();
|
|
}
|
|
};
|
|
|
|
// when avatar triggers reflection area, begin reflecting
|
|
this.stopFarTrigger = function(entityID, event) {
|
|
toggleMirrorMode();
|
|
};
|
|
}); |