Create 3D model of pile with points with Three.js










-2















Im developing an web-app that is supposed to create a 3d model of a gravel pile
from points measured with a laser instrument with three.js. The only problem is the
creating a hull that supposed to be the surface of the pile that includes all points. I already made a pointswarm model with the points and tried to make a hull around it with ConvexBufferGeometry but not all points get included in the hull when using ConvexBufferGeometry. Can someone please point me in the right direction?










share|improve this question






















  • Can you please demonstrate the issue with a live example. ConvexBufferGeometry uses a Quick Hull implementation in order to compute the convex hull for a given set of points. If this is not the case for your data, you have to provide more information so it's possible to investigate the issue.

    – Mugen87
    Nov 15 '18 at 15:31











  • I can post a sample tomorrow when i am back at work but the problem is just that convexGeometry uses quickhull and quickhull creates the smallest geometry that swallows all points but all points are part of the hull.

    – Pei-turn
    Nov 15 '18 at 17:29











  • Have a look at this forum thread. If it's what you're looking for, I can post it here as an answer.

    – prisoner849
    Nov 15 '18 at 20:27











  • @prisoner849 Thanks =D that was exactly what i was looking for. Post it as a answer and i will accept it.

    – Pei-turn
    Nov 16 '18 at 6:37











  • @Pei-turn You're welcome :)

    – prisoner849
    Nov 16 '18 at 7:19















-2















Im developing an web-app that is supposed to create a 3d model of a gravel pile
from points measured with a laser instrument with three.js. The only problem is the
creating a hull that supposed to be the surface of the pile that includes all points. I already made a pointswarm model with the points and tried to make a hull around it with ConvexBufferGeometry but not all points get included in the hull when using ConvexBufferGeometry. Can someone please point me in the right direction?










share|improve this question






















  • Can you please demonstrate the issue with a live example. ConvexBufferGeometry uses a Quick Hull implementation in order to compute the convex hull for a given set of points. If this is not the case for your data, you have to provide more information so it's possible to investigate the issue.

    – Mugen87
    Nov 15 '18 at 15:31











  • I can post a sample tomorrow when i am back at work but the problem is just that convexGeometry uses quickhull and quickhull creates the smallest geometry that swallows all points but all points are part of the hull.

    – Pei-turn
    Nov 15 '18 at 17:29











  • Have a look at this forum thread. If it's what you're looking for, I can post it here as an answer.

    – prisoner849
    Nov 15 '18 at 20:27











  • @prisoner849 Thanks =D that was exactly what i was looking for. Post it as a answer and i will accept it.

    – Pei-turn
    Nov 16 '18 at 6:37











  • @Pei-turn You're welcome :)

    – prisoner849
    Nov 16 '18 at 7:19













-2












-2








-2








Im developing an web-app that is supposed to create a 3d model of a gravel pile
from points measured with a laser instrument with three.js. The only problem is the
creating a hull that supposed to be the surface of the pile that includes all points. I already made a pointswarm model with the points and tried to make a hull around it with ConvexBufferGeometry but not all points get included in the hull when using ConvexBufferGeometry. Can someone please point me in the right direction?










share|improve this question














Im developing an web-app that is supposed to create a 3d model of a gravel pile
from points measured with a laser instrument with three.js. The only problem is the
creating a hull that supposed to be the surface of the pile that includes all points. I already made a pointswarm model with the points and tried to make a hull around it with ConvexBufferGeometry but not all points get included in the hull when using ConvexBufferGeometry. Can someone please point me in the right direction?







javascript three.js






share|improve this question













share|improve this question











share|improve this question




share|improve this question










asked Nov 15 '18 at 13:23









Pei-turnPei-turn

58




