question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Set different materials on cube's different side?

See original GitHub issue

In chrome console it says that material as an array has been deprecated. I want to apply different material to cube’s different side.

//convert from SVG
var imageCanvas = document.createElement("canvas");
canvg(imageCanvas, image.svg);

var texture = new THREE.Texture(imageCanvas);
texture.needsUpdate = true;

var geometry = new THREE.CubeGeometry(200, 10, 200);
var cubeMaterial = new THREE.MeshBasicMaterial({
    map : texture
});

var cube = new THREE.Mesh(geometry, cubeMaterial);

Like this, all 6 cube’s sides have that picture as material. I would like to apply that picture material to only 2 sides an on the rest 4 I would like to put a color. How can I do that?

And also, is there any other place between this issues list, API Docs and those examples here on GitHub where I can lear Three.js?

Issue Analytics

  • State:closed
  • Created 12 years ago
  • Reactions:1
  • Comments:8 (4 by maintainers)

github_iconTop GitHub Comments

7reactions
mrienstracommented, Feb 15, 2012

Hi Dino4674,

This issue / solution might be what you are looking for: #744

This worked for me:

var materials = [
    leftSide,        // Left side
    rightSide,       // Right side
    topSide,         // Top side
    bottomSide,      // Bottom side
    frontSide,       // Front side
    backSide         // Back side
];
var geometry = new THREE.CubeGeometry(100, 75, 8, 1, 1, 1, materials);
var someMesh = new THREE.Mesh(geometry, new THREE.MeshFaceMaterial());
0reactions
Dino4674commented, Feb 15, 2012

It looks like you were right after all.

I your say

cube.lookAt(camera.position)

you can see exactly which one is the front.

So the answer is that Three looks on Y as height and Z as depth.

Read more comments on GitHub >

github_iconTop Results From Across the Web

how to apply a texture on one side of a cube in Unity - YouTube
Transcript · The Ultimate BEGINNERS GUIDE to Materials in Unity · LIGHTING in Unity · Tutorial: Blender MODELLING For Absolute Beginners | Low...
Read more >
Can anyone help? i need a different texture on each side of a ...
If you're using a static mesh cube, you can't apply different textures to it. If you want to do it in UE, go...
Read more >
Different Texture on each side of Cube - Unity Forum
You need a cube (created in a 3D app) where each face is a submesh, and has a different material. Or you can...
Read more >
Different Material/Texture to each side of a cube?
Solved: Simple question, how do I apply a material to one side of a cube? Thanks.
Read more >
Applying a different color/texture/material to each side of a cube
The initial material assignment will affect the whole cube. Make sure when you select the select the second face, make a new material...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found