Space Materials & Environmental Textures
Control the visual atmosphere and environmental materials within your virtual spaces. These functions help create immersive environments by managing textures, lighting effects, and surface properties of space elements.
getMaterials
getMaterials(callback: Function)
Returns the list of all materials used in the virtual space environment. Use this to understand and modify the visual atmosphere of your space.
Virtual Environment Example:
// Get all materials in a virtual showroom space
api.getMaterials(function(materials){
console.log('Space environment materials:', materials);
// Use this to create dynamic environmental changes
});
2
3
4
5
setMaterial
setMaterial(material: object, callback: Function)
Updates a material by its material id. Get the materials from the getMaterials list.
api.getMaterials(function(materials) {
var mat = materials[0];
// Disable materials diffuse texture
mat.channels.diffuseColor.enabled = false;
console.log(mat);
api.setMaterial(mat, function() {
console.log('Material updated');
});
});
2
3
4
5
6
7
8
9
setMaterialAnimationSpeed
setMaterialAnimationSpeed(materialId: string, speed: number, [callback: Function])
Updates a material animation speed by its material id. Get the materials from the getMaterials list.
api.setMaterialAnimationSpeed('materialId', 2, function() {
console.log('Animation speed updated');
})
2
3
removeMaterial
removeMaterial(materialId: string, [callback: Function])
Removes material by id. Get the materials from the getMaterials list.
api.getMaterials(function(materials) {
var mat = materials[0];
api.removeMaterial(mat.id, function() {
console.log('Material removed');
});
});
2
3
4
5
6
7
removeMaterialChannel
removeMaterialChannel(materialId: string, channel: string, [callback: Function])
Remove material channel (only for textures). Get the materials from the getMaterials list.
api.removeMaterialChannel('material_id', 'albedoTexture', function() {
console.log('Channel removed');
});
2
3
updateMaterialChannel
updateMaterialChannel(materialId: string, channel: string, textureId: string, [callback: Function])
Update material channel texture. Get the materials from the getMaterials list. Get the textures from the getTextures list.
api.updateMaterialChannel('material_id', 'albedoTexture', 'texture_id', function() {
console.log('Channel updated');
});
2
3
getTextures
getTextures(callback: Function)
Returns the list of textures in the scene (includes textureId's).
api.getTextures(function(textures){
console.log(textures);
});
2
3
addTexture
addTexture(url: string, callback: Function)
Add a new texture to the textures in the scene. The response includes the textureId.
Hint: The url is a CORS-enabled image file. The file format must be natively supported by the web browser.
api.addTexture('https://www.rooom.com/texture.png', function(textureId){
console.log('New texture added with ID: ', textureId);
});
2
3
addVideoTexture
addVideoTexture(url: string, options: object, callback: Function)
Add a new video texture to the textures in the scene. The response includes the textureId.
The options
parameter:
loop
(boolean) will make the video loop.mute
(boolean) will play the video with audio muted. This is useful to avoid blocking autoplay in browsers.
Hint: The url is a CORS-enabled image file. The file format must be natively supported by the web browser.
api.addVideoTexture('https://www.rooom.com/texture.mp4', {loop: true, mute: true}, function(textureId){
console.log('New video texture added with ID: ', textureId);
});
2
3
updateTexture
updateTexture(textureId: string, url: string, callback: Function)
Update an existing texture in the scene. Get the textures from the getTextures list.
Hint: The url is a CORS-enabled image file. The file format must be natively supported by the web browser.
api.updateTexture('1234567890', 'https://www.rooom.com/texture.png', function(textureId){
console.log('Replaced texture with ID: ', textureId);
});
2
3
updateVideoTexture
updateVideoTexture(textureId: string, url: string, options: object, callback: Function)
Update an existing video texture in the scene. Get the textures from the getTextures list.
The options
parameter:
loop
(boolean) will make the video loop.mute
(boolean) will play the video with audio muted. This is useful to avoid blocking autoplay in browsers.
Hint: The url is a CORS-enabled image file. The file format must be natively supported by the web browser.
api.updateVideoTexture('1234567890', 'https://www.rooom.com/texture.mp4', {loop: true, mute: true}, function(textureId){
console.log('Replaced video texture with ID: ', textureId);
});
2
3
Material channels
The following material channels are available:
- diffuseTexture
- diffuseColor
- albedoTexture
- albedoColor
- bumpTexture
- emissiveTexture
- reflectionTexture
- lightmapTexture
- ambientTexture
- ambientColor
- emissiveColor
They can be edited as JSON objects using the setMaterial function. Their exact attributes depend on the specific channel and texture options.