three.js

ThreeJS - Intersection of a line and sphere

不打扰是莪最后的温柔 提交于 2019-12-24 05:40:19
问题 I have two objects on my scene: a red line and a sphere. While camera rotating/zooming/moving, I need to check the following: Does the line intersects with the sphere looking from the current position of the camera (please see images below)? Please use this JS fiddle that creates the scene on the images. I know how to find the intersection between the current mouse position and objects on the scene (just like this example shows). But how to do this in my case? JS Fiddle Code: /** * PREPARE

Loading OBJ model from local machine with Three.js?

北城以北 提交于 2019-12-24 05:13:13
问题 I'm trying to load an OBJ model with Three.js. At first I tried this: var loader = new THREE.OBJLoader( ); loader.load( 'chair.obj', function ( object ) { scene.add( object ); }); But I got an error saying that cross origin request are only supported in HTTP. I looked on the internet for help, found this page: https://github.com/mrdoob/three.js/wiki/How-to-run-things-locally and tried to run Chrome from cmd line: chrome --allow-file-access-from-files Still nothing. Finally I tried using

three.js perspectivecamera current angle in degrees

 ̄綄美尐妖づ 提交于 2019-12-24 05:13:12
问题 For a project I use a PerspectiveCamera which gets rotated using the vrcontrols from r69. At one point I require the current viewing angle degrees (horizontal & vertical degrees at which direction the camera is looking at). How would I acquire those? 回答1: What you want are also called euler angles. Three.js eulers have a built in function to set them from a quaternion. var quat = new THREE.Quaternion(); var euler = new THREE.Euler(); euler.setFromQuaternion(quat); alert('X in degrees: ' +

Is clipping done automatically in Three.js?

我只是一个虾纸丫 提交于 2019-12-24 04:51:36
问题 So, I was reading about clipping in this Wikipedia article. It seems pretty essential to any and all games, so, do I have to do it, or is it done automatically by Three.js, or even WebGL? Thanks! 回答1: You can pass values for the near and far clipping planes to your camera object: var camera = new THREE.PerspectiveCamera( fov, aspect, near, far ); near and far can contain values for example near = 0.1 and far = 10000 so an object which lies between these values will be rendered. EDIT: near and

Can you use raw WebGL Textures with three.js

≡放荡痞女 提交于 2019-12-24 04:20:58
问题 I have a fairly complicated architecture where I am doing most of my stuff in Three.JS but I also have a special renderer that renders directly to a raw WebGL texture. Is it possible to use this WebGL texture in a three.js "Texture"? It looks like the Three.JS texture class is just a container for an image or video or canvas, and somewhere deep in the guts of three.js it will upload that to a real webgl texture. How can I just have Three.js render my WebGL texture onto a mesh? 回答1: @Brendan's

Getting 'PERFORMANCE WARNING' messages in Chrome

南楼画角 提交于 2019-12-24 04:10:09
问题 I just recently starting getting these messages, and was wondering if anyone has seen them, or know what may be causing them. I'm using Three.js with Chrome version '21.0.1180.57' on MacOS. I don't get these messages with Safari or FireFox. PERFORMANCE WARNING: Attribute 0 is disabled. This has signficant performance penalty WebGL: too many errors, no more errors will be reported to the console for this context. 回答1: Same message on Firefox is : "Error: WebGL: Drawing without vertex attrib 0

Web viewer for point cloud (PLY) file without faces

淺唱寂寞╮ 提交于 2019-12-24 04:06:07
问题 I am trying Three.Js for web viewing of PLY files using this example as reference. My PLY file is just Point Cloud with only vertices and NO faces. It seems that ThreeJs needs faces as well for creating geometry for rendering. What is the alternate to ThreeJS or how do I display these files online? --UPDATE-- Based on this SO answer, I converted the PLY file into a JSON format which looks like var data = [ "-4.3529 -5.92232 21.9669", // x, y, z "108 99 74", // r, g, b "-4.25362 -5.98312 22

Three.js: forcing loop to unroll

自闭症网瘾萝莉.ら 提交于 2019-12-24 03:48:15
问题 When using normally three.js I get this error at Firebug: gl.getProgramInfoLog() (54,6): warning X3557: loop only executes for 1 iteration(s), forcing loop to unroll Even all the rest looks like working properly and not giving any problem. Trying with some examples from the net I see the same error message, you can find it for example at some examples in the net like this one When it uses three.min.js appears at line: 537 and with three.js it appears at line: 25909. 回答1: Which version of

How to Hide/Show Objects using Three.js release 54?

不打扰是莪最后的温柔 提交于 2019-12-24 03:34:07
问题 I've asked this question as a part of Huge question but was recommended to ask in parts. Here comes the part of my previous question. My previous question was: Here I've been using Three.js Release 50 and able to show/hide the objects (In my application, it is a mesh child) with the help of: THREE.SceneUtils.traverseHierarchy(mesh,function(child){ var z = document.getElementById("cameras").selectedIndex*5 -10; if (z === -10){ child.visible = true; } else if (child.position.z !== z){ child

Blender 2.7X Exporter to .json For three.js JSONLoader

匆匆过客 提交于 2019-12-24 03:16:11
问题 I am trying to export from Blender into Three.js using the JSON route (for animations) Three.js version r71 Blender version 2.74 The current Blender exporter successfully exports a .json file NOT a .js file. All examples within the r71 folders import .js files only. Does anyone have any working examples on how to import a .json file that has been exported from Blender 2.7x? If not, I'll have to go back to Blender 2.69 and use the commonly documented .js import. 回答1: I might be wrong but .json