Mugen87/dive

skeletons are not synced right when the scene moves

Closed this issue · 5 comments

Hi @Mugen87, thanks for your help, I've made the VR controls working.

I found that when the scene was moved, everything including the meshes was synced correctly except the skeletons. Since the hitboxes were bound with the skeletons, they didn't follow the game entities position under this situation.

https://raw.githack.com/Mugen87/dive/master/app/index.html It can be seen by turning on the skeletonHelpers and using I, J, K, L keys to move the scene. You can see the skeletons get double position changes from the scene position.

and using I, J, K, L keys to move the scene.

I'm afraid I don't understand. These keys actually do nothing. And even if I use the arrow keys to modify the target of THREE.OrbitControls, the helpers are rendered correctly.

Sorry, the link should be from my fork https://raw.githack.com/shenzhuxi/dive/master/app/index.html.
I added this piece of code to change this.scene.position in World.js.

        document.addEventListener( 'keydown', (event) => {
                switch ( event.keyCode ) {

                    case 73: // up I
                        this.scene.position.y++;
                        break;

                    case 74: // left J
                        this.scene.position.x++;
                        break;

                    case 75: // down K
                        this.scene.position.y--;
                        break;

                    case 76: // right L
                        this.scene.position.x--;
                        break;
                }
        }, false );

Okay, after investigating your code, I actually realized that transforming the scene has massive implications on the app. Simply because Yuka maps it's own coordinate spaces to renderable components (three.js entities). If you transform the scene, you basically break this mapping. Hence, I really not recommend doing this. And it's not something that is going to be fixed.

Thanks @Mugen87!
I will just give the camera a parent in three.js instead of moving the whole world and made it playable now somehow.

BTW, in scenarios like an earthquake or boat (game entities need to navigate on a moving platform) what's the best practice in Yuka?

The earth or the moving platform would be game entities itself. You just animate them.