three.js

Three.js mouse picking object

 ̄綄美尐妖づ 提交于 2019-12-18 18:40:04
问题 So i found a lot of tutorials on how to use mouse picking on default objects available in Threejs itself, but is it possible to use mouse picking on imported models like a .obj file and displaying a sphere at the exact position where the user clicks the model? If so, can someone give me a tutorial or at least an example with source code so i can use it. I prefer a tutorial, because thats a better way to learn it. ;) EDIT: So i got mouse picking working for the model! But now i want to show a

3D Boolean operations with Three CSG

半腔热情 提交于 2019-12-18 18:31:16
问题 Following the example here: http://learningthreejs.com/blog/2011/12/10/constructive-solid-geometry-with-csg-js/ And using Three.js with https://github.com/chandlerprall/ThreeCSG, I'm trying to do 3D boolean operations on nodes from the model. Like for example if I have a wall with a window, I want to do invert() on that to get just the window. I have a function that returns all the vertices of the polygons of a node, here's an example of vertices of an object without holes https://pastebin

Scaling a Three.js geometry only up

≡放荡痞女 提交于 2019-12-18 17:55:47
问题 I'm trying to scale the geometries y-axis. This made my cube scale both up and down. I think mesh.transformY works to animate the cube up half of the scaling value. This would make it look like the cube just scaled upwards. Are there other solutions for this? var geometry = new THREE.BoxGeometry(1, 1, 1); var mesh = new THREE.Mesh(geometry, new THREE.MeshPhongMaterial({ color: 0xffffff })); mesh.position.set(0, 2, 0); mesh.scale.set(0.98, 0.95, 0.992); mesh.castShadow = true; scene.add(mesh);

Three.js - Using multiple textures in a single PointCloud

醉酒当歌 提交于 2019-12-18 17:26:31
问题 I'm trying to use multiple textures in a single PointCloud using a ShaderMaterial. I'm passing a texture array to the shader along with texture index attributes and selecting the appropriate texture to use in the fragment shader. Relevant Setup Code: var particleCount = 100; var uniforms = { textures: { type: 'tv', value: this.getTextures() } }; var attributes = { texIndex: { type: 'f', value: [] }, color: { type: 'c', value: [] }, }; var material = new THREE.ShaderMaterial({ uniforms:

Three.js - Using multiple textures in a single PointCloud

狂风中的少年 提交于 2019-12-18 17:26:22
问题 I'm trying to use multiple textures in a single PointCloud using a ShaderMaterial. I'm passing a texture array to the shader along with texture index attributes and selecting the appropriate texture to use in the fragment shader. Relevant Setup Code: var particleCount = 100; var uniforms = { textures: { type: 'tv', value: this.getTextures() } }; var attributes = { texIndex: { type: 'f', value: [] }, color: { type: 'c', value: [] }, }; var material = new THREE.ShaderMaterial({ uniforms:

billboarding vertices in the vertex shader

前提是你 提交于 2019-12-18 16:58:36
问题 Code demonstrating issue (comment/uncomment out the gl_Position lines in the vertex shader) var scene; var book; var shaderMaterial; var renderer = new THREE.WebGLRenderer({ antialias: true }); renderer.setClearColor(0x000000); document.body.appendChild(renderer.domElement); var camera = new THREE.PerspectiveCamera(55, 1, 0.1, 40000); window.onresize = function () { renderer.setSize(window.innerWidth, window.innerHeight); camera.aspect = window.innerWidth / window.innerHeight; camera

three.js transparent maps issue

大兔子大兔子 提交于 2019-12-18 15:54:12
问题 I'm creating loads of particles (80.000 to be exact) and I have set a transparent map, though, not all particles are transparent. I'm using a transparent PNG image: (it's barely visible but it's there alright) as the material map, though it shows a black background as seen here: If you look closely, some particles blend together well (no overlapping black edges) though some do not. Could it be because there are so many overlapping transparent objects or shouldn't this be an issue? Here's the

Reset camera using OrbitControls.js

好久不见. 提交于 2019-12-18 15:06:48
问题 I'm using OrbitControls.js to allow mouse interaction. I'm adding a button into the scene that allows to "reset" the camera to it's state where it was before any mouse interactions. I have tried to save camera.position and camera.rotation before any interactions: camera_initial_position = camera.position; camera_initial_rotation = camera.rotation; And after the "reset" button is pressed, the initial position and rotation is set: camera.position = camera_initial_position; camera.rotation =

Exporting a simple model with texture from Blender to three.js

夙愿已清 提交于 2019-12-18 15:00:32
问题 Note: I want to avoid modifying the model in the javascript code and do all the model design inside Blender. Note #2: While this question is long, it is actually a basic problem (title says it all). The below is "walk-through" to the problem. I am trying export Blender models to threejs.org as DAE model but have problem with models with texture (I have tried JSON and OBJ+MTL format too): To make things simpler, here are the steps I perform (and fail) to add texture to simple "Startup file"

How to change width of CubeGeometry with Three.js?

你离开我真会死。 提交于 2019-12-18 14:47:15
问题 I have a cube geometry and a mesh, and i don't know how to change the width (or height... i can change x, y and z though). Here's a snippet of what i have right now: geometry = new THREE.CubeGeometry( 200, 200, 200 ); material = new THREE.MeshBasicMaterial( { color: 0xff0000, wireframe: true } ); mesh = new THREE.Mesh( geometry, material ); // WebGL renderer here function render(){ mesh.rotation.x += 0.01; mesh.rotation.y += 0.02; renderer.render( scene, camera ); } function changeStuff(){