"use strict";
var THEGAME = THEGAME || {};
var _gameEngine;
function degreeToRadians(deg) {
return deg * (Math.PI / 180);
}
THEGAME.Engine = function (babylonEngine) {
this._babylonEngine = babylonEngine;
this._scene = null;
this._meshRegularGuy = null;
this._camera = null;
this._currentDebugBoxToDisplay = 0;
this._debugBoneBoxes = [];
this._ragDollReady = false;
var that = this;
THEGAME.Engine.prototype.updateRagDoll = function () {
for (var x = 0; x < that._skeletonRegularGuy.bones.length; x++) {
// for each "test" bone (we'll try just a couple bones)
var bone = (that._skeletonRegularGuy.bones[x]);
if (bone.name != "rHand" && bone.name != "rForeArm" && bone.name != "lHand" && bone.name != "lForeArm") {
continue;
}
// get the bone's absolute matrix
var boneMatrix = bone.getAbsoluteMatrix().clone();
// now find the mesh with the physics enabled...
var boneDebugBox = "debugBox_" + bone.name;
var boneMesh = that._scene.getMeshByName(boneDebugBox);
var boneMeshParent = null;
if (bone._parent) {
var boneParentDebugBox = "debugBox_" + bone._parent.name;
boneMeshParent = that._scene.getMeshByName(boneParentDebugBox);
}
// now I want to orient the bone to the LOCATION of the mesh
// I do this by taking the difference in start and current mesh position
// and apply the Translation to the matrix (this works)
var startPosition = boneMesh.saveStartPosition;
var vectorDiff = boneMesh.position.subtract(boneMesh.saveStartPosition);
if (boneMeshParent) {
var vectorDiffParent = boneMeshParent.position.subtract(boneMeshParent.saveStartPosition);
vectorDiff = vectorDiff.subtract(vectorDiffParent);
}
...
Please Whitelist JSFiddle in your content blocker.
Help keep JSFiddle free for always by one of two ways:
Whitelist JSFiddle in your content blocker (two clicks)
Go PRO and get access to additional PRO features →
Join the 4+ million users, and keep the JSFiddle dream alive.
Ad-free
All ads in the editor and listing pages are turned completely off.
Use pre-released features
You get to try and use features (like the Palette Color Generator) months before everyone else.
Fiddle collections
Sort and categorize your Fiddles into multiple collections.
Private collections and fiddles
You can make as many Private Fiddles, and Private Collections as you wish!
Console
Debug your Fiddle with a minimal built-in JavaScript console.