How to replace and load a GLTF model into a ready made html document
up vote
0
down vote
favorite
I have copied code from https://threejs.org/examples/#webgl_loader_gltf and pasted it into an html document. I relinked all of the models, textures and .js files locally from MrDoob's JavaScript 3D library https://github.com/mrdoob/three.js/. When I link GLTF files from his folder locally on my computer I am able to view them in firefox but when I simply change the GLTF to my model I am unable to see it. I tried scalling the model down in blender before I export it and I also tried viewing it in Babylon viewer online (I was able to view my own GLTF model on the online Babylon viewer no problem).
// model
var loader = new THREE.GLTFLoader();
loader.load( '../../skull_downloadable/scene.gltf', function ( gltf )
gltf.scene.traverse( function ( child )
if ( child.isMesh )
child.material.envMap = envMap;
);
scene.add( gltf.scene );
, undefined, function ( error )
console.error( error );
);
renderer = new THREE.WebGLRenderer( antialias: true );
renderer.setPixelRatio( window.devicePixelRatio );
renderer.setSize( window.innerWidth, window.innerHeight );
renderer.gammaOutput = true;
container.appendChild( renderer.domElement );
window.addEventListener( 'resize', onWindowResize, false );
// stats
stats = new Stats();
container.appendChild( stats.dom );
}
function onWindowResize()
camera.aspect = window.innerWidth / window.innerHeight;
camera.updateProjectionMatrix();
renderer.setSize( window.innerWidth, window.innerHeight );
webgl gltf
add a comment |
up vote
0
down vote
favorite
I have copied code from https://threejs.org/examples/#webgl_loader_gltf and pasted it into an html document. I relinked all of the models, textures and .js files locally from MrDoob's JavaScript 3D library https://github.com/mrdoob/three.js/. When I link GLTF files from his folder locally on my computer I am able to view them in firefox but when I simply change the GLTF to my model I am unable to see it. I tried scalling the model down in blender before I export it and I also tried viewing it in Babylon viewer online (I was able to view my own GLTF model on the online Babylon viewer no problem).
// model
var loader = new THREE.GLTFLoader();
loader.load( '../../skull_downloadable/scene.gltf', function ( gltf )
gltf.scene.traverse( function ( child )
if ( child.isMesh )
child.material.envMap = envMap;
);
scene.add( gltf.scene );
, undefined, function ( error )
console.error( error );
);
renderer = new THREE.WebGLRenderer( antialias: true );
renderer.setPixelRatio( window.devicePixelRatio );
renderer.setSize( window.innerWidth, window.innerHeight );
renderer.gammaOutput = true;
container.appendChild( renderer.domElement );
window.addEventListener( 'resize', onWindowResize, false );
// stats
stats = new Stats();
container.appendChild( stats.dom );
}
function onWindowResize()
camera.aspect = window.innerWidth / window.innerHeight;
camera.updateProjectionMatrix();
renderer.setSize( window.innerWidth, window.innerHeight );
webgl gltf
are you running a local server like Servez or one of these (stackoverflow.com/questions/12905426/…)
– gman
Nov 12 at 17:39
I am not running a local server I'm just using the files off of my hard drive
– Gideon Chrapko
Nov 12 at 19:27
then you are going to have problems. you need to run a local server. it will take you 30 seconds. without one you can't do WebGL dev as the browser will block loading files and images of.yoir hard drive has it would be a security risk
– gman
Nov 13 at 2:11
Amazing thank you so much, I am using Servez and it helped. I also had trouble locating files within my html document but I was able to find the proper files while running it off of the server fixed everything!
– Gideon Chrapko
Nov 13 at 11:08
add a comment |
up vote
0
down vote
favorite
up vote
0
down vote
favorite
I have copied code from https://threejs.org/examples/#webgl_loader_gltf and pasted it into an html document. I relinked all of the models, textures and .js files locally from MrDoob's JavaScript 3D library https://github.com/mrdoob/three.js/. When I link GLTF files from his folder locally on my computer I am able to view them in firefox but when I simply change the GLTF to my model I am unable to see it. I tried scalling the model down in blender before I export it and I also tried viewing it in Babylon viewer online (I was able to view my own GLTF model on the online Babylon viewer no problem).
// model
var loader = new THREE.GLTFLoader();
loader.load( '../../skull_downloadable/scene.gltf', function ( gltf )
gltf.scene.traverse( function ( child )
if ( child.isMesh )
child.material.envMap = envMap;
);
scene.add( gltf.scene );
, undefined, function ( error )
console.error( error );
);
renderer = new THREE.WebGLRenderer( antialias: true );
renderer.setPixelRatio( window.devicePixelRatio );
renderer.setSize( window.innerWidth, window.innerHeight );
renderer.gammaOutput = true;
container.appendChild( renderer.domElement );
window.addEventListener( 'resize', onWindowResize, false );
// stats
stats = new Stats();
container.appendChild( stats.dom );
}
function onWindowResize()
camera.aspect = window.innerWidth / window.innerHeight;
camera.updateProjectionMatrix();
renderer.setSize( window.innerWidth, window.innerHeight );
webgl gltf
I have copied code from https://threejs.org/examples/#webgl_loader_gltf and pasted it into an html document. I relinked all of the models, textures and .js files locally from MrDoob's JavaScript 3D library https://github.com/mrdoob/three.js/. When I link GLTF files from his folder locally on my computer I am able to view them in firefox but when I simply change the GLTF to my model I am unable to see it. I tried scalling the model down in blender before I export it and I also tried viewing it in Babylon viewer online (I was able to view my own GLTF model on the online Babylon viewer no problem).
// model
var loader = new THREE.GLTFLoader();
loader.load( '../../skull_downloadable/scene.gltf', function ( gltf )
gltf.scene.traverse( function ( child )
if ( child.isMesh )
child.material.envMap = envMap;
);
scene.add( gltf.scene );
, undefined, function ( error )
console.error( error );
);
renderer = new THREE.WebGLRenderer( antialias: true );
renderer.setPixelRatio( window.devicePixelRatio );
renderer.setSize( window.innerWidth, window.innerHeight );
renderer.gammaOutput = true;
container.appendChild( renderer.domElement );
window.addEventListener( 'resize', onWindowResize, false );
// stats
stats = new Stats();
container.appendChild( stats.dom );
}
function onWindowResize()
camera.aspect = window.innerWidth / window.innerHeight;
camera.updateProjectionMatrix();
renderer.setSize( window.innerWidth, window.innerHeight );
// model
var loader = new THREE.GLTFLoader();
loader.load( '../../skull_downloadable/scene.gltf', function ( gltf )
gltf.scene.traverse( function ( child )
if ( child.isMesh )
child.material.envMap = envMap;
);
scene.add( gltf.scene );
, undefined, function ( error )
console.error( error );
);
renderer = new THREE.WebGLRenderer( antialias: true );
renderer.setPixelRatio( window.devicePixelRatio );
renderer.setSize( window.innerWidth, window.innerHeight );
renderer.gammaOutput = true;
container.appendChild( renderer.domElement );
window.addEventListener( 'resize', onWindowResize, false );
// stats
stats = new Stats();
container.appendChild( stats.dom );
}
function onWindowResize()
camera.aspect = window.innerWidth / window.innerHeight;
camera.updateProjectionMatrix();
renderer.setSize( window.innerWidth, window.innerHeight );
// model
var loader = new THREE.GLTFLoader();
loader.load( '../../skull_downloadable/scene.gltf', function ( gltf )
gltf.scene.traverse( function ( child )
if ( child.isMesh )
child.material.envMap = envMap;
);
scene.add( gltf.scene );
, undefined, function ( error )
console.error( error );
);
renderer = new THREE.WebGLRenderer( antialias: true );
renderer.setPixelRatio( window.devicePixelRatio );
renderer.setSize( window.innerWidth, window.innerHeight );
renderer.gammaOutput = true;
container.appendChild( renderer.domElement );
window.addEventListener( 'resize', onWindowResize, false );
// stats
stats = new Stats();
container.appendChild( stats.dom );
}
function onWindowResize()
camera.aspect = window.innerWidth / window.innerHeight;
camera.updateProjectionMatrix();
renderer.setSize( window.innerWidth, window.innerHeight );
webgl gltf
webgl gltf
edited Nov 12 at 5:16
Zain Farooq
1,7132926
1,7132926
asked Nov 12 at 5:14
Gideon Chrapko
22
22
are you running a local server like Servez or one of these (stackoverflow.com/questions/12905426/…)
– gman
Nov 12 at 17:39
I am not running a local server I'm just using the files off of my hard drive
– Gideon Chrapko
Nov 12 at 19:27
then you are going to have problems. you need to run a local server. it will take you 30 seconds. without one you can't do WebGL dev as the browser will block loading files and images of.yoir hard drive has it would be a security risk
– gman
Nov 13 at 2:11
Amazing thank you so much, I am using Servez and it helped. I also had trouble locating files within my html document but I was able to find the proper files while running it off of the server fixed everything!
– Gideon Chrapko
Nov 13 at 11:08
add a comment |
are you running a local server like Servez or one of these (stackoverflow.com/questions/12905426/…)
– gman
Nov 12 at 17:39
I am not running a local server I'm just using the files off of my hard drive
– Gideon Chrapko
Nov 12 at 19:27
then you are going to have problems. you need to run a local server. it will take you 30 seconds. without one you can't do WebGL dev as the browser will block loading files and images of.yoir hard drive has it would be a security risk
– gman
Nov 13 at 2:11
Amazing thank you so much, I am using Servez and it helped. I also had trouble locating files within my html document but I was able to find the proper files while running it off of the server fixed everything!
– Gideon Chrapko
Nov 13 at 11:08
are you running a local server like Servez or one of these (stackoverflow.com/questions/12905426/…)
– gman
Nov 12 at 17:39
are you running a local server like Servez or one of these (stackoverflow.com/questions/12905426/…)
– gman
Nov 12 at 17:39
I am not running a local server I'm just using the files off of my hard drive
– Gideon Chrapko
Nov 12 at 19:27
I am not running a local server I'm just using the files off of my hard drive
– Gideon Chrapko
Nov 12 at 19:27
then you are going to have problems. you need to run a local server. it will take you 30 seconds. without one you can't do WebGL dev as the browser will block loading files and images of.yoir hard drive has it would be a security risk
– gman
Nov 13 at 2:11
then you are going to have problems. you need to run a local server. it will take you 30 seconds. without one you can't do WebGL dev as the browser will block loading files and images of.yoir hard drive has it would be a security risk
– gman
Nov 13 at 2:11
Amazing thank you so much, I am using Servez and it helped. I also had trouble locating files within my html document but I was able to find the proper files while running it off of the server fixed everything!
– Gideon Chrapko
Nov 13 at 11:08
Amazing thank you so much, I am using Servez and it helped. I also had trouble locating files within my html document but I was able to find the proper files while running it off of the server fixed everything!
– Gideon Chrapko
Nov 13 at 11:08
add a comment |
active
oldest
votes
Your Answer
StackExchange.ifUsing("editor", function ()
StackExchange.using("externalEditor", function ()
StackExchange.using("snippets", function ()
StackExchange.snippets.init();
);
);
, "code-snippets");
StackExchange.ready(function()
var channelOptions =
tags: "".split(" "),
id: "1"
;
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function()
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled)
StackExchange.using("snippets", function()
createEditor();
);
else
createEditor();
);
function createEditor()
StackExchange.prepareEditor(
heartbeatType: 'answer',
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader:
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
,
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
);
);
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53256269%2fhow-to-replace-and-load-a-gltf-model-into-a-ready-made-html-document%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
active
oldest
votes
active
oldest
votes
active
oldest
votes
active
oldest
votes
Thanks for contributing an answer to Stack Overflow!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Some of your past answers have not been well-received, and you're in danger of being blocked from answering.
Please pay close attention to the following guidance:
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53256269%2fhow-to-replace-and-load-a-gltf-model-into-a-ready-made-html-document%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
are you running a local server like Servez or one of these (stackoverflow.com/questions/12905426/…)
– gman
Nov 12 at 17:39
I am not running a local server I'm just using the files off of my hard drive
– Gideon Chrapko
Nov 12 at 19:27
then you are going to have problems. you need to run a local server. it will take you 30 seconds. without one you can't do WebGL dev as the browser will block loading files and images of.yoir hard drive has it would be a security risk
– gman
Nov 13 at 2:11
Amazing thank you so much, I am using Servez and it helped. I also had trouble locating files within my html document but I was able to find the proper files while running it off of the server fixed everything!
– Gideon Chrapko
Nov 13 at 11:08