Reactivate old IK code
This commit is contained in:
parent
5cec293c90
commit
2b38a90a58
@ -50,7 +50,7 @@
|
||||
<script src="lib/three_custom.js"></script>
|
||||
<script src="lib/GLTFExporter.js"></script>
|
||||
<script src="lib/CanvasFrame.js"></script>
|
||||
<!--script src="lib/fik.min.js"></script-->
|
||||
<script src="lib/fik.min.js"></script>
|
||||
<script src="lib/molang.js"></script>
|
||||
<script src="js/preview/OrbitControls.js"></script>
|
||||
<script src="js/outliner/tree.vue.js"></script>
|
||||
|
@ -2521,7 +2521,7 @@ BARS.defineActions(function() {
|
||||
Timeline.vue._data.focus_channel = val != 'all' ? val : null;
|
||||
}
|
||||
})
|
||||
/*
|
||||
|
||||
//Inverse Kinematics
|
||||
new Action('ik_enabled', {
|
||||
icon: 'check_box_outline_blank',
|
||||
@ -2553,6 +2553,6 @@ BARS.defineActions(function() {
|
||||
onAfter: function() {
|
||||
Undo.finishEdit('move keyframes')
|
||||
}
|
||||
})*/
|
||||
})
|
||||
|
||||
})
|
||||
|
@ -88,8 +88,8 @@ function updateNslideValues() {
|
||||
}
|
||||
}
|
||||
if (Modes.animate && Group.selected) {
|
||||
//BarItems.slider_ik_chain_length.update();
|
||||
//BarItems.ik_enabled.setIcon(Group.selected.ik_enabled ? 'check_box' : 'check_box_outline_blank')
|
||||
BarItems.slider_ik_chain_length.update();
|
||||
BarItems.ik_enabled.setIcon(Group.selected.ik_enabled ? 'check_box' : 'check_box_outline_blank')
|
||||
}
|
||||
}
|
||||
function setProjectResolution(width, height, modify_uv) {
|
||||
|
@ -1493,7 +1493,6 @@ const BARS = {
|
||||
'rescale_toggle'
|
||||
]
|
||||
})
|
||||
/*
|
||||
Toolbars.bone_ik = new Toolbar({
|
||||
id: 'bone_ik',
|
||||
children: [
|
||||
@ -1501,7 +1500,7 @@ const BARS = {
|
||||
'slider_ik_chain_length'
|
||||
],
|
||||
default_place: !Blockbench.isMobile
|
||||
})*/
|
||||
})
|
||||
|
||||
|
||||
Toolbars.palette = new Toolbar({
|
||||
|
@ -228,15 +228,15 @@ function setupPanels() {
|
||||
condition: {modes: ['animate']},
|
||||
selection_only: true,
|
||||
toolbars: {
|
||||
//bone_ik: Toolbars.bone_ik,
|
||||
bone_ik: Toolbars.bone_ik,
|
||||
},
|
||||
component: {
|
||||
template: `
|
||||
<div>
|
||||
<p>${ tl('panel.element.origin') }</p>
|
||||
<div class="toolbar_wrapper bone_origin"></div>
|
||||
<!--p>${ tl('panel.bone.ik') }</p>
|
||||
<div class="toolbar_wrapper bone_ik"></div-->
|
||||
<p>${ tl('panel.bone.ik') }</p>
|
||||
<div class="toolbar_wrapper bone_ik"></div>
|
||||
</div>
|
||||
`
|
||||
}
|
||||
|
@ -428,6 +428,8 @@ class Group extends OutlinerElement {
|
||||
}});
|
||||
new Property(Group, 'vector', 'rotation');
|
||||
new Property(Group, 'array', 'cem_animations', {condition: () => Format.id == 'optifine_entity'});
|
||||
new Property(Group, 'boolean', 'ik_enabled', {condition: () => Format.animation_mode});
|
||||
new Property(Group, 'number', 'ik_chain_length', {condition: () => Format.animation_mode});
|
||||
|
||||
|
||||
function getCurrentGroup() {
|
||||
|
@ -1049,7 +1049,10 @@
|
||||
var undo_keyframes = [];
|
||||
var animator = Animator.selected.getBoneAnimator();
|
||||
if (animator && Toolbox.selected.id === 'move_tool' && Group.selected.ik_enabled && Group.selected.ik_chain_length) {
|
||||
/*
|
||||
|
||||
|
||||
|
||||
|
||||
var bone = Group.selected;
|
||||
for (var i = Group.selected.ik_chain_length; i > 0; i--) {
|
||||
bone = bone.parent;
|
||||
@ -1063,18 +1066,12 @@
|
||||
}
|
||||
Undo.initEdit({keyframes: undo_keyframes})
|
||||
|
||||
var solver = new FIK.Structure3D(scene);
|
||||
|
||||
var chain = new FIK.Chain3D();
|
||||
var start = new FIK.V3(0, 0, 0);
|
||||
var endLoc = new FIK.V3(0, 2, 0);
|
||||
|
||||
var basebone;
|
||||
|
||||
|
||||
var bones = [];
|
||||
let basebone;
|
||||
let bones = [];
|
||||
var bone = Group.selected;
|
||||
for (var i = Group.selected.ik_chain_length; i >= 0; i--) {
|
||||
for (let i = Group.selected.ik_chain_length; i >= 0; i--) {
|
||||
if (bone instanceof Group) {
|
||||
bones.push(bone);
|
||||
bone = bone.parent;
|
||||
@ -1082,29 +1079,35 @@
|
||||
}
|
||||
|
||||
bones.reverse();
|
||||
var parent_bone;
|
||||
console.log(bones)
|
||||
|
||||
let solver = new FIK.Structure3D(scene);
|
||||
let chain = new FIK.Chain3D();
|
||||
|
||||
let parent_bone;
|
||||
bones.forEach((bone, i) => {
|
||||
|
||||
var copy_bone = new THREE.Bone();
|
||||
var startPoint = new FIK.V3(0,0,0).copy(bone.mesh.getWorldPosition(new THREE.Vector3()))
|
||||
if (!bones[i+1]) return;
|
||||
|
||||
var bone = new FIK.Bone3D(startPoint, startPoint)
|
||||
chain.addBone(bone)
|
||||
let startPoint = new FIK.V3(0,0,0).copy(bone.mesh.getWorldPosition(new THREE.Vector3()))
|
||||
let endPoint = new FIK.V3(0,0,0).copy(bones[i+1].mesh.getWorldPosition(new THREE.Vector3()))
|
||||
console.log(startPoint, endPoint)
|
||||
|
||||
let fik_bone = new FIK.Bone3D(startPoint, endPoint)
|
||||
chain.addBone(fik_bone)
|
||||
if (!basebone) {
|
||||
basebone = bone;
|
||||
basebone = fik_bone;
|
||||
}
|
||||
})
|
||||
|
||||
|
||||
//chain.addBone(new FIK.Bone3D(new FIK.V3(1, 2, 0), new FIK.V3(0, 6, 0), undefined, 1, 0x00FF00));
|
||||
//chain.addBone(new FIK.Bone3D(new FIK.V3(0, 6, 0), new FIK.V3(0, 9, 0), undefined, 1, 0x0000FF));
|
||||
var target = new FIK.V3()
|
||||
let target = new FIK.V3()
|
||||
|
||||
solver.add(chain, target, true);
|
||||
Transformer.solver = solver
|
||||
|
||||
/*
|
||||
Transformer.solver = solver
|
||||
|
||||
|
||||
|
||||
/*
|
||||
var ik_solver = Transformer.ik_solver = {};
|
||||
|
||||
|
||||
@ -1385,16 +1388,16 @@
|
||||
//scope.keyframes[0].select()
|
||||
|
||||
|
||||
/*
|
||||
var ik_solver = Transformer.ik_solver;
|
||||
var solver = Transformer.solver;
|
||||
console.log(solver)
|
||||
|
||||
ik_solver.target.position.copy(planeIntersect.point);
|
||||
solver.targets[0].copy(planeIntersect.point);
|
||||
|
||||
main_preview.render()
|
||||
|
||||
ik_solver.ik.solve();
|
||||
solver.update();
|
||||
|
||||
ik_solver.copy_bones.forEach((copy_bone, i) => {
|
||||
[].forEach((copy_bone, i) => {
|
||||
var keyframe = scope.keyframes[i];
|
||||
if (keyframe) {
|
||||
var bone = copy_bone.original;
|
||||
@ -1408,7 +1411,10 @@
|
||||
}
|
||||
})
|
||||
|
||||
*/
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
} else {
|
||||
scope.keyframes[0].offset(axis, difference);
|
||||
|
Loading…
x
Reference in New Issue
Block a user