未验证 提交 24f8df36 编写于 作者: M Michael Herzog 提交者: GitHub

Merge pull request #16583 from Mugen87/dev33

Examples: Clean up
......@@ -359,7 +359,7 @@ THREE.AssimpLoader.prototype = {
var ASSBIN_MESH_HAS_COLOR_BASE = 0x10000;
var AI_MAX_NUMBER_OF_COLOR_SETS = 1;
var AI_MAX_NUMBER_OF_TEXTURECOORDS = 4;
var aiLightSource_UNDEFINED = 0x0;
//var aiLightSource_UNDEFINED = 0x0;
//! A directional light source has a well-defined direction
//! but is infinitely far away. That's quite a good
//! approximation for sun light.
......@@ -367,7 +367,7 @@ THREE.AssimpLoader.prototype = {
//! A point light source has a well-defined position
//! in space but no direction - it emits light in all
//! directions. A normal bulb is a point light.
var aiLightSource_POINT = 0x2;
//var aiLightSource_POINT = 0x2;
//! A spot light source emits light in a specific
//! angle. It has a position and a direction it is pointing to.
//! A good example for a spot light is a light spot in
......@@ -378,49 +378,49 @@ THREE.AssimpLoader.prototype = {
//! Typically, there's at most one ambient light in a scene.
//! This light type doesn't have a valid position, direction, or
//! other properties, just a color.
var aiLightSource_AMBIENT = 0x4;
//var aiLightSource_AMBIENT = 0x4;
/** Flat shading. Shading is done on per-face base,
* diffuse only. Also known as 'faceted shading'.
*/
var aiShadingMode_Flat = 0x1;
//var aiShadingMode_Flat = 0x1;
/** Simple Gouraud shading.
*/
var aiShadingMode_Gouraud = 0x2;
//var aiShadingMode_Gouraud = 0x2;
/** Phong-Shading -
*/
var aiShadingMode_Phong = 0x3;
//var aiShadingMode_Phong = 0x3;
/** Phong-Blinn-Shading
*/
var aiShadingMode_Blinn = 0x4;
//var aiShadingMode_Blinn = 0x4;
/** Toon-Shading per pixel
*
* Also known as 'comic' shader.
*/
var aiShadingMode_Toon = 0x5;
//var aiShadingMode_Toon = 0x5;
/** OrenNayar-Shading per pixel
*
* Extension to standard Lambertian shading, taking the
* roughness of the material into account
*/
var aiShadingMode_OrenNayar = 0x6;
//var aiShadingMode_OrenNayar = 0x6;
/** Minnaert-Shading per pixel
*
* Extension to standard Lambertian shading, taking the
* "darkness" of the material into account
*/
var aiShadingMode_Minnaert = 0x7;
//var aiShadingMode_Minnaert = 0x7;
/** CookTorrance-Shading per pixel
*
* Special shader for metallic surfaces.
*/
var aiShadingMode_CookTorrance = 0x8;
//var aiShadingMode_CookTorrance = 0x8;
/** No shading at all. Constant light influence of 1.0.
*/
var aiShadingMode_NoShading = 0x9;
//var aiShadingMode_NoShading = 0x9;
/** Fresnel shading
*/
var aiShadingMode_Fresnel = 0xa;
var aiTextureType_NONE = 0x0;
//var aiShadingMode_Fresnel = 0xa;
//var aiTextureType_NONE = 0x0;
/** The texture is combined with the result of the diffuse
* lighting equation.
*/
......@@ -428,21 +428,21 @@ THREE.AssimpLoader.prototype = {
/** The texture is combined with the result of the specular
* lighting equation.
*/
var aiTextureType_SPECULAR = 0x2;
//var aiTextureType_SPECULAR = 0x2;
/** The texture is combined with the result of the ambient
* lighting equation.
*/
var aiTextureType_AMBIENT = 0x3;
//var aiTextureType_AMBIENT = 0x3;
/** The texture is added to the result of the lighting
* calculation. It isn't influenced by incoming light.
*/
var aiTextureType_EMISSIVE = 0x4;
//var aiTextureType_EMISSIVE = 0x4;
/** The texture is a height map.
*
* By convention, higher gray-scale values stand for
* higher elevations from the base height.
*/
var aiTextureType_HEIGHT = 0x5;
//var aiTextureType_HEIGHT = 0x5;
/** The texture is a (tangent space) normal-map.
*
* Again, there are several conventions for tangent-space
......@@ -457,7 +457,7 @@ THREE.AssimpLoader.prototype = {
* function defined to map the linear color values in the
* texture to a suitable exponent. Have fun.
*/
var aiTextureType_SHININESS = 0x7;
//var aiTextureType_SHININESS = 0x7;
/** The texture defines per-pixel opacity.
*
* Usually 'white' means opaque and 'black' means
......@@ -469,7 +469,7 @@ THREE.AssimpLoader.prototype = {
* The exact purpose and format is application-dependent.
* Higher color values stand for higher vertex displacements.
*/
var aiTextureType_DISPLACEMENT = 0x9;
//var aiTextureType_DISPLACEMENT = 0x9;
/** Lightmap texture (aka Ambient Occlusion)
*
* Both 'Lightmaps' and dedicated 'ambient occlusion maps' are
......@@ -483,14 +483,14 @@ THREE.AssimpLoader.prototype = {
* Contains the color of a perfect mirror reflection.
* Rarely used, almost never for real-time applications.
*/
var aiTextureType_REFLECTION = 0xB;
//var aiTextureType_REFLECTION = 0xB;
/** Unknown texture
*
* A texture reference that does not match any of the definitions
* above is considered to be 'unknown'. It is still imported,
* but is excluded from any further postprocessing.
*/
var aiTextureType_UNKNOWN = 0xC;
//var aiTextureType_UNKNOWN = 0xC;
var BONESPERVERT = 4;
function ASSBIN_MESH_HAS_TEXCOORD( n ) {
......@@ -634,7 +634,7 @@ THREE.AssimpLoader.prototype = {
];
this.mFaces = [];
this.mBones = [];
this.hookupSkeletons = function ( scene, threeScene ) {
this.hookupSkeletons = function ( scene ) {
if ( this.mBones.length == 0 ) return;
......@@ -668,7 +668,6 @@ THREE.AssimpLoader.prototype = {
var skeletonRoot = scene.findNode( this.mBones[ i ].mName );
if ( ! skeletonRoot ) return;
var threeSkeletonRoot = skeletonRoot.toTHREE( scene );
var threeSkeletonRootParent = threeSkeletonRoot.parent;
var threeSkeletonRootBone = cloneTreeToBones( threeSkeletonRoot, scene );
this.threeNode.add( threeSkeletonRootBone );
var bone = findMatchingBone( threeSkeletonRootBone, this.mBones[ i ].mName );
......@@ -808,32 +807,6 @@ THREE.AssimpLoader.prototype = {
}
function aiVector2D() {
this.x = 0;
this.y = 0;
this.toTHREE = function () {
return new THREE.Vector2( this.x, this.y );
};
}
function aiVector4D() {
this.w = 0;
this.x = 0;
this.y = 0;
this.z = 0;
this.toTHREE = function () {
return new THREE.Vector4( this.w, this.x, this.y, this.z );
};
}
function aiColor3D() {
this.r = 0;
......@@ -1051,9 +1024,8 @@ THREE.AssimpLoader.prototype = {
this.mNumAllocated = 0;
this.mNumProperties = 0;
this.mProperties = [];
this.toTHREE = function ( scene ) {
this.toTHREE = function () {
var name = this.mProperties[ 0 ].dataAsString();
var mat = new THREE.MeshPhongMaterial();
for ( var i = 0; i < this.mProperties.length; i ++ ) {
......@@ -1224,7 +1196,7 @@ THREE.AssimpLoader.prototype = {
};
this.toTHREE = function ( o, tps ) {
this.toTHREE = function ( o ) {
this.sortKeys();
var length = this.getLength();
......@@ -1390,7 +1362,7 @@ THREE.AssimpLoader.prototype = {
var o = this.mRootNode.toTHREE( this );
for ( var i in this.mMeshes )
this.mMeshes[ i ].hookupSkeletons( this, o );
this.mMeshes[ i ].hookupSkeletons( this );
if ( this.mAnimations.length > 0 ) {
......@@ -1492,26 +1464,6 @@ THREE.AssimpLoader.prototype = {
}
function Read_aiVector2D( stream ) {
var v = new aiVector2D();
v.x = readFloat( stream );
v.y = readFloat( stream );
return v;
}
function Read_aiVector4D( stream ) {
var v = new aiVector4D();
v.w = readFloat( stream );
v.x = readFloat( stream );
v.y = readFloat( stream );
v.z = readFloat( stream );
return v;
}
function Read_aiColor3D( stream ) {
var c = new aiColor3D();
......@@ -1587,30 +1539,6 @@ THREE.AssimpLoader.prototype = {
}
function ReadArray( stream, data, size ) {
for ( var i = 0; i < size; i ++ ) data[ i ] = Read( stream );
}
function ReadArray_aiVector2D( stream, data, size ) {
for ( var i = 0; i < size; i ++ ) data[ i ] = Read_aiVector2D( stream );
}
function ReadArray_aiVector3D( stream, data, size ) {
for ( var i = 0; i < size; i ++ ) data[ i ] = Read_aiVector3D( stream );
}
function ReadArray_aiVector4D( stream, data, size ) {
for ( var i = 0; i < size; i ++ ) data[ i ] = Read_aiVector4D( stream );
}
function ReadArray_aiVertexWeight( stream, data, size ) {
for ( var i = 0; i < size; i ++ ) data[ i ] = Read_aiVertexWeight( stream );
......@@ -1855,8 +1783,6 @@ THREE.AssimpLoader.prototype = {
// if there are less than 2^16 vertices, we can simply use 16 bit integers ...
mesh.mFaces = [];
var indexCounter = 0;
mesh.mIndexArray = [];
for ( var i = 0; i < mesh.mNumFaces; ++ i ) {
......
......@@ -19,9 +19,7 @@ import {
Skeleton,
SkinnedMesh,
TextureLoader,
Vector2,
Vector3,
Vector4
Vector3
} from "../../../build/three.module.js";
var AssimpLoader = function ( manager ) {
......@@ -381,7 +379,7 @@ AssimpLoader.prototype = {
var ASSBIN_MESH_HAS_COLOR_BASE = 0x10000;
var AI_MAX_NUMBER_OF_COLOR_SETS = 1;
var AI_MAX_NUMBER_OF_TEXTURECOORDS = 4;
var aiLightSource_UNDEFINED = 0x0;
//var aiLightSource_UNDEFINED = 0x0;
//! A directional light source has a well-defined direction
//! but is infinitely far away. That's quite a good
//! approximation for sun light.
......@@ -389,7 +387,7 @@ AssimpLoader.prototype = {
//! A point light source has a well-defined position
//! in space but no direction - it emits light in all
//! directions. A normal bulb is a point light.
var aiLightSource_POINT = 0x2;
//var aiLightSource_POINT = 0x2;
//! A spot light source emits light in a specific
//! angle. It has a position and a direction it is pointing to.
//! A good example for a spot light is a light spot in
......@@ -400,49 +398,49 @@ AssimpLoader.prototype = {
//! Typically, there's at most one ambient light in a scene.
//! This light type doesn't have a valid position, direction, or
//! other properties, just a color.
var aiLightSource_AMBIENT = 0x4;
//var aiLightSource_AMBIENT = 0x4;
/** Flat shading. Shading is done on per-face base,
* diffuse only. Also known as 'faceted shading'.
*/
var aiShadingMode_Flat = 0x1;
//var aiShadingMode_Flat = 0x1;
/** Simple Gouraud shading.
*/
var aiShadingMode_Gouraud = 0x2;
//var aiShadingMode_Gouraud = 0x2;
/** Phong-Shading -
*/
var aiShadingMode_Phong = 0x3;
//var aiShadingMode_Phong = 0x3;
/** Phong-Blinn-Shading
*/
var aiShadingMode_Blinn = 0x4;
//var aiShadingMode_Blinn = 0x4;
/** Toon-Shading per pixel
*
* Also known as 'comic' shader.
*/
var aiShadingMode_Toon = 0x5;
//var aiShadingMode_Toon = 0x5;
/** OrenNayar-Shading per pixel
*
* Extension to standard Lambertian shading, taking the
* roughness of the material into account
*/
var aiShadingMode_OrenNayar = 0x6;
//var aiShadingMode_OrenNayar = 0x6;
/** Minnaert-Shading per pixel
*
* Extension to standard Lambertian shading, taking the
* "darkness" of the material into account
*/
var aiShadingMode_Minnaert = 0x7;
//var aiShadingMode_Minnaert = 0x7;
/** CookTorrance-Shading per pixel
*
* Special shader for metallic surfaces.
*/
var aiShadingMode_CookTorrance = 0x8;
//var aiShadingMode_CookTorrance = 0x8;
/** No shading at all. Constant light influence of 1.0.
*/
var aiShadingMode_NoShading = 0x9;
//var aiShadingMode_NoShading = 0x9;
/** Fresnel shading
*/
var aiShadingMode_Fresnel = 0xa;
var aiTextureType_NONE = 0x0;
//var aiShadingMode_Fresnel = 0xa;
//var aiTextureType_NONE = 0x0;
/** The texture is combined with the result of the diffuse
* lighting equation.
*/
......@@ -450,21 +448,21 @@ AssimpLoader.prototype = {
/** The texture is combined with the result of the specular
* lighting equation.
*/
var aiTextureType_SPECULAR = 0x2;
//var aiTextureType_SPECULAR = 0x2;
/** The texture is combined with the result of the ambient
* lighting equation.
*/
var aiTextureType_AMBIENT = 0x3;
//var aiTextureType_AMBIENT = 0x3;
/** The texture is added to the result of the lighting
* calculation. It isn't influenced by incoming light.
*/
var aiTextureType_EMISSIVE = 0x4;
//var aiTextureType_EMISSIVE = 0x4;
/** The texture is a height map.
*
* By convention, higher gray-scale values stand for
* higher elevations from the base height.
*/
var aiTextureType_HEIGHT = 0x5;
//var aiTextureType_HEIGHT = 0x5;
/** The texture is a (tangent space) normal-map.
*
* Again, there are several conventions for tangent-space
......@@ -479,7 +477,7 @@ AssimpLoader.prototype = {
* function defined to map the linear color values in the
* texture to a suitable exponent. Have fun.
*/
var aiTextureType_SHININESS = 0x7;
//var aiTextureType_SHININESS = 0x7;
/** The texture defines per-pixel opacity.
*
* Usually 'white' means opaque and 'black' means
......@@ -491,7 +489,7 @@ AssimpLoader.prototype = {
* The exact purpose and format is application-dependent.
* Higher color values stand for higher vertex displacements.
*/
var aiTextureType_DISPLACEMENT = 0x9;
//var aiTextureType_DISPLACEMENT = 0x9;
/** Lightmap texture (aka Ambient Occlusion)
*
* Both 'Lightmaps' and dedicated 'ambient occlusion maps' are
......@@ -505,14 +503,14 @@ AssimpLoader.prototype = {
* Contains the color of a perfect mirror reflection.
* Rarely used, almost never for real-time applications.
*/
var aiTextureType_REFLECTION = 0xB;
//var aiTextureType_REFLECTION = 0xB;
/** Unknown texture
*
* A texture reference that does not match any of the definitions
* above is considered to be 'unknown'. It is still imported,
* but is excluded from any further postprocessing.
*/
var aiTextureType_UNKNOWN = 0xC;
//var aiTextureType_UNKNOWN = 0xC;
var BONESPERVERT = 4;
function ASSBIN_MESH_HAS_TEXCOORD( n ) {
......@@ -656,7 +654,7 @@ AssimpLoader.prototype = {
];
this.mFaces = [];
this.mBones = [];
this.hookupSkeletons = function ( scene, threeScene ) {
this.hookupSkeletons = function ( scene ) {
if ( this.mBones.length == 0 ) return;
......@@ -690,7 +688,6 @@ AssimpLoader.prototype = {
var skeletonRoot = scene.findNode( this.mBones[ i ].mName );
if ( ! skeletonRoot ) return;
var threeSkeletonRoot = skeletonRoot.toTHREE( scene );
var threeSkeletonRootParent = threeSkeletonRoot.parent;
var threeSkeletonRootBone = cloneTreeToBones( threeSkeletonRoot, scene );
this.threeNode.add( threeSkeletonRootBone );
var bone = findMatchingBone( threeSkeletonRootBone, this.mBones[ i ].mName );
......@@ -830,32 +827,6 @@ AssimpLoader.prototype = {
}
function aiVector2D() {
this.x = 0;
this.y = 0;
this.toTHREE = function () {
return new Vector2( this.x, this.y );
};
}
function aiVector4D() {
this.w = 0;
this.x = 0;
this.y = 0;
this.z = 0;
this.toTHREE = function () {
return new Vector4( this.w, this.x, this.y, this.z );
};
}
function aiColor3D() {
this.r = 0;
......@@ -1073,9 +1044,8 @@ AssimpLoader.prototype = {
this.mNumAllocated = 0;
this.mNumProperties = 0;
this.mProperties = [];
this.toTHREE = function ( scene ) {
this.toTHREE = function () {
var name = this.mProperties[ 0 ].dataAsString();
var mat = new MeshPhongMaterial();
for ( var i = 0; i < this.mProperties.length; i ++ ) {
......@@ -1246,7 +1216,7 @@ AssimpLoader.prototype = {
};
this.toTHREE = function ( o, tps ) {
this.toTHREE = function ( o ) {
this.sortKeys();
var length = this.getLength();
......@@ -1412,7 +1382,7 @@ AssimpLoader.prototype = {
var o = this.mRootNode.toTHREE( this );
for ( var i in this.mMeshes )
this.mMeshes[ i ].hookupSkeletons( this, o );
this.mMeshes[ i ].hookupSkeletons( this );
if ( this.mAnimations.length > 0 ) {
......@@ -1514,26 +1484,6 @@ AssimpLoader.prototype = {
}
function Read_aiVector2D( stream ) {
var v = new aiVector2D();
v.x = readFloat( stream );
v.y = readFloat( stream );
return v;
}
function Read_aiVector4D( stream ) {
var v = new aiVector4D();
v.w = readFloat( stream );
v.x = readFloat( stream );
v.y = readFloat( stream );
v.z = readFloat( stream );
return v;
}
function Read_aiColor3D( stream ) {
var c = new aiColor3D();
......@@ -1609,30 +1559,6 @@ AssimpLoader.prototype = {
}
function ReadArray( stream, data, size ) {
for ( var i = 0; i < size; i ++ ) data[ i ] = Read( stream );
}
function ReadArray_aiVector2D( stream, data, size ) {
for ( var i = 0; i < size; i ++ ) data[ i ] = Read_aiVector2D( stream );
}
function ReadArray_aiVector3D( stream, data, size ) {
for ( var i = 0; i < size; i ++ ) data[ i ] = Read_aiVector3D( stream );
}
function ReadArray_aiVector4D( stream, data, size ) {
for ( var i = 0; i < size; i ++ ) data[ i ] = Read_aiVector4D( stream );
}
function ReadArray_aiVertexWeight( stream, data, size ) {
for ( var i = 0; i < size; i ++ ) data[ i ] = Read_aiVertexWeight( stream );
......@@ -1877,8 +1803,6 @@ AssimpLoader.prototype = {
// if there are less than 2^16 vertices, we can simply use 16 bit integers ...
mesh.mFaces = [];
var indexCounter = 0;
mesh.mIndexArray = [];
for ( var i = 0; i < mesh.mNumFaces; ++ i ) {
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册