I have this proyect:
index.html (3.3 KB)
With this images in the same folder as the index.html file.






But I want when the ‘Mario’ check the collision with any bricks around the scene, it repels, like Super Mario 64. Its possible?
I have this proyect:
index.html (3.3 KB)
With this images in the same folder as the index.html file.
But I want when the ‘Mario’ check the collision with any bricks around the scene, it repels, like Super Mario 64. Its possible?
Check out mesh-bvh!
https://gkjohnson.github.io/three-mesh-bvh/example/bundle/characterMovement.html
How can i download this ‘mesh-bvh’ and test it?
Here’s what I’m doing for setup rn:
In your html:
<script type="importmap">
{
"imports": {
"three": "https://threejs.org/build/three.module.js",
"three/examples/": "https://threejs.org/examples/",
"three-mesh-bvh": "https://unpkg.com/three-mesh-bvh@0.7.3/build/index.module.js"
}
}</script>
<script type='module' src="./js/index.js"></script>
and then use the parts you need from this js:
for instance for generating the collision geometry I’m doing something like this:
import {MeshBVH,MeshBVHHelper,acceleratedRaycast,StaticGeometryGenerator } from 'three-mesh-bvh';
// nscene contains just the meshes I want to collide with:
const staticGenerator = new StaticGeometryGenerator( nscene );
staticGenerator.attributes = [ 'position' ];
const mergedGeometry = staticGenerator.generate();
mergedGeometry.boundsTree = new MeshBVH( mergedGeometry,{maxDepth:70});
scene.add( nscene );
I’m assuming you want a 3d solution.
Here’s the main github page for mesh-bvh which has a section on the different ways to import/use/download it:
but…
If you only need a 2d solution, you could maybe use a 2d game engine like pixijs or phaser.
I need a 3d solution, not 2d…
Cool. Then mesh-bvh is probably a good way to go!
It’s not my website. It’s the mesh-bvh website.
You’re trying to run a locally downloaded copy from your own machine, probably by double clicking the html. That isn’t really going to work since you need to actually “host” the files somehow.