13
13
* limitations under the License.
14
14
*/
15
15
16
- import { Mesh , MeshStandardMaterial , Object3D } from 'three' ;
17
- import { GLTFReference } from 'three/examples/jsm/loaders/GLTFLoader.js' ;
16
+ import { Group , Mesh , MeshStandardMaterial , Object3D } from 'three' ;
17
+ import { GLTF , GLTFReference } from 'three/examples/jsm/loaders/GLTFLoader.js' ;
18
+ import { SkeletonUtils } from 'three/examples/jsm/utils/SkeletonUtils.js' ;
18
19
19
20
import { Material , PBRMetallicRoughness , Texture , TextureInfo } from '../../gltf-2.0.js' ;
20
21
import { assetPath , loadThreeGLTF } from '../../test-helpers.js' ;
@@ -23,6 +24,8 @@ import {CorrelatedSceneGraph} from './correlated-scene-graph.js';
23
24
24
25
const HORSE_GLB_PATH = assetPath ( 'models/Horse.glb' ) ;
25
26
const ORDER_TEST_GLB_PATH = assetPath ( 'models/order-test/order-test.glb' ) ;
27
+ const KHRONOS_TRIANGLE_GLB_PATH =
28
+ assetPath ( 'models/glTF-Sample-Models/2.0/Triangle/glTF/Triangle.gltf' ) ;
26
29
27
30
const getObject3DByName =
28
31
< T extends Object3D > ( root : Object3D , name : string ) : T | null => {
@@ -87,5 +90,26 @@ suite('facade/three-js/correlated-scene-graph', () => {
87
90
88
91
expect ( referencedGltfTexture ) . to . be . equal ( gltfTexture ) ;
89
92
} ) ;
93
+
94
+ suite ( 'when correlating a cloned glTF' , ( ) => {
95
+ test ( 'ignores the GLTFLoader "default" material' , async ( ) => {
96
+ const threeGLTF = await loadThreeGLTF ( KHRONOS_TRIANGLE_GLB_PATH ) ;
97
+ const correlatedSceneGraph = CorrelatedSceneGraph . from ( threeGLTF ) ;
98
+
99
+ const scene = SkeletonUtils . clone ( threeGLTF . scene ) as Group ;
100
+ const scenes : Group [ ] = [ scene ] ;
101
+
102
+ const cloneThreeGLTF : GLTF = { ...threeGLTF , scene, scenes} ;
103
+
104
+ const cloneCorrelatedSceneGraph =
105
+ CorrelatedSceneGraph . from ( cloneThreeGLTF , correlatedSceneGraph ) ;
106
+
107
+ for ( const threeObject of
108
+ cloneCorrelatedSceneGraph . threeObjectMap . keys ( ) ) {
109
+ expect ( ( threeObject as MeshStandardMaterial ) . isMaterial )
110
+ . to . be . undefined ;
111
+ }
112
+ } ) ;
113
+ } ) ;
90
114
} ) ;
91
115
} ) ;
0 commit comments