Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
Ablesons
three.js
提交
cd3807b3
T
three.js
项目概览
Ablesons
/
three.js
与 Fork 源项目一致
从无法访问的项目Fork
通知
2
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
T
three.js
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
cd3807b3
编写于
2月 15, 2017
作者:
M
Mr.doob
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Updated builds.
上级
07b64132
变更
3
显示空白变更内容
内联
并排
Showing
3 changed file
with
624 addition
and
602 deletion
+624
-602
build/three.js
build/three.js
+72
-61
build/three.min.js
build/three.min.js
+480
-480
build/three.module.js
build/three.module.js
+72
-61
未找到文件。
build/three.js
浏览文件 @
cd3807b3
...
...
@@ -5030,7 +5030,7 @@
var skinbase_vertex = "#ifdef USE_SKINNING\n\tmat4 boneMatX = getBoneMatrix( skinIndex.x );\n\tmat4 boneMatY = getBoneMatrix( skinIndex.y );\n\tmat4 boneMatZ = getBoneMatrix( skinIndex.z );\n\tmat4 boneMatW = getBoneMatrix( skinIndex.w );\n#endif";
var skinning_pars_vertex = "#ifdef USE_SKINNING\n\tuniform mat4 bindMatrix;\n\tuniform mat4 bindMatrixInverse;\n\t#ifdef BONE_TEXTURE\n\t\tuniform sampler2D boneTexture;\n\t\tuniform int boneTexture
Width;\n\t\tuniform int boneTextureHeight;\n\t\tmat4 getBoneMatrix( const in float i ) {\n\t\t\tfloat j = i * 4.0;\n\t\t\tfloat x = mod( j, float( boneTextureWidth ) );\n\t\t\tfloat y = floor( j / float( boneTextureWidth ) );\n\t\t\tfloat dx = 1.0 / float( boneTextureWidth );\n\t\t\tfloat dy = 1.0 / float( boneTextureHeight
);\n\t\t\ty = dy * ( y + 0.5 );\n\t\t\tvec4 v1 = texture2D( boneTexture, vec2( dx * ( x + 0.5 ), y ) );\n\t\t\tvec4 v2 = texture2D( boneTexture, vec2( dx * ( x + 1.5 ), y ) );\n\t\t\tvec4 v3 = texture2D( boneTexture, vec2( dx * ( x + 2.5 ), y ) );\n\t\t\tvec4 v4 = texture2D( boneTexture, vec2( dx * ( x + 3.5 ), y ) );\n\t\t\tmat4 bone = mat4( v1, v2, v3, v4 );\n\t\t\treturn bone;\n\t\t}\n\t#else\n\t\tuniform mat4 boneMatrices[ MAX_BONES ];\n\t\tmat4 getBoneMatrix( const in float i ) {\n\t\t\tmat4 bone = boneMatrices[ int(i) ];\n\t\t\treturn bone;\n\t\t}\n\t#endif\n#endif\n";
var skinning_pars_vertex = "#ifdef USE_SKINNING\n\tuniform mat4 bindMatrix;\n\tuniform mat4 bindMatrixInverse;\n\t#ifdef BONE_TEXTURE\n\t\tuniform sampler2D boneTexture;\n\t\tuniform int boneTexture
Size;\n\t\tmat4 getBoneMatrix( const in float i ) {\n\t\t\tfloat j = i * 4.0;\n\t\t\tfloat x = mod( j, float( boneTextureSize ) );\n\t\t\tfloat y = floor( j / float( boneTextureSize ) );\n\t\t\tfloat dx = 1.0 / float( boneTextureSize );\n\t\t\tfloat dy = 1.0 / float( boneTextureSize
);\n\t\t\ty = dy * ( y + 0.5 );\n\t\t\tvec4 v1 = texture2D( boneTexture, vec2( dx * ( x + 0.5 ), y ) );\n\t\t\tvec4 v2 = texture2D( boneTexture, vec2( dx * ( x + 1.5 ), y ) );\n\t\t\tvec4 v3 = texture2D( boneTexture, vec2( dx * ( x + 2.5 ), y ) );\n\t\t\tvec4 v4 = texture2D( boneTexture, vec2( dx * ( x + 3.5 ), y ) );\n\t\t\tmat4 bone = mat4( v1, v2, v3, v4 );\n\t\t\treturn bone;\n\t\t}\n\t#else\n\t\tuniform mat4 boneMatrices[ MAX_BONES ];\n\t\tmat4 getBoneMatrix( const in float i ) {\n\t\t\tmat4 bone = boneMatrices[ int(i) ];\n\t\t\treturn bone;\n\t\t}\n\t#endif\n#endif\n";
var skinning_vertex = "#ifdef USE_SKINNING\n\tvec4 skinVertex = bindMatrix * vec4( transformed, 1.0 );\n\tvec4 skinned = vec4( 0.0 );\n\tskinned += boneMatX * skinVertex * skinWeight.x;\n\tskinned += boneMatY * skinVertex * skinWeight.y;\n\tskinned += boneMatZ * skinVertex * skinWeight.z;\n\tskinned += boneMatW * skinVertex * skinWeight.w;\n\tskinned = bindMatrixInverse * skinned;\n#endif\n";
...
...
@@ -16496,7 +16496,6 @@
prefixVertex = [
'precision ' + parameters.precision + ' float;',
'precision ' + parameters.precision + ' int;',
...
...
@@ -16512,7 +16511,6 @@
( parameters.useFog && parameters.fog ) ? '#define USE_FOG' : '',
( parameters.useFog && parameters.fogExp ) ? '#define FOG_EXP2' : '',
parameters.map ? '#define USE_MAP' : '',
parameters.envMap ? '#define USE_ENVMAP' : '',
parameters.envMap ? '#define ' + envMapModeDefine : '',
...
...
@@ -16894,7 +16892,35 @@
function allocateBones( object ) {
if ( capabilities.floatVertexTextures && object && object.skeleton && object.skeleton.useVertexTexture ) {
var skeleton = object.skeleton;
var bones = skeleton.bones;
if ( capabilities.floatVertexTextures ) {
if ( skeleton.boneTexture === undefined ) {
// layout (1 matrix = 4 pixels)
// RGBA RGBA RGBA RGBA (=> column1, column2, column3, column4)
// with 8x8 pixel texture max 16 bones * 4 pixels = (8 * 8)
// 16x16 pixel texture max 64 bones * 4 pixels = (16 * 16)
// 32x32 pixel texture max 256 bones * 4 pixels = (32 * 32)
// 64x64 pixel texture max 1024 bones * 4 pixels = (64 * 64)
var size = Math.sqrt( bones.length * 4 ); // 4 pixels needed for 1 matrix
size = _Math.nextPowerOfTwo( Math.ceil( size ) );
size = Math.max( size, 4 );
var boneMatrices = new Float32Array( size * size * 4 ); // 4 floats per RGBA pixel
boneMatrices.set( skeleton.boneMatrices ); // copy current values
var boneTexture = new DataTexture( boneMatrices, size, size, RGBAFormat, FloatType );
skeleton.boneMatrices = boneMatrices;
skeleton.boneTexture = boneTexture;
skeleton.boneTextureSize = size;
}
return 1024;
...
...
@@ -16910,17 +16936,12 @@
var nVertexUniforms = capabilities.maxVertexUniforms;
var nVertexMatrices = Math.floor( ( nVertexUniforms - 20 ) / 4 );
var maxBones = nVertexMatrices;
if ( object && object.isSkinnedMesh ) {
maxBones = Math.min( object.skeleton.bones.length, maxBones );
if ( maxBones < object.skeleton.bones.length ) {
var maxBones = Math.min( nVertexMatrices, bones.length );
console.warn( 'WebGLRenderer: too many bones - ' + object.skeleton.bones.length + ', this GPU supports just ' + maxBones + ' (try OpenGL instead of ANGLE)' );
if ( maxBones < bones.length ) {
}
console.warn( 'THREE.WebGLRenderer: Skeleton has ' + bones.length + ' bones. This GPU supports ' + maxBones + '.' );
return 0;
}
...
...
@@ -16967,7 +16988,7 @@
// heuristics to create shader parameters according to lights in the scene
// (not to blow over maxLights budget)
var maxBones =
allocateBones( object )
;
var maxBones =
object.isSkinnedMesh ? allocateBones( object ) : 0
;
var precision = renderer.getPrecision();
if ( material.precision !== null ) {
...
...
@@ -17024,9 +17045,9 @@
sizeAttenuation: material.sizeAttenuation,
logarithmicDepthBuffer: capabilities.logarithmicDepthBuffer,
skinning: ( object && object.isSkinnedMesh ),
skinning: ( object && object.isSkinnedMesh )
&& maxBones > 0
,
maxBones: maxBones,
useVertexTexture: capabilities.floatVertexTextures
&& object && object.skeleton && object.skeleton.useVertexTexture
,
useVertexTexture: capabilities.floatVertexTextures,
morphTargets: material.morphTargets,
morphNormals: material.morphNormals,
...
...
@@ -21479,11 +21500,10 @@
if ( skeleton ) {
if ( capabilities.floatVertexTextures
&& skeleton.useVertexTexture
) {
if ( capabilities.floatVertexTextures ) {
p_uniforms.set( _gl, skeleton, 'boneTexture' );
p_uniforms.set( _gl, skeleton, 'boneTextureWidth' );
p_uniforms.set( _gl, skeleton, 'boneTextureHeight' );
p_uniforms.set( _gl, skeleton, 'boneTextureSize' );
} else {
...
...
@@ -23027,9 +23047,7 @@
* @author ikerr / http://verold.com
*/
function Skeleton( bones, boneInverses, useVertexTexture ) {
this.useVertexTexture = useVertexTexture !== undefined ? useVertexTexture : true;
function Skeleton( bones, boneInverses ) {
this.identityMatrix = new Matrix4();
...
...
@@ -23038,34 +23056,7 @@
bones = bones || [];
this.bones = bones.slice( 0 );
// create a bone texture or an array of floats
if ( this.useVertexTexture ) {
// layout (1 matrix = 4 pixels)
// RGBA RGBA RGBA RGBA (=> column1, column2, column3, column4)
// with 8x8 pixel texture max 16 bones * 4 pixels = (8 * 8)
// 16x16 pixel texture max 64 bones * 4 pixels = (16 * 16)
// 32x32 pixel texture max 256 bones * 4 pixels = (32 * 32)
// 64x64 pixel texture max 1024 bones * 4 pixels = (64 * 64)
var size = Math.sqrt( this.bones.length * 4 ); // 4 pixels needed for 1 matrix
size = _Math.nextPowerOfTwo( Math.ceil( size ) );
size = Math.max( size, 4 );
this.boneTextureWidth = size;
this.boneTextureHeight = size;
this.boneMatrices = new Float32Array( this.boneTextureWidth * this.boneTextureHeight * 4 ); // 4 floats per RGBA pixel
this.boneTexture = new DataTexture( this.boneMatrices, this.boneTextureWidth, this.boneTextureHeight, RGBAFormat, FloatType );
} else {
this.boneMatrices = new Float32Array( 16 * this.bones.length );
}
this.boneMatrices = new Float32Array( this.bones.length * 16 );
// use the supplied bone inverses or calculate the inverses
...
...
@@ -23170,22 +23161,27 @@
return function update() {
var bones = this.bones;
var boneInverses = this.boneInverses;
var boneMatrices = this.boneMatrices;
var boneTexture = this.boneTexture;
// flatten bone matrices to array
for ( var b = 0, bl =
this.
bones.length; b < bl; b ++ ) {
for ( var b = 0, bl = bones.length; b < bl; b ++ ) {
// compute the offset between the current and the original transform
var matrix =
this.bones[ b ] ? this.
bones[ b ].matrixWorld : this.identityMatrix;
var matrix =
bones[ b ] ?
bones[ b ].matrixWorld : this.identityMatrix;
offsetMatrix.multiplyMatrices( matrix,
this.
boneInverses[ b ] );
offsetMatrix.toArray(
this.
boneMatrices, b * 16 );
offsetMatrix.multiplyMatrices( matrix, boneInverses[ b ] );
offsetMatrix.toArray( boneMatrices, b * 16 );
}
if (
this.useVertexTexture
) {
if (
boneTexture !== undefined
) {
this.
boneTexture.needsUpdate = true;
boneTexture.needsUpdate = true;
}
...
...
@@ -23195,7 +23191,7 @@
clone: function () {
return new Skeleton( this.bones, this.boneInverses
, this.useVertexTexture
);
return new Skeleton( this.bones, this.boneInverses );
}
...
...
@@ -23229,7 +23225,7 @@
* @author ikerr / http://verold.com
*/
function SkinnedMesh( geometry, material
, useVertexTexture
) {
function SkinnedMesh( geometry, material ) {
Mesh.call( this, geometry, material );
...
...
@@ -23286,7 +23282,7 @@
this.normalizeSkinWeights();
this.updateMatrixWorld( true );
this.bind( new Skeleton( bones
, undefined, useVertexTexture
), this.matrixWorld );
this.bind( new Skeleton( bones ), this.matrixWorld );
}
...
...
@@ -23398,7 +23394,7 @@
clone: function () {
return new this.constructor( this.geometry, this.material
, this.skeleton.useVertexTexture
).copy( this );
return new this.constructor( this.geometry, this.material ).copy( this );
}
...
...
@@ -42038,6 +42034,21 @@
} );
Object.defineProperty( Skeleton.prototype, 'useVertexTexture', {
get: function () {
console.warn( 'THREE.Skeleton: useVertexTexture has been removed.' );
},
set: function () {
console.warn( 'THREE.Skeleton: useVertexTexture has been removed.' );
}
} );
//
PerspectiveCamera.prototype.setLens = function ( focalLength, filmGauge ) {
...
...
build/three.min.js
浏览文件 @
cd3807b3
因为 它太大了无法显示 source diff 。你可以改为
查看blob
。
build/three.module.js
浏览文件 @
cd3807b3
...
...
@@ -5024,7 +5024,7 @@ var shadowmask_pars_fragment = "float getShadowMask() {\n\tfloat shadow = 1.0;\n
var skinbase_vertex = "#ifdef USE_SKINNING\n\tmat4 boneMatX = getBoneMatrix( skinIndex.x );\n\tmat4 boneMatY = getBoneMatrix( skinIndex.y );\n\tmat4 boneMatZ = getBoneMatrix( skinIndex.z );\n\tmat4 boneMatW = getBoneMatrix( skinIndex.w );\n#endif";
var skinning_pars_vertex = "#ifdef USE_SKINNING\n\tuniform mat4 bindMatrix;\n\tuniform mat4 bindMatrixInverse;\n\t#ifdef BONE_TEXTURE\n\t\tuniform sampler2D boneTexture;\n\t\tuniform int boneTexture
Width;\n\t\tuniform int boneTextureHeight;\n\t\tmat4 getBoneMatrix( const in float i ) {\n\t\t\tfloat j = i * 4.0;\n\t\t\tfloat x = mod( j, float( boneTextureWidth ) );\n\t\t\tfloat y = floor( j / float( boneTextureWidth ) );\n\t\t\tfloat dx = 1.0 / float( boneTextureWidth );\n\t\t\tfloat dy = 1.0 / float( boneTextureHeight
);\n\t\t\ty = dy * ( y + 0.5 );\n\t\t\tvec4 v1 = texture2D( boneTexture, vec2( dx * ( x + 0.5 ), y ) );\n\t\t\tvec4 v2 = texture2D( boneTexture, vec2( dx * ( x + 1.5 ), y ) );\n\t\t\tvec4 v3 = texture2D( boneTexture, vec2( dx * ( x + 2.5 ), y ) );\n\t\t\tvec4 v4 = texture2D( boneTexture, vec2( dx * ( x + 3.5 ), y ) );\n\t\t\tmat4 bone = mat4( v1, v2, v3, v4 );\n\t\t\treturn bone;\n\t\t}\n\t#else\n\t\tuniform mat4 boneMatrices[ MAX_BONES ];\n\t\tmat4 getBoneMatrix( const in float i ) {\n\t\t\tmat4 bone = boneMatrices[ int(i) ];\n\t\t\treturn bone;\n\t\t}\n\t#endif\n#endif\n";
var skinning_pars_vertex = "#ifdef USE_SKINNING\n\tuniform mat4 bindMatrix;\n\tuniform mat4 bindMatrixInverse;\n\t#ifdef BONE_TEXTURE\n\t\tuniform sampler2D boneTexture;\n\t\tuniform int boneTexture
Size;\n\t\tmat4 getBoneMatrix( const in float i ) {\n\t\t\tfloat j = i * 4.0;\n\t\t\tfloat x = mod( j, float( boneTextureSize ) );\n\t\t\tfloat y = floor( j / float( boneTextureSize ) );\n\t\t\tfloat dx = 1.0 / float( boneTextureSize );\n\t\t\tfloat dy = 1.0 / float( boneTextureSize
);\n\t\t\ty = dy * ( y + 0.5 );\n\t\t\tvec4 v1 = texture2D( boneTexture, vec2( dx * ( x + 0.5 ), y ) );\n\t\t\tvec4 v2 = texture2D( boneTexture, vec2( dx * ( x + 1.5 ), y ) );\n\t\t\tvec4 v3 = texture2D( boneTexture, vec2( dx * ( x + 2.5 ), y ) );\n\t\t\tvec4 v4 = texture2D( boneTexture, vec2( dx * ( x + 3.5 ), y ) );\n\t\t\tmat4 bone = mat4( v1, v2, v3, v4 );\n\t\t\treturn bone;\n\t\t}\n\t#else\n\t\tuniform mat4 boneMatrices[ MAX_BONES ];\n\t\tmat4 getBoneMatrix( const in float i ) {\n\t\t\tmat4 bone = boneMatrices[ int(i) ];\n\t\t\treturn bone;\n\t\t}\n\t#endif\n#endif\n";
var skinning_vertex = "#ifdef USE_SKINNING\n\tvec4 skinVertex = bindMatrix * vec4( transformed, 1.0 );\n\tvec4 skinned = vec4( 0.0 );\n\tskinned += boneMatX * skinVertex * skinWeight.x;\n\tskinned += boneMatY * skinVertex * skinWeight.y;\n\tskinned += boneMatZ * skinVertex * skinWeight.z;\n\tskinned += boneMatW * skinVertex * skinWeight.w;\n\tskinned = bindMatrixInverse * skinned;\n#endif\n";
...
...
@@ -16490,7 +16490,6 @@ function WebGLProgram( renderer, code, material, parameters ) {
prefixVertex = [
'precision ' + parameters.precision + ' float;',
'precision ' + parameters.precision + ' int;',
...
...
@@ -16506,7 +16505,6 @@ function WebGLProgram( renderer, code, material, parameters ) {
( parameters.useFog && parameters.fog ) ? '#define USE_FOG' : '',
( parameters.useFog && parameters.fogExp ) ? '#define FOG_EXP2' : '',
parameters.map ? '#define USE_MAP' : '',
parameters.envMap ? '#define USE_ENVMAP' : '',
parameters.envMap ? '#define ' + envMapModeDefine : '',
...
...
@@ -16888,7 +16886,35 @@ function WebGLPrograms( renderer, capabilities ) {
function allocateBones( object ) {
if ( capabilities.floatVertexTextures && object && object.skeleton && object.skeleton.useVertexTexture ) {
var skeleton = object.skeleton;
var bones = skeleton.bones;
if ( capabilities.floatVertexTextures ) {
if ( skeleton.boneTexture === undefined ) {
// layout (1 matrix = 4 pixels)
// RGBA RGBA RGBA RGBA (=> column1, column2, column3, column4)
// with 8x8 pixel texture max 16 bones * 4 pixels = (8 * 8)
// 16x16 pixel texture max 64 bones * 4 pixels = (16 * 16)
// 32x32 pixel texture max 256 bones * 4 pixels = (32 * 32)
// 64x64 pixel texture max 1024 bones * 4 pixels = (64 * 64)
var size = Math.sqrt( bones.length * 4 ); // 4 pixels needed for 1 matrix
size = _Math.nextPowerOfTwo( Math.ceil( size ) );
size = Math.max( size, 4 );
var boneMatrices = new Float32Array( size * size * 4 ); // 4 floats per RGBA pixel
boneMatrices.set( skeleton.boneMatrices ); // copy current values
var boneTexture = new DataTexture( boneMatrices, size, size, RGBAFormat, FloatType );
skeleton.boneMatrices = boneMatrices;
skeleton.boneTexture = boneTexture;
skeleton.boneTextureSize = size;
}
return 1024;
...
...
@@ -16904,17 +16930,12 @@ function WebGLPrograms( renderer, capabilities ) {
var nVertexUniforms = capabilities.maxVertexUniforms;
var nVertexMatrices = Math.floor( ( nVertexUniforms - 20 ) / 4 );
var maxBones = nVertexMatrices;
if ( object && object.isSkinnedMesh ) {
maxBones = Math.min( object.skeleton.bones.length, maxBones );
if ( maxBones < object.skeleton.bones.length ) {
var maxBones = Math.min( nVertexMatrices, bones.length );
console.warn( 'WebGLRenderer: too many bones - ' + object.skeleton.bones.length + ', this GPU supports just ' + maxBones + ' (try OpenGL instead of ANGLE)' );
if ( maxBones < bones.length ) {
}
console.warn( 'THREE.WebGLRenderer: Skeleton has ' + bones.length + ' bones. This GPU supports ' + maxBones + '.' );
return 0;
}
...
...
@@ -16961,7 +16982,7 @@ function WebGLPrograms( renderer, capabilities ) {
// heuristics to create shader parameters according to lights in the scene
// (not to blow over maxLights budget)
var maxBones =
allocateBones( object )
;
var maxBones =
object.isSkinnedMesh ? allocateBones( object ) : 0
;
var precision = renderer.getPrecision();
if ( material.precision !== null ) {
...
...
@@ -17018,9 +17039,9 @@ function WebGLPrograms( renderer, capabilities ) {
sizeAttenuation: material.sizeAttenuation,
logarithmicDepthBuffer: capabilities.logarithmicDepthBuffer,
skinning: ( object && object.isSkinnedMesh ),
skinning: ( object && object.isSkinnedMesh )
&& maxBones > 0
,
maxBones: maxBones,
useVertexTexture: capabilities.floatVertexTextures
&& object && object.skeleton && object.skeleton.useVertexTexture
,
useVertexTexture: capabilities.floatVertexTextures,
morphTargets: material.morphTargets,
morphNormals: material.morphNormals,
...
...
@@ -21473,11 +21494,10 @@ function WebGLRenderer( parameters ) {
if ( skeleton ) {
if ( capabilities.floatVertexTextures
&& skeleton.useVertexTexture
) {
if ( capabilities.floatVertexTextures ) {
p_uniforms.set( _gl, skeleton, 'boneTexture' );
p_uniforms.set( _gl, skeleton, 'boneTextureWidth' );
p_uniforms.set( _gl, skeleton, 'boneTextureHeight' );
p_uniforms.set( _gl, skeleton, 'boneTextureSize' );
} else {
...
...
@@ -23021,9 +23041,7 @@ LOD.prototype = Object.assign( Object.create( Object3D.prototype ), {
* @author ikerr / http://verold.com
*/
function Skeleton( bones, boneInverses, useVertexTexture ) {
this.useVertexTexture = useVertexTexture !== undefined ? useVertexTexture : true;
function Skeleton( bones, boneInverses ) {
this.identityMatrix = new Matrix4();
...
...
@@ -23032,34 +23050,7 @@ function Skeleton( bones, boneInverses, useVertexTexture ) {
bones = bones || [];
this.bones = bones.slice( 0 );
// create a bone texture or an array of floats
if ( this.useVertexTexture ) {
// layout (1 matrix = 4 pixels)
// RGBA RGBA RGBA RGBA (=> column1, column2, column3, column4)
// with 8x8 pixel texture max 16 bones * 4 pixels = (8 * 8)
// 16x16 pixel texture max 64 bones * 4 pixels = (16 * 16)
// 32x32 pixel texture max 256 bones * 4 pixels = (32 * 32)
// 64x64 pixel texture max 1024 bones * 4 pixels = (64 * 64)
var size = Math.sqrt( this.bones.length * 4 ); // 4 pixels needed for 1 matrix
size = _Math.nextPowerOfTwo( Math.ceil( size ) );
size = Math.max( size, 4 );
this.boneTextureWidth = size;
this.boneTextureHeight = size;
this.boneMatrices = new Float32Array( this.boneTextureWidth * this.boneTextureHeight * 4 ); // 4 floats per RGBA pixel
this.boneTexture = new DataTexture( this.boneMatrices, this.boneTextureWidth, this.boneTextureHeight, RGBAFormat, FloatType );
} else {
this.boneMatrices = new Float32Array( 16 * this.bones.length );
}
this.boneMatrices = new Float32Array( this.bones.length * 16 );
// use the supplied bone inverses or calculate the inverses
...
...
@@ -23164,22 +23155,27 @@ Object.assign( Skeleton.prototype, {
return function update() {
var bones = this.bones;
var boneInverses = this.boneInverses;
var boneMatrices = this.boneMatrices;
var boneTexture = this.boneTexture;
// flatten bone matrices to array
for ( var b = 0, bl =
this.
bones.length; b < bl; b ++ ) {
for ( var b = 0, bl = bones.length; b < bl; b ++ ) {
// compute the offset between the current and the original transform
var matrix =
this.bones[ b ] ? this.
bones[ b ].matrixWorld : this.identityMatrix;
var matrix =
bones[ b ] ?
bones[ b ].matrixWorld : this.identityMatrix;
offsetMatrix.multiplyMatrices( matrix,
this.
boneInverses[ b ] );
offsetMatrix.toArray(
this.
boneMatrices, b * 16 );
offsetMatrix.multiplyMatrices( matrix, boneInverses[ b ] );
offsetMatrix.toArray( boneMatrices, b * 16 );
}
if (
this.useVertexTexture
) {
if (
boneTexture !== undefined
) {
this.
boneTexture.needsUpdate = true;
boneTexture.needsUpdate = true;
}
...
...
@@ -23189,7 +23185,7 @@ Object.assign( Skeleton.prototype, {
clone: function () {
return new Skeleton( this.bones, this.boneInverses
, this.useVertexTexture
);
return new Skeleton( this.bones, this.boneInverses );
}
...
...
@@ -23223,7 +23219,7 @@ Bone.prototype = Object.assign( Object.create( Object3D.prototype ), {
* @author ikerr / http://verold.com
*/
function SkinnedMesh( geometry, material
, useVertexTexture
) {
function SkinnedMesh( geometry, material ) {
Mesh.call( this, geometry, material );
...
...
@@ -23280,7 +23276,7 @@ function SkinnedMesh( geometry, material, useVertexTexture ) {
this.normalizeSkinWeights();
this.updateMatrixWorld( true );
this.bind( new Skeleton( bones
, undefined, useVertexTexture
), this.matrixWorld );
this.bind( new Skeleton( bones ), this.matrixWorld );
}
...
...
@@ -23392,7 +23388,7 @@ SkinnedMesh.prototype = Object.assign( Object.create( Mesh.prototype ), {
clone: function () {
return new this.constructor( this.geometry, this.material
, this.skeleton.useVertexTexture
).copy( this );
return new this.constructor( this.geometry, this.material ).copy( this );
}
...
...
@@ -42032,6 +42028,21 @@ Object.defineProperties( LOD.prototype, {
} );
Object.defineProperty( Skeleton.prototype, 'useVertexTexture', {
get: function () {
console.warn( 'THREE.Skeleton: useVertexTexture has been removed.' );
},
set: function () {
console.warn( 'THREE.Skeleton: useVertexTexture has been removed.' );
}
} );
//
PerspectiveCamera.prototype.setLens = function ( focalLength, filmGauge ) {
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录