three.js

Three.JS: Get position of rotated object

情到浓时终转凉″ 提交于 2019-12-23 05:17:21
问题 In Three.JS, I am capable of rotating an object about its origin. If I were to do this with a line, for instance, the line rotates, but the positions of its vertices are not updated with their new locations. Is there some way to apply the rotation matrix to the position of the vertices to find the new position of the point? Say I rotate a line with points at (0,0,0) and (0,100,100) by 45° on the x, 20° on the y, and 100° on the z. How would I go about finding the actual position of the

Update Collada (.dae ) file code from A-Frame or JS

久未见 提交于 2019-12-23 05:16:14
问题 I load collada (.dae) file in A-Frame. Its loaded fine. But now i have to update that file from user input like color, etc.. How to update the code inside the .dae file from html, js or A-Frame This is the Loaded A Frame code : <a-scene> <a-assets> <a-asset-item id="box" src="box.dae"></a-asset-item> </a-assets> <a-entity id="collada" collada-model="#box"></a-entity> <a-entity id="cmr" position="0 1 5" rotation="0 0 0"> <a-camera> <a-cursor color="#2E3A87" > </a-camera> </a-entity> </a-scene>

Converting a Shadertoy into my own local Three.js sandbox

耗尽温柔 提交于 2019-12-23 05:05:57
问题 I'm making a local shader sandbox based on a Shadertoy by lennyjpg with the help of these two SO Q&A's (one, two). I'm converting the Shadertoy to use Three.js as a sandbox for a larger project that uses Three.js. However, while there are no errors displaying, I'm not seeing the expected result. Only the camera helper displays. What am I doing wrong here? (See the runnable snippet below.) Thanks in advance! var SCREEN_WIDTH = window.innerWidth; var SCREEN_HEIGHT = window.innerHeight; var

Render 100k sprites with 0.1 opacity, transparent maps and smooth antialiasing

久未见 提交于 2019-12-23 04:52:32
问题 I have the following setup (only relevant bits of code): Renderer renderer = new THREE.WebGLRenderer({ antialias: true, alpha: true, canvas: canvas }); Textures dot: THREE.ImageUtils.loadTexture('./assets/images/dot.png') Material let material = new THREE.PointsMaterial({ size: size, sizeAttenuation: true, color: color, map: textures.dot, // alphaMap: textures.dotAlpha, blending: THREE.NormalBlending, // THREE.MultiplyBlending transparent: true, alphaTest: 0.1, opacity: 0.3 }); Point cloud

Three.js Water Shaders migration from r48 to r52

孤人 提交于 2019-12-23 04:48:34
问题 I am developing a chemistry simulation project. I was searching for water simulation. I have extracted code from this example http://waterstretch.ecoulon.com/ It uses Three.js r48 and the extracted code works perfect. Now I have tried to upgrade the working code of my project to Three.js r52. The example shows black screen WITHOUT ANY CONSOLE ERRORS :O I have tested Three.js r49 and newer but not helped and I can't find any helpful information in the change log. https://github.com/mrdoob

Can i use fabric.js and three.js in the same canvas?

时光怂恿深爱的人放手 提交于 2019-12-23 04:45:07
问题 Is it possible to use three.js for 3d drawing and add to fabric.js for 2d drawing to the same canvas? I just like the way fabric.js handles manipulation and would like to make use of it. Before I start to experiment, I'm wondering if any one has tried this? Is it possible? 回答1: An alternative approach is to use FabricJS with an off-screen canvas, then use that canvas as a texture (image) source for your on-screen WebGL/tree.js canvas and the polygon you are rendering there. Is it possible to

Error in OBJLoader of THREE.JS lilbrary

早过忘川 提交于 2019-12-23 04:38:11
问题 I'm trying to follow the examples in that book in order to learn the Three.js library "Learning Three.js: The JavaScript 3D Library for WebGL" and I also have the example sets downloaded from that github link https://github.com/josdirksen/learning-threejs. Most of the examples are runing fine but some of them raises an error especially the one which loads Wavefront objects with OBJLoader.js file. It raises the following error in run time Uncaught TypeError: undefined is not a function VM12649

How fast is the jscript garbage collector? Three.js Matrix Rotations

主宰稳场 提交于 2019-12-23 04:35:29
问题 I am using these two functions in order to rotate my objects in my three.js scenes // Rotate an object around an arbitrary axis in object space function rotateAroundObjectAxis(object, axis, radians) { rotationMatrix = new THREE.Matrix4(); rotationMatrix.makeRotationAxis(axis.normalize(), radians); object.matrix.multiplySelf(rotationMatrix); // post-multiply object.rotation.getRotationFromMatrix(object.matrix, object.scale); delete rotationMatrix; } // Rotate an object around an arbitrary axis

Creating clickable polygons three.js

落花浮王杯 提交于 2019-12-23 04:32:27
问题 I'm using three.js for creating clickable polygons, when i create polygon in this way var geo = new THREE.Geometry(); geo.vertices.push(new THREE.Vector3(0.3, 0.3, 0.5)); geo.vertices.push(new THREE.Vector3(0.3, 0.4, 0.5)); geo.vertices.push(new THREE.Vector3(0.4, 0.4, 0.5)); geo.vertices.push(new THREE.Vector3(0.6, 0.35, 0.5)); geo.vertices.push(new THREE.Vector3(0.4, 0.3, 0.5)); for (var face = 0 ; face < 5 - 2; face++) { // this makes a triangle fan, from the first +Y point around geo

Calculating frame and aspect ratio guides to match cameras

生来就可爱ヽ(ⅴ<●) 提交于 2019-12-23 04:24:43
问题 I'm trying to visualize film camera crop and aspect ratio in Three.js. Please bear with me, it's a math problem, and I can't describe it in lesser words... Instead of just using CameraHelper, I'm using three slightly modified CameraHelper objects for each camera. The helper lines can be seen when looking at a camera (cone), or when looking through a camera, the helper lines effectively create guide lines for the current camera. Frame helper (bluish one with sides rendered). This is configured