three.js

setEulerFromRotationMatrix does not exist in three.js?

倖福魔咒の 提交于 2019-12-11 13:34:39
问题 I am trying to use the following to rotate my mesh on its own y axis: // Rotate an object around an arbitrary axis in object space var rotObjectMatrix; function rotateAroundObjectAxis(object, axis, radians) { rotObjectMatrix = new THREE.Matrix4(); rotObjectMatrix.makeRotationAxis(axis.normalize(), radians); object.matrix.multiplySelf(rotObjectMatrix); // post-multiply // new code for Three.js r50+ object.rotation.setEulerFromRotationMatrix(object.matrix); // old code for Three.js r49 and

readRenderTargetPixels results all zeroes

久未见 提交于 2019-12-11 13:24:46
问题 The problem: I'm trying to read the pixel values from a render target, but the values are all coming back as zeroes. Am I doing something wrong, or is this functionality broken for the version I'm using? What I have: An important note is that I'm stuck using r76. I know, I know, it upsets me, too. The code below is literally all I have. Just click the "GO" button in the upper-right, and it will produce an alert that says whether or not the entire render target buffer was zeroes or not. What I

How to change pivot point for rotation on TrackballControls but keep camera.lookAt position same?

蓝咒 提交于 2019-12-11 13:22:26
问题 I need to be able to change rotation pivot without changing camera lookAt on THREE.TrackballControls no mater what I tried I could not succeed. Please give me a direction to solve this problem. What I am actually trying to achieve is Revit like mouse controls. 回答1: I was able to solve this problem by creating 2 3D objects named orbit and target, then add target and camera into orbit as child objects... camera always looks at target.position, mousemove on x axis rotates the orbit object around

Occluded object with three.js behaving strangely

☆樱花仙子☆ 提交于 2019-12-11 13:02:41
问题 Using the three.js library I managed to show occluded edges of a 3D object as dashed lines. And I want edges occluded by other objects to behave the same way. With the solution explained here it's working fine except in some strange cases. Here's an illustration of such a case (I use an orthographic camera so we don't see how far away objects are from each other, hence the text in the picture): Has anyone ever encountered something similar? Any idea why in this case it's not working? Maybe

Can I merge geometry in every frame in rendering process using three.js?

怎甘沉沦 提交于 2019-12-11 12:58:13
问题 I'm new to three.js and just tried some ideas. Now the problem is I created a line in the scene and used it as a base to clone and transform. So that the cloned ones will be shown as a sequence of transformation in the scene. The simplified code is like: var line, scene, camera, light, renderer; var frame = 0; var random_degree = Math.round(Math.random() * 360); var container = document.getElementById( 'container' ); init(); animate(); function init() { renderer = new THREE.WebGLRenderer();

SpotLight in Three.js. Wrong lightened area and shadows

谁都会走 提交于 2019-12-11 12:44:10
问题 I'm newbie at Three.js and OpenGL at all. So I can't understand lighting. I add SpotLight to my scene as follow: var light = new THREE.SpotLight(0xffff00); light.position.set( 1.5, 5.5, 0.9 ); light.shadowCameraVisible = true; light.shadowDarkness = 1; light.intensity = 2; light.castShadow = true; light.shadowCameraNear = 0.1; light.shadowCameraFar = 50; light.target = new THREE.Object3D(); light.target.position.set(5.5, 5.5, 0); scene.add(light); I turn on shadow map debug at WebGLRenderer

THREE.SVGRenderer save text of image

旧巷老猫 提交于 2019-12-11 12:13:55
问题 Is there a way to obtain the svg text (an image) from THREE.SVGRenderer ? Currently using r58. 回答1: You should be able to access the SVG DOM with renderer.domElement To convert that to XML string (if that is what you mean by "svg text"): var XMLS = new XMLSerializer(); var svgfile = XMLS.serializeToString(renderer.domElement); 回答2: You could try printing the page to PDF. 来源: https://stackoverflow.com/questions/17398134/three-svgrenderer-save-text-of-image

Getting the real screen width in pixels of a div/image using Three.js and the CSS3DRenderer

非 Y 不嫁゛ 提交于 2019-12-11 12:08:35
问题 Really been struggling with this one. I have a program that uses the CSS3D Renderer of Three.js and I am trying to get projected "real" screen-width in pixels of a div (which contains a single image). I've tried using getBoundingClientRect() on the image but the widths and heights returned from that function are wrong. I assume due to a perspective issue. I have also tried this method which gives me an accurate center coordinate and is from this post by mrdoob: https://stackoverflow.com/a

three.js - Trying to include a subwindow into main window

霸气de小男生 提交于 2019-12-11 11:59:53
问题 I try to include, into a main window (representing sphere), a subwindow representing a zoomed view of this sphere. For this moment, I can display a right-bottom subwindow containing the three axes of main scene. These axes are rotating the same way I make rotate the sphere with mouse. Now, I would like to display, into this subwindow, a zoomed view of the sphere instead of having the subwindow with 3D axes. From Can multiple WebGLRenderers render the same scene?, we can't use a second time

Best way to make a BufferGeometry contour in Three.js

三世轮回 提交于 2019-12-11 11:58:55
问题 I'd like to make a specific contour in my BufferGeometry . The goal is make a fill polygon and the lines around. Now, I try using MultiMaterialObject, but the line crosses the square: http://jsfiddle.net/VsWb9/3918/ var positionArray = [0,0,0, 0,100,0, 100,100,0, 0,0,0, 100,100,0 ,100,0,0], colorArray = []; for(var i = positionArray.length;i--;) colorArray[i]=1 // white bufferGeo.addAttribute('position', new THREE.BufferAttribute(new Float32Array(positionArray), 3)); bufferGeo.addAttribute(