three.js

Embed widgets with pythreejs: wrong perspective and camera look-at

≯℡__Kan透↙ 提交于 2020-01-14 06:36:26
问题 The bounty expires in 3 days . Answers to this question are eligible for a +50 reputation bounty. Peque wants to draw more attention to this question. I am using pythreejs to visualize some 3D models. When visualizing the models on a Jupyter notebook, everything works as expected. But when trying to embed the widget in an HTML document, I am facing two problems: It seems the camera, on load, is looking at (0, 0, 0), not as expected, and once you interact with the widget, the camera will "jump

Raycasting after dynamically changing Mesh in Three.js

北慕城南 提交于 2020-01-14 05:37:13
问题 I have a mesh cloned from another mesh. But after cloning, I translate and rotate it. And do a ray-casting a point to it but it is not working as expected. It is keep intersecting with the original position before translation and rotation. Sample code is as below const raycaster = THREE.Raycaster() const proposedModel = model.clone() proposedModel.translateX(1) proposedModel.translateY(1) proposedModel.translateZ(1) const q = new THREE.Quaternion( -0.847, -0.002, -0.505, 0.168 ) proposedModel

Mapbox: Get loaded tile coordinates? [closed]

☆樱花仙子☆ 提交于 2020-01-14 04:15:09
问题 Closed . This question needs to be more focused. It is not currently accepting answers. Want to improve this question? Update the question so it focuses on one problem only by editing this post. Closed 2 years ago . I'd like to load 3D terrain onto my mapbox map, like Peter's example, however I'm hoping to find a much simpler implementation. My idea is to use mapbox's data event to get each loaded tile and simply load a three.js mesh above it.. but I need to figure out how to calculate each

How to extrude different shapes on the same spline without interruptions

为君一笑 提交于 2020-01-14 03:56:27
问题 I'm writing a scene with meshes generated with ExtrudeGeometry from different shapes extruded along a SplineCurve3 used as extrudePath in ExtrudeGeometry 's settings. For now, to do that, I split the spline in many segments, but there is a problem, as you can see in the attached picture: I want the starting point of second mesh (star) to be perpendicular to the end point of previous mesh (circle). Here my jsfiddle. Now as you can see in the picture and in the demo, the star does not start

How to add fog to texture in shader (THREE.JS R76)

情到浓时终转凉″ 提交于 2020-01-14 03:55:35
问题 So firstly, I am aware of this post: ShaderMaterial fog parameter does not work My question is a bit different... I am trying to apply the fog in my three.js scene to a shader thats using a TEXTURE and I can't figure it out. My best guess as to what is supposed to go into the frag was: resultingColor = mix(texture2D(glowTexture, vUv), fogColor, fogFactor); This works when the texture2D part is just a normal color but as a texture it doesn't render. THREE.glowShader = { vertexShader: [ `

Three.js: how to apply rotation matrix to some base object's state?

假如想象 提交于 2020-01-14 03:49:07
问题 In this question Three.js: chaotic mesh rotation after applyMatrix I asked about an issue. Now I'll try to look at the issue from another end: to describe the desired behaviour of the program. I have an array of rotation matrices for each time point of object's state. Each rotation matrix represents a difference between some initial object state (point zero) and the desired state. User should be able at any time select any desired rotation matrix from the array. How to implement the correct

Showing Coordinate Lines of a 3D earth

血红的双手。 提交于 2020-01-14 03:21:08
问题 Here is a 3D earth made based on Three js I want to find the location of Longitude and Latitude of the currently clicked location and show the coordinate lines What should be the strategy to define those diversion lines? How could I map my texture to it's correct equivalent Longitude/Latitude? Edit 1 : My question in a simpler form: How can I get the x, y of the pattern image which was clicked inside the sphere? 来源: https://stackoverflow.com/questions/10431632/showing-coordinate-lines-of-a-3d

extending lambert material, opacity not working

我的未来我决定 提交于 2020-01-14 02:59:09
问题 i would like to create a custom material which extends the lambert shader but setting the mesh translucent doesn't work. var shaders = { lambert : THREE.ShaderLib['lambert'] } materials.mylambert = function(parameters){ var vertexShader = shaders.mylambert.vertexShader , fragmentShader = shaders.mylambert.fragmentShader , uniforms = shaders.mylambert.uniforms , attributes = {} var material = new THREE.ShaderMaterial( { vertexShader: vertexShader , fragmentShader: fragmentShader , uniforms:

(Three.js) Custom Mesh UV Display Texture Properly

末鹿安然 提交于 2020-01-14 01:34:05
问题 I have created a custom Geometry function for Three.js, based on the Plane Geometry. Everything works fine, except that I don't know how to make the UV display correctly. I use 4 triangles per Square, while the THREE.PlaneGeometry is only using 2 triangles per square. The code for PlaneGeometry UV's looks like this: var uva = new THREE.Vector2( ix / gridX, 1 - iz / gridZ ); var uvb = new THREE.Vector2( ix / gridX, 1 - ( iz + 1 ) / gridZ ); var uvc = new THREE.Vector2( ( ix + 1 ) / gridX, 1 -

Cannot add to scene after rendering THREE.js

℡╲_俬逩灬. 提交于 2020-01-13 23:59:49
问题 See example: http://jsfiddle.net/pehrlich/nm1tzLLm/2/ In newer versions of THREE.js, if I call render before adding additional objects to the scene, they will never be visible, even with additional calls to render. Is this expected behavior? See full code: var cube, cube2, geometry, light, material, renderer; window.scene = new THREE.Scene(); window.camera = new THREE.PerspectiveCamera(75, window.innerWidth / window.innerHeight, 0.1, 10000); renderer = new THREE.WebGLRenderer(); renderer