Skip to content

Commit

Permalink
enhance DataTextureLoader
Browse files Browse the repository at this point in the history
  • Loading branch information
deepkolos committed Feb 28, 2021
1 parent fa43b75 commit 056c0b8
Show file tree
Hide file tree
Showing 6 changed files with 57 additions and 70 deletions.
64 changes: 34 additions & 30 deletions build/three.js
Original file line number Diff line number Diff line change
Expand Up @@ -9106,17 +9106,17 @@
clone: function clone() {
/*
// Handle primitives
const parameters = this.parameters;
if ( parameters !== undefined ) {
const values = [];
for ( const key in parameters ) {
values.push( parameters[ key ] );
}
const geometry = Object.create( this.constructor.prototype );
const parameters = this.parameters;
if ( parameters !== undefined ) {
const values = [];
for ( const key in parameters ) {
values.push( parameters[ key ] );
}
const geometry = Object.create( this.constructor.prototype );
this.constructor.apply( geometry, values );
return geometry;
}
return new this.constructor().copy( this );
}
return new this.constructor().copy( this );
*/
return new BufferGeometry().copy(this);
},
Expand Down Expand Up @@ -27313,7 +27313,7 @@
loader.setPath(this.path);
loader.setWithCredentials(scope.withCredentials);
loader.load(url, function (buffer) {
var texData = scope.parse(buffer);
var texData = scope.parse(buffer, texture);
if (!texData) return;

if (texData.image !== undefined) {
Expand Down Expand Up @@ -27355,6 +27355,10 @@
texture.minFilter = LinearFilter;
}

if (texData.generateMipmaps !== undefined) {
texture.generateMipmaps = texData.generateMipmaps;
}

texture.needsUpdate = true;
if (onLoad) onLoad(texture, texData);
}, onProgress, onError);
Expand Down Expand Up @@ -33489,23 +33493,22 @@
var weight = this._updateWeight(time);

if (weight > 0) {
var _interpolants = this._interpolants;
var interpolants = this._interpolants;
var propertyMixers = this._propertyBindings;

switch (this.blendMode) {
case AdditiveAnimationBlendMode:
for (var j = 0, m = _interpolants.length; j !== m; ++j) {
_interpolants[j].evaluate(clipTime);

for (var j = 0, m = interpolants.length; j !== m; ++j) {
interpolants[j].evaluate(clipTime);
propertyMixers[j].accumulateAdditive(weight);
}

break;

case NormalAnimationBlendMode:
default:
for (var _j = 0, _m = _interpolants.length; _j !== _m; ++_j) {
_interpolants[_j].evaluate(clipTime);
for (var _j = 0, _m = interpolants.length; _j !== _m; ++_j) {
interpolants[_j].evaluate(clipTime);

propertyMixers[_j].accumulate(accuIndex, weight);
}
Expand Down Expand Up @@ -35083,15 +35086,15 @@
// TODO: delete this comment?
const distanceGeometry = new THREE.IcosahedronBufferGeometry( 1, 2 );
const distanceMaterial = new THREE.MeshBasicMaterial( { color: hexColor, fog: false, wireframe: true, opacity: 0.1, transparent: true } );
this.lightSphere = new THREE.Mesh( bulbGeometry, bulbMaterial );
this.lightSphere = new THREE.Mesh( bulbGeometry, bulbMaterial );
this.lightDistance = new THREE.Mesh( distanceGeometry, distanceMaterial );
const d = light.distance;
if ( d === 0.0 ) {
this.lightDistance.visible = false;
} else {
this.lightDistance.scale.set( d, d, d );
}
this.add( this.lightDistance );
const d = light.distance;
if ( d === 0.0 ) {
this.lightDistance.visible = false;
} else {
this.lightDistance.scale.set( d, d, d );
}
this.add( this.lightDistance );
*/


Expand All @@ -35113,12 +35116,12 @@
}
/*
const d = this.light.distance;
if ( d === 0.0 ) {
this.lightDistance.visible = false;
} else {
this.lightDistance.visible = true;
if ( d === 0.0 ) {
this.lightDistance.visible = false;
} else {
this.lightDistance.visible = true;
this.lightDistance.scale.set( d, d, d );
}
}
*/

};
Expand Down Expand Up @@ -35620,7 +35623,7 @@
1/___0/|
| 6__|_7
2/___3/
0: max.x, max.y, max.z
0: max.x, max.y, max.z
1: min.x, max.y, max.z
2: min.x, min.y, max.z
3: max.x, min.y, max.z
Expand Down Expand Up @@ -38462,3 +38465,4 @@
Object.defineProperty(exports, '__esModule', { value: true });

})));
//# sourceMappingURL=data:application/json;charset=utf-8;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoidGhyZWUuanMiLCJzb3VyY2VzIjpbXSwic291cmNlc0NvbnRlbnQiOltdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiIn0=
3 changes: 2 additions & 1 deletion build/three.min.js

