three.js

set transparent (opacity: 0) to some faces of a sphere geometry

久未见 提交于 2019-12-25 00:12:57
问题 I want to make half the faces of a sphere transparent and the other half colored. How can I do that? I've tried to set a transparent color, but it seems it doesn't work that way. geometry = new THREE.SphereGeometry(1.0, 17, 17); for (var i = 0; i < geometry.faces.length; i++) { let x = Math.random(); //Here I'm trying to set a transparent color to half the faces of the sphere. let color = 0 if (x < 0.5) { color = '0x000000'; } else { color = '0xffffff'; } geometry.faces[i].color.setHex(color)

BoxGeometry sides

被刻印的时光 ゝ 提交于 2019-12-24 23:40:51
问题 I already asked a Question here: Add Thickness to faces The core question is solved but i ran into another problem. Before my walls were set on side:THREE.BackSide so that they didnt show when they faced the camera but now when they have a thickness that doesnt work anymore and i dont realy understand why. Before: Before After: After How can i make the thick walls behave like the Plane walls ? 回答1: A very rough concept of controlling the visibility of a wall (I've slightly changed translating

Three js, loading texture to only specific mtl

|▌冷眼眸甩不掉的悲伤 提交于 2019-12-24 23:25:11
问题 I am loading obj & mtl file using OBJMTLLoader. There are multiple materials in the object. What I want is to apply texture to a particular material within the object. Eg. I have a Bag object, and it has Handle, Brand name, Wheels as different material. I want to add different texture to each of them. The texture will not be there in the material file. I want to add it using code only. <pre> var loader = new THREE.OBJMTLLoader(); loader.load( 'obj/Test.obj', 'obj/Test.mtl', function ( object

Light Not showing on object

本秂侑毒 提交于 2019-12-24 23:23:02
问题 so Ive been messing with this, and Ive finally gotten everything to kind of work for me. I'm a beginner at any type of javascript so I don't know if this is a simple fix. Basically I cant get the light to show up on the moon like how it does in the original. Well here is what I have thus far. <script type="text/javascript" id="mainCode"> var container, renderer, scene, camera, mesh, light = { speed: 0.1, distance: 1000, position: new THREE.Vector3(0, 0, 0), orbit: function (center, time) {

Extract animation vertices

旧街凉风 提交于 2019-12-24 22:41:01
问题 I have an object loaded with GLTFLoader and an animation using THREE.AnimationMixer . I know I can get vertices of the object by using .fromBufferGeometry().vertices on the Mesh geometry. How can I get all the vertices during an animation and see how they change over the time? KeyframeTrack does not seem to modify geometry directly. 回答1: I know I can get vertices of the object by using .fromBufferGeometry().vertices on the Mesh geometry. It's not necessary to convert your geometry to Geometry

AFRAME position far away from camera

依然范特西╮ 提交于 2019-12-24 20:30:21
问题 Following this question AFRAME screen to world position I can get the position of the vector, but it seems to be very close to camera, how do I get it around 100px further away from the camera? let mouse = new three.Vector2() let camera = AFRAME.scenes[0].camera let rect = document.querySelector('body').getBoundingClientRect() mouse.x = ( (e.clientX - rect.left) / rect.width ) * 2 - 1 mouse.y = - ( (e.clientY - rect.top) / rect.height ) * 2 + 1 let vector = new three.Vector3( mouse.x, mouse.y

THREE.js Orthographic camera position not updating after zoom with OrbitControl

我的未来我决定 提交于 2019-12-24 20:19:31
问题 I'm using THREE.OrbitControls to zoom a THREE.OrthographicCamera. But, even thought the ortho camera renders correctly as zoomed, all that is updating on the camera is the 'zoom' property. Even after calling camera.updateProjectionMatrix(). Do I need to manually update the 'position' property of the camera based on the updated 'zoom' property? I want to display its position in my UI. 回答1: "Zooming" should never change a camera's position. Zooming changes the field of view of a camera, while

Coordinates.speed always returns as 'null'

我们两清 提交于 2019-12-24 19:36:54
问题 I am trying to develop a system where the particles on the background change their speed accordingly to the speed of the device (while you are in a car or bus, for example). For this, the Geolocation API sounded like a great option, with the Coordinates.speed property. The problem is that my speed is always returning as null . From what I've read, it should be a device-related issue, but I have tried with a Nexus 6p, a Mac, a Samsung tablet and an iPad, always with the same null answer in the

How do I figure out the UV Mapping from Ricoh Theta S Dual FIsh Eye to a Three.js r71 SphereGeometry

一曲冷凌霜 提交于 2019-12-24 19:08:05
问题 I am trying to reproduce the three.js panaorama dualfisheye example using Three.js r71. I need to stick to r71 because eventually I will use this code on autodesk forge viewer which is based on Three.js r71. I made some progress, but I need help in figuring out UV mapping. If you compare the result from this link three.js panaorama dualfisheye example with the code snippet there is obiously an issue. var camera, scene, renderer; var isUserInteracting = false, onMouseDownMouseX = 0,

How can I offload Object3d.toJSON() operation to a web worker?

别来无恙 提交于 2019-12-24 19:04:15
问题 I need to convert the active scene in threejs to json object. But as the models become bigger, the process takes more and more time. I can't even show a progress bar for the same. I tried to send the threejs scene to a web worker and convert it to json at the worker. But I wasn't able to send the scene object to the worker. Is it possible to send the threejs scene to web worker? Or is there any promise based implementation for the Object3d.toJSON() ? 回答1: Is it possible to send the threejs