PHP, HTML & JavaScript- Foro | | | | - Página 1 - |
|  HofK | Auf una heißen Tipp de IF hin, Yo me de tiempo three.js [...] angeschaut. Como [...] (bastante unten) el ersten Resultate. |
| | | | |
| | | | - Página 9 - |
| |  HofK | Soeben Yo el alpha Versión con Skalierung en [...] gebracht. Auf [...] es una Video erneuert.
Für el Halbkugeln Es el Skalierung zwischen Start- y Endfunktion posible.
Für el Kugel klappt el Skalierung aber sólo zwischen el Standardwerten 0 y 1.
Einige Versuche con Start- y Endfunktion führten a siempre unterschiedlichen Fehlpositionierungen. Dabei reagieren konvexe y konkave Características unterschiedlich. Wenn el Abende otra vez länger voluntad, muss Yo como veces tiefer en el matemático Theorie eintauchen. Eventuell hay una simple Solución - muss uno sólo encontrar.
Im Ver código fuente son Teile el Versuche todavía sichtbar, porque Yo como eventuell otra vez ansetze.
Momentan verfügbare Características:
// u azimuth (start: x axis, counterclockwise) // for hemispheres: v polar (start: pole 0, end: equator 1), t time
stretchSouth,//function ( u, v, t )// stretch / compress south hemisphere en -y direction stretchNorth, //function ( u, v, t )// stretch / compress north hemisphere en +y direction endPole,//function ( u, t )// end angle ( to equator, por phi) startPole, //function ( u, t )// start angle ( from south- or north pole, por phi) scalePoleH,//function ( v, t )// scaling hemispheres from pole to equator ( is overwritten by scalePole )
// for sphere: v polar (start: south pole 0, end: north pole 1), t time
rAzimuthPole, //function ( u, v, t )// radius depending on location, equatorGap,//function ( u, t )// gap en relation to the radius squeeze,// function ( u, t )// 0 sphere to 1 flat circle moveX,//function ( u, v, t )// factor for radius, move en x direction moveY,//function ( u, v, t )// factor for radius, move en y direction moveZ,//function ( v, u, t )// factor for radius, move en z direction
endAzimuth,//function ( v, t )// end azimuth angle phi (por theta) startAzimuth,//function ( v, t )// starting azimuth angle phi (por theta) scaleAzimuth,//function ( u, t )// scaling between start and end of azimuth angle ( phi 0 .. 2*PI)
scalePole, //function ( v, t )// scaling between start and end of polar angle (theta -PI/2 .. PI/2 )
materialSouth,//function ( u, v, t )// material South materialNorth,//function ( u, v, t )// material North materialPlane,//function ( u, t )// material of extra south top or north bottom materialWedge,//function ( v, t )// material wedge side |
| | | | |
| |  HofK | En Positionierung el singulären Pole y Mittelpunkte de Boden y Deckel gab lo todavía Fehler en el Zusammenhang con el Anwendung el Características.
Das Problema steckt en el Kugelkoordinaten. El Pole haben zwar eindeutig una Polwinkel theta ( -Pi/2, +Pi/2), aber como ellos normal mittig mentira no cierto Azimut phi.
En Berechnung con Características el u (y así phi) como Argument haben, hay entonces Problemas - unsinnige Ergebnisse.
Deshalb berechne Soy un muy pequeño Kreis a Mittelpunkte (x y z) y nehme el Mittelwert. Dazu muss, auch si sólo algunos Kugelkeile gewünscht voluntad, hay desafortunadamente el vollständige Kreis geschlossen voluntad. Das aumenta el Auswahlabfragen, es pero no a vermeiden.
So hay nun aber auch en solchen Fällen sinnvolle Ergebnisse. Auf [...] Es el Versión aktuell.
El Berechnung geschieht en el Zusammenspiel el Características function setPoleVertex( south_north ) function setVertex( south_north ) function setPlaneCenterVertex( south_north )


 |
| | | | |
| |  HofK | Zwischendurch veces algo Abwechslung.
Auf el Cuestión uno algo hilflosen Anfängers hin [...] Yo mein algo älteres Ejemplo a raycast überarbeitet. El deutschsprachigen Variables Inglés ausgedrückt y el Kommentare wo sinnvoll traducido. Dazu ni Erweiterung para mejor Verständnis des algo schwierigen three.js Sachverhalts: Der Strahl kann dargestellt voluntad. [...] 

