mirror of
https://github.com/overte-org/overte.git
synced 2025-08-10 18:03:27 +02:00
physical rack
This commit is contained in:
parent
6cc3077d67
commit
152fdb8112
1 changed files with 28 additions and 13 deletions
|
@ -9,16 +9,21 @@
|
||||||
// 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
|
||||||
/*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 */
|
/*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 */
|
||||||
|
Script.include("../../libraries/utils.js");
|
||||||
|
|
||||||
var HIFI_PUBLIC_BUCKET = "http://s3.amazonaws.com/hifi-public/";
|
var HIFI_PUBLIC_BUCKET = "http://s3.amazonaws.com/hifi-public/";
|
||||||
|
|
||||||
var basketballURL = HIFI_PUBLIC_BUCKET + "models/content/basketball2.fbx";
|
var basketballURL = HIFI_PUBLIC_BUCKET + "models/content/basketball2.fbx";
|
||||||
var collisionSoundURL = HIFI_PUBLIC_BUCKET + "sounds/basketball/basketball.wav";
|
var collisionSoundURL = HIFI_PUBLIC_BUCKET + "sounds/basketball/basketball.wav";
|
||||||
var rackURL = HIFI_PUBLIC_BUCKET + "models/basketball_hoop/basketball_rack.fbx";
|
var rackURL = HIFI_PUBLIC_BUCKET + "models/basketball_hoop/basketball_rack.fbx";
|
||||||
var rackCollisionHullURL = HIFI_PUBLIC_BUCKET + "models/basketball_hoop/basketball_hoop_collision_hull.obj";
|
var rackCollisionHullURL = HIFI_PUBLIC_BUCKET + "models/basketball_hoop/rack_collision_hull.obj";
|
||||||
var basketballSwitcherURL= Script.resolvePath('basketballSwitcher.js');
|
var basketballSwitcherURL = Script.resolvePath('basketballSwitcher.js');
|
||||||
|
|
||||||
|
var NUMBER_OF_BALLS = 4;
|
||||||
var DIAMETER = 0.30;
|
var DIAMETER = 0.30;
|
||||||
|
|
||||||
|
var GRABBABLE_DATA_KEY = "grabbableKey";
|
||||||
|
|
||||||
var rackStartPosition =
|
var rackStartPosition =
|
||||||
Vec3.sum(MyAvatar.position,
|
Vec3.sum(MyAvatar.position,
|
||||||
Vec3.multiplyQbyV(MyAvatar.orientation, {
|
Vec3.multiplyQbyV(MyAvatar.orientation, {
|
||||||
|
@ -28,25 +33,31 @@ var rackStartPosition =
|
||||||
}));
|
}));
|
||||||
|
|
||||||
var rack = Entities.addEntity({
|
var rack = Entities.addEntity({
|
||||||
|
name:'Basketball Rack',
|
||||||
type: "Model",
|
type: "Model",
|
||||||
modelURL: rackURL,
|
modelURL: rackURL,
|
||||||
position: rackStartPosition,
|
position: rackStartPosition,
|
||||||
shapeType: 'compound',
|
shapeType: 'compound',
|
||||||
// gravity: {
|
gravity: {
|
||||||
// x: 0,
|
x: 0,
|
||||||
// y: -9.8,
|
y: -9.8,
|
||||||
// z: 0
|
z: 0
|
||||||
// },
|
},
|
||||||
|
linearDamping:1,
|
||||||
dimensions: {
|
dimensions: {
|
||||||
x: 0.4,
|
x: 0.4,
|
||||||
y: 1.37,
|
y: 1.37,
|
||||||
z: 1.73
|
z: 1.73
|
||||||
},
|
},
|
||||||
collisionsWillMove: false,
|
collisionsWillMove: true,
|
||||||
ignoreForCollisions: false,
|
ignoreForCollisions: false,
|
||||||
compoundShapeURL: rackCollisionHullURL
|
compoundShapeURL: rackCollisionHullURL
|
||||||
});
|
});
|
||||||
|
|
||||||
|
setEntityCustomData(GRABBABLE_DATA_KEY, rack, {
|
||||||
|
grabbable: false
|
||||||
|
});
|
||||||
|
|
||||||
var nonCollidingBalls = [];
|
var nonCollidingBalls = [];
|
||||||
var collidingBalls = [];
|
var collidingBalls = [];
|
||||||
|
|
||||||
|
@ -100,11 +111,11 @@ function createNonCollidingBalls() {
|
||||||
function createCollidingBalls() {
|
function createCollidingBalls() {
|
||||||
var position = rackStartPosition;
|
var position = rackStartPosition;
|
||||||
var i;
|
var i;
|
||||||
for (i = 0; i < 4; i++) {
|
for (i = 0; i < NUMBER_OF_BALLS; i++) {
|
||||||
var collidingBall = Entities.addEntity({
|
var collidingBall = Entities.addEntity({
|
||||||
type: "Model",
|
type: "Model",
|
||||||
name: 'Colliding Basketball',
|
name: 'Colliding Basketball',
|
||||||
shapeType:'Sphere',
|
shapeType: 'Sphere',
|
||||||
position: {
|
position: {
|
||||||
x: position.x,
|
x: position.x,
|
||||||
y: position.y + DIAMETER * 2,
|
y: position.y + DIAMETER * 2,
|
||||||
|
@ -116,15 +127,19 @@ function createCollidingBalls() {
|
||||||
z: DIAMETER
|
z: DIAMETER
|
||||||
},
|
},
|
||||||
restitution: 1.0,
|
restitution: 1.0,
|
||||||
linearDamping: 1,
|
linearDamping: 0.00001,
|
||||||
|
gravity: {
|
||||||
|
x: 0,
|
||||||
|
y: -9.8,
|
||||||
|
z: 0
|
||||||
|
},
|
||||||
collisionsWillMove: true,
|
collisionsWillMove: true,
|
||||||
ignoreForCollisions: false,
|
ignoreForCollisions: false,
|
||||||
modelURL: basketballURL,
|
modelURL: basketballURL,
|
||||||
script:basketballSwitcherURL
|
|
||||||
});
|
});
|
||||||
collidingBalls.push(collidingBall);
|
collidingBalls.push(collidingBall);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
createNonCollidingBalls();
|
// createNonCollidingBalls();
|
||||||
createCollidingBalls();
|
createCollidingBalls();
|
Loading…
Reference in a new issue