0

I want to create a human body using a frame where i can update the model, cloths, and other measurement. In three.js i tried and its working there but i don't know how to do that thing in A Frame ?

Refer link oh three.js Model : example

Rizban Ahmad
  • 139
  • 1
  • 13
  • In A-Frame, you wrap three.js code in components: https://aframe.io/docs/0.3.0/core/component.html – ngokevin Nov 16 '16 at 21:42
  • So can we update Collada (.dae) file components also ? – Sunil gauswami Nov 17 '16 at 05:10
  • Yeah, just traverse the object3d once the collada meshes are loaded in – ngokevin Nov 17 '16 at 05:28
  • yes traverse() will working fine with components. But when i use second time on onclick event my changed was not affected in model. Here is Example text file. [CODE](https://drive.google.com/open?id=0B4zkSgVE4wsANVkyN2IxNUlsQnc) – Sunil gauswami Nov 17 '16 at 05:38
  • components are statically registered just once before the scene, they aren't meant to be called like functions. the code you have is *registering* a component, not invoking its code. you need to add event handling within a component. – ngokevin Nov 17 '16 at 06:32
  • how we can use that component with event handling ? So we can click the button and update the properties of collada model. – Sunil gauswami Nov 17 '16 at 10:36
  • write an event listener (`el.addEventListener('click', function () { // ... Do stuff })`) – ngokevin Nov 17 '16 at 10:41
  • When i used this with click event its give model is undefined. Here is Code : `AFRAME.registerComponent('model-overrider', { init: function() { // update also i used this.el.addEventListener('click', function(e) { var model = e.detail.model; alert("1."+model) model.traverse(function(o) { alert("2."+o) if (o instanceof THREE.Mesh) { alert("3."+o.material); o.material.color = new THREE.color("red"); } }); }); } });` Here alert(1) is giving undefined value. So traverse() not work. – Sunil gauswami Nov 18 '16 at 05:19
  • Where'd you get `e.detail.model` from? You can `console.log(e.detail)`. Get `e.detail.el`. Then `el.getObject3D('mesh');` – ngokevin Nov 18 '16 at 19:40
  • Possible duplicate of [Update Collada (.dae ) file code from A-Frame or JS](http://stackoverflow.com/questions/40585192/update-collada-dae-file-code-from-a-frame-or-js) – ngokevin Nov 23 '16 at 05:13
  • Thank You for your help @ngokevin. Now i did it using onclick event. Now i am able to change material and geometry of dae on onclick action. I am not using AFRAME.registerComponent or el.addEventListener. Thank you so much. – Sunil gauswami Nov 23 '16 at 06:02

0 Answers0