Try it like so: https://jsfiddle.net/kjLy6eso/
You compute the bounding box for the plane geometry first. You then copy this AABB to the helper and apply the matrix transformation per animation step.
Try it like so: https://jsfiddle.net/kjLy6eso/
You compute the bounding box for the plane geometry first. You then copy this AABB to the helper and apply the matrix transformation per animation step.
It turns out to be like this !! what a hidden mystery!Why not wirte it in the document. In addition, Now my box3 can follow the plane ,but I got warning like this three.js:3484 THREE.Matrix3: .getInverse() canât invert matrix, determinant is 0. I think it caused by the plane bounding box 's z dimension . If I want to eliminate this warning , I must manually set min=-1 adn max=1 at each update. It seems a little awkward that add an instruction only to eliminate a warning.
Instead of using a PlaneGeometry
use a BoxGeometry
like this:
var geometry = new THREE.BoxBufferGeometry(20, 20, 0.1);
Ok , Thatâs it . what about detecting collision to objects in motion. I keep thinking these days and draw a solution base on the previous solution .
I test it . for now itâs no problem yet. I hope the mothod correct
TBH, I donât understand your drawing. But the video looks good
Hi!
As youâre using THREE.Box3()
, maybe itâs better to use its .containsPoint()
method. For checking, if a bullet (as itâs just a small point) touched or already inside the bounding box.
Should be simplier than raycasting.
This test is not robust since you only detect a hit if the bullet is within the bounding box at exact that moment. But a bullet travels through 3D space and you have to check if there was a hit during the entire frame. If you are not using a ray, bullets can âpass throughâ objects.
Yes, I totally agree.
But it seems enough for such type of game
I donât know how slow shoud be a PC to be unable to perform that operation frequent enough
thank you for respond. .containsPoint()
mehod are good complement to the algorithm. I shall keep my testing .
Hello, after nearly a week of fiddling and testing. I get an accurate result.
https://jsfiddle.net/relaxslow/eqLp7znr/
just click and fire
Instead use box3, I use custom line . The line can even not closed ,since I test each of the line segment.
This algorithm support rotate and scale thus add flexibility to my game.
thanks again!
Oh, by the way . because the tween.js on cdn has error , I turn to use gsap tweenmax.
Could you tell about the error youâve bumped into?
I use this: https://cdnjs.com/libraries/tween.js/
I copy from other fiddle-- https://cdnjs.cloudflare.com/ajax/libs/tween.js/16.3.5/Tween.min.js, It cause error result that when I stop one tween it also stop another tween .I test it 2 days and exclude all the possiblity in my program. When I change to local tween.js , the result is all correct.
Since you provide a new version of tween.js . I shall test it again.