Class: ND

ND~ND(n, settingsopt)

N-dimensional graphics. Extends MyObject.

Constructor

new ND(n, settingsopt)

N-dimensional graphics. Creates an N-dimensional graphic object, checks for a collision between an n-dimensional plane and an n-dimensional graphics object and returns the (n-1)-dimensional intersection geometry if a collision was occurs.
Parameters:
Name Type Attributes Default Description
n number space dimension of the graphical object.
settings object <optional>
{} The following settings are available
Properties
Name Type Attributes Default Description
object object <optional>
geometry, position and rotation of the n-dimensional graphical object.
Properties
Name Type Attributes Default Description
name String <optional>
name of n-dimensional graphical object.
color number | String | object <optional>
'lime' color of N-dimensional graphic object.
number - Hex triplet color. Example: 0xffffff - white color
String - color name. See list of available color names in the _colorKeywords object in the Color.js file.
object - Sets the color separately for each vertice.
	You can choose one way for setting of the vertice color from two available:
	
	1. Set the fourth w coordinate of each vertex in a range from
		settings.options.scales.w.min to
		settings.options.scales.w.max
		
		w coordinate is index of palette color. See  method from ColorPicker class.
		Example:
		settings.object.geometry.position: [
			//pyramid
			[0,-0.9428090415820634,0.33333333333333326, 1],
			[0.8164965662730563,0.4714045207910317,0.33333333333333326, 0.5],
			[-0.8164965662730563,0.4714045207910317,0.33333333333333326, 0],
			[7.32733549761259e-9,4.230438555019589e-9,-1.0, -1.0],
		],
	
	2. Set a settings.object.geometry.colors array. 
Have effect only if settings.object.geometry.colors are not defined.
faces boolean | object <optional>
true or object - display the n-dimensional graphical object faces instead of edges.
Properties
Name Type Attributes Default Description
opacity float <optional>
0.5 color Float in the range of 0.0 - 1.0 indicating how transparent the material is. A value of 0.0 indicates fully transparent, 1.0 is fully opaque. If the transparent property is not set to true, the material will remain fully opaque and this value will only affect its color. See Material.opacity.
transparent boolean <optional>
true Defines whether this material is transparent. This has an effect on rendering as transparent objects need special treatment and are rendered after non-transparent objects. When set to true, the extent to which the material is transparent is controlled by setting its opacity property. See Material.transparent.
geometry Array | Object <optional>
Array of vertices and indices of the n-dimensional graphical object.
Every item of array is n-dimensional vector of vertice of object.
Or Object. See object's keys below.
Properties
Name Type Attributes Default Description
position Array <optional>
Array of vertices of the n-dimensional graphical object.
Every item of array is n-dimensional vector of vertice of object.
For example, if you want to create a tetrahedron, then you need to create an array of 4 vertices.
settings.object.geometry.position: [
	[-0.6, 0.1, 0.8],//0
	[0.7, 0.5, 0.9],//1
	[0, -0.4, 0.8],//2
	[0, 0, -0.6]//3
],
colors Array <optional>
Array of colors for the each vertex.
Every vertex is associated with 3 values of the colors array.
Each value of the colors array is red or green or blue color of the particular vertex in range from 0 to 1.

0 is no color.
1 is full color.

For example:
settings.object.geometry.colors: [
	1, 0, 0,//red color of the position[0] vertex.
	0, 1, 0,//green color of the position[1] vertex.
	0, 0, 1,//blue color of the position[2] vertex.
	1, 1, 1,//white color of the position[3] vertex.
],
Have effect only if settings.object.geometry.position points are not THREE.Vector4 type.
See arrayFuncs parametr of the Player.getPoints(...) for details.
opacity array <optional>
array of opacities for the each vertex. Each item of array is float value in the range of 0.0 - 1.0 indicating how transparent the material is. A value of 0.0 indicates fully transparent, 1.0 is fully opaque.
boRememberPosition Array <optional>
true true - Remember vertex positions for higher performance. As result, new vertex positions have no effect.
indices Array <optional>
Array of indices of vertices of the n-dimensional graphical object. Allows for vertices to be re-used across multiple segments.
Indices is divided to segments:

indices[0] is edges. Every edge is two indexes of the edge's vertices. Used in 1D objects and higher.
indices[1] is faces. Every face is three indexes of the edges from indices[0]. Used in 3D objects and higher.
indices[2] is bodies. Every bodie is four face indexes from indices[1]. Used in 4D objects and higher.
For example:

n = 1 line.
settings.object.geometry.position = [
	[-0.5, 1],//0
	[0.5]//1
]
settings.object.geometry.indices = [
	[
		0,//index of the settings.object.geometry.position[0] = [-0.5, 1]
		1,//index of the settings.object.geometry.position[1] = [0.5]
	]//0
]//0

