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

41 lines
1.7 KiB
JavaScript

// CameraFlasher.js
// 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(){
var _this = this;
var IMPORT_URL = "http://hifi-content.s3.amazonaws.com/caitlyn/production/lazybonesToybox/cameras/cameraFlash2.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+")");
_this.entityID = entityID;
ringSound = SoundCache.getSound(soundURL);
}
this.startNearGrab = function(entityID, mouseEvent) {
print("START NEAR GRAB");
var entProperties = Entities.getEntityProperties(this.entityID);//, ["position", "rotation"]);//, "position").position;//Entities.getEntityProperties(this);
var jointNames = Entities.getJointNames(entityID);
print("Joint Names "+jointNames);
var jointIndex = Entities.getJointIndex(entityID, "Flash");
print("JOINT INDEX IS "+jointIndex);
var jointLocInObjectFrame = Entities.getAbsoluteJointTranslationInObjectFrame(entityID, jointIndex);
var jointLocInWorld = Vec3.sum(entProperties.position, Vec3.multiplyQbyV(entProperties.rotation, jointLocInObjectFrame));
print("LOCATION IS "+JSON.stringify(jointLocInWorld));
Audio.playSound(ringSound, {
position: jointLocInWorld,
volume: 0.5
});
Script.setTimeout(function(){},2555);
//var jointLocSphere = Entities.addEntity({type:"Sphere", position: jointLocInWorld, Lifetime: 30});
Clipboard.importEntities(IMPORT_URL);
Clipboard.pasteEntities(jointLocInWorld);
}
});