three.js

render OBJ file using THREE.OBJLoader

二次信任 提交于 2019-12-18 13:22:18
问题 How to render OBJ file using THREE.OBJLoader method, I've a sample OBJ format but it won't render anything nor I see error in chrome dev tool 回答1: Check out the OBJLoader usage sample at https://github.com/mrdoob/three.js/blob/master/examples/webgl_loader_obj.html#L75 (In action http://mrdoob.github.com/three.js/examples/webgl_loader_obj.html ) var loader = new THREE.OBJLoader(); loader.load( objURL, function ( object ) { scene.add( object ); } ); 回答2: Try adding a light into the scene or

Three.js: How to Update BufferGeometry Vertices

蓝咒 提交于 2019-12-18 13:02:47
问题 I just have to update a line that have 2 vertices, and i trying to use these things above that are changed in r58, but the lines cant move, i just made this to initialize: var geometry = new THREE.BufferGeometry(); geometry.addAttribute('position', Float32Array, 2, 3); geometry.dynamic = true; var position = geometry.attributes.position; position.needsUpdate = true; var p = position.array; var i = 0; p[i++] = vertex1.position.x; p[i++] = vertex1.position.y; p[i++] = vertex1.position.z; p[i++]

using three.js JSONLoader

≡放荡痞女 提交于 2019-12-18 12:48:06
问题 Just can't see models imported into three.js scene. The geometry looks fine but the model isn't displaying no matter what material I apply to it. I'm new to WebGL so it's hard for me to diagnose, but my guess is that something is going wrong during the JSONLoader callback. Thanks for all help. var camera, scene, renderer, mesh, loader; init(); animate(); function init() { camera = new THREE.PerspectiveCamera( 75, window.innerWidth / window.innerHeight, 1, 10000 ); camera.position.z = 1000;

How to animate the camera in three.js to look at an object?

心不动则不痛 提交于 2019-12-18 12:42:06
问题 In Three.js, I would like to have the camera looking at an object in the scene, and when I click on another object, to have the camera rotate smoothly to look at the new object. (i.e animate the rotation of the camera). I´ve checked in SO and this is the most similar question : Three.js How to use quaternion to rotate camera I've also tried modifying the code in this website and I manage to get something like this http://jsfiddle.net/F7Bh3/ var quat0 = mesh2.quaternion; var eye = mesh2

three.js 3d models as hyperlink

被刻印的时光 ゝ 提交于 2019-12-18 12:37:47
问题 I'm trying to figure out a way to use a 3D model created with Three.js as a hyperlink. In other words, if I click on a cube (a THREE.CubeGeometry), I want another page to open. For instance, in this threejs.org example, how can I change it, so that instead of making little dots on the boxes, clicking on the boxes would open another page, like a hyperlink? 回答1: One way to achieve it will be to associate custom userData(URL) with every cube while its being created. So here is a sample code how

Three.js polygon triangulation fails in pseudo duplicate points

拟墨画扇 提交于 2019-12-18 12:35:07
问题 In three.js there is a function triangulateShape() . Now I encountered a failure to triangulate polygons that are simplified using Javascript Clipper. Simplifying in Clipper is done using Unioning. Wikipedia article determines unioning as finding the simple polygon or polygons containing the area inside either of two simple polygons. The same article says that in simple polygon "exactly two edges meet at each vertex" and also determines a weakly simple polygon, where edges can meet, but says

Best options for animation in THREE.JS

江枫思渺然 提交于 2019-12-18 12:34:38
问题 What is the best options for animations (texture animations, moving objects, hiding/showing object,...) in three.js ? Do you use extra lib. such as tween.js or something else ? Thanks. 回答1: Tween.js is the popular way to go... check the article at: http://learningthreejs.com/blog/2011/08/17/tweenjs-for-smooth-animation/ 回答2: Many agree that you need RequestAnimationFrame to manage browser performance. Three.js even includes a cross-browser shim for it. I would also recommend Frame.js for

three.js TypeError: Cannot read property 'center' of undefined

故事扮演 提交于 2019-12-18 12:32:38
问题 I am trying import OBJ (tried different) on server with node.js and three.js - I got this Error after parse file. This is current code how I import geometry: var loader = new THREE.OBJLoader(); loader.load(modelPath, function (geometryObj) { var materialObj = new THREE.MeshBasicMaterial( { vertexColors: THREE.FaceColors, overdraw: 0.5 } ); mesh = new THREE.Mesh(geometryObj, materialObj); scene.add(mesh); Here is call stack: this.center.copy( sphere.center ); TypeError: Cannot read property

three.js TypeError: Cannot read property 'center' of undefined

本秂侑毒 提交于 2019-12-18 12:30:03
问题 I am trying import OBJ (tried different) on server with node.js and three.js - I got this Error after parse file. This is current code how I import geometry: var loader = new THREE.OBJLoader(); loader.load(modelPath, function (geometryObj) { var materialObj = new THREE.MeshBasicMaterial( { vertexColors: THREE.FaceColors, overdraw: 0.5 } ); mesh = new THREE.Mesh(geometryObj, materialObj); scene.add(mesh); Here is call stack: this.center.copy( sphere.center ); TypeError: Cannot read property

Quality of Three.js shadow in Chrome/MacOS?

跟風遠走 提交于 2019-12-18 12:24:04
问题 I am experimenting with a simple Three.js scene (novice in this area). I am using the Three.js WebGLRenderer and have set up a plane, a cube that casts shadows and a directional light source. The result is shown in the image. How do I: 1. Increase the quality of the shadow rendering? 2. Get rid of the jagged edges? I have set the antialiasing to true but it does not seem to help in any browser ... renderer = new THREE.WebGLRenderer({ antialias: true}); 回答1: You can do two things. First set a