Global

Members

(constant) Earcut

Port from https://github.com/mapbox/earcut (v2.2.4)
Source:

(constant) REVISION

License:
  • Copyright 2010-2022 Three.js Authors SPDX-License-Identifier: MIT
Source:

(constant) STEP :number

The step value used in calculations.
Type:
  • number
Source:

(constant) UniformsLib

Uniforms library for shared webgl shaders
Source:

(constant) camera :PerspectiveCamera

Represents the camera used in the scene.
Type:
Source:

(constant) camera :PerspectiveCamera

Represents a camera in the 3D scene.
Type:
Source:

(constant) emptyTexture

Uniforms of a program. Those form a tree structure with a special top-level container for the root, which you get by calling 'new WebGLUniforms( gl, program )'. Properties of inner nodes including the top-level container: .seq - array of nested uniforms .map - nested uniforms by name Methods of all nodes except the top-level container: .setValue( gl, value, [textures] ) uploads a uniform value(s) the 'textures' parameter is needed for sampler uniforms Static methods of the top-level container (textures factorizations): .upload( gl, seq, values, textures ) sets uniforms in 'seq' to 'values[id].value' .seqWithValue( seq, values ) : filteredSeq filters 'seq' entries with corresponding entry in values Methods of the top-level container (textures factorizations): .setValue( gl, name, value, textures ) sets uniform with name 'name' to 'value' .setOptional( gl, obj, prop ) like .set for an optional property of the object
Source:

(constant) globalLight :AmbientLight

Represents the global light in the scene.
Type:
  • AmbientLight
Source:

(constant) helper :PointLightHelper

Represents a helper for a point light.
Type:
  • PointLightHelper
Source:

(constant) light :PointLight

Represents a light source in the scene.
Type:
  • PointLight
Source:

(constant) renderer :WebGLRenderer

The WebGL renderer used for rendering the scene.
Type:
  • WebGLRenderer
Source:

shapeStore :Object

Object that stores shapes with their corresponding keys.
Type:
  • Object
Source:

shape_cols :Object.<string, number>

Object representing the shape columns.
Type:
  • Object.<string, number>
Source:

(constant) shape_obj :ShapeObject

The shape object.
Type:
Source:

(constant) shape_placed_obj :Object.<string, number>

Object representing the placement of shapes.
Type:
  • Object.<string, number>
Source:

(constant) sol_scene :Scene

Represents the sol_scene object.
Type:
  • Scene
Source:

sol_worker :Pyramid

Represents a sol_worker object.
Type:
Source:

worker :Pyramid

Represents a worker object.
Type:
Source:

Methods

CatmullRom()

Bezier Curves formulas obtained from https://en.wikipedia.org/wiki/B%C3%A9zier_curve
Source:

add(obj)

Adds an object to the scene.
Parameters:
Name Type Description
obj Object The object to be added to the scene.
Source:

add(obj)

Adds an object to the SolScene.
Parameters:
Name Type Description
obj object The object to add.
Source:

add_row_for_diags_if_valid(problem_mat, shape, size) → {boolean}

Adds rows to the problem matrix if the shape's layout is valid.
Parameters:
Name Type Description
problem_mat Array.<Array.<number>> The problem matrix.
shape Object The shape object.
size number The size of the shape.
Source:
Returns:
- True if rows were added, false otherwise.
Type
boolean

add_rows_for_shape_in_horizontal_and_vertical_slices(prob_mat, shape) → {Array.<Array.<number>>}

Adds rows for a given shape in horizontal and vertical slices to the problem matrix.
Parameters:
Name Type Description
prob_mat Array.<Array.<number>> The problem matrix to add rows to.
shape Shape The shape to add rows for.
Source:
Returns:
- The updated problem matrix.
Type
Array.<Array.<number>>

calculatePosition(layer, radius, x, y, maxLayer) → {Array.<number>}

Calculates the position of a point in 3D space based on the given parameters.
Parameters:
Name Type Description
layer number The layer of the point.
radius number The radius of the sphere.
x number The x-coordinate of the point.
y number The y-coordinate of the point.
maxLayer number The maximum layer of the sphere.
Source:
Returns:
The calculated position as an array [x, y, z].
Type
Array.<number>

