var camera, scene, renderer;
var geometry, material, mesh;
import * as THREE from 'https://cdn.jsdelivr.net/npm/[email protected]/build/three.module.js';
import { OrbitControls } from 'https://cdn.jsdelivr.net/npm/[email protected]/examples/jsm/controls/OrbitControls.js';
init();
animate();
function init() {
camera = new THREE.PerspectiveCamera( 30, window.innerWidth / window.innerHeight, 1.01, 20 );
camera.position.z = 3;
camera.position.y = 3;
camera.position.x = 3;
scene = new THREE.Scene();
var loa = new THREE.TextureLoader();
var map1 = loa.load( 'https://upload.wikimedia.org/wikipedia/commons/1/1b/Facebook_icon.svg');
var map2 = loa.load( '' );
var geometry = new THREE.BoxBufferGeometry(1,1,1);
var cubeMaterials = [
new THREE.MeshBasicMaterial({map:map1, transparent:true}),
new THREE.MeshBasicMaterial({map:map1, transparent:true}),
new THREE.MeshBasicMaterial({map:map1, transparent:true}),
new THREE.MeshBasicMaterial({map:map1, transparent:true}),
new THREE.MeshBasicMaterial({map:map1, transparent:true}),
new THREE.MeshBasicMaterial({map:map1, transparent:true}),
];
// Create a MeshFaceMaterial, which allows the cube to have different materials on each face
console.log(cubeMaterials)
// var cubeMaterial = new THREE.Mesh(cubeMaterials);
var cube = new THREE.Mesh(geometry, cubeMaterials);
scene.add( cube );
renderer = new THREE.WebGLRenderer( { antialias: true } );
renderer.setSize( window.innerWidth, window.innerHeight );
document.body.appendChild( renderer.domElement );
var controls = new OrbitControls( camera, renderer.domElement );
}
function animate() {
requestAnimationFrame( animate );
renderer.render( scene, camera );
}
Please Whitelist JSFiddle in your content blocker.
Help keep JSFiddle free for always by one of two ways:
Whitelist JSFiddle in your content blocker (two clicks)
Go PRO and get access to additional PRO features →
Join the 4+ million users, and keep the JSFiddle dream alive.
Ad-free
All ads in the editor and listing pages are turned completely off.
Use pre-released features
You get to try and use features (like the Palette Color Generator) months before everyone else.
Fiddle collections
Sort and categorize your Fiddles into multiple collections.
Private collections and fiddles
You can make as many Private Fiddles, and Private Collections as you wish!
Console
Debug your Fiddle with a minimal built-in JavaScript console.