three.js

Color Gradient for Three.js line

走远了吗. 提交于 2019-12-20 02:56:17
问题 I only can find THREE.LineBasicMaterial(). Is there a way to have a simple color gradient from point a to point b? 回答1: You can use Vertex & fragment shaders for change color for vertices[0] and vertices[1]. (Line points) See http://mrdoob.github.com/three.js/examples/webgl_custom_attributes_lines.html 来源: https://stackoverflow.com/questions/11589274/color-gradient-for-three-js-line

Texture repeating for meshes with random size

本秂侑毒 提交于 2019-12-20 02:22:13
问题 I need some help with texturing in three.js. I have multiply blocks each with random width/height and I need apply same texture to them but repeated along whole block. As I see from another answers I can set texture repeating with this code: lavaTexture.wrapS = lavaTexture.wrapT = THREE.RepeatWrapping; lavaTexture.repeat.set( 2, 2 ); But in this case I should manually set how many times texture will be repeated. In my case this mean that if I would like to have 100 blocks of random size - I

three.js - text next to line

不羁的心 提交于 2019-12-20 02:09:21
问题 I've a tube geometry in a scene which is built from data loaded as JSON. I've to put a line as a marker at each segment. And for that I am taking centroid of a face as starting point and added 10 to each co-ordinate of centroid as end point of line. Please find the jsfiddle of tube with line Please find below the code of adding line from the center of a face. var lineGeo, lineMat, line; var fx=tube.faces[3].centroid.x; var fy=tube.faces[3].centroid.y; var fz=tube.faces[3].centroid.z; lineGeo

three.js - text next to line

℡╲_俬逩灬. 提交于 2019-12-20 02:09:08
问题 I've a tube geometry in a scene which is built from data loaded as JSON. I've to put a line as a marker at each segment. And for that I am taking centroid of a face as starting point and added 10 to each co-ordinate of centroid as end point of line. Please find the jsfiddle of tube with line Please find below the code of adding line from the center of a face. var lineGeo, lineMat, line; var fx=tube.faces[3].centroid.x; var fy=tube.faces[3].centroid.y; var fz=tube.faces[3].centroid.z; lineGeo

Intersect Sprites with Raycaster

拜拜、爱过 提交于 2019-12-20 01:44:09
问题 I want to realize a 3D interactive globe with three.js and I wonder if there is a way to intersect over Sprites primitive with the Raycaster? 回答1: If you check the source code for RayCaster at https://github.com/mrdoob/three.js/blob/master/src/core/Raycaster.js it would appear that the intersectObject function only checks objects that are instances of THREE.Particle or THREE.Mesh, not THREE.Sprite. Possibly this is because sprites could be set to use screen coordinates, and so a ray that

Three.js as background of website possible?

你离开我真会死。 提交于 2019-12-19 21:46:24
问题 I've been looking at using three.js for a fun experiment on a site. I would like to use a current experiment (for which I already have the code for) and use it as a background for my site. Anybody know how to do this? I saw it done here: http://janjorissen.be/ Three JS API: https://github.com/mrdoob/three.js/wiki/API-Reference 回答1: usually i use iframe for that. Thus you dont have conflict with the base page. <style> iframe { z-index : -9999; position: absolute; top : 0; left : 0; width : 100

Z-buffer issue with BufferGeometry in ParticleSystem

浪子不回头ぞ 提交于 2019-12-19 12:05:34
问题 In my application I'm having troubles with the z-buffer. I have a ParticleSystem in which the dots have a texture to look like spheres. But there are two problems which I can't solve at the same time.... Either the spheres were sorted right in z-buffer but aren't transparent or they are transparent but not right sorted! Please have a look at my JSfiddle. (based on this example from mrdoob) In the original example all looks well. But as you can see in my fiddle, the texture is not transparent,

Threejs: why is wireframe thickness not adjusting for me?

情到浓时终转凉″ 提交于 2019-12-19 12:00:28
问题 I am unable to create thick wireframes. Using the following code: new THREE.MeshBasicMaterial( { color: new THREE.Color( 'rgb(100,100,100)' ), emissive: new THREE.Color( 'rgb(23,23,23)' ), shading: THREE.FlatShading, wireframeLinewidth: 10, wireframe: true }) I get the following result: no matter what number I use the lines are always 1px thick. I've noticed that the same is true for threejs api demos page: is this a known bug? is there any work around? 回答1: The maximum required thickness of

Changing Raycaster position dynamically

梦想与她 提交于 2019-12-19 11:39:11
问题 I have a canvas, inside that I have several cubes. I use Raycaster to select them and change their colors. But the canvas is inside of a draggable object and when I move around I cannot change the colors, the color changing works in the original position. I think I also have to change the dimensions of the Raycaster. How can I do that? Here is the example. 回答1: try to change a code as follows: function onDocumentMouseDown( event ) { event.preventDefault(); var x = event.offsetX == undefined ?

Creating a CubeGeometry equivilent using CSS3DRenderer

六眼飞鱼酱① 提交于 2019-12-19 11:32:15
问题 I am looking for sample code, that would show how one can create a cube (similar to THREE.CubeGeometry ) in ThreeJS using CSS3DRenderer . Something like below var my_cube = new **CSS3dCubeGeometry**( cube_width, cube_height, cube_depth) var object = new THREE.CSS3DObject( my_cube ); scene.add( object ); THREE.CSS3DObject doesn't exist and I am looking for a potential implementation of it. 回答1: You can create a cube with CSS3DRenderer like so: // params var r = Math.PI / 2; var d = 50; var pos