Hi,
I make 3d models with blender and I need to present them on a website. Can I upload my models here on github to have access to them online? If so, how can I do it?
Hi,
I make 3d models with blender and I need to present them on a website. Can I upload my models here on github to have access to them online? If so, how can I do it?
I moved your question to #questions - just to let you know, #resources category is to share resources like libraries, tutorials etc.
If youâd like to use github as hosting, create a repo and enable github pages on it. Repo will then become a normal, hosted website, and you will be able to access resources using links like:
https://[YOUR_NAME].github.io/[REPO_NAME]/[PATH]/[FILE].[EXTENSION]
(ex.: https://mjurczyk.github.io/three.js/examples/models/gltf/BoomBox/glTF/BoomBox.gltf)
Thank you very much!
So I created a repo and uploaded the mesh. But when I try to display the mesh on the website I still get an error:
Access to XMLHttpRequest at âhttps://github.com/ga34rul/assets/blob/882ed02e67e740e68d03e150a9fb5cd535573cd0/Shelf.glb?raw=trueâ has been blocked by CORS policy: No âAccess-Control-Allow-Originâ header is present on the requested resource.
github.com/ga34rul/assets/blob/882ed02e67e740e68d03e150a9fb5cd535573cd0/Shelf.glb?raw=true:1
I tried different paths like https://github.com/ga34rul/assets/raw/meshes/Shelf.glb and so an. He wont let me display it on the site.
Maybe I uploaded it wrong? Can I also upload my meshes in the three.js/examples/models/gltf -path?
Sorry, my mistake - try removing the https:
from the url:
//github.com/ga34rul/assets/blob/882ed02e67e740e68d03e150a9fb5cd535573cd0/Shelf.glb?raw=true
Iâm guessing you are trying to load these assets in a non-HTTPS origin and itâs blocked automatically.
just tried it. He then puts the https: automatically in front of the URL and I get the same error.
https:
part.this is how the code looks like:
const gltfLoader = new THREE.GLTFLoader();
gltfLoader.load(â//github.com/ga34rul/assets/blob/gh-pages/Shelf.glb?raw=trueâ, (gltf) => {
const shelfMesh = gltf.scene;
shelfMesh.position.set(0,0,0);
scene.add(shelfMesh);
});
I removed the âhttps:â
Sorry for the high noob-level⌠oO
I uploaded the file under âgh-pagesâ. Still the same. No matter if itâs under âgh-pagesâ, âmainâ or âmeshesâ.
I right click on ârawâ or âDownloadâ to get the URL. Maybe thatâs the mistake? I donât see any other way to access the URL.
(function(){
var q = new XMLHttpRequest();
q.open('HEAD', 'https://raw.githubusercontent.com/ga34rul/assets/0be5fd5c951882a646c850629d4d8e0dac5baa55/Shelf.glb', !1);
q.send(null); alert(q.getAllResponseHeaders()) })();
If I were you, I wouldnât use a free host.
Why do you say so? I understand about other âiffyâ adware based sites etc, but why not github?
@rrrr_rrrr why the HEAD
request? That looks like a nasty hack.
On the other hand your URL structure works much better - just instead of using it in XHR, it should be enough to do:
(new GLTFLoader()).load(
"//raw.githubusercontent.com/ga34rul/assets/0be5fd5c951882a646c850629d4d8e0dac5baa55/Shef.glb",
model => {
scene.add(model.scene);
}
);
I need to type "THREE.GLTFLoader instead of just GLTFLoader , otherwise I get an error. But still I get the same error as usual. Itâs starting to get frustratingâŚ
I donât mind to share the models I create. So if it is possible to upload them to three.js/model it might work.
Hm, I tested it on codepen and it works just fine. Can you share your code?
A simple and easy way to check if a file can be fetched.
Run it from console, address bar or your own custom javascript commander.
he wont let my post any answers no moreâŚ
I hope this time it works:
so I commented my code and put yours:
//const gltfLoader = new THREE.GLTFLoader();
/* gltfLoader.load(â//github.com/ga34rul/assets/blob/gh-pages/Shelf.glbâ, (gltf) => {
const shelfMesh = gltf.scene;
shelfMesh.position.set(0,0,0);
shelfMesh.scale.set(3,3,3);
scene.add(shelfMesh);
}); */
(new THREE.GLTFLoader()).load(
â//github.com/ga34rul/assets/blob/gh-pages/Shelf.glbâ,
model => {
scene.add(model.scene);
}
);
Edit: Or do you mean the whole code? itâs pretty longâŚ
Iâve been changing the URL the whole timeâŚ
When I type your code (with another URL), I get:
[Deprecation] Synchronous XMLHttpRequest on the main thread is deprecated because of its detrimental effects to the end userâs experience. For more help, check https://xhr.spec.whatwg.org/.
In your code the URL is now to raw.githubuserconrent.com - it will not work.
Using the URL @rrrr_rrrr shared should work.
Iâm probably too dumb -__-"
Can you show the code with that url used ? Iâm afk, canât write you a sample codepen atm, sry.
(new THREE.GLTFLoader()).load(
â//raw.githubusercontent.com/ga34rul/assets/0be5fd5c951882a646c850629d4d8e0dac5baa55/Shef.glbâ,
model => {
scene.add(model.scene);
}
);
Garçon. My dear. Please do take a look at that url youâre using. Take as much time, letter by letter. Inhale that url. Become that url. You shalt then find the truth. Truth that is not connected to github / hosting / GLTFLoader in any way. :â) (it is kind of connected to my mistake in the post I made earlier, but I asked you to specifically use @rrrr_rrrrâs url, not mine, so that clears my name and any claims against me. )
[ Hint: look at the filename :â) ]