learning-threejs | Code repository for the examples from the Packt book | Learning library
kandi X-RAY | learning-threejs Summary
kandi X-RAY | learning-threejs Summary
Code repository for the examples from the Packt book "Learning Threejs"
Support
Quality
Security
License
Reuse
Top functions reviewed by kandi - BETA
Currently covering the most popular Java, JavaScript and Python libraries. See a Sample of learning-threejs
learning-threejs Key Features
learning-threejs Examples and Code Snippets
Community Discussions
Trending Discussions on learning-threejs
QUESTION
I'm trying to use the wavefront-obj
package to read an OBJ file. Here is an example of OBJ file.
After downloading this file, I do
...ANSWER
Answered 2018-May-02 at 13:50Looks like your OBJ file has some directives that wavefront-obj doesn't recognize. You can see in the source that wavefront-obj only understands the #
, v
, vt
, vn
, and f
directives. Your file kicks off with mtllib
and o
directives, and appears to have several others not in the supported list.
A priori, I would therefore expect a Left
result instead of a Right
as you're getting. But the wavefront-obj author fell into a common parser-combinator pitfall: their top-level parser does not end with eof
. So it sees the first two comment lines, then none of its parsers match the next line but it doesn't mind not being at the end of the file, so it reports successfully parsing an empty list of directives.
Between this and a few other things I noticed while sourcediving (comments are almost certainly not treated correctly, failure to exploit the predictable structure of directives and therefore code duplication), I expect you're going to have to do quite a bit of work if you want this package to work reliably and correctly.
QUESTION
I'm worked with Three.JS before, but not on meshes. I think I am approaching my problem the right way, but I'm not sure.
The Goal
I'm trying to make a 3D blobby object that has specific verticies. The direction of the verticies are fixed, but their radius from center varies. You can imagine it sort of like an audio equalizer, except radial and in 3D.
I'm open to scrapping this approach and taking a totally different one if there's some easier way to do this.
Current Progress
I took this example and cleaned/modified it to my needs. Here's the HTML and JavaScript:
HTML (disco-ball.html
)
ANSWER
Answered 2017-Aug-12 at 14:10Three provides a huge range of options. These are just suggestions, your best bet is to read the Three documentation start point and find what suits you.
A mesh is just a set of 3D points and an array of indexes describing each triangle. Once you have built the mesh you only need to update the verts and let Three update the shader attributes, and the mesh normals
Your questionsQ1. Use Three.Geometry for the mesh.
Q2. As you are building the mesh you can use the curve helpers eg Three.CubicBezierCurve3 or Three.QuadraticBezierCurve3 or maybe your best option Three.SplineCurve
Another option is to use a modifier and create the simple mesh and then let Three subdivide the mesh for you. eg three example webgl modifier subdivision
Though not the fastest solution, if the vert count is low it will do this each frame without any loss of frame rate.
Q3. Using Three.Geometry you can can set the mesh morph targets, an array of vertices.
Another option is to use a modifier, eg three example webgl modifier subdivision
Or you can modify the vertices directly each frame.
QUESTION
I have been trying to find a way to be able to toggle between two scenes in three.js. I am aware that one can load a scene by using sceneLoader / exportScene combo.
Code taken from josdirksen/learning-threejs - loading a scene
...ANSWER
Answered 2017-May-04 at 19:06You can redraw the canvas by removing current scene scene.remove(mesh);
and add create new mesh add into scene
Demo http://jsfiddle.net/sumitridhal/x8t801f5/4/
You can add custom controls using dat.GUI
library.
QUESTION
Is there a way to save and load stringified objects with three.js?
I found this: https://github.com/josdirksen/learning-threejs/blob/master/chapter-08/03-load-save-json-object.html
but they use localstorage
to save and load, which won't work between sessions or different computers.
Is there a way to load files just like the model is loaded? This should be like loading data files for a game.
I run the webgl client with Autodesk viewer locally with http-server
.
ANSWER
Answered 2017-Apr-09 at 20:40If the Object can be written to localstorage it can just as well be exported as a file. You can send them to a server and store them there (maybe something like firebase would be useful here), or you can intiate a "download" directly from the browser. This is explained in Create a file in memory for user to download, not through server.
For loading a file, you can use the file-api, which is shown here: How to open a local disk file with Javascript?.
You just need to replace the localstorage-parts in your example accordingly.
Community Discussions, Code Snippets contain sources that include Stack Exchange Network
Vulnerabilities
No vulnerabilities reported
Install learning-threejs
Support
Reuse Trending Solutions
Find, review, and download reusable Libraries, Code Snippets, Cloud APIs from over 650 million Knowledge Items
Find more librariesStay Updated
Subscribe to our newsletter for trending solutions and developer bootcamps
Share this Page