Skip to content

Geometry

Josh Stovall edited this page Dec 19, 2020 · 3 revisions

Geometry

Create basic geometries.

These functions wrap the three.js geometries into simple functions — creating the geometry, material, and mesh at once.

List of Geometries

Parameters

Name Type Options Default Description
blend string none normal add subtract multiply normal object's blend mode
bumpMap string bump map file
bumpScale float 0.5 bump map scale
color color white color of object
position array [x,y,z] coordinates [0,0,0] position of object
rotation array [x,y,z] Euler rotation [0,0,0] rotation of object
reflect float 0.0 to 1.0 0.5 object's degree of reflectivity
side string front back both front which side will be rendered
physics bool true physics on or off
bounce float 0.0 to 1.0 amount of restitution ("bounciness")
friction float 0.0 to 1.0 amount of friction
mass int greater than 0 object's mass/weight
wireframe bool false render as a wireframe
map string map a texture file
material string basic depth lambert mirror normal phong physical standard standard object material

blend

blending equations for the material's RGB and Alpha

Options none, normal, add, subtract, multiply

color

Color of the material

could be a hexcolor '#FF0000'/0xFF0000 or a string 'red'.

side

Defines which side of faces will be rendered. See Material Constants

Options front,back,both
front would render a box visible from the outside.
back would render a box visible from the inside.
both would render a box visible from either side.

map

Map a texture to the object

material

Meterial of the object

Options basic depth lambert mirror normal phong physical standard
See https://threejsfundamentals.org/threejs/lessons/threejs-materials.html

All Geometries

Box()

new XR.Box({
  color: 0xffff00,
  side:"front",
  blend:"add",
  position: [0,1,-2]
});

Circle()

new XR.Circle({
  radius: 1,
  segments: 8,
  theta: [0, 2*Pi]
});

Cone()

new XR.Cone({
  radius: 1,
  height: 1,
  segments: 8,
  openEnded: true,
  theta: [0,2*Pi]
});

Cylinder()

new XR.Cylinder({
  radius: [1, 1],
  segments: 8,
  color: 0xffff00,
  position: [0.3,0.3,0.3],
  theta: [0,2*Pi]
});

Dodecahedron()

new XR.Dodecahedron({
  radius: 1,
  detail: 0
});

Icosahedron()

new XR.Icosahedron({
  radius: 1,
  detail: 0
});

Octahedron()

new XR.Octahedron({
  radius: 1,
  detail: 0
});

Plane()

new XR.Plane({
  width: 1,
  height:1
});

Ring()

new XR.Ring({
  radius: [0.5, 1],
  segments:8,
  theta:[0,2*Pi]
});

Sphere()

new XR.Sphere({
  radius: 1,
  segments: [32,32],
  color: 0xffff00,
  phi:   [PI * 2],
  theta: [0,2*Pi]
});

Tetrahedron()

new XR.Tetrahedron({
   radius: 1,
   detail: 0
});

Torus()

new XR.Torus({
  radius: 1,
  tube: 0.4,
  segments:[8,6],
  arc: 6
});

segments
type: array
represent the [radialSegments, tubularSegments]

TorusKnot()

new XR.TorusKnot({
  radius: 1,
  tube: 0.4,
  segments:[64,8],
  wind:[2,3]
});

segments

type: array
represent the [radialSegments, tubularSegments]

wind

type: array
default: [2,3] represent the [p, q] how many times the geometry winds around a circle in the interior of the torus

Clone this wiki locally