threejs


WebGL and Three JS dedicated forum. Here we can discuss about Three JS 3D library.
 
HomeCalendarGalleryFAQSearchRegisterLog in

Share | 
 

 Function geometry addon for three.js

View previous topic View next topic Go down 
AuthorMessage
hofk

avatar

Posts : 2
Points : 6
Reputation : 0
Join date : 2017-03-23
Location : Germany

PostSubject: Function geometry addon for three.js   Thu Mar 23, 2017 8:43 pm

Inspired by
https://threejs.org/examples/js/ParametricGeometries.js ( @author zz85 ),
I have programmed an addon for three.js (named THREEf http://sandbox.threejs.hofk.de/THREEf.js  and https://github.com/hofk/THREEf.js ) to produce with only 9 properties, 18 functions and 1 array almost infinite many time-varying geometries:

Code:

geometry =  new THREE.Geometry();
geometry.createMorphGeometry = THREEf.createMorphGeometry; // insert the methode from THREEf.js
geometry.createMorphGeometry(); // apply the methode ( here without parameters: all default )
 

You can try it there. http://sandbox.threejs.hofk.de/ (BETA, currently only with Firefox)

Basic examples http://sandbox.threejs.hofk.de/examplesTHREEf.html - also other browsers.
A library of forms is in progress. http://sandbox.threejs.hofk.de/formLibrary.pdf

An example:
Code:

geometry.createMorphGeometry({
    radius: 100,
    radiusSegments: 50,
    scaleCircAngle: function ( u, t ) { return 1 / ( 1 + Math.exp( - 12 * ( u - 0.5 ) ) ) },
    moveX: function ( u, v, t ) { return -0.5 * ( 1 + Math.cos( 2 * Math.PI * u ) ) },
    moveZ: function ( u, v, t ) { return -0.12 * Math.sin( 6 * Math.PI * u ) },
    rCircHeight: function ( u, v, t ) { return 0.5 + 0.5 * Math.sqrt( 1 - ( 2 * v - 1 ) * ( 2 * v - 1 ) ) }
});



Note that there is a memory leak when updating material index in function animate() !
But this is also in an very easy example (only three.js) that results in a fairly slow memory allocation.
See under
http://threejs.hofk.de/memoryleak/memoryLeak.html

I have looked in three.js but this is really great and I have too little knowledge to recognize something there. I don't know how to fix the memory leak. scratch

The memory leak is stuffed!
I just had to change a single command instead geometry.elementsNeedUpdate = true; now geometry.groupsNeedUpdate = true; and the sandbox has no memory leak anymore.
My answer to my question:
http://stackoverflow.com/questions/42910083/memory-leak-when-updating-material-index-in-function-animate-three-js-r84/43179478#43179478  Wink

---> https://discourse.threejs.org/t/addon-produces-almost-infinite-many-time-varying-geometries-with-functions/262
Back to top Go down
http://sandbox.threejs.hofk.de/
 
Function geometry addon for three.js
View previous topic View next topic Back to top 
Page 1 of 1
 Similar topics
-
» Theory Of Everything (Geometry Dash)
» AMS Super V8 Addon v1.0 - released 18.12.2016
» Notes of gold/roll raids in 3.0.5 CWOW
» For those who can't wait : Chinese client+Delocalizator
» Boz sprintcars 2010 Coming to Tuesdays

Permissions in this forum:You cannot reply to topics in this forum
threejs :: Web programming :: Javascript Libraries-
Jump to: