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
| const gui = new dat.GUI() const options = { Main: 0x787A79, Main_Light: 0xb9b9b9, Main_Dark: 0x383838, Hooves: 0x46423c, Hair: 0x383838, Muzzle: 0x3d3426, Eye_Dark: 0x181818, Eye_White: 0xe0e0e0 } const gltfLoader = new GLTFLoader() const donkeyUrl = new URL('../asserts/Donkey.gltf', import.meta.url) gltfLoader.load(donkeyUrl.href, gltf => { const model = gltf.scene; scene.add(model) gui.addColor(options, 'Main').onChange(newVal => { model.getObjectByName('Cube').material.color.set(newVal) }) gui.addColor(options, 'Main_Light').onChange(newVal => { model.getObjectByName('Cube_1').material.color.set(newVal) }) gui.addColor(options, 'Main_Dark').onChange(newVal => { model.getObjectByName('Cube_2').material.color.set(newVal) }) gui.addColor(options, 'Hooves').onChange(newVal => { model.getObjectByName('Cube_3').material.color.set(newVal) }) gui.addColor(options, 'Hair').onChange(newVal => { model.getObjectByName('Cube_4').material.color.set(newVal) }) gui.addColor(options, 'Muzzle').onChange(newVal => { model.getObjectByName('Cube_5').material.color.set(newVal) }) gui.addColor(options, 'Eye_Dark').onChange(newVal => { model.getObjectByName('Cube_6').material.color.set(newVal) }) gui.addColor(options, 'Eye_White').onChange(newVal => { model.getObjectByName('Cube_7').material.color.set(newVal) }) }, undefined, err => { console.error(err) })
|