-
Notifications
You must be signed in to change notification settings - Fork 1
Geometry
Create basic geometries.
These functions wrap the three.js geometries into simple functions — creating the geometry, material, and mesh at once.
- Box()
- Circle()
- Cone()
- Cylinder()
- Dodecahedron()
- Icosahedron()
- Octahedron()
- Plane()
- Ring()
- Sphere()
- Tetrahedron()
- Torus()
- TorusKnot()
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 |
blending equations for the material's RGB and Alpha
Options
none
,normal
,add
,subtract
,multiply
Color of the material
could be a hexcolor
'#FF0000'
/0xFF0000
or a string'red'
.
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 a texture to the object
Meterial of the object
Options
basic
depth
lambert
mirror
normal
phong
physical
standard
See https://threejsfundamentals.org/threejs/lessons/threejs-materials.html
new XR.Box({
color: 0xffff00,
side:"front",
blend:"add",
position: [0,1,-2]
});
new XR.Circle({
radius: 1,
segments: 8,
theta: [0, 2*Pi]
});
new XR.Cone({
radius: 1,
height: 1,
segments: 8,
openEnded: true,
theta: [0,2*Pi]
});
new XR.Cylinder({
radius: [1, 1],
segments: 8,
color: 0xffff00,
position: [0.3,0.3,0.3],
theta: [0,2*Pi]
});
new XR.Dodecahedron({
radius: 1,
detail: 0
});
new XR.Icosahedron({
radius: 1,
detail: 0
});
new XR.Octahedron({
radius: 1,
detail: 0
});
new XR.Plane({
width: 1,
height:1
});
new XR.Ring({
radius: [0.5, 1],
segments:8,
theta:[0,2*Pi]
});
new XR.Sphere({
radius: 1,
segments: [32,32],
color: 0xffff00,
phi: [PI * 2],
theta: [0,2*Pi]
});
new XR.Tetrahedron({
radius: 1,
detail: 0
});
new XR.Torus({
radius: 1,
tube: 0.4,
segments:[8,6],
arc: 6
});
segments
type: array
represent the [radialSegments, tubularSegments]
new XR.TorusKnot({
radius: 1,
tube: 0.4,
segments:[64,8],
wind:[2,3]
});
type: array
represent the [radialSegments, tubularSegments]
type: array
default: [2,3]
represent the [p, q]
how many times the geometry winds around a circle in the interior of the torus