vizicities icon indicating copy to clipboard operation
vizicities copied to clipboard

How to move from city to city?

Open hipsterpercaso opened this issue 10 years ago • 5 comments

What's the best option in 0.2.0 branch for move from one city to another changing the world origin? i tried world.project(new VIZI.LatLon(51.496006, 0.2)); but it has no effect.

hipsterpercaso avatar Feb 21 '15 16:02 hipsterpercaso

This is sorely lacking from the core platform right now and I plan to implement a proper method of moving around in a future update. In the meantime, this is a quick hack that I've been using to do something similar:

var coords = new VIZI.LatLon(…);
var projected = world.project(coords);
var scale = controls.getZoom();

controls.controls.target.x = projected.x;
controls.controls.target.z = projected.y;

controls.controls.update();

controls.zoomTo(scale);

This will move the camera to a new location, though it does screw the camera angle up slightly. This also doesn't change the world origin which can lead to accuracy errors should you be moving a long way away.

Let me know if you come up with anything better!

Edit: You might also be interested in how Brian Chirls moves his customised ViziCities: https://github.com/povdocs/webvr-cities/blob/master/js/main.js#L663

robhawkes avatar Feb 24 '15 14:02 robhawkes

Also, if you move the world instead of moving the camera, you can avoid the accuracy errors...I think.

brianchirls avatar Feb 24 '15 14:02 brianchirls

I believe so, I've tried your code and i'm receiving lot of errors from the workers

// Convert exported geom into a typed array
var verticesArray = new Float64Array( exportedGeom.data.vertices );
var normalsArray = new Float64Array( exportedGeom.data.normals );
// var colorsArray = new Float64Array( exportedGeom.colors );
// Seems to be manually set to have 1 array in the uvs array
//

https://github.com/mrdoob/three.js/blob/master/examples/js/exporters/GeometryExporter.js#L231

----> var uvsArray = new Float64Array( exportedGeom.data.uvs[0] ); Uncaught TypeError: Cannot read property '0' of undefined

The only solution came in mind is (cool effect like fadeout) - delete the html node #vizicities-viewport - delete VIZI object, inject again the #vizicities-viewport, reinstantiate vizi with new coordinates, (cool effect fadein).

:D

2015-02-24 15:21 GMT+01:00 Brian Chirls [email protected]:

Also, if you move the world instead of moving the camera, you can avoid the accuracy errors...I think.

— Reply to this email directly or view it on GitHub https://github.com/vizicities/vizicities/issues/134#issuecomment-75764192 .

hipsterpercaso avatar Feb 24 '15 14:02 hipsterpercaso

The only solution came in mind is (cool effect like fadeout) - delete the html node #vizicities-viewport - delete VIZI object, inject again the #vizicities-viewport, reinstantiate vizi with new coordinates, (cool effect fadein).

Also, better to deallocate some threejs stuff world.scene.scene.traverse(function(mesh) { if (object instanceof THREE.Mesh) { scene.remove( mesh ); } })

world.scene.scene.geometry.dispose(); world.scene.scene.material.dispose(); world.scene.scene.texture.dispose(); for preventing threejs memory leaks. What do you think, Robin?

@brianchirls move the world was my first attempt, but it doesn't seems to move :/

hipsterpercaso avatar Feb 24 '15 14:02 hipsterpercaso

#144 fixes the controls.moveTo(point) and controls.moveBy(delta) methods so you can successfully move around, though this doesn't change the world.origin yet, nor remove existing objects from the world.

I've got a high-priority TODO for adding some kind of world.reset(latlon) or world.moveToLatLon(latlon) for basically starting from scratch. In the meantime, there isn't much you can do if you want a full reset as the Blueprint modules will still exist (I also need to implement some method of removing them).

I'll update again when I have something productive for you.

robhawkes avatar Mar 11 '15 20:03 robhawkes