checkInput(shapes, coords) → {boolean}

Checks if the number of spheres for each shape matches the number of coordinates provided.
Parameters:
Name Type Description
shapes Array.<string> An array of shape names.
coords Array.<Array.<number>> An array of coordinate arrays, where each array represents the coordinates for a shape.
Source:
Returns:
- Returns true if the number of spheres for each shape matches the number of coordinates, otherwise false.
Type
boolean

cloneUniforms()

Uniform Utilities
Source:

componentDidMount()

Initializes the component and sets up the scene and pyramid rendering.
Source:

componentWillUnmount()

Cleans up resources before the component is unmounted.
Source:

convert_rect_coords_to_diags(shape_layout, size) → {Array.<Array.<number>>}

Converts rectangular coordinates to diagonal coordinates based on the shape layout and size.
Parameters:
Name Type Description
shape_layout Array.<Array.<number>> The layout of the shape in rectangular coordinates.
size number The size of the shape.
Source:
Returns:
- The converted diagonal coordinates.
Type
Array.<Array.<number>>

convert_to_pyramid_layers(solution, problem_matrix, mat_header, start_shapes, start_squares) → {Array.<Array.<Array.<number>>>}

Converts a solution format to a pyramid layers format.
Parameters:
Name Type Description
solution Array.<number> The solution format to convert.
problem_matrix Array.<Array.<number>> The problem matrix.
mat_header Array.<string> The matrix header.
start_shapes Array.<string> The starting shapes.
start_squares Array.<Array.<Array.<number>>> The starting squares.
Source:
Returns:
The converted pyramid layers format.
Type
Array.<Array.<Array.<number>>>

coord_to_col(coord) → {number}

Converts a 3D coordinate to a column index in the problem matrix.
Parameters:
Name Type Description
coord Array.<number> The 3D coordinate [x, y, z].
Source:
Returns:
- The column index in the problem matrix.
Type
number

cover(X, Y, r) → {Array}

Removes redundant elements from the input set and returns the remaining elements as an array.
Parameters:
Name Type Description
X Object The input set represented as an object.
Y Array The input set represented as an array.
r number The index of the element to be covered.
Source:
Returns:
- The remaining elements after removing redundancies.
Type
Array

createSphere(x, y, z, color, radius, segs) → {Mesh}

Creates a sphere object with the specified position, color, radius, and number of segments.
Parameters:
Name Type Description
x number The x-coordinate of the sphere's position.
y number The y-coordinate of the sphere's position.
z number The z-coordinate of the sphere's position.
color string The color of the sphere.
radius number The radius of the sphere.
segs number The number of segments used to create the sphere.
Source:
Returns:
The created sphere object.
Type
Mesh

createSphere(x, y, z, color, radiusopt, segsopt) → {Object}

Creates a sphere and adds it to the scene.
Parameters:
Name Type Attributes Default Description
x number The x-coordinate of the sphere.
y number The y-coordinate of the sphere.
z number The z-coordinate of the sphere.
color string The color of the sphere.
radius number <optional>
1 The radius of the sphere.
segs number <optional>
15 The number of segments of the sphere.
Source:
Returns:
The created sphere object.
Type
Object

createSphere(x, y, z, color, radius, segs) → {Mesh}

Creates a sphere with the specified position, color, radius, and number of segments.
Parameters:
Name Type Description
x number The x-coordinate of the sphere's position.
y number The y-coordinate of the sphere's position.
z number The z-coordinate of the sphere's position.
color string The color of the sphere.
radius number The radius of the sphere.
segs number The number of segments used to create the sphere.
Source:
Returns:
The created sphere mesh.
Type
Mesh

createSphere(x, y, z, color, radiusopt, segsopt) → {object}

Creates a sphere object.
Parameters:
Name Type Attributes Default Description
x number The x-coordinate of the sphere.
y number The y-coordinate of the sphere.
z number The z-coordinate of the sphere.
color string The color of the sphere.
radius number <optional>
1 The radius of the sphere.
segs number <optional>
15 The number of segments of the sphere.
Source:
Returns:
The created sphere object.
Type
object

createState() → {Object}

Creates a new state object.
Source:
Returns:
The newly created state object.
Type
Object

createTimer(func)

