<script src="https://rawgit.com/mrdoob/three.js/dev/build/three.js"></script>
<script src="https://rawgit.com/mrdoob/three.js/dev/examples/js/controls/OrbitControls.js"></script>
<!--
Line precision defines a distance when the raycaster should be intersecting the line base on distance even if the ray does not cross over the line.
-->
CSS
body {
margin:0;
}
JavaScript
;var objects = [];
var scene = new THREE.Scene();
var width = window.innerWidth;
var height = window.innerHeight * .75;
var camera = new THREE.PerspectiveCamera( 35, width/height, 0.1, 1000 );
camera.position.z += 60;
var renderer = new THREE.WebGLRenderer();
renderer.setSize( width, height );
renderer.setClearColor( 0xcccccc, 1 );
document.body.appendChild( renderer.domElement );
scene.add(camera);
// add mouse click for camera orbiting
controls = new THREE.OrbitControls(camera, renderer.domElement);
controls.screenSpacePanning = true;
setToFullOrbit(controls)
// modify camera
camera.position.copy(new THREE.Vector3(120, 120, 120) );
// fix first frame render issue going invisible
camera.lookAt(new THREE.Vector3(0,0,0));
// add grid for spacing visual
var grid = new THREE.GridHelper(144, 12);
grid.rotateX(THREE.Math.degToRad(90));
scene.add(grid);
/*
// add axis to scene for orientation visual
var axisHelper = new THREE.AxisHelper(12);
scene.add(axisHelper);
*/
// ------------ playground here
//vectorExample1(new THREE.Vector3(1,1,0));
//vectorDirectionExample(new THREE.Vector3(8,8,0).normalize());
//vectorDirectionExample(new THREE.Vector3(8,8,0).normalize());
//cubeExample();
//shapeGeometrySquareExample();
//shape 1
/*
var vec2s = [
new THREE.Vector2(),
new THREE.Vector2(0, 24),
new THREE.Vector2(48, 24),
new THREE.Vector2(24, 0)
];
var m = shapeGeometry(vec2s, 0x0000ff);
m.add(new THREE.AxesHelper(5));
//rotateFromCentroid(m, 45);
vec2s = [
new THREE.Vector2(24, 0),
new THREE.Vector2(48, 24),
new THREE.Vector2(84, -12),
new THREE.Vector2(60, -36)
];
var s = shapeGeometry(vec2s, 0xff0000);
s.add(new THREE.AxesHelper(5));
*/
//shape 2
var vec2s = [
new THREE.Vector2(),
new THREE.Vector2(0, 24),
new THREE.Vector2(48, 24),
new THREE.Vector2(48, 0)
];
var m = shapeGeometry(vec2s, 0x0000ff);
m.add(new THREE.AxesHelper(5));
//rotateFromCentroid(m, 45);
vec2s = [
new THREE.Vector2(),
new...
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.