Skip to content
Draft
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 blocks/transform.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ export function defineTransformBlocks() {
if (!changeEventParentBlock) return;
const changeEventBlockType= changeEventParentBlock.type;
console.log("The type of this change event is", changeEventBlockType);
if (changeEventBlockType != "rotate_to") return;
if (!["rotate_to", "scale", "resize"].includes(changeEventBlockType)) return;
console.log(handleFieldOrChildChange(block, changeEvent));
}
Blockly.Blocks["move_by_xyz"] = {
Expand Down
38 changes: 36 additions & 2 deletions ui/blockmesh.js
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ export function deleteMeshFromBlock(blockId) {
}

export function getMeshFromBlock(block) {
if (block && block.type === "rotate_to") {
if (block && !["rotate_to", "scale", "resize"].includes(block.type)) {
block = block.getParent();
}

Expand Down Expand Up @@ -253,7 +253,9 @@ export function updateMeshFromBlock(mesh, block, changeEvent) {
"load_multi_object",
"load_character",
"create_map",
"rotate_to"
"rotate_to",
"scale",
"resize"
].includes(block.type)
) {
color = block
Expand Down Expand Up @@ -381,13 +383,23 @@ export function updateMeshFromBlock(mesh, block, changeEvent) {

// Retrieve the position values (X, Y, Z) from the connected blocks
let position;
let origin;

position = {
x: block.getInput("X").connection.targetBlock().getFieldValue("NUM"),
y: block.getInput("Y").connection.targetBlock().getFieldValue("NUM"),
z: block.getInput("Z").connection.targetBlock().getFieldValue("NUM"),
};

if (["scale", "resize"].includes(block.type)) {
origin = {
x: block.getInput("X").connection.targetBlock().getFieldValue("TEXT"),
y: block.getInput("Y").connection.targetBlock().getFieldValue("TEXT"),
z: block.getInput("Z").connection.targetBlock().getFieldValue("TEXT"),
};
console.log("origin");
}

let colors,
width,
height,
Expand Down Expand Up @@ -589,6 +601,28 @@ export function updateMeshFromBlock(mesh, block, changeEvent) {
});
break;

case "scale":
flock.scale(mesh.name, {
x: position.x,
y: position.y,
z: position.z,
xOrigin: origin.x,
yOrigin: origin.y,
zOrigin: origin.z,
});
break;

case "resize":
flock.resize(mesh.name, {
x: position.x,
y: position.y,
z: position.z,
xOrigin: origin.x,
yOrigin: origin.y,
zOrigin: origin.z,
});
break;

default:
flock.positionAt(mesh.name, {
x: position.x,
Expand Down