Element Polyhedron3D
JXG.GeometryElement
↳ JXG.GeometryElement3D
↳ Polyhedron3D
A polyhedron in a 3D view consists of faces.
Defined in: polyhedron3d.js.
Extends
JXG.GeometryElement3D.
| Constructor Attributes | Constructor Name and Description |
|---|---|
|
Create a polyhedron in a 3D view consisting of faces.
|
| Field Attributes | Field Name and Description |
|---|---|
|
Color array to define fill colors of faces cyclically.
|
| Field Attributes | Field Name and Description |
|---|---|
|
Contains the defining data of the polyhedron:
Definitions of vertices and a list of vertices for each face.
|
|
|
List of Face3D objects.
|
|
|
Number of faces
|
- Methods borrowed from class JXG.GeometryElement:
- _set, addChild, addDescendants, addParents, addParentsFromJCFunctions, addRotation, addTicks, addTransform, animate, bounds, clearTrace, cloneToBackground, countChildren, createGradient, createLabel, draggable, eval, evalVisProp, formatNumberLocale, fullUpdate, generatePolynomial, getAttribute, getAttributes, getLabelAnchor, getName, getParents, getProperty, getSnapSizes, getTextAnchor, getType, handleSnapToGrid, hasPoint, hide, hideElement, noHighlight, normalize, prepareUpdate, remove, removeAllTicks, removeChild, removeDescendants, removeTicks, resolveShortcuts, setArrow, setAttribute, setDash, setDisplayRendNode, setLabel, setLabelText, setName, setParents, setPosition, setPositionDirectly, setProperty, show, showElement, snapToPoints, update, updateRenderer, updateVisibility, useLocale
- Events borrowed from class JXG.GeometryElement:
- attribute, attribute:key, down, drag, keydrag, mousedown, mousedrag, mousemove, mouseout, mouseover, mouseup, move, out, over, pendown, pendrag, penup, touchdown, touchdrag, touchup, up
Element Detail
Polyhedron3D
Create a polyhedron in a 3D view consisting of faces. Faces can
be 0-, 1- or 2-dimensional.
-
This element has no direct constructor. To create an instance of this element you have to call JXG.Board#create
with type "polyhedron3d".
- Possible parent array combinations are:
-
{} TODO
- Throws:
- {Exception}
- If the element cannot be constructed with the given parent objects an exception is thrown.
- Examples:
var box = [-4, 4];
var view = board.create(
'view3d',
[[-5, -3], [8, 8],
[box, box, box]],
{
projection: 'parallel',
trackball: { enabled: false },
depthOrder: {
enabled: true
},
xPlaneRear: { visible: false },
yPlaneRear: { visible: false },
zPlaneRear: { fillOpacity: 0.2 }
}
);
var cube = view.create('polyhedron3d', [
[
[-3, -3, -3],
[3, -3, -3],
[3, 3, -3],
[-3, 3, -3],
[-3, -3, 3],
[3, -3, 3],
[3, 3, 3],
[-3, 3, 3]
],
[
[0, 1, 2, 3],
[0, 1, 5, 4],
[[1, 2, 6, 5], { fillColor: 'black', fillOpacity: 0.5, strokeWidth: 5 }],
[2, 3, 7, 6],
[3, 0, 4, 7],
[4, 5, 6, 7]
]
], {
fillColorArray: ['blue', 'red', 'yellow']
});
var box = [-4, 4];
var view = board.create(
'view3d',
[[-5, -3], [8, 8],
[box, box, box]],
{
projection: 'parallel',
trackball: { enabled: false },
depthOrder: {
enabled: true
},
xPlaneRear: { visible: false },
yPlaneRear: { visible: false },
zPlaneRear: { fillOpacity: 0.2 }
}
);
var aa = view.create('point3d', [-3, -3, -3], { name: 'A', layer: 12});
var bb = view.create('point3d', [() => aa.X(), () => aa.Y(), 3], { name: 'B', fixed: true, layer: 12});
var cube = view.create('polyhedron3d', [
{
a: 'A',
b: [3, -3, -3],
c: [3, 3, -3],
d: [-3, 3, -3],
e: bb,
f: [3, -3, 3],
g: [3, 3, 3],
h: [-3, 3, 3]
},
[
['a', 'b', 'c', 'd'],
['a', 'b', 'f', 'e'],
['b', 'c', 'g', 'f'],
['c', 'd', 'h', 'g'],
['d', 'a', 'e', 'h'],
['e', 'f', 'g', 'h'],
['a', 'g'], // Edge
['f'] // Vertex
]
], {
fillColorArray: ['blue', 'red', 'yellow'],
fillOpacity: 0.4,
layer: 12
});
cube.faces[6].setAttribute({ strokeWidth: 5 });
cube.faces[7].setAttribute({ strokeWidth: 10 });
var box = [-4, 4];
var view = board.create(
'view3d',
[[-5, -3], [8, 8],
[box, box, box]],
{
projection: 'parallel',
trackball: { enabled: false },
depthOrder: {
enabled: true
},
xPlaneRear: { visible: false },
yPlaneRear: { visible: false },
zPlaneRear: { fillOpacity: 0.2 }
}
);
var s = board.create('slider', [[-4, -6], [4, -6], [0, 2, 4]], { name: 's' });
var cube = view.create('polyhedron3d', [
[
() => { let f = s.Value(); return [-f, -f, -f]; },
() => { let f = s.Value(); return [f, -f, -f]; },
() => { let f = s.Value(); return [f, f, -f]; },
() => { let f = s.Value(); return [-f, f, -f]; },
() => { let f = s.Value(); return [-f, -f, f]; },
() => { let f = s.Value(); return [f, -f, f]; },
() => { let f = s.Value(); return [f, f, f]; },
// () => { let f = s.Value(); return [-f, f, f]; }
[ () => -s.Value(), () => s.Value(), () => s.Value() ]
],
[
[0, 1, 2, 3],
[0, 1, 5, 4],
[1, 2, 6, 5],
[2, 3, 7, 6],
[3, 0, 4, 7],
[4, 5, 6, 7],
]
], {
strokeWidth: 3,
fillOpacity: 0.6,
fillColorArray: ['blue', 'red', 'yellow'],
shader: {
enabled:false
}
});
var box = [-4, 4];
var view = board.create(
'view3d',
[[-5, -3], [8, 8],
[box, box, box]],
{
projection: 'parallel',
trackball: { enabled: false },
depthOrder: {
enabled: true
},
xPlaneRear: { visible: false },
yPlaneRear: { visible: false },
zPlaneRear: { fillOpacity: 0.2 }
}
);
let rho = 1.6180339887;
let vertexList = [
[0, -1, -rho], [0, +1, -rho], [0, -1, rho], [0, +1, rho],
[1, rho, 0], [-1, rho, 0], [1, -rho, 0], [-1, -rho, 0],
[-rho, 0, 1], [-rho, 0, -1], [rho, 0, 1], [rho, 0, -1]
];
let faceArray = [
[4, 1, 11],
[11, 1, 0],
[6, 11, 0],
[0, 1, 9],
[11, 10, 4],
[9, 1, 5],
[8, 9, 5],
[5, 3, 8],
[6, 10, 11],
[2, 3, 10],
[2, 10, 6],
[8, 3, 2],
[3, 4, 10],
[7, 8, 2],
[9, 8, 7],
[0, 9, 7],
[4, 3, 5],
[5, 1, 4],
[0, 7, 6],
[7, 2, 6]
];
var ico = view.create('polyhedron3d', [vertexList, faceArray], {
fillColorArray: [],
fillOpacity: 1,
strokeWidth: 0.1,
layer: 12,
shader: {
enabled: true,
type: 'angle',
hue: 60,
saturation: 90,
minlightness: 60,
maxLightness: 80
}
});
Attribute Detail
{Array}
fillColorArray
Color array to define fill colors of faces cyclically.
Alternatively, the fill color can be defined for each face individually.
Defined in: options3d.js.
Defined in: options3d.js.
- Default Value:
- ['white', 'black']
Field Detail
{Object}
def
Contains the defining data of the polyhedron:
Definitions of vertices and a list of vertices for each face. This is pretty much the input given
in the construction of the polyhedron plus internal data.
polyhedron = {
view: view,
vertices: {},
coords: {},
coords2D: {},
zIndex: {},
faces: []
};
{Array}
faces
List of Face3D objects.
{Number}
numberFaces
Number of faces
Attributes borrowed from other Elements
- Attributes borrowed from class JXG.GeometryElement:
- aria, cssClass, dash, dashScale, draft, dragToTopOfLayer, element3D, fillColor, fillOpacity, fixed, frozen, gradient, gradientAngle, gradientCX, gradientCY, gradientEndOffset, gradientFR, gradientFX, gradientFY, gradientR, gradientSecondColor, gradientSecondOpacity, gradientStartOffset, highlight, highlightCssClass, highlightFillColor, highlightFillOpacity, highlightStrokeColor, highlightStrokeOpacity, highlightStrokeWidth, isLabel, layer, lineCap, needsRegularUpdate, nonnegativeOnly, precision, priv, rotatable, scalable, shadow, snapToGrid, strokeColor, strokeOpacity, strokeWidth, tabindex, trace, traceAttributes, transitionDuration, transitionProperties, visible, withLabel
Fields borrowed from other Elements
- Fields borrowed from class JXG.GeometryElement3D:
- element2D, is3D, view
- Fields borrowed from class JXG.GeometryElement:
- _org_type, _pos, ancestors, baseElement, board, childElements, descendants, dump, elementClass, elType, hasLabel, highlighted, id, inherits, isDraggable, isReal, lastDragTime, methodMap, mouseover, name, needsUpdate, notExistingParents, numTraces, parents, quadraticform, rendNode, stdform, subs, symbolic, traces, transformations, type, visProp, visPropCalc
Methods borrowed from other Elements
- Methods borrowed from class JXG.GeometryElement:
- _set, addChild, addDescendants, addParents, addParentsFromJCFunctions, addRotation, addTicks, addTransform, animate, bounds, clearTrace, cloneToBackground, countChildren, createGradient, createLabel, draggable, eval, evalVisProp, formatNumberLocale, fullUpdate, generatePolynomial, getAttribute, getAttributes, getLabelAnchor, getName, getParents, getProperty, getSnapSizes, getTextAnchor, getType, handleSnapToGrid, hasPoint, hide, hideElement, noHighlight, normalize, prepareUpdate, remove, removeAllTicks, removeChild, removeDescendants, removeTicks, resolveShortcuts, setArrow, setAttribute, setDash, setDisplayRendNode, setLabel, setLabelText, setName, setParents, setPosition, setPositionDirectly, setProperty, show, showElement, snapToPoints, update, updateRenderer, updateVisibility, useLocale
Events borrowed from other Elements