Large diffs are not rendered by default.

9 changes: 8 additions & 1 deletion build/three.module.js
Original file line number Diff line number Diff line change
Expand Up @@ -34868,7 +34868,7 @@ DataTextureLoader.prototype = Object.assign( Object.create( Loader.prototype ),
loader.setWithCredentials( scope.withCredentials );
loader.load( url, function ( buffer ) {

const texData = scope.parse( buffer );
const texData = scope.parse( buffer, texture );

if ( ! texData ) return;

Expand Down Expand Up @@ -34929,6 +34929,12 @@ DataTextureLoader.prototype = Object.assign( Object.create( Loader.prototype ),

}

if ( texData.generateMipmaps !== undefined ) {

texture.generateMipmaps = texData.generateMipmaps;

}

texture.needsUpdate = true;

if ( onLoad ) onLoad( texture, texData );
Expand Down Expand Up @@ -48928,3 +48934,4 @@ if ( typeof window !== 'undefined' ) {
}

export { ACESFilmicToneMapping, AddEquation, AddOperation, AdditiveAnimationBlendMode, AdditiveBlending, AlphaFormat, AlwaysDepth, AlwaysStencilFunc, AmbientLight, AmbientLightProbe, AnimationClip, AnimationLoader, AnimationMixer, AnimationObjectGroup, AnimationUtils, ArcCurve, ArrayCamera, ArrowHelper, Audio, AudioAnalyser, AudioContext, AudioListener, AudioLoader, AxesHelper, AxisHelper, BackSide, BasicDepthPacking, BasicShadowMap, BinaryTextureLoader, Bone, BooleanKeyframeTrack, BoundingBoxHelper, Box2, Box3, Box3Helper, BoxGeometry as BoxBufferGeometry, BoxGeometry, BoxHelper, BufferAttribute, BufferGeometry, BufferGeometryLoader, ByteType, Cache, Camera, CameraHelper, CanvasRenderer, CanvasTexture, CatmullRomCurve3, CineonToneMapping, CircleGeometry as CircleBufferGeometry, CircleGeometry, ClampToEdgeWrapping, Clock, Color, ColorKeyframeTrack, CompressedTexture, CompressedTextureLoader, ConeGeometry as ConeBufferGeometry, ConeGeometry, CubeCamera, CubeReflectionMapping, CubeRefractionMapping, CubeTexture, CubeTextureLoader, CubeUVReflectionMapping, CubeUVRefractionMapping, CubicBezierCurve, CubicBezierCurve3, CubicInterpolant, CullFaceBack, CullFaceFront, CullFaceFrontBack, CullFaceNone, Curve, CurvePath, CustomBlending, CustomToneMapping, CylinderGeometry as CylinderBufferGeometry, CylinderGeometry, Cylindrical, DataTexture, DataTexture2DArray, DataTexture3D, DataTextureLoader, DataUtils, DecrementStencilOp, DecrementWrapStencilOp, DefaultLoadingManager, DepthFormat, DepthStencilFormat, DepthTexture, DirectionalLight, DirectionalLightHelper, DiscreteInterpolant, DodecahedronGeometry as DodecahedronBufferGeometry, DodecahedronGeometry, DoubleSide, DstAlphaFactor, DstColorFactor, DynamicBufferAttribute, DynamicCopyUsage, DynamicDrawUsage, DynamicReadUsage, EdgesGeometry, EdgesHelper, EllipseCurve, EqualDepth, EqualStencilFunc, EquirectangularReflectionMapping, EquirectangularRefractionMapping, Euler, EventDispatcher, ExtrudeGeometry as ExtrudeBufferGeometry, ExtrudeGeometry, FaceColors, FileLoader, FlatShading, Float16BufferAttribute, Float32Attribute, Float32BufferAttribute, Float64Attribute, Float64BufferAttribute, FloatType, Fog, FogExp2, Font, FontLoader, FrontSide, Frustum, GLBufferAttribute, GLSL1, GLSL3, GammaEncoding, GreaterDepth, GreaterEqualDepth, GreaterEqualStencilFunc, GreaterStencilFunc, GridHelper, Group, HalfFloatType, HemisphereLight, HemisphereLightHelper, HemisphereLightProbe, IcosahedronGeometry as IcosahedronBufferGeometry, IcosahedronGeometry, ImageBitmapLoader, ImageLoader, ImageUtils, ImmediateRenderObject, IncrementStencilOp, IncrementWrapStencilOp, InstancedBufferAttribute, InstancedBufferGeometry, InstancedInterleavedBuffer, InstancedMesh, Int16Attribute, Int16BufferAttribute, Int32Attribute, Int32BufferAttribute, Int8Attribute, Int8BufferAttribute, IntType, InterleavedBuffer, InterleavedBufferAttribute, Interpolant, InterpolateDiscrete, InterpolateLinear, InterpolateSmooth, InvertStencilOp, JSONLoader, KeepStencilOp, KeyframeTrack, LOD, LatheGeometry as LatheBufferGeometry, LatheGeometry, Layers, LensFlare, LessDepth, LessEqualDepth, LessEqualStencilFunc, LessStencilFunc, Light, LightProbe, Line, Line3, LineBasicMaterial, LineCurve, LineCurve3, LineDashedMaterial, LineLoop, LinePieces, LineSegments, LineStrip, LinearEncoding, LinearFilter, LinearInterpolant, LinearMipMapLinearFilter, LinearMipMapNearestFilter, LinearMipmapLinearFilter, LinearMipmapNearestFilter, LinearToneMapping, Loader, LoaderUtils, LoadingManager, LogLuvEncoding, LoopOnce, LoopPingPong, LoopRepeat, LuminanceAlphaFormat, LuminanceFormat, MOUSE, Material, MaterialLoader, MathUtils as Math, MathUtils, Matrix3, Matrix4, MaxEquation, Mesh, MeshBasicMaterial, MeshDepthMaterial, MeshDistanceMaterial, MeshFaceMaterial, MeshLambertMaterial, MeshMatcapMaterial, MeshNormalMaterial, MeshPhongMaterial, MeshPhysicalMaterial, MeshStandardMaterial, MeshToonMaterial, MinEquation, MirroredRepeatWrapping, MixOperation, MultiMaterial, MultiplyBlending, MultiplyOperation, NearestFilter, NearestMipMapLinearFilter, NearestMipMapNearestFilter, NearestMipmapLinearFilter, NearestMipmapNearestFilter, NeverDepth, NeverStencilFunc, NoBlending, NoColors, NoToneMapping, NormalAnimationBlendMode, NormalBlending, NotEqualDepth, NotEqualStencilFunc, NumberKeyframeTrack, Object3D, ObjectLoader, ObjectSpaceNormalMap, OctahedronGeometry as OctahedronBufferGeometry, OctahedronGeometry, OneFactor, OneMinusDstAlphaFactor, OneMinusDstColorFactor, OneMinusSrcAlphaFactor, OneMinusSrcColorFactor, OrthographicCamera, PCFShadowMap, PCFSoftShadowMap, PMREMGenerator, ParametricGeometry as ParametricBufferGeometry, ParametricGeometry, Particle, ParticleBasicMaterial, ParticleSystem, ParticleSystemMaterial, Path, PerspectiveCamera, Plane, PlaneGeometry as PlaneBufferGeometry, PlaneGeometry, PlaneHelper, PointCloud, PointCloudMaterial, PointLight, PointLightHelper, Points, PointsMaterial, PolarGridHelper, PolyhedronGeometry as PolyhedronBufferGeometry, PolyhedronGeometry, PositionalAudio, PropertyBinding, PropertyMixer, QuadraticBezierCurve, QuadraticBezierCurve3, Quaternion, QuaternionKeyframeTrack, QuaternionLinearInterpolant, REVISION, RGBADepthPacking, RGBAFormat, RGBAIntegerFormat, RGBA_ASTC_10x10_Format, RGBA_ASTC_10x5_Format, RGBA_ASTC_10x6_Format, RGBA_ASTC_10x8_Format, RGBA_ASTC_12x10_Format, RGBA_ASTC_12x12_Format, RGBA_ASTC_4x4_Format, RGBA_ASTC_5x4_Format, RGBA_ASTC_5x5_Format, RGBA_ASTC_6x5_Format, RGBA_ASTC_6x6_Format, RGBA_ASTC_8x5_Format, RGBA_ASTC_8x6_Format, RGBA_ASTC_8x8_Format, RGBA_BPTC_Format, RGBA_ETC2_EAC_Format, RGBA_PVRTC_2BPPV1_Format, RGBA_PVRTC_4BPPV1_Format, RGBA_S3TC_DXT1_Format, RGBA_S3TC_DXT3_Format, RGBA_S3TC_DXT5_Format, RGBDEncoding, RGBEEncoding, RGBEFormat, RGBFormat, RGBIntegerFormat, RGBM16Encoding, RGBM7Encoding, RGB_ETC1_Format, RGB_ETC2_Format, RGB_PVRTC_2BPPV1_Format, RGB_PVRTC_4BPPV1_Format, RGB_S3TC_DXT1_Format, RGFormat, RGIntegerFormat, RawShaderMaterial, Ray, Raycaster, RectAreaLight, RedFormat, RedIntegerFormat, ReinhardToneMapping, RepeatWrapping, ReplaceStencilOp, ReverseSubtractEquation, RingGeometry as RingBufferGeometry, RingGeometry, SRGB8_ALPHA8_ASTC_10x10_Format, SRGB8_ALPHA8_ASTC_10x5_Format, SRGB8_ALPHA8_ASTC_10x6_Format, SRGB8_ALPHA8_ASTC_10x8_Format, SRGB8_ALPHA8_ASTC_12x10_Format, SRGB8_ALPHA8_ASTC_12x12_Format, SRGB8_ALPHA8_ASTC_4x4_Format, SRGB8_ALPHA8_ASTC_5x4_Format, SRGB8_ALPHA8_ASTC_5x5_Format, SRGB8_ALPHA8_ASTC_6x5_Format, SRGB8_ALPHA8_ASTC_6x6_Format, SRGB8_ALPHA8_ASTC_8x5_Format, SRGB8_ALPHA8_ASTC_8x6_Format, SRGB8_ALPHA8_ASTC_8x8_Format, Scene, SceneUtils, ShaderChunk, ShaderLib, ShaderMaterial, ShadowMaterial, Shape, ShapeGeometry as ShapeBufferGeometry, ShapeGeometry, ShapePath, ShapeUtils, ShortType, Skeleton, SkeletonHelper, SkinnedMesh, SmoothShading, Sphere, SphereGeometry as SphereBufferGeometry, SphereGeometry, Spherical, SphericalHarmonics3, SplineCurve, SpotLight, SpotLightHelper, Sprite, SpriteMaterial, SrcAlphaFactor, SrcAlphaSaturateFactor, SrcColorFactor, StaticCopyUsage, StaticDrawUsage, StaticReadUsage, StereoCamera, StreamCopyUsage, StreamDrawUsage, StreamReadUsage, StringKeyframeTrack, SubtractEquation, SubtractiveBlending, TOUCH, TangentSpaceNormalMap, TetrahedronGeometry as TetrahedronBufferGeometry, TetrahedronGeometry, TextGeometry as TextBufferGeometry, TextGeometry, Texture, TextureLoader, TorusGeometry as TorusBufferGeometry, TorusGeometry, TorusKnotGeometry as TorusKnotBufferGeometry, TorusKnotGeometry, Triangle, TriangleFanDrawMode, TriangleStripDrawMode, TrianglesDrawMode, TubeGeometry as TubeBufferGeometry, TubeGeometry, UVMapping, Uint16Attribute, Uint16BufferAttribute, Uint32Attribute, Uint32BufferAttribute, Uint8Attribute, Uint8BufferAttribute, Uint8ClampedAttribute, Uint8ClampedBufferAttribute, Uniform, UniformsLib, UniformsUtils, UnsignedByteType, UnsignedInt248Type, UnsignedIntType, UnsignedShort4444Type, UnsignedShort5551Type, UnsignedShort565Type, UnsignedShortType, VSMShadowMap, Vector2, Vector3, Vector4, VectorKeyframeTrack, Vertex, VertexColors, VideoTexture, WebGL1Renderer, WebGLCubeRenderTarget, WebGLMultisampleRenderTarget, WebGLRenderTarget, WebGLRenderTargetCube, WebGLRenderer, WebGLUtils, WireframeGeometry, WireframeHelper, WrapAroundEnding, XHRLoader, ZeroCurvatureEnding, ZeroFactor, ZeroSlopeEnding, ZeroStencilOp, sRGBEncoding };
//# sourceMappingURL=data:application/json;charset=utf-8;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoidGhyZWUubW9kdWxlLmpzIiwic291cmNlcyI6W10sInNvdXJjZXNDb250ZW50IjpbXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6IiJ9
21 changes: 3 additions & 18 deletions examples/js/loaders/TGALoader.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,24 +8,6 @@ THREE.TGALoader.prototype = Object.assign( Object.create( THREE.DataTextureLoade

constructor: THREE.TGALoader,

load: function ( url, onLoad, onProgress, onError ) {

function onDataTextureLoad( texture, texData ) {

texture.flipY = true;
texture.generateMipmaps = true;
texture.unpackAlignment = 4;
texture.magFilter = THREE.LinearFilter;
texture.minFilter = THREE.LinearMipmapLinearFilter;

if ( onLoad ) onLoad( texture, texData );

}

return THREE.DataTextureLoader.prototype.load.call( this, url, onDataTextureLoad, onProgress, onError );

},

parse: function ( buffer ) {

// reference from vthibault, https://github.com/vthibault/roBrowser/blob/master/src/Loaders/Targa.js
Expand Down Expand Up @@ -520,6 +502,9 @@ THREE.TGALoader.prototype = Object.assign( Object.create( THREE.DataTextureLoade
data: imageData,
width: header.width,
height: header.height,
flipY: true,
generateMipmaps: true,
minFilter: THREE.LinearMipmapLinearFilter,

};

Expand Down
22 changes: 3 additions & 19 deletions examples/jsm/loaders/TGALoader.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import {
DataTextureLoader,
LinearFilter,
LinearMipmapLinearFilter
} from '../../../build/three.module.js';

Expand All @@ -14,24 +13,6 @@ TGALoader.prototype = Object.assign( Object.create( DataTextureLoader.prototype

constructor: TGALoader,

load: function ( url, onLoad, onProgress, onError ) {

function onDataTextureLoad( texture, texData ) {

texture.flipY = true;
texture.generateMipmaps = true;
texture.unpackAlignment = 4;
texture.magFilter = LinearFilter;
texture.minFilter = LinearMipmapLinearFilter;

if ( onLoad ) onLoad( texture, texData );

}

return DataTextureLoader.prototype.load.call( this, url, onDataTextureLoad, onProgress, onError );

},

parse: function ( buffer ) {

// reference from vthibault, https://github.com/vthibault/roBrowser/blob/master/src/Loaders/Targa.js
Expand Down Expand Up @@ -526,6 +507,9 @@ TGALoader.prototype = Object.assign( Object.create( DataTextureLoader.prototype
data: imageData,
width: header.width,
height: header.height,
flipY: true,
generateMipmaps: true,
minFilter: LinearMipmapLinearFilter,

};

Expand Down
8 changes: 7 additions & 1 deletion src/loaders/DataTextureLoader.js
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ DataTextureLoader.prototype = Object.assign( Object.create( Loader.prototype ),
loader.setWithCredentials( scope.withCredentials );
loader.load( url, function ( buffer ) {

const texData = scope.parse( buffer );
const texData = scope.parse( buffer, texture );

if ( ! texData ) return;

Expand Down Expand Up @@ -93,6 +93,12 @@ DataTextureLoader.prototype = Object.assign( Object.create( Loader.prototype ),

}

if ( texData.generateMipmaps !== undefined ) {

texture.generateMipmaps = texData.generateMipmaps;

}

texture.needsUpdate = true;

if ( onLoad ) onLoad( texture, texData );
Expand Down

0 comments on commit 056c0b8

Please sign in to comment.