MCPcopy
hub / github.com/lo-th/Oimo.js / initSkeleton

Function initSkeleton

examples/demos/kinematic3.js:40–99  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

38};
39
40function initSkeleton () {
41
42 mid = [];
43
44 var p1 = new THREE.Vector3();
45 var p2 = new THREE.Vector3();
46 var i, lng = bones.length, name, bone, child, o, d, w;
47
48 for( i = 0; i<lng; i++ ){
49
50 bone = bones[i];
51 name = bone.name;
52 d = 1;
53 p1.copy(bone.getWorldPosition());
54
55 if( i===0 || i===1 || i===2 || i===4 ) w = 4;
56 else w = 2;
57
58 if( bone.children.length > 0 ) child = bone.children[0];
59 else child = null;
60
61 if( child !== null ){
62
63 p2.copy( child.getWorldPosition() );
64 d = Math.distanceVector( p1, p2 ) * scale;
65
66 }
67
68 if( i===4 ) d*=2;
69
70 mid[i] = d * 0.5;
71
72 o = {
73 name:name,
74 size:[w,d,w],
75 pos:p1.toArray(),
76 move: true,
77 kinematic: true,
78 density:0.3,
79 restitution:0,
80 material:'donut'
81 }
82
83 add( o );
84
85 //console.log(name, i);
86
87 }
88
89 loaded = true;
90
91 addHair()
92 addExtra();
93
94 // world internal loop
95
96 world.postLoop = postLoop;
97 world.play();

Callers 1

initAnimationFunction · 0.85

Calls 3

addHairFunction · 0.85
addExtraFunction · 0.85
addFunction · 0.50

Tested by

no test coverage detected