three.js

Three.js raycaster intersection

独自空忆成欢 提交于 2019-12-12 16:15:56
问题 I wrote the code below to get intersection point with a 3d shape. It works well but if there are two intersection point with shape, it returns me only the farest intersection while I need the nearest intersection with the shape. How can I do to get the nearest intersection? /*here I create a cube*/ var geometry0 = new THREE.Geometry() geometry0.vertices = [new THREE.Vector3(0.5, -0.5, 0.5), new THREE.Vector3(-0.5, -0.5, 0.5), new THREE.Vector3(-0.5, -0.5, -0.5), new THREE.Vector3(0.5, -0.5,

Three.js: OrbitControl with zoom damping?

天涯浪子 提交于 2019-12-12 16:07:33
问题 The damping feature has been added in the r.72dev branch of three.js. It works great for smoother rotating. Does it enable damping (inertia) for the zoom as well? controls = new THREE.OrbitControls( camera, renderer.domElement ); controls.enableDamping = true; controls.dampingFactor = 0.25; 回答1: I added zoom damping to the three.js r73 OrbitControls , see this demo : Fiddle using three.js r107, but OrbitControls are still the r73 version: http://jsfiddle.net/y62d4qnr/ Usage is just like the

Custom UVgenerator Three.js for extrudedgeometry

你说的曾经没有我的故事 提交于 2019-12-12 15:18:03
问题 I want to use a texture on the surface of my extruded geometry. I have been researching custom UVgenerators for a while now, and have found these related questions: 1.) How to apply a texture to THREE.ExtrudeGeometry? 2.) Loaded texture appears blurred, or like a single color. How to make the texture crisp and sharp However, the method proposed to divide my geometry points by 1000 and to mesh.scale.set(1000,1000,1) doesn't work because my geometry is no longer in the correct place. I would

My object isn't reflects the light in Three.js

若如初见. 提交于 2019-12-12 15:06:39
问题 I have some CubeGeometry based mesh in a three.js scene, and all of them reflects the PointLight what I'm using globally. But one of them, which made by "hand" with just THREE.Geometry (add vertices and faces by code) is not reflected. Even it has no color, I only can set color for this, if I set a THREE.Color to "emissive" key on the MeshPhongMaterial. The geometry made by a JS function dinamically. I'm using this litghs: pointLight = new THREE.PointLight(0xFFFEF0, 1, 100000) pointLight

three.js click single particle

邮差的信 提交于 2019-12-12 15:03:11
问题 In this example you can see 2 particles which are clickable but they are both affected by the click. Also i want just to detect clicks on particles without filtering them out of the scene. Like here if (intersects.length>0){ if(intersects[0].object.type == "Points"){ intersects[0].object.material.color.setHex( Math.random() * 0xffffff ); } } It is important for me to use particles because they can stay always the same size to the camera and i dont need to use a second orthographic camera. In

Most efficient way to get a Three.js project to work in a ruby on rails app?

强颜欢笑 提交于 2019-12-12 14:23:51
问题 I'm trying -unsuccessfully- to get a Three.js project to work within the Ruby on Rails framework I keep thinking that there must be an easier way to do this than the way I'm doing it at the moment First I googled for a guide/tutorial on how to port working Three.js code to rails and found very little on the subject. Which I figure means: either people don't do it very often -or- that it's so obvious that no one has bothered to document it. Next I googled for a three.js gem and found one here

Three.js - Wrong Bounding Box importing Blender JSON model

半城伤御伤魂 提交于 2019-12-12 12:27:13
问题 I am having some problems manipulating the objects I load from Blender. I think the pivot point is always set to 0,0,0 instead of the current object's position. I correctly position and import the objects in the Blender scene, but then I have problems rotating them. I have used BoundingBoxHelper to see what is happening, but the bounding box is not appearing surrounding the object but centered in the world and with a 1-unit size (I guess that is the default) This is the code I use to load the

Three.JS with Canvas Renderer, broken Textures

浪子不回头ぞ 提交于 2019-12-12 11:43:17
问题 If you look at http://stemkoski.github.io/Three.js/Wireframe.html without enable webgl, you see a white diagnal line crossing the texture. This happens only in CanvasRenderer. Does anyone knows how can this be fixed. When WebGL is enabled, the output is correct, like below: 回答1: The diagonal lines are an artifact of CanvasRenderer . You can compensate for them by setting material.overdraw = 0.5 , or some number between 0 and 1. The distortion in the checkerboard pattern when using

THREE.TrackballControls rotation center

烂漫一生 提交于 2019-12-12 11:15:20
问题 I have 1 object on scene and want to rotate it relative to its axis. I use THREE.TrackballControls. But when my object in not in the center of screen, rotation is bad (it is rotating relative to center of screen). I tried to change camera position before creating controls. But it did not work. var scene = new THREE.Scene(); var camera = new THREE.PerspectiveCamera(75, 1, 0.1, 1000); camera.position.z = 3; camera.position.y = 10; controls = new THREE.TrackballControls( camera ); Is it possible

Clickable particles in three.js PointCloud

可紊 提交于 2019-12-12 10:43:30
问题 I am visualizing 3d data points (which I read in via a csv-file) with the help of three.js. I want to click on points in that PointCloud to show other measurement data for those specific points. According to examples I found this is possible apparently but I don't get it working. I have the following code (basically from those examples): function onDocumentMouseMove(e) { mouseVector.x = 2 * (e.clientX / containerWidth) - 1; mouseVector.y = 1 - 2 * (e.clientY / containerHeight); var vector =