gkjohnson / three-bvh-csg

A flexible, memory compact, fast and dynamic CSG implementation on top of three-mesh-bvh
MIT License
602 stars 46 forks source link

buildFunctions line 770 countNodes sometimes has undefined property #94

Closed AsDeadAsADodo closed 1 year ago

AsDeadAsADodo commented 1 year ago

This is the error stack. Same two Brush es , sometimes it's ok , sometimes got this error.

buildFunctions.js:785 Uncaught TypeError: Cannot read properties of undefined (reading 'count')
    at countNodes (buildFunctions.js:785:13)
    at countNodes (buildFunctions.js:791:15)
    at buildPackedTree (buildFunctions.js:770:19)
    at new MeshBVH (MeshBVH.js:165:18)
    at Brush.prepareGeometry (Brush.js:68:26)
    at Evaluator.evaluate (Evaluator.js:137:5)
    at csg (animationTest.js:767:39)
    at animationTest.js:778:30
AsDeadAsADodo commented 1 year ago

The only difference between good and error is one of the brushes ' position is random. There's no other errors.

AsDeadAsADodo commented 1 year ago

图片

AsDeadAsADodo commented 1 year ago

When this shows up , console print error Normally it's 图片

AsDeadAsADodo commented 1 year ago

图片

node.count is 0 , however in else snippet , node.left and node.right are both undefined

gkjohnson commented 1 year ago

Please provide a repro case with jsfiddle or something comparable so this can be inspected.

AsDeadAsADodo commented 1 year ago

@gkjohnson Sorry for the delay , I tried to build a issue version , but we did lots of commits that day I cant reproduce this error.

I fixed this by reducing the random range , tested like 20+ times .

图片

I suppose this may help too ? No other errors and warnings .

gkjohnson commented 1 year ago

I fixed this by reducing the random range

Unfortunately I'm not sure what this means. Without a minimal reproduce-able example on something like jsfiddle this isn't possible to debug. The line you're pointing to is in the three-mesh-bvh project which is fairly well used and well tested. Without a minimal example it's hard to say whether the problem is in your codebase or not.