Questions tagged [three.js]
Three.js is a JavaScript 3D Library which makes use of WebGL
125 questions
1
vote
1
answer
921
views
Throw ball - distance and force
I have a question, I need a formula to calculate the distance and a force based on the speed that drags the finger up on the phone. And is there any way I can get a look? And also shows the trajectory ...
1
vote
0
answers
487
views
Texture mapping artifacts at triangle edge (for thin triangles?)
I'm working on generating programmatic textures for 3d models and showing them in WebGL using Threejs. To do this I generate a texture image (PNG) that contains per-triangle textures (a rectangle on ...
2
votes
1
answer
1k
views
2d game with 3d js. game engine
I'm trying to understand if it's possible to create a game where the player can switch between 2d (strategic/bird view) and 3d (actual gameplay) using only the 3d supported JS/HTML5 game engine, like ...
0
votes
1
answer
342
views
How to add a JSON object / model into your whitestorm world / scene?
I am loading the object from my json file.
...
0
votes
1
answer
1k
views
How would I process accelerometer data to use it for camera rotation?
I'm using Three.js to make a web-based 3D first-person game. I would like the player to be able to control the camera rotation with their device's accelerometer.
The sensor data is received via the <...
2
votes
1
answer
935
views
Sorting sprites above the surface of 3D mesh?
I'm having trouble getting sprites to display on top of a 3D mesh. My requirements are as follows:
Sprite should billboard
Sprite should not clip into the mesh
Sprite should be hidden when on the ...
2
votes
3
answers
1k
views
How can I rotate the camera for a player walking around the surface of a sphere? [duplicate]
I'm making a 3D game where the player can walk across the surface of a planet.
I am having a problem correctly rotating the camera's frame of reference, so that the camera is oriented correctly ...
2
votes
2
answers
10k
views
Adding multiple materials to a single mesh in three.js
I've been doing some reading and can't seem to figure out a good way to do this..
I have a simple globe with a material on it like so:
...
4
votes
4
answers
10k
views
Three.js— how to rotate sphere without moving light (using OrbitControls)?
Okay, I think the problem that I'm having is that when I create my DirectionalLight with three.js, when I then rotate my object with ...
0
votes
1
answer
886
views
Rotating pitch and yaw causes roll
So I'm new to working with a 3D space and not sure how to fix my problem, I basically have a turret that rotates along its Z axis, and pitches along it's Y but after rotating 180 on the Z axis the ...
0
votes
1
answer
993
views
Shader to render objects with distance independent size
I am trying to find a way to render certain objects in my 3d scene without the effects of the perspective projection. E.g. I want them to have the same pixel dimension independent of distance to the ...
1
vote
0
answers
667
views
How to simulate projectile path in 3D with Physijs andThree.js? [closed]
I'm new in 3D rendering with WebGL. I would like to simulate a 3D projectile path using Three.js and Physijs.
How could I achieve this?
2
votes
1
answer
9k
views
How to make texture size correctly in THREE.js?
I'm new to THREE.js and I have a frustrating problem. I can't get my grass texture to size "normally" on the terrain.
I get it, the terrain is steep, but that doesn't mean the grass should be ...
0
votes
4
answers
2k
views
Position object in FOV in threejs
I'm just starting with threejs, and I'm building a basic first person shooter. I use pointer lock controls.
When the user clicks ("shoots") an object, I remove it and place it at another random ...
2
votes
1
answer
91
views
How to create guides to off-screen objects?
I've played Metroid Blast on Wii U, and would like to build one of its features in a three.js game.
The feature is: if an opponent is out of view, a guide is displayed showing the direction of the ...
0
votes
1
answer
2k
views
360 degree quaternion interpolation?
I am in the process of implementing interpolation into a simple game loop I am playing with after reading the infamous "fix your timestep" article (which is amazing by the way). I have the position ...
1
vote
1
answer
309
views
Unexpected quaternion rotation behavior
First off let me apologize for the vague title but I really couldn't think of a more descriptive one (maybe after reading this a more advanced user might be able to edit it).
Alright, so I have been ...
1
vote
0
answers
82
views
align local Y to be parallel with global Y during or after slerp
I am using the following function to have a globe rotate a point on its surface to face the global Z toward the camera. This works fine, but after each rotation the Y axis seen as a green line is not ...
4
votes
2
answers
3k
views
How do you avoid lag with Three.js and mousemove?
I'm trying to create a browser moba-like game using three.js. I'm using WASD for movement and the player rotation follows the mouse with mousemove then lookAt() the ...
3
votes
0
answers
747
views
My collision detection is not working when I rotate my mesh in three.js
I am trying to move a ball mesh through a maze. The maze belongs to a parent object3d. My issue is that when I move the ball I can't detect collision right well because in the rotation, the axis ...
4
votes
1
answer
159
views
Timers and performance for mobile JS
I'm using the Three.js JavaScript library to do some things in WebGL, and I wonder how the graphic aspects of timers are done on mobile.
I was creating numbers with geometries and just replacing them ...
1
vote
0
answers
58
views
How to use quaternion on another referential
I'm new on Three.js and despite a mechanical background, I can't find how quaternion works: it's like it always refers on local part referential and not the global one.
I've illustrated it here : ...
1
vote
0
answers
67
views
Unstable behavior when applying impulse
I created a video that describes the problem since it very hard to explain it. Basically, using physi.js, I am applying random impulse on the object. In the video, at 0:17 the problem begins when the ...
2
votes
1
answer
470
views
White dots artifacts when applying borders to hex tiled geometry
I have a hexagon tiled geometry I created in Blender
Which I then load in WebGL, using THREE.js library. Below is the loading code, I've cut the code of creating scene, lights, etc. I create rendered ...
0
votes
1
answer
3k
views
How can I export a model from Unity to three.js?
I want to buy some assets from the Unity asset store and use them in my three.js project, but I am not sure what the best way to go about this is. Some cursory googling got me this, but Collada ...
0
votes
1
answer
3k
views
three.js objects disappear
I haven't got a lot of experience with 3D Frameworks - but was playing around with three.js and came across something that (to me) is a bit odd and I wondered why this happened. I am rendering the ...
1
vote
3
answers
1k
views
Loading Collada Files Quickly (three.js, OpenGL, Javascript)
Okay, so I've created these sleek-looking spaceship models for an OpenGL game that I'm going to make. To make them look sleek and smooth, I used a Subdivision Surface modifier in Blender. Hmm... ...
1
vote
0
answers
46
views
My Directional light lights the floor of my cave but not the ceiling (concave mesh)
I am developing a small demo with Meshes created from a vertex map.
When i put a hole in the mesh (making it concave) the physics work fine but the directional lightning only lights one part of the ...
0
votes
1
answer
2k
views
THREE.JS: why is the rotation only applied on the last axis used?
my function:
...
0
votes
1
answer
830
views
PhysiJS and objects on top of moving objects
Using Physijs which uses ammo.js.
I am attempting to simply place a sphere on top of a box, the box is moving back and forth and I want the sphere to move with it while also being able to move on top ...
-3
votes
1
answer
333
views
handling wars in multiplayer browser game [closed]
I'm building a browser game about countries, cities, the user control his city, building it upgrading it, can fight other cities in the same country, elections and war between countries, peace, trade ...
4
votes
1
answer
939
views
Vertex ordering with THREEjs's exporter
I'm using THREEjs's exporter to export a 2D polygon plane. The resulting JSON gives me the vertices. I'm trying to properly order these vertices as to make the actual polygon shape, without luck.
...
3
votes
1
answer
4k
views
determining view boundaries based on z position when using a perspective projection
I'm using three.js to make an animation of a box moving around the screen in 3 dimensions.
It is moving pseudo-randomly, according to a noise function. So, I want to place an invisible wall just ...
0
votes
1
answer
2k
views
How can you merge the geometries of cloned objects in Three.JS?
So I'm testing the best non-voxel way to display a lot of objects at once and so I found how to merge geometries.
Now, I can easily merge most geometries, but I can't seem to merge the geometries of ...
1
vote
1
answer
1k
views
WebGL (three.js) - rendering object behind camera far plane
I need to have one object that is always visible/rendered (a lens flare, to be exact). I don't want to set the camera far plane to the maximum possible distance between camera and the sun (performance ...
0
votes
1
answer
220
views
JavaScript THREE.js webgl spotlight rendering
I'm playing with webgl/JavaScript/THREE and a spotlight. And I see unexpected results. And I don't understand what's going on, and I'm hoping you can point me in the right direction. In my particular ...
1
vote
2
answers
4k
views
Three.js: Lighting not calculating correctly on THREE.Geometry objects
I have a three.js (REVISION: '68') issue with the lighting of THREE.Geometry objects:
I'm using the THREE.Geometry class to build up objects using vertices and faces, then I computeFaceNormals() and ...
0
votes
1
answer
353
views
Rendering mountains around a tile layer [closed]
When making a 2D Pokémon game, I just faked elevation by putting mountain tiles underneath the land. Now my tiles are 3D models, so I'm using layer properties to define their elevation. What I don't ...
1
vote
0
answers
1k
views
Must light helper be added directly in scene?
Following method of adding light helper works ok:
...
1
vote
1
answer
2k
views
How to implement 2d collision detection that is immune to low framerate and fast movement? [duplicate]
I am trying to implement my own collision detection for a 2.5d voxel style platformer using Three.js.
I have a problem with my implementation - if the framerate is too low or the character is moving ...
5
votes
2
answers
8k
views
What object3D properties are required to make rayCaster.intersectObjects() work?
FYI, I am trying to do something almost identical to the following:
Merging geometry/mesh without losing benefits
I essentially have a list of Three.object3D's. These objects are "merged" ...
4
votes
1
answer
668
views
How do I make cars on a one-dimensional track avoid collisions?
Using three.js, I use a simple spline to represent a road. Cars can only move forward on the spline. A car should be able to slow-down behind a slow moving car. I know how to calculate the distance ...
11
votes
4
answers
10k
views
Merging geometry/mesh without losing benefits
In three.js we can simply merge geometry to limit the amount of draw calls and thus increase performance. In a simple test with one material, I could draw 50.000 cubes + shadows @ 60fps on my GTX660 ...
2
votes
1
answer
2k
views
Emscripten code and three.js
I would like, if it's possible, to use Emscripten code generated from C/C++ with the Javascript library three.js. For example, from emscripten code I want to pass rendering information to the three.js ...
4
votes
1
answer
7k
views
Orthographic Camera and Raycasting in Three.js
I'm working on a test project porting a simple game from iOS to Javascript. I've got the orthographic camera working and it can view the objects in the scene and move up and down the tower of meshes ...
2
votes
1
answer
3k
views
Three.js camera turning leftside right
In Three.js I am trying to implement an orbiting camera can be rotated around the x and the y axis. I am using these two functions:
...
1
vote
1
answer
822
views
How to make player rotate towards mouse [duplicate]
I'm making a top down shooter with Three.js and Box2d. I'm displaying all of the graphics in 3d, but all of the physics are done in 2d, so it's sort of like super smash bros in a way.
Anyway, how can ...
4
votes
1
answer
5k
views
Most efficient way to implement delta time
Here's one way to implement delta time:
...
-2
votes
1
answer
1k
views
List of GLSL ES built-in variables
I am writing an article on WebGL and three.js, I'm trying to search all the built-in variables available in the vertex and fragment shader.
I've found many sites mentioning some, for example:
...
0
votes
2
answers
6k
views
what function creates rotation effect in three.js?
which part of the code is responsible for the rotation in this example? Is it the camera or the scene itself?
http://threejs.org/examples/#canvas_camera_orthographic