-
Notifications
You must be signed in to change notification settings - Fork 8
/
drag-and-drop.js
28 lines (23 loc) · 930 Bytes
/
drag-and-drop.js
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
const dropEl = document.querySelector('.dropzone');
const inputEl = document.querySelector('.input');
const listEl = document.querySelector('.list');
const dropzone = new SimpleDropzone(dropEl, inputEl);
dropzone.on('drop', async ({files}) => {
let loader = new GltfLoader.GltfLoader();
let asset = await loader.loadFromFiles(files);
for(let i=0; i < asset.gltf.buffers.length; i++) {
let bufferData = await asset.bufferData.get(i);
console.log(asset.gltf.buffers[i].uri, bufferData)
}
for(let i=0; i < asset.gltf.images.length; i++) {
let imageData = await asset.imageData.get(i);
console.log(asset.gltf.images[i].uri, imageData);
}
files = Array.from(files);
listEl.innerHTML = files
.map(([filename, file]) => `<li>${filename} : ${file.size} bytes</li>`)
.join('');
});
dropzone.on('droperror', ({message}) => {
alert(`Error: ${message}`);
});