Bone.js 962 字节
Newer Older
1 2
/**
 * @author mikael emtinger / http://gomo.se/
A
alteredq 已提交
3
 * @author alteredq / http://alteredqualia.com/
4 5 6
 */

THREE.Bone = function( belongsToSkin ) {
7

8
	THREE.Object3D.call( this );
9 10

	this.skin = belongsToSkin;
11

12 13 14 15
	this.accumulatedRotWeight = 0;
	this.accumulatedPosWeight = 0;
	this.accumulatedSclWeight = 0;

16 17
};

18
THREE.Bone.prototype = Object.create( THREE.Object3D.prototype );
19

20
THREE.Bone.prototype.update = function ( forceUpdate ) {
21

22 23
	// update local

24 25 26 27 28 29
	if ( this.matrixAutoUpdate ) {

		forceUpdate |= this.updateMatrix();

	}

30 31
	// update skin matrix

32
	if ( forceUpdate || this.matrixWorldNeedsUpdate ) {
33

34
		this.matrixWorldNeedsUpdate = false;
35
		forceUpdate = true;
36

37 38 39 40 41 42
		// Reset weights to be re-accumulated in the next frame

		this.accumulatedRotWeight = 0;
		this.accumulatedPosWeight = 0;
		this.accumulatedSclWeight = 0;

43 44 45
	}

	// update children
A
alteredq 已提交
46

M
Mr.doob 已提交
47
	for ( var i = 0, l = this.children.length; i < l; i ++ ) {
48

49
		this.children[ i ].update( forceUpdate );
50

51 52 53 54
	}

};