three.js

THREE.js custom tangent attribute how do i load it

倖福魔咒の 提交于 2019-12-13 05:31:52
问题 I'm looking at this example: http://threejs.org/examples/webgl_custom_attributes.html and notice that the custom displacement attribute gets filled by vertices.length for ( var v = 0; v < vertices.length; v++ ) { values[ v ] = 0; noise[ v ] = Math.random() * 5; } My question is, how does this relate to the number of normals, uvs and tangents? When i export my model from 3ds max, i have more UVs than vertices. I need to assign tangents per this UV number because they are different at seams. I

Spawn particle at edge of screen

不问归期 提交于 2019-12-13 05:29:59
问题 I've searched far and wide, so if there's a similar question please forgive me but I just couldn't find it. To put what I'm trying to do in context: I want to create an infinitely-generated field of stars that disappear as they go offscreen and reappear at the edge of the screen where the camera is moving. I'm working with a top-down view, so it must be pretty simple to achieve this, but alas I haven't a clue. I'm using the following code to determine whether a star has gone off-screen and

get back to normal after the traverse in threejs

梦想与她 提交于 2019-12-13 05:04:52
问题 in threejs am working around with the traverse method to apply the WireframeHelper for the models that is loaded using OBJMTLLoder, for this kind of models we must use traverse to apply the Wireframe for child of the Object, so here i can apply the wireframes and so on using traverse but after the traverse i can't get back to my normal object meaning that i can't remove the wireframes with the traversed mesh, the mesh is added with the scene with scene.add( wfh ); where wfh is WireframeHelper

Performance drop on multiple restart of scene from threejs

|▌冷眼眸甩不掉的悲伤 提交于 2019-12-13 05:01:47
问题 I have been building the application using the threejs now when i am trying to restart the scene multiple time there is the performance drop as per the forum Performance drops when trying to reset whole scene with Three.js i am deallocating all the __objects available inside my scene i am runing a loop and deleting my objects also by creating a custom unload function more over i am also clearing the time interval from request animation frame. But on each restart there is performance drop

extracting the 2D screen position of a 3D point with three.js [duplicate]

感情迁移 提交于 2019-12-13 04:57:11
问题 This question already has answers here : Converting 3D position to 2d screen position [r69!] (3 answers) Closed 4 years ago . I am trying to figure out how to get the 2D screen coordinates for a 3D point. I am using three.js to generate some snowflakes that fall slowly down the screen. I originally wrote the script just as a 2d canvas animation and added mouse interaction so you could blow the snow around with mouse movement. It worked well, but when switching to webgl the snowflakes were now

three.js - how do I get the vertices of an object?

Deadly 提交于 2019-12-13 04:43:59
问题 I am trying to import a model from blender and loop through all vertices. I am using the colladaloader for the import. It all works fine and the model is loading. But I do not want the faces of the model - I only need the vertex positions for my purposes. Can anyone tell me if there is a way to do this? e.g. a loop that loops through all vertices of the imported model? Thanks, Tomo 回答1: If geo represents your geometry: for (var i = 0; i < geo.vertices.length; i++) { var v = geo.vertices[i]; /

How to strech(scale) mesh on the world axis

与世无争的帅哥 提交于 2019-12-13 04:43:18
问题 There is an online 3d editor where you can edit individual meshes (move, scale, rotate). Ability to edit meshes implemented using custom transform controls which based on threejs's TransformControls code. This is fragment from mousemove event: var intersect = intersectObjects(pointer, [xzPlane]); // intersect mouse's pointer with horizontal plane var point = new THREE.Vector3(); point.copy(intersect.point); point.sub(offset); // coords from mousedown event (from start stretching) // some code

I'm doing something wrong with SpotLights and shadows in Three.js

不羁的心 提交于 2019-12-13 04:41:38
问题 I have a really simple scene which has one .dae mesh in it, and a 7000*7000 plane underneath the mesh. I'd like it to be lit by a high SpotLight , so the mesh throws a shadow on the ground. But, something seems to be broken! No matter how high I put the SpotLight , it never lights up the plane! Also, it lights the mesh up only a little, while it is in a small square (perimeter). You can see the situation here: As soon as I move the mesh (a monster) around, it wont be lit anymore. This is how

Three.js - calculating relative rotations

家住魔仙堡 提交于 2019-12-13 04:41:12
问题 I have a THREE.Scene with two meshes added, meshA and meshB , each of which has been rotated in different ways. My goal is to remove meshB from the scene and re-add it as a child of meshA , while preserving its global position and rotation -- in other words, the position and rotation of meshB should appear the same before and after this code. My current, almost working attempt is as follows: var globalOffset = new THREE.Vector3().subVectors( meshB.position, meshA.position ); var localOffset =

Three.js : Invisible background for background and png particles

。_饼干妹妹 提交于 2019-12-13 04:39:45
问题 I'm having trouble setting invisible background and alpha channel on my particles. For christmas I wanted to use your example script wegl_particles_sprite . Adapted to the situation. I have set the code in a full screen div in foreground and succeeded to make it unclickable so that I can still use my website. The problem is that I couldn't set png alpha channels to transparent even with transparent=true; . First I set the background transparent: OK renderer = new THREE.WebGLRenderer( {