Creates a timer that repeatedly calls the specified function at a given frame rate.
Parameters:
Name Type Description
func function The function to be called repeatedly by the timer.
Source:

create_dicts(problem_matrix_reduced, headers_reduced) → {Array.<Object>}

Creates dictionaries X and Y based on the given problem matrix and headers.
Parameters:
Name Type Description
problem_matrix_reduced Array.<Array.<boolean>> The reduced problem matrix.
headers_reduced Array.<string> The reduced headers.
Source:
Returns:
- An array containing the dictionaries X and Y.
Type
Array.<Object>

dispose()

Disposes the scene and cleans up resources.
Source:

dispose()

Disposes the SolScene.
Source:

disposeSphere(instance)

Removes a sphere instance from the scene and disposes its material and geometry.
Parameters:
Name Type Description
instance Object3D The sphere instance to dispose.
Source:

disposeSphere(sphere)

Disposes a sphere from the scene.
Parameters:
Name Type Description
sphere Object The sphere object to be disposed.
Source:

disposeSphere(sphere)

Disposes a sphere object.
Parameters:
Name Type Description
sphere object The sphere object to dispose.
Source:

dlx(items, sets) → {Array}

Solves the exact cover problem using the Dancing Links algorithm.
Parameters:
Name Type Description
items Object The items to be covered.
sets Object The sets of items.
Source:
Returns:
- The solution to the exact cover problem.
Type
Array

drawPosition(position)

Draws the position on the pyramid.
Parameters:
Name Type Description
position Array.<Array.<Array.<string>>> The position to be drawn.
Source:

generate_headers() → {Array}

Generates headers for a dictionary of objects.
Source:
Returns:
An array of headers.
Type
Array

generate_headers() → {Array.<string>}

Generates headers for a matrix based on shape names and coordinates.
Source:
Returns:
An array of headers.
Type
Array.<string>

get_diag_slices() → {Array.<Array.<Array.<Array.<number>>>>}

Retrieves the diagonal slices from the horizontal slices.
Source:
Returns:
The diagonal slices.
Type
Array.<Array.<Array.<Array.<number>>>>

get_horizontal_slices() → {Array.<Array.<number>>}

Generates the horizontal slices for a polyhedron.
Source:
Returns:
The horizontal slices of the polyhedron.
Type
Array.<Array.<number>>

init(dom)

Initializes the scene with the provided DOM element.
Parameters:
Name Type Description
dom HTMLElement The DOM element to initialize the scene with.
Source:

initScene(sol_canvas)

Initializes the scene with the given canvas element.
Parameters:
Name Type Description
sol_canvas HTMLCanvasElement The canvas element to render the scene on.
Source:

initialiseScene(canvas)

Initializes the scene with the given canvas.
Parameters:
Name Type Description
canvas HTMLCanvasElement The canvas element to render the scene on.
Source:

layerVisible(idx, v)

Updates the visibility of a layer and its spheres.
Parameters:
Name Type Description
idx number The index of the layer.
v boolean The new visibility state.
Source:

onClearButton()

Clears the UI and resets the state.
Source:

onNextButton()

Handles the click event of the next button. Pops a solution from the state's solutions array and calls sol_drawPosition to draw it.
Source:

onPrevButton()

Handles the click event of the "Prev" button.
Source:

onSolveButton()

Handles the event when the solve button is clicked.
Source:

onStopButton()

Stops the execution and clears the interval timer.
Source:

populate_problem_matrix3D() → {Array}

Populates a problem matrix for 3D shapes.
Source:
Returns:
The problem matrix.
Type
Array

reduce_problem_matrix(problem_matrix, problem_headers, shapes_used, squares_used) → {Array.<Array.<number>>}

Reduces the problem matrix by removing rows and columns based on the shapes and squares used.
Parameters:
Name Type Description
problem_matrix Array.<Array.<number>> The problem matrix to be reduced.
problem_headers Array.<string> The headers of the problem matrix.
shapes_used Array.<string> The shapes used in the problem.
squares_used Array.<Array.<string>> The squares used in the problem.
Source:
Returns:
- The reduced problem matrix.
Type
Array.<Array.<number>>

renderPyramid()

Renders the pyramid by iterating through the layers of spheres and updating their positions and colors.
Source:

