three.js

Three.js position and direct the camera

你离开我真会死。 提交于 2019-12-11 15:04:35
问题 For me is impossible after hours/days of search to find the answer to such a central problem in Three.js: I know 1) the position of the camera (=my eyes) 2) The direction of the camera (of my eyes) 3) the direction of my head. Generate the camera (we ignore camera angle, near/far, aso). The nearest I get is as follows: camera = new THREE.PerspectiveCamera(150, window.innerWidth / window.innerHeight, 0.1, 5000); camera.position.x = myParams.eye_x; camera.position.y = myParams.eye_y; camera

Figuring out how much of the side of a cube is visible

倾然丶 夕夏残阳落幕 提交于 2019-12-11 14:52:25
问题 I have a simple Three.js scene with a camera that orbits around a cube, always looking directly at it. I need to figure out the percentage of the side that is currently most visible by the camera as it orbits around the cube. So if I'm looking straight on then side 1 (the "front") can be seeing 100% and all other 5 sides are at 0%. If I rotate the camera slightly to the right right then part of side 2 (the "right side") can now be seen -- perhaps 20%, while side one can now be seen at %80. If

BulletPhysics (ammo.js) - How would you applying force directed to a point?

孤街醉人 提交于 2019-12-11 14:40:28
问题 I want the Force converge to a point of the scene. So the Force will not be the same on each point of the scene (like Y vector) but change direction in the space. It is like gravity converge to the center of the Planet or Star. How would you do this with Ammo.js ? Best regards PS1 : Firstly, I want exactly to rewrite this example with Ammo.js : http://lo-th.github.io/Oimo.js/#planet PS2 : My final intention is to rewrite this example of gravity in 3D with Three.js and Ammo.js : https://bruno

Threejs, understanding raycaster's intersectd object coordinates

本小妞迷上赌 提交于 2019-12-11 14:36:03
问题 Hello, I have one doubt: I have implemented a raycaster and I have been testing it manually, however I do not know why on most of the clicks which I made on the 3D model, it did not get the intersection point. First I will show you the points I clicked on, then the points which were logged in the web console then the code I have implemented and finally the web structure: I have clicked on those eight points: And the results are: []length: 0__proto__: Array(0) []length: 0__proto__: Array(0) [

How to change geometry color with dat.GUI?

穿精又带淫゛_ 提交于 2019-12-11 14:34:15
问题 I have the following code to render a simple cube. It has dat.GUI controls to change rotation, and I want to add a color changer also. Eventually, I want to have a more complex geometry and want to be able to change the color of more than one element. $(function(){ var scene = new THREE.Scene(); var camera = new THREE.PerspectiveCamera(45, window.innerWidth/window.innerHeight, .1, 500); var renderer = new THREE.WebGLRenderer(); renderer.setClearColor(0xdddddd); renderer.setSize(window

Simple holes aren't rendered properly in Three.js

独自空忆成欢 提交于 2019-12-11 14:21:52
问题 I have a simple rectangular wall and I like to place multiple window holes on it. It always works great for the first hole, but as soon as I add additional holes the polygon becomes messed up. See the images below to see what I'm talking about. How can I draw holes properly in Three.js? The right hole is not drawn properly. After increasing the height of the right hole the entire wall mesh becomes halfcut. Here is a sample code that causes above problem: var shape = new THREE.Shape(); shape

Three.js: using an image texture causes other objects to disappear

此生再无相见时 提交于 2019-12-11 13:58:45
问题 I'm trying to visualize a space time cube. As a reference I take this image I found on google: http://www.intechopen.com/source/html/38305/media/image7.jpeg . Actually I managed to do it but there is a weird bug as soon as I start to use a texture for the bottom of the cube (which is a plane in my case). The things that are just above the plane are some how not always visible and the image is sometimes distorted. It is hard to explain so you might check the jfiddle out I created: http:/

Point one object to face a distant object

元气小坏坏 提交于 2019-12-11 13:52:06
问题 I have two objects, let's call them nearObject and farObject. Once nearObject gets within a certain distance from farObject, I want farObject to rotate to face nearObject. This should happen instantly, it does not need to slowly rotate over time. 1) The distance is arbitrary, so I am using the following to get distance information. nearObject.position.distanceToSquared(farObject.position); 2) Now I want farObject to rotate perpendicular to the vector between the two objects. What is the

three.js - canvas texture on tube geometry for ipad

谁说胖子不能爱 提交于 2019-12-11 13:47:30
问题 I've a 3d model of a tube geometry. There are 18000 co-ordinates on production side. I am taking every 9th co-ordinate so that actually plotting 9000 co-ordinates to build a tube geometry. I've to use CanvasRenderer only. Now when I use vertexColors: THREE.VertexColors in WebGLRenderer , the model displays different color on each face. When I change it to CanvasRenderer , the model turns into white color only. Even I change vertexColors: THREE.FaceColors , the result is same. Please find

ThreeJS r69 Trackball controls, camera and directional Light

久未见 提交于 2019-12-11 13:41:38
问题 I need to sync trackball controls and camera with the directional light. My case scenario: Init an empty scene with camera, lights and controls. Load a bufferGeometry obj, get its centroid and set camera and controls position and target relative to the obj centroid. Basically I simply set camera position and controls.target with: camera.lookAt( position ); camera.position = position; controls.target.copy( position ); where position is a Three.Vector3 obj. Directional light has to sync