提交 13699987 编写于 作者: M Mr.doob

Starting the *Loader change. First ImageLoader and testing.

上级 d35e4f3b
......@@ -60,11 +60,25 @@
camera.position.z = 500;
scene.add( camera );
mesh = new THREE.Mesh( new THREE.PlaneGeometry( 300, 300, 3, 3 ), new THREE.MeshBasicMaterial( { map: THREE.ImageUtils.loadTexture( 'textures/shadow.png' ), overdraw: true } ) );
// THREE.ImageUtils.loadTexture( 'textures/shadow.png' )
var shadowTexture = new THREE.Texture();
var loader = new THREE.ImageLoader();
loader.addEventListener( 'complete', function ( event ) { shadowTexture.image = event.image } );
loader.load( 'textures/shadow.png' );
mesh = new THREE.Mesh( new THREE.PlaneGeometry( 300, 300, 3, 3 ), new THREE.MeshBasicMaterial( { map: shadowTexture, overdraw: true } ) );
mesh.position.y = - 250;
scene.add( mesh );
mesh = new THREE.Mesh( new THREE.SphereGeometry( 200, 20, 20 ), new THREE.MeshBasicMaterial( { map: THREE.ImageUtils.loadTexture( 'textures/land_ocean_ice_cloud_2048.jpg' ), overdraw: true } ) );
// THREE.ImageUtils.loadTexture( 'textures/land_ocean_ice_cloud_2048.jpg' )
var earthTexture = new THREE.Texture();
var loader = new THREE.ImageLoader();
loader.addEventListener( 'complete', function ( event ) { earthTexture.image = event.image } );
loader.load( 'textures/land_ocean_ice_cloud_2048.jpg' );
mesh = new THREE.Mesh( new THREE.SphereGeometry( 200, 20, 20 ), new THREE.MeshBasicMaterial( { map: earthTexture, overdraw: true } ) );
scene.add( mesh );
renderer = new THREE.CanvasRenderer();
......
......@@ -8,7 +8,7 @@ THREE.EventTarget = function () {
this.addEventListener = function ( type, listener ) {
if ( listeners[ type ] == undefined ) {
if ( listeners[ type ] === undefined ) {
listeners[ type ] = [];
......
......@@ -2,27 +2,30 @@
* @author mrdoob / http://mrdoob.com/
*/
THREE.ImageLoader = function () {};
THREE.ImageLoader = function () {
THREE.ImageLoader.prototype = new THREE.Loader();
THREE.ImageLoader.prototype.constructor = THREE.ImageLoader;
THREE.EventTarget.call( this );
THREE.ImageLoader.prototype.load = function ( url, callback ) {
var _this = this;
var that = this;
var image = new Image();
this.crossOrigin = 'anonymous';
image.onload = function () {
this.load = function ( url ) {
callback( image );
var image = new Image();
image.addEventListener( 'load', function () {
that.onLoadComplete();
_this.dispatchEvent( { type: 'complete', image: image } );
};
image.crossOrigin = this.crossOrigin;
image.src = path;
}, false );
image.addEventListener( 'error', function () {
_this.dispatchEvent( { type: 'error', image: image } );
}, false );
image.crossOrigin = this.crossOrigin;
image.src = url;
that.onLoadStart();
};
};
......@@ -18,6 +18,7 @@ COMMON_FILES = [
'core/Vector2.js',
'core/Vector3.js',
'core/Vector4.js',
'core/EventTarget.js',
'core/Frustum.js',
'core/Ray.js',
'core/Rectangle.js',
......@@ -43,6 +44,7 @@ COMMON_FILES = [
'lights/SpotLight.js',
'loaders/Loader.js',
'loaders/BinaryLoader.js',
'loaders/ImageLoader.js',
'loaders/JSONLoader.js',
'loaders/SceneLoader.js',
'materials/Material.js',
......@@ -95,7 +97,6 @@ EXTRAS_FILES = [
'extras/core/BufferGeometry.js',
'extras/core/Curve.js',
'extras/core/CurvePath.js',
'extras/core/EventTarget.js',
'extras/core/Gyroscope.js',
'extras/core/Path.js',
'extras/core/Shape.js',
......@@ -146,6 +147,7 @@ CANVAS_FILES = [
'core/Vector2.js',
'core/Vector3.js',
'core/Vector4.js',
'core/EventTarget.js',
'core/Frustum.js',
'core/Ray.js',
'core/Rectangle.js',
......@@ -169,6 +171,7 @@ CANVAS_FILES = [
'lights/PointLight.js',
'loaders/Loader.js',
'loaders/BinaryLoader.js',
'loaders/ImageLoader.js',
'loaders/JSONLoader.js',
'loaders/SceneLoader.js',
'materials/Material.js',
......@@ -204,6 +207,7 @@ WEBGL_FILES = [
'core/Vector2.js',
'core/Vector3.js',
'core/Vector4.js',
'core/EventTarget.js',
'core/Frustum.js',
'core/Ray.js',
'core/Rectangle.js',
......@@ -229,6 +233,7 @@ WEBGL_FILES = [
'lights/SpotLight.js',
'loaders/Loader.js',
'loaders/BinaryLoader.js',
'loaders/ImageLoader.js',
'loaders/JSONLoader.js',
'loaders/SceneLoader.js',
'materials/Material.js',
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册