n = 2 triangle
settings.object.geometry.position = [
	[-0.7, 0.2],//0
	[0.8, 0.6],//1
	[0.1, -0.5]//2
],
//edges
settings.object.geometry.indices[0] = [
	[0, 1],//0 index of the settings.object.geometry.positions [-0.7, 0.2] and [0.8, 0.6]
	[0, 2],//1 index of the settings.object.geometry.positions [-0.7, 0.2] and [0.1, -0.5]
	[1, 2] //2 index of the settings.object.geometry.positions [0.8, 0.6] and [0.1, -0.5]
]

n = 3 tetrahedron.
settings.object.geometry.position = [
	[0.8, -0.6, 0.1],//0
	[0.9, 0.7, 0.5],//1
	[0.8, 0, -0.4],//2
	[-0.6, 0.1, 0.1]//3
],
//edges
settings.object.geometry.indices[0] = [
	[0, 1]//0 index of the settings.object.geometry.positions [0.8, -0.6, 0.1] and [0.9, 0.7, 0.5]
	[0, 2]//1 index of the settings.object.geometry.positions [0.8, -0.6, 0.1] and [0.8, 0, -0.4]
	[0, 3]//2 index of the settings.object.geometry.positions [0.8, -0.6, 0.1] and [-0.6, 0.1, 0.1]
	[1, 2]//3 index of the settings.object.geometry.positions [0.9, 0.7, 0.5] and [0.8, 0, -0.4]
	[1, 3]//4 index of the settings.object.geometry.positions [0.9, 0.7, 0.5] and [-0.6, 0.1, 0.1]
	[2, 3]//5 index of the settings.object.geometry.positions [0.8, 0, -0.4] and [-0.6, 0.1, 0.1]
]
//faces. Indices of the edges settings.object.geometry.indices[0]
settings.object.geometry.indices[1] = [
	[0, 1, 3]//tetrahedron's face 0
	[0, 2, 4]//tetrahedron's face 1
	[3, 4, 5]//tetrahedron's face 2
	[1, 2, 5]//tetrahedron's face 3
]

n = 4 pentachoron 5-cell.
settings.object.geometry.position = [
	[0.8, -0.6, 0.1, -0.85],//0
	[0.9, 0.7, 0.5, -0.55],//1
	[0.8, 0, -0.4, 0],//2
	[-0.6, 0.1, -0.3, 0.55],//3
	[-0.5, 0.2, 0.3, 0.85],//4
],
//edges
settings.object.geometry.indices[0] = [
	[0, 1]//0 index of the settings.object.geometry.positions [0.8, -0.6, 0.1, -0.85] and [0.9, 0.7, 0.5, -0.55]
	[0, 2]//1 index of the settings.object.geometry.positions [0.8, -0.6, 0.1, -0.85] and [0.8, 0, -0.4, 0]
	[0, 3]//2 index of the settings.object.geometry.positions [0.8, -0.6, 0.1, -0.85] and [-0.6, 0.1, -0.3, 0.55]
	[0, 4]//3 index of the settings.object.geometry.positions [0.8, -0.6, 0.1, -0.85] and [-0.5, 0.2, 0.3, 0.85]
	[1, 2]//4 index of the settings.object.geometry.positions [0.9, 0.7, 0.5, -0.55] and [0.8, 0, -0.4, 0]
	[1, 3]//5 index of the settings.object.geometry.positions [0.9, 0.7, 0.5, -0.55] and [-0.6, 0.1, -0.3, 0.55]
	[1, 4]//6 index of the settings.object.geometry.positions [0.9, 0.7, 0.5, -0.55] and [-0.5, 0.2, 0.3, 0.85]
	[2, 3]//7 index of the settings.object.geometry.positions [0.8, 0, -0.4, 0] and [-0.6, 0.1, -0.3, 0.55]
	[2, 4]//8 index of the settings.object.geometry.positions [0.8, 0, -0.4, 0] and [-0.5, 0.2, 0.3, 0.85]
	[3, 4]//9 index of the settings.object.geometry.positions [-0.6, 0.1, 0.1, 0.55] and [-0.5, 0.2, 0.3, 0.85]
]
//faces. Indices of the edges settings.object.geometry.indices[0]
settings.object.geometry.indices[1] = [
	[7, 8, 9],//0 no 0, 1 vertices
	[5, 6, 9],//1 no 0, 2 vertices
	[4, 6, 8],//2 no 0, 3 vertices
	[4, 5, 7],//3 no 0, 4 vertices
	[2, 3, 9],//4 no 1, 2 vertices
	[1, 3, 8],//5 no 1, 3 vertices
	[1, 2, 7],//6 no 1, 4 vertices
	[0, 3, 6],//7 no 2, 3 vertices
	[0, 2, 5],//8 no 2, 4 vertices
	[0, 1, 4],//9 no 3, 4 vertices
]
//bodies. Indices of the faces settings.object.geometry.indices[1]
settings.object.geometry.indices[2] = [
[2, 1, 3, 0],//0 no 0 vertice
[5, 6, 4, 0],//1 no 1 vertice
[8, 7, 1, 4],//2 no 2 vertice
[9, 7, 2, 5],//3 no 3 vertice
[9, 8, 3, 6],//4 no 4 vertice
]
position Array | number <optional>
Array - position of the n-dimensional graphical object in n-dimensional coordinates.
number - position of the 0 coordinate of the n-dimensional graphical object.
rotation Array | number <optional>
Array - rotation in radians of the n-dimensional graphical object in n-dimensional coordinates.
n space dimensionArray indexAxis of rotationAxis typeNote
0no rotation
1no rotation
20No effect for 2-dimensional space
1No effect for 2-dimensional space
22(z)point
300(x)line
11(y)
22(z)
400, 1(xy)plane
10, 2(xz)
20, 3(xw)
31, 2(yz)
41, 3(yw)
52, 3(zw)
500, 1, 2(xyz)3D space
10, 1, 3(xyw)
20, 1, 4(xy4)
30, 2, 3(xzw)
40, 2, 4(xz4)
50, 3, 4(xw4)
61, 2, 3(yzw)
71, 2, 4(yz4)
81, 3, 4(yw4)
92, 3, 4(zw4)
number - rotation in radians around axis 0 or rotation around axis 2 for 2D objects i.e. space dimension n = 2.
See Can rotations in 4D be given an explicit matrix form?, Rotation matrix.
Examples:
n = 4, rotation = [Math.PI / 5, 1, 2, 3, 4, 5]
rotation around 0, 1(xy) plane is Math.PI / 5 radians.
rotation around 0, 2(xz) plane is 1 radian.
etc.

