diff --git a/src/core/rendering/conversion/ninja_geometry.ts b/src/core/rendering/conversion/ninja_geometry.ts index c086dd46..26c5e351 100644 --- a/src/core/rendering/conversion/ninja_geometry.ts +++ b/src/core/rendering/conversion/ninja_geometry.ts @@ -202,8 +202,13 @@ class GeometryCreator { bones[vertex.bone_weight_status] = [vertex.bone_id, vertex.bone_weight]; } + const total_weight = bones.reduce((total, [, weight]) => total + weight, 0); + for (const [bone_index, bone_weight] of bones) { - this.builder.add_bone_weight(bone_index, bone_weight); + this.builder.add_bone_weight( + bone_index, + total_weight > 0 ? bone_weight / total_weight : bone_weight, + ); } } } diff --git a/src/viewer/gui/model_3d/Model3DSelectListView.ts b/src/viewer/gui/model_3d/Model3DSelectListView.ts index ccbbe1d7..e6fbc8b2 100644 --- a/src/viewer/gui/model_3d/Model3DSelectListView.ts +++ b/src/viewer/gui/model_3d/Model3DSelectListView.ts @@ -33,21 +33,24 @@ export class Model3DSelectListView extends Resizable }); this.disposable( - selected.observe(({ value: model }) => { - if (this.selected_element) { - this.selected_element.classList.remove("active"); - this.selected_element = undefined; - } - - if (model && model !== this.selected_model) { - const index = this.models.indexOf(model); - - if (index !== -1) { - this.selected_element = this.element.childNodes[index] as HTMLLIElement; - this.selected_element.classList.add("active"); + selected.observe( + ({ value: model }) => { + if (this.selected_element) { + this.selected_element.classList.remove("active"); + this.selected_element = undefined; } - } - }), + + if (model && model !== this.selected_model) { + const index = this.models.indexOf(model); + + if (index !== -1) { + this.selected_element = this.element.childNodes[index] as HTMLLIElement; + this.selected_element.classList.add("active"); + } + } + }, + { call_now: true }, + ), ); this.finalize_construction(); diff --git a/src/viewer/stores/Model3DStore.ts b/src/viewer/stores/Model3DStore.ts index 1028b6d5..f4706350 100644 --- a/src/viewer/stores/Model3DStore.ts +++ b/src/viewer/stores/Model3DStore.ts @@ -195,7 +195,7 @@ export class Model3DStore extends Store { this.current_animation.observe(({ value }) => this.load_animation(value)), ); - this.set_current_model(this.models[[3, 5, 6, 8][Math.floor(Math.random() * 4)]]); + this.set_current_model(this.models[Math.floor(Math.random() * this.models.length)]); } set_current_model = (current_model: CharacterClassModel): void => { diff --git a/version.txt b/version.txt index 425151f3..d81cc071 100644 --- a/version.txt +++ b/version.txt @@ -1 +1 @@ -40 +42