Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

I tried to pick-up objects and it didn't work out. #366

Open
volcanoqq opened this issue Oct 7, 2023 · 4 comments
Open

I tried to pick-up objects and it didn't work out. #366

volcanoqq opened this issue Oct 7, 2023 · 4 comments

Comments

@volcanoqq
Copy link

normal.video.mp4

Like in the video, my manipulator tries to grasp the object, but visually they do not collide, why does the object bounce away.

@volcanoqq
Copy link
Author

`

  // Mechanical arm
  const left = editor.scene.getObjectByName("左抓手");
  const right = editor.scene.getObjectByName("右抓手");

  physicsManager.createRigidBodyByObject(left, {
    shape: "convex",
    collisionFlags: 2,
  });
  physicsManager.createRigidBodyByObject(right, {
    shape: "convex",
    collisionFlags: 2,
  });

  left.body.setFriction(1);
  right.body.setFriction(1);

  // Objects that need to be grabbed
  for (let i = 1; i <= 6; i++) {
    const obj = editor.scene.getObjectByName("电池" + i);
    physicsManager.createRigidBodyByObject(obj, {
      shape: "convex",
    });
  }

`

`

//PhysicsManager.js

import { AmmoPhysics } from "@enable3d/ammo-physics";
import * as THREE from "three";

export class PhysicsManager {
  constructor(editor) {
    this.editor = editor;
    this.physics = new AmmoPhysics(editor.scene);
    this.physics.debug.enable(true);
  }

  createRigidBodyByObject(object, options = {}) {
    this.physics.add.existing(object, options);
  }

  update(delta) {
    this.physics.update(delta * 1000);
    this.physics.updateDebugger();
  }
}

`

@yandeu
Copy link
Member

yandeu commented Oct 7, 2023

Have you looked at this example?
https://enable3d.io/examples/standalone/pick-up-objects.html

I highly recommend using a box shape for the bricks.
And a compound of box shapes for the crane.

Maybe you also want to change the fixedTimeStep in https://enable3d.io/docs.html#physics-configuration.

@volcanoqq
Copy link
Author

volcanoqq commented Oct 9, 2023

Yes, I've seen the example of pick-up objects, but my animation used tween.

If you use box shape to create, there will be an object rotation mismatch problem.

In this issue of mine at (https://github.com/enable3d/enable3d/issues/365)

What does fixedTimeStep do, and why do I need to change it?

@yandeu
Copy link
Member

yandeu commented Oct 11, 2023

What does fixedTimeStep do

See the bullet manual:
https://github.com/bulletphysics/bullet3/blob/master/docs/Bullet_User_Manual.pdf

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants