Comments (3)
lib will soon has some APIs to provide raw geometry data as lines. so that you can draw these lines in your rendering engine to visualize easily.
the data from THREE usually wont match with the physics mesh because usually physic mesh will be much simpler then the actually game world geometry. so, better draw physics world with the data from physics world but not from your THREE world.
from rapier.js.
i think it should work as long as the THREE model is in the world space, because the TriMesh is in world space, besides, you probably have to consider for the unit conversion between them, TriMesh: meter, THREE: vector.
you can try to visualize it. 👍
from rapier.js.
Not sure if this would be a right place to ask, if RAPIER.ColliderDesc.trimesh(vertices, indices)
is fully implemented or this is still on the roadmap? I tried load a simple model 3D of the cube:
import('@dimforge/rapier3d').then(rapierModule => {
setupScene()
RAPIER = rapierModule;
console.log("initRapier()");
let gravity = { x: 0.0, y: -2.1, z: 0.0 };
let world = new RAPIER.World(gravity);
const eventQueue = new RAPIER.EventQueue(true);
// Load the 3D model using Three.js's GLTFLoader
const loader = new GLTFLoader();
loader.load('models/floor1.glb', function (gltf) {
scene.add(gltf.scene)
const model = gltf.scene.children[0].geometry;
// Ensure vertices and indices are correctly defined and formatted
const vertices = new Float32Array(model.attributes.position.array);
let indices;
if (model.index) {
indices = new Uint32Array(model.index.array);
} else {
// Handle unindexed geometry by generating indices
indices = new Uint32Array([...Array(vertices.length / 3).keys()]);
}
console.log('Vertices:', vertices);
console.log('Indices:', indices);
try {
const trimesh = new RAPIER.TriMesh(vertices, indices);
console.log('TriMesh created successfully', trimesh);
const isValid = validateMapping(trimesh.vertices, trimesh.indices);
console.log("isValid",isValid)
console.log('Vertices length:', vertices.length);
console.log('Indices length:', indices.length);
let groundColliderDesc = RAPIER.ColliderDesc.trimesh(trimesh)
// // .setTranslation(0, groundHeight, 0)
// // .setActiveEvents(RAPIER.ActiveEvents.COLLISION_EVENTS);
let groundCollider = world.createCollider(groundColliderDesc);
init()
window.groundColliderHandle = groundCollider.handle;
window.myRapierWorld = world;
window.eventQueue = eventQueue;
} catch (error) {
console.error('Failed to create TriMesh:', error);
}
});
});
Any clue?
from rapier.js.
Related Issues (20)
- Contact force behaviour changes upgrading from 0.11.2 to 0.12.0 HOT 3
- RangeError when creating colliders HOT 2
- Expose `user_force` for RigidBody2D
- World.debugRender returning extra lines HOT 1
- Runtime Error: unreachable on long running window HOT 2
- Changing RigidBody bodyType before any collisions makes rigidBody static HOT 2
- RuntimeError: unreachable when using RAPIER.JointData.spring HOT 1
- Large filesize (1MB of raw WASM) HOT 3
- RigidBody/Joint/etc. Cloning
- Set Frame for Revolute/Prismatic Joints
- TriMesh should have better documentation. Example included. HOT 1
- Built app WASM issue after upgrading to 0.13.1 HOT 9
- KinematicCharacterController.setMaxSlopeClimbAngle is not working HOT 4
- Issues with sensors HOT 2
- Add missing bindings to the JS bindings.
- `RigidBody.lockRotation` and `RigidBody.lockTranslation` do not unlock when sent `false` on its `locked` argument HOT 2
- Unstable core features HOT 3
- Tunneling problem with CCD enabled bodies HOT 2
- Unable to configure stiffness or damping for spherical joints
- Adding ±90 Degree Rotation Limits to JointData.spherical HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from rapier.js.