89 lines
3.4 KiB
JavaScript
89 lines
3.4 KiB
JavaScript
// drumSticks.js
|
|
|
|
|
|
(function() {
|
|
|
|
var DRUM_STICK_MODEL = "http://hifi-content.s3.amazonaws.com/alexia/Keyboard/drumstick.fbx";
|
|
var DRUM_STICK_SHAFT_MODEL = "http://hifi-content.s3.amazonaws.com/alexia/Keyboard/drumstick_shaft.fbx";
|
|
|
|
function DrumSticks() {
|
|
var _this = this;
|
|
_this.entity = null;
|
|
_this.leftDrumStick = null;
|
|
_this.rightDrumStick = null;
|
|
_this.leftDrumStickShaft = null;
|
|
_this.rightDrumStickShaft = null;
|
|
_this.leftHandJointIndex = null;
|
|
_this.rightHandJointIndex = null;
|
|
this.preload = function(entityID) {
|
|
_this.entity = entityID;
|
|
_this.rightHandJointIndex = MyAvatar.getJointIndex("_CAMERA_RELATIVE_CONTROLLER_RIGHTHAND");
|
|
_this.leftHandJointIndex = MyAvatar.getJointIndex("_CAMERA_RELATIVE_CONTROLLER_LEFTHAND");
|
|
};
|
|
|
|
this.enterEntity = function(entity) {
|
|
print(_this.leftHandJointIndex);
|
|
_this.leftDrumStick = Entities.addEntity({
|
|
name: "LeftDrumStick",
|
|
type: "Model",
|
|
localPosition: {x: 0.0, y: 0.43, z: 0.04},
|
|
localRotation: Quat.IDENTITY,
|
|
collisionless: false,
|
|
shapeType: "sphere",
|
|
dynamic: true,
|
|
modelURL: DRUM_STICK_MODEL,
|
|
parentID: MyAvatar.sessionUUID,
|
|
parentJointIndex: _this.leftHandJointIndex
|
|
});
|
|
|
|
_this.leftDrumStickShaft = Entities.addEntity({
|
|
name: "LeftDrumStickShaft",
|
|
type: "Model",
|
|
localPosition: {x: 0.0, y: 0.3, z: 0.04},
|
|
localRotation: Quat.IDENTITY,
|
|
collisionless: true,
|
|
modelURL: DRUM_STICK_SHAFT_MODEL,
|
|
parentID: MyAvatar.sessionUUID,
|
|
parentJointIndex: _this.leftHandJointIndex
|
|
});
|
|
|
|
_this.rightDrumStick = Entities.addEntity({
|
|
name: "RightDrumStick",
|
|
type: "Model",
|
|
localPosition: {x: 0.0, y: 0.43, z: 0.04},
|
|
localRotation: Quat.IDENTITY,
|
|
collisionless: false,
|
|
shapeType: "sphere",
|
|
dynamic: true,
|
|
modelURL: DRUM_STICK_MODEL,
|
|
parentID: MyAvatar.sessionUUID,
|
|
parentJointIndex: _this.rightHandJointIndex
|
|
});
|
|
|
|
_this.rightDrumStickShaft = Entities.addEntity({
|
|
name: "LeftDrumStickShaft",
|
|
type: "Model",
|
|
localPosition: {x: 0.0, y: 0.3, z: 0.04},
|
|
localRotation: Quat.IDENTITY,
|
|
collisionless: true,
|
|
modelURL: DRUM_STICK_SHAFT_MODEL,
|
|
parentID: MyAvatar.sessionUUID,
|
|
parentJointIndex: _this.rightHandJointIndex
|
|
});
|
|
};
|
|
|
|
this.leaveEntity = function(enity) {
|
|
Entities.deleteEntity(_this.leftDrumStick);
|
|
Entities.deleteEntity(_this.rightDrumStick);
|
|
Entities.deleteEntity(_this.leftDrumStickShaft);
|
|
Entities.deleteEntity(_this.rightDrumStickShaft);
|
|
_this.leftDrumStick = null;
|
|
_this.rightDrumStick = null;
|
|
_this.leftDrumStickShaft = null;
|
|
_this.rightDrumStickShaft = null;
|
|
};
|
|
}
|
|
|
|
|
|
return new DrumSticks();
|
|
});
|