n = 4, rotation = Math.PI / 5
rotation around 0, 1(xy) plane is Math.PI / 5 radians.

n = 2, rotation = [0, 0, Math.PI / 4]
rotation around 2(z) point is Math.PI / 4 radians.

n = 2, rotation = Math.PI / 5
rotation around 2(z) point is Math.PI / 5 radians.
geometry.iAxes Array <optional>
array of indices of the axes. For example if iAxes is [1,2], then axis 1 interpret as axis 0 and axis 2 interpret as axis 1. As result, you can rotate axes around another axis to 90 degrees. In example above you have rotated axis 1 and 2 around axis 0 to 90 degrees.
plane Boolean <optional>
false true - create vectorPlane. See settings.vectorPlane below.
vectorPlane Array <optional>
n-dimensional position of the panel intersecting with the settings.object.geometry n-dimensional graphical object. Available only if settings.plane is true.
scene THREE.Scene <optional>
THREE.Scene. Define scene if you want visualise n-dimensional plane and n-dimensional object to 3-D space of the scene.
options Options <optional>
See Options. Uses only if scene is defined.
onIntersection Event <optional>
Plane and object intersection event. The onIntersection function parameter is the (n-1)-dimensional geometry of the intersection if a collision occurred, or undefined if a collision did not occur.
isRaycaster Boolean <optional>
true false - Ignoring of the mouse over of the object event or accept of the event if isRaycaster is true or undefined.
Source:
See:

Extends

  • MyObject

Members

geometry

returns geometry of N-dimensional object. See settings.object.geometry parameter of ND.
	key geometry - get or set a geometry of nD object. See See settings.object.geometry parameter of ND.
	key D3 - Projection of nD object to 3D space for visualization.
		D3.points - Points of projection. See .setFromPoints of THREE.BufferGeometry.
		D3.indices - Indices of points of projection. See .setIndex of THREE.BufferGeometry.
		D3.color - color of projection.
Source:

vectorPlane

Returns N-dimensional vector of the plane that intersects nD object.
Source:

Methods

intersection(geometryIntersectionopt, iIntersectionsopt)

Parameters:
Name Type Attributes Default Description
geometryIntersection geometryIntersection <optional>
{ position: [], indices: [[]] } Arrays of vertices and indexes of the result of the intersection of the panel and the nD object. See settings.object.geometry of ND constructor for details.
Properties
Name Type Attributes Description
position array <optional>
Array of vertices of the result of the intersection. See settings.object.geometry.position of ND constructor for details.
indices array <optional>
Array of indices of vertices of the result of the intersection. See settings.object.geometry.indices of ND constructor for details.
iIntersections array <optional>
Array of indices that have been added to geometryIntersection.indices
Source:
Returns:
an array of intersection points of vectorPlane and geometry. See constructor for details.