GithubHelp home page GithubHelp logo

Comments (8)

chandlerprall avatar chandlerprall commented on July 4, 2024

Scaling is the one feature of Three.js that I purposefully left out because it is a feature not supported by physics libraries. It would be impossible to update an object's scaling on the fly and a new collision body would need to be created every time the scale changes. This would be an expensive operation to do between frames if the user isn't planning for it, and I feel that cost is much more apparent if you are forced to create a whole new object if you change an object's size.

That said, I could use an object's scale at creation time for the physics body but I don't want to set up an expectation for the user that changing the scale later will have an effect. The only use case I can think of is if you are importing a custom geometry and want multiple sizes of it.

What are you trying to use scale to do?

from physijs.

 avatar commented on July 4, 2024

thats actually a really good reason for leaving it out. its not really a problem, but it would be nice if it was hinted at somewhere in the documentation - i just spent a couple hours in confusion because i scaled my ground x100 as a BoxMesh and objects kept falling through. a mistake on my part that hopefully no one else makes

from physijs.

chandlerprall avatar chandlerprall commented on July 4, 2024

I apologize for the confusion - I've added a page to the wiki to help address this.

from physijs.

tapio avatar tapio commented on July 4, 2024

That said, I could use an object's scale at creation time for the physics body but I don't want to set up an expectation for the user that changing the scale later will have an effect. The only use case I can think of is if you are importing a custom geometry and want multiple sizes of it.

@chandlerprall I have bumped into that exact use case: I'm loading a few different rock models and I want the size of each individual instance be randomized to give extra variance to the scene, but I also want to reuse the geometry.

As far as I know, THREE.Geometry doesn't have a scale property, so the scale would need to be another parameter to Physijs mesh constructor, but that way it should also be apparent that the scale is a construction time option.

from physijs.

chandlerprall avatar chandlerprall commented on July 4, 2024

'scale' property is now respected when adding a mesh to the scene.

from physijs.

tapio avatar tapio commented on July 4, 2024

Thanks!

from physijs.

lazd avatar lazd commented on July 4, 2024

It doesn't seem scaling works for Physijs.ConcaveMesh:

var groundMesh = new Physijs.ConcaveMesh(geometry, faceMaterial, 0);
groundMesh.scale.set(10, 10, 10);
scene.add(groundMesh);

The mesh appears and can be collided with, but it is considered to be it's default size by the physics engine. I had a look at 1afa96b, then added a breakpoint at line 784, and the ConcaveMesh doesn't seem to have object._physijs.width and friends. Setting those variables manually to 1 doesn't help either.

Thoughts?

from physijs.

chandlerprall avatar chandlerprall commented on July 4, 2024

@lazd mind creating a new issue for this? It's a simple fix but I'd like an active ticket so I don't lose track of it and forget.

from physijs.

Related Issues (20)

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.