58












  • Can you please demonstrate the issue with a live example. ConvexBufferGeometry uses a Quick Hull implementation in order to compute the convex hull for a given set of points. If this is not the case for your data, you have to provide more information so it's possible to investigate the issue.

    – Mugen87
    Nov 15 '18 at 15:31











  • I can post a sample tomorrow when i am back at work but the problem is just that convexGeometry uses quickhull and quickhull creates the smallest geometry that swallows all points but all points are part of the hull.

    – Pei-turn
    Nov 15 '18 at 17:29











  • Have a look at this forum thread. If it's what you're looking for, I can post it here as an answer.

    – prisoner849
    Nov 15 '18 at 20:27











  • @prisoner849 Thanks =D that was exactly what i was looking for. Post it as a answer and i will accept it.

    – Pei-turn
    Nov 16 '18 at 6:37











  • @Pei-turn You're welcome :)

    – prisoner849
    Nov 16 '18 at 7:19

















  • Can you please demonstrate the issue with a live example. ConvexBufferGeometry uses a Quick Hull implementation in order to compute the convex hull for a given set of points. If this is not the case for your data, you have to provide more information so it's possible to investigate the issue.

    – Mugen87
    Nov 15 '18 at 15:31











  • I can post a sample tomorrow when i am back at work but the problem is just that convexGeometry uses quickhull and quickhull creates the smallest geometry that swallows all points but all points are part of the hull.

    – Pei-turn
    Nov 15 '18 at 17:29











  • Have a look at this forum thread. If it's what you're looking for, I can post it here as an answer.

    – prisoner849
    Nov 15 '18 at 20:27











  • @prisoner849 Thanks =D that was exactly what i was looking for. Post it as a answer and i will accept it.

    – Pei-turn
    Nov 16 '18 at 6:37











  • @Pei-turn You're welcome :)

    – prisoner849
    Nov 16 '18 at 7:19
















Can you please demonstrate the issue with a live example. ConvexBufferGeometry uses a Quick Hull implementation in order to compute the convex hull for a given set of points. If this is not the case for your data, you have to provide more information so it's possible to investigate the issue.

– Mugen87
Nov 15 '18 at 15:31





Can you please demonstrate the issue with a live example. ConvexBufferGeometry uses a Quick Hull implementation in order to compute the convex hull for a given set of points. If this is not the case for your data, you have to provide more information so it's possible to investigate the issue.

– Mugen87
Nov 15 '18 at 15:31













I can post a sample tomorrow when i am back at work but the problem is just that convexGeometry uses quickhull and quickhull creates the smallest geometry that swallows all points but all points are part of the hull.

– Pei-turn
Nov 15 '18 at 17:29





I can post a sample tomorrow when i am back at work but the problem is just that convexGeometry uses quickhull and quickhull creates the smallest geometry that swallows all points but all points are part of the hull.

– Pei-turn
Nov 15 '18 at 17:29













Have a look at this forum thread. If it's what you're looking for, I can post it here as an answer.

– prisoner849
Nov 15 '18 at 20:27





Have a look at this forum thread. If it's what you're looking for, I can post it here as an answer.

– prisoner849
Nov 15 '18 at 20:27













@prisoner849 Thanks =D that was exactly what i was looking for. Post it as a answer and i will accept it.

– Pei-turn
Nov 16 '18 at 6:37





@prisoner849 Thanks =D that was exactly what i was looking for. Post it as a answer and i will accept it.

– Pei-turn
Nov 16 '18 at 6:37













@Pei-turn You're welcome :)

– prisoner849
Nov 16 '18 at 7:19





@Pei-turn You're welcome :)

– prisoner849
Nov 16 '18 at 7:19












1 Answer
1






active

oldest

votes


















1














You can try to combine Three.js with Delaunator library for triangulation of your points to make a surface:






var scene = new THREE.Scene();
var camera = new THREE.PerspectiveCamera(60, 1, 1, 1000);
camera.position.setScalar(150);
var renderer = new THREE.WebGLRenderer(
antialias: true
);
var canvas = renderer.domElement;
document.body.appendChild(canvas);

var controls = new THREE.OrbitControls(camera, canvas);

var light = new THREE.DirectionalLight(0xffffff, 1.5);
light.position.setScalar(100);
scene.add(light);
scene.add(new THREE.AmbientLight(0xffffff, 0.5));

var size = x: 200, y: 200 ;
var pointsCount = 1000;
var points3d = ;
for (let i = 0; i < pointsCount; i++)
let x = THREE.Math.randFloatSpread(size.x);
let z = THREE.Math.randFloatSpread(size.y);
let y = noise.perlin2(x / size.x * 5, z / size.y * 5) * 50;
points3d.push(new THREE.Vector3(x, y, z));


