mirror of
https://thingvellir.net/git/overte
synced 2025-03-27 23:52:03 +01:00
add hover game scripts
This commit is contained in:
parent
eb3cafb4f9
commit
3603c8cf2e
3 changed files with 165 additions and 0 deletions
60
unpublishedScripts/DomainContent/Home/hoverGame/hoverBall.js
Normal file
60
unpublishedScripts/DomainContent/Home/hoverGame/hoverBall.js
Normal file
|
@ -0,0 +1,60 @@
|
|||
(function() {
|
||||
var _this;
|
||||
HoverBall = function() {
|
||||
_this = this;
|
||||
}
|
||||
|
||||
var MIN_DISTANCE_THRESHOLD = 0.075;
|
||||
|
||||
var CENTER_POINT_LOCATION = {
|
||||
x: 0,
|
||||
y: 0,
|
||||
z: 0
|
||||
};
|
||||
|
||||
HoverBall.prototype = {
|
||||
preload: function(entityID) {
|
||||
this.entityID = entityID;
|
||||
|
||||
},
|
||||
unload: function() {
|
||||
|
||||
},
|
||||
startDistanceGrab: function() {
|
||||
|
||||
},
|
||||
continueDistantGrab: function() {
|
||||
var position = Entities.getEntityProperties(_this.entityID).position;
|
||||
var distanceFromCenterPoint = Vec3.distance(position, CENTER_POINT_LOCATION);
|
||||
if (distanceFromCenterPoint < MIN_DISTANCE_THRESHOLD) {
|
||||
|
||||
_this.turnOnGlow();
|
||||
} else {
|
||||
_this.turnOffGlow();
|
||||
}
|
||||
},
|
||||
releaseGrab: function() {
|
||||
_this.turnOffGlow();
|
||||
},
|
||||
turnOnGlow: function() {
|
||||
|
||||
},
|
||||
turnOffGlow: function() {
|
||||
|
||||
},
|
||||
findHoverContainer: function() {
|
||||
var position = Entities.getEntityProperties(_this.entityID).position;
|
||||
var results = Entities.findEntities(position, 3);
|
||||
results.forEach(function(item) {
|
||||
var props = Entities.getEntityProperties(item);
|
||||
if (props.name.indexOf('hoverGame_container') > -1) {
|
||||
return item
|
||||
}
|
||||
})
|
||||
},
|
||||
|
||||
}
|
||||
|
||||
return new HoverBall();
|
||||
|
||||
})
|
|
@ -0,0 +1,28 @@
|
|||
(function() {
|
||||
|
||||
HoverContainer = function() {
|
||||
|
||||
}
|
||||
|
||||
HoverContainer.prototype = {
|
||||
preload: function(entityID) {
|
||||
this.entityID = entityID;
|
||||
|
||||
var data = {
|
||||
action: 'add',
|
||||
id: this.entityID
|
||||
};
|
||||
Messages.sendLocalMessage('Hifi-Hand-RayPick-Blacklist', JSON.stringify(data))
|
||||
},
|
||||
unload: function() {
|
||||
var data = {
|
||||
action: 'remove',
|
||||
id: this.entityID
|
||||
};
|
||||
Messages.sendLocalMessage('Hifi-Hand-RayPick-Blacklist', JSON.stringify(data))
|
||||
}
|
||||
}
|
||||
|
||||
return new HoverContainer();
|
||||
|
||||
})
|
77
unpublishedScripts/DomainContent/Home/hoverGame/wrapper.js
Normal file
77
unpublishedScripts/DomainContent/Home/hoverGame/wrapper.js
Normal file
|
@ -0,0 +1,77 @@
|
|||
// createPingPongGun.js
|
||||
//
|
||||
// Script Type: Entity Spawner
|
||||
// Created by James B. Pollack on 9/30/2015
|
||||
// Copyright 2015 High Fidelity, Inc.
|
||||
//
|
||||
// This script creates a gun that shoots ping pong balls when you pull the trigger on a hand controller.
|
||||
// Distributed under the Apache License, Version 2.0.
|
||||
// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html
|
||||
//
|
||||
|
||||
|
||||
HoverGame = function(spawnPosition, spawnRotation) {
|
||||
|
||||
var scriptURL = "atp:/hoverGame/hoverInner.js";
|
||||
|
||||
var hoverContainerProps = {
|
||||
type: 'Model',
|
||||
modelURL: 'atp:/hoverGame/hover.fbx',
|
||||
name: 'home_model_hoverGame_container',
|
||||
dimensions: {
|
||||
x: 0.2543,
|
||||
y: 0.3269,
|
||||
z: 0.4154
|
||||
},
|
||||
compoundShapeURL: 'atp:/hoverGame/hoverHull.obj',
|
||||
rotation: spawnRotation,
|
||||
script: scriptURL,
|
||||
userData: JSON.stringify({
|
||||
"grabbableKey": {
|
||||
"grabbable":false
|
||||
},
|
||||
'hifiHomeKey': {
|
||||
'reset': true
|
||||
}
|
||||
}),
|
||||
dynamic: true,
|
||||
position: spawnPosition
|
||||
};
|
||||
|
||||
var hoverBall = {
|
||||
type: 'Sphere',
|
||||
name: 'home_model_hoverGame_sphere',
|
||||
dimensions: {
|
||||
x: 0.25,
|
||||
y: 0.25,
|
||||
z: 0.25,
|
||||
},
|
||||
compoundShapeURL: 'atp:/hoverGame/hoverHull.obj',
|
||||
rotation: spawnRotation,
|
||||
script: scriptURL,
|
||||
userData: JSON.stringify({
|
||||
'hifiHomeKey': {
|
||||
'reset': true
|
||||
}
|
||||
}),
|
||||
dynamic: true,
|
||||
gravity:{
|
||||
x:0,
|
||||
y:-9.8,
|
||||
z:0
|
||||
},
|
||||
position: spawnPosition
|
||||
};
|
||||
|
||||
var hoverContainer = Entities.addEntity(hoverContainerProps);
|
||||
|
||||
function cleanup() {
|
||||
print('HOVER GAME CLEANUP!')
|
||||
Entities.deleteEntity(hoverInner);
|
||||
}
|
||||
|
||||
this.cleanup = cleanup;
|
||||
|
||||
print('HOME CREATED HOVER GAME')
|
||||
|
||||
}
|
Loading…
Reference in a new issue