resetShapeObj()

Resets the shape object by updating the shape_obj and shape_placed_obj properties.
Source:

shape_to_row(shape) → {Array}

Converts a shape object to a row in the problem matrix.
Parameters:
Name Type Description
shape Object The shape object to convert.
Source:
Returns:
- The row representing the shape in the problem matrix.
Type
Array

sol_drawPosition(position) → {void}

Draws the position on the solution pyramid.
Parameters:
Name Type Description
position Array.<Array.<Array.<string>>> The position to be drawn on the pyramid.
Source:
Returns:
Type
void

sol_init(dom)

Initializes the SolScene.
Parameters:
Name Type Description
dom object The DOM element to attach the scene to.
Source:

sol_layerVisible(idx, v)

Updates the visibility of a layer in the solution pyramid object.
Parameters:
Name Type Description
idx number The index of the layer.
v boolean The new visibility state of the layer.
Source:

sol_renderPyramid()

Renders the solution pyramid by updating the positions and colors of the spheres in the scene.
Source:

(generator) solve(X, Y, solutionopt) → {Array}

Solves the given problem using a Dancing Link algorithm.
Parameters:
Name Type Attributes Default Description
X Object The input object containing the problem data.
Y Object The input object containing the problem constraints.
solution Array <optional>
[] The current solution being built.
Source:
Yields:
- The next valid solution found.
Type
Array

uncover(X, Y, r, cols)

Uncover function assigns colors to the vertices of a graph in a specific order. It starts from the last row and assigns colors to the vertices in reverse order. For each vertex, it assigns a color and updates the adjacent vertices' colors.
Parameters:
Name Type Description
X Array.<Set.<number>> An array of sets representing the vertices and their assigned colors.
Y Array.<Array.<number>> An array of arrays representing the adjacency list of the graph.
r number The index of the row to start uncovering from.
cols Array.<any> An array of colors to assign to the vertices.
Source:

Type Definitions

Colours

Object representing the colours used in the scene.
Type:
  • Object
Properties:
Name Type Description
A number The hexadecimal value of colour A.
B number The hexadecimal value of colour B.
C number The hexadecimal value of colour C.
D number The hexadecimal value of colour D.
E number The hexadecimal value of colour E.
F number The hexadecimal value of colour F.
G number The hexadecimal value of colour G.
H number The hexadecimal value of colour H.
I number The hexadecimal value of colour I.
J number The hexadecimal value of colour J.
K number The hexadecimal value of colour K.
L number The hexadecimal value of colour L.
Source:

ShapeObject

Represents a number of spheres in a shape object.
Type:
  • Object
Properties:
Name Type Description
A number The number of spheres in A.
B number The number of spheres in B.
C number The number of spheres in C.
D number The number of spheres in D.
E number The number of spheres in E.
F number The number of spheres in F.
G number The number of spheres in G.
H number The number of spheres in H.
I number The number of spheres in I.
J number The number of spheres in J.
K number The number of spheres in K.
L number The number of spheres in L.
Source:

inputShapes

Represents a collection of input shapes.
Type:
  • Object
Properties:
Name Type Description
get function Retrieves the input shapes.
add function Adds a shape to the collection.
clear function Clears the collection of input shapes.
store Array The array that stores the input shapes.
Source:

sol_Colours

Object representing the colours used in the sol scene.
Type:
  • Object
Properties:
Name Type Description
A number Colour A represented as hexadecimal value.
B number Colour B represented as hexadecimal value.
C number Colour C represented as hexadecimal value.
D number Colour D represented as hexadecimal value.
E number Colour E represented as hexadecimal value.
F number Colour F represented as hexadecimal value.
G number Colour G represented as hexadecimal value.
H number Colour H represented as hexadecimal value.
I number Colour I represented as hexadecimal value.
J number Colour J represented as hexadecimal value.
K number Colour K represented as hexadecimal value.
L number Colour L represented as hexadecimal value.
Source:

sol_inputShapes

Represents the input shapes for the sol scene.
Type:
  • Object
Properties:
Name Type Description
get function Retrieves the input shapes.
add function Adds a shape to the input shapes.
clear function Clears the input shapes.
store Array The array that stores the input shapes.
Source: