Skip to content

Commit 0127ea8

Browse files
committed
2D BlendSpace Modes & Weights
1 parent c23d3ce commit 0127ea8

3 files changed

Lines changed: 529 additions & 20 deletions

File tree

code/template_tweakpanel.html

Lines changed: 16 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@
2626
// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
2727
Debug.pnt.add( [0,0.5,0], 0x00ff00, 5, 2 );
2828
Debug.ln.add( [0,0.5,0], [0,1,0], 0xffffff );
29-
29+
3030
// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
3131
// App.createRenderLoop( onPreRender ).start();
3232
App.renderLoop();
@@ -35,7 +35,7 @@
3535

3636
function onPreRender( dt, et ){}
3737

38-
async function buildUI(){
38+
async function buildUI(){
3939
appendGithubLink( false );
4040
// ! https://github.com/tallneil/tweakpane-plugin-inputs
4141
// https://github.com/dgxyzw/tweakpane-plugin-gradient
@@ -44,7 +44,7 @@
4444
// https://github.com/donmccurdy/tweakpane-plugin-thumbnail-list?tab=readme-ov-file
4545
// https://github.com/tweakpane/plugin-camerakit
4646
// https://github.com/0b5vr/tweakpane-plugin-rotation
47-
// https://github.com/cocopon/tweakpane/issues/508 Example of reset control
47+
// https://github.com/cocopon/tweakpane/issues/508 Example of reset control
4848
// https://github.com/0b5vr/tweakpane-plugin-profiler
4949
// https://github.com/brunoimbrizi/tweakpane-plugin-chromatic
5050
// https://github.com/LuchoTurtle/tweakpane-plugin-file-import
@@ -83,7 +83,7 @@
8383
// f2.addBinding( Ref, 'Yellow', { readonly: true, });
8484
// f2.addBinding( Ref, 'L_click', { readonly: true, });
8585
// f2.addBinding( Ref, 'R_click', { readonly: true, });
86-
86+
8787
// f0.addBinding( Ref, 'showGizmo', { label: 'Gizmo' } ).on( "change", e=>{
8888
// if( e.value ) Gizmo.show();
8989
// else Gizmo.hide();
@@ -106,6 +106,17 @@
106106
// y : { step:0.01, min:-1, max:1, inverted:true },
107107
// });
108108

109+
// state.sel = 0
110+
// f.addBinding( state, 'sel', {
111+
// label : 'Modes',
112+
// options : {
113+
// Quadrants : 0,
114+
// Diamond : 1,
115+
// Corners : 2,
116+
// Triangle : 3,
117+
// },
118+
// });
119+
109120
// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
110121
Ref.pane = p;
111122
}
@@ -124,4 +135,4 @@
124135
.ppane .tp-sldtxtv_t { max-width: 40px; }
125136
.ppane .tp-sglv_i{ color:white; }
126137
</style>
127-
</body></html>
138+
</body></html>

code/webgl/anim/001_char_0_root.html

Lines changed: 12 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@
4040
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
4141
Animation Tree
4242
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
4444
https://www.youtube.com/watch?v=km4SGFzpEc0
4545
https://godotforums.org/d/33975-programmatically-setup-animation-trees/2
4646
https://kidscancode.org/godot_recipes/4.x/animation/using_animation_sm/index.html
@@ -92,29 +92,26 @@
9292
loadAnimations( `${url}/anim_land_traverse.gltf` ),
9393
]);
9494

95-
96-
95+
// aryAnim.forEach( (o,i)=>console.log( i, o.name ) );
96+
9797
// Add character to scene
9898
App.scene.add( root );
9999
Ref.skel = skinned.skeleton;
100100
Ref.root = root;
101101

102102
// Execute Animation
103-
const clip = aryAnim[19];
103+
const clip = aryAnim[19];
104104
Ref.mixer = new THREE.AnimationMixer( skinned );
105105
Ref.action = Ref.mixer.clipAction( clip );
106106
Ref.action.play();
107-
107+
108108
await TEST();
109109

110110
Ref.frame0 = clipFramePosition( clip, 'origin', 0 );
111111
Ref.frameX = clipFramePosition( clip, 'origin', -1 );
112112

113-
114113
// console.log( Ref.frame0, Ref.frameX );
115114

116-
117-
118115
// skinned.skeleton.bones.forEach( (v,i)=>console.log( i, v.name ) );
119116
// aryAnim.forEach( (v,i)=>console.log( i, v.name ) );
120117

@@ -142,7 +139,7 @@
142139
// NEW LOOP, RESET PREV
143140

144141
// Delta between last pos in prev loop to last frame
145-
DELTA.fromSub( Ref.frameX, PREV );
142+
DELTA.fromSub( Ref.frameX, PREV );
146143
DELTA[1] = 0;
147144

148145
// Copy current postion as new PREV for next frame
@@ -155,13 +152,13 @@
155152

156153
// Add Both deltas !!!!
157154
DELTA2.add( DELTA );
158-
155+
159156
Ref.root.position.x += DELTA2[0];
160157
Ref.root.position.z += DELTA2[2];
161158
}else{
162159
// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
163160
// CURRENT LOOP
164-
161+
165162
// Compute position delta
166163
CURR.copyObj( rBone.position );
167164
CURR[1] = 0;
@@ -198,8 +195,8 @@
198195
let skinned;
199196
let mat = null;
200197
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 } );
203200

204201
if( mat ) m.material = mat;
205202
// if( !skel ) skel = m.skeleton; // First skeleton
@@ -219,7 +216,7 @@
219216
if( opt.skelHelper ){
220217
App.scene.add( new THREE.SkeletonHelper( skel.bones[0] ) );
221218
}
222-
219+
223220
// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
224221
return [ tf.scene, skinned ];
225222
}
@@ -264,7 +261,7 @@
264261
App.scene.add( root );
265262

266263
// Execute Animation
267-
const clip = aryAnim[19];
264+
const clip = aryAnim[19];
268265
Ref.mixer2 = new THREE.AnimationMixer( skinned );
269266
Ref.action2 = Ref.mixer2.clipAction( clip );
270267
Ref.action2.play();

0 commit comments

Comments
 (0)