El alte Versión restos obtener. [...] 
-----
Weiterhin es THREEf en Revision 87 umgestellt, [...] y enthält nun auch el vertexFaceNumbersHelper
El Änderung a r87 betrifft flatShading:
flatShading =document.getElementById( "flatShading" ).checked;
//shading =flatshading ? THREE.FlatShading : THREE.SmoothShadig; // old //.flatShading: true or false; // three.js r87
Also muy simplemente como Eigenschaft sólo true oder falso.
Beim Test Yo eben festgestellt, dass el Sandbox nun auch en Opera 48.0.2685.50 (PGO) y Chrome 61.0.3163.100 se ejecuta! Hatte Yo no mehr esperado. Kann Yo, el Referencia en Firefox wohl löschen.
Auf GitHub muss THREEf todavía erneuert voluntad. |
| | | | |
| |  HofK | HofK (18.10.2017)
... Wenn el Abende otra vez länger voluntad, muss Yo como veces tiefer en el matemático Theorie eintauchen. Eventuell hay una simple Solución - muss uno sólo encontrar. ...
Lo bedurfte keiner tieferen mathematischen Forschungen. El Solución es bastante simplemente y fast como Yo ya hatte. Wenn uno aber una pequeña Fehler no bemerkt y todos Varianten otra vez con einbaut, sieht lo dunkel de. Irgendwann kam el Erleuchtung , Yo kann bastante hartnäckig ser. El Anzahl el Fehlversuche es no veröffentlichungsfähig - tener auch no mitgezählt.
Und así simplemente es:
In el Función create():
if ( g.scaleH ) {
// ...HSE Hemisphere Start- End
g.scalePoleHSE = function( u, v, t ) { volver 1 - ( g.startPole( u, t ) + ( g.endPole( u, t ) - g.startPole(u, t ) ) * g.scalePoleH( v, t ) ) }
} más {
// uses the decomposed scale function (South and North)
g.scalePoleS = function( u, v, t ) { volver 2 * ( g.startPole( u, t ) + ( g.endPole( u, t ) - g.startPole( u, t ) ) * g.scalePole( v / 2, t ) ) }
g.scalePoleN = function( u, v, t ) { volver 2 * ( 1 - g.endPole( u, t ) + ( g.endPole( u, t ) - g.startPole( u, t ) ) * ( 1 - g.scalePole( 1 - v / 2, t ) ) ) }
}
y luego en morphVertices( time ) el Berechnung des passenden Polwinkels theta .
In el Sandbox [...] ahora verfügbar, y hay [...] momentan aktuelles Video 4.
 |
| | | | |
| |  HofK | Como con indexed BufferGeometry nun wesentliche Sachen en THREEp trabajo, bin Yo esta el sogenannte Dreieckssuppe, non indexed Buffer Geometry anzugehen.
Manch uno stürzt se como Hobby en riesige Puzzle, Yo erzeuge me una systematisches Durcheinander y zwänge lo entonces por JavaScript en el benötigte Orden.

Mein Vorteil ahora en zweiten Geometrie-Variante es, dass Yo anhand el ersten Variante muy rápidamente el Korrektheit prüfen kann. So es todavía no Grafik a sehen, como sólo create() existiert y el Positionen todavía no berechnet son, aber anhand uno Kontrollausgabe sieht uno, dass lo stimmt.

