three.js

Using Three JS exporter and JSON loader correctly

99封情书 提交于 2019-12-25 08:59:43
问题 EDIT: Originally models didn't even load but I fixed that so now the question is how to export models into js file with textures included in the file. The ThreeJSExporter.ms exporter is located in three.js-master\utils\exporters\max , designed to export 3d models from 3ds max to *.js files. It adds to 3ds max a window (see screenshot) which exports into *.js. ThreeJSExporter.ms window: As the window says it exports to three.js ASCII JSON format . For some reason these exported files don't

How to make a Json model auto-rotates in the scene?

a 夏天 提交于 2019-12-25 08:00:10
问题 I can rotate the ballmesh when I use mouseevent. First try var jsonLoader = new THREE.JSONLoader(); jsonLoader.load('models/ball.json', addJsonToScn); function addJsonToScn(geometry) { var ball = new THREE.BufferGeometry().fromGeometry(geometry); var mtl = new THREE.MeshBasicMaterial( { color: 0xff0000 } ); ballmesh = new THREE.Line(ball, mtl); scene.add(ballmesh); } document.addEventListener('click', rotateMesh, false); function rotateMesh() { ballmesh.rotation.y += 0.1; } function animate()

How can i achieve exact functionality like pointerlock example in threejs but move around programmatically instead of mouse

旧时模样 提交于 2019-12-25 07:47:38
问题 How can i achieve THREE.js pointerlock controls example functionality but move around programmatically (values from accelerometer device) instead of mouse movement? 回答1: THREE.PointerLockControls (next: Module ) works this way: Module makes a construction yawObject -> pitchObject -> camera ( pitchObject is a child of yawObject and camera becomes a child of pitchObject ). You add yawObject (which you could get from Module with yourControls.getObject() function) to your scene (to keep

Three.JS project - loaders don't load local models (with screenshot)

萝らか妹 提交于 2019-12-25 07:46:57
问题 Example projects don't load 3d models to the scene. Or load but don't display, idk. I tried both - the examples from three.js archive that I downloaded, also my own projects with my own models. So I simply open three.js-master folder, open the index page in the examples folder, go through the list of examples. All examples work except the loaders examples. I just go through all of them and not a single format works, not obj, not fbx. What's wrong with local stuff? Online examples work but if

Light penetrating through meshes

帅比萌擦擦* 提交于 2019-12-25 07:36:47
问题 I have a room containing some furniture. I am using a directional light as a sun for casting shadows of windows and doors but the light penetrates through walls and falls on every object. Is there a way to avoid penetration of light through walls? I have read and figured out that lights in threejs doesn't follow physical laws but I am just curious. 回答1: Sounds like light is scattering off of somethings. Could be bouncing off of things outside the room or things within the room/window frame.

How To get 2D Snapshot [like panoramic] of whole 3D Three.js Scene?

拟墨画扇 提交于 2019-12-25 07:28:30
问题 How To get 2d Snapshot of Three.js 3D Scene ?? I need to get 2D Snapshot of my 3D scene like a panoramic image.(Full 360 snapshot) Demo Used:- http://patcat.com/demos/VRWeatherParticles/ I tried this solution :- 1. How do you save an image from a Three.js canvas? 2. Three.js: How can I make a 2D SnapShot of a Scene as a JPG Image? When i do (what mentioned in Link 2) :- renderer = new THREE.WebGLRenderer({ preserveDrawingBuffer: true }); var strMime = "image/jpeg"; imgData = renderer

three.js Switching objects on click

萝らか妹 提交于 2019-12-25 07:23:27
问题 I want to hide/reveal objects with the click of a button. i.e. click button on a GUI and obj1 is hidden and obj2 is revealed. I was told to do this using object.traverse(object.visible=false); but it does not seem to work. Here is how I'm rendering my objects var gal = jsonLoader.load( "model/galmodel.js", addModelToScene ) ; gal.traverse(gal.visible = false); Can anyone point me into the right direction on how to make this work? And the command that will hide/reveal the objects on click?

Three.js Mirrored Normal Maps Flipped Channel

懵懂的女人 提交于 2019-12-25 07:17:27
问题 I have added a normal map to a model in Three.js that is mirrored down the middle. It looks like one of the channels (green perhaps?) is flipped on the mirrored side. I have one ambient light, one directional headlight, and one spotlight. Here is the code that I use to make the material: // Create a MeshPhongMaterial for the model var material = new THREE.MeshPhongMaterial(); material.map = THREE.ImageUtils.loadTexture(texture_color); // Wrapping modes //THREE.RepeatWrapping = 1000; //THREE

How to properly change the camera view to move forward and backward into a scene in Three.js?

只愿长相守 提交于 2019-12-25 07:06:45
问题 I want to make it such that I can move around in the following manner in three.js by moving the perspectivecamera: "hit a key or button to move the camera forward into the direction im looking at" "hit a key or button to move the camera downward below the direction im looking at" "hit a key or button to pitch the camera such that the "fov" is of a different value "hit keys or buttons to pitch the camera such that i am rotating as if pivoted at the place the camera is to be able to see whats

three.js: how to apply alpha-map when using OBJMTL loader?

不问归期 提交于 2019-12-25 07:01:22
问题 Actually I am trying to upload these .obj and .mtl file by OBJMTLloader. all is working fine but the image in mtl file is loaded by map_d is not uploaded. newmtl Eyelashes Ns 10.0000 Ni 1.5000 d 0.5000 Tr 0.0000 Tf 1.0000 1.0000 1.0000 illum 2 Ka 0.5880 0.5880 0.5880 Kd 0.5880 0.5880 0.5880 Ks 0.0000 0.0000 0.0000 Ke 0.0000 0.0000 0.0000 map_Ka EyelashesDiffuseTexture.jpg map_Kd EyelashesDiffuseTexture.jpg map_d EyeLashes_Opacity_Texture.jpg My code is var loader = new THREE.OBJMTLLoader();