Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix error when loading painting from URL #268

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/systems/brush.js
Original file line number Diff line number Diff line change
Expand Up @@ -507,7 +507,7 @@ AFRAME.registerSystem('brush', {
console.timeEnd('Binary Loading');
},
loadFromUrl: function (url, binary) {
var loader = new THREE.XHRLoader(this.manager);
var loader = new THREE.FileLoader(this.manager);
loader.crossOrigin = 'anonymous';
if (binary === true) {
loader.setResponseType('arraybuffer');
Expand Down
13 changes: 6 additions & 7 deletions src/systems/painter.js
Original file line number Diff line number Diff line change
Expand Up @@ -76,13 +76,12 @@ AFRAME.registerSystem('painter', {
if (urlParams.url || urlParams.urljson) {
var isBinary = urlParams.urljson === undefined;
this.brushSystem.loadFromUrl(urlParams.url || urlParams.urljson, isBinary);
document.getElementById('logo').setAttribute('visible', false);
document.getElementById('acamera').setAttribute('orbit-controls', 'initialPosition: 0 1.6 3');
document.getElementById('apainter-logo').classList.remove('hidden');
//document.getElementById('apainter-author').classList.remove('hidden'); // not used yet
} else { // No painting to load, move camera in front of logo
const cameraEl = document.getElementById('acamera')
cameraEl.setAttribute('position', '0 1.6 0');
document.addEventListener('DOMContentLoaded', e => {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is strange. This logic is in the init method. It shouldn't run before the DOM is ready. Maybe I'm not fully understanding

document.getElementById('logo').setAttribute('visible', false);
document.getElementById('acamera').setAttribute('position', '0 1.6 3');
document.getElementById('apainter-logo').classList.remove('hidden');
//document.getElementById('apainter-author').classList.remove('hidden'); // not used yet
});
}

if (urlParams.bgcolor !== undefined) {
Expand Down