All CS 307 Examples
This is a list of the most important demos we have available to
you, along with what they show.
Template
If you just want a minimal template file to get started on your
programming, try this template file. Note
that the template omits optional stuff like the library file that
defines the TW.createBarn()
function.
Barn
- the barn, using TW. This is our
earliest, simplest example. It builds a barn, with the colors of the
faces corresponding to the orientation of the face (that is, the surface
normal). It uses the TW module to simplify things like the camera
setup.
- the barn, documented. This is
the same code, with code pretty-printed into the document, so you can
view it more easily.
Early
These are demos in the Early subdirectory.
- axes. This very simple example is just
to show the three-dimensional coordinate system that we use.
- single color barn. This shows a
barn in which the barn is just a single color, but one you can
specify. Consequently, it's about direct-color specification.
- multi-colored barn. This
is a different barn geometry, where each face has a different color
index into a list of colors, showing how different faces of an object
can have different colors that you specify.
Color
These are demos in the Color subdirectory.
Basic Modeling
These are demos in the BasicModeling
subdirectory.
- Barn
Instance Transform. This shows how to use the
set()
methods of an Object's position
, rotation
,
and scale
to modify an instance. These properties are
defined by
THREE.Object3D() . Uses a GUI to modify the 9 parameters.
- Plane, Box and
Sphere. This shows one of each of those geometries, without any
instance transformation supplied.
- polygonal sphere.
This shows a sphere, with a GUI to try different widthSegments and
heightSegments.
- barn
instance transform. This shows the barn, with a GUI to modify its
position, rotation, and scaling.
- Blocks. This shows an
arrangement of blocks, showing the essentials of the instance
transformation (translate, rotate, scale), to create a variety of
instances of a particular geometrical object.
- Cylinder Rotation.
This shows how you can rotate a cylinder either around its middle or
around its end, by using a nested coordinate object. Has a GUI to modify
the rotations.
- Leg. This shows how you can
create a complex nested object, comprising three cylinders. Has a GUI
to modify the joint angles rotations.
- Fence. This shows how you
can create an object by cloning, translating and adding to a container object.
- Curved Fence. This
shows how you can create an object by cloning, translating, rotating and
adding to a container object.
- Snow Person. This shows
how to compose a graphics object from existing geometrical objects; in
this case, three spheres and a cone. This is one of our simplest
compositional objects. It also allows toggling of a
global
wireframe
parameter, which shows how to set up
keyboard callback to do that.
- Teddy Bear.
This shows how to compose a bear from spheres and tubes. A bit more
complex than the snow person.
- Mobile. This shows a fairly
complex compositional object, in which we have to keep track of
different coordinate systems.
Camera API
A few demos to help understand cameras:
Material and Lighting
Texture Mapping
- tutor 1 shows a demo
texture and allows you to adjust the texture parameters and
the
wrap
setting.
- Plane Flags shows
computed textures (flags) on a plane.
- Plane Flags v2
shows computed textures (flags) on a plane, but this time adjusting the
texture coordinates so that the gray part of the US flag texture is
omitted.
- Plane Buffy shows an
image (Buffy) on a plane.
- Plane
Harry fails to shows an image (Harry Potter) on a plane,
due to the browser's Same Origin Security Policy.
- Mikey
Cube shows a texture on each side of a cube.
Animation
Curves and Surfaces
- S curve 1 the
simplest, 2D Bezier curve demo
- S curve 2 the
previous demo, but with a GUI added, so you can play with all the controls
- S curve 3 a simple
demo, but in 3D, not 2D
- Dome Surface a
demo of a 2D surface, a dome.