Space System
Defining the layout
The space system defines the Form object, which is data that defines the layout of the virtual space.
Before specifying how layouts are represented, we first need to define what it means to "place" something in a virtual space. The standard then defines how data is related to the virtual space. In other words, it standardizes how the virtual space is reconstructed from the data.
A virtual space is modeled as a three-dimensional space (right-handed ), with one distinguished "up" direction that determines the ground plane.
The ground plane is defined as the plane passing through the origin and orthogonal to the "up" direction.
We then choose an orthonormal basis of the space such that two of its elements lie on this plane.
so that any location on the ground can be expressed by a two-dimensional coordinate ,
which we refer to as a Position.
Any location in the space can be expressed by a three-dimensional coordinate .
The third coordinate, called height, measures vertical displacement relative to the ground plane.
Together, a Position and a height determine any point in the virtual space.
From this basis, we can now define the layout structure through a Form object.
Specification
Form: The layout
A Form object has following data:
where
versionis required for version control, allowing implementations to maintain backward compatibility.layoutis required, and its data is an array ofEmbedding, representing placed artifacts in the space.layoutModeis recommended. It specifies which layout mode is used. If not provided, the freeform layout mode is used as the default.metadatais optional. It is used to hold any additional data about the scene.
Embedding: Placed artifact
An Embedding represents a placed artifact, it has following data:
where
artifactis required, and itstypemust bemodel; it is theArtifactthat is placed at theposition. The local origin of theArtifactis used for the alignment.positionis required; it defines where the artifact is placed.rotationis required; it defines the rotation of the artifact around the up direction.heightis optional for the discrete and continuous layout mode (and will be ignored if provided), but required for the freeform layout mode.stackIndexis required for the discrete and continuous layout mode, but optional for the freeform layout mode (and will be ignored if provided). AllEmbeddingin thelayoutmust have distinctstackIndex.
volume.width corresponds to the direction before rotation. We are now ready to explain the three layout modes:
The discrete layout mode
The discrete layout mode requires position to be discrete, usually aligned with a lattice or cell-based coordinate logic.
The rotation must be only 0, 90, 180, or 270 degrees.
For all Embeddings, embedding.artifact.content is recommended to have its local origin at the lowest point of its mesh.
It also requires the layout to follow the stacking logic.
The coordinate in space is calculated by the stacking logic; thus, an explicitly provided height will be ignored.
The continuous layout mode
The continuous layout mode does not require position to be discrete.
The model stored in artifact is recommended to have its local origin at the lowest point of its mesh.
It requires the layout to follow the stacking logic.
The coordinate in space is calculated by the stacking logic; thus, an explicitly provided height will be ignored.
The freeform layout mode
The freeform layout mode does not require position to be discrete,
and the layout does not need to follow the stacking logic.
The height will be used as the coordinate; thus, the stackIndex will be ignored.
In practice, one can combine the position and height into coordinate:
which simply represents the space coordinate .
Euler angles module
If the freeform layout mode is used, one can also use the optional Euler angles module.
The Euler angles module replace the rotation by an EulerAngles
which describes the orientation of the artifact by Euler angles.
Block layout mode module
The block layout mode module is an optional extension applicable exclusively to the freeform layout mode.
In the block layout mode:
- It is recommended that all used
Artifacthasvolumemetadata and its dimensions (length,width,height) are either exactly 1 or an integer. If not specified, their dimensions will be taken to be 1. - It is required that each component of a
coordinate— that is, each of its three numbers — must individually be an integer. - The
rotationof eachEmbeddingmust be either 0, 90, 180, or 270 degrees. If the Euler Angles Module is used, then each component of theEulerAnglesmust also be either 0, 90, 180, or 270 degrees.
flat layout mode and platform layout mode module
The flat layout mode and platform layout mode are two-dimensional layout modes, providing a top-down perspective space or side-scrolling space.
flat layout mode and platform layout mode are for future plan.
Stacking Logic
In the discrete and continuous layout modes, the placement of artifacts must follow a stacking logic to ensure physical consistency. The stacking logic defines how artifacts are placed vertically on top of existing artifacts, ensuring physical consistency.
All Embeddings in a layout must have distinct stackIndex values.
It is recommended that all used Artifact has volume metadata. If not specified, their dimensions (length, width, height) will be taken to be 1.
The stacking logic has an optional even placement module with a threshold for evenness.
The stacking logic operates as follows:
- Order all
Embeddings inlayoutby theirstackIndex, in ascending order. - For each to-be-placed
Embedding: - Find all
Embeddings whose footprints overlap with the to-be-placedEmbedding's footprint. - For each found
Embedding, determine its top. For each point in the footprint, keep only theEmbeddingthat has the highest top at that point. - If using the even placement module, and the
evenPlacementproperty of the to-be-placedEmbedding'sArtifactis found and istrue:
- Calculate the difference between the highest top and the lowest top. If the difference exceeds the threshold, the layout is invalid.
- Check the
stackableproperty of all foundEmbeddings'Artifacts. If any of them isfalse, the layout is invalid.
- Otherwise, if even placement module is not used:
- Find the
Embeddingwith the highest top and check thestackableproperty of its associatedArtifact. If it isfalse, the layout is invalid.
- Place the
Artifactat the highest top. That is, the coordinate is set to the height of the highest top. - If no overlapping
Embeddingoccurs within the footprint, the currentEmbeddingis placed at height zero (the floor).
The "top" of an Embedding is defined as the sum of its coordinate and the volume.height of its corresponding Artifact.
In freeform layout mode, stacking logic is not applied. Height must be explicitly specified per Embedding.
Reconstruct layout
We now relate the layout to the space.
- Calculate the coordinate for each
Embeddingby either applying stacking logic to thelayoutif freeform layout mode is not used, or using theheightif freeform layout mode is used. - For each
Embeddingin thelayout:- Place the
contentmodel at the point in space corresponding to the coordinate defined by thepositionand the calculated coordinate.
- Place the
Tile module
In many use cases, a boundary is necessary to define for a virtual space. Optional tile module provides an explicit way of doing so.
where
tileListis required if the tile module is used. It is an array of two-dimensional coordinates oftiles.tileVisibilityis optional if the tile module is used. It defines the visibility of the floor. It is by default true.tileModelis optional iftileVisibilityisfalseand will be ignored; otherwise, it is required and must be a model typeArtifact.
A tile is a finite two-dimensional plane that serves as the floor of the space, with its local origin at the center of the plane.
A tileList is an array of ground coordinates where tiles will be placed to form the complete floor.
If a tileList is provided, all other artifacts' footprints must be contained within the tiles, otherwise, the layout is not valid.
We define the footprint of an Embedding as the projection of its bounding box (defined by the volume of its corresponding Artifact) onto the ground plane.
tile has fixed dimensions of 1 by 1 and it is forced to be placed on an integer lattice.Reconstruct floor
We now associate each tile with the space if tileVisibility is true:
For each Position element in the tileList, place tileModel at the corresponding coordinate, with the coordinate set to zero.
One example of cell-based coordinate logic
In discrete layout mode, it is often desirable to restrict placement onto a regular grid to simplify validation and user interaction. Here we provide an example of the cell-based coordinate logic.
The ground is divided into cells of size by . The cells are placed such that the origin of the space coincides with the corner points of nearby cells. Therefore,
- the center of a cell belongs to the set , known as the cell lattice,
- the corners (vertices) of the cells belong to the set , where denotes all integers and half-integers, known as the vertex lattice.
A valid placement of an Embedding must have its footprint’s corners exactly coinciding with some points in the vertex lattice.
This restricts the Artifact to have only values for volume.length and volume.width.
Moreover:
- If the
volume.lengthis an integer, then the coordinate in the length direction must lie in . - If the
volume.lengthis a half-integer, then the coordinate in the length direction must lie in . - The same rule applies to
volume.width.
Implementation hints
This section provides practical hints for implementing the space system.
Storage
In practice, Form is ideally stored on-chain as a digital asset.
When a user visits their space, the client fetches the digital asset
and reconstructs the scene of the space from it.
Therefore, the space system in practice simply introduces a new kind of digital asset; there is no additional development needed on-chain.
Invalid layout
In practice, invalid layout judgment happens per Embedding,
i.e., it occurs if the to-be-placed Embedding is either beyond the boundary
or cannot be placed according to the stacking logic.
Thus, the stacking logic can be thought of as placing Artifacts one by one,
where each placement may be valid or invalid.
For a smooth user experience, the client usually just skips invalid placements
by removing the invalid Embedding and continuing with the next Embedding in the layout list.
Other modules
Optional modules can be added so that the Form can define global properties of the space.
Global shader module
The global shader module provides a default shader for all objects in the space.
where shader must store an implementation of a shader,
for example, using GLSL.
In practice, shaders are often specified individually within each Artifact;
the global shader provides an optional fallback mechanism.
Global lighting module
The global lighting module provides a global lighting to the space.
where lighting must store a model.
It is recommended that the model contains only directional lights.
The model is placed at the space origin.
Global Scene module
Global scene module provides a global scene to the space.
where scene must store a model.
The model is placed at the space origin.
Global environment map module
Global environment map module provided a global environment map to the space.
where environment must store an environment map (also known as HDRIs), which will be applied to the space.