Berechnet voluntad el a una sólo virtuell existierendem vertex gehörenden faces y el jeweilige Ecke a,b oder c des Dreiecks.
Natürlich hay otra vez Indexrechnungen ( fIdx - face index) wo uno se muss.
if ( j === 0 ) {
if( i > bottomS ) { fIdx = uWed * ( i - 1 ) * ( i - 1 ) + w * ( 2 * ( i - 1 ) + 1 ) - uWed * bottomS * bottomS; ... if( i < topS ) { fIdx = uWed * i * i + w * ( 2 * i + 1 ) - uWed * bottomS * bottomS;
----
if ( j > 0 ) {
if( i > bottomS ) { fIdx = uWed * ( i - 1 ) * ( i - 1 ) + w * ( 2 * ( i - 1 ) + 1 ) + 2 * ( j - 1 ) - uWed * bottomS * bottomS; ... if( i < topS ) { fIdx = uWed * i * i + w * ( 2 * i + 1 ) + 2 * j - 1 - uWed * bottomS * bottomS;
----
if ( w === uWed - 1) {
if( i > bottomS ) { fIdx = uWed * ( i - 1 ) * ( i - 1 ) + w * ( 2 * ( i - 1 ) + 1 ) + 2 * ( i - 1 ) - uWed * bottomS * bottomS; ... if( i < topS ) { fIdx = uWed * i * i + w * ( 2 * i + 1 ) + 2 * i - 1 - uWed * bottomS * bottomS;
Mit
fPos = fIdx * 9;
vFace.push( fPos ); vPos.push( fPos + b );
fIdx ++;
voluntad el ermittelten Werte gespeichert. Hier en el Ejemplo el Ecke b (Konstante 3, drei Koordinatenwerte je Punkt) para el Position. Das hängt de el jeweiligen Anfangsecke y el Drehsinn (Süd/ Nord unterschiedlich) de y entspricht el Anordnung en indexedBufferGeometry.
Dazu hay otra vez una "Konstruktionsblatt".
 |
| | | | |
| |  HofK | Zwischendurch veces algo Abwechselung en Indexfummelei.
In einfachem Inglés gestellte Fragen verstehe Yo, y así podría Yo dort [...] 
eventuell algo weiterhelfen.
Dazu Yo sólo una vorhandenes Ejemplo ligeramente verändert y Inglés gemacht.

Lo kann bajo [...] algo más unten (en Knoten) ausprobiert voluntad.
<!doctype html>
<html lang="de">
<head>
<title> picture ball </title>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, user-scalable=no, minimum-scale=1.0, maximum-scale=1.0">
</head>
<body>
<script src="../js/three.min.87.js"></script>
<script src="../js/OrbitControls.js"></script>
<script src="../js/THREEx.WindowResize.js"></script>
<div id="threejs" style="position: absolute; left:0px; top:0px"></div>
</body>
<script>
var boards = [];
var texture = [];
var matTexture = [];
init();
animate();
//...........................
function init() {
scene = new THREE.Scene();
camera = new THREE.PerspectiveCamera( 45, window.innerWidth/ window.innerHeight,1, 300000 );
scene.add( camera );
camera.position.set( 0, 1500, 5000 );
renderer = new THREE.WebGLRenderer( { antialias:true } );
renderer.setSize( window.innerWidth, window.innerHeight );
renderer.setClearColor( 0xeeeeee );
container = document.getElementById('threejs' );
container.appendChild( renderer.domElement );
THREEx.WindowResize( renderer, camera );
controls = new THREE.OrbitControls( camera, renderer.domElement );
texture[0] = new THREE.TextureLoader().load( "waterlily.png" );
texture[1] = new THREE.TextureLoader().load( "dahlia.jpg" );
texture[2] = new THREE.TextureLoader().load( "petunia.jpg" );
texture[3] = new THREE.TextureLoader().load( "frog.jpg" );
for (var z = 0; z < 4; z++) {
matTexture[z] = new THREE.MeshBasicMaterial( { color:0xffdd99, map: texture[z], transparent:true, opacity:0.8, wireframe:falso} );
}
// ball
materialSph = new THREE.MeshBasicMaterial( { color: 0x0099dd, transparent: true, opacity: 0.8, wireframe:falso } );
sphGeo = new THREE.SphereGeometry(1200, 8, 8);
sphere = new THREE.Mesh( sphGeo, materialSph );
scene.add( sphere );
// board for some things
materialBoard = new THREE.MeshBasicMaterial({color:0xdddddd, transparent:true, opacity:0.4, wireframe: true });
boardGeo = new THREE.PlaneGeometry(500,500);
picGeo = new THREE.PlaneGeometry( 200, 200 );
for (var i = 0; i < sphGeo.vertices.length; i++) {
board = new THREE.Mesh( boardGeo, materialBoard );// board for pictures etc.
pic = new THREE.Mesh( picGeo, matTexture[ i % 4 ] );
board.add( pic ) ;// add picture to the board
pic.position.x = -70;// position on the board
pic.position.y = 120;
boards.push( board );
scene.add( boards[ i ] );
boards[ i ].position.set( 1.3 * sphGeo.vertices[ i ].x , 1.3 * sphGeo.vertices[ i ].y, 1.3 * sphGeo.vertices[ i ].z );
}
}
function animate() {
requestAnimationFrame( animate );
for( var n = 0; n < boards.length; n ++ ) {
boards[ n ].lookAt( camera.position );
// or see https://discourse.threejs.org/t/add-marker-to-rotating-globe-object-help/1116/6
// boards[ n ].quaternion.copy( camera.quaternion );
}
renderer.render( scene, camera );
controls.update();
}
</script>
</html>
|
| | | | |
| |  HofK | Kleiner Nachschlag a discourse.threejs.org Ayuda (s.o.) [...] 

<!doctype html>
<html lang="de">
<head>
<title> picture coil </title>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, user-scalable=no, minimum-scale=1.0, maximum-scale=1.0">
</head>
<body>
<script src="../js/three.min.87.js"></script>
<script src="../js/OrbitControls.js"></script>
<script src="../js/THREEx.WindowResize.js"></script>
<!-- https://github.com/hofk/THREEf.js/blob/master/THREEf_87/THREEf.js -->
<script src="../js/THREEf.js"></script>
<div id="threejs" style="position: absolute; left:0px; top:0px"></div>
</body>
<script>
var boards = [];
var texture = [];
var matTexture = [];
init();
animate();
//...........................
function init() {
scene = new THREE.Scene();
camera = new THREE.PerspectiveCamera( 75, window.innerWidth/ window.innerHeight,1, 100000 );
scene.add( camera );
camera.position.set( -200, 500, 12000 );
renderer = new THREE.WebGLRenderer( { antialias:true } );
renderer.setSize( window.innerWidth, window.innerHeight );
renderer.setClearColor( 0xeeeeee );
container = document.getElementById('threejs' );
container.appendChild( renderer.domElement );
THREEx.WindowResize( renderer, camera );
controls = new THREE.OrbitControls( camera, renderer.domElement );
texture[0] = new THREE.TextureLoader().load( "waterlily.png" );
texture[1] = new THREE.TextureLoader().load( "dahlia.jpg" );
texture[2] = new THREE.TextureLoader().load( "petunia.jpg" );
texture[3] = new THREE.TextureLoader().load( "frog.jpg" );
for (var z = 0; z < 4; z++) {
matTexture[z] = new THREE.MeshBasicMaterial( { map: texture[z], transparent:true, opacity:0.8, wireframe:falso} );
}
// coil generated with addon THREEf.js
var geometry = new THREE.Geometry();
geometry.createMorphGeometry = THREEf.createMorphGeometry;// insert the methode from THREEf.js
// apply the methode with some parámetros
geometry.createMorphGeometry({
radius: 200,
height: 600,
radiusSegments: 18,
heightSegments: 80,
withBottom: true,
withTop: true,
centerX: function ( v, t ) { volver 2 * Math.sin( 6 * Math.PI * v ) },
centerY: function ( v, t ) { volver v * ( v + 10 ) },
centerZ: function ( v, t ) { volver 2 * Math.cos( 6 * Math.PI * v ) }
});
var material = new THREE.MeshBasicMaterial( { color: 0x0099dd, transparent: true, opacity: 0.8, wireframe:falso } );
var mesh = new THREE.Mesh( geometry, material );
scene.add( mesh );
// board for some things
materialBoard = new THREE.MeshBasicMaterial({color:0xdd00dd, transparent:true, opacity:0.5, wireframe: falso });
boardGeo = new THREE.PlaneGeometry(500,500);
picGeo = new THREE.PlaneGeometry( 160, 160 );
idx = 0;
for (var i = 0; i < geometry.vertices.length; i++) {
if ( i % 32 === 0) {
board = new THREE.Mesh( boardGeo, materialBoard );// board for pictures etc.
pic1 = new THREE.Mesh( picGeo, matTexture[ idx % 4 ] );
pic2 = new THREE.Mesh( picGeo, matTexture[ ( idx % 4 ) % 2 ] );
board.add( pic1 );// add picture to the board
board.add( pic2 );
pic1.position.x = -70;// position on the board
pic1.position.y = 120;
pic1.position.z = 20;
pic2.position.x = 80;
pic2.position.y = -120;
pic2.position.z = 20;
boards.push( board );
scene.add( boards[ idx ] );
boards[ idx ].position.set( 1.4 * geometry.vertices[ i ].x , geometry.vertices[ i ].y + 300, 1.4 * geometry.vertices[ i ].z );
idx ++;
}
}
}
function animate() {
requestAnimationFrame( animate );
for( var n = 0; n < boards.length; n ++ ) {
boards[ n ].quaternion.copy( camera.quaternion );
}
renderer.render( scene, camera );
controls.update();
}
</script>
</html>
-----------------------------------------------------------------------------------------
En meiner Indexrechnerei ha mich una falso gesetzte Klammer aufgehalten. Constantemente darüber hinweg gelesen y largo no entdeckt. Das Ergebnis war sólo en cierto Konstellationen falso.

offensichtlich no korrekt 

nun klappt lo aber  |
| | | | |
| |  p.specht
 | | | | XProfan 11Computer: Gerät, daß es in Mikrosekunden erlaubt, 50.000 Fehler zu machen, zB 'daß' statt 'das'... | 08.11.2017 ▲ |
| |
| |  HofK | Posesiones soeben el "Buddelkasten" en el neuesten Stand gebracht. [...] In ihm puede ser ahora Gebilde de el three.js "Dreieckssuppe" non indexed BufferGeometry erzeugen.
Auf el Weg dahin war el uv Mapping una vez "eigen". Como kommt el Cuestión en "Bug oder Feature?"

Manche Fehler son simplemente así "schön", dass uno algo lo hacer kann.
Noch fehlt en non indexed el Berechnung el Normalen, en indexed se como momentan el three.js interne Función benutzt. Sie führt aber a unschönen Nähten y muss auch todavía ersetzt voluntad. Das son otra vez una ausgiebige Rechnerei como en THREEf. |
| | | | |
| |  Georg Teles | In Sachen Grafik bin Yo una Niete aber verfolge el hilo ya länger y el Beispiele dejar echt viel Spielerei übrig, como kann Yo auch sólo staunen genial ! |
| | | | |
| |  HofK | Georg Teles (11.11.2017)
In Sachen Grafik bin Yo una Niete ...
Mi Fähigkeiten en Grafik son auch más bescheiden, hier se sólo algo dreidimensionales Denken, algo Mathematik en Form de 3D Geometrie y una wenig dreidimensionales Rechnen (Vektorrechnung) benötigt. Und entonces el Datenfelder con el schönen Indexrechnereien.
Entscheidend Es el zugrunde liegende Biblioteca three.js, el el 3D Web-Grafik webGL sólo handhabbar macht.
___________________________________________________
El Berechnung el Normalen ging más rápido como angenommen, como Yo bastante simplemente de THREEf kopieren podría y sólo algunos Los cambios anstanden.
Auch el Nähte son ya fast weg. Im Bild erkennbar, dass al Äquator no Naht sichtbar es y a el Schnittstelle erster/letzter Keil sólo todavía en el Nordhalbkugel.

El Nahtglättung es todavía halbwegs überschaubar.
if (g.top > eqt) fehlt todavía. También una Prüfung en optimierbarkeit el Zeilen.
Fünf veces } al Ende son no gerade übersichtlich, como bieten se entonces abschließende Kommentare a. (Im Gesamtprogramm son lo hier entonces 7 Klammern!) Durch el Faltung des Codes en el Editor behält uno (meistens) aber todavía el Überblick. |
| | | | |
| |  HofK | Nachdem auch el letzte Naht geglättet war, fiel me una, dass Yo vorhatte en non indexed BufferGeometry una Explosionsdarstellung a probieren.
Und el funktioniert dank el vorhandenen Daten denkbar simplemente.
Desde que a Berechnung el Vertex-Normalen el Normalen el Dreiecke (faces) benötigte, estos en el Datenfeld g.faceNormals abgespeichert.
Addiert uno nun a cada Ecke (vertex - Ortsvektor) una Vielfaches dieser Dreiecks-Normalen, así treibt lo el Dreiecke de el Mitte her auseinander.


Como el Dreiecke de Boden, Deckel y Keil identische Normalen haben (parallel!) voluntad ellos gleichartig movido y bleiben así zusammen.
Se puede el nun auch en el Sandbox [...] ausprobieren. El Función explode wirkt natürlich sólo non indexed y nimmt lediglich el Zeitparameter t entgegen.
THREEp arbeitet nun con el neuesten Revision 88 de three.js zusammen. Für THREEf voluntad Yo explode nachrüsten. |
| | | | |
|
RespuestaTema opciones | 356.939 Views |
ThemeninformationenDieses Thema ha 10 subscriber: |