three.js

Adding geometry to a three.js mesh after render

≡放荡痞女 提交于 2019-12-29 01:35:14
问题 I'm creating a mesh with a THREE.Geometry instance, then populating the geometry's vertices and faces arrays dynamically. The geometry is iteratively refined, adding additional vertices and faces at each iteration. If I refine the geometry before adding the mesh to the scene, it renders correctly. However, if I add the mesh to the scene and render it, then modify it, only the initial N faces the geometry contained on first render are shown. Changes to the position of the vertices used by

Blender exports a three.js animation - bones rotate strangely

好久不见. 提交于 2019-12-28 13:58:08
问题 I'm currently trying to export an animated blender model to three.js using the exporter of three.js (github.com/mrdoob/three.js/tree/dev/utils/exporters/blender/2.66/scripts/addons). I've created a model including bones and weights and a tiny animation. The problem I have: The model gets broken. Somehow the bones don't rotate around their origin but around the origin of the root bone. Moving the bones manually does not make a difference. I followed these tutorials: devmatrix.wordpress.com

Blender exports a three.js animation - bones rotate strangely

六月ゝ 毕业季﹏ 提交于 2019-12-28 13:57:50
问题 I'm currently trying to export an animated blender model to three.js using the exporter of three.js (github.com/mrdoob/three.js/tree/dev/utils/exporters/blender/2.66/scripts/addons). I've created a model including bones and weights and a tiny animation. The problem I have: The model gets broken. Somehow the bones don't rotate around their origin but around the origin of the root bone. Moving the bones manually does not make a difference. I followed these tutorials: devmatrix.wordpress.com

Three.js texture / image update at runtime

半腔热情 提交于 2019-12-28 13:48:11
问题 I am trying to change a cube image at run time by selecting an option from Select Form element. When running the code, the image changes after selecting, but the previous cube and image stays in the scene. How I clear / refresh / update the scene properly when changing the material / image / texture. <div id = "container"></div> <form id = "changesForm"> Cube Image: <br> <select id = "cubeImage"> <option value = "random">Random</option> <option value = "image1">First Image</option> <option

THREE js proper removing object from scene (still reserved in HEAP)

有些话、适合烂在心里 提交于 2019-12-28 11:54:12
问题 What is the proper way to remove mesh form scene? In this example: removable_items = []; box = new THREE.Object3D(); scene.add(box); function add() { var mesh = new THREE.Mesh( new THREE.IcosahedronGeometry( 10, 5 ), new THREE.MeshPhongMaterial( {color: 0xFFFFFF}) ); box.add( mesh ); removable_items.push(mesh); //clean(); ///// when is integrated in function memory is cleaned properly } function clean() { if( removable_items.length > 0 ) { removable_items.forEach(function(v,i) { v.parent

How to set up skybox in Autodesk Forge

大憨熊 提交于 2019-12-28 07:08:10
问题 I want to add a skybox to my Forge scene, but Forge is different from three.js. I want to know what I can do for it. I have tried new THREE.CubeTextureLoader , but the three.js in Forge doesn't have this function. Then I tried to build a CubeGeometry , but it did't work well. This is my code: var materialArr=[]; var directions = ["aa_RT","aa_LF","aa_UP","aa_DN","aa_FR","aa_BK"] ; for (var i = 0; i < 6; i++){ materialArray.push( new THREE.MeshBasicMaterial({ map: THREE.ImageUtils.loadTexture(

Complex shape character outline

青春壹個敷衍的年華 提交于 2019-12-28 05:15:52
问题 Say I have this character and I want allow user to select it, so when it s selected I want to show an outline around it. the character is an object3D with some meshes. I tried to clone and set a backside material, but it did NOT work, the problem was each cube in the shape was render with backside separately so the outline was wrong. do I need to create another mesh for the outline, is there an easier way? 回答1: What @spassvolgel wrote is correct; What I suspect needs to be done is something

Three.js - Geometry on top of another

淺唱寂寞╮ 提交于 2019-12-28 01:12:22
问题 Is it posible in Three.js to have a mesh always rendered on top of the scene, even if it's position is behind all objects? I'm implementing a lasso selection with a mesh and I need to render the selecting box on top of the rest of the scene. 回答1: Yes. First do this: renderer.autoClear = false; Then create a second scene that contains just the objects you want to be on top. Then, in your render loop: renderer.clear(); // clear buffers renderer.render( scene, camera ); // render scene 1

How to get the absolute position of a vertex in three.js?

最后都变了- 提交于 2019-12-27 13:58:10
问题 As far as I know var point = object.geometry.vertices[i]; will return with the relative position for the x , y and z of the point inside the geometry of the object. How to get the absolute position, if the object was moved, rotated or scaled? 回答1: First make sure the object's matrices have been updated. object.updateMatrixWorld(); The render loop usually calls this for you. Then, do this: var vector = object.geometry.vertices[i].clone(); vector.applyMatrix4( object.matrixWorld ); The vector

How to get the absolute position of a vertex in three.js?

﹥>﹥吖頭↗ 提交于 2019-12-27 13:57:07
问题 As far as I know var point = object.geometry.vertices[i]; will return with the relative position for the x , y and z of the point inside the geometry of the object. How to get the absolute position, if the object was moved, rotated or scaled? 回答1: First make sure the object's matrices have been updated. object.updateMatrixWorld(); The render loop usually calls this for you. Then, do this: var vector = object.geometry.vertices[i].clone(); vector.applyMatrix4( object.matrixWorld ); The vector