How to use the MeshBasicMaterial function from three

Find comprehensive JavaScript three.MeshBasicMaterial code examples handpicked from public code repositorys.

Three.MeshBasicMaterial is a class in Three.js library that creates a basic material for rendering mesh objects.

154
155
156
157
158
159
160
161
162
    heads.computeBoundingBox();

    object.add(
        new THREE.Mesh(
            heads,
            new THREE.MeshBasicMaterial({vertexColors: THREE.VertexColors}),
        ),
    );
}
fork icon117
star icon808
watch icon24

+ 11 other calls in file

1293
1294
1295
1296
1297
1298
1299
1300
1301
1302
1303
MapMartiniHeightNode.geometry = new MapNodeGeometry(1, 1, 1, 1);
MapMartiniHeightNode.tileSize = 256;


class MapView extends three.Mesh {
    constructor(root = MapView.PLANAR, provider = new OpenStreetMapsProvider(), heightProvider = null) {
        super(undefined, new three.MeshBasicMaterial({ transparent: true, opacity: 0.0 }));
        this.lod = null;
        this.provider = null;
        this.heightProvider = null;
        this.root = null;
fork icon75
star icon468
watch icon0

+ 5 other calls in file

How does three.MeshBasicMaterial work?

The three.MeshBasicMaterial class in the Three.js library creates a basic material for rendering a mesh by defining its color, opacity, and wireframe properties among others. It is a simple material that does not respond to light sources and can be used for creating unlit surfaces. When rendering, each pixel of the mesh is drawn with the specified color, irrespective of the lighting or shading of the scene. The material is suitable for creating simple 3D models, wireframes, and particle systems, among others.

36
37
38
39
40
41
42
43
44
45
46
    }
  }


  const geometry = new THREE.BoxGeometry(entity.width, entity.height, entity.width)
  geometry.translate(0, entity.height / 2, 0)
  const material = new THREE.MeshBasicMaterial({ color: 0xff00ff })
  const cube = new THREE.Mesh(geometry, material)
  return cube
}

fork icon57
star icon163
watch icon0

+ 3 other calls in file

270
271
272
273
274
275
276
277
278
279
var wd=this.internal.imagespa[0] * 4;


if (!this.internal.simplemode) {
    this.internal.origin=new THREE.Mesh(bisCrossHair.createcrosshair(wd,this.internal.imagespa[0],false), 
                              new THREE.MeshBasicMaterial( {color: 0xffffff, wireframe:false}));
    subviewer.getScene().add(this.internal.origin);
}

return subviewer;
fork icon31
star icon74
watch icon16

+ 38 other calls in file

Ai Example

1
2
3
4
5
6
7
8
9
10
11
// Create a geometry
const geometry = new THREE.BoxGeometry(1, 1, 1);

// Create a material with red color
const material = new THREE.MeshBasicMaterial({ color: 0xff0000 });

// Create a mesh with geometry and material
const mesh = new THREE.Mesh(geometry, material);

// Add mesh to the scene
scene.add(mesh);

This example creates a red cube using BoxGeometry and MeshBasicMaterial and adds it to the scene.

155
156
157
158
159
160
161
162
163

// R1 lights
var fontLoader = new THREE.FontLoader();

const materials = [
    new THREE.MeshBasicMaterial( { color: 0x00ff00 } )
];

fontLoader.load( '/static/roboto_regular.json', function ( font ) {
fork icon26
star icon28
watch icon0

+ 2 other calls in file

35
36
37
38
39
40
41
42
43
    size: options.legendSize,
    height: textGeometryHeight,
    curveSegments: textCurveSegments,
});

var material = new THREE.MeshBasicMaterial({
    color: options.legendColor,
    transparent: true,
});
fork icon17
star icon119
watch icon21

+ 3 other calls in file

588
589
590
591
592
593
594
595
596

if (!texture.data) return;

textures[material.map.id] = texture;

if (material instanceof THREE.MeshBasicMaterial
  || material instanceof THREE.SpriteMaterial) {

  shader = basicMaterialShader;
fork icon15
star icon55
watch icon0

788
789
790
791
792
793
794
795
796
797
	side: THREE.DoubleSide
});
var g = new THREE.PlaneGeometry(w / 4, h / 4);
var m = new THREE.Mesh(g, mat);

var matbg = new THREE.MeshBasicMaterial({
	color: 0xffffff,
	side: THREE.DoubleSide
});
var gbg = new THREE.PlaneGeometry(w / 4, h / 4);
fork icon13
star icon110
watch icon0

+ 3 other calls in file

18
19
20
21
22
23
24
25
26
27
self.mesh.receiveShadow = false;
//
var materials = [

  new THREE.MeshLambertMaterial({ color: 0x90A075 }),
  new THREE.MeshBasicMaterial({ color: 0xffffff})

];
self.mesh.material = new THREE.MultiMaterial(materials);
self.mesh.material.materials[0].skinning = true;
fork icon10
star icon33
watch icon0

2080
2081
2082
2083
2084
2085
2086
2087
2088
2089
  }
}

