Skip to content

Commit d1c3681

Browse files
committed
Bedrock attachable fixes
1 parent 855c4ee commit d1c3681

File tree

4 files changed

+19
-6
lines changed

4 files changed

+19
-6
lines changed

js/formats/bedrock/bedrock.js

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -821,9 +821,13 @@ window.calculateVisibleBox = calculateVisibleBox;
821821

822822
codec.dispatchEvent('parse', {model: data.object});
823823

824-
Project.geometry_name = geometry_name;
825-
Project.texture_width = 16;
826-
Project.texture_height = 16;
824+
if (!args.import_to_current_project) {
825+
Project.model_identifier = geometry_name;
826+
Project.texture_width = 16;
827+
Project.texture_height = 16;
828+
} else if (args.collection) {
829+
args.collection.model_identifier = geometry_name;
830+
}
827831

828832
if (typeof description.visible_bounds_width == 'number' && typeof description.visible_bounds_height == 'number') {
829833
Project.visible_box[0] = Math.max(Project.visible_box[0], description.visible_bounds_width || 0);

js/formats/bedrock/bedrock_multi_file.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -248,7 +248,8 @@ BARS.defineActions(function() {
248248
name: project_parsed.name || 'Attachable',
249249
scope: 2,
250250
export_codec: 'bedrock',
251-
export_path: attachable_path
251+
export_path: attachable_path,
252+
model_identifier: project_parsed.model_identifier,
252253
}).add();
253254
for (let animation of Animation.all) {
254255
animation.setScopeFromAnimators();
@@ -288,7 +289,7 @@ BARS.defineActions(function() {
288289
export_codec: 'bedrock',
289290
export_path: file.path,
290291
}).add();
291-
Codecs.bedrock.load(json, file, {import_to_current_project: true});
292+
Codecs.bedrock.load(json, file, {import_to_current_project: true, collection});
292293
let content = finder.find();
293294
let scope = finder.findEmptyScope();
294295
content.nodes.forEach(node => node.scope = scope);

js/outliner/collections.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ export interface CollectionOptions {
2727
name?: string
2828
export_codec?: string
2929
export_path?: string
30+
model_identifier?: string
3031
visibility?: boolean
3132
scope?: number
3233
}
@@ -381,6 +382,7 @@ export class Collection {
381382

382383
this.extend(form_data);
383384
this.children.replace(vue_data.content.map(node => node.uuid));
385+
this.saved = false;
384386

385387
Blockbench.dispatchEvent('edit_collection_properties', {collection: this})
386388

js/outliner/types/group.js

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -651,7 +651,13 @@ new NodePreviewController(Group, {
651651

652652
if (target_group) {
653653
bone.position.set(group.origin[0], group.origin[1], group.origin[2])
654-
if (group.parent == Outliner.ROOT) bone.position.y -= 24;
654+
if (group.parent instanceof Group) {
655+
bone.position.x -= group.parent.origin[0];
656+
bone.position.y -= group.parent.origin[1];
657+
bone.position.z -= group.parent.origin[2];
658+
} else {
659+
bone.position.y -= 24;
660+
}
655661
target_group.mesh.add(bone);
656662
bone.updateMatrixWorld();
657663
}

0 commit comments

Comments
 (0)