mirror of
https://github.com/HifiExperiments/overte.git
synced 2025-08-10 01:06:25 +02:00
Fix js linting issues in shortbow
This commit is contained in:
parent
619867293e
commit
dd895dc04a
4 changed files with 54 additions and 41 deletions
|
@ -1,5 +1,14 @@
|
||||||
|
//
|
||||||
|
// Created by Ryan Huffman on 1/10/2017
|
||||||
|
// Copyright 2017 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
|
||||||
|
//
|
||||||
|
|
||||||
|
|
||||||
var leftHandPosition = {
|
var leftHandPosition = {
|
||||||
"x": 0,//-0.0881,
|
"x": 0,
|
||||||
"y": 0.0559,
|
"y": 0.0559,
|
||||||
"z": 0.0159
|
"z": 0.0159
|
||||||
};
|
};
|
||||||
|
@ -23,10 +32,10 @@ var userData = {
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
};
|
||||||
|
|
||||||
var id = Entities.addEntity({
|
var id = Entities.addEntity({
|
||||||
position: MyAvatar.position,
|
"position": MyAvatar.position,
|
||||||
"collisionsWillMove": 1,
|
"collisionsWillMove": 1,
|
||||||
"compoundShapeURL": Script.resolvePath("bow_collision_hull.obj"),
|
"compoundShapeURL": Script.resolvePath("bow_collision_hull.obj"),
|
||||||
"created": "2016-09-01T23:57:55Z",
|
"created": "2016-09-01T23:57:55Z",
|
||||||
|
@ -52,8 +61,7 @@ var id = Entities.addEntity({
|
||||||
"script": Script.resolvePath("bow.js"),
|
"script": Script.resolvePath("bow.js"),
|
||||||
"shapeType": "compound",
|
"shapeType": "compound",
|
||||||
"type": "Model",
|
"type": "Model",
|
||||||
//"userData": JSON.stringify(userData),
|
|
||||||
"userData": "{\"grabbableKey\":{\"grabbable\":true},\"wearable\":{\"joints\":{\"RightHand\":[{\"x\":0.0813,\"y\":0.0452,\"z\":0.0095},{\"x\":-0.3946,\"y\":-0.6604,\"z\":0.4748,\"w\":-0.4275}],\"LeftHand\":[{\"x\":-0.0881,\"y\":0.0259,\"z\":0.0159},{\"x\":0.4427,\"y\":-0.6519,\"z\":0.4592,\"w\":0.4099}]}}}",
|
"userData": "{\"grabbableKey\":{\"grabbable\":true},\"wearable\":{\"joints\":{\"RightHand\":[{\"x\":0.0813,\"y\":0.0452,\"z\":0.0095},{\"x\":-0.3946,\"y\":-0.6604,\"z\":0.4748,\"w\":-0.4275}],\"LeftHand\":[{\"x\":-0.0881,\"y\":0.0259,\"z\":0.0159},{\"x\":0.4427,\"y\":-0.6519,\"z\":0.4592,\"w\":0.4099}]}}}",
|
||||||
lifetime: 600
|
"lifetime": 600
|
||||||
});
|
});
|
||||||
print("Created bow:", id);
|
print("Created bow:", id);
|
||||||
|
|
|
@ -11,6 +11,8 @@
|
||||||
//
|
//
|
||||||
// Because .json can't be Script.include'd directly, the contents are copied over
|
// Because .json can't be Script.include'd directly, the contents are copied over
|
||||||
// to here and exposed as a global variable.
|
// to here and exposed as a global variable.
|
||||||
|
//
|
||||||
|
|
||||||
SHORTBOW_ENTITIES =
|
SHORTBOW_ENTITIES =
|
||||||
{
|
{
|
||||||
"Entities": [
|
"Entities": [
|
||||||
|
@ -831,17 +833,18 @@ SHORTBOW_ENTITIES =
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
"Version": 65
|
"Version": 65
|
||||||
}
|
};
|
||||||
|
|
||||||
// Add LocalPosition to entity data if parent properties are available
|
// Add LocalPosition to entity data if parent properties are available
|
||||||
var entities = SHORTBOW_ENTITIES.Entities;
|
var entities = SHORTBOW_ENTITIES.Entities;
|
||||||
var entitiesByID = {}
|
var entitiesByID = {};
|
||||||
for (var i = 0; i < entities.length; ++i) {
|
var i, entity;
|
||||||
var entity = entities[i];
|
for (i = 0; i < entities.length; ++i) {
|
||||||
|
entity = entities[i];
|
||||||
entitiesByID[entity.id] = entity;
|
entitiesByID[entity.id] = entity;
|
||||||
}
|
}
|
||||||
for (var i = 0; i < entities.length; ++i) {
|
for (i = 0; i < entities.length; ++i) {
|
||||||
var entity = entities[i];
|
entity = entities[i];
|
||||||
if (entity.parentID !== undefined) {
|
if (entity.parentID !== undefined) {
|
||||||
var parent = entitiesByID[entity.parentID];
|
var parent = entitiesByID[entity.parentID];
|
||||||
if (parent !== undefined) {
|
if (parent !== undefined) {
|
||||||
|
|
|
@ -5,6 +5,7 @@
|
||||||
// Distributed under the Apache License, Version 2.0.
|
// Distributed under the Apache License, Version 2.0.
|
||||||
// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html
|
// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html
|
||||||
//
|
//
|
||||||
|
/* globals utils, SHORTBOW_ENTITIES, TEMPLATES:true */
|
||||||
|
|
||||||
Script.include('utils.js');
|
Script.include('utils.js');
|
||||||
Script.include('shortbow.js');
|
Script.include('shortbow.js');
|
||||||
|
@ -19,10 +20,11 @@ TEMPLATES = SHORTBOW_ENTITIES.Entities;
|
||||||
// @returns {object} The new object
|
// @returns {object} The new object
|
||||||
function mergeObjects(a, b) {
|
function mergeObjects(a, b) {
|
||||||
var obj = {};
|
var obj = {};
|
||||||
for (var key in b) {
|
var key;
|
||||||
|
for (key in b) {
|
||||||
obj[key] = b[key];
|
obj[key] = b[key];
|
||||||
}
|
}
|
||||||
for (var key in a) {
|
for (key in a) {
|
||||||
obj[key] = a[key];
|
obj[key] = a[key];
|
||||||
}
|
}
|
||||||
return obj;
|
return obj;
|
||||||
|
@ -55,7 +57,7 @@ function spawnTemplate(templateName, overrides) {
|
||||||
// @return {object} The matching template, or null if not found
|
// @return {object} The matching template, or null if not found
|
||||||
function getTemplate(name) {
|
function getTemplate(name) {
|
||||||
for (var i = 0; i < TEMPLATES.length; ++i) {
|
for (var i = 0; i < TEMPLATES.length; ++i) {
|
||||||
if (TEMPLATES[i].name == name) {
|
if (TEMPLATES[i].name === name) {
|
||||||
return TEMPLATES[i];
|
return TEMPLATES[i];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -68,7 +70,7 @@ for (var i = 0; i < TEMPLATES.length; ++i) {
|
||||||
var template = TEMPLATES[i];
|
var template = TEMPLATES[i];
|
||||||
|
|
||||||
// Fixup model url
|
// Fixup model url
|
||||||
if (template.type == "Model") {
|
if (template.type === "Model") {
|
||||||
var urlParts = template.modelURL.split("/");
|
var urlParts = template.modelURL.split("/");
|
||||||
var filename = urlParts[urlParts.length - 1];
|
var filename = urlParts[urlParts.length - 1];
|
||||||
var newURL = Script.resolvePath("models/" + filename);
|
var newURL = Script.resolvePath("models/" + filename);
|
||||||
|
@ -155,8 +157,8 @@ function createLocalGame() {
|
||||||
serverScripts: Script.resolvePath('shortbowServerEntity.js')
|
serverScripts: Script.resolvePath('shortbowServerEntity.js')
|
||||||
});
|
});
|
||||||
|
|
||||||
bowPositions = [];
|
var bowPositions = [];
|
||||||
spawnPositions = [];
|
var spawnPositions = [];
|
||||||
for (var i = 0; i < TEMPLATES.length; ++i) {
|
for (var i = 0; i < TEMPLATES.length; ++i) {
|
||||||
var template = TEMPLATES[i];
|
var template = TEMPLATES[i];
|
||||||
if (template.name === "SB.BowSpawn") {
|
if (template.name === "SB.BowSpawn") {
|
||||||
|
|
|
@ -7,45 +7,45 @@
|
||||||
//
|
//
|
||||||
|
|
||||||
if (!Function.prototype.bind) {
|
if (!Function.prototype.bind) {
|
||||||
Function.prototype.bind = function(oThis) {
|
Function.prototype.bind = function(oThis) {
|
||||||
if (typeof this !== 'function') {
|
if (typeof this !== 'function') {
|
||||||
// closest thing possible to the ECMAScript 5
|
// closest thing possible to the ECMAScript 5
|
||||||
// internal IsCallable function
|
// internal IsCallable function
|
||||||
throw new TypeError('Function.prototype.bind - what is trying to be bound is not callable');
|
throw new TypeError('Function.prototype.bind - what is trying to be bound is not callable');
|
||||||
}
|
}
|
||||||
|
|
||||||
var aArgs = Array.prototype.slice.call(arguments, 1),
|
var aArgs = Array.prototype.slice.call(arguments, 1),
|
||||||
fToBind = this,
|
fToBind = this,
|
||||||
fNOP = function() {},
|
NOP = function() {},
|
||||||
fBound = function() {
|
fBound = function() {
|
||||||
return fToBind.apply(this instanceof fNOP
|
return fToBind.apply(this instanceof NOP
|
||||||
? this
|
? this
|
||||||
: oThis,
|
: oThis,
|
||||||
aArgs.concat(Array.prototype.slice.call(arguments)));
|
aArgs.concat(Array.prototype.slice.call(arguments)));
|
||||||
};
|
};
|
||||||
|
|
||||||
if (this.prototype) {
|
if (this.prototype) {
|
||||||
// Function.prototype doesn't have a prototype property
|
// Function.prototype doesn't have a prototype property
|
||||||
fNOP.prototype = this.prototype;
|
NOP.prototype = this.prototype;
|
||||||
}
|
}
|
||||||
fBound.prototype = new fNOP();
|
fBound.prototype = new NOP();
|
||||||
|
|
||||||
return fBound;
|
return fBound;
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
utils = {
|
utils = {
|
||||||
parseJSON: function(json) {
|
parseJSON: function(json) {
|
||||||
try {
|
try {
|
||||||
return JSON.parse(json);
|
return JSON.parse(json);
|
||||||
} catch(e) {
|
} catch (e) {
|
||||||
return undefined;
|
return undefined;
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
findSurfaceBelowPosition: function(pos) {
|
findSurfaceBelowPosition: function(pos) {
|
||||||
var result = Entities.findRayIntersection({
|
var result = Entities.findRayIntersection({
|
||||||
origin: pos,
|
origin: pos,
|
||||||
direction: { x: 0, y: -1, z: 0 }
|
direction: { x: 0.0, y: -1.0, z: 0.0 }
|
||||||
});
|
});
|
||||||
if (result.intersects) {
|
if (result.intersects) {
|
||||||
return result.intersection;
|
return result.intersection;
|
||||||
|
|
Loading…
Reference in a new issue