DevLost

A developer lost in the mountains

Tip: how to dinamically update a texture on a mesh in three.js

Sometimes there is the need to change the texture of a mesh at run time; for instance to change aspect of a virtual character, to create some light effects and so on.
In the code snippet below, function loadNewTexture accept the url of the new image for the texture to create a new image object. In the onload event of the image, it is drawed on the texture assigned to the material of the mesh.

Do not forget to set "needsUpdate property of the mesh to true at the end.



MyObject.prototype.loadNewTexture = function (src) {
    var that = this;
    var textureImg = new Image();
    textureImg.src = src;
    textureImg.onload = function () {
        var ctx = that.mesh.material.map.image.getContext('2d');
        ctx.drawImage(textureImg, 0, 0, textureImg.width, textureImg.height, 
      0, 0, textureImg.width, textureImg.height);
        that.mesh.material.map.needsUpdate = true;
    };
}

Near Field Communication in Windows 8: Part 2

In the first part of this article series we have described the main concepts of Near Field communication and how Microsoft has provided support for this technology in Windows 8. Then we have seen how to set up two Windows 8 virtual machines with a proximity driver, i.e something which allows us to simulate a tap gesture. In this second part we will learn how to use the sample proximity driver and explore the functionalities exposed by the Proximity API.

NetNfpControl: a testing tool to simulate a proximity event

As already described in the first part, we can use a sample proximity driver to simulate a tap gesture. We found the sample netnfp solution in the Windows 8 Driver Samples package. In this solution, together with the driver and the package for the driver projects, there is also a project, NetNfpControl, containing a testing tool to simulate proximity hardware.


Read all on silverlightshow:

http://www.silverlightshow.net/items/Near-Field-Communication-in-Windows-8-Part-2.aspx


Near Field Communication in Windows 8 = Near Field Proximity

Near Field Communication (NFC) is certainly a promising technology and some standardization processes are on-going at nfc-forum
Microsoft announced extended support for this technology in Windows 8, but renamed it as Near Field Proximity. I'm investigating on the Proximity API that developers can use to create NFC-enabled apps; it is surprisingly simple..

Read more on my first-part article:

http://www.silverlightshow.net/items/Near-Field-Communication-in-windows-8-part-1.aspx

Silverlight and Sharepoint working together: event receivers in Silverlight

In this article we will become familiar with the Sharepoint event receivers, a cool feature which allows the user to be notified about various events occurring inside a Sharepoint environment. An example is the possibility to receive the notification of an item added to a list. Unfortunately, the mechanism works at server side and that means that there is no “out of the box” possibility to use the feature directly in a Silverlight application.

Nevertheless, we will find a way to make the event receivers available in a Silverlight web part in order to give a new dimension of interactivity to a Sharepoint solution.

As an example we will create a small application to invite our colleagues to a coffee break and get a close to real time answer. This will involve the creation of a wcf service with a service contract for a Sharepoint solution and a service contract for a Silverlight web part. Both contracts are duplex service contracts. Now you may be like “all this mess for a silly application to get someone together for a coffee break?” In fact, it may sound useless but it is not. Event receivers are a great feature of Sharepoint and exporting them into a Silverlight web part opens a very interesting perspective.

Let’s suppose we want to create a small application running in a Sharepoint site (a kind of widget) to quickly organize a coffee break with colleagues. We want to be able to select a time and send an invitation to our user’s group. The other users should be notified quite immediately and they should be able to accept or turn down the invitation. Eventually we should be notified about all the confirmations received from our colleagues. All this without the need to refresh any page.

 The image below sums it all up:

Full story on my article on silverlightshow:

http://www.silverlightshow.net/items/Silverlight-and-Sharepoint-working-together-event-receivers-in-Silverlight.aspx