Git Product home page Git Product logo

Comments (2)

ponchio avatar ponchio commented on July 23, 2024

It lokks like the problem is centering the object.

In the last commit i removed the autocentering code and moved it to the .html file, to be more compliant with threejs loading procedure.

In attachment an example:
nxs centering example.zip

from nexus.

dragonpoint avatar dragonpoint commented on July 23, 2024

I'm so sorry that the problem is because I didn't include corto.js in my project so ......
about how to center the object I have another solution without scaling model

//my program is showing a single model
function onLoadNxObjOver()
{
var p = new THREE.Vector3();
g_NexusObj.geometry.boundingBox.getCenter(p);
//move objec to (0,0,0)
g_NexusObj.position.set(-p.x, -p.y, -p.z);

//not necessary but my special demands
g_Obj = new THREE.Object3D();
g_Obj.add(g_NexusObj);
g_scene.add(g_Obj);

fitCameraToObject( g_camera, g_NexusObj.geometry.boundingBox, 1 );

}

// my camera's init position is (0,0,z?)
function fitCameraToObject( camera, boundingBox, offset )
{
offset = offset || 1.25;
const size = new THREE.Vector3();
boundingBox.getSize(size);
const maxDim = Math.max( size.x, size.y, size.z );
const fov = camera.fov * ( Math.PI / 180 );
cameraZ = Math.abs( maxDim * 2 * Math.tan( fov * 2 ) );
cameraZ *= offset;
camera.position.z = cameraZ;
}

from nexus.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.