Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Binary file modified examples/screenshots/webgl_materials_blending.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified examples/screenshots/webgl_materials_blending_custom.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
27 changes: 7 additions & 20 deletions examples/webgl_materials_blending.html
Original file line number Diff line number Diff line change
Expand Up @@ -45,9 +45,9 @@

// BACKGROUND

const canvasBackground = document.createElement( 'canvas' );
const ctx = canvasBackground.getContext( '2d' );
canvasBackground.width = canvasBackground.height = 128;
const canvas = document.createElement( 'canvas' );
const ctx = canvas.getContext( '2d' );
canvas.width = canvas.height = 128;
ctx.fillStyle = '#ddd';
ctx.fillRect( 0, 0, 128, 128 );
ctx.fillStyle = '#555';
Expand All @@ -59,21 +59,11 @@
ctx.fillStyle = '#777';
ctx.fillRect( 96, 96, 32, 32 );

mapBg = new THREE.CanvasTexture( canvasBackground );
mapBg.wrapS = mapBg.wrapT = THREE.RepeatWrapping;
mapBg.repeat.set( 128, 64 );

/*
let mapBg = textureLoader.load( 'textures/disturb.jpg' );
mapBg = new THREE.CanvasTexture( canvas );
mapBg.wrapS = mapBg.wrapT = THREE.RepeatWrapping;
mapBg.repeat.set( 8, 4 );
*/
mapBg.repeat.set( 64, 32 );

const materialBg = new THREE.MeshBasicMaterial( { map: mapBg } );

const meshBg = new THREE.Mesh( new THREE.PlaneGeometry( 4000, 2000 ), materialBg );
meshBg.position.set( 0, 0, - 1 );
scene.add( meshBg );
scene.background = mapBg;

// OBJECTS

Expand Down Expand Up @@ -125,12 +115,9 @@

}

const canvas = document.createElement( 'canvas' );
const context = canvas.getContext( 'webgl2', { alpha: false } ); // TODO Remove workaround

// RENDERER

renderer = new THREE.WebGLRenderer( { canvas: canvas, context: context } );
renderer = new THREE.WebGLRenderer();
renderer.setPixelRatio( window.devicePixelRatio );
renderer.setSize( window.innerWidth, window.innerHeight );
document.body.appendChild( renderer.domElement );
Expand Down
Loading