buildar / awe.js

The jQuery for the Augmented Web
515 stars 113 forks source link

awe.projections.delete doesn't work #10

Closed dortizesquivel closed 7 years ago

dortizesquivel commented 9 years ago

Hi guys, thanks for sharing this library it is awesome. I have been working in a little POC and I found I can not remove a projection once it is added to a POI. So basically the steps to replicate this issue are:

1 - Create a point of interest like this:

awe.pois.add({
   id: 'marker',
   position: {x: 0, y: 0, z: 10000},
   visible: false
});

2 - Add a projection

awe.projections.add({
   id: 'top_label',
   geometry: {shape: 'text', text: "Hi Chicken", parameters: {
      size: 20,
      height: 8,
      curveSegments: 2,
      font: "helvetiker"
   }},
   rotation: {x:180, y: 0, z:0},
   position: {x: -40, y: 0, z: 0},
   material: {
      type: 'phong',
      color: 0xEBE41A
   }
}, {poi_id: 'marker'});

3 - Then once the scene is rendered in a timeout I try to remove the projection

setInterval( function(){
   awe.projections.delete({id: 'top_label'}, {poi_id: 'marker'});
   // awe.scene_needs_rendering = 1;
}, 10000);

I can see how the projection object has been removed from the awe.projections collection, but when the scene is rendered again it still contains the projection.

robman commented 9 years ago

Hi @dortizesquivel - yes there's an issue with the remove() call. Until this is fixed we'd recommend using visibility to just hide any projections you want gone.

awe.projections.update({ data:{ visible:true }, where: { id:"top_label" } })

Also note that you don't need the second object parameter for the delete function (when it's fixed).

dortizesquivel commented 9 years ago

Hi Robman, thank you very much, I will give a try to the visibility.

The reason why I wanted to remove the projection is because I didn't manage to update the projection's text. In my POC I'm polling an HTTP service which return a simple string every 5 seconds. I would like to show this string in my projection. I'm using a geometry with the shape 'text', I managed to update its position, material etc but not the actual text. By any chance do you know if it is possible to update the text?

robman commented 9 years ago

You'll need to make your text projection visible:false and then add a new one. Then do the same again when really new text is returned from your http service. This will end up creating a lot of invisible projections - but it should be able to handle 10's or even hundreds of these before you notice any performance issues. This is just a temporary work around until the delete() function is restored. Also see the notes about visibility in https://github.com/buildar/awe.js/issues/8#issuecomment-123255086 - if you call delete() and it fails silently, then it seems the visible:false updates will fail on some objects.

robman commented 7 years ago

Hi @dortizesquivel please checkout our updated repos at https://github.com/awe-media/awe.js which had a major refactor including how this is handled. Checkout the docs in the wiki and please raise an issue there if you find anything that doesn't work.