<!--
-->
<html>
<head>
<title>3dhtml Example :: SolarSystem3D</title>
<!-- helper libs -->
<script language="JavaScript" src="../js/LyrObj.js"></script>
<script language="JavaScript" src="../js/ClipButton.js"></script>
<script language="JavaScript" src="../js/ColorUtil.js"></script>
<!-- core 3dhtml lib -->
<script language="JavaScript" src="../js/3dhtml.js"></script>
<!-- modulators -->
<script language="JavaScript" src="../js/MouseModulator.js"></script>
<!-- materials -->
<script language="JavaScript" src="../js/materials.js"></script>
<script language="javascript">
<!--
var sunMaterial = new Material('<img src="images/sun.gif" width="20" height="20" alt="" border="0">');
var mercuryMaterial = createClipButtonMaterial("images/mercury.gif", 20, 180, 20, 20, 9);
var venusMaterial = createClipButtonMaterial("images/venus.gif", 20, 180, 20, 20, 9);
var earthMaterial = createClipButtonMaterial("images/earth.gif", 20, 180, 20, 20, 9);
var moonMaterial = createClipButtonMaterial("images/moon.gif", 20, 180, 20, 20, 9);
var marsMaterial = createClipButtonMaterial("images/mars.gif", 20, 180, 20, 20, 9);
this.name = name;
this.distance = distance;
this.rotation = rotation;
this.toString = PlanetToString;
this.model = new Model(name, material);
this.model.setPoints( new Array( new Point3D(0, 0, 0, 0) ) );
var myMatrix = new Matrix();
myMatrix.translate(this.distance, 0, 0);
this.model.transform(myMatrix);
this.animate = PlanetAnimate;
this.rotationMatrix = new Matrix();
this.rotationMatrix.rotateY(this.rotation);
}
this.model.transform(this.rotationMatrix);
}
return this.name + " @ " + this.distance + " with " + this.rotation + ".";
}
var planets = new Array(
new Planet("mercury", mercuryMaterial, 0.387, 0.235),
new Planet("venus", venusMaterial, 0.72, 0.175),
new Planet("earth", earthMaterial, 1, 0.145),
new Planet("mars", marsMaterial, 1.5, 0.12)
);
var sunModel = new Model("sun", sunMaterial);
sunModel.setPoints( new Array(new Point3D(0, 0, 0, 0)) );
var moonModel = new Model("moon", moonMaterial);
moonModel.setPoints( new Array(new Point3D(0, 0, 0, 0)) );
var moonInitMatrix = new Matrix();
moonInitMatrix.translate(0.1, 0, 0);
moonModel.transform(moonInitMatrix);
var myMouseModulator = new MouseModulator("myMouseModulator", MouseModulator.MODE_ROTATE);
fixNetscape();
var initMatrix = new Matrix();
initMatrix.scale(180, 180, 180);
initMatrix.rotateX( degToRad(-90) );
sunModel.assignLayers();
sunModel.transform(initMatrix);
sunModel.draw();
for (i = 0; i < planets.length; i++) {
planets[i].model.assignLayers();
planets[i].model.linkTo(sunModel);
planets[i].model.draw();
}
moonModel.assignLayers();
moonModel.linkTo(planets[2].model);
moonModel.draw();
animate();
}
var delay = 1;
myMouseModulator.animate();
mouseModMatrix = myMouseModulator.getMatrix();
sunModel.transform(mouseModMatrix);
sunModel.draw();
for (planetIndex = 0; planetIndex < planets.length; planetIndex++) {
var p = planets[planetIndex];
if (p.animate) p.animate();
p.model.draw();
}
var staticRotateMatrix = new Matrix();
staticRotateMatrix = new Matrix();
staticRotateMatrix.rotateY(0.4);
staticRotateMatrix.rotateZ(0.4);
moonModel.transform(staticRotateMatrix);
moonModel.draw();
setTimeout("animate()", delay);
}
document.onmousemove = mouseMoveHandler;
document.onmousedown = mouseDownHandler;
document.onmouseup = mouseUpHandler;
if (ns) document.captureEvents(Event.MOUSEMOVE | Event.MOUSEDOWN | Event.MOUSEUP);
myMouseModulator.move(e);
return !ie;
}
myMouseModulator.down(e);
}
myMouseModulator.up(e);
}
</script>
</head>
<body onload="initOnLoad()" bottommargin="0" leftmargin="0" marginheight="0" marginwidth="0" rightmargin="0" topmargin="0" style="height:100%" bgcolor="black">
<!-- layer to bugfix netscape -->
<div id="fixnetscape" style="position:absolute;visibility:hidden"></div>
<script language="JavaScript" type="text/javascript">
<!--
sunModel.createPointCode();
moonModel.createPointCode();
for (i = 0; i < planets.length; i++) {
planets[i].model.createPointCode()
}
</script>
</body>
</html>
Syntax highlighted by Code2HTML, v. 0.9, modified by Netzministerium, 2001.