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";
});
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
20 October 2015 16:45
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.