|
@@ -19,9 +19,7 @@ import {
|
|
Skeleton,
|
|
Skeleton,
|
|
SkinnedMesh,
|
|
SkinnedMesh,
|
|
TextureLoader,
|
|
TextureLoader,
|
|
- Vector2,
|
|
|
|
- Vector3,
|
|
|
|
- Vector4
|
|
|
|
|
|
+ Vector3
|
|
} from "../../../build/three.module.js";
|
|
} from "../../../build/three.module.js";
|
|
|
|
|
|
var AssimpLoader = function ( manager ) {
|
|
var AssimpLoader = function ( manager ) {
|
|
@@ -381,7 +379,7 @@ AssimpLoader.prototype = {
|
|
var ASSBIN_MESH_HAS_COLOR_BASE = 0x10000;
|
|
var ASSBIN_MESH_HAS_COLOR_BASE = 0x10000;
|
|
var AI_MAX_NUMBER_OF_COLOR_SETS = 1;
|
|
var AI_MAX_NUMBER_OF_COLOR_SETS = 1;
|
|
var AI_MAX_NUMBER_OF_TEXTURECOORDS = 4;
|
|
var AI_MAX_NUMBER_OF_TEXTURECOORDS = 4;
|
|
- var aiLightSource_UNDEFINED = 0x0;
|
|
|
|
|
|
+ //var aiLightSource_UNDEFINED = 0x0;
|
|
//! A directional light source has a well-defined direction
|
|
//! A directional light source has a well-defined direction
|
|
//! but is infinitely far away. That's quite a good
|
|
//! but is infinitely far away. That's quite a good
|
|
//! approximation for sun light.
|
|
//! approximation for sun light.
|
|
@@ -389,7 +387,7 @@ AssimpLoader.prototype = {
|
|
//! A point light source has a well-defined position
|
|
//! A point light source has a well-defined position
|
|
//! in space but no direction - it emits light in all
|
|
//! in space but no direction - it emits light in all
|
|
//! directions. A normal bulb is a point light.
|
|
//! 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
|
|
//! A spot light source emits light in a specific
|
|
//! angle. It has a position and a direction it is pointing to.
|
|
//! angle. It has a position and a direction it is pointing to.
|
|
//! A good example for a spot light is a light spot in
|
|
//! 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.
|
|
//! Typically, there's at most one ambient light in a scene.
|
|
//! This light type doesn't have a valid position, direction, or
|
|
//! This light type doesn't have a valid position, direction, or
|
|
//! other properties, just a color.
|
|
//! other properties, just a color.
|
|
- var aiLightSource_AMBIENT = 0x4;
|
|
|
|
|
|
+ //var aiLightSource_AMBIENT = 0x4;
|
|
/** Flat shading. Shading is done on per-face base,
|
|
/** Flat shading. Shading is done on per-face base,
|
|
* diffuse only. Also known as 'faceted shading'.
|
|
* diffuse only. Also known as 'faceted shading'.
|
|
*/
|
|
*/
|
|
- var aiShadingMode_Flat = 0x1;
|
|
|
|
|
|
+ //var aiShadingMode_Flat = 0x1;
|
|
/** Simple Gouraud shading.
|
|
/** Simple Gouraud shading.
|
|
*/
|
|
*/
|
|
- var aiShadingMode_Gouraud = 0x2;
|
|
|
|
|
|
+ //var aiShadingMode_Gouraud = 0x2;
|
|
/** Phong-Shading -
|
|
/** Phong-Shading -
|
|
*/
|
|
*/
|
|
- var aiShadingMode_Phong = 0x3;
|
|
|
|
|
|
+ //var aiShadingMode_Phong = 0x3;
|
|
/** Phong-Blinn-Shading
|
|
/** Phong-Blinn-Shading
|
|
*/
|
|
*/
|
|
- var aiShadingMode_Blinn = 0x4;
|
|
|
|
|
|
+ //var aiShadingMode_Blinn = 0x4;
|
|
/** Toon-Shading per pixel
|
|
/** Toon-Shading per pixel
|
|
*
|
|
*
|
|
* Also known as 'comic' shader.
|
|
* Also known as 'comic' shader.
|
|
*/
|
|
*/
|
|
- var aiShadingMode_Toon = 0x5;
|
|
|
|
|
|
+ //var aiShadingMode_Toon = 0x5;
|
|
/** OrenNayar-Shading per pixel
|
|
/** OrenNayar-Shading per pixel
|
|
*
|
|
*
|
|
* Extension to standard Lambertian shading, taking the
|
|
* Extension to standard Lambertian shading, taking the
|
|
* roughness of the material into account
|
|
* roughness of the material into account
|
|
*/
|
|
*/
|
|
- var aiShadingMode_OrenNayar = 0x6;
|
|
|
|
|
|
+ //var aiShadingMode_OrenNayar = 0x6;
|
|
/** Minnaert-Shading per pixel
|
|
/** Minnaert-Shading per pixel
|
|
*
|
|
*
|
|
* Extension to standard Lambertian shading, taking the
|
|
* Extension to standard Lambertian shading, taking the
|
|
* "darkness" of the material into account
|
|
* "darkness" of the material into account
|
|
*/
|
|
*/
|
|
- var aiShadingMode_Minnaert = 0x7;
|
|
|
|
|
|
+ //var aiShadingMode_Minnaert = 0x7;
|
|
/** CookTorrance-Shading per pixel
|
|
/** CookTorrance-Shading per pixel
|
|
*
|
|
*
|
|
* Special shader for metallic surfaces.
|
|
* Special shader for metallic surfaces.
|
|
*/
|
|
*/
|
|
- var aiShadingMode_CookTorrance = 0x8;
|
|
|
|
|
|
+ //var aiShadingMode_CookTorrance = 0x8;
|
|
/** No shading at all. Constant light influence of 1.0.
|
|
/** No shading at all. Constant light influence of 1.0.
|
|
*/
|
|
*/
|
|
- var aiShadingMode_NoShading = 0x9;
|
|
|
|
|
|
+ //var aiShadingMode_NoShading = 0x9;
|
|
/** Fresnel shading
|
|
/** 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
|
|
/** The texture is combined with the result of the diffuse
|
|
* lighting equation.
|
|
* lighting equation.
|
|
*/
|
|
*/
|
|
@@ -450,21 +448,21 @@ AssimpLoader.prototype = {
|
|
/** The texture is combined with the result of the specular
|
|
/** The texture is combined with the result of the specular
|
|
* lighting equation.
|
|
* lighting equation.
|
|
*/
|
|
*/
|
|
- var aiTextureType_SPECULAR = 0x2;
|
|
|
|
|
|
+ //var aiTextureType_SPECULAR = 0x2;
|
|
/** The texture is combined with the result of the ambient
|
|
/** The texture is combined with the result of the ambient
|
|
* lighting equation.
|
|
* lighting equation.
|
|
*/
|
|
*/
|
|
- var aiTextureType_AMBIENT = 0x3;
|
|
|
|
|
|
+ //var aiTextureType_AMBIENT = 0x3;
|
|
/** The texture is added to the result of the lighting
|
|
/** The texture is added to the result of the lighting
|
|
* calculation. It isn't influenced by incoming light.
|
|
* calculation. It isn't influenced by incoming light.
|
|
*/
|
|
*/
|
|
- var aiTextureType_EMISSIVE = 0x4;
|
|
|
|
|
|
+ //var aiTextureType_EMISSIVE = 0x4;
|
|
/** The texture is a height map.
|
|
/** The texture is a height map.
|
|
*
|
|
*
|
|
* By convention, higher gray-scale values stand for
|
|
* By convention, higher gray-scale values stand for
|
|
* higher elevations from the base height.
|
|
* higher elevations from the base height.
|
|
*/
|
|
*/
|
|
- var aiTextureType_HEIGHT = 0x5;
|
|
|
|
|
|
+ //var aiTextureType_HEIGHT = 0x5;
|
|
/** The texture is a (tangent space) normal-map.
|
|
/** The texture is a (tangent space) normal-map.
|
|
*
|
|
*
|
|
* Again, there are several conventions for tangent-space
|
|
* Again, there are several conventions for tangent-space
|
|
@@ -479,7 +477,7 @@ AssimpLoader.prototype = {
|
|
* function defined to map the linear color values in the
|
|
* function defined to map the linear color values in the
|
|
* texture to a suitable exponent. Have fun.
|
|
* texture to a suitable exponent. Have fun.
|
|
*/
|
|
*/
|
|
- var aiTextureType_SHININESS = 0x7;
|
|
|
|
|
|
+ //var aiTextureType_SHININESS = 0x7;
|
|
/** The texture defines per-pixel opacity.
|
|
/** The texture defines per-pixel opacity.
|
|
*
|
|
*
|
|
* Usually 'white' means opaque and 'black' means
|
|
* Usually 'white' means opaque and 'black' means
|
|
@@ -491,7 +489,7 @@ AssimpLoader.prototype = {
|
|
* The exact purpose and format is application-dependent.
|
|
* The exact purpose and format is application-dependent.
|
|
* Higher color values stand for higher vertex displacements.
|
|
* Higher color values stand for higher vertex displacements.
|
|
*/
|
|
*/
|
|
- var aiTextureType_DISPLACEMENT = 0x9;
|
|
|
|
|
|
+ //var aiTextureType_DISPLACEMENT = 0x9;
|
|
/** Lightmap texture (aka Ambient Occlusion)
|
|
/** Lightmap texture (aka Ambient Occlusion)
|
|
*
|
|
*
|
|
* Both 'Lightmaps' and dedicated 'ambient occlusion maps' are
|
|
* Both 'Lightmaps' and dedicated 'ambient occlusion maps' are
|
|
@@ -505,14 +503,14 @@ AssimpLoader.prototype = {
|
|
* Contains the color of a perfect mirror reflection.
|
|
* Contains the color of a perfect mirror reflection.
|
|
* Rarely used, almost never for real-time applications.
|
|
* Rarely used, almost never for real-time applications.
|
|
*/
|
|
*/
|
|
- var aiTextureType_REFLECTION = 0xB;
|
|
|
|
|
|
+ //var aiTextureType_REFLECTION = 0xB;
|
|
/** Unknown texture
|
|
/** Unknown texture
|
|
*
|
|
*
|
|
* A texture reference that does not match any of the definitions
|
|
* A texture reference that does not match any of the definitions
|
|
* above is considered to be 'unknown'. It is still imported,
|
|
* above is considered to be 'unknown'. It is still imported,
|
|
* but is excluded from any further postprocessing.
|
|
* but is excluded from any further postprocessing.
|
|
*/
|
|
*/
|
|
- var aiTextureType_UNKNOWN = 0xC;
|
|
|
|
|
|
+ //var aiTextureType_UNKNOWN = 0xC;
|
|
var BONESPERVERT = 4;
|
|
var BONESPERVERT = 4;
|
|
|
|
|
|
function ASSBIN_MESH_HAS_TEXCOORD( n ) {
|
|
function ASSBIN_MESH_HAS_TEXCOORD( n ) {
|
|
@@ -656,7 +654,7 @@ AssimpLoader.prototype = {
|
|
];
|
|
];
|
|
this.mFaces = [];
|
|
this.mFaces = [];
|
|
this.mBones = [];
|
|
this.mBones = [];
|
|
- this.hookupSkeletons = function ( scene, threeScene ) {
|
|
|
|
|
|
+ this.hookupSkeletons = function ( scene ) {
|
|
|
|
|
|
if ( this.mBones.length == 0 ) return;
|
|
if ( this.mBones.length == 0 ) return;
|
|
|
|
|
|
@@ -690,7 +688,6 @@ AssimpLoader.prototype = {
|
|
var skeletonRoot = scene.findNode( this.mBones[ i ].mName );
|
|
var skeletonRoot = scene.findNode( this.mBones[ i ].mName );
|
|
if ( ! skeletonRoot ) return;
|
|
if ( ! skeletonRoot ) return;
|
|
var threeSkeletonRoot = skeletonRoot.toTHREE( scene );
|
|
var threeSkeletonRoot = skeletonRoot.toTHREE( scene );
|
|
- var threeSkeletonRootParent = threeSkeletonRoot.parent;
|
|
|
|
var threeSkeletonRootBone = cloneTreeToBones( threeSkeletonRoot, scene );
|
|
var threeSkeletonRootBone = cloneTreeToBones( threeSkeletonRoot, scene );
|
|
this.threeNode.add( threeSkeletonRootBone );
|
|
this.threeNode.add( threeSkeletonRootBone );
|
|
var bone = findMatchingBone( threeSkeletonRootBone, this.mBones[ i ].mName );
|
|
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() {
|
|
function aiColor3D() {
|
|
|
|
|
|
this.r = 0;
|
|
this.r = 0;
|
|
@@ -1073,9 +1044,8 @@ AssimpLoader.prototype = {
|
|
this.mNumAllocated = 0;
|
|
this.mNumAllocated = 0;
|
|
this.mNumProperties = 0;
|
|
this.mNumProperties = 0;
|
|
this.mProperties = [];
|
|
this.mProperties = [];
|
|
- this.toTHREE = function ( scene ) {
|
|
|
|
|
|
+ this.toTHREE = function () {
|
|
|
|
|
|
- var name = this.mProperties[ 0 ].dataAsString();
|
|
|
|
var mat = new MeshPhongMaterial();
|
|
var mat = new MeshPhongMaterial();
|
|
|
|
|
|
for ( var i = 0; i < this.mProperties.length; i ++ ) {
|
|
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();
|
|
this.sortKeys();
|
|
var length = this.getLength();
|
|
var length = this.getLength();
|
|
@@ -1412,7 +1382,7 @@ AssimpLoader.prototype = {
|
|
var o = this.mRootNode.toTHREE( this );
|
|
var o = this.mRootNode.toTHREE( this );
|
|
|
|
|
|
for ( var i in this.mMeshes )
|
|
for ( var i in this.mMeshes )
|
|
- this.mMeshes[ i ].hookupSkeletons( this, o );
|
|
|
|
|
|
+ this.mMeshes[ i ].hookupSkeletons( this );
|
|
|
|
|
|
if ( this.mAnimations.length > 0 ) {
|
|
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 ) {
|
|
function Read_aiColor3D( stream ) {
|
|
|
|
|
|
var c = new aiColor3D();
|
|
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 ) {
|
|
function ReadArray_aiVertexWeight( stream, data, size ) {
|
|
|
|
|
|
for ( var i = 0; i < size; i ++ ) data[ i ] = Read_aiVertexWeight( stream );
|
|
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 ...
|
|
// if there are less than 2^16 vertices, we can simply use 16 bit integers ...
|
|
mesh.mFaces = [];
|
|
mesh.mFaces = [];
|
|
-
|
|
|
|
- var indexCounter = 0;
|
|
|
|
mesh.mIndexArray = [];
|
|
mesh.mIndexArray = [];
|
|
|
|
|
|
for ( var i = 0; i < mesh.mNumFaces; ++ i ) {
|
|
for ( var i = 0; i < mesh.mNumFaces; ++ i ) {
|