three.js

ThreeJs Box Outline

前提是你 提交于 2020-01-25 03:56:05
问题 I am making something in three.js and it had cubes (or rectangles) with outlines, because wireframe now renders diagonals I couldn't use that, I cant use Images either, and I tried boxhelper, I need something like the wireframe in older versions, but not transparent, is there anyway to to this? 来源: https://stackoverflow.com/questions/24869737/threejs-box-outline

Three.JS Shadow to object

杀马特。学长 韩版系。学妹 提交于 2020-01-24 15:11:22
问题 I want to add castShadow and receiveShadow on a object. But what do I wrong with the following code?... var mtlLoader = new THREE.MTLLoader(); mtlLoader.setPath("objects/Tree/"); mtlLoader.load("tree.mtl", function(materials) { materials.preload(); var objLoader = new THREE.OBJLoader(); objLoader.setMaterials(materials); objLoader.setPath("objects/Tree/"); objLoader.load("tree.obj", function(gate) { var positionX = 0; var positionY = 4; var positionZ = 0; gate.position.x = positionX; gate

ThreeJs different material to each face of cube

佐手、 提交于 2020-01-24 13:17:25
问题 I loading a cube object exported from Blender using GLTFLoader, and trying to apply color on each face of the cube using addGroup method, but the result is not as expected. I am getting the result as following image below. The model can be download from the link https://github.com/SourceCodeZone/3D/blob/master/Cube/test.glb I am referring the answer here BufferGeometry: how to render groups of faces Below is the code. var cube; var loader = new THREE.GLTFLoader(); loader.load( './Model/GLTF

play animation once instead of looping three.js

久未见 提交于 2020-01-24 12:43:06
问题 I have exported blender JSON animation into THREE.js, everything works fine, but I want to play the animation only once and stop instead of looping the animation. 回答1: Old question, but in case anyone needs it the solution is to set animation.setLoop( THREE.LoopOnce ) let objLoader = new THREE.ObjectLoader() objLoader.load('./your.json', function( obj ) { scene.add( obj ) animationMixer = new THREE.AnimationMixer( obj ) animation = animationMixer.clipAction( obj.animations[ 0 ] ) animation

Performance drops when trying to reset whole scene with Three.js

只愿长相守 提交于 2020-01-24 08:22:08
问题 In my current project Im using Threejs for buildin a level with meshes. All the graphical stuff with camera, scene, projector, renderer and so on is done in one object. For test purposes I want to reset the whole scene with different parameters, for example different level sizes. Because I want measure time of an algorithm I want a "full" reset. So my current approach is deleting the div-box containing the scene/canvas and deleting the whole object which has the threejs code. After this I

Performance drops when trying to reset whole scene with Three.js

对着背影说爱祢 提交于 2020-01-24 08:20:22
问题 In my current project Im using Threejs for buildin a level with meshes. All the graphical stuff with camera, scene, projector, renderer and so on is done in one object. For test purposes I want to reset the whole scene with different parameters, for example different level sizes. Because I want measure time of an algorithm I want a "full" reset. So my current approach is deleting the div-box containing the scene/canvas and deleting the whole object which has the threejs code. After this I

three.js toDataURL PNG is black

不打扰是莪最后的温柔 提交于 2020-01-23 17:40:06
问题 I'm trying to grab a screenshot with renderer.domElement.toDataURL("image/png"), and save it to a file. The image is the right size, but it's black. I have preserveDrawingBuffer turned on. I think I'm decoding and saving the file correctly, because when I hexdump it I can see the correct initial characters for the PNG format, as well as the IHDR and IDAT chunk headers. However the closing IEND is missing. Any known issues here? Hints? Windows 7/Firefox up to date if it matters. Thanks...

How to bend a cylinder in three.js?

一世执手 提交于 2020-01-23 11:56:20
问题 How would you arc or bend a cylinder type geometry (that has distortion) in three.js? Id like to specify these parameters: Bend Start - at what percent of the cylinder's height the bend starts Bend End - at what percent of the cylinder's height the bend ends Angle - how strong the bend is I'll be controlling them with sliders. My cylinder shape is created from an extrusion of a bezier curve that the user draws (extension of geometry class in three.js). I'd also like to be able to layer

Three.js Device Orientation Controls to point at a specific target on load

无人久伴 提交于 2020-01-23 10:39:51
问题 I'm using the Device Orientation Controls in Three.js to set up a web application for Google Cardboard. When I load the scene, the default target of the camera is the Y direction (Z on the phone) where there might not be any objects. I'd like to define a direction before loading. Does anyone have any suggestions on how to do this without the need to rotate the objects in the scene? Thanks in advance for your help! 回答1: Add your camera to a THREE.Object3D(). Rotate the parent object. 回答2: I

Three.js custom objLoader geometry lighting

空扰寡人 提交于 2020-01-23 07:46:51
问题 I have this object I'm loading with THREE.objLoader and then create a mesh with it like so: mesh = new THREE.SceneUtils.createMultiMaterialObject( geometry, [ new THREE.MeshBasicMaterial({color: 0xFEC1EA}), new THREE.MeshBasicMaterial({ color: 0x999999, wireframe: true, transparent: true, opacity: 0.85 }) ] ); In my scene I then add a DirectionalLight, it works and I can see my object, however it's like the DirectionalLight was an ambient one. No face is getting darker or lighter as it should