@@ -48,7 +48,8 @@ abstract class BaseVoxelTool extends LayerTool<UserLayerWithVoxelEditing> {
4848 | Float32Array
4949 | undefined ;
5050 if ( ! mouseState ?. active || ! vox ) return undefined ;
51- const planeNormal = mouseState ?. planeNormal ;
51+ if ( ! mouseState . planeNormal ) return ;
52+ const planeNormal = editContext . transformGlobalToVoxelNormal ( mouseState . planeNormal ) ;
5253 if ( ! mouseState ?. active || ! vox || ! planeNormal ) return undefined ;
5354 const CHUNK_POSITION_EPSILON = 1e-3 ;
5455 const shiftedVox = new Float32Array ( 3 ) ;
@@ -288,10 +289,14 @@ export class VoxelBrushTool extends BaseVoxelTool {
288289 1 ,
289290 Math . floor ( this . layer . voxBrushRadius . value ?? 3 ) ,
290291 ) ;
292+ const editContext = this . getEditingContext ( ) ;
293+ if ( editContext === undefined ) {
294+ throw new Error ( "editContext is undefined" ) ;
295+ }
291296 const shapeEnum = this . layer . voxBrushShape . value ;
292297 let basis = undefined as undefined | { u : Float32Array ; v : Float32Array } ;
293298 if ( shapeEnum === BrushShape . DISK && this . currentMouseState ?. planeNormal ) {
294- const n = this . currentMouseState . planeNormal ;
299+ const n = editContext . transformGlobalToVoxelNormal ( this . currentMouseState . planeNormal ) ;
295300 const u = vec3 . create ( ) ;
296301 const tempVec =
297302 Math . abs ( vec3 . dot ( n , vec3 . fromValues ( 1 , 0 , 0 ) ) ) < 0.9
@@ -304,10 +309,7 @@ export class VoxelBrushTool extends BaseVoxelTool {
304309 basis = { u, v } ;
305310 }
306311
307- const editContext = this . getEditingContext ( ) ;
308- if ( editContext === undefined ) {
309- throw new Error ( "editContext is undefined" ) ;
310- }
312+
311313 for ( const p of points )
312314 editContext . controller ?. paintBrushWithShape (
313315 p ,
@@ -361,7 +363,8 @@ export class VoxelFloodFillTool extends BaseVoxelTool {
361363 return ;
362364 }
363365 const seed = this . getPoint ( this . mouseState ) ;
364- const planeNormal = this . mouseState . planeNormal ;
366+ if ( ! this . mouseState . planeNormal ) return ;
367+ const planeNormal = editContext . transformGlobalToVoxelNormal ( this . mouseState . planeNormal ) ;
365368 if ( ! seed || ! planeNormal ) return ;
366369 try {
367370 const value = this . layer . getVoxelPaintValue (
0 commit comments