Git Product home page Git Product logo

phy's People

Contributors

lo-th avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

phy's Issues

(physx worker bug) - Contacts involving a vehicle are not detected

(physx) Adding a contact between a vehicle and a body is never triggered.

However, the worker does detect the contact - it only doesn't find the name of the object so it doesnt call the callback.

Screenshot 2024-05-14 at 20 58 16
In the supplied screenshot - when the worker receives the "addVehicle" - it just lacks:

case "vehicle":
     C.set(A.vehicleActor.ptr, A.name);

then later on, Q is found correctly as the vehicle and the callback reaches phy.

Screenshot 2024-05-14 at 21 01 29

Donation

Hey,

I love your work on phy and would like to donate 50eur, but I am not comfortable to share my private address (which is required by paypal).

Don't you have github sponsors?

Thanks

Yannick

A Question about Breakables

Hi there!

Been playing a little trying to understand how breakables work and have some questions about the intended use case.

I saw that when breaking the object by slicing its geometry (which sits as a children[0] of the Basic3D container) - then discards the parent Basic3D object and sets the children as the parent.

This has a nuber of implications, as the children is not a Basic3D:

1 - object will be at 0,0,0 - ish (as the children pos & quat are the decal - and the real worldpos & quat were in the discarded quats
2 - collisions are then (broken/unstable) - what happens with the collision shape, volume, etc... ?
3 - several places where this body is indexed will rty to call stuff from the basic3d object causing crashes
4 - also - in the case of instances it will fail right away because there is no mesh as chilren of the (fake) instance Basic3d.

Soooo --- As the functionality looks really cool - i wonder how it should be used ? ?

thanks in advance !!!

Hero over kinematic - and question about jump!

Hello !

So i have been fiddling with Hero so he can now board platforms and move alongside them -- the development was nearly finished I just added a couple things here and there. Do you think it is a good solution ?

https://gist.github.com/nebular/81025fdb25ed6cc7b563437948ad3989
https://www.youtube.com/watch?v=8hva2y7IyWo

also im trying to fix the jump and always come up with everything screwed up! Why is it so difficult to add the impulse vertical :( can you share some advice about that ?

thanx in advance!

API Documentation please

Please provide some reference to any API documentation
Like how to play pause animation and physics
get/set the mas velocity on runtime and other available properties of bodies
enable disable physics in runtime
change materials in runtime

thanks for reading...

How to use

Can you please provide a sample implementation

MuJoCo engine support

DeepMind bought the company behind MuJoCo a while ago and open sourced it. It's a very robust engine with a huge ecosystem around it. It's a general-purpose engine, but it's particularly well-suited to bringing embodied agents that are trained via reinforcement learning into games, since most software for training RL agents uses MuJoCo as the physics engine. The idea is that you train with Python, and then you can deploy on the web with no "domain gap" problem.

Despite being more robust / 'scientifically accurate' than game-oriented physics engines, it is still fast/efficient. Here's an existing wasm port:

I'm not sure how hard this would be to add to Phy, but if it's feasible then that would be very exciting!

Some more links to check out:

Jolt soft body support

Since Jolt now has soft body support, it'd be neat if Phy had support too:

There are some caveats to the current implementation though - e.g. soft bodies can only collide with rigid bodies (not other soft bodies, and I'm guessing soft body self-collision is not supported either, but just a guess).

Maybe with all the caveats listed in the linked comment it is too early to add to Phy, but I guess it might be handy to have this tracking issue for it anyway.

Cannot build

If I run npm run build I get [!] Error: Could not resolve './_physx/engine.js' from src/Physx.js because the /src/_physx directory is not in the repo. Is there a way to get that code? Thanks.

relative paths for phy init not respected.

I ran into this problem when trying to deploy to github pages, which puts everything in a subdirectory with the name of your project ie:

https://ubernaut.github.io/simple-template/

you should be able to pass in a relative path (like './') so compact would be resolved at:

https://ubernaut.github.io/simple-template/compact

instead, it will insist on trying to find it here:

https://ubernaut.github.io/compact/

this doesn't work, phy will fail to find the physics hex files in compact if they aren't at the root of your url's path:

phy.init({
    type: "physx",
    worker: true,
    compact: true,
    scene: scene,
    renderer: renderer,
    callback: physicsReady,
    path: './'
    
  });

workaround:
You can pass in an explicit path and it does correctly prefix the dependencies so set an env variable in your package script for the path you want to use. like this (start is for local dev where it can run at root, and build is for gh pages):


  "scripts": {
    "test": "",
    "start": "export stpath='./'; parcel --https index.html",
    "build": "export stpath='/simple-template/'; parcel build index.html --public-url /simple-template/"
  },

then reference the variable in the init

  phy.init({
    type: "physx",
    worker: true,
    compact: true,
    scene: scene,
    renderer: renderer,
    callback: physicsReady,
    path: process.env.stpath
  });

Kinematic object in Physx not effecting a block sitting on top

let mP
onComplete = () => {
    mP = phy.add({ name:'movingPlatform', type:'box', pos:[0,0,0], size:[10,1,10], restitution:0, friction:0.5, kinematic:true})
    phy.add({type: 'box', material:'chrome', size: [1,1,1], pos: [0, 1.1, 0] })
}

update = () => {
    phy.change( { name:mP.name, pos:[mP.position.x, mP.position.y, mP.position.z+0.1], wake:true } )
}

box1 isn't effected by the movement of the platform underneath it when using Physx.

Problems with InstancedMesh after phy.remove

Create some objects that make use of InstancedMesh

        let test = []
        for(let i=0; i < 100; i++) { 
            test.push(phy.add( { type: 'cylinder', size:[1,1], instance:'someObj', mesh:aMesh, pos:[0,i,0]} ))
        }

Then remove some.

        setTimeout( () => {
            for(let i=0; i < 100; i+=2) { 
                phy.remove(test[i].name)
            }            
        }, 2000)

The mesh of the removed objects remains in view.

I've also seen an issue where the remaining instances then flicker in and out of view.

(Motor Bug) Joints cannot be removed if not on DEBUG mode

So if you add a joint with "debug" turned off

  • no jointdebug is created in thre world
  • joint is added to the physics motor (root.post...)

When removing this joint, phy.remove(joint.name) --- the routine in Motor will do nothing, as phy.byName() returns null - however the joint is kept alive in the worker.

This causes many nasty bugs - for example

  • if you remove any object part of the joint, the worker (physx at least) will later crash on stepItems (when attempting to call getGlobalPose() on the existing joints, but their objects do not exist.

  • if joints belong to instancemeshes and instances are removed, joints are kept alive and sometimes point to the wrong instance, resulting in funny joints between incorrect objects in the scene

After that crash, worker must be restarted.

My temp fix:

	// RLP: SEND ALWAYS TO MOTOR to remove non-exising joints
	static remove(name, direct = false, physicsType = "joint") {

		if (name.constructor === Array) return Motor.removes(name, direct);

		let b = Motor.byName(name);

		if (b) {

			// remove on three side

			if (b.extraRemove) b.extraRemove();
			ITEM_LIBRARY[b.type].clear(b);

		}

		const objectType = b ? b.type : physicsType;

		// remove on physics side
		if (objectType) root.post({ m: "remove", o: { name: name, type: objectType } }, null, direct);

	}

So when removing joints, I call remove(jointName, false, "joint") - or remove(jointName, false) as physicsType is set to joint. It's not the most elegant but it works well.

softBody

hello,
Do you plan to add the softBody demos?
just like virtual clothes

a terrain request

First of all, thats a really really great project.

I'd like to ask if you could provide the code for Havok terrain?

I would be incredibly grateful.

How to load custom glb model using phy engine?

I am making a web app using ThreeJS and React
It's very similar with the museum example of phy
I implemented almost of functionalities using Phy
However I encountered in issue to load custom museum model

phy.load(
'dices.glb',
onComplete
)

phy.load(
['dices.glb', 'yo.jpg'],
onComplete
)

This code are wrotten at the Phy engine guide
https://lo-th.github.io/phy/docs/index.html#manual/phy-load

But this code doesn't works in my project

I will share my main code:

const loadModels = () => {
	const models = ["./assets/models/musee.glb"];

	phy.load([...models], onCompleteLoadModels);
};

const onCompleteLoadModels = () => {}

This code occured errors at the crhome console like the following:

 index.tsx:86 SyntaxError: Unexpected token '<', "<!doctype "... is not valid JSON
at JSON.parse (<anonymous>)
at GLTFLoader.parse (Phy.module.js:17994:17)
at Object.onLoad (Phy.module.js:17889:11)
at three.module.js:44245:38

If I remove the above code, all works well
In one word, if I use simple model like box, the project works well
But if I gonna load new model, it occur error

It's a urgent project, so I would be happy anyone let me know how to overcome this issue

Best regards

Custom build of Bullet 3?

The lib uses a custom build directly from Bullet 3.1.7 last version?

Could you share the build script and code adaptations needed?

Awesome lib and demo visuals btw!

Question: does this engine support convex hulls, or full mesh collisions?

I was hoping to make a chain (out of hundreds of linked torus shaped objects), but that isn't a convex hull. Does this project support full mesh-based collisions? It looks like it does with the gear demo, but that may have been some creative modelling of multiple convex shapes glued together.

Thanks! This project looks amazing!

Missing Havok source `'./_havok/engine.js'`

Hi @lo-th ! Thank you for your awesome repo. I'm exploring it and was wondering where the Havok source is?

Inside src/Havok.js, there's:

export { engine } from './_havok/engine.js';

But './_havok/engine.js' doesn't exist, so I'm confused how Havok is an available option according to the Docs

add gdb model

Could you add a simple example to how to add a gdb model to the scene ?

Headless option

Hello, your work is amazing. But I was wondering how to use it for example on the server, is it very linked with ThreeJS, maybe have a headless option? So we can use it both on the client and on the server.

Ragdoll demo: Limbs fall off when using Havok

Cool project! Just tried out the demo and noticed that the ragdolls fall apart when using the Havok engine.

(Also, random question: Are soft bodies supported with Havok or PhysX?)

phy.add contact callback is called for all contacts when using Havok

phy.add({ type:'contact', b1:obj1.name, b2:'obj2.name, callback: someCallback })

In Havok someCallback is called for all collisions involving obj1, not just those involving obj2 but arg.hit is always false.

Phsyx works as expected

Rapier, seems to always have arg.hit == true

Also, including all details of the contact in the collision callback argument is probably needed in most real world uses - body1, body2, position, velocity etc

Vehicles Over Kinematic Platforms lose traction

Hi there Lo.th!

I will send a separate message detailing how much I love you and what an endless collection of awesomeness this repository is. Im learning so much.

I only use PHYSX engine (that has the native vehicle) - so maybe the bug does not apply to other ones.

There is something with the vehicle wheels that make them sink in kinematic platforms and lose traction. I have compiled a short video showing the issue, shall you find the time to take a look and share some advice.

https://www.youtube.com/watch?v=RubbU1yXCKc

Thanks for your awesome work.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.