threeJs wrong (too low) camera position The 2019 Stack Overflow Developer Survey Results Are In Announcing the arrival of Valued Associate #679: Cesar Manara Planned maintenance scheduled April 17/18, 2019 at 00:00UTC (8:00pm US/Eastern) The Ask Question Wizard is Live! Data science time! April 2019 and salary with experienceRetrieve the position (X,Y) of an HTML elementAnimating Canvas Billboard in THREE.jsOdd artifacts and Empty texture in extruded shape in three.jsthree.js: Rotate around origin after panning cameraUsing textures on spheres in three.jsthree.js Mesh not displaying rectangle depending on orientationHow to load .obj 3D model in Three.js?GLTF create instancesThreejs JSONLoader and OOP, how to attach model to scene (from loader callback)How to overlay texture from GLTF model dynamically - Three.js

Why did Peik Lin say, "I'm not an animal"?

Was credit for the black hole image misappropriated?

Visa regaring travelling European country

How did the audience guess the pentatonic scale in Bobby McFerrin's presentation?

What can I do if neighbor is blocking my solar panels intentionally?

Is it ethical to upload a automatically generated paper to a non peer-reviewed site as part of a larger research?

How to determine omitted units in a publication

What to do when moving next to a bird sanctuary with a loosely-domesticated cat?

Why can't devices on different VLANs, but on the same subnet, communicate?

How did passengers keep warm on sail ships?

How do you keep chess fun when your opponent constantly beats you?

US Healthcare consultation for visitors

If I score a critical hit on an 18 or higher, what are my chances of getting a critical hit if I roll 3d20?

What aspect of planet Earth must be changed to prevent the industrial revolution?

Do warforged have souls?

How to type a long/em dash `—`

"... to apply for a visa" or "... and applied for a visa"?

University's motivation for having tenure-track positions

Would an alien lifeform be able to achieve space travel if lacking in vision?

Didn't get enough time to take a Coding Test - what to do now?

How to handle characters who are more educated than the author?

Are spiders unable to hurt humans, especially very small spiders?

Identify 80s or 90s comics with ripped creatures (not dwarves)

Why not take a picture of a closer black hole?



threeJs wrong (too low) camera position



The 2019 Stack Overflow Developer Survey Results Are In
Announcing the arrival of Valued Associate #679: Cesar Manara
Planned maintenance scheduled April 17/18, 2019 at 00:00UTC (8:00pm US/Eastern)
The Ask Question Wizard is Live!
Data science time! April 2019 and salary with experienceRetrieve the position (X,Y) of an HTML elementAnimating Canvas Billboard in THREE.jsOdd artifacts and Empty texture in extruded shape in three.jsthree.js: Rotate around origin after panning cameraUsing textures on spheres in three.jsthree.js Mesh not displaying rectangle depending on orientationHow to load .obj 3D model in Three.js?GLTF create instancesThreejs JSONLoader and OOP, how to attach model to scene (from loader callback)How to overlay texture from GLTF model dynamically - Three.js



.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty height:90px;width:728px;box-sizing:border-box;








1















I am new to ThreeJS, what I am trying to accomplish is to load a gltf model, which is correctly shown in three-gltf-viewer, it is valid.



model from gltf web validator



When I load it into threeJS, the model loads up ok but the camera is placed on the horizon line of the model, and the orbit control does not work when I try to zoom in and out or any other rotation of the scene is disabled.



model from threeJS



I tried to tweak any possible values of camera and scene but I just can't "jump on top" of the model and see it from above. Here is the code.



var scene = new THREE.Scene();
var camera = new THREE.PerspectiveCamera( 800, window.innerWidth / window.innerHeight, 500, 1500000 );
camera.position.set(1, 1, 1);

var renderer = new THREE.WebGLRenderer( alpha: false );
renderer.setClearColor( 0xC5C5C3 );
renderer.setPixelRatio( window.devicePixelRatio );
renderer.setSize(window.innerWidth, window.innerHeight);
document.body.appendChild(renderer.domElement);

var controls = new THREE.OrbitControls( camera, renderer.domElement );
var ambientLight = new THREE.AmbientLight( 0xcccccc );
scene.add( ambientLight );
var directionalLight = new THREE.DirectionalLight( 0xffffff );
directionalLight.position.set( 0, 1, 1 ).normalize();
scene.add( directionalLight );

// Instantiate a loader
var loader = new THREE.GLTFLoader();
loader.load('GLTF_local_coord_sys/GEOTIFF_local_coord_sys.gltf',
function(gltf)
var object = gltf.scene;
gltf.scene.scale.set( 0.65, 0.65, 0.65 );
gltf.scene.position.x = 1;
gltf.scene.position.y = 1;
gltf.scene.position.z = 1;

scene.add( gltf.scene );
camera.lookAt(scene.position);
,
function ( xhr )
console.log( ( xhr.loaded / xhr.total * 100 ) + '% loaded' );
,
function ( error )
console.log( 'An error happened' );

);
camera.position.z =25;
function animate()
render();
requestAnimationFrame( animate );


