I added a few methods to three-orbit-controls to be able to manually define phi or theta and be able to rotate to a given point.
// rotation in Y
controls.setAzimuthalAngle(theta);
// rotation in X
controls.setPolarAngle(phi);
I added a few methods to three-orbit-controls to be able to manually define phi or theta and be able to rotate to a given point.
// rotation in Y
controls.setAzimuthalAngle(theta);
// rotation in X
controls.setPolarAngle(phi);
| // Kudos to armadilly | |
| fbo.begin(); | |
| ///pre-multiply background color of the fbo for correct blending! | |
| ofClear(ofColor(fboBgColor * (fboBgColor.a / 255.) , fboBgColor.a)); | |
| //Set this blending mode for anything you draw INSIDE the fbo | |
| glBlendFuncSeparate(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA, GL_ONE, GL_ONE_MINUS_SRC_ALPHA); | |
| //your draw code here! | |
| fbo.end(); |
| attribute vec3 position; | |
| uniform mat4 modelViewMatrix; | |
| uniform mat4 modelMatrix; | |
| uniform mat4 projectionMatrix; | |
| uniform float scale; | |
| uniform float size; | |
| uniform float aspect; | |
| varying vec2 vUv; |
| const cloneGltf = (gltf) => { | |
| const clone = { | |
| animations: gltf.animations, | |
| scene: gltf.scene.clone(true) | |
| }; | |
| const skinnedMeshes = {}; | |
| gltf.scene.traverse(node => { | |
| if (node.isSkinnedMesh) { |
| // https://discourse.threejs.org/t/functions-to-calculate-the-visible-width-height-at-a-given-z-depth-from-a-perspective-camera/269 | |
| function visibleHeightAtDepth(depth, camera) { | |
| // compensate for cameras not positioned at z=0 | |
| const cameraOffset = camera.position.z; | |
| if ( depth < cameraOffset ) depth -= cameraOffset; | |
| else depth += cameraOffset; | |
| // vertical fov in radians | |
| const vFOV = camera.fov * Math.PI / 180; | |
| // Math.abs to ensure the result is always positive |
| var cameraZ = camera.position.z; | |
| var planeZ = 5; | |
| var distance = cameraZ - planeZ; | |
| var aspect = viewWidth / viewHeight; | |
| var vFov = camera.fov * Math.PI / 180; | |
| var planeHeightAtDistance = 2 * Math.tan(vFov / 2) * distance; | |
| var planeWidthAtDistance = planeHeightAtDistance * aspect; | |
| // or |
| // There's always some fiddling because the GLTF exports a whole scene | |
| // with root bone and skinned mesh already appended to it. | |
| let gltf = loadedGltf; | |
| let skinned; | |
| gltf.scene.traverse(function(object) { | |
| if (object instanceof THREE.SkinnedMesh) { | |
| skinned = object; | |
| } | |
| }) |