- monthly subscription or
- one time payment
- cancelable any time
"Tell the chef, the beer is on me."
The Pattern Library is a fresh new project by New Yorker Tim Holman and Claudio Guglieri from San Francisco. The two, who both don’t stem from where they are currently located, established a repository of seamless website backgrounds called “The Pattern Library”. The concept of the site matches the content – it’s extraordinary…
Since its introduction, 3D graphics in the browser has been a popular topic. But if you were to create your apps using plain old WebGL it would take a very long. But now we have some pretty useful libraries that we can take advantage of, like Three.js. So in this series I will show you how to create stunning 3D experiences for the browser.
I do expect you to have a basic understanding of 3D space before you start reading this tutorial, as I won’t be explaining things like coordinates, vectors etc.
We will start with the code from previous part of this series. Also, grab the assets I provided and put them in the same folder as your app. Now, since we will use images here you will have to put your app on some static server (may be local), because unless you start the browser with enabled file access from files (for example using the --allow-file-access-from-files
flag in Chrome) CORS will not let you load them from file. That’s all you need to do before proceeding.
If you’ve ever got so bored that you went with creating something using pure OpenGL, you probably remember how much pain it is to load a texture. Luckily, Three.js comes with a nice function that will load and set up the texture for us. Add this line before the definition of our cube’s material:
var cubeTexture = THREE.ImageUtils.loadTexture('./box.png');
It’s really all you have to do in order to have your texture loaded.
In a real-world app you would have to preload the texture like any normal image and show the users some fancy loading bar to let them know that you are loading (Three.js will use the cached image then).
Now we will apply the texture to our cube. This is also easy, you just need to replace the color definition in the cube’s material to look like this:
var cubeMaterial = new THREE.MeshLambertMaterial({ map: cubeTexture });
The map
attribute sets the texture. Now you can open the browser and you should see a rotating, textured cube:
You can also colorize the texture, just add the color
definition in the material’s options, like that:
var cubeMaterial = new THREE.MeshLambertMaterial({ map: cubeTexture, color: 0x28c0ec });
And now the cube turns blue:
This way you can have multiple different objects with the same texture if only the color changes.
You can set different materials for every face of the cube. To achieve that, you have to change the whole material’s definition. First, define the materials
array. Each element in the array will correspond to the material of one face. They go in this order: right, left, top, bottom, front and back:
var materials = []; materials.push(new THREE.MeshLambertMaterial({ map: cubeTexture, color: 0xff0000 })); // right face materials.push(new THREE.MeshLambertMaterial({ map: cubeTexture, color: 0xffff00 })); // left face materials.push(new THREE.MeshLambertMaterial({ map: cubeTexture, color: 0xffffff })); // top face materials.push(new THREE.MeshLambertMaterial({ map: cubeTexture, color: 0x00ffff })); // bottom face materials.push(new THREE.MeshLambertMaterial({ map: cubeTexture, color: 0x0000ff })); // front face materials.push(new THREE.MeshLambertMaterial({ map: cubeTexture, color: 0xff00ff })); // back face
As you can see each face has it’s own material, so you can set different textures, colors and other attributes for each one. Next, change the type of the cube’s material to THREE.MeshFaceMaterial
:
var cubeMaterial = new THREE.MeshFaceMaterial(materials);
You only need to pass the materials
array as the parameter. In the browser you should see that each side of the cube has different color:
Let’s say you want to create an effect of spinning snowflakes in your app. If you were to render each snowflake as a mesh you will get very low fps. That’s where particles come into play. They are way less complicated, and drawing them as a whole particle system makes them really efficient.
Start with creating a geometry for our particles:
var particles = new THREE.Geometry;
THREE.Geometry
is a base geometry object, without any shape. Now we have to define the position of each particle in the system. Let it be completely random:
for (var p = 0; p < 2000; p++) { var particle = new THREE.Vector3(Math.random() * 500 - 250, Math.random() * 500 - 250, Math.random() * 500 - 250); particles.vertices.push(particle); }
This loop will create 2000 randomly placed particles and put them all in the geometry. Next, you have to define particles’ material:
var particleMaterial = new THREE.ParticleBasicMaterial({ color: 0xeeeeee, size: 2 });
Notice that we are using THREE.ParticleBasicMaterial
, which is only for particles. In options we only define the color and the size of each particle. Finally, you can create the particle system and add it to the scene:
var particleSystem = new THREE.ParticleSystem(particles, particleMaterial); scene.add(particleSystem);
Now, to make the scene look better let’s rotate the particles in the direction opposite to the one that the cube is rotating in (change the render
function to look like this):
function render() { requestAnimationFrame(render); var delta = clock.getDelta(); cube.rotation.y -= delta; particleSystem.rotation.y += delta; renderer.render(scene, camera); }
We moved the clock.getDelta
to the variable, because if you would use it like that:
cube.rotation.y -= clock.getDelta(); particleSystem.rotation.y += clock.getDelta();
The particle system would not rotate, because the second call will return a number close to zero (remember that it’s getting the time from the last call).
Now open up the browser and you should see a cube and particles rotating:
Let’s combine both things you’ve learned in this tutorial and turn those ugly white squares into real snowflakes. First, load the snowflake texture:
var particleTexture = THREE.ImageUtils.loadTexture('./snowflake.png');
Now, change the particles’ material to use the texture. Also, enable transparency and make the particles bigger so we can see the shape:
var particleMaterial = new THREE.ParticleBasicMaterial({ map: particleTexture, transparent: true, size: 5 });
If you open the browser you should see some nice snowflakes flowing around the cube:
Smoke effect is pretty easy to achieve and it looks nice. Start by creating the geometry, just like with the snowflakes:
var smokeParticles = new THREE.Geometry; for (var i = 0; i < 300; i++) { var particle = new THREE.Vector3(Math.random() * 32 - 16, Math.random() * 230, Math.random() * 32 - 16); smokeParticles.vertices.push(particle); }
The only difference here is that we are choosing the position from a rectangular prism with dimensions 32x32x230. Now, let’s load the texture and define the material:
var smokeTexture = THREE.ImageUtils.loadTexture('./smoke.png'); var smokeMaterial = new THREE.ParticleBasicMaterial({ map: smokeTexture, transparent: true, blending: THREE.AdditiveBlending, size: 50, color: 0x111111 });
In material definition, there is a blending
option. It tells the renderer how it should render one object on another. With THREE.AdditiveBlending
overlapping color values will be added to each other which will result in a brighter smoke in the areas with higher particle density. We also set the color to almost black, so the smoke looks more natural.
Finally, create the particle system, move it a bit to the left and add it to the scene:
var smoke = new THREE.ParticleSystem(smokeParticles, smokeMaterial); smoke.sortParticles = true; smoke.position.x = -150; scene.add(smoke);
You also have to set smoke.sortParticles
to true. When it’s false the background of the sprite may be drawn as black. If you open the browser you should see a still pillar of smoke next to the cube:
To animate the smoke we have to loop trough all of the particles and move them up a bit. Add this code to the render
function:
var particleCount = smokeParticles.vertices.length; while (particleCount--) { var particle = smokeParticles.vertices[particleCount]; particle.y += delta * 50; if (particle.y >= 230) { particle.y = Math.random() * 16; particle.x = Math.random() * 32 - 16; particle.z = Math.random() * 32 - 16; } } smokeParticles.__dirtyVertices = true;
In the loop we are adding delta * 50
to the y position of the particle. Next we check if the particle is higher than 230, if so we randomly choose its new position somewhere in the bottom of the smoke pillar. Finally, the most important thing: setting the geometry’s __dirtyVertices
flag to true.
To improve the performance, Three.js is caching the objects to avoid building all of the WebGL calls again every frame, so if we change something in the geometry of the object we have to let the renderer know that it has changed. Basically, the
__dirtyVertices
flag will just reach the element.
If you open the browser now you should see a smoothly animated smoke next to the cube.
In this tutorial you’ve learned how to use textures and particles. As before, don’t be afraid to experiment a bit with your app. If you have problems take a look at the documentation. In the next article I will teach you how to load models and animate them.
In this collection, you will find some elegant and classy foil texture sets that are available for free of cost. It is the web designer responsibility to make the website look like what the client wants its website to appear. A designer can make a website look elegant and sober or rich and trendy by using appropriate type of textures. Basically, the designer has to create a website design that matches with the company profile and can represent it in the most effective manner.
Using classy foil texture gives your website designs a very classy and elegant look; as well as such textures help you in adding some extra depth to your design as well to the content to the websites. Enjoy!
Gold Foil by Seren Dipity stock
Rainbow Sunburst Metallic Foil
Another awesome collection for all creative people is presented here. In this collection, we gathered some Dirty-Looking Rotten Wood Texture. You can also download all these texture free of cost. So have a look at these awesome textures and apply them in your up-coming projects. The appearance of all these textures is mucky so if you apply these textures in a smart and creative way then it gives you outstanding result and also enhances your design.
So what are you waiting for? Why not try them out? See for yourself and choose a texture that suits to your needs the most. Do let us know what you think about this compilation. Feel free to share your opinions and comments with us via comment section below. Enjoy and have fun everyone.
Stock Texture – Decayed Wood IV
Rotted Wood Tree Stump Texture
With this collection, we want to share something very creative with you guys. This time it is abstract mosaic textures. Basically, mosaic is a form of art where different colored tiles or stones or papers or other mediums of different shapes and sizes are placed together in an artistic manner to create different patterns and images. One can see such type of art in old-aged structures such as churches, temples, and mansions.
In this post, we have put together a collection of some free as well as useful abstract mosaic textures for you. So take a look at this collection and choose which texture will be useful for you. Moreover, all of these textures are free to use so go ahead and download as many as you like. Please chime in with other recommendations! Your comments are always more than welcome! Enjoy!
Gold Mosaic Tile Texture Stock
Crack_Mosaic_Filigree_BlackWhite_Texture
Mosaic tile texture of an old bathroom
Textures are what you need if you want a surface to look realistic. Sure, you might as well create them digitally, e.g. using Photoshop. Yet, Photoshop’s results are much too clean to fake reality in a believable manner. If you want to create a photorealistic texture with your favorite image editor, you’ll need to combine filters with filters on filters, ’til days end. Why not walk the easy path and choose one of the following textures based on photos in different resolutions?
In our daily life, we use lots of things and sponges are one of them. When we listen the word sponge, few things that come in our mind are that sponges are used for washing, bathing, or absorbing liquids, etc. Sponges can also be used in different ways like it can be used in web or graphic designing. Yes, in this collection we are going to showcase 23 free and marvelous sponge textures for your next designing project.
This collection will show you that using sponges in a right way can give your designs a fabulous result. This is because sponge contains a nice look and texture and for this reason sponges are used in web and graphic designing. Sponge textures enhance the designs look and feel this is the reason that all experience, creative and talented designers are using sponge textures. With this collection, we aim to share with you cool and inspirational stocks for the world of creativeness and design for free. Do let us know what you feel about this round up.
While the flat design trend is getting more and more popular not everyone is constructing their website designs with solid pastel colours. Textures are great for giving your designs a realistic tactile feeling and range from the use of subtle noise to full on material scans. This post showcases those sites that take texture use to the max and use heavy wood, leather and concrete style textures to add impact to their designs.
Today, we are presenting another fresh collection of some free and appealing vintage paper texture packs for you. Using the right texture in any type of design is very crucial as it can have a great impact on the overall design. This is the reason that designers pay special attention to the selection of texture for their designs. Majority of the designers keep a huge collection of different type of texture that they use in their projects. This time, we are showcasing some vintage paper texture for you.
We hope that you will like this collection and find these vintage paper texture packs useful for your projects. Though all of them are free to use but we will encourage you to read the terms and conditions before using them for commercial purpose.
Adding realistic watercolor effects can be a great way to enhance your web and graphic design. Today we have a set of 4 watercolor textures that can be downloaded for free. With the help of these textures you can easily add beautiful watercolor effects to your own work.
These textures are free for use on personal and commercial projects.
Download the textures (7 MB zip file)
You may also be interested in:
Today we have a set of 5 textures from padded envelopes. The set includes scanned textures from both the inside and outside of a padded envelope, and they can be used for creating backgrounds in your own designs.
These textures are free for use in your own personal and commercial projects.
Download the textures (8 MB zip file)
If you’re looking for an abstract background to use in your own designs, bokeh backgrounds can be a good choice. Today we have a free set of 4 bokeh backgrounds that you can download and use in yoor own projects. These 4 backgrounds are samples from the larger set of 40 bokeh textures available at Vandelay Premier.
The backgrounds are free for use in your own personal and commercial projects.
Download the zip file (3 MB zip file)
Today we have a set of 4 textures that were created by staining paper with watercolors. The result is a unique set of textures that can be used for creating backgrounds and giving soft watercolor textures to elements within your own work.
The textures can be used in your own personal and commercial projects. Each textures is sized at 3600 pixels by 3600 pixels, 300 dpi.
Download the textures (16 MB zip file)
Today we have a free set of 4 metal textures that is available for download. The set includes a variety of different types of metal textures, and they can be used in your own personal and commercial design projects.
The textures are free for use, no attribution required.
Download the textures (8 MB zip file)
You may also be interested in:
Today we have a set of 4 free textures that come from our Premier Texture Bundle 4. This grab bag includes 4 different types of textures to give you some variety. The full Premier Texture Bundle 4 includes 125 high res textures for just $29, so if you like these free textures you may want to check out the full bundle.
These free textures can be used in your own personal and commercial projects.
Download the textures (15 MB zip file)
Today we have a set of 3 free noise texture overlays from our friends at PhotographyPla.net. These textures are created specifically for the purpose of adding grain/noise/texture to photos. You can add the texture on top of a photo in Photoshop and set the blend mode to “screen”.
Each of the textures is 3600 pixels by 3600 pixels at 300 dpi, so they can be used for both print and web-based projects. You can see the full set of Noise Texture Overlays that is available for purchase at PhotographyPla.net.
The textures are free for use in your personal or commercial projects.
Download the textures (15 MB zip file)
"Tell the chef, the beer is on me."
"Basically the price of a night on the town!"
"I'd love to help kickstart continued development! And 0 EUR/month really does make fiscal sense too... maybe I'll even get a shirt?" (there will be limited edition shirts for two and other goodies for each supporter as soon as we sold the 200)