three.js

Ray casting on a plane geometry only works from on direction

心不动则不痛 提交于 2019-12-25 16:46:52
问题 I'm using plane geometries as walls in a game. I'm using ray caster to provide the player from moving through them. The problem is that planes only works one way. When the player comes from the "front" side it works but when it comes from behind it moves through. Cube and sphere geometries works from any directions so my ray caster function seems to do the job. I have set material to be double sided but it doesn't help. Does any one know about this issue? How can I make the plane using both

Shadow map appearing on wrong place

只愿长相守 提交于 2019-12-25 13:43:33
问题 I'm trying to make use of the built-in shadow map plugin in three.js. After initial difficulties I have more or less acceptable image with one last glitch. That one being shadow appearing on top some (all?) surfaces, with normal 0,0,1. Below are pictures of the same model. Three.js Preview.app (Mac) And the code used to setup shadows: var shadowLight = new THREE.DirectionalLight(0xFFFFFF); shadowLight.position.x = cx + dmax/2; shadowLight.position.y = cy - dmax/2; shadowLight.position.z =

How to make an app ready for 'ovrweb' protocol (to be viewed in Gear VR)?

杀马特。学长 韩版系。学妹 提交于 2019-12-25 13:38:48
问题 I have a web app that uses ThreeJS. I am currently trying to include WebVR to be used with Gear VR. I am aware that I need to link to that web app using the ovrweb protocol in order to open it in Gear VR. My problem is that it does not. Whenever I use window.location.href = "ovrweb:http://my-app-url" , I am asked to attach the device to Gear VR. But once I do so, the screen remains black. I noticed that the same thing happens whenever I use some non-VR webpage as the URL (like ovrweb:https:/

Three.js: How to add an object perpendicular to a face (normal)?

旧城冷巷雨未停 提交于 2019-12-25 12:54:12
问题 I'm trying to add a box (called "marker") perpendicular to the face I'm clicking on. To do this, on click, I cast a ray, if it hits something, I get the normal's intersecting point values and transfer them to the "marker" as its rotation values. Before asking this question, I read this answer ( How do I make an object perpendicular to a face with Three.js? ) but could not make it work... For now, it adds the marker where it needs to, but with a slightly wrong orientation expect on cube's top.

three.js shadowCascade DirectionalLight

旧巷老猫 提交于 2019-12-25 11:55:03
问题 I'm trying to copy the shadowCascade functionality from http://threejs.org/examples/webgl_morphtargets_md2_control.html to my project. I did this 1:1 however I only get a a little bit of shadowing at a certain angles and rotations, and often cut off. Further, enabling shadowCascade from start throws shader errors. I have to wait for some time until I can set shadowCascade = true. I tried to find documentation, links or hints explaining how shadowCascade works and what all those parameters do,

Three.js merge with different textures

折月煮酒 提交于 2019-12-25 09:09:49
问题 I have a scene with two individual meshes. It looks like this: this.loadFiles("gras", (gras) => { var particleMaterial = new THREE.MeshPhongMaterial(); particleMaterial.map = THREE.ImageUtils.loadTexture("models/planets/gras.jpg"); particleMaterial.side = THREE.DoubleSide; this.mesh = new THREE.Mesh(gras,particleMaterial); this.loadFiles("rocks", (rocks) => { var particleMaterial = new THREE.MeshPhongMaterial(); particleMaterial.map = THREE.ImageUtils.loadTexture("models/planets/rocks.jpg");

three.js Orthographic Camera: Zoom All

谁说我不能喝 提交于 2019-12-25 09:08:39
问题 I am a complete newbee to three.js , and I cannot find out how to implement a "zoom all" with a OrthograpicCamera . I have been searching on the documentation and on the web, and I have only found solutions for PerspectiveCamera , that involve altering the field of view. My goal is to achieve a fitting of all the 3D objects of a scene to the screen, so they are shown as bigger as possible. Any ideas to achieve this will be helpful. Thanks. 回答1: You could calculate the 2D screen space bounding

Problems With Vector Reflection with Particle Collisions

邮差的信 提交于 2019-12-25 09:07:27
问题 I was wondering whether I made a math mistake in my particle collision simulation found here. The particles don't seem to separate properly during collision resolution. Here is a code snippet from the function which separates particles and changes their velocities: //particle 1 var pi = particles[i]; //particle 2 var pj = particles[j]; //particle 1 to particle 2 var pimpj = pi.mesh.position.clone().sub(pj.mesh.position); //particle 2 to particle 1 var pjmpi = pj.mesh.position.clone().sub(pi

Three.js merge with different textures

落花浮王杯 提交于 2019-12-25 09:07:05
问题 I have a scene with two individual meshes. It looks like this: this.loadFiles("gras", (gras) => { var particleMaterial = new THREE.MeshPhongMaterial(); particleMaterial.map = THREE.ImageUtils.loadTexture("models/planets/gras.jpg"); particleMaterial.side = THREE.DoubleSide; this.mesh = new THREE.Mesh(gras,particleMaterial); this.loadFiles("rocks", (rocks) => { var particleMaterial = new THREE.MeshPhongMaterial(); particleMaterial.map = THREE.ImageUtils.loadTexture("models/planets/rocks.jpg");

How to add 3d context works in JsBridge by adding WebGLRenderingContext?

非 Y 不嫁゛ 提交于 2019-12-25 09:05:21
问题 Currently JsBridge supports only getContext("2d") and not getContext("webgl"). public object getContext(string contextType) { if (contextType == "2d") { if (this.context == null) { this.context = new CanvasRenderingContext2D(this.window, this); } return this.context; } return null; } Ideally, to make JsBridge supports 3D, one needs public object getContext(string contextType) { if (contextType == "2d") { if (this.context == null) { this.context = new CanvasRenderingContext2D(this.window, this