// a basic line in 3D space used for a sense of dimension. Can be updated in real time.
class Line{
constructor(start, end){
this.start = start;
this.end = end;
this.geometry = new THREE.BufferGeometry();
var vertices = new Float32Array([
start.x, start.y, start.z,
end.x, end.y, end.z,
]);
// itemSize = 3 because there are 3 values (components) per vertex
this.geometry.setAttribute( 'position', new THREE.BufferAttribute( vertices, 3 ) );
this.mesh = new THREE.Line(this.geometry, new THREE.LineBasicMaterial({color: 0xff0000}));
}
update(height){
var yVector = new THREE.Vector3(0,1,0);
yVector.setLength(height);
var newEnd = this.start.clone();
newEnd.add(yVector);
this.end.copy(newEnd);
this.geometry.verticesNeedUpdate = true;
}
}
// a proxy mesh/platform for selecting in 3D space. Will move up and down to mouse location on drag
class Level {
constructor(vec3s, isMultiArray = false){
if(isMultiArray){
var deserializedVec3s = [];
vec3s.forEach((vec3) => {
deserializedVec3s.push(new THREE.Vector3(vec3[0], vec3[1]));
});
vec3s = deserializedVec3s;
this.points = deserializedVec3s;
} else {
this.points = vec3s;
}
this.mesh = new THREE.Mesh(); // empty mesh
this.mesh.name = 'grabspot container';
// amount is the extrude settings
var vec2s = vec3sToVec2s(vec3s);
var extrudeSettings = {
amount: .5,
bevelEnabled: true,
bevelSegments: 1,
steps: 1,
bevelSize: 0,
bevelThickness: 1
};
var shape = new THREE.Shape(vec2s);
var shapeGeo = new THREE.ExtrudeGeometry(shape, extrudeSettings);
shapeGeo.applyMatrix(new THREE.Matrix4().makeRotationX(-Math.PI / 2)); // rotate 90
shapeGeo.applyMatrix(new THREE.Matrix4().makeTranslation(0, 1.5, 0)); // offset y half
var levelMat = new THREE.MeshStandardMaterial({color:0xffffff});
this.mesh2d =...
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.