Thx for the help, @RaananW . Yep, we had to wait for the heightMap to finish loading, then do:
sphere.physicsImpostor.registerOnPhysicsCollide(ground.physicsImpostor, myCollide); in line 44… during the heightMap load call-back. Right? Yeah.
Holger and others… notice how using that ‘register’ thing… requires that we tell exactly WHICH mesh collides with WHICH mesh? We needed to give it TWO specific mesh, and intersectsMesh is also that way… you’re not allowed to check THIS mesh colliding-with ANY OTHER mesh. ActionManager’s onIntersectEnterTrigger ALSO requires you to specify a specific target.
Well, for physics, there is a top secret and dangerous way to monitor for ground mesh… colliding with ANY other physics-active mesh (p-mesh). I think it is similar to the old onCollide() that doesn’t seem to work anymore.
First, I set angular and linear damping on sphere, to make it stop rolling quickly.
10 seconds later, I add mass to the 0-mass box… which makes it shoot slightly towards camera… due to a still-unfixed anomaly in Cannon plugin setParam(). Don’t sweat it. Main thing… it starts dropping after a 10-sec delay.
The box colliding wth ground… ALSO changes the color of sphere! Cool, huh? ANY physics mesh… colliding with ground… runs your myCollide function. How?
Look at line 65 (which is where Raanan’s line 44 was located in PG #6).
You guys (using the register way) stayed-at BJS mesh.physicsImpostor level… a BJS object… and you didn’t need to go deeper into native areas.
Line 65 reaches deeper… to mesh.physicsImpostor.physicsBody level (a Cannon object)… and it calls an underscored property (for internal use only?)… and… well… it’s just a deep dive into Cannon native lands… to push your myCollide function into an array of collide-listeners.
And when I did this, I was able to accomplish a ground-collides-with-ANY-physics-mesh event trigger… not needing TWO specific collide objects. Only one… ground.
Notice the object called test that arrives in the first parameter of myCollide? It has some "stuff’ on it. I tried to query that ‘test’ object to see if I could get the name of the mesh that just collided with ground (‘box’). I couldn’t find it on the ‘test’ object, but I didn’t look real carefully.
Ok, I just wanted to show you that. Rannan didn’t mention that intersectsMesh and actionManager onIntersectEnterTrigger (and ‘register’ method)… require TWO specific mesh to check for collisions… which sucks, under certain circumstances.
I have been trying to nudge @Deltakosh into allowing actionManager onIntersectEnterTrigger the option to use ‘ANY’ as the target, but he hasn’t budged. Likely a technical or performance issue.
Ok, party on, guyz.