Skip to content

Commit

Permalink
Updated examples builds
Browse files Browse the repository at this point in the history
  • Loading branch information
mrdoob committed Jul 28, 2021
1 parent 40e73ed commit 5820a00
Show file tree
Hide file tree
Showing 2 changed files with 74 additions and 11 deletions.
12 changes: 2 additions & 10 deletions examples/js/loaders/FBXLoader.js
Original file line number Diff line number Diff line change
Expand Up @@ -2119,16 +2119,8 @@
}

const curve = new THREE.NURBSCurve( degree, knots, controlPoints, startKnot, endKnot );
const vertices = curve.getPoints( controlPoints.length * 7 );
const positions = new Float32Array( vertices.length * 3 );
vertices.forEach( function ( vertex, i ) {

vertex.toArray( positions, i * 3 );

} );
const geometry = new THREE.BufferGeometry();
geometry.setAttribute( 'position', new THREE.BufferAttribute( positions, 3 ) );
return geometry;
const points = curve.getPoints( controlPoints.length * 12 );
return new THREE.BufferGeometry().setFromPoints( points );

}

Expand Down
73 changes: 72 additions & 1 deletion examples/js/loaders/GLTFLoader.js
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,11 @@

return new GLTFMaterialsIorExtension( parser );

} );
this.register( function ( parser ) {

return new GLTFMaterialsSpecularExtension( parser );

} );
this.register( function ( parser ) {

Expand Down Expand Up @@ -331,6 +336,7 @@
KHR_MATERIALS_CLEARCOAT: 'KHR_materials_clearcoat',
KHR_MATERIALS_IOR: 'KHR_materials_ior',
KHR_MATERIALS_PBR_SPECULAR_GLOSSINESS: 'KHR_materials_pbrSpecularGlossiness',
KHR_MATERIALS_SPECULAR: 'KHR_materials_specular',
KHR_MATERIALS_TRANSMISSION: 'KHR_materials_transmission',
KHR_MATERIALS_UNLIT: 'KHR_materials_unlit',
KHR_MATERIALS_VOLUME: 'KHR_materials_volume',
Expand Down Expand Up @@ -741,6 +747,70 @@

}

}
/**
* Materials specular Extension
*
* Specification: https://github.com/KhronosGroup/glTF/tree/master/extensions/2.0/Khronos/KHR_materials_specular
*/


class GLTFMaterialsSpecularExtension {

constructor( parser ) {

this.parser = parser;
this.name = EXTENSIONS.KHR_MATERIALS_SPECULAR;

}

getMaterialType( materialIndex ) {

const parser = this.parser;
const materialDef = parser.json.materials[ materialIndex ];
if ( ! materialDef.extensions || ! materialDef.extensions[ this.name ] ) return null;
return THREE.MeshPhysicalMaterial;

}

extendMaterialParams( materialIndex, materialParams ) {

const parser = this.parser;
const materialDef = parser.json.materials[ materialIndex ];

if ( ! materialDef.extensions || ! materialDef.extensions[ this.name ] ) {

return Promise.resolve();

}

const pending = [];
const extension = materialDef.extensions[ this.name ];
materialParams.specularIntensity = extension.specularFactor !== undefined ? extension.specularFactor : 1.0;

if ( extension.specularTexture !== undefined ) {

pending.push( parser.assignTexture( materialParams, 'specularIntensityMap', extension.specularTexture ) );

}

const colorArray = extension.specularColorFactor || [ 1, 1, 1 ];
materialParams.specularTint = new THREE.Color( colorArray[ 0 ], colorArray[ 1 ], colorArray[ 2 ] );

if ( extension.specularColorTexture !== undefined ) {

pending.push( parser.assignTexture( materialParams, 'specularTintMap', extension.specularColorTexture ).then( function ( texture ) {

texture.encoding = THREE.sRGBEncoding;

} ) );

}

return Promise.all( pending );

}

}
/**
* BasisU THREE.Texture Extension
Expand Down Expand Up @@ -2501,7 +2571,7 @@
* @param {Object} materialParams
* @param {string} mapName
* @param {Object} mapDef
* @return {Promise}
* @return {Promise<Texture>}
*/


Expand Down Expand Up @@ -2533,6 +2603,7 @@
}

materialParams[ mapName ] = texture;
return texture;

} );

Expand Down

0 comments on commit 5820a00

Please sign in to comment.