Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
Ablesons
three.js
提交
2a29bd2b
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,发现更多精彩内容 >>
提交
2a29bd2b
编写于
3月 14, 2019
作者:
M
Mr.doob
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Updated generated jsm files.
上级
822530be
变更
3
隐藏空白更改
内联
并排
Showing
3 changed file
with
247 addition
and
451 deletion
+247
-451
examples/jsm/controls/OrbitControls.js
examples/jsm/controls/OrbitControls.js
+24
-5
examples/jsm/controls/TrackballControls.js
examples/jsm/controls/TrackballControls.js
+1
-1
examples/jsm/loaders/GLTFLoader.js
examples/jsm/loaders/GLTFLoader.js
+222
-445
未找到文件。
examples/jsm/controls/OrbitControls.js
浏览文件 @
2a29bd2b
...
@@ -546,32 +546,44 @@ var OrbitControls = function ( object, domElement ) {
...
@@ -546,32 +546,44 @@ var OrbitControls = function ( object, domElement ) {
function
handleKeyDown
(
event
)
{
function
handleKeyDown
(
event
)
{
//console.log( 'handleKeyDown' );
// console.log( 'handleKeyDown' );
var
needsUpdate
=
false
;
switch
(
event
.
keyCode
)
{
switch
(
event
.
keyCode
)
{
case
scope
.
keys
.
UP
:
case
scope
.
keys
.
UP
:
pan
(
0
,
scope
.
keyPanSpeed
);
pan
(
0
,
scope
.
keyPanSpeed
);
scope
.
update
()
;
needsUpdate
=
true
;
break
;
break
;
case
scope
.
keys
.
BOTTOM
:
case
scope
.
keys
.
BOTTOM
:
pan
(
0
,
-
scope
.
keyPanSpeed
);
pan
(
0
,
-
scope
.
keyPanSpeed
);
scope
.
update
()
;
needsUpdate
=
true
;
break
;
break
;
case
scope
.
keys
.
LEFT
:
case
scope
.
keys
.
LEFT
:
pan
(
scope
.
keyPanSpeed
,
0
);
pan
(
scope
.
keyPanSpeed
,
0
);
scope
.
update
()
;
needsUpdate
=
true
;
break
;
break
;
case
scope
.
keys
.
RIGHT
:
case
scope
.
keys
.
RIGHT
:
pan
(
-
scope
.
keyPanSpeed
,
0
);
pan
(
-
scope
.
keyPanSpeed
,
0
);
scope
.
update
()
;
needsUpdate
=
true
;
break
;
break
;
}
}
if
(
needsUpdate
)
{
// prevent the browser from scrolling on cursor keys
event
.
preventDefault
();
scope
.
update
();
}
}
}
function
handleTouchStartRotate
(
event
)
{
function
handleTouchStartRotate
(
event
)
{
...
@@ -682,8 +694,15 @@ var OrbitControls = function ( object, domElement ) {
...
@@ -682,8 +694,15 @@ var OrbitControls = function ( object, domElement ) {
if
(
scope
.
enabled
===
false
)
return
;
if
(
scope
.
enabled
===
false
)
return
;
// Prevent the browser from scrolling.
event
.
preventDefault
();
event
.
preventDefault
();
// Manually set the focus since calling preventDefault above
// prevents the browser from setting it automatically.
scope
.
domElement
.
focus
?
scope
.
domElement
.
focus
()
:
window
.
focus
();
switch
(
event
.
button
)
{
switch
(
event
.
button
)
{
case
scope
.
mouseButtons
.
LEFT
:
case
scope
.
mouseButtons
.
LEFT
:
...
...
examples/jsm/controls/TrackballControls.js
浏览文件 @
2a29bd2b
...
@@ -499,7 +499,7 @@ var TrackballControls = function ( object, domElement ) {
...
@@ -499,7 +499,7 @@ var TrackballControls = function ( object, domElement ) {
function
touchstart
(
event
)
{
function
touchstart
(
event
)
{
if
(
_this
.
enabled
===
false
)
return
;
if
(
_this
.
enabled
===
false
)
return
;
event
.
preventDefault
();
event
.
preventDefault
();
switch
(
event
.
touches
.
length
)
{
switch
(
event
.
touches
.
length
)
{
...
...
examples/jsm/loaders/GLTFLoader.js
浏览文件 @
2a29bd2b
...
@@ -10,12 +10,10 @@ import {
...
@@ -10,12 +10,10 @@ import {
AddEquation
,
AddEquation
,
AlwaysDepth
,
AlwaysDepth
,
AnimationClip
,
AnimationClip
,
AnimationUtils
,
BackSide
,
BackSide
,
Bone
,
Bone
,
BufferAttribute
,
BufferAttribute
,
BufferGeometry
,
BufferGeometry
,
BufferGeometryUtils
,
Camera
,
Camera
,
ClampToEdgeWrapping
,
ClampToEdgeWrapping
,
Color
,
Color
,
...
@@ -34,7 +32,6 @@ import {
...
@@ -34,7 +32,6 @@ import {
Interpolant
,
Interpolant
,
InterpolateDiscrete
,
InterpolateDiscrete
,
InterpolateLinear
,
InterpolateLinear
,
InterpolateSmooth
,
LessDepth
,
LessDepth
,
LessEqualDepth
,
LessEqualDepth
,
Line
,
Line
,
...
@@ -284,7 +281,7 @@ var GLTFLoader = ( function () {
...
@@ -284,7 +281,7 @@ var GLTFLoader = ( function () {
break
;
break
;
case
EXTENSIONS
.
MSFT_TEXTURE_DDS
:
case
EXTENSIONS
.
MSFT_TEXTURE_DDS
:
extensions
[
EXTENSIONS
.
MSFT_TEXTURE_DDS
]
=
new
GLTFTextureDDSExtension
(
json
);
extensions
[
EXTENSIONS
.
MSFT_TEXTURE_DDS
]
=
new
GLTFTextureDDSExtension
();
break
;
break
;
case
EXTENSIONS
.
KHR_TEXTURE_TRANSFORM
:
case
EXTENSIONS
.
KHR_TEXTURE_TRANSFORM
:
...
@@ -313,23 +310,7 @@ var GLTFLoader = ( function () {
...
@@ -313,23 +310,7 @@ var GLTFLoader = ( function () {
}
);
}
);
parser
.
parse
(
function
(
scene
,
scenes
,
cameras
,
animations
,
json
)
{
parser
.
parse
(
onLoad
,
onError
);
var
glTF
=
{
scene
:
scene
,
scenes
:
scenes
,
cameras
:
cameras
,
animations
:
animations
,
asset
:
json
.
asset
,
parser
:
parser
,
userData
:
{}
};
addUnknownExtensionsToUserData
(
extensions
,
glTF
,
json
);
onLoad
(
glTF
);
},
onError
);
}
}
...
@@ -460,6 +441,10 @@ var GLTFLoader = ( function () {
...
@@ -460,6 +441,10 @@ var GLTFLoader = ( function () {
}
}
// Some lights (e.g. spot) default to a position other than the origin. Reset the position
// here, because node-level parsing will only override position if explicitly specified.
lightNode
.
position
.
set
(
0
,
0
,
0
);
lightNode
.
decay
=
2
;
lightNode
.
decay
=
2
;
if
(
lightDef
.
intensity
!==
undefined
)
lightNode
.
intensity
=
lightDef
.
intensity
;
if
(
lightDef
.
intensity
!==
undefined
)
lightNode
.
intensity
=
lightDef
.
intensity
;
...
@@ -603,7 +588,6 @@ var GLTFLoader = ( function () {
...
@@ -603,7 +588,6 @@ var GLTFLoader = ( function () {
this
.
name
=
EXTENSIONS
.
KHR_DRACO_MESH_COMPRESSION
;
this
.
name
=
EXTENSIONS
.
KHR_DRACO_MESH_COMPRESSION
;
this
.
json
=
json
;
this
.
json
=
json
;
this
.
dracoLoader
=
dracoLoader
;
this
.
dracoLoader
=
dracoLoader
;
THREE
.
DRACOLoader
.
getDecoderModule
();
}
}
...
@@ -619,21 +603,23 @@ var GLTFLoader = ( function () {
...
@@ -619,21 +603,23 @@ var GLTFLoader = ( function () {
for
(
var
attributeName
in
gltfAttributeMap
)
{
for
(
var
attributeName
in
gltfAttributeMap
)
{
if
(
!
(
attributeName
in
ATTRIBUTES
)
)
continue
;
var
threeAttributeName
=
ATTRIBUTES
[
attributeName
]
||
attributeName
.
toLowerCase
()
;
threeAttributeMap
[
ATTRIBUTES
[
attributeName
]
]
=
gltfAttributeMap
[
attributeName
];
threeAttributeMap
[
threeAttributeName
]
=
gltfAttributeMap
[
attributeName
];
}
}
for
(
attributeName
in
primitive
.
attributes
)
{
for
(
attributeName
in
primitive
.
attributes
)
{
if
(
ATTRIBUTES
[
attributeName
]
!==
undefined
&&
gltfAttributeMap
[
attributeName
]
!==
undefined
)
{
var
threeAttributeName
=
ATTRIBUTES
[
attributeName
]
||
attributeName
.
toLowerCase
();
if
(
gltfAttributeMap
[
attributeName
]
!==
undefined
)
{
var
accessorDef
=
json
.
accessors
[
primitive
.
attributes
[
attributeName
]
];
var
accessorDef
=
json
.
accessors
[
primitive
.
attributes
[
attributeName
]
];
var
componentType
=
WEBGL_COMPONENT_TYPES
[
accessorDef
.
componentType
];
var
componentType
=
WEBGL_COMPONENT_TYPES
[
accessorDef
.
componentType
];
attributeTypeMap
[
ATTRIBUTES
[
attributeName
]
]
=
componentType
;
attributeTypeMap
[
threeAttributeName
]
=
componentType
;
attributeNormalizedMap
[
ATTRIBUTES
[
attributeName
]
]
=
accessorDef
.
normalized
===
true
;
attributeNormalizedMap
[
threeAttributeName
]
=
accessorDef
.
normalized
===
true
;
}
}
...
@@ -1293,6 +1279,7 @@ var GLTFLoader = ( function () {
...
@@ -1293,6 +1279,7 @@ var GLTFLoader = ( function () {
var
ATTRIBUTES
=
{
var
ATTRIBUTES
=
{
POSITION
:
'
position
'
,
POSITION
:
'
position
'
,
NORMAL
:
'
normal
'
,
NORMAL
:
'
normal
'
,
TANGENT
:
'
tangent
'
,
TEXCOORD_0
:
'
uv
'
,
TEXCOORD_0
:
'
uv
'
,
TEXCOORD_1
:
'
uv2
'
,
TEXCOORD_1
:
'
uv2
'
,
COLOR_0
:
'
color
'
,
COLOR_0
:
'
color
'
,
...
@@ -1308,10 +1295,8 @@ var GLTFLoader = ( function () {
...
@@ -1308,10 +1295,8 @@ var GLTFLoader = ( function () {
};
};
var
INTERPOLATION
=
{
var
INTERPOLATION
=
{
CUBICSPLINE
:
InterpolateSmooth
,
// We use custom interpolation GLTFCubicSplineInterpolation for CUBICSPLINE.
CUBICSPLINE
:
undefined
,
// We use a custom interpolant (GLTFCubicSplineInterpolation) for CUBICSPLINE tracks. Each
// KeyframeTrack.optimize() can't handle glTF Cubic Spline output values layout,
// keyframe track will be initialized with a default interpolation type, then modified.
// using InterpolateSmooth for KeyframeTrack instantiation to prevent optimization.
// See KeyframeTrack.optimize() for the detail.
LINEAR
:
InterpolateLinear
,
LINEAR
:
InterpolateLinear
,
STEP
:
InterpolateDiscrete
STEP
:
InterpolateDiscrete
};
};
...
@@ -1357,12 +1342,14 @@ var GLTFLoader = ( function () {
...
@@ -1357,12 +1342,14 @@ var GLTFLoader = ( function () {
}
}
var
defaultMaterial
;
/**
/**
* Specification: https://github.com/KhronosGroup/glTF/blob/master/specification/2.0/README.md#default-material
* Specification: https://github.com/KhronosGroup/glTF/blob/master/specification/2.0/README.md#default-material
*/
*/
function
createDefaultMaterial
()
{
function
createDefaultMaterial
()
{
return
new
MeshStandardMaterial
(
{
defaultMaterial
=
defaultMaterial
||
new
MeshStandardMaterial
(
{
color
:
0xFFFFFF
,
color
:
0xFFFFFF
,
emissive
:
0x000000
,
emissive
:
0x000000
,
metalness
:
1
,
metalness
:
1
,
...
@@ -1372,6 +1359,8 @@ var GLTFLoader = ( function () {
...
@@ -1372,6 +1359,8 @@ var GLTFLoader = ( function () {
side
:
FrontSide
side
:
FrontSide
}
);
}
);
return
defaultMaterial
;
}
}
function
addUnknownExtensionsToUserData
(
knownExtensions
,
object
,
objectDef
)
{
function
addUnknownExtensionsToUserData
(
knownExtensions
,
object
,
objectDef
)
{
...
@@ -1448,34 +1437,21 @@ var GLTFLoader = ( function () {
...
@@ -1448,34 +1437,21 @@ var GLTFLoader = ( function () {
if
(
hasMorphPosition
)
{
if
(
hasMorphPosition
)
{
// TODO: Error-prone use of a callback inside a loop.
var
pendingAccessor
=
target
.
POSITION
!==
undefined
var
accessor
=
target
.
POSITION
!==
undefined
?
parser
.
getDependency
(
'
accessor
'
,
target
.
POSITION
)
?
parser
.
getDependency
(
'
accessor
'
,
target
.
POSITION
)
.
then
(
function
(
accessor
)
{
// Cloning not to pollute original accessor below
return
cloneBufferAttribute
(
accessor
);
}
)
:
geometry
.
attributes
.
position
;
:
geometry
.
attributes
.
position
;
pendingPositionAccessors
.
push
(
a
ccessor
);
pendingPositionAccessors
.
push
(
pendingA
ccessor
);
}
}
if
(
hasMorphNormal
)
{
if
(
hasMorphNormal
)
{
// TODO: Error-prone use of a callback inside a loop.
var
pendingAccessor
=
target
.
NORMAL
!==
undefined
var
accessor
=
target
.
NORMAL
!==
undefined
?
parser
.
getDependency
(
'
accessor
'
,
target
.
NORMAL
)
?
parser
.
getDependency
(
'
accessor
'
,
target
.
NORMAL
)
.
then
(
function
(
accessor
)
{
return
cloneBufferAttribute
(
accessor
);
}
)
:
geometry
.
attributes
.
normal
;
:
geometry
.
attributes
.
normal
;
pendingNormalAccessors
.
push
(
a
ccessor
);
pendingNormalAccessors
.
push
(
pendingA
ccessor
);
}
}
...
@@ -1489,6 +1465,24 @@ var GLTFLoader = ( function () {
...
@@ -1489,6 +1465,24 @@ var GLTFLoader = ( function () {
var
morphPositions
=
accessors
[
0
];
var
morphPositions
=
accessors
[
0
];
var
morphNormals
=
accessors
[
1
];
var
morphNormals
=
accessors
[
1
];
// Clone morph target accessors before modifying them.
for
(
var
i
=
0
,
il
=
morphPositions
.
length
;
i
<
il
;
i
++
)
{
if
(
geometry
.
attributes
.
position
===
morphPositions
[
i
]
)
continue
;
morphPositions
[
i
]
=
cloneBufferAttribute
(
morphPositions
[
i
]
);
}
for
(
var
i
=
0
,
il
=
morphNormals
.
length
;
i
<
il
;
i
++
)
{
if
(
geometry
.
attributes
.
normal
===
morphNormals
[
i
]
)
continue
;
morphNormals
[
i
]
=
cloneBufferAttribute
(
morphNormals
[
i
]
);
}
for
(
var
i
=
0
,
il
=
targets
.
length
;
i
<
il
;
i
++
)
{
for
(
var
i
=
0
,
il
=
targets
.
length
;
i
<
il
;
i
++
)
{
var
target
=
targets
[
i
];
var
target
=
targets
[
i
];
...
@@ -1609,30 +1603,6 @@ var GLTFLoader = ( function () {
...
@@ -1609,30 +1603,6 @@ var GLTFLoader = ( function () {
}
}
}
}
function
isPrimitiveEqual
(
a
,
b
)
{
var
dracoExtA
=
a
.
extensions
?
a
.
extensions
[
EXTENSIONS
.
KHR_DRACO_MESH_COMPRESSION
]
:
undefined
;
var
dracoExtB
=
b
.
extensions
?
b
.
extensions
[
EXTENSIONS
.
KHR_DRACO_MESH_COMPRESSION
]
:
undefined
;
if
(
dracoExtA
&&
dracoExtB
)
{
if
(
dracoExtA
.
bufferView
!==
dracoExtB
.
bufferView
)
return
false
;
return
isObjectEqual
(
dracoExtA
.
attributes
,
dracoExtB
.
attributes
);
}
if
(
a
.
indices
!==
b
.
indices
)
{
return
false
;
}
return
isObjectEqual
(
a
.
attributes
,
b
.
attributes
);
}
function
isObjectEqual
(
a
,
b
)
{
function
isObjectEqual
(
a
,
b
)
{
if
(
Object
.
keys
(
a
).
length
!==
Object
.
keys
(
b
).
length
)
return
false
;
if
(
Object
.
keys
(
a
).
length
!==
Object
.
keys
(
b
).
length
)
return
false
;
...
@@ -1647,59 +1617,40 @@ var GLTFLoader = ( function () {
...
@@ -1647,59 +1617,40 @@ var GLTFLoader = ( function () {
}
}
function
isArrayEqual
(
a
,
b
)
{
function
createPrimitiveKey
(
primitiveDef
)
{
if
(
a
.
length
!==
b
.
length
)
return
false
;
var
dracoExtension
=
primitiveDef
.
extensions
&&
primitiveDef
.
extensions
[
EXTENSIONS
.
KHR_DRACO_MESH_COMPRESSION
];
var
geometryKey
;
for
(
var
i
=
0
,
il
=
a
.
length
;
i
<
il
;
i
++
)
{
if
(
dracoExtension
)
{
if
(
a
[
i
]
!==
b
[
i
]
)
return
false
;
geometryKey
=
'
draco:
'
+
dracoExtension
.
bufferView
+
'
:
'
+
dracoExtension
.
indices
}
+
'
:
'
+
createAttributesKey
(
dracoExtension
.
attributes
);
return
true
;
}
function
getCachedGeometry
(
cache
,
newPrimitive
)
{
}
else
{
for
(
var
i
=
0
,
il
=
cache
.
length
;
i
<
il
;
i
++
)
{
var
cached
=
cache
[
i
];
if
(
isPrimitiveEqual
(
cached
.
primitive
,
newPrimitive
)
)
return
cached
.
promis
e
;
geometryKey
=
primitiveDef
.
indices
+
'
:
'
+
createAttributesKey
(
primitiveDef
.
attributes
)
+
'
:
'
+
primitiveDef
.
mod
e
;
}
}
return
null
;
return
geometryKey
;
}
}
function
getCachedCombinedGeometry
(
cache
,
geometries
)
{
function
createAttributesKey
(
attributes
)
{
for
(
var
i
=
0
,
il
=
cache
.
length
;
i
<
il
;
i
++
)
{
var
cached
=
cache
[
i
];
if
(
isArrayEqual
(
geometries
,
cached
.
baseGeometries
)
)
return
cached
.
geometry
;
}
return
null
;
}
function
getCachedMultiPassGeometry
(
cache
,
geometry
,
primitives
)
{
var
attributesKey
=
''
;
for
(
var
i
=
0
,
il
=
cache
.
length
;
i
<
il
;
i
++
)
{
var
keys
=
Object
.
keys
(
attributes
).
sort
();
var
cached
=
cache
[
i
];
for
(
var
i
=
0
,
il
=
keys
.
length
;
i
<
il
;
i
++
)
{
if
(
geometry
===
cached
.
baseGeometry
&&
isArrayEqual
(
primitives
,
cached
.
primitives
)
)
return
cached
.
geometry
;
attributesKey
+=
keys
[
i
]
+
'
:
'
+
attributes
[
keys
[
i
]
]
+
'
;
'
;
}
}
return
null
;
return
attributesKey
;
}
}
...
@@ -1728,48 +1679,6 @@ var GLTFLoader = ( function () {
...
@@ -1728,48 +1679,6 @@ var GLTFLoader = ( function () {
}
}
/**
* Checks if we can build a single Mesh with MultiMaterial from multiple primitives.
* Returns true if all primitives use the same attributes/morphAttributes/mode
* and also have index. Otherwise returns false.
*
* @param {Array<GLTF.Primitive>} primitives
* @return {Boolean}
*/
function
isMultiPassGeometry
(
primitives
)
{
if
(
primitives
.
length
<
2
)
return
false
;
var
primitive0
=
primitives
[
0
];
var
targets0
=
primitive0
.
targets
||
[];
if
(
primitive0
.
indices
===
undefined
)
return
false
;
for
(
var
i
=
1
,
il
=
primitives
.
length
;
i
<
il
;
i
++
)
{
var
primitive
=
primitives
[
i
];
if
(
primitive0
.
mode
!==
primitive
.
mode
)
return
false
;
if
(
primitive
.
indices
===
undefined
)
return
false
;
if
(
primitive
.
extensions
&&
primitive
.
extensions
[
EXTENSIONS
.
KHR_DRACO_MESH_COMPRESSION
]
)
return
false
;
if
(
!
isObjectEqual
(
primitive0
.
attributes
,
primitive
.
attributes
)
)
return
false
;
var
targets
=
primitive
.
targets
||
[];
if
(
targets0
.
length
!==
targets
.
length
)
return
false
;
for
(
var
j
=
0
,
jl
=
targets0
.
length
;
j
<
jl
;
j
++
)
{
if
(
!
isObjectEqual
(
targets0
[
j
],
targets
[
j
]
)
)
return
false
;
}
}
return
true
;
}
/* GLTF PARSER */
/* GLTF PARSER */
function
GLTFParser
(
json
,
extensions
,
options
)
{
function
GLTFParser
(
json
,
extensions
,
options
)
{
...
@@ -1782,9 +1691,7 @@ var GLTFLoader = ( function () {
...
@@ -1782,9 +1691,7 @@ var GLTFLoader = ( function () {
this
.
cache
=
new
GLTFRegistry
();
this
.
cache
=
new
GLTFRegistry
();
// BufferGeometry caching
// BufferGeometry caching
this
.
primitiveCache
=
[];
this
.
primitiveCache
=
{};
this
.
multiplePrimitivesCache
=
[];
this
.
multiPassGeometryCache
=
[];
this
.
textureLoader
=
new
TextureLoader
(
this
.
options
.
manager
);
this
.
textureLoader
=
new
TextureLoader
(
this
.
options
.
manager
);
this
.
textureLoader
.
setCrossOrigin
(
this
.
options
.
crossOrigin
);
this
.
textureLoader
.
setCrossOrigin
(
this
.
options
.
crossOrigin
);
...
@@ -1796,7 +1703,9 @@ var GLTFLoader = ( function () {
...
@@ -1796,7 +1703,9 @@ var GLTFLoader = ( function () {
GLTFParser
.
prototype
.
parse
=
function
(
onLoad
,
onError
)
{
GLTFParser
.
prototype
.
parse
=
function
(
onLoad
,
onError
)
{
var
parser
=
this
;
var
json
=
this
.
json
;
var
json
=
this
.
json
;
var
extensions
=
this
.
extensions
;
// Clear the loader cache
// Clear the loader cache
this
.
cache
.
removeAll
();
this
.
cache
.
removeAll
();
...
@@ -1804,21 +1713,27 @@ var GLTFLoader = ( function () {
...
@@ -1804,21 +1713,27 @@ var GLTFLoader = ( function () {
// Mark the special nodes/meshes in json for efficient parse
// Mark the special nodes/meshes in json for efficient parse
this
.
markDefs
();
this
.
markDefs
();
// Fire the callback on complete
Promise
.
all
(
[
this
.
getMultiDependencies
(
[
'
scene
'
,
this
.
getDependencies
(
'
scene
'
)
,
'
animation
'
,
this
.
getDependencies
(
'
animation
'
)
,
'
camera
'
this
.
getDependencies
(
'
camera
'
),
]
).
then
(
function
(
dependencies
)
{
]
).
then
(
function
(
dependencies
)
{
var
scenes
=
dependencies
.
scenes
||
[];
var
result
=
{
var
scene
=
scenes
[
json
.
scene
||
0
];
scene
:
dependencies
[
0
][
json
.
scene
||
0
],
var
animations
=
dependencies
.
animations
||
[];
scenes
:
dependencies
[
0
],
var
cameras
=
dependencies
.
cameras
||
[];
animations
:
dependencies
[
1
],
cameras
:
dependencies
[
2
],
asset
:
json
.
asset
,
parser
:
parser
,
userData
:
{}
};
addUnknownExtensionsToUserData
(
extensions
,
result
,
json
);
onLoad
(
scene
,
scenes
,
cameras
,
animations
,
json
);
onLoad
(
result
);
}
).
catch
(
onError
);
}
).
catch
(
onError
);
...
@@ -1991,40 +1906,6 @@ var GLTFLoader = ( function () {
...
@@ -1991,40 +1906,6 @@ var GLTFLoader = ( function () {
};
};
/**
* Requests all multiple dependencies of the specified types asynchronously, with caching.
* @param {Array<string>} types
* @return {Promise<Object<Array<Object>>>}
*/
GLTFParser
.
prototype
.
getMultiDependencies
=
function
(
types
)
{
var
results
=
{};
var
pending
=
[];
for
(
var
i
=
0
,
il
=
types
.
length
;
i
<
il
;
i
++
)
{
var
type
=
types
[
i
];
var
value
=
this
.
getDependencies
(
type
);
// TODO: Error-prone use of a callback inside a loop.
value
=
value
.
then
(
function
(
key
,
value
)
{
results
[
key
]
=
value
;
}.
bind
(
this
,
type
+
(
type
===
'
mesh
'
?
'
es
'
:
'
s
'
)
)
);
pending
.
push
(
value
);
}
return
Promise
.
all
(
pending
).
then
(
function
()
{
return
results
;
}
);
};
/**
/**
* Specification: https://github.com/KhronosGroup/glTF/blob/master/specification/2.0/README.md#buffers-and-buffer-views
* Specification: https://github.com/KhronosGroup/glTF/blob/master/specification/2.0/README.md#buffers-and-buffer-views
* @param {number} bufferIndex
* @param {number} bufferIndex
...
@@ -2327,6 +2208,18 @@ var GLTFLoader = ( function () {
...
@@ -2327,6 +2208,18 @@ var GLTFLoader = ( function () {
return
this
.
getDependency
(
'
texture
'
,
mapDef
.
index
).
then
(
function
(
texture
)
{
return
this
.
getDependency
(
'
texture
'
,
mapDef
.
index
).
then
(
function
(
texture
)
{
switch
(
mapName
)
{
case
'
aoMap
'
:
case
'
emissiveMap
'
:
case
'
metalnessMap
'
:
case
'
normalMap
'
:
case
'
roughnessMap
'
:
texture
.
format
=
RGBFormat
;
break
;
}
if
(
parser
.
extensions
[
EXTENSIONS
.
KHR_TEXTURE_TRANSFORM
]
)
{
if
(
parser
.
extensions
[
EXTENSIONS
.
KHR_TEXTURE_TRANSFORM
]
)
{
var
transform
=
mapDef
.
extensions
!==
undefined
?
mapDef
.
extensions
[
EXTENSIONS
.
KHR_TEXTURE_TRANSFORM
]
:
undefined
;
var
transform
=
mapDef
.
extensions
!==
undefined
?
mapDef
.
extensions
[
EXTENSIONS
.
KHR_TEXTURE_TRANSFORM
]
:
undefined
;
...
@@ -2345,6 +2238,124 @@ var GLTFLoader = ( function () {
...
@@ -2345,6 +2238,124 @@ var GLTFLoader = ( function () {
};
};
/**
* Assigns final material to a Mesh, Line, or Points instance. The instance
* already has a material (generated from the glTF material options alone)
* but reuse of the same glTF material may require multiple threejs materials
* to accomodate different primitive types, defines, etc. New materials will
* be created if necessary, and reused from a cache.
* @param {Object3D} mesh Mesh, Line, or Points instance.
*/
GLTFParser
.
prototype
.
assignFinalMaterial
=
function
(
mesh
)
{
var
geometry
=
mesh
.
geometry
;
var
material
=
mesh
.
material
;
var
extensions
=
this
.
extensions
;
var
useVertexTangents
=
geometry
.
attributes
.
tangent
!==
undefined
;
var
useVertexColors
=
geometry
.
attributes
.
color
!==
undefined
;
var
useFlatShading
=
geometry
.
attributes
.
normal
===
undefined
;
var
useSkinning
=
mesh
.
isSkinnedMesh
===
true
;
var
useMorphTargets
=
Object
.
keys
(
geometry
.
morphAttributes
).
length
>
0
;
var
useMorphNormals
=
useMorphTargets
&&
geometry
.
morphAttributes
.
normal
!==
undefined
;
if
(
mesh
.
isPoints
)
{
var
cacheKey
=
'
PointsMaterial:
'
+
material
.
uuid
;
var
pointsMaterial
=
this
.
cache
.
get
(
cacheKey
);
if
(
!
pointsMaterial
)
{
pointsMaterial
=
new
PointsMaterial
();
Material
.
prototype
.
copy
.
call
(
pointsMaterial
,
material
);
pointsMaterial
.
color
.
copy
(
material
.
color
);
pointsMaterial
.
map
=
material
.
map
;
pointsMaterial
.
lights
=
false
;
// PointsMaterial doesn't support lights yet
this
.
cache
.
add
(
cacheKey
,
pointsMaterial
);
}
material
=
pointsMaterial
;
}
else
if
(
mesh
.
isLine
)
{
var
cacheKey
=
'
LineBasicMaterial:
'
+
material
.
uuid
;
var
lineMaterial
=
this
.
cache
.
get
(
cacheKey
);
if
(
!
lineMaterial
)
{
lineMaterial
=
new
LineBasicMaterial
();
Material
.
prototype
.
copy
.
call
(
lineMaterial
,
material
);
lineMaterial
.
color
.
copy
(
material
.
color
);
lineMaterial
.
lights
=
false
;
// LineBasicMaterial doesn't support lights yet
this
.
cache
.
add
(
cacheKey
,
lineMaterial
);
}
material
=
lineMaterial
;
}
// Clone the material if it will be modified
if
(
useVertexTangents
||
useVertexColors
||
useFlatShading
||
useSkinning
||
useMorphTargets
)
{
var
cacheKey
=
'
ClonedMaterial:
'
+
material
.
uuid
+
'
:
'
;
if
(
material
.
isGLTFSpecularGlossinessMaterial
)
cacheKey
+=
'
specular-glossiness:
'
;
if
(
useSkinning
)
cacheKey
+=
'
skinning:
'
;
if
(
useVertexTangents
)
cacheKey
+=
'
vertex-tangents:
'
;
if
(
useVertexColors
)
cacheKey
+=
'
vertex-colors:
'
;
if
(
useFlatShading
)
cacheKey
+=
'
flat-shading:
'
;
if
(
useMorphTargets
)
cacheKey
+=
'
morph-targets:
'
;
if
(
useMorphNormals
)
cacheKey
+=
'
morph-normals:
'
;
var
cachedMaterial
=
this
.
cache
.
get
(
cacheKey
);
if
(
!
cachedMaterial
)
{
cachedMaterial
=
material
.
isGLTFSpecularGlossinessMaterial
?
extensions
[
EXTENSIONS
.
KHR_MATERIALS_PBR_SPECULAR_GLOSSINESS
].
cloneMaterial
(
material
)
:
material
.
clone
();
if
(
useSkinning
)
cachedMaterial
.
skinning
=
true
;
if
(
useVertexTangents
)
cachedMaterial
.
vertexTangents
=
true
;
if
(
useVertexColors
)
cachedMaterial
.
vertexColors
=
VertexColors
;
if
(
useFlatShading
)
cachedMaterial
.
flatShading
=
true
;
if
(
useMorphTargets
)
cachedMaterial
.
morphTargets
=
true
;
if
(
useMorphNormals
)
cachedMaterial
.
morphNormals
=
true
;
this
.
cache
.
add
(
cacheKey
,
cachedMaterial
);
}
material
=
cachedMaterial
;
}
// workarounds for mesh and geometry
if
(
material
.
aoMap
&&
geometry
.
attributes
.
uv2
===
undefined
&&
geometry
.
attributes
.
uv
!==
undefined
)
{
console
.
log
(
'
THREE.GLTFLoader: Duplicating UVs to support aoMap.
'
);
geometry
.
addAttribute
(
'
uv2
'
,
new
BufferAttribute
(
geometry
.
attributes
.
uv
.
array
,
2
)
);
}
if
(
material
.
isGLTFSpecularGlossinessMaterial
)
{
// for GLTFSpecularGlossinessMaterial(ShaderMaterial) uniforms runtime update
mesh
.
onBeforeRender
=
extensions
[
EXTENSIONS
.
KHR_MATERIALS_PBR_SPECULAR_GLOSSINESS
].
refreshUniforms
;
}
mesh
.
material
=
material
;
};
/**
/**
* Specification: https://github.com/KhronosGroup/glTF/blob/master/specification/2.0/README.md#materials
* Specification: https://github.com/KhronosGroup/glTF/blob/master/specification/2.0/README.md#materials
* @param {number} materialIndex
* @param {number} materialIndex
...
@@ -2492,14 +2503,6 @@ var GLTFLoader = ( function () {
...
@@ -2492,14 +2503,6 @@ var GLTFLoader = ( function () {
if
(
materialDef
.
name
!==
undefined
)
material
.
name
=
materialDef
.
name
;
if
(
materialDef
.
name
!==
undefined
)
material
.
name
=
materialDef
.
name
;
// Normal map textures use OpenGL conventions:
// https://github.com/KhronosGroup/glTF/tree/master/specification/2.0#materialnormaltexture
if
(
material
.
normalScale
)
{
material
.
normalScale
.
y
=
-
material
.
normalScale
.
y
;
}
// baseColorTexture, emissiveTexture, and specularGlossinessTexture use sRGB encoding.
// baseColorTexture, emissiveTexture, and specularGlossinessTexture use sRGB encoding.
if
(
material
.
map
)
material
.
map
.
encoding
=
sRGBEncoding
;
if
(
material
.
map
)
material
.
map
.
encoding
=
sRGBEncoding
;
if
(
material
.
emissiveMap
)
material
.
emissiveMap
.
encoding
=
sRGBEncoding
;
if
(
material
.
emissiveMap
)
material
.
emissiveMap
.
encoding
=
sRGBEncoding
;
...
@@ -2540,9 +2543,7 @@ var GLTFLoader = ( function () {
...
@@ -2540,9 +2543,7 @@ var GLTFLoader = ( function () {
for
(
var
gltfAttributeName
in
attributes
)
{
for
(
var
gltfAttributeName
in
attributes
)
{
var
threeAttributeName
=
ATTRIBUTES
[
gltfAttributeName
];
var
threeAttributeName
=
ATTRIBUTES
[
gltfAttributeName
]
||
gltfAttributeName
.
toLowerCase
();
if
(
!
threeAttributeName
)
continue
;
// Skip attributes already provided by e.g. Draco extension.
// Skip attributes already provided by e.g. Draco extension.
if
(
threeAttributeName
in
geometry
.
attributes
)
continue
;
if
(
threeAttributeName
in
geometry
.
attributes
)
continue
;
...
@@ -2579,8 +2580,6 @@ var GLTFLoader = ( function () {
...
@@ -2579,8 +2580,6 @@ var GLTFLoader = ( function () {
* Specification: https://github.com/KhronosGroup/glTF/blob/master/specification/2.0/README.md#geometry
* Specification: https://github.com/KhronosGroup/glTF/blob/master/specification/2.0/README.md#geometry
*
*
* Creates BufferGeometries from primitives.
* Creates BufferGeometries from primitives.
* If we can build a single BufferGeometry with .groups from multiple primitives, returns one BufferGeometry.
* Otherwise, returns BufferGeometries without .groups as many as primitives.
*
*
* @param {Array<GLTF.Primitive>} primitives
* @param {Array<GLTF.Primitive>} primitives
* @return {Promise<Array<BufferGeometry>>}
* @return {Promise<Array<BufferGeometry>>}
...
@@ -2591,22 +2590,6 @@ var GLTFLoader = ( function () {
...
@@ -2591,22 +2590,6 @@ var GLTFLoader = ( function () {
var
extensions
=
this
.
extensions
;
var
extensions
=
this
.
extensions
;
var
cache
=
this
.
primitiveCache
;
var
cache
=
this
.
primitiveCache
;
var
isMultiPass
=
isMultiPassGeometry
(
primitives
);
var
originalPrimitives
;
if
(
isMultiPass
)
{
originalPrimitives
=
primitives
;
// save original primitives and use later
// We build a single BufferGeometry with .groups from multiple primitives
// because all primitives share the same attributes/morph/mode and have indices.
primitives
=
[
primitives
[
0
]
];
// Sets .groups and combined indices to a geometry later in this method.
}
function
createDracoPrimitive
(
primitive
)
{
function
createDracoPrimitive
(
primitive
)
{
return
extensions
[
EXTENSIONS
.
KHR_DRACO_MESH_COMPRESSION
]
return
extensions
[
EXTENSIONS
.
KHR_DRACO_MESH_COMPRESSION
]
...
@@ -2624,14 +2607,15 @@ var GLTFLoader = ( function () {
...
@@ -2624,14 +2607,15 @@ var GLTFLoader = ( function () {
for
(
var
i
=
0
,
il
=
primitives
.
length
;
i
<
il
;
i
++
)
{
for
(
var
i
=
0
,
il
=
primitives
.
length
;
i
<
il
;
i
++
)
{
var
primitive
=
primitives
[
i
];
var
primitive
=
primitives
[
i
];
var
cacheKey
=
createPrimitiveKey
(
primitive
);
// See if we've already created this geometry
// See if we've already created this geometry
var
cached
=
getCachedGeometry
(
cache
,
primitive
)
;
var
cached
=
cache
[
cacheKey
]
;
if
(
cached
)
{
if
(
cached
)
{
// Use the cached geometry if it exists
// Use the cached geometry if it exists
pending
.
push
(
cached
);
pending
.
push
(
cached
.
promise
);
}
else
{
}
else
{
...
@@ -2650,7 +2634,7 @@ var GLTFLoader = ( function () {
...
@@ -2650,7 +2634,7 @@ var GLTFLoader = ( function () {
}
}
// Cache this geometry
// Cache this geometry
cache
.
push
(
{
primitive
:
primitive
,
promise
:
geometryPromise
}
)
;
cache
[
cacheKey
]
=
{
primitive
:
primitive
,
promise
:
geometryPromise
}
;
pending
.
push
(
geometryPromise
);
pending
.
push
(
geometryPromise
);
...
@@ -2658,95 +2642,7 @@ var GLTFLoader = ( function () {
...
@@ -2658,95 +2642,7 @@ var GLTFLoader = ( function () {
}
}
return
Promise
.
all
(
pending
).
then
(
function
(
geometries
)
{
return
Promise
.
all
(
pending
);
if
(
isMultiPass
)
{
var
baseGeometry
=
geometries
[
0
];
// See if we've already created this combined geometry
var
cache
=
parser
.
multiPassGeometryCache
;
var
cached
=
getCachedMultiPassGeometry
(
cache
,
baseGeometry
,
originalPrimitives
);
if
(
cached
!==
null
)
return
[
cached
.
geometry
];
// Cloning geometry because of index override.
// Attributes can be reused so cloning by myself here.
var
geometry
=
new
BufferGeometry
();
geometry
.
name
=
baseGeometry
.
name
;
geometry
.
userData
=
baseGeometry
.
userData
;
for
(
var
key
in
baseGeometry
.
attributes
)
geometry
.
addAttribute
(
key
,
baseGeometry
.
attributes
[
key
]
);
for
(
var
key
in
baseGeometry
.
morphAttributes
)
geometry
.
morphAttributes
[
key
]
=
baseGeometry
.
morphAttributes
[
key
];
var
pendingIndices
=
[];
for
(
var
i
=
0
,
il
=
originalPrimitives
.
length
;
i
<
il
;
i
++
)
{
pendingIndices
.
push
(
parser
.
getDependency
(
'
accessor
'
,
originalPrimitives
[
i
].
indices
)
);
}
return
Promise
.
all
(
pendingIndices
).
then
(
function
(
accessors
)
{
var
indices
=
[];
var
offset
=
0
;
for
(
var
i
=
0
,
il
=
originalPrimitives
.
length
;
i
<
il
;
i
++
)
{
var
accessor
=
accessors
[
i
];
for
(
var
j
=
0
,
jl
=
accessor
.
count
;
j
<
jl
;
j
++
)
indices
.
push
(
accessor
.
array
[
j
]
);
geometry
.
addGroup
(
offset
,
accessor
.
count
,
i
);
offset
+=
accessor
.
count
;
}
geometry
.
setIndex
(
indices
);
cache
.
push
(
{
geometry
:
geometry
,
baseGeometry
:
baseGeometry
,
primitives
:
originalPrimitives
}
);
return
[
geometry
];
}
);
}
else
if
(
geometries
.
length
>
1
&&
BufferGeometryUtils
!==
undefined
)
{
// Tries to merge geometries with BufferGeometryUtils if possible
for
(
var
i
=
1
,
il
=
primitives
.
length
;
i
<
il
;
i
++
)
{
// can't merge if draw mode is different
if
(
primitives
[
0
].
mode
!==
primitives
[
i
].
mode
)
return
geometries
;
}
// See if we've already created this combined geometry
var
cache
=
parser
.
multiplePrimitivesCache
;
var
cached
=
getCachedCombinedGeometry
(
cache
,
geometries
);
if
(
cached
)
{
if
(
cached
.
geometry
!==
null
)
return
[
cached
.
geometry
];
}
else
{
var
geometry
=
BufferGeometryUtils
.
mergeBufferGeometries
(
geometries
,
true
);
cache
.
push
(
{
geometry
:
geometry
,
baseGeometries
:
geometries
}
);
if
(
geometry
!==
null
)
return
[
geometry
];
}
}
return
geometries
;
}
);
};
};
...
@@ -2780,8 +2676,6 @@ var GLTFLoader = ( function () {
...
@@ -2780,8 +2676,6 @@ var GLTFLoader = ( function () {
return
parser
.
loadGeometries
(
primitives
).
then
(
function
(
geometries
)
{
return
parser
.
loadGeometries
(
primitives
).
then
(
function
(
geometries
)
{
var
isMultiMaterial
=
geometries
.
length
===
1
&&
geometries
[
0
].
groups
.
length
>
0
;
var
meshes
=
[];
var
meshes
=
[];
for
(
var
i
=
0
,
il
=
geometries
.
length
;
i
<
il
;
i
++
)
{
for
(
var
i
=
0
,
il
=
geometries
.
length
;
i
<
il
;
i
++
)
{
...
@@ -2793,7 +2687,7 @@ var GLTFLoader = ( function () {
...
@@ -2793,7 +2687,7 @@ var GLTFLoader = ( function () {
var
mesh
;
var
mesh
;
var
material
=
isMultiMaterial
?
originalMaterials
:
originalMaterials
[
i
];
var
material
=
originalMaterials
[
i
];
if
(
primitive
.
mode
===
WEBGL_CONSTANTS
.
TRIANGLES
||
if
(
primitive
.
mode
===
WEBGL_CONSTANTS
.
TRIANGLES
||
primitive
.
mode
===
WEBGL_CONSTANTS
.
TRIANGLE_STRIP
||
primitive
.
mode
===
WEBGL_CONSTANTS
.
TRIANGLE_STRIP
||
...
@@ -2851,118 +2745,9 @@ var GLTFLoader = ( function () {
...
@@ -2851,118 +2745,9 @@ var GLTFLoader = ( function () {
assignExtrasToUserData
(
mesh
,
meshDef
);
assignExtrasToUserData
(
mesh
,
meshDef
);
meshes
.
push
(
mesh
);
parser
.
assignFinalMaterial
(
mesh
);
// 2. update Material depending on Mesh and BufferGeometry
var
materials
=
isMultiMaterial
?
mesh
.
material
:
[
mesh
.
material
];
var
useVertexColors
=
geometry
.
attributes
.
color
!==
undefined
;
var
useFlatShading
=
geometry
.
attributes
.
normal
===
undefined
;
var
useSkinning
=
mesh
.
isSkinnedMesh
===
true
;
var
useMorphTargets
=
Object
.
keys
(
geometry
.
morphAttributes
).
length
>
0
;
var
useMorphNormals
=
useMorphTargets
&&
geometry
.
morphAttributes
.
normal
!==
undefined
;
for
(
var
j
=
0
,
jl
=
materials
.
length
;
j
<
jl
;
j
++
)
{
var
material
=
materials
[
j
];
if
(
mesh
.
isPoints
)
{
var
cacheKey
=
'
PointsMaterial:
'
+
material
.
uuid
;
var
pointsMaterial
=
parser
.
cache
.
get
(
cacheKey
);
if
(
!
pointsMaterial
)
{
pointsMaterial
=
new
PointsMaterial
();
Material
.
prototype
.
copy
.
call
(
pointsMaterial
,
material
);
pointsMaterial
.
color
.
copy
(
material
.
color
);
pointsMaterial
.
map
=
material
.
map
;
pointsMaterial
.
lights
=
false
;
// PointsMaterial doesn't support lights yet
parser
.
cache
.
add
(
cacheKey
,
pointsMaterial
);
}
material
=
pointsMaterial
;
}
else
if
(
mesh
.
isLine
)
{
var
cacheKey
=
'
LineBasicMaterial:
'
+
material
.
uuid
;
var
lineMaterial
=
parser
.
cache
.
get
(
cacheKey
);
if
(
!
lineMaterial
)
{
lineMaterial
=
new
LineBasicMaterial
();
meshes
.
push
(
mesh
);
Material
.
prototype
.
copy
.
call
(
lineMaterial
,
material
);
lineMaterial
.
color
.
copy
(
material
.
color
);
lineMaterial
.
lights
=
false
;
// LineBasicMaterial doesn't support lights yet
parser
.
cache
.
add
(
cacheKey
,
lineMaterial
);
}
material
=
lineMaterial
;
}
// Clone the material if it will be modified
if
(
useVertexColors
||
useFlatShading
||
useSkinning
||
useMorphTargets
)
{
var
cacheKey
=
'
ClonedMaterial:
'
+
material
.
uuid
+
'
:
'
;
if
(
material
.
isGLTFSpecularGlossinessMaterial
)
cacheKey
+=
'
specular-glossiness:
'
;
if
(
useSkinning
)
cacheKey
+=
'
skinning:
'
;
if
(
useVertexColors
)
cacheKey
+=
'
vertex-colors:
'
;
if
(
useFlatShading
)
cacheKey
+=
'
flat-shading:
'
;
if
(
useMorphTargets
)
cacheKey
+=
'
morph-targets:
'
;
if
(
useMorphNormals
)
cacheKey
+=
'
morph-normals:
'
;
var
cachedMaterial
=
parser
.
cache
.
get
(
cacheKey
);
if
(
!
cachedMaterial
)
{
cachedMaterial
=
material
.
isGLTFSpecularGlossinessMaterial
?
extensions
[
EXTENSIONS
.
KHR_MATERIALS_PBR_SPECULAR_GLOSSINESS
].
cloneMaterial
(
material
)
:
material
.
clone
();
if
(
useSkinning
)
cachedMaterial
.
skinning
=
true
;
if
(
useVertexColors
)
cachedMaterial
.
vertexColors
=
VertexColors
;
if
(
useFlatShading
)
cachedMaterial
.
flatShading
=
true
;
if
(
useMorphTargets
)
cachedMaterial
.
morphTargets
=
true
;
if
(
useMorphNormals
)
cachedMaterial
.
morphNormals
=
true
;
parser
.
cache
.
add
(
cacheKey
,
cachedMaterial
);
}
material
=
cachedMaterial
;
}
materials
[
j
]
=
material
;
// workarounds for mesh and geometry
if
(
material
.
aoMap
&&
geometry
.
attributes
.
uv2
===
undefined
&&
geometry
.
attributes
.
uv
!==
undefined
)
{
console
.
log
(
'
THREE.GLTFLoader: Duplicating UVs to support aoMap.
'
);
geometry
.
addAttribute
(
'
uv2
'
,
new
BufferAttribute
(
geometry
.
attributes
.
uv
.
array
,
2
)
);
}
if
(
material
.
isGLTFSpecularGlossinessMaterial
)
{
// for GLTFSpecularGlossinessMaterial(ShaderMaterial) uniforms runtime update
mesh
.
onBeforeRender
=
extensions
[
EXTENSIONS
.
KHR_MATERIALS_PBR_SPECULAR_GLOSSINESS
].
refreshUniforms
;
}
}
mesh
.
material
=
isMultiMaterial
?
materials
:
materials
[
0
];
}
}
...
@@ -3147,10 +2932,7 @@ var GLTFLoader = ( function () {
...
@@ -3147,10 +2932,7 @@ var GLTFLoader = ( function () {
if
(
PATH_PROPERTIES
[
target
.
path
]
===
PATH_PROPERTIES
.
weights
)
{
if
(
PATH_PROPERTIES
[
target
.
path
]
===
PATH_PROPERTIES
.
weights
)
{
// node can be Group here but
// Node may be a Group (glTF mesh with several primitives) or a Mesh.
// PATH_PROPERTIES.weights(morphTargetInfluences) should be
// the property of a mesh object under group.
node
.
traverse
(
function
(
object
)
{
node
.
traverse
(
function
(
object
)
{
if
(
object
.
isMesh
===
true
&&
object
.
morphTargetInfluences
)
{
if
(
object
.
isMesh
===
true
&&
object
.
morphTargetInfluences
)
{
...
@@ -3167,20 +2949,16 @@ var GLTFLoader = ( function () {
...
@@ -3167,20 +2949,16 @@ var GLTFLoader = ( function () {
}
}
// KeyframeTrack.optimize() will modify given 'times' and 'values'
// buffers before creating a truncated copy to keep. Because buffers may
// be reused by other tracks, make copies here.
for
(
var
j
=
0
,
jl
=
targetNames
.
length
;
j
<
jl
;
j
++
)
{
for
(
var
j
=
0
,
jl
=
targetNames
.
length
;
j
<
jl
;
j
++
)
{
var
track
=
new
TypedKeyframeTrack
(
var
track
=
new
TypedKeyframeTrack
(
targetNames
[
j
]
+
'
.
'
+
PATH_PROPERTIES
[
target
.
path
],
targetNames
[
j
]
+
'
.
'
+
PATH_PROPERTIES
[
target
.
path
],
AnimationUtils
.
arraySlice
(
inputAccessor
.
array
,
0
)
,
inputAccessor
.
array
,
AnimationUtils
.
arraySlice
(
outputAccessor
.
array
,
0
)
,
outputAccessor
.
array
,
interpolation
interpolation
);
);
// Here is the trick to enable custom interpolation.
// Override interpolation with custom factory method.
// Overrides .createInterpolant in a factory method which creates custom interpolation.
if
(
sampler
.
interpolation
===
'
CUBICSPLINE
'
)
{
if
(
sampler
.
interpolation
===
'
CUBICSPLINE
'
)
{
track
.
createInterpolant
=
function
InterpolantFactoryMethodGLTFCubicSpline
(
result
)
{
track
.
createInterpolant
=
function
InterpolantFactoryMethodGLTFCubicSpline
(
result
)
{
...
@@ -3193,8 +2971,7 @@ var GLTFLoader = ( function () {
...
@@ -3193,8 +2971,7 @@ var GLTFLoader = ( function () {
};
};
// Workaround, provide an alternate way to know if the interpolant type is cubis spline to track.
// Mark as CUBICSPLINE. `track.getInterpolation()` doesn't support custom interpolants.
// track.getInterpolation() doesn't return valid value for custom interpolant.
track
.
createInterpolant
.
isInterpolantFactoryMethodGLTFCubicSpline
=
true
;
track
.
createInterpolant
.
isInterpolantFactoryMethodGLTFCubicSpline
=
true
;
}
}
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录