function render()
renderer.render( scene, camera );

render();
animate();


Does anyone know how to fix this?










share|improve this question
























  • function ( error ) de console.log( 'An error happened' ); ); might be the problem

    – Tomasz Zieliński
    Mar 8 at 12:40











  • Thanks for spotting it, actually that was a piece of comment (I removed) before posting the code, I removed it but still I have the same problem.

    – user3523583
    Mar 8 at 13:52

















1















I am new to ThreeJS, what I am trying to accomplish is to load a gltf model, which is correctly shown in three-gltf-viewer, it is valid.



model from gltf web validator



When I load it into threeJS, the model loads up ok but the camera is placed on the horizon line of the model, and the orbit control does not work when I try to zoom in and out or any other rotation of the scene is disabled.



model from threeJS



I tried to tweak any possible values of camera and scene but I just can't "jump on top" of the model and see it from above. Here is the code.



var scene = new THREE.Scene();
var camera = new THREE.PerspectiveCamera( 800, window.innerWidth / window.innerHeight, 500, 1500000 );
camera.position.set(1, 1, 1);

var renderer = new THREE.WebGLRenderer( alpha: false );
renderer.setClearColor( 0xC5C5C3 );
renderer.setPixelRatio( window.devicePixelRatio );
renderer.setSize(window.innerWidth, window.innerHeight);
document.body.appendChild(renderer.domElement);

var controls = new THREE.OrbitControls( camera, renderer.domElement );
var ambientLight = new THREE.AmbientLight( 0xcccccc );
scene.add( ambientLight );
var directionalLight = new THREE.DirectionalLight( 0xffffff );
directionalLight.position.set( 0, 1, 1 ).normalize();
scene.add( directionalLight );

// Instantiate a loader
var loader = new THREE.GLTFLoader();
loader.load('GLTF_local_coord_sys/GEOTIFF_local_coord_sys.gltf',
function(gltf)
var object = gltf.scene;
gltf.scene.scale.set( 0.65, 0.65, 0.65 );
gltf.scene.position.x = 1;
gltf.scene.position.y = 1;
gltf.scene.position.z = 1;

scene.add( gltf.scene );
camera.lookAt(scene.position);
,
function ( xhr )
console.log( ( xhr.loaded / xhr.total * 100 ) + '% loaded' );
,
function ( error )
console.log( 'An error happened' );

);
camera.position.z =25;
function animate()
render();
requestAnimationFrame( animate );


function render()
renderer.render( scene, camera );

render();
animate();


Does anyone know how to fix this?










share|improve this question
























  • function ( error ) de console.log( 'An error happened' ); ); might be the problem

    – Tomasz Zieliński
    Mar 8 at 12:40











  • Thanks for spotting it, actually that was a piece of comment (I removed) before posting the code, I removed it but still I have the same problem.

    – user3523583
    Mar 8 at 13:52













1












1








1








I am new to ThreeJS, what I am trying to accomplish is to load a gltf model, which is correctly shown in three-gltf-viewer, it is valid.



model from gltf web validator



When I load it into threeJS, the model loads up ok but the camera is placed on the horizon line of the model, and the orbit control does not work when I try to zoom in and out or any other rotation of the scene is disabled.



model from threeJS



I tried to tweak any possible values of camera and scene but I just can't "jump on top" of the model and see it from above. Here is the code.



var scene = new THREE.Scene();
var camera = new THREE.PerspectiveCamera( 800, window.innerWidth / window.innerHeight, 500, 1500000 );
camera.position.set(1, 1, 1);

var renderer = new THREE.WebGLRenderer( alpha: false );
renderer.setClearColor( 0xC5C5C3 );
renderer.setPixelRatio( window.devicePixelRatio );
renderer.setSize(window.innerWidth, window.innerHeight);
document.body.appendChild(renderer.domElement);

var controls = new THREE.OrbitControls( camera, renderer.domElement );
var ambientLight = new THREE.AmbientLight( 0xcccccc );
scene.add( ambientLight );
var directionalLight = new THREE.DirectionalLight( 0xffffff );
directionalLight.position.set( 0, 1, 1 ).normalize();
scene.add( directionalLight );

