diff --git a/src/extensions/jwVector/index.js b/src/extensions/jwVector/index.js index 07fa83e3085..086d3812c5f 100644 --- a/src/extensions/jwVector/index.js +++ b/src/extensions/jwVector/index.js @@ -287,6 +287,7 @@ class Extension { { opcode: 'round', text: '[ROUNDING] of [VECTOR]', + hideFromPalette: true, arguments: { ROUNDING: { menu: 'roundingFunctions', @@ -295,6 +296,17 @@ class Extension { }, ...Vector.Block }, + { + opcode: 'roundNew', + text: '[ROUNDING] of [VECTOR]', + arguments: { + ROUNDING: { + menu: 'roundingFunctionsAcceptReporters', + }, + VECTOR: Vector.Argument + }, + ...Vector.Block + }, "---", { opcode: 'getPos', @@ -355,6 +367,23 @@ class Extension { } ] }, + roundingFunctionsAcceptReporters: { // needs to be separate to not break old projects + acceptReporters: true, + items: [ + { + text: 'round', + value: 'round' + }, + { + text: 'ceil', + value: 'ceil' + }, + { + text: 'floor', + value: 'floor' + } + ] + }, } }; } @@ -461,9 +490,15 @@ class Extension { return new VectorType(Math.floor(v.x), Math.floor(v.y)) case 'ceil': return new VectorType(Math.ceil(v.x), Math.ceil(v.y)) + case 'round': + return new VectorType(Math.round(v.x), Math.round(v.y)) } - return new VectorType(Math.round(v.x), Math.round(v.y)) + return v + } + + roundNew(args) { + return this.round(args) } getPos({}, util) {