three.js

Add subdivision to a geometry

穿精又带淫゛_ 提交于 2020-01-03 16:48:24
问题 I'm trying add subdivisions to a sphere like this: http://stemkoski.github.com/Three.js/Subdivision-Cube.html Here's my code: http://jsfiddle.net/mdrorum/HvFLw/ <script src="http://mrdoob.github.com/three.js/build/three.js"></script> <script type="text/javascript"> var camera, scene, renderer; var geometry, material, mesh; var smooth, subdiv, modifier; init(); animate(); function init() { camera = new THREE.PerspectiveCamera( 75, window.innerWidth / window.innerHeight, 1, 10000 ); camera

Change Object parent in Three.js?

怎甘沉沦 提交于 2020-01-03 15:39:28
问题 Is it possible to change the parent of any object? For example: scene.add(Object); Object.Add(OtherObject); OtherObject.parent = scene; // <-- Something like this I just know that I can remove the Object and create it again in the new parent, but I'll hope there's another way. I got some Object that are on a plane, if I click them I want fix them to the camera so I can see all the time in front of the camera. And If I click them Again I wanna set the parent again to the plane. Why did this

Change Object parent in Three.js?

蓝咒 提交于 2020-01-03 15:39:00
问题 Is it possible to change the parent of any object? For example: scene.add(Object); Object.Add(OtherObject); OtherObject.parent = scene; // <-- Something like this I just know that I can remove the Object and create it again in the new parent, but I'll hope there's another way. I got some Object that are on a plane, if I click them I want fix them to the camera so I can see all the time in front of the camera. And If I click them Again I wanna set the parent again to the plane. Why did this

Set an object's absolute rotation around the world axis

人走茶凉 提交于 2020-01-03 08:42:11
问题 Update: Added a jsfiddle to illustrate: JSFiddle I have an object ( a cube ) that is placed in the scene. My goal is to be supplied 3 angles which represent an object's orientation in the real world. The angles will be measured against real-world X, Y and Z axis. What I am failing (miserably) is how to give an object these angles and then as the data changes, set the object to receive a new triplet of angles. What I seem to be finding is that when I set an initial set of angles, all is good,

THREE.js raycasting very slow against single > 500k poly (faces) object, line intersection with globe

蹲街弑〆低调 提交于 2020-01-03 08:42:10
问题 in my project I have a player walk around a globe. The globe is not just a sphere, it has mountains and valleys, so I need the players z position to change. For this I'm raycasting a single ray from player's position against a single object (the globe) and I get the point they intersect and change players position accordingly. I'm only raycasting when the player moves, not on every frame. For a complex object it takes forever. It takes ~200ms for an object with ~1m polys (faces) (1024x512

JSONLoader not displaying model

夙愿已清 提交于 2020-01-03 05:49:05
问题 So I've taken a class in Three.js only to find out I haven't been educated in how to load models. I found a model on Turbosquid.com <http://storage2.turbosquid.com/Download/index.php?ID=717563_8377529> , and successfully converted it to JSON using convert_obj_three.py. I've surfed for good code and found a few decent examples on stackoverflow, but for some reason when I run it in chrome, I get no model. <html> <head></head> <body> <script src="http://threejs.org/build/three.js"></script>

How to detect what side of a cube is clicked

♀尐吖头ヾ 提交于 2020-01-03 05:12:33
问题 Right now, I am trying to make a navigational menu, but to do this, I need to detect what side is clicked by the user. Is there any way to do this with raycasting, or if not, any other way? Here is my code if you need it: CodePen Link The short version is here var geometry = new THREE.BoxGeometry(200, 200, 200); var material = new THREE.MeshLambertMaterial( { color: 65535, morphTargets: true }); for (var i = 0; i < 8; i++) { var vertices = []; for (var v = 0; v < geometry.vertices.length; v++

Rotate text to face user when camera is rotated

送分小仙女□ 提交于 2020-01-03 04:54:10
问题 If you take a look at my fiddle: http://jsfiddle.net/jmg157/Y35cQ/1/ You'll see I have grid labels on the cube axes. What I'd like to do is whenever the user rotates around the cube, have the text rotate as well so that the numbers are always facing the user. I tried things like xMarks.rotation = camera.rotation , where xMarks are the text objects, but no success. Any suggestions would be greatly appreciated. 回答1: three.js is now quaternion-based. To make the text created with THREE

how to achieve a cross fade between different cameras / scenes in three.js?

我的未来我决定 提交于 2020-01-03 03:25:15
问题 Is it possible, and if so, what is the best way to achieve the following effect in three.js: I am displaying scene S1 as viewed from camera C1and from there: crossfade to scene S2 as viewed from camera C2, or crossfade to scene S1 as seen from camera C3 Any assistance helping me think about this will be greatly appreciated! 回答1: Something like this is pretty easy: Use 2 rendertargets to draw the different scenes from the different cameras Use both rendertargets with this blend shader https:/

A-Frame: How do you add multiple meshes to an entity with setObject3D?

浪子不回头ぞ 提交于 2020-01-03 03:03:07
问题 With A-Frames tags, one can add multiple components as children to an entity: <a-scene> <a-entity> <a-box>...</a-box> <a-box>...</a-box> </a-entity> <a-scene> How would you duplicate this in a registered component with the setObject3D method? CodePen: https://codepen.io/ubermario/pen/wrwjVG 回答1: Yup, you can name the object3D however you want. The mesh word is just sort of commonly accepted for meshes and used by geometry/material components. To clarify: setObject3D('mesh') setObject3D(