// Instantiate a loader
var loader = new THREE.GLTFLoader();
loader.load('GLTF_local_coord_sys/GEOTIFF_local_coord_sys.gltf',
function(gltf)
var object = gltf.scene;
gltf.scene.scale.set( 0.65, 0.65, 0.65 );
gltf.scene.position.x = 1;
gltf.scene.position.y = 1;
gltf.scene.position.z = 1;

scene.add( gltf.scene );
camera.lookAt(scene.position);
,
function ( xhr )
console.log( ( xhr.loaded / xhr.total * 100 ) + '% loaded' );
,
function ( error )
console.log( 'An error happened' );

);
camera.position.z =25;
function animate()
render();
requestAnimationFrame( animate );


function render()
renderer.render( scene, camera );

render();
animate();


Does anyone know how to fix this?










share|improve this question
















I am new to ThreeJS, what I am trying to accomplish is to load a gltf model, which is correctly shown in three-gltf-viewer, it is valid.



model from gltf web validator



When I load it into threeJS, the model loads up ok but the camera is placed on the horizon line of the model, and the orbit control does not work when I try to zoom in and out or any other rotation of the scene is disabled.



model from threeJS



I tried to tweak any possible values of camera and scene but I just can't "jump on top" of the model and see it from above. Here is the code.



var scene = new THREE.Scene();
var camera = new THREE.PerspectiveCamera( 800, window.innerWidth / window.innerHeight, 500, 1500000 );
camera.position.set(1, 1, 1);

var renderer = new THREE.WebGLRenderer( alpha: false );
renderer.setClearColor( 0xC5C5C3 );
renderer.setPixelRatio( window.devicePixelRatio );
renderer.setSize(window.innerWidth, window.innerHeight);
document.body.appendChild(renderer.domElement);

var controls = new THREE.OrbitControls( camera, renderer.domElement );
var ambientLight = new THREE.AmbientLight( 0xcccccc );
scene.add( ambientLight );
var directionalLight = new THREE.DirectionalLight( 0xffffff );
directionalLight.position.set( 0, 1, 1 ).normalize();
scene.add( directionalLight );

// Instantiate a loader
var loader = new THREE.GLTFLoader();
loader.load('GLTF_local_coord_sys/GEOTIFF_local_coord_sys.gltf',
function(gltf)
var object = gltf.scene;
gltf.scene.scale.set( 0.65, 0.65, 0.65 );
gltf.scene.position.x = 1;
gltf.scene.position.y = 1;
gltf.scene.position.z = 1;

scene.add( gltf.scene );
camera.lookAt(scene.position);
,
function ( xhr )
console.log( ( xhr.loaded / xhr.total * 100 ) + '% loaded' );
,
function ( error )
console.log( 'An error happened' );

);
camera.position.z =25;
function animate()
render();
requestAnimationFrame( animate );


function render()
renderer.render( scene, camera );

render();
animate();


Does anyone know how to fix this?







javascript three.js 3d gltf






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited Mar 8 at 18:44









Marquizzo

6,64152045




6,64152045










asked Mar 8 at 12:33









user3523583user3523583

4810




4810












  • function ( error ) de console.log( 'An error happened' ); ); might be the problem

    – Tomasz Zieliński
    Mar 8 at 12:40











  • Thanks for spotting it, actually that was a piece of comment (I removed) before posting the code, I removed it but still I have the same problem.

    – user3523583
    Mar 8 at 13:52

















  • function ( error ) de console.log( 'An error happened' ); ); might be the problem

    – Tomasz Zieliński
    Mar 8 at 12:40











  • Thanks for spotting it, actually that was a piece of comment (I removed) before posting the code, I removed it but still I have the same problem.

    – user3523583
    Mar 8 at 13:52
















function ( error ) de console.log( 'An error happened' ); ); might be the problem

– Tomasz Zieliński
Mar 8 at 12:40





function ( error ) de console.log( 'An error happened' ); ); might be the problem

– Tomasz Zieliński
Mar 8 at 12:40













Thanks for spotting it, actually that was a piece of comment (I removed) before posting the code, I removed it but still I have the same problem.

– user3523583
Mar 8 at 13:52





Thanks for spotting it, actually that was a piece of comment (I removed) before posting the code, I removed it but still I have the same problem.

– user3523583
Mar 8 at 13:52












0






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',
autoActivateHeartbeat: false,
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
);



);













draft saved

draft discarded


















StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55063338%2fthreejs-wrong-too-low-camera-position%23new-answer', 'question_page');

);

Post as a guest















Required, but never shown

























0






active

oldest

votes








0






active

oldest

votes









active

oldest

votes






active

oldest

votes















draft saved

draft discarded
















































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.




draft saved


draft discarded














StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55063338%2fthreejs-wrong-too-low-camera-position%23new-answer', 'question_page');

);

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







Popular posts from this blog

1928 у кіно

Захаров Федір Захарович

Ель Греко