-
Notifications
You must be signed in to change notification settings - Fork 514
Expand file tree
/
Copy pathtest.js
More file actions
559 lines (512 loc) · 25.7 KB
/
test.js
File metadata and controls
559 lines (512 loc) · 25.7 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
const request = function (url, cb) {
const image = new Image();
image.onload = () => {
const canvas = document.createElement('canvas');
canvas.width = image.width;
canvas.height = image.height;
const ctx = canvas.getContext('2d');
ctx.drawImage(image, 0, 0, image.width, image.height);
const imgData = ctx.getImageData(0, 0, image.width, image.height);
const result = { width : image.width, height : image.height, data : new Uint8Array(imgData.data) };
cb(null, result);
};
image.onerror = function (err) {
cb(err);
};
image.src = url;
};
function uint8ArrayEqual(a, b) {
for (let i = 0; i < b.length; i++) {
if (a[i] !== b[i]) {
return false;
}
}
return true;
}
/* eslint-disable no-undef */
const decoders= {
'image/crn': maptalks.transcoders.crn && maptalks.transcoders.crn(),
'image/ktx2': maptalks.transcoders.ktx2 && maptalks.transcoders.ktx2(),
'image/cttf': maptalks.transcoders.ktx2 && maptalks.transcoders.ktx2(),
'draco': maptalks.transcoders.draco && maptalks.transcoders.draco()
}
describe('GLTF', () => {
beforeEach(() => {
});
afterEach(() => {
});
it('status', () => {
expect(gltf.GLTFLoader).to.be.ok();
});
it('load gltf', done => {
const root = 'models/DamagedHelmet/glTF';
gltf.Ajax.getJSON(root + '/DamagedHelmet.gltf', {}).then(json => {
expect(json).to.be.ok();
expect(json.asset.version).to.be.eql('2.0');
done();
});
});
describe('gltf v2', () => {
it('load damagedhelmet nodes', done => {
const root = 'models/DamagedHelmet/glTF';
gltf.Ajax.getJSON(root + '/DamagedHelmet.gltf', {}).then(json => {
const loader = new gltf.GLTFLoader(root, json, { requestImage : request });
loader.load().then(gltf => {
const name = gltf.scenes[gltf.scene].name;
expect(name).to.be.eql('Scene');
const nodes = gltf.scenes[gltf.scene].nodes;
expect(nodes[0]).to.be.ok();
expect(gltf.meshes[0]).to.be.ok();
expect(gltf.materials.length).to.be.eql(1);
const textures = gltf.textures;
expect(textures.length).to.be.eql(5);
for (let i = 0; i < textures.length; i++) {
expect(textures[i].image.array).to.be.ok();
}
// NOTE: 以下数组的相等测试用来测试以生成的buffer.id和image.id为缓存的key的情况
expect(uint8ArrayEqual(textures[0].image.array.slice(0, 6), [188, 202, 205, 255, 188, 202])).to.be.ok();
expect(uint8ArrayEqual(textures[1].image.array.slice(0, 6), [0, 24, 0, 255, 0, 24])).to.be.ok();
expect(uint8ArrayEqual(textures[2].image.array.slice(0, 6), [0, 0, 0, 255, 0, 0])).to.be.ok();
expect(uint8ArrayEqual(textures[3].image.array.slice(0, 6), [252, 252, 252, 255, 252, 252])).to.be.ok();
expect(uint8ArrayEqual(textures[4].image.array.slice(0, 6), [126, 127, 253, 255, 126, 127])).to.be.ok();
expect(gltf.skins.length).to.be.eql(0);
done();
});
});
});
it('load images and buffers stroed in base64 without requestImage method', done => {
const root = 'models/v2/BoxTextured';
gltf.Ajax.getJSON(root + '/BoxTextured.gltf', {}).then(json => {
const loader = new gltf.GLTFLoader(root, json);
loader.load().then(gltf => {
expect(gltf.scene).to.be.eql(0);
const nodes = gltf.scenes[gltf.scene].nodes;
expect(nodes[0]).to.be.ok();
const textures = gltf.textures;
expect(textures.length).to.be.eql(1);
const texture = textures[0];
expect(texture.image.array.length).to.be.eql(262144);
expect(texture.image.array instanceof Uint8Array).to.be.ok();
expect(texture.sampler).to.be.ok();
done();
});
});
});
it('load gltf as buffer', done => {
const root = 'models/v2/BoxTextured';
gltf.Ajax.getArrayBuffer(root + '/BoxTextured.gltf', {}).then(res => {
const loader = new gltf.GLTFLoader(root, {buffer: res.data, byteOffset: 0});
loader.load().then(gltf => {
expect(gltf.scene).to.be.eql(0);
const nodes = gltf.scenes[gltf.scene].nodes;
expect(nodes[0]).to.be.ok();
const textures = gltf.textures;
expect(textures.length).to.be.eql(1);
const texture = textures[0];
expect(texture.image.array.length).to.be.eql(262144);
expect(texture.image.array instanceof Uint8Array).to.be.ok();
expect(texture.sampler).to.be.ok();
done();
});
});
});
it('node has many child nodes', done => {
const root = 'models/v2/scene';
gltf.Ajax.getJSON(root + '/scene.gltf', {}).then(json => {
const loader = new gltf.GLTFLoader(root, json);
loader.load().then(gltf => {
expect(gltf.scene).to.be.eql(0);
const nodes = gltf.scenes[gltf.scene].nodes;
expect(nodes[0]).to.be.ok();
const children0 = nodes[0].children;
expect(children0.length).to.be.eql(1);
const children1 = children0[0].children;
expect(children1.length).to.be.eql(1);
const children2 = children1[0].children;
expect(children2.length).to.be.eql(12);
const children3 = children2[0];
expect(children3).to.be.ok();
let index = 0;
for (const node in gltf.nodes) {
expect(Number(gltf.nodes[node].nodeIndex)).to.be.eql(index);
index++;
}
done();
});
});
});
it('load image data from buffers', done => {
const root = 'models/dbxc';
gltf.Ajax.getJSON(root + '/dbxc.gltf', {}).then(json => {
const loader = new gltf.GLTFLoader(root, json);
loader.load().then(gltf => {
expect(gltf.scene).to.be.eql(0);
const nodes = gltf.scenes[gltf.scene].nodes;
expect(nodes[0]).to.be.ok();
const textures = gltf.textures;
expect(textures.length).to.be.eql(4);
expect(textures[0].image.array.length).to.be.eql(262144);
expect(textures[1].image.array.length).to.be.eql(262144);
expect(textures[2].image.array.length).to.be.eql(65536);
expect(textures[3].image.array.length).to.be.eql(262144);
done();
});
});
});
it('get texture\'s width and height', done => {
const root = 'models/DamagedHelmet/glTF';
gltf.Ajax.getJSON(root + '/DamagedHelmet.gltf', {}).then(json => {
const loader = new gltf.GLTFLoader(root, json);
loader.load().then(gltf => {
expect(gltf.scene).to.be.eql(0);
const nodes = gltf.scenes[gltf.scene].nodes;
expect(nodes[0]).to.be.ok();
const textures = gltf.textures;
expect(textures[0].image.width).to.be.eql(2048);
expect(textures[1].image.height).to.be.eql(2048);
done();
});
});
});
it('load v2 glb', done => {
const root = 'models/v2/Duck';
gltf.Ajax.getArrayBuffer(root + '/Duck.glb', {}).then(json => {
const loader = new gltf.GLTFLoader(root, { buffer : json.data, byteOffset : 0 }, { requestImage : request });
loader.load().then(gltf => {
expect(gltf.scene).to.be.eql(0);
const nodes = gltf.scenes[gltf.scene].nodes;
expect(nodes[0]).to.be.ok();
expect(nodes[0].children[0].mesh).to.be.eql(0);
const primitive = gltf.meshes[0].primitives[0];
//primitive
expect(primitive.attributes.NORMAL.array.length).to.be.eql(7197);
expect(primitive.attributes.NORMAL.array instanceof Float32Array).to.be.ok();
expect(primitive.attributes.POSITION.array.length).to.be.eql(7197);
expect(primitive.attributes.POSITION.array instanceof Float32Array).to.be.ok();
expect(primitive.attributes.TEXCOORD_0.array.length).to.be.eql(4798);
expect(primitive.attributes.TEXCOORD_0.array instanceof Float32Array).to.be.ok();
expect(primitive.indices.array.length).to.be.eql(12636);
expect(primitive.indices.array instanceof Uint16Array).to.be.ok();
const textures = gltf.textures;
const materials = gltf.materials;
//materialasset
const index = primitive.material;
const baseColorTexture = materials[index].pbrMetallicRoughness.baseColorTexture.index;
expect(textures[baseColorTexture].image.array.length).to.be.eql(1048576);
expect(textures[baseColorTexture].image.mimeType).to.be.eql('image/png');
done();
});
});
});
it('load animations', done => {
const root = 'models/dancing/glTF';
gltf.Ajax.getJSON(root + '/SambaDancing.gltf', {}).then(json => {
const loader = new gltf.GLTFLoader(root, json);
loader.load().then(gltf => {
const animations = gltf.animations;
expect(animations.length).to.be.eql(1);
const aniamtion = animations[0];
const samplers = aniamtion.samplers;
const channels = aniamtion.channels;
expect(samplers.length).to.be.eql(53);
expect(channels.length).to.be.eql(53);
for (let i = 0; i < samplers.length; i++) {
expect(samplers[i].input.array instanceof Float32Array).to.be.ok();
expect(samplers[i].output.array instanceof Float32Array).to.be.ok();
}
expect(samplers[0].input.array.length).to.be.eql(365);
expect(samplers[0].output.array.length).to.be.eql(1460);
done();
});
});
});
it('get timespan when gltf has animations', done => {
const root = 'models/cubicspline';
gltf.Ajax.getJSON(root + '/cubicspline.gltf', {}).then(json => {
const loader = new gltf.GLTFLoader(root, json);
loader.load().then(data => {
const animTimeSpan = gltf.GLTFLoader.getAnimationTimeSpan(data);
expect(animTimeSpan.max).to.be.eql(2.5);
expect(animTimeSpan.min).to.be.eql(0.0);
done();
});
});
});
it('load gltf model with skinning', done => {
const root = 'models/dancing/glTF';
gltf.Ajax.getJSON(root + '/SambaDancing.gltf', {}).then(json => {
const loader = new gltf.GLTFLoader(root, json);
loader.load().then(gltf => {
const skins = gltf.skins;
const skin0 = skins[0];
const skin1 = skins[1];
expect(skin0.joints.length).to.be.eql(52);
expect(skin1.joints.length).to.be.eql(52);
done();
});
});
});
it('get external resources', (done) => {
const root = 'models/DamagedHelmet/glTF';
gltf.Ajax.getJSON(root + '/DamagedHelmet.gltf', {}).then(json => {
const loader = new gltf.GLTFLoader(root, json);
const resources = loader.getExternalResources();
expect(resources.length).to.be.eql(6);
expect(resources[0].type).to.be.eql('buffer');
expect(resources[0].uri).to.be.eql('DamagedHelmet.bin');
expect(resources[1].type).to.be.eql('image');
expect(resources[1].uri).to.be.eql('Default_albedo.jpg');
done();
});
});
it('create channels map', done => {
const root = 'models/dancing/glTF';
gltf.Ajax.getJSON(root + '/SambaDancing.gltf', {}).then(json => {
const loader = new gltf.GLTFLoader(root, json);
loader.load().then(gltf => {
const node = 0;
expect(gltf.animations[0].channelsMap[node]).to.be.ok();
expect(gltf.animations[0].channelsMap[node].length).to.be.eql(2);
expect(Object.keys(gltf.animations[0].channelsMap).length).to.be.eql(52);
done();
});
});
});
it('get all resources in .bin', (done) => {
const root = 'models/商业1-17263520294539783362';
gltf.Ajax.getJSON(root + '/商业1.gltf', {}).then(json => {
const loader = new gltf.GLTFLoader(root, json);
loader.load().then(gltf => {
expect(gltf.scene).to.be.eql(0);
const nodes = gltf.scenes[gltf.scene].nodes;
expect(nodes[0]).to.be.ok();
const children0 = nodes[0].children;
expect(children0.length).to.be.eql(1);
const children1 = children0[0].children;
expect(children1.length).to.be.eql(1);
const children2 = children1[0].children;
expect(children2.length).to.be.eql(1);
const children3 = children2[0];
expect(children3).to.be.ok();
let index = 0;
for (const node in gltf.nodes) {
expect(Number(gltf.nodes[node].nodeIndex)).to.be.eql(index);
index++;
}
done();
});
});
});
it('fix the source image could not be decode', (done) => {
const root = 'models/rw';
gltf.Ajax.getArrayBuffer(root + '/RW_nanren_1_1663921653346.glb', {}).then(json => {
const loader = new gltf.GLTFLoader(root, { buffer : json.data, byteOffset : 0 }, { requestImage : request });
loader.load().then(gltf => {
expect(gltf.scene).to.be.eql(0);
const textures = gltf.textures;
expect(textures.length).to.be.eql(1);
const materials = gltf.materials;
expect(materials.length).to.be.eql(1);
expect(textures[0].image.array.length).to.be.eql(4194304);
done();
});
});
});
});
});
describe('gltf v1', () => {
it('load box glb', done => {
const root = 'models/v1/Box';
gltf.Ajax.getArrayBuffer(root + '/Box.glb', {}).then(response => {
const loader = new gltf.GLTFLoader(root, { buffer : response.data, byteOffset : 0 });
loader.load()
.then(json => {
expect(json.scene).to.be.eql(0);
const nodes = json.scenes[json.scene].nodes;
expect(nodes[0]).to.be.ok();
expect(nodes[0].children.length).to.be.eql(1);
const meshId = nodes[0].children[0].mesh;
const mesh = json.meshes[meshId];
const primitive = mesh.primitives[0];
//primitive
expect(primitive.attributes.NORMAL.array.length).to.be.eql(72);
expect(primitive.attributes.NORMAL.array instanceof Float32Array).to.be.ok();
const normal = primitive.attributes.NORMAL;
expect(normal.array.slice(0, 3)).to.be.eql({ '0': 0, '1': 0, '2': 1 });
expect(primitive.attributes.POSITION.array.length).to.be.eql(72);
expect(primitive.attributes.POSITION.array instanceof Float32Array).to.be.ok();
const position = primitive.attributes.POSITION;
expect(position.array.slice(0, 3)).to.be.eql({ '0': -0.5, '1': -0.5, '2': 0.5 });
expect(primitive.indices.array.length).to.be.eql(36);
expect(primitive.indices.array instanceof Uint16Array).to.be.ok();
done();
});
});
});
});
describe('get animation clip', () => {
it('get TRS matrix', done => {
const root = 'models/cubicspline';
gltf.Ajax.getJSON(root + '/cubicspline.gltf', {}).then(json => {
const loader = new gltf.GLTFLoader(root, json);
loader.load().then(data => {
const time = 0.5;
const animation = gltf.GLTFLoader.getAnimationClip(data, 0, time);
//const correctMat = mat4.fromValues(1.0290393123321313, 0, -0, 0, 0, 1.0290393123321313, 0, 0, 0, -0, 1.0290393123321313, 0, 0, 0, 0, 1);
expect(animation.translation).to.be.eql([0, 0, 0]);
expect(animation.rotation).to.be.eql([0, 0, 0, 1]);
expect(animation.scale).to.be.eql([1.0290393123321313, 1.0290393123321313, 1.0290393123321313]);
done();
});
});
});
it('get weights for morph targets', done => {
const root = 'models/v2/simpleMorph';
gltf.Ajax.getJSON(root + '/simpleMorph.gltf', {}).then(json => {
const loader = new gltf.GLTFLoader(root, json);
loader.load().then(data => {
gltf.GLTFLoader.getAnimationClip(data, 0, 0.5);
expect(data.nodes[0].weights).to.be.eql([0, 0.5]);
gltf.GLTFLoader.getAnimationClip(data, 0, 1.0);
expect(data.nodes[0].weights).to.be.eql([0, 1]);
gltf.GLTFLoader.getAnimationClip(data, 0, 1.5);
expect(data.nodes[0].weights).to.be.eql([0.5, 1]);
gltf.GLTFLoader.getAnimationClip(data, 0, 2.0);
expect(data.nodes[0].weights).to.be.eql([1, 1]);
done();
});
});
});
it('more than 8 morph targets', done => {
const root = 'models/v2/simple_flower_loop';
gltf.Ajax.getJSON(root + '/scene.gltf', {}).then(json => {
const loader = new gltf.GLTFLoader(root, json);
loader.load().then(data => {
expect(data.nodes[6].weights).to.be.eql([0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]);
expect(data.meshes[0].primitives[0].morphTargets['POSITION_35']).to.be.ok();
const animation = gltf.GLTFLoader.getAnimationClip(data, 6, 0.8);
const weights = animation.weights;
expect(weights).to.be.eql([0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0.7999999046327038, 0.19999961853013806, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]);
done();
});
});
});
it('asset', done => {
const root = 'models/dancing/glTF';
gltf.Ajax.getJSON(root + '/SambaDancing.gltf', {}).then(json => {
const loader = new gltf.GLTFLoader(root, json);
loader.load().then(gltf => {
expect(gltf.asset).to.be.ok();
done();
});
});
});
it('more than one animations', done => {
const root = 'models/v2/Fox';
gltf.Ajax.getJSON(root + '/Fox.gltf', {}).then(json => {
const loader = new gltf.GLTFLoader(root, json);
loader.load().then(data => {
const timeSpan1 = gltf.GLTFLoader.getAnimationTimeSpan(data);
const timeSpan2 = gltf.GLTFLoader.getAnimationTimeSpan(data, 'Survey');
const timeSpan3 = gltf.GLTFLoader.getAnimationTimeSpan(data, 'Walk');
const timeSpan4 = gltf.GLTFLoader.getAnimationTimeSpan(data, 'Run');
expect(timeSpan1).to.be.eql({ max: 3.4166667461395264, min: 0 });
expect(timeSpan2).to.be.eql({ max: 3.4166667461395264, min: 0 });
expect(timeSpan3).to.be.eql({ max: 0.7083333134651184, min: 0 });
expect(timeSpan4).to.be.eql({ max: 1.1583333015441895, min: 0 });
done();
});
});
});
it('a large number of meshes', done => {
const root = 'models/258-Third';
gltf.Ajax.getArrayBuffer(root + '/258-Third.glb', {}).then(response => {
const loader = new gltf.GLTFLoader(root, { buffer : response.data, byteOffset : 0 }, { decoders, transferable: true });
loader.load({
skipAttributeTransform: true
})
.then(json => {
expect(json).to.be.ok();
expect(Object.keys(json.meshes).length).to.be.eql(1755);
expect(Object.keys(json.nodes).length).to.be.eql(1887);
done();
});
});
})
});
describe('gltf extensions', () => {
it('KHR_materials_pbrSpecularGlossiness', (done) => {
const root = 'models/v2/KHR/';
gltf.Ajax.getArrayBuffer(root + '/scene.glb', {}).then(json => {
const loader = new gltf.GLTFLoader(root, { buffer : json.data, byteOffset : 0 });
loader.load().then(gltfData => {
const meshes = gltfData.meshes;
const materials = gltfData.materials;
const textures = gltfData.textures;
const pbrSpecularGlossiness = materials[meshes[0].primitives[0].material].extensions['KHR_materials_pbrSpecularGlossiness'];
expect(pbrSpecularGlossiness).to.be.ok();
const diffuseTexture = pbrSpecularGlossiness.diffuseTexture;
expect(textures[diffuseTexture.index].image.array.length).to.be.eql(4194304);
expect(pbrSpecularGlossiness.glossinessFactor).to.be.eql(0);
expect(pbrSpecularGlossiness.specularFactor).to.be.eql([0, 0, 0]);
done();
});
});
});
});
describe('interleaved', () => {
it('interleaved data structrue model', done => {
const root = 'models/interleaved/SimpleTexture';
gltf.Ajax.getJSON(root + '/SimpleTexture.gltf', {}).then(json => {
const loader = new gltf.GLTFLoader(root, json);
loader.load().then(gltf => {
const mesh = gltf.meshes[0];
const primitive = mesh.primitives[0];
expect(primitive.attributes['POSITION'].array.length).to.be.eql(12);
expect(primitive.attributes['POSITION'].byteLength).to.be.eql(48);
expect(primitive.attributes['POSITION'].byteStride).to.be.eql(0);
expect(primitive.attributes['POSITION'].itemSize).to.be.eql(3);
expect(primitive.attributes['POSITION'].byteOffset).to.be.eql(0);
expect(primitive.attributes['POSITION'].componentType).to.be.eql(5126);
expect(primitive.attributes['TEXCOORD_0'].array.length).to.be.eql(8);
expect(primitive.attributes['TEXCOORD_0'].byteLength).to.be.eql(32);
expect(primitive.attributes['TEXCOORD_0'].byteStride).to.be.eql(0);
expect(primitive.attributes['TEXCOORD_0'].itemSize).to.be.eql(2);
expect(primitive.attributes['TEXCOORD_0'].byteOffset).to.be.eql(0);
expect(primitive.attributes['POSITION'].componentType).to.be.eql(5126);
expect(primitive.indices.array.length).to.be.eql(6);
done();
});
});
});
it('readInterleavedArray', done => {
const root = 'models/interleaved/SimpleTexture';
gltf.Ajax.getJSON(root + '/SimpleTexture.gltf', {}).then(json => {
const loader = new gltf.GLTFLoader(root, json);
loader.load().then(json => {
const mesh = json.meshes[0];
const primitive = mesh.primitives[0];
expect(primitive.attributes['POSITION'].array.length).to.be.eql(12);
expect(primitive.attributes['POSITION'].array.slice(3, 6)).to.eql({'0': 1, '1': 0, '2': 0});
done();
});
});
})
});
describe('draco', () => {
it('draco model', done => {
const root = 'models/draco';
gltf.Ajax.getJSON(root + '/draco.gltf', {}).then(json => {
const loader = new gltf.GLTFLoader(root, json, { decoders, transferable: true });
loader.load().then(json => {
expect(json.meshes[0]).to.be.ok();
expect(json.nodes[0]).to.be.ok();
const mesh = json.meshes[0];
const primitive = mesh.primitives[0];
expect(primitive.attributes['POSITION'].array.length).to.be.eql(43668);
expect(primitive.attributes['POSITION'].array.slice(0, 3)).to.eql({0: -0.6119945645332336, 1: -0.03094087541103363, 2: 0.48309004306793213});
done();
});
});
});
});