var geom = new THREE.BufferGeometry().setFromPoints(points3d);
var cloud = new THREE.Points(
geom,
new THREE.PointsMaterial( color: 0x99ccff, size: 2 )
);
scene.add(cloud);

// triangulate by [x, z]
var indexDelaunay = Delaunator.from(
points3d.map(v =>
return [v.x, v.z];
)
);

var meshIndex = ; // delaunay index => three.js index
for (let i = 0; i < indexDelaunay.triangles.length; i++)
meshIndex.push(indexDelaunay.triangles[i]);


geom.setIndex(meshIndex); // add three.js index to the existing geometry
geom.computeVertexNormals();
var mesh = new THREE.Mesh(
geom, // re-use the existing geometry
new THREE.MeshLambertMaterial( color: "purple", wireframe: true )
);
scene.add(mesh);

var gui = new dat.GUI();
gui.add(mesh.material, "wireframe");

render();

function resize(renderer)

function render()
if (resize(renderer))
camera.aspect = canvas.clientWidth / canvas.clientHeight;
camera.updateProjectionMatrix();

renderer.render(scene, camera);
requestAnimationFrame(render);

html, body 
height: 100%;
margin: 0;
overflow: hidden;
font-family: Verdana;

canvas
width: 100%;
height: 100%;
display; block;


#info
position: absolute;
margin-left: 10px;


a
color: yellow;
text-decoration: none;

<script src="https://cdnjs.cloudflare.com/ajax/libs/three.js/98/three.min.js"></script>
<script src="https://threejs.org/examples/js/controls/OrbitControls.js"></script>

<!-- https://github.com/mapbox/delaunator -->
<script src="https://unpkg.com/delaunator@3.0.2/delaunator.js"></script>

<script src="https://josephg.github.io/noisejs/perlin.js"></script>

<script src="https://cdnjs.cloudflare.com/ajax/libs/dat-gui/0.7.3/dat.gui.min.js"></script>

<div id="info">
<a href="https://github.com/mapbox/delaunator" target="blank">Delaunator<br>(triangulation)</a>
</div>








