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.
Highlight Functions
getHighlight
getHighlight(nodeId: string, [callback: Function])
Returns the highlight settings for a specific node. The nodeId
is the ID of the node, which can be found via getNodeList.
api.getHighlight(nodeId, function(highlight){
console.log('Highlight settings:', highlight);
});
2
3
setHighlight
setHighlight(nodeId: string, options: object, [callback: Function])
Sets highlight effects for a specific node to make it stand out visually. The nodeId
is the ID of the node, which can be found via getNodeList.
api.setHighlight(nodeId, {
color: [1, 0, 0], // Red highlight
intensity: 0.8
}, function(){
console.log('Highlight applied');
});
2
3
4
5
6
setScale
setScale(nodeId: string, scale: [x: number, y: number, z: number], [callback: Function])
Sets the scaling values for a node in X, Y, and Z dimensions. The nodeId
is the ID of the node, which can be found via getNodeList.
api.setScale(nodeId, [2.0, 1.5, 1.0], function(newScale){
console.log('New scale values:', newScale);
});
2
3
getScale
getScale(nodeId: string, [callback: Function])
Returns the current scaling values of a node. The nodeId
is the ID of the node, which can be found via getNodeList.
api.getScale(nodeId, function(scale){
console.log('Current scale:', scale); // [x, y, z]
});
2
3
Advanced Material Functions
setMaterialAnimationSpeed
setMaterialAnimationSpeed(materialId: string, speed: number, [callback: Function])
Sets the animation speed factor for animated materials. Get the materialId from the getMaterials list.
api.setMaterialAnimationSpeed('material_123', 2.0, function(){
console.log('Material animation speed doubled');
});
2
3
removeMaterial
removeMaterial(materialId: string, [callback: Function])
Removes a material from the scene. Get the materialId from the getMaterials list.
api.removeMaterial('material_123', function(){
console.log('Material removed from scene');
});
2
3
removeMaterialChannel
removeMaterialChannel(materialId: string, channel: string, [callback: Function])
Removes a specific texture channel from a material. Available channels: 'albedoTexture', 'diffuseTexture', 'bumpTexture', 'emissiveTexture', 'reflectionTexture', 'lightmapTexture', 'ambientTexture'.
api.removeMaterialChannel('material_123', 'albedoTexture', function(){
console.log('Texture channel removed');
});
2
3