three.js

Controlling background video visibility using THREE.Vector3 and OrbitControls.js

假如想象 提交于 2019-12-11 17:21:52
问题 i have this example that stackoverflow user Marquizzo helped me develop. What it'd like to change is that instead of background color changing based on camera position I would like to have a short looped video background that becomes visible only in the position that right now in the example makes the background go gradually black. Additional features would be audio volume increasing in the same way and also activiating an invisible hotspot (also only in the same range of camera position) to

How to declare a BufferGeometry of another object in Three.js?

断了今生、忘了曾经 提交于 2019-12-11 16:57:48
问题 I was working with generating random lines in Three.js, as demonstrated in this fiddle. But, I was wondering if I can acces the Buffer Geometry of another object (in my case THREE.PerspectiveCamera) so that the lines would be created inside that geometry (view-frustum). I found out that by calling this: var helperGeometry = camera_RT_Helper.geometry; console.log(helperGeometry) it will return: What I use for assigning the BUFFER GEOMETRY : var myBufferGeometry = new THREE.BufferGeometry(); /

Position a body in cannon.js relative to local rotation

余生颓废 提交于 2019-12-11 16:53:59
问题 I have a body in cannon.js that has a quaternion rotation applied to it. I want to move it 100 units along a vector relative to it's local rotation. Eg let body = new CANNON.Body({ mass: 0 }); body.quaternion.setFromAxisAngle(new CANNON.Vec3(0,0,1),(2*Math.PI)/6); body.position.set(0,0,100); //this is wrong Using body.position.set(x, y, z); moves the body relative to the world rather than the local rotation. I think I need to add a vector after applying the quaternion to it, but the docs for

How to use fragment shader from glslsandbox.com

此生再无相见时 提交于 2019-12-11 16:52:01
问题 i want experiment with ShaderMaterial material from Three.js. But i don't know OpenGl Shading language.When i use fragment shader code in above site,i get a bunch or errors.So i dont know vertex and fragment shader depend with each other or no matter.If is right what i should write in vertex shader.Thank My copy-pasted vertex shader for BoxGeometry uniform float time; varying vec2 vUv; varying vec2 surfacePosition; uniform vec2 resolution; void main() { vec3 posChanged = position; posChanged

How to rotate 90 degree camera control angle rotate left,right side in three.js?

我只是一个虾纸丫 提交于 2019-12-11 16:51:19
问题 I created 2 buttons left and right . if I click left button camera rotate 90 degrees each time. I called leftMode function. my camera rotate does not work. How to do this rotate angle 90 degree?. Please tell, What mistake in my code? camera3D = new THREE.PerspectiveCamera(angle, width / height, near, far); camera3D.position.set(0, 10, 500); /* Floor */ var geometry = new THREE.PlaneGeometry(10000, 10000, 10, 10); var material = new THREE.MeshBasicMaterial({ color: 0x444444 }); var floor = new

How to Toggle ThreeJS Outer Face Direction

那年仲夏 提交于 2019-12-11 16:44:59
问题 I am trying to make a function that will invert a Three.js Geometry across the xz plane. Scaling the geometry by (1, -1, 1) will effectively do just this, but now the planes that were facing outwards are facing inwards, so I can see through the geometry. I know there is a way to render both sides of the faces, but I'd rather not so I can speed up render times. Is there an easy way I can toggle which face of a plane is shown? 回答1: material.side = THREE.BackSide or material.side = THREE

Rotate camera to look at Selected object in three.js

强颜欢笑 提交于 2019-12-11 16:36:28
问题 I am trying to design a map. So, when I select any geometry, I want the object to come at the centre of the viewport and the camera to be looking at it. I have spent quite a lot of time looking everywhere on the web but failed to find the answer. Please note that I don't want to rotate the object. I just want to update the camera. I am trying to get something like in this example where when we click the number, it comes to the centre : https://sketchfab.com/3d-models/jurassic-aquarium-diorama

make three.js skybox from tilemap

断了今生、忘了曾经 提交于 2019-12-11 16:22:34
问题 I can make a three.js skybox using 6 separate image files. But I want to be able to build a skybox from a single image made up of tiles. For example if I have a composite tiled image as source (see (http://www.zen226082.zen.co.uk/STACK_EXCHANGE/Giant_A.jpg)... i dont have enough rep to post it here :-(. I can load the composite image into a canvas and copy each tile into a cache buffer and then send them into a Three.js materials array. The materials are then used to make a skybox. However

Load positions attribute from a JSON file in Three JS Buffer Geometry Points

吃可爱长大的小学妹 提交于 2019-12-11 16:21:04
问题 I am new in using Three JS Buffer Geometry my task is to draw Buffer Geometry Points, I have position attribute and color attribute value saved in a separate JSON file, how can I use them to populate on Buffer Geometry points? I tried FileReader function to read the JSON but its a asynchronous call. I also tried Loader of Three JS but I couldn't success. My buffer geometry code init() function loop that creates position and set color: for ( var i = 0; i < 81; i += 3 ) { // positions //var x =

Three.js place an object in rotating camera's fov

醉酒当歌 提交于 2019-12-11 16:20:52
问题 I have a fixed-position, perspective camera that rotates around all 3 axes via keyboard input. At random intervals, independent of user input, I need to place objects within the camera's field of view no matter what direction the camera is looking. The objects will also need to be offset specific x and y distances from the center of the camera's fov and offset a specific z distance from the camera's position. I cannot use camera.addChild because once the object is added I need to move the