share|improve this answer






















    Your Answer






    StackExchange.ifUsing("editor", function ()
    StackExchange.using("externalEditor", function ()
    StackExchange.using("snippets", function ()
    StackExchange.snippets.init();
    );
    );
    , "code-snippets");

    StackExchange.ready(function()
    var channelOptions =
    tags: "".split(" "),
    id: "1"
    ;
    initTagRenderer("".split(" "), "".split(" "), channelOptions);

    StackExchange.using("externalEditor", function()
    // Have to fire editor after snippets, if snippets enabled
    if (StackExchange.settings.snippets.snippetsEnabled)
    StackExchange.using("snippets", function()
    createEditor();
    );

    else
    createEditor();

    );

    function createEditor()
    StackExchange.prepareEditor(
    heartbeatType: 'answer',
    autoActivateHeartbeat: false,
    convertImagesToLinks: true,
    noModals: true,
    showLowRepImageUploadWarning: true,
    reputationToPostImages: 10,
    bindNavPrevention: true,
    postfix: "",
    imageUploader:
    brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
    contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
    allowUrls: true
    ,
    onDemand: true,
    discardSelector: ".discard-answer"
    ,immediatelyShowMarkdownHelp:true
    );



    );













    draft saved

    draft discarded


















    StackExchange.ready(
    function ()
    StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53320479%2fcreate-3d-model-of-pile-with-points-with-three-js%23new-answer', 'question_page');

    );

    Post as a guest















    Required, but never shown

























    1 Answer
    1






    active

    oldest

    votes








    1 Answer
    1






    active

    oldest

    votes









    active

    oldest

    votes






    active

    oldest

    votes









    1














    You can try to combine Three.js with Delaunator library for triangulation of your points to make a surface:






    var scene = new THREE.Scene();
    var camera = new THREE.PerspectiveCamera(60, 1, 1, 1000);
    camera.position.setScalar(150);
    var renderer = new THREE.WebGLRenderer(
    antialias: true
    );
    var canvas = renderer.domElement;
    document.body.appendChild(canvas);

    var controls = new THREE.OrbitControls(camera, canvas);

    var light = new THREE.DirectionalLight(0xffffff, 1.5);
    light.position.setScalar(100);
    scene.add(light);
    scene.add(new THREE.AmbientLight(0xffffff, 0.5));

    var size = x: 200, y: 200 ;
    var pointsCount = 1000;
    var points3d = ;
    for (let i = 0; i < pointsCount; i++)
    let x = THREE.Math.randFloatSpread(size.x);
    let z = THREE.Math.randFloatSpread(size.y);
    let y = noise.perlin2(x / size.x * 5, z / size.y * 5) * 50;
    points3d.push(new THREE.Vector3(x, y, z));


    var geom = new THREE.BufferGeometry().setFromPoints(points3d);
    var cloud = new THREE.Points(
    geom,
    new THREE.PointsMaterial( color: 0x99ccff, size: 2 )
    );
    scene.add(cloud);

    // triangulate by [x, z]
    var indexDelaunay = Delaunator.from(
    points3d.map(v =>
    return [v.x, v.z];
    )
    );

    var meshIndex = ; // delaunay index => three.js index
    for (let i = 0; i < indexDelaunay.triangles.length; i++)
    meshIndex.push(indexDelaunay.triangles[i]);


    geom.setIndex(meshIndex); // add three.js index to the existing geometry
    geom.computeVertexNormals();
    var mesh = new THREE.Mesh(
    geom, // re-use the existing geometry
    new THREE.MeshLambertMaterial( color: "purple", wireframe: true )
    );
    scene.add(mesh);

    var gui = new dat.GUI();
    gui.add(mesh.material, "wireframe");

    render();

    function resize(renderer)

    function render()
    if (resize(renderer))
    camera.aspect = canvas.clientWidth / canvas.clientHeight;
    camera.updateProjectionMatrix();

    renderer.render(scene, camera);
    requestAnimationFrame(render);

    html, body 
    height: 100%;
    margin: 0;
    overflow: hidden;
    font-family: Verdana;

    canvas
    width: 100%;
    height: 100%;
    display; block;


    #info
    position: absolute;
    margin-left: 10px;


    a
    color: yellow;
    text-decoration: none;

    <script src="https://cdnjs.cloudflare.com/ajax/libs/three.js/98/three.min.js"></script>
    <script src="https://threejs.org/examples/js/controls/OrbitControls.js"></script>

    <!-- https://github.com/mapbox/delaunator -->
    <script src="https://unpkg.com/delaunator@3.0.2/delaunator.js"></script>

    <script src="https://josephg.github.io/noisejs/perlin.js"></script>

    <script src="https://cdnjs.cloudflare.com/ajax/libs/dat-gui/0.7.3/dat.gui.min.js"></script>

    <div id="info">
    <a href="https://github.com/mapbox/delaunator" target="blank">Delaunator<br>(triangulation)</a>
    </div>








    share|improve this answer



























      1














      You can try to combine Three.js with Delaunator library for triangulation of your points to make a surface:






      var scene = new THREE.Scene();
      var camera = new THREE.PerspectiveCamera(60, 1, 1, 1000);
      camera.position.setScalar(150);
      var renderer = new THREE.WebGLRenderer(
      antialias: true
      );
      var canvas = renderer.domElement;
      document.body.appendChild(canvas);

      var controls = new THREE.OrbitControls(camera, canvas);

      var light = new THREE.DirectionalLight(0xffffff, 1.5);
      light.position.setScalar(100);
      scene.add(light);
      scene.add(new THREE.AmbientLight(0xffffff, 0.5));

      var size = x: 200, y: 200 ;
      var pointsCount = 1000;
      var points3d = ;
      for (let i = 0; i < pointsCount; i++)
      let x = THREE.Math.randFloatSpread(size.x);
      let z = THREE.Math.randFloatSpread(size.y);
      let y = noise.perlin2(x / size.x * 5, z / size.y * 5) * 50;
      points3d.push(new THREE.Vector3(x, y, z));


      var geom = new THREE.BufferGeometry().setFromPoints(points3d);
      var cloud = new THREE.Points(
      geom,
      new THREE.PointsMaterial( color: 0x99ccff, size: 2 )
      );
      scene.add(cloud);

      // triangulate by [x, z]
      var indexDelaunay = Delaunator.from(
      points3d.map(v =>
      return [v.x, v.z];
      )
      );

      var meshIndex = ; // delaunay index => three.js index
      for (let i = 0; i < indexDelaunay.triangles.length; i++)
      meshIndex.push(indexDelaunay.triangles[i]);


      geom.setIndex(meshIndex); // add three.js index to the existing geometry
      geom.computeVertexNormals();
      var mesh = new THREE.Mesh(
      geom, // re-use the existing geometry
      new THREE.MeshLambertMaterial( color: "purple", wireframe: true )
      );
      scene.add(mesh);

      var gui = new dat.GUI();
      gui.add(mesh.material, "wireframe");

      render();

      function resize(renderer)

      function render()
      if (resize(renderer))
      camera.aspect = canvas.clientWidth / canvas.clientHeight;
      camera.updateProjectionMatrix();

      renderer.render(scene, camera);
      requestAnimationFrame(render);

      html, body 
      height: 100%;
      margin: 0;
      overflow: hidden;
      font-family: Verdana;

      canvas
      width: 100%;
      height: 100%;
      display; block;


      #info
      position: absolute;
      margin-left: 10px;


      a
      color: yellow;
      text-decoration: none;

      <script src="https://cdnjs.cloudflare.com/ajax/libs/three.js/98/three.min.js"></script>
      <script src="https://threejs.org/examples/js/controls/OrbitControls.js"></script>

      <!-- https://github.com/mapbox/delaunator -->
      <script src="https://unpkg.com/delaunator@3.0.2/delaunator.js"></script>

      <script src="https://josephg.github.io/noisejs/perlin.js"></script>

      <script src="https://cdnjs.cloudflare.com/ajax/libs/dat-gui/0.7.3/dat.gui.min.js"></script>

      <div id="info">
      <a href="https://github.com/mapbox/delaunator" target="blank">Delaunator<br>(triangulation)</a>
      </div>








      share|improve this answer

























        1












        1








        1







        You can try to combine Three.js with Delaunator library for triangulation of your points to make a surface:






        var scene = new THREE.Scene();
        var camera = new THREE.PerspectiveCamera(60, 1, 1, 1000);
        camera.position.setScalar(150);
        var renderer = new THREE.WebGLRenderer(
        antialias: true
        );
        var canvas = renderer.domElement;
        document.body.appendChild(canvas);

        var controls = new THREE.OrbitControls(camera, canvas);

        var light = new THREE.DirectionalLight(0xffffff, 1.5);
        light.position.setScalar(100);
        scene.add(light);
        scene.add(new THREE.AmbientLight(0xffffff, 0.5));

        var size = x: 200, y: 200 ;
        var pointsCount = 1000;
        var points3d = ;
        for (let i = 0; i < pointsCount; i++)
        let x = THREE.Math.randFloatSpread(size.x);
        let z = THREE.Math.randFloatSpread(size.y);
        let y = noise.perlin2(x / size.x * 5, z / size.y * 5) * 50;
        points3d.push(new THREE.Vector3(x, y, z));


        var geom = new THREE.BufferGeometry().setFromPoints(points3d);
        var cloud = new THREE.Points(
        geom,
        new THREE.PointsMaterial( color: 0x99ccff, size: 2 )
        );
        scene.add(cloud);

        // triangulate by [x, z]
        var indexDelaunay = Delaunator.from(
        points3d.map(v =>
        return [v.x, v.z];
        )
        );

        var meshIndex = ; // delaunay index => three.js index
        for (let i = 0; i < indexDelaunay.triangles.length; i++)
        meshIndex.push(indexDelaunay.triangles[i]);


        geom.setIndex(meshIndex); // add three.js index to the existing geometry
        geom.computeVertexNormals();
        var mesh = new THREE.Mesh(
        geom, // re-use the existing geometry
        new THREE.MeshLambertMaterial( color: "purple", wireframe: true )
        );
        scene.add(mesh);

        var gui = new dat.GUI();
        gui.add(mesh.material, "wireframe");

        render();

        function resize(renderer)

        function render()
        if (resize(renderer))
        camera.aspect = canvas.clientWidth / canvas.clientHeight;
        camera.updateProjectionMatrix();

        renderer.render(scene, camera);
        requestAnimationFrame(render);

        html, body 
        height: 100%;
        margin: 0;
        overflow: hidden;
        font-family: Verdana;

        canvas
        width: 100%;
        height: 100%;
        display; block;


        #info
        position: absolute;
        margin-left: 10px;


        a
        color: yellow;
        text-decoration: none;

        <script src="https://cdnjs.cloudflare.com/ajax/libs/three.js/98/three.min.js"></script>
        <script src="https://threejs.org/examples/js/controls/OrbitControls.js"></script>

        <!-- https://github.com/mapbox/delaunator -->
        <script src="https://unpkg.com/delaunator@3.0.2/delaunator.js"></script>

        <script src="https://josephg.github.io/noisejs/perlin.js"></script>

        <script src="https://cdnjs.cloudflare.com/ajax/libs/dat-gui/0.7.3/dat.gui.min.js"></script>

        <div id="info">
        <a href="https://github.com/mapbox/delaunator" target="blank">Delaunator<br>(triangulation)</a>
        </div>








        share|improve this answer













        You can try to combine Three.js with Delaunator library for triangulation of your points to make a surface:






        var scene = new THREE.Scene();
        var camera = new THREE.PerspectiveCamera(60, 1, 1, 1000);
        camera.position.setScalar(150);
        var renderer = new THREE.WebGLRenderer(
        antialias: true
        );
        var canvas = renderer.domElement;
        document.body.appendChild(canvas);

        var controls = new THREE.OrbitControls(camera, canvas);

        var light = new THREE.DirectionalLight(0xffffff, 1.5);
        light.position.setScalar(100);
        scene.add(light);
        scene.add(new THREE.AmbientLight(0xffffff, 0.5));

        var size = x: 200, y: 200 ;
        var pointsCount = 1000;
        var points3d = ;
        for (let i = 0; i < pointsCount; i++)
        let x = THREE.Math.randFloatSpread(size.x);
        let z = THREE.Math.randFloatSpread(size.y);
        let y = noise.perlin2(x / size.x * 5, z / size.y * 5) * 50;
        points3d.push(new THREE.Vector3(x, y, z));


        var geom = new THREE.BufferGeometry().setFromPoints(points3d);
        var cloud = new THREE.Points(
        geom,
        new THREE.PointsMaterial( color: 0x99ccff, size: 2 )
        );
        scene.add(cloud);

        // triangulate by [x, z]
        var indexDelaunay = Delaunator.from(
        points3d.map(v =>
        return [v.x, v.z];
        )
        );

        var meshIndex = ; // delaunay index => three.js index
        for (let i = 0; i < indexDelaunay.triangles.length; i++)
        meshIndex.push(indexDelaunay.triangles[i]);


        geom.setIndex(meshIndex); // add three.js index to the existing geometry
        geom.computeVertexNormals();
        var mesh = new THREE.Mesh(
        geom, // re-use the existing geometry
        new THREE.MeshLambertMaterial( color: "purple", wireframe: true )
        );
        scene.add(mesh);

        var gui = new dat.GUI();
        gui.add(mesh.material, "wireframe");

        render();

        function resize(renderer)

        function render()
        if (resize(renderer))
        camera.aspect = canvas.clientWidth / canvas.clientHeight;
        camera.updateProjectionMatrix();

        renderer.render(scene, camera);
        requestAnimationFrame(render);

        html, body 
        height: 100%;
        margin: 0;
        overflow: hidden;
        font-family: Verdana;

        canvas
        width: 100%;
        height: 100%;
        display; block;


        #info
        position: absolute;
        margin-left: 10px;


        a
        color: yellow;
        text-decoration: none;

        <script src="https://cdnjs.cloudflare.com/ajax/libs/three.js/98/three.min.js"></script>
        <script src="https://threejs.org/examples/js/controls/OrbitControls.js"></script>

        <!-- https://github.com/mapbox/delaunator -->
        <script src="https://unpkg.com/delaunator@3.0.2/delaunator.js"></script>

        <script src="https://josephg.github.io/noisejs/perlin.js"></script>

        <script src="https://cdnjs.cloudflare.com/ajax/libs/dat-gui/0.7.3/dat.gui.min.js"></script>

        <div id="info">
        <a href="https://github.com/mapbox/delaunator" target="blank">Delaunator<br>(triangulation)</a>
        </div>








        var scene = new THREE.Scene();
        var camera = new THREE.PerspectiveCamera(60, 1, 1, 1000);
        camera.position.setScalar(150);
        var renderer = new THREE.WebGLRenderer(
        antialias: true
        );
        var canvas = renderer.domElement;
        document.body.appendChild(canvas);

        var controls = new THREE.OrbitControls(camera, canvas);

        var light = new THREE.DirectionalLight(0xffffff, 1.5);
        light.position.setScalar(100);
        scene.add(light);
        scene.add(new THREE.AmbientLight(0xffffff, 0.5));

        var size = x: 200, y: 200 ;
        var pointsCount = 1000;
        var points3d = ;
        for (let i = 0; i < pointsCount; i++)
        let x = THREE.Math.randFloatSpread(size.x);
        let z = THREE.Math.randFloatSpread(size.y);
        let y = noise.perlin2(x / size.x * 5, z / size.y * 5) * 50;
        points3d.push(new THREE.Vector3(x, y, z));


        var geom = new THREE.BufferGeometry().setFromPoints(points3d);
        var cloud = new THREE.Points(
        geom,
        new THREE.PointsMaterial( color: 0x99ccff, size: 2 )
        );
        scene.add(cloud);

        // triangulate by [x, z]
        var indexDelaunay = Delaunator.from(
        points3d.map(v =>
        return [v.x, v.z];
        )
        );

        var meshIndex = ; // delaunay index => three.js index
        for (let i = 0; i < indexDelaunay.triangles.length; i++)
        meshIndex.push(indexDelaunay.triangles[i]);


        geom.setIndex(meshIndex); // add three.js index to the existing geometry
        geom.computeVertexNormals();
        var mesh = new THREE.Mesh(
        geom, // re-use the existing geometry
        new THREE.MeshLambertMaterial( color: "purple", wireframe: true )
        );
        scene.add(mesh);

        var gui = new dat.GUI();
        gui.add(mesh.material, "wireframe");

        render();

        function resize(renderer)

        function render()
        if (resize(renderer))
        camera.aspect = canvas.clientWidth / canvas.clientHeight;
        camera.updateProjectionMatrix();

        renderer.render(scene, camera);
        requestAnimationFrame(render);

        html, body 
        height: 100%;
        margin: 0;
        overflow: hidden;
        font-family: Verdana;

        canvas
        width: 100%;
        height: 100%;
        display; block;


        #info
        position: absolute;
        margin-left: 10px;


        a
        color: yellow;
        text-decoration: none;

        <script src="https://cdnjs.cloudflare.com/ajax/libs/three.js/98/three.min.js"></script>
        <script src="https://threejs.org/examples/js/controls/OrbitControls.js"></script>

        <!-- https://github.com/mapbox/delaunator -->
        <script src="https://unpkg.com/delaunator@3.0.2/delaunator.js"></script>

        <script src="https://josephg.github.io/noisejs/perlin.js"></script>

        <script src="https://cdnjs.cloudflare.com/ajax/libs/dat-gui/0.7.3/dat.gui.min.js"></script>

        <div id="info">
        <a href="https://github.com/mapbox/delaunator" target="blank">Delaunator<br>(triangulation)</a>
        </div>





        var scene = new THREE.Scene();
        var camera = new THREE.PerspectiveCamera(60, 1, 1, 1000);
        camera.position.setScalar(150);
        var renderer = new THREE.WebGLRenderer(
        antialias: true
        );
        var canvas = renderer.domElement;
        document.body.appendChild(canvas);

        var controls = new THREE.OrbitControls(camera, canvas);

        var light = new THREE.DirectionalLight(0xffffff, 1.5);
        light.position.setScalar(100);
        scene.add(light);
        scene.add(new THREE.AmbientLight(0xffffff, 0.5));

        var size = x: 200, y: 200 ;
        var pointsCount = 1000;
        var points3d = ;
        for (let i = 0; i < pointsCount; i++)
        let x = THREE.Math.randFloatSpread(size.x);
        let z = THREE.Math.randFloatSpread(size.y);
        let y = noise.perlin2(x / size.x * 5, z / size.y * 5) * 50;
        points3d.push(new THREE.Vector3(x, y, z));


        var geom = new THREE.BufferGeometry().setFromPoints(points3d);
        var cloud = new THREE.Points(
        geom,
        new THREE.PointsMaterial( color: 0x99ccff, size: 2 )
        );
        scene.add(cloud);

        // triangulate by [x, z]
        var indexDelaunay = Delaunator.from(
        points3d.map(v =>
        return [v.x, v.z];
        )
        );

        var meshIndex = ; // delaunay index => three.js index
        for (let i = 0; i < indexDelaunay.triangles.length; i++)
        meshIndex.push(indexDelaunay.triangles[i]);


        geom.setIndex(meshIndex); // add three.js index to the existing geometry
        geom.computeVertexNormals();
        var mesh = new THREE.Mesh(
        geom, // re-use the existing geometry
        new THREE.MeshLambertMaterial( color: "purple", wireframe: true )
        );
        scene.add(mesh);

        var gui = new dat.GUI();
        gui.add(mesh.material, "wireframe");

        render();

        function resize(renderer)

        function render()
        if (resize(renderer))
        camera.aspect = canvas.clientWidth / canvas.clientHeight;
        camera.updateProjectionMatrix();

        renderer.render(scene, camera);
        requestAnimationFrame(render);

        html, body 
        height: 100%;
        margin: 0;
        overflow: hidden;
        font-family: Verdana;

        canvas
        width: 100%;
        height: 100%;
        display; block;


        #info
        position: absolute;
        margin-left: 10px;


        a
        color: yellow;
        text-decoration: none;

        <script src="https://cdnjs.cloudflare.com/ajax/libs/three.js/98/three.min.js"></script>
        <script src="https://threejs.org/examples/js/controls/OrbitControls.js"></script>

        <!-- https://github.com/mapbox/delaunator -->
        <script src="https://unpkg.com/delaunator@3.0.2/delaunator.js"></script>

        <script src="https://josephg.github.io/noisejs/perlin.js"></script>

        <script src="https://cdnjs.cloudflare.com/ajax/libs/dat-gui/0.7.3/dat.gui.min.js"></script>

        <div id="info">
        <a href="https://github.com/mapbox/delaunator" target="blank">Delaunator<br>(triangulation)</a>
        </div>






        share|improve this answer












        share|improve this answer



        share|improve this answer










        answered Nov 16 '18 at 7:14









        prisoner849prisoner849

        7,70821326




        7,70821326





























            draft saved

            draft discarded
















































            Thanks for contributing an answer to Stack Overflow!


            • Please be sure to answer the question. Provide details and share your research!

            But avoid


            • Asking for help, clarification, or responding to other answers.

            • Making statements based on opinion; back them up with references or personal experience.

            To learn more, see our tips on writing great answers.




            draft saved


            draft discarded














            StackExchange.ready(
            function ()
            StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53320479%2fcreate-3d-model-of-pile-with-points-with-three-js%23new-answer', 'question_page');

            );

            Post as a guest















            Required, but never shown





















































            Required, but never shown














            Required, but never shown












            Required, but never shown







            Required, but never shown

































            Required, but never shown














            Required, but never shown












            Required, but never shown







            Required, but never shown







            Popular posts from this blog

            Top Tejano songwriter Luis Silva dead of heart attack at 64

            政党

            天津地下鉄3号線