Closed magiraldooc closed 7 years ago
Hi @magiraldooc - glad you're finding awe.js easy to use 8)
This should be working fine - if you look at line 1242 of awe-standard.js (https://github.com/buildar/awe.js/blob/master/js/awe-standard.js#L1242) you can see we set the object's visible to the boolean you provided - plus we walk all the children and set their visible to the same value.
Your code does look correct - so if there's some structure that's not being covered then we can extend this to make it work. If you could send a dump of the basic structure of the pois that aren't being set to visible:false that might give us a clue.
If you added a console.log(JSON.stringify(mesh)) and/or console.log(JSON.stringify(mesh.children)) inside the if block at line 1242 on awe-standard.js that should give you the output we need.
Thanks.
Hi @robman
I tried to add console.log(JSON.stringify(mesh)) and/or console.log(JSON.stringify(mesh.children)) on awe-standard.js, but the console shows the following error:
Uncaught TypeError: Converting circular structure to JSON (11:38:49:612 | error, javascript) at _update_mesh_io (libs/js/awe-standard.js:1248:50) at this_awe.constructor.pois.update (libs/js/awe-standard.js:453:11) at awe.events.add.handler (index.html:221:58) at awe.events.add.handler (awe.marker_ar.js:186:16) at (anonymous function) (libs/js/awe-standard.js:1616:13)
This is my JS function:
function loadAr(){ window.awe.init({ device_type: awe.AUTO_DETECT_DEVICE_TYPE, settings: { container_id: 'container', default_camera_position: { x: 0, y: 0, z: 0 }, default_lights: [{ id: 'point_ligth', type: 'point', color: 0xFFFFFF, }], }, ready: function(){ awe.util.require([ { capabilities: ['gum','webgl'], files: [ ['libs/js/awe-standard-dependencies.js', 'libs/js/awe-standard.js'], 'awe-jsartoolkit-dependencies.js', 'awe.marker_ar.js', ], success: function(){ awe.setup_scene(); awe.pois.add({ id: 'poi_1', position: { x: 0, y: 0, z: 10000 }, visible: false }); awe.projections.add({ id: 'projection_1', geometry: { path: 'resources/Lander.obj', x: 120, y: 120, z: 120 }, scale: { x: 10, y: 10, z: 10 }, position: { x: 150, y: 150, z: 50, }, material: { type: 'phong', color: 0xFFFFFF }, texture: { path: 'resources/Lander_D.png' }, }, { poi_id: 'poi_1' }); awe.projections.add({ id: 'projection_2', geometry: { path: 'resources/Astronaut.obj', x: 120, y: 120, z: 120 }, scale: { x: 10, y: 10, z: 10 }, position: { x: 50, y: 50, z: 50, }, material: { type: 'phong', color: 0xFFFFFF }, texture: { path: 'resources/Spacesuit_D.png' }, }, { poi_id: 'poi_1' }); awe.projections.add({ id: 'projection_3', geometry: { shape: 'image', x: 500, y: 500, z: 1 }, scale: { x: 100, y: 1, z: 100 }, position: { x: 50, y: 0, z: 50, }, material: { type: 'phong', color: 0xFFFFFF }, texture: { path: 'resources/SuperficieLunar.jpg' }, }, { poi_id: 'poi_1' }); awe.projections.list(); awe.events.add([ { id: 'ar_tracking_marker1', device_types: { pc: 1, android: 1 }, register: function(handler){ window.addEventListener('ar_tracking_marker', handler, false); }, unregister: function(handler){ window.removeEventListener('ar_tracking_marker', handler, false); }, handler: function(event){ if(event.detail){ if(event.detail['63']){ awe.pois.update({ data: { visible: true, matrix: event.detail['63'].transform }, where: { id: 'poi_1' } }); }else{ awe.pois.update({ data: { visible: false }, where: { id: 'poi_1' } }); } awe.scene_needs_rendering = 1; } } } ]); } }, { capabilities: [], success: function(){ document.body.innerHTML = '
Try this demo in the latest version of Chrome or Firefox on a PC or Android device
'; } } ]); } }); }Thanks for your help and attention
Thanks guys for the response on #7 but i still have a problem of texture not being applied and 3d model stays on screen even after marker has left display. Thanks
Hi @magiraldooc - we've done some more testing and this visibility update definitely does work. However, it seems like there's an issue that only shows up after a failed js call. Unfortunately it seems that these other errors are silent - but after they happen the walk through mesh.children seems to fail.
We'll see if we can track this down and fix it in an upcoming release.
Sorry we can't be more help at the moment.
Hi @magiraldooc and @aminubakori please checkout our updated repos at https://github.com/awe-media/awe.js which includes a major refactor. This issue should be resolved now but if you find anything doesn't work then please raise an issue there.
Hi
This library is very easy to use, thanks for that.
I am doing some experiments with the library, rendering 3D objects like cubes and when the marker is tracked, the object appears and disappear when the marker is not on tracking, but i have a problem with custom 3D objects, because this appear on marker tracking, but when the marker is not on tracking, the objects never disappear as the objects made with the library.
The handler event function that i have is:
Thanks for your help.