Wednesday 15 September 2010

javascript - Using three.js, how would I do to draw freehand on a cube? -


I am trying for most people today that they basically find a way to represent a graffitti wall, and The indicator in any direction that direction was my first impression that I needed some kind of custom texture, but I really can not understand it; If the IDK is such that I am burnt, or what is, but I have it three. Js can not think of a way to do it in terms of

Do any of you have a better fortune, or someone knows how I can do something like this?

For more details, "In this way" I basically want to use a bitmap brush above the contents in a solid composition.

I know that it is a bit old, but I was recently walking with it, and I think I found a way to do this.

Canvas, then make the texture using that canvas, then use any code, it should work very well with plain surfaces, but with fields or non-regular shapes Too complicated.

Something like this should be:

  var canvas = document.createElement ('canvas'); Var ctx = canvas.getContext ('2d'); / * Reference options here * / var Texture = New three. Mix (canvas); Texture.needsUpdate = true; Var graffWall = new.MeshBasicMaterial ({map: texture1}); Mesh.material = content; // or: var mesh = new three. Mesh (geometry, content); // And here comes the magic ... more or less var wall = document.getElementById ('canvas'); Var ctx = mesh.material.map.image.getContext ('2d'); Var ctx = el.getContext ('2d'); Var Heading; Wall.onmousedown = function (e) {isDrawing = true; Ctx.lineWidth = 10; Ctx.lineJoin = ctx.lineCap = 'round'; Ctx.moveTo (e.clientX, e.clientY); }; Wall.onmousemove = function (e) {if (isDrawing) {ctx.lineTo (e.clientX, e.clientY); Ctx.stroke (); }}; Wall.onmouseup = function () {isDrawing = false; }     

Not sure that this will work, but this is an attitude.

No comments:

Post a Comment