80 lines
2.2 KiB
JavaScript
80 lines
2.2 KiB
JavaScript
// createHookGun.js
|
|
//
|
|
// Script Type: Entity Spawner
|
|
// Created by Matti 'Menithal' Lahtinen
|
|
// Copyright 2016 High Fidelity, Inc.
|
|
//
|
|
// This script originally created a gun that shoots ping pong balls. Modified to now rez a hook gun instead by Matti 'Menithal' Lahtinen
|
|
// Distributed under the Apache License, Version 2.0.
|
|
// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html
|
|
//
|
|
/*global MyAvatar, Entities, AnimationCache, SoundCache, Scene, Camera, Overlays, HMD, AvatarList, AvatarManager, Controller, UndoStack, Window, Account, GlobalServices, Script, ScriptDiscoveryService, LODManager, Menu, Vec3, Quat, AudioDevice, Paths, Clipboard, Settings, XMLHttpRequest, randFloat, randInt */
|
|
|
|
var scriptURL = Script.resolvePath('http://www.norteclabs.com/HF/objects/hookgun/entity_scripts/hookgun.js?ga2b2');//entity_scripts/hookgun.js'); // Needs to be moved to remote.
|
|
var MODEL_URL = "http://www.norteclabs.com/HF/objects/hookgun/HookGun.fbx?55ssd12";
|
|
var COLLISION_HULL_URL = "http://www.norteclabs.com/HF/objects/hookgun/HookGunPhysics.obj?2";
|
|
|
|
|
|
|
|
|
|
var center = Vec3.sum(Vec3.sum(MyAvatar.position, {
|
|
x: 0,
|
|
y: 0.5,
|
|
z: 0
|
|
}), Vec3.multiply(0.5, Quat.getFront(Camera.getOrientation())));
|
|
|
|
var hookGunEntity = {
|
|
type: "Model",
|
|
name: "HookGun",
|
|
modelURL: MODEL_URL,
|
|
shapeType: 'compound',
|
|
compoundShapeURL: COLLISION_HULL_URL,
|
|
script: scriptURL,
|
|
position: center,
|
|
dimensions: {
|
|
x: 0.0643,
|
|
y: 0.1873,
|
|
z: 0.2878
|
|
},
|
|
gravity: {x:0,y:-9,z:0},
|
|
dynamic: true,
|
|
userData: JSON.stringify({
|
|
grabbableKey: {
|
|
invertSolidWhileHeld: true
|
|
},
|
|
wearable: {
|
|
joints: {
|
|
RightHand: [{
|
|
x: 0.02,
|
|
y: 0.20,
|
|
z: 0.04
|
|
}, {
|
|
x: 0.500,
|
|
y: 0.500,
|
|
z: -0.500,
|
|
w: 0.500
|
|
}],
|
|
LeftHand: [{
|
|
x: -0.02,
|
|
y: 0.20,
|
|
z: 0.04
|
|
}, {
|
|
x: 0.500,
|
|
y: -0.500,
|
|
z: 0.500,
|
|
w: 0.500
|
|
}]
|
|
}
|
|
}
|
|
})
|
|
};
|
|
|
|
var hookGun = Entities.addEntity(hookGunEntity);
|
|
var hookGun2 = Entities.addEntity(hookGunEntity);
|
|
/*
|
|
function cleanUp() {
|
|
Entities.deleteEntity(hookGun);
|
|
Entities.deleteEntity(hookGun2);
|
|
}
|
|
Script.scriptEnding.connect(cleanUp);
|
|
*/
|