Forum

attach_move_cb not working

19 October 2015 21:41
i was looking at the custom anchors example specific adding a generic anchor. I am using the same code that you provided, but with my own object, and the attach_move_cb callback function is never hit. I am assuming there is some setting within blender that is needed but not sure what. Any Ideas?

var obj = m_scs.get_object_by_name("obj");


var cyl_text = document.createElement("span");
cyl_text.id = "cyl_anchor";
cyl_text.style.position = "absolute";
cyl_text.style.backgroundColor = "yellow";
cyl_text.style.color = "black";
cyl_text.style.padding = "5px";
cyl_text.innerHTML = "Cylinder (Generic)";
document.body.appendChild(cyl_text);


m_anchors.attach_move_cb(obj, function (x, y, appearance, obj, elem) {
var anchor_elem = document.getElementById("cyl_anchor");
anchor_elem.style.left = x + "px";
anchor_elem.style.top = y + "px";

if (appearance == "visible")
anchor_elem.style.visibility = "visible";
else
anchor_elem.style.visibility = "hidden";
});
20 October 2015 15:11
Hi, this function should work for anchor objects. Does your EMPTY object have the setting "Anchors> Enable Anchor" applied in Blender? More info https://www.blend4web.com/doc/en/objects.html?highlight=anchor
20 October 2015 16:28
Yeah, turns out it doesn't do what i was hoping it would, i would like to be able to attach an anchor to an object, that way whenever i copy and translate my object i can move the tag with it.
20 October 2015 16:45
Are you doing copying and translations in Blender or in your app via JavaScript? If you need an annotation near your object you can always parent an anchor empty to it. Hope this helps!
26 October 2015 18:31
im doing the copying and translations using javascript. i want to create a generic object that has a annotation associated to it, when i copy and move that object i want to be able to access the anchor and change the name. My problem is i cant copy and translate an empty, and i cannot assign an anchor to an object. I have tried creating an object and an empty and parenting them together but this does not seem to work.
26 October 2015 21:32
im doing the copying and translations using javascript. i want to create a generic object that has a annotation associated to it, when i copy and move that object i want to be able to access the anchor and change the name. My problem is i cant copy and translate an empty, and i cannot assign an anchor to an object. I have tried creating an object and an empty and parenting them together but this does not seem to work.
Unfortunately, such APIs are not available now. You'll need to create a pool of empty objects with anchors in Blender, and then move them via JavaScript in your app.
The Founder | Twitter | Facebook | Linkedin
 
Please register or log in to leave a reply.