Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Multiple balls.

  • Loading branch information...
commit cff1d393a20851252f25ac81663e6b01a6ead299 1 parent 09dcebf
Peter Behr authored
Showing with 33 additions and 16 deletions.
  1. +2 −1  index.html
  2. +15 −15 js/clonesmos.js
  3. +16 −0 models/clone.js
View
3  index.html
@@ -33,7 +33,8 @@
<!--<script type="text/javascript" src="js/default.js"></script>-->
<!--<script type="text/javascript" src="http://code.jquery.com/jquery-latest.js"></script>-->
<script type="text/javascript" src="js/Three.js"></script>
-<script type="text/javascript" src="js/base.js"></script>
+<script type="text/javascript" src="models/clone.js"></script>
+<script type="text/javascript" src="js/clonesmos.js"></script>
</body>
</html>
View
30 js/clonesmos.js
@@ -12,32 +12,32 @@ function init() {
camera.position.z = 1000;
scene.add( camera );
- geometry = new THREE.CubeGeometry( 200, 200, 200 );
- material = new THREE.MeshBasicMaterial( { color: 0xff0000, wireframe: true } );
-
- mesh = new THREE.Mesh( geometry, material );
- scene.add( mesh );
-
- renderer = new THREE.CanvasRenderer();
+ var clones = [];
+ clones.push(new Clone());
+ clones.push((new Clone()).radius(100));
+ for (var i = 0; i < clones.length; i++) {
+ var clone = clones[i];
+ console.log(clone);
+ var geometry = new THREE.SphereGeometry(clone.r, clone.segmentsX, clone.segmentsY);
+ var material = new THREE.MeshBasicMaterial({ color: clone.color, wireframe: clone.wireframe });
+ var mesh = new THREE.Mesh( geometry, material );
+ scene.add( mesh );
+ }
+
+ renderer = new THREE.WebGLRenderer();
renderer.setSize( window.innerWidth, window.innerHeight );
document.body.appendChild( renderer.domElement );
-
}
function animate() {
-
// note: three.js includes requestAnimationFrame shim
requestAnimationFrame( animate );
render();
-
}
function render() {
-
- mesh.rotation.x += 0.01;
- mesh.rotation.y += 0.02;
-
+ // mesh.rotation.x += 0.01;
+ // mesh.rotation.y += 0.02;
renderer.render( scene, camera );
-
}
View
16 models/clone.js
@@ -0,0 +1,16 @@
+var Clone = function (r, segmentsX, segmentsY, color, wireframe) {
+ this.r = r || 500;
+ this.segmentsX = segmentsX || 100;
+ this.segmentsY = segmentsY || 100;
+ this.color = color || 0xccaa00;
+ this.wireframe = wireframe || true;
+}
+
+Clone.prototype.radius = function (r) {
+ if (typeof(r) === 'undefined') {
+ return this.r;
+ } else {
+ this.r = r;
+ return this;
+ }
+}
Please sign in to comment.
Something went wrong with that request. Please try again.