content/hifi-content/caitlyn/production/lazybonesToybox/cameras/cameraFlasher.js
2022-02-13 22:19:19 +01:00

37 lines
No EOL
1.3 KiB
JavaScript

//
// Copyright 2016 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
//
(function(){
// Script.include("../libraries/utils.js");
var IMPORT_URL = "http://hifi-content.s3.amazonaws.com/caitlyn/production/lazybonesToybox/cameras/cameraFlash.svo.json";
var soundURL ='http://hifi-content.s3.amazonaws.com/caitlyn/production/lazybonesToybox/cameras/353044__montclairguy__camera-sound.wav';
var ringSound;
this.preload = function(entityID) {
print("preload("+entityID+")");
ringSound = SoundCache.getSound(soundURL);
};
this.startNearGrab = function(entityID, mouseEvent) {
var orientation = Camera.getOrientation();
orientation = Quat.safeEulerAngles(orientation);
orientation.x = 0;
orientation = Quat.fromVec3Degrees(orientation);
var center = Vec3.sum(MyAvatar.position, Vec3.multiply(3, Quat.getFront(orientation)));
var bellPosition = Entities.getEntityProperties(entityID).position;
Audio.playSound(ringSound, {
position: bellPosition,
volume: 0.5
});
Clipboard.importEntities(IMPORT_URL);
Clipboard.pasteEntities(center);
};
})