Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Azurelib Animator 1.0.8 #553

Merged
merged 8 commits into from
Jun 1, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion plugins.json
Original file line number Diff line number Diff line change
Expand Up @@ -850,7 +850,7 @@
"icon": "azureicon.png",
"description": "Create animated blocks, items, entity, and armor using the AzureLib library and plugin. This is a fork of Geckolib and cross compatibility will not be promised in the future.",
"tags": ["Minecraft: Java Edition"],
"version": "1.0.7",
"version": "1.0.8",
"min_version": "4.8.0",
"new_repository_format": true,
"await_loading": true,
Expand Down
19 changes: 19 additions & 0 deletions plugins/azurelib_utils/LICENSE.MD
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
MIT License

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
9 changes: 5 additions & 4 deletions plugins/azurelib_utils/about.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,14 +22,15 @@ repositories {

dependencies {
//Common 1.20.1+ Latest Only
compileOnly "mod.azure.azurelib:azurelib-common-MCVERSION:MODVERSION"
compileOnly "mod.azure.azurelib:azurelib-common-MCVER:MODVER"

//Fabric or Quilt and older
modImplementation "mod.azure.azurelib:azurelib-fabric-MCVERSION:MODVERSION"
modApi "com.terraformersmc:modmenu:VERSION" // Fabric bug is requiring this
modImplementation "mod.azure.azurelib:azurelib-fabric-MCVER:MODVER"
//Fabric bug is requiring this
modApi "com.terraformersmc:modmenu:VERSION"

//Forge 1.20.1 and older (Forge is no longer supported)
implementation fg.deobf("mod.azure.azurelib:azurelib-forge-MCVERSION:MODVERSION")
implementation fg.deobf("mod.azure.azurelib:azurelib-forge-MCVER:MODVER")

//NeoForge 1.20.1
implementation fg.deobf("mod.azure.azurelib:azurelib-neo-MCVER:MODVER")
Expand Down
2 changes: 1 addition & 1 deletion plugins/azurelib_utils/azurelib_utils.js

Large diffs are not rendered by default.

20 changes: 20 additions & 0 deletions plugins/azurelib_utils/changelog.json
Original file line number Diff line number Diff line change
Expand Up @@ -34,5 +34,25 @@
]
}
]
},
"1.0.8": {
"title": "1.0.8",
"date": "2024-06-01",
"author": "AzureDoom",
"categories": [
{
"title": "Changes",
"list": [
"Disables some logging that isn't needed.",
"Now include a license with plugin info, sourced MIT"
]
},
{
"title": "Fixes",
"list": [
"Fixes issue with easing and keyframes."
]
}
]
}
}
10 changes: 0 additions & 10 deletions src/azurelib_utils/animationUi.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,15 +22,10 @@ export const unloadAnimationUI = () => {

//#region Global Animation UI Handlers
export const displayAnimationFrameCallback = (/*...args*/) => {
// const keyframe = $('#keyframe');
// console.log('displayAnimationFrameCallback:', args, 'keyframe:', keyframe); // keyframe is null here
};

export function updateKeyframeEasing(value) {
Undo.initEdit({keyframes: Timeline.selected})
// var axis = $(obj).attr('axis');
// const value = $(obj).val();
// console.log('updateKeyframeEasing value:', value, 'obj:', obj);
if (value === "-") return;
Timeline.selected.forEach((kf) => {
kf.easing = value;
Expand All @@ -43,11 +38,9 @@ export function updateKeyframeEasing(value) {
export function updateKeyframeEasingArg(obj) {
Undo.initEdit({keyframes: Timeline.selected})
if ($(obj).val() === "-") return;
// console.log('updateKeyframeEasingArg value:', $(obj).val(), 'obj:', obj);
Timeline.selected.forEach((kf) => {
const value = parseEasingArg(kf, $(obj).val().trim());
kf.easingArgs = [value];
// obj.value = value;
})
Undo.finishEdit('edit keyframe easing argument')
}
Expand Down Expand Up @@ -88,7 +81,6 @@ export const updateKeyframeSelectionCallback = (/*...args*/) => {
};

const keyframesByChannel = Timeline.keyframes.reduce((acc, kf) => {
// Dear god I miss lodash
if (!acc.has(kf.animator)) acc.set(kf.animator, {});
const animatorChannels = acc.get(kf.animator);
if (!animatorChannels[kf.channel]) animatorChannels[kf.channel] = [];
Expand Down Expand Up @@ -238,8 +230,6 @@ export const updateKeyframeSelectionCallback = (/*...args*/) => {
</div>`;
scaleBar = document.getElementById('keyframe_bar_easing_arg1');
}

// console.log('easingBar:', easingBar, 'keyframe:', keyframe);
}
}
};
Expand Down
7 changes: 0 additions & 7 deletions src/azurelib_utils/codec.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,11 +25,9 @@ export function unloadCodec() {
function onProjectCompile(e) {
if (Format.id !== "azure_model") return;
e.model.azurelibSettings = azurelibSettings;
// console.log(`compileCallback model:`, e.model);
}

function onProjectParse(e) {
// console.log(`onProjectParse:`, e);
if (e.model && typeof e.model.azurelibSettings === 'object') {
Object.assign(azurelibSettings, omit(e.model.azurelibSettings, ['formatVersion']));
} else {
Expand All @@ -40,7 +38,6 @@ function onProjectParse(e) {

function onBedrockCompile(e) {
console.log('onBedrockCompile e:', e);
// maybeExportItemJson(e.options);
}

function animatorBuildFile() {
Expand All @@ -53,7 +50,6 @@ function animatorBuildFile() {
}
);
}
// console.log('animatorBuildFile res:', res);
return res;
}

Expand Down Expand Up @@ -298,9 +294,6 @@ var format = new ModelFormat({
}
})

//Object.defineProperty(format, 'integer_size', {get: _ => Templates.get('integer_size')})
// codec.format = format; // This sets the default format for the codec

export default codec; // This is used for plugin "Export Animated Model" menu item

//#endregion Codec / ModelFormat
5 changes: 0 additions & 5 deletions src/azurelib_utils/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -68,11 +68,6 @@ if (!semverSatisfies(semverCoerce(Blockbench.version), SUPPORTED_BB_VERSION_RANG
lines: [`<b class="tl"><a href="https://wiki.azuredoom.com/">AzureLib</a> Animation Utils v${version}</b>`],
form: {
objectType: {label: 'Object Type', type: 'select', default: azurelibSettings.objectType, options: OBJ_TYPE_OPTIONS},
// modSDK: {label: 'Modding SDK', type: 'select', default: azurelibSettings.modSDK, options: MOD_SDK_OPTIONS},
// entityType: {label: 'Entity Type', value: azurelibSettings.entityType},
// javaPackage: {label: 'Java Package', value: azurelibSettings.javaPackage},
// animFileNamespace: {label: 'Animation File Namespace', value: azurelibSettings.animFileNamespace},
// animFilePath: {label: 'Animation File Path', value: azurelibSettings.animFilePath},
},
onConfirm: function(formResult) {
Object.assign(azurelibSettings, formResult);
Expand Down
66 changes: 50 additions & 16 deletions src/azurelib_utils/keyframe.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import { easingFunctions, EASING_DEFAULT, getEasingArgDefault } from './easing';
//#region Keyframe Mixins
export function loadKeyframeOverrides() {
addMonkeypatch(Keyframe, "prototype", "getLerp", keyframeGetLerp);
addMonkeypatch(Keyframe, "prototype", "getArray", keyframeGetArray);
addMonkeypatch(Keyframe, "prototype", "compileBedrockKeyframe", keyframeCompileBedrock);
addMonkeypatch(Keyframe, "prototype", "getUndoCopy", keyframeGetUndoCopy);
addMonkeypatch(Keyframe, "prototype", "extend", keyframeExtend);

Expand All @@ -30,29 +30,67 @@ function keyframeGetLerp(other, axis, amount, allow_expression) {
const arg1 = Array.isArray(other.easingArgs) && other.easingArgs.length > 0
? other.easingArgs[0]
: getEasingArgDefault(other);
// console.log(`keyframeGetLerp arg1: ${arg1}`);
easingFunc = easingFunc.bind(null, arg1);
}
const easedAmount = easingFunc(amount);
const start = this.calc(axis);
const stop = other.calc(axis);
const result = lerp(start, stop, easedAmount);
// console.log('keyframeGetLerp easing:', easing, 'arguments:', arguments, 'start:', start, 'stop:', stop, 'amount:', amount, 'easedAmount:', easedAmount, 'result:', result);
if (Number.isNaN(result)) {
throw new Error('batman');
}
return result;
}

function keyframeGetArray() {
const { easing, easingArgs } = this;
let result = Original.get(Keyframe).getArray.apply(this, arguments);
if (Format.id === "azure_model") {
result = { vector: result, easing };
if (hasArgs(easing)) result.easingArgs = easingArgs;
}
console.log('keyframeGetArray arguments:', arguments, 'this:', this, 'result:', result);
return result;
function azurelibGetArray(data_point = 0) {
const { easing, easingArgs, getArray } = this;
let result = getArray.call(this, data_point);

if (Format.id === "azure_model") {
result = { vector: result, easing };
if (hasArgs(easing)) {
result.easingArgs = easingArgs;
}
}

return result;
}

function keyframeCompileBedrock() {
if (Format.id !== "azure_model" || !this.transform) {
return Original.get(Keyframe).compileBedrockKeyframe.apply(this, arguments);
}

const previousKeyframe = this.getPreviousKeyframe.bind(this);

if (this.interpolation === 'catmullrom') {
const previous = previousKeyframe();
const includePre = (!previous && this.time > 0) || (previous && previous.interpolation !== 'catmullrom');

return {
pre: includePre ? azurelibGetArray.call(this, 0) : undefined,
post: azurelibGetArray.call(this, includePre ? 1 : 0),
lerp_mode: this.interpolation,
};
}

if (this.data_points.length === 1) {
const previous = previousKeyframe();

if (previous && previous.interpolation === 'step') {
return new oneLiner({
pre: azurelibGetArray.call(previous, 1),
post: azurelibGetArray.call(this),
});
} else {
return azurelibGetArray.call(this);
}
}

return new oneLiner({
pre: azurelibGetArray.call(this, 0),
post: azurelibGetArray.call(this, 1),
});
}

function keyframeGetUndoCopy() {
Expand All @@ -62,13 +100,11 @@ function keyframeGetUndoCopy() {
Object.assign(result, { easing });
if (hasArgs(easing)) result.easingArgs = easingArgs;
}
console.log('keyframeGetUndoCopy arguments:', arguments, 'this:', this, 'result:', result);
return result;
}

function keyframeExtend(dataIn) {
const data = Object.assign({}, dataIn);
console.log('keyframeExtend 1 arguments:', arguments);
if (Format.id === "azure_model") {
if (typeof data.values === 'object') {
if (data.values.easing !== undefined) {
Expand All @@ -91,13 +127,11 @@ function keyframeExtend(dataIn) {
}
}
const result = Original.get(Keyframe).extend.apply(this, arguments);
console.log('keyframeExtend 2 arguments:', arguments, 'this:', this, 'result:', result);
return result;
}

function reverseKeyframesCondition() {
const res = Original.get(BarItems.reverse_keyframes).condition() && Format.id !== "azure_model";
// console.log('reverseKeyframesCondition original:',Original.get(BarItems.reverse_keyframes).condition(), 'res:', res);
return res;
}

Expand Down
2 changes: 1 addition & 1 deletion src/azurelib_utils/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "azurelib_utils",
"version": "1.0.7",
"version": "1.0.8",
"private": true,
"description": "AzureLib Animator",
"main": "index.js",
Expand Down
Loading