ThreeJS Setting the Right Aspect Ratio for the Camera
One quick note for myself and anyone who will ever use this… If you are working with an abnormal size canvas, you need to do some math to set the size of the renderer to be correct with the aspect ratio: [pastacode lang=”javascript” manual=”let%20rect%20%3D%20this.renderer.domElement.getBoundingClientRect()%3B%0A%09%09camera.aspect%20%3D%20rect.width%20%2F%20rect.height%3B%0A%09%09camera.updateProjectionMatrix()%3B%0A%09%09renderer.setSize(%20rect.width%2C%20rect.height%20)%3B” message=”” highlight=”” provider=”manual”/] Basically, you are working out the bounding box in which the scene will
iDevice Continuously Reconnects USB
Sound familiar? You plug in your iphone/ipad and it just continuously reconnects… some people say its the cord others say its privacy settings I say its the disk utility… To fix this just disconnect and open Disk Utility > First Aid and run it, then reconnect the device. voila NOTE: This site is all about helpful hints tricks and tips.
Find the (x,y) coordinates of an index value in an array
Web graphics often require us to work with images (bitmaps) in the form of a giant array of rgb values. However translating between the index of the array and the x,y coordinates of the bitmap can be confusing. I’ve written a couple formulas below to help you translate from index to x,y and vice versa. Let’s say you have an
How to show transparency on Blender texture
Sometimes I will use transparency on a blender texture only to find the preview in blender doesn’t show it. Below I’ve written a bit about how to get your transparency to show up. You will need to map UV’s to do this. If you want show transparency on a blender texture and it’s not showing up when you set the
Learn how to map a sphere with a texture in Blender
In the following video I show how to map a texture to a sphere in blender. The concept would be the same with more advanced and complex objects, however, in those cases your textures would need to be modified to match the geometry. This is a simple example to show the basic mechanical process for blender texture mapping. One thing
How to assign two materials to an object in Blender
In the video below I show how to assign more than one texture to an object in blender. This process is useful if you going to use transparency on your objects and need to have multiple layers to create an effect. It can also be useful later if you’re doing work with blending texture programatically or if your using a
Export GLTF Format From Blender to ThreeJS
In the following video I show how to export textures/meshes from blender into the new(ish) gltf format. This is a binary format that contains the mesh and images in a very small file size which works well for exporting to webGL contexts. It’s sort of the new collada exporter and very easy to use with libraries such as threejs. As