Skip to content

Instantly share code, notes, and snippets.

//
// clownGloveDispenser.js
//
// Created by Thijs Wenker on 8/2/16.
// Copyright 2016 High Fidelity, Inc.
//
// Based on examples/winterSmashUp/targetPractice/shooterPlatform.js
//
// Distributed under the Apache License, Version 2.0.
// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html
// test for web entities event bridge
var URL = "https://s3.amazonaws.com/hifi-public/tony/webBridgeTest.html"
var spawnPoint = Vec3.sum(Vec3.sum(MyAvatar.position, Vec3.multiply(1.0, Quat.getFront(MyAvatar.orientation))), {x: 0, y: 0.5, z: 0});
var forward = Quat.getFront(MyAvatar.orientation);
var right = Vec3.cross(Quat.getFront(MyAvatar.orientation), Quat.getUp(MyAvatar.orientation));
var entities = [];
<!DOCTYPE html>
<html lang="en">
<link rel="stylesheet" href="http://code.jquery.com/mobile/1.4.5/jquery.mobile-1.4.5.min.css" />
<script src="http://code.jquery.com/jquery-1.11.1.min.js"></script>
<script src="http://code.jquery.com/mobile/1.4.5/jquery.mobile-1.4.5.min.js"></script>
<script>
$(document).ready(function () {
EventBridge.emitWebEvent("ready");
EventBridge.scriptEventReceived.connect(function (msg) {
console.log("WEB: recv script event = " + JSON.stringify(msg));
(function () {
var Switch = function () {};
Switch.prototype.clickReleaseOnEntity = function (entityID, event) {
if (event.isLeftButton) {
print("PASS");
}
};
return new Switch();
});
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8" />
<body>
<h1>High Fidelity Sites<hi>
<ul>
<li><a href="hifi://demo">demo</a></li>
<li><a href="hifi://dev-demo">dev-demo</a></li>
<li><a href="hifi://Welcome">Welcome</a></li>
var spawnPoint = Vec3.sum(Vec3.sum(MyAvatar.position, Vec3.multiply(1.0, Quat.getFront(MyAvatar.orientation))), {x: 0, y: 0.5, z: 0});
var forward = Quat.getFront(MyAvatar.orientation);
var right = Vec3.cross(Quat.getFront(MyAvatar.orientation), Quat.getUp(MyAvatar.orientation));
var entities = [];
// this should create a near-grabbable web entity
entities.push(Entities.addEntity({
type: "Web",
var spawnPoint = Vec3.sum(MyAvatar.position, Vec3.multiply(1.0, Quat.getFront(Camera.getOrientation())));
var right = Vec3.cross(Quat.getFront(Camera.getOrientation()), Quat.getUp(Camera.getOrientation()));
var WEB_URL = "https://metaverse.highfidelity.com/marketplace";
var overlays = [];
// this should create a web3d overlay one meter in front of the camera.
overlays.push(Overlays.addOverlay("web3d", {
{
"version": "1.0",
"root": {
"id": "userAnimStateMachine",
"type": "stateMachine",
"data": {
"currentState": "userAnimNone",
"states": [
{
"id": "userAnimNone",
var spawnPoint = Vec3.sum(MyAvatar.position, Vec3.multiply(1.5, Quat.getFront(Camera.getOrientation())));
var right = Vec3.cross(Quat.getFront(Camera.getOrientation()), Quat.getUp(Camera.getOrientation()));
var MODEL_URL = "https://s3.amazonaws.com/hifi-public/tony/axes.fbx";
var entities = [];
// create axes test object
entities.push(Entities.addEntity({
type: "Model",
var spawnPoint = Vec3.sum(MyAvatar.position, Vec3.multiply(4.0, Quat.getFront(Camera.getOrientation())));
var right = Vec3.cross(Quat.getFront(Camera.getOrientation()), Quat.getUp(Camera.getOrientation()));
spawnPoint = Vec3.sum(spawnPoint, Vec3.multiply(-1, right));
var MODEL_URL = "https://s3.amazonaws.com/hifi-public/tony/axes.fbx";
var overlays = [];
// this model should be 1/10th a meter tall, very small