Skip to content

Instantly share code, notes, and snippets.

// pucks-sliding-fix1.js
//
// Script allows users in full body trackers to utilize High Fidelity's avatar
// movement animations.
//
// Created by Robin Wilson 6/20/2018
// Copyright 2018 High Fidelity, Inc.
//
// Distributed under the Apache License, Version 2.0.
{
"DataVersion": 0,
"Entities": [
{
"clientOnly": false,
"color": {
"blue": 0,
"green": 0,
"red": 255
},
(function(){
var loopTime = -1; // Loop for how long? -1 is always on.
var soundURL = null;//SoundCache.getSound(SOUND_URL);
var lastSoundURL = null;
var receiverName = "";
var soundLoop = null;
var soundLocal = null;
var soundVolume = null;
var refreshInterval = 500;
Script.include("/~/system/libraries/Xform.js");
var USE_CONTROLLERS_NOT_ANIM_VARS = true;
var BOX_HEIGHT = 0.1;
var cubes = [];
var handlerId;
var controllerMapping;
@hyperlogic
hyperlogic / gestureRecorder.js
Created July 17, 2018 18:23
Sample of how to record and detect hand controller gestures
"use strict";
/* globals Xform */
//
// gestureRecorder.js
// examples
//
// Created by Anthony Thibault on 2016/06/30
// Copyright 2016 High Fidelity, Inc.
//
{
"version": "1.0",
"root": {
"id": "userAnimStateMachine",
"type": "stateMachine",
"data": {
"currentState": "userAnimNone",
"states": [
{
"id": "userAnimNone",
var DOMAIN_GOTO = "hifi://dev-mobile-master"
var DOMAIN_CHANGE_TIME_MS = 2800;
var domainChanges = 0;
var comeBack = false;
var initialPos = MyAvatar.position;
var shouldStop = function() {
return Vec3.length(Vec3.subtract(initialPos, MyAvatar.position)) > 0.1;
}
var tick = Script.setInterval(function() {
console.log("Changing domains " + (++domainChanges) + " times");
{
"version": "1.1",
"root": {
"id": "userAnimStateMachine",
"type": "stateMachine",
"data": {
"currentState": "userAnimNone",
"states": [
{
"id": "userAnimNone",
/* global Xform */
Script.include("/~/system/libraries/Xform.js");
var handlerId = MyAvatar.addAnimationStateHandler(function (props) {
if (HMD.active) {
var hmdWorld = new Xform(Quat.cancelOutRollAndPitch(HMD.rotation), HMD.position);
var avatarToWorld = new Xform(MyAvatar.orientation, MyAvatar.position);
var headIndex = MyAvatar.getJointIndex("Head");
var headAvatar = new Xform(Quat.cancelOutRollAndPitch(MyAvatar.getAbsoluteJointRotationInObjectFrame(headIndex)),
{
"version": "1.0",
"root": {
"id": "userAnimStateMachine",
"type": "stateMachine",
"data": {
"currentState": "userAnimNone",
"states": [
{
"id": "userAnimNone",