var camera, scene, renderer;
var geometry, material, mesh;
var dotMaterial;
var dotGeometry;
var points=[];
var objects=[];
var drag=false;
var selpointsids=[];
var pointseffect=[];
var oldPos;
var newPos;
var startX,startY,dragX,dragY;
var controls;
function init() {
camera = new THREE.PerspectiveCamera( 70, window.innerWidth / window.innerHeight, 0.01, 10 );
camera.position.z = 1;
scene = new THREE.Scene();
geometry = new THREE.PlaneBufferGeometry( 1, 1, 250, 250 );
dotMaterial = new THREE.PointsMaterial( { size: 1, sizeAttenuation: false } );
// modify geometry
dotGeometry = new THREE.Geometry();
var positionAttribute = geometry.attributes.position;
console.log( positionAttribute.count );
for ( var i = 0; i < positionAttribute.count; i ++ ) {
// access single vertex (x,y,z)
var x = positionAttribute.getX( i );
var y = positionAttribute.getY( i );
var z = positionAttribute.getZ( i );
// modify data (in this case just the z coordinate)
if(x>-0.3 && x<0.3 && y>-0.2 && y<0.3)
{
//z += Math.random() * 0.1;
}
// write data back to attribute
positionAttribute.setXYZ( i, x, y, z );
addPoint(x,y,z);
}
var dot = new THREE.Points( dotGeometry, dotMaterial );
scene.add(dot);
//points.push(dotGeometry);
//
//material = new THREE.MeshNormalMaterial();
mesh = new THREE.Mesh( geometry, material );
scene.add( mesh );
objects.push(mesh);
renderer = new THREE.WebGLRenderer( { antialias: true } );
renderer.setSize( window.innerWidth, window.innerHeight );
document.body.appendChild( renderer.domElement );
controls = new THREE.OrbitControls( camera, renderer.domElement );
controls.rotateSpeed=0;
}
function addPoint(x,y,z)
{
//console.log("point coord",x,y,z);
dotGeometry.vertices.push(new THREE.Vector3( x, y, z));
points.push(new THREE.Vector3( x, y, z));
}
function onKeyPress( event )...
Please Whitelist JSFiddle in your content blocker.
Help keep JSFiddle free for always by one of two ways:
Whitelist JSFiddle in your content blocker (two clicks)
Go PRO and get access to additional PRO features →
Join the 4+ million users, and keep the JSFiddle dream alive.
Ad-free
All ads in the editor and listing pages are turned completely off.
Use pre-released features
You get to try and use features (like the Palette Color Generator) months before everyone else.
Fiddle collections
Sort and categorize your Fiddles into multiple collections.
Private collections and fiddles
You can make as many Private Fiddles, and Private Collections as you wish!
Console
Debug your Fiddle with a minimal built-in JavaScript console.