THREE.js + video-mapping - three.js

Is there a way to control 'properties' when mapping a video to a mesh in THREE.js in webGL (i.e,.the video "texture" is not aligned where i would like on the mesh/is this something that can only be handled through UV-mapping in Blender or other modeling program?)-I am loading a video programmatically as 'texture' onto a simple 3d model. Thanks!

You can certainly change the UVs of your three.js mesh, and as a result, control the alignment of your video texture.
Here is an example where that is done: http://mrdoob.github.com/three.js/examples/webgl_materials_video.html

Related

THREE js: Disable auto rotate of sprite

I used sprites in Three js to display 2d images, the problem that I faced with sprites that they rotate to face the camera.
I am trying to use it to fake a shadow for the 3d object. When I rotate the camera the 3d object tilt with the camera until it makes a 30-degree angle with the horizontal but it's shadow (2d sprite) still at 0 degrees.
How to disable the auto rotation of sprite, or is there another solution to preview 2d images in three js to look like a 3d object?
How to disable the auto rotation of sprite, or is there another solution to preview 2d images in three js to look like a 3d object?
It's not possible to disable the orientation towards the camera with a flag or configuration. You would have to modify the shader code of SpriteMaterial for this.
I suggest you use a mesh instead based on a PlaneBufferGeometry and a MeshBasicMaterial. Alternatively, you write a custom billboard shader with ShaderMaterial or RawShaderMaterial.

Unity 3D Does Not Apply Texture To Object Properly

I have got a problem with texturing an object in Unity 3D. I have made a simple object in 3Ds Max and inserted it into Unity and then tried to apply an image as texture but it does not apply the texture and it only changes the color of the object! This is the print screen:
As you can see I have got two models. One of them is made in 3Ds Max and does not apply the texture and the other one is made in Unity and it's a cube and it gets the texture correctly.
So what's going wrong here ? Not that I also changed the tiling and offset settings of model's shader but still nothing's changed at all! :(
You didn't UV Unwrapped the 3d object before exporting to Unity3D.
To apply the textures on 3d mesh, any engine needs to know coordinates for texture, and this is called UV Mapping.
WIKIPEDIA - UV_mapping

How to use part of a texture?

How do I create a three.js material/geometry which uses part of a texture?
I am first rendering a scene to a texture. This texture is used for a Mesh with a CubeGeometry and a MeshLambertMaterial. What I would like to do now is have only a part of the texture displayed on the cube face (like a window into the texture).
I've done this before using OpenGL ES directly, with shaders, but I don't see what parameters might make it possible using the standard three.js library.
That is what texture coordinates are for. See this question and answer:
http://stackoverflow.com/questions/19366991/drawing-part-of-open-gl-texture/19367844#19367844

Three.js: Video Texture on Skybox

Can someone help with videotexture on cube in three.js with WebGLRenderer.
I am trying to use Three.js to render a cube with one-piece videotexture from one file without use
THREE.ImageUtils.loadTextureCube
instead image such as jpg, but I don't get visible cubes. Should ideally i need create something like 180 degrees half sphere video panorama but only with cube. That is, i want to put a texture to all faces of a cube, not cutting it, in the one stream because if I use different video textures on every face then this will affect the performance.
I am trying to use video texture on sphere like here
http://mrdoob.github.com/three.js/examples/webgl_panorama_equirectangular.html
and all works fine, but i want use cube like here
http://mrdoob.github.com/three.js/examples/webgl_materials_cubemap_balls_refraction.html
but I don't get visible cubes.
I don't want to cut a movie file to six different parts to put them on every face of the cube as in this example.
Maybe other methods to overlay material on cube form one video file than using different textures for each face?
Thx and sorry for my english.

Can I draw 2D shapes onto on a flat three.js face?

I would like to play around with testing a 3D map, of sorts. At it's simplest, one flat pane, with map lines etc. drawn onto it, flat (as if I was drawing onto an HTML canvas). But I want that pane to be movable in 3D space.
I know that I can make a flat pane in three.js very simply, but is it possible to implement some sort of 'custom texture' that would allow me to programmatically draw onto this pane?
It is called render-to-texture in webGL.
Three.js provides WebGLRenderTarget which can be used as image source for further textures. You render your scene to WebGLRenderTarget instead of main WebGL screen. Then you use this WebGLRenderTarget as image source for the texture.
A lot of 2D post-processing works like this. They render the world to 2D texture, then use fragment shaders to apply per-pixel postprocessing code, like blurring.
For examples, see e.g. http://mrdoob.github.com/three.js/examples/webgl_postprocessing.html
It renders the scene for 2D postprocessing, but the theory is the same.
Here is the WebGLRenderTarget setup code:
https://github.com/mrdoob/three.js/blob/master/examples/js/postprocessing/EffectComposer.js#L14

Resources