WIP attachable display mode

This commit is contained in:
JannisX11 2023-03-23 00:34:08 +01:00
parent fda020d26e
commit 2eb3ea0bf9
7 changed files with 95 additions and 2 deletions

View File

@ -1938,6 +1938,81 @@ BARS.defineActions(function() {
Undo.finishEdit('Bake animation into model')
}
})
// Attachable Preview
let camera_preset_1st = {
name: tl('action.bedrock_animation_mode.attachable_first'),
id: 'attachable_first',
condition: () => Format.id == 'bedrock' && Project.bedrock_animation_mode == 'attachable_first',
position: [0, 16, -37],
projection: "perspective",
target: [0, 16, 0],
focal_length: 20,
};
DefaultCameraPresets.push(camera_preset_1st);
function updateBase(mode) {
if (mode == 'attachable_first') {
Project.model_3d.position.set(-23, 21, 0);
Project.model_3d.rotation.set(
Math.degToRad(-86.6),
Math.degToRad(42),
Math.degToRad(124),
'ZYX'
);
} else {
Project.model_3d.position.set(0, 0, 0);
Project.model_3d.rotation.set(0, 0, 0);
}
}
let bedrock_animation_mode_select = new BarSelect('bedrock_animation_mode', {
condition: {
modes: ['animate'],
formats: ['bedrock'],
},
category: 'animation',
value: 'entity',
options: {
entity: true,
attachable_first: true,
attachable_third: true
},
onChange() {
if (Project.bedrock_animation_mode == this.value) return;
Project.bedrock_animation_mode = this.value;
updateBase(this.value);
if (this.value == 'entity') {
Preview.selected.loadAnglePreset(DefaultCameraPresets[0]);
} else if (this.value == 'attachable_first') {
Preview.selected.loadAnglePreset(camera_preset_1st);
}
}
})
/*
todo
Third
Add player rig as reference model
Attach model based on binding return values
First
Add center camera button
*/
Blockbench.on('select_project', ({project}) => {
bedrock_animation_mode_select.set(project.bedrock_animation_mode || 'entity');
})
Blockbench.on('select_mode', ({mode}) => {
if (Modes.animate && Project.bedrock_animation_mode) {
updateBase(Project.bedrock_animation_mode);
} else {
updateBase();
}
})
})
Interface.definePanels(function() {

View File

@ -2174,6 +2174,7 @@ const BARS = {
'rotation_space',
'selection_mode',
'animation_controller_preview_mode',
'bedrock_animation_mode',
'lock_motion_trail',
'extrude_mesh_selection',
'inset_mesh_selection',

View File

@ -211,6 +211,10 @@ window.BedrockEntityManager = class BedrockEntityManager {
} else {
this.findEntityTexture(this.project.geometry_name)
}
if (this.client_entity && this.client_entity.type == 'attachable') {
Project.bedrock_animation_mode = 'attachable_first';
BarItems.bedrock_animation_mode.set(Project.bedrock_animation_mode);
}
}
initAnimations() {
let anim_list = this.client_entity && this.client_entity.description && this.client_entity.description.animations;

View File

@ -466,6 +466,12 @@ new Property(ModelProject, 'string', 'skin_pose', {
condition: {formats: ['skin']},
default: 'none'
});
new Property(ModelProject, 'enum', 'bedrock_animation_mode', {
exposed: false,
values: ['entity', 'attachable_first'],
condition: {formats: ['bedrock']},
default: 'entity'
});
new Property(ModelProject, 'array', 'timeline_setups', {
exposed: false,
condition: () => Format.animation_mode,

View File

@ -1381,7 +1381,7 @@ class Preview {
DefaultCameraPresets[0], '_',
...DefaultCameraPresets.slice(1, 7), '_',
...DefaultCameraPresets.slice(7, 11), '_',
...DefaultCameraPresets.slice(11), '_',
...DefaultCameraPresets.slice(11).filter(preset => Condition(preset.condition)), '_',
...presets
];

File diff suppressed because one or more lines are too long

View File

@ -1589,6 +1589,11 @@
"action.lock_motion_trail.desc": "Lock the motion trail to the currently selected group",
"action.looped_animation_playback": "Looped Playback",
"action.looped_animation_playback.desc": "Preview animations in an infinite loop",
"action.bedrock_animation_mode": "Bedrock Animation Mode",
"action.bedrock_animation_mode.desc": "Select the mode to edit animations for Minecraft: Bedrock Edition in",
"action.bedrock_animation_mode.entity": "Entity",
"action.bedrock_animation_mode.attachable_first": "Item 1st Person",
"action.bedrock_animation_mode.attachable_third": "Item 3rd Person",
"timeline.rotation": "Rotation",
"timeline.position": "Position",
@ -1844,6 +1849,8 @@
"codec.fbx.export_animations": "Export Animations",
"preview.center_camera": "Center Camera",
"panel.uv": "UV",
"panel.display": "Display",
"panel.textures": "Textures",