|
40 | 40 | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ |
41 | 41 | Animation Tree |
42 | 42 | https://docs.godotengine.org/en/latest/tutorials/animation/animation_tree.html |
43 | | -https://www.youtube.com/watch?v=iElHZhOxGYA |
| 43 | +https://www.youtube.com/watch?v=iElHZhOxGYA |
44 | 44 | https://www.youtube.com/watch?v=km4SGFzpEc0 |
45 | 45 | https://godotforums.org/d/33975-programmatically-setup-animation-trees/2 |
46 | 46 | https://kidscancode.org/godot_recipes/4.x/animation/using_animation_sm/index.html |
|
92 | 92 | loadAnimations( `${url}/anim_land_traverse.gltf` ), |
93 | 93 | ]); |
94 | 94 |
|
95 | | - |
96 | | - |
| 95 | + // aryAnim.forEach( (o,i)=>console.log( i, o.name ) ); |
| 96 | + |
97 | 97 | // Add character to scene |
98 | 98 | App.scene.add( root ); |
99 | 99 | Ref.skel = skinned.skeleton; |
100 | 100 | Ref.root = root; |
101 | 101 |
|
102 | 102 | // Execute Animation |
103 | | - const clip = aryAnim[19]; |
| 103 | + const clip = aryAnim[19]; |
104 | 104 | Ref.mixer = new THREE.AnimationMixer( skinned ); |
105 | 105 | Ref.action = Ref.mixer.clipAction( clip ); |
106 | 106 | Ref.action.play(); |
107 | | - |
| 107 | + |
108 | 108 | await TEST(); |
109 | 109 |
|
110 | 110 | Ref.frame0 = clipFramePosition( clip, 'origin', 0 ); |
111 | 111 | Ref.frameX = clipFramePosition( clip, 'origin', -1 ); |
112 | 112 |
|
113 | | - |
114 | 113 | // console.log( Ref.frame0, Ref.frameX ); |
115 | 114 |
|
116 | | - |
117 | | - |
118 | 115 | // skinned.skeleton.bones.forEach( (v,i)=>console.log( i, v.name ) ); |
119 | 116 | // aryAnim.forEach( (v,i)=>console.log( i, v.name ) ); |
120 | 117 |
|
|
142 | 139 | // NEW LOOP, RESET PREV |
143 | 140 |
|
144 | 141 | // Delta between last pos in prev loop to last frame |
145 | | - DELTA.fromSub( Ref.frameX, PREV ); |
| 142 | + DELTA.fromSub( Ref.frameX, PREV ); |
146 | 143 | DELTA[1] = 0; |
147 | 144 |
|
148 | 145 | // Copy current postion as new PREV for next frame |
|
155 | 152 |
|
156 | 153 | // Add Both deltas !!!! |
157 | 154 | DELTA2.add( DELTA ); |
158 | | - |
| 155 | + |
159 | 156 | Ref.root.position.x += DELTA2[0]; |
160 | 157 | Ref.root.position.z += DELTA2[2]; |
161 | 158 | }else{ |
162 | 159 | // ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ |
163 | 160 | // CURRENT LOOP |
164 | | - |
| 161 | + |
165 | 162 | // Compute position delta |
166 | 163 | CURR.copyObj( rBone.position ); |
167 | 164 | CURR[1] = 0; |
|
198 | 195 | let skinned; |
199 | 196 | let mat = null; |
200 | 197 | for( const m of util.traverseFind( tf.scene, o=> (o.type === 'SkinnedMesh') ) ){ |
201 | | - if( opt.phong != null ) mat = new THREE.MeshPhongMaterial( { color: opt.phong } ); |
202 | | - if( opt.toon ) mat = new THREE.MeshToonMaterial( { map: m.material.map, normalMap: m.material.normalMap } ); |
| 198 | + if( opt.phong != null ) mat = new THREE.MeshPhongMaterial( { color: opt.phong } ); |
| 199 | + if( opt.toon ) mat = new THREE.MeshToonMaterial( { map: m.material.map, normalMap: m.material.normalMap } ); |
203 | 200 |
|
204 | 201 | if( mat ) m.material = mat; |
205 | 202 | // if( !skel ) skel = m.skeleton; // First skeleton |
|
219 | 216 | if( opt.skelHelper ){ |
220 | 217 | App.scene.add( new THREE.SkeletonHelper( skel.bones[0] ) ); |
221 | 218 | } |
222 | | - |
| 219 | + |
223 | 220 | // ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ |
224 | 221 | return [ tf.scene, skinned ]; |
225 | 222 | } |
|
264 | 261 | App.scene.add( root ); |
265 | 262 |
|
266 | 263 | // Execute Animation |
267 | | - const clip = aryAnim[19]; |
| 264 | + const clip = aryAnim[19]; |
268 | 265 | Ref.mixer2 = new THREE.AnimationMixer( skinned ); |
269 | 266 | Ref.action2 = Ref.mixer2.clipAction( clip ); |
270 | 267 | Ref.action2.play(); |
|
0 commit comments