UPDATE: After taking advice from gaitat, I encountered a new issue: now the box is not visible at all. To illustrate this problem, I have created another question.
I have a basic box geometry that I am attempting to apply a texture to. However, all I am getting is a completely white box. To showcase this problem, I have set up a simple test page. Below is the content of that page:
"use strict";
// create DOM elements:
var container = document.createElement('div');
document.body.appendChild(container);
var info = document.createElement('div');
container.appendChild(info);
// define a 'Box2' geometry instance: (see implementation below)
var myBox2geom = new THREE.BoxGeometry(100, 100, 100, 10, 10, 10); // parameters: x,y,z dimensions and segment widths
// create a 'Box2' mesh with texture:
var texture = new THREE.TextureLoader().load("crate.gif");
console.log("texture: ", texture);
var material = new THREE.MeshLambertMaterial({ map: texture, side: THREE.DoubleSide, emissive: 0xffffff });
texture.minFilter = THREE.NearestFilter;
var myBox2mesh = new THREE.Mesh(myBox2geom, material);
// add mesh to scene:
var scene = new THREE.Scene();
scene.add(myBox2mesh);
// add light source:
var light = new THREE.PointLight(0xffffff);
light.position.set(100, 200, 300);
light.lookAt(new THREE.Vector3(0, 0, 0));
scene.add(light);
// set up camera:
var camera = new THREE.PerspectiveCamera(45, window.innerWidth / window.innerHeight, 1, 10000);
camera.position.x = 100;
camera.position.y = 200;
camera.position.z = 300;
camera.lookAt(new THREE.Vector3(0, 0, 0));
scene.add(camera);
// create renderer:
var renderer = new THREE.WebGLRenderer();
renderer.setSize(window.innerWidth, window.innerHeight);
container.appendChild(renderer.domElement);
// render the scene!
renderer.render(scene, camera);
THREE.Box2Geometry = function(width, height, depth, widthSegments, heightSegments, depthSegments) {
...geometry implementation...
};
THREE.Box2Geometry.prototype = Object.create(THREE.Geometry.prototype);
<!doctype html>
<html>
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1, user-scalable=no">
</head>
<body>
<script src="https://raw.githubusercontent.com/mrdoob/three.js/master/build/three.js"></script>
<script src="main.js"></script>
</body>
</html>