if (
  materialDef.normalTexture !== undefined &&
  materialType !== THREE.MeshBasicMaterial
) {
  pending.push(
    parser.assignTexture(
      materialParams,
fork icon3
star icon7
watch icon8

+ 74 other calls in file

62
63
64
65
66
67
68
69
70
71
    if (options.glslVersion) {
      material.glslVersion = options.glslVersion;
    }
  }
} else {
  material = new THREE.MeshBasicMaterial({
    color : new THREE.Color(1, 1, 1),
    transparent : false,
    opacity : 1.0,
    map : this.impl,
fork icon10
star icon3
watch icon3

+ 7 other calls in file

120
121
122
123
124
125
126
127
128

// Empty array to be populated with meshes
this.meshes = []

// Defining a single material for all the polyhedra
const mat = new THREE.MeshBasicMaterial(
  { wireframe: true, color: 0xffffff }
)
const size = 300
fork icon21
star icon0
watch icon1

42
43
44
45
46
47
48
49
50
51
this.renderer = params.renderer;
this.camera = camera;
this.scene = scene;
var plane = new THREE.Mesh(
  new THREE.PlaneGeometry(1, 1, 1, 1), 
  new THREE.MeshBasicMaterial({
    transparent: true,
    opacity: 0.05,
    color: new THREE.Color(0.5, 0.5, 0.5),
    side: THREE.DoubleSide
fork icon4
star icon25
watch icon2

+ 7 other calls in file

470
471
472
473
474
475
476
477
478
    */



    //const geometry = new THREE.CylinderGeometry( 1, 1, 20, 32 );
    //const material = new THREE.MeshBasicMaterial( {color: 0xffff00} );
    //const cylinder = new THREE.Mesh( geometry, material );
    //scene.add( cylinder );
}
fork icon3
star icon7
watch icon0

+ 3 other calls in file

95
96
97
98
99
100
101
102
103
//let aCurveFloat32 = new Float32Array(this.pos.buffer); //, 3);

//geometry.setAttribute( 'position', new THREE.Float32BufferAttribute( positions, 3 ) );

const plane_1_geometry = new THREE.PlaneGeometry( 1, 1 );
const plane_1_material = new THREE.MeshBasicMaterial( {color: 0xffff00, side: THREE.DoubleSide} );
let plane_1_mesh = new THREE.Mesh( plane_1_geometry, plane_1_material );

this.scene.add(plane_1_mesh);
fork icon3
star icon7
watch icon0

+ 2 other calls in file

34
35
36
37
38
39
40
41
42
43
this.avgSpeed = 0;
this.totalDistance = 0;
const c = 0xffffff;
this.lineMaterial = new THREE.LineBasicMaterial({ transparent: true, color: c, linewidth: 2.0 });
this.sphereMaterial = new THREE.MeshBasicMaterial({ transparent: true, color: c, opacity: 0.0 });
this.animatingSphereMaterial = new THREE.MeshBasicMaterial({ transparent: true, color: c, opacity: 1.0 });
this.facesMaterial = new THREE.MeshBasicMaterial({ color: 0xffffff, transparent: true, opacity: 0.0, side: THREE.DoubleSide });
this.lineSegmentMaterial = new THREE.LineBasicMaterial({ transparent: true, color: 0xaaaaaa, opacity: 0.0, linewidth: 1.0 });
this.lastPosition = new THREE.Vector3(0, 0, 0);
this.spheres = [];
fork icon2
star icon6
watch icon6

+ 5 other calls in file

97
98
99
100
101
102
103
104
105
106
switch (randomInt) {
  case 0: 
    return new THREE.MeshBasicMaterial( {color: getRandomColor()} );
    break;
  case 1: 
    return new THREE.MeshBasicMaterial( {color: getRandomColor(), wireframe: true} );
    break;
  case 2:
    return new THREE.MeshNormalMaterial();
    break;
fork icon14
star icon4
watch icon0

+ 11 other calls in file

1373
1374
1375
1376
1377
1378
1379
1380
1381
1382
1383
1384
1385
const TransformControlsPlane = function () {




    THREE.Mesh.call( this,
        new THREE.PlaneBufferGeometry( 100000, 100000, 2, 2 ),
        new THREE.MeshBasicMaterial( { visible: false, wireframe: true, side: THREE.DoubleSide, transparent: true, opacity: 0.1 } )
    );


    this.type = 'TransformControlsPlane';

fork icon4
star icon26
watch icon0

259
260
261
262
263
264
265
266
267
268
269
270




function computeLayerTriangles(show) {
    timer = new Timer()
    let obj = mainObj
    let mat = new THREE.MeshBasicMaterial({
        color: 0x0000ff,
        wireframe: true,
        transparent: true,
        opacity: 0.2,
fork icon2
star icon14
watch icon0

+ 8 other calls in file

73
74
75
76
77
78
79
80
81
82
        changeSpeed: function(skip, speed) {
                params.speed = speed;
        }
}

var crystalMaterial = new THREE.MeshBasicMaterial({
        wireframe: true,
        transparent: true,
        opacity: params.opacity
});
fork icon0
star icon4
watch icon2

Other functions in three

Sorted by popularity

function icon

three.Vector3 is the most popular function in three (22341 examples)