three.js

How to toggle preserveDrawingBuffer in three.js?

大兔子大兔子 提交于 2020-01-19 01:50:31
问题 Basically, I want the setup where I could go to preserveDrawingBuffer=true, render the scene once, grab the screenshot, and go back. However, this poses two problems: there is no method in renderer to dispose all the buffers, canvas goes black if I do renderer = new THREE.WebGLRenderer({canvas:renderer.domElement,preserveDrawingBuffer:true}); How do I do this properly? EDIT: I did not find the way to toggle this, so I had to clone scene and create second renderer instead to make the

local mesh rotation without geometry translate and pivot (THREEJS)

北城余情 提交于 2020-01-17 06:15:30
问题 I try to apply a "local rotation" to a mesh in THREEJS. I want to rotation to be applied around the geometry center but it is applied around the geometry "origin" (0, 0, 0). Assumption: I can not modify the geometry. What I do right now: mesh3D.position.copy(worldPosition); mesh3D.rotation.setFromRotationMatrix(localRotation); mesh3D.updateMatrixWorld(true); Is the only solution to use a pivot somehow? I'd also like to avoid that as it changes the object children hierarchy... Thanks 回答1: To

Raycaster - How to move the mesh that I clicked on

℡╲_俬逩灬. 提交于 2020-01-17 05:41:28
问题 I am trying to click on an object, which is a mesh. For instance, if I click on apple, I want the apple to move in the specific coordinates. Right now, I set the clickedObject as apple for right now. document.addEventListener('mousedown', onDocumentMouseDown, false); var objects = new Array(); objects.push(apple, orange, banana); var clickedObject; function onDocumentMouseDown(event) { var mouse_x = ( event.clientX / window.innerWidth ) * 2 - 1; var mouse_y = -( event.clientY / window

THREE.js - Object Picking doesnt report parent object name on object loaded with OBJMTLLoader

China☆狼群 提交于 2020-01-17 04:57:26
问题 I have loaded an OBJ file with MTL file textures using OBJMTLLoader. I copied the example from http://threejs.org/examples/webgl_loader_obj_mtl.html. The main object (man in business suit with hair, hands and shoes) displays OK with correct textures (e.g. eyes, mouth, tie, buttons). The loaded object is a THREE.Group with 10 children, each child being a THREE.Object3D which has further 3, 5 or 7 child THREE.Mesh objects. Here is the js code for loading the OBJ and MTL... //===================

Edit the 3D text Properties to position and align width Cube using Three.js

女生的网名这么多〃 提交于 2020-01-17 03:50:25
问题 I have the fiddle created using Three.js, where it shows "Lines" along with "Cube" to show the guidelines for the Cube. Here is the Fiddle for the same: http://jsfiddle.net/boquqL84/8/ Now I want to add text also so I can show the heading for each guideline like which line is "Width", "Height" or "Length" as show in the diagram below: The text is working fine when I updated the Three.js file and included the font js file. Now the question is how to align the text, which has the bending

three.js gif image loader on before model load

无人久伴 提交于 2020-01-17 02:48:27
问题 How to show a gif image loader to indicate the status of the model on before load the 3d models using OBJMTLLoader or AssimpJSONLoader ? am using three.js version 67 and am using below code load the gif loader, but the function doesn't have any effect while load the model var loadManager = new THREE.LoadingManager(); loadManager.onProgress = function ( item, loaded, total ) { alert('hi'); console.log( item, loaded, total ); }; var objloader = new THREE.OBJMTLLoader(loadManager); what am doing

three.js gif image loader on before model load

别等时光非礼了梦想. 提交于 2020-01-17 02:48:19
问题 How to show a gif image loader to indicate the status of the model on before load the 3d models using OBJMTLLoader or AssimpJSONLoader ? am using three.js version 67 and am using below code load the gif loader, but the function doesn't have any effect while load the model var loadManager = new THREE.LoadingManager(); loadManager.onProgress = function ( item, loaded, total ) { alert('hi'); console.log( item, loaded, total ); }; var objloader = new THREE.OBJMTLLoader(loadManager); what am doing

Three.js post process: FXAA does not work with SSAO enabled

有些话、适合烂在心里 提交于 2020-01-17 02:21:08
问题 In this simple test scene, I need SSAO and FXAA effects composed together, but I can't get it work. When SSAO is enabled, if I also enable FXAA the render gets black. In the fiddle, if you uncomment composer.addPass(FXAA_effect); you'll see the issue. I check different examples of how to add these effects one at time, they work individually, but I can't get them together. What am I missing? JSFiddle: http://jsfiddle.net/ur3tpwag/ That's the code: var scene = new THREE.Scene(); var camera =

Sprites incorrect positioning

雨燕双飞 提交于 2020-01-16 19:27:28
问题 I use Three.js ver. 65 The browsers are Firefox ver. 27.0.1 and Chrome 32.0.1700.107 m. I tested the app on Windows Xp, 7 and 8. My problems are the following (http://jsfiddle.net/j8DN6/4/): 1) What I can not understand is why the sprites are not centered respect to the center of the Cartesian axes. I.e: spritey.position = (0, 0, 0); 2) The sprites unlike other objects, which rotate properly around the z axis, they follow strange trajectories different from those expected. 3) If I turn the 3d

Use camera as background, while display objects in A-frame

断了今生、忘了曾经 提交于 2020-01-16 18:54:35
问题 I want to use camera video feed as background in a-frame, while overlaying objects on it. I know it is possible but I don't know how exactly to do it. so I am here to ask for help! 回答1: You can have a simple overlay by adding an element before the scene: <img src='overlay.jpg' /> <a-scene></a-scene> fiddle here. Here is a nice article about using a camera stream, I'll just use a basic version of it: html <video autoplay></video> <a-scene></a-scene> js // grab the video element const video =