Three.JS rotate projection so that the y axis becomes the z-axis

You could just change the camera rather than the entire coordinate system. For example: var WIDTH = 1024; var HEIGHT = 768; var VIEW_ANGLE = 45; var ASPECT = WIDTH / HEIGHT; var NEAR = 0.1; var FAR = 10000; camera = new THREE.PerspectiveCamera(VIEW_ANGLE, ASPECT, NEAR, FAR); camera.position.z = 300; camera.up = new THREE.Vector3( 0, … Read more

How to save canvas animation as gif or webm?

In modern browsers you can use a conjunction of the MediaRecorder API and the HTMLCanvasElement.captureStream method. The MediaRecorder API will be able to encode a MediaStream in a video or audio media file on the fly, resulting in far less memory needed than when you grab still images. const ctx = canvas.getContext(‘2d’); var x = … Read more

Converting 3D position to 2d screen position [r69!]

I’ve written for my project the following function; it receives an THREE.Object3D instance and a camera as a parameters and returns the position on the screen. function toScreenPosition(obj, camera) { var vector = new THREE.Vector3(); var widthHalf = 0.5*renderer.context.canvas.width; var heightHalf = 0.5*renderer.context.canvas.height; obj.updateMatrixWorld(); vector.setFromMatrixPosition(obj.matrixWorld); vector.project(camera); vector.x = ( vector.x * widthHalf ) + widthHalf; … Read more

Display wireframe and solid color

To render both a model and its wireframe, you can use a pattern like this one: // mesh var material = new THREE.MeshPhongMaterial( { color: 0xff0000, polygonOffset: true, polygonOffsetFactor: 1, // positive value pushes polygon further away polygonOffsetUnits: 1 } ); var mesh = new THREE.Mesh( geometry, material ); scene.add( mesh ) // wireframe var … Read more

techhipbettruvabetnorabahisbahis forumu