mirror of
https://github.com/overte-org/overte.git
synced 2025-04-21 22:44:15 +02:00
Add the hoop
This commit is contained in:
parent
676c02c77e
commit
cbd55ddba6
2 changed files with 49 additions and 113 deletions
|
@ -1,113 +0,0 @@
|
|||
//
|
||||
// createFlashlight.js
|
||||
// examples/entityScripts
|
||||
//
|
||||
// Created by Sam Gateau on 9/9/15.
|
||||
// Copyright 2015 High Fidelity, Inc.
|
||||
//
|
||||
// This is a toy script that create a flashlight entity that lit when grabbed
|
||||
// This can be run from an interface and the flashlight will get deleted from the domain when quitting
|
||||
//a
|
||||
// Distributed under the Apache License, Version 2.0.
|
||||
// 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 */
|
||||
Script.include("../../utilities.js");
|
||||
Script.include("../../libraries/utils.js");
|
||||
|
||||
var courtURL = "https://hifi-public.s3.amazonaws.com/eric/models/woodFloor.fbx";
|
||||
var basketballURL = "https://hifi-public.s3.amazonaws.com/models/content/basketball2.fbx";
|
||||
var ballCollisionSound = "https://hifi-public.s3.amazonaws.com/sounds/basketball/basketball.wav";
|
||||
var hoopURL = "http://hifi-public.s3.amazonaws.com/models/basketball_hoop/basketball_hoop.fbx";
|
||||
var hoopCollisionHullURL = "http://hifi-public.s3.amazonaws.com/models/basketball_hoop/basketball_hoop_collision_hull.obj";
|
||||
|
||||
var BALL_DIAMETER = 0.30;
|
||||
var DISTANCE_IN_FRONT_OF_ME = 1.0;
|
||||
|
||||
var hoopStartPosition =
|
||||
Vec3.sum(MyAvatar.position,
|
||||
Vec3.multiplyQbyV(MyAvatar.orientation, {
|
||||
x: 0,
|
||||
y: 0.0,
|
||||
z: -DISTANCE_IN_FRONT_OF_ME * 2
|
||||
}));
|
||||
|
||||
// courtStartPosition.y = hoopStartPosition.y - 2
|
||||
|
||||
|
||||
// var court = Entities.addEntity({
|
||||
// type: "Model",
|
||||
// modelURL: courtURL,
|
||||
// dimensions: {
|
||||
// x: 28.65,
|
||||
// y: 0.02,
|
||||
// z: 15.24
|
||||
// },
|
||||
// position: courtStartPosition,
|
||||
// shapeType: 'box'
|
||||
// });
|
||||
|
||||
|
||||
|
||||
var ballPosition = Vec3.sum(MyAvatar.position,
|
||||
Vec3.multiplyQbyV(MyAvatar.orientation, {
|
||||
x: 0,
|
||||
y: 0.0,
|
||||
z: -DISTANCE_IN_FRONT_OF_ME
|
||||
}));
|
||||
|
||||
|
||||
|
||||
var ballRotation = Quat.multiply(MyAvatar.orientation,
|
||||
Quat.fromPitchYawRollDegrees(0, -90, 0));
|
||||
|
||||
var basketball = Entities.addEntity({
|
||||
type: "Model",
|
||||
position: ballPosition,
|
||||
rotation: ballRotation,
|
||||
dimensions: {
|
||||
x: BALL_DIAMETER,
|
||||
y: BALL_DIAMETER,
|
||||
z: BALL_DIAMETER
|
||||
},
|
||||
gravity: {
|
||||
x: 0,
|
||||
y: -9.8,
|
||||
z: 0
|
||||
},
|
||||
collisionsWillMove: true,
|
||||
collisionSoundURL: ballCollisionSound,
|
||||
modelURL: basketballURL,
|
||||
restitution: 1.0,
|
||||
linearDamping: 0.00001,
|
||||
shapeType: "sphere"
|
||||
});
|
||||
|
||||
|
||||
var hoop = Entities.addEntity({
|
||||
type: "Model",
|
||||
modelURL: hoopURL,
|
||||
position: hoopStartPosition,
|
||||
shapeType: 'compound',
|
||||
gravity: {
|
||||
x: 0,
|
||||
y: -9.8,
|
||||
z: 0
|
||||
},
|
||||
// rotation: Quat.fromPitchYawRollDegrees(0, -90, 0)),
|
||||
dimensions: {
|
||||
x: 1.89,
|
||||
y: 3.99,
|
||||
z: 3.79
|
||||
},
|
||||
compoundShapeURL: hoopCollisionHullURL
|
||||
});
|
||||
|
||||
|
||||
|
||||
function cleanup() {
|
||||
Entities.deleteEntity(basketball);
|
||||
Entities.deleteEntity(hoop);
|
||||
// Entities.deleteEntity(court);
|
||||
}
|
||||
Script.scriptEnding.connect(cleanup);
|
49
examples/toys/basketball_hoop/createHoop.js
Normal file
49
examples/toys/basketball_hoop/createHoop.js
Normal file
|
@ -0,0 +1,49 @@
|
|||
//
|
||||
// createHoop.js
|
||||
// examples/entityScripts
|
||||
//
|
||||
// Created by James B. Pollack on 9/29/2015
|
||||
// Copyright 2015 High Fidelity, Inc.
|
||||
//
|
||||
// This is a script that creates a persistent basketball hoop with a working collision hull. Feel free to move it.
|
||||
// Run basketball.js to make a basketball.
|
||||
//
|
||||
// Distributed under the Apache License, Version 2.0.
|
||||
// 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 */
|
||||
Script.include("../../utilities.js");
|
||||
Script.include("../../libraries/utils.js");
|
||||
|
||||
var hoopURL = "http://hifi-public.s3.amazonaws.com/models/basketball_hoop/basketball_hoop.fbx";
|
||||
var hoopCollisionHullURL = "http://hifi-public.s3.amazonaws.com/models/basketball_hoop/basketball_hoop_collision_hull.obj";
|
||||
|
||||
|
||||
var DISTANCE_IN_FRONT_OF_ME = 1.0;
|
||||
|
||||
var hoopStartPosition =
|
||||
Vec3.sum(MyAvatar.position,
|
||||
Vec3.multiplyQbyV(MyAvatar.orientation, {
|
||||
x: 0,
|
||||
y: 0.0,
|
||||
z: -DISTANCE_IN_FRONT_OF_ME * 2
|
||||
}));
|
||||
|
||||
|
||||
var hoop = Entities.addEntity({
|
||||
type: "Model",
|
||||
modelURL: hoopURL,
|
||||
position: hoopStartPosition,
|
||||
shapeType: 'compound',
|
||||
gravity: {
|
||||
x: 0,
|
||||
y: -9.8,
|
||||
z: 0
|
||||
},
|
||||
dimensions: {
|
||||
x: 1.89,
|
||||
y: 3.99,
|
||||
z: 3.79
|
||||
},
|
||||
compoundShapeURL: hoopCollisionHullURL
|
||||
});
|
Loading…
Reference in a new issue