0

Does anybody have simple sample regarding the picking x3dom objects. There are two samples given in the homepage of x3dom but they are complex for em to understand. I would be really thankful if someone could provide me with simpler example. Thanking you in advance.

1 Answers1

1

not sure exactly what you mean by picking

here is a sample page which changes color based on mouseclick mouse over and mouse out

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html;charset=utf-8" />
<link rel="stylesheet" type="text/css" href="http://x3dom.org/x3dom/example/x3dom.css">    </link>
<script type="text/javascript" src = "http://x3dom.org/x3dom/example/x3dom.js"></script>
</head>
<body>

<X3D width="500px" height="400px" showLog='true' showStat="true">
<Scene DEF='scene' >
<Shape >
<Box onclick="toggleRendering();" onmouseover="toggleRendering2();"  onmouseout="toggleRendering3();" />        
<Appearance><Material diffuseColor='0 1 0' /></Appearance>
</Shape>
</Scene>
</X3D>


<script>

var flag = true;

function toggleRendering()
{
flag = !flag;

var mat = document.getElementsByTagName("Material");
var aMat = mat[0];

if (flag) aMat.diffuseColor = "1 0 0";
else aMat.diffuseColor = "0 0 1";

return false;
}

function toggleRendering2()
{
var mat = document.getElementsByTagName("Material");
var aMat = mat[0];

aMat.diffuseColor = "1 1 1";

return false;
}


function toggleRendering3()
{
var mat = document.getElementsByTagName("Material");
var aMat = mat[0];

aMat.diffuseColor = "0 0 0";

return false;
}
</script>

</body>
</html>
drfrog
  • 347
  • 2
  • 9
  • Thank you for the reply.What I meant was like the one given in the example http://www.x3dom.org/x3dom/example/x3dom_carousel.xhtml. To display the attribute or database linked to the x3dom object when it is clicked.the example doesnot seem to work in my pc..there is no change in the colour with the mouse movement. what could be the reason for that? thank you once again. – user1879084 Dec 23 '12 at 11:16
  • first off i would suggest using firefox or chrome for debuggin your x3dom. both have great debugging addons to help you diagnose issues. basically what is happening with the carousel example is an onclick is in every sphere/planet. that onclick fires the showvalue function which loads the url into the div element on the right. just look at the source code to follow the logic there – drfrog Dec 27 '12 at 07:26