46 lines
1.7 KiB
JavaScript
46 lines
1.7 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(){
|
||
|
||
var _this;
|
||
MyEntity = function() {
|
||
_this = this;
|
||
};
|
||
|
||
MyEntity.prototype = {
|
||
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;
|
||
|
||
var entProperties = Entities.getEntityProperties(this.entityID);//, ["position", "rotation"]);//, "position").position;//Entities.getEntityProperties(this);
|
||
var jointNames = Entities.getJointNames(entProperties);
|
||
var jointIndex = Entities.getJointIndex(entProperties, "Flash");
|
||
var jointLocInObjectFrame = Entities.getAbsoluteJointTranslationInObjectFrame(entProperties, jointIndex);
|
||
var jointLocInWorld = Vec3.sum(entProperties.position, Vec3.multiplyQbyV(entProperties.rotation, jointLocInObjectFrame));
|
||
|
||
this.preload = function(entityID) {
|
||
print("preload("+entityID+")");
|
||
this.entityID = entityID;
|
||
ringSound = SoundCache.getSound(soundURL);
|
||
},
|
||
|
||
this.startNearGrab = function(entityID, mouseEvent) {
|
||
print("LOCATION IS "+jointLocInWorld.position);
|
||
Audio.playSound(ringSound, {
|
||
position: jointLocInWorld,
|
||
volume: 0.5
|
||
});
|
||
Script.setTimeout(function(){},2555);
|
||
var jointLocSphere = Entities.addEntity({type:"Sphere", position: jointLocInWorld.position});
|
||
Clipboard.importEntities(IMPORT_URL);
|
||
Clipboard.pasteEntities(jointLocInWorld.position);
|
||
},
|
||
};
|
||
return new MyEntity();
|
||
});
|