提交 cff069e4 编写于 作者: M Mugen87

GLTFLoader: Introduce setDDSLoader().

上级 325a0579
......@@ -12,6 +12,7 @@ THREE.GLTFLoader = ( function () {
this.manager = ( manager !== undefined ) ? manager : THREE.DefaultLoadingManager;
this.dracoLoader = null;
this.ddsLoader = null;
}
......@@ -124,6 +125,13 @@ THREE.GLTFLoader = ( function () {
},
setDDSLoader: function ( ddsLoader ) {
this.ddsLoader = ddsLoader;
return this;
},
parse: function ( data, path, onLoad, onError ) {
var content;
......@@ -195,7 +203,7 @@ THREE.GLTFLoader = ( function () {
break;
case EXTENSIONS.MSFT_TEXTURE_DDS:
extensions[ EXTENSIONS.MSFT_TEXTURE_DDS ] = new GLTFTextureDDSExtension();
extensions[ EXTENSIONS.MSFT_TEXTURE_DDS ] = new GLTFTextureDDSExtension( this.ddsLoader );
break;
case EXTENSIONS.KHR_TEXTURE_TRANSFORM:
......@@ -287,16 +295,16 @@ THREE.GLTFLoader = ( function () {
* https://github.com/KhronosGroup/glTF/tree/master/extensions/2.0/Vendor/MSFT_texture_dds
*
*/
function GLTFTextureDDSExtension() {
function GLTFTextureDDSExtension( ddsLoader ) {
if ( ! THREE.DDSLoader ) {
if ( ! ddsLoader ) {
throw new Error( 'THREE.GLTFLoader: Attempting to load .dds texture without importing THREE.DDSLoader' );
}
this.name = EXTENSIONS.MSFT_TEXTURE_DDS;
this.ddsLoader = new THREE.DDSLoader();
this.ddsLoader = ddsLoader;
}
......@@ -855,7 +863,7 @@ THREE.GLTFLoader = ( function () {
},
// Here's based on refreshUniformsCommon() and refreshUniformsStandard() in WebGLRenderer.
refreshUniforms: function ( renderer, scene, camera, geometry, material, group ) {
refreshUniforms: function ( renderer, scene, camera, geometry, material ) {
if ( material.isGLTFSpecularGlossinessMaterial !== true ) {
......@@ -2549,7 +2557,7 @@ THREE.GLTFLoader = ( function () {
? new THREE.SkinnedMesh( geometry, material )
: new THREE.Mesh( geometry, material );
if ( mesh.isSkinnedMesh === true && !mesh.geometry.attributes.skinWeight.normalized ) {
if ( mesh.isSkinnedMesh === true && ! mesh.geometry.attributes.skinWeight.normalized ) {
// we normalize floating point skin weight array to fix malformed assets (see #15319)
// it's important to skip this for non-float32 data since normalizeSkinWeights assumes non-normalized inputs
......@@ -2837,7 +2845,7 @@ THREE.GLTFLoader = ( function () {
for ( var j = 0, jl = outputArray.length; j < jl; j ++ ) {
scaled[j] = outputArray[j] * scale;
scaled[ j ] = outputArray[ j ] * scale;
}
......
......@@ -5,6 +5,9 @@ import {
Scene
} from '../../../src/Three';
import { DRACOLoader } from './DRACOLoader';
import { DDSLoader } from './DDSLoader';
export interface GLTF {
animations: AnimationClip[];
scene: Scene;
......@@ -16,12 +19,17 @@ export interface GLTF {
export class GLTFLoader {
constructor(manager?: LoadingManager);
manager: LoadingManager;
dracoLoader: DRACOLoader | null;
ddsLoader: DDSLoader | null;
path: string;
crossOrigin: string;
resourcePath: string;
load(url: string, onLoad: (gltf: GLTF) => void, onProgress?: (event: ProgressEvent) => void, onError?: (event: ErrorEvent) => void) : void;
setPath(path: string) : GLTFLoader;
setResourcePath(path: string) : GLTFLoader;
setCrossOrigin(value: string): GLTFLoader;
setDRACOLoader(dracoLoader: object): GLTFLoader;
setDRACOLoader(dracoLoader: DRACOLoader): GLTFLoader;
setDDSLoader(ddsLoader: DDSLoader): GLTFLoader;
parse(data: ArrayBuffer | string, path: string, onLoad: (gltf: GLTF) => void, onError?: (event: ErrorEvent) => void) : void;
}
......@@ -61,7 +61,6 @@ import {
Skeleton,
SkinnedMesh,
SpotLight,
Texture,
TextureLoader,
TriangleFanDrawMode,
TriangleStripDrawMode,
......@@ -78,6 +77,7 @@ var GLTFLoader = ( function () {
this.manager = ( manager !== undefined ) ? manager : DefaultLoadingManager;
this.dracoLoader = null;
this.ddsLoader = null;
}
......@@ -190,6 +190,13 @@ var GLTFLoader = ( function () {
},
setDDSLoader: function ( ddsLoader ) {
this.ddsLoader = ddsLoader;
return this;
},
parse: function ( data, path, onLoad, onError ) {
var content;
......@@ -261,7 +268,7 @@ var GLTFLoader = ( function () {
break;
case EXTENSIONS.MSFT_TEXTURE_DDS:
extensions[ EXTENSIONS.MSFT_TEXTURE_DDS ] = new GLTFTextureDDSExtension();
extensions[ EXTENSIONS.MSFT_TEXTURE_DDS ] = new GLTFTextureDDSExtension( this.ddsLoader );
break;
case EXTENSIONS.KHR_TEXTURE_TRANSFORM:
......@@ -353,16 +360,16 @@ var GLTFLoader = ( function () {
* https://github.com/KhronosGroup/glTF/tree/master/extensions/2.0/Vendor/MSFT_texture_dds
*
*/
function GLTFTextureDDSExtension() {
function GLTFTextureDDSExtension( ddsLoader ) {
if ( ! THREE.DDSLoader ) {
if ( ! ddsLoader ) {
throw new Error( 'THREE.GLTFLoader: Attempting to load .dds texture without importing THREE.DDSLoader' );
throw new Error( 'THREE.GLTFLoader: Attempting to load .dds texture without importing DDSLoader' );
}
this.name = EXTENSIONS.MSFT_TEXTURE_DDS;
this.ddsLoader = new THREE.DDSLoader();
this.ddsLoader = ddsLoader;
}
......@@ -921,7 +928,7 @@ var GLTFLoader = ( function () {
},
// Here's based on refreshUniformsCommon() and refreshUniformsStandard() in WebGLRenderer.
refreshUniforms: function ( renderer, scene, camera, geometry, material, group ) {
refreshUniforms: function ( renderer, scene, camera, geometry, material ) {
if ( material.isGLTFSpecularGlossinessMaterial !== true ) {
......@@ -1719,7 +1726,7 @@ var GLTFLoader = ( function () {
* Requests the specified dependency asynchronously, with caching.
* @param {string} type
* @param {number} index
* @return {Promise<Object3D|Material|Texture|AnimationClip|ArrayBuffer|Object>}
* @return {Promise<Object3D|Material|THREE.Texture|AnimationClip|ArrayBuffer|Object>}
*/
GLTFParser.prototype.getDependency = function ( type, index ) {
......@@ -2008,7 +2015,7 @@ var GLTFLoader = ( function () {
/**
* Specification: https://github.com/KhronosGroup/glTF/tree/master/specification/2.0#textures
* @param {number} textureIndex
* @return {Promise<Texture>}
* @return {Promise<THREE.Texture>}
*/
GLTFParser.prototype.loadTexture = function ( textureIndex ) {
......@@ -2615,7 +2622,7 @@ var GLTFLoader = ( function () {
? new SkinnedMesh( geometry, material )
: new Mesh( geometry, material );
if ( mesh.isSkinnedMesh === true && !mesh.geometry.attributes.skinWeight.normalized ) {
if ( mesh.isSkinnedMesh === true && ! mesh.geometry.attributes.skinWeight.normalized ) {
// we normalize floating point skin weight array to fix malformed assets (see #15319)
// it's important to skip this for non-float32 data since normalizeSkinWeights assumes non-normalized inputs
......@@ -2903,7 +2910,7 @@ var GLTFLoader = ( function () {
for ( var j = 0, jl = outputArray.length; j < jl; j ++ ) {
scaled[j] = outputArray[j] * scale;
scaled[ j ] = outputArray[ j ] * scale;
}
......
......@@ -269,6 +269,7 @@
THREE.DRACOLoader.setDecoderPath( 'js/libs/draco/gltf/' );
loader.setDRACOLoader( new THREE.DRACOLoader() );
loader.setDDSLoader( new THREE.DDSLoader() );
var url = sceneInfo.url.replace( /%s/g, state.extension );
......
......@@ -90,7 +90,7 @@ var files = [
{ path: 'loaders/EquirectangularToCubeGenerator.js', dependencies: [], ignoreList: [] },
{ path: 'loaders/FBXLoader.js', dependencies: [ { name: 'Zlib', path: 'libs/inflate.min.js' }, { name: 'TGALoader', path: 'loaders/TGALoader.js' }, { name: 'NURBSCurve', path: 'curves/NURBSCurve.js' } ], ignoreList: [] },
{ path: 'loaders/GCodeLoader.js', dependencies: [], ignoreList: [] },
{ path: 'loaders/GLTFLoader.js', dependencies: [], ignoreList: [ 'NoSide', 'Matrix2', 'DDSLoader', 'Camera' ] },
{ path: 'loaders/GLTFLoader.js', dependencies: [], ignoreList: [ 'NoSide', 'Matrix2', 'Camera', 'Texture' ] },
{ path: 'loaders/HDRCubeTextureLoader.js', dependencies: [ { name: 'RGBELoader', path: 'loaders/RGBELoader.js' } ], ignoreList: [] },
{ path: 'loaders/KMZLoader.js', dependencies: [ { name: 'ColladaLoader', path: 'loaders/ColladaLoader.js' } ], ignoreList: [] },
{ path: 'loaders/LDrawLoader.js', dependencies: [], ignoreList: [ 'Cache', 'Material', 'Object3D' ] },
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册